How To Make An NPC Move When You Look At It

Hello all,

I’ve searched but can’t find exactly what I’m looking for, let me be more specific. I have a hospital environment that has several turns/corners the player must walk around. I also have a man, that I want to walk around each corner before the player does. Let me clarify though.

If the turn is right, and the player is looking left, the man will not walk. Once the player sees the man, he will walk around the corner. Then when you turn the corner, he will just be walking around the next corner etc. This will happen several times. I will then just need him to walk straight after the final turn. - How do I accomplish this? - And yes, I have the model with the animations. I just don’t know how to apply it.

Thank you for your time.

P.S. I’m sorry if this is a double post. I typed this all up and then it asked me to log in and I didn’t see it posted :confused: So I’m hoping it only posted once.

I had an idea on using a Ray to determine when play visual looking at target. There is no such thing as Ray cone unfortunately. My next idea was having a trigger, if player is in trigger, PREPARE man to walk, but it needs one more condition, if player is in trigger AND visually looking towards this man, have the man perform the action. For this you can use Unity - Scripting API: Physics.SphereCast this might work, if the spherecast is towards the man object, then activate man to walk.

You could use the OnBecameVisible() function along with some occlusion culling.