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 / Sliding Collision w/o Dark Basic's commands

Author
Message
Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 13th Apr 2003 07:02
In my game, i use the distance formula for collision detection.
ie. Sqrt((mX#-X#)^2+(mY#+25-Y#)^2+(mZ#-Z#)^2). This makes my game a lot faster. The only problem is, is that it causes it to be "sticky" collision instead of sliding. Is there a way to add sliding collision to this formula and save the speed of the game or will i just have to live with darkbasic's code?
Chief Voyager
21
Years of Service
User Offline
Joined: 20th Mar 2003
Location: United States
Posted: 16th Apr 2003 04:00
i'd like to know this as well, is it possible to do the whole
dec x position, ect.?

You're ate up like a soup sandwich.
Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 18th Apr 2003 23:10 Edited at: 18th Apr 2003 23:13
I thought about it for like 5 min. today and it came to me. Here is my code for DBC sliding collision without darkbasic's commands. I used a little math that i learned in geometry last year of similar triangles. It makes the programs sooooo much faster cause you don't have to use darkbasic's collision commands.

I just found the point that the object is trying to go to, found the x and y distances and then used a little bit of math with similar triangles (all of the corresponding sides of similar tiangles are proportionate to each other). I used that to find how far along the wall it wants to go and then moved it that far parallel with the wall.

The only problem with it is that it won't work on angled or curved walls, only walls that are parallel to x or z axis. I haven't thought much on how to do angled or curved yet. Any Ideas are needed and would be awesome.

Hope this helps you. It didn't take me that long, i'm just mad that i didn't think of it before. Cool, use it all you want, just toss me in the credits. Tell me if there's any problems.
Sorry it's kind of hard to explain but if you know any math you'll figure it out really quickly.
By the way, the backup varible is a flag that is used to let it know if the object is moving backwards.

Any Ideas on the angled/curved walls?
That would be cool.

Peace out

Login to post a reply

Server time is: 2024-11-24 10:48:12
Your offset time is: 2024-11-24 10:48:12