void emitVRActionVector1Change(SteamVR_Action_Single action, float value) { if (ClientManager.instance.state != BaseNetworking.componentState.RUNNING || ClientManager.instance.workerClient == null) { return; } Debug.Log("sending vector1 of " + action.GetShortName() + "=" + value); VRActionVector1Message message = new VRActionVector1Message(); message.actionName = action.GetShortName(); message.value = value; ClientManager.instance.workerClient.sendMessage(message); }
private Quaternion lastRotation; //the rotation of the controller on the previous frame void Start() { triggerPull = SteamVR_Input._default.inActions.GrabTrigger; grabCollider = GetComponent <Collider>(); playerCollider = gameObject.transform.parent.GetComponent <Collider>(); //Gets the input source for the hand we are using if (gameObject.name.Contains("left")) { hand = SteamVR_Input_Sources.LeftHand; } else if (gameObject.name.Contains("right")) { hand = SteamVR_Input_Sources.RightHand; } }
private void GrabUpdate(SteamVR_Action_Single fromAction, SteamVR_Input_Sources fromSource, float newAxis, float newDelta) { if (grabbedObject == null && newAxis > 0.5f) { //raycast int mask = ~LayerMask.NameToLayer("Mech"); RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, grabRange, mask)) { grabbedRigidB = hit.transform.GetComponent <Rigidbody>(); if (hit.transform.GetComponent <IGrabable>() && grabbedRigidB) { grabbedObject = hit.transform; grabbedRigidB.isKinematic = true; grabbedcoll = grabbedObject.GetComponent <Collider>(); grabbedcoll.enabled = false; } } } if (grabbedObject != null && newAxis > 0.5f) { //grabbedObject.position = Vector3.Lerp(grabbedObject.position, transform.position + holdOffset, 0.3f); grabbedObject.position = Vector3.Lerp(grabbedObject.position, transform.position + transform.TransformDirection(holdOffset), 0.3f); grabbedObject.rotation = Quaternion.Lerp(grabbedObject.rotation, transform.rotation, 0.3f); } if (grabbedObject != null && newAxis < 0.3f) { grabbedRigidB.isKinematic = false; grabbedObject.position = grabbedObject.position + transform.forward; grabbedRigidB.velocity = transform.forward * throwSpeed; // change to 'throwing' grabbedcoll.enabled = true; grabbedObject = null; grabbedRigidB = null; } }
public float GetAxis(SteamVR_Action_Single axis1D) { return(axis1D.GetAxis(handType)); }
public void UpdateHandler(SteamVR_Action_Single fromAction, SteamVR_Input_Sources fromSource, float newAxis, float newDelta) { }
void Update() { if (actionSetChanged) { switch (currentActionSet.GetShortName()) { case "MySet": currentActionSet.Activate(currentSource, 0, false); pose.poseAction = SteamVR_Input.GetAction <SteamVR_Action_Pose>("MySet", "Pose", false, false); gripClickAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("MySet", "GripClick", false, false); triggerPullAction = SteamVR_Input.GetAction <SteamVR_Action_Single>("MySet", "Teleport", false, false); joyStickAction = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("MySet", "Move", false, false); break; case "Sword": currentActionSet.Activate(currentSource, 0, false); pose.poseAction = SteamVR_Input.GetAction <SteamVR_Action_Pose>("Sword", "Pose", false, false); //gripClickAction = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("Sword", "InitiateSlash", false, false); triggerClickAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Sword", "InitiateSlash", false, false); joyStickAction = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("Sword", "Move", false, false); break; default: break; } actionSetChanged = false; } gripClick = gripClickAction.GetStateDown(currentSource); triggerClickUp = triggerClickAction.GetStateUp(currentSource); triggerValue = triggerPullAction.GetAxis(currentSource); triggerClick = triggerClickAction.GetLastStateDown(currentSource); detach = detachAction.GetStateDown(currentSource); moveValue = joyStickAction.GetAxis(currentSource); //INITIATESLASH CODE ---------------------------------------------------------------------------------------------------------------------------------- if (triggerClick && attached && currentActionSet.GetShortName().Equals("Sword")) { slashParticles = currentlyAttachedObject.GetComponent <ParticleSystem>(); ParticleSystem.EmissionModule emiss = slashParticles.emission; emiss.rateOverDistance = 200f; } if (triggerClickUp && attached && currentActionSet.GetShortName().Equals("Sword")) { slashParticles = currentlyAttachedObject.GetComponent <ParticleSystem>(); ParticleSystem.EmissionModule emiss = slashParticles.emission; emiss.rateOverDistance = 0f; } //OBJECT DETACH CODE --------------------------------------------------------------------------------------------------------------------------------- if (attached && detach && hover.closestHoverObj != null) { //Grab a reference to the current closestHoverObject that is obtained by running Hover() in Hover.cs try { ObjectInteraction detachCall = hover.closestHoverObj.GetComponent <ObjectInteraction>(); attached = detachCall.DetachObjectFromController(); currentActionSet.Deactivate(currentSource); currentActionSet = SteamVR_Input.GetActionSet("MySet"); currentlyAttachedObject = null; actionSetChanged = true; } catch (NullReferenceException) { Debug.LogWarning("detachCall Hand is null in OculusInput.cs"); return; } } //OBJECT ATTACH CODE --------------------------------------------------------------------------------------------------------------------------------- if (gripClick && hover.closestHoverObj != null && !attached) { try { ObjectInteraction attachCall = hover.closestHoverObj.GetComponent <ObjectInteraction>(); attached = attachCall.AttachObjectToController(this.gameObject, hover.hoverPoint); currentlyAttachedObject = hover.closestHoverObj; currentActionSet.Deactivate(currentSource); currentActionSet = SteamVR_Input.GetActionSet("Sword"); //CHANGE THIS LATER WHEN WE HAVE MORE THAN ONE ITEM TO PICK UP actionSetChanged = true; } catch (NullReferenceException) { Debug.LogWarning("attachCall Right Hand is null in OculusInput.cs"); return; } } //TRIGGER PRESS CODE --------------------------------------------------------------------------------------------------------------------------------- if (triggerValue > 0.1f) { int layerMask = (1 << 9); if (Physics.Raycast(transform.position, transform.forward - transform.up, out RaycastHit hit, 50f, layerMask)) { teleTarget.transform.position = hit.point; Debug.DrawRay(transform.position, (transform.forward - transform.up) * 100f, Color.blue, 5f); } } if (triggerValue > 0.75f && pressFlag)//Teleport using raycast { print("Teleport"); Debug.DrawRay(transform.position, transform.forward * 100f, Color.red); if (Physics.Raycast(transform.position, transform.forward - transform.up, out RaycastHit hit, 100f)) { cameraRig.transform.position = hit.point; } pressFlag = false; } if (triggerValue < 0.1f)//Must release or almost release trigger before teleporting again { pressFlag = true; } //JOYSTICK MOVEMENT CODE --------------------------------------------------------------------------------------------------------------------------------- if (moveValue.y > 0.1f || moveValue.y < -0.1f) {//Forward and Backward Vector3 controllerMove = new Vector3(((transform.forward - transform.up).normalized).x, 0f, (((transform.forward - transform.up).normalized).z)); cameraRig.transform.Translate(controllerMove * moveValue.y); } if (moveValue.x > 0.1f || moveValue.x < -0.1f) {//Right and Left Vector3 controllerMove = new Vector3(transform.right.x, 0f, transform.right.z); cameraRig.transform.Translate(controllerMove * moveValue.x); } }
private void OnRightSqueeze(SteamVR_Action_Single fromAction, SteamVR_Input_Sources fromSource, float newAxis, float newDelta) { DataManager.Send(RightSqueezeKey, newAxis.ToString()); }
public void Awake() { penguPoint.GetComponent <MeshRenderer>().enabled = isPenguVisible; trigger = SteamVR_Actions._default.Squeeze; }
void Start() { Pose = GetComponent <SteamVR_Behaviour_Pose>(); //sprayingTracker = GetComponent<SteamVR_Action_Vector3>(); sprayingTracker = GetComponent <SteamVR_Action_Single>(); }
private void OnAxisValueChanged(SteamVR_Action_Single actionIn, SteamVR_Input_Sources hand, float newAxis, float newDelta) { Value = actionIn.GetAxis(Hand); }
public void MiddlePressUpdate(SteamVR_Action_Single fromAction, SteamVR_Input_Sources fromSource, float tCurrent, float tDelta) { cITA.MiddlePressUpdate(tCurrent); }
/* * @brief: function runs at a fixed rate of 1 / fixed time step */ void FixedUpdate() { if (global.startup) { return; } // Will only use VR Controller input if the control toggle from brachIOplexus is disabled if (!global.controlToggle) { // clears buffer clearRotationArray(); // Gets current values from the actions single = (SteamVR_Action_Single)trigger; // Gets a float 0 to 1 boolean = (SteamVR_Action_Boolean)push; // Gets a bool (if button is pressed or not) vector2 = (SteamVR_Action_Vector2)joystick; // Get a 2-D vector (0 to 1) // Determines if the end effectors should open or not // Will need to be expanded for future end effectors (only created for chopsticks) // if both triggers are pressed OR if neither triggers are pressed, don't move if (single.GetAxis(Left) != 0 && single.GetAxis(Right) != 0 || (single.GetAxis(Left) == 0 && single.GetAxis(Right) == 0)) { global.SteamVRControl[4] = 0; } else if (single.GetAxis(Left) != 0 && single.GetAxis(Right) == 0) { global.SteamVRControl[4] = single.GetAxis(Left); } else if (single.GetAxis(Left) == 0 && single.GetAxis(Right) != 0) { global.SteamVRControl[4] = -1 * single.GetAxis(Right); } // Checks if the controllers are from the VIVE if (SteamVR.instance.hmd_ModelNumber == "VIVE_Pro MV") { // Checks first if the trackpad is pressed down if (boolean.GetState(Left)) { // Gets values from the Left trackpad leftJoy = vector2.GetAxis(Left); // Only fills array if the value is above the threshold global.SteamVRControl[0] = Math.Abs(leftJoy.x) >= 0.15 ? -1 * leftJoy.x : 0; global.SteamVRControl[1] = Math.Abs(leftJoy.y) >= 0.15 ? -1 * leftJoy.y : 0; } // Checks first if the trackpad is pressed down if (boolean.GetState(Right)) { // Gets value from Right trackpad rightJoy = vector2.GetAxis(Right); // Only fills array if tyhe value is above the threshold global.SteamVRControl[2] = Math.Abs(rightJoy.x) >= 0.15 ? -1 * rightJoy.x : 0; global.SteamVRControl[3] = Math.Abs(rightJoy.y) >= 0.15 ? -1 * rightJoy.y : 0; } } else { // Gets values from the Left trackpad leftJoy = vector2.GetAxis(Left); // Only fills array if the value is above the threshold global.SteamVRControl[0] = Math.Abs(leftJoy.x) >= 0.15 ? -1 * leftJoy.x : 0; global.SteamVRControl[1] = Math.Abs(leftJoy.y) >= 0.15 ? -1 * leftJoy.y : 0; // Gets value from Right trackpad rightJoy = vector2.GetAxis(Right); // Only fills array if tyhe value is above the threshold global.SteamVRControl[2] = Math.Abs(rightJoy.x) >= 0.15 ? -1 * rightJoy.x : 0; global.SteamVRControl[3] = Math.Abs(rightJoy.y) >= 0.15 ? -1 * rightJoy.y : 0; } } }
public override void Initialize(ActionCanvasBase actionCanvasBase) { base.Initialize(actionCanvasBase); actionAxis = SteamVR_Input.GetAction <SteamVR_Action_Single>(actionName + "Axis"); }
private void SqueezeMethode(SteamVR_Action_Single fromAction, SteamVR_Input_Sources fromSource, float newAxis, float newDelta) { }
private void OnTriggerActionChange(SteamVR_Action_Single fromAction, SteamVR_Input_Sources fromSource, float newAxis, float newDelta) { triggerSensitivity = newAxis; }
private void RGrab(SteamVR_Action_Single action, SteamVR_Input_Sources source, float axis, float delta) { m_Animator.SetFloat("RPointBlend", axis); }
private void Grab(SteamVR_Action_Single action, SteamVR_Input_Sources source, float axis, float delta) { animator.SetFloat("GrabBlend", axis); }
public float Axis(SteamVR_Action_Single action) { return(m_currentFrame ? action[m_index].axis : action[m_index].lastAxis); }