Question by
DejanBabic · Aug 10, 2017 at 04:41 PM ·
directionexplain
Can someone explain why direction can't be changed like this?
using UnityEngine; using System.Collections;
public class Done_Mover : MonoBehaviour { public float speed; private Rigidbody rb;
void Start()
{
rb = GetComponent <Rigidbody> ();
rb.velocity = transform.forward * speed;
}
void ChangeDirection ()
{
rb.velocity = transform.forward * -speed;
}
void Update()
{
if (transform.position.z == 7.0f)
{
Debug.Log ("position reached");
ChangeDirection();
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612132424im_/https://answers.unity.com/themes/thub/images/avi.jpg)