I am trying to smoothly control the roll of a physics entity that is part of a group.
I would like to smoothly roll the entity with the cursor keys to a max of ~30
degrees, and then have it smoothly "self center" its roll when no cursor key is
pressed.
For the entity to self center its roll when no cursor key is pressed, I try to
adjust the amount of roll torque to correct with like this;
Code:
roll_offset = abs(my.roll)*300;//force lessens as we get closer to 0 roll
if(my.roll > 1)
{
phent_addtorquelocal(my, vector(-roll_offset,0,0));
}
if(my.roll < -1)
{
phent_addtorquelocal(my, vector(roll_offset,0,0));
}
I use a similar method to roll the entity with the cursor keys, adding torque
if the roll is less than the target roll.
This method dosent work smoothly at all. The entity "wobbles" as it overshoots
center when it self centers its roll, and it "stutters" when a cursor key is
pressed and it reaches a roll limit to either side. Plus it rolls way too
quickly.
I have also tried to disable physics each frame, adjust the entitys roll,
then enable physics again, but the other parts of the group go flying off!
Perhaps this cannot be done with a physics entity?
Does anyone have any suggestions?
Thanks!