How to Rotate Rigidbody?

Software: Away3D 4.x

Arno, Newbie
Posted: 13 September 2012 08:30 AM   Total Posts: 25

Any suggestion how to force a rotate on a rigidbody?

I tried different approaches.

1) rigidBody.rotateY += 0.1;

works but after a 90 degrees it gets weird two frames are blending through eachother. One with the model rotated 90.1 and one with the model rotated 0.1. And if ik rotate it faster than 0.1 degree per frame the models start to fall through the ground

2) rigidBody.transform.appendRotation(10, Vector3D.Y_AXIS);

Doesn’t do anything

if you look on the bullet physics forum there is a setCentralForceRotation() but i can’t find it in Away3d Physics (for example: http://stackoverflow.com/questions/8196634/how-to-apply-rotation-to-a-body-in-bullet-physics-engine)


[edit]

angularVelocity also does something. Rotates correct if i add 1 every frame but if I rotate it wit 0.1 nothing happens.

I’m still in search for a trustable way to rotate a rigidBody

   

John Brookes, Moderator
Posted: 13 September 2012 09:52 AM   Total Posts: 732   [ # 1 ]

If you wnat to set the transform, clone it first.

var mtx:Matrix3D = body.transform.clone();
mtx.prependRotation(30, Vector3D.Y_AXIS);
body.transform = mtx;

if its a rigidbody and you want a “rotation force” (torque)
body.applyTorque(new Vector3D(0, 50, 0));
or
body.applyTorqueImpulse(new Vector3D(0, 1, 0));

or set its angular velocity
body.angularVelocity = new Vector3D(0, 2, 0);

Rigidbodies will fall asleep if the rotation/translation falls below a certain value.
Turn on debugging. If the mesh is green its asleep.

 

   

Arno, Newbie
Posted: 13 September 2012 01:12 PM   Total Posts: 25   [ # 2 ]

Thanks they are all working but one bad point about the rotation in general is that it makes bodies dance around on the ground. On low rotation (0.1) you see the body staying the same for rotation for a few seconds and than taking a big jump.

Also if you let something rotating on position 0,0,0 the body slides left and right.

I have to see if this is workable for me

 

   

John Brookes, Moderator
Posted: 13 September 2012 01:34 PM   Total Posts: 732   [ # 3 ]

what are you rotating? As in, what are you trying to simulate?

Also any code example of the issue?

 

   

Arno, Newbie
Posted: 14 September 2012 06:35 AM   Total Posts: 25   [ # 4 ]

This is one example of the. When i don’t rotate it the box is normal on the ground. When it rotates it is through the ground

rotationY += 0.001;
var mtx:Matrix3D = _rigidBody.transform.clone();
mtx.prependRotation(rotationY, Vector3D.Y_AXIS);
_rigidBody.transform = mtx;

What i want is to create some sort of AI. So control the x and z for a body and there rotation so the box is alway facing forward if they move a certain way

 

File Attachments
PhysicsTest.swf  (File Size: 1112KB - Downloads: 362)
   

John Brookes, Moderator
Posted: 14 September 2012 12:59 PM   Total Posts: 732   [ # 5 ]

You can use the transform to set its position/rotation.

But you wouldnt generally use it in an enterframe. Other forces will also act on a rigidbody.
Im guessing you have a realy high gravity or friction.

Use forces or the linear/angular velocity to contantly move a rigidbody.


Like I said if you find small increments dont work then its probably falling asleep.
But it could also be that friction and or gravity is stopping it moving and also making things jump.

 

   

Arno, Newbie
Posted: 14 September 2012 01:52 PM   Total Posts: 25   [ # 6 ]

i have this to let the body not go to sleep: _rigidBody.activate(true)

the gravity is: private var _gravity:Vector3D =  new Vector3D(0, -100, 0);

if i give the cube friction 0.1 and mass 0.05 (_rigidBody.gravity = Vector3D(0,-5,0); the result is still the same.

I also tried to get the angularVelocity and add my angularVelocity but also with no result.

Any idea how to do it another way?

 

   

skywind, Newbie
Posted: 08 October 2012 07:49 PM   Total Posts: 1   [ # 7 ]

i have exactly same problem with dancing rotation, solution was to rotate in this way: body.rotation = new Vector3D(0,y,0);  but not body.rotationY. Good luck)

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X