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 / How to make a collision between objects?

Author
Message
HartZa
23
Years of Service
User Offline
Joined: 5th Jun 2003
Location:
Posted: 26th Jul 2003 19:47
I know this is just a newbie-question and this q. can be found from this forum, i´'m just too lazy to look all the pages...

But:
I'm making 3rd person RPG, and my main character (white cube at this moment ) is going through all objects.
I've tried lots of different methods, but none of them works...
I think the problem is in my object movement, i should make it with newxvalue etc., but i'm making it with move object bla bla bla.
So, if you can help me either:
1. To make a simple collision between object 1 and 2
2. To give me a movement code which uses newxvalue, newyvalue and newzvalue, and collision with that

P.S: You can see i'm not pro, i have many posts on this forum, including semi-newbie questions with WAY TOO simple answers!
Stats: Athlon XP Palomino 2600+ 2088mhz, GF4Ti420 128mb AGP8x, 512mb ddr dual-memory
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Jul 2003 20:45
I don't thinks it's anything to do with your object movement. If MOVE OBJECT works for what you are doing, stick with it.

Here's a small snippit to show simple collision between two boxes - use the up/down keys to move the box.



What you may also want to do is to put a check to see if your objects are within a certain range of each other before using the OBJECT COLLISION/OBJECT HIT commands, as these functions are a bit slow.
HartZa
23
Years of Service
User Offline
Joined: 5th Jun 2003
Location:
Posted: 27th Jul 2003 20:16
Yeah, thanks.
but what snippet should i use when i want to stop the main character object movement when it hits other objects?
like in any game...

Stats: Athlon XP Palomino 2600+ 2088mhz, GF4Ti420 128mb AGP8x, 512mb ddr dual-memory
ReD_eYe
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 27th Jul 2003 21:04
heres some old dbc code that should work in pro


You know whats weird???
Donald duck never wore pants, yet everything time he got out of the shower he put a towel around his waist...
Whats with that???
Revolution
23
Years of Service
User Offline
Joined: 27th Dec 2002
Location:
Posted: 28th Jul 2003 12:48
i was thinking about how to do some quick collision the other day, and it has probably already been used but have a cube around the character that is hidden and moves with the character, then put the collision on that. But i am not to sure weather this would work.
ReD_eYe
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 28th Jul 2003 17:39
its called a collision box and db has inbuilt commands for making them!

You know whats weird???
Donald duck never wore pants, yet everything time he got out of the shower he put a towel around his waist...
Whats with that???
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 28th Jul 2003 18:57
Just a quick question, what is the difference between OBJECT HIT and OBJECT COLLISION? Seems like the same thing to me though.

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
HartZa
23
Years of Service
User Offline
Joined: 5th Jun 2003
Location:
Posted: 31st Jul 2003 19:49
thanks for the snippet, red_eye...
but it doesn't work like i want to.
I don't want that "sticky" thing when you hit the boxes,
i want it to move smoothly, like when you hit wall eg. Counter-Strike.
In CS, you won't stuck in the same place where you hit the wall first time, you move still, but slower...
How's this possible in DBPro?
And Bulleyes: Test the IanM's snippet, it tells you...

Stats: Athlon XP Palomino 2600+ 2088mhz, GF4Ti420 128mb AGP8x, 512mb ddr dual-memory
adr
23
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 1st Aug 2003 19:44
You want something called "sliding collision"... I've never looked into it but I know the forum is peppered with comments and snippets.

use http://www.mywestsomerset.com/forumsearch.html and search for "sliding collision"

Bender:Blackmail’s such an ugly word. I prefer extortion. The x makes it sound cool.
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 2nd Aug 2003 08:17
Thanks HartZa and IanM, that example really tells me the difference between OBJECT HIT and OBJECT COLLISION.

I had been working on several ways to perform collision detection in DBpro for the past few days. Yes, adr is right! The collision that you need is called sliding collision. The procedure is roughly as below:

1. You check whether you collide onto an object, either using OBJECT HIT and OBJRCT COLLISION.

2. If it is collided, get the sliding offset data using GET , COLLISION X, GET COLLISION Y, and GET COLLISION Z.

3. Adjust your current object position by subtracting the sliding the collision data from step #2 from the position.

Unfortunately, I found that DBpro collision detection functions only work best only if your 3-D model does not have complicated shape, i.e. box and sphere will be the best. The documentation said that it will create a bounding box/sphere for each limbs in the object, but I found that there is only a SINGLE bounding box/sphere around the object, which makes the collision detection very inaccurate.

I would appreciate it if someone correct me if I am wrong, as I am still learning it though, and I might miss some details.

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/

Login to post a reply

Server time is: 2026-07-22 10:04:44
Your offset time is: 2026-07-22 10:04:44