Sign in to follow this  
danharibo

Rays V. Physics

Recommended Posts

danharibo    122
I'm Using Ogre(Eihort) NxOgre(0.6) PhysX(2.7.0). I need to make weapons for my game, if they didn't need much accuracy, i would just use Rays, but this game need accurate Ballistics, so i can't just go in a straight line! So i'm not sure whether to create a physics object and use that with a collision callback, or to use a ray and move it down slightly based on the distance. Help!

Share this post


Link to post
Share on other sites
oliii    2196
If you want to model your bullets as a fast moving point in space, I'd suggest using small rays or segments. Point moves from frame to frame at a given speed, and you check for ray intersection from the point position, with the point velocity, up to the frame time. It should be more efficient than using a small fast moving body, and probably as accurate. You have also to consider that using a standard body for your bullet can mean that you will force the engine checking collisions between bullets if you are not careful, and that's a no-no.

It also depends on the engine capabilities and how well they handle ray intersection detection. They can also have implemented a special optimised 'particle' mechanism, that does the ray/segment thing, and provides you with all the callbacks you need.

Share this post


Link to post
Share on other sites
smitty1276    560
At first glance, there is no reason why you can't treat it similarly to a "ray". It's path would still be described as a parametric equation, but would be quadratic rather than linear. You could even throw in something to account for drag, if you wanted to.

It would, however, add a lot of complexity to intersection tests.

In the end, oliii's suggestion is probably the best approach. Using discreet linear segments, per frame, is probably much more efficient. If you have to pre-compute the point of impact, it may not be.

Share this post


Link to post
Share on other sites
You could use something like a swept sphere test, where the radius of the sphere represents a reasonable amount of ballistic arc for a segment. Depending on circumstances, you could do a few swept sphere segments to accomodate a larger arc. Then, if you got a hit within a given segment, you could do the piecewise linear ray testing that's been mentioned.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this