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

How to move a part of a rigidbody

Discussion in 'Physics' started by LightRay2, Jun 13, 2015.

  1. LightRay2

    LightRay2

    Joined:
    Jun 6, 2015
    Posts:
    3
    Hello!

    I have a rigidbody consisting of 4 child 3D shapes (rigidbody component attached to their parent). Now I want to rotate one of the children by keyboard (but whole figure should continue to react to collisions with surrounding objects as a single rigidbody). How can I accomplish this?

    Thanks in advance!
     
  2. Simo

    Simo

    Joined:
    Sep 16, 2012
    Posts:
    85
    Hi,

    try localRotation, something like

    if(Keypressed)
    child.localRotation = desiredRotation;
     
  3. LightRay2

    LightRay2

    Joined:
    Jun 6, 2015
    Posts:
    3
    Thanks, it works! The only problem is after changing localRotation whole rigidbody starts shaking :( (like pendulum) I want it to transform without any forces applied!
     
  4. Simo

    Simo

    Joined:
    Sep 16, 2012
    Posts:
    85
    you need to change your hierarchy
    Rigidbody
    |
    -------Child (just a Transform)
    |
    ------- 3D shapes (localPosition should be 0,0,0)