var respawn = Vector3 (0, 2, 0);
function OnCollisionEnter (collision:Collision){
while(UnityEngine.Collision.GameObject(“Player”));{
transform.Translate(respawn);
}
}
Using this code I get the error, MissingMethodException: UnityEngine.Collision.GameObject, could you please help me fix this error.
Instead of UnityEngine.Collision.GameObject, it should just be collision.gameObject. Also is Player the name of the gameObject? If so it should be this: collision.gameObject.name == “Player”
thanks but now its crashing unity
That means the while is causing an infinite loop. Make sure the condition can be met for it to stop.