|
-
Sep 13th, 2004, 09:30 AM
#1
Thread Starter
Frenzied Member
2D Car Physics
Does anyone have any good links with info on how to achieve realistic car physícs in a 2D world? In school we've currently only gone as far as, v=at and all the other stuff not involving friction(s=½at²). From this I can make it move forward and backwards sort of realistically... But it still doesn't involve friction... I see this as a good opportunity to get ahead in school as well, so please give me all you got =).
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Sep 13th, 2004, 10:14 AM
#2
Not NoteMe
Do you actually want realistic car physics, or realistic looking physics.
If it doesn't need to be perfect it'll be a lot easier.
For example for friction (assuming you're using a vector to represent speed/direction) you could just multiply it by a number less than 1 each frame.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Sep 13th, 2004, 10:15 AM
#3
Thread Starter
Frenzied Member
I found this:
http://home.planet.nl/~monstrous/tutcar.html
But if you guys have anything else, feel free to post it as well, since this is 'a bit' to precise(airresistance really isn't a neccesity)
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Sep 13th, 2004, 10:39 AM
#4
Thread Starter
Frenzied Member
Originally posted by SLH
Do you actually want realistic car physics, or realistic looking physics.
If it doesn't need to be perfect it'll be a lot easier.
For example for friction (assuming you're using a vector to represent speed/direction) you could just multiply it by a number less than 1 each frame.
Look =)... Well, my problem really is to simulate turning... and sliding, I really don't know where to start on that... When does it start sliding on that kind of ground(say asphalt) at a certain angle and velocity...
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Sep 13th, 2004, 11:38 AM
#5
Not NoteMe
To get good physics it's not gonna be easy, but what i'd do is have a location and velocity of the back of the car, and one for the front.
Do this for the front and the back.
You have the actual velocity of the front, and the desired velocity (dictated by the speed of the wheels (back), and the direction they're facing(front)). To get the desired velocity for the front simply assume the wheels are moving the same speed as the car is moving i.e. desired velocity for the front and actual velocity for the front have the same magnitude.
Perform ActualVelocity-DesiredVelocity (and store it in a vector called 'Slide'. If the magnitude of this vector is past a particular value then the wheels (front or back) will slide. The amount they slide could be a proportion of the 'slide' vector.
Now you have the desired velocity and the slide velocity for the front and back of the car. Now we need to do friction for each wheel to stop the car going super speed when in a straight line.
The vector for this would simply be a proportion of the difference between the actual velocity and the desired velocity. HOWEVER it's a vector in the oposite direction of the motion of the wheels (it's the magnatude that's proportional).
Doing it this way will take into account breaking, provided you calculate your desired velocity as 0 if breaking.
Now simply add the desired velocity, the slide velocity and the friction velocity for the front and back wheels.
Finally to prevent the car 'stretching' get a vector from the front wheels to the back wheels, then make the back wheels' position = the frontwheels position plus a vector the length of the car, in the direction of the vector you just made.
Last edited by SLH; Sep 13th, 2004 at 11:42 AM.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Sep 13th, 2004, 11:40 AM
#6
Not NoteMe
Note, this doesn't model the physics in any way realistically, it should look nice though. 
If you want to add realism start doing things like using the friction formula to calculate just how big the 'slide' vector should be etc...
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Sep 13th, 2004, 11:58 AM
#7
Thread Starter
Frenzied Member
Okay... This may sound silly... But i've always seen a vector as a line in an X,Y system(what's it called in english?) but that doesn't seem to be the right definition of it - could you tell me in short what it actually is?
And thank you many times for the info already given, It's a great help =).
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Sep 13th, 2004, 12:03 PM
#8
Not NoteMe
A vector is made up of two or more 1D dimensions.
When working in 2 dimensions (as you are) there are X and Y components.
A vector can be used to represent either a position relative to the origin:
Vector.X = 5
Vector.Y = 9
Vector now represents (5,9)
Or it can be used to represent a direction with magnitude.
Vector.X = 3
Vector.Y = 4
Vector now represents a (particular) direction with magnitude 5.
I think of a vector as an arrow (since it has a direction).
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Sep 13th, 2004, 12:12 PM
#9
Thread Starter
Frenzied Member
Hmm, so I would create a vector as a type with the fields X and Y ? Making it an arrow pointing to it? And why would the magnitude be 5? Is that a number relevant to the X Y coordinates you gave, or simply something you just said? Sorry for me being so bad at this =/
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Sep 13th, 2004, 12:26 PM
#10
Not NoteMe
-
Sep 13th, 2004, 12:29 PM
#11
Thread Starter
Frenzied Member
hmm, Okay then - I get what a vector is now =) - thanks....
I'm gonna try putting something together from what you said, but I might have some more questions.
Thanks a lot for the great help so far....
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Sep 13th, 2004, 02:19 PM
#12
PowerPoster
How is the direction of a vector defined.
I'll use a 3D vector
Vector.X = 10
Vector.Y = 10
Vector.Z = 10
Now how do I know which direction i am moving...generally I would believe given the angle this would be forward.
Vector.X = -10
Vector.Y = -10
Vector.Z = -10
Now given the angle, this would be backwards?
If so, then a vector only has 2 directions given an angle...forward and backwards.
Em I wrong?
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Sep 13th, 2004, 02:29 PM
#13
Not NoteMe
The direction of a vector is totally dependant on your coordinate system.
Not sure what you mean by 'given the angle'? What angle do you mean?? A vector doesn't store an angle (you can work any angle you need out though).
A little example:
Lets say that in my coordinate system x goes left to right, y goes top to bottom, and the origin is top-left. Let's also pretend that my Z axis goes from front to back, i.e. from close to the screen to away from the screen.
the 3D vector
Vector.X = 10
Vector.Y = 10
Vector.Z = 10
would start at the origin (all vectors start at the origin when it's defining a direction), and go 10 units left, to units down, and 10 units away from the screen.
Basically 10 units along each axis.
To get a vector in the opposite direction you are correct, it's simply the negative of that vector.
i.e.
Vector.x = vector.x * -1
Vector.y = vector.y * -1
Vector.z = vector.z * -1
BTW, it's a good idea to make operators for things like addition, subtraction, unary minus, finding the magnitude, multiplying by a number, finding the 'unit vector' (given a vector) etc...
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Sep 14th, 2004, 05:24 PM
#14
PowerPoster
Thanks for the nice explanation.
with dx7 at least...maybe not others, if you type
#define D3D_OVERLOADS
you get a few operators like that.
But yes, it would be a great idea to make operators for it
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|