-
Notifications
You must be signed in to change notification settings - Fork 125
Open
Description
Hi prime31, I created a small enhancement to the Editor class so we can move the nodes to start at the location of the GameObject where the GoDummyPath is.
I added this script just bellow this script block:
if( GUILayout.Button( "Shift Path to Start at Origin" ) ) { ... }
Here is the code:
// shift the start point to the GameObject where the GoDummyPath is
if (GUILayout.Button("Shift Path to Start at Object"))
{
Undo.RegisterUndo(_target, "Path Vector Changed");
var offset = Vector3.zero;
// see what kind of path we are. the simplest case is just a straight line
var path = new GoSpline(_target.nodes, _target.forceStraightLinePath);
if (path.splineType == SplineType.StraightLine)
offset = _target.transform.position - _target.nodes[0];
else
offset = _target.transform.position - _target.nodes[1];
for (var i = 0; i < _target.nodes.Count; i++)
_target.nodes[i] += offset;
GUI.changed = true;
}
I hope you add this to the branch. I found this very useful to observe the path when creating some spawn nodes in my game and reusing previously saved paths.
You may want to create a method that receives the start position Vector3 as an argument to avoid code duplication in both buttons (Shift Path to Start at Origin and this new one I created)
Metadata
Metadata
Assignees
Labels
No labels