I have problem with looping.
When Player catch “Meat” then Camera Shake for 5 sec.
I have problem only with 5 sec Shaking.
My script is bad and stupid.
Please help.
var Shake=false;
function Update()
{
...
Shake(); // still shake function?
}
function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag == "Meat")
{
Shake=true; //Activate Shake function
Destroy(hit.gameObject);
meat += 10;
PlayerPrefs.SetInt("meat", meat);
GameObject.Find("GUI_meat").guiText.text = "MEAT: "+meat;
}
}
function Shake()
{
if (Shake==true) // still check?
{
if (Time.time < Time.time + 5.0)
{
camera.main.transform.position += Random.insideUnitSphere * .1;
//HOW TO MAKE DO IT FOR 5 SEC
yield WaitForSeconds (0.1);
}
else
{
Shake=false;
}
}
}