"Directional" One Shots?

Hello everyone, first off, I hope this is the right section. I am new to the forums.
Basically I am creating a horror game, with jump scares obviously.
Here is an example of this script for a jump scare I have.

```csharp
**using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OneShotMannequin : MonoBehaviour
{
[SerializeField] private Animator Mannequin1;
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag(“Player”))
{
Mannequin1.SetBool(“Appear”, true);
}
}
}**
```

So basically, a player walks through a Trigger (box collider) and an animation plays. In this case, the player walks down into a basement, triggers the animation of the mannequin appearing. However, the mannequin is behind the player, so when they player turns around to go back up the stairs, the mannequin will be there.

Is there a way to make sort of a directional one shot jump scare? So if there is a trigger, when the player walks through it nothing happens, but if they turn around and walk through it the other way, it will trigger the jump scare or whatever. Hope this makes sense. Thanks

You can make two trigger areas:

A - at the bottom of the basement stairs

B - further into the basement area

When the player trips A you check a boolean (BeenFarEnoughInsideYet) and if it is not yet fired, you do nothing.

When the player trips B you SET the boolean above to true.

When the player goes back through A this time the scare jumps out.

Keep in mind if you let the player back up out of there he might do that, going “nope nope nope nope” and be walking backwards, which might make the spawn happen behind him anyway.

In that case you can check the player’s transform.forward vector and perhaps even use that as a location where to spawn the mannequin, so the thing pops into place in front of him even if he backs up nervously.

Thank you, I will try this.