Search Unity

PathMagic released!

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

  1. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    PathMagic is a UNITY editor extension that allows to create paths for smooth movement of game objects, such as cameras, players, scene objects, and so on.

    You specify waypoints with 3D bezier control points, orientation, velocity, and PathMagic do the rest!

    Take a look at the demo video

    Features
    • Advanced in-scene and inspector editors
    • Full integrated undo/redo and multiple objects edit support
    • Full global position, rotation and scale of all waypoints for path adjusting
    • Best interpolation of orientation and velocity between waypoints
    • Transform orientation specified manually or by a target Transform to follow
    • Intelligent insert/Remove waypoint within the path
    • Great simulation system: manage your path during the simulation in edit mode
    • Powerful and simple user interface
    PathMagic lets you create a path in less than 15 seconds!

    This is the link at the Asset store: http://u3d.as/kht

    Suggestions are welcome!
     
    theANMATOR2b likes this.
  2. marcojacovone

    marcojacovone

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

    version 1.1.1 of PathMagic is on the store! This version introduces some new features such as events fixed global look at. This is a screenshot of the new inspector.



    Velocity bias now can be negative to implement forward and backward animation, the connected transform can “Global Look at” at fixed point, so orientation is never interpolated between waypoints and look at specific point continuously.

    Events is a great feature. There is a global events list. Currently the only event that can be detected is “Waypoint changed”. Each time the animator passes a waypoint the event is fired, and your code is executed. The method that is called receive an integer parameter that is the waypoint index. Another way is define a event when a specific waypoint is reached, to do that, click on the waypoint on the list. A specific events list for the waypoints appear.



    In this case you define what happens when the specific waypoint (2 in this case) is reached. The called method has no params. You can use events, for example, to stop a path and start another one, creating amazing animation effects.

    Have you tried to animate particles? ;-)
     
  3. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hey Guys,

    another version of PathMagic is on the store! Version 1.1.2.

    Improvements
    - Global follow path direction
    Bug Fixing
    - Strange transform handles in scene view (thanks to Lion)
    - Simulation, Play and final build now goes at the same velocity (thanks to Mads)
     
  4. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    A small preview of PathMagic v.1.2

    Improvements: Asymmetrical tangents!

     
  5. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Another amazing feature is coming!
    Path sampling, for constant speed bezier paths!

    Take a look, it will be released with version 1.2 of PathMagic!

     
  6. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    With coming version 1.2 of PathMagic, you will put more that one transform on a same path. This makes me thinking about some possibilities this enables. And… Here we go!

    Simply make a character with bones (a skinned mesh renderer in Unity), and connect single bones to the same path, each at specific position.

    Do you want to see the result?

    Take a look!

     
  7. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    PathMagic 1.2.1 released.

    Release notes:

    Improvements

    • New Global Follow Path bias for smooth camera paths
    • New Path templates (GameObject->PathMagic->Create new path from template)
    • Override Global Follow Target in PathMagicAnimator
    • Override Global Follow Path in PathMagicAnimator (only for non-pre-sampled paths)
    • Scripting: All public attributes become properties in PathMagic class
    • Scripting: All public attributes become properties in PathMagicAnimator class
    • Customizable path color in editor
    • Some editor styles looks better
    • Ease in/out for velocity at waypoint level
    • Compatibility with Unity 4.6.6
    Changes

    • Clear selection shortcut (Esc) does not select all waypoints anymore
    • “F” don’t center on waypoint anymore, use Enter
    Fixes

    • Corrected strange rotation at end of path with GlobalFollowPath and not looped

    Take a look at the post https://jacovone.com/wordpress/?p=2567
     
  8. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
  9. martibergoglio

    martibergoglio

    Joined:
    May 28, 2015
    Posts:
    14
    Hi, i have a question, may be it is a stupid one but i cant figured out.
    Im using 2 path with separates cameras for make a cinematic, i want one path "Start on Play" and start the other by code, when try to reference the Script Unity does not recognize de namespace "PathMagic"...is there any trick or is just me?
     
  10. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,

    depends on how you want to reference the path. You can set it in a property for example, or access it via a static member. Anyway, can you send me a very small project extraction, so that I can work on it for you?

    Thanks,
    Marco
     
  11. SumoT

    SumoT

    Joined:
    Jan 15, 2013
    Posts:
    1
    Hello,

    I just bought your plugin and your demos look great. I have what may be a similar question to martibergoglio, do you have any examples on how to programmatically interact with an animation along path that has been created with PathMagic? Specifically, I want to be able to start, pause, continue, or exit an animation. It would also be nice to be able to request a spline through an API based on a start, mid, and end point, with all of the facing information.

    Thank you
    Curtis
     
  12. marcojacovone

    marcojacovone

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


    PathMagic (and ParhMagicAnimator) class has very basic methods for interact with the animation, such as Play, Pause, Stop, Rewind, ... All you need is a reference to the object.

    Alternatively you can animate objects on the path with Mechanim, this allows you to interact with the animation through Mechanim's workflow, and give you a more accurate control on animation curves.

    To dynamically create a new arc on the path, you need to add a waypoint in the waypoints array, and set in/out tangents (velocity, orientation, etc.) because PathMagic uses brazier curves.

    A good example for dynamic waypoint generation is already in the package, check template paths (a utility for make a regular path from scratch in a few clicks).

    Give me a feedback, and tell me if you need more support, for example a simple example project.

    Have a nice day.
    Marco.
     
  13. fred2507

    fred2507

    Joined:
    Mar 3, 2015
    Posts:
    4
    Hi, i'm thinking of buying Pathmagic, but I want to ask, if I can do the following: for animating something like a chain, i'm able to set (with pathanimator) different currentpos values, then play. But then, all the Cubes would come together in the end of the path.. is it possible, to do add something like a targetpos?

    Cube.currentpos = 0.1f;
    Cube.Play(targetpos = 0.9f);

    Thank you!
     
  14. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,

    what you can do is to call Play() only for the first item of the chain, and in Update() of a script, you can set

    currentPos of the second item = currentPos of the first - delta
    currentPos of the third item = currentPos of the second - delta
    ...

    This should work.
    Let me know if you solve with this approach. If you don't, we will find together another strategy.
    Thanks

    Marco
     
  15. Robosport

    Robosport

    Joined:
    Dec 6, 2014
    Posts:
    5
    What are the correct settings in the inspector for the first waypoint and the last waypoint in order to have the path ease into the move and then ease out at the end, instead of starting and stopping at full velocity?
     
  16. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,

    for example, if you have 5 waypoints, you can set velocities as follows:

    v1: 0.5
    v2: 2
    v3: 5
    v4: 2
    v5: 0.5

    after, you have to set

    for w1: velocity out: slow
    for w5: velocity in: slow

    other velocity ease can be medium or fast.

    Alternatively, you can animate your target over the path by animating CurrentPos of the PathMagic with Mechanim.
    Thanks,
    Marco
     
  17. Robosport

    Robosport

    Joined:
    Dec 6, 2014
    Posts:
    5
    Thank you for the quick reply.
     
  18. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hey Guys,

    a new version of PathMagic is coming... In the new version we introduce physics.
    Take a look!

     
  19. milan8888

    milan8888

    Joined:
    Jul 9, 2015
    Posts:
    12
    Hi

    once the path is made - is it possible to save it as animation?
     
  20. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Not for now...
    PathMagic has its own animator. I believe however this is a very simple to implement, if you really need it, I can help you.

    Marco.
     
  21. milan8888

    milan8888

    Joined:
    Jul 9, 2015
    Posts:
    12
    Well yeah - i guess its needed. I work with the Shadowgun GM Kit and all other flycams use animations. Dont think its a good idea to mix things as i need to stay compatible.
     
  22. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    876
    Hi,

    I was looking for a simple path editor, mostly because I need a quick visual way to build paths.

    I have to implement a crowd system (2D) that takes the current camera bounds in account to recycle a person moving out the camera to make it re enter the other side with some randomization.

    For this, I'd need the path system to:

    1) be able to get the Y position in the path, or the percentage along the path or between nodes to be able to move an object right outside from the camera bounds at a determined X position. In a manner that works very similar to a f(x) function.
    2) be as performant as possible since I'm on mobile. I may also not need splines if the moving direction vector of the entity I'm moving is not changing from a node to another (segmented/broken line).
    That is, I don't want the entities on a broken path to continuously recalculate direction on a flat line between two points, but only when reaching a path node.
    Performance-wise, I may also use splines or other types of controlled smoothings if the performance hit on the update function for every entity (I guess 30 entities at a time or so) isn't excessive.
    3) I should be able to deactivate instances on a path, and let them resume in any moment)
    4) I really need a way to vertically "drop" instances on a path, so a method to get a Y for every X should be provided or be easy to implement. Since the camera may teleport along with the player, I need to scatter objects on a path (it's a side view game, much like a platformer) randomly inside the camera frustrum (well, I actually use a orthographic camera).
    5) should be easy to setup a path in the editor, possibly being able to reorder the points in the path list from the inspector, or insert a node at a certain position to refine the path.

    I'm kind of in a hurry because I've got a deadline relatively soon.

    Is PathMagic the right asset for me?

    Thank you,

    Kind regards,
    Alessandro Salvati
     
  23. donping

    donping

    Joined:
    Mar 24, 2017
    Posts:
    1
    Hellow

    I want move object with same speed but to do that I have to set tangent value some how.

    Is there other way to move object with same speed? (p1 -> p2 -> p3)

    Please!
     
    Last edited: Mar 24, 2017
  24. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Yes,

    You can enable the pre-sample path option, in the inspector of the path, in the top right.
    Select the option and specify an amount of samples suitable for you.

    The will move along the path at constant speed.

    Regards,
    Marco.
     
  25. jameskett

    jameskett

    Joined:
    Apr 2, 2017
    Posts:
    5
    Hi Marco, I'm looking for a spline-based solution to let me add AI paths to a racing game , but I need to be able to get the closest point on the path relative to a vehicle's position , for things like working out current race positions and so the AI can work out where the AI path is etc... - does PathMagic have a way to return the nearest point on a path for a Vector3 world position?
     
  26. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Yes,

    There is a specific script in the package that let you move the target along the path, in the nearest position respect to a Vector3 in world space.

    Check the demo videos with attention, you will find a specific example for it.
    Any way, after the purchase, I can help you to solve specific needs.

    Thanks for your interest in PathMagic.
    Marco.
     
    jameskett likes this.
  27. jameskett

    jameskett

    Joined:
    Apr 2, 2017
    Posts:
    5
    Thanks Marco, just purchased a copy to have a test with.
     
  28. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Ok,

    thanks for trust. Tell me if you need support.

    Marco
     
  29. jameskett

    jameskett

    Joined:
    Apr 2, 2017
    Posts:
    5
    It seems to be working very well, I've got much smoother AI driving now than I had before using my own system.

    One issue seems to be trying to have multiple followers per spline - I couldn't get that to work. I tried adding one follower script per vehicle in my game code, and setting the targets etc.. correctly for each one , but it seems they all reference the same CurrentPos on the main spline, so they were all giving the same nearest position, no matter where the actual target vehicle was located.

    I tried another method adding 1 copy of the main spline per vehicle (instanced in code), with a single follower script attached to each spline, and that works fine and I have 16 vehicles all following the AI spline and working, but it seems a bit wasteful as I now have 16 copies of the same spline in the scene at runtime.

    Is there any way I can have multiple follower scripts on one spline all correctly returning the closest position to their own target object?
     
  30. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,

    You want to have a single spline, with many targets followed by respective followers, that share the same path. It is correct?
    If so, you have to:

    1. Create the main spline
    2. Attach a PathMagicAnimator to each follower and set the previous path as the "PathMagic path" property of the PathMagicAnimator inspector
    3. Now attach a PathMagicFollower to each follower, and set the object you want to follow as "Target" property of PathMagicFollower inspector
    You can try with two cubes that follow two different spheres but remaining on the same shared path.

    Tell me.
     
  31. jameskett

    jameskett

    Joined:
    Apr 2, 2017
    Posts:
    5
    Yes - a single spline, with many targets (vehicles) followed by respective followers, that share the same path.

    Basically each AI vehicle asks for the closest point on the main spline , so it can work out what direction to turn to remain on the track , and it also samples the spline a few times ahead of it to work out what direction the spline will curve and so whether it needs to speed up or slow down.

    The AI vehicle was using the CurrentPos from the follower script to get the closest point on the spline , which worked fine with a single vehicle but with more than one vehicle (each with their own follower script) CurrentPos returned the same position for all of them. I tried having 1 PathMagicFollower script per vehicle , and I also tried having 16 PathMagicFollower scripts attached to the main spline , but in both cases they all returned the same closest position no matter what target object each script was set to.

    When you say - "Attach a PathMagicAnimator to each follower" - where you say "follower" do you mean in my case on each vehicle? Or do I need another gameObject per vehicle to act as the "follower" ?
     
  32. jameskett

    jameskett

    Joined:
    Apr 2, 2017
    Posts:
    5
    Aha I've got it working now with just 1 spline, using the method you described , thanks Marco.
     
  33. kgersony

    kgersony

    Joined:
    Jan 24, 2017
    Posts:
    2
    I would like to save the PathMagic Path as an animation. I believe this was asked before. I'm not a programmer so any help would be appreciated. Thanks in advance!
     
  34. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,

    this feature will be present in the upcoming 1.2.5 version, that will be released soon.

    Marco
     
    milan8888 likes this.
  35. kgersony

    kgersony

    Joined:
    Jan 24, 2017
    Posts:
    2
    Oh good! Thanks.
     
  36. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Version 1.2.5 is out!

    Enjoy
     
    NeatWolf likes this.
  37. Phrygian

    Phrygian

    Joined:
    Jul 13, 2013
    Posts:
    9
    Is there a way to pause for an amount of time on a waypoint?
     
  38. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Sorry for delay in response.

    PathMagic supports events on waypoint.

    You can pause a target object by connecting the "Reached" event on a specific waypoint, and setting up a timer.
    When the timer expires, you can call Play() again on PathMagic object, and the target restarts from its current location.

    Regards,
    Marco
     
  39. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    Hello and thanks for your efforts!

    I need to import a long list of points from an ASCII file on disk -- it looks like that is not directly supported in the current version. Is that correct?

    If not, at first blush it seems I could generate a point list in the way you currently do for templates. However, this need not be dynamic -- the paths don't change at runtime, we know them all in advance. We can just load them.

    What do you advise as the easiest and best fit for your existing code?
     
  40. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    It looks like there is currently no way to specify a time interval for each waypoint.

    I suppose I can manage time separately and call equal increments to Preview position, but that seems backwards.

    Is there a supported option I'm missing?
     
  41. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    A last question for now: is it possible to easily make the spline path visible?
     
  42. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    I added an 'Import' option to the template tool, with support for loading path points from disk as shown:



    Here's an example of a path with ~100 waypoint nodes:



    In my case, I have times for bird positions at each waypoint. Consider these times for (5) waypoints:

    The total time is ~4 minutes, but the time delta between each waypoint varies as shown.

    I gather I should use your provided .Velocity attribute to set relative speed for each segment, but what values should I use to ensure the total time matches the individual point times?

    I'd like to set the velocities on load then modify Position at runtime to play back the bird path motion. The loading code follows:

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

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    When I press 'Start' in the main PathMagic script to begin the animation of the target object with ~100 waypoints, frame rate drops steeply, to an unusable level.

    Is that normal? Are there any settings responsible for that FPS drop?

    Baking to a legacy animation doesn't cause the slowdown, but for my purposes setting 'PreviewPosition' by script is much better.
     
    Last edited: Dec 2, 2017
  44. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    Regarding PathMagic velocity settings -- is there a way to set ease-in/ease-out timing to zero globally for all waypoints?

    That is, with multiple waypoints I see the object target ease-out to a full stop, then ease-in again. I want the object to continue at constant speed.

    In the forum I see your suggestion to click ‘Pre-sampled’ path and enter a ‘samples’ value to match keypoints, in order to set in/out at uniform speed.

    However, for me that results in the same thing -- the object slows to a full stop between waypoints.
     
    Last edited: Dec 3, 2017
  45. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    It's been 10 days since I first wrote -- I'd love to get some help, especially with my last question in bold, immediately above.

    Thanks for your time...
     
  46. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,

    I try to give answers per point.
    • I need to import a long list of points from an ASCII file on disk -- it looks like that is not directly supported in the current version. Is that correct?
      • Correct. At the moment this is not supported
    • If not, at first blush it seems I could generate a point list in the way you currently do for templates. However, this need not be dynamic -- the paths don't change at runtime, we know them all in advance. We can just load them
      • This is not completely true. You can write your code to load your waypoints, but you can also change waypoints definition at Runtime. This can be very hard especially for tangents generation...
    • It looks like there is currently no way to specify a time interval for each waypoint. I suppose I can manage time separately and call equal increments to Preview position, but that seems backwards
      • What do you mean with "interval between waypoints"? If you mean a time of pause in that waypoint, you have to manage a pregressive slow before reaching the waypoint, then create a reached event that pause the path, and setup a timer via scripting. When the timer exipres, you can play the apth again
    • A last question for now: is it possible to easily make the spline path visible?
      • The spline path in only visible in the editor view, because it is not a game element, but a developing element
    • I gather I should use your provided .Velocity attribute to set relative speed for each segment, but what values should I use to ensure the total time matches the individual point times?
      • Path magic don't think in terms of real time during play. To achieve your objectives, you have to set pre-sampled path, with a number of samples that ensure a good definition of the approximation. In Pre-sampled mode, PathMagic maintain a costant velocity (only if you set the velocity at waypoint level the same for all waypoints). In this configuration, the velocity is constant among the effective space between waypoints, so for increase the time between a waypoint and the next, you have to put the second one a bit more far from the previous. There is not automatic tool for that, you have to set it manually
    • When I press 'Start' in the main PathMagic script to begin the animation of the target object with ~100 waypoints, frame rate drops steeply, to an unusable level. Is that normal? Are there any settings responsible for that FPS drop?
      • This happens only in the editor, and in the scene view, because of time Unity spend to draw the inspector. If you select another object during the animation, or at paly time, the animation should go smoothly
    • Regarding PathMagic velocity settings -- is there a way to set ease-in/ease-out timing to zero globally for all waypoints?
      • If your intent is to have a global constant velocity, but an ease-in and stop at each waypoint, proceed in this mode: Set presampled path at some samples number (samples number define the quality of sampling), then at each waypoint set a very low speed (i.e. 0.02, not 0), put "Fast" for ease-in and ease-out parameters. Tweak the globa Velocity Bias to set the global speed velocity. The effective stop at each waypoint have to be implemented via reached event in a separate script.
    • Regarding PathMagic velocity settings -- is there a way to set ease-in/ease-out timing to zero globally for all waypoints?
      • Look at previous answer, there is not a global ease-in/out function
    • It's been 10 days since I first wrote -- I'd love to get some help, especially with my last question in bold, immediately above
      • Sorry, you made a lot of questions, in a very busy period for me
    Thanks for your interest in PathMagic.
    Regards,
    Marco
     
  47. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    Thanks Marco,

    You wrote:
    This is the opposite of what I want:
    To explain:

    I have a presampled path for a bird's flight, as shown above. Since PathMagic won't let me set the time between waypoints as you wrote, I'd like the path object to follow at a constant speed, smoothly passing through the waypoints in terms of both speed and orientation.

    PathMagic is stopping at each waypoint, easing out to a full halt, then easing in again. How can I prevent that?

    Thanks again...
     
  48. marcojacovone

    marcojacovone

    Joined:
    Jul 7, 2014
    Posts:
    63
    Hi,

    if your path is pre-sampled, and the target transform ease out to zero velocity at a waypoint, i think it means in that waypoint you set a very low speed. Try to set the velocity of each waypoint to 1, and tweak the global velocity bias to adjust the general speed.

    If it won't work, try to send me a small extract of your project (i.e. a simple scene with the instance of PathMagic and its waypoints).

    Regards,
    Marco
     
  49. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    Thanks, Marco,

    The velocity is set to 1 on each waypoint, and the tangents are generated similarly to your PathMagic 'CreateCircularTemplatePath' (see code below).

    Thanks for offering to look at a simplified version of my file, which I posted here:
    www.insightdigital.org/California_Parks/pathMagicTest.zip

    This scene contains a PM object, a target character, and a reference sphere at every waypoint for reference.

    If you click on the character, 'PathMagic_Sample', press play and follow it in the editor, you'll see the character slow, stop, and restart ~400 times over the 200 samples in the path.

    The PM object preview slider appears not to show this, but that playback is much faster than the 3,000 second duration of the baked animation. Therefore, maybe the problem is with relatively long timings when baking in PM?

    Here are my steps in PathMagic:
    • Click OFF ‘Start on play’, ‘Loop path’

    • Edit waypoints if needed

    • Assign ‘Target transform’

    • Click ‘Pre-sampled’ path and enter ‘samples’ value to match keypoints, to set in/out at uniform speed

    • Orient character by checking ‘Global follow path’ with ‘Follow bias’ at minimum

    • Click ‘Utility:Look to Forward’

    • Bake as legacy animation: make sure to enter the duration in seconds
    I created the PM object by modifying your editor 'CreatePathEditorWindow.cs' to importing telemetry data as I noted in my above posts. That code follows:

    Code (CSharp):
    1.         /// <summary>
    2.         /// Loads points from disk.
    3.         /// </summary>
    4.         /// <param name="pm">Pm.</param>
    5.         private void CreatePathFromFile(PathMagic pm)
    6.         {
    7.             _samples = valuesCollection.Count;
    8.             Waypoint[] wps = new Waypoint[_samples];
    9.  
    10.             Debug.Log("==> Importing total points: " + _samples);
    11.  
    12.             for (int i = 0; i < _samples; i++)
    13.             {
    14.                 wps[i] = new Waypoint();
    15.  
    16.                 // Set position for the new waypoint
    17.                 wps[i].position = new Vector3((float)valuesCollection[i].X, valuesCollection[i].Altitude, (float)valuesCollection[i].Z);
    18.  
    19.                 // Set velocity from waypoint time
    20.                 wps[i].Velocity = 1;
    21.  
    22.                 wps[i].symmetricTangents = _sameTangentRadius;
    23.  
    24.                 int prevIndex = ((i - 1) < 0) ? (i + _samples - 1) : (i - 1);
    25.                 Vector3 prevPos = new Vector3(_radiusX / (_samples - 1) * prevIndex, 0, 0);
    26.  
    27.                 wps[i].inTangent = (prevPos - wps[i].position).normalized * _inTangentRadius;
    28.                 wps[i].outTangent = -wps[i].inTangent; //(nextPos - wps [i].position).normalized * _outTangentRadius;
    29.             }
    30.  
    31.             // Keep path open
    32.             //pm.loop = _closed;
    33.             pm.waypoints = wps;
    34.         }
    My steps using the above to create the file I sent:
    • Export from ‘fileConvert’ object in ‘TerraLand Generator’ project

    • GameObject PathMagic:Create new path from template:Import
     
    Last edited: Dec 9, 2017
  50. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    In case it's useful, my class for holding the waypoint source data folows:

    Code (CSharp):
    1.     List<Values> valuesCollection = new List<Values>();
    2.  
    3.     class Values
    4.     {
    5.         public int Condor { get; set; }
    6.         public DateTime Date { get; set; }
    7.         public int Altitude { get; set; }
    8.         public double X { get; set; }
    9.         public double Z { get; set; }
    10.         public Values()
    11.         {
    12.         }
    13.  
    14.         public Values(int Condor, double Lattitude, int Altitude, double Longitude, DateTime date)
    15.         {
    16.             this.Condor = Condor;
    17.             this.X = Lattitude;
    18.             this.Z = Longitude;
    19.             this.Altitude = Altitude;
    20.             this.Date = date;
    21.         }
    22.     }
    23.  
    I populate this values from a telemetry source on disk via the loader below, then build waypoints using the PathMagic classes as shown in my code snippet in the above reponse:

    Code (CSharp):
    1.     private void readPointList()
    2.     {
    3.         // Load point file from disk
    4.         using (StreamReader sr = new StreamReader(outputPath))
    5.         {
    6.             // Convert from telemetry time to C#
    7.             // [2013-07-04@10:47:06] = "DateTime(2013, 7, 4, 10, 47, 6, 0)"
    8.             // DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123);
    9.  
    10.             // Read total points in input file
    11.             int inputPointCurrent = 0;
    12.             inputPointCount = Convert.ToInt32(sr.ReadLine());
    13.             Debug.Log("Total points in file:  " + inputPointCount + "; starting at point count:  " + inputPointCurrent);
    14.  
    15.             // Iterate through points in the input file
    16.             while (inputPointCurrent < inputPointCount)
    17.             {
    18.                 // Read condor ID, X, Y, Z, date+time
    19.                 valuesCollection.Add(new Values(Convert.ToInt16(sr.ReadLine()), Convert.ToDouble(sr.ReadLine()), Convert.ToInt16(sr.ReadLine()), Convert.ToDouble(sr.ReadLine()), Convert.ToDateTime(sr.ReadLine() + " " + sr.ReadLine()) ));
    20.                 inputPointCurrent++;
    21.             }
    22.  
    23.             Debug.Log("Stopped at end of file with point:  " + inputPointCurrent + ", for a total point count of:  " + inputPointCurrent);
    24.         }
    25.     }
     
unityunity