Daniel
Daniel

Reputation: 85

addtorque pivot point with box collider

My gameobject is a rectangle. It has a rigidbody, and a boxcollider. The anchor point is toward the left end of the gameobject. Using this code while the game is running causes the gameobject to turn around the z axis on the anchor point. when i set istrigger false, the object begins spinning around the center of itself. why does this happen? Is there a way to make the gameobject to spin around its anchor point while the istrigger bool of the box collider is false?

After some playing around, i have figured out that it i rotating on the center of the boxcollider. I need to figure out how to change the center of the box collider now without affecting the shape

     private void FixedUpdate()
    {
        rigidbody.AddTorque(Vector3.back);
    }

Upvotes: 0

Views: 613

Answers (1)

Daniel
Daniel

Reputation: 85

rigidbody.centerOfMass = gameobject.transform.position;

Upvotes: 1

Related Questions