Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Inertia and momentum

Author
Message
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 11th Jul 2003 14:42
Hello!

I'm trying to write a top down racing game, however, my cars stick to the track like a train on rails. I want to make them skid round corners but I'm not sure how to go about it - any ideas?

Thank you
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 11th Jul 2003 15:51
Just like Supercars for the Amiga, eh?

I thought about this a while ago. I think the answer is that if the player tries to turn the car too sharply when driving over a certain speed, even though the direction the car points changes, it continues to travel in the previous direction of motion.

On a theoretical level, how about something like the following:


Hope that is helpful. I'd be interested to see your game when it is finished.

Phil

What do you mean, bears aren't supposed to wear hats and a tie?
adr
21
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 11th Jul 2003 17:20 Edited at: 11th Jul 2003 17:32
Spooky, but I've just been discussing this with one of my work colleagues, a friend over IRC as well as the author of Victory Road.

We've tried to simplying the physics as much as possible but I'm still confused. If you imagine that the y-angle of the car is totally independant of the x and z velocity, then you can get your skidding effect.



There - skidding...

Next step - if you make it so that when you hit left your car turns left perpetually you're making progress; With that in place, you can dampen or resist your rate of turn variably. Turning, turning, turning, *bang* no resistance = skidding....

Here's where I get stuck. Translating your velocity vector so that it reflects your y-angle. If you make your velocity vector point in the same direction as your y-angle though, you've lost your skidding effect.

/me is stuck

PS Supercars ruled. I can still remember the much saught after white car you won towards the end...

----------------------------------------------------

edit:

I suppose, as a super hacky hack, you could curvevalue your velocity toward your y-angle. That way, you'd skid, but eventually retain control. You could still apply the resisting rate of turn idea for more drastic skids, but you could also change the rate of curvevaluing to suit speed for example....

Thoughts?

Bender:Blackmail’s such an ugly word. I prefer extortion. The x makes it sound cool.
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 11th Jul 2003 17:49
http://home.wxs.nl/~monstrous/tutcar.html

And there's an article of all things car physics, it's an extremely long read but well worth it.

"Computers are useless they can only give you answers."
adr
21
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 11th Jul 2003 18:02
I tried to read that tutorial once before but I just got totally lost. I could understand the part about acceleration in a straight line, but once it started talking about turning forces/slip angles/rotational velocity, I couldn't understand it.



That's why I started on my great quest to fake the physics. Downloading the Masker Coder's version didn't help either - a bit untidy for my liking

Bender:Blackmail’s such an ugly word. I prefer extortion. The x makes it sound cool.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 11th Jul 2003 19:04
Thanks for all the input, I'll see what I can do.

Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 11th Jul 2003 19:05
P.S. Wasn't the amiga top down racer called 'Super Skidmarks' by Acid Software I seem to remember?

Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 11th Jul 2003 20:14
Yes. There was that too. But Supercars by Magnetic Fields was better.

www.magneticfields.co.uk

Phil

What do you mean, bears aren't supposed to wear hats and a tie?
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 14th Jul 2003 10:03
I have come up with any idea that sort of works - there's a better solution out there but if anyone's interested:

object 1 is your car
object 2 is a hidden plain of width 1, height 1

All then movement calulations are based on object 2(hidden)
All the rotation calculations are on your object 1 (car)
do

if leftkey()=1 or joystick left()=1 then dec carangle#,turnangle#
if rightkey()=1 or joystick right()=1 then inc carangle#,turnangle#
if spacekey()=1 or joystick fire c()=1 and speed#<maxspeed# then inc speed#,acceleration#
if returnkey()=1 or joystick fire d()=1 and speed#>0 then dec speed#,brake#
if spacekey()=0 and returnkey()=0 and joystick fire c()=0 and joystick fire d()=0 and speed#>0 then dec speed#,deceleration#


if carangle# > skidangle# then inc skidangle#,grip#
if carangle# < skidangle# then dec skidangle#,grip#
yrotate object 1,wrapvalue(carangle#)
yrotate object 2,wrapvalue(skidangle#)

if speed#>0 then move object 2,-speed#
position object 1,object position x(2),0,object position z(2)

position camera object position x(1),cameraheight,object position z(1)-cameraposition
point camera object position x(1),0,object position z(1)

sync
loop

I've tried it - it works. But it's not pretty coding and the effect isn't quite what I had in mind.
I'm still open to suggestion

Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 14th Jul 2003 10:04
P.S. how do you enter a code snippet in a reply? I thought I just had done in the above thread but obviously not.

Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 14th Jul 2003 10:08
OK no sarcastic comments please - I've just worked it out! It would be that window below the one I'm typing in labeled 'CODE' - I'll get my glasses

Login to post a reply

Server time is: 2024-11-24 23:10:56
Your offset time is: 2024-11-24 23:10:56