first commit
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user