function Update() {
if (!moving && !park)
{
if (!turnAround)
{
///move staight on if no arrays
transform.Translate(Vector3.forward * Time.deltaTime* speed);
}
else
{
var targetRotation = Quaternion.Euler(Vector3.Reflect(transform.position, Vector3.forward));
transform.rotation = Quaternion.Slerp( transform.rotation, targetRotation, Time.deltaTime * turnSpeed );
if (transform.rotation.y == -1)
{
turnAround = false;
}
}
}
}
Here is my code i am having problems turning the transform around a 180 degress then making turnAround = false to stop the rotate. It will be like when you hit a ball onto a wall at different angles the truck will turn then follow the forward motion the same.
Thanks