NPC animation when player is near

Hey all,

What is the best technique to decide if an entity should move or not? here is the scenario…

My character runs around a city, there are cars and NPCs that move around the city as well. If the character is not in range, or the NPC is not viewable there is no reason for it to do whatever animation is associated with it. If my character moves within eye shot of the NPC, I want it to start playing. What is the best technique to figure this out?

If that does not make since, please let me know.

Thank you,
Ross

Hi @Ross_Lehr!

You can easily check the distance between the character and NPC.

https://developer.playcanvas.com/api/pc.Vec3.html#distance

The topic below can be useful.

1 Like