Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Does ICollisionEventsJob only works with PhysicsShape?

Discussion in 'Physics for ECS' started by Alex-Solovev, Dec 13, 2023.

  1. Alex-Solovev

    Alex-Solovev

    Joined:
    Feb 13, 2022
    Posts:
    25
    I'm new to ECS and I was trying to test basic collision detection based on the following piece of documentation https://docs.unity3d.com/Packages/com.unity.physics@1.0/manual/simulation-results.html
    It doesn't seem to be working, I'm not using PhysicsShape (as it is not part of Unity.Physics for some reason) my prefab only has Rigidbody, so I'm confused at this point. Can anyone just confirm that trigger/collision event only work with PhysicsBody from samples repository or is there anything I'm missing?
     
    borysovcorp likes this.
  2. Alex-Solovev

    Alex-Solovev

    Joined:
    Feb 13, 2022
    Posts:
    25
    Apparently, the answer to my question is – yes! It's far from straightforward (for me as someone who is just trying ECS) that when you install Unity.Physics package you also need to import sample files for any collision/trigger events to be working. Perhaps the documentation can be updated.
     
  3. C0d1ngJammer

    C0d1ngJammer

    Joined:
    Oct 15, 2018
    Posts:
    8
    Hello,
    Iam facing the same problem/issue and would use it if:
    Physic Shape and Physic Body is about to get deprecated as some forums-posts do say
    Using Physic Shape and Physic Body lead to incorrect collision detection (triggering way before collision actualy happens). So you still are going to use it as us mentioned?

    Just saw a Discord-Post:

    • Using ITriggerEventsJob with native Collider and Rigidbody works fine
    • Using ICollisionEventsJob with native Collider and Rigidbody does not fire events/execute the job
    • Switchign to the unity authoring samples Physics Shape and Physics Body, and setting Collide Raise Collision Events as the Collision response on Physics body will let ICollisionEventsJob work as expected

    This sucks :(
     
    Last edited: Dec 21, 2023
    borysovcorp likes this.
  4. Alex-Solovev

    Alex-Solovev

    Joined:
    Feb 13, 2022
    Posts:
    25
    Yeah, it would be an understatement to say that I was shocked when I realised that collision events only work with those custom physics components. I was working on a prototype and once I managed to make those events occur, I've moved onto other systems. So I haven't touched the physics since then, but I'm quite satisfied with what I get from ECS overall, hence I will be moving forward with it and will see how it goes :D
     
  5. C0d1ngJammer

    C0d1ngJammer

    Joined:
    Oct 15, 2018
    Posts:
    8
    Good to hear. Yet it seems like that collisionevents and triggerevents are raised too early when at least on of two entities colliding vertical. At least with version 1.2.0-pre.6. Just to be aware of, Iam going to raise an issue
     
  6. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    17
    I'm not even able to get the provided Collision events example running with 1.2.0-pre.6. I'm getting an error on the .Schedule line: It's saying it can't convert SimulationSingleton to JobHandle. I've submitted a bug report, but I'd love to get some kind of collision detection without relying on the deprecated Physics Body.
     
    C0d1ngJammer likes this.