unity rb controller
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class PlayerMovement : MonoBehaviour
{
private Rigidbody rb;
[Range(2,15)]
[SerializeField] private float horizontalSpeed;
[Range(2, 15)]
[SerializeField] private float verticalSpeed;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void FixedUpdate()
{
Vector3 nextPos = rb.position + (transform.forward * Input.GetAxis("Move X") * horizontalSpeed * Time.fixedDeltaTime) + (transform.up * Input.GetAxis("Move Y") * verticalSpeed * Time.fixedDeltaTime) + (transform.right * Input.GetAxis("Move Z") * horizontalSpeed * Time.fixedDeltaTime);
rb.MovePosition(nextPos);
}
}