first commit
This commit is contained in:
49
Assets/Scripts/Core/Graph Tasks/CheckInput.cs
Normal file
49
Assets/Scripts/Core/Graph Tasks/CheckInput.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions {
|
||||
|
||||
[Category("Core")]
|
||||
[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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user