public void ResetToInteractbaleDefault() { input.VRActions = new string[] { "NONE", "ACTION", "PICKUP_DROP" }; #if Int_Oculus || (Int_SteamVR && !Int_SteamVR2) input.triggerKey = 1; input.triggerKeyOculus = 1; input.padTop = 0; input.padTopOculus = 0; input.padLeft = 0; input.padLeftOculus = 0; input.padRight = 0; input.padRightOculus = 0; input.padBottom = 0; input.padBottomOculus = 0; input.padCentre = 0; input.padCentreOculus = 0; input.padTouch = 0; input.padTouchOculus = 0; input.gripKey = 2; input.gripKeyOculus = 2; input.menuKey = 0; input.menuKeyOculus = 0; input.AXKey = 0; input.AXKeyOculus = 0; #endif #if Int_SteamVR2 if (input.isSteamVR()) { SteamVR_Action_Boolean actionAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("ACTION"); SteamVR_Action_Boolean pickupDropAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("PICKUP_DROP"); input.booleanActions.Clear(); input.booleanActions.Add(actionAction); input.booleanActions.Add(pickupDropAction); input.triggerPressure = SteamVR_Input.GetAction <SteamVR_Action_Single>("TriggerPressure"); input.touchPosition = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("TouchPosition"); input.padTouched = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("PadTouched"); input.padPressed = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("PadPressed"); input.handType = input.LeftHand ? SteamVR_Input_Sources.LeftHand : SteamVR_Input_Sources.RightHand; SteamVR_Behaviour_Pose poseComp = input.GetComponent <SteamVR_Behaviour_Pose>(); if (poseComp == null) { poseComp = input.gameObject.AddComponent <SteamVR_Behaviour_Pose>(); poseComp.inputSource = input.handType; } } #endif EditorUtility.SetDirty(input); EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); }
private void OnBackActionChange(SteamVR_Action_Boolean actionIn, SteamVR_Input_Sources inputSource, bool newValue) { if (isBack.GetStateDown(hand.handType)) { Debug.Log("Back down"); moveVertical -= 1f; } if (isBack.GetStateUp(hand.handType)) { Debug.Log("Forward up"); moveVertical += 1f; } }
public void TriggerDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { Debug.Log("Trigger is down"); pressingGrab = true; /* * if (grabbingSomething && objectInHand != null) * { * objectInHand.GetComponent<Transform>().parent = null; * } */ }
private void OnRightActionChange(SteamVR_Action_Boolean actionIn, SteamVR_Input_Sources inputSource, bool newValue) { if (isRight.GetStateDown(hand.handType)) { Debug.Log("Right down"); moveHorizontal += 1f; } if (isRight.GetStateUp(hand.handType)) { Debug.Log("Right up"); moveHorizontal -= 1f; } }
// Start is called before the first frame update void Start() { pose = GetComponent <SteamVR_Behaviour_Pose>(); rightHand = pose.inputSource; //tr = transform.parent.transform; RTrigger = SteamVR_Actions.default_RTrigger; LTrigger = SteamVR_Actions.default_LTrigger; lineEnableHandler = true; CreateLine(); }
// Called when the trigger on the controller is pushed down. protected virtual void OnTriggerUp(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { if (GetControllerState(fromSource).Holding != null) { var gun = GetControllerState(fromSource).Holding.PhysicsBody.GetComponent <IGun>(); if (gun != null) { gun.TriggerUp(); } } StopInteracting(fromSource); // Always stop interacting with interactable objects when releasing the trigger button. }
public void ButtonDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { if (interactable.attachedToHand == null) { return; } if (interactable.attachedToHand.handType != fromSource) { return; // if not the same hand, don't do anything } Delete(); }
private void XR_SetNextPrimaryFireMode(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { if (fromSource != parentHand.otherHand.handType) { return; } if (parentHand.otherHand.currentAttachedObject != offHandHoldArea) { return; } SetNextPrimaryFireMode(); }
//this is for when you press release the grip on the controller public void GripUp(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { if (singleLine) { draw = false; } if (multipleLine) { StartCoroutine(currentObj.GetComponent <TrailObject>().TimeUntilDestroy()); currentObj.transform.parent = null; currentObj = null; } }
// Start is called before the first frame update void Start() { tr = GetComponent <Transform>(); pose = GetComponent <SteamVR_Behaviour_Pose>(); hand = pose.inputSource; trigger = SteamVR_Actions.default_InteractUI; haptic = SteamVR_Actions.default_Haptic; GameObject sel = GameObject.FindWithTag("Button"); CreateLine(); }
//this is for when you press down the trigger on the controller public void TriggerDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { if (singleLine) { multipleLine = true; singleLine = false; } else if (multipleLine) { singleLine = true; multipleLine = false; } }
public void GrabDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { if (pluckedObject != null) { return; } if (selection != null) { selection.Grab(transform); SetGrabbing(selection); } }
private void CreateSetupAction( ref SteamVRBooleanAction action, SteamVR_Action_Boolean usedAction, UnityAction <SteamVR_Behaviour_Boolean, SteamVR_Input_Sources, bool> pressDown, UnityAction <SteamVR_Behaviour_Boolean, SteamVR_Input_Sources, bool> pressUp) { action = gameObject.AddComponent <SteamVRBooleanAction>(); StartCoroutine(SetupAction(action, usedAction, pressDown, pressUp)); }
private void OnMenuBtnActionDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { if (canvas.enabled) { canvas.enabled = false; // transform.position = canvas.worldCamera.transform.position + canvas.worldCamera.transform.forward * distance; } else { canvas.enabled = true; } UpdatePointerState(); }
private void StopSpray(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { ClickCounter += 1; if (isCanOn) { NetworkDrawScript[] scripts = FindObjectsOfType <NetworkDrawScript>(); foreach (NetworkDrawScript nds in scripts) { nds.StoptNetworkDrawRPC(); } IsSpray = false; } }
public void Setup(Transform parent) { m_radialItems = new Dictionary <InventorySlot, RadialItem>(); m_retrievedIcons = new Dictionary <InventorySlot, Sprite>(); hackyInput[InputAction.SelectMelee] = false; hackyInput[InputAction.SelectConsumable] = false; hackyInput[InputAction.SelectHackingTool] = false; hackyInput[InputAction.SelectResourcePack] = false; hackyInput[InputAction.SelectStandard] = false; hackyInput[InputAction.SelectSpecial] = false; hackyInput[InputAction.SelectTool] = false; m_weaponRadialAction = SteamVR_Input.GetBooleanAction("WeaponRadialMenu"); m_radialMenu = new GameObject("WeaponRadial").AddComponent <RadialMenu>(); m_radialMenu.Setup(VR_Input.InteractionHand.MainHand); m_radialMenu.transform.SetParent(parent); m_radialMenu.AddRadialItem("Melee", WantToSelectMelee, out RadialItem melee); m_radialMenu.AddRadialItem("Secondary", WantToSelectSecondary, out RadialItem secondary); m_radialMenu.AddRadialItem("Tool", WantToSelectTool, out RadialItem tool); m_radialMenu.AddRadialItem("Pack", WantToSelectPack, out RadialItem pack); m_radialMenu.AddRadialItem("HackingTool", WantToSelectHackingTool, out RadialItem hackingTool); m_radialMenu.AddRadialItem("Consumable", WantToSelectConsumable, out RadialItem consumable); m_radialMenu.AddRadialItem("Primary", WantToSelectPrimary, out RadialItem primary); m_radialMenu.OnMenuClosedWithoutItem += MenuClosedQuick; melee.SetIcon(VRAssets.MeleeFallback, 1.5f); primary.SetIcon(VRAssets.PrimaryFallback); secondary.SetIcon(VRAssets.SecondaryFallback); tool.SetIcon(VRAssets.ToolFallback); consumable.SetIcon(VRAssets.ThrowableFallback); pack.SetIcon(VRAssets.PackFallback); hackingTool.SetIcon(VRAssets.HackingToolFallback); pack.Active = false; consumable.Active = false; m_radialItems.Add(InventorySlot.GearMelee, melee); m_radialItems.Add(InventorySlot.GearStandard, primary); m_radialItems.Add(InventorySlot.GearSpecial, secondary); m_radialItems.Add(InventorySlot.GearClass, tool); m_radialItems.Add(InventorySlot.Consumable, consumable); m_radialItems.Add(InventorySlot.ResourcePack, pack); m_radialItems.Add(InventorySlot.HackingTool, hackingTool); InventoryAmmoEvents.OnInventoryAmmoUpdate += AmmoUpdate; BackpackEvents.OnNewItemStatus += ItemStatusChanged; VRConfig.configWeaponInfoText.SettingChanged += ToggleInfoText; }
// activate/deactivate pointer when the associated button is pressed void ActivatePointer(SteamVR_Action_Boolean action, SteamVR_Input_Sources source) { if (simulationStatus == true) { // update pointer status mode pointerIsActive = !pointerIsActive; // set the laser pointer on the source hand SetPointerToHand(GameObject.Find(source.ToString())); // activate/deactivate laser pointer on the source hand measureLaserPointer.gameObject.SetActive(pointerIsActive); } }
protected void MeasureButtonPressTime(Hand hand, SteamVR_Action_Boolean buttonAction) { if (WasButtonPressed(hand, buttonAction)) { startTime = Time.time; } if (WasButtonReleased(hand, buttonAction)) { duration = Time.time - startTime; // Debug.Log("Buttonpress duration: " + duration); // Debug.Log("deltaTime: " + Time.deltaTime); } }
void Awake() { watchRadialMenu = SteamVR_Input.GetBooleanAction("WatchRadialMenu"); toggleWatchMode = SteamVR_Input.GetBooleanAction("ToggleWatchMode"); Current = this; ItemEquippableEvents.OnPlayerWieldItem += ItemSwitched; InventoryAmmoEvents.OnInventoryAmmoUpdate += AmmoUpdate; Controllers.HandednessSwitched += SetHandedness; VRConfig.configWatchScaling.SettingChanged += WatchScaleChanged; VRConfig.configUseNumbersForAmmoDisplay.SettingChanged += AmmoDisplayChanged; VRConfig.configWatchColor.SettingChanged += WatchColorChanged; VRConfig.configWatchInfoText.SettingChanged += WatchRadialInfoTextChanged; ChatMsgEvents.OnChatMsgReceived += ChatMsgReceived; }
private void OnTriggerPressedOrReleased(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource, bool newState) { Debug.Log("Trigger was pressed or released"); if (gameInOn == false) { screenController.StartGame(); gameInOn = true; } else { Debug.Log("something else"); } }
void emitVRActionBooleanChange(SteamVR_Action_Boolean action, bool value) { if (ClientManager.instance.state != BaseNetworking.componentState.RUNNING || ClientManager.instance.workerClient == null) { return; } Debug.Log("sending boolean of " + action.GetShortName() + "=" + value); VRActionBoolMessage message = new VRActionBoolMessage(); message.actionName = action.GetShortName(); message.value = value; ClientManager.instance.workerClient.sendMessage(message); }
// Start is called before the first frame update void Start() { trigger = SteamVR_Actions.default_Trigger; pose = GetComponent <SteamVR_Behaviour_Pose>(); hand = pose.inputSource; CreateLineRenderer(); tr = GetComponent <Transform>(); audioSource = GetComponent <AudioSource>(); audioSource.loop = false; audioSource.playOnAwake = false; }
/// <summary> /// Toggles the active state of the location panel. /// </summary> /// <param name="fromAction">Action that triggered the behavior.</param> /// <param name="fromSource">Source of the action.</param> public void TooltipActive(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { Debug.Log("Activating tooltip"); if (active) { LocationPanel.SetActive(false); active = false; } else { LocationPanel.SetActive(true); active = true; } }
IEnumerator Start() { yield return(new WaitForSeconds(2.0f)); pose = GetComponent <SteamVR_Behaviour_Pose>(); hand = SteamVR_Input_Sources.LeftHand; teleport = SteamVR_Actions.default_Teleport; pointerPrefab = Resources.Load <GameObject>("Pointer"); pointer = Instantiate <GameObject>(pointerPrefab, this.transform); tr = GetComponent <Transform>(); CreateLine(); }
private void DialogInteract(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { // If we have the spell plane open, end the conversation if (spellPlane.isSpellPlaneActive) { lineRenderer.enabled = false; if (activeDialogManager != null) { activeDialogManager.EndDialogEarly(); } return; } // -- Next dialog line if (activeDialogManager != null) { activeDialogManager.DisplayNextSentence(); } // Raycast forward from the hand // If we collide with something that we can chat with, then start that conversation if (Physics.Raycast(hand.transform.position, hand.transform.forward, out RaycastHit hit, raycastDistance, startDialogRaycastLayerMask)) { if (hit.collider.TryGetComponent(out BaseDialog dialog)) { // If we aren't already in a conversation with this character, then start a new convo if (dialog.dialogManager != activeDialogManager || !activeDialogManager.isDialogActive) { // Raycast to the collision point lineRenderer.SetPosition(0, hand.transform.position); lineRenderer.SetPosition(1, hit.point); lineRendererAnimator.SetTrigger("fire"); // -- Phase out of the old dialog // WIP if (activeDialogManager != null) { activeDialogManager.EndDialogEarly(); } // -- Start a new convo activeDialogManager = dialog.dialogManager; otherDialogInteractor.activeDialogManager = dialog.dialogManager; dialog.StartDialog(); return; } } }
protected void TriggerLoop(Hand hand, SteamVR_Action_Boolean triggerAction) { if (WasButtonPressed(hand, triggerAction)) { if (hand.hoveringInteractable != null) { tmpSoundblob = hand.hoveringInteractable.gameObject; tmpSoundblob.GetComponent <AudioSource>().loop = !tmpSoundblob.GetComponent <AudioSource>().loop; } else { return; } } }
public static bool GetActionUp(InputAction action) { if (!Initialized) { return(false); } SteamVR_Action_Boolean boolActionMapping = GetBoolActionMapping(action); if (IsIRLCrouchValid(action)) { return(boolActionMapping != null && !boolActionMapping.GetStateDown(SteamVR_Input_Sources.Any) || !boolActionMapping.GetState(SteamVR_Input_Sources.Any) && (boolActionMapping.GetStateUp(SteamVR_Input_Sources.Any) || (HMD.Hmd.transform.localPosition.y + VRConfig.configFloorOffset.Value > VRConfig.configCrouchHeight.Value / 100f))); } return(boolActionMapping != null && boolActionMapping.GetStateUp(SteamVR_Input_Sources.Any)); }
public void modeSwitchDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { if (currentModeIsOverView == false) { GameObject spawner = GameObject.Find("Spawner"); spawner.GetComponent <Spawn_nodes>().reset("overview"); currentModeIsOverView = true; } else { GameObject spawner = GameObject.Find("Spawner"); spawner.GetComponent <Spawn_nodes>().reset("standard"); currentModeIsOverView = false; } }
private void PrimaryFireStateUpdate(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource, bool newState) { // Can't shoot the gun when we're in the middle of force grabbing if (grappler.isGrappleProjectileDeployed) { return; } if (IsTransitioningBetweenFireModes()) { return; } // Pass the fire action to the active "Blaster Module" //fireModes[primaryFireMode].OnStateUpdate(fromAction, fromSource, newState); }
public static bool GetAction(InputAction action) { if (!VRInput.Initialized) { return(false); } SteamVR_Action_Boolean boolActionMapping = VRInput.instance.GetBoolActionMapping(action); if (IsIRLCrouchValid(action)) { return((boolActionMapping != null && boolActionMapping.GetState(SteamVR_Input_Sources.Any)) || HMD.hmd.transform.localPosition.y < VRInput.IRLCrouchBorder); } return(boolActionMapping != null && boolActionMapping.GetState(SteamVR_Input_Sources.Any)); }