Radio Control car physics???

Started by
15 comments, last by Jasun220 22 years, 7 months ago
Well, as others have said, you should read up on vectors, also, create your own physics engine if you can, you''ll know what the hell you did, instead of being left in the dark by someone elses code, to get the "floating" effect of the camera, all you need to do is translate the camera coordinates and have it follow the car at a certain velocity, it wouldn''t be to hard to do, if your using OpenGL, try something like this...

I haven''t really used glulookat or whatever before but you can find info on nehes site i''m sure, it does camera stuff, but do something like this if i''m wrong


make sure you specify that this goes to the camera coordinates, it will move the camera back 5 units.
glTranslatef(0.0f,0.0f,-5.0f):

then do a little loop that makes the camera "follow" the car...

in this example, x will be the actual speed that the car is going, so you can just use this variable from wherever else youre using it.
again, make sure you''re specifying that these are camera coordinates
while(vehicle_speed == x)
{
doing this, will make the camera always follow 5 units behind the car, no matter what speed it is going.
also, i''m not really sure if you can do this with glTranslatef or whatever, i''m kind of new to opengl myself.
vehicle_speed - 5 = camera_speed;
glTranslatef(0.0f,0.0f,camera_speed);
}
that''s just something i came up with in my head, i''m really not sure if it works or not, but you could probably get what i was thinking of from that. hope i helped some.
Advertisement
I know what ur saying, in fact thats what i got coded in my G3D game. But that ONLY says 5 or whatever behind the car at ALL times, download that demo from Jedaye, and see how that camera works, that is what i would like.
Do you mean the dampening effect?



**
Ste
**Ste
Yeah i guess
Thats quite literally a one line thing...along with some stored data...

When you update the camera position vector (in world space) use the equation:

TargetPosition = some value relative to the object you are following;
CameraPosition += ((TargetPosition - CameraPosition) / 16.0f);

Simple eh?

Edited by - Jedaye on August 25, 2001 4:15:10 PM
**Ste
And thatll make the effect just like in that demo? Wow, i thought it would be alot of code.
Indeed, simple eh?

there are limitations with this appraoch tho...try playing with the ''16.0f'' value...you will soon find out what i mean...

There are far more complex approaches involving some quite interesting physics (spring equations etc), it all depends upon what you want anf what type of game you are implimenting it in...

I like to think of this one as: Object <-> pole <-> camera Where the camera acts as if its attatched to the objects via a pole and 2 pivets...
**Ste

This topic is closed to new replies.

Advertisement