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!!!!!!!!!

Author
Message
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 2nd Oct 2004 21:23
Please help me with collision. Ive tried everything and I cant get it working. And i cant continue my new game until I can do collision!

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
Richard Davey
Retired Moderator
23
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 2nd Oct 2004 21:29 Edited at: 2nd Oct 2004 21:30
Your post is useless - here is why:

1) We have no idea what you are trying to perform collision with - 3D or 2D?
2) We have no idea what you have already tried to do
3) No examples of short, concise bits of source code that don't work for you
4) No examples of ideas you might have had to resolve the problem

If you seriously want some help, re-think how you ask for it.

"I am not young enough to know everything."
- Oscar Wilde
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 3rd Oct 2004 03:54
VERY,VERY! Sorry but I was in a hurry to type cos I had to go out. Ill try again.

I am trying to acheive 3D collision for this game Im working on. everything works cept you can walk through everything! I have tryed using:

Make object cube 1,10
set object collision to boxes
set object collision on 1

Make object cube 2,100
set object collision to boxes
set object collision on 2

(This is just an example of what i have done)
I know I have missed out something really obvious but I just dont know what.

oh and by the way I've tried cpoying and modifying some tutorials and help files but still no Joy!

Hope that was better. I apologise again for my rushed first post

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 3rd Oct 2004 04:15 Edited at: 3rd Oct 2004 04:16
Well setting collision on isn't going to automatically detect collision, your going to need to do all that yourself. I don't know if this will work, as I'm no expert on collision, but it might help you understand what you need to do.


Ok object 1 is the player
Object 2 is a box

if object collsion (1,2)>0
position object 1, object position x(1), object position y(1) object position z(1)-1
endif



Ok one command you need to learn is IF OBJECT COLLISION, this command checks for collision, and the two paremeters after it are the objects your trying to detect for, for example your checking for collision between object 1 and two thus in parethesis you put (1,2), after that you need to tell the program what condition it needs to activate collision, I added a >0 there, this means that if collision is greater than zero, then the collision would do something, which is what follows in the if statement. It's not easy, and I might be shooting you down the wrong path, but thats what I think anyway.

Well anyway, once the collision has been detected by the above command, we need to tell the program what to do about it, now I decided to position the object at a new position relative to its current one, I did this with the position object command, after that command is three paremeters, the x, y, and z, I dont want to move the player right or left (x), or up or down (y) but I do want to move it backwards, so that it can not enter the wall, so I added....

object position z(1)-1

the 1 in parethesis is the player object, and the -1 is telling it to move back 1 unit.

Hope I helped.

Note. I have no documentation present, if the commands listed above are worded wrong, or have errors it's because I simply dont have them in front of me, please search for them in the DB help files.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 3rd Oct 2004 05:06
Yeah I keep getting a Unrecognised parameter at
if object collision (7,2)>0

Which is really annoying cos I thought you were on to something then.

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 3rd Oct 2004 07:20
It could be because it's not finding the objects, I have had that problem before, try checking for collision on all objects, you do this by checking one object against zero, so if object 7 was the player it would be...

If object collision (7,0)>0

Try that and see if the error goes away.

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.
Hop a long
21
Years of Service
User Offline
Joined: 12th May 2004
Location: The Code Dump
Posted: 3rd Oct 2004 12:01
Hey Saberdude
Most of the examples on my site include simple collision testing.
You'll find boxes, bullets and walking models that all hit something. Here's a place to start:
http://www.geocities.com/hifin2003/sliding-collision.html
All the solutions are basic, no prize winners here. But check out the links section if you require more depth.
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 3rd Oct 2004 19:55
Hey thanks guys. Hop a Long Ill look at your code and try to understand it. Ill post back If I have any questions. (After Ive done my Homework!)

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 3rd Oct 2004 23:33 Edited at: 3rd Oct 2004 23:36
Hi again. Hop along. I ve looked at your code and I dont understand this bit:
Make Object Collision Box 10,-10,-10,-10,10,10,10,0

What are all the 10,-10,-10,-10,10,10,10,0 for?

(I understand the rest though!)

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
Turoid
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 4th Oct 2004 00:15
a collision box is a collision detector around the main object, the 10,-10,-10,-10,10,10,10,0 is the scale data of the collision box. if you look close you'll see that there are 3 -10's and 3 10's.
the diffrence between -10 and 10 is 20.. so this collision box will do good around a cube that's 20 big.. like: make object cube 1,20

Do you need a complete FPS,3rdPS engine ?? Or a collision command libary?? well here it is:
http://forum.thegamecreators.com/?m=forum_view&t=38869&b=6&p=0
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 4th Oct 2004 00:46
!!!!!!!!! I still can't do it!!!!!!!!! Im getting really frustrated now!!!!!!!!!! Here...is...the..code Im working on. can you take a look!
(part of it is just copy paste from your example hop along)


Replace the models with primitives.
P.S Dont steal my code

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 4th Oct 2004 04:58
make object cube 1,1
make object cube 2,1
position object 1,25,0,25
point object 1,0,0,0
position camera 0,50,0
point camera 0,0,0
do
oldx# = object position x(1)
oldy# = object position y(1)
oldz# = object position z(1)
text 0,0,str$(oldx#)

if upkey()
move object 1,0.05
endif
if downkey()
move object 1,-0.05
endif
if object collision (1,2)
position object 1,oldx#,oldy#,oldz#
endif
loop

works fine here, this is my second attempt to post this, the first post was a massive description of collision, how to do it, and how it works, but the stupid forum header dropdown box somehow became active and swapped pages for me when I scrolled with the mouse wheel, so I lost it all , I hope this shorter post is some help, if not then I will write it all out again tommorow

Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 4th Oct 2004 05:15
Hi again. Mentor. Your code worked fine but when i tried to implement it into my game it didnt work. However ive had an idea.
If I had an object a positionedat 0,0,0 and I did something like:

if object position 1=0,0,0 then position object 1,object position x(),object position y(),object position z()-1

would that work?

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 4th Oct 2004 05:50
but objects can have exact positions in floating point, your code would have to have the object at exactly 0,0,0 any slight deviation and it isn`t at 0,0,0 and so it won`t work, I looked at your code and I can`t see what you are trying to do, none of your objects have the same y so they couldnt collide anyway as far as I can see, just what are you trying to do exactly?.

Mentor.

PC1: P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 4th Oct 2004 14:29
Okay, I'd like to add my two cents to this discussion, something I have found to be true when using the object collision command. The first thing I'd like to say is that "object collision(x,y) > 0" hasn't been all that successful for me, as though the parameter (x,y) is not being tested properly. (particularly when testing against several objects.) Therefor, every time I want to detect collision against a specific object I use the coomand of;

if object collision(x,0) = y

or in your case;

if object collision(7,0) = 2

Second, your code here has a bit of a problem;

If Object Collision(7,2) > 0
` Obtain the object id for our text print out
obj_id = Object Collision(7,2)
` Decrement the Player coordinates to begin the slide
` You would need y if crossing a bridge, applying gravity etc.
` The Get Object Collision command only returns a value when a non-rotating
` collision box is used.
Dec posx#,get object collision x()
Dec posy#,get object collision y()
Dec posz#,get object collision z()

Endif

In that when you run the command "obj_id = object collision(7,2)" the result can be ONLY a 1 or 0. This will NOT give you the object number of the collision, while the command of "obj_id = object collision(7,0)" will return the number of the object touching object #7. If obj_id is supposed to be a flag merely indicating that the two have collided, then ignore this part...

good luck!
S.

Any truly great code should be indisguishable from magic.
nuclear glory
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location:
Posted: 5th Oct 2004 03:50
If you have the enhancement pack you could always try our plugin as well. It's really geared for 3D collision.

Site at:
http://www.nuclearglory.com/ngc.php

Lead Programmer/Director
Powerful Collision DLL for DBPro and DBC: http://www.nuclearglory.com
Lightwave Scene Exporter to .X also at: http://www.nuclearglory.com
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 5th Oct 2004 04:43
if this helps *AT ALL* ( i don't know, i've NEVER used the object collision commands )

If you don't care about what you get back with an "object collision (*,0)" command, try the following (* symbolises 'whatever'):

If Object Collision(*,0) <> 0
`whatever
EndIf

I love operators. Seriously. I mean, did you know you can do stuff like If (some command) <> 3 Or 5 ? Mm..

[img src=http://blanky.pt-web.net/ddd.gif] >::p
Hop a long
21
Years of Service
User Offline
Joined: 12th May 2004
Location: The Code Dump
Posted: 6th Oct 2004 02:20 Edited at: 6th Oct 2004 02:31
Saberdude:
You have do have two sync commands in your code. That could cause problems. Also after you check for collision you have to use the results of that check. The code gives you updated coordinates for the colliding object. If you don't want the "cat" to pass through the "bunker" you will have to reposition the cat with the new data right after the collision check :
Position Object 7,posx#,posy#,posz#
Now the cat should slide along the edges of the bunker. Be sure to read what Sandra D says about the values returned for the obj_id variable. You can help yourself during touble shooting by writing print or text statements that will report the status of your code while it is running :
Text 10,100, "The cat hits number: "+str$(obj_id)
If you do the check for all objects and get a 2 on screen you know you hit. So collision detection is working. But if you continue to plow on through bunker 2 you know your positioning code is at fault. Try again and let us know how you are doing. You are getting quite a following. Nothing worth doing was ever easy to learn.
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 6th Oct 2004 02:33 Edited at: 6th Oct 2004 02:36
Yes I know LOL! I hope this topic may help some other people who are having the same or similar problem. As many Ideas on how to do it are mentioned here!

P.S By the way Nuclear Glory dude, I would like to use your DLL but I couldnt get the demo working and Im only 13 and Im not allowed to buy it.

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 6th Oct 2004 02:45
Ok I have just tried printing The cat hits number: "+str$(obj_id)
and it does say I am colliding with object 2 its just nothing is happening. Thats a step forward right. But only problem is that my colliding box is too big so it says Im colliding with it even though Im not...

P.S How do I insert pics like screen shots so I can show u stuff?

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 6th Oct 2004 03:13
Sorry for 3 posts in a row but I have some great news...SUCCESS!!!!!
Its not sliding collision but its COLLISION. Here is what Ive done:
If Object Collision(7,0)=2 then position object 7,posx#,posy#,posz#

Its sooooooo simple too, Now if I can refine it It will be perfect and I can finish my game and all of you guys will be in the credits cos you helped me alot!!!!!!!!! Any more tips howecer will be much appreciated!

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
Hop a long
21
Years of Service
User Offline
Joined: 12th May 2004
Location: The Code Dump
Posted: 6th Oct 2004 04:08
Way to go Dude!
I can see by your comments:
Quote: "...SUCCESS!!!!! "
that you are discovering the fun of programming. You seem to be enjoying working your way through the "puzzle". It's just the way you would play a game. So I don't know if you want any "cheats". But if the going gets too frustrating try:
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 6th Oct 2004 04:27 Edited at: 6th Oct 2004 04:31
....... I don't know wot to say cept THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

P.S I would post some screenies of my game cept I dont know how!

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
Hop a long
21
Years of Service
User Offline
Joined: 12th May 2004
Location: The Code Dump
Posted: 7th Oct 2004 03:43
I could not ask for more.

You are welcome.
MrNick
21
Years of Service
User Offline
Joined: 23rd Feb 2004
Location:
Posted: 7th Oct 2004 07:02
i don't know if this helps but this should work...
if that didn't work, you copy of db may be screwed. check if its the latest version and get an update if needed.

"think about the risk of victory: life is short and so is glory... but death is forever..."
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 7th Oct 2004 12:33
For a moment there, I felt like a smart person. lol

Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.

Login to post a reply

Server time is: 2025-05-24 17:05:06
Your offset time is: 2025-05-24 17:05:06