study/first_study/Library/PackageCache/com.unity.inputsystem@02433b2481ab/Samples~/LightbarAndRumble/MotorSettings.cs
jh04010421 739d49f1a0 Unity | 2026.01.20
수업 실습 파일
2026-01-20 11:01:57 +09:00

29 lines
695 B
C#

using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.DualShock;
public class MotorSettings : MonoBehaviour
{
[Range(0, 1)] public float lowFrequencyMotorSpeed;
[Range(0, 1)] public float highFrequencyMotorSpeed;
public void SetMotorSpeeds()
{
var gamepad = Gamepad.current;
if (gamepad != null)
{
Debug.Log("Current gamepad: " + gamepad);
gamepad.SetMotorSpeeds(lowFrequencyMotorSpeed, highFrequencyMotorSpeed);
}
}
private void OnDisable()
{
var gamepad = Gamepad.current;
if (gamepad != null)
{
gamepad.SetMotorSpeeds(0, 0);
}
}
}