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.

DarkBASIC Professional Discussion / collision problem

Author
Message
MightyRy
15
Years of Service
User Offline
Joined: 19th Oct 2010
Location:
Posted: 27th Dec 2010 20:22 Edited at: 27th Dec 2010 20:31
Here is my movement function




The problem im having is that when the player collides with the map. When the player walks up a rock and then back off it again. The player wil remain at the height it reached up the rock and doesnt return the original y value.

with this part of the code unremed...



..the player will start on the ground rather than the Y value, 50, that was set for player position.

What i need is a solution to return the player back to 50 Y if it comes back down from and object rather than staying at the height it reached
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 27th Dec 2010 23:29
You're keeping track of the oldx#,y,z position before the collision,
can't you just use the oldy# for his after collision height?
MightyRy
15
Years of Service
User Offline
Joined: 19th Oct 2010
Location:
Posted: 28th Dec 2010 01:53 Edited at: 28th Dec 2010 01:53
so what do i need to change, the..



after the colision

to..



???
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 28th Dec 2010 09:24 Edited at: 28th Dec 2010 09:42
Seems like you are saying, if collision happens do this


You might try, if collision happens, reset previous oldy# position


Or, I was searching the forum and found this by TheComet


Of interest are the lines
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th Dec 2010 09:27
Actually you need to add gravity to the object so make sure you increase the vertical speed of your object downwards every loop.

Basically make a variable called say 'grav#' and add this code:


...and add the remarked code:


MightyRy
15
Years of Service
User Offline
Joined: 19th Oct 2010
Location:
Posted: 28th Dec 2010 12:26
Thanks billr i have for now used the old#y.

But i would like the player to climb the object and after if they are not on the object fall back to 50 Y.

Baxlash from the code i gave you what do i need to take out and where would the code you mention fit?

Login to post a reply

Server time is: 2026-07-21 20:35:18
Your offset time is: 2026-07-21 20:35:18