50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using NodeCanvas.Framework;
|
|
using ParadoxNotion.Design;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
namespace NodeCanvas.Tasks.Conditions {
|
|
|
|
[Category("Reset/Input")]
|
|
[Description("Check if input condition was matched this frame")]
|
|
public class CheckInput : ConditionTask<Transform>{
|
|
public BBParameter<string> actionName;
|
|
public BBParameter<string> actionValue;
|
|
|
|
protected override string info {
|
|
get { return "Player Input"; }
|
|
}
|
|
|
|
private InputAction action;
|
|
|
|
//Use for initialization. This is called only once in the lifetime of the task.
|
|
//Return null if init was successfull. Return an error string otherwise
|
|
protected override string OnInit(){
|
|
return null;
|
|
}
|
|
|
|
//Called whenever the condition gets enabled.
|
|
protected override void OnEnable(){
|
|
action = agent.GetComponent<PlayerInput>().actions.FindAction(actionName.value);
|
|
}
|
|
|
|
//Called whenever the condition gets disabled.
|
|
protected override void OnDisable() {
|
|
|
|
}
|
|
|
|
//Called once per frame while the condition is active.
|
|
//Return whether the condition is success or failure.
|
|
protected override bool OnCheck() {
|
|
// if (action.type == InputActionType.Button){
|
|
if (action.WasPressedThisFrame()) { return true; }
|
|
// } else if (action.type == InputActionType.Value) {
|
|
//
|
|
// }
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|