Advertisement

Game Physics !!

Started by March 01, 2000 12:31 PM
12 comments, last by tcs 24 years, 7 months ago
No, No, No and 1000x NO
This is NOT my problem!
I have problems with detection when the player should stay on ground. I can''t get this working with different update rates...
Tim--------------------------glvelocity.gamedev.netwww.gamedev.net/hosted/glvelocity
Hmm, time for a diagnoses. Create a very steep, but not completely vertical grade [slope.] Now test walking down this grade. If my suspiscion is correct, you will stop partway down and you won't slide or fall any further. I'm still trying to figure out whats going wrong, but I need to know the result of this first before I can suggest any solutions.

Edited by - SonicSilcion on 3/8/00 1:46:59 PM
Advertisement
I think there is something wrong with the order of the operations on the person.

What you seem to be doing is something like this:

if (in the air) then    do gravityelse // on the ground    move sideways according to inputendifdrawloop 


The problem is that it is possible to take a gravityless step in your world. You will have to do gravity every time after a move, like this:

move according to inputif (on ground) then    // person is on level ground    do nothingelse if (under ground) then    // person is moving up slope    adjust to height of groundelse if (in air)    // down slope    do gravity    if (on or under ground)        adjust so they are correctly on ground    else  //still above ground        // slope too steep for sinlge step to reach bottom        now in falling state    endifendifdrawloop 


This will mean doing more than one "check to see if person is on the ground" check per loop. The idea is that no move is done without gravity right after it, so a person on the ground coming into the physics engine will come out of the physics engine also on the ground. As you said, just making smaller steps will not make the problem go away.


---
Grandpa Simpson - "I never thought I could shoot down a German plane, but last year I proved myself wrong!"


Edited by - spejic on 3/8/00 2:45:40 PM
---Grandpa Simpson - "I never thought I could shoot down a German plane, but last year I proved myself wrong!"
Hmm, yeah, you may not have correctly interpreted what I had said...See, on each frame, after input, you inflict gravity, whether the player is on the ground or not. Yes, this means that he will likely fall through the floor. THEN you do a test, and if he is below the floor, set him to be on the floor. Doing some kind of funky special case about whether he is on the ground or not is NOT the way to go. Just always afflict gravity, and then if his feet are below the ground, set them to be on the ground, and then render the frame. That should do it...

- Hai, watashi no chichi no kuruma ga oishii deshita!
...or, in other words, "Yes, my dad's car was deliscious!"
- Hai, watashi no chichi no kuruma ga oishikatta desu!...or, in other words, "Yes, my dad's car was delicious!"

This topic is closed to new replies.

Advertisement