Top down analog stick driven aiming

Hi Guys!

I have got my twin stick controls up and running only problems are:

  1. The rotation control is upside down, for example when I push up on the right analog stick it points the player down rather than up.

  2. When I return the controller to the starting position, it puts the player back to facing the way they started the level. So if the start facing the left wall they can move around but once they let go of the right stick it goes back to facing left, rather than just staying at its last position.

Here is the blueprint (only the part that controls the rotation)

Any help appreciated! (screens of blueprints preferred)

  1. You simply need to reverse the axis values. Multiply by -1 then connect that.
  2. Try adding relative rotation instead of set rotation.

Edit: actually there is no relative rotation function for this, use get control rotation, add the gamepad axis vector then use that to set control rotation.

Which node handles the multiplying? and I have the Get control there but I’m not sure of its placement within the graph.

I don’t have a controller to test it so I’m gonna base this on the image you posted but I would imagine it would look something like that.

I’m assuming that Y axis is the up down axis, if not then reverse the X axis.

Unfortunately neither of those have worked. The Multiply is just sending the Pawn crazy and making it twitch back and forth, and the get control rotation needs a target, I got an instance of the controller but it made no noticeable difference

Really stuck on what to do next…

Well, one way that strikes me would be to take your X and Y stick data and generate a vector. Then use a Find Look At Rotation node with your character’s location as the start, and your character location + your stick vector as the destination. Then toss out everything but yaw and slap it on the character.

Will give that a try when I get home later. who knew making a character rotate would be such a pain, got most other things setup with minimal resistance!

Anyone have any idea of how to make this in a similar way but by using the mouse to aim and rotate the character in topdown view instead of the gamepad? Similar to say Alien Swarm as an example

There is a project template ‘top down’ that uses that system - I suggest have a look at that, it has the feature you are looking for :slight_smile:

Yeah I have tried that but it doesn’t really use the mouse to aim/shoot, instead you click to move the character with the mouse, I have problems identifying where this is done in that example

Ok guys, We have rotation!! now the only thing left is point 2

Any ideas?

ok bumping this thread - turns out the rotation is causing issues - I’ve found through directly possessing the pawn that when the rotation goes through a certain 90 degrees (depicted below in red) the pawn view is actually rotating 90 degrees making the game world appear as if you were lying on the floor

081b7e4f37809a314f1a105e1e372123e4caed96.jpeg

essentially the X & Y of the right analog stick is creating a vector which then gets turned into a ‘rotation based on axes’ then sent to the controlled actor

any ideas what in the world could be causing that?

This is the blueprint if it helps at all, any help would be amazing, hit such a stumbling block because of this.

The problem might be on the ‘Make Rotation From Axes’ node - currently you are supplying (0,0,0) for Right and Up, but the node expects unit vectors for each input. Maybe try first using a Normalize node on the result of your MakeVector (to ensure its length is 1) and then use the ‘Rotation From X Vector’ node. You might also only want to change rotation if the input is non-zero. This is a rough sketch, have not actually tried it!


Sounds like a ‘twin stick shooter’ would be a good Template in a future release…

Ah looks like James beat me to it!

I was experimenting with it and this is what I ended up with.

Works nicely.

Oh my god they actually work! Amazing! Colours seem brighter now!! :stuck_out_tongue:

Can’t thank you guys enough - And James, a twin stick example would be so beneficial, simply because it seems setting rotation like that is so much more complex than other methods

now to sort out my projectiles! weeeeee!

Thanks guys I was going to start working on a twin stick shooter this week. This is good information

Hello my player seems to be off. When I push the right_stick in the up direction my player turns to the right and not straight up like I thought he would. I wonder do I have to offset this by 90 or something. Okay have a good day!!

Oh yea and why do we use Make Rot from X and no other axis?

im using set actor rotation method as described and everything works well apart from one glitch. when the right stick is released the actor resets to facing +X instead of remaining the the direction it was facing. Any Ideas?