So I am working on tweaking the blueprints from the marketplace item Generic Shooter to fit my current needs, which involve holding down the left mouse button to “charge” the projectile and increase the velocity or just the initial speed of the projectile. (it’s for a bow)
Currently when I fire it seems to only be taking the default speed/velocity and the projectile is simply dropping to the floor. The Fire (LMB) event is in the player character’s blueprints, and after some toying around with that and the projectile blueprints, this is what I have come up with.
The idea with this version is that it counts how long the mouse button is held down, then it should multiply the amount of seconds by 500 and make that the initial speed for the projectile.
Player Character BP
I’m not quite as experienced with this engine as I’d like to be so I assume I have made a few errors in here, so any guidance would be much appreciated. Apologies if the links are a bit messy and hard to follow in the first image.
i think this should work, but actually i suggest you to set the initial velocity instead of the max, since it’s an arrow it should start fast and fall instead getting faster while it’s in the air (like a missile), i also suggest you to avoid using tick, in this case this should not be a problem but using tick may cause you to have a heavy CPU load.
try the same code, but change the “initial speed” instead of the max speed and try to set the speed in the projectile’s “event begin play”(so it will be set when the projectile spawn)
I’ll take your advice on this when I get back from work today, as everything I see looks pretty much spot on, but the max speed is a variable name, I am changing the initial speed
Event Begin Play will be my first port of call, but can you see any reason as to why this isn’t changing the initial speed at all?
oh yah, just noticed you’re actually settings the initial speed, tried to replicate at my end, tried to change the initial speed at begin play and it had no effect, i have a theory, i think the “initial speed” variable in the projectile movement component is used just to apply the initial velocity but after this use the variable has no use at all, you can change it, but changing the variable won’t change the speed, my theory seems to be enforced by the fact that if you try to change the initial speed in the construction script (while the actor is being created) it actually works, but the problem for you is that you can’t get a reference to the player character from the construction script, i will try to find a workadound for you.
I would do this in a slighlt different manner. Instead of a tick, use function. Wiht LMB pressed use “set function timer by name” node - check looping and adjust the “tick” of the function. The function itself is really simple, just set velocity by multiplying previous value by 1.05 or something lower. On LMB released just pause the function.