Need to shoot projectile at an angle with variable power
I am wondering if it is possible to shoot a sphere projectile actor from a spawning actor in a specific angle (maybe the X axis rotation of spawning actor). I am trying to launch a ball up a track. I will acquire power amount from how long the fire button is held. Upon release of fire key I can spawn the ball and add an impulse though I am only adjusting Y and Z of vector input in Add Impulse node. Is there perhaps some other way to go about this.
In the current case I am only adding some Z value for upwards lift. Could I just calculate it roughly? The Z value would most likely always be lower even if the shot is launched at max power. I need it to launch into the angle of the track not bounce onto it.
Here is a small figure example of the behavior I'm seeking. Blue arrow is Z axis of cube, Green is Y axis.
asked Apr 30 '18 at 04:05 PM in Blueprint Scripting
Possible nodes you can use to get direction vectors:
Actor -> Get Actor Forward, Get Actor Right, Get Actor Up
Rotator -> Get Forward, Get Right, Get Up
(My Target location - My location)-> Normalize (if you wanted to aim at something).
If you want to get the local +Y of your "spawn actor" then it would be Get Actor Right. Remember you can also get the rotation of a bone or socket then get it's forward, right, etc too.
Just multiply that value times "shoot power" or whatever and use that as the impulse you add. You will effectivley shoot in that direction.
Oh yeah and in UE4 local Forward = +X, Right = +Y , Up +Z.
Follow this question
Once you sign in you will be able to subscribe for any updates here