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

DOTween (HOTween v2), a Unity tween engine

Discussion in 'Assets and Asset Store' started by Demigiant, Aug 5, 2014.

  1. meross

    meross

    Joined:
    Jan 25, 2015
    Posts:
    2
    Hello.
    I am in trouble because I do not know the cause of the error.

    IndexOutOfRangeException: Array index is out of range.
    DG.Tweening.Plugins.PathPlugin.SetChangeValue (DG.Tweening.Core.TweenerCore`3 t)
    DG.Tweening.Tweener.DoStartup[Vector3,Path,PathOptions] (DG.Tweening.Core.TweenerCore`3 t)
    DG.Tweening.Core.TweenerCore`3[UnityEngine.Vector3,DG.Tweening.Plugins.Core.PathCore.Path,DG.Tweening.Plugins.Options.PathOptions].Startup ()
    DG.Tweening.Core.TweenManager.Update (UpdateType updateType, Single deltaTime, Single independentTime)
    DG.Tweening.Core.DOTweenComponent.Update ()

    When I used 'DOLocalPath ()' and added 'Kill (true)' processing, it came to be generated, but since it is processing a lot, it is occurring in which object I do not know, I am in trouble.

    Does anyone have any hints?
     
  2. Arcanebits

    Arcanebits

    Joined:
    Dec 18, 2013
    Posts:
    108
    Help Needed!
    Dot Tween work nicely under Unity, but when compiled it does nothing
    Updated to the latest version and runing unity 2017.1.2f1 and nothing...

    Everything works inside unity, but when the game its copiled it acts like it werent even installed.
    Any one can help?
    Aldo
     
  3. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    94
    Hi everyone,
    Would like to achieve a (recyclable) scrolling list with DoTween.
    Is there any resource showing how to do this please?
    Any help is welcome ;)

    In this example, Object 1 and Object 9 are hidden. When scroll down occurs,Object 9 image is loaded, then Object 2 to 9 scroll up. Finally, Object 1 take the place of previous Object 9...ready for next scroll
     
  4. GS796

    GS796

    Joined:
    Dec 16, 2016
    Posts:
    24
    Hi,
    I am trying to build for Universal Windows Platform (UWP)- and I get this error using the latest Dotween Hyper Compatible Version (or the normal version) with "Safe Mode" on or off.

    "'DOTween.dll' ---> System.ArgumentNullException: Value cannot be null."

    Is there any workaround for this issue, or do I need to remove Dotween from the project?
    Thanks,


    Failed running C:\Program Files\Unity\Editor\Data\il2cpp/build/UnityLinker.exe --api=NET_4_6 -out="C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\tempStrip" -l=none -c=link --link-symbols -x="C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Core.xml" -f="C:\Program Files\Unity\Editor\Data\il2cpp\LinkerDescriptors" -x "C:\Users\Public\Documents\Unity Projects\Projects\TestGame/Temp\StagingArea\Data/methods_pointedto_by_uievents.xml" -x "C:\Users\Public\Documents\Unity Projects\Projects\TestGame/Temp\StagingArea\Data/UnityEngine.xml" -x "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\preserved_derived_types.xml" -x "C:\Program Files\Unity\Editor\Data\il2cpp\LinkerDescriptors\mscorlib45.xml" -x "C:\Program Files\Unity\Editor\Data\il2cpp\LinkerDescriptors\System45.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Accessibility.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\AI.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Animation.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\AR.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\AssetBundle.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Audio.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Cloth.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Core.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\CrashReporting.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Director.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\GameCenter.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Grid.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\ImageConversion.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\IMGUI.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Input.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\JSONSerialize.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\ParticlesLegacy.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\ParticleSystem.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\PerformanceReporting.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Physics.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Physics2D.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\ScreenCapture.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\SharedInternals.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\SpriteMask.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\SpriteShape.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\StyleSheets.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Terrain.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\TerrainPhysics.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\TextRendering.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Tilemap.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\UI.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\UIElements.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\UNET.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\UnityAnalytics.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\UnityConnect.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\UnityWebRequest.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\UnityWebRequestAudio.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\UnityWebRequestTexture.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\UnityWebRequestWWW.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Vehicles.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Video.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\VR.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Web.xml" -x "C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport\Whitelists\Wind.xml" -x "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Assets\link.xml" -x "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Assets\FacebookSDK\link.xml" -x "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Assets\Plugins\UnityPurchasing\script\link.xml" -d "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\Assembly-CSharp-firstpass.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\Assembly-CSharp.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\Assembly-UnityScript-firstpass.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\Assembly-UnityScript.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\UnityEngine.UI.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\DOTween.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\Facebook.Unity.Settings.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\PlayMaker.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\TextMeshPro-1.0.55.2017.2.0b12.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\UnityEngine.Analytics.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\I18N.CJK.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\I18N.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\I18N.MidEast.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\I18N.Other.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\I18N.Rare.dll" -a "C:\Users\Public\Documents\Unity Projects\Projects\TestGame\Temp\StagingArea\Data\Managed\I18N.West.dll"

    stdout:
    Fatal error in Unity CIL Linker
    Mono.Linker.MarkException: Error processing method: 'System.Void DG.Tweening.TweenParams::.cctor()' in assembly: 'DOTween.dll' ---> System.ArgumentNullException: Value cannot be null.
    Parameter name: instruction
    at Mono.Cecil.Cil.InstructionOffset..ctor(Instruction instruction)
    at Mono.Cecil.Cil.CodeReader.ReadScope(ScopeDebugInformation scope)
    at Mono.Cecil.Cil.CodeReader.ReadScopes(Collection`1 scopes)
    at Mono.Cecil.Cil.CodeReader.ReadScope(ScopeDebugInformation scope)
    at Mono.Cecil.Cil.CodeReader.ReadScopes(Collection`1 scopes)
    at Mono.Cecil.Cil.CodeReader.ReadScope(ScopeDebugInformation scope)
    at Mono.Cecil.Cil.CodeReader.ReadDebugInfo()
    at Mono.Cecil.Cil.CodeReader.ReadMethodBody()
    at Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
    at Mono.Cecil.MethodDefinition.<>c.<get_Body>b__41_0(MethodDefinition method, MetadataReader reader)
    at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TRet& variable, TItem item, Func`3 read)
    at Mono.Cecil.MethodDefinition.get_Body()
    at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
    at UnityLinker.Steps.UnityMarkStep.ProcessMethod(MethodDefinition method)
    at Mono.Linker.Steps.MarkStep.ProcessQueue()
    --- End of inner exception stack trace ---
    at Mono.Linker.Steps.MarkStep.ProcessQueue()
    at Mono.Linker.Steps.MarkStep.ProcessEntireQueue()
    at Mono.Linker.Steps.MarkStep.Process()
    at UnityLinker.Steps.UnityMarkStep.Process(LinkContext context)
    at Mono.Linker.Pipeline.Process(LinkContext context)
    at UnityLinker.UnityDriver.Run()
    at UnityLinker.UnityDriver.RunDriver()
    stderr:

    UnityEngine.Debug:LogError(Object)
    UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:128)
    UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:73)
    UnityEditorInternal.AssemblyStripper:RunAssemblyLinker(IEnumerable`1, String&, String&, String, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:89)
    UnityEditorInternal.AssemblyStripper:StripAssembliesTo(String[], String[], String, String, String&, String&, String, IIl2CppPlatformProvider, IEnumerable`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:82)
    UnityEditorInternal.AssemblyStripper:RunAssemblyStripper(String, IEnumerable, String, String[], String[], String, IIl2CppPlatformProvider, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:204)
    UnityEditorInternal.AssemblyStripper:StripAssemblies(String, IIl2CppPlatformProvider, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:114)
    UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:152)
    UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry, Boolean) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:34)
    PostProcessUAPIl2Cpp:RunIL2CPP() (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessUAPIl2Cpp.cs:378)
    PostProcessWinRT:process() (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessWinRT.cs:231)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  5. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    789
  6. GS796

    GS796

    Joined:
    Dec 16, 2016
    Posts:
    24
    @flashframe
    Thanks for the response. I missed that post.
    I tried that version but I get a similar error:

    stdout:
    Fatal error in Unity CIL Linker
    Mono.Linker.MarkException: Error processing method: 'System.Void DG.Tweening.TweenExtensions::Kill(DG.Tweening.Tween,System.Boolean)' in assembly: 'DOTween.dll' ---> System.ArgumentNullException: Value cannot be null.

    Is there some other compatibility setting I should be aware of?
     
  7. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    789
    The only other issue I’m aware of with UWP was that safe mode was causing errors. Not sure if that was fixed or not. You might want to try contacting @demigiant on twitter. He’s very responsive there.
     
  8. Riddlah

    Riddlah

    Joined:
    Mar 26, 2014
    Posts:
    19
    Hi

    I want tween multiple objects.
    Where i put tween inside loop. Tweens does not work. It tweens either one object or none objects. Any help please ?

    Code (CSharp):
    1.  
    2. for (int i = 0; i < tracks.Length; i++)
    3. {
    4.   DOTween.To(() => tracks[i].GetComponent<RectTransform>().anchoredPosition, x => tracks[i].GetComponent<RectTransform>().anchoredPosition = x,
    5.   new Vector2(0, 0), 2f);
    6. }
     
  9. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    789
    Does it make a difference if you use the shortcut?

    Code (CSharp):
    1. for (int i = 0; i < tracks.Length; i++)
    2. {
    3.     RectTransform r = tracks[i].GetComponent<RectTransform>();
    4.     r.DOAnchorPos(new Vector2(0f,0f), 2f);
    5. }
     
  10. Riddlah

    Riddlah

    Joined:
    Mar 26, 2014
    Posts:
    19
    Thank you very much :) It works.
     
  11. GilbertoBitt

    GilbertoBitt

    Joined:
    May 27, 2013
    Posts:
    111
  12. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Your proposal is intriguing to me.. What do you suppose would be the benefit?
    The big -purported- advantage of MEC are the use of CoRoutines without a Monobehaviour;
    No Garbage Allocation; And Faster?

    DoTween contains exactly ONE necessary Monobeahiour: DOTweenComponent
    There are 6 total Corountines to be found :
    Code (CSharp):
    1.  
    2.         // CALLED BY TweenExtensions, creates a coroutine that waits for the tween to be complete (or killed)
    3.         internal IEnumerator WaitForCompletion(Tween t)
    4.         {
    5.             while (t.active && !t.isComplete) yield return null;
    6.         }
    7.  
    8.         // CALLED BY TweenExtensions, creates a coroutine that waits for the tween to be rewinded (or killed)
    9.         internal IEnumerator WaitForRewind(Tween t)
    10.         {
    11.             while (t.active && (!t.playedOnce || t.position * (t.completedLoops + 1) > 0)) yield return null;
    12.         }
    13.  
    14.         // CALLED BY TweenExtensions, creates a coroutine that waits for the tween to be killed
    15.         internal IEnumerator WaitForKill(Tween t)
    16.         {
    17.             while (t.active) yield return null;
    18.         }
    19.  
    20.         // CALLED BY TweenExtensions, creates a coroutine that waits for the tween to reach a given amount of loops (or to be killed)
    21.         internal IEnumerator WaitForElapsedLoops(Tween t, int elapsedLoops)
    22.         {
    23.             while (t.active && t.completedLoops < elapsedLoops) yield return null;
    24.         }
    25.  
    26.         // CALLED BY TweenExtensions, creates a coroutine that waits for the tween to reach a given time position (or to be killed)
    27.         internal IEnumerator WaitForPosition(Tween t, float position)
    28.         {
    29.             while (t.active && t.position * (t.completedLoops + 1) < position) yield return null;
    30.         }
    31.  
    32.         // CALLED BY TweenExtensions, creates a coroutine that waits for the tween to be started (or killed)
    33.         internal IEnumerator WaitForStart(Tween t)
    34.         {
    35.             while (t.active && !t.playedOnce) yield return null;
    36.         }
    37.  
    38.  
    39. Copyright (c) 2015 Daniele Giardini, Demigiant
    40.  
    41. To check out DOTween license, visit this page: http://dotween.demigiant.com/license.php
    42.  
    43. In short:
    44. - You can freely use DOTween in both commercial and non-commercial projects
    45. - You can redistribute verbatim copies of the code, along with any readme files and attributions
    46. - You can modify the code only for your own use and you cannot redistribute modified versions (but you can send pull requests to me)
    47.  
    These CoRoutines do not generate garbage.

    So that leaves... Faster?
    Do you find DoTween slow?

    I, myself, am a fan of MEC and use it in most of my projects.
    It just doesn't need integration with DoTween. No point.

    Having said that, you could easily do it.
    Download the source from GitHub and replace the StartCoroutine calls in TweenExtensions.cs with the MEC calls.
    You'll have to compile the DLLs yourself.
     
    Last edited: Dec 14, 2017
    GilbertoBitt likes this.
  13. redmugstudios

    redmugstudios

    Joined:
    Dec 21, 2016
    Posts:
    60
    Is it doable in DOTween to crossfade between two different sprites? Lets say an event was triggered and I want this particular sprite on the ground to change to a different sprite gradually, like for 5 seconds duration.
     
  14. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Yes.
    Entirely possible.
    A piece of cake, even.
    However, there is no "Cross Fade Sprite" shortcut included in the box.
    You'll need to code it yourself.
    I strongly suggest reading the documentation
    SpriteRenderer.DOFade(float to, float duration)
     
  15. redmugstudios

    redmugstudios

    Joined:
    Dec 21, 2016
    Posts:
    60
    That's good to know. I'll check this out.
     
  16. Percy-Pea

    Percy-Pea

    Joined:
    Aug 31, 2014
    Posts:
    75
    Hi there, I have a problem :(

    I use : DOTween.ToAlpha(() => _vignette.color, x => _vignette.color = x, 1, 5f);

    Where _vignette is an 'Image' component (Unity UI thingermy).

    However, how do I kill it?

    _vignette.DOKill(); doesn't seem to work (returns 0) and if I try _vignette.color.DOKill(); it doesn't like it (I guess as it's not a component.

    Is there another way to kill the tween part way though?

    Thanks
     
  17. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    789
    You can use Kill() if you have a reference to the Tween, or DOTween.Kill(targetOrID) if you use the shortcut.

    So you could do:

    Code (CSharp):
    1. Tween t = DOTween.ToAlpha(() => _vignette.color, x => _vignette.color = x, 1, 5f);
    2. t.Kill();
    or

    Code (CSharp):
    1. _vignette.DOFade(1f, 5f);
    2. DOTween.Kill(_vignette); //possibly _vignette.transform
    Notice the shortcut used for the Image component

    http://dotween.demigiant.com/documentation.php#shortcuts

    Edit: Guess you need the Pro version to use the Image shortcuts. But for $15 everyone should buy the pro version and support the developer IMHO :)
     
    Last edited: Dec 22, 2017
  18. Percy-Pea

    Percy-Pea

    Joined:
    Aug 31, 2014
    Posts:
    75
    Thanks very much, DoFade worked perfectly
     
    flashframe likes this.
  19. Frp529

    Frp529

    Joined:
    Apr 26, 2017
    Posts:
    3
    @Izitmee I'd like to learn how DOTween works under non-runtime environments?
     
  20. dreadthread

    dreadthread

    Joined:
    Feb 2, 2016
    Posts:
    1
    I'm trying to get a tween to run throughout the duration of a sequence but its not working. According to the documentation the last line there should do what I want it to:
    Sequence fadeSequence = DOTween.Sequence();
    fadeSequence
    .Append(turnText.DOFade(0, 0.25f))
    .Append(turnText.DOText(turn + " Turn", 0))
    .Append(turnText.DOColor(transitionColor, 0))
    .Append(turnText.DOFade(1, 0.25f))
    .Insert(0, turnText.DOScale(5, fadeSequence.Duration()));
     
  21. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    I'm using DOTween and I want to rotate an object by X degrees, and then later rotate it back, and I'm using this code:

    Code (CSharp):
    1. // Rotate 90 on X-axis
    2. transform.DOLocalRotate(new Vector3(90, 0, 0), 1f);
    3.  
    4. // Then a little later
    5. transform.DOLocalRotate(new Vector3(0, 0, 0), 1f);
    It kind of looks cool, like a ninja spinning around, but that's not what I want, I just want it to go back to 0 on all axis. I get the impression that the X-axis rotates as it should, but Y and Z are rotated 360 to get back to 0 once again which causes the spinning.

    How do I stop this behaviour? I tried both DOLocalRotate and DORotate. I couldn't find options to restrict to one axis here, and I can't find DORotateX similar to DOMoveX and DOScaleX. Why isn't rotation among the shortcuts?

    Thanks!
     
  22. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    789
    Try:

    Code (CSharp):
    1. // Rotate 90 on X-axis
    2. transform.DOLocalRotate(new Vector3(90f, 0, 0), 1f, RotateMode.LocalAxisAdd);
    3. // Then a little later
    4. transform.DOLocalRotate(new Vector3(-90f, 0, 0), 1f, RotateMode.LocalAxisAdd);
     
  23. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    Thanks a lot @flashframe, that worked perfectly. Seems to have missed that in the docs.. :/
     
  24. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    Hmm, it works when the object isn't rotated in any other direction, but if the object have fallen over, it doesn't set itself to (90,0,0) which is what I want, due to this function just adds 90 to x. Is there any way I can do what I did in my original script to make it toggle between 0,0,0 and 90,0,0 without crazy 360 spinning?

    I tried this, but since I can't edit that variable directly, I think i need to rewrite it somehow...
    Code (CSharp):
    1. DOTween.To( () => transform.eulerAngles.x, x => transform.eulerAngles.x = x,targetRotation,1f).OnComplete(RotationComplete);
    (Cannot modify a value type return value of `UnityEngine.Transform.eulerAngles'. Consider storing the value in a temporary variable)

    Any ideas? :)
     
  25. zacksawyer

    zacksawyer

    Joined:
    Jun 13, 2017
    Posts:
    9
    DOTWeen rotation around X axis:

    Latest version of DoTween 1.1.640 when I incrementally rotate a game object around X (for instance by 20 degree like 20, 40, 60, 80 and 100), once it passes 90 degree instead of rotating further it goes back to under 90 with some numerical error on other axis (like 1.5 degree rotation on y and z axis). No matter what is the rotation mode like fast360 or anything else the problem is there. This only happens when the object is rotated around X axis. (Y and Z are fine)
    I assumed it might be a bug. I tested on a blank project and applied rotation to a cube primitive.
     
    Last edited: Jan 4, 2018
  26. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    789
    Not sure if it solves your original problem, but this should fix the error in the second approach.

    Code (CSharp):
    1. Vector3 rot = transform.eulerAngles;
    2. DOTween.To( () => rot.x, x => rot.x = x,targetRotation,1f).OnUpdate(()=> { transform.eulerAngles = rot; }).OnComplete(RotationComplete);
    3.  
     
  27. Drunken-Monkey

    Drunken-Monkey

    Joined:
    Dec 15, 2011
    Posts:
    95
    I having a problem looping the following sequence. It jumps away from new relative location it should be starting at.

    Code (CSharp):
    1.     s.Append(transform.DOMoveX(4.0f, 5).SetRelative().SetEase(Ease.Linear));
    2.         s.Append(transform.DOMoveY(-0.5f, 1).SetRelative().SetEase(Ease.Linear));
    3.         s.Append(transform.DOMoveX(-4.0f, 5).SetRelative().SetEase(Ease.Linear));
    4.         s.Append(transform.DOMoveY(-0.5f, 1).SetRelative().SetEase(Ease.Linear));
    5.         s.SetLoops(-1, LoopType.Incremental);
    It may just be me being new to dotween., but the movement should be space invaders like.
     
  28. M-P-F

    M-P-F

    Joined:
    Apr 22, 2015
    Posts:
    12
    What is the process for animating the "Top" property of a RectTransform (Unity 5.6.3). Maybe I'm blind, but I can't find that anywhere: changing the SizeDelta does all sorts of weird things to Left, Right and Bottom values, too.

    Element is this:
    upload_2018-1-11_13-49-16.png

    I want to Tween the "Top" part of those values, leaving the others intact.
     
  29. Drunken-Monkey

    Drunken-Monkey

    Joined:
    Dec 15, 2011
    Posts:
    95

    Ok, I bought the Pro version and got it working with Paths in the Editor, but if I do the same thing in code, it doesn't loop.

    Code (CSharp):
    1.   public Vector3[] waypoints = new[]
    2.     {
    3.         new Vector3(  5,      0,  0),
    4.         new Vector3(  5, -0.25f,  0),
    5.         new Vector3( -5, -0.25f,  0),
    6.         new Vector3( -5, -0.5f,  0)
    7.     };
    8.  
    9.    private void EnemyMovementPath()
    10.     {
    11.         transform.DOPath(waypoints, 20, PathType.Linear).SetEase(Ease.Linear).SetRelative().SetLoops(-1,LoopType.Incremental);
    12.     }
    13.  
    Any ideas?
     
  30. Drunken-Monkey

    Drunken-Monkey

    Joined:
    Dec 15, 2011
    Posts:
    95
    Then I am confused on the purpose of .SetRelative and LoopType.Incremental. Using the editor with these options does exactly what I expected, just not in code. The path becomes relative from the start point.

    upload_2018-1-14_16-24-49.png
     
  31. exoter

    exoter

    Joined:
    Apr 25, 2015
    Posts:
    10
    I've got a problem with the latest version of DOTween and 2017.3. This worked just fine on 2017.2

    Code (CSharp):
    1.  
    2. DOTween.To(() => this.mainPanel.preferredHeight, x => this.mainPanel.preferredHeight = x, this.mainPanelMaxHeight, UIConsts.Animation.Speed.S300);
    3. this.subPanel.DOMoveY(0, UIConsts.Animation.Speed.S300);
    4.  
    mainPanel has a LayoutElement script attached. subPanel is child of the mainPanel.
    Basically what this does is expand the parent and slowly move down the child making a nice effect.
    But now only one of those works -> if I comment the first one the second one works and vice versa.

    Any ideas are welcomed
     
  32. MR_Jaxin

    MR_Jaxin

    Joined:
    Apr 12, 2017
    Posts:
    2
    I want to set up the dotween motion curve, for example, just start fast, then slow down for a few seconds, and then get faster. Can you tell me how to set up?
     
  33. fazraz

    fazraz

    Joined:
    Feb 27, 2015
    Posts:
    14
    How can I make an object move continuously in one direction without coming to a stop or having to loop?
     
  34. Tim0n

    Tim0n

    Joined:
    Mar 11, 2015
    Posts:
    3
    Hey just started using DoTween for a project to test some things out. I am currently using transform.DoJump to get my character to do an arc as he moves to the right, this is working pretty good but I have one problem though.

    Even if I rotate my character 90 degrees the character will still jump towards the global upvector. Is there any way to make the DOJump command jump in the characters local upvector or is it possible to make a custom sequence that works exactly like DOJump but which only uses DOMove or something similar?
     
  35. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    789
    Have you tried using DOLocalJump instead? That uses localPosition instead of position to move the y-axis, so should give you the result you're looking for.

    EDIT. Actually, I guess it won't, since rotation won't affect local y. How about using parenting to achieve this? Have a child object that performs the jump, and control rotation on the parent object?
     
    Last edited: Jan 23, 2018
    Tim0n likes this.
  36. Tim0n

    Tim0n

    Joined:
    Mar 11, 2015
    Posts:
    3
    Ah sweet seems to work with parenting, thanks!
     
  37. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    I'm having trouble with SetLookAt at the end of a DoPath. On curved paths, the rotation snaps to some default position at the end of a path. The rotation tracks smoothly all along the path, but then snaps at the end to something wrong. After searching, I saw a similar bug discussed in the summer, but there was a post saying it was fixed in July. I'm wondering if that fix made it into the most recent AssetStore version dated August??? Or maybe it has reappeared in Unity 2017.2+???

    Here's the code:
    Code (CSharp):
    1. this.transform.DOPath(nextPath, duration, PathType.CatmullRom, PathMode.TopDown2D).SetEase(Ease.Linear).SetLookAt(0.1f);
    I noticed that PathType.Linear does not have this problem, but that pathtype also doesn't have smooth curves.
     
  38. Drunken-Monkey

    Drunken-Monkey

    Joined:
    Dec 15, 2011
    Posts:
    95
    Is this product supported by the developer anymore? And if so, whom would that be?
     
  39. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    789
    He’s very responsive on twitter.

    @demigiant
     
  40. ArtC0de

    ArtC0de

    Joined:
    Sep 7, 2015
    Posts:
    14
    Hello! Just bought the Pro Version of this software, I'm still trying to learn it but on YT there only 2 videos...
    I'm trying to start an animation from a script:
    From the Inspector Editor I already configure it how I would like to do it, I disabled "AutoPlay"
    But now how I start the animation?
    Like: I click on a GameObject and than I want to start the animation. It must simple no?
     
  41. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    ArtC0de likes this.
  42. ArtC0de

    ArtC0de

    Joined:
    Sep 7, 2015
    Posts:
    14
    I'm not very good at reading documentation, but somehow I did it! ahaha awsome software :)

    A question... it's possible to start the animation of all the game objects that are under one ROOT/PARENT?
     
    FuguFirecracker likes this.
  43. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    I'm pretty sure that's not a feature, but because Transform implements IEnumerable... It's trivial to do in a foreach loop.

    Code (CSharp):
    1.  
    2. foreach (Transform t in RootGameObject.transform)
    3.                 {
    4.                     t.DoMove(42,42,Skidoo);
    5.                 }
    6.  
     
    ArtC0de likes this.
  44. ArtC0de

    ArtC0de

    Joined:
    Sep 7, 2015
    Posts:
    14
    Man I'm really a newbie here, I'm trying to do this but doesnt work...

    Code (CSharp):
    1. public GameObject parent_1;
    2.  
    3.     private void Start()
    4.     {
    5.         parent_1 = GetComponentInChildren<GameObject>();
    6.     }
    7.     public void openGate()
    8.     {
    9.         foreach (Transform t in parent_1.transform)
    10.         {
    11.             t.DOPlay();
    12.         }
    13.        
    14.     }
     
  45. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    I don't know what you're trying to accomplish with the Start Method.
    You don't need to find anything in your Root... the foreach loop with discover those Transforms for you. HOW!? You ask... The Transform class implements the IEnumerable interface and thereby has a built in method to fetch those transform for you. So just Set your RootGameObject in the inspector.

    What script do you have attached to your child game objects?

    EDIT:
    Some actual working code
    Create an empty gameobject, make a bunch of cubes and parent them to the Empty.
    Attach script to the root and set root object in inspector
    Press play and watch all your cubes move to random locales

    Code (CSharp):
    1.  
    2. using DG.Tweening;
    3. using UnityEngine;
    4.  
    5. public class RootAround : MonoBehaviour
    6. {
    7.  
    8.     public GameObject Root;
    9.  
    10.     protected void Start()
    11.     {
    12.         foreach (Transform t in Root.transform)
    13.         {
    14.             t.DOMove(new Vector3(Random.Range(-10, 10), Random.Range(-10, 10), Random.Range(-10,10)), 3 );
    15.         }
    16.     }
    17. }
    18.  
    Okay... So you wanna control the individual tweens attached to gameObjects
    This goes on Root:
    Code (CSharp):
    1. using DG.Tweening;
    2. using UnityEngine;
    3.  
    4. public class RootAround : MonoBehaviour
    5. {
    6.  
    7.     public GameObject Root;
    8.  
    9.     protected void Start()
    10.     {
    11.         foreach (Transform t in Root.transform)
    12.         {
    13.             var tween = t.GetComponent<MyVerOwnTween>();
    14.             if (tween)
    15.             {
    16.                 Debug.Log("Got it");
    17.                 tween.MyTweener.Play();
    18.             }
    19.         }
    20.     }
    21. }
    22.  
    This [or whatever] is attached to the children:
    Code (CSharp):
    1. using DG.Tweening;
    2. using UnityEngine;
    3.  
    4. public class MyVerOwnTween : MonoBehaviour
    5. {
    6.  
    7.     public Tweener MyTweener;
    8.     private Transform _transform;
    9.  
    10.     protected void Awake() // important to set this in Awake so it's defined before the Root Start
    11.     {
    12.        
    13.         _transform = GetComponent<Transform>();
    14.         MyTweener = _transform.DOMove(new Vector3(Random.Range(-10, 10), Random.Range(-10, 10), Random.Range(-10, 10)), 3).Pause();
    15.     }
    16.  
     
    Last edited: Jan 26, 2018
    ArtC0de likes this.
  46. ArtC0de

    ArtC0de

    Joined:
    Sep 7, 2015
    Posts:
    14
    @FuguFirecracker Thanks for the tips! The code works so I'll try my best to understand how all this work :) thanks again for all!

    EDIT: YOU ARE AWESOME! Thanks a lot for all your help and time! I was hitting the head all day to undesrtand this! I really appreciate it! Thanks!
     
    Last edited: Jan 26, 2018
  47. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    I appreciate your appreciation ;)

    If you want each tween on your objects to be completely different, You need to look into C# interfaces.
    Define an interface [ call it ITweener] with a Tweener property your tween scripts can then derive from the ITweener interface

    The foreach loop would then GetComponent<ITweener> insted of <MyVerOwnTween>

    Interfaces a great thing to know
    Code (CSharp):
    1. public interface ITweener
    2. {
    3.      Tweener Tweener { get;  }
    4. }
    And that's all there is to it.
     
    ArtC0de likes this.
  48. ArtC0de

    ArtC0de

    Joined:
    Sep 7, 2015
    Posts:
    14
    Very usefull to know! I started recently in coding so any of this tips are really appreciated :)
    Thanks again!
     
  49. gringo2012

    gringo2012

    Joined:
    Jul 6, 2012
    Posts:
    46
    I have a really weird behaviour on one of my tweens and I hope somebody already experienced this issue...

    I have a tween that I would like to play only once (change the scale of an object) but once the tween ends I'd like it to get back to the initial scale.
    So if my button on screen has a scale of 1, I'd like the tween to do an Ease and change it's scale to 1.2 for example, and at the end the tween would set the scale back to 1, all part of the same Ease effect, so I'm not looking to reset the scale in a Complete event or play 2 tweens in sequence that would go to 1.2 then back to 1.
    If I run the same tween in a loop with a Yoyo effect it is reset properly, I just need to do it in 1 tween.
    Is this even possible?

    Here's my tween code: (pulsateIntensity is 0.2f and duration is 0.5)
    Code (CSharp):
    1. this.transform.DOScale(pulsateIntensity, durationInSeconds).SetRelative().SetEase(easeEffect).Play();
    At the end of the tween my object ends up with a scale of 1.2, while I'd like it to get back to it's initial scale

    This on the other hand resets it to the initial scale, but plays it twice, of course (I know it resets it cause a Yoyo in 2 steps would play the animation once, then in reverse)
    Code (CSharp):
    1. this.transform.DOScale(pulsateIntensity, durationInSeconds).SetRelative().SetEase(easeEffect).SetLoops(2, LoopType.Yoyo);
    So, is there an easy way to play a tween once then have the initial values smoothly reseted?

    Thanks in advance
     
  50. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    This does exactly that:
    Grows to a scale of 1.2 and then shrinks back to 1. The tween then finishes.
    Code (CSharp):
    1. .transform.DOScale(1.2f, 0.5f).SetLoops(2, LoopType.Yoyo).Play();
    It does not play twice.
    Are you calling it twice?

    Here's the full code you can stick on a cube:
    Code (CSharp):
    1. using DG.Tweening;
    2. using UnityEngine;
    3.  
    4. public class Pulsar : MonoBehaviour
    5. {
    6.  
    7.     protected void Start()
    8.     {
    9.         DOTween.Sequence().AppendInterval(1f).OnComplete(PlayTween).Play();
    10.  
    11.     }
    12.  
    13.     private void PlayTween()
    14.     {
    15.         transform.DOScale(1.2f, 0.5f).SetLoops(2, LoopType.Yoyo).Play();
    16.     }
    17. }
    18.