RichTufty
22-05-2008 16:21:55
Hi,
I'm wondering if anyone can help or point me in the right direction. I'm currently using a normal raycast to detect bodies in from of my player which works perfectly. But I would like to be able to detect bodies which are not in a direct line from the player's position (straight line of sight). For example: say I have a weapon that is represented by a particle system that is constantly emitted in front of the player that is like a liquid projectile. I would like to know if the particle system has collided with a body and the position in world space of where that happened. I don't want to add a physics body to every particle being emitted, because i think this would be too costly.
I was wondering if you could have a Ray that wasn't a straight line, but a curved line? If not then what would be the best approach?
I tried to draw a diagram to show you different ideas I had:

the black curved line is the ideal line I would like to detect if a body has intersected with it. The red dotted lines are straight RayCast lines.
a) This is what i have already without changing anything. Straight line raycast which isn't really any good.
d) is the ideal curved RayCast line, if something intersects then I could get the distance along the curved line and know it's world position.
if I can't achieve d) then b) and c) are different approaches...
b) I could fire several rays at different angles from the player and detect if anything is intersecting with the curved line, this is very inaccurate.
c) I could have 3 or 4 raycasts that are roughly along the same curve and detect if anything has intersected that way. It's not 100% accurate but I'm sure it would be pretty good for what i would like.
Any help, advice or ideas on how to approach this problem would be much appreciated!
Tufty
I'm wondering if anyone can help or point me in the right direction. I'm currently using a normal raycast to detect bodies in from of my player which works perfectly. But I would like to be able to detect bodies which are not in a direct line from the player's position (straight line of sight). For example: say I have a weapon that is represented by a particle system that is constantly emitted in front of the player that is like a liquid projectile. I would like to know if the particle system has collided with a body and the position in world space of where that happened. I don't want to add a physics body to every particle being emitted, because i think this would be too costly.
I was wondering if you could have a Ray that wasn't a straight line, but a curved line? If not then what would be the best approach?
I tried to draw a diagram to show you different ideas I had:
the black curved line is the ideal line I would like to detect if a body has intersected with it. The red dotted lines are straight RayCast lines.
a) This is what i have already without changing anything. Straight line raycast which isn't really any good.
d) is the ideal curved RayCast line, if something intersects then I could get the distance along the curved line and know it's world position.
if I can't achieve d) then b) and c) are different approaches...
b) I could fire several rays at different angles from the player and detect if anything is intersecting with the curved line, this is very inaccurate.
c) I could have 3 or 4 raycasts that are roughly along the same curve and detect if anything has intersected that way. It's not 100% accurate but I'm sure it would be pretty good for what i would like.
Any help, advice or ideas on how to approach this problem would be much appreciated!
Tufty