I have placed dozens of enemies also continuously determining the player’s position. My game is too slow right now. I want to make sleep enemies such that no execution to be done by them. I have tried to make them sleep but no use. Any suggestions
IEnumerator sleep_local(float distance){
yield return new WaitForSeconds(distance/50.0f);
}
void Update(){
float s_time,e_time;
rig_enemy.isKinematic =true;
s_time = Time.realtimeSinceStartup;
Debug.Log("Starting to sleep");
StartCoroutine(sleep_local(250.0f));
e_time = Time.realtimeSinceStartup - s_time;
Debug.Log("Ending sleep :"+e_time.ToString());
rig_enemy.isKinematic =false;
}