Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.18
more ▼

asked Nov 27 '17 at 09:04 PM in Blueprint Scripting

avatar image

11 1 3 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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).

more ▼

answered Nov 27 '17 at 11:54 PM

avatar image

11 1 3 5

avatar image pafin May 19 '19 at 03:57 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question