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 in DBC

Author
Message
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 2nd Apr 2007 20:54
Hello All,

I hope you are all having a wonderful day. Well right to the point then. I'm creating a small demo that showcases a sphere collecting various shapes ala katamari damacy.

I've recieved some help on it already from latch and he helped me a lot, but alas, i'm stuck again and i'm seeking some guidance.

I'm still working on it, but i would like some outside feedback as well. I appreciate it guys.

oh yea, here's the code.



have a good day everyone one, and happy easter!

zombie

ThinkDigital
19
Years of Service
User Offline
Joined: 18th Aug 2005
Location: A galaxy far, far away...
Posted: 5th Apr 2007 01:56
What's it supposed to be colliding with?

"Variables won't, constants aren't."
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 5th Apr 2007 04:09
well i have the sphere colliding with the cone. The only problem is that when i roll over the cone, the cylinder i made gets picked up too. I'm trying to fiure out how to pick up the shapes seperately.

Turoid
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 5th Apr 2007 10:47
I think that this is what you want:




PS: I'm at work now and did not tested the code..

I am awesome and always right.
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 5th Apr 2007 22:39 Edited at: 6th Apr 2007 00:08
thanks, now it doesn't pick up the box when i run over the cone. Thank you again, now i can get the sphere to pick up the box and i'm good. Have a good day. I appreciate your help, thank you again.

zombie

Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 7th Apr 2007 21:06 Edited at: 7th Apr 2007 22:23
Well it was bound to happen again, i'm confused, i can't for the life of me figure out how to pick up the cylinder! so i have included a wonderful commet in the program. It is this one aspect keeping me from what i sooo want to accomplish, a katamari type game.



Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Apr 2007 03:37
For each object, you have to define some type of collision.

make object sphere 1,25
set object collision to spheres

make object cube 2,25
set object collision to boxes

make object cylinder 3,25
set object collision to boxes

etc.

It's not necessary to include the line
set object collision on <object no> after the collision has already occured.

I was going to provide a working example, but I think you'll benefit more if you work it out yourself.

Enjoy your day.
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 8th Apr 2007 03:42 Edited at: 8th Apr 2007 06:32
i agree latch, thank you very much I want to be able to do it without example code.

gahhhhhhhhhhhh!!! what is wrong with me. why can't i make this work!!!!!!!!!!!!!!!! i'm just a little annoyed as to how many people have helped with this one topic and i'm going insane, becasue it all makes sense i just can't apply it.



Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 8th Apr 2007 22:43 Edited at: 8th Apr 2007 22:49
I think I found the issue. Apparently you are misusing the OBJECT COLLISION command:

With OBJECT COLLISION(object a , object b) , it will only return an object number if b is equal to 0. For example, this:

OBJECT COLLISION(1,0)

Would return the object number of the objejct that object 1 is colliding with, because the second number is 0. It returns a 0 if object 1 isn't colliding with anything.
BUT, if both a AND b are object numbers, it will return a 0 for FALSE (the objects specified are NOT colliding), or a 1 for TRUE (the objects ARE colliding). So, this:

OBJECT COLLISION(1,2)

Would return a 1 if objects 1 and 2 were colliding, otherwise a 0 would be returned. Notice how in your code you write:


if object collision(1,3)=3
glue object to limb 3,1,0
position object 3,8,1,1
set object collision on 3
endif


OBJECT COLLISION will not return a 3 for the object number because the second number is not 0. What it will return is a 0 if the objects are not colliding, and a 1 if they are. So, that should be changed to:


if object collision(1,3)=1 <--- There's the difference.
glue object to limb 3,1,0
position object 3,8,1,1
set object collision on 3
endif


I hope this helps to get your program working 100%.

Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 8th Apr 2007 23:41 Edited at: 8th Apr 2007 23:43
yes that does work, haha. i'm so sorry for being such a dick about this.

my sphere picks it up, but now it kind of floats, its weird, its not in the ball like my first object. i was wondering if you could run my code *its dbc* and see if the black cylinder will be frozen on the outside of the ball. I appreciate all your help.

I'm gonna try and fix it, thank you all so much again, don't know where i'd be without you. be good if i put the code in huh haha.

zombie

i'm soooo sorry to keep asking for help, i feel terrible with all the help i've recieved, so i just want to know if the cylinder floats for anybody else on the outside of the ball.



Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 9th Apr 2007 00:09
Don't feel bad, that's what this board is for-- lots of questions

Okay. Notice that here:


if object collision(1,3)=1
glue object to limb 3,1,0
position object 3,8,1,1
set object collision on 3
endif


You reposition object 3. If you erase the position object, then the cylinder will appear directly in the center of the ball.

*I'm not sure (don't quote me on this) but I believe that using POSITION OBJECT on an object that has been glued to a limb offsets it from that limb's position instead of from 0,0,0. So, the position object would offset it from the center of the ball.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 9th Apr 2007 00:38
@sixty

You are totally right. Positioning the glued object will offset it from the limb.

@zombie
A couple of things:
When you are testing something, you might want to give yourself a frame of reference or some kind of marker for distance or position. I usually throw a matrix in or something so I can see how far something has moved and in what direction. Also, you are moving a sphere around which is very hard to see which direction it is pointing. Try using a cone on it's side - that way you can tell exactly which way it is pointing and moving.

Seeing your frustration, I have prepared a working example. I exaggerated the offset based on Sixty Squares position object indication. If you want a couple of clues you can look at the example. I used subroutines, and also condensed the collision code into one check for multiple objects. I based it on your approach of using limb 0 to glue all of the objects to.



Enjoy your day.
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 9th Apr 2007 01:13 Edited at: 9th Apr 2007 01:40
@ sixty squares and latch- i feel so ridicoulous right now, it seems like with collision the answer is right there, but you just can't grab it.

I don't know how to thank you two enough, i suppose one way is to post the working example when its finished. And so, i with the resources given to me now, i will make this, becasue at this point i better be able to huh? haha

all joking aside, thank you all soooo much for helping me out. i'll get that out asap, right now its snack time.


latch- that is a wonderful example, if you don't mind, may i use the objhit code? I'd like to use it and maybe mod it to make it pick up objects on the other side of the cone as well. i won't use it unless you say its okay though. Oh yea, i guess i could position it randomly, that could be cool.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 9th Apr 2007 23:41
Quote: "may i use the objhit code?"


sure, no problem

Enjoy your day.
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 9th Apr 2007 23:47 Edited at: 9th Apr 2007 23:47
cool, thanks latch.

alien master
17
Years of Service
User Offline
Joined: 12th Jun 2007
Location:
Posted: 21st Jun 2007 08:08 Edited at: 21st Jun 2007 08:12
hey to have the camera follow the ball around as it moves just put this

right under the up down left right commands

@latch
Really nice example but....like for katamari purposes lol...what if every time you collided with a sphere box etc...you would pick it up and it would make you bigger?
and if something was bigger than you to the point where you couldnt pick it up could you do that?

Alienmaster
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 21st Jun 2007 18:42
@alien master

My example is just a very basic premise. Move around, bump into an object, and glue it to the main object.

Not having actually seen katamari, I assume it's like a big snowball and as it rolls, it picks up objects and get's bigger. Making the actual ball would be more difficult than just gluing objects to limb 0 because you would have to control rotation, direction, things like that - and limb 0 is the main object itself.

Off the top of my head, you might start with limb 1 - then set the offsets of the objects collected based on the main object's current rotation angles and the size of the objects glued to the limb. Maybe there would be a set number of objects or a total size of the objects that would graduate the next collection to limb 2 which would be a little further out (thus making the ball bigger). With each "growth", you might encase the whole ball in an invisible sphere that represents each overall size increase. You can get the size of the sphere and compare that to any object the main ball comes in contact with. If the sphere is bigger, you can pickup the new object, if it is smaller, you can't.

Positioning the objects on each level of growth would be key and a bit tricky. If there was a maximum number of objects that could be attached for each level of growth, you could set offsets ahead of time and keep count of each added object. When count = 1 for the current level, use predefined offset and angle 1 for the first object rolled over. When count = 2, use the second set of info - and so on until the max size for the level or the max count is reached.

Enjoy your day.
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 22nd Sep 2007 12:52
Looking through the code and what you all have said, I understand this a lot better than I did before but I'm holding off on any further production until I am sure that I can do 3d, its something nice to look forward to.

Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 4th Nov 2007 14:26 Edited at: 7th Nov 2007 01:35
Mini Update-

I left this alone for a long time, but now reread through all of this and after reading latch's suggestion to geet it done, and now I'm gaining some small progress. I feel I'm close, I will post the code when it is working, I can feel it, so close .


Still close but closer than before..its going good guys.

I've nearly worked out a system for the direction of the new limbs placements and the pickups on the collison. Thanks again latch for suggesting that, its been fun thinking of the math to program.

Zombie

Dr. Mannete- OMG It's Zombie's voice, it's so Suave!

Login to post a reply

Server time is: 2025-05-31 20:51:05
Your offset time is: 2025-05-31 20:51:05