I have been at this for over a day now. I think I’ve checked and tried every single code I’ve found on google and still nothing.
I am making a top-down game. The player will be moving with WASD, however I want him to be looking at the mouse and not following it. All the scripts I found online rotate the player to where the mouse is but the controls follow the mouse.
For example, when the mouse is at the bottom of the screen the player is facing down. So far so good. When I press W the player then moves down as well. What I want to happen is even though he is facing down, when I press W I want him to move up.
I am using GetAxis with Horizontal and Vertical and then translating the player accordingly.
Please help 
2 Answers
2
Difficult to tell for sure without code, but the scripts you’re finding are likely using Transform.forward to move forward, which has the effect of moving the object in the direction it’s facing. Replace transform.forward with Vector3.up to move toward the top of the screen.
If that doesn’t help, we’ll probably need to see some of your code.
Try this…
function moveCharacter()
{
if(Input.GetAxis("Horizontal") < 0)
{
transform.position.x -= speed * Time.deltaTime;
}
if(Input.GetAxis("Horizontal") > 0)
{
transform.position.x += speed * Time.deltaTime;
}
if(Input.GetAxis("Vertical") > 0)
{
transform.position.z += speed * Time.deltaTime;
}
if(Input.GetAxis("Vertical") < 0)
{
transform.position.z -= speed * Time.deltaTime;
}
}
Transform.Translate is going to move the transform relative to the direction it is facing. By changing the components of the position directly, we can move exactly as you like.
Wow, I can't believe it was that simple. And I've wasted so much time trying to figure it out. Thank you VERY much!!
– mafamaul