Movement Solutions
private float speed;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
MovementSolution1(h, v);
}
private void MovementSolution1(float h, float v)
{
Vector3 dir = new Vector3(h, 0, v);
rb.MovePosition(rb.position + dir * speed * Time.fixedDeltaTime);
}
private void MovementSolution2(float h, float v)
{
Vector3 movement = new Vector3(0, 0, 0);
movement.Set(h, 0f, v);
movement = movement.normalized * speed * Time.fixedDeltaTime;
rb.MovePosition(rb.position + movement);
}
private void MovementSolution3(float h, float v)
{
Vector3 movement = new Vector3(h, 0f, v);
movement = movement.normaliz