How to detect if a player is being chased by an npc/player

How would you detect when something or someone is chasing a player, without just checking the distance between the two (since a chaser could be chasing another player, and the new player is just near).

I’m trying to make a tutorial, where the new player should avoid the chaser, so, how would you do that?

1 Like

I mean if you’re not using distance.. you might have to use an attribute or something like that

1 Like

please elaborate more, like why you cant just add a object value somewhere that directs towards the current player it’s chasing.

I can do that if it’s an NPC, but if it’s a player, I can’t. Players are unpredictable.

it will be really hard to accurately be checking if a player is chasing a player, but you could make a radius around each player and npc, and if they touch each other it will assume it is chasing them, then when they leave the radius it stops thinking that.

you could make a circle around each player and npc then when they touch make a sort of indicator, then when the stop touching it goes away.

1 Like

I will check and get back to you if that works. What I’m thinking is of something like Forsaken’s detection for when you’re getting chased, and it plays the chase theme, instead of the layered terror radius.

Check the direction player A (killer) is moving, the position of player B (survivor), as well as the direction player B is moving in.

If they’re both moving in the same-ish direction and within a certain radius of eachother, it’s safe to assume that player B is getting chased by player A. If player B isn’t already in “chase mode”, another thing you could add is a FOV check, to make sure that the killer is actually intending to be in a chase and not just happening to be walking by and in the same direction.

To factor for turns in a path, you make a chase “ending” start a 10-second timer, if player B starts getting chased by player A again in that time, the chase is still ongoing. If not, the chase has ended. If you also wanted to, you could make it so if a player is already in a chase, then going the general-opposite direction of the killer would count as the chase continuing to avoid the chase “ending” when the killer and survivor may be running in literal circles. Alternatively you compare the move directions of the survivor in the past x seconds compared to the current move direction of the killer and bla bla bla its complicated.

I unfortunately can only help with concepting here though, Vector math isn’t really my strong suit.