Getting a Projectile to bounce back after hitting a collision box but in a random direction.

Hello, I’m using unreal engine 5.1 and I’m making a VR star wars indie game but I’ve come to a hold where I cant seem to get the projectiles to bounce back in a random direction. Currently I have made it so the projectiles can bounce back when they hit my collision box that is attached to my lightsaber and that it just using an integer value of -1 but that’s only deflecting it in a straight line I want it to go slightly in a random direction.
The bullet is a seperate blueprint from the enemy AI and so is the lightsaber. i’m currently using the lightsaber for the integer value so when it hits the lightsaber it bounces back to the enemy.
If you have any screenshots or videos that you can show me that would be a big help thanks.

1 Like

Hi Rayden,

Take a look at the Blueprint function ‘Random Unit Vector Cone in Degrees’

You could input that ‘hit normal’ vector and then control how wide the cone is with that ‘Cone Half Angle’ variable. The node would then output a random direction that still lies within that cone.

Let us know how this goes / if you need any more help with this.

1 Like

Hey thanx for the relply, only just seen it. so i have the function but i dont know where to put it. Do you have an idea

You want to get a vector pointing from your ‘BulletSpawnLocation’ to the enemy. That would feed into the ‘Cone Dir’ then you’d use the output to for the Impulse.

You’d probably be working with a normalized (0-1) vector. So you’ll need to multiply it by a float before feeding it into the impulse node.