Jump to content

Always keep body (cylinder) upright


Ywa
 Share

Recommended Posts

Hi there,

 

I'm trying to keep a body (cylinder in this case) upright while being able to set the velocity & change Y-rotation.

 

I tried to set the X & Z-axis to 0.0 every frame. This kinda worked, however, setting the velocity caused weird effects like sudden slowdowns.

Setting the center of mass real low (0.0 -50.0 0.0) didn't help anything.

 

The reason I want to keep it upright is to mimic controller functionality (control it as a player).

 

Who can help me with this?

 

Thanks in advance.

Link to comment
Share on other sites

There's a function to calculate the omega (angular velocity) needed to move a body to a specific rotation. Use this and multiply it by the mass to get the torque (angular force) you need.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I tried Metatron's suggestion. Didn't work.

 

Josh, this code doesn't work either (called every frame), either nothing or alot of Y-rotating happens. 50.0 is the mass.

SetBodyTorque(vBody.Entity,(CalcBodyOmega(vBody.Entity,Vec3D(0,fCameraAngleY,0))*50.0),1);

 

How did you solve this issue in your controller-class?

Link to comment
Share on other sites

The controller does not use the physics simulator. It has a simplified system to control things in an unrealistic way that is better for gameplay. The problem is adding torque to force something upright will always have unintended effects that are felt elsewhere, like when standing on ramps.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I remember you posted it's sourcecode (of that class, together with the vehicle-class). But I can't find them on the forums anymore.

Do you want to republish them? Could come in handy, even though I'm aware it doesn't use the simulator.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...