Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Simple Waypoint System (SWS) - Move objects along paths

Discussion in 'Assets and Asset Store' started by Baroni, Dec 10, 2011.

  1. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Interested or looking for support? Ask me anything in this thread - from developer to developer :)

    Simple Waypoint System (SWS) is an editor extension that allows you to create waypoints and paths very easily right within the editor. With those created, you can then tell any kind of game object to follow a specific path. Useful for every automated movement in your games including but not limited to:
    • AI Patrol behavior
    • Movement on a Path
    • Moving Platforms
    • Camera and Game Object animation
    • Cut Scenes
    Simple Waypoint System provides a custom path creator interface for linear or curved splines, bezier curves and NavMesh paths. Our path creator lets you place waypoints just by clicking on ground, they get connected internally. After the part of path construction, you are still able to edit your existing path with the built-in buttons, which add or remove waypoints, place them onto other objects or invert the path direction. Movement scripts, utilizing the free tween library DOTween or Unity’s NavMesh agents, conclude what you need for a simple waypoint system.

    Features:

    ✅ Custom path manager editor
    ✅ Linear, curved, bezier and NavMesh paths
    ✅ Movement scripts with many flexible options
    ✅ Call own methods at waypoints via events
    ✅ Works in 2D or 3D space
    ✅ Advanced example scenes
    ✅ Full source code in C#
    ✅ Quick Start documentation




    Documentation:
    Get it here:
    Try it out:
     
    Last edited: Aug 3, 2023
    vihaansengupta2710 and John3D like this.
  2. Thomas-Pasieka

    Thomas-Pasieka

    Joined:
    Sep 19, 2005
    Posts:
    2,174
    That's looking pretty nice I have to say! What can people expect price wise? Nice demo scene setup as well.
     
  3. Daniel-Talis

    Daniel-Talis

    Joined:
    Dec 10, 2011
    Posts:
    425
    Hi, does it work on Terrains?
     
  4. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    @Thomas
    Hello and thanks Thomas!

    I just submitted it 2 minutes ago with the price of 10$!
    Let's see how it goes, maybe there are some later adjustments (not up).

    I also already have an idea for upcoming versions... so I will try to keep this updated.

    Greetings
     
  5. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi Daniel,

    it's a very simple system (as stated a few times in the main post above ;) ),
    so it depends on how you setup your waypoint gameobjects. If you place them with high distance,
    I am sure your path will go through hills and some uneven terrain...
    Besides of that, it will work on terrain too, because you can place your waypoints onto every object.

    edit: oh I forgot something, have a look at the video and the 2 screenshots, there are 2 paths with a curve, so if you place your waypoints very close to each other this could work very well for hills...
     
    Last edited: Dec 10, 2011
  6. Roachie

    Roachie

    Joined:
    Aug 2, 2009
    Posts:
    67
    Looks great. Is there a way to make the object stop at a specific waypoint for a period of time before carrying on ?

    Thanks
     
  7. jermaine

    jermaine

    Joined:
    Feb 10, 2009
    Posts:
    28
    looks very nice. I plan to buy it.
     
  8. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    @Roachie

    that's definitely possible! The iMove component which moves the object has a delay variable to let the object stop at every waypoint and continue after a specified time.

    Edit: delay at a specific or all waypoints is now a built-in setting.

    @jermaine

    thanks for your interest, much appreciated!
     
    Last edited: Dec 17, 2011
  9. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    I'm happy to announce that SWS is now live and available to download!

    The last update (1.1) adds new features such as:
    - random selection of waypoints - looptype random
    - delay interface to allow delay at a specific or all waypoints
    - animation support (see bootcamp soldier in the trailer)
    and minor fixes!

    Try it, it's only 10$ :D

    http://u3d.as/content/baronium3d/simple-waypoint-system-sws-/2xi

    I would like to say thank you to the people who have bought it,
    before I ever mentioned that it's online, thanks :)
     
  10. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Any comments, thoughts or requests so far?
     
  11. kodagames

    kodagames

    Joined:
    Jul 8, 2009
    Posts:
    548
    Its an excellent product!!! Simple Waypoint System the keyword here is "Simple" and it is.

    I really like this system and believe it could be the start of something bigger well Im hoping anyway.

    I love that you can easily add delay of movement at any waypoint and play one animation while at that way point by simply dragging a iMove script onto the character. I can have the character randomly switch between way points by simply by selecting a different loop type from the drop down list.

    Its really cool and for the price you cant beat it! I give this one 2 Thumbs Up!
     
    ice2011 likes this.
  12. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    I make a short faq out of recent e-mail conversations, so other users can read this, too.

    Question:
    I tried integrating SWS and keep getting a NullReferanceException:
    NullReferenceException: Object reference not set to an instance of an object
    iTween.LateUpdate () (at Assets/Plugins/iTween.cs:6453)
    Answer:
    This could occur if you already use iTween and therefore 2 iTween scripts are located within your project.
    Delete one iTween script, and (if not already done) place the other one into the Plugins folder.

    Question:
    I can't assign a scene path transform to the path container slot of an enemy prefab.
    How do I instantiate my enemies at runtime and have them know how to get my path?
    Answer:
    This is a limited behaviour of Unity, scene objects can't be assigned to prefabs.
    The simplest solution would be to make a prefab per path transform (not Waypoint Manager) and assign that path prefab as path container to your enemy. Another way would be a short custom script, which returns the path transform, adds it to the Waypoint Manager dictionary, assigns it to the enemy path container and then calls iMove's provided movement method StartMove(). Update: Version 1.2 includes an example script for runtime instantiation.

    Question:
    I need to replace the waypoint placement key of WaypointManager. Alt + left mouse click seems too inconvenient.
    Answer:
    To replace the waypoint placement key, you will have to edit line 27 in WaypointEditor.cs as follows:
    For example to use it without mouse input and only with key "P" pressed, replace the if query with:
    "if (Event.current.type == EventType.keyDown Event.current.keyCode == KeyCode.P placing)".



    @zeek
    thanks! Much appreciated ;)

    Your question via e-mail was:
    "How would I make a waypoint a child of a character to instantiate at runtime? This way I can instantiate the character and the path he uses at the same time in the same place."

    If a waypoint should be the child of a character, this would not be the best solution, because this waypoint would always follow the character as it walks. Your path (and its waypoints) should never move with its walkers. The runtime instantiation part could be accomplished with a method described in the "How do I instantiate my enemies at runtime..."-answer above:
    1. Instantiate the enemy.
    2. Instantiate the path prefab (if needed), and set its position via script to where it should be. The first waypoint position is then equal to the path transform position.
    3. Add this path via script to the static Waypoint Manager dictionary, like the Awake() function does in the "foreach"-part.
    4. Assign that path transform via script to the iMove path container of your enemy.
    5. Call iMove's standard StartMove() method, to start movement of this enemy with the new path.
    Update: Version 1.2 includes an example script for runtime instantiation.

    Hope this helps! I will include some changes to this workflow in the next update, to remove custom scripts and smooth it out.
    I sent you early modifications to Waypoint Manager via pm.
     
    Last edited: Feb 28, 2012
  13. cheezorg

    cheezorg

    Joined:
    Jun 5, 2008
    Posts:
    394
    Bought it and love it! So easy to use and perfect for moving platforms and enemies around in my game. Love it. Love it. Love it.

    My one request would be a Reset function to call from script to be able to reset an iMove GameObject to a stationary position.

    Example: A moving platform is triggered to StartMove() by the player. The player falls off the platform to his death and is respawned at his last checkpoint (without reloading the level). I call Reset() on the iMove platform to reset it for the player to trigger again.
     
  14. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hey cheezorg,

    I'm glad that you like it!

    Regarding your request, I tested some code and came up with this short method,
    just put that into your iMove.cs script and you will be able to call it, no need to touch existing code.

    Code (csharp):
    1. public void Reset()
    2. {
    3.     StopCoroutine("NextWaypoint"); //stops further execution, if we set a waypoint delay
    4.     iTween.Stop(gameObject); //stops movement of this gameobject
    5.     currentPoint = 0; //set current waypoint index to zero, so next time we start from the beginning
    6.     transform.position = waypoints[currentPoint]; //position our gameobject at our first waypoint
    7. }
    I will also include a more flexible solution in the next update, wrote some new features today as well.
    But for the time being I hope this solves your issue. Feel free to ask more questions while dealing with SWS!

    Greetings
     
  15. cheezorg

    cheezorg

    Joined:
    Jun 5, 2008
    Posts:
    394
    Beautiful! Thanks.
     
  16. jocoUnity

    jocoUnity

    Joined:
    Oct 2, 2011
    Posts:
    25
    Great package!

    How would I (in code) stop an object following a path and start following different path? C# plz
     
    IgorAherne likes this.
  17. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hey jocoUnity, thanks :)

    that feature would require you to edit some code, so I suggest you to wait until the next update.
    I already finished runtime path instantiation support, which includes changing a path through code (this then requires 2-3 lines).

    The new version with another great feature (can't say more) will be released in early february, I hope you can wait until then!

    Greetings
     
  18. isaacch

    isaacch

    Joined:
    Oct 19, 2011
    Posts:
    20
    Looks nice, however I have a few questions.

    Does this allow paths to cross each other ?

    If so, is there a function to let AIs stop in their path and wait for another AI to pass by before continuing with the path? To avoid collision.

    Also, is there a function to let AIs walk through each other if they are on the same path ?

    Hope you can clarify my doubts.

    Thanks ! :)
     
    HaoSunWashU likes this.
  19. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi flamerx2,

    You can place your paths / waypoints wherever you want, so they could cross or intersect each other.
    However, two paths cannot share the same waypoints - they are independent.

    Not yet. But since every walker / AI object moves from waypoint to waypoint, this could be fairly easy to implement. Before calling the automatic movement function (which brings the walker to the next waypoint), all you need to do is integrate your own function that checks if other walkers are in closer range and therefore delay the movement. The functionality of iTween also allows to check that every frame, while between waypoints, with it's "onupdate" parameter.

    Your objects automatically walk through each other, if they don't have a rigidbody and thus physics disabled.

    You're welcome :)
     
  20. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Good news :)

    I decided to not hold back the next update and it's live on the Asset Store out now!

    The big new feature is runtime instantiation,
    this comes along with changing paths at runtime and better control of your walker objects.
    Theres also a new example script for this purpose.

    Full Changelog:

    Fixes&Changes
    -replaced some calculations with iTween's internal methods
    -iMove now has direct access to Path Manager waypoints
    (your walker objects will update at runtime when you reposition waypoints)
    -reset delay at specific waypoints if path container gets null fix

    Features:
    -WaypointManager: AddPath() added to support more flexibility and path instantiation
    -iMove: added SetPath(), Stop() and Reset() methods, see documentation
    -Example_Runtime: new script to demonstrate combinations of those new methods
     
  21. alejandro

    alejandro

    Joined:
    Jul 7, 2009
    Posts:
    7
    How can I smooth the rotation of the camera when goes for the next point?
     
  22. alejandro

    alejandro

    Joined:
    Jul 7, 2009
    Posts:
    7
    maybe this iTweenHash.Add("looktime", 4 ); will smooth the rotation of the camera.
     
  23. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hey alejandro,

    I think you're on the right track. You could try to implement that parameter into iMove's "Move()" method with a public variable, something like
    Code (csharp):
    1. public class iMove : MonoBehaviour
    2. {
    3.    public float lookTime;
    4.    ...
    5.  
    6.     void Move(int point)
    7.     {
    8.      //iTween parameters
    9.      iTweenHash.Add("looktime", lookTime);
    10.      ...
    11.     }
    12. }
    13.  
    As you suggested, with a large value this would generate high smoothness. I also tried the "lookahead" parameter but didn't achieved useful results. Please report how the solution above works out for you.
     
    Last edited: Jan 30, 2012
  24. isaacch

    isaacch

    Joined:
    Oct 19, 2011
    Posts:
    20
    Really nice and simple to use ! :D

    Is it possible to change the speed of the walkers during runtime ?

    I've tried adjusting the speed variable during runtime, but what it seems to change the speed of the walker only after they reached the next waypoint in line, is there any way to change the speed of the walker while they are walking to the next waypoint ?
     
  25. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    @flamerx2

    Thanks :)

    Unfortunately this is a limitation of iTween - It only recognizes changed variables in the moment of assigning a new iTween component, and that would be every new waypoint. To work around that you would need to set your new speed, destroy the current iTween component, then instantly attach a new one (so it takes the new speed variable as argument and continues walking).

    You could use the existing methods Stop() and StartMove() to achieve that, however it is possible that you also have to wait a frame between those calls as stated in iTween's documentation: http://itween.pixelplacement.com/documentation.php#Stop

    Short example:
    Code (csharp):
    1. IEnumerator Slow()
    2. {
    3.    iMoveScript.speed /= 2; //set halve walker object speed
    4.    iMoveScript.Stop(); //stop object and destroy iTween component
    5.    yield return new WaitForEndofFrame(); //wait one frame
    6.    iMoveScript.StartMove(); //assign new iTween component and continue walking with halve speed
    7. }
    8.  
     
  26. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
  27. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
  28. Jaloper

    Jaloper

    Joined:
    Feb 8, 2012
    Posts:
    4
    I've been looking around at iTween and other editors and I can't seem to find an easy way to make paths that are relative to the object that will move on it. Does sws do this?
     
  29. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi Jaloper,

    I think I don't quite understand your question. Paths are created and placed in world space, they and their waypoints are gameobjects which can be moved at runtime - Your walker objects, that will move on them, will update their (next) waypoint positions each new waypoint. Do you want to parent the paths to the walker objects and move them both, or could you explain in more detail what you are trying to achieve?
     
  30. UnleadedGames

    UnleadedGames

    Joined:
    Feb 17, 2008
    Posts:
    242
    Baroni, Will your script allow multiple animations? From what I can tell with the solider I see an idle and walk animation, but is it possible to have a different animation play at each way-point when it is on a delay? I'm trying to find an easier way to do simple cut scenes, and this seems perfect!
     
  31. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    @msken

    Thanks for your interest! Yes, a different animation per waypoint is possible, but not implemented for the ease of use.
    Actually I use an array for defining the delay value per waypoint - an extra array for setting the animation per waypoint would only be an addition to this, the code is already there.
    I would be happy to provide you hints and example codes once you told me your decision :)
     
  32. UnleadedGames

    UnleadedGames

    Joined:
    Feb 17, 2008
    Posts:
    242
    At $10 how can I refuse? LOL thanks Baroni, purchase coming soon!
     
  33. Jaloper

    Jaloper

    Joined:
    Feb 8, 2012
    Posts:
    4
    Yeah parenting the path to my object and moving them both is what I want to do. Is this possible in iTween? Or is that a feature of sws?
     
  34. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Alright, I tested some functionality of iTween and mixed it with SWS.
    So far, here is my result. (The path moves to the right over 10 seconds)
    Is this demonstration near your issue?
    Seems like that's possible with iTween - but it's not integrated nor battle tested with SWS yet and therefore misses some of its basic functionality. I'll see whether I can implement this over the next weekend.
    Please let me know if you are interested.
     
    Last edited: Feb 8, 2012
  35. Jaloper

    Jaloper

    Joined:
    Feb 8, 2012
    Posts:
    4
    Yeah that looks like what I want to do. Just moving the path as a whole. I'm going to guess that you changed each of the vectors individually? I could probably just do it that way but wanted to see if there was an easier way before I dive into that.

    Would you be able to post your code for that? Just curious how you accessed each node.

    (Unless of course I'm completely wrong in how you did that :eek:)
     
  36. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Each waypoint is a gameobject, parented to a path gameobject. I moved the whole path object with one iTween.MoveTo call.

    I can't post the code here, because it is based on SWS and even if it's cheap, it's for sale ;)
    But, all waypoints of a path are stored and accessed via a Transform array.
     
  37. Jaloper

    Jaloper

    Joined:
    Feb 8, 2012
    Posts:
    4
    Oh okay. So each waypoint is a gameObject that can be parented.

    Sounds like SWS is something I will invest in. Thanks!
     
  38. alperozer

    alperozer

    Joined:
    Aug 18, 2011
    Posts:
    11
    Hi Baroni,

    I want to ask a simple question. Based on my itween experience, speed is not constant along the path even you set the easetype to linear. If you need constant speed you have to place the path points to the even distances.

    Does SWS solve this problem ? In every single point on the path containing many points speed is the same ?

    Thanks a lot.
     
  39. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi alperozer,

    yes, it does! SWS is based on waypoints and straight paths, it provides you with a speed or time value to move your objects constantly between those waypoints. iTween's lack of linear easetypes on a path was the basic idea for creating SWS... right now only straight paths are implemented, but I would like to implement curved paths within a future update...

    Greetings
     
  40. isaacch

    isaacch

    Joined:
    Oct 19, 2011
    Posts:
    20

    Thanks for the reply :)

    I've tried using the Stop() and StartMove(), however, what happens is that the walker objects stop on their current position and starts moving from their beginning with the new speed variable that I set, is there any way to make them move from where they left off ?
     
  41. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Normally they should go on from where they left off...
    Did you set moveToPath to true before calling StartMove()? Otherwise your object would spawn at the last waypoint and start from there, if that's what you are seeing.
     
  42. isaacch

    isaacch

    Joined:
    Oct 19, 2011
    Posts:
    20
    Ok, I've set moveToPath to true and it works as expected now.

    Thanks for the help ! :)
     
  43. alperozer

    alperozer

    Joined:
    Aug 18, 2011
    Posts:
    11
    Thank you very much Baroni, curved paths feature would be so great. There is really need for a robust solution for this issue.

    Are there any movement smoothing parameter when following a straight path ? Because I plan to move the camera object on a straight path.
     
  44. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Last edited: Feb 12, 2012
  45. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Please add the option by orient to path to reverse orientation, my fish is swimming backwards.
    Thanks
     
  46. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Also please add the option of bezier curves so we can have smooth rotation around the points.
     
  47. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    @Lars
    Reverse orientation could be possible if you implement Unity's LookAt() in iMove.cs (maybe as Update() or Coroutine) and use the latest waypoint position (of the waypoint array) as target. E.g. waypoints[currentPoint-1]. So your object will always orient backwards while moving forwards, after that you would only have to ensure that this method does not exceed or falls below the waypoint array length, because this will result in a null reference exception.

    Bezier curves is a feature that is already on my list. I will have to invest more time for this one.
     
  48. Jethro

    Jethro

    Joined:
    Aug 23, 2011
    Posts:
    30
    Can I just use your editor, and access the waypoints from my code? ie. for cars to follow a track.
    In other words I don't want to use iMove I guess.
    I am already doing this with a stack of transforms as waypoints.
    But your system just looks tidier and smooths things out with beziers.

    Thanks.
     
  49. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    @Jethro
    Yes, each path gameObject has a "PathManager" component attached that stores the waypoint transform array you defined in the editor. You can access this component for using it your own movement solution.
    At runtime, all "PathManager" components are added to a dictionary of the "WaypointManager" component for allowing an even more simplified access like:
    Code (csharp):
    1. Debug.Log(WaypointManager.Paths["Path1"].waypoints.Length); //debug waypoint count of "Path1"
    Just to clarify, bezier curves aren't available yet.
     
  50. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    could you please add a rotation offset variable in the editor by orient to path setting.
    Thanks