using System.Collections; using System.Collections.Generic; using UnityEngine; public class CharMovementPhy : MonoBehaviour { private float horizontalInput; private float verticalInput; [SerializeField] private float velocity; private Rigidbody rb; void Start() { rb = GetComponent<Rigidbody>(); } // Update is called once per frame void Update() { horizontalInput = Input.GetAxis("Horizontal"); verticalInput = Input.GetAxis("Vertical"); } private void FixedUpdate() { rb.velocity = new Vector3(verticalInput * velocity, rb.velocity.y, horizontalInput * velocity); } }