예제 #1
0
    //calling default vibration
    public void Vibration(int playerId)
    {
#if UNITY_SWITCH
        foreach (Joystick joystick in ReInput.players.GetPlayer(playerId).controllers.Joysticks)
        {
            // Get the Switch Gamepad Extension from the Joystick
            ISwitchVibrationDevice ext = joystick.GetExtension <ISwitchVibrationDevice>();
            if (ext != null)
            {
                // Create a new SwitchVibration
                // You could also use the SetVibration overload that takes 5 float values instead
                SwitchVibration vib = new SwitchVibration()
                {
                    amplitudeLow  = 1f,
                    frequencyLow  = 50,
                    amplitudeHigh = 0.5f,
                    frequencyHigh = 100
                };

                // Send the vibration to the controller
                for (int i = 0; i < ext.vibrationMotorCount; i++)
                {
                    ext.SetVibration(i, vib); // set vibration in each motor
                }
            }
        }
#endif
    }
예제 #2
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "DustBox")
        {
            //フラグ関連
            Hold     = false;
            GameOver = true;
            //フィールドマネージャー情報を渡す
            FieldManeger.Instance.PlayerGameOvers[playerNumber] = true;
            //爆弾を持っていたら消す
            Destroy(ShootObject);
        }

        if (other.tag == "Bomb")
        {
            //爆弾の位置
            Vector3 BombPos = other.gameObject.transform.position;
            //爆弾のyの数値を合わせる そうしないと変な方向を向く
            BombPos.y = transform.position.y;
            //爆弾の方を向く
            transform.LookAt(BombPos);
            //吹っ飛ぶ力を設定 bombimpactは爆弾側で設定している
            Vector3 force = transform.position - (transform.forward * bombimpact);
            //後ろに吹っ飛ぶ
            rb.AddForce(force, ForceMode.Impulse);
            //上に吹っ飛ぶ
            rb.AddForce(Vector3.up * 300.0f);
            //振動
            Pad   = true;
            Timer = 0.5f;
            SwitchVibration.LowVibration(playerNumber, 0.3f);
        }
    }
예제 #3
0
 void Controller()
 {
     Timer -= Time.deltaTime;
     if (Timer <= 0)
     {
         Pad = false;
         SwitchVibration.LowVibration(playerNumber, 0.0f);
     }
 }
예제 #4
0
 private void OnDestroy()
 {
     SwitchVibration.LowVibration(playerNumber, 0.0f);
 }