I’m trying to make a simple 2D character controller, but with the following code the player falls extremely slowly! I’ve seen similar problems before, but I can’t seem to find a working answer. I know I could directly set rb.velocity, but I’m curious as to why this is not working. Any thoughts? Thanks!
using UnityEngine;
public class PlayerMotor : MonoBehaviour {
private Rigidbody2D rb;
private Vector2 vel;
private bool jumped;
private void Awake()
{
rb = GetComponent<Rigidbody2D>();
}
public void Move(float h)
{
vel = new Vector2(h, rb.velocity.y);
//transform.Translate(vel * Time.deltaTime);
}
public void Jump()
{
jumped = true;
}
private void FixedUpdate()
{
rb.MovePosition(rb.position + vel * Time.fixedDeltaTime);
}
}