Advertisement
leomovskii

PlayerMovement

Oct 23rd, 2024
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.36 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class PlayerMovement : MonoBehaviour {
  4.  
  5.     public float speed = 0.02f;
  6.  
  7.     // Update is called once per frame
  8.     void Update() {
  9.         float x = Input.GetAxis("Horizontal");
  10.         float y = Input.GetAxis("Vertical");
  11.  
  12.         Vector3 move = new Vector3(x, y, 0);
  13.         move.Normalize();
  14.  
  15.         transform.position = transform.position + move * speed;
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement