# Lazer Collision detection...

This topic is 2812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey
So, in my project, the AI are shooting lazers to the player(an ellipsoid).
What is the way to know if the lazer is actually shooting at the player??
I thought of making an AABB for the lazer but the didn't go well because it showed collisions when the lazer wasn't near the player.
Should i make a cylindrical Bounding Shape instead?? if so, what is the intersection test between a cylinder and an ellipsoid??

##### Share on other sites
Hey

Is it possible to use a line intersection for the laser?
if so you could simplify the intersection test to sphere vs ray and just limit the intersection to the length of the line.

if you transform the ray by the inverse of the sphere matrix you can test for ellipsoid aswell.

Intersection between sphere and ray can be googled and its a very simple test.

##### Share on other sites

Hey

Is it possible to use a line intersection for the laser?
if so you could simplify the intersection test to sphere vs ray and just limit the intersection to the length of the line.

if you transform the ray by the inverse of the sphere matrix you can test for ellipsoid aswell.

Intersection between sphere and ray can be googled and its a very simple test.

I thought of this, but my lazer is more like cylindrical shape with a radius of 0.5 rather than a ray...
Just one thing, by the sphere matrix you mean the matrix consisting of the right,up,look vectors(x,y,z), right??

##### Share on other sites
Yea I mean the transformation matrix for the sphere

##### Share on other sites
We use GJK for collision.

We typically search for the closest, or a sufficiently close solution.

In your case we would be ray casting against the convex shape (the ellipsoid). The ray being the center of the laser.
We would solve for the closest solution. This would be a point on the laser ray that was as close to the ellipsoid as possible.

If that point was not more than the laser's radius away from the ellipsoid then it would be considered a hit.

This is basically the method:
http://www.continuousphysics.com/ftp/pub/test/physics/papers/jgt04raycast.pdf

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 11
• 9
• 24
• 45