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.

Newcomers DBPro Corner / Collision problems

Author
Message
Alvind
16
Years of Service
User Offline
Joined: 6th Dec 2007
Location: Northern Ireland
Posted: 14th Nov 2013 21:35
Hi guys I'm having a bit of a problem learning my way around DarkBasic Pro.

Displayed is the program which I'm creating, the exact problem I have is whenever the player (a tank) comes close to a mesh I created (to act as a wall) it starts to sink below the level of the mesh and goes under it rather than just stopping dead.
It then stays on the level it sunk down to.

Where should I start looking?



http://dai.moddb.com
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 14th Nov 2013 23:04
Without your models I can't prove it but when the tank collides with the wall the "Get Object Collision Y()" is returning a small negative value. Try writing the result of the "Get Object Collision Y()" and printing it to the screen to see what's going on.

The easiest thing would be to just remove "Dec YPos#,Get Object Collision Y()" from both bits of collision code. If the movement of the tanks is purely on the XZ plane then you don't need to resolve the collision on the Y axis anyway.

This may sound like an overly simplistic solution but it's the sort of thing I do.

one of these days I'll come up with a better signature
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 15th Nov 2013 15:55
Correct me if I'm wrong, but since your floor is a flat plain your Y position should never really change, so just find out what that position is and keep using it:

Position Object 2,XPos#,n#,ZPos#

D.D.
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 15th Nov 2013 16:08 Edited at: 15th Nov 2013 16:09
Totally agree with what has been suggested so far. I made up some dummy objects and ran the program and did not see the issue you are seeing. As a suggestion, you might consider adjusting the Y height placement of your wall. Instead of hard-coding the Y placement, maybe check to see the object's height and divide it in half:


So many games to code.....so little time.
Alvind
16
Years of Service
User Offline
Joined: 6th Dec 2007
Location: Northern Ireland
Posted: 16th Nov 2013 22:31
Thanks guys I will give this a try. Many thanks!

http://dai.moddb.com
Alvind
16
Years of Service
User Offline
Joined: 6th Dec 2007
Location: Northern Ireland
Posted: 17th Nov 2013 20:15
This did indeed work. Thanks

http://dai.moddb.com

Login to post a reply

Server time is: 2024-03-29 10:03:02
Your offset time is: 2024-03-29 10:03:02