Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Set Parent

Discussion in 'Project Tiny' started by Sladzio, Apr 3, 2019.

  1. Sladzio

    Sladzio

    Joined:
    Apr 15, 2014
    Posts:
    14
    Hey! When I change entity parent in the editor it maintains its world position. When using TransformNode.parent the object is parented but it's local position is equal to the one before parenting, which is causing weird results. Is there a way to parent an object and maintain it's current world position?
     
  2. Rupture13

    Rupture13

    Joined:
    Apr 12, 2016
    Posts:
    130
    You will have to manually calculate a new local position to apply after setting its new parent so the world position will be the same.
     
  3. Sladzio

    Sladzio

    Joined:
    Apr 15, 2014
    Posts:
    14
    I was trying to do that by using the functions from TransformService like
    localPositionFromWorldPosition, but it looks like they don't work. Do you have any other ideas on how to calculate this new localPosition?
     
    Rangerz132 likes this.