Id like to have a character walk forward, backwards and strafe sideways whilst the mouse pointer dictates what direction the character is facing.
How to allow a 3rd person character to face where the mouse is aiming
If you simply what the character to face the direction in which the mouse is pointing, take a look at the 3rd Person Blueprint Template and under the Blueprints folder for My Character, go to the Defaults tab and search for Pawn. Check the User Controller Rotation Yaw option and that will allow the pawn to face the direction the mouse is pointing.
Note: The character in this example doesn’t animate and rotate towards the camera, there would be a little more involved in this.
Hope this helps points you in the right direction (yes pun intended)!
Simply put your character as the Target for “Get Actor Location” and “Set Actor Rotation” and it will look at wherever your mouse is! I tested this as well to make sure it works.
If you don’t want debug lines to draw, then change the “Draw Debug Type” under “Single Line Trace for Objects” to “None”. As well, this Blueprint will only look at Static geometry (BSP brushes, etc.), so you may want to add more types to the “Make Array” node. Just click “Add pin” and select all of the things that you want to look at from the drop-down.
Not a problem! If I need to clarify anything in my Blueprint I’ll be happy to assist you.
Thank you so much guys. I tried Alexander’s solution first and that worked perfectly, all id need now is to create the strafe and walk backwards animations. Thank you ParralexLLC, ill try your solution too later.
Thanks so much! BUT… with my top down shooter game (WASD to move north, south, east, west) I needed the player to always face where the mouse was. This blueprint Parralex provided was a great solution! I had to add one more thing… a Break Rot and a Make Rot. This is because with the character would become inverted when mousing over tall objects. SOOOOO, Here is what I did to fix this! Hope it helps someone!
For future readers, the additions that he made (Break Rot and Make Rot) are isolating the Yaw, which is the angle on the X,Y plane (Pitch is for the Z plane, while Roll is not used). This makes sure that the character is looking parallel to the ground, while keeping the surface direction intact. This is perfect for Top-Down Shooters. For a Sidescroller, you would want to isolate the Pitch, although you would need to figure out the Yaw for the direction that you want to face (left or right).
Thank you Zortalas for your contribution, I’m sure it will be helpful to someone!
Thank you Wes for this simple solution using Blueprint. I cross posted your answer under my question about creating a 3rd person shooter perspective like Gears of War. It’s one step closer to what many of us are trying to create without c++ coding.
Hey. I tried the solution for top down view… If I’m using the “top-down blueprint” template, I should put that blueprint in the MyCharacter actor, right?
I did it and the character keeps looking to a fixed point in my level, not where the mouse is.
I’m attaching a screenshot of my graph. If anyone could point me at the right direction, I would appreciate it!
nevermind. found my mistake… the multiplier to the World Direction was set to 0.
Hi I was wondering how you got the Strafe InputAxis to work? I was trying this out and got the character to look at and follow the mouse with W, but am having problem with strafing around. Any help would be much appreciated
Hi, I’m very new to this, I’ve tried the above solution and my character still turns when I hit the S key. If I ever get this to work, will I have to make an animation to make his legs run backwards?