This commit is contained in:
2026-07-09 21:33:33 +02:00
commit 84a2a365f3
2364 changed files with 950134 additions and 0 deletions
@@ -0,0 +1,41 @@
using System.Collections.Generic;
using System.Linq;
using Sirenix.OdinInspector;
using Unity.AI.Navigation;
using UnityEngine;
using VOID.Generic.Objects.Abstract;
namespace VOID.Generic.Objects.Traversable
{
[RequireComponent(typeof(NavMeshLink))]
public class TraversableObject : AbstractObject
{
[Title("=== Traversable properties ===")]
public TraversableObjectData traversableData;
private void OnDrawGizmosSelected()
{
if (traversableData.path.Count > 1)
{
Gizmos.color = Color.blue;
traversableData.path.ForEach(t =>
{
var pos = t.position;
Gizmos.DrawSphere(pos, 0.05f);
Gizmos.DrawLine(pos, pos + t.forward * 0.25f);
});
Gizmos.DrawLineList(traversableData.path.Select(t => t.position).ToArray());
}
}
protected override List<ObjectComponent> GetObjectComponents()
{
return base.GetObjectComponents()
.Union(new List<ObjectComponent>
{
traversableData
})
.ToList();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1620bd1665bc4fbeaa7fb4e1adad15ac
timeCreated: 1705173241
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using Unity.AI.Navigation;
using UnityEngine;
using UnityEngine.AI;
using VOID.Generic.Navigation;
namespace VOID.Generic.Objects.Traversable
{
[Serializable]
public class TraversableObjectData : ObjectComponent<TraversableObject>
{
#region Initialize
protected override void Initialize()
{
navMeshLink = parent.GetComponent<NavMeshLink>();
// Find traversable's FIRST link point
var startPos = navMeshLink.startTransform.position + navMeshLink.startPoint;
NavMesh.SamplePosition(startPos, out var hitStart, 0.5f, NavMesh.AllAreas);
linkStartPosition = hitStart.position;
// Find traversable's SECOND link point
var endPos = navMeshLink.endTransform.position + navMeshLink.endPoint;
NavMesh.SamplePosition(endPos, out var hitEnd, 0.5f, NavMesh.AllAreas);
linkEndPosition = hitEnd.position;
// ..And register it in navigation manager
NavigationManager.current.RegisterTraversable(parent);
}
#endregion
[Title("Pathing")]
[RequiredListLength(MinLength = 2)]
public List<Transform> path;
// Runtime cache
[ShowInInspector] [ReadOnly] public NavMeshLink navMeshLink { get; private set; }
[ShowInInspector] [ReadOnly] public Vector3 linkStartPosition { get; private set; }
[ShowInInspector] [ReadOnly] public Vector3 linkEndPosition { get; private set; }
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2fa497b528a644fea275bacac7eb7957
timeCreated: 1705440793