[HELP] How to compute a bounce angle

Hello!

I am making a shooter and my bullet bounce. I am using the physic to do this.

I have a preview of the trajectory on press and shoot on release, this works. The issue is that my trajectory stops at the first wall and I have no idea how to preview the bounce!

Here is my predict trajectory: Imgur: The magic of the Internet

I am quite new to the engine (few days) and I look up countless solutions that I either don’t understand, don’t know how to apply to my case or don’t work.

Thanks a lot :slight_smile:

I am not going to comment on your implementation, but you should consider using something other than ‘Tick’ to do this to improve performance. On to your question: The OutHit struct contains what you need. Use the Impact Point and Impact Normal to create your new trace.

Hey! Thanks for the answer; yes the implementation is bad and I should rework it true.

the solution gives me a static direction no matter where I aim: Imgur: The magic of the Internet

I try to have like a “pool” game display where you can see the bounces and all :slight_smile:
Thanks!

EDIT: Get Reflection Vector | Unreal Engine Documentation
Yep fixed lmao

Try it like so:

This would give up to X bounces as in the loop. We start at the yellow point.

Script to copy and clean up:

Looks pretty cool and way better than my “copy paste the same node”

Ill look into it!

1 Like

I wouldn’t bother with optimisation at this point. If a game of Pool is the goal, you can keep the whole thing on Tick and never look at it again. But maybe you’re going mobile with this and every tick counts!

If you had 100 actors doing 100 sphere traces across 100 huge pool tables, that’d would be a very different story. Here you’ll have a single loop several elements long.

The easiest way to optimise it is to place a Gate behind the Tick event. Open the gate only when the player adjust the angle or there are balls on the move. Otherwise, the last trace result is not stale and can be used to visualise the trajectory.

If you’re going to visualise it with spline mesh components, do note that this can get costly. Still unmeasurable and utterly negligible in this very instance.

Good luck!

Makes total sense, for now just enemies shooting at you and you can only fire one bullet by one and for pc. Just a side project to learn the engine!
Thanks!