I am trying to make a car drive towards a player and ram him. I've looked at the asset store and can't find anything. My current script has the car making strange turns and circling the ball. Any help would be much appreciated Code (CSharp): void Update (){ lookAt(); chase (); //keeps car on floor transform.rotation = Quaternion.Euler(lockPos, transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z); if (transform.position.y < 0) { transform.position = new Vector3 (transform.position.x, 0, transform.position.z); } if (transform.position.y > 0) { transform.position = new Vector3 (transform.position.x, 0, transform.position.z); } } // Turn to face the player. void lookAt (){ // Rotate to look at player. Quaternion rotation= Quaternion.LookRotation(Target.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime); } void chase (){ transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime); }
@planetxo's suggestion is a good one. Or if you want it slightly more natural, adjust the speed smoothly based on the angle between the car's heading and the direction of the player. (You can use Vector3.Angle to find out what this angle is.)