Answers for "how to make character move unity"

C#
9

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));
    }
}
Posted by: Guest on June-30-2020
2

how to make character move unity

float horizontal = Input.GetAxis("Horizontal");
 float vertical = Input.GetAxis("Vertical");
 float speed = 5.0f;
 
 void Update(){
     transform.position = new Vector3(horizontal, 0, vertical) * speed * Time.deltaTime;
 }
Posted by: Guest on March-06-2020

Code answers related to "how to make character move unity"

C# Answers by Framework

Browse Popular Code Answers by Language