Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

How do I enable raisesCollision from script?

Discussion in 'DOTS Physics' started by gmarchioro, Mar 8, 2020.

  1. gmarchioro

    gmarchioro

    Joined:
    Jan 12, 2020
    Posts:
    8
    I am instantiating entiy coverted from gameobjects.
    The physics works but OnCollision event is not raised. This can be raised if I add a PhysicShape script and I enable it under Advanced section.
    Since I want to keep GameObject and be able to switch from "standard" to ECS esily, I am wondering how can I enable raisesCollision from script. What data should I set?
    Thanks
     
  2. Adam-Mechtley

    Adam-Mechtley

    Unity Technologies

    Joined:
    Feb 5, 2007
    Posts:
    290
    This gets converted into the material properties on the `PhysicsCollider` component. I would recommend you convert two copies of your collider, one with events enabled and one without, and then at run-time you can swap the value of the `PhysicsCollider` component between the two states as needed.