Search Unity

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

Simple Waypoint System (SWS) - Move objects along paths

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

  1. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    40
    Hi Baroni, I think I'm close but I'm stuck on something. I don't think it's a problem with SWS, but maybe you'll see something obvious I'm missing. I tried different coordinate conversions and my sprite never comes on screen unless I specify (0,0,0).

    Creating the line:
    Code (CSharp):
    1. squiggle.points3.Add(Camera.main.ScreenToWorldPoint(touch.position));
    The rest:
    Code (CSharp):
    1. void moveTracker()
    2. {
    3.     // Create mover game object
    4.     Vector3 center = new Vector3(0, 0, 0);
    5.     GameObject mover = Instantiate(Thomas, squiggle.points3[0], Quaternion.identity); // Nowhere to be found
    6.     mover.transform.position = center; // Now at center screen
    7.  
    8.     //create path manager game object
    9.     GameObject newPath = new GameObject("Track");
    10.     PathManager path = newPath.AddComponent<PathManager>();
    11.  
    12.     //declare waypoint positions
    13.     Vector3[] positions = squiggle.points3.ToArray();
    14.     Transform[] waypoints = new Transform[positions.Length];
    15.  
    16.     //instantiate waypoints
    17.     for (int i = 0; i < positions.Length; i++)
    18.     {
    19.         GameObject newPoint = new GameObject("Waypoint " + i);
    20.         waypoints[i] = newPoint.transform;
    21.         waypoints[i].position = positions[i];
    22.     }
    23.  
    24.     //assign waypoints to path
    25.     path.Create(waypoints, true);
    26.  
    27.     //optional for visibility in the build
    28.     newPath.AddComponent<PathRenderer>();
    29.     newPath.GetComponent<LineRenderer>().material = new Material(Shader.Find("Sprites/Default"));
    30.  
    31.     // Start movement on the path
    32.     mover.GetComponent<splineMove>().SetPath(WaypointManager.Paths[path.name]);
    33.  
    34. }

    Thanks for looking!

    David
     
  2. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hey @dacoursey,

    your code looks fine to me! What's the position in squiggle.points3[0] when you instantiate the object? If that's the correct one, then it could also be that your sprite is there but the rotation is off by 90 degrees, so it's facing up and you can't see it?

    On a different note, one thing you can do (and probably did already) on the movement script is to set the pathMode to Sidescroller2D. The movement works though, correct?
     
  3. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    40
    No, my movement isn't working. I figured out it was the Z coordinate causing the mover to not show up. Here is the code now. When I get to the last line I get a null reference exception, but I can't figure out what is missing.

    Code (CSharp):
    1. void moveTracker()
    2. {
    3.     Debug.Log("############################## Moving Now ###################################");
    4.  
    5.     // Create mover object
    6.     Vector3 origin = new Vector3(0, 0, 0);
    7.     origin = squiggle.points3[0];
    8.     origin.z = 0;
    9.     GameObject mover = Instantiate(Thomas, origin, Quaternion.identity);
    10.     mover.name = "mover";
    11.  
    12.     //create path manager object
    13.     GameObject newPath = new GameObject("path");
    14.     PathManager path = newPath.AddComponent<PathManager>();
    15.  
    16.     //declare waypoint positions
    17.     Vector3[] positions = squiggle.points3.ToArray();
    18.     Transform[] waypoints = new Transform[positions.Length];
    19.  
    20.     //instantiate waypoints
    21.     for (int i = 0; i < positions.Length; i++)
    22.     {
    23.         GameObject newPoint = new GameObject("Waypoint " + i);
    24.         waypoints[i] = newPoint.transform;
    25.         waypoints[i].position = positions[i];
    26.     }
    27.  
    28.     //assign waypoints to path
    29.     path.Create(waypoints, true);
    30.     Debug.Log("############################## Path Created ###################################");
    31.  
    32.     // Start movement on the path
    33.     mover.GetComponent<splineMove>().SetPath(WaypointManager.Paths[path.name]);
    34.  
    35. }
     
  4. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    @dacoursey you are creating and accessing the path in the same frame. Paths add themselves to the WaypointManager.Paths dictionary in Awake(), but this is executed one frame later. So instead of calling SetPath(WaypointManager...) you would need to call SetPath(path) with the newly created PathManager component directly.
     
  5. tosvus

    tosvus

    Joined:
    Dec 27, 2016
    Posts:
    44
    Hi, I bought this and it looks really promising, but I have one problem. I would like to create a very simple traffic pattern with perpetually moving cars going in a long path (basically a closed loop path that zig-zags through all the streets. I would like to have it so I have set a car to a waypoint ahead of time, so when the game starts, car 1 starts at waypoint 1, car 2 starts at waypoint 2 and so on. Is this possible? I'm not terribly good at scripting.. Thanks!
     
  6. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi @tosvus, thanks for your purchase! Please have a look at the variables on the movement script, specifically the 'startPoint' variable.
     
    tosvus likes this.
  7. Unlimited_Energy

    Unlimited_Energy

    Joined:
    Jul 10, 2014
    Posts:
    469
    Hello,
    I have a bird that follows a bezier Path type from the ground to the air and all over the place. When he hits certain curves he will flip upside down on the curve. Is their a way to keep his y axis up all the time? I know you can lock the position on Y as a setting on the models spline move script but when this is activated there seems to be aseparatee White line connecting all the waypoints instead of yellow and its path is WAYYY different than with NONE selected for position lock. It seems the entire path system gets pushed to the ground much lower than the yellow line with this enabled.

    I just need to lock the Y position without the path changing..
     
  8. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hey @sunseeker1988, I guess you actually mean locking the rotation, not position. Locking the position will result in your path being flattened, while locking the rotation will just exclude one rotation axis. Please try locking the X axis, as done in the sample scenes for the 'Ethan' character. A note about the white/yellow lines: yellow lines are the lines drawn by the path logic as a preview, and white lines are the actual movement curves your object is following.
     
    Unlimited_Energy likes this.
  9. Unlimited_Energy

    Unlimited_Energy

    Joined:
    Jul 10, 2014
    Posts:
    469
    Thank you! Works great.
     
  10. Unlimited_Energy

    Unlimited_Energy

    Joined:
    Jul 10, 2014
    Posts:
    469
    I just realized this did not work now that I went back to it. When I do what you said my bird no longer follows the spline into the air. I have manually moved the waypoints into trees and on top of buildings for the bird. It travels this path correctly when no locking or rotational position are enabled except when it hits a certain waypoint in the air it seems to turn the model upside down on the path, this happens when the path does a fishhook in air. I tried rotating the waypoints to see if I could change the turn from flipping the model.

    When I lock the x axis it changes the white lines from following the exact layout of the yellow lines, to them being almost flat on the ground. None of the lines curve up into te sky or trees, they become flattened all on the same level.
     
  11. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    @sunseeker1988 did you set 'lockPosition' to 'None', and 'lockRotation' to 'X' like I said? If this still doesn't work out, you can also use the experimental waypoint rotation feature that allows for full manual control over the rotation. - I'm taking a nap now, it's 2 am here... ;)
     
  12. tolosaoldfan

    tolosaoldfan

    Joined:
    Sep 14, 2012
    Posts:
    92
    Hi,
    I just bought your product, and I wonder if it's possible to get ease behavior between waypoints.
    I saw that is possible to define an ease method for the whole path, but I need a way to accelerate just after the point A, decelerate until the point B. After the point B reached, new acceleration (always the same acceleration).
    Thanks
     
  13. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi @tolosaoldfan, thank you for your purchase! Unfortunately there is no easing for waypoint segments, due to the logic on how path tweens are being built - they are one (combined) chain of waypoints, not individual segments. If you would like to control the speed in-between waypoints, I would suggest using an event at these waypoints, which could start a coroutine that manipulates the speed over time using the movement script's ChangeSpeed method.
     
  14. Wambhse

    Wambhse

    Joined:
    Aug 11, 2015
    Posts:
    13
    Hey, I'm not sure what I am doing wrong here, but I am trying to use the GotoWayPoint function and the waypoint int value does not match up with waypoints on the path manager, and it seems to be giving me random values at runtime. Let me explain alittle. I have a Gameobject with a spline move script on it. The Path container field is connect to my Path Manager Script etc. I have 15 way points on my Path Manager. Now on My Spline Move script I am using the event system to send the gameobject to a different waypoint via the GotoWayPoint function. However when I do this, the int index I pass does not match up with the waypoint int value on the Path Manager. For an example i'll have the event call GoToWayPoint int value 0. But it doesn't go to waypoint 0 it will go to say waypoint 8, what's more is I'll have another event calling the GoToWayPoint on my spline move script, with say int index's like 2, 6, 9 and those will all go to random waypoints, some will even go to the same waypoint even though the GoTOWayPoint int index values are different. Like GoToWayPoint(0) GoToWayPoint(2) GoToWayPoint(5) and all three will go to waypoint 7. I can't seem to figure out how the GoToWayPoint is suppose to work. Can you please help me. Thanks
     
  15. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi @Wambhse, thanks for the explanation. The 'startPoint' functionality you can set on the movement script inspector uses GoToWaypoint internally, so that is proved to work correctly. Could you please send me a small repro project (with only the files needed) to our support email so I can take a look?
     
  16. vice39

    vice39

    Joined:
    Nov 11, 2016
    Posts:
    108
    Hey guys, I just bought and installed this in my project, and the "Start Path" button does nothing.

    I'm using Unity 5.5.2f1, the sample scenes load, I can see the splines and the walkers will move correctly. However I can't modify or add a spline. The "Start Path" button does nothing. No error, it doesn't turn into "Finish Editing" and press "p" on the keyboard does nothing.

    Please advise,
    Thanks!
     
  17. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hey @vice39, thank you for your purchase! Just to make sure, did you enter a path name before pressing 'Start Path'? Also it might be the most obvious thing to recommend, but did you close and restart Unity? Lastly if you have multiple scene views or inspectors opened at the same time, the editor could be confused about which view to use - in this case you could try switching to the default layout. Please report back if this helped.
     
  18. vice39

    vice39

    Joined:
    Nov 11, 2016
    Posts:
    108
    Yup, it was the pathname. Very silly of me to miss that, but an error msg would be nice :)
     
  19. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Actually it should throw a warning, maybe you have disabled those in the console? I'll recheck that.
     
  20. vice39

    vice39

    Joined:
    Nov 11, 2016
    Posts:
    108
    Yeah, warnings are disabled. Unity throws so many of them, and I have so many assets that throw endless warnings that warnings have become meaningless.
     
  21. Oshigawa

    Oshigawa

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

    i've got an idea i would like to implement using SWS, i was hoping you can help me out on this. I've got this small space shooter game going on and i'm trying to implement branching paths of the enemies instead of making a million single paths to imitate a sense of randomness.

    I thought of two approaches. The first one is currently not supported by SWS (as far as i know but would pose a better solution than the second one). Basically it would enable connecting multiple paths and selecting a random one on the connection points which at which would the event be fired.



    Or in Unity, it would be something like this



    The next approach would be possible to do with the current state of things since the paths would not be connected by any waypoints.



    The object would move along the Path 1 and when it reaches the end waypoint, event would be fired and the object would move to Waypoint 1 of Path 2 or Path 3. However, there are several problem i may encounter here.

    First, i would need to activate "set to path" on runtime for the object to move to the next path when it reaches the end waypoint of the current path. If i enable it after the object reaches the waypoint (after the set random path is activated) the object would have probably already "jumped" to the next paths first waypoint. If i activate it while the object is in transit to the current paths end waypoint i don't know what kind of behaviour i can expect. I can keep it always enabled, but some spawn points can be far from the first waypoint which can cause the delay in the planned wave tempo.

    The second one is the movement to the next path itself, it would be strictly linear which would look ugly after a smooth movement along the bezier path, especially if some easing was involved.

    Any ideas of a good solution to this? I'm using Playmaker btw, coding something like this is out of my current skill set.
     
  22. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    I thought of a third solution too.



    If i make Path 1 with an end waypoint one the EXACT same location as the start waypoint of Path 2 and Path 3 and fire a set random path event on the end waypoints that would pose a workaround. However, i'm worried about how fast (i'm sure the code itself IS fast) will the new path be set upon activating the event, stopping and continuing via new path might be visible even if only occurs on one frame.

    For further branching, Paths 4, 5, 6, 7 can't have multiple waypoint 1 locations, so new paths would need to be made, so that would be total of 11 paths for this simple branch. Something simpler would be useful :D
     
  23. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Ah, the troubles, i can't simply copy/paste transform values since the waypoint 0 position always displays a LOCAL position, not world.

    Even if i get the first paths last waypoint world position by custom script, it doesn't mean a lot, when i copy it to the next paths object transform, they don't match. I might need a bit of a precision in the debug script, debug.log only shows one decimal place argh.



    Edit: Ok, the position stuff is sorted out, the waypoints are now matching, i'll check how the things work a bit later, i'm on teamviewer, can't really see if there's going to be any jerking when switching paths due to low frame rate.

    Still like to hear proposition on how to make thing simpler though!
     
    Last edited: May 17, 2017
  24. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hey @Kruko, thanks a lot for the screenshots! Those were really helpful in understanding what you are trying to do.

    Although a bit of a manual effort, branching is actually possible in SWS. For example, if you are leaving path1-waypoint2 and would like to continue on path2-waypoint4, you would set the 'startPoint' variable on the movement script to 3 and call SetPath() by passing in path2. This implies that you already know the starting point values on the following paths. The object will start at that point on the new path. If your end/start waypoints are not located exactly on the same position, you can also set 'moveToPath' to true before calling SetPath(). I'm not sure if you have looked into that concept already, but it seems you have excluded it from being possible in solution one?

    Switching paths indeed might be visible for one frame, as the movement code needs "a break" to initialize a new tween before being able to run it.
     
  25. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Ok, i'll check out that solution and let you know (as soon as i get over flu :confused:)
     
  26. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    @Baroni

    Hello,

    just wanted to let you know the approach number 3 work flawlessly, there are no visible hiccups when changing paths during runtime. I hope this is going to help someone too, it's really simple once you get it going and actually easier to make complicated bezier path that will have a good shape when you break them into smaller sections.

    Cheers!
     
    Baroni likes this.
  27. onesoftfalcon

    onesoftfalcon

    Joined:
    Oct 4, 2016
    Posts:
    2
    Hi,
    How can i moving the path while player moving in path? When i add simple script to path:
    // in update function
    transform.position += new Vector3(0,-1,0) * Time.deltaTime;

    The path moving down but the player still move by path at start. I want player move by path and path is moving. How can i do that?
    Thank so much!
     
  28. onesoftfalcon

    onesoftfalcon

    Joined:
    Oct 4, 2016
    Posts:
    2
  29. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hey @onesoft8bit,

    glad you found a description on how do it! Just so you know, there is a sample included in the "Advanced" example scene, look out for the "Local" sample (a rotating path with an object moving on it).
     
  30. mohfarhan90

    mohfarhan90

    Joined:
    Jun 14, 2017
    Posts:
    1
    Hi,

    I am using SWS in a racing game for opponents, but their movement is not smooth and they jerk successively. Is there problem in SWS or in something other?

    Any help will be appreciated.

    Thanks in advance
     
  31. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi @mohfarhan90,

    every project is different - it is not possible for me to answer your question without seeing what you are doing. Maybe you have rigidbodies attached to the moving objects which interferes with the movement script? Maybe some debug logs eating performance of the game, or something completely different.

    Have you tried opening the example scenes and did you experience any stutter there? If they don't stutter and you can't figure out why, you can always send a small project that reproduces your issue to our support email.
     
    mohfarhan90 likes this.
  32. janvetulani3r

    janvetulani3r

    Joined:
    Feb 8, 2017
    Posts:
    12
    Hi!
    Is it possible to move the Events from the Spline Move script to the each individual path under the Waypoint manager?
    I need to have multiple paths I switch between, and I need events to fire at the end (or at certain positions on each path), and I'd rather to be able to set them up individually per path.

    Thanks!
     
  33. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi @janvetulani3r,

    currently you cannot assign events to the PathManager component (except if you add this yourself). However you can place a trigger on any point in the game that calls your custom method. Please see the events example scene for a sample, specifically the "character hits wall and flies in the air" sample in there.
     
  34. Oshigawa

    Oshigawa

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

    a while ago i had a question about branching paths, and in the end i decided to do it by making multiple paths with different paths' first and last waypoints matching positions, so when the enemy gets on the last waypoint of a path, event triggers that sets random path. Here's how it looks like with Playmaker, simple actually.



    Unfortunately, all of that works when the object is already in the scene. But when it is spawned, it obviously refers to the prefab FSM receiver, not the instantiated copy FSM receiver, the way Unity works, of course.

    One guy had the same question a while ago on your website forum: https://www.rebound-games.com/forum/index.php?topic=304.0

    His action is really cool and does the job, any chance of including it or modifying your action to make it work on instantiated prefabs?
     
    Last edited: Jun 25, 2017
  35. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    @Baroni

    Another question. i'm having two paths connected by a waypoint on the same coordinates, like described above. Ship choses a random path and starts moving on it, but when it reaches waypoint 1, it disappears. Now, all the prefabs despawn when they are not visible anymore, so i checked if Z coordinates of the waypoints are ok, but everything's fine.

    I'm using Catmull Rom with Path Mode Ignore on Bezier curves, if it matters.

    Any ideas what i should check next?

     
  36. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Ah, after half of day of banging head i got it. On every waypoint 1 of every path select random path event activates, i was able to disable the unwanted behaviour by disabling the FSM when the enemy reaches the waypoint of the first branch, but that disables me from further branching. Since that event is in a completely different state that doesn't run, i can only imagine that it adds an event to all waypoints 1 of every path it moves on.

    Also, it seems that other instantiated prefabs besides the owner are affected, as if the event is added to all the prefabs following the path, not just the one that adds it. Does that makes sense?
     
    Last edited: Jun 26, 2017
  37. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Here's a short image for clarification of the problem, red line is the first path, blue line is second.

    1.) I've got one prefab spawning, moving over red path and adding an event to waypoint 1. Upon reaching waypoint 1, event is triggered, and random path is selected via set path random action. Prefab continues moving via blue path. But it simply disappears when it reaches the waypoint 1 of the blue path (instead of continuing towards waypoint 2). By disabling the FSM that controls the add event/set path random after the object reaches waypoint 1 of the red path and starts moving on the blue path i eliminated the problem and prefab goes all the way to waypoint 2 (end waypoint).

    By debugging, i've seen that the set path random is also activated on the blue paths waypoint 1, which shouldn't be the case, since the first path set was the red one. This is problematic since turning of the FSM removes the possibility of further branching.

    2.) The other problem is really strange. I had the first ship do its stuff like in the problem number one, spawns, sets red path, moves along the path, on waypoint 1 sets random path, disables the FSM and moves on to waypoint 1 of the blue path where it ends it's journey. But take a look at the NEXT ship going on the red path:



    It enters the screen following the red path, passes the waypoint 1, but then jerks back to it and then fires the set path random action and starts moving on the blue path.

    I used that guys' add event at waypoint fix instead of default add event at waypoint action since it's not possible to target instantiated FSM in your action. Regardless of that, walker object is set to use owner and event target is set to self (in the fix action).
     
    Last edited: Jun 26, 2017
  38. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi Kruko, wow, a lot of posts to go through ;)

    I'm not that familiar with how PlayMaker works, but I can't imagine that it is not possible to assign a different owner to a PlayMaker action at runtime? So you are using the modified action from the forums now, or do you need further help on this?

    If you add an event, it is added to the movement script, not the path. Events on movement scripts are being preserved even when switching paths (except the waypoint does not exist anymore on the new path). If you wish to do this once only, you would need to clear the events list before switching to a different path.

    I'm not sure this is how it works - even without PlayMaker, assigning something to an instance does not manipulate other instances. Only when the prefab is being manipulated the other instances are modified too. Again, this must be something other users more familiar with PlayMaker (or on the PlayMaker forums) should be able to answer.

    I hope I've clarified that above, that an event added to the movement script is not being cleared automatically.

    That sounds like the "prefab modification" issue above, where multiple instances are being modified? It's really hard for me to figure out what you are doing in your project and actions, but even if I would have the project, I'm not that into PlayMaker to investigate this properly. Maybe my explanations above helped a bit already, and if they didn't, could you please try to get clarifications on the PlayMaker forums instead and send me a project that reproduces this as a last resort? Thanks!
     
  39. Oshigawa

    Oshigawa

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

    Thanks for the help, it set my mind in the right direction. I wasn't aware that the event is added to the movement script, not the path, very useful information. If i have multiple branches, i'll simply remove the event upon reaching the first branch waypoint and then add event to the next waypoint, no need for shutting down complete FSM.

    As for the jerk in the gif i provided, i made a stupid mistake. I copied and pasted the FSM from another prefab, but forgot to change the path values when setting random path, so it actually takes one path and upon reaching the waypoint returns to other path. So, everything works fine, and everything is clarified, thanks again!
     
    Baroni likes this.
  40. jricardomiguel

    jricardomiguel

    Joined:
    Feb 10, 2017
    Posts:
    27
    Hello, I have very doubts @Baroni. You do not have any video tutorial on how I can use the features? I just managed to make a cube (or character) walk on the line that I set ... How do I get the cube to walk randomly or looped?

    Thanks!
     
  41. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi @jricardomiguel, we have a very simple video tutorial for getting you started here. What you are asking regarding walking randomly or looped are settings on the movement script, which you can set right in the inspector. Both of them can be set via the loop type. I would suggest having a deeper look at the inspector values to get more familiar with them.
     
  42. Grafos

    Grafos

    Joined:
    Aug 30, 2011
    Posts:
    231
    Hi, I was wondering if there's a way to ease in and out speed when reaching a waypoint? I have a camera following a path, stopping in a few waypoints, but using a pause event for a few seconds stops and starts it abruptly
     
  43. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi @Grafos, you can either define your custom animation curve for the path that slows down on certain spots (select ease type = custom in the inspector), or trigger an event along the path that calls ChangeSpeed on the movement script with an increasingly smaller value in a coroutine to slow it down over time.
     
  44. Justin-Wasilenko

    Justin-Wasilenko

    Joined:
    Mar 10, 2015
    Posts:
    103
    Having a problem where I create my object move it along a straight line and then I want it to be taken over by SWS and set on it's path.

    I created a video showing the problem:


    The gameobject when coming to the path, doesn't just start at waypoint 1, it gets there, comes back a little bit and then heads in the right direction towards waypoint 2.

    Also when trying to create a new path in my project I get the following error as soon as I push P:
    Code (CSharp):
    1. [Exception] NullReferenceException: Object reference not set to an instance of an object
    2. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    3. WaypointEditor.OnSceneGUI()    Assets/SWS/Scripts/Editor/WaypointEditor.cs:62
    4. 61:   }
    5. -->62:   else if (Event.current.keyCode == script.placementKey)
    6. 63:   {
    7. 64:       //cast a ray against mouse position
    8.  
    9. MonoMethod.Invoke()    /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222
    10.  
    11. MonoMethod.Invoke()    /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232
    12.  
    13. MethodBase.Invoke()    /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115
    14.  
    15. UnityEditor.SceneView.CallOnSceneGUI()    C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:2392
    16.  
    17. UnityEditor.SceneView.HandleSelectionAndOnSceneGUI()    C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1721
    18.  
    19. UnityEditor.SceneView.OnGUI()    C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1553
    20.  
    21. MonoMethod.Invoke()    /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222
    22.  
    I have been having to duplicate old paths I created before to get around that issue.
     
  45. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    @Justin-Wasilenko the first issue could be due to floating point imprecision. That occurs more often, if your object is located at a position above 150 +- at any axis. Is this the case?

    Never saw that second error before, what version of SWS and Unity are you running? Any special steps to reproduce this is in a new project?
     
  46. Justin-Wasilenko

    Justin-Wasilenko

    Joined:
    Mar 10, 2015
    Posts:
    103
    Yes that is the case, I am using world re-basing and this occurs when the object is 15000 units from zero. I haven't tested closer to zero but that isn't possible. Space games are unfortunately rather larger....

    Error only occurs in my project. I tried SWS in a new project and it works fine. Using Unity 5.6.2p1.

    Update: Just tried position everything around world zero and that does indeed solve the problem. However that leaves me without a solution since the player has to be at zero, and the objects have to be very far in the distance...
     
    Last edited: Jul 20, 2017
  47. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Maybe something related to your scene views or layout, would be nice if you get any additional information on that.

    Thanks for the confirmation. I've brought this up with Daniele (developer of DOTween) some time ago, but we couldn't figure out a way to solve this, since Unity just adds some very minor offset to the desired Vector3 position due to the floating point issue mentioned. This results in DOTween adding a new waypoint at the current position (which it shouldn't), because it thinks the difference of 0.000x makes it a new starting point. Maybe a solution would be to let DOTween ignore more than 3 decimals for creating waypoint positions... Simple Waypoint Systems only uses these generated positions for its path movement, so technically I cannot implement a fix on my side.

    Could you please post this issue on DOTween's github page, or contact its developer directly (all links found here, at the bottom). Please also keep me updated about the progress on this.
     
  48. Justin-Wasilenko

    Justin-Wasilenko

    Joined:
    Mar 10, 2015
    Posts:
    103
    Submitted the issue at: https://github.com/Demigiant/dotween/issues/143

    Thanks for your responses!
     
  49. CDUnityDev

    CDUnityDev

    Joined:
    Jan 31, 2017
    Posts:
    25
    Hey, I'm having trouble getting my Mecanim character working with SWS. In the example scenes, there's just an animator controller on the character. My component setup currently looks like this:


    And in game, my character slides down the path in T-pose unless a key that would normally trigger an animation is pressed. How does SWS know which animations to play as the character moves through the spline?

    Edit: Got it working, was missing the Move Script - excellent asset BTW
     
    Last edited: Jul 25, 2017
    Baroni likes this.
  50. Justin-Wasilenko

    Justin-Wasilenko

    Joined:
    Mar 10, 2015
    Posts:
    103