Advertisement
Huntrt

Key Manager Usage Sample

Jan 5th, 2023 (edited)
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.41 KB | Source Code | 0 0
  1. using UnityEngine;
  2.  
  3. public class UsageSample : MonoBehaviour
  4. {
  5.     void Update()
  6.     {
  7.         //Empty input direction
  8.         Vector2 direction = Vector2.zero;
  9.         //Set direction base on when press key of action
  10.         if(Input.GetKey(KeyManager.i.Up)) dir.y = 1;
  11.         if(Input.GetKey(KeyManager.i.Down)) dir.y = -1;
  12.         if(Input.GetKey(KeyManager.i.Left)) dir.x = -1;
  13.         if(Input.GetKey(KeyManager.i.Right)) dir.x = 1;
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement