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.

Code Snippets / Collision w/o DB's commands

Author
Message
Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 18th Apr 2003 23:12 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-04-25 15:15:20
Your offset time is: 2024-04-25 15:15:20