protected void UpdateHandRotation() { // make sure the Joycon only gets checked if attached if (joycons.Count > 0) { currentJoycon = joycons [jc_ind]; // j.SetRumble (160, 320, 0.2f, 200); // Then call SetRumble(0,0,0) when you want to turn it off. stick = currentJoycon.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = currentJoycon.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = currentJoycon.GetAccel(); orientation = currentJoycon.GetVector(); //Vector3 v = orientation.eulerAngles; gameObject.transform.rotation = orientation; //SetRotation(); eulerAngle = orientation.eulerAngles; } }
// Update is called once per frame void Update() { if (j != null && j.state > Joycon.state_.ATTACHED) { gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); orientation = j.GetVector(); gameObject.transform.rotation = orientation; if (this.transform.rotation.eulerAngles.y - 90 < maxAngle && this.transform.rotation.eulerAngles.y - 90 > -maxAngle) { xMax = this.transform.rotation.eulerAngles.y - 90; } if (-this.transform.rotation.eulerAngles.z + 90 < maxAngle && -this.transform.rotation.eulerAngles.z + 90 > -maxAngle) { zMax = -this.transform.rotation.eulerAngles.z + 90; } if (this.transform.rotation.eulerAngles.x < maxAngle && -this.transform.rotation.eulerAngles.x > maxAngle) { yMax = this.transform.rotation.eulerAngles.x; } fix = Quaternion.Euler(xMax, yMax, zMax); gameObject.transform.rotation = fix; } }
void JoyconUpdate() { stick = j.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); gravity.x = 0.9f * gravity.x + 0.1f * accel.x; gravity.y = 0.9f * gravity.y + 0.1f * accel.y; gravity.z = 0.9f * gravity.z + 0.1f * accel.z; linearAccel.x = accel.x - gravity.x; linearAccel.y = accel.y - gravity.y; linearAccel.z = accel.z - gravity.z; orientation.x = j.GetVector().x; orientation.y = j.GetVector().y; orientation.w = j.GetVector().w; //Al sumarle la y a la z el gameObject se coloca en la posición que tiene el mando. Actúan sobre el mismo eje de forma contraria orientation.z = j.GetVector().z + j.GetVector().y; gameObject.transform.rotation = orientation; }
void SetKeys(ref Keys key, Joycon joycon) { key.JoyStick.x = joycon.GetStick()[0]; key.JoyStick.y = joycon.GetStick()[1]; key.JoyGyro = joycon.GetGyro(); key.JoyAccel = joycon.GetAccel(); key.JoyRad = joycon.GetVector(); Vector3 gy = key.JoyGyro; gy.x = -key.JoyGyro.y; gy.z = -key.JoyGyro.x; gy.y = key.JoyGyro.z; key.JoyGyro = gy; Vector3 ac = key.JoyGyro; ac.x = -key.JoyAccel.y; ac.z = -key.JoyAccel.x; ac.y = 0f;//key.JoyAccel.z; key.JoyAccel = ac; //なぜか↑のほうむくから補正 key.JoyGyro.x += 0.01f; }
// Update is called once per frame void Update() { // make sure the Joycon only gets checked if attached if (joycon != null) { // GetButtonDown checks if a button has been pressed (not held) if (joycon.GetButtonDown(Joycon.Button.SHOULDER_1)) { // Joycon has no magnetometer, so it cannot accurately determine its yaw value. Joycon.Recenter allows the user to reset the yaw value. joycon.Recenter(); } stick = joycon.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = joycon.GetGyro(); gyroMagnitude = gyro.magnitude; // Accel values: x, y, z axis values (in Gs) accel = joycon.GetAccel(); accelMagnitude = accel.magnitude; // fix rotation orientation = joycon.GetVector(); // orientation = new Quaternion(orientation.x, orientation.z, orientation.y, orientation.w); // Quaternion quat = Quaternion.Inverse(orientation); // Vector3 rot = quat.eulerAngles; // rot += rotationOffset; // orientation = Quaternion.Euler(rot); // rotation = orientation.eulerAngles; if (joyconType == JoyconManager.JoyconType.left) { gameObject.transform.rotation = Quaternion.Euler(0, Mathf.Abs(orientation.x) * 180 - 90, 0); } if (joyconType == JoyconManager.JoyconType.right && accelMagnitude > forceNeeded && !cooldown) { //#if UNITY_STANDALONE_WIN voiceR.Reload(); //#endif cooldown = true; StartCoroutine(BeenSwung()); } // rumble info // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md // The last argument (time) in SetRumble is optional. Call it with three arguments to turn it on without telling it when to turn off. // (Useful for dynamically changing rumble values.) // Then call SetRumble(0,0,0) when you want to turn it off. IEnumerator BeenSwung() { yield return(new WaitForSeconds(cooldownLenght)); cooldown = false; } } }
// Update is called once per frame void Update() { if (joycons.Count > 0) { Joycon j = joycons[jc_ind]; gyro = j.GetGyro(); gameObject.transform.position.Set(gyro.x, gyro.y, 0); } }
// Update is called once per frame void Update() { // make sure the Joycon only gets checked if attached if (joycons.Count > 0) { j = joycons[jc_ind]; // GetButtonDown checks if a button has been pressed (not held) if (j.GetButtonDown(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 pressed"); // GetStick returns a 2-element vector with x/y joystick components Debug.Log(string.Format("Stick x: {0:N} Stick y: {1:N}", j.GetStick()[0], j.GetStick()[1])); // Joycon has no magnetometer, so it cannot accurately determine its yaw value. Joycon.Recenter allows the user to reset the yaw value. j.Recenter(); } // GetButtonDown checks if a button has been released if (j.GetButtonUp(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 released"); } // GetButtonDown checks if a button is currently down (pressed or held) if (j.GetButton(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 held"); } if (j.GetButtonDown(Joycon.Button.DPAD_DOWN)) { Debug.Log("Rumble"); // Rumble for 200 milliseconds, with low frequency rumble at 160 Hz and high frequency rumble at 320 Hz. For more information check: // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md j.SetRumble(30, 130, 2f, 100); // The last argument (time) in SetRumble is optional. Call it with three arguments to turn it on without telling it when to turn off. // (Useful for dynamically changing rumble values.) // Then call SetRumble(0,0,0) when you want to turn it off. } stick = j.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); orientation = j.GetVector(); orientation = Quaternion.Inverse(new Quaternion(orientation.x, orientation.z, orientation.y, orientation.w)); orientationXYZ = orientation.eulerAngles; orientationXYZ = new Vector3(orientationXYZ.x, orientationXYZ.y, orientationXYZ.z); gameObject.transform.localRotation = Quaternion.Euler(orientationXYZ); } }
// Update is called once per frame void FixedUpdate() { Joycon j = joycons[jc_ind]; stick = new Vector2(j.GetStick()[0], j.GetStick()[1]); OSCHandler.Instance.SendMessageToClient("myClient", "/left/joystick/x", stick.x); OSCHandler.Instance.SendMessageToClient("myClient", "/left/joystick/y", stick.y); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); OSCHandler.Instance.SendMessageToClient("myClient", "/left/gyro/x", gyro.x); OSCHandler.Instance.SendMessageToClient("myClient", "/left/gyro/y", gyro.y); OSCHandler.Instance.SendMessageToClient("myClient", "/left/gyro/z", gyro.z); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); OSCHandler.Instance.SendMessageToClient("myClient", "/left/accel/x", accel.x); OSCHandler.Instance.SendMessageToClient("myClient", "/left/accel/y", accel.y); OSCHandler.Instance.SendMessageToClient("myClient", "/left/accel/z", accel.z); orientation = j.GetVector(); OSCHandler.Instance.SendMessageToClient("myClient", "/left/orientation/0", orientation[0]); OSCHandler.Instance.SendMessageToClient("myClient", "/left/orientation/1", orientation[1]); OSCHandler.Instance.SendMessageToClient("myClient", "/left/orientation/2", orientation[2]); OSCHandler.Instance.SendMessageToClient("myClient", "/left/orientation/3", orientation[3]); //Buttons OSCHandler.Instance.SendMessageToClient("myClient", "/left/buttons/down", (j.GetButton(Joycon.Button.DPAD_DOWN) ? 1 : 0)); OSCHandler.Instance.SendMessageToClient("myClient", "/left/buttons/up", (j.GetButton(Joycon.Button.DPAD_UP) ? 1 : 0)); OSCHandler.Instance.SendMessageToClient("myClient", "/left/buttons/right", (j.GetButton(Joycon.Button.DPAD_RIGHT) ? 1 : 0)); OSCHandler.Instance.SendMessageToClient("myClient", "/left/buttons/left", (j.GetButton(Joycon.Button.DPAD_LEFT) ? 1 : 0)); OSCHandler.Instance.SendMessageToClient("myClient", "/left/buttons/minus", (j.GetButton(Joycon.Button.MINUS) ? 1 : 0)); OSCHandler.Instance.SendMessageToClient("myClient", "/left/buttons/bumper", (j.GetButton(Joycon.Button.SHOULDER_1) ? 1 : 0)); OSCHandler.Instance.SendMessageToClient("myClient", "/left/buttons/trigger", (j.GetButton(Joycon.Button.SHOULDER_2) ? 1 : 0)); OSCHandler.Instance.SendMessageToClient("myClient", "/left/buttons/home", (j.GetButton(Joycon.Button.CAPTURE) ? 1 : 0)); OSCHandler.Instance.SendMessageToClient("myClient", "/left/buttons/joystick", (j.GetButton(Joycon.Button.STICK) ? 1 : 0)); OSCHandler.Instance.SendMessageToClient("myClient", "/left/buttons/side-top", (j.GetButton(Joycon.Button.SL) ? 1 : 0)); OSCHandler.Instance.SendMessageToClient("myClient", "/left/buttons/side-bottom", (j.GetButton(Joycon.Button.SR) ? 1 : 0)); if (rumble == 1) { j.SetRumble(rumbleFreqLow, rumbleFreqHigh, 0.6f, rumbleLen); rumble = 0; } for (var i = 0; i < OSCHandler.Instance.packets.Count; i++) { // Process OSC receivedOSC(OSCHandler.Instance.packets[i]); // Remove them once they have been read. OSCHandler.Instance.packets.Remove(OSCHandler.Instance.packets[i]); i--; } }
private void RecordCurrentInputs() { Vector3 rA = rightJoycon.GetAccel(); Vector3 lA = leftJoycon.GetAccel(); Vector3 rG = rightJoycon.GetGyro(); Vector3 lG = leftJoycon.GetGyro(); float time = Time.time - recordingStartTime; Gesture.DataPoint dp = new Gesture.DataPoint(lA, rA, lG, rG, time); recordingBuffer.Add(dp); }
///<summary> ///Maps the rotation of the joycon to the object ///</summary> private void RotateObject() { if (joyconLeft != null && joyconRight != null) { rotate = joyconRight.GetGyro(); transform.Rotate(rotate); } else if (joyconLeft != null) { rotate = joyconLeft.GetGyro(); transform.Rotate(rotate); } }
public string JoyconToString(Joycon j) { var hands = j.isLeft ? "Left" : "Right"; var quaternion = j.GetVector(); float x = (float)(quaternion.eulerAngles.X * 180.0f / Math.PI); float y = (float)(quaternion.eulerAngles.Y * 180.0f / Math.PI); float z = (float)(quaternion.eulerAngles.Z * 180.0f / Math.PI); Vector3 rotate = new Vector3(x, y, z); Vector3 gyro = j.GetGyro(); string result = "{\"hands\":\"" + hands + "\",\"gyro\":{\"X\":" + gyro.X + ",\"Y\":" + gyro.Y + ",\"Z\":" + gyro.Z + "},\"rotate\":{\"X\":" + rotate.X + ",\"Y\":" + rotate.Y + ",\"Z\":" + rotate.Z + "}}"; return(result); }
// Update is called once per frame void Update() { // make sure the Joycon only gets checked if attached if (j != null && j.state > Joycon.state_.ATTACHED) { stick = j.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); orientation = j.GetVector(); smooth = Mathf.SmoothDamp(smooth, Mathf.Abs(accel.x) * 2, ref v, smoothtime); smoother = Mathf.SmoothDamp(smoother, Mathf.Abs(accel.x) * 2, ref vr, smoothertime); } gameObject.transform.rotation = orientation; if (smooth > 1 && playor == false) { tuning.Stop(); song.Play(); playor = true; } if (playor == true) { if (Mathf.Abs(accel.x) < 0.3f) { timer += Time.deltaTime; } else { timer = 0; } song.pitch = smoother * 1.5f; song.pitch = Mathf.Clamp(song.pitch, 0.8f, 1.5f); if (timer > 1) { song.Stop(); } if (timer > 10) { tuning.Play(); playor = false; } } }
public static Vector3 GetJoyConGyro(bool isLeftJoyCon) { if (isLeftJoyCon && m_joyconL != null) { return(m_joyconL.GetGyro()); } else if (!isLeftJoyCon && m_joyconR != null) { return(m_joyconR.GetGyro()); } else { return(Vector3.zero); } }
// Update is called once per frame void Update() { stick = j.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); orientation = j.GetVector(); OscMessage message = new OscMessage(); message.address = "/UpdateXYZ"; message.values.Add(transform.position.x); message.values.Add(transform.position.y); message.values.Add(transform.position.z); osc.Send(message); message = new OscMessage(); message.address = "/UpdateGyro"; message.values.Add(gyro[0]); message.values.Add(gyro[1]); message.values.Add(gyro[2]); osc.Send(message); message = new OscMessage(); message.address = "/UpdateAccel"; message.values.Add(accel[0]); message.values.Add(accel[1]); message.values.Add(accel[2]); osc.Send(message); message = new OscMessage(); message.address = "/UpdateOri"; message.values.Add(orientation[0]); message.values.Add(orientation[1]); message.values.Add(orientation[2]); message.values.Add(orientation[3]); osc.Send(message); message = new OscMessage(); message.address = "/UpdateStick"; message.values.Add(stick[0]); message.values.Add(stick[1]); osc.Send(message); }
// Use this for initialization void Start() { SphereRadius = -1; joycons = JoyconManager.Instance.j; if (joycons.Count > 0) { j = joycons[jc_ind]; gyro = j.GetGyro(); yinit = gyro.y; initpump = false; BaseRadius = gameObject.transform.localScale.y; } else { Debug.Log("Pas de joycons détectés."); yinit = -1; } }
// Update is called once per frame void Update() { stick = j.GetStick(); gyro = j.GetGyro(); accel = j.GetAccel(); if (FixableItemController.locked) { if ((Input.GetKeyDown(KeyCode.Return) || accel.magnitude > 3) && locked && dragonImage.fillAmount >= 0.75f) { locked = !locked; dragCon.flameFill.fillAmount -= 0.01f; } else if (dragonImage.fillAmount <= 0f && !locked) { t = 0; powerBar.value = 0; locked = !locked; } else if ((Input.GetKeyDown(KeyCode.Return) || accel.magnitude > 3) && dragonImage.fillAmount > 0f) { dragCon.flameFill.fillAmount -= 0.01f; j.SetRumble(50, 50, 5.0f, 1000); if (powerBar.value >= sweetSpotMin && powerBar.value <= sweetSpotMax) { Debug.Log("BING - GOOD"); GameController.overallGameScore += 1; Debug.Log("Score: " + GameController.overallGameScore); } else { Debug.Log("BONG - BAD"); } } if (!locked) { t += Time.deltaTime; powerBar.value = Mathf.Abs(Mathf.Sin(t)); } } }
// Update is called once per frame void Update() { // make sure the Joycon only gets checked if attached if (j != null && j.state > Joycon.state_.ATTACHED) { stick = j.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); orientation = j.GetVector(); } gameObject.transform.rotation = orientation; song.pitch = gyro.y * -0.75f + 1.25f; song.reverbZoneMix = accel.x / 2 + 1; //song.volume = gyro.x; }
// Update is called once per frame void Update() { if (joycons.Count > 0) { //Modifie l'orientation du tampon (Axe Y) selon l'axe Z du gyroscope float orientation = j.GetGyro().z; if (!jumpMode) { gameObject.transform.Rotate(new Vector3(0, orientation, 0)); } //Si le bouton "Flèche vers le haut" est pressé et que le tampon n'est pas en plein animation, on fait bouger le tampon. if ((j.GetButtonDown(Joycon.Button.DPAD_UP)) && !jumpMode) { jumpMode = true; Debug.Log("JUMP !"); sInstance.setTamponRotation(gameObject.transform.rotation.eulerAngles.y); //Pour que l'animation de mouvement ne se fasse pas instantanément, on utilise //une fonction de co-routine jumpAnim et on l'appelle avec StartCoroutine. StartCoroutine(jumpAnim()); } } }
// Update is called once per frame void Update() { // make sure the Joycon only gets checked if attached if (joycon != null) { // GetButtonDown checks if a button has been pressed (not held) if (joycon.GetButtonDown(Joycon.Button.SHOULDER_1)) { // Joycon has no magnetometer, so it cannot accurately determine its yaw value. Joycon.Recenter allows the user to reset the yaw value. joycon.Recenter(); } stick = joycon.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = joycon.GetGyro(); gyroMagnitude = gyro.magnitude; // Accel values: x, y, z axis values (in Gs) accel = joycon.GetAccel(); accelMagnitude = accel.magnitude; // fix rotation orientation = joycon.GetVector(); orientation = new Quaternion(orientation.x, orientation.z, orientation.y, orientation.w); Quaternion quat = Quaternion.Inverse(orientation); Vector3 rot = quat.eulerAngles; rot += rotationOffset; orientation = Quaternion.Euler(rot); rotation = orientation.eulerAngles; // rumble info // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md // The last argument (time) in SetRumble is optional. Call it with three arguments to turn it on without telling it when to turn off. // (Useful for dynamically changing rumble values.) // Then call SetRumble(0,0,0) when you want to turn it off. } }
//砲台の回転処理 private void TurretTurn() { for (int i = 0; i < joycons.Count; i++) { Turret inProcTurret = turrets[i]; Joycon inProcJoycon = joycons[i]; //砲台の角度を加算 inProcTurret.rotation += inProcJoycon.GetGyro().z *inProcTurret.trunSpeed *Time.fixedDeltaTime; //角度、砲台からプレイヤーまでの距離を元に砲台の位置を計算 float x = Mathf.Cos(-inProcTurret.rotation) * inProcTurret.trunRadius * transform.localScale.x; float y = Mathf.Sin(-inProcTurret.rotation) * inProcTurret.trunRadius * transform.localScale.y; //計算した位置に砲台を移動 inProcTurret.transform.SetPosition(new Vector3(x, y) + transform.position); //プレイヤーから砲台までの方向ベクトルを計算して正規化 Vector2 lookDir = (inProcTurret.transform.position - transform.position).normalized; //方向ベクトルを元に砲台の向きを変える inProcTurret.transform.LookAt2D(lookDir); } }
// Update is called once per frame void Update() { if (joycons.Count > 0) { gyro = j.GetGyro(); if ((!initpump) && gyro.y >= yinit + 5) { Debug.Log("Action de pompage initialisé."); initpump = true; } if (initpump && gyro.y <= yinit - 5) { Debug.Log("De l'air est envoyé !"); //initpump = false; gameObject.transform.localScale += new Vector3(0.1f, 0.1f, 0.1f); SphereRadius = gameObject.transform.localScale.y; radius = SphereRadius; } else if (SphereRadius > BaseRadius) { gameObject.transform.localScale -= new Vector3(0.01f, 0.01f, 0.01f); SphereRadius = gameObject.transform.localScale.y; radius = SphereRadius; } if (SphereRadius != -1) { if (SphereRadius >= 5) { Debug.Log("La sphère éclate !"); j.SetRumble(160f, 320f, 0.6f, 550); Destroy(gameObject); Application.Quit(); } } } }
// Update is called once per frame void Update() { // make sure the Joycon only gets checked if attached if (joycons.Count > 0) { Joycon j = joycons [jc_ind]; // GetButtonDown checks if a button has been pressed (not held) if (j.GetButtonDown(Joycon.Button.SHOULDER_2)) { tilting = true; Debug.Log("Shoulder button 2 pressed"); // GetStick returns a 2-element vector with x/y joystick components Debug.Log(string.Format("Stick x: {0:N} Stick y: {1:N}", j.GetStick()[0], j.GetStick()[1])); // Joycon has no magnetometer, so it cannot accurately determine its yaw value. Joycon.Recenter allows the user to reset the yaw value. j.Recenter(); } // GetButtonDown checks if a button has been released if (j.GetButtonUp(Joycon.Button.SHOULDER_2)) { tilting = false; Debug.Log("Shoulder button 2 released"); } // GetButtonDown checks if a button is currently down (pressed or held) if (j.GetButton(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 held"); } if (j.GetButtonDown(Joycon.Button.DPAD_DOWN)) { Debug.Log("Rumble"); // Rumble for 200 milliseconds, with low frequency rumble at 160 Hz and high frequency rumble at 320 Hz. For more information check: // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md j.SetRumble(160, 320, 0.6f, 200); transform.position = Vector3.Lerp(transform.position, new Vector3(0, 0, transform.position.z), 1f); // The last argument (time) in SetRumble is optional. Call it with three arguments to turn it on without telling it when to turn off. // (Useful for dynamically changing rumble values.) // Then call SetRumble(0,0,0) when you want to turn it off. } stick = j.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); orientation = j.GetVector(); if (tilting) { transform.rotation = new Quaternion(0f, 0f, orientation.z, orientation.w); } else { transform.rotation = new Quaternion(0, 0, 0, 0); transform.Translate(new Vector3(gyro.z, gyro.y, 0) * Time.deltaTime * speed, Space.World); } } }
// Update is called once per frame void Update() { // make sure the Joycon only gets checked if attached if (j != null && j.state > Joycon.state_.ATTACHED) { stick = j.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); orientation = j.GetVector(); smooth = Mathf.SmoothDamp(smooth, Mathf.Abs(average) * 2, ref v, smoothtime); smoother = Mathf.SmoothDamp(smoother, Mathf.Abs(average) * 2, ref vr, smoothertime); smoother = Mathf.Clamp(smoother, 0.8f, 1.2f); } average = (gyro.x + gyro.y + gyro.z) / 3; gameObject.transform.rotation = orientation; if (smooth > 1 && playor == false) { tuning.Stop(); shoosh.Play(); song.Play(); playor = true; crashy = false; songFinishedTimer = 0; } if (playor == true) { songFinishedTimer += Time.deltaTime; if (Mathf.Abs(average) < 0.3f) { //timer += Time.deltaTime; } else { timer = 0; } if (timer < 1) { crashy = false; song.pitch = smoother * 1.5f; song.pitch = Mathf.Clamp(song.pitch, 0.8f, 1.5f); } if (timer > 1) { song.pitch = 0; if (crashy == false) { if (songFinishedTimer < 80 && songFinishedTimer > 5) { crash.Play(); crashy = true; } else { tuning.Play(); playor = false; crashy = true; } } if (timer > 30.9f) { tuning.Play(); playor = false; } } } if (Mathf.Abs(average) < 0.3f) { timer += Time.deltaTime; } }
void Update() { if (Input.GetMouseButton(0)) { if (Input.GetKey(KeyCode.Q)) { transform.Rotate(Vector3.forward * rotationSpeed * Time.deltaTime); } else if (Input.GetKey(KeyCode.E)) { transform.Rotate(-Vector3.forward * rotationSpeed * Time.deltaTime); } } if (joycons.Count > 0) { Joycon j = joycons[jc_ind]; // GetButtonDown checks if a button has been pressed (not held) if (j.GetButtonDown(Joycon.Button.PLUS)) { Debug.Log("Plus pressed"); // GetStick returns a 2-element vector with x/y joystick components //Debug.Log(string.Format("Stick x: {0:N} Stick y: {1:N}", j.GetStick()[0], j.GetStick()[1])); // Joycon has no magnetometer, so it cannot accurately determine its yaw value. Joycon.Recenter allows the user to reset the yaw value. j.Recenter(); } // GetButtonDown checks if a button has been released if (j.GetButtonDown(Joycon.Button.DPAD_DOWN)) { Debug.Log("Rumble"); // Rumble for 200 milliseconds, with low frequency rumble at 160 Hz and high frequency rumble at 320 Hz. For more information check: // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md j.SetRumble(160, 320, 0.6f, 200); // The last argument (time) in SetRumble is optional. Call it with three arguments to turn it on without telling it when to turn off. // (Useful for dynamically changing rumble values.) // Then call SetRumble(0,0,0) when you want to turn it off. } stick = j.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); if (accel.magnitude > 3) { j.SetRumble(50, 50, 5.0f, 1000); } orientation = j.GetVector(); /*if (j.GetButton(Joycon.Button.DPAD_UP)) * { * gameObject.GetComponent<Renderer>().material.color = Color.red; * } * else * { * gameObject.GetComponent<Renderer>().material.color = Color.blue; * }*/ /*orientation.y = 0; * orientation.x = 0; * gameObject.transform.rotation = orientation;*/ } }
// Update is called once per frame void Update() { // make sure the Joycon only gets checked if attached if (joycons.Count > 0) { Joycon j = joycons[jc_ind]; // GetButtonDown checks if a button has been pressed (not held) if (j.GetButtonDown(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 pressed"); // GetStick returns a 2-element vector with x/y joystick components Debug.Log(string.Format("Stick x: {0:N} Stick y: {1:N}", j.GetStick()[0], j.GetStick()[1])); // Joycon has no magnetometer, so it cannot accurately determine its yaw value. Joycon.Recenter allows the user to reset the yaw value. j.Recenter(); } // GetButtonDown checks if a button has been released if (j.GetButtonUp(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 released"); } // GetButtonDown checks if a button is currently down (pressed or held) //Sets win condition if (joycons[0].GetButton(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 held"); for (int x = 0; x < joycons.Count; x++) { if (j.GetButton(Joycon.Button.SHOULDER_2)) { winner = jc_ind; Debug.Log(winner); } } } if (j.GetButtonDown(Joycon.Button.DPAD_DOWN)) { Debug.Log("Rumble"); // Rumble for 200 milliseconds, with low frequency rumble at 160 Hz and high frequency rumble at 320 Hz. For more information check: // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md j.SetRumble(160, 320, 0.6f, 200); // The last argument (time) in SetRumble is optional. Call it with three arguments to turn it on without telling it when to turn off. // (Useful for dynamically changing rumble values.) // Then call SetRumble(0,0,0) when you want to turn it off. } stick = j.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); //sends out rumble signal if movement is sensed //determines whether someone needs to go back or not if (gyro.x >= 1 || gyro.y >= 1 || gyro.z >= 1 || accel.x >= 1 || accel.y >= 1 || accel.z >= 1 && isRed == true) //Debug.Log(jc_ind + "go back"); { whoGoesBack = jc_ind; j.SetRumble(160, 320, 0.6f, 200); someoneGoesBack = true; } else { someoneGoesBack = false; } orientation = j.GetVector(); if (j.GetButton(Joycon.Button.DPAD_UP) && jc_ind == 0) { gameObject.GetComponent <Renderer>().material.color = Color.green; isRed = true; Debug.Log("dragon is asleep"); } else { gameObject.GetComponent <Renderer>().material.color = Color.red; isRed = true; Debug.Log("dragon is awake"); } //gameObject.transform.rotation = orientation; } }
// Update is called once per frame void Update() { // make sure the Joycon only gets checked if attached if (j != null) { // GetButtonDown checks if a button has been pressed (not held) if (j.GetButtonDown(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 pressed"); // GetStick returns a 2-element vector with x/y joystick components Debug.Log(string.Format("Stick x: {0:N} Stick y: {1:N}", j.GetStick()[0], j.GetStick()[1])); // Joycon has no magnetometer, so it cannot accurately determine its yaw value. Joycon.Recenter allows the user to reset the yaw value. j.Recenter(); } // GetButtonDown checks if a button has been released if (j.GetButtonUp(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 released"); } // GetButtonDown checks if a button is currently down (pressed or held) if (j.GetButton(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 held"); } if (j.GetButtonDown(Joycon.Button.DPAD_DOWN)) { Debug.Log("Rumble"); // Rumble for 200 milliseconds, with low frequency rumble at 160 Hz and high frequency rumble at 320 Hz. For more information check: // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md j.SetRumble(160, 320, 0.6f, 200); // The last argument (time) in SetRumble is optional. Call it with three arguments to turn it on without telling it when to turn off. // (Useful for dynamically changing rumble values.) // Then call SetRumble(0,0,0) when you want to turn it off. } stick = j.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); if (gyro.y < -1) { Debug.Log("l'avant tourne vers le bas "); } if (gyro.y > 1) { Debug.Log("l'avant tourne vers nous "); } // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); /* * if (accel.x > 1) * Debug.Log("pointe vers la haut"); * if (accel.x < -1) * Debug.Log("pointe vers le bas"); * if (accel.z < -0.99) * Debug.Log("a plat"); * if (accel.z > 0.99) * Debug.Log("a l'envers"); * if (accel.y > 1) * Debug.Log("sur la tranche, posé sur le rail"); * if (accel.y < -1) * Debug.Log("sur la tranche, rail vers le haut"); */ orientation = j.GetVector(); if (j.GetButton(Joycon.Button.DPAD_UP)) { gameObject.GetComponent <Renderer>().material.color = Color.red; } else { gameObject.GetComponent <Renderer>().material.color = Color.blue; } gameObject.transform.RotateAround(gameObject.transform.localPosition, transform.forward, -gyro.z); gameObject.transform.RotateAround(gameObject.transform.localPosition, transform.right, -gyro.y); gameObject.transform.RotateAround(gameObject.transform.localPosition, transform.up, -gyro.x); // gameObject.transform.rotation = orientation; } }
// Update is called once per frame void Update() { // make sure the Joycon only gets checked if attached if (joycons.Count > 0) { Joycon j = joycons[jc_ind]; // GetButtonDown checks if a button has been pressed (not held) if (j.GetButtonDown(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 pressed"); // GetStick returns a 2-element vector with x/y joystick components Debug.Log(string.Format("Stick x: {0:N} Stick y: {1:N}", j.GetStick()[0], j.GetStick()[1])); // Joycon has no magnetometer, so it cannot accurately determine its yaw value. Joycon.Recenter allows the user to reset the yaw value. j.Recenter(); gameObject.transform.position = Vector3.zero; } // GetButtonDown checks if a button has been released if (j.GetButtonUp(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 released"); } // GetButtonDown checks if a button is currently down (pressed or held) if (j.GetButton(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 held"); } if (j.GetButtonDown(Joycon.Button.DPAD_DOWN)) { Debug.Log("Rumble"); // Rumble for 200 milliseconds, with low frequency rumble at 160 Hz and high frequency rumble at 320 Hz. For more information check: // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md j.SetRumble(160, 320, 0.6f, 200); // The last argument (time) in SetRumble is optional. Call it with three arguments to turn it on without telling it when to turn off. // (Useful for dynamically changing rumble values.) // Then call SetRumble(0,0,0) when you want to turn it off. } if (j.GetButton(Joycon.Button.DPAD_UP)) { gameObject.GetComponent <Renderer>().material.color = Color.red; } else { gameObject.GetComponent <Renderer>().material.color = Color.yellow; } stick = j.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); accel1 = j.GetAccel1(); accel2 = j.GetAccel2(); accel3 = j.GetAccel3(); bool isMoving = false; bool debug = false; if (gyro.x > angle_mort || gyro.x < -angle_mort || debug) { isMoving = true; orientation.x = j.GetVector().x; } if (gyro.y > angle_mort || gyro.y < -angle_mort || debug) { isMoving = true; orientation.y = j.GetVector().y; } if (gyro.z > angle_mort || gyro.z < -angle_mort || debug) { isMoving = true; orientation.z = j.GetVector().z; } if (isMoving) { orientation.w = j.GetVector().w; gameObject.transform.rotation = orientation; } gameObject.transform.position = new Vector3(accel3.x * vitesse, accel1.y * vitesse, accel3.z * vitesse); cursor1.transform.position = accel1; cursor2.transform.position = accel2; cursor3.transform.position = accel3; cursor4.transform.position = accel1 + accel2 + accel3; } }
private bool ReportToBuffer(Joycon hidReport, byte[] outputData, ref int outIdx) { outputData[outIdx] = 0; bool isLeft = hidReport.isLeft; if (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_LEFT : Joycon.Button.Y)) { outputData[outIdx] |= 0x80; } if (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_DOWN : Joycon.Button.B)) { outputData[outIdx] |= 0x40; } if (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_RIGHT : Joycon.Button.A)) { outputData[outIdx] |= 0x20; } if (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_UP : Joycon.Button.X)) { outputData[outIdx] |= 0x10; } if (hidReport.GetButton(Joycon.Button.PLUS)) { outputData[outIdx] |= 0x08; } if (hidReport.GetButton(isLeft ? Joycon.Button.STICK2 : Joycon.Button.STICK)) { outputData[outIdx] |= 0x04; } if (hidReport.GetButton(isLeft ? Joycon.Button.STICK : Joycon.Button.STICK2)) { outputData[outIdx] |= 0x02; } if (hidReport.GetButton(Joycon.Button.MINUS)) { outputData[outIdx] |= 0x01; } outputData[++outIdx] = 0; if (hidReport.GetButton(!swapXY ? (isLeft ? Joycon.Button.Y : Joycon.Button.DPAD_LEFT) : (isLeft ? Joycon.Button.X : Joycon.Button.DPAD_UP))) { outputData[outIdx] |= 0x80; } if (hidReport.GetButton(!swapAB ? (isLeft ? Joycon.Button.B : Joycon.Button.DPAD_DOWN) : (isLeft ? Joycon.Button.A : Joycon.Button.DPAD_RIGHT))) { outputData[outIdx] |= 0x40; } if (hidReport.GetButton(!swapAB ? (isLeft ? Joycon.Button.A : Joycon.Button.DPAD_RIGHT) : (isLeft ? Joycon.Button.B : Joycon.Button.DPAD_DOWN))) { outputData[outIdx] |= 0x20; } if (hidReport.GetButton(!swapXY ? (isLeft ? Joycon.Button.X : Joycon.Button.DPAD_UP) : (isLeft ? Joycon.Button.Y : Joycon.Button.DPAD_LEFT))) { outputData[outIdx] |= 0x10; } if (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER2_1 : Joycon.Button.SHOULDER_1)) { outputData[outIdx] |= 0x08; } if (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER_1 : Joycon.Button.SHOULDER2_1)) { outputData[outIdx] |= 0x04; } if (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER2_2 : Joycon.Button.SHOULDER_2)) { outputData[outIdx] |= 0x02; } if (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER_2 : Joycon.Button.SHOULDER2_2)) { outputData[outIdx] |= 0x01; } outputData[++outIdx] = (hidReport.GetButton(Joycon.Button.HOME)) ? (byte)1 : (byte)0; outputData[++outIdx] = 0; // no touch pad float[] leftStick = hidReport.GetStick(); // 127 is 0 outputData[++outIdx] = (byte)(Math.Max(0, Math.Min(255, 127 + leftStick[0] * 127))); outputData[++outIdx] = (byte)(Math.Max(0, Math.Min(255, 127 + leftStick[1] * 127))); float[] rightStick = hidReport.GetStick2(); // 127 is 0 outputData[++outIdx] = (byte)(Math.Max(0, Math.Min(255, 127 + rightStick[0] * 127))); outputData[++outIdx] = (byte)(Math.Max(0, Math.Min(255, 127 + rightStick[1] * 127))); //we don't have analog buttons so just use the Button enums (which give either 0 or 0xFF) outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_LEFT : Joycon.Button.Y)) ? (byte)0xFF : (byte)0; outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_DOWN : Joycon.Button.B)) ? (byte)0xFF : (byte)0; outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_RIGHT : Joycon.Button.A)) ? (byte)0xFF : (byte)0; outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.DPAD_UP : Joycon.Button.X)) ? (byte)0xFF : (byte)0; outputData[++outIdx] = (hidReport.GetButton(!swapXY ? (isLeft ? Joycon.Button.Y : Joycon.Button.DPAD_LEFT) : (isLeft ? Joycon.Button.X : Joycon.Button.DPAD_UP))) ? (byte)0xFF : (byte)0; outputData[++outIdx] = (hidReport.GetButton(!swapAB ? (isLeft ? Joycon.Button.B : Joycon.Button.DPAD_DOWN) : (isLeft ? Joycon.Button.A : Joycon.Button.DPAD_RIGHT))) ? (byte)0xFF : (byte)0; outputData[++outIdx] = (hidReport.GetButton(!swapAB ? (isLeft ? Joycon.Button.A : Joycon.Button.DPAD_RIGHT) : (isLeft ? Joycon.Button.B : Joycon.Button.DPAD_DOWN))) ? (byte)0xFF : (byte)0; outputData[++outIdx] = (hidReport.GetButton(!swapXY ? (isLeft ? Joycon.Button.X : Joycon.Button.DPAD_UP) : (isLeft ? Joycon.Button.Y : Joycon.Button.DPAD_LEFT))) ? (byte)0xFF : (byte)0; outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER2_1 : Joycon.Button.SHOULDER_1)) ? (byte)0xFF : (byte)0; outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER_1 : Joycon.Button.SHOULDER2_1)) ? (byte)0xFF : (byte)0; outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER2_2 : Joycon.Button.SHOULDER_2)) ? (byte)0xFF : (byte)0; outputData[++outIdx] = (hidReport.GetButton(isLeft ? Joycon.Button.SHOULDER_2 : Joycon.Button.SHOULDER2_2)) ? (byte)0xFF : (byte)0; outIdx++; //DS4 only: touchpad points for (int i = 0; i < 2; i++) { outIdx += 6; } //motion timestamp Array.Copy(BitConverter.GetBytes(hidReport.Timestamp), 0, outputData, outIdx, 8); outIdx += 8; //accelerometer { var accel = hidReport.GetAccel(); if (accel != null) { Array.Copy(BitConverter.GetBytes(accel.Y), 0, outputData, outIdx, 4); outIdx += 4; Array.Copy(BitConverter.GetBytes(-accel.Z), 0, outputData, outIdx, 4); outIdx += 4; Array.Copy(BitConverter.GetBytes(accel.X), 0, outputData, outIdx, 4); outIdx += 4; } else { outIdx += 12; Console.WriteLine("No accelerometer reported."); } } //gyroscope { var gyro = hidReport.GetGyro(); if (gyro != null) { Array.Copy(BitConverter.GetBytes(gyro.Y), 0, outputData, outIdx, 4); outIdx += 4; Array.Copy(BitConverter.GetBytes(gyro.Z), 0, outputData, outIdx, 4); outIdx += 4; Array.Copy(BitConverter.GetBytes(gyro.X), 0, outputData, outIdx, 4); outIdx += 4; } else { outIdx += 12; Console.WriteLine("No gyroscope reported."); } } return(true); }
void JoyconMethod() { // make sure the Joycon only gets checked if attached if (joycons.Count > 0) { Joycon j = joycons [jc_ind]; // GetButtonDown checks if a button has been pressed (not held) if (canSpawnSpriteMask) { if (j.GetButtonDown(Joycon.Button.SHOULDER_2) && !isCuttingAnim) { //Debug.Log ("Shoulder button 2 pressed"); j.SetRumble(160, 320, 0.6f, 200); Shrink spriteMask = Instantiate(spriteMaskPrefab, transform.position, transform.rotation); spriteMask.playerRedController = this; numOfMasksSpawnable--; isCuttingAnim = true; audio.Play(); } } // GetButtonDown checks if a button has been released if (j.GetButtonUp(Joycon.Button.SHOULDER_2)) { //Debug.Log ("Shoulder button 2 released"); isCuttingAnim = false; } // GetButtonDown checks if a button is currently down (pressed or held) if (j.GetButton(Joycon.Button.SHOULDER_2)) { //Debug.Log ("Shoulder button 2 held"); } if (j.GetButtonDown(Joycon.Button.DPAD_DOWN)) { //Debug.Log ("Rumble"); // Rumble for 200 milliseconds, with low frequency rumble at 160 Hz and high frequency rumble at 320 Hz. For more information check: // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md //j.SetRumble (160, 320, 0.6f, 200); // The last argument (time) in SetRumble is optional. Call it with three arguments to turn it on without telling it when to turn off. // (Useful for dynamically changing rumble values.) // Then call SetRumble(0,0,0) when you want to turn it off. } stick = j.GetStick(); // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); orientation = j.GetVector(); if (j.GetButton(Joycon.Button.DPAD_UP)) { transform.Translate(0f, moveSpeedY, 0f, Space.World); } else { } if (j.GetButton(Joycon.Button.DPAD_DOWN)) { transform.Translate(0f, -moveSpeedY, 0f, Space.World); } else { } if (j.GetButton(Joycon.Button.DPAD_LEFT)) { transform.Translate(-moveSpeedX, 0f, 0f, Space.World); } else { } if (j.GetButton(Joycon.Button.DPAD_RIGHT)) { transform.Translate(moveSpeedX, 0f, 0f, Space.World); } else { } float zOnly = orientation.eulerAngles.z; Vector3 newRot = new Vector3(gameObject.transform.localRotation.x, gameObject.transform.localRotation.y, zOnly); //gameObject.transform.eulerAngles = newRot; Quaternion targetRotation = Quaternion.Euler(newRot); transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, degreesPerSec * Time.deltaTime); //gameObject.transform.rotation = orientation; } }
// Update is called once per frame void Update() { // make sure the Joycon only gets checked if attached if (j != null && j.state > Joycon.state_.ATTACHED) { // Gyro values: x, y, z axis values (in radians per second) gyro = j.GetGyro(); // Accel values: x, y, z axis values (in Gs) accel = j.GetAccel(); stick = j.GetStick(); orientation = j.GetVector(); gameObject.transform.rotation = orientation; //Test motion detection //x-rotation -> turn tetrimino //z-rotation -> move tetrimino //tilt forward (rotation.Y and rotation.Z negative) -> make tetrimino go faster if (gyro.x <= -20 && !_isMoving) { Debug.Log(gyro.x); StartCoroutine(TurnLeft()); } if (gyro.x >= 20 && !_isMoving) { Debug.Log(gyro.x); StartCoroutine(TurnRight()); } if (gyro.z <= -5 && !_isMoving) { Debug.Log(gyro.z); StartCoroutine(MoveLeft()); } if (gyro.z >= 5 && !_isMoving) { Debug.Log(gyro.z); StartCoroutine(MoveRight()); } if (orientation.w < 0.44) { Debug.Log("Tetrimino falling faster"); } // GetButtonDown checks if a button has been pressed (not held) if (j.GetButtonDown(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 pressed"); // GetStick returns a 2-element vector with x/y joystick components Debug.Log(string.Format("Stick x: {0:N} Stick y: {1:N}", j.GetStick()[0], j.GetStick()[1])); // Joycon has no magnetometer, so it cannot accurately determine its yaw value. Joycon.Recenter allows the user to reset the yaw value. j.Recenter(); } // GetButtonDown checks if a button has been released if (j.GetButtonUp(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 released"); } // GetButtonDown checks if a button is currently down (pressed or held) if (j.GetButton(Joycon.Button.SHOULDER_2)) { Debug.Log("Shoulder button 2 held"); } if (j.GetButtonDown(Joycon.Button.DPAD_DOWN)) { Debug.Log("Rumble"); // Rumble for 200 milliseconds, with low frequency rumble at 160 Hz and high frequency rumble at 320 Hz. For more information check: // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md j.SetRumble(160, 320, 0.6f, 200); // The last argument (time) in SetRumble is optional. Call it with three arguments to turn it on without telling it when to turn off. // (Useful for dynamically changing rumble values.) // Then call SetRumble(0,0,0) when you want to turn it off. } if (j.GetButtonDown(Joycon.Button.DPAD_LEFT)) { j.Recenter(); } } }