Search Unity

Set the a childs local angle (my head is exploding!)

Discussion in 'Editor & General Support' started by Gibbonuk, Dec 22, 2016.

  1. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    175
    I cant understand whats going on and now my heads popped so ive come on here as know one of you guys will know the answer.

    To try and explain this ill go with this:

    A plane can fly through the air and be at any angle, it has flaps ETC. These Flaps ETC are child objects to the main plane object. In the editor I can position and angle them how i want. All good.

    Now i want that flap, elevator what ever to move up or down to a certain angle on one of its OWN axis?

    I feel I have tried every local, euler, inversetransform function available and non get me to what i want.
    The script I have to do the angle changing is attached to FLAP object.

    What i dont understand is, in the editor lets say my child object (elevator in this case) I set its rotation at 0,0,0 and i then in the EDITOR I rotate (locally) the X axis my using my mouse only the X values change such as 20,0,0 or -20,0,0 .. If i run the game, pause it and do that same again this is not the case... all values change.

    Hope you can help
    Thanks
     
  2. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,761
    I would add an empty gameobject between the wing and the flap, you can then use that objects local rotations as well as the flaps.
     
  3. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    175
    Hi SpookyCat, I should have said, that is what i am doing, I have the wing, then an empty game object with the flap inside. I am scripting on the empty game object, but its just not having it.

    Basically if in the editor if I set the flap so its 0,0,45 degrees in the editor, i want the flap to still move +/- n degrees on its long side but at 45 desgrees. Understand what I mean? so it would be 20,0,45 or -20,0,45?

    Thanks
    Andy
     
  4. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    175
    Ahh sorted it, I changed the script to be on the flap thats within the empty and figured it out.

    Thanks