Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoDummyPathEditor Enhancement #12

Open
RavenCastleSTU opened this issue Oct 19, 2012 · 0 comments
Open

GoDummyPathEditor Enhancement #12

RavenCastleSTU opened this issue Oct 19, 2012 · 0 comments

Comments

@RavenCastleSTU
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant