 Thread: Reflecting Angle of a bullet / bounce function using angles

1. Reflecting Angle of a bullet / bounce function using angles

Hello all, recently I have been tackling a problem that I believe could have a simple fix, I could just be overthinking. Here it is:
I have a bullet flying at x angle, when it reaches an obstacle it has to reflect, (not the opposite angle apart from at 0,90 and 180 degrees). I have attached a picture for further explanation. Also i am not using inbuilt fusion movement so i cannot use the bounce function. I have come up with a few main inital bullet angles and then next to them put the reflection angle, from the graph there is no correlation.
Deflecting Bullets.png
Thanks for the help  Reply With Quote

2. its just math; collides with a vertical wall - negate the X, collides with horizontal - negate the Y. ie x= x* -1 on a vertical wall; y= y* -1 on a horizontal wall.
or use this formula −(2(n · v) n − v) explained here; http://www.3dkingdoms.com/weekly/weekly.php?a=2  Reply With Quote

3. thanks, how do i calculate the normal of an obstacle?  Reply With Quote

4. you can do it with detectors  Reply With Quote

5. Sorry not quite following  Reply With Quote

6. >> you can use detectors to test the "angulation" of the obstacle surface
i.e. two 1 pixel detector you would fastloop against the obstacle,
until they hit, and then calculate the angle between the two detectors
this is probably required if you have complex shapes, not just very simple straight surfaces/segments

if you can manage to use active objects as obstacles,
you could store some math information describing the surface directly in their values,
and i.e.

1) if you can store the obstacle surface segment vector x y components,
consider the normal vector to V(x,y) in 2D is simply the transpose coordinates with a inverse sign= N(-y, x)

2) if you don't have the obstacle surface segment vector, you can very simply obtain it from:
a) coordinates of any segment lying on the object surface: V.x=X2-X1, V.y=Y2-Y1
b) the object angle (again, assuming it is as simple as a segment, or a rectangle >> a "thick" segment): V.x=cos(angle), V.y=sin(angle)

3) if you have the object angle, you can also just add 90 degrees to that to directly have the normal vector: N.x=cos(angle+90), N.y=sin(angle+90)  Reply With Quote Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•