Rigidbody.moveposition rigid body movement

using UnityEngine;

public class PlayerContrller1 : MonoBehaviour 
{
    private Transform mmTransform;
    private Rigidbody mmRigidbody;

    
    void Start ()
    {
        mmTransform=gameObject.GetComponent<Transform>();
        mmRigidbody=gameObject.GetComponent<Rigidbody>();
    }
    void Update ()
    {
        PlayerMove();
    }
    //Method

    private void PlayerMove()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        Vector3 dir = new Vector3(h, 0, v);
        mmRigidbody.MovePosition(mmTransform.position + dir * 0.2f);
    }
}

Input input key settings.

Upper menu bar: edit=>Project settings=>input

Similar Posts: