I am new to unity..I am facing a problem with a moved object. I assign the gameObject a velocity but when it reaches a specific position ( 23,14, -750), the gameobject freezes. I can't know why. Sometimes it object continues moving and other times it suddenly stops. What's going wrong ? Thank you
{
if (transform.localPosition.z <= -760) {
gameObject.SetActive (false);
}
gameObject.rigidbody.velocity = new Vector3 (0, 0, -speed);
}
If you set an object to inactive, it will "freeze":
if (transform.localPosition.z <= -760) {
gameObject.SetActive (false);
}
Not sure what you expect SetActive(false) to do but it has the result of stopping all logic including position updates and collision for the particular game object.