Compare commits
5 Commits
ae1908013d
...
f2df9a6910
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2df9a6910 | ||
|
|
6ebfd4ef2b | ||
|
|
78498e5212 | ||
|
|
80276fbdbf | ||
|
|
598fa9f6fc |
@@ -12,15 +12,18 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 7a686a47eee2fa44cb0a34b5d86e4d5e, type: 3}
|
||||
m_Name: GrappleAimBT
|
||||
m_EditorClassIdentifier:
|
||||
_serializedGraph: '{"type":"NodeCanvas.BehaviourTrees.BehaviourTree","nodes":[{"_position":{"x":730.5245,"y":284.5939},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"0"},{"_condition":{"actionName":{"_value":"Grapple"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_position":{"x":498.9515,"y":429.918},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"1"},{"_action":{"fieldOfView":{"label":"FOV","value":60.0,"changeValue":1},"orbitFollowTop":{"label":"Top","changeHeight":1,"height":2.0,"changeRadius":1,"radius":2.0},"orbitFollowCenter":{"label":"Center","changeHeight":1,"height":1.5,"changeRadius":1,"radius":2.4},"orbitFollowBottom":{"label":"Bottom","changeHeight":1,"height":0.7,"changeRadius":1,"radius":2.0},"cameraOffset":{"label":"Screen
|
||||
Position","newValue":{"x":2.0,"z":-1.0},"changeX":1,"changeZ":1},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"},"_position":{"x":527.6321,"y":581.3029},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"2"},{"_action":{"waitTime":{"_value":0.3},"$type":"NodeCanvas.Tasks.Actions.Wait"},"_position":{"x":682.4366,"y":430.895},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"3"},{"_condition":{"actionName":{"_value":"Grapple"},"actionValue":{},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_position":{"x":826.7462,"y":427.8908},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"4"},{"_action":{"fieldOfView":{"label":"FOV","changeValue":2},"orbitFollowTop":{"label":"Top","changeHeight":2,"changeRadius":2},"orbitFollowCenter":{"label":"Center","changeHeight":2,"changeRadius":2},"orbitFollowBottom":{"label":"Bottom","changeHeight":2,"changeRadius":2},"screenPosition":{"label":"Screen
|
||||
Position","changeX":2,"changeY":2},"cameraOffset":{"label":"Screen Position","changeX":2,"changeY":2,"changeZ":2},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"},"_position":{"x":880.8403,"y":568.1857},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"5"}],"connections":[{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"3"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"4"},"_targetNode":{"$ref":"5"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{}},"derivedData":{"repeat":true,"$type":"NodeCanvas.BehaviourTrees.BehaviourTree+DerivedSerializationData"}}'
|
||||
_serializedGraph: '{"type":"NodeCanvas.BehaviourTrees.BehaviourTree","nodes":[{"_position":{"x":732.5245,"y":286.5939},"$type":"NodeCanvas.BehaviourTrees.Sequencer","$id":"0"},{"_condition":{"actionName":{"_value":"Grapple"},"actionPhase":{"_value":3},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_position":{"x":359.9515,"y":502.918},"$type":"NodeCanvas.BehaviourTrees.WaitUntil","$id":"1"},{"_action":{"fieldOfView":{"label":"FOV","value":60.0,"changeValue":1},"orbitPositionDamping":{"label":"Position
|
||||
Damping","newValue":{"x":0.2,"z":0.2},"changeX":1,"changeZ":1},"orbitFollowTop":{"label":"Top","changeHeight":1,"height":2.0,"changeRadius":1,"radius":2.0},"orbitFollowCenter":{"label":"Center","changeHeight":1,"height":1.5,"changeRadius":1,"radius":2.4},"orbitFollowBottom":{"label":"Bottom","changeHeight":1,"height":0.2,"changeRadius":1,"radius":0.8},"cameraOffset":{"label":"Screen
|
||||
Position","newValue":{"x":2.0,"y":0.5,"z":-1.0},"changeX":1,"changeY":1,"changeZ":1},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"},"_position":{"x":184.6321,"y":659.3029},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"2"},{"policy":1,"_position":{"x":599.0,"y":507.0},"$type":"NodeCanvas.BehaviourTrees.Parallel","$id":"3"},{"repeaterMode":2,"repeatTimes":{"_value":1},"_position":{"x":470.0,"y":657.0},"$type":"NodeCanvas.BehaviourTrees.Repeater","$id":"4"},{"_action":{"eventName":{"_value":"Grapple
|
||||
Zoomed"},"delay":{},"$type":"NodeCanvas.Tasks.Actions.SendEvent"},"_position":{"x":438.0,"y":795.0},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"5"},{"_action":{"waitTime":{"_value":0.1},"$type":"NodeCanvas.Tasks.Actions.Wait"},"_position":{"x":647.4366,"y":655.895},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"6"},{"failureRemap":1,"_position":{"x":839.0,"y":509.0},"$type":"NodeCanvas.BehaviourTrees.Remapper","$id":"7"},{"_condition":{"actionName":{"_value":"Grapple"},"actionPhase":{"_value":4},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_position":{"x":798.0,"y":585.0},"$type":"NodeCanvas.BehaviourTrees.Interruptor","$id":"8"},{"repeaterMode":2,"repeatTimes":{"_value":1},"_position":{"x":838.9237,"y":701.0772},"$type":"NodeCanvas.BehaviourTrees.Repeater","$id":"9"},{"_action":{"eventName":{"_value":"Grapple
|
||||
Zoomed"},"delay":{},"$type":"NodeCanvas.Tasks.Actions.SendEvent"},"_position":{"x":807.9237,"y":837.0771},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"10"},{"_action":{"fieldOfView":{"label":"FOV","changeValue":2},"orbitFollowTop":{"label":"Top","changeHeight":2,"changeRadius":2},"orbitFollowCenter":{"label":"Center","changeHeight":2,"changeRadius":2},"orbitFollowBottom":{"label":"Bottom","changeHeight":2,"changeRadius":2},"screenPosition":{"label":"Screen
|
||||
Position","changeX":2,"changeY":2},"cameraOffset":{"label":"Screen Position","changeX":2,"changeY":2,"changeZ":2},"$type":"NodeCanvas.Tasks.Actions.ChangeCameraSettings"},"_position":{"x":1186.84,"y":501.1857},"$type":"NodeCanvas.BehaviourTrees.ActionNode","$id":"11"}],"connections":[{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"3"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"7"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"11"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"6"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"4"},"_targetNode":{"$ref":"5"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"7"},"_targetNode":{"$ref":"8"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"8"},"_targetNode":{"$ref":"9"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"},{"_sourceNode":{"$ref":"9"},"_targetNode":{"$ref":"10"},"$type":"NodeCanvas.BehaviourTrees.BTConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{}},"derivedData":{"repeat":true,"$type":"NodeCanvas.BehaviourTrees.BehaviourTree+DerivedSerializationData"}}'
|
||||
_objectReferences: []
|
||||
_graphSource:
|
||||
_version: 3.31
|
||||
_category:
|
||||
_comments:
|
||||
_translation: {x: -21.80302, y: 59.90968}
|
||||
_translation: {x: -285, y: -93}
|
||||
_zoomFactor: 1
|
||||
_haltSerialization: 0
|
||||
_externalSerializationFile: {fileID: 0}
|
||||
|
||||
@@ -14,7 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
_serializedGraph: '{"type":"NodeCanvas.StateMachines.FSM","nodes":[{"_actionList":{"executionMode":1,"actions":[{"moveSpeed":{"_value":12.0},"moveDirection":{"_name":"groundMoveDirection","_targetVariableID":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6"},"$type":"NodeCanvas.Tasks.Actions.CalculateGroundedLocomotion"},{"valueA":{"_name":"rotationSpeed","_targetVariableID":"d888730f-97df-4288-bb99-1f6c8a34a7c5"},"valueB":{"_value":10.0},"$type":"NodeCanvas.Tasks.Actions.SetFloat"},{"valueA":{"_name":"facingDirection","_targetVariableID":"c713d622-aafb-43e7-ae0e-ac0b86a85a37"},"valueB":{"_value":1},"$type":"NodeCanvas.Tasks.Actions.SetVariable`1[[Reset.Player.Movement.PlayerFacingDirection,
|
||||
Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}]},"_repeatStateActions":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":559.9924,"y":711.7622},"$type":"NodeCanvas.StateMachines.ActionState","$id":"0"},{"_actionList":{"executionMode":1,"actions":[{"moveSpeed":{"_value":30.0},"moveDirection":{"_name":"groundMoveDirection","_targetVariableID":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6"},"$type":"NodeCanvas.Tasks.Actions.CalculateGroundedLocomotion"},{"valueA":{"_name":"rotationSpeed","_targetVariableID":"d888730f-97df-4288-bb99-1f6c8a34a7c5"},"valueB":{"_value":1.0},"$type":"NodeCanvas.Tasks.Actions.SetFloat"},{"valueA":{"_name":"facingDirection","_targetVariableID":"c713d622-aafb-43e7-ae0e-ac0b86a85a37"},"valueB":{"_value":2},"$type":"NodeCanvas.Tasks.Actions.SetVariable`1[[Reset.Player.Movement.PlayerFacingDirection,
|
||||
Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}]},"_repeatStateActions":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":916.0607,"y":852.7302},"$type":"NodeCanvas.StateMachines.ActionState","$id":"1"},{"_actionList":{"executionMode":1,"actions":[{"moveSpeed":{"_value":20.0},"moveDirection":{"_name":"groundMoveDirection","_targetVariableID":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6"},"$type":"NodeCanvas.Tasks.Actions.CalculateGroundedLocomotion"},{"valueA":{"_name":"rotationSpeed","_targetVariableID":"d888730f-97df-4288-bb99-1f6c8a34a7c5"},"valueB":{"_value":2.0},"$type":"NodeCanvas.Tasks.Actions.SetFloat"}]},"_repeatStateActions":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":1161.288,"y":522.152},"$type":"NodeCanvas.StateMachines.ActionState","$id":"2"},{"_position":{"x":430.6569,"y":381.1322},"$type":"NodeCanvas.StateMachines.AnyState","$id":"3"},{"_position":{"x":465.0,"y":561.0},"$type":"NodeCanvas.StateMachines.EmptyState","$id":"4"}],"connections":[{"_condition":{"actionName":{"_value":"Sprint"},"actionValue":{"_value":""},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"timeout":{"_value":0.1},"$type":"NodeCanvas.Tasks.Conditions.Timeout"},"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"desiredVector3":{"_value":{"z":1.0}},"tolerance":{"_value":0.5},"negate":{},"$type":"NodeCanvas.Tasks.Conditions.GetMovementInputDotProduct"},"_sourceNode":{"$ref":"2"},"_targetNode":{"$ref":"0"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"321e55c7-f93e-4667-a0dc-559eb61c6898"},"valueB":{},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"321e55c7-f93e-4667-a0dc-559eb61c6898"},"valueB":{"_value":true},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_sourceNode":{"$ref":"4"},"_targetNode":{"$ref":"0"},"$type":"NodeCanvas.StateMachines.FSMConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{"isGrounded":{"_propertyPath":"UnityEngine.CharacterController.isGrounded","_name":"isGrounded","_id":"321e55c7-f93e-4667-a0dc-559eb61c6898","$type":"NodeCanvas.Framework.Variable`1[[System.Boolean,
|
||||
Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}]},"_repeatStateActions":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":916.0607,"y":852.7302},"$type":"NodeCanvas.StateMachines.ActionState","$id":"1"},{"_actionList":{"executionMode":1,"actions":[{"moveSpeed":{"_value":20.0},"moveDirection":{"_name":"groundMoveDirection","_targetVariableID":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6"},"$type":"NodeCanvas.Tasks.Actions.CalculateGroundedLocomotion"},{"valueA":{"_name":"rotationSpeed","_targetVariableID":"d888730f-97df-4288-bb99-1f6c8a34a7c5"},"valueB":{"_value":2.0},"$type":"NodeCanvas.Tasks.Actions.SetFloat"}]},"_repeatStateActions":true,"_color":{"r":1.0,"g":0.42,"b":0.32,"a":1.0},"_position":{"x":1161.288,"y":522.152},"$type":"NodeCanvas.StateMachines.ActionState","$id":"2"},{"_position":{"x":383.6569,"y":483.1322},"$type":"NodeCanvas.StateMachines.AnyState","$id":"3"},{"_position":{"x":419.0,"y":609.0},"$type":"NodeCanvas.StateMachines.EmptyState","$id":"4"}],"connections":[{"_condition":{"actionName":{"_value":"Sprint"},"actionPhase":{"_value":3},"$type":"NodeCanvas.Tasks.Conditions.CheckInput"},"_sourceNode":{"$ref":"0"},"_targetNode":{"$ref":"1"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"timeout":{"_value":0.1},"$type":"NodeCanvas.Tasks.Conditions.Timeout"},"_sourceNode":{"$ref":"1"},"_targetNode":{"$ref":"2"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"checkAgainst":2,"checkAgainstValue":{"_value":{"z":1.0}},"desiredValue":{"_value":1.0},"tolerance":{"_value":0.32},"considerCameraRotation":{},"negate":{},"$type":"NodeCanvas.Tasks.Conditions.GetMovementInputDotProduct"},"_sourceNode":{"$ref":"2"},"_targetNode":{"$ref":"0"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"321e55c7-f93e-4667-a0dc-559eb61c6898"},"valueB":{},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_sourceNode":{"$ref":"3"},"_targetNode":{"$ref":"4"},"$type":"NodeCanvas.StateMachines.FSMConnection"},{"_condition":{"valueA":{"_name":"isGrounded","_targetVariableID":"321e55c7-f93e-4667-a0dc-559eb61c6898"},"valueB":{"_value":true},"$type":"NodeCanvas.Tasks.Conditions.CheckBoolean"},"_sourceNode":{"$ref":"4"},"_targetNode":{"$ref":"0"},"$type":"NodeCanvas.StateMachines.FSMConnection"}],"canvasGroups":[],"localBlackboard":{"_variables":{"isGrounded":{"_propertyPath":"UnityEngine.CharacterController.isGrounded","_name":"isGrounded","_id":"321e55c7-f93e-4667-a0dc-559eb61c6898","$type":"NodeCanvas.Framework.Variable`1[[System.Boolean,
|
||||
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},"groundMoveDirection":{"_name":"groundMoveDirection","_id":"16ae5ce4-097a-4c21-94a5-2c5d9ce73eb6","_isPublic":true,"$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.Vector3,
|
||||
UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},"rotationSpeed":{"_name":"rotationSpeed","_id":"d888730f-97df-4288-bb99-1f6c8a34a7c5","_isPublic":true,"$type":"NodeCanvas.Framework.Variable`1[[System.Single,
|
||||
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},"facingDirection":{"_name":"facingDirection","_id":"c713d622-aafb-43e7-ae0e-ac0b86a85a37","_isPublic":true,"$type":"NodeCanvas.Framework.Variable`1[[Reset.Player.Movement.PlayerFacingDirection,
|
||||
@@ -24,7 +24,7 @@ MonoBehaviour:
|
||||
_version: 3.31
|
||||
_category:
|
||||
_comments:
|
||||
_translation: {x: -337, y: -84}
|
||||
_translation: {x: -258, y: -69}
|
||||
_zoomFactor: 1
|
||||
_haltSerialization: 0
|
||||
_externalSerializationFile: {fileID: 0}
|
||||
|
||||
21
Assets/Resources/InputSignal.asset
Normal file
21
Assets/Resources/InputSignal.asset
Normal file
@@ -0,0 +1,21 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b8d78c77b27bcee4792dedf004b44012, type: 3}
|
||||
m_Name: InputSignal
|
||||
m_EditorClassIdentifier:
|
||||
_parameters:
|
||||
- _ID: e1c42702-42ed-4f84-b52d-4e72b42a7de5
|
||||
_name: action
|
||||
_type: UnityEngine.InputSystem.InputAction
|
||||
- _ID: 95540415-c9c3-4b53-87b6-97dcfb13cf6e
|
||||
_name: phase
|
||||
_type: UnityEngine.InputSystem.InputActionPhase
|
||||
8
Assets/Resources/InputSignal.asset.meta
Normal file
8
Assets/Resources/InputSignal.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69b5f370da7b862439a366000ea6e230
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because one or more lines are too long
@@ -1,47 +0,0 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions {
|
||||
|
||||
[Category("Core/Input")]
|
||||
[Description("Returns a float from two Vector3s")]
|
||||
public class GetMovementInputDotProduct : ConditionTask<PlayerControls>{
|
||||
[SliderField(0f,1f)]
|
||||
public BBParameter<Vector3> desiredVector3;
|
||||
public BBParameter<float> tolerance;
|
||||
public BBParameter<bool> negate;
|
||||
|
||||
//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 bool OnCheck(){
|
||||
Vector3 rawInputVector3 = new(agent.rawMoveInput.x, 0f, agent.rawMoveInput.y);
|
||||
float dotProduct = Vector3.Dot(desiredVector3.value, rawInputVector3);
|
||||
|
||||
//Debug.Log(dotProduct);
|
||||
|
||||
if (dotProduct < tolerance.value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnEnable() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnDisable() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ public class Vector3CameraValueGroupDrawer : ObjectDrawer<Vector3CameraValueGrou
|
||||
|
||||
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label(_instance.ToString(), labelOptions);
|
||||
GUILayout.Label(_instance.label, labelOptions);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
@@ -220,7 +220,7 @@ public class Vector2CameraValueGroupDrawer : ObjectDrawer<Vector2CameraValueGrou
|
||||
|
||||
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label(_instance.ToString(), labelOptions);
|
||||
GUILayout.Label(_instance.label, labelOptions);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
@@ -326,8 +326,9 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
public class ChangeCameraSettings : ActionTask{
|
||||
[ParadoxNotion.Design.Header("Main Settings")]
|
||||
public FloatCameraValueGroup fieldOfView = new (newLabel: "FOV");
|
||||
|
||||
[ParadoxNotion.Design.Header("Orbit Follow Ring Settings")]
|
||||
|
||||
[ParadoxNotion.Design.Header("Orbit Follow Ring Settings"), Space (5)]
|
||||
public Vector3CameraValueGroup orbitPositionDamping = new(newLabel: "Position Damping");
|
||||
public OrbitalFollowValueGroup orbitFollowTop = new (newLabel: "Top");
|
||||
public OrbitalFollowValueGroup orbitFollowCenter = new (newLabel: "Center");
|
||||
public OrbitalFollowValueGroup orbitFollowBottom = new (newLabel: "Bottom");
|
||||
@@ -336,7 +337,7 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
public Vector2CameraValueGroup screenPosition = new (newLabel: "Screen Position");
|
||||
|
||||
[ParadoxNotion.Design.Header("Camera Offset Settings")]
|
||||
public Vector3CameraValueGroup cameraOffset = new (newLabel: "Screen Position");
|
||||
public Vector3CameraValueGroup cameraOffset = new (newLabel: "Offset");
|
||||
|
||||
//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
|
||||
@@ -461,6 +462,34 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
break;
|
||||
}
|
||||
|
||||
// Position Damping
|
||||
switch (orbitPositionDamping.changeX) {
|
||||
case CameraSettingsToggle.NewValue:
|
||||
CameraSettingsProcessor.values.orbitPositionDamping.targetValue.x = orbitPositionDamping.newValue.x;
|
||||
break;
|
||||
case CameraSettingsToggle.ResetValue:
|
||||
CameraSettingsProcessor.values.orbitPositionDamping.targetValue.x = CameraSettingsProcessor.values.orbitPositionDamping.originalValue.x;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (orbitPositionDamping.changeY) {
|
||||
case CameraSettingsToggle.NewValue:
|
||||
CameraSettingsProcessor.values.orbitPositionDamping.targetValue.y = orbitPositionDamping.newValue.y;
|
||||
break;
|
||||
case CameraSettingsToggle.ResetValue:
|
||||
CameraSettingsProcessor.values.orbitPositionDamping.targetValue.y = CameraSettingsProcessor.values.orbitPositionDamping.originalValue.y;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (orbitPositionDamping.changeZ) {
|
||||
case CameraSettingsToggle.NewValue:
|
||||
CameraSettingsProcessor.values.orbitPositionDamping.targetValue.z = orbitPositionDamping.newValue.z;
|
||||
break;
|
||||
case CameraSettingsToggle.ResetValue:
|
||||
CameraSettingsProcessor.values.orbitPositionDamping.targetValue.z = CameraSettingsProcessor.values.orbitPositionDamping.originalValue.z;
|
||||
break;
|
||||
}
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,12 @@ namespace NodeCanvas.Tasks.Conditions {
|
||||
|
||||
public BBParameter<string> observerLabel;
|
||||
public BBParameter<RaycastHit> outputHitTo;
|
||||
|
||||
|
||||
protected override string info{
|
||||
get {
|
||||
return $"Check Environment Observer, [\"{observerLabel.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
|
||||
|
||||
102
Assets/Scripts/Core/Graph Tasks/CheckGenericObserver.cs
Normal file
102
Assets/Scripts/Core/Graph Tasks/CheckGenericObserver.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System.Drawing;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NodeCanvas.Editor;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Reset {
|
||||
[Category("Reset")]
|
||||
[Description("Creates an environment observer unattached from the player, such as for checking from the Camera or another arbitray location.")]
|
||||
public class CheckGenericObserver : ConditionTask<Transform>{
|
||||
[Space(5)]
|
||||
public BBParameter<EnvironmentObserver.CastType> castType;
|
||||
|
||||
public BBParameter<float> length;
|
||||
public BBParameter<Vector3> direction;
|
||||
public BBParameter<Vector3> offset;
|
||||
public BBParameter<LayerMask> ignoreLayers;
|
||||
|
||||
public BBParameter<float> width;
|
||||
|
||||
public BBParameter<Vector3> size;
|
||||
|
||||
public BBParameter<Vector3> rotation;
|
||||
|
||||
public bool drawGizmos;
|
||||
public bool drawGizmosOnlyWhenActive;
|
||||
|
||||
private EnvironmentObserver observer;
|
||||
|
||||
protected override void OnTaskInspectorGUI(){
|
||||
BBParameterEditor.ParameterField("Cast Type", castType);
|
||||
|
||||
BBParameterEditor.ParameterField("Length", length);
|
||||
BBParameterEditor.ParameterField("Direction", direction);
|
||||
BBParameterEditor.ParameterField("Offset", offset);
|
||||
BBParameterEditor.ParameterField("Ignore Layers", ignoreLayers);
|
||||
|
||||
if (castType.value == EnvironmentObserver.CastType.SphereCast || castType.value == EnvironmentObserver.CastType.SphereOverlap) {
|
||||
BBParameterEditor.ParameterField("Width", width);
|
||||
}
|
||||
|
||||
if (castType.value == EnvironmentObserver.CastType.BoxCast || castType.value == EnvironmentObserver.CastType.BoxOverlap) {
|
||||
BBParameterEditor.ParameterField("Size", size);
|
||||
}
|
||||
|
||||
if (castType.value != EnvironmentObserver.CastType.Ray) {
|
||||
BBParameterEditor.ParameterField("Rotation", rotation);
|
||||
}
|
||||
|
||||
drawGizmos = EditorGUILayout.Toggle("Draw Gizmos", drawGizmos);
|
||||
|
||||
if (drawGizmos) {
|
||||
drawGizmosOnlyWhenActive = EditorGUILayout.Toggle("Draw Gizmos Only When Active", drawGizmosOnlyWhenActive);
|
||||
}
|
||||
}
|
||||
|
||||
//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() {
|
||||
observer = new EnvironmentObserver(){
|
||||
castType = castType.value,
|
||||
active = true,
|
||||
|
||||
length = length.value,
|
||||
direction = direction.value,
|
||||
offset = offset.value,
|
||||
ignoreLayers = ignoreLayers.value,
|
||||
|
||||
width = width.value,
|
||||
|
||||
size = size.value,
|
||||
rotation = rotation.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() {
|
||||
bool check = observer.Evaluate(agent.gameObject);
|
||||
|
||||
if (drawGizmos) {
|
||||
observer.DrawObserverGizmo(agent.gameObject, true);
|
||||
}
|
||||
|
||||
return check;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb4b5bf056649ca48b1b14dbe499de46
|
||||
@@ -1,49 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions {
|
||||
|
||||
[Category("Reset/Input")]
|
||||
[Description("Check if input condition was matched this frame")]
|
||||
[Description("Check if input condition was matched this frame by phase.")]
|
||||
public class CheckInput : ConditionTask<Transform>{
|
||||
public BBParameter<string> actionName;
|
||||
public BBParameter<string> actionValue;
|
||||
|
||||
public BBParameter<InputActionPhase> actionPhase;
|
||||
|
||||
private SignalDefinition signalDefinition;
|
||||
protected override string info {
|
||||
get { return "Player Input"; }
|
||||
get { return $"Input <b>{actionName.value}</b> was <b>{actionPhase.value}</b>"; }
|
||||
}
|
||||
|
||||
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(){
|
||||
try {
|
||||
signalDefinition = Resources.Load<SignalDefinition>("InputSignal");
|
||||
} catch (Exception e) {
|
||||
Debug.LogError($"Error finding the Input Signal defintion: {e.Message}");
|
||||
throw;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//Called whenever the condition gets enabled.
|
||||
protected override void OnEnable(){
|
||||
action = agent.GetComponent<PlayerInput>().actions.FindAction(actionName.value);
|
||||
protected override void OnEnable() {
|
||||
signalDefinition.onInvoke -= OnSignalInvoke;
|
||||
signalDefinition.onInvoke += OnSignalInvoke;
|
||||
}
|
||||
|
||||
//Called whenever the condition gets disabled.
|
||||
protected override void OnDisable() {
|
||||
|
||||
signalDefinition.onInvoke -= OnSignalInvoke;
|
||||
}
|
||||
|
||||
//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;
|
||||
|
||||
void OnSignalInvoke(Transform sender, Transform receiver, bool isGlobal, params object[] args){
|
||||
// Take the input arguments as objects and convert them to InputAction & Phases
|
||||
InputAction thisAction = (InputAction)args[0];
|
||||
InputActionPhase thisActionPhase = (InputActionPhase)args[1];
|
||||
|
||||
if (actionName.value == thisAction.name && actionPhase.value == thisActionPhase) {
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnCheck() { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using NodeCanvas.Framework;
|
||||
using NUnit.Framework.Constraints;
|
||||
using ParadoxNotion.Design;
|
||||
using ParadoxNotion.Serialization.FullSerializer;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions {
|
||||
|
||||
[Category("Reset/Input")]
|
||||
[Description("Returns a float from two Vector3s")]
|
||||
public class GetMovementInputDotProduct : ConditionTask<PlayerControls>{
|
||||
enum CheckDotProductAgainst{
|
||||
ForwardDirection,
|
||||
CameraDirection,
|
||||
InputVector3
|
||||
}
|
||||
|
||||
[ExposeField, fsSerializeAs] CheckDotProductAgainst checkAgainst;
|
||||
[ParadoxNotion.Design.ShowIf("checkAgainst", 2)] public BBParameter<Vector3> checkAgainstValue;
|
||||
[SliderField(-1f, 1f)] public BBParameter<float> desiredValue;
|
||||
public BBParameter<float> tolerance;
|
||||
|
||||
public BBParameter<bool> considerCameraRotation;
|
||||
public BBParameter<bool> negate;
|
||||
|
||||
//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 bool OnCheck(){
|
||||
// Switch what the dot product is checked against
|
||||
Vector3 valueToCheck;
|
||||
|
||||
switch (checkAgainst) {
|
||||
case CheckDotProductAgainst.ForwardDirection:
|
||||
Debug.Log(agent.transform.forward);
|
||||
valueToCheck = agent.transform.forward;
|
||||
break;
|
||||
case CheckDotProductAgainst.CameraDirection:
|
||||
valueToCheck = Camera.main.transform.forward;
|
||||
break;
|
||||
case CheckDotProductAgainst.InputVector3:
|
||||
valueToCheck = checkAgainstValue.value.normalized;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
// Get the input as a Vector3
|
||||
Vector3 rawInputVector3 = new Vector3(agent.rawMoveInput.x, 0f, agent.rawMoveInput.y);
|
||||
if (considerCameraRotation.value) {
|
||||
rawInputVector3 = Camera.main.transform.rotation * rawInputVector3;
|
||||
}
|
||||
|
||||
// Calculate dor product
|
||||
float dotProduct = Vector3.Dot(valueToCheck, rawInputVector3);
|
||||
|
||||
Debug.Log(dotProduct);
|
||||
|
||||
// Compare against the desired tolerance and output result
|
||||
if (tolerance.value > Mathf.Abs(dotProduct - tolerance.value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnEnable() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnDisable() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,13 +90,16 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
break;
|
||||
case PlayerFacingDirection.Movement:
|
||||
// Check magnitude to avoid the "Look rotation viewing vector is zero" debug
|
||||
if (controls.rawMoveInput.magnitude == 0) { break; }
|
||||
|
||||
// Set desired rotation to input direction, with respect to camera rotation
|
||||
if (agent.isGrounded){
|
||||
if (controls.rawMoveInput.magnitude == 0) { break; }
|
||||
|
||||
targetRotation = Quaternion.LookRotation(currentMoveDir) *
|
||||
Quaternion.Euler(Camera.main.transform.rotation.eulerAngles.Flatten(0f, null, 0f));
|
||||
} else {
|
||||
if (airMoveDirection.value.magnitude == 0) { break; }
|
||||
|
||||
targetRotation = Quaternion.LookRotation(airMoveDirection.value);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -28,6 +28,8 @@ public struct CameraSettingSingleValue<T>{
|
||||
|
||||
public struct CameraSettingValues{
|
||||
public CameraSettingSingleValue<float> mainFieldOfView;
|
||||
|
||||
public CameraSettingSingleValue<Vector3> orbitPositionDamping;
|
||||
|
||||
public CameraSettingSingleValue<float> orbitFollowTopHeight;
|
||||
public CameraSettingSingleValue<float> orbitFollowTopRadius;
|
||||
@@ -43,6 +45,8 @@ public struct CameraSettingValues{
|
||||
public CameraSettingValues(float defaultSmoothing){
|
||||
mainFieldOfView = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
|
||||
orbitPositionDamping = new CameraSettingSingleValue<Vector3>(defaultSmoothing);
|
||||
|
||||
orbitFollowTopHeight = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
orbitFollowTopRadius = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
orbitFollowCenterHeight = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
@@ -86,6 +90,7 @@ public class CameraSettingsProcessor : MonoBehaviour{
|
||||
values = new CameraSettingValues{
|
||||
cameraOffsetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .2f, offset.Offset),
|
||||
mainFieldOfView = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, main.Lens.FieldOfView),
|
||||
orbitPositionDamping = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .2f, orbit.TrackerSettings.PositionDamping),
|
||||
orbitFollowTopHeight = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Top.Height),
|
||||
orbitFollowTopRadius = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Top.Radius),
|
||||
orbitFollowCenterHeight = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Center.Height),
|
||||
@@ -101,6 +106,10 @@ public class CameraSettingsProcessor : MonoBehaviour{
|
||||
values.mainFieldOfView.targetValue, ref values.mainFieldOfView.velocityRef,
|
||||
values.mainFieldOfView.smoothing);
|
||||
|
||||
orbit.TrackerSettings.PositionDamping = Vector3.SmoothDamp(orbit.TrackerSettings.PositionDamping,
|
||||
values.orbitPositionDamping.targetValue, ref values.orbitPositionDamping.velocityRefV3,
|
||||
values.orbitPositionDamping.smoothing);
|
||||
|
||||
orbit.Orbits.Top.Height = Mathf.SmoothDamp(orbit.Orbits.Top.Height,
|
||||
values.orbitFollowTopHeight.targetValue, ref values.orbitFollowTopHeight.velocityRef,
|
||||
values.orbitFollowTopHeight.smoothing);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
@@ -6,11 +7,15 @@ using UnityEngine.UIElements;
|
||||
using NodeCanvas;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using Sirenix.OdinInspector;
|
||||
|
||||
public class PlayerControls : MonoBehaviour{
|
||||
// References
|
||||
private Player thisPlayer;
|
||||
|
||||
private PlayerInput input;
|
||||
public SignalDefinition inputSignal;
|
||||
|
||||
// TODO: Turn these into accessors
|
||||
public Vector2 rawMoveInput;
|
||||
public Vector2 rawLookInput;
|
||||
@@ -20,6 +25,31 @@ public class PlayerControls : MonoBehaviour{
|
||||
void Awake(){
|
||||
thisPlayer = GetComponent<Player>();
|
||||
graph = GetComponent<GraphOwner>();
|
||||
input = GetComponent<PlayerInput>();
|
||||
|
||||
// Add the delegates for each method
|
||||
foreach (InputAction action in input.actions) {
|
||||
action.started += SendToGraph;
|
||||
action.canceled += SendToGraph;
|
||||
action.performed += SendToGraph;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the delegates for each method
|
||||
void OnDisable(){
|
||||
foreach (InputAction action in input.actions) {
|
||||
action.started -= SendToGraph;
|
||||
action.canceled -= SendToGraph;
|
||||
action.performed -= SendToGraph;
|
||||
}
|
||||
}
|
||||
|
||||
// This will call the OnSignalInvoke for this type of Signal Defintion. CheckInput is the recieving end.
|
||||
public void SendToGraph(InputAction.CallbackContext ctx){
|
||||
inputSignal.Invoke(transform, transform, false, new object[]{
|
||||
ctx.action,
|
||||
ctx.phase
|
||||
});
|
||||
}
|
||||
|
||||
public void OnMove(InputValue value){
|
||||
|
||||
@@ -15,6 +15,12 @@ public class EnvironmentObserver{
|
||||
IntersectingLength,
|
||||
}
|
||||
|
||||
enum ObserverGizmoDrawingCondition{
|
||||
Always,
|
||||
OnlyActive,
|
||||
Never
|
||||
}
|
||||
|
||||
public enum CastType{
|
||||
Ray,
|
||||
BoxOverlap,
|
||||
@@ -41,7 +47,6 @@ public class EnvironmentObserver{
|
||||
[FoldoutGroup("Settings")] public Vector3 direction;
|
||||
[FoldoutGroup("Settings")] public Vector3 offset;
|
||||
[PropertySpace(0, 5), FoldoutGroup("Settings")] public LayerMask ignoreLayers = ~0;
|
||||
|
||||
|
||||
[ShowIfGroup("Settings/CastsOnly", VisibleIf = "@castType == CastType.SphereCast || castType == CastType.SphereOverlap")]
|
||||
[FoldoutGroup("Settings")] public float width;
|
||||
@@ -71,27 +76,28 @@ public class EnvironmentObserver{
|
||||
[BoxGroup("Text/Hit")] public float hitTextSize;
|
||||
[BoxGroup("Text/Hit")] public Vector3 hitLocationOffset;
|
||||
[BoxGroup("Text/Hit")] public Vector3 hitRotationOffset;
|
||||
|
||||
[FoldoutGroup("Text"), SerializeField, ShowInInspector] ObserverGizmoDrawingCondition gizmoDrawingCondition;
|
||||
|
||||
[SerializeReference, PropertySpace(5, 5)]
|
||||
public List<EnvironmentObserver> children;
|
||||
|
||||
// NOTE: I had a ref for a RaycastHit here that would correspond to hit but idk if it's needed.
|
||||
public bool Evaluate(GameObject player){
|
||||
public bool Evaluate(GameObject source){
|
||||
if (active) {
|
||||
// Remove player's layer from LayerMask.
|
||||
ignoreLayers -= player.layer;
|
||||
ignoreLayers -= source.layer;
|
||||
|
||||
// Set some of the variables used later during casting
|
||||
Vector3 relativeStart = player.transform.position + offset;
|
||||
Vector3 relativeStartWithRotation = player.transform.position + player.transform.rotation * offset ;
|
||||
Vector3 relativeStart = source.transform.position + offset;
|
||||
Vector3 relativeStartWithRotation = source.transform.position + source.transform.rotation * offset ;
|
||||
|
||||
switch (castType) {
|
||||
case CastType.Ray:
|
||||
Physics.Raycast(relativeStart, player.transform.rotation * direction, out hit, length, ignoreLayers);
|
||||
Physics.Raycast(relativeStart, source.transform.rotation * direction, out hit, length, ignoreLayers);
|
||||
break;
|
||||
case CastType.BoxOverlap:
|
||||
overlapHits = Physics.OverlapBox(relativeStartWithRotation, size / 2f,
|
||||
player.transform.rotation * Quaternion.Euler(rotation), ignoreLayers);
|
||||
source.transform.rotation * Quaternion.Euler(rotation), ignoreLayers);
|
||||
|
||||
if (overlapHits.Length > 0) {
|
||||
return true;
|
||||
@@ -103,8 +109,8 @@ public class EnvironmentObserver{
|
||||
case CastType.BoxCast:
|
||||
// TODO: Make this not an if statement. Check that it works with NodeCanvas first
|
||||
if (Physics.BoxCast(relativeStartWithRotation, size / 2f,
|
||||
player.transform.rotation * Quaternion.Euler(rotation) * direction,
|
||||
out hit, player.transform.rotation * Quaternion.Euler(rotation), length,
|
||||
source.transform.rotation * Quaternion.Euler(rotation) * direction,
|
||||
out hit, source.transform.rotation * Quaternion.Euler(rotation), length,
|
||||
ignoreLayers)
|
||||
) {
|
||||
};
|
||||
@@ -112,7 +118,7 @@ public class EnvironmentObserver{
|
||||
case CastType.SphereCast:
|
||||
// TODO: Make this not an if statement. Check that it works with NodeCanvas first
|
||||
if (Physics.SphereCast(relativeStartWithRotation, width / 2f,
|
||||
player.transform.rotation * Quaternion.Euler(rotation) * direction,
|
||||
source.transform.rotation * Quaternion.Euler(rotation) * direction,
|
||||
out hit, length,
|
||||
ignoreLayers)
|
||||
) {
|
||||
@@ -127,29 +133,35 @@ public class EnvironmentObserver{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void DrawObserverGizmo(GameObject player){
|
||||
Vector3 relativeStart = player.transform.position + offset;
|
||||
Vector3 relativeStartWithRotation = player.transform.position + player.transform.rotation * (offset);
|
||||
public void DrawObserverGizmo(GameObject source, bool drawAnyways = false){
|
||||
if (!drawAnyways){
|
||||
if (gizmoDrawingCondition == ObserverGizmoDrawingCondition.Never || (gizmoDrawingCondition == ObserverGizmoDrawingCondition.OnlyActive ! & active)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 relativeStart = source.transform.position + offset;
|
||||
Vector3 relativeStartWithRotation = source.transform.position + source.transform.rotation * (offset);
|
||||
|
||||
// Setup the variables for boxcast, spherecast, etc
|
||||
// Create an offset start point for the center of the wirebox, since gizmos are drawn with their pivot in the center.
|
||||
Vector3 offsetWithRotationAndLength = (Quaternion.LookRotation(direction) * Quaternion.Euler(rotation)) * (Vector3.forward * (length / 2));
|
||||
Vector3 offsetFromCenter = relativeStartWithRotation + player.transform.rotation * offsetWithRotationAndLength;
|
||||
Vector3 offsetFromCenter = relativeStartWithRotation + source.transform.rotation * offsetWithRotationAndLength;
|
||||
|
||||
// Also create a rotation for use with the gizmos. Mainly just to shorten the lines
|
||||
Quaternion gizmosRotation = player.transform.rotation * Quaternion.LookRotation(direction) * Quaternion.Euler(rotation);
|
||||
Quaternion gizmosRotation = source.transform.rotation * Quaternion.LookRotation(direction) * Quaternion.Euler(rotation);
|
||||
Vector3 firstBoxOffset = gizmosRotation * (Vector3.forward * size.z);
|
||||
|
||||
Color gizmoColor = Evaluate(player) ? Color.green : Color.red;
|
||||
Color gizmoColor = Evaluate(source) ? Color.green : Color.red;
|
||||
gizmoColor = active ? gizmoColor : Color.gray;
|
||||
|
||||
using (Draw.ingame.WithColor(gizmoColor)){
|
||||
switch (castType) {
|
||||
case CastType.Ray:
|
||||
Draw.ingame.Line(relativeStart, relativeStart + (player.transform.rotation * direction.normalized) * length);
|
||||
Draw.ingame.Line(relativeStart, relativeStart + (source.transform.rotation * direction.normalized) * length);
|
||||
break;
|
||||
case CastType.BoxOverlap:
|
||||
Draw.ingame.WireBox(relativeStartWithRotation, player.transform.rotation * Quaternion.Euler(rotation), size);
|
||||
Draw.ingame.WireBox(relativeStartWithRotation, source.transform.rotation * Quaternion.Euler(rotation), size);
|
||||
break;
|
||||
case CastType.SphereCast:
|
||||
Draw.ingame.SolidCircle(relativeStartWithRotation, relativeStartWithRotation - Camera.main.transform.position, width * 1, gizmoColor.Alpha(.5f));
|
||||
@@ -173,7 +185,7 @@ public class EnvironmentObserver{
|
||||
Vector3 labelStartPos = Vector3.zero;
|
||||
switch (labelTextLocation) {
|
||||
case LabelDrawingLocation.PlayerOffset:
|
||||
labelStartPos = player.transform.position;
|
||||
labelStartPos = source.transform.position;
|
||||
break;
|
||||
case LabelDrawingLocation.IntersectingLength:
|
||||
labelStartPos = offsetFromCenter;
|
||||
@@ -203,7 +215,7 @@ public class EnvironmentObserver{
|
||||
// Since the label is already drawn just use the previous startPos
|
||||
switch (labelTextLocation) {
|
||||
case LabelDrawingLocation.PlayerOffset:
|
||||
labelStartPos = player.transform.position;
|
||||
labelStartPos = source.transform.position;
|
||||
break;
|
||||
case LabelDrawingLocation.IntersectingLength:
|
||||
labelStartPos = offsetFromCenter;
|
||||
@@ -228,11 +240,7 @@ public class EnvironmentObserver{
|
||||
gizmoColor
|
||||
);
|
||||
}
|
||||
|
||||
Sirenix.Utilities.Editor.GUIHelper.RequestRepaint();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static Color GetObserverStatusColorStatic(bool active, RaycastHit hit){
|
||||
@@ -320,7 +328,6 @@ public class PlayerEnvironmentManager : MonoBehaviour{
|
||||
}
|
||||
|
||||
void Update(){
|
||||
Debug.Log(EvaluateFromString("gamedev"));
|
||||
}
|
||||
|
||||
void LateUpdate(){
|
||||
|
||||
@@ -38,19 +38,19 @@ public class PlayerMovement : MonoBehaviour
|
||||
// }
|
||||
// }
|
||||
|
||||
void FixedUpdate(){
|
||||
LayerMask environmentLayer = LayerMask.NameToLayer("Environment");
|
||||
|
||||
if (Physics.Raycast(transform.position + Vector3.up, transform.forward, out forwardRay, 2.5f, ~environmentLayer)){
|
||||
thisPlayer.controls.graph.SendEvent("ForwardRay", true, null);
|
||||
}
|
||||
|
||||
if (Physics.Raycast(transform.position + Vector3.up, transform.position + Vector3.left, out leftRay, maxDistance: 2f, ~environmentLayer )) {
|
||||
thisPlayer.controls.graph.SendEvent("LeftRay", true, null);
|
||||
}
|
||||
|
||||
if (Physics.Raycast(transform.position + Vector3.up, transform.position + Vector3.right, out rightRay, maxDistance: 2f, ~environmentLayer )) {
|
||||
thisPlayer.controls.graph.SendEvent("RightRay", true, null);
|
||||
}
|
||||
}
|
||||
// void FixedUpdate(){
|
||||
// LayerMask environmentLayer = LayerMask.NameToLayer("Environment");
|
||||
//
|
||||
// if (Physics.Raycast(transform.position + Vector3.up, transform.forward, out forwardRay, 2.5f, ~environmentLayer)){
|
||||
// thisPlayer.controls.graph.SendEvent("ForwardRay", true, null);
|
||||
// }
|
||||
//
|
||||
// if (Physics.Raycast(transform.position + Vector3.up, transform.position + Vector3.left, out leftRay, maxDistance: 2f, ~environmentLayer )) {
|
||||
// thisPlayer.controls.graph.SendEvent("LeftRay", true, null);
|
||||
// }
|
||||
//
|
||||
// if (Physics.Raycast(transform.position + Vector3.up, transform.position + Vector3.right, out rightRay, maxDistance: 2f, ~environmentLayer )) {
|
||||
// thisPlayer.controls.graph.SendEvent("RightRay", true, null);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user