Download

2D Projectile Bounce/Ricochet

Hey all,

I’m new to development and working on my first project which is a 2D run and gun type game. I’m working on trying to get an enemy to be a projectile and continuously bounce off of the floor/walls/ceiling.
I’ve tried searching quite a bit and have tried dissecting the projectile blueprints in the First Person Template without any luck so far.

Currently I have a paper flipbook with a collision component and the projectile movement component spawning in at a location and traveling -500 X and -500 Z so that it is moving at a 45 degree angle. It has “should bounce” checked and my floor tiles have a collision box set as well, but I cannot figure out how to get the projectile to bounce off of the floor and continue in a 45 degree trajectory. It just flies straight through the floor.

Do I need to change the X and Z values every time it reaches the point of collision? Surely there’s an easier solution than this.

If it always needs to be 45deg you have to code it with line traces. Otherwise physics take over and you have no certainty the angle would be exact.

to code it, remove the projectile movement component and set the movement based on the time alpha on the ontick component.
forward vector x speed x delta time
The line trace hit result will tell you when to stop, and a little trig will be how you calculate the 45deg bounce/change of direction.

Okay, I’ll start doing some research on line tracing then. I was beginning to think it was something simple yet hard to figure out, like I need to use a sphere for collision rather than a box.

Thanks for your response.