Search Unity

Prime31 GoKit Tween Library Live

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

  1. UnbreakableOne

    UnbreakableOne

    Joined:
    Nov 16, 2013
    Posts:
    168
    What's best way to show a "3 ... 2... 1 ... GO !" sequence using a single text mesh? I've tried changing the text to "3" and "2" and "1" and appending them but it will always have the last value obviously. Then I tried coroutines that I faced with that bug I posted before this.

    I've written all the effects I want for it's fade in and fade out, just don't know how to change the text of the text mesh and append it so it would store copies of the source text mesh or something like it.

    Thanks.
     
  2. _ben

    _ben

    Joined:
    Apr 21, 2013
    Posts:
    7
    I'm using a very simple TweenChain. Just moving an object from one position to another. The object has a child with a sprite renderer on it. I want to be able to toggle a switch in game and playforwards or playbackwards to make the object move back and forth from wherever it is at.

    Everything works fine, however for an instant when the switch toggles I can see all the objects flash at the start as well as end positions of the tween, they then continue the animation properly. Has anyone run into this? Any ideas what the problem could be?

    I'm using:

    void Start() {

    var tween = new GoTween(transform, Random.Range(1.6f, 3.2f), new GoTweenConfig().position(new Vector3(transform.position.x, transform.position.y - 10, transform.position.z)).setEaseType(GoEaseType.QuadInOut));

    currentTweenChain = new GoTweenChain();
    currentTweenChain.append(tween);

    }
    and then currentTweenChain.playForwards() or currentTweenChain.playBackwards() depending on the state of the switch

    I've also tried using the reverse function and then just play() which gives the same result.
     
    Last edited: May 2, 2014
  3. pixlweaver

    pixlweaver

    Joined:
    Dec 21, 2012
    Posts:
    92
    I have just started experimenting with GoKit and am running into an issue. Perhaps I'm doing something wrong here? I am trying to tween an object's local position. Here's my example:

    Code (csharp):
    1. cube.transform.localPositionTo(1f, new Vector3(1f,0,0), true);
    I would expect this to move the cube on it's local X axis, however, it is tweening on the world X axis instead. Is this a bug or am I going about this the wrong way?
     
  4. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @pxl, that tween will move the cube 1 Unity unit in the x direction.
     
  5. pixlweaver

    pixlweaver

    Joined:
    Dec 21, 2012
    Posts:
    92
    Does that mean I have to parent the cube and apply a rotation to that in order to tween the cube's position on it's local x axis? I am used to iTween, in which I can set the tween to use the object's self space.
     
  6. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @pxl, you can parent it or you can just translate from local to world and pass the result vector.
     
  7. j.miller12

    j.miller12

    Joined:
    Jul 15, 2013
    Posts:
    1
    Recently switched to GoKit from iTween, and ran into an issue when I built do device (Android). Loading a GoSpline that was saved into StreamingAssets/, on the android device it was not working at all until we changed this line in GoSpline.cs:

    from:
    to:
    After changing that it worked on device! Am I doing something wrong or was the code wrong? Also makes me a bit nervous because it looks like it could end up in an infinite loop if something doesn't load...
     
  8. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @j.miller, good spot! It should indeed be "!" loadAsset.isDone. I'll push an update momentarily.
     
  9. gstock

    gstock

    Joined:
    Feb 19, 2014
    Posts:
    10
    I'm creating a tween path on the editor and handling the position on the Update method. I need to know in which segment of the path my object is, is there a way to get it?

    Thanks!
     
  10. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    865
    Hi! I am using GoKit and I like it. I have a problem through, with Time.timeScale = 0 tween wouldn't play even if I globally set

    Code (csharp):
    1. Go.defaultUpdateType = GoUpdateType.TimeScaleIndependentUpdate;
    or using

    Code (csharp):
    1. TweenConfig().setUpdateType(GoUpdateType.TimeScaleIndependentUpdate);
    Some tweens are working, but some don't. When I set Time.timeScale to 1 they start to work….

    What are the things I need to do properly in order to get this to work? Thanks!
     
  11. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Hey Mike, somehow I missed GoKit... but catching up on what you've been u p too. Pretty cool!

    Oh, by the way..... regarding the tutorial video... Euler is not pronounced "Euler", but rather like "Oil-er". Not that it ever feels comfortable to say it that way to me. But that was how the guys name was pronounced. :)

    David
     
  12. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @pretender, I can't se to reproduce what you are seeing. Please include exact steps to reproduce.


    @david, you'll never get me to say Euler like a Scotsman! It's already been burned into my brain to say it like My Cousin Vinny! Depending on your tween needs don't forget to checkout GoKitLite. GoKit is more powerful and you can easily add your own custom tweens whereas GoKitLite is just insanely fast having been stripped down to only its essence.
     
  13. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476

    Hey, I don't make the rules! :D
     
  14. MDarkwing

    MDarkwing

    Joined:
    Jul 30, 2013
    Posts:
    2
    Is there a difference between .localPosition and position tween property because I'm not seeing one. My object move same whichever I use. My intuition tells me that localPosition should move it according to Space.Self which I need, but that's not happening. Is it possible that such powerful library doesnt have this option?
     
  15. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    All position tweens support relative or non-relative movement. Just pass true for the relative parameter.
     
  16. gstock

    gstock

    Joined:
    Feb 19, 2014
    Posts:
    10
    Hi!

    Is it possible to get the length of a Path created with the GoKit visual editor? I've been looking around the source code, but I haven't find an easy way to do it.

    Thanks!!
     
  17. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    There is nothing built in to get the path length but GoKit is 100% extensible. Just make a subclass of AbstractGoSplineSolver and add in a public property to access the _pathLength ivar.
     
  18. randi23

    randi23

    Joined:
    Feb 17, 2014
    Posts:
    7
    Hi, I'm newbie here, I think this library is very useful for me, but when I try to buid & run my game for Windows Phone 8 using this library, I got this error :

    Maybe you can help me?
     
  19. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    Windows Phone/Store runs on the WinRT. Tons of APIs such as most of the System.IO classes do not exist there. You either need to remove calls to classes that don't exist or replace them with WinRT equivalents.
     
  20. randi23

    randi23

    Joined:
    Feb 17, 2014
    Posts:
    7
    So I can't use that method? What is the alternative for load the .asset ?

    Thanks, sorry i'm newbie here :D
     
  21. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    You can certainly use that method but you have to properly wrap non-WinRT code and provide a WinRT compatible code path just like you would for any code that isn't in the WinRT frameworks. The full list of missing types in WinRT is available right in the Unity documentation: http://docs.unity3d.com/Manual/windowsstore-missingtypes.html
     
  22. randi23

    randi23

    Joined:
    Feb 17, 2014
    Posts:
    7
    OK, thanks.
    I have try that, now the error code has change to :

    is it the same problem (missing API) ?
     
  23. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    That log is telling you that ConvertAll does not exist in your SplineController::GetTransforms() method. If you read through the logs Unity dumps line by line it will almost always lead you to the underlying issue.
     
  24. randi23

    randi23

    Joined:
    Feb 17, 2014
    Posts:
    7

    Yeah you right, Sorry I'm not read it carefully, now my proble is solved.
    Big Thanks :D
     
  25. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    How to use GoLookAtType with Go.to
    Code (CSharp):
    1. _tween = Go.to(gameObject, 4, new GoTweenConfig().position(new Vector3(9, 4, 0)));
     
  26. king_

    king_

    Joined:
    Mar 21, 2014
    Posts:
    5
    can you give a small example for this
    Code (CSharp):
    1. public static Tween colorFrom( this Material self, float duration, Color endValue, MaterialColorType colorType = MaterialColorType.Color )
    what i'm using
    Code (CSharp):
    1. cube.colorTo (1f, a,cube.color);
    but getting errors
     
  27. king_

    king_

    Joined:
    Mar 21, 2014
    Posts:
    5
    sorry got my solution but getting this error
    Code (CSharp):
    1. tween failed to validate target: ScaleTweenProperty
    2. UnityEngine.Debug:Log(Object)
    3. GoTween:addTweenProperty(AbstractTweenProperty) (at Assets/Plugins/GoKit/GoTween.cs:211)
    4. GoTween:.ctor(Object, Single, GoTweenConfig, Action`1) (at Assets/Plugins/GoKit/GoTween.cs:98)
    5. Go:to(Object, Single, GoTweenConfig) (at Assets/Plugins/GoKit/Go.cs:250)
    the code
    Code (CSharp):
    1. Go.to (GO, 1f, new GoTweenConfig ().scale (new Vector3 (2, 2, 0)).setEaseType (GoEaseType.BackOut));
     
  28. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    bodyMaterial.colorTo(5f, bodyColor, "_Color");

    above line waits for 5 secs and snaps to new color. Its not really tweening. Am i doin it wrong !. I am looking smooth color transition.

    Edit:
    Sorry my bad. Other line of code overriding this. Now it works just fine. Thanks
     
    Last edited: Aug 4, 2014
  29. king_

    king_

    Joined:
    Mar 21, 2014
    Posts:
    5
    try leantween,gokit is not so friendly
     
  30. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Is there a way to reuse a TweenConfig while changing its position property? Since there's no remove tween property I don't see a way to change the existing position property.
     
  31. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    The TweenConfig class recently (a couple days ago) received a new clone method that should do exactly what you are looking for.
     
  32. dkoontz

    dkoontz

    Joined:
    Aug 7, 2009
    Posts:
    198
    Is there any way to tween a field or are only properties supported?
     
  33. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    I've been trying to do something where I create a Tween, have it do it's Tween. Remove itself from the Tween list. But the class that fired that Tween saves the reference to the Tween, and then where it wants to play it again, it adds it back via Go.instance.AddTween(tween). But the method fails to do that because the tweens .isValid method returns false as the 'target' is missing. I don't quite understand this pattern and presume I've just missing something. What would be the proper way to create a tween, run it, have it remove itself, then be able to add it back and run again?
     
  34. Mathieu

    Mathieu

    Joined:
    Jun 13, 2005
    Posts:
    103
    I'm trying to tween the intensity value of the Bloom effect from StandardAssets. I'm having a hard time figuring it out.
    Code (CSharp):
    1.  
    2.  
    3.         UnityStandardAssets.ImageEffects.Bloom bloom = GetComponent<UnityStandardAssets.ImageEffects.Bloom>();
    4.  
    5.         // if I change bloom intensity this way, it's working...
    6.         // bloom.bloomIntensity = 2.0f;
    7.  
    8.         // if I use GoKit floatProp it have no effect
    9.         Go.to(
    10.                 bloom,
    11.                 1.0f,
    12.                 new GoTweenConfig()
    13.                 .floatProp("bloomIntensity", 1.0f)
    14.             );
    15.  
    Any idea?
     
  35. db82

    db82

    Joined:
    Mar 14, 2012
    Posts:
    24
    I think the property needs to be defined as a setter/getter like so:

    public float bloomIntensity { get; set; }

    See here - https://github.com/prime31/GoKit/wiki/3.-Tweening-Custom-Properties
     
  36. Mathieu

    Mathieu

    Joined:
    Jun 13, 2005
    Posts:
    103
    Thank you db82, it's working! :)
     
  37. Andrew-Q

    Andrew-Q

    Joined:
    Jun 2, 2015
    Posts:
    3
    Hello, I've got a question regarding local path movement. If I set it to relative it get parents transform, so starting position is fine.

    But, if parent is moving, object starts and continue to follow path in world vectors of path, so this happens:


    My question is, is it possible to move in local coordinates using path? If so, can you please provide some hint.

    Thanks.
     
  38. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
    The following code is doing a 2.2k allocation on GO.AddTween
    Code (CSharp):
    1. ScaleTweenProperty scaleProperty = new ScaleTweenProperty(new Vector3(SCALE_EFFECT_MAGNITUDE,SCALE_EFFECT_MAGNITUDE,SCALE_EFFECT_MAGNITUDE));
    2.                 GoTweenConfig scaleTweenConfig = new GoTweenConfig();
    3.                 //scaleTweenConfig.scale = new Vector3(;
    4.                 scaleTweenConfig.addTweenProperty(scaleProperty);
    5.                 scaleTweenConfig.easeType = GoEaseType.Punch;
    6.                 scaleTweenConfig.loopType = GoLoopType.RestartFromBeginning;
    7.                 //scaleTweenConfig.onCompleteHandler = ResetScale();
    8.  
    9.                 GoTween scaleTween = new GoTween(playerPortrait.transform, 1, scaleTweenConfig);
    10.                 scaleTween.setOnCompleteHandler( c => ResetScale() );
    11.                 Go.addTween(scaleTween);
    Is there any way to avoid this? I'm trying to make a UI element pulsate on impact.
     
  39. Kellyrayj

    Kellyrayj

    Joined:
    Aug 29, 2011
    Posts:
    936
    I'm looking for an example of how to tween the pivot values of a RectTransform.

    Code (CSharp):
    1.         Go.to(thisRect.pivot, .5f, new GoTweenConfig().vector2Prop(new Vector2(0,0));
    2.  
    This is my terrible attempt. Any thoughts on how to accomplish this would be greatly appreciated!
     
  40. Jackin-Joe

    Jackin-Joe

    Joined:
    May 31, 2016
    Posts:
    2
    Gokit how to achieve the effect , same as transform.RotateAround