Reflecting Angle of a bullet / bounce function using angles

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • 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.
    Please login to see this attachment.
    Thanks for the help

  • 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; Please login to see this link.

  • >> 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)

    a selection of my Fusion examples can be found Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!