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

HOTween: a fast and powerful Unity tween engine

Discussion in 'Assets and Asset Store' started by Demigiant, Jan 7, 2012.

  1. soxroxr

    soxroxr

    Joined:
    Jul 17, 2012
    Posts:
    60
    Thank you very much, Izitmee. :) I couldn't find it in the documentation on the website, but I got it.

    I have one more question! If you wouldn't mind. :)

    Is there a way to change the time/speed (I'm using speed) while it's moving, without stringing paths together? Making the speed public and switching it in the inspector doesn't do it while the game is going.

    Thank you again. :)
     
  2. FredZvt81

    FredZvt81

    Joined:
    Apr 8, 2014
    Posts:
    24
    Hi Folks!

    I think that the best solution would be to create a Parallel class that implements IHOTweenComponent and could be nested into Sequences.
    This way, we could forget about the durations, we could just setup the order that we want and let the tool do its magic!

    I have, however, succeded with the effect that I was searching for using some helper classes.
    I don't think that the solution was the best but it worked for me.

    My idea was to create a class that stores all the Tweeners that must be played in parallel and use OnComplete callbacks in order to play tweens and groups of tweens in parallel, one after another. I've call this class TweenersInParallel.

    On the way to implement this idea, I bumped into another problem: I did not find a way of adding callbacks to IHOTweenComponents without overwriting any callbacks that have been added via TweenParms. Also, apparently I could have only one callback for each event. Izitmee, I was curious as to why you took this approach. Why did you didn't use a simple event for this? Anyway, I created another helper class to solve this problem and I called it TweenerWrapper. What it basically does is add a callback for the event that I wish to handle in IHOTweenComponent and make a broadcast to more than one listener.

    Code (csharp):
    1.  
    2. public class TweenerWrapper
    3. {
    4.     public IHOTweenComponent Tweener { get; private set; }
    5.     public event Action OnPlay;
    6.     public event Action OnComplete;
    7.  
    8.     public TweenerWrapper(IHOTweenComponent tweener)
    9.     {
    10.         if (tweener == null)
    11.             throw new ArgumentNullException("tweener");
    12.            
    13.         this.Tweener = tweener;
    14.         this.Tweener.Pause(); // Pause it so it won't start to play immediatly
    15.         this.Tweener.ApplyCallback(CallbackType.OnPlay, HandleTweenerOnPlayEvent);
    16.         this.Tweener.ApplyCallback(CallbackType.OnComplete, HandleTweenerOnCompleteEvent);
    17.     }
    18.  
    19.     private void HandleTweenerOnPlayEvent(TweenEvent p_callbackData)
    20.     {
    21.         // Broadcast the play event
    22.         if (OnPlay != null) OnPlay();
    23.     }
    24.  
    25.     private void HandleTweenerOnCompleteEvent(TweenEvent p_callbackData)
    26.     {
    27.         // Broadcast the complete event
    28.         if (OnComplete != null) OnComplete();
    29.     }
    30. }
    31.  
    Code (csharp):
    1.  
    2. public class TweenersInParallel
    3. {
    4.     private List<TweenerWrapper> Tweeners;
    5.     private bool isTweening;
    6.     private int tweenersCount;
    7.     private int completedTweeners;
    8.  
    9.     public event Action onPlay;
    10.     public event Action onComplete;
    11.  
    12.     public TweenersInParallel()
    13.     {
    14.         isTweening = false;
    15.         tweenersCount = 0;
    16.         Tweeners = new List<TweenerWrapper>();
    17.     }
    18.  
    19.     public void AddTweener(TweenerWrapper tweener)
    20.     {
    21.         if (isTweening)
    22.             throw new Exception("Not allowed while tweening.");
    23.  
    24.         tweener.OnComplete += VerifyCompletion;
    25.         Tweeners.Add(tweener);
    26.     }
    27.  
    28.     private void VerifyCompletion()
    29.     {
    30.         if (++completedTweeners == tweenersCount)
    31.         {
    32.             isTweening = false;
    33.             if (onComplete != null) onComplete();
    34.         }
    35.     }
    36.  
    37.     public void PlayTweeners()
    38.     {
    39.         if (onPlay != null) onPlay();
    40.  
    41.         if (Tweeners.Count > 0)
    42.         {
    43.             isTweening = true;
    44.             completedTweeners = 0;
    45.             tweenersCount = Tweeners.Count;
    46.  
    47.             foreach (var tweener in Tweeners)
    48.                 tweener.Tweener.Play();
    49.         }
    50.         else
    51.         {
    52.             if (onComplete != null) onComplete();
    53.         }
    54.     }
    55. }
    56.  
    When using TweenerWrapper, you must not use the TweenParms.OnComplete because it'll be overwriten.
    See this example of usage in my project:

    Code (csharp):
    1.  
    2. public TweenerWrapper FadeOut(float duration, Action onComplete = null)
    3. {
    4.     var spriteRenderer = GetSpriteRenderer();
    5.     if (spriteRenderer != null)
    6.     {
    7.         var tweener =
    8.             new TweenerWrapper(
    9.                 HOTween.To(
    10.                     spriteRenderer.material,
    11.                     duration,
    12.                     new TweenParms()
    13.                         .Prop("color", new Color(1f, 1f, 1f, 0f))
    14.                         // .OnComplete(...) <- Don't use this!
    15.                 )
    16.             );
    17.  
    18.         tweener.OnPlay += () => isAnimationRunning = true;
    19.         tweener.OnComplete += () =>
    20.         {
    21.             isAnimationRunning = false;
    22.  
    23.             Hide();
    24.             ResetAlpha();
    25.  
    26.             if (onComplete != null)
    27.                 onComplete();
    28.         };
    29.  
    30.         return tweener;
    31.     }
    32.     return null;
    33. }
    34.  
    You could now use TweenersInParallel.onComplete to setup groups of parallel animations in sequence.
    See this example of usage in my project:

    Code (csharp):
    1.  
    2. var playBeforePlayerMove = new TweenersInParallel();
    3. var playAfterPlayerMove = new TweenersInParallel();
    4. ...
    5. playBeforePlayerMove.onComplete += () =>
    6. {
    7.     Player.MoveTo(direction, 1, () =>   // MoveTo returns a TweenerWrapper and the third parameter is an onComplete callback.
    8.     {
    9.         playAfterPlayerMove.PlayTweeners();
    10.        
    11.     }).Tweener.Play();
    12. };
    13. playBeforePlayerMove.PlayTweeners();
    14.  
    Cheers!
    Fred
     
  3. brosmaninho

    brosmaninho

    Joined:
    Apr 9, 2014
    Posts:
    1
    Great FredZvt81, this worked for me too!

    thx!
     
  4. Iceo MK

    Iceo MK

    Joined:
    Nov 12, 2013
    Posts:
    2
    Hello there,

    I'm trying to change the path of which the object follows mid-game.
    This is because I want the player to choose where the object goes (setting two paths, and allowing a trigger to switch between them).

    The problem with this is the following:
    1) The current HOPath script basically moves the object it's attached to.
    2) I need to create different paths (on different gameObjects) then assign the PathController to a specific gameObject path to follow.

    I dug through the scripts and couldn't really understand where the HOPath script says something like "Move this gameObject".

    Great work on making this amazing system that doesn't use up too much processing power, and it's great for all the features it has.
     
  5. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @CremaGames: with your code, you're creating a master Sequence which runs all the child Sequences one after the other, while the child Sequences contain parallel tweens. You should use the Insert method on the master Sequence instead, if you want that to have parallel children.

    @soxroxr: you can change the timeScale of your tween/sequence, even while the tween/sequence is running, and the speed will vary accordingly.

    @FredZvt81: thanks for posting that code :) Still, I don't see a reason for making a parallel version of Sequences, since if you use Insert with an initial parameter of 0, it does exactly that (see my reply to CremaGames, who was simply using it wrongly). I find Insert more powerful since it also allows you to place tweens at a given time of choice, other than in parallel.
    About why I didn't use regular event logic, it's because imho the current callback system is easier to use, allows for a more compact layout, and I didn't see a reason to add more than one callback to a tween. But I'll think about it more for HOTween V2 (when I'll find the time to work more on it).
     
  6. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Iceo MK: I can't answer for HOPath because it's Vevusio's oeuvre. I'd suggest that you either contact him directly or, if you want a more advanced path system (which still uses HOTween), rely on Baroni's Simple Waypoint System (not free, but cheap).
     
  7. CremaGames

    CremaGames

    Joined:
    Mar 5, 2014
    Posts:
    59
    @Izitmee I don't think the code is wrong, I want exactly that. Ten sequences that run one after the other, and each sequence has 10 tweens that run in parallel. I don't want to run in parallel the sequences under the master sequence.

    Here's a visual representation of what I want to do:

     
  8. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Oh, sorry, I misunderstood. Anyway, I just made a test to see if there was some bug, but everything works perfectly here. Here is an example package which achieves what you want to do (you'll have to add the HOTween library yourself). Let me know.
     
  9. CremaGames

    CremaGames

    Joined:
    Mar 5, 2014
    Posts:
    59
    Your code works fine, I'm trying to put it in my code put I'm getting this error whenever I nest two sequences ><

    Code (csharp):
    1. ArgumentNullException: Argument cannot be null.
    2. Parameter name: collection
    3. System.Collections.Generic.List`1[System.Object].CheckCollection (IEnumerable`1 collection) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:435)
    4. System.Collections.Generic.List`1[System.Object].AddRange (IEnumerable`1 collection) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:136)
    5. Holoville.HOTween.Sequence.GetTweenTargets () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Sequence.cs:496)
    6. Holoville.HOTween.Core.TweenInfo..ctor (Holoville.HOTween.Core.ABSTweenComponent tween) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Core/TweenInfo.cs:70)
    7. Holoville.HOTween.HOTween.GetTweenInfos () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:2059)
    8. BoardManager.Update () (at Assets/Script/BoardManager.cs:223)
    9.  
    PD: I was adding a blank sequence in one of the loops, problem solved.
     
    Last edited: Apr 10, 2014
  10. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
  11. Hosh

    Hosh

    Joined:
    Apr 14, 2014
    Posts:
    1
    Hi,

    within my project I'm moving streetcars and busses on different paths in a scene.
    Everything works perfectly due to HOTween (acceleration and breaking for realistic vehicle behavior, etc...), so thanks for the great work.

    Now I'd like to add a trailer car to one of the streetcars and the trailer naturally has to follow the locomotive (following its spline defined by the MoveTO tween).
    Is there something like a "lookBack" functionality where you can get the position AND orientation for an earlier t of the tween?

    Or if someone has an idea how to realize a realistic following behavior for a trailer to follow a locomotive, since they are two different game objects on a curvy path?

    Happy for any inspiration!
    Hosh
     
    Last edited: Apr 14, 2014
  12. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    @Hosh, you can just use Queue, and enqueue each update and after certain queue count, you start de-queuing?

    Hey Izitme, do you have any idea why would such spike happen in middle of a game? By the way, this was in the Editor, but big (but smaller relative to editor spike) spikes do happen on mobile devices too?

    http://i.imgur.com/737goV7.png?1

    Great script by the way!
     
    Last edited: Apr 15, 2014
  13. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi,
    I'm using HOTween to move characters(A and B) and put a HOTween.Kill() inside OnCollisionEnter() so they can stop when collide each other.
    But it seems that it only works once, next time tween A, it will go through B because it's already inside.
    Is that possible to let HOTween handle this situation? Maybe a raycaster? Thank you :)
    ---------------------------------

    [Solve] Yes, raycast is the key.
     
    Last edited: Apr 17, 2014
  14. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Hosh: what Kobix said :) Otherwise, you could "chain" the trailers to their locomotives, and use their Update to set the correct position based on the locomotive itself.

    @Kobix: that seems to be because you didn't set HOTween to be permanent, so when all tweens end it gets destroyed, and is recreated when a new tween is needed, thus also restarting all the coroutines. I would recommend using HOTween.Init as mentioned in the best practices.

    @zhuchun: I wouldn't want HOTween to manage raycasts, since they're better implemented case by case (though you could always create a TweenPlugin that handles that) :p Glad you solved it in the meantime :)
     
  15. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hello izitmee

    i d like to do i weapon fire projectil using hotween, but the HOTween.By(myObject, 1, "myProperty", 2); doesn t seem to behave right for me, i need something like a move forward and if i do any rotation on the object it will still move forward relative to his rotation.

    does it make sense?
     
  16. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Makes sense :) You have simply to tween the localPosition instead than the position of your object, and then when you rotate its parent the tween will be rotated accordingly.
     
  17. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hi izitme
    weird i try this , put that script onmy cube.
    void Start () {

    HOTween.To(this.transform, 1, "localPosition", new Vector3(10,0,0),true);

    }
    work fine if i translate from the editor, but when i manually rotate the cube i would expect to get the result as shown on the picture 2, but it just translate without taking in account the rotation

    $simpleRotation.jpg

    as that the correct behavior or do i miss something here?
     
    Last edited: Apr 18, 2014
  18. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi :)

    That should work exactly as your picture, but you have to put your cube inside a container gameObject, and then rotate the container and not the cube (otherwise, localPosition will be the same as position). All this, while still keeping the tween tied to your cube, and not the container.
     
  19. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    oh i see, that was the trick, thanks for the hint izitmee. work like a charm now
     
  20. nkhajanchi.mg14

    nkhajanchi.mg14

    Joined:
    Mar 6, 2014
    Posts:
    13
    Hi,

    I am working on a project which will be for Android, WP8 and Windows Store all three platforms. And I want to use HOTween in my project. As mentioned that for WP8 I need to use HOTweenMicro and for other platforms use normal HOTWeen.

    One way is that when I compile for WP8 I copy HOTweenMicro dlls in plugins folder and when compiling for Android I again overwrite normal HOTween DLLs. But that is not very streamlined and correct way of doing this.

    I want to know how can automate this process, using both HOTween and HOTWeenMicro in same project and just and when I change Build setting to Android HOTween get used and when Build setting change to WP8 HOTweenMicro get used.

    I know we write os specific code using compiler directives (#if, #define etc.) but I don't know how to include 2 different plugins having same name (Holoville.HOTween) but from different DLLs for different OS.

    Thanks
     
  21. SupremeBeing

    SupremeBeing

    Joined:
    Jun 28, 2013
    Posts:
    7
    What is the best way to use HoTween inside the Update() method when the position I am tweening to changes slightly every Update() or so?

    At the moment I am using the 'OverwriteManager' to clean up all the extra tweens which works ok. Though it throws a lot of warnings about destroying redundent tweeners - this is easily fixed by changing the warning level. Just wondering if there is a cleaner way to do this.

    I tried killing the tweener before recreating it every time but that doesn't seem to work quite as expected.
     
  22. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @nkhajanchi.mg14: HOTween and HOTweenMicro share the same DLL name because they can't live together in the same project. That was the only solution to allow the same code to work for both. So the only way you could automate builds would be to create a custom build panel (which is always a very useful thinig), which replaces the HOTween files with the correct version before building. You might want to check out Advanced Builder, where you might be able to implement something like that with his OnPreBuild/OnPostBuild methods (but ask the author first, to be sure it's really possible).

    @SupremeBeing: if you're changing a tween endValue inside each Update, I would definitely recommend not to use a tween engine for that, since it would be overkill. Instead, you should move your object using Vector3.SmoothDamp or something like that.
     
  23. nkhajanchi.mg14

    nkhajanchi.mg14

    Joined:
    Mar 6, 2014
    Posts:
    13
    @Izitmee Thanks for your quick reply. I will surely try it out.
     
  24. EasyPlay

    EasyPlay

    Joined:
    Mar 23, 2014
    Posts:
    8
    HOTween is a great tween engine,thoght I used itween before.HOTween can do more than itween especial on fade in/out.Now I have another question:
    1, I have a tk2dsprite gameobject,I want it move orient to path;
    2, I have realize it on itween,now I want to use HOTween in my 2D project ,not two engine.
    3, I use the example pathbasic,I find it work well in 3D,but In 2D,I find some problem.
    $moveonpath1.png
    the problem is :
    1,first loop it maybe work well,but move some loop,it look like this:
    $movetopath2.png
    I find it rotate and look error in 2D.

    Can you tell me how to make tk2dSprite or Sprite orient to path in 2D?
    I work in Mac and unity3d 4.3.4f.
     
  25. WhiteCastle

    WhiteCastle

    Joined:
    Sep 6, 2013
    Posts:
    14
    I have an app with a dynamic path of waypoints (an infinite runner) and I am struggling with maintaining a constant speed. Basically I spawn the next section (small terrain) as needed (immediately after exiting and destroying a previous section) and stop the existing PlugVector3Path tween and create a new one with the new waypoints added starting with my current position and restart the tween. The problem I am having is in setting the duration for the tween. I set a specific duration per terrain section of 15 seconds and then set the duration to number of sections * 15 and the end result is that it speeds up and slows down. I assume the reason has something to do with the fact that each terrain section has a different number of waypoints. Thus, if I have a three terrain sections spawned at one time and they have (15, 17, 15) waypoints respectively and then the next time I create the tween I have (17, 15, 17) waypoints respectively the effective speed is different since the duration is constant and there are more waypoints to cross. Is there a better way to accomplish this?
     
  26. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @EasyPlay: thanks, glad you like it :) I still have to test PlugVector3Path with Unity's 2D system. Did you try to use the LockPosition additional method parameter, to lock the Z axis? Do you still get the same issue?

    @WhiteCastle: the constant path speed is pased on the lenght of the path, not the number of waypoints, so that can't be an issue. Instead, probably each path has a different length. You should use the SpeedBased method parameter, which should achieve what you want.
     
  27. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @EasyPlay: by the way, if you still have issues after locking the Z axis, can you create a sample project which replicates those issues, so I can use that as a test?
     
  28. EasyPlay

    EasyPlay

    Joined:
    Mar 23, 2014
    Posts:
    8
    thanks very much,it works perfect lock Z axis,the code below:

    HOTween.To( target1, 8, new TweenParms().Prop( "position", new PlugVector3Path( path ).ClosePath().LockPosition(Axis.Z).OrientToPath() ).Loops( -1 ).Ease( EaseType.Linear ).OnStepComplete( PathCycleComplete ) );
     
  29. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Whew, great to know, thanks :)
     
  30. WhiteCastle

    WhiteCastle

    Joined:
    Sep 6, 2013
    Posts:
    14
    @Izitmee - Thanks so much for the suggestion. I have not had time yet to try it but it sounds very promising.
     
  31. kildaver

    kildaver

    Joined:
    Jun 14, 2012
    Posts:
    2
    Code (csharp):
    1. Assets/Holoville/HOPath/PathPreview.cs(2,7): error CS0246: The type or namespace name
    2.  
    3. `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    I found a fix. in PathPreview.cs, remove :
    Code (csharp):
    1. using UnityEditor;
    and replace it with:
    Code (csharp):
    1. #if UNITY_EDITOR
    2. using UnityEditor;
    3. #endif
    In addition, after line 156, add:
    Code (csharp):
    1. if UNITY_EDITOR
    Conclude by placing this line at 179 (above the comment about drawing the path control points:
    Code (csharp):
    1. #endif
    That's it. Doing that allowed me to compile my project, and I can still use the editor.

    Hope this helps!
     
  32. Superflat

    Superflat

    Joined:
    Mar 19, 2009
    Posts:
    354
    Hello!

    The editor bug i mentioned like... 20 pages back has reared it's head. I cant add any new tweens with the editor. When i click the selection get's cancelled right away and the list of tweens is shown again. This time i have made a video. Please advise.

    https://www.youtube.com/watch?v=NI43K-Da9d4

    You'll see that I get through at one point but it just get's cancelled on the next click.
     
  33. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Still puzzled by this issue. Nobody else reported it, and here everything works. Can you try to detach the panel and keep it floating? Does it still happen? What version of Unity are you using? Did you download the latest editor version? If everything else fails, can you send me that project, or possibly a smaller one which replicates the issue, so I can check it out?
     
  34. Superflat

    Superflat

    Joined:
    Mar 19, 2009
    Posts:
    354
    Working on a Macbook pro. Latest editor both Hotween and Unity.

    Tried deleting all HOTween stuff and reimporting but it didnt fix it. Floating the panel doesnt work either.

    [Edit] A new scene seems to work fine. Any way i can save my tweens or something?
    [Edit 2] Okay it seems to be related to NGUI components. If i disable, say, a UILabel, then i can tween fine. So my guess is there is something going wrong with the way you get your variables to tween or something. Which is weird as it worked fine.
     
    Last edited: Apr 27, 2014
  35. Superflat

    Superflat

    Joined:
    Mar 19, 2009
    Posts:
    354
    Cancel that. Seems to still do it even with NGUi disabled. It's like it's not consuming my first click and then applies the click to the underlaying GUI layout.

    [Edit] Problem seemed to have gone away after updating NGUI. Which is weird as i hadnt updated any of the packages and it worked fine before.
     
    Last edited: Apr 27, 2014
  36. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Seems weird that NGUI started giving problems without any update happening, but maybe it had some auto-generated script that was created on certain conditions, and which conflicted with other editors? Anyway, glad it's solved now :)
     
  37. ks1364

    ks1364

    Joined:
    Apr 30, 2014
    Posts:
    7
    hi guys
    how i can change z axis with y axis in hotween?
    because i use 2d part in unity 4.3.4 and i can't use hotween to move curved gameobject.
    can everybody helps me please?
     
  38. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hey ks1364. You mean how to use PlugVector3Path with 2D? As long as you pass the correct waypoints everything works.
     
  39. Spikeh

    Spikeh

    Joined:
    Jun 7, 2013
    Posts:
    24
    Hey Izitmee!

    Just started getting this error, and I'm not entirely sure why - double clicking doesn't take me anywhere (I assume it's something that Hotween is doing inside its internal Update() method):

    NullReferenceException: Object reference not set to an instance of an object
    Holoville.HOTween.Tweener.Update (Single p_shortElapsed, Boolean p_forceUpdate, Boolean p_isStartupIteration, Boolean p_ignoreCallbacks, Boolean p_ignoreDelay) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:809)
    Holoville.HOTween.Tweener.Update (Single p_shortElapsed, Boolean p_forceUpdate, Boolean p_isStartupIteration, Boolean p_ignoreCallbacks) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Tweener.cs:684)
    Holoville.HOTween.Core.ABSTweenComponent.Update (Single p_elapsed) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/Core/ABSTweenComponent.cs:954)
    Holoville.HOTween.HOTween.DoUpdate (UpdateType p_updateType, Single p_elapsed) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:2173)
    Holoville.HOTween.HOTween.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__HOTween.Assembly/HOTweenV1/HOTween.cs:728)


    Just upgraded to the latest version too, just in case it was a bug. It's probably something I'm doing, but the error message is not very helpful...

    Any ideas what I'm doing / how I can find out where the error is?
     
  40. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    It seems like you created and started an empty Sequence somewhere in your code. Mhmm will have to make that error more readable though.
     
  41. Spikeh

    Spikeh

    Joined:
    Jun 7, 2013
    Posts:
    24
    The only tween that's in progress is as follows:

    Code (csharp):
    1.  
    2.     private void TweenToNextWaypoint() {
    3.         if (Waypoints == null || Waypoints.Count <= 0) {
    4.             return;
    5.         }
    6.  
    7.         // Always tween to the second waypoint
    8.         var nextWaypoint = Waypoints[_waypointIndex];
    9.         //Debug.Log("{0} Duration: {1}, Pause Duration: {2}, Angle: {3}, Next Waypoint Index: {4}", DebugPrefix,
    10.         //  nextWaypoint.Duration, nextWaypoint.Pause, nextWaypoint.Angle, _waypointIndex);
    11.  
    12.         _currentTween = HOTween.To(CameraTransform,
    13.             nextWaypoint.Duration,
    14.             new TweenParms()
    15.                 .Prop("rotation", nextWaypoint.Angle)
    16.                 .Ease(EaseType.EaseInOutQuad)
    17.                 .Delay(nextWaypoint.Pause)
    18.                 .OnStart(() => SetCameraMode(CameraMode.Scanning)) // Set up scanning mode
    19.                 // Recurse
    20.                 .OnComplete(() => {
    21.                     Debug.Log("{0} Tweening to next waypoint...");
    22.                     TweenToNextWaypoint();
    23.                     Debug.Log("{0} Finished tweening");
    24.                 })
    25.             );
    26.  
    27.         // Increment the index for the waypoints
    28.         _waypointIndex++;
    29.  
    30.         if (_waypointIndex >= Waypoints.Count) {
    31.             // We've reached the max limit of waypoints, reset to the first one
    32.             _waypointIndex = 0;
    33.         }
    34.     }
    35.  
    This method is called by another method (one shot), then recurses (in OnComplete()).

    It was working fine until I started refactoring, not sure why it's not working now :(
     
    Last edited: May 1, 2014
  42. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Spikeh can you edit your post and use the CODE tags around your code? Otherwise I'm having a very bad time reading it :p
     
    Last edited: May 1, 2014
  43. Spikeh

    Spikeh

    Joined:
    Jun 7, 2013
    Posts:
    24
    Sorry! Sorted now :)
     
  44. Spikeh

    Spikeh

    Joined:
    Jun 7, 2013
    Posts:
    24
    just commented out the following line, and it seems to work (but obv I don't get the desired results):

    .OnStart(() => SetCameraMode(CameraMode.Scanning)) // Set up scanning mode

    I've written debug statements all over the SetCameraMode() bit, but I can't figure out where the null reference is occurring
     
  45. Spikeh

    Spikeh

    Joined:
    Jun 7, 2013
    Posts:
    24
    Figured it out. I was trying to kill the tween that was currently being executed, within the OnStart() method.
     
  46. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Sorry if it took me a while to come back, but glad you solved it already :)
     
  47. ks1364

    ks1364

    Joined:
    Apr 30, 2014
    Posts:
    7
    hey Izitmee
    thanks for reply
    yes how i use PlugVector3Path with 2D? or better i say, how i use OrientToPath?
    meanwhile, i use HOPath, Visual Path Editor by Vevusio and i can just add waypoints, what do you mean "As long as you pass the correct waypoints everything works."
    sorry my friend i'm new in unity.please more explanation
     
  48. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    I meant that if you pass waypoints that don't use the Z axis, like Unity 2D does, everything should work. To use OrientToPath with 2D, you do like this, eventually using the lockAxis parameter of the method to lock required axis:

    Code (csharp):
    1.  
    2. ...
    3.   .Prop("position", new PlugVector3Path(myPath).OrientToPath())
    4. ...
    5.  
     
  49. ks1364

    ks1364

    Joined:
    Apr 30, 2014
    Posts:
    7
    of course i don't use the z axis.the z axis in all waypoints equals zero but when press play everything change, the z pozition,z rotation, ...
     
  50. ks1364

    ks1364

    Joined:
    Apr 30, 2014
    Posts:
    7
    i found it.i must use Prop("rotation",...).but i don't know how tolook at the next waypoint by rotate on the z axis only.for example:
    can you help me Izitmee?