add unity project
add FSM examples
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace DefaultNamespace
|
||||
{
|
||||
public class FireButton : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private InputAction _inputAction;
|
||||
|
||||
private bool _isPressed;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_inputAction.Enable();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_inputAction.Disable();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
_isPressed = _isPressed || _inputAction.triggered;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (_isPressed)
|
||||
{
|
||||
_isPressed = false;
|
||||
// spawn bullet
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user