Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved GameObject and entity collision event

Discussion in 'Physics for ECS' started by wcpwcp9, May 22, 2023.

  1. wcpwcp9

    wcpwcp9

    Joined:
    Jan 14, 2021
    Posts:
    8
    Is there a way to make gameobject and entity generate collision events?
    If not , Does it mean that if you want to develop games with Unity.Physics, all implementations must be based on Entity?
     
    AntonioModer likes this.
  2. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    277
    Once your game objects have been baked into Entities, you can only operate on the Entities level. Any UnityEngine collision event or trigger will not work.

    That said, have a look at the scene "2d1. Events - Triggers.unity" in the PhysicsSamples project for Unity Physics.
    This demo explains how to work with collision triggers in Unity Physics.
    For general information on how to use Unity Physics for queries, including collider queries, have a look at the corresponding section in the official documentation.

    Let me know if you have any additional question.
     
  3. wcpwcp9

    wcpwcp9

    Joined:
    Jan 14, 2021
    Posts:
    8
    Thank you.
    I also want to know that if I make a shooting game, the bullets use Entity, and if I want to calculate the bullet hitting the character, can the character only be made of Entity? Is there a way for the character to keep use GameObject?
     
    Vectrex likes this.
  4. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    277
    Do you need the GameObject also at runtime? If not, with the baking workflow, the GameObject that you set up during authoring will simply be turned into an Entity and then you can do all your game logic in systems efficiently and in a nicely modular manner.

    That said, you can still use standard game objects - built-in physics for example - side by side with Unity Physics and Entities in general. You just need to keep the game objects you don't want to be baked into Entities outside of the subscenes. These game objects will then simply be stepped as before, alongside the systems for Entities.
    Then you can write some glue to communicate between your "entity representations" and your "game object representations" to do whatever you want.