Saturday, May 17, 2014

RayCasting



I've been pretty busy this week with family over for my brother's high school graduation and haven't had a chance to upload many videos or work on my game.

I'm running into a problem with my game and collision detection.

From what I've I can tell is there are a few main ways of detecting collisions.  Up until this point I've been using discrete stepping.  Move objects from group A  at a certain speed along a certain vector.  Then check to see if objects from group A overlap objects from group B.

This is fine Unless the bullet moves more than the object's width in 1 frame.

The problem is with the second case. This happens frequently with projectiles in games eg: bullets In FPS games, or in any game with fast moving projectiles in that case.

Another way to to is to look at two trajectories and see if the objects would ever intersect,  Basically fire, calculate if they are going to hit, wait a certain time then proc a hit. This method is very processor efficient because the only thing you need to keep track of is a timer (if they are going to hit), but it does not account for objects that change their trajectory.

The final method I've found is raycasting.

"This uses linear algebra to determine whether a line representing body A's trajectory is intersected by another line representing the boundary of some other solid body B. "

http://gamedev.stackexchange.com/questions/22765/how-do-i-check-collision-when-firing-bullet

I need to use some modified form of raycasting to determine if the objects intersect.  Instead of ray's I need to use spheres,  although I may be able to get away with using a ray for the bullet instead of a sphere.

http://www.realtimerendering.com/intersections.html

Gotta read that site up.

I'll post a video next week when I have more work done.   Wish I paid more attention in calculus,  lol fml. Bet you didn't think video games were so hard to make.

Guess it's a good thing the courses didn't transfer..


No comments:

Post a Comment