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

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

    Administrator

    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.