Rigid body vibrating?
I'm having a problem where the interaction of my player with the ground is causing the player to vibrate constantly, bouncing up and down. I know the problem is generated from my click to move code which lerps the player to my mouse click, because if I remove the code things are find. I'm pretty sure the issue is that the player's collider is intersecting ever so slightly with the floor's and is continually getting kicked out every time it falls back in, causing the vibrating effect. My player's rigidBody is Dynamic with gravity and a frozen Z rotation. My floor's rb is static. I'm sure the fix for this is quick and I'm missing something silly, anyone have any ideas? public class MovePlayer : MonoBehaviour { public float speed = 1.5f; private Vector3 target; void Start() { target = transform.position; } void FixedUpdate() { OnClick(); } public void OnClick() { if (Input.GetMouseButtonDown(0)) { target = Camera.main.ScreenToWorldPoint(Input.mousePosition); //target.z = transform.position.z; } transform.position = Vector2.Lerp(transform.position, target, Time.deltaTime * 1f); } }
Your answer
Follow this Question
Related Questions
Replace Vector3.Lerp with something equivalent for rigidbody2D !! 1 Answer
Y-axis movement stuck. Help me please :c,Not Moving by pressing Button :C. Help me please 0 Answers
Rigidbody2D.MovePosition() doesn't do anything (but animations and transform.Translate() works) 0 Answers
Moving Items Across Screen Produces lag (build attached to show issue) 0 Answers