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 / Having a collision mean something between two objects (sparkys, maybe)

Author
Message
Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 27th May 2009 11:06
I've been trying to use sparkys with this, but I'm happy to use the built in if thats better for this.

Source


Ok, so I want to set it up so when object 1 (the template character) collides with object 2 (or any other object for that matter) He stops, I don't want him bouncing off, or phasing through the object, just so he stops when he touches the wall, or an an object. So how and where do I put what collision data, sorry to ask such a simple question, but I think so far collisions have been the trickiest part of learning darkbasic pro.

Thanks.

(And for future reference, but not quite needed now, how would I make it so I could have him walk over objects that are smaller than a certain height, so he can just walk up stairs and whatnot?)

Thankyou again.

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 27th May 2009 17:58 Edited at: 27th May 2009 18:01
well if you want very simple collision, i would use this:
-first, you save the position
-second, you move the object
-third, you check if there is collision
-fourth, if there IS collision, you place the object at its old position.

so that code would look like this :


however, if you want very easy collision that looks very good, look Here! its very good commented and just as easy as this to implement, you just need sparky's Collision DLL to make it work. and it also takes care of stairs and stuff, just don;t make them too high (if you know what i mean)

Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 27th May 2009 18:47 Edited at: 27th May 2009 19:23
uhh, sorry to sound really noobish, but player position x# isn't recognised, am I doing something wrong?

I enter what you've written, (excanging playerobject for 1 of course)

Have I not defined something correctly or what, in my code I havn't defined player position x, and it isn't understanding it naturaly, so...

Edit:
Also I read the tutorial you posted bobbel, it was useful to start understadning sparky's dll, but i'm not not sure it helped me in this case, as I'm trying to make the player object collide with everything else on my map, how do I do this (and preferably, have everything collide with everything on my map, useless now as I have no other moving objects, but for later when i suddenly start having enitities walk threw stuff...

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 27th May 2009 20:24
Hi jasonorc, the playerposx# is just a variable. you could enter anything here. but what i would enter is the current position of the player object. so Object Position X(PlayerObject) is what i would enter there, i just wasn't sure of the object number you used. do this too for the y and z position.

and for having everything collide with anything in the map, with the first code snippet, if you would leave it like Object Collision(PlayerObj, 0) it checks collision for every object that exists. for the second, you can use SC_SphereSlideGroup, but thats a bit difficult.

hope you get this. if you don't, don;t hes(t)itate to ask question

*ding ding*
Cagedrei
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 27th May 2009 20:24 Edited at: 27th May 2009 20:25
Try:



D'Oh! Cross-posted with bobbel. Hmm.
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 27th May 2009 20:27
omg lol

*ding ding*
Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 27th May 2009 20:33 Edited at: 27th May 2009 20:41
Ok, so I fixed it all up, added it all, but the collisions are very clumsy, I have to reverse in a perfect direction to get out a collision, and scaled objects can't be collided with, I guess I'll have to struggle to understand sparkys then

My site: www.skyknight.co.uk
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 27th May 2009 23:55
Regarding the scaling issue, I noticed that the new version of Sparky's has to be done a little differently than the old version in order to work.
First, you setup the object, then use:

SC_Allowobjectscaling ObjectNumber

scale the object and then use:

SC_UpdateObject ObjectNumber

works fine for me.

LB

bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 28th May 2009 09:22
i prefer makin the objects just the right size, so you don;t have all the stuff with scaling and things

*ding ding*
Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 28th May 2009 11:23 Edited at: 28th May 2009 13:09
Hi, ok using sparkys I can now check that something is colliding or not, but how do I make a collision so that when object 1 cannot faze through anything, so he actualy "collides" with stuff.

My site: www.skyknight.co.uk
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 28th May 2009 15:32
I remmed out a bunch of stuff in your code and made some primatives in order to make a working example of it. This assumes that you have the current version of Sparky's in your 'user-plugins' folder.




By the way, I believe you could easily code this to eliminate the goto.

LB

Login to post a reply

Server time is: 2024-11-24 06:30:41
Your offset time is: 2024-11-24 06:30:41