I've been making a game and recently I lost a lot of work so have been rebuilding. However for some reason the enemy cubes now goes straight through the map to get to me, rather than navigating it. This is the script I have
var rotation = Quaternion.LookRotation(Target.position - transform.position);
Distance = Vector3.Distance(Target.position, transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * Damping);
transform.position += transform.forward * Speed * Time.deltaTime;
The Map has a Mesh Collider and the Cube has a Box Collider. I tried adding a RigidBody to the cube but had no luck. Any help would be appreciated.
↧