Compare commits
4 Commits
8919a69e50
...
cf70287797
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf70287797 | ||
|
|
4bd307fba8 | ||
|
|
e49909580c | ||
|
|
30509b3714 |
@@ -12,10 +12,13 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: f945e777233a59f4aba40aeca29093a6, type: 3}
|
m_Script: {fileID: 11500000, guid: f945e777233a59f4aba40aeca29093a6, type: 3}
|
||||||
m_Name: TestEnemyCombatFSM
|
m_Name: TestEnemyCombatFSM
|
||||||
m_EditorClassIdentifier: NodeCanvas::NodeCanvas.StateMachines.FSM
|
m_EditorClassIdentifier: NodeCanvas::NodeCanvas.StateMachines.FSM
|
||||||
_serializedGraph: '{"type":"NodeCanvas.StateMachines.FSM","nodes":[{"_actionList":{"executionMode":1,"actions":[]},"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_name":"Circling
|
_serializedGraph: '{"type":"NodeCanvas.StateMachines.FSM","nodes":[{"_actionList":{"executionMode":1,"actions":[{"pauseIntervalRange":{"_value":{"x":1.0,"y":3.0}},"unpauseIntervalRange":{"_value":{"x":1.0,"y":3.0}},"speedRange":{"_value":{"x":1.0,"y":3.0}},"speedChangeIntervalRange":{"_value":{"x":1.0,"y":3.0}},"speedSmoothing":{"_value":0.5},"strafeDirectionChangeInterval":{"_value":{"x":1.0,"y":3.0}},"directionSmoothing":{"_value":0.5},"$type":"Reset.Units.CircleTarget"}]},"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_name":"Circling
|
||||||
Movement","_position":{"x":589.0,"y":145.0},"$type":"NodeCanvas.StateMachines.ActionState","$id":"0"},{"_name":"Try
|
Movement","_position":{"x":589.0,"y":145.0},"$type":"NodeCanvas.StateMachines.ActionState","$id":"0"},{"_name":"Try
|
||||||
to Attack","_position":{"x":991.0,"y":421.0},"$type":"NodeCanvas.StateMachines.EmptyState","$id":"1"},{"_nestedBT":{"_value":1},"executionMode":0,"_variablesMap":[{"_targetSubGraphVariableID":"c96d2e2b-e09d-4abc-a287-3e6821b42c4b","_canWrite":true,"_type":"UnityEngine.Animator","_name":"bodyAnimator","_targetVariableID":"00b78a8a-fb9e-44d0-b9a8-81c6992abd41"}],"_position":{"x":1213.0,"y":503.0},"$type":"NodeCanvas.StateMachines.NestedBTState","$id":"2"},{"_onEnterList":{"executionMode":1,"actions":[]},"_onUpdateList":{"executionMode":1,"actions":[]},"_onExitList":{"executionMode":1,"actions":[]},"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_name":"Walk
|
to Attack","_position":{"x":805.0,"y":384.0},"$type":"NodeCanvas.StateMachines.EmptyState","$id":"1"},{"_nestedBT":{"_value":1},"executionMode":0,"_variablesMap":[{"_targetSubGraphVariableID":"c96d2e2b-e09d-4abc-a287-3e6821b42c4b","_canWrite":true,"_type":"UnityEngine.Animator","_name":"bodyAnimator","_targetVariableID":"00b78a8a-fb9e-44d0-b9a8-81c6992abd41"}],"_position":{"x":1007.0,"y":209.0},"$type":"NodeCanvas.StateMachines.NestedBTState","$id":"2"},{"_onEnterList":{"executionMode":1,"actions":[{"value":{"_value":true},"$type":"Reset.Units.TogglePathfinding"}]},"_onUpdateList":{"executionMode":1,"actions":[]},"_onExitList":{"executionMode":1,"actions":[{"value":{},"$type":"Reset.Units.TogglePathfinding"}]},"foldEnter":true,"foldExit":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_name":"Walk
|
||||||
To Target","_position":{"x":256.0,"y":-182.0},"$type":"NodeCanvas.StateMachines.SuperActionState","$id":"3"}],"connections":[{"_condition":{"timeout":{"_value":1.0},"$type":"NodeCanvas.Tasks.Conditions.Timeout"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"target":{"_name":"target","_targetVariableID":"4a2889be-2a8a-4a68-ab49-fa456e2c9a19"},"maxDistance":{"_value":15.0},"layerMask":{"_value":{"value":255}},"awarnessDistance":{},"viewAngle":{"_value":90.0},"_invert":true,"$type":"NodeCanvas.Tasks.Conditions.CanSeeTarget"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"3"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"probability":{"_value":1.0},"maxValue":{"_value":4.0},"$type":"NodeCanvas.Tasks.Conditions.Probability"},"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"0"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"target":{"_name":"target","_targetVariableID":"4a2889be-2a8a-4a68-ab49-fa456e2c9a19"},"maxDistance":{"_value":15.0},"layerMask":{"_value":{"value":255}},"awarnessDistance":{},"viewAngle":{"_value":90.0},"$type":"NodeCanvas.Tasks.Conditions.CanSeeTarget"},"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"0"},"$type":"NodeCanvas.StateMachines.FSMConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{"testModelAnimator":{"_name":"testModelAnimator","_id":"7222df40-dd9e-41ce-a85a-a5221009180e","_isPublic":true,"$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.Animator,
|
To Target","_position":{"x":305.0,"y":-146.0},"$type":"NodeCanvas.StateMachines.SuperActionState","$id":"3"},{"_actionList":{"executionMode":1,"actions":[]},"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_name":"Target
|
||||||
|
Too Close","_position":{"x":318.0,"y":369.0},"$type":"NodeCanvas.StateMachines.ActionState","$id":"4"},{"_conditionList":{"conditions":[]},"_actionList":{"executionMode":1,"actions":[{"facingDirection":{"label":"Facing
|
||||||
|
Direction","value":{"_value":{"$content":0,"$type":"Reset.Units.UnitFacingDirection"}},"changeValue":{"_value":1}},"rotationSpeed":{"label":"Rotation
|
||||||
|
Speed","changeValue":{},"value":{},"_changeSmoothing":{},"_smoothing":{},"_changeEasing":{},"_easing":{}},"$type":"Reset.Units.ChangeRotationSettings"},{"value":{},"$type":"Reset.Units.TogglePathfinding"}]},"_position":{"x":774.0,"y":-16.0},"$type":"NodeCanvas.StateMachines.OnFSMEnter"}],"connections":[{"_condition":{"timeout":{"_value":1.0},"$type":"NodeCanvas.Tasks.Conditions.Timeout"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"conditions":[{"target":{"_name":"target","_targetVariableID":"6661b63d-1d1f-4620-945e-7769012891f2"},"maxDistance":{"_value":15.0},"layerMask":{"_value":{"value":255}},"awarnessDistance":{},"viewAngle":{"_value":90.0},"_invert":true,"$type":"NodeCanvas.Tasks.Conditions.CanSeeTarget"},{"checkTarget":{"_name":"target","_targetVariableID":"6661b63d-1d1f-4620-945e-7769012891f2"},"checkType":1,"distance":{"_value":10.0},"$type":"NodeCanvas.Tasks.Conditions.CheckDistanceToGameObject"}],"$type":"NodeCanvas.Framework.ConditionList"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"3"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"checkTarget":{"_name":"target","_targetVariableID":"6661b63d-1d1f-4620-945e-7769012891f2"},"distance":{"_value":2.0},"$type":"NodeCanvas.Tasks.Conditions.CheckDistanceToGameObject"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"4"},"_isDisabled":true,"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"probability":{"_value":1.0},"maxValue":{"_value":4.0},"$type":"NodeCanvas.Tasks.Conditions.Probability"},"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"0"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_sourceNode":{"$ref":"2"},"_targetNode":{"$ref":"0"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"conditions":[{"target":{"_name":"target","_targetVariableID":"6661b63d-1d1f-4620-945e-7769012891f2"},"maxDistance":{"_value":15.0},"layerMask":{"_value":{"value":255}},"awarnessDistance":{},"viewAngle":{"_value":90.0},"$type":"NodeCanvas.Tasks.Conditions.CanSeeTarget"},{"checkTarget":{"_name":"target","_targetVariableID":"6661b63d-1d1f-4620-945e-7769012891f2"},"distance":{"_value":10.0},"$type":"NodeCanvas.Tasks.Conditions.CheckDistanceToGameObject"}],"$type":"NodeCanvas.Framework.ConditionList"},"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"0"},"$type":"NodeCanvas.StateMachines.FSMConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{"testModelAnimator":{"_name":"testModelAnimator","_id":"7222df40-dd9e-41ce-a85a-a5221009180e","_isPublic":true,"$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.Animator,
|
||||||
UnityEngine.AnimationModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},"bodyAnimator":{"_name":"bodyAnimator","_id":"00b78a8a-fb9e-44d0-b9a8-81c6992abd41","_isPublic":true,"$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.Animator,
|
UnityEngine.AnimationModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},"bodyAnimator":{"_name":"bodyAnimator","_id":"00b78a8a-fb9e-44d0-b9a8-81c6992abd41","_isPublic":true,"$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.Animator,
|
||||||
UnityEngine.AnimationModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}}}}'
|
UnityEngine.AnimationModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}}}}'
|
||||||
_objectReferences:
|
_objectReferences:
|
||||||
@@ -25,7 +28,7 @@ MonoBehaviour:
|
|||||||
_version: 3.31
|
_version: 3.31
|
||||||
_category:
|
_category:
|
||||||
_comments:
|
_comments:
|
||||||
_translation: {x: 132, y: 296}
|
_translation: {x: 290, y: 452}
|
||||||
_zoomFactor: 1
|
_zoomFactor: 1
|
||||||
_haltSerialization: 0
|
_haltSerialization: 0
|
||||||
_externalSerializationFile: {fileID: 0}
|
_externalSerializationFile: {fileID: 0}
|
||||||
|
|||||||
164
Assets/Scripts/Units/Graph Tasks/CircleTarget.cs
Normal file
164
Assets/Scripts/Units/Graph Tasks/CircleTarget.cs
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
using System;
|
||||||
|
using NodeCanvas.Framework;
|
||||||
|
using ParadoxNotion.Design;
|
||||||
|
using Sirenix.Utilities;
|
||||||
|
using UnityEngine;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Reset.Units {
|
||||||
|
|
||||||
|
[Category("Reset/Units")]
|
||||||
|
[Description("Gives the unit a new direction that causes them to circle the target.")]
|
||||||
|
public class CircleTarget : ActionTask<UnitMovementHandler>{
|
||||||
|
enum StrafeDirection{
|
||||||
|
Forward = 0, Backwards, Left, Right
|
||||||
|
}
|
||||||
|
|
||||||
|
// References
|
||||||
|
private IUnitTargetProvider targetProvider;
|
||||||
|
|
||||||
|
// Pause settings
|
||||||
|
[Description("How long will this unit wait to stop moving and pause")]
|
||||||
|
public BBParameter<Vector2> pauseIntervalRange;
|
||||||
|
[Description("How long this unit will within paused movement")]
|
||||||
|
public BBParameter<Vector2> unpauseIntervalRange;
|
||||||
|
|
||||||
|
// Speed settings
|
||||||
|
public BBParameter<Vector2> speedRange;
|
||||||
|
[Description("How long this unit will wait before switching movement speed")]
|
||||||
|
public BBParameter<Vector2> speedChangeIntervalRange;
|
||||||
|
[SliderField(0, 1)]
|
||||||
|
public BBParameter<float> speedSmoothing;
|
||||||
|
|
||||||
|
// Strafe direction settings
|
||||||
|
[Description("How long this unit will wait before switching strafe direction")]
|
||||||
|
public BBParameter<Vector2> strafeDirectionChangeInterval;
|
||||||
|
[SliderField(0, 1)]
|
||||||
|
public BBParameter<float> directionSmoothing;
|
||||||
|
|
||||||
|
// Pause state management
|
||||||
|
private bool strafePaused;
|
||||||
|
private float lastPauseEnterTime;
|
||||||
|
private float lastPauseExitTime;
|
||||||
|
private float pauseChangeTimeElapsed;
|
||||||
|
private float nextPauseChangeTime;
|
||||||
|
|
||||||
|
// Direct state management
|
||||||
|
private float lastDirectionChangeTime;
|
||||||
|
private float directionChangeTimeElapsed;
|
||||||
|
private StrafeDirection currentStrafeDirection;
|
||||||
|
private float nextDirectionChangeTime;
|
||||||
|
|
||||||
|
// Speed state management
|
||||||
|
private float lastSpeedChangeTime;
|
||||||
|
private float speedChangeTimeElapsed;
|
||||||
|
private float currentSpeed;
|
||||||
|
private float nextSpeedChangeTime;
|
||||||
|
|
||||||
|
//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() {
|
||||||
|
if (pauseIntervalRange.value == Vector2.zero){ Debug.LogError($"Please set a setting for pause intervals on {agent.name}", agent.gameObject);}
|
||||||
|
if (unpauseIntervalRange.value == Vector2.zero){ Debug.LogError($"Please set a setting for unpause intervals on {agent.name}", agent.gameObject);}
|
||||||
|
if (speedRange.value == Vector2.zero){ Debug.LogError($"Please set a setting for speed range on {agent.name}", agent.gameObject);}
|
||||||
|
if (speedChangeIntervalRange.value == Vector2.zero){ Debug.LogError($"Please set a setting for speed change intervals on {agent.name}", agent.gameObject);}
|
||||||
|
if (strafeDirectionChangeInterval.value == Vector2.zero){ Debug.LogError($"Please set a setting for strafe direction change intervals on {agent.name}", agent.gameObject);}
|
||||||
|
|
||||||
|
// Get reference to target provider
|
||||||
|
targetProvider = agent.gameObject.GetComponent<IUnitTargetProvider>();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//This is called once each time the task is enabled.
|
||||||
|
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||||
|
//EndAction can be called from anywhere.
|
||||||
|
protected override void OnExecute(){
|
||||||
|
// Reset timers
|
||||||
|
lastPauseEnterTime = 0f;
|
||||||
|
lastPauseExitTime = 0f;
|
||||||
|
pauseChangeTimeElapsed = 0f;
|
||||||
|
lastDirectionChangeTime = 0f;
|
||||||
|
directionChangeTimeElapsed = 0f;
|
||||||
|
|
||||||
|
// Initialize with direction
|
||||||
|
currentStrafeDirection = (StrafeDirection)Random.Range(0, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called once per frame while the action is active.
|
||||||
|
protected override void OnUpdate() {
|
||||||
|
// Set a new direction
|
||||||
|
agent.SetNewDirection(GetVector3Direction().ToVector2(), directionSmoothing.value, true);
|
||||||
|
|
||||||
|
// Set paused or set new speed if unpaused
|
||||||
|
if (strafePaused) {
|
||||||
|
agent.SetNewSpeed(0f, speedSmoothing.value, true);
|
||||||
|
} else {
|
||||||
|
agent.SetNewSpeed(currentSpeed, speedSmoothing.value, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the timers
|
||||||
|
CheckForChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to quickly transform a strafe direction into a Vector3
|
||||||
|
Vector3 GetVector3Direction(){
|
||||||
|
switch (currentStrafeDirection) {
|
||||||
|
case StrafeDirection.Forward:
|
||||||
|
return agent.transform.position.DirectionTo(targetProvider.UnitTarget.transform.position);
|
||||||
|
case StrafeDirection.Backwards:
|
||||||
|
return -agent.transform.position.DirectionTo(targetProvider.UnitTarget.transform.position);
|
||||||
|
case StrafeDirection.Left:
|
||||||
|
return Quaternion.AngleAxis(-90f, Vector3.up) * agent.transform.position.DirectionTo(targetProvider.UnitTarget.transform.position);
|
||||||
|
case StrafeDirection.Right:
|
||||||
|
return Quaternion.AngleAxis(90f, Vector3.up) * agent.transform.position.DirectionTo(targetProvider.UnitTarget.transform.position);
|
||||||
|
default:
|
||||||
|
return Vector3.zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetNewPauseChangeTime(){
|
||||||
|
if (strafePaused) {
|
||||||
|
nextPauseChangeTime = elapsedTime + Random.Range(unpauseIntervalRange.value.x, unpauseIntervalRange.value.y);
|
||||||
|
} else {
|
||||||
|
nextPauseChangeTime = elapsedTime + Random.Range(pauseIntervalRange.value.x, pauseIntervalRange.value.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetNewSpeedChangeTime(){
|
||||||
|
nextSpeedChangeTime = elapsedTime + Random.Range(speedChangeIntervalRange.value.x, speedChangeIntervalRange.value.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetNewDirectionChangeTime(){
|
||||||
|
nextDirectionChangeTime = elapsedTime + Random.Range(strafeDirectionChangeInterval.value.x, strafeDirectionChangeInterval.value.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckForChange(){
|
||||||
|
if (nextPauseChangeTime > elapsedTime) {
|
||||||
|
strafePaused = !strafePaused;
|
||||||
|
SetNewPauseChangeTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextSpeedChangeTime > elapsedTime) {
|
||||||
|
currentSpeed = Random.Range(speedRange.value.x, speedRange.value.y);
|
||||||
|
SetNewSpeedChangeTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextDirectionChangeTime > elapsedTime) {
|
||||||
|
currentStrafeDirection = (StrafeDirection)Random.Range(0, 3);
|
||||||
|
SetNewDirectionChangeTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called when the task is disabled.
|
||||||
|
protected override void OnStop() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called when the task is paused.
|
||||||
|
protected override void OnPause() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Units/Graph Tasks/CircleTarget.cs.meta
Normal file
2
Assets/Scripts/Units/Graph Tasks/CircleTarget.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9f9afac70b34c5e44b747e86f7491aa3
|
||||||
48
Assets/Scripts/Units/Graph Tasks/SetNewPathfindingPath.cs
Normal file
48
Assets/Scripts/Units/Graph Tasks/SetNewPathfindingPath.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
using NodeCanvas.Framework;
|
||||||
|
using ParadoxNotion.Design;
|
||||||
|
using Pathfinding;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Reset.Units {
|
||||||
|
|
||||||
|
[Category("Reset/Units")]
|
||||||
|
[Description("Set a new path towards a provided target")]
|
||||||
|
public class SetNewPathfindingPath : ActionTask<UnitPathfinding> {
|
||||||
|
|
||||||
|
//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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//This is called once each time the task is enabled.
|
||||||
|
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||||
|
//EndAction can be called from anywhere.
|
||||||
|
protected override void OnExecute() {
|
||||||
|
agent.seeker.StartPath(agent.transform.position, agent.GetComponent<IUnitTargetProvider>().UnitTarget.transform.position, OnPathComplete);
|
||||||
|
|
||||||
|
EndAction(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPathComplete(Path p){
|
||||||
|
if (!p.error) {
|
||||||
|
agent.AssignNewPath(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called once per frame while the action is active.
|
||||||
|
protected override void OnUpdate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called when the task is disabled.
|
||||||
|
protected override void OnStop() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called when the task is paused.
|
||||||
|
protected override void OnPause() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 71ce4953752dde3449673b8931aefc00
|
||||||
41
Assets/Scripts/Units/Graph Tasks/TogglePathfinding.cs
Normal file
41
Assets/Scripts/Units/Graph Tasks/TogglePathfinding.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using NodeCanvas.Framework;
|
||||||
|
using ParadoxNotion.Design;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Reset.Units {
|
||||||
|
|
||||||
|
[Category("Reset/Units")]
|
||||||
|
[Description("Set whether this unit can use pathfinding or not.")]
|
||||||
|
public class TogglePathfinding : ActionTask<UnitPathfinding>{
|
||||||
|
public BBParameter<bool> value;
|
||||||
|
|
||||||
|
//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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//This is called once each time the task is enabled.
|
||||||
|
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||||
|
//EndAction can be called from anywhere.
|
||||||
|
protected override void OnExecute(){
|
||||||
|
agent.pathfindingEnabled = value.value;
|
||||||
|
EndAction(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called once per frame while the action is active.
|
||||||
|
protected override void OnUpdate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called when the task is disabled.
|
||||||
|
protected override void OnStop() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called when the task is paused.
|
||||||
|
protected override void OnPause() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e7bebfffaed94604db733c72cde6be7d
|
||||||
@@ -31,7 +31,7 @@ namespace Reset.Units{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void LateUpdate(){
|
private void LateUpdate(){
|
||||||
TurnHead();
|
// TurnHead();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TurnHead(){
|
void TurnHead(){
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace Reset.Units{
|
|||||||
public class UnitPathfinding : UnitComponent, IUnitDirectionProvider{
|
public class UnitPathfinding : UnitComponent, IUnitDirectionProvider{
|
||||||
public Vector2 Direction{ get; set; }
|
public Vector2 Direction{ get; set; }
|
||||||
|
|
||||||
|
public bool pathfindingEnabled;
|
||||||
|
|
||||||
public Seeker seeker;
|
public Seeker seeker;
|
||||||
|
|
||||||
public float nextWaypointDistance = 3;
|
public float nextWaypointDistance = 3;
|
||||||
|
|||||||
Reference in New Issue
Block a user