Question by
TheFreeman98 · Oct 16, 2020 at 04:48 PM ·
game development
My character slides without me pressing any button
Here's the thing. I import the character model, set the corresping configuration on the Rigidbody2D (like Gravity Scale to 0 and so) and everything works just fine. The Character stays still.
When I try to add movement to the character is when the problem starts. The character moves but it just keeps sliding down. The Gravity Scale is set to 0 and i even tried turning the gravity all together but it just keeps sliding down. Here's my code:
public float moveSpeed = 5f;
public Rigidbody2D rb;
Vector2 movement;
void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
}
void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
Comment