Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question How to rotate parent based on own rotation(explained better in discription)

Discussion in 'Scripting' started by hover552, Sep 7, 2023.

  1. hover552

    hover552

    Joined:
    Feb 27, 2022
    Posts:
    36
    The attached file shows the Hierarchy.
    So what I want to happen is to rotate the Poco object based on the Control Sphere's rotation.
    So the more to the right the Control Sphere rotates the faster the Poco object rotates to the right,
    And the same with the other directions. How would I code this?
    It's VR but that shouldn't matter.(I think)
     

    Attached Files:

  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    8,417
    You will need to compare either rotation or some direction of the sphere to a reference empty game object, and use this value to apply a rotation to the parent object. I'd probably use
    Vector3.SignedAngle
    so you get both positive and negative values depending on the rotation.
     
  3. hover552

    hover552

    Joined:
    Feb 27, 2022
    Posts:
    36
    How would I implement this?
     
  4. hover552

    hover552

    Joined:
    Feb 27, 2022
    Posts:
    36
    Just found the solution. I added the control sphere transform.right to the ships transform.right with a dampining.