Compare commits
5 Commits
1c27be3e2f
...
39313c96d0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39313c96d0 | ||
|
|
4a1dbb9728 | ||
|
|
7fbe05e39b | ||
|
|
92c6ac0016 | ||
|
|
706e53c5f7 |
@@ -21,7 +21,7 @@ MonoBehaviour:
|
|||||||
_version: 3.31
|
_version: 3.31
|
||||||
_category:
|
_category:
|
||||||
_comments:
|
_comments:
|
||||||
_translation: {x: 1, y: -175}
|
_translation: {x: 21, y: -46}
|
||||||
_zoomFactor: 0.9967056
|
_zoomFactor: 0.9967056
|
||||||
_haltSerialization: 0
|
_haltSerialization: 0
|
||||||
_externalSerializationFile: {fileID: 0}
|
_externalSerializationFile: {fileID: 0}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -10,19 +10,23 @@ using Reset.Player.Movement;
|
|||||||
namespace NodeCanvas.Tasks.Actions {
|
namespace NodeCanvas.Tasks.Actions {
|
||||||
[Category("Reset/Movement")]
|
[Category("Reset/Movement")]
|
||||||
public class AddJump : ActionTask<CharacterController> {
|
public class AddJump : ActionTask<CharacterController> {
|
||||||
public BBParameter<float> jumpStrength;
|
|
||||||
public BBParameter<Vector3> airMoveDirection;
|
public BBParameter<Vector3> airMoveDirection;
|
||||||
|
public BBParameter<float> jumpPower;
|
||||||
|
|
||||||
public BBParameter<PlayerFacingDirection> playerFacingDirection;
|
[Space(5)]
|
||||||
|
public BBParameter<float> jumpStrength;
|
||||||
|
|
||||||
[Range(0f, 1f)]
|
[SliderField(0, 1)]
|
||||||
public BBParameter<float> standStillJumpStrength;
|
public BBParameter<float> standStillJumpStrength;
|
||||||
|
|
||||||
public BBParameter<float> jumpPower;
|
|
||||||
|
|
||||||
[Tooltip("Determines how much current movement vectors into jump direction")]
|
[Tooltip("Determines how much current movement vectors into jump direction")]
|
||||||
|
[SliderField(0, 1)]
|
||||||
public BBParameter<float> currentVelocityInheritence;
|
public BBParameter<float> currentVelocityInheritence;
|
||||||
public BBParameter<Vector3> directionalForce;
|
public BBParameter<Vector3> directionalForce;
|
||||||
|
|
||||||
|
[SliderField(0, 1)]
|
||||||
public BBParameter<float> directionalForceStrength;
|
public BBParameter<float> directionalForceStrength;
|
||||||
|
|
||||||
protected override string info {
|
protected override string info {
|
||||||
@@ -72,9 +76,12 @@ namespace NodeCanvas.Tasks.Actions {
|
|||||||
// Check threshold of current XZ velocity- if it's too close to zero, use the jumpStrength for jumping velocity. If it's not, use the current velocity
|
// Check threshold of current XZ velocity- if it's too close to zero, use the jumpStrength for jumping velocity. If it's not, use the current velocity
|
||||||
float velocityThreshold = 4f;
|
float velocityThreshold = 4f;
|
||||||
float magnitudeZeroDifference = Mathf.Clamp(currentVelocityVector3.magnitude - velocityThreshold, 0f, Mathf.Infinity) / velocityThreshold; // Divided by maximum to return a 0-1 value. Clamping not required.
|
float magnitudeZeroDifference = Mathf.Clamp(currentVelocityVector3.magnitude - velocityThreshold, 0f, Mathf.Infinity) / velocityThreshold; // Divided by maximum to return a 0-1 value. Clamping not required.
|
||||||
float outputVelocity = Mathf.Lerp(jumpStrength.value, currentVelocityVector3.magnitude, Math.Clamp(magnitudeZeroDifference, 0f, 1f));
|
float outputHoritontalVelocity = Mathf.Lerp(jumpStrength.value, currentVelocityVector3.magnitude, Math.Clamp(magnitudeZeroDifference, 0f, 1f));
|
||||||
|
|
||||||
outputVelocity = Mathf.Min(outputVelocity, Mathf.Lerp(standStillJumpStrength.value * jumpStrength.value, jumpStrength.value * .4f, magnitudeZeroDifference));
|
outputHoritontalVelocity = Mathf.Min(outputHoritontalVelocity, Mathf.Lerp(standStillJumpStrength.value * jumpStrength.value, jumpStrength.value * .4f, magnitudeZeroDifference));
|
||||||
|
|
||||||
|
// Do the same for directional jump strength
|
||||||
|
outputHoritontalVelocity = Mathf.Lerp(outputHoritontalVelocity, jumpStrength.value, directionalForceStrength.value);
|
||||||
|
|
||||||
// Remap the dot to set -1 (opposing direction) to -.5f, and 1 (same direciton) to 1.2f
|
// Remap the dot to set -1 (opposing direction) to -.5f, and 1 (same direciton) to 1.2f
|
||||||
// This is done to allow some sideways jumping direction change, but none backwards, and all forwards
|
// This is done to allow some sideways jumping direction change, but none backwards, and all forwards
|
||||||
@@ -94,7 +101,7 @@ namespace NodeCanvas.Tasks.Actions {
|
|||||||
outputDirection = Camera.main.transform.rotation.Flatten(0, null, 0) * outputDirection;
|
outputDirection = Camera.main.transform.rotation.Flatten(0, null, 0) * outputDirection;
|
||||||
|
|
||||||
// Set air move direction
|
// Set air move direction
|
||||||
airMoveDirection.value += outputDirection * outputVelocity;
|
airMoveDirection.value += outputDirection * outputHoritontalVelocity;
|
||||||
}
|
}
|
||||||
EndAction(true);
|
EndAction(true);
|
||||||
}
|
}
|
||||||
|
|||||||
121
Assets/Scripts/Core/Graph Tasks/ChangeAgentTransform.cs
Normal file
121
Assets/Scripts/Core/Graph Tasks/ChangeAgentTransform.cs
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
using System;
|
||||||
|
using NodeCanvas.Framework;
|
||||||
|
using ParadoxNotion.Design;
|
||||||
|
using ParadoxNotion.Serialization.FullSerializer;
|
||||||
|
using Sirenix.OdinInspector;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NodeCanvas.Tasks.Actions {
|
||||||
|
|
||||||
|
[Category("Reset")]
|
||||||
|
[Description("Update the agent's position and rotation (scale too, sure whynot) either instantly or over time.")]
|
||||||
|
public class ChangeAgentTransform : ActionTask<CharacterController>{
|
||||||
|
public enum TransformProperty{
|
||||||
|
Position,
|
||||||
|
Rotation,
|
||||||
|
Scale
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string info {
|
||||||
|
get{
|
||||||
|
string basicText = string.Format($"Player {targetProperty.ToString()} to {(targetValue.isPresumedDynamic ? targetValue.name : targetValue.value)}");
|
||||||
|
basicText += relativeToSelf.value ? ", relative to Self" : "";
|
||||||
|
|
||||||
|
return basicText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TransformProperty targetProperty;
|
||||||
|
|
||||||
|
[ParadoxNotion.Design.ShowIf("targetProperty", 0), Space(5)]
|
||||||
|
public BBParameter<bool> forcePositionChange;
|
||||||
|
|
||||||
|
public BBParameter<Vector3> targetValue;
|
||||||
|
|
||||||
|
public BBParameter<bool> relativeToSelf;
|
||||||
|
|
||||||
|
[Tooltip("Set this to the current position if you're trying to rotate by 'this much'. Keep it zero for world space values.")]
|
||||||
|
public BBParameter<Vector3> relativeValue;
|
||||||
|
|
||||||
|
public BBParameter<bool> changeInstantly;
|
||||||
|
public BBParameter<float> smoothing;
|
||||||
|
|
||||||
|
private Vector3 currentVel;
|
||||||
|
|
||||||
|
|
||||||
|
//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() {
|
||||||
|
switch (targetProperty) {
|
||||||
|
case TransformProperty.Position:
|
||||||
|
Vector3 relativeUseValue = relativeValue.value;
|
||||||
|
if (relativeToSelf.value) {
|
||||||
|
relativeUseValue = agent.transform.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changeInstantly.value) {
|
||||||
|
agent.Move(agent.transform.position.DirectionTo(relativeUseValue + targetValue.value));
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case TransformProperty.Rotation:
|
||||||
|
// agent.transform = Quaternion.Euler(relativeValue.value + targetValue.value);
|
||||||
|
break;
|
||||||
|
case TransformProperty.Scale:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changeInstantly.value) {
|
||||||
|
EndAction(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called once per frame while the action is active.
|
||||||
|
protected override void OnUpdate() {
|
||||||
|
switch (targetProperty) {
|
||||||
|
case TransformProperty.Position:
|
||||||
|
Vector3 relativeUseValue = relativeValue.value;
|
||||||
|
if (relativeToSelf.value) {
|
||||||
|
relativeUseValue = agent.transform.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!changeInstantly.value) {
|
||||||
|
Vector3 targetPosition = relativeUseValue + targetValue.value;
|
||||||
|
// agent.transform.position = Vector3.SmoothDamp(agent.transform.position, targetPosition,
|
||||||
|
// ref currentVel, smoothing.value * Time.deltaTime);
|
||||||
|
|
||||||
|
agent.Move((agent.transform.position.DirectionTo(targetPosition)).normalized * .5f * Mathf.Lerp(0, 1, Vector3.Distance(agent.transform.position, targetPosition)) * smoothing.value * Time.deltaTime);
|
||||||
|
EndAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case TransformProperty.Rotation:
|
||||||
|
agent.transform.rotation = Quaternion.Euler(relativeValue.value + targetValue.value);
|
||||||
|
break;
|
||||||
|
case TransformProperty.Scale:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//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: b77e2b9ac9aad644480508d5a86f4006
|
||||||
@@ -9,6 +9,7 @@ namespace NodeCanvas.Tasks.Conditions {
|
|||||||
public BBParameter<string> observerLabel;
|
public BBParameter<string> observerLabel;
|
||||||
public BBParameter<RaycastHit> outputHitTo;
|
public BBParameter<RaycastHit> outputHitTo;
|
||||||
|
|
||||||
|
|
||||||
//Use for initialization. This is called only once in the lifetime of the task.
|
//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
|
//Return null if init was successfull. Return an error string otherwise
|
||||||
protected override string OnInit(){
|
protected override string OnInit(){
|
||||||
|
|||||||
55
Assets/Scripts/Core/Graph Tasks/DecomposeRaycastHit.cs
Normal file
55
Assets/Scripts/Core/Graph Tasks/DecomposeRaycastHit.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
using NodeCanvas.Framework;
|
||||||
|
using ParadoxNotion.Design;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
|
namespace NodeCanvas.Tasks.Actions {
|
||||||
|
|
||||||
|
[Category("Reset")]
|
||||||
|
[Description("Breaks down an incoming RaycastHit into it's constituent parts for later use.")]
|
||||||
|
public class DecomposeRaycastHit : ActionTask{
|
||||||
|
public BBParameter<RaycastHit> raycastHit;
|
||||||
|
|
||||||
|
public BBParameter<Transform> transform;
|
||||||
|
public BBParameter<Collider> collider;
|
||||||
|
public BBParameter<GameObject> gameObject;
|
||||||
|
public BBParameter<float> distance;
|
||||||
|
public BBParameter<Vector3> normal;
|
||||||
|
public BBParameter<Vector3> point;
|
||||||
|
|
||||||
|
//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(){
|
||||||
|
if (transform.isDefined){ transform.value = raycastHit.value.transform; }
|
||||||
|
if (collider.isDefined){ collider.value = raycastHit.value.collider; }
|
||||||
|
if (gameObject.isDefined){ gameObject.value = raycastHit.value.transform.gameObject; }
|
||||||
|
if (distance.isDefined){ distance.value = raycastHit.value.distance; }
|
||||||
|
if (normal.isDefined){ normal.value = raycastHit.value.normal; }
|
||||||
|
if (point.isDefined){ point.value = raycastHit.value.point; }
|
||||||
|
|
||||||
|
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: 79f7cbb75d876f84b8edfae676ba324c
|
||||||
@@ -13,4 +13,7 @@ public static class MathExtensions{
|
|||||||
return (to - origin).normalized;
|
return (to - origin).normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Color Alpha(this Color input, float newAlpha){
|
||||||
|
return new Color(input.r, input.g, input.b, newAlpha);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ using UnityEngine.Serialization;
|
|||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class EnvironmentObserver{
|
public class EnvironmentObserver{
|
||||||
// TODO: Clean this ugly shit up. Custom inspector with Odin plz.
|
|
||||||
public string label;
|
|
||||||
|
|
||||||
enum LabelDrawingLocation{
|
enum LabelDrawingLocation{
|
||||||
PlayerOffset,
|
PlayerOffset,
|
||||||
HitLocation,
|
HitLocation,
|
||||||
@@ -26,10 +23,12 @@ public class EnvironmentObserver{
|
|||||||
SphereCast
|
SphereCast
|
||||||
}
|
}
|
||||||
|
|
||||||
// [BoxGroup("Settings")]
|
[PropertySpace(0, 5), LabelWidth(60)]
|
||||||
[ShowInInspector, SerializeField] public CastType castType;
|
public string label;
|
||||||
|
[PropertySpace(0, 10), LabelWidth(60)]
|
||||||
|
public CastType castType;
|
||||||
|
|
||||||
[Button(ButtonSizes.Large), GUIColor("@GetObserverStatusColorStatic(active, hit)")]
|
[Button(ButtonSizes.Large), GUIColor("@GetObserverStatusColorStatic(active, hit)"), PropertyOrder(-1), PropertySpace(5, 5)]
|
||||||
public void Active(){
|
public void Active(){
|
||||||
active = !active;
|
active = !active;
|
||||||
}
|
}
|
||||||
@@ -38,45 +37,43 @@ public class EnvironmentObserver{
|
|||||||
public bool active;
|
public bool active;
|
||||||
|
|
||||||
// Parameters for Cast cast types
|
// Parameters for Cast cast types
|
||||||
[BoxGroup("Settings")]
|
[FoldoutGroup("Settings")] public float length;
|
||||||
public float length;
|
[FoldoutGroup("Settings")] public Vector3 direction;
|
||||||
[BoxGroup("Settings")]
|
[FoldoutGroup("Settings")] public Vector3 offset;
|
||||||
public Vector3 direction;
|
[PropertySpace(0, 5), FoldoutGroup("Settings")] public LayerMask ignoreLayers = ~0;
|
||||||
[BoxGroup("Settings")]
|
|
||||||
public Vector3 offset;
|
|
||||||
|
|
||||||
[ShowIfGroup("Settings/Casts3D", VisibleIf = "@castType == CastType.Ray || castType == CastType.BoxCast || castType == CastType.SphereCast")]
|
|
||||||
[BoxGroup("Settings/Casts3D")]
|
|
||||||
public float width;
|
|
||||||
|
|
||||||
|
[ShowIfGroup("Settings/CastsOnly", VisibleIf = "@castType == CastType.SphereCast || castType == CastType.SphereOverlap")]
|
||||||
|
[FoldoutGroup("Settings")] public float width;
|
||||||
|
|
||||||
// Parameters for Overlap cast types
|
// Parameters for Overlap cast types
|
||||||
[BoxGroup("Settings/Overlaps")]
|
[ShowIfGroup("Settings/3DOnly", VisibleIf = "@castType == CastType.BoxCast && castType != CastType.BoxOverlap")] [FoldoutGroup("Settings")]
|
||||||
public Vector3 size;
|
public Vector3 size;
|
||||||
|
|
||||||
[PropertyTooltip(
|
[ShowIfGroup("Settings/3DOnly")]
|
||||||
"Only use rotation when an observers direction alone can't (for whatever reason) fully be expressed without specifying a rotation.")]
|
|
||||||
[ShowIfGroup("Settings/Casts3D")]
|
|
||||||
[BoxGroup("Settings/Casts3D")]
|
|
||||||
public Vector3 rotation;
|
public Vector3 rotation;
|
||||||
|
|
||||||
[BoxGroup("Settings")]
|
[HideInInspector]
|
||||||
public LayerMask ignoreLayers = ~0;
|
|
||||||
|
|
||||||
public RaycastHit hit;
|
public RaycastHit hit;
|
||||||
|
|
||||||
[SerializeReference]
|
|
||||||
public List<EnvironmentObserver> children;
|
|
||||||
|
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
public Collider[] overlapHits;
|
public Collider[] overlapHits;
|
||||||
|
|
||||||
public bool drawLabel;
|
[FoldoutGroup("Text")]
|
||||||
public Vector3 labelLocationOffset;
|
[BoxGroup("Text/Label")] public bool drawLabel;
|
||||||
public Vector3 labelRotationOffset;
|
[ShowInInspector, SerializeField] [BoxGroup("Text/Label")] LabelDrawingLocation labelTextLocation;
|
||||||
|
[BoxGroup("Text/Label")] public float labelSize;
|
||||||
|
[BoxGroup("Text/Label")] public Vector3 labelLocationOffset;
|
||||||
|
[BoxGroup("Text/Label")] public Vector3 labelRotationOffset;
|
||||||
|
|
||||||
[ShowInInspector, SerializeField]
|
[BoxGroup("Text/Hit")] public bool drawHitName;
|
||||||
LabelDrawingLocation labelLocation;
|
[ShowInInspector, SerializeField] [BoxGroup("Text/Hit")] LabelDrawingLocation hitTextLocation;
|
||||||
|
[BoxGroup("Text/Hit")] public float hitTextSize;
|
||||||
|
[BoxGroup("Text/Hit")] public Vector3 hitLocationOffset;
|
||||||
|
[BoxGroup("Text/Hit")] public Vector3 hitRotationOffset;
|
||||||
|
|
||||||
|
[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.
|
// 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 player){
|
||||||
@@ -86,7 +83,7 @@ public class EnvironmentObserver{
|
|||||||
|
|
||||||
// Set some of the variables used later during casting
|
// Set some of the variables used later during casting
|
||||||
Vector3 relativeStart = player.transform.position + offset;
|
Vector3 relativeStart = player.transform.position + offset;
|
||||||
Vector3 relativeStartWithRotation = player.transform.position + player.transform.rotation * (offset) ;
|
Vector3 relativeStartWithRotation = player.transform.position + player.transform.rotation * offset ;
|
||||||
|
|
||||||
switch (castType) {
|
switch (castType) {
|
||||||
case CastType.Ray:
|
case CastType.Ray:
|
||||||
@@ -105,11 +102,21 @@ public class EnvironmentObserver{
|
|||||||
break;
|
break;
|
||||||
case CastType.BoxCast:
|
case CastType.BoxCast:
|
||||||
// TODO: Make this not an if statement. Check that it works with NodeCanvas first
|
// TODO: Make this not an if statement. Check that it works with NodeCanvas first
|
||||||
if (Physics.BoxCast(relativeStartWithRotation, Vector3.one * (width / 2f), (player.transform.rotation * Quaternion.Euler(rotation) * direction),
|
if (Physics.BoxCast(relativeStartWithRotation, size / 2f,
|
||||||
out hit, Quaternion.LookRotation(direction) * Quaternion.Euler(rotation), length, ignoreLayers)
|
player.transform.rotation * Quaternion.Euler(rotation) * direction,
|
||||||
);
|
out hit, player.transform.rotation * Quaternion.Euler(rotation), length,
|
||||||
|
ignoreLayers)
|
||||||
|
) {
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
case CastType.SphereCast:
|
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,
|
||||||
|
out hit, length,
|
||||||
|
ignoreLayers)
|
||||||
|
) {
|
||||||
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,29 +129,21 @@ public class EnvironmentObserver{
|
|||||||
|
|
||||||
public void DrawObserverGizmo(GameObject player){
|
public void DrawObserverGizmo(GameObject player){
|
||||||
Vector3 relativeStart = player.transform.position + offset;
|
Vector3 relativeStart = player.transform.position + offset;
|
||||||
Vector3 relativeStartWithRotation = player.transform.position + player.transform.rotation * (offset) ;
|
Vector3 relativeStartWithRotation = player.transform.position + player.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;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
Vector3 firstBoxOffset = gizmosRotation * (Vector3.forward * size.z);
|
||||||
|
|
||||||
Color gizmoColor = Evaluate(player) ? Color.green : Color.red;
|
Color gizmoColor = Evaluate(player) ? Color.green : Color.red;
|
||||||
gizmoColor = active ? gizmoColor : Color.gray;
|
gizmoColor = active ? gizmoColor : Color.gray;
|
||||||
|
|
||||||
using (Draw.ingame.WithColor(gizmoColor)){
|
using (Draw.ingame.WithColor(gizmoColor)){
|
||||||
Vector3 labelStartPos = Vector3.zero;
|
|
||||||
switch (labelLocation) {
|
|
||||||
case LabelDrawingLocation.PlayerOffset:
|
|
||||||
labelStartPos = player.transform.position + labelLocationOffset;
|
|
||||||
break;
|
|
||||||
case LabelDrawingLocation.IntersectingLength:
|
|
||||||
labelStartPos = (relativeStart + (player.transform.rotation * direction * length) / 2f ) + labelLocationOffset;
|
|
||||||
break;
|
|
||||||
case LabelDrawingLocation.HitLocation:{
|
|
||||||
if (hit.transform != null) {
|
|
||||||
labelStartPos = hit.point + labelLocationOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (castType) {
|
switch (castType) {
|
||||||
case CastType.Ray:
|
case CastType.Ray:
|
||||||
Draw.ingame.Line(relativeStart, relativeStart + (player.transform.rotation * direction.normalized) * length);
|
Draw.ingame.Line(relativeStart, relativeStart + (player.transform.rotation * direction.normalized) * length);
|
||||||
@@ -152,35 +151,88 @@ public class EnvironmentObserver{
|
|||||||
case CastType.BoxOverlap:
|
case CastType.BoxOverlap:
|
||||||
Draw.ingame.WireBox(relativeStartWithRotation, player.transform.rotation * Quaternion.Euler(rotation), size);
|
Draw.ingame.WireBox(relativeStartWithRotation, player.transform.rotation * Quaternion.Euler(rotation), size);
|
||||||
break;
|
break;
|
||||||
case CastType.SphereOverlap:
|
case CastType.SphereCast:
|
||||||
|
Draw.ingame.SolidCircle(relativeStartWithRotation, relativeStartWithRotation - Camera.main.transform.position, width * 1, gizmoColor.Alpha(.5f));
|
||||||
|
Draw.ingame.WireCapsule(relativeStartWithRotation, relativeStartWithRotation + gizmosRotation * (Vector3.forward * (length - width / 2)), width);
|
||||||
break;
|
break;
|
||||||
case CastType.BoxCast:
|
case CastType.BoxCast:
|
||||||
// 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 / 2f);
|
|
||||||
Vector3 offsetFromCenter = relativeStartWithRotation + player.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);
|
|
||||||
|
|
||||||
// Draw the gizmos for the boxcast
|
// Draw the gizmos for the boxcast
|
||||||
Draw.ingame.WireBox(relativeStartWithRotation, gizmosRotation, Vector3.one * width);
|
Draw.ingame.WireBox(offsetFromCenter, gizmosRotation, new float3(size.x, size.y, length));
|
||||||
Draw.ingame.WireBox(offsetFromCenter, gizmosRotation, new float3(width, width, length + width));
|
Draw.ingame.SolidBox(relativeStartWithRotation, gizmosRotation, size, gizmoColor.Alpha(.1f));
|
||||||
|
|
||||||
|
Draw.ingame.WireBox(relativeStartWithRotation, gizmosRotation, size);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.ingame.Label3D(
|
Draw.ingame.SolidCircle(relativeStartWithRotation, relativeStartWithRotation - Camera.main.transform.position, .4f);
|
||||||
labelStartPos,
|
Draw.ingame.SolidCircle(hit.point, hit.point - Camera.main.transform.position, .4f);
|
||||||
player.transform.rotation * Quaternion.Euler(labelRotationOffset),
|
|
||||||
hit.collider == null ? "" : hit.collider.name,
|
// Set up variables for label (not hit name)
|
||||||
.5f,
|
Vector3 labelStartPos = Vector3.zero;
|
||||||
LabelAlignment.Center,
|
switch (labelTextLocation) {
|
||||||
Color.black
|
case LabelDrawingLocation.PlayerOffset:
|
||||||
);
|
labelStartPos = player.transform.position;
|
||||||
|
break;
|
||||||
|
case LabelDrawingLocation.IntersectingLength:
|
||||||
|
labelStartPos = offsetFromCenter;
|
||||||
|
break;
|
||||||
|
case LabelDrawingLocation.HitLocation:{
|
||||||
|
if (hit.transform != null) {
|
||||||
|
labelStartPos = hit.point;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw label
|
||||||
|
if (drawLabel) {
|
||||||
|
Draw.ingame.Label3D(
|
||||||
|
labelStartPos + labelLocationOffset,
|
||||||
|
gizmosRotation * Quaternion.Euler(labelRotationOffset),
|
||||||
|
label,
|
||||||
|
labelSize,
|
||||||
|
LabelAlignment.MiddleLeft,
|
||||||
|
gizmoColor
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up variables for hit name
|
||||||
|
// Since the label is already drawn just use the previous startPos
|
||||||
|
switch (labelTextLocation) {
|
||||||
|
case LabelDrawingLocation.PlayerOffset:
|
||||||
|
labelStartPos = player.transform.position;
|
||||||
|
break;
|
||||||
|
case LabelDrawingLocation.IntersectingLength:
|
||||||
|
labelStartPos = offsetFromCenter;
|
||||||
|
break;
|
||||||
|
case LabelDrawingLocation.HitLocation:{
|
||||||
|
if (hit.transform != null) {
|
||||||
|
labelStartPos = hit.point;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw hitname
|
||||||
|
if (drawLabel) {
|
||||||
|
Draw.ingame.Label3D(
|
||||||
|
labelStartPos + labelLocationOffset,
|
||||||
|
gizmosRotation * Quaternion.Euler(labelRotationOffset),
|
||||||
|
label,
|
||||||
|
hitTextSize,
|
||||||
|
LabelAlignment.MiddleLeft,
|
||||||
|
gizmoColor
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Sirenix.Utilities.Editor.GUIHelper.RequestRepaint();
|
Sirenix.Utilities.Editor.GUIHelper.RequestRepaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Color GetObserverStatusColorStatic(bool active, RaycastHit hit){
|
static Color GetObserverStatusColorStatic(bool active, RaycastHit hit){
|
||||||
|
|||||||
BIN
Documents/Graphics/UI/Icons.afdesign
Normal file
BIN
Documents/Graphics/UI/Icons.afdesign
Normal file
Binary file not shown.
Reference in New Issue
Block a user