maint: raycast clean-up

This commit is contained in:
Chris
2025-03-12 17:23:40 -04:00
parent 55bbe468df
commit 29f57a47b0
2 changed files with 17 additions and 47 deletions

View File

@@ -1,9 +1,4 @@
using System;
using Sirenix.OdinInspector;
using UnityEditor;
using UnityEngine;
using Unity.Mathematics;
using NodeCanvas.Framework;
using Drawing;
public class PlayerMovement : MonoBehaviour
@@ -21,20 +16,33 @@ public class PlayerMovement : MonoBehaviour
}
void Update(){
Color forwardRayStatus = Color.red;
// Create Ray Colors
Color forwardRayStatus = Color.red;
Color leftRayStatus = Color.red;
Color rightRayStatus = Color.red;
if (forwardRay.collider&& forwardRay.transform.gameObject.layer == LayerMask.NameToLayer("Environment")){ forwardRayStatus = Color.green;}
if (leftRay.collider&& leftRay.transform.gameObject.layer == LayerMask.NameToLayer("Environment")){ leftRayStatus = Color.green;}
if (rightRay.collider&& rightRay.transform.gameObject.layer == LayerMask.NameToLayer("Environment")){ rightRayStatus = Color.green;}
using (Draw.WithColor(forwardRayStatus)) {
Draw.Line(transform.position + transform.up, transform.position + transform.forward * 2.5f + transform.up);
}
using (Draw.WithColor(leftRayStatus)) {
Draw.Line(transform.position + transform.up, transform.position + -transform.right * 2f + transform.up);
}
using (Draw.WithColor(rightRayStatus)) {
Draw.Line(transform.position + transform.up, transform.position + transform.right * 2f + transform.up);
}
}
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<bool>("ForwardRay", true, null);
thisPlayer.controls.graph.SendEvent("ForwardRay", true, null);
}
if (Physics.Raycast(transform.position + Vector3.up, transform.position + Vector3.left, out leftRay, maxDistance: 2f, ~environmentLayer )) {