Benvictus

PS4 Controller Script

May 27th, 2019
1,379
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PS4Script : MonoBehaviour {
  5.  
  6.     public Transform player;
  7.     public float speed = 5;
  8.  
  9.  
  10.     void Start()
  11.     {
  12.         player = this.gameObject.transform;
  13.     }
  14.  
  15.     void Update ()
  16.     {
  17.         if (Input.GetButtonDown("Square_PS4"))
  18.         {
  19.             Debug.Log("Square Pressed");
  20.         }
  21.         if (Input.GetButtonDown("Cross_PS4"))
  22.         {
  23.             Debug.Log("Cross Pressed");
  24.         }
  25.         if (Input.GetButtonDown("Circle_PS4"))
  26.         {
  27.             Debug.Log("Circle Pressed");
  28.         }
  29.         if (Input.GetButtonDown("Triangle_PS4"))
  30.         {
  31.             Debug.Log("Triangle Pressed");
  32.         }
  33.         if (Input.GetButtonDown("L1_PS4"))
  34.         {
  35.             Debug.Log("L1 Pressed");
  36.         }
  37.  
  38.         if (Input.GetButtonDown("L2_PS4"))
  39.         {
  40.             Debug.Log("L2 Pressed");
  41.         }
  42.  
  43.         if (Input.GetButtonDown("L3_PS4"))
  44.         {
  45.             Debug.Log("L3 Pressed");
  46.         }
  47.  
  48.         if (Input.GetButtonDown("R1_PS4"))
  49.         {
  50.             Debug.Log("R1 Pressed");
  51.         }
  52.  
  53.         if (Input.GetButtonDown("R2_PS4"))
  54.         {
  55.             Debug.Log("R2 Pressed");
  56.         }
  57.  
  58.         if (Input.GetButtonDown("R3_PS4"))
  59.         {
  60.             Debug.Log("R3 Pressed");
  61.         }
  62.  
  63.         if (Input.GetButtonDown("Options_PS4"))
  64.         {
  65.             Debug.Log("Options Button Pressed");
  66.         }
  67.  
  68.         if (Input.GetButtonDown("Share_PS4"))
  69.         {
  70.             Debug.Log("Share Button Pressed");
  71.         }
  72.  
  73.         if (Input.GetButtonDown("Playstation_PS4"))
  74.         {
  75.             Debug.Log("Playstation Button Pressed");
  76.         }
  77.  
  78.         Vector3 LeftJoystickDir = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
  79.         Debug.DrawRay(player.position, LeftJoystickDir, Color.green, 0.5f);
  80.  
  81.         Vector3 RightJoystickDir = new Vector3(Input.GetAxisRaw("PS4_HorizontalR"), 0, Input.GetAxisRaw("PS4_VerticalR"));
  82.         Debug.DrawRay(player.position, RightJoystickDir, Color.cyan, 0.5f);
  83.     }
  84. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×