first commit
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa43a8c4734db77489f6576153efdc16
|
||||
folderAsset: yes
|
||||
timeCreated: 1493315486
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,80 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Name("Curve Tween")]
|
||||
[Category("Movement/Direct")]
|
||||
public class CurveTransformTween : ActionTask<Transform>
|
||||
{
|
||||
|
||||
public enum TransformMode
|
||||
{
|
||||
Position,
|
||||
Rotation,
|
||||
Scale
|
||||
}
|
||||
|
||||
public enum TweenMode
|
||||
{
|
||||
Absolute,
|
||||
Additive
|
||||
}
|
||||
|
||||
public enum PlayMode
|
||||
{
|
||||
Normal,
|
||||
PingPong
|
||||
}
|
||||
|
||||
public TransformMode transformMode;
|
||||
public TweenMode mode;
|
||||
public PlayMode playMode;
|
||||
public BBParameter<Vector3> targetPosition;
|
||||
public BBParameter<AnimationCurve> curve = AnimationCurve.EaseInOut(0, 0, 1, 1);
|
||||
public BBParameter<float> time = 0.5f;
|
||||
|
||||
private Vector3 original;
|
||||
private Vector3 final;
|
||||
private bool ponging = false;
|
||||
|
||||
protected override void OnExecute() {
|
||||
|
||||
if ( ponging )
|
||||
final = original;
|
||||
|
||||
if ( transformMode == TransformMode.Position )
|
||||
original = agent.localPosition;
|
||||
if ( transformMode == TransformMode.Rotation )
|
||||
original = agent.localEulerAngles;
|
||||
if ( transformMode == TransformMode.Scale )
|
||||
original = agent.localScale;
|
||||
|
||||
if ( !ponging )
|
||||
final = targetPosition.value + ( mode == TweenMode.Additive ? original : Vector3.zero );
|
||||
|
||||
ponging = playMode == PlayMode.PingPong;
|
||||
|
||||
if ( ( original - final ).magnitude < 0.1f )
|
||||
EndAction();
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
|
||||
var value = Vector3.Lerp(original, final, curve.value.Evaluate(elapsedTime / time.value));
|
||||
|
||||
if ( transformMode == TransformMode.Position )
|
||||
agent.localPosition = value;
|
||||
if ( transformMode == TransformMode.Rotation )
|
||||
agent.localEulerAngles = value;
|
||||
if ( transformMode == TransformMode.Scale )
|
||||
agent.localScale = value;
|
||||
|
||||
if ( elapsedTime >= time.value )
|
||||
EndAction(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30b9a32c147a4ed489bda7e84c3e4a34
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Movement/Direct/CurveTransformTween.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,42 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("Movement/Direct")]
|
||||
[Description("Move & turn the agent based on input values provided ranging from -1 to 1, per second (using delta time)")]
|
||||
public class InputMove : ActionTask<Transform>
|
||||
{
|
||||
|
||||
[BlackboardOnly]
|
||||
public BBParameter<float> strafe;
|
||||
[BlackboardOnly]
|
||||
public BBParameter<float> turn;
|
||||
[BlackboardOnly]
|
||||
public BBParameter<float> forward;
|
||||
[BlackboardOnly]
|
||||
public BBParameter<float> up;
|
||||
|
||||
public BBParameter<float> moveSpeed = 1;
|
||||
public BBParameter<float> rotationSpeed = 1;
|
||||
|
||||
public bool repeat;
|
||||
|
||||
protected override void OnUpdate() {
|
||||
var targetRotation = agent.rotation * Quaternion.Euler(Vector3.up * turn.value * 10);
|
||||
agent.rotation = Quaternion.Slerp(agent.rotation, targetRotation, rotationSpeed.value * Time.deltaTime);
|
||||
|
||||
var forwardMovement = agent.forward * forward.value * moveSpeed.value * Time.deltaTime;
|
||||
var strafeMovement = agent.right * strafe.value * moveSpeed.value * Time.deltaTime;
|
||||
var upMovement = agent.up * up.value * moveSpeed.value * Time.deltaTime;
|
||||
agent.position += strafeMovement + forwardMovement + upMovement;
|
||||
|
||||
if ( !repeat ) {
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4824aebfefed5e49808299f88fc5a7c
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Movement/Direct/InputMove.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,32 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("Movement/Direct")]
|
||||
[Description("Moves the agent away from target per frame without pathfinding")]
|
||||
public class MoveAway : ActionTask<Transform>
|
||||
{
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<GameObject> target;
|
||||
public BBParameter<float> speed = 2;
|
||||
public BBParameter<float> stopDistance = 3;
|
||||
public bool waitActionFinish;
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( ( agent.position - target.value.transform.position ).magnitude >= stopDistance.value ) {
|
||||
EndAction();
|
||||
return;
|
||||
}
|
||||
|
||||
agent.position = Vector3.MoveTowards(agent.position, target.value.transform.position, -speed.value * Time.deltaTime);
|
||||
if ( !waitActionFinish ) {
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e7e65c778e4e744ba46fd7e28c66165
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Movement/Direct/MoveAway.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,31 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("Movement/Direct")]
|
||||
[Description("Moves the agent towards to target per frame without pathfinding")]
|
||||
public class MoveTowards : ActionTask<Transform>
|
||||
{
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<GameObject> target;
|
||||
public BBParameter<float> speed = 2;
|
||||
public BBParameter<float> stopDistance = 0.1f;
|
||||
public bool waitActionFinish;
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( ( agent.position - target.value.transform.position ).magnitude <= stopDistance.value ) {
|
||||
EndAction();
|
||||
return;
|
||||
}
|
||||
|
||||
agent.position = Vector3.MoveTowards(agent.position, target.value.transform.position, speed.value * Time.deltaTime);
|
||||
if ( !waitActionFinish ) {
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebdc9bb8b5fe3d645a2838bb47091266
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Movement/Direct/MoveTowards.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,35 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("Movement/Direct")]
|
||||
[Description("Rotate the agent away from target per frame")]
|
||||
public class RotateAway : ActionTask<Transform>
|
||||
{
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<GameObject> target;
|
||||
public BBParameter<float> speed = 2;
|
||||
[SliderField(1, 180)]
|
||||
public BBParameter<float> angleDifference = 5;
|
||||
public BBParameter<Vector3> upVector = Vector3.up;
|
||||
public bool waitActionFinish;
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( Vector3.Angle(target.value.transform.position - agent.position, -agent.forward) <= angleDifference.value ) {
|
||||
EndAction();
|
||||
return;
|
||||
}
|
||||
|
||||
var dir = target.value.transform.position - agent.position;
|
||||
agent.rotation = Quaternion.LookRotation(Vector3.RotateTowards(agent.forward, dir, -speed.value * Time.deltaTime, 0), upVector.value);
|
||||
if ( !waitActionFinish ) {
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bc2bfd412ae3ff4a9780db864fd127d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Movement/Direct/RotateAway.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,35 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("Movement/Direct")]
|
||||
[Description("Rotate the agent towards the target per frame")]
|
||||
public class RotateTowards : ActionTask<Transform>
|
||||
{
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<GameObject> target;
|
||||
public BBParameter<float> speed = 2;
|
||||
[SliderField(1, 180)]
|
||||
public BBParameter<float> angleDifference = 5;
|
||||
public BBParameter<Vector3> upVector = Vector3.up;
|
||||
public bool waitActionFinish;
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( Vector3.Angle(target.value.transform.position - agent.position, agent.forward) <= angleDifference.value ) {
|
||||
EndAction();
|
||||
return;
|
||||
}
|
||||
|
||||
var dir = target.value.transform.position - agent.position;
|
||||
agent.rotation = Quaternion.LookRotation(Vector3.RotateTowards(agent.forward, dir, speed.value * Time.deltaTime, 0), upVector.value);
|
||||
if ( !waitActionFinish ) {
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3ca4941575dcc545acbd4f99e8846fa
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Movement/Direct/RotateTowards.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aca2ffc885c5a854dbd09930aede48c5
|
||||
folderAsset: yes
|
||||
timeCreated: 1493315492
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
using NavMesh = UnityEngine.AI.NavMesh;
|
||||
using NavMeshHit = UnityEngine.AI.NavMeshHit;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Name("Find Closest NavMesh Edge")]
|
||||
[Category("Movement/Pathfinding")]
|
||||
[Description("Find the closes Navigation Mesh position to the target position")]
|
||||
public class FindClosestEdge : ActionTask
|
||||
{
|
||||
|
||||
public BBParameter<Vector3> targetPosition;
|
||||
[BlackboardOnly]
|
||||
public BBParameter<Vector3> saveFoundPosition;
|
||||
|
||||
private NavMeshHit hit;
|
||||
|
||||
protected override void OnExecute() {
|
||||
if ( NavMesh.FindClosestEdge(targetPosition.value, out hit, -1) ) {
|
||||
saveFoundPosition.value = hit.position;
|
||||
EndAction(true);
|
||||
return;
|
||||
}
|
||||
|
||||
EndAction(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5db9efb29d06114ab702c7c8095184d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Movement/Pathfinding/FindClosestEdge.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,58 @@
|
||||
using UnityEngine;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using NavMeshAgent = UnityEngine.AI.NavMeshAgent;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("Movement/Pathfinding")]
|
||||
[Description("Flees away from the target")]
|
||||
public class Flee : ActionTask<NavMeshAgent>
|
||||
{
|
||||
|
||||
[RequiredField, Tooltip("The target to flee from.")]
|
||||
public BBParameter<GameObject> target;
|
||||
[Tooltip("The speed to flee.")]
|
||||
public BBParameter<float> speed = 4f;
|
||||
[Tooltip("The distance to flee at.")]
|
||||
public BBParameter<float> fledDistance = 10f;
|
||||
[Tooltip("A distance to look away from the target for valid flee destination.")]
|
||||
public BBParameter<float> lookAhead = 2f;
|
||||
|
||||
protected override string info {
|
||||
get { return string.Format("Flee from {0}", target); }
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
if ( target.value == null ) { EndAction(false); return; }
|
||||
agent.speed = speed.value;
|
||||
if ( ( agent.transform.position - target.value.transform.position ).magnitude >= fledDistance.value ) {
|
||||
EndAction(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( target.value == null ) { EndAction(false); return; }
|
||||
var targetPos = target.value.transform.position;
|
||||
if ( ( agent.transform.position - targetPos ).magnitude >= fledDistance.value ) {
|
||||
EndAction(true);
|
||||
return;
|
||||
}
|
||||
|
||||
var fleePos = targetPos + ( agent.transform.position - targetPos ).normalized * ( fledDistance.value + lookAhead.value + agent.stoppingDistance );
|
||||
if ( !agent.SetDestination(fleePos) ) {
|
||||
EndAction(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void OnPause() { OnStop(); }
|
||||
protected override void OnStop() {
|
||||
if ( agent.gameObject.activeSelf ) {
|
||||
agent.ResetPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 004335b421e457b4298f969c177b4497
|
||||
timeCreated: 1427360377
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Movement/Pathfinding/Flee.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,65 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
using NavMeshAgent = UnityEngine.AI.NavMeshAgent;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Name("Seek (GameObject)")]
|
||||
[Category("Movement/Pathfinding")]
|
||||
public class MoveToGameObject : ActionTask<NavMeshAgent>
|
||||
{
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<GameObject> target;
|
||||
public BBParameter<float> speed = 4;
|
||||
public BBParameter<float> keepDistance = 0.1f;
|
||||
|
||||
private Vector3? lastRequest;
|
||||
|
||||
protected override string info {
|
||||
get { return "Seek " + target; }
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
if ( target.value == null ) { EndAction(false); return; }
|
||||
agent.speed = speed.value;
|
||||
if ( Vector3.Distance(agent.transform.position, target.value.transform.position) <= agent.stoppingDistance + keepDistance.value ) {
|
||||
EndAction(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( target.value == null ) { EndAction(false); return; }
|
||||
var pos = target.value.transform.position;
|
||||
if ( lastRequest != pos ) {
|
||||
if ( !agent.SetDestination(pos) ) {
|
||||
EndAction(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
lastRequest = pos;
|
||||
|
||||
if ( !agent.pathPending && agent.remainingDistance <= agent.stoppingDistance + keepDistance.value ) {
|
||||
EndAction(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPause() { OnStop(); }
|
||||
protected override void OnStop() {
|
||||
if ( agent.gameObject.activeSelf ) {
|
||||
agent.ResetPath();
|
||||
}
|
||||
lastRequest = null;
|
||||
}
|
||||
|
||||
public override void OnDrawGizmosSelected() {
|
||||
if ( target.value != null ) {
|
||||
Gizmos.DrawWireSphere(target.value.transform.position, keepDistance.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a804aa6acf99524b8c50ce5d5e259ed
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Movement/Pathfinding/MoveToGameObject.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,56 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
using NavMeshAgent = UnityEngine.AI.NavMeshAgent;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Name("Seek (Vector3)")]
|
||||
[Category("Movement/Pathfinding")]
|
||||
public class MoveToPosition : ActionTask<NavMeshAgent>
|
||||
{
|
||||
|
||||
public BBParameter<Vector3> targetPosition;
|
||||
public BBParameter<float> speed = 4;
|
||||
public BBParameter<float> keepDistance = 0.1f;
|
||||
|
||||
private Vector3? lastRequest;
|
||||
|
||||
protected override string info {
|
||||
get { return "Seek " + targetPosition; }
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
agent.speed = speed.value;
|
||||
if ( Vector3.Distance(agent.transform.position, targetPosition.value) < agent.stoppingDistance + keepDistance.value ) {
|
||||
EndAction(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( lastRequest != targetPosition.value ) {
|
||||
if ( !agent.SetDestination(targetPosition.value) ) {
|
||||
EndAction(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
lastRequest = targetPosition.value;
|
||||
|
||||
if ( !agent.pathPending && agent.remainingDistance <= agent.stoppingDistance + keepDistance.value ) {
|
||||
EndAction(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPause() { OnStop(); }
|
||||
protected override void OnStop() {
|
||||
if ( lastRequest != null && agent.gameObject.activeSelf ) {
|
||||
agent.ResetPath();
|
||||
}
|
||||
lastRequest = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f2b21c100f8a9e45849b27c9515e91c
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Movement/Pathfinding/MoveToPosition.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,112 @@
|
||||
using System.Collections.Generic;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
using NavMeshAgent = UnityEngine.AI.NavMeshAgent;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("Movement/Pathfinding")]
|
||||
[Description("Move Randomly or Progressively between various game object positions taken from the list provided")]
|
||||
public class Patrol : ActionTask<NavMeshAgent>
|
||||
{
|
||||
|
||||
public enum PatrolMode
|
||||
{
|
||||
Progressive,
|
||||
Random
|
||||
}
|
||||
|
||||
[RequiredField, Tooltip("A list of gameobjects patrol points.")]
|
||||
public BBParameter<List<GameObject>> targetList;
|
||||
[Tooltip("The mode to use for patrol (progressive or random)")]
|
||||
public BBParameter<PatrolMode> patrolMode = PatrolMode.Random;
|
||||
public BBParameter<float> speed = 4;
|
||||
public BBParameter<float> keepDistance = 0.1f;
|
||||
|
||||
private int index = -1;
|
||||
private Vector3? lastRequest;
|
||||
|
||||
protected override string info {
|
||||
get { return string.Format("{0} Patrol {1}", patrolMode, targetList); }
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
|
||||
if ( targetList.value.Count == 0 ) {
|
||||
EndAction(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( targetList.value.Count == 1 ) {
|
||||
|
||||
index = 0;
|
||||
|
||||
} else {
|
||||
|
||||
if ( patrolMode.value == PatrolMode.Random ) {
|
||||
var newIndex = index;
|
||||
while ( newIndex == index ) {
|
||||
newIndex = Random.Range(0, targetList.value.Count);
|
||||
}
|
||||
index = newIndex;
|
||||
}
|
||||
|
||||
if ( patrolMode.value == PatrolMode.Progressive ) {
|
||||
index = (int)Mathf.Repeat(index + 1, targetList.value.Count);
|
||||
}
|
||||
}
|
||||
|
||||
var targetGo = targetList.value[index];
|
||||
if ( targetGo == null ) {
|
||||
ParadoxNotion.Services.Logger.LogWarning("List game object is null on Patrol Action Task.", LogTag.EXECUTION, this);
|
||||
EndAction(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var targetPos = targetGo.transform.position;
|
||||
|
||||
agent.speed = speed.value;
|
||||
if ( ( agent.transform.position - targetPos ).magnitude < agent.stoppingDistance + keepDistance.value ) {
|
||||
EndAction(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
var targetPos = targetList.value[index].transform.position;
|
||||
if ( lastRequest != targetPos ) {
|
||||
if ( !agent.SetDestination(targetPos) ) {
|
||||
EndAction(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
lastRequest = targetPos;
|
||||
|
||||
if ( !agent.pathPending && agent.remainingDistance <= agent.stoppingDistance + keepDistance.value ) {
|
||||
EndAction(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPause() { OnStop(); }
|
||||
protected override void OnStop() {
|
||||
if ( lastRequest != null && agent.gameObject.activeSelf ) {
|
||||
agent.ResetPath();
|
||||
}
|
||||
lastRequest = null;
|
||||
}
|
||||
|
||||
public override void OnDrawGizmosSelected() {
|
||||
if ( agent && targetList.value != null ) {
|
||||
foreach ( var go in targetList.value ) {
|
||||
if ( go != null ) {
|
||||
Gizmos.DrawSphere(go.transform.position, 0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fc1b07b3887fbb4ca09601314fb700f
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Movement/Pathfinding/Patrol.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,66 @@
|
||||
using UnityEngine;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
|
||||
using NavMeshAgent = UnityEngine.AI.NavMeshAgent;
|
||||
using NavMesh = UnityEngine.AI.NavMesh;
|
||||
using NavMeshHit = UnityEngine.AI.NavMeshHit;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("Movement/Pathfinding")]
|
||||
[Description("Makes the agent wander randomly within the navigation map")]
|
||||
public class Wander : ActionTask<NavMeshAgent>
|
||||
{
|
||||
|
||||
[Tooltip("The speed to wander with.")]
|
||||
public BBParameter<float> speed = 4;
|
||||
[Tooltip("The distance to keep from each wander point.")]
|
||||
public BBParameter<float> keepDistance = 0.1f;
|
||||
[Tooltip("A wander point can't be closer than this distance")]
|
||||
public BBParameter<float> minWanderDistance = 5;
|
||||
[Tooltip("A wander point can't be further than this distance")]
|
||||
public BBParameter<float> maxWanderDistance = 20;
|
||||
[Tooltip("If enabled, will keep wandering forever. If not, only one wander point will be performed.")]
|
||||
public bool repeat = true;
|
||||
|
||||
protected override void OnExecute() {
|
||||
agent.speed = speed.value;
|
||||
DoWander();
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( !agent.pathPending && agent.remainingDistance <= agent.stoppingDistance + keepDistance.value ) {
|
||||
if ( repeat ) {
|
||||
DoWander();
|
||||
} else {
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DoWander() {
|
||||
var min = minWanderDistance.value;
|
||||
var max = maxWanderDistance.value;
|
||||
min = Mathf.Clamp(min, 0.01f, max);
|
||||
max = Mathf.Clamp(max, min, max);
|
||||
var wanderPos = agent.transform.position;
|
||||
while ( ( wanderPos - agent.transform.position ).magnitude < min ) {
|
||||
wanderPos = ( Random.insideUnitSphere * max ) + agent.transform.position;
|
||||
}
|
||||
|
||||
NavMeshHit hit;
|
||||
if ( NavMesh.SamplePosition(wanderPos, out hit, agent.height * 2, NavMesh.AllAreas) ) {
|
||||
agent.SetDestination(hit.position);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPause() { OnStop(); }
|
||||
protected override void OnStop() {
|
||||
if ( agent.gameObject.activeSelf ) {
|
||||
agent.ResetPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7516e8832e25203438fd50fa07cd847c
|
||||
timeCreated: 1426570396
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Movement/Pathfinding/Wander.cs
|
||||
uploadId: 704937
|
||||
Reference in New Issue
Block a user