i gave a rigidbody a velocity at void start(), and i want it to stop once it reaches a certain point in the screen.
tryed doing rb.velocity = Vector3.zero and such, but couldnt find any thing thet worked even after searching the forum.
void Start()
{
changedSpeed = false;
rb = GetComponent<Rigidbody> ();
if (this.tag == "Boss") {
rb.velocity = transform.forward * speed;
///////
} else {
rb.velocity = transform.forward * speed;
}
}
void FixedUpdate ()
{
if (this.tag == "Boss") {
rb = GetComponent<Rigidbody> ();
if ((rb.position.z <= 13.5) && (changedSpeed == false)) {
string messege = string.Format("position z = {0}, speed = {1}", rb.position.z, rb.velocity.ToString());
Debug.Log (messege);
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
rb.angularDrag = 0;
messege = string.Format("position z = {0}, speed = {1}", rb.position.z, rb.velocity.ToString());
Debug.Log (messege);
changedSpeed = true;
}
}
}