Modifying speed of ProjectileMovement component after spawn

Is it possible to modify the InitialSpeed (or otherwise make it move) after a ProjectileMovement component comes into existence in the game?

My project has a projectile (an arrow), that exists in the world before its “fired”, and I want the speed at which it travels to be variable on how far back the player draws the bow. If i set the “Initial Speed” variable in the ProjectileMovement component’s default settings, it flies off just fine (the component has auto-activate disabled, and I trigger it at the right time with an Activate node), so I am pretty sure everything as far as the arrow actor, as a projectile, actually works.

However! I want to modulate the speed of the arrow. So, I’m setting “initial speed” to be whatever the desired speed is (I’ve confirmed the value i’m feeding it is, in fact, good and correct) and then activating the component; this is where my problem is. It seems that it ignores any value set via blueprint, and going with whatever the default value is. Leaving the default at 0 just causes the arrow to unceremoniously drop to the ground, ignoring whatever value I set via blueprint.

I’ve also tried to create a ProjectileMovement component on demand, but it seems to behave in the exact same way. Perhaps it only cares about “Initial Speed” the moment the component comes into existence and setting it after is meaningless?

Has anyone else got the ProjectileMovement component to work with a variable speed after it already exists in the world? Or is there any other way to change the velocity of a ProjectileMovement component after it’s come into existance?

Solved it on my own! It turns out on top of my original issue, just setting the Initial Velocity was sending the projectile on the world X axis regardless of whether or not the “Initial Velocity in Local Space” was set to true. I was tying to find a better way to launch the projectile, when I discovered the “Set Velocity in Local Space” function of the ProjectileComponent. It takes a vector input, so I just made a vector using my calculated speed for the X value, and not only did it fix the issue of where the projectile was going, it also launched it at that velocity after the component was created!

Also, for anyone else who is trying to do something similar, It doesn’t appear to be able to work twice; IE if I wanted to launch the same arrow twice, it wouldn’t work unless I created a new ProjectileComponent on the fly to deal with it (I also deleted the old one, but I don’t think would prevent the new one from working).

2 Likes

Thank you so much. I tried so many ways to alter the speed.
I even let the projectile movement component spawn deactivated, changed the initial speed in real time and activated it, but it would launch with its original value. Nothing helped.

Hey there, I’m currently facing the same issue and I’m not sure how to set up the vector input for the “Set Velocity in Local Space” function so that it doesn’t keep firing in the world X axis. If you could help, that would really be appreciated.
Thanks.

It’s been a while since I played with this BP, but here’s a screenshot of relevant part:

It looks like it’s straight up local space, so with X being the forward axis, i’m just taking my pre-calculated speed and feeding it into the x value of a 3vector, leaving the other 2 axis at zero.

Hope this helps!

edit: oopsie, meant for this to be a reply to Efigr.

Thank you so MUCH!!!
This also is by the best solution when you’re soft loading. All other solutions didnt work for me this did!!!

1 Like