As said, rigidbody moves fine, even smoothly in the x axis.
Problem comes in on the y axis. Whenever the character goes up or down, it noticeably shakes.
Additional Info:
- Unity 5.6
- Using linear interpolation
- Mass is 5
- Linear Drag is 20
- Gravity is 0
- Angular Drag is 0
- Locked rotation on the z-axis
- Dynamic Rigidbody
No parent Object, not even a child
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMovement : MonoBehaviour { Rigidbody2D rbody; //Animator anim; public float speed = 0; /*SpriteRenderer sr; Vector2 movementVector; void Start () { rbody = GetComponent<Rigidbody2D> (); anim = GetComponent<Animator> (); sr = GetComponent<SpriteRenderer>(); }*/ void Update(){ //sr.sortingOrder = ((int)Camera.main.WorldToScreenPoint (sr.bounds.min).y) * -1; movementVector = new Vector2 ((Input.GetAxisRaw("Horizontal"))*3, Input.GetAxisRaw("Vertical")); /*if (movementVector != Vector2.zero) { anim.SetBool ("isWalking", true); anim.SetFloat ("inputX", movementVector.x); anim.SetFloat ("inputY", movementVector.y); } else anim.SetBool ("isWalking", false); }*/ void FixedUpdate(){ rbody.AddForce (movementVector * speed); }
}
I also noticed that changing the mass and linear drag affected the movement speed on the y axis but not on the x axis, and movement on the y axis is noticeably faster than on the x axis, which is why I multiplied the horizontal input by 3.