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

Child wrong position when Parent rotating

Discussion in 'Scripting' started by CrymX, Nov 26, 2015.

  1. CrymX

    CrymX

    Joined:
    Feb 16, 2015
    Posts:
    179
    Hello there, i have a weird bug with my player.

    My character is animated, i have a script on the spin, so my character can rotate.

    I have on the child of this spin, a gun, added in the prefab. The gun rotate perfectly with his parent.
    On the gun, i add a child at runtime for some particule on the "canon". The transform.position of the particule (debugged) is always the same as the canon (that is what i want).

    But, when my particule play, the position of the particule is always the position where the particules is added for the first time.

    So, i added my particule without parent (in the root of my scene) and put a script on it who update the position and the rotation on update.
    With it the particles play at the right place but, they have no parent.

    Why when i add it as a child at runtime the position is not updated when the parent rotate ?
    (if the parent move, like my character is walking, the child move too, but never take in condition the parent rotation)
     
  2. CrymX

    CrymX

    Joined:
    Feb 16, 2015
    Posts:
    179
    Is that possible it's because i rotate a spin who is animated at the same time ? (i rotate the spin in the lateUpdate)
     
  3. CrymX

    CrymX

    Joined:
    Feb 16, 2015
    Posts:
    179
    Anyone have the same issue ? Or something similar ?