Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Help Wanted parenting physics triggers

Discussion in 'DOTS Physics' started by Niond, Jul 29, 2021.

  1. Niond

    Niond

    Joined:
    Jul 28, 2021
    Posts:
    1
    I've been working on a project where we want to create an object that has a small trigger around it's model and a second larger trigger to determine if something gets close.
    In the mono world i would have set up the scene hierarchy like this:

    -parent (small trigger / movement logic)
    -- child (large trigger)

    This causes the child to move with the parent.

    "Converting" this approach to ECS authorings led me to this:

    -parent (PhysicsShape "Raise Trigger Events" / PhysicsBody "Kinematic" / MyMovementComponent)
    -- child (PhysicsShape / Kinematic PhysicsBody)

    But as the PhysicsBody authorings states: the child "gets un-parented during the conversion process so it can take part in the physics simulation". This seems to be reasonable for a "Dynamic" and "Static" PhysicsBody but for a "Kinematic" Body I'd like to keep the parenting.

    I didn't find a built in option to re-enable the parenting.
    The first simple solution that came to my mind was to write a new system which syncs the positions. All that would be needed is a new component that references the other entity. The only issue i have with this approach is that it makes it more complicated for a designer. We want to provide prefabs to the designers which can be nested in arbitrary ways with (almost) no need to manually add authorings. Forcing them to remember this "trigger sync authoring" is error prone.

    Is there a better way to achieve this than syncing the positions with a new system? Is there something in the documentation I've missed?
     
  2. Arnold_2013

    Arnold_2013

    Joined:
    Nov 24, 2013
    Posts:
    14
    Just like you propose. I use a 'FollowSystem' to place the child entity with physics at the location & rotation of the parent. (my child objects are always at the same location as their parent)

    Normal children (without physics) will be placed at the right location. So having a 'physics child' follow a 'normal child' could work if you need some offset rotation scale stuff to go right. I dont know if you can make this designer friendly.

    Edit: Physics child Translation set to normal childs LocalToWorld.Position i guess
     
unityunity