The question is answered, right answer was accepted
Vertical movement is greater than horizontal and diagonal movement
My vertical speed on the y axis is greater than the speed on the x axis and diagonals.
The code is under FixedUpdate:
Vector2 direction = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
if (direction.x > 0 || direction.y > 0 || direction.x < 0 || direction.y < 0)
{
direction = direction.normalized * playerSpeed * Time.fixedDeltaTime;
body.MovePosition((Vector2)gameObject.transform.position + direction );
}
What am I missing?
Thanks in advance
Gravity? Write this under declaration of vector direction to see in console the values:
Debug.Log("H - "+ Input.GetAxisRaw("Horizontal") + " V - "+ Input.GetAxisRaw("Vertical"));
Bye
H - -1 V - 0 H - 1 V - 0 H - 0 V - 1 H - 0 V - -1 etc
vertical 1 or -1 (H - 0) is about 0.3 times faster (moves faster up or down, covers more tiles in a shorter amount of time) than when, for example H - 1 V - 1 and vice versa and H - 1 or H - -1 and V 0.
gravity scale is set to 0 on the rigidbody
put a debu.log(direction) inside the tell us whats giving you when you move in the Y axis and in the X axis, if the direction is the same but in both directions the problem is somewhere else. also change that code from the fixedupdate to the updtae and change the time.deltaTime, leave fixedupdate to physics. you will have issues with inputs otherwise.
Follow this Question
Related Questions
Dash Movement Platformer 0 Answers
SteamVR Movement based on controller direction 0 Answers
Player Movement Freezes in Unity3D [Please help, no answers!] 1 Answer
How do i lerp player movement?,How to lerp movment 0 Answers
Moving simultaneously with UP LEFT, W D using GetAxisRaw. Rotating localScale to flip animation 2 Answers