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 / Detecting Obstacles in the "World"

Author
Message
daniel95
15
Years of Service
User Offline
Joined: 25th Jul 2009
Location:
Posted: 25th Jul 2009 13:12
I'm using one of the DARK GDK`s samples (World) as my environment in my game. The problem is when the object which I have put in this world get to an obstacle like stairs, ramps, or walls, it can't detect it and it just flows over and passes through walls. Can you please let me know how I can detect these obstacles in the world environment?
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 25th Jul 2009 17:23 Edited at: 25th Jul 2009 17:24
Detecting the obstacles is not that difficult, its doing it efficiently that can be challenging and then deciding what you should do when you get a collision.

You can use the db collision commands but Sparkys collision is faster (I have been told), you can download that for free somewhere on this site.

But that doesn't do everything for you, collision can be quite challenging.

If you dont fancy any of that, to start with just do some very basic collision yourself, calculate the distance between you and the centre of the object and then test if you are too close in your loop(collision), you will need to store your old position values(from last loop) and then if there is a collision just reset the current position to the old position.
daniel95
15
Years of Service
User Offline
Joined: 25th Jul 2009
Location:
Posted: 25th Jul 2009 18:40
Thanks.But there is another problem.When an object gets to a ramp that is going downwards,it doesn't go down,but just floats over it.Does anyone have a solution to this problem?
Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 25th Jul 2009 18:50
One solution is to check if there is any space under the player, usually with raycasting, and if so, move the player down.

daniel95
15
Years of Service
User Offline
Joined: 25th Jul 2009
Location:
Posted: 25th Jul 2009 18:54
I don't understand.Sorry,but can you explain me how to make the player go,normally,down,and not fly over everything.
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 25th Jul 2009 21:28
I believe you can use the "dbIntesectObject" command to figure out the hieght the object needs to be at, then you just move him there.
daniel95
15
Years of Service
User Offline
Joined: 25th Jul 2009
Location:
Posted: 25th Jul 2009 23:28
So,you are saying that I should give my object smaller Y coordinate so it will go down? Because the player I'm using is in coordinates 0,0,0,and I should give him coordinate like: -2?Sorry for asking so much questions ,but I'm new in this and I'm such a noob.But that's because I'm in to programming a lot and I don't know much about it.So Please,anyone who knows this,help me!
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 26th Jul 2009 03:08
Raycasting can check for a collision under your feet, it also returns the distance of the object(floor) you are testing against, so you then have the distance that you need to move your player down (Y axis).

I am not new to all this and I struggle getting collision to work as well as I would like, you are attempting to tackle a very tricky aspect of game programming, research what ray-casting is and how to use it, also get hold of sparkys.

Another route would be to look into height-maps, give that a search and see what you think will be easier for you.
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 26th Jul 2009 03:59
ok daniel95, I'd try to use some sort of gravity system.

//check height
return value of intersect object command

//reduce gravity
if y position is less than return of intersect
gravity = 0
else
gravity = 1

//add gravity
y = y - 1

something kind of like that.
daniel95
15
Years of Service
User Offline
Joined: 25th Jul 2009
Location:
Posted: 26th Jul 2009 23:47
Thank you both,very,very much!
daniel95
15
Years of Service
User Offline
Joined: 25th Jul 2009
Location:
Posted: 28th Jul 2009 01:42
But it still doesn't work,so if anyone could just give me the code to enter,it would be cool,but if not,it's okay.

Login to post a reply

Server time is: 2024-10-01 08:48:27
Your offset time is: 2024-10-01 08:48:27