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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How do I enable raisesCollision from script?

Discussion in 'Physics for ECS' 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.