How to make an object to follow the player when the object comes in range with the player. I tried using smooth follow but it didn’t work.
- Felipe
How to make an object to follow the player when the object comes in range with the player. I tried using smooth follow but it didn’t work.
I dont know what your code looks like but to do this you would have to calculate the distance from the player to the enemy.
Calculating the difference in an if statement and checking to see if it is close enough should work:
Variables i used in this example:
var enemy : Transform;
var startFollow = 5;
if(Vector3.Distance(enemy.position, transform.position) <= startFollow) {
// Your Code Here
}