- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
Alp-Giray-Savrum · Feb 06, 2014 at 03:26 PM ·
cameraloopshake
Loop a script ?
Hello Devs, I'm confused at a script.
var originPosition:Vector3;
var originRotation:Quaternion;
var shake_decay: float;
var shake_intensity: float;;
function Start () {
Shake();
yield WaitForSeconds(2);
}
function Update(){
if(shake_intensity > 0){
transform.position = originPosition + Random.insideUnitSphere * shake_intensity;
transform.rotation = Quaternion(
originRotation.x + Random.Range(-shake_intensity,shake_intensity)*.2,
originRotation.y + Random.Range(-shake_intensity,shake_intensity)*.2,
originRotation.z + Random.Range(-shake_intensity,shake_intensity)*.2,
originRotation.w + Random.Range(-shake_intensity,shake_intensity)*.2);
shake_intensity -= shake_decay;
}
}
function Shake(){
originPosition = transform.position;
originRotation = transform.rotation;
shake_intensity = 0.1;
shake_decay = 0.002;
yield WaitForSeconds(2);
Loop();
}
function Loop(){
originPosition = transform.position;
originRotation = transform.rotation;
shake_intensity = 0.1;
shake_decay = 0.002;
yield WaitForSeconds(2);
Shake();
}
This is my shake script. Actually i want to make it work when i enable it but some reason, when i enable it in editor, then disable it and enable it again, it isn't works :S So i decided to create a loop method. Or can i do something else ?
in this code debug gives;
Definition of 'Shake.Loop()' depends on 'Shake.Shake()' whose type could not be resolved because of a cycle. Explicitly declare the type of either one to break the cycle.
that error.
Comment
Your answer
Follow this Question
Related Questions
2.5D SideScroller - Camera shaking on the Y Axis 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Camera shake loop in main menu? 1 Answer
FPS Camera moving by my left mouse button 1 Answer
Script Issue 2 Answers