Using a better way to rotate the player character using Input Axis Turn

Hi, I have just almost finished with the Mars Marine tutorial, and I was finding it very frustrating how the mouse movement felt, and that when the character rotates using the mouse input, the keyboard mapping wouldnt feel inquisitive.

So now: No need for Mouse deadzone → No need for mouse smoothing → character keeps walking with ‘W’ Key pressed in the direction the character is face.

I thought I’d share the fix that I managed to find online after a lot of looking around, and its actually a lot simpler than the mouse input controls in this tutorial. Although the tutorial has taught a lot in this section! (Love these tutorials :D!!)


Screenshot 2022-11-09 210636
Screenshot 2022-11-09 210722

2 Likes

A lot of the times things like this will come down to personal preference. While I also think what was shown in the tutorial is not ideal for me personally, it does illustrate a way of achieving a result which may be useful for other things.
In a game like this, I like to move in the direction of the WASD keys while using my mouse to look around, but the mechanics do feel a bit off. Part of the joys of game dev really. Lots of trial and error. Finding a nice player controller is half the battle, and makes such a big difference to your game in the end.
I made a game with a similar player controller prior to starting this course. Similar to what you see in V-Rising, where there is a reticle on screen the player is always facing. I find having the visual aid helps with orientation, otherwise it’s hard to tell which way you are facing.

Here are my blueprints if you’re interested in having a look:

This function is called on tick:

2 Likes

I just wanted to make a follow up post as I spent most of today attempting to implement what I did in my other game into Mars Marine, mostly with little success until now. While the above are the blueprints I used in the other game, they do not work in Mars Marine in the same way, likely due to other settings elsewhere in the project. Hopefully I will cover everything here and will not have missed anything.

The first 2 sets of blueprints are in the player’s blueprint. Directional movement is simply this, with control rotation and get vectors removed. Update Player Aim does not need to be on tick. Using this will have the player move in the WASD directions, regardless of which direction they are facing.

Here is my Update Mouse Aim function, within the Update Player Aim function. This will have the player face the direction of the mouse cursor.

This function is what I have in my game mode blueprint coming off the event Begin Play. It is what displays a cursor (crosshairs) onscreen. Having a visual aid is just something I prefer in a game like this.
Notice I have both Set Input Mode Game Only AND Set Input Mode Game And UI. Weirdly enough, having Set Input Mode Game Only first is necessary if you want the crosshairs to display on begin play without having to click the mouse button. For whatever reason, you need to have Set Input Mode Game And UI next, otherwise your left mouse button will not shoot unless you click twice! :crazy_face:
Oh, and be sure to uncheck Hide Cursor During Capture. :wink:

I hope this helps anyone trying out different ways of controlling the player. I felt like I wanted to update my previous post when I realised those blueprints don’t work as intended for Mars Marine.
Happy Game Deving! :grin:

3 Likes

The method we use in the course simulates the mouse as if it were a joystick, and that the direction you move the mouse is the direction you would like to be facing.

I don’t believe it’s the best solution either for mouse-based aiming in a game like this but I thought explaining the logic behind it would help.

3 Likes

I think the information in the lecture is fine since we are learning about principles that can be applied to all kinds of things. Some of those nodes wouldn’t be obvious to most people unless they had a degree in mathematics. :wink:

Wow thanks!

No problem! It’s good to try out different ways of doing things. UE 5.1 apparently has a new player input system which may improve things even more. :pray:

1 Like

Yeah I’ve been playing around with it for a project, it’s interesting.

I haven’t tried it yet, but the way things are set up now with 5.1 might make for an easy way to create a player controller plugin. Even though it’s trivial, no more setting up player controllers. Just import your plug in and away you go!

One of the potential things you can do with this new system is creating isolated control schemes for different situations.

Using a first-person shooter as an example. I could have an input context for being on foot and then set a different context when the player decides to hop into a vehicle like a tank or plane.

I must say perfect timing! I was thinking of trying to do a project like that myself (I was trained as a tank driver during my conscription) and to hear that’s relatively easy to do? My idea was to have FPS elements and also the view from the commanders perspective which means giving orders etc. I can only imagine it being a bit of a hassle to implement, especially if you want controller support. Damn UE 5.1 and 5.2 or whatever it is with those new features like map generation seem exciting!

Privacy & Terms