IsPointInBeam?
#1

Basically what I'm trying to do is detect if a player gets killed by the rockets from a hunter/hydra. To do this, I want to project a sort of 'beam' in the rockets' path, and if any players are in that beam when they die (well, in the beam when the rockets were fired) (whilst in a vehicle), it will be detected.

The beam will have to have a variable width (radius of about 2 units/meters?)

Here's an illustration:

It's rather big - if it doesn't fit on your page click here http://www.puu.sh/3jR2a



Not sure how to go about doing this. Any help appreciated greatly.

So basically, IsPointInBeam.


Also, the beam will have to be 'attached' to the vehicle, responding to all the rotation also. When a player dies, it will check all rockets fired in the area, and the beams for those rockets (stored in memory) and if the player is in any of the beams, it's detected, so the beams have to be 're-created' after the vehicle has moved. So quaternion angles need to be used to get the beam's position relative to the vehicle's position AND ROTATION.
Reply
#2

I think this is the concept your looking for

http://en.wikipedia.org/wiki/Line%E2...e_intersection

Consider the beam just a line with it's radius determined relative to the radius of a sphere in which the line will intersect.
Reply
#3

I don't want a sphere - I want a cylinder.
Reply
#4

It's the same thing (sorta)

"Consider the beam just a line with it's radius determined relative to the radius of a sphere in which the line will intersect."

I think your getting the visualization wrong, you don't need a cylinder you need a line, the sphere makes the line cylindrical. The sphere is your TARGET point when that is moved around it would form a cylindrical collision if you plotted it enough times.
Reply
#5

good luck, i think you'll need it

Hoping someone will answer.. lol
Reply
#6

Let's say your beam has a x, y, and z lenght (also called vector), and since vectors are freely movable, you need to define your current position, by creating a linear function made of vectors.
(my x, my y, my z) + s * (lenght x, lenght y, lenght z)

Now this function tells you that you have a three dimensional finite line, fixed at some position in a coordinates system, and it is stretchable. Making s infinite makes the whole line infinite long, anyway.

Try to handle some object as a sphere, and since a sphere has a center point and on every side the same radius, you can determine the closest approach of your "beam" to the single point (center of the sphere).

Now we have to allocate, where the vector from the center of the sphere points meets our beam function and what direction it has to go to meet actually our beam function.

We can create a line from our position to the center of the sphere (object) and define it as a vector and use the first vector we know from our beam function, we can create a normalized vector using 2 vectors in a three dimensional space (vector cross product). Now we create a normalized vector using our generated normalized vector and the vector known from our beam function.

Great, this vector now can be transformed into a line function, giving it the start position at the center of the sphere and creating an equation to detect how long your line from the center of the sphere to our beam function has to be, to cross it. The now known variable "s" can be used to calculate the vector, using only the line function from the center of the sphere to the cross point of our beam function, throwing away the starting position values and have a proper vector, which describes how long it is and what direction it goes. We can simply calculate its real lenght using Pythagora's equation sqrt(aІ + bІ + cІ) = d and you will get the actual closest distance from the center of the sphere to the closest approach. If your result equals or is smaller than your sphere radius size, your beam crosses your sphere (hit) else it does not (no hit).

Edit: There is a much faster way to compare sizes without using square root at all,
ResultІ should equal or be smaller than radiusІ to detect it as a hit.
resultІ <= radiusІ
instead
sqrt(resultІ) <= radius
Reply
#7

Quote:
Originally Posted by [uL]Pottus
View Post
It's the same thing (sorta)

"Consider the beam just a line with it's radius determined relative to the radius of a sphere in which the line will intersect."

I think your getting the visualization wrong, you don't need a cylinder you need a line, the sphere makes the line cylindrical. The sphere is your TARGET point when that is moved around it would form a cylindrical collision if you plotted it enough times.
Listen to what they say about spheres, remember they might not explain the looping part, but you need to loop.

MP2 he is right, let me show you what he means... (instead of trying to think about your street or class logic, listen to the real facts)



MP2 for us to make this right for you, you need to have a base code we can work on, show us what you want to do with the code.
Reply
#8

So you're saying do this:

http://www.puu.sh/3jTBS

(But closer together)
?

Surely's there's a better way than this..? A 'proper' way? Line of sight..

Also, what about the offsets with the quaternions?
Reply
#9

Use a sphere as the player's position.
That equation checks to see if the cylinder (path of the rocket) goes through a sphere (the player's position).
Reply
#10

Quote:
Originally Posted by Kreatyve
View Post
Set the players as the sphere to detect if the player is being targeted by the hunter.
So how do I do that..? Okay so I had it backwards, the hunter projects a line and the player is a sphere. So how do I go about detecting that?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)