Advertisement
mew_fi

inputstuff

Jan 27th, 2022
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.53 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.XR.Interaction.Toolkit;
  5. using UnityEngine.InputSystem;
  6.  
  7. public class InputStuff : MonoBehaviour
  8. {
  9.     public ActionBasedController ABController; // Access the action based controller and its input
  10.     public Transform PoseMaker;
  11.     [HideInInspector]
  12.     public Transform PoseCube, PoseYaxis, PoseXaxis, PoseZaxis;
  13.     Transform PoseYpositive, PoseXpositive, PoseZpositive;
  14.  
  15.     // custom input properties
  16.     public InputActionProperty input_triggerAnalog;
  17.     public InputActionProperty input_thumbForce;
  18.     public InputActionProperty input_move2D;
  19.     public InputActionProperty input_gripForce;
  20.     public InputActionProperty input_gripFingers;
  21.     public InputActionProperty input_primaryPress;
  22.     public InputActionProperty input_secondaryPress;
  23.     public InputActionProperty input_velocity;
  24.     public InputActionProperty input_angVelocity;
  25.  
  26.     float PoseCubeScale;
  27.  
  28.     [HideInInspector] public float triggerAnalog, thumbForce;
  29.     [HideInInspector] public Vector2 move2D;
  30.     [HideInInspector] public Vector3 velocity;
  31.     [HideInInspector] public Vector3 angularVelocity;
  32.  
  33.     [HideInInspector] public Vector3 position;
  34.     [HideInInspector] public Quaternion rotation;
  35.  
  36.     [HideInInspector] public float gripForce, gripFingers, primaryPress, secondaryPress;
  37.  
  38.     private void Update() {
  39.         // read input into the variables
  40.         triggerAnalog = input_triggerAnalog.action.ReadValue<float>();
  41.         thumbForce = input_thumbForce.action.ReadValue<float>();
  42.         move2D = input_move2D.action.ReadValue<Vector2>();
  43.         gripForce = input_gripForce.action.ReadValue<float>();
  44.         gripFingers = input_gripFingers.action.ReadValue<float>();
  45.         primaryPress = input_primaryPress.action.ReadValue<float>();
  46.         secondaryPress = input_secondaryPress.action.ReadValue<float>();
  47.         velocity = input_velocity.action.ReadValue<Vector3>();
  48.         angularVelocity = input_angVelocity.action.ReadValue<Vector3>();
  49.         position = ABController.positionAction.action.ReadValue<Vector3>();
  50.         rotation = ABController.rotationAction.action.ReadValue<Quaternion>();
  51.        
  52.         //PoseCube.localPosition = new Vector3(move2D.x * 0.09f, 0, move2D.y * 0.09f);
  53.  
  54.         // PoseCube.localScale = Vector3.one * PoseCubeScale + Vector3.one * PoseCubeScale * 2 * thumbForce;
  55.        
  56.         // PoseZpositive.localScale = Vector3.one * (1 + triggerAnalog);
  57.         // PoseYpositive.localScale = Vector3.one * (1 + primaryPress);
  58.         // PoseXpositive.localScale = Vector3.one * (1 + secondaryPress);
  59.  
  60.         // PoseXaxis.localScale = new Vector3(0.005f + gripForce * 0.03f, 0.1f, 0.005f + gripForce * 0.03f);
  61.         // PoseYaxis.localScale = new Vector3(0.005f + gripForce * 0.03f, 0.1f, 0.005f + gripForce * 0.03f);
  62.         // PoseZaxis.localScale = new Vector3(0.005f + gripForce * 0.03f, 0.1f, 0.005f + gripForce * 0.03f);
  63.         //if (thumbForce > 0) Debug.Log(thumbForce.ToString("f2"));
  64.         //if (gripFingers > 0) Debug.Log(gripFingers.ToString("f2"));
  65.  
  66.  
  67.     }
  68.  
  69.  
  70.     private void Start(){
  71.         PoseCube = PoseMaker.Find("Cube");
  72.         PoseXaxis = PoseMaker.Find("XAxis");
  73.         PoseYaxis = PoseMaker.Find("YAxis");
  74.         PoseZaxis = PoseMaker.Find("ZAxis");
  75.         PoseXpositive = PoseMaker.Find("X-Positive");
  76.         PoseYpositive = PoseMaker.Find("Y-Positive");
  77.         PoseZpositive = PoseMaker.Find("Z-Positive");
  78.         PoseCubeScale = PoseCube.localScale.x;
  79.     }
  80.  
  81. }
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement