Skip to main content
gamedev.net
🔒 Locked

simulating forces

Started by 3dstudio 2 replies 300+ views
Original Post
3dstudio
3dstudio
I am doing gravity in my game engine but am wondering how tom implement it?I understand it has to do with vectors and that vectors can define points V(x,y,z) but how do i use it for gravity?I understand it should be something like V(0,-1,0) vector in negative y but how do i simulate it how do i use this vector at all?i.e. player is walking and he falls down the cliff he goes down smoothly and accelerates until he dies, how will vector help me here?Also i understand it can be used to calculate orintation of reflecting ball and other...My question is how will i make something really fall and other with just these numbers in vector, is there a way?.Also some colission detection routines or articles are welcome but something simple.Thanks alot!!!!!! Ripper
Real life is in infinite number of pixels xy however i use computer finite 16001200Ripper
Sneftel
Sneftel
Read articles in the "Math and Physics" section of GameDev.



Don''t listen to me. I''ve had too much coffee.
y2kiah
y2kiah
There should be three different types of vectors in your engine. Position vectors (an objects position relative to the origin), velocity vectors (the speed and direction of an object), and acceleration vectors (the rate at which the speed is changing). The acceleration vectors will update the velocity vectors, and the velocity vectors will update the position vectors. So, if you want your guy to fall, he will be at a certain position. The only force is gravity if he is standing still, which is applied as an acceleration vector (0,-9.8,0) in m/s or (0,-32.2,0) in ft/s, to the velocity of the guy. So he will accelerate downward and his downward velocity will increase, thereby changing his position downward more and more over time. To apply acceleration to velocity, just add the two vectors together and you get a new velocity. To apply velocity to position do the same. Of course, now you will need to add you own timing and collision detection routines, so read up! Later.
3dstudio
3dstudio
Maybe i didnt mention i use opengl, and i am wondering if applying grvity could be done by use of gltranslate function
so i move player down by a factor in vector?It is not quite clear but could i use a loop which just iterates gltranslate function in negative -y and send down to the pipeline to render it so it just appears as if he moves down on the screen.This is faking and simple and i am wondering if this is the way to do it?Thanks!!How do you do it?

Ripper
Real life is in infinite number of pixels xy however i use computer finite 16001200Ripper

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.