Answers for "unity movement wasd c#"

C#
0

unity movement wasd c#

using UnityEngine

public class Example : MonoBehaviour
{

public float speed = 10;
public Transform object;

	public void Update()
	{
    	float horizontalInput = Input.GetAxis("Horizontal");
    	float verticalInput = Input.GetAxis("Vertical");

    	Vector3 movement = new Vector3(horizontalInput, verticalInput, 0);
    	movement = movement.normalized * speed * Time.deltaTime;

    	object.transform.position += movement;
	}

}
Posted by: Guest on February-12-2021

C# Answers by Framework

Browse Popular Code Answers by Language