private void HandleOnTriggerDown(byte controllerId, float value) { MLInputController controller = _controllerConnectionHandler.ConnectedController; if (controller != null && controller.Id == controllerId) { MLInputControllerFeedbackIntensity intensity = (MLInputControllerFeedbackIntensity)((int)(value * 2.0f)); controller.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); Vector3 newPieceLocation = ControllerLocation; Vector3 newPieceRotation = ControllerRotation; //Vector3 newPieceLocation = ControllerLocation; //Vector3 newPieceRotation = ControllerRotation; if (!StartPlaced && !touchingObject) { StartPoint = newPieceLocation; ballInstance = Instantiate(Ball, newPieceLocation, Quaternion.identity); StartPlaced = true; InfoText.text = "Set end point"; } else if (!EndPlaced && !touchingObject) { EndPoint = newPieceLocation; Instantiate(EndModel, newPieceLocation, Quaternion.identity); EndPlaced = true; InfoText.text = "Place your track down, and press the bumper to start."; isReadyToStart = true; } else if (!Started && !touchingObject) { Instantiate(SelectedPrefab, newPieceLocation, Quaternion.Euler(newPieceRotation)); } } }
/// <summary> /// Handles the event for trigger down. /// </summary> /// <param name="controller_id">The id of the controller.</param> /// <param name="value">The value of the trigger button.</param> private void HandleOnTriggerDown(byte controllerId, float value) { MLInputController controller = _controllerConnectionHandler.ConnectedController; if (controller != null && controller.Id == controllerId) { MLInputControllerFeedbackIntensity intensity = (MLInputControllerFeedbackIntensity)((int)(value * 2.0f)); controller.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); //public void SetParent(GameObject Cube) //{ // //Makes the GameObject "newParent" the parent of the GameObject "player". // controller.transform.parent = Cube.transform; // //Display the parent's name in the console. // Debug.Log("Player's Parent: " + controller.transform.parent.name); // // Check if the new parent has a parent GameObject. // if (Cube.transform.parent != null) // { // //Display the name of the grand parent of the player. // Debug.Log("Player's Grand parent: " + controller.transform.parent.parent.name); // } //} } }
void OnCollisionEnter(Collision col) { // Check for blade reflect if (col.collider.gameObject.layer == 10) { // Play reflect sound var sound = Instantiate(ReflectSound, transform.position, Quaternion.identity); sound.pitch = Random.Range(ReflectMinPitch, ReflectMaxPitch); sound.PlayOneShot(sound.clip); // Add some haptics MLInputControllerFeedbackIntensity intensity = MLInputControllerFeedbackIntensity.Medium; _controller.Controller.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); // TODO: Reflect instead of destroy } // Spawn an explosion if (Explosion) { var explosion = Instantiate(Explosion, transform.position, Quaternion.identity); Destroy(explosion, Lifespan); } Destroy(gameObject); }
/// <summary> /// Handles the event for trigger down. /// </summary> /// <param name="controller_id">The id of the controller.</param> /// <param name="value">The value of the trigger button.</param> private void HandleOnTriggerDown(byte controllerId, float value) { if (_mlInputController != null && _mlInputController.Id == controllerId) { MLInputControllerFeedbackIntensity intensity = (MLInputControllerFeedbackIntensity)((int)(value * 2.0f)); _mlInputController.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); } }
/// <summary> /// Handles the event for trigger down. /// </summary> /// <param name="controller_id">The id of the controller.</param> /// <param name="value">The value of the trigger button.</param> public virtual void HandleOnTriggerDown(byte controllerId, float value) { MLInputController controller = _controllerConnectionHandler.ConnectedController; if (controller != null && controller.Id == controllerId) { MLInputControllerFeedbackIntensity intensity = (MLInputControllerFeedbackIntensity)((int)(value * 2.0f)); controller.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); } }
private void Handle_OnTriggerDown(byte controllerId, float triggerValue) { Debug.Log("Handle_OnTriggerDown"); MLInputControllerFeedbackIntensity intensity = (MLInputControllerFeedbackIntensity)((int)(triggerValue * 2.0f)); _controller.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); Shoot(); }
private void OnTriggerEnter(Collider other) { if (other.tag == "picker") { MLInputController controller = _controllerConnectionHandler.ConnectedController; currentSelect = id; transform.DOLocalMoveZ(-0.5f, .3f); transform.DOScale(initialScale * 1.2f, .3f); MLInputControllerFeedbackIntensity intensity = (MLInputControllerFeedbackIntensity)((int)(.8f)); controller.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); } }
/// <summary> /// Updates controller vibration haptics. /// </summary> private void UpdateHaptics() { if (_controller.Type == MLInputControllerType.Device) { // For trigger issue a buzz vibe with appropriate pressure sensitivity to the body. if (_controller.TriggerValue > 0.2f) // Adding in some deadzone checking. { MLInputControllerFeedbackIntensity intensity = (MLInputControllerFeedbackIntensity)((int)(_controller.TriggerValue * 2.0f)); _controller.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); } } }
private void HandleOnTriggerDown(byte controllerId, float value) { MLInputController controller = connectionHandler.ConnectedController; if (controller != null && controller.Id == controllerId) { MLInputControllerFeedbackIntensity intensity = (MLInputControllerFeedbackIntensity)((int)value * 2.0f); controller.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); debugLog.text = "Start capturing has been enables by the trigger button action"; startTracking = true; } }
/// <summary> /// Handles the event for trigger down. /// </summary> /// <param name="controller_id">The id of the controller.</param> /// <param name="value">The value of the trigger button.</param> private void HandleOnTriggerDown(byte controllerId, float value) { MLInputController controller = _controllerConnectionHandler.ConnectedController; if (controller != null && controller.Id == controllerId) { // NOTE: Hardcoded to 0.1 since there was a bug that would make the controller vibrate max when // trigger > 0.8 but < 1.0 MLInputControllerFeedbackIntensity intensity = (MLInputControllerFeedbackIntensity)0.1f; // controller.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); } }
/// <summary> /// Handles the event for trigger down. /// </summary> /// <param name="controller_id">The id of the controller.</param> /// <param name="value">The value of the trigger button.</param> private void HandleOnTriggerDown(byte controllerId, float value) { MLInputController controller = _controllerConnectionHandler.ConnectedController; if (controller != null && controller.Id == controllerId) { //cs.TransferObject(); //Debug.Log("I tried to sync color"); MLInputControllerFeedbackIntensity intensity = (MLInputControllerFeedbackIntensity)((int)(value * 2.0f)); controller.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); } }
/// <summary> /// Handles the event for trigger down. /// </summary> /// <param name="controller_id">The id of the controller.</param> /// <param name="value">The value of the trigger button.</param> private void HandleOnTriggerDown(byte controllerId, float value) { MLInputController controller = _controllerConnectionHandler.ConnectedController; if (controller != null && controller.Id == controllerId) { MLInputControllerFeedbackIntensity intensity = (MLInputControllerFeedbackIntensity)((int)(value * 2.0f)); controller.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); if (isActive) { island.GetComponent <Animator>().SetTrigger("disappear"); GetComponent <AudioSource>().volume = 0; } else { island.GetComponent <Animator>().SetTrigger("appear"); GetComponent <AudioSource>().volume = 0.4f; } isActive = !isActive; } }
//Constructors: public HapticSetting(bool enabled, MLInputControllerFeedbackPatternVibe pattern, MLInputControllerFeedbackIntensity intensity) { this.enabled = enabled; this.pattern = pattern; this.instensity = intensity; }
public static extern bool MLInputStartControllerFeedbackPatternVibe(byte controllerId, MLInputControllerFeedbackPatternVibe pattern, MLInputControllerFeedbackIntensity intensity);
//Public Methods: public void StartHaptic(MLInputControllerFeedbackPatternVibe vibe, MLInputControllerFeedbackIntensity intensity) { controlInput.Control.StartFeedbackPatternVibe(vibe, intensity); }
public MLResult StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe pattern, MLInputControllerFeedbackIntensity intensity) { if (MLControllerNativeBindings.MLInputStartControllerFeedbackPatternVibe(controllerId, pattern, intensity)) { return(MLResult.Create(MLResult.Code.Ok)); } MLResult result = MLResult.Create(MLResult.Code.UnspecifiedFailure, "UnityMagicLeap - MLInputStartControllerFeedbackPatternVibe() returned an error."); MLPluginLog.ErrorFormat("MLInputController.StartFeedbackPatternVibe failed. Reason: {0}", result); return(result); }
void Update() { if (!_extend.Extended()) { return; } var transform = Source.transform; var position = transform.position; var direction = transform.up; // Raycast to check for surfaces to slice // Debug.DrawLine(position, position + direction * Length, Color.yellow, 2.0f, false); var wasHit = _isHit; _isHit = false; var hitCount = Physics.RaycastNonAlloc(position, direction, _hits, Length, _layerMask); if (hitCount == 0) { _isFirstHit = true; return; } var firstHit = _hits[0]; Vector3[] interpolateTargets = null; _isHit = true; // Play Sound if (wasHit) { if (Time.time > _lastCrackleSound + _crackleSoundCooldown) { ResetCrackleCooldown(); _lastCrackleSound = Time.time; CrackleSound.pitch = Random.Range(MinPitch, MaxPitch); CrackleSound.transform.position = firstHit.point; CrackleSound.PlayOneShot(CrackleSound.clip); } } else { if (Time.time > _lastSliceSound + _sliceSoundCooldown) { ResetSliceCooldown(); _lastSliceSound = Time.time; Sound.pitch = Random.Range(MinPitch, MaxPitch); Sound.transform.position = firstHit.point; Sound.PlayOneShot(Sound.clip); } } // Add haptics if (Time.time > _lastBuzz + SliceBuzzCooldown) { _lastBuzz = Time.time; MLInputControllerFeedbackIntensity intensity = MLInputControllerFeedbackIntensity.Low; var speed = _swing.AverageSpeed; if (speed >= SliceBuzzMediumSpeed) { intensity = MLInputControllerFeedbackIntensity.Medium; } if (speed >= SliceBuzzHighSpeed) { intensity = MLInputControllerFeedbackIntensity.High; } _controller.Controller.StartFeedbackPatternVibe(MLInputControllerFeedbackPatternVibe.Buzz, intensity); } // Check for distance travelled and interpolate if (!_isFirstHit) { var interpolateDirection = (firstHit.point - _lastHit); var distance = interpolateDirection.magnitude; if (distance <= DecalMinDistance) { // Not moved far enough for decals // Still want some sparks though var particleRotation = Quaternion.LookRotation(firstHit.normal); PlaySparks(firstHit, particleRotation); return; } if (distance >= DecalMinDistance * 2) { interpolateDirection = interpolateDirection.normalized * DecalMinDistance; interpolateTargets = new Vector3[(int)Math.Ceiling(distance / DecalMinDistance) - 1]; Vector3 targetLocation = _lastHit + interpolateDirection; for (int i = 0; i < interpolateTargets.Length; i++) { interpolateTargets[i] = targetLocation; targetLocation += interpolateDirection; } } } _isFirstHit = false; _lastHit = firstHit.point; // Check for particle limit var particleCount = hitCount; if (interpolateTargets != null) { particleCount *= (interpolateTargets.Length + 1); } PurgeParticles(particleCount); // Check current location CheckHits(hitCount, position, direction); // Check interpolated locations if (interpolateTargets != null) { foreach (Vector3 target in interpolateTargets) { var interpolateDirection = target - position; hitCount = Physics.RaycastNonAlloc(position, interpolateDirection, _hits, Length, _layerMask); if (hitCount != 0) { CheckHits(hitCount, position, interpolateDirection); } } } }