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 / How do i make gravity in a FPS?

Author
Message
blablaguy
16
Years of Service
User Offline
Joined: 27th May 2008
Location:
Posted: 27th May 2008 10:26
Hello! im new here and im trying to make a FPS but there is 1 problem... if the camera looks up and moves forward it will start to fly in the sky...

i've tried



But that makes the camera always stay at one level... then the player will not be able to climb stairs or go down slopes... Can any1 help me???
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 27th May 2008 15:07
Every frame you make the camera fall, ie decrease the y value by a gravity constant, and then make sure that the camera is not below the floor by doing a while loop with a collision check.
unitech
17
Years of Service
User Offline
Joined: 27th Jun 2007
Location:
Posted: 27th May 2008 19:21 Edited at: 27th May 2008 22:42
That would be the same as
dbPositionCamera(dbCameraPositionX(),1,dbCameraPositionZ());
You would not need the if?

try this..
static int amount = 1;
dbPositionCamera( dbCameraPositionX(), dbCameraPositionY() - amount, dbCameraPositionZ() );

Then do you if. But you should use rays for gravity. Or somthing like sharky's collision.
blablaguy
16
Years of Service
User Offline
Joined: 27th May 2008
Location:
Posted: 28th May 2008 08:08
ok ty for the help, but if i do

That will make me go down forever...
unitech
17
Years of Service
User Offline
Joined: 27th Jun 2007
Location:
Posted: 28th May 2008 14:09
If your terrain will be perfectly flat and you never change the value of amount yes. If amount changes then that if will cause you troubles.

You would need to do this.



other wise just use a static number. Also you really dont need the < check since you r only gong to be subtracting by 1. Will you even be under ground?

Login to post a reply

Server time is: 2024-09-29 21:19:27
Your offset time is: 2024-09-29 21:19:27