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 / Cshop and collision detection

Author
Message
Quantum
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 18th Dec 2002 15:51
how do i distinguish between walls and floors in my level created with Cshop? I have created gravity so that the player stops falling when he hits the floor using the object collision() command. But if the player is on the floor, i can't test for collisions with walls because the player is already colliding with the floor. the object collision() command treats the entire level as a unit. This means that if i detect for collision on one surface, i am detecting collision on all surfaces.
Ratty Rat
21
Years of Service
User Offline
Joined: 24th Sep 2002
Location:
Posted: 18th Dec 2002 17:33
There must be several ways of tackling this, here are a couple.

You could keep a 'walking' flag or mode (as opposed to falling etc) once you have detected collision with the ground you set the mode to walking and move the object up a little so it is not in collision with the ground, thus you can detect wall collisions. While in walking mode your object is not affected by gravity so it does not go down, of course you now have to work out how to detect when the object falls off an edge....

Alternatively you can use collision detection objects other than your player object, one in front of the player, one behind, to the left/right, below and above. Make them invisible and detect collisions with those instead, that way when you below one has detected a collision with the ground your front/back/sides objects are still free to detect wall collisions. This way you can also detect when you collide with 2 walls at once.

Other ideas keep coming to mind, like using spherical or cube collision, you just have to find what works best in your game without too much loss of speed.

Login to post a reply

Server time is: 2024-05-02 03:07:29
Your offset time is: 2024-05-02 03:07:29