Hi all, I have a simple script here which moves and rotates the player based on a random range. The problem I am having is that I can’t get the line I marked to work with Time.deltaTime. This is the error I am getting: Operator ‘*’ cannot be used with a left hand side of type ‘UnityEngine.Quaternion’ and a right hand side of type ‘float’.
Shake.js
var x : float;
var y : float;
var z : float;
var xRot : float;
var yRot : float;
var zRot : float;
var xCont : float;
var yCont : float;
var zCont : float;
var xContMax : float;
var yContMax : float;
var zContMax : float;
var xRotCont : float;
var yRotCont : float;
var zRotCont : float;
var xRotContMax : float;
var yRotContMax : float;
var zRotContMax : float;
function PlayCameraShake() {
if(this.GetComponent("EnemyDamageReciever1").hitPoints <= 0) {
this.GetComponent("EnemyAII").active = false;
this.rigidbody.useGravity = true;
//this.GetComponent("iTweenEvent").Play();
}
}
function Update() {
x = Random.RandomRange (xCont, xContMax);
y = Random.RandomRange (yCont, yContMax);
z = Random.RandomRange (zCont, zContMax);
xRot = Random.RandomRange (xRotCont, xRotContMax);
yRot = Random.RandomRange (yRotCont, yRotContMax);
zRot = Random.RandomRange (zRotCont, zRotContMax);
this.rigidbody.velocity = new Vector3 (x, y, z) * Time.deltaTime;
this.rigidbody.rotation = new Quaternion.Euler (xRot, yRot, zRot) * Time.deltaTime; <<<Error Here
}
I checked the docs and searched here for awhile but couldn’t find a solution. Can someone give me an idea how to make this work? Thank you!