Getting a Spawn Transform in the direction the player faces and the camera inclination

Hello !

As the title says, I am trying to spawn an actor (with SpawnActor node) giving him a Spawn Transform so that the actor goes in the proper direction. The context is quite simple : it is a fireball (projectile) the player sends away.

I would like to get a Spawn Transform in the same direction XY the player faces and to modify this vector so that the projectile goes upwards/downwards the same way the camera is inclined.

I achieved the first part (spawning projectile from the player in the direction he faces) without too much trouble. However I cannot figure out a way to just add a modification on the Z axis from the camera inclination without messing up the X and Y axis.

The blueprint I’ve got right now :

  • I think I might not use the proper method to get inclination of the camera (ConvertMouseLocationToWorldSpace seems odd to do that but that’s what I figured out).

  • Transform Rotation is (I guess) where everything messes up. Even though I put 0 in the scale for X and Y axis in Make Transform, the Transform Rotation still messes up the X and Y axis.

Does what I’m doing make any sense at all ?

Surely there is a much simpler way to just modify Z axis that I missed ?

The blueprint as showed above in video if you want to see it in action :

EDIT : to simplify the problem we assume we just want it to spawn from the player, not the hand of the player (I guess that translation in space shouldn’t be an issue)

have you tried just using the control rotation of the player camera for the rotation? it seems like you just trying to shoot a projectile from a place in front of the character toward the direction the camera is facing.

I just tried your version. It is so much simpler and understable and works wonders !! Thank you very much ! It is exactly what I was looking for :smiley:

Oh no there is a small problem it sends the projectile in the direction the camera faces, not the player I didn’t notice at first

I slightly modified your version to make it send projectile in the direction the player faces. I don’t know if I should modify the Right and Up vectors as well ? It works fine except that the angle upward/downward seems to be stuck between +45° and -45° and I can’t figure out why. But that’s a much minor problem.

Blueprint modified for anyone wondering :

wouldnt it be easier to use a make rotator then split the rot pin and just take the values you need instead of doing all the math? for example you could take the x and Z from the character which would control the roll and yaw of the projectile, then you could take the y from the camera to control the pitch.

I’m not sure to understand how to do what you are saying. Roll, yaw and pitch are a bit too abstract for me. I’ll try to look it up tomorrow. On another note, I did understand why it doesn’t go above 45°. I should normalize my vectors so that when inclination is high, translation on x and y decreases. I guess that is the math you say I could try to avoid.

you may actually need some math if you intend to from the characters hand via a socket.

but anyways the below picture shows what i meant. as for the roll pitch and yaw those terms come from flying planes and they are simpler than you may think. for roll imagine you do a cartwheel, your rolling your body to the side (for ue4 rotation on the X axis). pitch would be a somersault, your rotating your body in a forward or back direction(ue4 rotation on the Y axis). yaw would be like turning in place whilst standing (ue4 Rotation on the Z axis).

That is 100% what I was trying to achieve ! Thanks a lot ! If anyone new like me reads this and has trouble reproducing the BP, to get the Roll Pitch and Yaw in the GetActorRotation instead of a rotator, you have to right click on the rotator and choose “Split struct pin”. I couldn’t figure out how to reproduce the blueprint at first because of this.

I didn’t need to do math to spawn projectile from hand I simply added a socket on the middle finger and used that location (mid animation).

So the final version looks like this :

For anyone curious of seeing it in action here’s a video :


The only issue I see may be that the hand being off-centre it might be slightly odd to aim that way. I think I’ll just put the character off-centre so that the hand ends up in the middle where the cross aim would be when at mid cast animation. But that’s a whole other topic. The projectile is 100% good :> Thanks again for your help :smiley:

EDIT : forgot to clean up BP before taking the screenshot

also instead of the split struct pin you could have also dragged off the rotator pin and searched for break. that will give you a break rotator node. personally though i prefer the split struct pin as its a bit cleaner in this case.

Ok, didn’t know that, dully noted ! Thanks again :smiley: