Forum Discussion

godb.74120's avatar
godb.74120
Honored Guest
9 days ago
Solved

Help with collision event triggering multiple times.

I am working on a game in horizon world where players throw rocks to hit NPCs (from unity asset bundles). I am encountering an issue with collision detection where a single rock hit is triggering multiple events.

Here's the setup:

  • NPC has a trigger zone 
  • Player throw rocks at the NPC 
  • NPC should register a hit when a rock enters the trigger  and die after 2 hits
  • When NPC dies, it should trigger a single  event to move a bridge to the scene

Current behavior:

  • Using CodeBlockEntityTrigger to detect rock collisions
  • When a rock hits the NPC'c trigger zone, the hit event fires multiple times
  • After 2 hits, the bridge move event gets triggered twice

What I've tried

  1. Using state flags to prevent multiple hit from firing
  2. Tracking hit processing state with boolean flags
  3. Using a set to track rocks that have already hit an NPC

Would really appreciate it if you could provide suggestions on how to fix this issue. Thank you

  • You may have to share some related code. Physical Collision is known to fire multiple times due to geometry of the objects, but typically triggers only fire once when entered. I suspect something is not behaving as expected in our scripts, or the world is just misbehaving, but shutting it down and returning should resolve that issue.

1 Reply

  • You may have to share some related code. Physical Collision is known to fire multiple times due to geometry of the objects, but typically triggers only fire once when entered. I suspect something is not behaving as expected in our scripts, or the world is just misbehaving, but shutting it down and returning should resolve that issue.