how to make a character move in unity 3d

Code Example - how to make a character move in unity 3d

                
                        how to make your player move in unity
                    
                
 

unity move character

                        
                                using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    [SerializeField] private float speed = 5.0f;

    private void Update()
    {
        var horizontal = Input.GetAxis("Horizontal");
        var vertical = Input.GetAxis("Vertical");
        transform.Translate(new Vector3(horizontal, 0, vertical) * (speed * Time.deltaTime));
    }
}
                            
                        
 

Related code examples