Muhammad Faizan Khan
Muhammad Faizan Khan

Reputation: 10561

How to follow a car with correct rotation

I am making a game where car will follow a user car. I am moving use car using keyboard keys it is working fine running on my game environment roads smoothly. To follow enemy car i am using nevMesh, it correctly following but the following car/enemey car rotation is not correct. I am surprise that how do i control it? or is there any other way to acheive this thing

Upvotes: 0

Views: 67

Answers (1)

Nestoraj
Nestoraj

Reputation: 762

You can use "LookAt()" function to rotate your enemy cars.

public void LookTarget(){
    EnemyCarTransform.LookAt(UserCarTransform);
}

Make sure you use Transform property and call it everytime you move your enemy car.

Upvotes: 2

Related Questions