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

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Yes, I thought it would have something to do with the component order.
    Are you sure that waypoints.Length is not null? The waypoint array is set during StartMove(), but your code does not tell the object to start moving, so waypoints.Length is still null. That means now you have the choice between:
    1. declare "waypoints" as public and set them in your script too (see StartMove())
    2. call StartMove() before receiving MessageOptions, which sets the waypoint array
    3. call SetPath(PathManager) to automatically start moving (StartMove()) of your object, then get MessageOptions
     
  2. matrix211v1

    matrix211v1

    Joined:
    Jan 20, 2009
    Posts:
    193
    #2 Seems to work for me, thanks for your help!
     
  3. DirkTheDaring

    DirkTheDaring

    Joined:
    Dec 21, 2012
    Posts:
    5
    bought this, love it... now. I know with I tween I can control forward progression from one point to another by pressing a key such as uparrow. Since I'm using the waypoint system on my car... is there any way I can make the car move along the path but only when I press the uparrow?
    By the way, for the money... this utility is a MUST HAVE for Unity3D
     
  4. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi Dirk,

    thank you for your purchase!

    With iTween you would likely use its PutOnPath() method, which puts a GameObject on a path at the provided percentage (from the documentation). There's a demonstration of this method in the scene "Example_Runtime". PutOnPath() does not use the automated movement of iMove or hoMove and instead controls the object based on user input.

    If you want to use HOTween for movement based on user input, I suggest you look up its GoTo() method which basically does the same. If the car should accelerate or slow down smoothly, you would have to manipulate GoTo's value over time accordingly. That would be a separate script and has nothing in common with iMove or hoMove. Let me know if you need further help.

    Thanks again :)
     
  5. DirkTheDaring

    DirkTheDaring

    Joined:
    Dec 21, 2012
    Posts:
    5
    how would I use HOtween? am i able to hire you to write a script that would do this using the ho move script selection through your interface? then i have it and dont ever have to bother people again.
     
    Last edited: Dec 21, 2012
  6. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    hoMove uses HOTween as tweening library. HOTween is a standalone library, written by Daniele ("Izitmee" on the forums). It's simply awesome! The documentation is located on his website.

    As I mentioned, hoMove automatically moves your object. It's my own implementation and has nothing to do with user input. You would have to write a new script which moves the object based on user input. I could do that for you within the next days, our special promotion consumes a lot of time lately. Please send me a private message or email us at info[at]rebound-games.com for further details if you're interested.
     
  7. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Just purchased your system on the asset store, but having a bit of difficulty getting started with creating waypoints using unity 4 (indie).

    I followed the included PDF instructions and got the manager object into my scene, then I enter a name for a path, and hit the button in the inspector to start creating waypoints, and I see in "hints" on the inspector - should be done with "alt-left click" - im assuming must be in the scene view...

    Well as I hold alt, my camera pans about, and left clicking has no effect. I hope I haven't missed something obvious!

    But for now to get around this problem, I just made a prefab of one of the example scene's curved paths, and then opened my scene, created a manager, and dropped that prefab on top of the manager, thus allowing me to edit the path with the inspector...but I hope you can clue me in as to why thats happening? Do I need to un-assign the pan for the camera or something?

    Thanks for the great system, been looking at many options, tried an approach of my own, but yours seems to really be point on - as long as I can get that part working anyway haha.

    EDIT:
    Even with that sort of dissapointing bit, I have integrated this into my project in roughly a couple hours. I am so super impressed like seriously - you have a pretty solid tool aside from that part bugging me. The included examples had me ready to get my AI drivers following waypoints and with much smoother smooth curves instead of jerky ones - which is great! I bet I can make some awesome stuff with this tool and the handy features that come with the 'tween's
     
    Last edited: Dec 23, 2012
  8. javanoob

    javanoob

    Joined:
    Aug 15, 2012
    Posts:
    64
    Hi just bought this little gem ,can anyone one tell me if it can do one simple thing please:) Get an AI car (not on spline) to just follow say 10 waypoints in a row ,but driving itself ? (not rigidly fixed path) :) Merry Christmas ,this was my gift to my self :p
     
  9. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    to do that, depends on what exactly you already have, like is your car physical? just a model? and so on...

    but there is an example included that has a car thats in the curved scene. Maybe since I told you that, you can tell me if your able to alt left click and place waypoints? and also if you use unity 4...
     
  10. javanoob

    javanoob

    Joined:
    Aug 15, 2012
    Posts:
    64
    hey there im using the unity car tutorial car setup ,tweaked a lot lol , and I was trying to use Andrew Gotows checkpoint script the cars follow the markers using engines and physics . not on spline paths ,the only issue I have with that great script is it works perfectly on windows builds but has some error on Android build so I thought I would buy this little beauty and hope it can do the same thing ,ps heres the script and error from Andrew Gotows tutorial ..

    the error I get is

    Assets/Scripts/Car Control/AICar_Script.js(98,36): BCE0019: 'position' is not a member of 'Object'.

    Basically if SWS wont drive the car around the waypoints then a #pragma strict (I guess) fix would make the script above do just that :) sooo close ,it works on Windows but not Android :( ,Any ideas anyone ?






    // ----------- CAR TUTORIAL SAMPLE PROJECT, ? Andrew Gotow 2009 -----------------

    // Here's the basic AI driven car script described in my tutorial at www.gotow.net/andrew/blog.
    // A Complete explaination of how this script works can be found at the link above, along
    // with detailed instructions on how to write one of your own, and tips on what values to
    // assign to the script variables for it to work well for your application.

    // Contact me at Maxwelldoggums@Gmail.com for more information.



    // These variables allow the script to power the wheels of the car.
    var FrontLeftWheel : WheelCollider;
    var FrontRightWheel : WheelCollider;

    // These variables are for the gears, the array is the list of ratios. The script
    // uses the defined gear ratios to determine how much torque to apply to the wheels.
    var GearRatio : float[];
    var CurrentGear : int = 0;

    // These variables are just for applying torque to the wheels and shifting gears.
    // using the defined Max and Min Engine RPM, the script can determine what gear the
    // car needs to be in.
    var EngineTorque : float = 600.0;
    var MaxEngineRPM : float = 3000.0;
    var MinEngineRPM : float = 1000.0;
    private var EngineRPM : float = 0.0;

    // Here's all the variables for the AI, the waypoints are determined in the "GetWaypoints" function.
    // the waypoint container is used to search for all the waypoints in the scene, and the current
    // waypoint is used to determine which waypoint in the array the car is aiming for.
    var waypointContainer : GameObject;
    private var waypoints : Array;
    private var currentWaypoint : int = 0;

    // input steer and input torque are the values substituted out for the player input. The
    // "NavigateTowardsWaypoint" function determines values to use for these variables to move the car
    // in the desired direction.
    private var inputSteer : float = 0.0;
    private var inputTorque : float = 0.0;

    function Start () {
    // I usually alter the center of mass to make the car more stable. I'ts less likely to flip this way.
    rigidbody.centerOfMass.y = -1.5;

    // Call the function to determine the array of waypoints. This sets up the array of points by finding
    // transform components inside of a source container.
    GetWaypoints();
    }

    function Update () {

    // This is to limith the maximum speed of the car, adjusting the drag probably isn't the best way of doing it,
    // but it's easy, and it doesn't interfere with the physics processing.
    rigidbody.drag = rigidbody.velocity.magnitude / 250;

    // Call the funtion to determine the desired input values for the car. This essentially steers and
    // applies gas to the engine.
    NavigateTowardsWaypoint();

    // Compute the engine RPM based on the average RPM of the two wheels, then call the shift gear function
    EngineRPM = (FrontLeftWheel.rpm + FrontRightWheel.rpm)/2 * GearRatio[CurrentGear];
    ShiftGears();

    // set the audio pitch to the percentage of RPM to the maximum RPM plus one, this makes the sound play
    // up to twice it's pitch, where it will suddenly drop when it switches gears.
    audio.pitch = Mathf.Abs(EngineRPM / MaxEngineRPM) + 1.0 ;
    // this line is just to ensure that the pitch does not reach a value higher than is desired.
    if ( audio.pitch > 2.0 ) {
    audio.pitch = 2.0;
    }

    // finally, apply the values to the wheels. The torque applied is divided by the current gear, and
    // multiplied by the calculated AI input variable.
    FrontLeftWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * inputTorque;
    FrontRightWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * inputTorque;

    // the steer angle is an arbitrary value multiplied by the calculated AI input.
    FrontLeftWheel.steerAngle = 10 * inputSteer;
    FrontRightWheel.steerAngle = 10 * inputSteer;
    }

    function ShiftGears() {
    // this funciton shifts the gears of the vehcile, it loops through all the gears, checking which will make
    // the engine RPM fall within the desired range. The gear is then set to this "appropriate" value.
    if ( EngineRPM >= MaxEngineRPM ) {
    var AppropriateGear : int = CurrentGear;

    for ( var i = 0; i < GearRatio.length; i ++ ) {
    if ( FrontLeftWheel.rpm * GearRatio < MaxEngineRPM ) {
    AppropriateGear = i;
    break;
    }
    }

    CurrentGear = AppropriateGear;
    }

    if ( EngineRPM <= MinEngineRPM ) {
    AppropriateGear = CurrentGear;

    for ( var j = GearRatio.length-1; j >= 0; j -- ) {
    if ( FrontLeftWheel.rpm * GearRatio[j] > MinEngineRPM ) {
    AppropriateGear = j;
    break;
    }
    }

    CurrentGear = AppropriateGear;
    }
    }

    function GetWaypoints () {
    // Now, this function basically takes the container object for the waypoints, then finds all of the transforms in it,
    // once it has the transforms, it checks to make sure it's not the container, and adds them to the array of waypoints.
    var potentialWaypoints : Array = waypointContainer.GetComponentsInChildren( Transform );
    waypoints = new Array();

    for ( var potentialWaypoint : Transform in potentialWaypoints ) {
    if ( potentialWaypoint != waypointContainer.transform ) {
    waypoints[ waypoints.length ] = potentialWaypoint;
    }
    }
    }


    Transform wp = waypoints[currentWaypoint] as Transform;


    function NavigateTowardsWaypoint () {
    // now we just find the relative position of the waypoint from the car transform,
    // that way we can determine how far to the left and right the waypoint is.
    Vector3 RelativeWaypointPosition = transform.InverseTransformPoint( new Vector3( waypoints[currentWaypoint].position.x, transform.position.y, waypoints[currentWaypoint].position.z ) );


    // by dividing the horizontal position by the magnitude, we get a decimal percentage of the turn angle that we can use to drive the wheels
    inputSteer = RelativeWaypointPosition.x / RelativeWaypointPosition.magnitude;

    // now we do the same for torque, but make sure that it doesn't apply any engine torque when going around a sharp turn...
    if ( Mathf.Abs( inputSteer ) < 0.5 ) {
    inputTorque = RelativeWaypointPosition.z / RelativeWaypointPosition.magnitude - Mathf.Abs( inputSteer );
    }else{
    inputTorque = 0.0;
    }

    // this just checks if the car's position is near enough to a waypoint to count as passing it, if it is, then change the target waypoint to the
    // next in the list.
    if ( RelativeWaypointPosition.magnitude < 20 ) {
    currentWaypoint ++;

    if ( currentWaypoint >= waypoints.length ) {
    currentWaypoint = 0;
    }
    }

    }


    This is the error ?

    Assets/Scripts/Car Control/AICar_Script.js(98,36): BCE0019: 'position' is not a member of 'Object'.


    im on latest Unity3 btw ,and which bit did you mean about clivking objects please ?
     
    Last edited: Dec 23, 2012
  11. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    its strange, I am doing something quite similar - using the unity ALT physics system tutorial, to make AI drivers drive around a city :D

    Anyway, im on unity4, and when I make a new path, using the manager, I cant hold the alt key, and left click in the scene to create waypoints - and I thought thats how you make them from scratch.

    Umm I could give you some ideas, since I am doing something so similar - let me re-read your problem and see if I understand your problem.

    EDIT: ok read over your problem, I have no ideas for ya as far as that goes - I made my own simple waypoints prior to buying this package - which were pretty basic, just a gizmo drawn where a empty gameobject is, and I would lead my AI to those by adjusting the steering based on the angle to the waypoints, and the speed based on if it was a sharp turn. then I tried building out to android, and although it lagged a bit (not optimised whatsoever, non-mobile skybox, tons of things wrong) it did run on my droid RAZR - so I dont doubt that this system would work with no problems whatsoever! but that also depends if you use it like I do, I have a guide object moving around between its waypoints, and this lets me make it sort of move along the splines, but it is truley just following the guide object, which is following the splines! I am experimenting with this as a viable traffic system setup, but its only in its early stages right now - wish I knew more to tell you, but give me some months and this system may be more fleshed out, and I would be able to steer you better in the right direction no pun intended lol
     
    Last edited: Dec 23, 2012
  12. javanoob

    javanoob

    Joined:
    Aug 15, 2012
    Posts:
    64
    Sounds cool ! ,I have the waypoint thing working in windows builds but as soon as I switch platform to Android I get the error . so im kinda stuck for a waypoint script ( Hence I bought SWS ) ,but I have a feeling it isn't gonna do what I want hence I ask about the script above .I am still flapping in the water when it comes to programming and I have tried loads to fix this error but I think I need a pragma strict guy on it :)

    Feel kinda stupid now blowing ten dollars on something that didnt do what I hoped ,ah well such is life I guess .
    Im not trashing SWS :p I just want a car to go fom waypoint to waypoint using its own physics engine like the above script ,I have been trying this for six months and not getting anywhere thats why I bought SWS ,Im off to buy easyroads now to see if that has a waypoint system ,the wife can only kill me once I guess .......
     
    Last edited: Dec 23, 2012
  13. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi MD_Reptile,

    thank you very much for your kind words! I'm glad to see that SWS is helping you with the AI drivers :)

    Now for creating waypoints, pressing alt and clicking in the scene view is really all you have to do. Besides of having a background object in the scene to click on. You can also modify the key for placing waypoints in the WaypointEditor script, see this post.
     
  14. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi java,

    well if you want to move a car from waypoint to waypoint using its own physics engine, then a tweening engine (SWS) can't help you with that. Basically a tween is an animation from one point to another, so it has to be a fixed path. What you can do with SWS is to create a path and let your car follow it. You can also reposition the waypoints each round through script to simulate a different path. But it's not an AI package (thus being in the animation section of the Asset Store) and does not find new paths for your cars once they left the track or collided with something. Sorry that I can't help you with your script as it's not related to SWS... maybe the scripting or support section would be a better place to ask.
     
  15. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    I'll try changing which keys create new nodes. Like i said i got around it by using a prefab of one of the example paths, and editing existing nodes. Still speeds up my work flow a lot. I've got physics based ai drivers following a guide object, and that guide object followed the paths. The guide object must only wait for the ai to catch up. Easy to implement with pause () ... Great tool it really is.
     
  16. javanoob

    javanoob

    Joined:
    Aug 15, 2012
    Posts:
    64
    Lol ,stiill glad I bought it Baroni ,it will make another million things so much easier :)
    If I sounded ungrateful I apologise :( ,Your software is wonderful and will really make life so much easier for me :)

    I was hoping to get the AI script thing fixed too,but as I say I love your software and have been playing all morning its 10/10 and sooo good value at $10 ,thanks :)
     
    Last edited: Dec 23, 2012
  17. javanoob

    javanoob

    Joined:
    Aug 15, 2012
    Posts:
    64
    Got it working :) now I can really relax Merry Christmas SWS users and thanks Big Fella for making this its sweet :) like I said 10/10 :)
     
  18. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hehe, congratulations! Sometimes even I don't know what SWS is capable of :) Merry christmas!
     
  19. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Really the one thing that sold me more than anything else, is the "adding waypoints between existing ones" feature, because I had been doing this by hand for the longest time (drop in prefab, connect it up to local nodes...really frustratingly tedious when you have a whole city to drop in waypoints for...), and had tried writing similar tools of my own to do it, but had not come close to the seamless-ness of SWS, where I can just highlight a path, and then visibly see the numbered nodes, and add anywhere in between I need, while keeping the naming convention and such - I have to say this is certainly one of the best tools I have ever aquired for unity (and the ONLY paid tool so far!), and being so simple, its really great at what it does, and there will be a very satisfied customer writing a review here soon! Merry Christmas to you Baroni!

    EDIT: Hmmm tried following that post about changing the key to allow you to place waypoints, with this exact line from your post:

    and that does not do anything either :( Have you tried this on unity 4? Both the default alt-left click and this P key one do nothing for me - perhaps this only happens to unity 4?

    When I did the alt left click, it shows the "eye" symbol where the "grab" symbol would usually be, and its highlighted, which allows me to orbit the view in the scene. As far as I knew, this same thing happens in unity 3, I'll load up unity 3 and test this out there - just to make sure it works for me there - but Baroni you should test this out on a install of Unity4 and see what happens for you. Maybe I am doing it wrong still!

    EDIT 2: tried unity 3, tried the new update (as of 24th of dec) and neither worked :/ I'll wait for you to let me know whats up!
     
    Last edited: Dec 24, 2012
  20. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    I really appreciate that you have taken the time to write down your experience with SWS so far. Valuable feedback, thank you!

    Still, I'm sorry that some odd things are going on for you when creating paths. Have you tried creating a path in one of the included example scenes? Does your background / surface object has a collider attached to work with?

    None of the other users had noticed difficulties with Unity4, I nearly did a full check before submitting it a few weeks ago. As suggested by you, I created a new Unity4 project minutes ago, imported SWS from the Asset Store and created paths just fine. You're right that pressing "alt" shows the eye symbol, but you can't orbit while placing waypoints (on Windows). So it finally comes to the points I mentioned above, or your project or SWS import is somehow broken. That would be very odd, because you tried it in both Unity 3 and 4.

    Edit: Important instructions from the documentation:
    1. Select the Waypoint Manager object.
    2. Enter a name in the "Path Name" field and click on "Start Path".
    3. Press alt and click on objects with colliders in the scene view. Don't select them though.
    4. Finish the path by clicking "Finish Editing".

    If you can't get it running in minutes, please send me your project for investigation. I'll do some overtime for you. Merry christmas to you as well :)
     
    Last edited: Dec 24, 2012
  21. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    You know what - works no problem at all in the example scenes! I must have some things happening in my scene which are conflicting with SWS - Thanks for helping me get to the bottom of this! If I figure out whats doing this in the scene I am in, I will be sure to let you know why it happened incase others have this problem. Oh and when I was testing the creation of points in the examples, very good! I really like this system, its proved to be worth every penny!
     
  22. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Please can someone tell me if it works with Unity 4? thanks
     
  23. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    847
    I upgraded a project to Unity 4 that uses SWS and had no problems whatsoever. I guess starting one from scratch should work fine, too.
     
  24. Dauntless

    Dauntless

    Joined:
    Nov 21, 2012
    Posts:
    16
    Hey Baroni, I love SWS. Just wondering if anyone could help me with one thing. I need to slow down the speed of my creature once it enters a trigger. I have SWS on a creature following a path. I have a turret that I would like to slow down the creatures speed once it enters its trigger area. The trigger script is in javascript so I moved SWS into the Standard Assets folder so they can interact with each other. The speed value goes down in the inspector but the creature does not slow down. Any help is greatly appreciated! Thanks

    hoMove.cs

    //added
    public void SlowSpeed(float slowEnemy)
    {

    speed = speed - slowEnemy;

    }



    Turret.js

    var slowEnemy : float;

    function OnTriggerEnter(other : Collider)
    {
    if(other.gameObject.tag == "Ground_Enemy")
    {
    other.gameObject.SendMessage("SlowSpeed", slowEnemy, SendMessageOptions.DontRequireReceiver);
    }
    }
     
    Last edited: Dec 29, 2012
  25. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi Dauntless,

    thank you!

    Since 2.1.2, there's a new method called "ChangeSpeed" in both movement scripts, which you can use via SendMessage for slowing down the objects. I suggest you update to the newest version and look up this method in the documentation.


    Edit:
    Last two days of the sale!
    Don't miss out on a 30% rebate if you are interested in one of our products.
     
    Last edited: Dec 29, 2012
  26. Dauntless

    Dauntless

    Joined:
    Nov 21, 2012
    Posts:
    16
    Thank you Sir! :)
     
  27. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Continue to get this error running Unity 3.5.7.

    NullReferenceException: Object reference not set to an instance of an object
    iMove.PlayWalk () (at Assets/SWS/Scripts/Movement/iMove.cs:437)
    iMove.Move (Int32 point) (at Assets/SWS/Scripts/Movement/iMove.cs:195)
    iMove+<NextWaypoint>c__Iterator8.MoveNext () (at Assets/SWS/Scripts/Movement/iMove.cs:326)
    UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
    iTween:CallBack(String) (at Assets/SWS/Scripts/PixelPlacement/iTween.cs:7051)
    iTween:TweenComplete() (at Assets/SWS/Scripts/PixelPlacement/iTween.cs:4652)
    iTween:Update() (at Assets/SWS/Scripts/PixelPlacement/iTween.cs:6565)
    the lie in question in iMove.cs line num 437

    anim.Play(walkAnim.name);


    I followed the instructions pretty well I think. I also had this working well last year but now since upgrade not working. Is this a known issue or my bad?

    I see it counting the way points as it runs but my animation doesn't move.

    Thanks and great package btw!
     
    Last edited: Jan 3, 2013
  28. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi jococo,

    well it seems that iMove can't find either the animation component or the animation clip.
    iMove searches for the animation component in the children of the gameobject it is attached to. Does one of the children actually have an animation component with the walk clip assigned to it? Don't know why the upgrade should break that.
     
  29. Jesse_Pixelsmith

    Jesse_Pixelsmith

    Joined:
    Nov 22, 2009
    Posts:
    296
    Oops, looks like I missed the sale! Oh well. Would there be any issues using this in conjunction with A*?

    What I'm thinking is having my AI follow SWS waypoints in an unalerted state, then if they detect the player, they switch to an alerted state and switch to A* dynamic pathfinding to track down and attack.

    Just curious if anyone else has done this. I like the simplicity of SWS and I dont think A* has a built in patrol point system... (could be wrong)
     
  30. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi jalex,

    there are no known issues in combination with an A* pathfinding tool, in case you use one of them at the same time.

    In fact, the author of HOTween, a generous person named Daniele, used SWS to do exactly what you've described. You can read more about his game and play it here:
    http://www.holoville.com/blog/?p=570

    Edit: the game seems to be unavailable at the moment..
     
    Last edited: Jan 4, 2013
  31. Jesse_Pixelsmith

    Jesse_Pixelsmith

    Joined:
    Nov 22, 2009
    Posts:
    296
    Thanks!

    Oh and also, just bought it and having a problem integrating with my project:



    I tried on a blank project and it's fine, but I'm not sure what's conflicting in mine. I don't have another copy of HOTween anywhere. Any advice?
     
  32. Jesse_Pixelsmith

    Jesse_Pixelsmith

    Joined:
    Nov 22, 2009
    Posts:
    296
  33. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
  34. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    411
    Hey Baroni, Happy 2013 man! have you seen this and what do you think about it? is it possible /worth implementing into SWS?
     
  35. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi nukeD,

    thanks, happy new year to you too!

    Yeah I saw the thread about LeanTween and followed it more or less actively. At a first glance, LeanTween tries to compete with HOTween performance wise. iTween is out of question, since it's not updated anymore and has serious performance impacts. Nothing wrong with that so far. However it seems that LeanTween only provides a small set of methods, while HOTween does have a lot more of them. HOTween does also support partial tweens, which allow moving on a part of the path and calling own methods through the message settings I've implemented. I still think HOTween was the best choice, because it has been used in many titles and Izitmee listens to customers very carefully. His update cycle is top notch. As long as LeanTween tries to do the same as HOTween, I can't see a need for an implementation now.
     
  36. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Plus, if I may add to the discussion (and thanks Baroni for the supernice words ;)) performance-wise LeanTween and HOTween are identical (those tests on the thread were setup wrongly, and HOTween was set in a "heavy performance" mode that is useful only for debugging purposes while in the Editor - I set it correctly and FPS became the same). The point where LeanTween is better is recycling, since it re-uses existing tweens instead than creating new ones.
     
  37. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Thanks for earlier help Baroni. Its all working now.

    I'm trying to develop an enemy chase/avoid AI script in 3D (like a fighter plane game, etc). It didn't seem like it but I wanted to ask if SWS had it built in already. If not any ideas where to start?

    Thanks again!
     
  38. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    SWS is an animation tool based on waypoints for automated movement along pre-defined paths. If you need artificial intelligence for complex behaviors in multiple scenarios (chase, avoid, search for help etc.), you would be better off with pathfinding package as a starting point.
     
  39. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Thanks Baroni I'll look into it.
     
  40. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Hi, I am a potential customer looking to see if SWS would work for the following situation:

    1. I have a character that is moving, Is is possible to make a custom camera path around the character that will follow him as he moves. So in this case, the camera path is SWS and the entire path is moving with the character as he moves.

    2. Dynamically change waypoints positions during game play.

    Thanks for your help.
     
  41. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi rocki,

    thank you for your interest.

    1. Yes. HOTween (implemented in SWS) does support local paths, which can be parented to a gameobject that is moving.

    2. Yes and no: Waypoints are just gameobjects. You can reposition them anytime through scripts, as you do with other gameobjects, so yes. However, there's a restriction when it comes to changing paths at runtime. HOTween (used for curved and straight paths) "initializes" the path at start and does not recognize further changes to it. Even if you change the path during gameplay, your object will follow the initial path, until you reinitialize the path. iTween (used for straight paths only) initializes its path after each waypoint, so you can still change every waypoint position except the current one.
    To summarize: Changing a path no object is currently moving on, no problem. Changing a path with an object moving on it does not work properly.
     
  42. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Baroni,

    1. Yes. HOTween (implemented in SWS) does support local paths, which can be parented to a gameobject that is moving.
    How would a small example script of doing local path look like with HOTween and SWS.

    2. Yes and no: Waypoints are just gameobjects. You can reposition them anytime through scripts, as you do with other gameobjects, so yes. However, there's a restriction when it comes to changing paths at runtime. HOTween (used for curved and straight paths) "initializes" the path at start and does not recognize further changes to it. Even if you change the path during gameplay, your object will follow the initial path, until you reinitialize the path. iTween (used for straight paths only) initializes its path after each waypoint, so you can still change every waypoint position except the current one.
    To summarize: Changing a path no object is currently moving on, no problem. Changing a path with an object moving on it does not work properly.

    Is there a way to modify HOTween so that it initializes its path after each waypoint?
     
  43. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    I'm not sure. Curved paths need more than two waypoints to form an actual curve, if you reposition a waypoint and reinitialize the path, it would alter the existing curve - so your gameobject could be teleported to a different position. Keep in mind that SWS is based on animation libraries, not pathfinding plugins. So I still recommend not to change waypoint position with objects walking on the path. You can ask HOTween related questions in this thread (click) and maybe come up with a different solution, of course.
     
  44. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    Just purchased this and it's awesome! Thanks. I'm having issues trying to hook into a HoMove path with javascript. I've got all the necessary files in the standard assets folder, but I'm confused on the exact code I need. This is code that I have that is attached to a gameObject that is following a path:

    var walker = GetComponent("hoMove");
    walker.Pause();


    I get an error 'Pause' is not a member of 'Object'.

    I'm still new with Unity, and I'm sure its just some dumb thing. Any help is greatly appreciated. I can get the Send Message thing working, but would like to avoid using that because I hear it is bad on performance, and the Pause command is also used by 2d toolkit, so it also pauses my objects animation.

    Thanks
     
    Last edited: Jan 22, 2013
  45. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    Actually I think I'm also having a problem with moving the scripts into the standard assets folder. Should this Standard Assets folder be inside my Asset folder? I get errors about missing scripts when it's inside the Asset folder. When its outside Assets in my root directory, the game compiles and works fine, but I am now missing the "Waypoint Manager" option under Windows and the inspector tools dont show up. Thanks
     
  46. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi meta,

    just checked js files in combination with hoMove, it's still fine. I imported the package SWS in my root folder, Project > Assets > SWS. Then I created a js file somewhere (doesn't matter). My script looks like this:

    Code (csharp):
    1. function Start()
    2. {
    3.     var script = gameObject.GetComponent("hoMove");
    4.  
    5.     yield WaitForSeconds(2);
    6.  
    7.     script.ChangeSpeed(20);
    8. }
    which does exactly what it should, it speeds up the object after two seconds. I don't know what went wrong with your project, maybe you could try to import it into an empty project.
     
  47. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    Thanks for the quick response Baroni.

    So the instructions in your documentation about moving files into Standard Assets if you are using javascript aren't necessary? I was able to get your script working fine when I made a new project with a simple path and cube. One more question though and this is probably just my lack of experience with coding in unity...

    When I try to take the line "var script = gameObject.GetComponent("hoMove");" Out of the Start() function and put it in Update() or just the beginning of the file, I get an error whenever I try to use any commands. The error I get is, 'ChangeSpeed' is not a member of 'UnityEngine.Component'.

    I'm confused as to why it works within the Start() function, but not elsewhere. Thanks again for holding my hand on this stuff. Just posted a positive review on the app store.
     
  48. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    Sry double post
     
  49. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Yes, indeed :) I remember a time when they were necessary, not sure what's changed since then.

    Difficult to explain, but that's how the scripts are built and Unity works. hoMove needs a short amount of time to initialize/create the tween for your object. That's why I put a two second delay in the Start() function, before calling ChangeSpeed(x), so it has successfully created the tween, before modifying it.
    Update() is called every frame, from the beginning till the end. Therefore it ignores any delay, otherwise Unity couldn't call it every frame. You get the error because the tween wasn't ready at the time it was accessed by Update().
    You also can't set it at the beginning of the file, because GetComponent has to be in a function which gets executed at runtime (it can't look for a component in the editor). Instead you can use a public variable and assign it directly in the inspector.

    Hope that makes sense! Just one more hint: Normally you need a component once and store it in a variable. Calling GetComponent every frame (in Update) heavily affects performance and isn't recommended.

    Thank you very much! Every review counts :)
     
  50. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    I appreciate the info Baroni. Still lots to wrap my mind around when it comes to programming and unity :D

    I was still having some issues, but everything is working great now. I ended up putting the scripts you mentioned in the pdf doc into Assets/Editor. I then put the entire SWS folder into Assets/Plugins. Everything is working perfectly with javascript now. I've got my enemies spawning from a pool with paths set at runtime.

    Thanks again.