Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    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,280
    Hotfix update 2.01 submitted.

    It contains user requested changes and features, such as:

    - iMove/hoMove: animation component need not be attached to main object Requested by ddmars
    - PathManager: added button for replacing all waypoints of a path with a prefab (can be used for attaching gizmos and selecting waypoints in the editor view port) Requested by Lars Steenhoff
    - iMove: lock-axis option added Requested by mikevanman
    - iMove: current location marked as public, allowing multiple starting points Indirect request by cel

    ... and one bugfix. Version history in main post updated.

    Please write a review if you've bought SWS, it really helps me to stay motivated and find more gaps that need to be filled.

    Thanks.
     
  2. GamesRUs

    GamesRUs

    Joined:
    Apr 8, 2012
    Posts:
    17
    The names it is looking for are 'WaypointEnd' and 'WaypointStart', right? If the space is removed then the code will not break that functionality, right?

    Good points on the closed loop... What I was trying to do there is make a quick method of creating a looped path, but maybe what would be better would be a selection of a loop pattern (circle, rectangle, ellipse, etc.), optionally the number of points and the radius (or radii in the case of an ellipse). Then the path would just need to be created manually as the start point and one point to establish the direction, then it generates the points as desired. Hmm.. Maybe I'll do that just to pass the time...

    Thanks!
     
  3. matte.szklarz

    matte.szklarz

    Joined:
    May 29, 2012
    Posts:
    10
    If you have "moveToPath" selected, and loop selected, it'll make the object follow a closed-loop.
    I think these two functionalities should be separated, and is something I did in my own custom iMove code with only a little bit of effort.
     
  4. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,536
    Just downloaded the latest version, and I get one error:

    UnassignedReferenceException: The variable anim of 'hoMove' has not been assigned.

    You probably need to assign the anim variable of the hoMove script in the inspector.
    UnityEngine.Animation.Play (System.String animation)
    hoMove.PlayWalk () (at Assets/SWS/Scripts/Movement/hoMove.cs:545)
    hoMove.Move () (at Assets/SWS/Scripts/Movement/hoMove.cs:205)
    hoMove+<NextWaypoint>c__Iterator12.MoveNext () (at Assets/SWS/Scripts/Movement/hoMove.cs:514)
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    hoMove:StartMove() (at Assets/SWS/Scripts/Movement/hoMove.cs:176)
    hoMove:Start() (at Assets/SWS/Scripts/Movement/hoMove.cs:117)

    Any ideas how I can fix it?

    Thanks
     
  5. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Sorry, seems a reference to the new animation component slipped through. I'll look into it in 9 hours from now and submit an hotfix, hopefully ready tomorrow.

    Thanks for pointing that out!
     
  6. zaxvax

    zaxvax

    Joined:
    Jun 9, 2012
    Posts:
    220
    Initialization of variable has gone for good. :)

    Make sure Start() method in hoMove.cs looks like this:
    Code (csharp):
    1.  
    2.     internal void Start()
    3.     {
    4.         if (!anim)
    5.             anim = gameObject.GetComponentInChildren<Animation>();
    6.        
    7.         //get start rotation for locking an axis maybe later
    8.         startRot = transform.localEulerAngles;
    9.  
    10.         //start moving instantly
    11.         if (onStart)
    12.             StartMove();
    13.     }
    14.  
     
    Last edited: Jun 13, 2012
  7. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    853
    Smee again! :)

    Can paths be created and deleted at runtime? Just thinking about combining this with xyber's Tile Based Map Nav to allow for curved paths from start to finish node, like the units in Civ 4 moved once you had roads layed down.
     
  8. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Hi Zaxvax,

    you're right that solves it, I'm not at home and wasn't able to post code. Forgot to include this in hoMove. There will be an additional hotfix which adresses this issue.

    Thanks!
     
  9. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Hey ho c-Row!

    Did you take a look at the example scene Example_Runtime? You'll find the basic functionality for path instantiation based on prefabs. Creating a path out of waypoints would only be the next step. Please let me know if you need further help.

    Greetings
     
  10. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280

    Hotfix 2.01a submitted. For those who fixed it already, you can skip this update.
     
  11. Propagandist

    Propagandist

    Joined:
    Dec 8, 2010
    Posts:
    1
    Hello,

    Just purchased SWS and I'm very impressed.

    I have a feature suggestion if it's not too troubling.

    I would like to be able to run a script when an object reaches the end of the path it is following. I looked through the documentation and examples and didn't seem to find such functionality.

    Anyway, great job with SWS.
     
  12. zaxvax

    zaxvax

    Joined:
    Jun 9, 2012
    Posts:
    220
    I suggest you just place a GO with a trigger at the end of your path with a script attached to it.
     
  13. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Hello Propagandist,

    many thanks for your kind words!

    As Zaxvax suggested, at the moment you would go with a manually placed gameobject at the end of your path, holding a script which gets called when your walker reaches/collides with it. I plan to implement a more advanced functionality, that will allow you to call a specific method with (if desired) at least one parameter for an attached function.

    Regards,
    B.
     
  14. Numonic

    Numonic

    Joined:
    Mar 22, 2009
    Posts:
    241
    I just got this system like 2 hours ago was busy working on projects and went back to work on it. Gotta say it's amazing but can I somehow translate this information for Android? I did a test build and it doesn't show the waypoint path I created but on my machine it shows up clearly?

    Thanks
     
  15. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Hey Numonic

    thanks!

    Do you mean the visual presentation of the path, the straight or curved lines? They do not show up because these are gizmos, only visible in the editor. If you want to make them visible you would need to attach a line renderer to the waypoints or use other approaches for interpolating and drawing of curved lines. Did I understand you correctly?

    Regards,
    B.
     
  16. Numonic

    Numonic

    Joined:
    Mar 22, 2009
    Posts:
    241
    No I made a test build on my wifes android and the game test build shows up but the actual character that animates on that path does not function. I play it in the unity editor and it works fine but when I do a test build on the android phone it does not work at all. It just stays where I orginally placed my character at the origin.
     
  17. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Do you use iMove or hoMove? I own a galaxy nexus so I can investigate this issue, but it's 1 am here, I will get back to you within 12 hours if the problem still exists.
     
  18. Numonic

    Numonic

    Joined:
    Mar 22, 2009
    Posts:
    241
    I'm using the imove script I don't really know how to get it to run on the android? Nothing in the docs mentioning this at all. Pretty much the reason I got it quick waypoint and just hand it off to a programmer for completion of AI.
     
  19. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    There is no additional step required to make SWS work on mobile devices, I just ran it on my nexus (ics4) and it worked fine. Maybe other customers can also confirm that SWS runs on mobile platforms.
     
  20. Numonic

    Numonic

    Joined:
    Mar 22, 2009
    Posts:
    241
    Can you tell me the steps you took in getting it to run. I'm doing development builds checked on and when it runs on the android the character is still on the ground doing nothing.
     
  21. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    I used the scenes of my package, switched the platform to Android and clicked Build&Run, which saves an apk file and pushes it to my phone.

    Do you use the same setup? It's really odd that it only works in your editor.
     
  22. Numonic

    Numonic

    Joined:
    Mar 22, 2009
    Posts:
    241
    I got it to work I just deleted a older build and made a fresh new one meaning I made a fresh new .apk
    Don't know why it worked but it did, just for the record I'm doing all this with a the Optimus v the no contract one month to month.
    Which is nice. Thanks ! for confirming that it works on your end.

    Best

    Oscar
     
  23. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Glad it's running now! Thanks for the additional information,

    good luck with your game.
     
  24. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Last week of madness sale! Save 33% on this handy path+movement system.
     
  25. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Offer termination sent. Thanks to all who participated!
     
    Last edited: Jun 25, 2012
  26. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,536
    I'm having trouble with aligning the waypoint to a model because I have to use the ALT key to navigate and also to place the object.

    Can I change the snap to object key to CTRL or some other custom key?

    Thanks
     
  27. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,536
    Also on iPhone 3s I have a problem, the waypoints work but after one loop they get stuck and the object does not move anymore.
    This does not happen in the editor, any idea what this could be ?
    I use the ho move script.
     
  28. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Sure, to modify the waypoint placement key see here, question 3:
    http://forum.unity3d.com/threads/11...(SWS)-RELEASED?p=787900&viewfull=1#post787900

    As for the second problem, I don't really have an idea. Numeric got it to work by deleting replacing the old build (on Android), but maybe you could also try the iOS micro mscorlib found on the HOTween download page.
     
  29. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,536
    Thanks for the reply, I got the hotkey to work, but the iPhone still seems to get problems, I tried the micro HOTween, and it has the same problem.

    I use 7 waypoint paths with 7 different objects with animations, some of them keep running but the ones that have a delay at a waypoint seem to get into trouble on the iPhone, maybe there is some bug in the delay part?
     
  30. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Could you please pm me a sample package that reproduces this issue? I don't have an iPhone, but I could test the scene on my g nexus.
     
  31. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,536
    The project a quite large to send it, I also found it is not always with the delay, sometimes also happens on a path without delay.

    I'll see if I can make a smaller one to send.
     
  32. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,536
    I think de stopping has to do with something that happens at the end of a path, because it always happens at the last waypoint, I use linear and pingpong loop.
     
  33. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,536
    One suggestion, when I'm placing waypoint sometimes I make a mistake and would like to undo the last waypoint and continue the creation of the waypoints. perhaps back space could be assigned to that.
    At the moment it comes down to finishing the waypoint and then adjusting manually. this a extra work that could be avoided by having a undo last waypoint option.
     
  34. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    You could ignore the badly placed waypoint and continue the creation. Once you finished the path, simply select the corresponding path manager and delete the unnecessary waypoint. It can't go easier than that :)
     
  35. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,536
    Ok thats the way I do it now, but sometimes the placement of an waypoint on an object goes completely wrong because snap to surface sometimes is confused and placed a waypoint high in the sky, and then I have to place the next on done the ground, I mean it just looks weird, anyway I will do it the way you suggested, but from a usability point of view it would be better to have a undo last waypoint option. :)

    But more important for me is the stopping of the waypoint at the end of a path on iPhone, this really is a very serious problem for me because I can't release my game the way it is now, so I will try to assemble a small scene that has this problem and send it to you, many thanks!
     
  36. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Thanks for your feedback, I'll see if I can take Unity's undo-handling into account in this case.
    Waiting for your repro scene.

    Regards
     
  37. StolleJay

    StolleJay

    Joined:
    Jun 27, 2012
    Posts:
    2
    Hello,
    i have 2 Questions:

    1. How i can make my Waypoints "Bezier"?
    2. How i can make this that when my Path is in the Air my Object (ex: here a Ball) is Rolling on the Ground and not in the middle of the Path in the Air?
     
  38. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Hello StolleJay,

    1. traditional bezier curves are not supported. The hoMove component uses Catmull-Rom paths, as supported by HOTween. Take a look at the provided example scene "Example_Curved".
    2. Your object will always follow the path. At start, you can adjust the height of the object via the variable "SizeToAdd" in iMove and hoMove. If you want to switch the object's path in the middle of the game there is a SetPath() method described in the docs. Is there any specific reason why the path should be in the air, but the ball should be on the ground - i.e. why don't you place the path on the ground?

    Regards,
    B.
     
  39. StolleJay

    StolleJay

    Joined:
    Jun 27, 2012
    Posts:
    2
    I want to Place the Path in the Air because my Terrain where the Balls need to Roll is uneven.
     
  40. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Well, unfortunately SWS doesn't automatically handles gravity. There is no way other than placing the waypoints as close to the ground as possible and not intersecting the terrain. A falling ball, leaving the path, would be against a strict path movement system...
     
    Last edited: Jun 28, 2012
  41. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Dear buyers,

    we sold 50 copies last month and only received one review.
    Please, take the time to write a short review on the Asset Store.

    Thanks for your support!
     
  42. __MaX__

    __MaX__

    Joined:
    Jul 3, 2012
    Posts:
    5
    Hi Baroni,

    Just wanted to ask if your path system supports parenting (aka moving the path with a parent). I'm working on a side scroller and the main entities are children of the main camera. I ran into a few issues with iTween Paths which doesn't update the original path position even if it's a children of the moved object.

    Thanks in advance for your answer.
     
  43. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Hello MaX,

    my path implementation consists of multiple waypoints built of gameobjects, therefore you can move the whole path and its children. However an object that walks on the path won't update if you reposition the path, until its current tween is completed. Please let me know if you need that functionality and want to move the path and the object that walks on it in its entirety. I wrote a very basic iTween script to handle this functionality but it's not included in the package.

    Regards
     
  44. __MaX__

    __MaX__

    Joined:
    Jul 3, 2012
    Posts:
    5
    I think it could lead to some issues if it's not updated in real time.

    If you want a real example : think of any sidescroller game like Thunderforce or Gradius, a camera moving along the X axis (to the right for instance) and ennemies spawning at the right or the left of the screen. If i define a path on a children of the camera i need that the entities (which are going to follow the path), stay on the path (which is indeed moving with the camera).

    With some stuffs i found on unity answers and on the forums, i managed to move update the paths with the parents with iTween... but there is an issue when i spawn the entities, as soon as they start the path they seem to "think" that the initial point of the path is way further from the actual position of the waypoint. And the phenomen seems to amplify when the camera moves away from its original position.

    If your product can solve our problems, i think it's worth buying it. If not... i think we are going to animate every pathing for the game :/

    (sorry if my english is not that perfect, i'm french =) )
     
  45. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    I propose you the following: I'll pm you my custom iTween script which should do what you want to achieve in a very simple manner. It has nearly nothing to do with my product, but if you like it, feel free to buy it. :) I'll prepare a package tomorrow, it's night here (I'm in the same timezone ;) ).
     
  46. vicour

    vicour

    Joined:
    Feb 29, 2012
    Posts:
    13
    I am having an issue with SWS:

    I want to have an object follow a path. It is simple to setup the path, and have the object follow it. (in this case a car) However, at random times during the path follow, the car will start rotating on its Z axis, which is not desired. Increasing the speed of the object makes the results change, but the object still wants to randomly rotate on its Z axis while following the path.

    How do I make the car object follow the path, but never rotate on it's Z axis?
     
  47. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Hi vicour,

    have you tried the integrated lock-axis option?

    Example image
     
  48. vicour

    vicour

    Joined:
    Feb 29, 2012
    Posts:
    13
    Yes, it does not fix this issue. Here is an image that illustrates the odd rotation behavior:

     
  49. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,280
    Could you pm me a small package demonstrating the problem, please? I can't get that much out of the image...
    Will investigate once I'm back (~6 hours). Thanks.
     
  50. vicour

    vicour

    Joined:
    Feb 29, 2012
    Posts:
    13
    I can't send you any data, but I have managed to isolate which script is doing it. HoMove produces the weird rotation behaviour, but iMove does not. If I use iMove the object follows the path perfectly and never tries to rotate itself. If I use hoMove on the same path, the object randomly rotates on Z mostly, but sometimes X and Y as well.