Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Torque around global axis.

Discussion in 'Physics' started by LastDude, Feb 5, 2018.

  1. LastDude

    LastDude

    Joined:
    Aug 5, 2015
    Posts:
    15
    Hi.

    I'am trying to rotate a object with AddTorque, but I want to rotate it around the global axis. The Y axis must be rotated around global and the X axis must be rotated around local.



    I don't want to rotate it without physics because it becomes choppy (yes, I'm making all rotations on the FixedUpdate).
     
  2. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    Do you need physics? MoveRotation would be simpler than addtorque
     
  3. Raistlin2015

    Raistlin2015

    Joined:
    Apr 4, 2015
    Posts:
    27
    RigidBody.AddRelativeTorque(Vector3.Up * rotationSpeed); // Adds torque relative to the RigidBody's local axis, in this case positive Y.

    RigidBody.AddTorque(Vector3.Up * rotationSpeed); // Adds torque to the RigidBody on the World axis, in this case the world positive Y.
     
  4. LastDude

    LastDude

    Joined:
    Aug 5, 2015
    Posts:
    15
    Any kind of rotation makes the movement really jerky(inside and outside of the FixedUpdate).

    This only works if there is no rotation on any axis. With the 45 degrees on the X axis that is used on the gif above it just rotates randomly.
     
  5. Raistlin2015

    Raistlin2015

    Joined:
    Apr 4, 2015
    Posts:
    27
    You're right. That's strange. Try creating an empty as a parent to the radio. Add the Rigid Body and script to the empty. Restrict rotation to Y on the empty's RigidBody and see if that works.....