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 Discussion / collision in a vertical wall

Author
Message
sjonny
18
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 1st Dec 2006 14:09
i want to make a collision into a vertical wall but when i place my collision it stays horizontal, how can i make it turn 90 degrees in my program?
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 1st Dec 2006 19:23
Collision happens no matter what the angle is... the object is either touching another object or it isn't.
sjonny
18
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 1st Dec 2006 20:01 Edited at: 1st Dec 2006 20:02
look i have now done it like this:


see the collision in darkbasic itself
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 1st Dec 2006 21:19 Edited at: 2nd Dec 2006 02:24
The collision box stays with the object. With the numbers you use you really can't see a difference between the normal collision and the modified collision box.

I've increased the size of the objects collision box modification to test it out.



Edit: I just thought about asking this: Are you wanting to increase the walls normal collision area so the player doesn't get too close to the wall?
sjonny
18
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 2nd Dec 2006 08:09
no i just want it to not get it go through the wall, but this still doesn't work how come?
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 2nd Dec 2006 23:56 Edited at: 2nd Dec 2006 23:59
It works just fine (when you see "Collision!" in the upper left corner it has detected collision). All you have to do is not let it keep going that direction when it detects collision. Also it's better to keep away from modifying the walls. If you just rem off the collision box it still works because every object already has a collision box exactly the size of the object.

The main reason I think you would want to modify the existing collision of an object (make it wider) is so the character doesn't get too close to the walls before collision is detected. But we use a better method. Instead of modifying the collision box of every object you just use one object around the player to check collision... usually it's a sphere. You make the sphere as big as you want so you can tweak the distance you want to keep away from everything (also how close an object has to be to "pick it up").

I've attached an image to illustrate a collision sphere (it's the green sphere around the robot). This object is normally hidden and follows the player object at all times (when it's not hidden it's usually a shield to protect the player). Notice in the image the sphere is right next to the wall... that's where it detects collision so the player is a good distance away from the walls and other objects at all times.

The following code makes another wall and detects collision on both walls. Once it hits the wall it changes direction and goes towards the other wall... it repeats it till you hit ESC.

Attachments

Login to view attachments
sjonny
18
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 3rd Dec 2006 12:36
ok this is what i have.



what have i done wrong?
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 4th Dec 2006 02:47
Ah I see what you're trying to do now. Instead of making the same object and rotating it... make it the right direction to begin with:

sjonny
18
Years of Service
User Offline
Joined: 25th Nov 2006
Location: darkbasic classic
Posted: 4th Dec 2006 08:36
thanks that is what i wanted to know

Login to post a reply

Server time is: 2025-05-26 02:53:40
Your offset time is: 2025-05-26 02:53:40