Advertisement
SatyamBhatt

Rewired Basic implementation

Feb 5th, 2025 (edited)
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | Gaming | 0 0
  1. using Rewired;
  2. using UnityEngine;
  3.  
  4. public class RewiredTest : MonoBehaviour
  5. {
  6.     private Player player;
  7.  
  8.     // Start is called before the first frame update
  9.     void Awake()
  10.     {
  11.         player = ReInput.players.GetPlayer(0);
  12.     }
  13.  
  14.     // Update is called once per frame
  15.     void Update()
  16.     {
  17.         //Input for Left Stick
  18.         float horizontal = player.GetAxis("Move Horizontal");
  19.         float vertical = player.GetAxis("Move Vertical");
  20.  
  21.         //--------- Input for Joystick --------------
  22.         if (new Vector2(horizontal, vertical) != Vector2.zero)
  23.         {
  24.             //DO SOMETHING
  25.         }
  26.  
  27.         //--------- Input for D-Pad --------------
  28.         if (player.GetButtonDown("Up"))
  29.         {
  30.             //DO SOMETHING
  31.         }
  32.         if (player.GetButtonDown("Down"))
  33.         {
  34.             //DO SOMETHING
  35.  
  36.         }
  37.         if (player.GetButtonDown("Left"))
  38.         {
  39.             //DO SOMETHING
  40.         }
  41.         if (player.GetButtonDown("Right"))
  42.         {
  43.             //DO SOMETHING
  44.         }
  45.  
  46.         //---------  Input for Buttons --------------
  47.         if (player.GetButtonDown("Trigger")) //Down
  48.         {
  49.             //DO SOMETHING
  50.         }
  51.         if (player.GetButton("Trigger")) //Held
  52.         {
  53.             //DO SOMETHING
  54.         }
  55.         if (player.GetButtonUp("Trigger")) //Up
  56.         {
  57.             //DO SOMETHING
  58.         }
  59.     }
  60. }
Tags: Rewired
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement