Dynamically setting the initial speed of a projectile via construction script?

Hey everyone,

In my game, my character can equip a bow and arrow. What I want to do is the further you pull back the string, the faster the arrow projectile goes when you release. The strength of the pull back is a simple float that is handled in the character blueprint. What I want to do is cast the arrows construction script, where I can set the initial speed of the ‘projectile movement component’.

Problem is, the ‘get player character’ node that I have to plug into the cast for it to work is mysteriously missing, as well as ‘get player controller’. Why don’t these show up in the construction script? I tried working around this and simply setting the initial speed in the event graph set up to an event tick, but it just doesn’t work that way, it has to be set up in the construction script. But I seemingly can’t cast there with the nodes I normally use to set up a cast because they are gone.

What do I do? How do I get a cast to work in the projectiles construction script? Is the construction script even the correct way of handling it?

The reason you cannot use the nodes you are use to using is that the construction script is meant for when an object is made, and there usually is no player data during this time, try using these nodes and casting during the Event Begin Play.

Will the begin play fire when the arrow blueprint is spawned? Or when the map starts? The float that determines the speed of the arrow is set right before the arrow is spawned, not at the beginning of the level.

Also, I did a test, and when you expose the ‘set initial speed’, or ‘velocity’ in the event graph, it will not change the default value. It will only work in the construction script so I need to find a way to set it there, or find a completely new and different approach to solving this problem.

The ‘Event Begin Play’ is fired when the arrow is spawned, and when the event fires, you can cast to your player and retrieve the speed that you want the arrow to use.