1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Prime31 GoKit Tween Library Live

Discussion in 'iOS and tvOS' started by prime31, Apr 26, 2012.

  1. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    We are proud to introduce a new open source tween library for Unity today. GoKit is now live on Github. GoKit is a tween library aimed at providing flexibility, performance and ease of use. It was designed with mobile in mind so allocations are kept to a minimum and many objects can be reused. What does that mean for standalones and web players? They too will benefit from all the performance tweaks making GoKit an awesome cross-platform solution. Have a look at the getting started tutorial video here.

    GoKit comes packed with a visual path editor and a path tween system that provides constant velocity for all path segments. Have a look at a video demo of the visual path editor here.

    Check out some brief examples to see how easy using GoKit is:

    Tween the position of a cube:
    Code (csharp):
    1. cube.positionTo( 2f, new Vector3( 25, 23, 2 ) );
    Tween the position and scale of a cube simultaneously:
    Code (csharp):
    1. Go.to( cube, 2f, new TweenConfig().position( new Vector3( 25, 23, 2 ) ).scale( 4 ) );
    Tween the position and scale of a cube simultaneously with a ping pong loop:
    Code (csharp):
    1. Go.to( cube, 2f, new TweenConfig()
    2.                 .position( new Vector3( 25, 23, 2 ) )
    3.                 .scale( 4 )
    4.                 .setIterations( 4, LoopType.PingPong ) );
    Some useful links:

    Github page
    API reference
    Wiki (includes examples and best practices)

    Once GoKit gets put through its paces we will also put it on the Asset Store as well. We are accepting pull requests on Github so if you find any bugs be sure to send one over. We wanted to get GoKit out as soon as possible so we didn't get to put together as many demo scenes as we would like. Over the next few days as we see how people are using GoKit we will add some more demo scenes showcasing what it can do along with some advanced usage examples.
     
  2. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    I've been anticipating the launch of GoKit..... Testing time!!! :) Thanks @Prime31
     
  3. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    is the GoKit folder, inside the Plugins folder(from the GIT master branch), the only file/folder actually needed to be imported into a new project's asset folder? Are there other necessary files from the GoKit master branch needed to import into a new unity project, before using GoKit?

    Would you recommend symlinking that folder into a project's assets folder(from the local Git Copy pulled from the Master GitHub branch), or just copying it into the local project's assets folder?
     
    Last edited: Apr 27, 2012
  4. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @zhx, just the GoKit folder is required. Symlinking will only work if you don't use Unitys version control. Otherwise Unity will get angry.
     
  5. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    684
    Very nice. Thanks for this. iTween now has some healthy competition. I particularly like the TweenConfig and chaining.

    Cheers.
     
  6. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @thylaxene, many thanks. While there is some overlap with the fantastic iTween both libraries have a slightly different focus. iTween is a true jack-of-all-trades while GoKit has a laser-like focus on tweening with great efficiency.
     
  7. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,440
    I can't seem to get materialColor working... well, not for textMeshes anyway.

    Code (csharp):
    1. Go.to( textMesh.font, 2.0f, new TweenConfig().materialColor( colorTo, MaterialColorType.Color, true ) );
    Where the start color is Color.white and the end color (colorTo) is white but with alpha of 0.0f;

    The tween should fade the textMesh font material out, but doesn't. The same technique with iTween worked fine.

    I've also tried...

    Code (csharp):
    1. Go.to( textMesh.font.material, 2.0f, new TweenConfig().materialColor( colorTo, MaterialColorType.Color, true ) );
     
    Last edited: Apr 28, 2012
  8. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @Seon, assuming you have a var textMesh that is of type TextMesh the following will work:

    Code (csharp):
    1. textMesh.renderer.material.colorTo( 3f, Color.clear );
    or, if you prefer this is another option (pick the syntax that tickles your fancy):

    Code (csharp):
    1. Go.to( textMesh.renderer, 5f, new TweenConfig().materialColor( Color.green ) );
    or this:

    Code (csharp):
    1. Go.to( textMesh.renderer.material, 5f, new TweenConfig().materialColor( Color.green ) );

    They are all valid ways to tween the _Color of a TextMeshes Material.
     
    _met44 likes this.
  9. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,440
    Yup, that works, thanks :)
     
  10. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    What advantages does this have over iTween?
     
  11. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, GoKit was built from the ground up for mobile. It keeps allocations to a bare minimum, strongly types vales all the way through and does anything it can to be as performance as possible. It was also made with extensibility in mind for cases where you want to add your own tweens. iTween is a superb library but is a bit dated and was not optimized for mobile.
     
  12. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    iTween Path uses Eulers? Curves, for their paths. A quick look, saw that you jst punch in positions. Do you have something similar to the visual path editor and do the paths curve and swoop?


    Also, would you be ale to give a percentage of how much more effecient your system is over iTween. For the record, I am using a lot of iTween in my current title and I love it. i have a few functional issues, but none regarding performance. That being said, performance is performance.
     
    Last edited: Apr 28, 2012
  13. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, GoKit currently has constant velocity paths (speed will always be the same regardless of the distance between the nodes) along with a visual path editor. Spline/bezier paths are on the todo list as well. I haven't benchmarked the two libraries so it is hard to say what the exact difference would be. GoKit reduces any casting, strings and allocations to the bare minimum so its raw code should be faster and in turn avoids the garbage collector.
     
  14. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    Right,
    so is the only option constant speed along the path? Or can you flip flop between? Also, can you alter any path speed dynamically? For instance if I am on a path, can I, part way, change my speed?
     
  15. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, right now (version 0.1) there isn't speed control though you could simply make a chain of two paths to pull that off. The first path would cover the slowe portion of travel then the second portion would cover the faster portion. Changing the ease type also has the same effect of allowing the speed to vary throughout the movement.
     
  16. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    Ok, and the path. Is it curved, or linear? Do you have a choice? Just as a user of iTween, to have the choice would be good.
     
  17. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, as mentioned previously splines aren't in there yet. We are openly accepting pull requests though. One of the main reasons we released to the community before the 1.0 version was to get everyone involved with shaping GoKits future.
     
  18. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    Ok.
    Cool.
    Well, spline options. True or false.
    Dynamiclly change path speed, time would be incredible.
     
  19. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, splines are the next big option on the todo list. The hard part is making them constant speed. Once constant speed is up and running efficiently (precalculated at tween start) changing speed is as simple as a time scale or ease type change.
     
  20. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    But ease type is in and out no?

    I mean if speed determines path travel time. If at any point on that path i can alter the speed by any factor would be huge.
     
  21. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, ease type is an equation. There are a bunch baked in but there is no reason you couldn't make your own. An ease equation is basically just a curve. Time scale would probably work better for your case. You can just increase/decrease it to speed/slow down the movement. That will be released in a day or two.
     
  22. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    But wouldnt timescale effect all objects? How could you limit it to the one object on path?
     
  23. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, the time scale property is per Tween so each Tween can have its time scale adjusted at will.
     
  24. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    Oh. Interesting.
    Is there a quick way to explain how i could do this in game without this plug in? Meaning, could i apply a single timescale effect to a single object in regular unity?
     
  25. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, Unity only has the global time scale property but you can mod that by just multiplying Time.deltaTime by the objects local time scale.
     
  26. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    Hmm right.
    Thanks.
     
  27. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    355
    Hi, I got problem with scenario when several game objects / enemies are 'tweened' using GoKit but in the process an enemy is destroyed / shot, this can happen any time...
    stacktrace:
    Code (csharp):
    1.  
    2. MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it.
    3. Your script should either check if it is null or you should not destroy the object.
    4. UnityEngine.Transform.set_position (Vector3 value)
    5. PositionTweenProperty.tick (Single totalElapsedTime) (at Assets/Plugins/GoKit/properties/specificTypes/PositionTweenProperty.cs:77)
    6. Tween.update (Single deltaTime) (at Assets/Plugins/GoKit/Tween.cs:119)
    7. Go.handleUpdateOfType (UpdateType updateType, Single deltaTime) (at Assets/Plugins/GoKit/Go.cs:67)
    8. Go.Update () (at Assets/Plugins/GoKit/Go.cs:87)
    9.  
    do you think it could be fixed 'easily' ?
     
  28. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @r618, when you destroy an object with any tweens running you need to destroy the tweens as well. The Go class has a method to retrieve all tweens for a particular target which can be used to grab and destroy them before destroying the actual object.
     
  29. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,440
    Hmm, I think an internal GoKit check/cleanup would also be a good idea :)
     
  30. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @mr seon, how exactly do you propose identifying a dangling reference? This seems more like a case of the programmer needing to properly clean up an object than a library trying to work around coding errors for the developer.
     
  31. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,440
    See, I knew that would get you going :)
     
  32. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,440
    Yay! iTween is totally gone from Cubemen - Now using GoKit exclusively. Thanks Mike for an awesome tween solution!
     
  33. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @r618, the latest push has a new method on the Go object that will kill all tweens with a given game object:

    Code (csharp):
    1. Go.killAllTweensWithTarget
    That should work for any case where you destroy an object that is current tweening without having the overhead of doing GetComponent lookups every frame. Best of both worlds as long as you remember to call it.
     
  34. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    355
    all that I needed was to call .destroy() on a tween / as for now I have it locally as a object member, so it was not problem accessing it /
    but thanks for info, it would surely took a bit longer to extract it from code

    as for dangling pointers: you are probably right as it does not make much sense of having tween running without tweened object and working around dangled _targets would be cumbersome, at least... :)
     
    Last edited: Apr 30, 2012
  35. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    Any word on when you may introduce the benzier(?) curvature of a path system?
     
  36. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, coming soon. shake and time scale per Tween was added in the last push.
     
  37. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    Great. Will there be an announcement and will it have a visual editor?
     
  38. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, it might not have a visual editor for the initial release but it will come at some point.
     
  39. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    And not to be a nag, but what is your honest timeline for these two features?
     
  40. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, we don't really do the whole timeline thing especially while still in the pre-version-1.0 stage. There are too many factors involved to be accurate. The project is open source so you can most definitely jump onboard and send us a pull request if you want to contribute to the project.
     
  41. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    Hm great.
    My time is taken tho and I am not at a position yet where i would fully trust my contributions. I might just be spinning wheels.



    Cheers!
     
  42. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    The first beta of the spline system just got pushed live. The path editor got an update to allow spline editing. If you use a path of more than 4 nodes it will automatically be set to a Catmull-Rom spline. You can override this behavior and use straight lines for path by simply passing "true" in as the second parameter to the GoSpline constructor. For paths of 3 segments a quadratic bezier is used. Cubic bezier is used for 4 segment paths. The groundwork is in there now for future updates adding full cubic bezier, quadratic bezier and any other spline types that are needed.

    Here is what the editor looks like:
    [​IMG]
     
  43. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    Great Mike!

    A suggestion, I wonder if it is possible but could be quite handy for someone using a lot of paths... To be able to remove node 14 from a path of 38 nodes. Meaning, to be be able to remove, delete any particular node, not just the one at the top of the list.
     
  44. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, just click on the node then press delete.l to remove a node.
     
  45. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    Why, aint that freakishly cool.
     
  46. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    Hi Mike,
    just testing out your pathing system. I like the Illustrator, "bezier(?)" tools, that let you adjust the path ends + a few other features for sure.

    What I am wondering is, I created a Cube, attached a path script (is this correct method, empty game object will do?) but more importantly, I get this error....

    DirectoryNotFoundException: Could not find a part of the path "/Users/renniemoffat/GoKitTest/Assets/StreamingAssets/demoRoute.asset".

    I have saved the path, and loaded it to be safe. Not sure what to do.

    Thanks.
     
  47. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, do you have a StreamingAssets directory in your project? Did you save the path with the mane demoRoute.asset? Is it saved in the StreamingAssets folder? It would seem you saved it elsewhere as the exception is a directory not found exception.
     
  48. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    I do have the streamingAssets directory.

    My project is just your GoKit Assets folder and its contents.

    I am not sure what you mean by did I "save it with the demoRoute.asset". I saved it in the streamingAsset folder.
     
  49. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,427
    @renman, the name of the file saved must match the name passed into the GoSpline constructor. See the demo scene for an example.
     
  50. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,039
    I am not sure what you mean. I am using the dummyPath script. I have studied the path demo but one thing that perplexed me was that since you do not use the dummy path visual script. And as such there are no references on the tweeening object in the inspector beyond trasform and lookat.


    I am admittedly a litte mixed up here.