Log collider of debug raycast (#425)

## Improvements
- The object path and name of the collider hit by the debug raycast is
printed in addition to the rigidbody. #423
This commit is contained in:
Noah 2022-10-19 21:05:44 -04:00 committed by GitHub
commit 5fcafe0ad5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -14,7 +14,7 @@ namespace NewHorizons.Utility.DebugUtilities
public Vector3 norm;
public DebugRaycastPlane plane;
public string bodyName;
public string colliderPath;
public string bodyPath;
public GameObject hitBodyGameObject;
public GameObject hitObject;

View File

@ -104,7 +104,8 @@ namespace NewHorizons.Utility.DebugUtilities
_planeDownLeftSphere .transform.localPosition = data.plane.origin + data.plane.u*-1*planeSize + data.plane.v*-1*planeSize;
_planeDownRightSphere.transform.localPosition = data.plane.origin + data.plane.u*1*planeSize + data.plane.v*-1*planeSize;
Logger.Log($"Raycast hit \"position\": {posText}, \"normal\": {normText} on [{data.bodyName}] at [{data.bodyPath}]");
Logger.Log($"Raycast hit \"position\": {posText}, \"normal\": {normText} on collider [{data.colliderPath}] " +
(data.bodyPath != null? $"at rigidbody [{data.bodyPath}]" : "not attached to a rigidbody"));
}
internal DebugRaycastData Raycast()
{
@ -124,8 +125,8 @@ namespace NewHorizons.Utility.DebugUtilities
var hitAstroObject = o.GetComponent<AstroObject>() ?? o.GetComponentInParent<AstroObject>();
data.bodyName = o.name;
data.bodyPath = o.transform.GetPath();
data.colliderPath = hitInfo.collider.transform.GetPath();
data.bodyPath = hitInfo.rigidbody?.transform.GetPath();
data.hitObject = o;
data.hitBodyGameObject = hitAstroObject?.gameObject ?? o;
data.plane = ConstructPlane(data);