How to make Projectile bounce sometimes but not all the time

I was wondering if someone can point me in the right direction.

Currently my projectile bounces everytime it hits a wall or object before being destroyed by Inital Life Span. I wanna make it to where if I shoot 5 times at a wall, it may or may not bounce once out of the five shots and the other 4 shots get destroyed. Randomly of course.

Something like this?

The one above some what worked, it bounced more often than not which is the opposite of what I was wanting. I thought this new one made more sense but it no longer works. I’m gonna take a break and come back to it.

Any thoughts?

Create two projectile classes. One that bounces and one that doesn’t. Randomly choose which to spawn per shot.

Or On spawn randomly disable bouncing.

It’s a lot easier if you use Projectile Movement Component. It has a bounce toggle.

Branch (If rand(1-5) == 1) { enable bounce}

The bool is set properly on the projectile movement, maybe just add a branch with destroy actor after your add impulse node, or a small (0.1 Sec) delay then destroy actor after setting should bounce to let your add impulse take effect.

mhm, bool with weight:

332331-screenshot-1.jpg

That was pretty much what I was trying to do but didnt know what nodes to use.

So it works if I plug it directly into the Event hit, but why wont it work plugged up like this? Is it the ‘Is Simulating Physics’ thats causing it to not work? I’m unsure.

Update, as I was looking at the screen shot and folloing the blueprint spaghetti I figured it out.

I forgot that the ‘Is simulating physics’ is for the other object the projectile hits. If I add the ShouldBounce before that branch it works like it should. Thank you guys very much.

Working Blueprint

Is there a way to still run it off Event hit? While this cleaner (I perfer it this way as well) I lose the event hit that adds random bounces. Sometimes itll bounce once, twice, or three times before intial life span ends it.

I could turn it into a fucntion duh

This way, if bounce is set to false it destroys the actor on impact while still running the rest of the blueprint to add impulse.

I’ll just add this is better (feels cleaner) handled in the Constructions Script of the projectile:

332358-screenshot-1.jpg

But if it works fine as is, you’re good.

Makes sense. You will want to adjust it to your needs.


One note here, since you mentioned simulating physics on a projectiles movement component. You can’t have both at the same time:

Normally the root component of the owning actor is moved, however another component may be selected (see SetUpdatedComponent()). If the updated component is simulating physics, only the initial launch parameters (when initial velocity is non-zero)will affect the projectile, and the physics sim will take over from there.

In short, in most cases, you do not want to simulate physics on the Projectile Movement Component separately. The component itself does the heavy lifting here.

So if you ever run into any inconsistent behaviours - that could be the culprit.

Good luck with the rest.

I’d set it in the Construction Script and decide what to do when it hits:

332359-screenshot-2.jpg

Should work. Fingers crossed!

Ah, that makes sense.

Did not know that.

But when I say simulating physics its not the projectile that has the physics but the object it hits (If physics are enabled) So If I shoot an object that has physics enabled, it will move.