Hi ¨
I have crane and ROV attached to it.
I can move the crane horizontally by left and right arrow keys and vertically by up and down arrow keys.
but when I suddenly relase the keys, the ROV should get swing effect o it for few seconds due to sudden stop.
I tried with the script but it woks only for a second and rotation stops.
What loop can I used instead of this?
Please help.
var frequencyMin : float = 1;
var frequencyMax : float = 2;
var magnitude : float = 0;
var timer : float =5.0;
private var randomInterval : float;
function Start () {
randomInterval = Random.Range(frequencyMin, frequencyMax);
}
function Update() {
if (Input.GetKeyDown (\"left\"))
{
print(\"dwn\");
}
/*transform.Rotate(Vector3.right * Time.deltaTime*5, Space.World);
transform.Rotate(Vector3.left, Time.deltaTime*5, Space.World);
// ... at the same time as spinning relative to the global
// Y axis at the same speed.
transform.Rotate(Vector3.up * Time.deltaTime*5, Space.World);*/
if ((Input.GetKeyUp (\"left\"))){
this.transform.position.y += (Mathf.Cos(Time.time * randomInterval) * magnitude);
this.transform.eulerAngles.x+= (Mathf.Cos(Time.time * randomInterval) * 0.05);
this.transform.eulerAngles.y+= (Mathf.Cos(Time.time * randomInterval) * 0.01);
this.transform.eulerAngles.z+= (Mathf.Cos(Time.time * randomInterval) * 0.03);
print(\"up\");
}
}
[/code]