Top Down Mouse look with pitch

Hello, Just asking for some advice on how I could go about adding pitch to a top down project.

Im trying to achieve my character able to shoot up and down depending on the height of an object or say terrain in the level. Im thinking I could go about adding a cross hair to the mouse position and setting a target for the player to use the node :" Look At Location", with that said, I’m not too positive that it would work out as I would want it to since I would be shooting at say other players, and AI.

I’d appreciate any tips on what others would do in this situation or if this is the route I should take in regards to this project and problem I am facing.

So far I have a normal top down mouse look project, but it just seems to streamline in regards to the levels having to be flat and not having any hills or buildings the characters and AI can climb onto and shoot down or up.

I think in a top down project, your mouse X and Y are likely already occupied with moving your cursor north, south east west…

So I’m guessing you’d like the pitch of your aiming to automatically vary according to the height of the actor that is being aimed at on a 3d map? (which is certainly achievable, I’m just trying to understand your objective before going into detail)

Yeah, what I’m trying to achieve is; say a character is higher in altitude, say standing on a hill, if I move the mouse to the character or up that hill. I would like for the players pitch aim offset to move accordingly to the height of the hill.

So I’m short yes what you described is what I would like to have happen in my project :slight_smile:

Yes, as you say… you’d use Get Look At Rotation node which would allow you to set the yaw, pitch of the units aiming at the crosshairs.

For the crosshair, you could use:

Get Actors under Mouse node and get the actor location (the units would always aim at the pivot of the actor, but you could offset this upwards if you like)
Or just send a trace directly from the crosshair location screen, wherever the trace hits something… you have a location… (you could use refine this using Casting to ensure that you are targeting only enemy units and not friendlies, or the ground)

But, I’ve tried setting up what you said and the character just jitters out of control. Obviously I have to hook up the exec pin but just have it disconnected for now.

for now, I’d suggest simplifying it…

The reason it doesn’t work is that setting Set Actor Rotation twice, and the second node is superseding the first node. What I’d do to prove the concept, is to use:

  1. just the first Set Actor Rotation node.
  2. plug the whole rotation into it (not just the yaw)

Depending on how your player character is controlled, there might be an issue with Control rotation Vs Actor rotation. This isn’t an issue with your BP but with how your character is setup… if the problem persists after making the above changes, try using Set Control Rotation instead of Set Actor Rotation. I’m fairly sure that, if a pawn uses Control Rotation, it utterly ignores Actor (world) Rotation.

As you understand, in the long run, understanding how your pawns are controlled and setting them up optimally for your specific needs will really be helpful.

So actually, how can i achieve this? The answer above is not a solution per se. My controller is restricted to Yaw rotation, as i want is to be.

But i want to have yaw AND pitch only on the crosshair, aka on the trace from my character to the enemy/model.

So in short : character - yaw, crosshair - pitch and yaw. How can i do it?

Thanks