I have script for my camera which is inside camera object. However I don`t want it to work immediatelly — but only when I click another object (player)?
How do I make it “sleep” until then?
Control the camera by Enabling/Disabling camera script from player or set a switch in camera script which can be controlled from player.
Camera Script
//Switch to enable and disable camera updation
public bool CamEnabled=false;
void LateUpdate()
{
if(CamEnabled)
{
//Perform all camera computations here (move all codes to here)
}
}
PlayerScript
//This will be your cusotm function which u have to make call as u desire
void OnPlayerClick()
{
//This is how you access your camera public variable
//Enable the public variable in camera script which controls camera updation
GameObject.Find("CameraObjectName").GetComponent<CameraScript>().CamEnabled=true;
}