Search Unity

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,261
    @idurvesh Yes, see my reply you've quoted. It's not weekend yet and I'm still on my way back in the office.
     
    idurvesh likes this.
  2. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    Ah sorry, I thought last weekend, no problem ,let me know soon, thanks in
     
  3. mog-mog-mog

    mog-mog-mog

    Joined:
    Feb 12, 2014
    Posts:
    266
    This is the warning I see in dotween which spam the log file -
    DOTWEEN :: An error inside a tween callback was silently taken care of > Array index is out of range.
     
  4. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    @lilboylost I still don't know where the warning occurs, as your report does not state any line numbers or scripts. Please send me a private message with the full error log. Note that you can also disable DOTween warnings completely by going to Tools > DOTween Utility Panel > Preferences > Log Behavior.
     
  5. deekpyro

    deekpyro

    Joined:
    Oct 16, 2012
    Posts:
    71
    Hey Baroni. Is there a way on splineMove to get if the object is currently tweeting or not? That would be useful. Also any ETA on when there may be an update with path rotations based on the transforms?
     
    Last edited: Sep 27, 2015
  6. mog-mog-mog

    mog-mog-mog

    Joined:
    Feb 12, 2014
    Posts:
    266
    It doesn't provide me any line numbers. I've already disabled warning, but it still show it :(
    Can you please search into DoTween code for above line/warning?


    DoTween.png
     
  7. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    @lilboylost could you please send me a repro project privately where that error occurs, so I can take a look at your setup. I do not support DOTween, meaning I probably have to contact its developer about that.

    @deekpyro you can check the tween directly about its current state. tween == null and tween.isPlaying() would work. No ETA for the waypoint rotations, as I still have to figure out the best scenario on how to use it.
     
  8. mog-mog-mog

    mog-mog-mog

    Joined:
    Feb 12, 2014
    Posts:
    266
    I have seen this error 3 out of 10 times, so I do not have repro steps. I believe it happens if you don't cancel the tween after object have been destroyed. I am okay as Dotween handle the error gracefully with warning. I would request contacting developer, it should be easy to check that line of log inside code and make sure that respect Log Behaviour setting. I am not in hurry, as this warning is non harmful except log performance every update.
     
  9. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    Hello,
    i have bought you asset. Looks easy to use. Just would like to know, is it possible to mark some of the points with a tag (or name it specifically) to navigate character to nearest of that points from any current position in path?
     
  10. Divistri

    Divistri

    Joined:
    Oct 1, 2015
    Posts:
    9
    Hey, Baroni! I just recently bought SWS and love it! I was wondering, could you give me some advice on how to best approach a player movement set up I'm working on?

    I want to accomplish:
    1. A closed path loop
    2. An object can move on this loop
    3. A player controls the movement of the object on the loop
    4. The player can pause the object's movement and make the object travel forwards and reverse on the loop
    Basically, the functionality of the Player Input Demo in the examples, but with a path that loops forwards and backwards.

    I currently have:
    1. A closed path loop with Loop Type set as Loop and Close Loop checked
    2. An object moving on the loop using splineMove
    3. A player controlling object movement on the loop using the script from Path Input Demo
    Step 4 seems to be the toughest part with these problems:
    1. Player moving in reverse at beginning: If the player starts at the first waypoint and moves in reverse on the path, they do not move in a loop on the path. They simply sit there as if the Loop Type was set to None.
    2. Player moving forwards at the end: If the player is moving forward and reaches the last waypoint on the path they hit the last waypoint like a dead end as if the Loop Type was set to None. Then if you keep trying to move forward the player begins to move forwards on the path automatically where the controls become unusable.
    If you could help me out with this, that would be absolutely amazing. Thanks for making such an awesome asset too!
     
    Last edited: Oct 10, 2015
  11. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    Hi nova, you can set the "startPoint" variable on the movement script to the desired waypoint index, set "moveToPath" to true and restart movement. Your object will then walk to the specified waypoint directly. If pathfinding is required, the navMove movement script and Unity's NavMesh system should be used.

    Hi there and thanks for the kind words :)
    The PathInputDemo script clamps the position/progress to the path and excludes loops. For loops and the problems you described, you have to reset the progress value if your object reaches the end of the path - so on a looping path this means that if you reached the end, set the progress back to 0. When going left on the beginning, set the progress to the end. Try this and replace it with the Update() method in PathInputDemo.cs.

    Code (csharp):
    1.  
    2.     //listens to user input
    3.     void Update()
    4.     {
    5.         float speed = speedMultiplier / 100f;
    6.         float duration = move.tween.Duration();
    7.  
    8.         //right arrow key
    9.         if (Input.GetKey("right"))
    10.         {
    11.             if (progress > duration) progress = 0;
    12.             //add a value based on time and speed to the progress to start moving right
    13.             progress += Time.deltaTime * 10 * speed;
    14.             move.tween.fullPosition = progress;
    15.         }
    16.  
    17.         //left arrow key
    18.         //same as above, but here we invert the progress direction
    19.         if (Input.GetKey("left"))
    20.         {
    21.             if (progress < 0) progress = duration;
    22.             progress -= Time.deltaTime * 10 * speed;
    23.             move.tween.fullPosition = progress;
    24.         }
    25.  
    26.         move.Pause();
    27.  
    28.         //let Mecanim animate our object when moving,
    29.         //otherwise set speed to zero
    30.         if ((Input.GetKey("right") || Input.GetKey("left"))
    31.             && progress != 0 && progress != duration)
    32.             animator.SetFloat("Speed", move.speed);
    33.         else
    34.             animator.SetFloat("Speed", 0f);
    35.     }
     
  12. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    I have tried you previous advice, but seem it not possible, because if I even set waypoint index from PathManager, the movement starts not prom the waypoint but from yellow handles.

    What I need in my case is:
    My character moves by path. In a certain time called by event he must find the nearest waypoint with a name "Target" (check it by distance) and move to that point from his current position on BezierPath even if that point is behind of his current position (how I understand I just can inverse the movement in that case)

    So currently I don't know how to:
    1. find the distances to exact waypoints
    2. understand is the nearest waypoint is behind or not
    3. reverse the movement if needed waypoint is "behind"
    How can I do it?

    P.S. if it not possible to "move back" to needed waypoint by the path, how to find nearest point in front of the path?
     
    Last edited: Oct 10, 2015
  13. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    What handles? If you are using bezier paths, each "yellow dot" is a waypoint - kind of. They are control points. This is different from the other movement scripts.

    1. BezierPathManager returns a list of all dots on the path via GetPathPoints(). With that array, you can check against the "real" waypoints, which are stored in BezierPathManager's bPoints list. Each bPoints[index].wp is a waypoint gameobject.
    Code (csharp):
    1. int index = 4; //searching for the 4th waypoint
    2. for (int i = 0; i < pathPoints.Length; i++)
    3. {
    4.    if(pathPoints[i] == bPoints[index].wp.position)
    5.    {
    6.        index = i; //found the real index
    7.        break;
    8.    }
    9. }
    2. Not sure what you're looking for here. The currentPoint value is your current index on the path. You could use the above code here as well to get an index and compare them.

    3.
    Code (csharp):
    1. //reverse movement
    2.             int currentPoint = move.currentPoint;
    3.             move.reverse = !move.reverse;
    4.             move.StartMove();
    5.             move.GoToWaypoint(currentPoint);
     
  14. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    ok thanks, that will help
     
  15. Divistri

    Divistri

    Joined:
    Oct 1, 2015
    Posts:
    9
    Thank you, that works perfectly! I have been struggling to get this simple movement system down using another buggy asset for a month with no support from the publisher, but I got it working in minutes with your asset and help. I'm really blown away with how polished SWS is and the amazing support it has. Thank you. :D

    If you don't mind, could I ask a couple more questions on the movement system?

    I realized the controls made movement instantaneous on the path when I think it would feel a lot better if it could accelerate and decelerate the movement.

    My current approach to decelerating is:
    1. Detect KeyUp
    2. Continue in direction as normal
    3. Reduce speed using
      Code (CSharp):
      1. speed -= 0.005f;
    4. Continue in direction as normal until speed is less than zero
    My question is, "Is this the best way to accomplish deceleration/acceleration?"
    I searched around a bit and saw people mention a tween.timeScale property. Would that be a better way to accomplish acceleration/deceleration?

    My second question revolves around Standard vs. Bezier path types.

    My current setup used splineMove so I used a Standard path type. I tried accomplishing the same thing with a Bezier path type and bezierMove, but found the movement paused for a split second when transitioning from the last waypoint to the first waypoint. I then attached the Bezier path to splineMove to find the movement didn't pause.

    "Does using a Beizer path type with a splineMove script affect the program in anyway?"

    I may want to use Bezier paths for finer path control, but have found the bezierMove to have the problem above. I imagine this is because bezierMove doesn't appear to support a closed path?

    Thank you again for the incredible help.
     
  16. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    :)

    When changing the speed on a movement script via ChangeSpeed(value), it actually makes use of the timeScale. But that doesn't work for the PathInputDemo script where the tween is deactivated and the object is "put" directly on the path position. The car demo (RapidInput scene) has another sample on how to let your object decelerate if no key has been pressed.

    No, not at all. Bezier paths just have more invisible control points (yellow dots) in addition to waypoints, for better control over path segments. I didn't even know you can use it like that :D It is true that bezierMove is a slightly stripped down version of splineMove.
     
  17. lishali12345

    lishali12345

    Joined:
    Apr 10, 2014
    Posts:
    3
    Hi Baroni, I want to know wether I can set the rotation of each waypoint in the path editor. I heard this plugin from the author of DoTween -- Daniele Giardini, but I'm not sure wether I can use this plugin to create Camera Animation for cutscene in my game. Thanks a lot.
     
  18. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    Thanks for your kind support in PM :)

    I just recently come into one query, I am developing racing game so I have attached parent object to SWS, I want my child to fly up down in curvey way when power ups get activated.Is it possible with SWS ?

    In other words, is it possible to have two splineMoves on one object where parent splineMove will follow different path whereas child object will follow other periodically as per requirement.

    I tried local option set to enable , its not working properly...
     
  19. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    @lishali12345
    Also, you could do that with a separate DORotate or DOLookAt tween...

    -------------------------------

    @idurvesh if I understand you correctly, this should work by having two gameobjects as you described:
    - empty gameobject (parent, splineMove following the path)
    --- child object (the actual car, this can be manipulated with local tweens)

    If you want to use smaller looping paths etc. for the child object while moving on the main path, please note that this changes the hierarchy setup to this:
    - empty gameobject (parent, splineMove following the path)
    --- looping path (PathManager with waypoints)
    ------ child object (the actual car, splineMove with "local" checkbox ticked)

    The "local" sample in example scene 4 actually does the same thing and you can move it around while the ball is still following the path.
     
  20. lishali12345

    lishali12345

    Joined:
    Apr 10, 2014
    Posts:
    3
    I want make the camera move in the waypoints, and I want the camera can rotate simultaneously when it's moving between the waypoints. For example, I have a path only have to waypoints A and B.

    A has Position: (0, 0, 0), EulerAngles: (0, 90, 0), B has Position: (0, 3, -3), EulerAngles: (0, 45, 0), I want to make the camera move from A to B, and the camera rotate from (0, 90, 0) to (0, 45, 0) when it's moving position.

    Can I just use Simple Waypoint System to get this in the Unity3D Editor?

    Thanks a lot!
     
  21. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    @lishali12345
    Thanks for the explanation. The current version of Simple Waypoint System will only handle the movement part, not the rotation. You can create an additional tween with the methods I linked earlier to get the desired result. This will be built-in in a future version.
     
  22. samwestdev

    samwestdev

    Joined:
    Jun 11, 2015
    Posts:
    2
    Does anybody knows why sometimes bezier points handle go inside the node and they become non movable?



    The only solution I found is to delete the node and recreate it (which is not ideal).

    Any idea?

    I'm using Unity 5.1.3.f1

    Thanks!
     
  23. lishali12345

    lishali12345

    Joined:
    Apr 10, 2014
    Posts:
    3
    Thanks.
     
  24. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    Sometimes? Any steps to reproduce this on my end? You could also select the waypoint gameobject in the hierarchy to move it.
     
  25. samwestdev

    samwestdev

    Joined:
    Jun 11, 2015
    Posts:
    2
    Looks like it happends when I add a new node after the last one (using the + button in the Path Manager inspector panel). It creates a new path node but the handles of the now second-last go inside the node and become not draggable.



    Thanks! This will do!
     
    Last edited: Oct 13, 2015
  26. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    Thanks I solved it by using "DOTween"'s localMoveY method...
     
  27. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    @Baroni Hello again, Before using SWS I had set up my custom waypoints which were child of my parent gameobject.Now I would like to convert thsoe waypoints to SWS, is it possible? My tracks are big so doing it from scratch will eat lot of time.

    I had tried drag-drop waypoints to PathManager but its not working..
     
  28. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    @idurvesh Whats "not working"? For normal PathManagers, you could write an editor script that gets your waypoints and set them to the PathManager.waypoints array. For bezier paths, you need to have control points too and assign/overwrite the bPoints list of the BezierPathManager.
     
    idurvesh likes this.
  29. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    Awesome,That did work.<3

    Someone who may be intrested in script, here is it, (place the script on PathManager object)

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEditor;
    4. using SWS;
    5.  
    6.  
    7. [ExecuteInEditMode()]
    8. public class SWSWayPointCHanger : MonoBehaviour {
    9.  
    10.     public bool changeWayPoints;
    11.     public Transform[] newWaypoints;
    12.  
    13.     // Update is called once per frame
    14.     void Update () {
    15.  
    16.         if (changeWayPoints)
    17.         {
    18.             PathManager existingPM = GetComponent<PathManager>();
    19.  
    20.             existingPM.waypoints = newWaypoints;
    21.  
    22.  
    23.  
    24.             changeWayPoints = false;
    25.         }
    26.  
    27.     }
    28. }
    29.  
     
  30. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    We use your package as the pathing solution in our tower defense game to move the creep. We are using splineMove to move the the creep along a path (PathManager). We are also using object pooling to recycling the creep object so we dont need to call instantiate() everytime a creep is spawned. So when a creep object first spawn, we move the creep object by calling StartMove() on the splineMove instance. Upon reaching the final way, the creep object is deactivated. All this works perfectly. But when the object is activated and StartMove() is called again (to repeat the exact same process), Following error occur:

    transform.position assign attempt for 'CreepVehicle(Clone)' is not valid. Input position is { NaN, NaN, NaN }.
    UnityEngine.Transform:set_position(Vector3)
    DG.Tweening.<>c__DisplayClass105:<DOPath>b__104(Vector3) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/ShortcutExtensions.cs:843)
    DG.Tweening.Plugins.PathPlugin:EvaluateAndApply(PathOptions, Tween, Boolean, DOGetter`1, DOSetter`1, Single, Path, Path, Single, Boolean) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Plugins/PathPlugin.cs:107)
    DG.Tweening.Core.TweenerCore`3:ApplyTween(Single, Int32, Int32, Boolean, UpdateMode) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenerCore.cs:175)
    DG.Tweening.Tween:DoGoto(Tween, Single, Int32, UpdateMode) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:234)
    DG.Tweening.Core.TweenManager:Update(UpdateType, Single, Single) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:391)
    DG.Tweening.Core.DOTweenComponent:Update() (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:50)


    Following the error, ReachedEnd() is called as if the creep object has reached its destination. Have you encounter this issue before? Or any idea what could have caused the error?
     
  31. josemauriciob

    josemauriciob

    Joined:
    Mar 5, 2009
    Posts:
    662
    hi ..
    please help on SWF
    i need to instantiate a lot of enemies on a specific path,

    I import PLAYMAKER add on..
    but give me an error....

    i put the picture here because
    to much text.
    please help.

    on any otehr idea how instantiate to clone enemies on a diferent path please ?

    erro ui.jpg
     
  32. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    @Mark_T Thanks for the explanation. I don't know what the error means, DOTween's developer could help with that. Please try calling Stop() on the movement script before deactivation, maybe that solves it and should be the proper way. Only deactivating the object does not destroy its tween.

    @josemauriciob answering your email. Please use only one channel to contact me.
     
  33. josemauriciob

    josemauriciob

    Joined:
    Mar 5, 2009
    Posts:
    662
    thanks ... i am using unity 5.1.3
    and , can not do nothing, because, inmediatly import playmaker, those errors appear.
     
  34. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    Simple Waypoint System contains a PlayMaker addon package, NOT PlayMaker itself. Which PlayMaker version are you using?

    Edit:
    For the third and last time (1 via email, 2 times here): you DID NOT import PlayMaker. This is Simple Waypoint System, and this is PlayMaker. I'm not sure if you see the difference.

    A shout-out to the moderator who removed your illegally shared project link in here.
     
    Last edited: Oct 20, 2015
  35. josemauriciob

    josemauriciob

    Joined:
    Mar 5, 2009
    Posts:
    662
    thanks again ... so much .. i understand now....
    i thoght is the same package sorry.

    i just need to instantiate enemies on specific path with SWS on untity 5x please
    and thats my problem yet.... no solve it yet

    when I instantiate , how can i tell to prefab the specific path to follow please ?

    if someone have any idea, i will apreciatte so much.
    thanks and sorry again
     
  36. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    SWS_SetPath action... each action is showcased in the PlayMaker example scene.
    SWS > Plugins > PlayMaker > Scenes > Example_PlayMaker.unity.
     
  37. chinchoppa

    chinchoppa

    Joined:
    Jul 1, 2015
    Posts:
    3
    umm
    sory iam still new
    why cant i put the name in waypoint manager ??
    also i open the scene there's also no name in waypoint manager in the example scene
    trying follow the doc.pdf where it said got to put the name of the path
     

    Attached Files:

  38. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    @chinchoppa
    Please update to the latest version. In your screenshot, in the inspector there is a field for entering the path name. It should work with the latest version, if you select the Waypoint Manager prefab in your scene.
     
  39. chinchoppa

    chinchoppa

    Joined:
    Jul 1, 2015
    Posts:
    3
    Thankyou for fast respond
    iam using unity 5.1.1f
    and sws 5.03
    i cant type anything in the textbox on the waypoint manager... (following the Doc.pdf making start from the plane/terrain)
    maybe i should use the prefab instead of making new one maybe @@
    also in all the your example scene when itry to see the waypoint manager, it was blank textfield

    sorry for the long post
     

    Attached Files:

  40. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    SWS 5.0.3 is not the latest one. From the release notes:
     
  41. chinchoppa

    chinchoppa

    Joined:
    Jul 1, 2015
    Posts:
    3
    aww,,
    thanks dude
     
  42. josemauriciob

    josemauriciob

    Joined:
    Mar 5, 2009
    Posts:
    662
    sorry again for persist on my instantiate problem,
    now I have the scene: Example_PlayMaker.unity (imported)
    but this error appear.....(inmediatly import playmaker scene)

    erro ui2 g.jpg

    any idea ?

    my intention is not to embarrass someone, I need to solve my problem with this scene.
    again sincere apologies.
     
    Last edited: Oct 21, 2015
  43. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    You are asking the same question over and over again. This is the fifth time now. I will not repeat myself. Please, for the love of god, read my replies!
     
    Last edited: Oct 21, 2015
  44. josemauriciob

    josemauriciob

    Joined:
    Mar 5, 2009
    Posts:
    662
  45. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    Hello,

    I can't understand, how to reverse movement from existing position on the path to 1st waypoint?
    Method called randomly, so the exact object position can be between two waypoints.
     
  46. PrettyFlyGames

    PrettyFlyGames

    Joined:
    Aug 30, 2012
    Posts:
    74
  47. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    Do you actually mean reverse, or just restart? To restart from the beginning, call ResetToStart() and StartMove() on the movement script. Reversing is a different thing..

    @Dweebster
    Thanks for using it and linking your project! Good luck with the new approach :)
     
  48. MarcopoloR

    MarcopoloR

    Joined:
    Feb 4, 2015
    Posts:
    114
    Hi I have a weird problem. For some reason the waypoints started showing up in play mode where before they only showed up in scene mode. I do not want them to show up in play mode at the moment because I want to see how the scene will look while running without have a bunch of distracting waypoint circles and the lines connecting them in the way. I tried everything I can think of including resetting all my graphics settings, even tagging the waypoints as an invisible layer the waypoints dissappear but the connecting lines don't. It was working fine before, this just started happening for no apparent reason.
     
  49. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    Hi, you can enable/disable them in your Gizmo settings.

     
  50. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    Under word "reverse" I mean exactly reverse. I have explained what exactly do I mean.

    After hours spending on it, I found a dirty way, how to set it up
    1. Setting Event to the next bezier point
    2. pause by event
    3. In that event method calculate start point
    4. manually rotate the object
    5. Reverse beziermove and and set start point to current point where my character is
    6. Start movement
    That is quite complicated and did a lot of code for it... May be there is a faster and easier way?