Player Controls become inverted when colliding!!
Hi guys - So I'm working on a top-down shooter as a project for university. My player controls use the Unity Input Manager allowing them to move using WASD. This works no problem at all. However... Let's say for example I run into a wall or any other object my player controls become inverted! For example if I hit a wall, 'W' moves down and 'S' moves up instead :( I have no idea why this is happening - Any help at all is appreciated! :D
Here's my code:
public class CharacterController : MonoBehaviour
{
public float walkSpeed;
public float sprintSpeed;
void Update()
{
//Get horizontal and vertical axis from Unity Input Manager
transform.Translate(walkSpeed * Input.GetAxis("Horizontal") * Time.deltaTime, 0f, walkSpeed * Input.GetAxis("Vertical") * Time.deltaTime);
//Sprinting
if (Input.GetKey(KeyCode.LeftShift))
{
walkSpeed = sprintSpeed;
}
else
{
walkSpeed = walkSpeed;
}
if (Input.GetKeyUp(KeyCode.LeftShift))
{
walkSpeed = 4f;
}
}
}
Your answer
Follow this Question
Related Questions
How to specify forward direction for my character? 0 Answers
Setting the playerPrefab of network manager dynamically 1 Answer
How do I change the size in Input Manager? 1 Answer
Using new unity input system, camera movement is incredibly jittery. 1 Answer
Android Touchpad - Registering touch on whole screen 1 Answer