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 / Sparkys collision problem

Author
Message
Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 4th Feb 2012 16:17
Hello,
i'm trying to redo my collisions. Because i allways used the sliding demo as base.
But now i don't want to use Sphere Collision (want to use box) and without sliding.
But its allways porting my object to pos 0,0,0 - why?



Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Feb 2012 18:49
Quote: " if collide>0 x# = sc_getCollisionnormalX() y# = sc_getCollisionnormalY() z# = sc_getCollisionnormalZ() endif rem position the player position object Player_ObjectID,x#,y#,z#"

this part is wrong, you are positioning your object at the values which are normals at collision point. Normals are always between 0 and 1. Check sparky's examples to see how to do that properly

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 4th Feb 2012 19:34
Hmm ye but there are just examples with SphereCast/Slide or Raycast x.x
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Feb 2012 21:18
instead of positioning the object at normal, position it at the old position recorded before collision (oldx#, etc..)

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 4th Feb 2012 21:21
Ahh, allright, makes sense. I'll try that, thanks!
Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 4th Feb 2012 23:20
Okay it's working so far. But now i got another problem. If an Y collision appears, X&Z are activated too. Why? I thought it just returns 0/1?



Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Feb 2012 23:49 Edited at: 4th Feb 2012 23:53
Quote: " I thought it just returns 0/1?"

returns where?

Quote: "If an Y collision appears, X&Z are activated too."

there's no y collision, or x, or z, THere's only collision or no collision, there's nothing in between.

Are you talking about normals?
Edit:
I think you do ->normals don't tell you if collision appeared. Normals point in the direction of a polygon where collision occured. They have values between 0 and 1, not 0 or 1. And every collison point has all 3 components of a normal, not just x or y, or z.

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 5th Feb 2012 00:13
Hmm now i'm totally confused. How can i detect a x,y,z collision (If collision on X, don't move further. Same for Y & Z, without blocking each other?)

Without Sphere Collision?

In Examples are just

oldx# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
oldz# = sc_getCollisionSlideZ()

But i don't want to use Spheres & Slide.
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 5th Feb 2012 00:23
this part checks for collision
Quote: "collide = SC_ObjectCollision(Player_ObjectID, 1)"

if collide>0 then collision happened

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 5th Feb 2012 01:23
Okay, that's what i'm undstanding.

You said "Normals point in the direction of a polygon where collision occured."

Now: How do they point? How can i figure out if my collision was on x, on y or on z?

Because if a collision is on X, i have to block the X Movement. And if its on Y, i have to Block y movement.

Hope you understand my Problem. Thats the Part wich i don't understand.
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 5th Feb 2012 01:42
Quote: "How can i figure out if my collision was on x, on y or on z?"

You don't do that. Collision occurs on all 3 axis.

Quote: "Because if a collision is on X, i have to block the X Movement. And if its on Y, i have to Block y movement."

If you want to stop object from moving when collision occurs you block all 3 movements. If you block only one of them then you'll get sliding collision-> you said you don't want that

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 5th Feb 2012 01:47
Oh allright.
Well my only problem with sliding is, it's just working with SphereCollision, isnt it?
Because if i use Spheres, it will result in a collision with free space. (In the Picture the red marked)



Is there a way to get it working with a "box" collision?
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 5th Feb 2012 01:56
Quote: "Is there a way to get it working with a "box" collision?"

i don't think so

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 5th Feb 2012 02:11
That's bad... well, thanks anyway!
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 5th Feb 2012 02:28 Edited at: 5th Feb 2012 02:36
Make your sphere smaller?

Position the sphere at the bottom of the man, and make it no wider than the widest point of the man.



If you need to use collisions with the top half of the man, then do the check again, but with the sphere in a different place.

Hope that helps.

>edit<
Did draw pic in the end lol

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 5th Feb 2012 03:08
Thats a great Idea, thank you!
And nice drawing skills :p

Login to post a reply

Server time is: 2026-07-11 09:49:30
Your offset time is: 2026-07-11 09:49:30