Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
0 registered members (), 1,012 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Smoothly Controlling The Roll Of A Physics Entity? #70915
04/14/06 19:45
04/14/06 19:45
Joined: Jun 2005
Posts: 656
G
Grafton Offline OP
User
Grafton  Offline OP
User
G

Joined: Jun 2005
Posts: 656
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!


Not two, not one.
Re: Smoothly Controlling The Roll Of A Physics Entity? [Re: Grafton] #70916
04/16/06 01:44
04/16/06 01:44
Joined: Sep 2005
Posts: 274
Switzerland - Zurich
zwecklos Offline
Member
zwecklos  Offline
Member

Joined: Sep 2005
Posts: 274
Switzerland - Zurich
Maybe I understood you the right way, then this might help you

roll_offset = abs(my.roll) * smoothness;

smoothness is a variable that will inrease/decrease its value per frame.
you could make a little counter which handle the variable smoothness for your purpose.

I think the problem is that you are using a static value:
roll_offset = abs(my.roll) * 300;

You should calculate roll_offset with a changing value to get a smooth moving/rotating. Increase its increasing to get a slow rotation into a fast and decrease it to get a fast rotation to a slow rotation.

I hope this helps

cheers

Zwecklos

Re: Smoothly Controlling The Roll Of A Physics Entity? [Re: zwecklos] #70917
04/16/06 14:19
04/16/06 14:19
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline
Expert
A.Russell  Offline
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
Yes, apply a small torque over time vs a large one all at one. Also, adding friction and/or a reverse torque will help it to slow down when a key isn't pressed.

Re: Smoothly Controlling The Roll Of A Physics Entity? [Re: A.Russell] #70918
04/16/06 20:15
04/16/06 20:15
Joined: Jun 2005
Posts: 656
G
Grafton Offline OP
User
Grafton  Offline OP
User
G

Joined: Jun 2005
Posts: 656
Thanks for the replies! I appreciate your ideas.

The entity is a motorcycle type vehicle. To get it to "lean into turns" (roll),
it must fight varing centrifugal forces which are greater or less depending on
the current speed, turn angle and the current roll of the vehicle (which
affects the center of gravity).

If I could nullify the forces that affect the roll of the vehicle, then I could
more easiler control the roll. However I have no idea how much roll torque the
physics engine is applying on the vehicle at any given time.

So far the only solution I have working is to add a huge roll torque force to
overcome the unknown (but smaller) roll force added by physics engine thereby
forcing it to roll like I want. Of course this is very ugly and an unrealistic
behavior.

Maybe I am overcomplicating this, and there is an easy solution? I am new with
the physics engine. Has anyone ever tried a motorcycle type of vehicle before?

Thanks Again!


Not two, not one.
Re: Smoothly Controlling The Roll Of A Physics Entity? [Re: Grafton] #70919
04/17/06 00:50
04/17/06 00:50
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline
Expert
A.Russell  Offline
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
Calculating the roll when countersteering a motorcycle in a turn is very complicated, and probably best avoided. I think it would be easier to model the motorcyle as a single physics object and use an animation for cornering. you could have the wheels as separate models and rotate them with distance covered.

Re: Smoothly Controlling The Roll Of A Physics Entity? [Re: A.Russell] #70920
04/18/06 22:15
04/18/06 22:15
Joined: Jun 2005
Posts: 656
G
Grafton Offline OP
User
Grafton  Offline OP
User
G

Joined: Jun 2005
Posts: 656
Thats an ingenious idea! And after some experimenting, it seems that it would
probably a little too limiting for my purpose.

I think I will pursue a solution without the physics engine.

Thanks for the help!


Not two, not one.

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1