Search Unity

PathMagic released!

Discussion in 'Assets and Asset Store' started by marcojacovone, Dec 16, 2015.

  1. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    Hello again, @marcojacovone, did you have a chance to duplicate my results from the file link above? Any hints on what I might be doing wrong?

    Thanks!
     
  2. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi, Kevin,

    I Can't see your sample scene. Can you pack the entire project into a zip and send me it?

    Thanks,
    MArco
     
  3. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    Last edited: Dec 12, 2017
  4. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    What version of Unity are you using? Have you extracted them via “export package” procedure?
     
  5. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
  6. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,

    It still don't work. See attached images.

    Schermata 2017-12-13 02.40.47.png

    Schermata 2017-12-13 02.41.17.png

    Tried with Unity 5.6.3 and 2017.2

    May be you've miss some dependencies?
     
  7. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    Thanks again @marcojacovone, sorry for the trouble!

    I exported a new package using a single cube as the path target, it cleanly loads in a new project when I tested it.

    Here are steps to see the trouble I'm having:
    • Import my most recent test Unity package (not attached here -- I sent this by e-mail as it includes PathMagic scripts, which of course I don't want to post publicly)
    • Open 'PathMagic_path' scene
    • The object '477_flight' has the PathMagic master script; object 'Capsule' has the baked animation from this set of waypoints
    Press PLAY, switch back to the Editor, frame and follow the 'Capsule' object.

    You'll see the object ease-out, stop, then ease-in many times over the path. Feel free to change values and bake again from the object '477_flight' to test.

    Again, I'd like the object to not stop, smoothly interpolate rotations through the waypoints given, and face forward.

    For reference, the 'sphere' object contains a sphere centered on each waypoint to make the correlation between waypoints and motion clear.

    Thanks again for your help!
     
  8. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    Thanks, @marcojacovone, I inserted your suggested code block to explicitly set the key tangents, and increased the sampling density -- and it works! The object doesn't stop now.

    Almost there -- but there are a few last problems:
    • The object with baked animation deflects at waypoints -- it does not smoothly interpolate. See the below image left: the rotation of the bird snaps between rotation A and B at the waypoint shown. Increasing the ‘Follow bias’ term smooths these deflection points, but with a fishtail motion which is non-physical for a body in flight. Is there a way to get more natural rotations with baked animation? The image below at right shows the kind of smooth rotation I'd like -- as if the waypoint were the control points on a NURBS spline:

    • The animated object jerks relative to moving camera. Perhaps moving the PathMagic transform update from 'Update' to 'LateUpdate' would help here? To be clear: in the Game view, from a moving camera we see the position for the PathMagic animated object jittering/strobing.
    • Since sampling time varies with each telemetry point, we currently handle velocity over time by baking waypoints into Unity legacy animation via PathMagic, given the sample rate. It would be good to take each waypoint's time into account (see the time difference in the sample points below). Is there any way to do this?
    477,36.16314,-121.6323,862,2013-07-04,10:47:06
    477,36.16397,-121.64795,770,2013-07-04,11:40:26
    477,36.16704,-121.67127,485,2013-07-04,11:43:08
     
    Last edited: Dec 14, 2017
  9. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    Hello, @marcojacovone,

    What is the best way to precisely set or compute how long a given presampled path will take to play?

    I've timed path playback at runtime (and in the Editor) with a number of different paths, all presampled and having 200 samples each: all the times are different, and they don't seem to relate simply to the total path length.

    I need to move an object at an initial speed that matches an object on a PathMagic path, so knowing the time from sample [0-1] seems the way to do that, since objects on presampled paths are meant to move at the same rate from beginning to end. That is:

    Code (CSharp):
    1. flight_speed = multplier * (currentPathScript.SamplesDistances[1] / (totalFlightDuration / currentPathScript.SamplesNum));
    The documentation doesn't discuss speed, hence my question...

    Thanks for your advice on how to set or determine times.
     
  10. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    Hello, @marcojacovone,

    Can you please respond to my question about getting and setting times for PathMagic paths?
     
  11. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,

    Pathmagic does not let you set the total path time or its total length. In the case of Pre-Sampled Path calculates the total length with the aim of proceeding at a constant speed (only if the speeds of the individual waypoints are all the same).

    So the idea of measuring the duration between two waypoints and multiplying it by the total number of waypoints should work.

    There is a public property for the TotalDistance.

    Code (CSharp):
    1.  
    2. /// <summary>
    3. /// Gets the total distance of the path in world units. This value is defined only for pre-sampled paths.
    4. /// </summary>
    5. /// <value>The total distance.</value>
    6. public float TotalDistance {
    7.     get {
    8.         return totalDistance;
    9.     }
    10. }
    11.  
    Thanks,
    Marco
     
  12. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    Hello, @marcojacovone,

    Thanks for your notes.

    As per my posts above, I am creating paths from a series of points -- see the code below.

    I'm setting uniform velocity (1.0) and symmetric tangents for each point. The resulting speed of the resulting PathMagic path seems to depend on the distance from one waypoint to the next. Therefore, the flight path speeds up and slows down from one waypoint to the next, which is not viable.

    Since PathMagic won't let me set explicit times for each waypoint from my input data, as a compromise I simply want all the waypoints in a given flight to be at roughly the same speed.

    What do you advise I do? Again, I would like a PathMagic path to travel at a uniform speed over a group of waypoints derived from 3d points. It doesn't need to be perfectly timed, but the current approach of varying the time by distance gives wildly different speeds between each waypoint, which isn't acceptable.

    Thanks for any suggestions!

    Code (CSharp):
    1.         private void CreatePathFromFile(PathMagic pm)
    2.         {
    3.             _samples = valuesCollection.Count;
    4.             Waypoint[] wps = new Waypoint[_samples];
    5.  
    6.             Debug.Log("==> Importing total points: " + _samples);
    7.  
    8.             for (int i = 0; i < _samples; i++)
    9.             {
    10.                 wps[i] = new Waypoint();
    11.  
    12.                 // Set position for the new waypoint
    13.                 wps[i].position = new Vector3((float)valuesCollection[i].X, valuesCollection[i].Altitude, (float)valuesCollection[i].Z);
    14.  
    15.                 // Set velocity from waypoint time
    16.                 wps[i].Velocity = 1;
    17.  
    18.                 wps[i].symmetricTangents = _sameTangentRadius;
    19.  
    20.                 int prevIndex = ((i - 1) < 0) ? (i + _samples - 1) : (i - 1);
    21.                 Vector3 prevPos = new Vector3(_radiusX / (_samples - 1) * prevIndex, 0, 0);
    22.  
    23.                 wps[i].inTangent = (prevPos - wps[i].position).normalized * _inTangentRadius;
    24.                 wps[i].outTangent = -wps[i].inTangent; //(nextPos - wps [i].position).normalized * _outTangentRadius;
    25.             }
    26.  
    27.             // Keep path open
    28.             //pm.loop = _closed;
    29.             pm.waypoints = wps;
    30.         }
     
  13. TimeTours

    TimeTours

    Joined:
    Mar 4, 2018
    Posts:
    14
    I don't understand how you set the path direction so it looks always "in the direction" of the path. Like the plane in demo video (not looking left or right like the attached camera in the demo video).

    Edit: Sorry, it is obviously "Global Follow Path". It didn't work first as I had some baked animation going on.
     
  14. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,443
    Suddenly I can't manipulate a PathMagic path with the mouse in the Edit view. Unity 2018.2.1f1 and the latest PathMagic, and I haven't changed either one in quite a while, so I am not sure what changed. New scene, restart Unity, nothing, new PathMagic added to the scene, nothing seems to let me manipulate by the gizmos. The grabby arrow tips of the gizmos also seem dimmer-colored than usual. There is some visual indication that I am grabbing, but nothing can be moved or rotated. It looks like one of your reviewers was complaining of something similar... did you ever find anything about it?
     
  15. zimethsuki

    zimethsuki

    Joined:
    Jun 29, 2014
    Posts:
    1
    Hi,

    I also get the same problem with halley, i cant manipulate the waypoint using the gizmo on scene view. The inspector was fine thou.

    I'm using Unity 2018.2.6 and the newest version of Path Magic.

    thank you for your help.
     
  16. Serhii-Horun

    Serhii-Horun

    Joined:
    Apr 12, 2015
    Posts:
    151
    Hi!

    I want to create moving platform, which have to move across path forward and backward.
    How can I reverse moving direction? If I switch Velocity Bias at the last point(simulate "backward" playing direction), it reverse only until previous node will be reached. Then the direction begin forward again.
    Something wrong with "Reached" event invoking in that case.

    I think it is a so basic staff and it should be implemented in that plugin. I can't believe that I can't find that feature in such great plugin

    Thanks!
     
    Kjelle69 likes this.
  17. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,

    can you tell me a bit more about your project?

    How do you invert the velocityBias?
    Can you send me a small extract of your project can reproduce the issue?

    Thanks
    Marco
     
  18. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    For all those who have the problem of gizmos that do not move in the editor...

    You need to replace the PathMagicEditor.cs file with the attached file.
    Tell me if you solve the issue.

    Thanks
    Marco
     

    Attached Files:

  19. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,443
    marcojacovone,

    I am trying to add another Utility button to the PathMagicEditor class, which will transfer the current rotation of the target object into the currently selected waypoint's rotation field. I am close, but not quite correct.

    Code (CSharp):
    1.  
    2. waypoints.GetArrayElementAtIndex(currentSelectedWaypoint).FindPropertyRelative("rotation").vector3Value =
    3.     ((PathMagic)serializedObject.targetObject).transform.rotation.eulerAngles;
    4.  
    Similar issue with position.

    Why? Sometimes the desired waypoint orientation is hard to update visually, for example the orientation of a character's bone. But it's easier to pose the character.

    I have the Preview "Apply Transform" turned off, select a waypoint, ensure a non-null target, orient the target as desired, and hit this button. The waypoint's rotation field updates, but it doesn't seem to update to the same direction or orientation that the target has. Not sure if it's a misunderstanding of local vs global, or what. Any idea?
     
    Last edited: Apr 20, 2019
  20. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,443
    Okay, I figured it out. It was confusion over the many different meanings of the word "target".

    This is around line 456, within the waypoints foldout:

    Code (CSharp):
    1.                     Transform _ourself = ((PathMagic)serializedObject.targetObject).transform;
    2.                     Transform _target = ((PathMagic)serializedObject.targetObject).target;
    3.                     GUI.enabled = (currentSelectedWaypoint >= 0 && currentSelectedWaypoint < waypoints.arraySize) && (_target != null);
    4.                     if (GUILayout.Button(new GUIContent("Copy Position from Target", "Updates current waypoint to be where target transform is currently placed"), GUILayout.Width(EditorGUIUtility.currentViewWidth / 2f)))
    5.                     {
    6.                         waypoints.GetArrayElementAtIndex(currentSelectedWaypoint).FindPropertyRelative("position").vector3Value =
    7.                             _ourself.InverseTransformPoint(_target.transform.position);
    8.                     }
    9.                     if (GUILayout.Button(new GUIContent("Copy Rotation from Target", "Updates current waypoint to look like target transform is currently looking"), GUILayout.Width(EditorGUIUtility.currentViewWidth / 2f)))
    10.                     {
    11.                         waypoints.GetArrayElementAtIndex(currentSelectedWaypoint).FindPropertyRelative("rotation").vector3Value =
    12.                             (Quaternion.Inverse(_ourself.transform.rotation) * _target.rotation).eulerAngles;
    13.                     }
    14.                     GUI.enabled = true;
    15.  
     
    NeatWolf likes this.
  21. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Well done.
    I Will integrate this feature in a next release.
    Thanks to halley.
     
    NeatWolf likes this.
  22. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    924
    Hi there Marco!

    Probably it's a bit of a stretch, but I'm asking nonetheless (it's for a little "doodle" project which ended up filling my whole spare time. Yes, an experiment, "one of those" :p ):

    since we already have a way to determine the distance from the path, is there any chance to build a SDF texture using pathmagic?

    My final goal would be to use the distance field in training the AI to stay as close as possible to the ideal driving path (think of a micromachine game, 1 path for the ideal trajectory, 2 paths, on per side, to mark the hard boundaries), so to build a grid where the AI should move to the best next point knowing the current position, and the distance (with falloff maybe) from the ideal path, and the hazard paths.

    I'm basically trying to optimize it for performance, so I'm not even sure the signed distance field is the best way to go :)

    Is there any particular feature of PathMagic I may have missed to achieve this result?
    (actually, the path could be also on different heights so squashing everything in 2D would be an approximation)
     
  23. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,443
    @marcojacovone, I have made a few interesting new scripts which I think may be interesting for you. They assist in setting up junctions or networks of pathmagic paths, and navigating randomly or toward a goal position in the network. Your website seems to be down.

    But now that I work with multiple paths so much, the issue of constant velocity has come up again. I have two paths of different physical lengths, and a target using an animator. The paths are both presampled, have velocity=1 at every waypoint, and have the same velocity bias. The animator never changes its velocity bias. But the actual target world space velocity is very different between a long path and a short path. The number of presample points does not affect the actual velocity, but the overall length of the path seems to do so. I want my animator target to move at a specific speed regardless of which path he is attached. Any ideas?

    Edit: after studying the code a bit more, the term "velocity" throughout the code is really "rate of change of the 'pos' interpolation." So every path's pos goes from 0->1 at the same rate if using the same "velocity bias," notwithstanding all the ease-in/ease-out waypoint stuff, regardless of path length or number of waypoints. So my approach to making this truly world-space velocity based is to creep forward the 'pos' until the real world position has traveled enough. There are some heuristics to ensure I creep forward only a few small iterations per frame to keep the workload down without being too inaccurate around tight curves. Now I can specify world speeds in m/s or km/h, and move cars along paths of any length.
     
    Last edited: May 30, 2019
  24. Kjelle69

    Kjelle69

    Joined:
    Nov 9, 2016
    Posts:
    53
    I have the same need in my current project. I dont want to loop the path but rather "Ping Pong" the whole linear path if possible ? :)
     
    Last edited: Nov 20, 2019
    NeatWolf likes this.
  25. Kjelle69

    Kjelle69

    Joined:
    Nov 9, 2016
    Posts:
    53
    I solved it :)


    Code (CSharp):
    1. using Jacovone;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class LoaderScript : MonoBehaviour
    7. {
    8.     public PathMagic pma;
    9.     public bool BackWards = false;
    10.  
    11.     // Use this for initialization
    12.     void Start()
    13.     {
    14.  
    15.     }
    16.  
    17.     // Update is called once per frame
    18.     void Update()
    19.     {
    20.         Debug.Log("Waypoint  " + pma.GetCurrentWaypoint().ToString());
    21.  
    22.         if (pma.GetCurrentWaypoint() == 9 & BackWards==false)
    23.         {
    24.             BackWards = true;
    25.             pma.VelocityBias = -0.1f;
    26.         }
    27.  
    28.         if (pma.GetCurrentWaypoint() == 1 & BackWards == true)
    29.         {
    30.             BackWards = false;
    31.             pma.VelocityBias = 0.1f;
    32.         }
    33.     }
    34. }
     
    NeatWolf likes this.
  26. KSatyaAravind

    KSatyaAravind

    Joined:
    Dec 11, 2019
    Posts:
    4
    Hi when im using simple model which has bones to follow the path but its not coming in correct way. whatever i do its always changing its oreintation. how to solve. Thanks in advance.
     
  27. werre

    werre

    Joined:
    Apr 29, 2018
    Posts:
    1
    Hello,

    Is this project still supported?

    I have issues with the actual path being displayed in editor in certain versions of Unity. On Mac, I can see and graphically edit the path on 2019.2.12, but on 2019.3.7 and 2019.3.9 it is not displayed at all (however function is working when run the path)

    On Windows, I can edit the path without problems on 2019.3.9.

    Any idea how to enable the path display, or what could go wrong on Unity here running on Mac?

    Thanks a lot in advance.
     
  28. Eispin

    Eispin

    Joined:
    Jun 4, 2017
    Posts:
    4
    Hi Marco,

    I bought PathMagic a few days ago and I love it! It´s helping me with a lot of things already.

    The Only Problem that I have right now is that when I bake the animation, which I probably have to due to performance, It doesnt consider my velocity values. It bakes it with constant speed.

    I´m not sure if I´m doing something wrong or if it´s just the way it is.

    Would be great to get some help!

    Cheers David
     
  29. Eispin

    Eispin

    Joined:
    Jun 4, 2017
    Posts:
    4
    My path behaves differently in speed and velocity in play mode, in "path mode" (just pressing start button when not in Play Mode) and when its a baked animation.

    It´s a great tool, but if its not reliable or representable for a final baked animation, I cannot use it :(
     
  30. thesimonator

    thesimonator

    Joined:
    Oct 30, 2022
    Posts:
    1
    I could find absolutely NO documentation on Path Magic. None! I may be dense but I have no idea how to create a path with this software.