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 multiple collisions

Author
Message
NickH
18
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 14th Apr 2010 23:23
Hi,

Today I added a projectile system to my game. The launching and collision works perfectly, but I need to be able to get exact collision coords to make sure a fast moving object doesn't explode slightly out of sync with the environment. Now this would normally be easy but I have a few ray casts, one of which is running all the time (the weapon). When I try and get the collision coords it's where the last ray hit and not where the projectile hit. I've put the collision data straight into variables after each ray casting/ collision check but the raycasting still seems to take over the results of the collision check. Is there a secret I'm missing to having multiple raycasting/ collision checks per loop?

I've used SC_groupCollision to check the collision and SC_getStaticCollisionX(),SC_getStaticCollisionY() and SC_getStaticCollisionZ() to save the collision coords.
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 14th Apr 2010 23:38
Have you tried SC_MultipleRayCast,Then to get the data you pass in the number of the collision eg SC_getStaticCollisionY(3) to get the third collision point along the ray,im sure there is a command that tells you how many collisions took place aswell,but as soon as you do another raycast of either type it will reset the collision list so you have to take them all and store them for use before the next raycast command is called.Hope this helps.
NickH
18
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 14th Apr 2010 23:40 Edited at: 15th Apr 2010 00:32
Hi

I've not tried multiple raycasts, but I don't want multiple collisions with any of my raycasts. I'm struggling to get the object collision data not the raycast. While trying to get the object collision data I get the main raycast data instead. if that makes sense

PS...I'm not using this for any kind of physics, just for projectiles. I'm using DarkPhysics for that.

Thanks

paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 15th Apr 2010 07:23 Edited at: 15th Apr 2010 08:43
if you are using SC_objectCollision(obj1,obj2) to detect the collision then they dont return any collision data through the Sc_getStaticCollisionx() commands,only the raycast commands do that.
As soon as you do a raycast command it will constantly reset this list with its its own collision info so any calls to Sc_getStaticCollisionx() will only return data from the last raycast command not from any collisions that took place.
The way i tend to check for object collision is to use a hidden dummy object,position it at the same position as the projectile,set object to object orientation then move the dummy object by the same amount as the projectile would move in a single loop,this prevents it from tunneling through things,next do a ray cast from the projectile to the dummy object.
This will give you the expected collision point if one would occur in the next loop.Unless the object is moving a lot between each loop it will be so close to its target that any remaining gap will be either un noticeable or hidden by an explosive effect.
This has the advantage of giving you the normal of the object hit so you can also place things like textured planes showing damage on the surface and orientate them to the correct angles.
NickH
18
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 15th Apr 2010 13:14 Edited at: 26th Apr 2010 21:56
Thanks Paul,

I think it's a little off that you can directly get the impact coords for a collision when it's so accurate with everything else. I've added a little ray cast which happens only on impact. I now have the collision coords. Thank god this was cured early on in the day. I now have all day to make the explosion

Login to post a reply

Server time is: 2026-07-26 12:32:45
Your offset time is: 2026-07-26 12:32:45