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 / 2D collision is not working perfect

Author
Message
MummyKillerSLO
17
Years of Service
User Offline
Joined: 5th Jul 2009
Location: Object Position Y(ObjChair)
Posted: 26th Aug 2011 00:21
Hi everyone!

I need some help. My collision is not working perfect. If the player hits wall at the corner, it will stuck. I also add picture if you don't have Darkbasic Pro at hand. Any help will be appriciated.

[img]null[/img]

Happy to having and using DarkBASIC Professional...
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 26th Aug 2011 00:50
It's working perfect in version 1.074 I have been trying to get stuck all over the map for a couple of minutes and works just fine

cheers.

I'm not a grumpy grandpa
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th Aug 2011 01:19
I can't get it to stick either. Version 1.075.

Alien002
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 26th Aug 2011 09:50
The best avice i have to solve your collision problem is to do X / Z direction one at a time. don't for get to update the old x / z positions. Like i did not to long ago . Few hours later a found it.

Other tips you might want a look at time based movement , Box Within box collision and smooth movement.
ZestyPro
14
Years of Service
User Offline
Joined: 27th Aug 2011
Location: The Grid
Posted: 27th Aug 2011 19:48
are you using sprites?

Haha!
MummyKillerSLO
17
Years of Service
User Offline
Joined: 5th Jul 2009
Location: Object Position Y(ObjChair)
Posted: 27th Aug 2011 22:30
Nope, all what you see on the screen is made with BOX command.

Happy to having and using DarkBASIC Professional...
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 28th Aug 2011 19:12
I couldn't get it stuck either. The things you don't need in your code is the UNDIM statement for an array that hasn't been dimensionalized yet and the GOSUB to Map and RETURN. DATA statements don't need to be run through to be seen.

I added green so I could see where the box is while checking for collision.


MummyKillerSLO
17
Years of Service
User Offline
Joined: 5th Jul 2009
Location: Object Position Y(ObjChair)
Posted: 28th Aug 2011 19:27 Edited at: 28th Aug 2011 19:30
Well if you just move the player it is less possibility to make it stuck. The way I did it, is that you move the player in the corner and then press left and down key at the same time, so player move diagonally to the corner.

I uploaded the image so you can see how to stuck .

EDIT: Oh and for UNDIM... I've made function to load maps, so when new map is loaded I must undim old dimensions of the map.

Happy to having and using DarkBASIC Professional...
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 29th Aug 2011 01:41 Edited at: 29th Aug 2011 01:49
I don't know if I have fixed it, but I can't get it stuck now...




Edit: no gets stuck somewhere else. Maybe try something to check both, and eventually you might fix it.

Login to post a reply

Server time is: 2026-07-10 17:19:13
Your offset time is: 2026-07-10 17:19:13