blob: 88c5a7b2e5c163c351bea90b4bdf5f249ae7e5a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
using UnityEngine;
namespace Pathfinding {
using Pathfinding.Util;
/// <summary>Helper for <see cref="Pathfinding.Examples.LocalSpaceRichAI"/></summary>
[HelpURL("https://arongranberg.com/astar/documentation/stable/localspacegraph.html")]
public class LocalSpaceGraph : VersionedMonoBehaviour {
Matrix4x4 originalMatrix;
MutableGraphTransform graphTransform = new MutableGraphTransform(Matrix4x4.identity);
public GraphTransform transformation { get { return graphTransform; } }
void Start () {
originalMatrix = transform.worldToLocalMatrix;
transform.hasChanged = true;
Refresh();
}
public void Refresh () {
// Avoid updating the GraphTransform if the object has not moved
if (transform.hasChanged) {
graphTransform.SetMatrix(transform.localToWorldMatrix * originalMatrix);
transform.hasChanged = false;
}
}
}
}
|