Ywa Posted August 10, 2012 Share Posted August 10, 2012 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. Quote Link to comment Share on other sites More sharing options...
Canardia Posted August 10, 2012 Share Posted August 10, 2012 Something like this should work: SetBodyOmega(barrelmodel,CalcBodyOmega(barrelmodel,Vec3(0,GetEntityRotation(barrelmodel).Y,0)); Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Josh Posted August 10, 2012 Share Posted August 10, 2012 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. Quote 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 More sharing options...
Ywa Posted August 10, 2012 Author Share Posted August 10, 2012 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? Quote Link to comment Share on other sites More sharing options...
Josh Posted August 10, 2012 Share Posted August 10, 2012 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. Quote 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 More sharing options...
Ywa Posted August 10, 2012 Author Share Posted August 10, 2012 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.