Search Unity

Question Rigidbody Ignore root object rotation

Discussion in 'Physics' started by gofotron, Dec 5, 2023.

  1. gofotron

    gofotron

    Joined:
    Sep 13, 2020
    Posts:
    1
    Good evening ;) Please help me!
    How to make the Rigidbody object take rotation from the parent Rigidbody object when parent use AddTorque?
    My problem is: child Rigidbody object rotate itself to global coordinats and allways look in one direction

    How to make it like this, but with working Rigidbody?
    I want the rotation of the ridgedbody parent to be transferred to the child and for this child I could also use AddTorgue

    Code (CSharp):
    1. void Update()
    2.     {
    3.         if (Input.GetKeyDown(KeyCode.A))
    4.         {
    5.             rb[0].AddRelativeTorque(new Vector3(1, 0, 0));
    6.         }
    7.     }
    8.     public Rigidbody[] rb;
    Thanks :)
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,435
    A dynamic Rigidbody should only be in the root of an object, and all the parts of the object are (ideally) rigid, that is, they don't change positions or rotations relative to that root.

    If you need moving assemblies of parts, like robot arms or forklifts or doors, then you should be working with Joints. Each separate part is at its own root with its own Rigidbody, but are associated (a.k.a. attached) with each other using various kinds of Joint components.