Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question Multiple events trigger per collision

Discussion in 'Physics for ECS' started by kizko, Jun 11, 2023.

  1. kizko

    kizko

    Joined:
    May 28, 2020
    Posts:
    14
    Hi.

    I am currently using the sample provided by Unity: CollisionEventImpulseSystem (link: https://github.com/Unity-Technologi...Events/Scripts/CollisionEventImpulseSystem.cs)

    Problem: for each collision, I want to set a bool to true. I will have another system which is subtracting health each time the bool is set to true. For some reason, I do get multiple collisions detected per... collision.



    This will end up killing the entity with 1 collision. How can I limit the number of collisions? Or is there something that I'm missing?

    Code:


    Components on the car:

    PS: I'm moving this through code to follow the car's position.

    Components on the "enemy":


    Thank you for your help! If I missed something for you to have the whole context, let me know.