Search Unity

Simple Waypoint System (SWS) - Move objects along paths

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

  1. paugoert

    paugoert

    Joined:
    Feb 17, 2019
    Posts:
    3
    Hi Baroni,

    Thank you for the input, i found another approach to work after watching those example. I add event handler to each waypoint. I pause the cube if it matched user input. Otherwise, i let the cube go. I think this method should be simpler.

    And one more question, how can i disable the event handle of waypoint programmatically. I want to disable event handle and the cube go without invoking any event handler code if condition match. I found that i can do it in unity UI in design time. But there is no public method.

    Alex
     
  2. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    @paugoert Please see the events example scene, which also has a sample on how to add waypoint events at runtime via code. You'll be able to remove waypoint events in a similar way.
     
  3. marcus_unity998

    marcus_unity998

    Joined:
    Jan 7, 2019
    Posts:
    10
    @Baroni How does Simple Waypoint compare to https://assetstore.unity.com/packages/tools/animation/pegasus-65397 ? Can I do a roller coaster experience, where the user can't control where he goes but he can move his head around to see the scenario?

    Another question, is it possible to trigger events? Suppose I want a rocket to explode when I pass by a waypoint, can I configure actions to trigger at chosen points in a path?
     
    Last edited: Feb 20, 2019
  4. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    @marcus_unity998 From the looks of it, Pegasus focuses more on the cinematic animation part for cameras and cutscenes. SWS is an all-round solution for moving objects, 2D or 3D. You would use what suits you best.

    We're having customers implementing rollercoaster experiences in 3D and VR. Actually you wouldn't move the "user" object, but only the cart. Then have the camera as a child of it, so you can control it however you want, independent from the movement script.

    Sure, that's what our waypoint events are for. See the webplayer, events sample scene for a demo. You can either trigger methods in your own script at waypoints, or simply add a trigger/collider to the path that triggers something when the moving object passes it.
     
    Last edited: Feb 20, 2019
  5. stvster

    stvster

    Joined:
    Mar 4, 2013
    Posts:
    70
    Hi all,SWS is awesome! How can I make object(animals) face the next waypoint?Mine follows path sideways.
    Thanx!



















    t
     
  6. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
  7. stvster

    stvster

    Joined:
    Mar 4, 2013
    Posts:
    70
    Hi RG,THANX!!
     
  8. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    how can i have Unity Waypoint Events on an movement script for more than 1 path when using SetPath() to change paths at runtime.

    For example when player reaches last waypoint in path i call unity event SetPath to a new path, and when i reach the end of that path i want to call unity event SetPath to yet another new path

    Is this a limitation of the plugin?

    i do see some code in the runtime add event example but different paths have different waypoint counts, perhaps there's a direct way to know when end of a path is reached.

    I see in another example you use tween.duration to mark the end of the tween, but does that value change when playing with speed at runtime?
    or since speed affects Timescale then the actual duration is still the same?


    My use case is simple really:
    actor moves along a path,
    player input controls speed of movement.
    At the end of the path i need a callback of some kind to know it happened.
    Set a new path and repeat.

    i'm only stuck on the callback part really.
     
    Last edited: Feb 26, 2019
  9. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    Hi, waypoint events is one way that could be used for this. Two things on that:
    - the events sample scene demonstrates how to add events via code at runtime. To dynamically get the last waypoint, you would get the current waypoint count on the movement script via pathContainer.waypoints.Length - 1.
    - note that events persist when switching paths, as long as the new waypoint count is equal or greater than the current one. So you may want to remove all events from the movement script when switching paths, just in case (see sample).

    If your use case allows it, a triggered event (trigger collider) would be easier. The events example scene has a sample for this as well. You would just place the trigger on the last waypoint of your path physically (with a game object and trigger), instead of switching around events on the movement script.
     
    luniac likes this.
  10. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    Got it, thanks.
     
  11. purnamasari

    purnamasari

    Joined:
    Mar 8, 2018
    Posts:
    17
    Hello, I'm facing weird movement when I use splineMove with Catmull Rom path type. The object y rotation changed weirdly like it's 90 then it change a little to 89.0 causing the object looks jittering. I copied everything on runtime demo, spawning and attaching them.

    Here is the code and the spline setting:

    upload_2019-3-11_11-29-54.png

    The code:

    Code (CSharp):
    1. GameObject newPath = new GameObject(Units[i].name+" Path");
    2.                 newPath.transform.parent = waypointManager.transform;
    3.  
    4.                 PathManager path = newPath.AddComponent<PathManager>();
    5.                
    6.  
    7.                 Transform[] waypoints = new Transform[temproute.Length];
    8.  
    9.                 //instantiate waypoints
    10.                 for (int k = 0; k < temproute.Length; k++)
    11.                 {
    12.                     GameObject newPoint = new GameObject("Waypoint " + k);
    13.                     temproute[k].y = spawnPoint.y;
    14.  
    15.                     waypoints[k] = newPoint.transform;
    16.                     waypoints[k].position = temproute[k];
    17.                 }
    18.  
    19.                 //assign waypoints to path
    20.  
    21.                 path.Create(waypoints, true);
    22.  
    23.                 Units[i].path = newPath;
    24.  
    25.  
    26.                 //optional for visibility in the build
    27.                 newPath.AddComponent<PathRenderer>();
    28.                 newPath.GetComponent<LineRenderer>().material = new Material(Shader.Find("Sprites/Default"));
    29.  
    30.                 Units[i].GetComponent<splineMove>().SetPath(WaypointManager.Paths[path.name]);
    The problem doesn't occurred if I choose linear path type, but it's not what I really want since I need a smooth rotation between the point. Is there anything I can do to fix this problem while achieve what I want?
     
  12. paugoert

    paugoert

    Joined:
    Feb 17, 2019
    Posts:
    3
    Hi Barconi
    I have defined a path with many way point. I found that there is a very curve from waypoint a to waypoint b. how can i make it straight.
     

    Attached Files:

    • Clip.jpg
      Clip.jpg
      File size:
      96.2 KB
      Views:
      642
  13. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    Hi @paugoert, segments are trying to create curves between waypoints. Your waypoints are too close to each other, it looks like you zoomed into the scene quite a bit. Delete some of them or move them further away from each other, this will smooth it out.

    Hi @purnamasari, thanks for the screenshot. Objects will try to orient to the path when movement starts, as you selected "Full 3D" as the Path Mode settings. You set the LookAhead value to 1, which means 100% - this is a value from 0 to 1, resulting in your object always orientating to the end of the path. Please reset this to 0 or something very small, e.g. 0.02 = 2%.

    @paugoert, @purnamasari: We've upgraded our support forum this weekend. Please register over there, as we will transition support for existing customers to our own forum. In the future, our forum will contain more code samples and guides for members (customers) only.
     
    purnamasari likes this.
  14. purnamasari

    purnamasari

    Joined:
    Mar 8, 2018
    Posts:
    17
    This is insane, everything is just work properly only with that! Yeah, I thought 1 was true and 0 was false ahaha silly me. Thank you so much! I'll register for the support forum asap.
     
  15. GorkaChampion

    GorkaChampion

    Joined:
    Feb 6, 2018
    Posts:
    103
    Hi, After installing SWS I have 720 errors referring namespaces, this is one of them, the rest are very similar within 4 o 5 other assets from the asset Store:
    Any ideas?

    Assets\AwesomeTechnologies\VegetationStudioPro\Runtime\Common\RunTimeLoader\VegetationItemSelector.cs(472,3): error CS0246: The type or namespace name 'BurstCompileAttribute' could not be found (are you missing a using directive or an assembly reference?)

    PS: I had to uninstall your asset because otherwise I can't work.
     
  16. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    Hello @GorkaChampion, the error you are referring to is not related to SWS. Our asset does not use the 'BurstCompileAttribute' type either. What is VegatationStudioPro?

    SWS' classes are all included in their own namespace called 'SWS'. If you get script conflicts, then you've probably imported an asset twice, or are using an asset that does not implement its own namespace thus conflicting with general script names.

    Note that DOTween is already included in SWS. If you are using that already, you can uncheck it on the import prompt.
     
  17. wpereiravika

    wpereiravika

    Joined:
    Apr 22, 2019
    Posts:
    2
    Hi Baroni,

    Your plugin looks amazing and powerful, however I have a few questions before purchasing it. The system would be something like this, I have three different rooms (room1, room 2 and room3) and all I want is to have a camera following paths connecting the three rooms and be able to move from one to another in different orders when I press a button (trigger).

    I'd like to use your tool for a walkthrough and be able to stop a look inside different spaces. Hope it makes sense, I'm looking forward for your answer.


    Cheers
     
  18. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    Hey @wpereiravika, thanks for your interest! Did you try out our web player (linked in the first post of this thread)? If you start it and take a look at scene 8, named "Camera Input", press the "up" arrow every few meters to let the camera continue moving along the path.

    That's basically the feature you are looking for. Of course, this also works with different paths and switching between them. The sample scenes have examples for all cases!
     
  19. wpereiravika

    wpereiravika

    Joined:
    Apr 22, 2019
    Posts:
    2
    Hey Baroni,

    Thanks for your quick response, didn't noticed the link for the web player and after trying out that's exactly what I need. Will buy it and start playing with it!


    Cheers!
     
  20. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Hi @Baroni

    Does toObject in the new version means that the game object now can move via path as if the first waypoint is on the object itself?
     
  21. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    Exactly that! It will also repeat that path from the new end position continuously.
     
    Oshigawa likes this.
  22. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Can't wait to try it out :D
     
  23. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    hi @Baroni

    i've got some errors when importing

    Code (CSharp):
    1. The call is ambiguous between the following methods or properties: 'DG.Tweening.DOTweenModuleUI.DOColor(UnityEngine.UI.Image, UnityEngine.Color, float)' and 'DG.Tweening.ShortcutExtensions46.DOColor(UnityEngine.UI.Image, UnityEngine.Color, float)'
    2. error CS0121: Assets\SWS\Extensions\DOTween\Modules\DOTweenModuleUI.cs(109,33)
    Code (CSharp):
    1. The call is ambiguous between the following methods or properties: 'DG.Tweening.DOTweenModuleSprite.DOColor(UnityEngine.SpriteRenderer, UnityEngine.Color, float)' and 'DG.Tweening.ShortcutExtensions43.DOColor(UnityEngine.SpriteRenderer, UnityEngine.Color, float)'
    2. error CS0121: Assets\SWS\Extensions\DOTween\Modules\DOTweenModuleSprite.cs(57,33)
    3.  
    Unity is 2018.3.7

    Any ideas?
     
  24. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    Hey @Oshigawa, SWS comes with DOTween Free as it wouldn't work without it. Do you already have a copy of DOTween in your project by any chance? If so, you would delete our (or your) DOTween folder.
     
  25. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Hi @Baroni

    sorry for wasting your time, i just figured out dotween is updated, so i indeed deleted the dotween folder and reimported the asset, all's fine now :)
     
  26. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
  27. Npicouet

    Npicouet

    Joined:
    May 17, 2018
    Posts:
    30
    Hello!
    I've only just started browsing you documents, but do you have additional functions on top of normal Dotween?

    In particular I'm looking for "GetClosestPointOnPath" or "GetClosestPercentOnPath" so I can project a point onto the path.

    Thanks! Just easier if I ask.
     
  28. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    Hi @Npicouet, we offer many methods for convenience around path functionality, such as SetPath, ChangeSpeed, and more.

    There is no "GetClosestPointOnPath" method currently, since the "ClosestPoint" very much depends on what you are looking for exactly - the waypoint, estimated closest Vector3 position, or bezier point? One challenge is that a path does not really exist in the scene - the moving object creates it. So when checking the closest point on a different path, there needs to be some kind of "ghost moving object" that creates the path first, for being able to check it.

    This question comes up from time to time and if you could post it on our support forum (as a customer), I would be happy to share some code there.
     
  29. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510
    How can I make sure that a closed loop path is “smooth” at the point where the beginning connects to the end?

    My gameobjects always turn a little at that point no matter how I adjust it


    By the way, I’m using follow path.
     
  30. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    @FiveFingerStudio if you mean the part where the object moves to the starting point for the first time (when having "Move To Path" enabled), that's caused by the "movement to path" and "movement on path" actually being two separate tweens. Because of that, they are not smoothed out together and so a little hiccup in rotation may occur. The reason for this is that otherwise, the closed loop would take the object origin into account too resulting in a different path.

    When the object reached the path and the closed loop is constructed, there should be no hiccups at the end. Could you confirm? Also could you elaborate what you mean by "I'm using follow path"?
     
  31. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510
    I meant that if I had waypoints 1 through 10 and had "closed loop" checked, when the object went from 10 to 1, there would be a hiccup. I noticed that if I place 10 at the exact location as 1, the hiccup is removed.

    I wrote the wrong terminology, I meant "Look Ahead", not follow path. I thought that was related to the hiccup. In any case, its fixed :).
     
  32. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510
    I've got another question.

    I want to use ease type " In Out Quint" along a path. I also want the gameobject to stop and start at the waypoints using that ease type....so I don't want to use "pause".

    Is there a way to achieve that?
     
  33. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    With waypoint events and a custom method. Since movement along a path is not defined in individual segments between waypoints, but one single tween, you can already use one ease type for the full path - see the car in our "Advanced" example scene for a sample, which acc- & decelerates. You could also use your own ease type, defined in an animation curve, for the full path - select "Unset" as the ease type and an animation curve field will show up.

    For ease types between segments, you would write a short custom method, called at the desired waypoints, which uses easing on a variable and passing that new value into the movement object's ChangeSpeed method on each update.

    For further questions or code samples, please register on our dedicated support forum (link in the first post, at the top).
     
  34. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510
    Thanks for a detailed response...that will help me out a lot!
     
  35. Battin

    Battin

    Joined:
    Apr 8, 2015
    Posts:
    11
    Hi Baroni,

    I'm wondering, would it be possible to use/implement your Waypoint system to make Lara Croft Go type of movement?
    Quickly from Node to Node with animation, moving along all axis and such?
     
  36. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    Hey @Battin, thank you for your interest. For a Lara Croft GO style movement, a waypoint system based on path tweens would not be the perfect fit. Path tweens are more suited for Sonic / endless runner games etc. or any kind of fixed animation basically. Path tweens do not function node to node in all directions - that would require switching paths constantly.

    For a movement type like this, in a grid layout, I would recommend using separate tweens for each step (i.e. up arrow = move 1 unit), built via code, and using triggers for animations.
     
  37. brentcataldo

    brentcataldo

    Joined:
    Mar 11, 2013
    Posts:
    2
    Hey @Baroni I can't seem to create any waypoints.
    I create a new scene. I add a plane with a collider. I add a Waypoint Manager. I enter a Path Name. I click 'Start Path'. But when I hover over the plane and press P no waypoints are added and I get this warning in my console:

    "Waypoint Manager: 3D Mode. Trying to place a waypoint but couldn't find valid target. Have you clicked on a collider?"

    But I DO have a collider! And it is the same dimensions as my plane. I have tried both the default mesh collider and box collider.

    I tried to make a path inside one of your example scenes. It recognises my clicks (no warnings) however the points are created all in a single location, nowhere near my mouse.

    I'm using the latest official Unity release 2019.1.8f1

    Any information or help would be greatly appreciated.

    Cheers
    Brent
     
  38. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
  39. KiberKachok

    KiberKachok

    Joined:
    Mar 23, 2019
    Posts:
    2
    Hello? can i make train system with your asset?
     
  40. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    Hi, you could, and several other users have done so. It depends on your requirements. If you are looking for highly complex train mechanics i.e. decoupling wagons or intersections, then this asset probably isn't designed for that. However if you are looking for an asset that does different types of movement, on predefined paths, then that's the perfect use case.
     
  41. freedom667

    freedom667

    Joined:
    Sep 6, 2015
    Posts:
    425
    can I drag the object integrated waypoint with mouse? or there is only automatic move?
     
  42. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    @freedom667 the movement is like a fixed animation, you cannot drag the object off the path. You would need to stop the movement script before dragging and use pathfinding to get it back to the path later, depending on your requirements.
     
  43. freedom667

    freedom667

    Joined:
    Sep 6, 2015
    Posts:
    425
    well, will you make a feature like this?
     
  44. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    @freedom667 No. The asset is using DOTween, a tweening library, for moving objects. Writing a feature for moving objects with the mouse would actually mean a completely separate update logic and you wouldn't need a tweening library - not even our asset - for that at all.
     
  45. Deleted User

    Deleted User

    Guest

    Is it possible to change the altitude for every single yellow waypoint in this System ?

    I would like to use it for fishes in the Sea ^^

    because in the video you do not see that you can change the height at these waypoints.

    would interest me !
     
  46. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    @w0rksgames Do you mean the y-position of each waypoint? Of course the waypoints can be placed everywhere, in 3D space. In our web player you can see aircraft doing loopings ;)
     
  47. Deleted User

    Deleted User

    Guest

    Thanks for your back writing ! I will probably buy it in the future if I need it ^^
     
  48. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    2 questions:
    1) How to have a delay on objects that are following the path?
    Example: 4 platforms follow a path, they each need to be spaced out by 25% of the path's distance. (platform 1 starts @ 0% of the path, platform 2 @ starts at 25% of the path, platform 3 @ starts at 50% of the path...).

    2) Is there a way to preview the movement along a path without going in playmode?
    It would be useful even if it's not possible to do it on every type of paths or that it's simplified, it's a good start to get a feel for what the movement will look like.
    It is also useful to see if the objects that would move along the path would intersect with undesired objects.

    Your package has a lot going on :). Good job with the Events system! It would really benefit from implementing those 2 features as they are really handy.
    Here's an example with my own path solution (delay + preview feature):
    lm7cE2oydv.gif

    PS: Adding tooltips when hovering over the values in the inspector would make the package more intuitive.
     
  49. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,265
    @FeastSC2
    There are several ways to do this:
    - place waypoints at the desired positions and enter the corresponding waypoint index in the movement script's startPoint value, or
    - place objects where they should start in the editor already, then enable moveToPath and enter the next waypoint as the startPoint value on the movement script, or
    - let the movement scripts initialize at runtime and modify their tween.fullPosition value (range 0-1, where e.g. 0.25 = 25% on the path)

    Currently not. I've thought about this multiple times, however it isn't that easy to implement, as tweens using DOTween would still need to initialize in the editor for previewing their animations. With ease types, movements are not linear so unfortunately there is no simple editor position interpolation between A-B using a slider.

    Thank you for your feedback! Please continue using our website forum for any support related questions.
     
    andreiagmu and FeastSC2 like this.
  50. andreiagmu

    andreiagmu

    Joined:
    Feb 20, 2014
    Posts:
    175
    Hi, I want to ask about a thing I noticed on SWS.

    I just noticed that, in the splineMove and navMove components, there's no property to set the UpdateType of the tweens made by SWS (to set that UpdateType value along with the other DOTween params). Is that by design?

    I think that would be an interesting property to add to the SWS Move components, instead of just using the Default Update Type on DOTween's settings.
    And maybe there are other DOTween properties (like TimeScale Independent) that would be nice if they were directly configurable in the SWS Move components.
     
    Last edited: Dec 30, 2019