Search Unity

How to not make a child object affected by parent object's angular velocity?

Discussion in 'Getting Started' started by CyberInteractiveLLC, Sep 23, 2017.

  1. CyberInteractiveLLC

    CyberInteractiveLLC

    Joined:
    May 23, 2017
    Posts:
    307
    Ok so iv'e got 2 objects, 1 is the Asteroid and other is a child glow following it, now the asteroid i have can rotate around via script, i'm trying to make the child glow not rotate with it, but just simply follow, i have tried adding the same rotator script that the parent asteroid has to the child glow and make it's value 0 but it's still rotating! , here's a pic of what exactly i need:


    and what i don't want is if the parent asteroid rotates while going down, for the child to rotate like this with it:



    i've also tried playing with the glow inspector setting but so far no luck
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    It sounds like you have the glow object actually set as a child of the asteroid in the scene hierarchy. Don't do that. Make it an entirely separate object, with a script that makes it move to the appropriate position relative to the thing it's following in LateUpdate.

    Alternatively, I guess you could keep it a child of the asteroid, but then you'll need a script that resets its global rotation every frame with something like

    Code (csharp):
    1. void LateUpdate() {
    2.    transform.rotation = Quaternion.identity;
    3. }
    HTH,
    - Joe
     
    Kiwasi and Ryiah like this.
  3. CyberInteractiveLLC

    CyberInteractiveLLC

    Joined:
    May 23, 2017
    Posts:
    307
    to make a script that moves to positions relative to parent object seems way above my skill to make

    i'll try the other way, thanks
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Code (CSharp):
    1. public Transform objectToFollow;
    2. public Vector3 offset;
    3.  
    4. void Update () {
    5.     transform.position = objectToFollow.position + offset;
    6. }
     
  5. CyberInteractiveLLC

    CyberInteractiveLLC

    Joined:
    May 23, 2017
    Posts:
    307
    oh wow, ok i will try.. what value do i replace the offset with ?
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Just assign it in the inspector via trial and error.
     
    CyberInteractiveLLC likes this.
  7. ivananic779

    ivananic779

    Joined:
    Sep 26, 2017
    Posts:
    1
  8. unity_Rc9DW_OtN0_ozg

    unity_Rc9DW_OtN0_ozg

    Joined:
    Jan 6, 2021
    Posts:
    1