mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Added path dump for debug raycaster
This commit is contained in:
parent
08c9afd988
commit
3cbc823b88
@ -1,4 +1,5 @@
|
||||
using NewHorizons.Builder.Body;
|
||||
using NewHorizons;
|
||||
using NewHorizons.Builder.Body;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -21,7 +22,7 @@ namespace NewHorizons.Utility
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Keyboard.current != null && Keyboard.current[Key.P].wasReleasedThisFrame)
|
||||
if (Main.Debug && Keyboard.current != null && Keyboard.current[Key.P].wasReleasedThisFrame)
|
||||
{
|
||||
// Raycast
|
||||
_rb.DisableCollisionDetection();
|
||||
@ -31,7 +32,7 @@ namespace NewHorizons.Utility
|
||||
if (Physics.Raycast(origin, direction, out RaycastHit hitInfo, 100f, layerMask))
|
||||
{
|
||||
var pos = hitInfo.transform.InverseTransformPoint(hitInfo.point);
|
||||
Logger.Log($"Raycast hit {{\"x\": {pos.x}, \"y\": {pos.y}, \"z\": {pos.z}}} on [{hitInfo.transform.gameObject.name}]");
|
||||
Logger.Log($"Raycast hit {{\"x\": {pos.x}, \"y\": {pos.y}, \"z\": {pos.z}}} on [{hitInfo.transform.gameObject.name}] at [{GetPath(hitInfo.transform.gameObject)}]");
|
||||
}
|
||||
_rb.EnableCollisionDetection();
|
||||
}
|
||||
|
||||
@ -172,5 +172,16 @@ namespace NewHorizons.Utility
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
public static string GetPath(GameObject obj)
|
||||
{
|
||||
string path = "/" + obj.name;
|
||||
while (obj.transform.parent != null)
|
||||
{
|
||||
obj = obj.transform.parent.gameObject;
|
||||
path = "/" + obj.name + path;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user