I am tring to make an NPC look at the player

I want an npc to look at the player after the player gets close to it. Can someone please help?

looking at the player is a very vague statement
please specifically explain what you want, or even provide an example and link so it’s easier for us to help

If player X is > NPC X, look right.
If player X is < NPC X, look left

To see if the player is close enough you can either use a proximity or the distance equation (I would recommend using the distance equation)
Proximity is probably the easiest, but depending on how the game is set up it could also cause lag, but in most cases it should be fine. @Truce2023

So, honestly, i don’t think its that confusing.

I want an NPC to look at the player object when it is nearby. So, if i go to the right of it, it will turn right.But only if the player is in a a set distance.

you can just use raycasts left and right

Is it top down or is it a side scroller???

but if you jump, or are above, it might not work, depends on if you want the NPC to always face the direction,or only if its on the same level

1 Like

I would have an extractor constantly extract the x position of the player(A) ,
then an extractor on the NPC’s x position(B)
Put them as inputs to the expression block as A-B,
Then filters to check if the output is negative or positive, if its positive, its to the right (flip)
Negative=to the left(back)
I think this is good (: Make sure to calculate in the expression

1 Like

it is a Side scroller

You can use Extractor to detect the player’s movement and the Flip behavior to make the NPC look at the player

Can you add a example please?