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. spikezart

    spikezart

    Joined:
    Oct 28, 2021
    Posts:
    72
    Yesssss! thank you!

    [QUOTE="You are probably using an own controller in the Animator component which does not have these variables."[/QUOTE]
     
  2. power_champ

    power_champ

    Joined:
    Oct 6, 2020
    Posts:
    10
    Hi all,

    This is more of a generic question but should I be able to step into the DOTween library while debugging without any extra setup?

    I'm currently experiencing the common problem of having an extra waypoint created when starting a path. Would like to see exactly why.

    PC
     
  3. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    Hey i have a quick question, just an observation of something but im not sure why it works the way it does.
    If i have a path tween running and then i start a "dash" tween on the same object like this:
    Code (CSharp):
    1.  dashTween = DOTween.To(() => thePlayer.fullPosition, y => thePlayer.fullPosition = y, thePlayer.fullPosition + dashChargeAmount, duration);
    WITHOUT STOPPING OR PAUSING the running path tween, its completely seamless and theres no jump after the dash tween completes, the path tween seamlessly continues from where the dash tween left the fullposition at.

    I don't understand why this is happening, since the Path Tween is tweening fullPosition at its own SLOWER rate compared to the dash tween, so that when the dash tween completes, the fullPosition is farther along the path than the path tween has reached, shouldnt the obj then teleport back to an earlier fullPosition to match the path tween fullPosition?

    Do you know what i mean?
    like for example to explain visually
    Path Tween: At 0 seconds => Waypoint1 => 5 seconds later => Waypoint 2
    Dash Tween: Runs at 1 second and reaches Waypoint 2 in 1 second and stops, so 3 seconds ahead of the Path Tween.
    At this point the Dash Tween is complete, and the Path Tween continues tweening the obj as normal, shouldn't it teleport the obj fullposition to the 2 second position between Waypoint 1 and 2?

    Instead it just continues from where the Dash Tween left of at Waypoint 2.
    Maybe im just misunderstanding of what exactly the tween is tweening, not the fullposition i guess, is it just the rate of change of full position?
     
    Last edited: Jan 21, 2023
  4. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    Hi @power_champ, I am not aware of any further debugging options for unwanted path points. At runtime, you have the DOTweenManager component that shows a list of currently running tweens with some more information, as well as the white lines between waypoints (with DOTween gizmos enabled) showing the generated path.

    Having an additional waypoint at the beginning could either result from "MoveToPath" being enabled on the movement script, the waypoints being too close to each other, or placing them with a very high zoom factor in the scene (again too close).

    @luniac Since I do not know the internals of DOTween, I can only assume that the path tween calculates its movement tween based on the current fullPosition, not a value that has been stored at the beginning of the tween. Therefore, modifying that fullPosition value always let's the object move from the current position onwards. What is "thePlayer.fullPosition" in your code, is it "thePlayerObj.splineMove.tween.fullPosition" or a local float variable? If it's tween.fullPosition, then that's the expected behavior, because you could also modify the fullPosition with or without another tween (does not matter) and it updates from there.
     
  5. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    yea its the full tween reference. it just weird me out how 2 tweens can be modifying fullPosition and it works... well i guess technically only my tween is directly working on fullPosition of the path tween, while the path tween is "implicitly" working on it?
    well whatever i guess lol
     
  6. pawelpietryka

    pawelpietryka

    Joined:
    Aug 18, 2022
    Posts:
    12
    @Baroni Hi, pretty new to programming and that's why confused with events. I know it's pretty much the same as subscribing to events with the new input system, but I still can't get it to work (yes I did look at the events examples but all the other code there was confusing to me)

    My Question: do you have a step-by-step guide how I can for example fire an event once a loop has been finished, or how to programmatically tell the manger to go to the next waypoint and wait until the next "go to next waypoint" gets received?

    I named my path "ratPath1" and the rat loops around the path fine. I also added the EventReceiver script to the GameObject, but I still didn't get it to work, sorry just lacking examples to "hack" my way through to the solution
     
  7. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    Hi @pawelpietryka, thanks for asking! The example codes could indeed be a bit confusing and it is planned to rework them into individual examples.

    There is no step by step guide for this specifically, as the functionality is really basic coding with events which does not explicitly relate to the asset itself. However I can provide you with some sample code: working with events requires two steps: subscribing to the event, and handling the event callback.

    Regarding your question, you would use the movementEndEvent and subscribe to it:

    Code (CSharp):
    1. using SWS;
    2.  
    3. public class YourClass : MonoBehaviour
    4. {
    5.     public splineMove move;
    6.  
    7.     public void Start()
    8.     {
    9.         move.movementEndEvent += MyMethod;
    10.     }
    11.  
    And the implement the method and handle what you want to do in there.

    Code (CSharp):
    1.  
    2.     public void MyMethod()
    3.     {
    4.         Debug.Log("Loop ended");
    5.     }
    6.  
    You would use the movementChangeEvent for this:

    Code (CSharp):
    1. using SWS;
    2.  
    3. public class YourClass : MonoBehaviour
    4. {
    5.     public splineMove move;
    6.  
    7.     public void Start()
    8.     {
    9.         move.movementChangeEvent += MyMethod;
    10.     }
    11.  
    12.     public void MyMethod(int waypointIndex)
    13.     {
    14.         if(waypointIndex > 0)
    15.         {
    16.            move.Pause();
    17.            //call move.Resume() at some other place or script to resume movement!
    18.         }
    19.     }
    20.  
    Hope this helps!
     
  8. pawelpietryka

    pawelpietryka

    Joined:
    Aug 18, 2022
    Posts:
    12
    oh man you are amazing thank you @Baroni

    I will try this tonight, but this makes so much more sense to me.

    SWS is a great tool, and after building my own, I love it!

    PS: For a noob like me, you guys should state not to import (or disable the folder) DOTween (& Pro) again (or maybe check through a script whether it's already installed) otherwise it will not fully install and spit out errors
     
  9. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    There is a bit of a tradeoff involved here - either I do not include DOTween in the asset and the user is required to do one more step, namely import DOTween manually, or have it in the asset and let the user eventually uncheck it on import (in the package contents popup). Usually I am always trying to avoid searching the full project hierarchy for a folder or file since that could result in bad performance or unwanted behaviour in large projects.
     
  10. rydski

    rydski

    Joined:
    May 5, 2021
    Posts:
    5
    Hi @Baroni

    Firstly I think the tool is fantastic and has saved me a load of time thank you!
    However I am attempting to pause the movement splines using a bool variable rather than the on screen buttons that are used in the runtime example 4, which isn't working? My coding is not the best, but I think it should work, the code is here (the resume part is unchanged, so would still show a button at this stage):

    Code (CSharp):
    1.     public ExampleClass4 example4;
    2.  
    3.     public bool paused;
    4.  
    5.     void DrawExample4()
    6.     {
    7.  
    8.         if (example4.moveRef.tween != null && example4.moveRef.tween.IsPlaying()
    9.             && paused)
    10.         {
    11.             example4.moveRef.Pause();
    12.        }
    13.  
    14.        if (example4.moveRef.tween != null && !example4.moveRef.tween.IsPlaying()
    15.            && GUI.Button(new Rect(30, 90, 100, 20), "Resume"))
    16.         {
    17.             example4.moveRef.Resume();
    18.         }
    19.     }
    20.  
    21.     [System.Serializable]
    22.     public class ExampleClass4
    23.     {
    24.         public splineMove moveRef;
    25.     }
    26.  
    27. }
     
  11. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    Hi @rydski, since I do not know what else you've modified from that sample, did you check whether DrawExample4() is called at all? Where do you set paused to true? What exactly does not work?
     
  12. rydski

    rydski

    Joined:
    May 5, 2021
    Posts:
    5
    Hi @Baroni, So to explain, I have tested the script with your original UI buttons of "pause" and "resume" and it works by pausing an NPC that is on a path as expected. However given that my game is in VR I cannot use GUI buttons, so instead wanted to use a bool variable to control the pause, so that I can change that bool variable from a controller button press. Here is the screenshot of the Object that shows the paused Bool variable

    upload_2023-1-26_18-35-29.png

    While the game is running, I have checked the Paused bool (from above) which should pause the NPC, however it does not. Here is the complete script:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Events;
    3. using DG.Tweening;
    4. using SWS;
    5.  
    6.  
    7. /// <summary>
    8. /// Example: demonstrates the programmatic use at runtime.
    9. /// <summary>
    10. public class PauseNPC : MonoBehaviour
    11. {
    12.  
    13.  
    14.     /// <summary>
    15.     /// Pause, resume example variables.
    16.     /// <summary>
    17.     public ExampleClass4 example4;
    18.  
    19.     public bool paused;
    20.  
    21.     void DrawExample4()
    22.     {
    23.  
    24.         if (example4.moveRef.tween != null && example4.moveRef.tween.IsPlaying()
    25.             && paused)
    26.         {
    27.             example4.moveRef.Pause();
    28.        }
    29.  
    30.        if (example4.moveRef.tween != null && !example4.moveRef.tween.IsPlaying()
    31.            && GUI.Button(new Rect(30, 90, 100, 20), "Resume"))
    32.         {
    33.             example4.moveRef.Resume();
    34.         }
    35.     }
    36.  
    37.     [System.Serializable]
    38.     public class ExampleClass4
    39.     {
    40.         public splineMove moveRef;
    41.     }
    42.  
    43. }
     
  13. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    @rydski Thanks for the additional explanation and full script. So, there are a few issues with your script:
    • the method DrawExample4() is not being called from anywhere
    • GUI.Button needs to be in the OnGUI method, otherwise it is not being rendered (also if only for testing)
    • you are overcomplicating the splineMove reference by encapsulating it in its own class
    The first two problems can be squished together by replacing the method name to OnGUI. As written in the official documentation, Unity calls OnGUI several times per frame automatically. The last thing would be just removing the class and putting the variable above.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Events;
    3. using DG.Tweening;
    4. using SWS;
    5.  
    6. /// <summary>
    7. /// Example: demonstrates the programmatic use at runtime.
    8. /// <summary>
    9. public class PauseNPC : MonoBehaviour
    10. {
    11.     /// <summary>
    12.     /// Pause, resume example variables.
    13.     /// <summary>
    14.     public splineMove moveRef;
    15.  
    16.     public bool paused;
    17.  
    18.     void OnGUI()
    19.     {
    20.         if(moveRef.tween == null) return;
    21.  
    22.         if (moveRef.tween.IsPlaying() && paused)
    23.         {
    24.            moveRef.Pause();
    25.         }
    26.         if (!moveRef.tween.IsPlaying() && GUI.Button(new Rect(30, 90, 100, 20), "Resume"))
    27.         {
    28.            moveRef.Resume();
    29.         }
    30.     }
    31. }
    Please note that actually basic Unity coding assistance (or custom coding) is not part of technical support. If you think it would be beneficial to you, I am offering a private support option on my website, a donation button, or I would appreciate just a review on the Asset Store after you used the asset some more :)
     
  14. rydski

    rydski

    Joined:
    May 5, 2021
    Posts:
    5
    Thanks @Baroni, will give it a try today. I appreciate you going the extra mile with this as you are right that it is not support, I will leave a positive review. Thanks again
     
  15. rydski

    rydski

    Joined:
    May 5, 2021
    Posts:
    5
    Hi @Baroni, unfortunately it did not work, however I will figure it out somehow, no need for you to anything. Thanks
     
  16. rydski

    rydski

    Joined:
    May 5, 2021
    Posts:
    5
    Hi @Baroni, I figured it out, below is the working script if anyone else has the same need as I had (to pause movement using a bool variable)

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Events;
    3. using DG.Tweening;
    4. using SWS;
    5.  
    6. public class PauseNPC : MonoBehaviour
    7. {
    8.     public splineMove moveRef;
    9.  
    10.     public bool paused;
    11.  
    12.     void Update()
    13.     {
    14.         if(moveRef.tween == null) return;
    15.         if (moveRef.tween.IsPlaying() && paused)
    16.         {
    17.             moveRef.Pause();
    18.         }
    19.         if (!moveRef.tween.IsPlaying() && !paused)
    20.         {
    21.             moveRef.Resume();
    22.         }
    23.     }
    24. }
     
  17. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    @rydski That's right, if you are not using GUI.Button you can also replace OnGUI() with Update() which is called several times per frame too. Thank you very much for the review!
     
  18. TakeThePowerBack

    TakeThePowerBack

    Joined:
    Sep 8, 2013
    Posts:
    2
    i'm using Simple WayPoint System and DOTween(HOTween v2) in unity3d project. thanks.
    (windows standalone build)

    tween.timeScale is real-world(unity3d world) speed?
    it looks like not same in my project.

    DOLocalPath(), DOPath(), tween.SetUpdate(true), Ease.Linear, LoopType.none is also using.

    tween.timeScale is set to 0.0812,
    but measured speed is 0.0792m/s,
    1.009644m / 12.7434897sec = 0.0792m/s
    (gameobject's moving distance / elapsed seconds = speed)
    measure during tween.Play() to tween.Pause().

    is there any way to using tween.timeScale to real speed?
    Thanks for yours help
     
  19. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    I was under the impression that it is, because DOTween callbacks rely on Unity Update calls to update the tween. So if you set DOTweens timescale to 1, it is called as often as the timescale set in Unity. Could you verify that both timescales are set to 1?

    Tools > Demigiant > DOTween Utility Panel > Preferences and
    Edit > Project Settings > Time

    Screen1.png Screen2.png
     
  20. TakeThePowerBack

    TakeThePowerBack

    Joined:
    Sep 8, 2013
    Posts:
    2
    Both timescales are set to 1.
    and i use tween.SetUpdate(true)
    FPS was 30~15 average
    1.PNG
     
  21. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    @TakeThePowerBack thanks for the screenshot, however I am not sure why you are mentioning the FPS average, is this related? There is a lot more to consider regarding FPS, for example the Unity Editor has its own FPS limiter. Or, the other way around, you could set it to a value of 60, because on mobile it is sometimes limited to 30 by default.
    https://answers.unity.com/questions/300467/how-to-limit-frame-rate-in-unity-editor.html

    Regarding the "tween.SetUpdate(true)" call, DOTween does not have such a method, only SetUpdate(UpdateType updateType, bool isIndependentUpdate = false) with two parameters. Note as the method description says, by passing "true" for the second parameter Unity's timescale is completely ignored.
    http://dotween.demigiant.com/documentation.php#tweenerSequenceSettings

    You could also try SetUpdate(UpdateType.Fixed) but then you would want to change your Project Settings' Fixed Timestep value back to the default of 0.02 instead of 0.2.

    Maybe we could take a step back and you could explain what you want to achieve, where exactly is the issue, and how I can reproduce it in a sample scene of the asset? Thanks!
     
  22. ctronc

    ctronc

    Joined:
    May 18, 2017
    Posts:
    19
    Hi @Baroni , thank you for this asset! I was hoping you could help me with an issue I'm facing that appears to be related to setting the MoveToPath bool to true.

    I'm working on a virtual tour project where the camera moves through the level using waypoints, then pauses at specific points to allow users to interact with objects and look around the surroundings before continuing along the path. Initially, I tried using a single path with multiple waypoints, but I found out from this forum that it's not possible to apply easing between individual waypoints, only to the entire path.

    My second attempt involved using different paths that would automatically stop at the last waypoint set at a point of interest, then resume and travel to the start of the next path. However, setting the "MoveToPath" boolean to true while traveling to the second path causes random "reboots". The camera goes to the first waypoint, turns around, and repeats the same sequence before finally traveling through the second path as intended. This behavior persists even though no loops have been set on the options, as shown in the attached screenshots. The camera does not experience this issue when "MoveToPath" is set to false, but this results in the camera instantly teleporting to the second path instead of a smooth transition. The red cube attached to the camera is purely for visibility and has no colliders. Also, the blue plane was set up after setting up the paths, and the waypoints were placed using the "C" key (camera positioning on the scene view).

    Looking forward to your reply, thanks!



    camera_inspector.png

    cubemovementcs.png
     
    Last edited: Mar 2, 2023
  23. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    Hi @ctronc, thanks for posting here!

    That's correct, easing can only be applied to the generated tween. Since a path requires multiple waypoints to form its shape, having easing from one waypoint to another would require a separate tween between waypoints, but then the movement would just be in straight lines.

    However, you could play around with custom easing. Again, this is defined for the full path, but it allows more control and you can place additional points in the curve, maybe coming close to your waypoints. See this section for more information.

    I think I know what happens here. You are calling SetPath in the "MovementEnd" callback, however when the callback is triggered, the (old) movement is still active. There is a known issue with this approach due to the order of internal actions. I guess it would solve itself if you add a small delay (e.g. 0.5 sec) before calling SetPath? Also, I do not see where you set MoveToPath to true, but it should be right before SetPath, so at best in that method as well.

    The "MovementEnd" event persists on your movement object, so every time it reaches the end of path "path_b", it calls SetPath(path_b) again, effectively resulting in a loop.
     
  24. eightbitbrainpower

    eightbitbrainpower

    Joined:
    Dec 8, 2017
    Posts:
    6
    Hello there. Is Playmaker support ditched for this addon? I can't find the custom actions package, yet I've seen people talking about it.
     
  25. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    Hi @eightbitbrainpower, yes, my custom PlayMaker actions were removed in the last update (see changelog). I have not touched them for years and never heard anyone actually use them. Their functionality was quite limited too and basically duplicated options that were either available via PlayMaker itself (set movement script variables) or easily possible in other ways (call script methods).

    I know that for other plugins there are actions maintained by other users or even by the PlayMaker developers, but for this asset and its price, the effort did not seem to be worth it in regard to what they delivered.
     
  26. eightbitbrainpower

    eightbitbrainpower

    Joined:
    Dec 8, 2017
    Posts:
    6
    Fair enough. Thank you for the clarification!
     
  27. ctronc

    ctronc

    Joined:
    May 18, 2017
    Posts:
    19
    (edited for clarity)

    @Baroni thank you very much for your help, your suggestions really helped!

    I'm currently encountering an issue where moving an object along a path can result in jarring transitions if the object's initial position and rotation is not exactly aligned with the first waypoint. When MoveToPath is set to False, the object teleports to the first waypoint (expected behaviour). When MoveToPath is set to True, the object follows a linear path to the first waypoint, stop, and then turn abruptly to align with the actual path. Setting a value for LookAhead helps a bit though.

    I'm wondering if there are any ways to address this,
    • Is there a way to ensure that the object is already perfectly positioned and aligned with the first waypoint before the path begins? This would ensure that when MoveToPath is set to False, the object's movement is seamless and uninterrupted.
    • Alternatively, when MoveToPath is set to True, is it possible to merge the initial alignment path and the actual path together? This would create the illusion of a single smooth path, even if the object's initial position and rotation are not perfectly aligned with the first waypoint.
    What I'm actually trying to do is to give the illusion of having a big path for a camera, giving the user an "on rails" experience. The big path is actually 4 different paths, each with their own easing. When I finish a path, the camera should stay on the last waypoint for a bit, the user interacts, and then the camera flies from the final waypoint and merges into the second path seamlessly. Do you think this is achievable with SWS?

    Thanks
     
    Last edited: Mar 8, 2023
  28. ctronc

    ctronc

    Joined:
    May 18, 2017
    Posts:
    19
    @Baroni , I think I managed to solve my issue! turns out in one hand the object I was moving along the path had some scripts attached to it that were altering its behaviour. On the other hand, I think one big path with speed modifiers at some points will work just fine, just as you suggested.

    However, I'm now having some trouble editing existing waypoints. Is it possible to edit an already existing path by placing a new waypoint with the camera look (using the "c" key), and then placing this new waypoint in between other waypoints, not just at the end? Or more generally, is it possible to rearrange waypoints somehow? I tried to replace the some of the waypoint transforms with transforms from random gameobjects, waypoints from another path, and waypoints from the same path using the dialog but I couldn't get it right, nothing happened at all, the original transforms stay there.

    Hope you can help me out, thanks!
     
  29. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    Hi @ctronc, great to hear you've worked out a way that plays nicely with your camera requirement! Nevertheless I would like to do a quick comment on the two questions in your previous post:

    If the object is placed at the first waypoint already and should start there with the correct rotation on game launch, it could simply be done by playing+pausing, copying the Transform values, exiting play mode and applying it in the editor. It gets more work with a path that follows anytime later, since then you would need to cache the Transform value by script and apply it right before calling SetPath().

    Even more advanced: you would have access to any position and rotation along the path using a "ghost object" i.e. an invisible object that temporarily follows the path, only for copying the Transform values over to your actual game object.

    MoveToPath already does that, even though it is not clearly visible, but it uses the initial position + first + second waypoints for a temporary path until the first waypoint is reached. This way, the curve is smoother, but it is true that it is still not 100% correct, and more noticeable when using a camera. Even when using the initial position and full path, with a camera you would still easily notice a deviation within 5-10 degrees in rotation. I do not have a solution for this right now, and this is on the list for the next major update.

    Unfortunately this has not been asked before, so it has not been considered yet. However since waypoints are just game objects, you could create a new path and then assign these game objects to your other path? Please see here for general instructions, specifically the screenshot showing the list of waypoints. Each game object in that waypoint slot can be replaced by dragging in a new game object.

    Yes, by re-assigning the waypoint game objects in the inspector, like I just said. The game object will stay where they are, but the path will be recalculated using the new order / positions. Drag & drop for the waypoints list is also planned in a future update! I'm not sure what exactly you mean that does not work, maybe you could post 1-2 screenshots for a quick visualization? Thanks!

    P.S. another alternative is moving new game objects as children under the path, and then using the "Update From Children" modifier on the PathManager.
     
  30. ctronc

    ctronc

    Joined:
    May 18, 2017
    Posts:
    19
    Hey @Baroni ,thank you for your valuable help and suggestions. Your "Update From Children" tip was incredibly helpful and worked like a charm for me. With this approach, I am now able to easily edit an existing path by adding a new waypoint at the end of the path using the camera view and the C key. I can then rearrange the waypoints in the inspector and select "Update from Children", no issues so far!

    I have also attached a video to demonstrate the process I was trying to use to assign new transforms to already existing waypoints, based on your post. This approach isn't working for me but I may have misunderstood something or done something wrong. Nonetheless, your support has been incredible and I now have a functional workflow. Thank you so much again for your assistance!

     
  31. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    @ctronc Thanks for the video! Wow, what Unity version is this on? You're doing it right, this definitely seems like regression, maybe even in Unity itself, since the code should not suddenly break. I will try to reproduce this in that version then.

    Glad that the "Update From Children" function is useful to you! (Honest) reviews on the Asset Store are always highly appreciated *hint hint* ;)
     
  32. ctronc

    ctronc

    Joined:
    May 18, 2017
    Posts:
    19
    @Baroni this is Unity 2021.3.11f1, hope that helps, and expect an honest review soon :)
    Thanks!
     
    Baroni likes this.
  33. OddKidToons

    OddKidToons

    Joined:
    Aug 29, 2019
    Posts:
    21
    Hello, help, I love your asset and I use it a lot for my animations, but for some reason when I try to create a new path it won't create them anymore. it started out not working every now and then and now doesn't do anything. What would cause this? I am using the same exact scene in every video. I press P and it draws nothing.
     
  34. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    Hi @OddKidToons thanks for using SWS! Have you tried resetting the editor layout (top right corner) to default? For some unknown reason, sometimes Unity just breaks all editor raycasts.
     
  35. OddKidToons

    OddKidToons

    Joined:
    Aug 29, 2019
    Posts:
    21

    Tried it now, it sorta works, see the video for the results. For some reason it won't show them as I drawn them.

    [edit] not working again, not even saving the points.

     
    Last edited: Mar 23, 2023
  36. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    Haven't seen that before. Could you create a new scene with only a plane, try to place waypoints and if it doesn't work, duplicate the full project and delete unnecessary folders and scenes before sending it to me? A download link in a private message would be great.
     
  37. OddKidToons

    OddKidToons

    Joined:
    Aug 29, 2019
    Posts:
    21
    How do i send in a private message? Sorry late reply, I got the covid vaccine and had a bad reaction to it. Been in bed all day.
     
  38. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    By clicking on my user name then "Start a Conversation". Get well soon!
     
  39. OddKidToons

    OddKidToons

    Joined:
    Aug 29, 2019
    Posts:
    21
    I think I sent one to you yesterday, did you see it?
     
  40. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    Hi @OddKidToons, yes thank you, it's just that I do not work on weekends :)
    Upon importing the .unitypackage (which toook over an hour) I was greeted with 110 errors related to DefaultPlayables and Addons\TimelineSalsa. Therefore I was not able to do any SWS tests. I noticed that you did not delete the 'SWS' folder prior to importing version 5.5.1, as that folder name changed to 'SimpleWaypointSystem' and you now have both in your project.

    As mentioned before, duplicating the project folder and sending over a zip of it is a more reliable approach for reproduction, since when you are exporting contents of the project as a unitypackage, I do not know which Unity version you are using and also do not get the ProjectSettings along with it (which contain necessary PackageManager references).
     
  41. OddKidToons

    OddKidToons

    Joined:
    Aug 29, 2019
    Posts:
    21
    Those are only showing because you need to install cinemachine first and they will all go away. We use this template for hundreds of cartoons. Nothing is missing except cinemachine, all those will go away once you install that from the registry. And I will check the SWS and delete it and reinstall it.
     
  42. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    @OddKidToons Ok. However as I said, it could be something broken in the Project Settings which are not included in a unitypackage export. I had that a few times before when trying to reproduce issues and after importing the unitypackage it just worked, because the issue was with the project. So if you still run into this, I would be very grateful if you could reupload a project (folder) and share the link in a PM. I know that this causes additional work - but for both of us :)
     
  43. OddKidToons

    OddKidToons

    Joined:
    Aug 29, 2019
    Posts:
    21
    I tried deleting SWS and reinstalling it. Same issue.

    I opened a new empty project and only installed SWS (nothing from registry) and did two tests from different angles and one didnt work at all
    and the second only showed the points after i clicked finish.


    The title of the video has unity version information.
    We are using 4 different Computers. Same result on all three PCs and Laptop. Ryzen 5 and Ryzen 9. RTX 3060 Ti and GTX 1660 Ti
     
    Last edited: Mar 28, 2023
  44. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    @OddKidToons Thank you for the videos and Unity version. I was about to ask whether this is a URP project, but simply downloaded that version and was able to reproduce it in a "3D Core" project as well. Had both issues - (1) no path created and also (2) no waypoints visible.

    (1) Seems to be caused by the WaypointManager not detecting the screen view. After clicking on "Start Path", one has to right-click / move view in the scene view to recognize it, then waypoints placed get added to the path correctly.
    (2) After waypoint placement and clicking "Finish Editing", deselecting and re-selecting the WaypointManager makes the waypoints visible again. Creating a second path does not produce invisible waypoints, instead they are visible immediately, during placement too.

    Nothing changed in the way editor events are handled in the latest versions - the unreliable outcome (first path has issues, others do not) really makes me wonder what Unity is up to here. At least the result is the same with several tries and a newly added WaypointManager each time. I do not think submitting a bug report to Unity would be useful because it is likely not getting backported, so I will first try to find the exact cause and a "reliable workaround". Thanks again for your patience, and hope that the above mentioned workarounds still allow you to work with SWS to some extent.
     
  45. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    I wasted my whole day with this and found that OnDrawGizmos is not called at all, for the first path, or before selecting the WaypointManager once. When parenting a cube or just some other random game object to the WaypointManager, it works. This led me to the bug "Editor: Fixed OnDrawGizmos is not called on child GOs to an empty parent. (1394023)" that was fixed in Unity 2022.2.0.

    So, as a workaround I now have to attach a Cube game object to the WaypointManager when it gets created? This is really funny and p* me off, by a lot.
     
  46. OddKidToons

    OddKidToons

    Joined:
    Aug 29, 2019
    Posts:
    21
    So it's Unity haha. I was guessing it is because the mouse curser would also change to a camera horizontal movement curser as well when I tried to make new paths. So if I am understanding you right, IF I place the waypoint manager under an empty object, it should work in 2021? Or this is in a update coming soon?
     
  47. OddKidToons

    OddKidToons

    Joined:
    Aug 29, 2019
    Posts:
    21
    Worth the wait. I'm serious I use SWS a LOT, it speeds up my workflow 10x with its easy of use.
     
  48. OddKidToons

    OddKidToons

    Joined:
    Aug 29, 2019
    Posts:
    21

    UPDATE: I see the update now. haha. Downloading, thank you!
     
  49. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,278
    Yep, Unity being Unity, you're welcome and thank you for the review! :)
    An empty game object under the WaypointManager is not enough (could have been that easy right?), it has to be a non-empty game object like a piece of environment or something like that. As promised, the update uses a child cube with all components disabled and to be double sure, a scale of zero.
     
  50. ryannotfound

    ryannotfound

    Joined:
    May 5, 2016
    Posts:
    6
    Hi All,
    I really love this script, I'm using it for some pathfinding for some animals, as well as a way for my Audio source of the water to flow close to the Player.

    one question, the OLD system used to allow for Waypoints to be defined, then you could easily change functions once a waypoint was reached... Old code:

    /// <summary>
    /// List of Unity Events invoked when reaching waypoints.
    /// <summary>
    [HideInInspector]
    public List<UnityEvent> events = new List<UnityEvent>();


    What replaces this? I have a bird in the sky, and I want to simply change the animation when he hits every 3rd (or so) waypoint, where I could call
    flap(), or Soar()... Little bit unsure now =/

    Cheers in advance.
    Ryan
     
    Last edited: Apr 4, 2023