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.

Dark GDK / Gravity and physics

Author
Message
CAJUN57
16
Years of Service
User Offline
Joined: 29th May 2008
Location:
Posted: 30th May 2008 01:16
im in the making of a fps that i plan on making multiplayer. I was wondering what is the best way to put gravity and physics in my game. so far i can only lock the camera at a specific height, but then i cant go up stairs or anything.

The south will rise again
deadlyduck
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: United Kingdom
Posted: 30th May 2008 04:06
Dark Physics is a good starting place,

you could also write your own simple physics for falling etc.

the first thing you need is collision boxes, if you have them working for moving in the x direction (horizontal) then getting the same collision tests to work y (vertically) is easy.

a nice simple way of doing collision is using dummy invisible cubes as your collision items, create one as your actor and then test that against the other invisible boxes.

there are lots of examples of similar techniques around.

create a cube,

start of game loop

store the cubes last location
move the cube using the keys or whatever controls you use,

test the cube for collision
if its hit something reset the stored cubes location
store the cubes last position

test under the cube by moving the cube down a little
if it hits something your stood on the ground so restore the cubes position
if it didn't hit anything then your falling, you can put simple acceleration to the cubes fall rate etc here, to be added to the next test.

etc.
etc.

move the camera to the cube

go back to the game loop


I'll not go into too much detail, this is just to give you an idea
deadlyduck
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: United Kingdom
Posted: 30th May 2008 04:09
Oh you can go up steps by testing if theres a collision move the cube up a little (the height of your single step up) and if there is no collision in this position you have steped up, so store the new position and carry on.
CAJUN57
16
Years of Service
User Offline
Joined: 29th May 2008
Location:
Posted: 30th May 2008 13:54
Thanks deadlyduck i got a simple gravity in my game now

The south will rise again

Login to post a reply

Server time is: 2024-11-20 11:33:20
Your offset time is: 2024-11-20 11:33:20