Search Unity

DOTween (HOTween v2), a Unity tween engine

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

  1. TaylorCaudle

    TaylorCaudle

    Joined:
    Feb 8, 2018
    Posts:
    158

    Hey, how was this GIF generated? I'm trying to generate a path like this, but NavMeshPath only generates straight lines between waypoints, how was this path generated?
     
  2. alexandergikalo

    alexandergikalo

    Joined:
    Oct 24, 2019
    Posts:
    19
    Has anyone experienced that transform.DOSpiral doesn't exist?
    I have pro version, using DG.Tweening added, all modules installed.
    Used standatd code from documentation:
    transform.DOSpiral(3, Vector3.forward, SpiralMode.ExpandThenContract, 1, 10);

    + found it at DOTweenProShortcuts. Code exists, but shortcut not work(((
     
    Last edited: May 2, 2022
  3. kenzen0

    kenzen0

    Joined:
    Sep 17, 2018
    Posts:
    16
    RectTransform Rect = this.GetComponent<RectTransform>();

    if (Input.GetButtonDown("Fire1"))
    {
    Tweener TW = Rect.DOLocalPath(
    path: new Vector3[] {
    Rect.localPosition+new Vector3(0, 0, 0),
    Rect.localPosition+new Vector3(500, 0, 0),
    Rect.localPosition+new Vector3(500, 500, 0),
    Rect.localPosition+new Vector3(0, 500, 0),
    }, //移動するポイント
    duration: 5f, //移動時間
    pathType: PathType.CatmullRom //移動するパスの種類
    )
    .SetLookAt(0.001f, forwardDirection: Vector3.right)
    .SetOptions(true)
    ;

    }


    I have placed an arrow on the uGUI.
    I want the arrow to point in the direction of travel using DoPath, but it doesn't work.
    What should I fix in my code?

    test.gif
     
  4. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    Rotate your arrow sprite 90 degrees. ;)
     
  5. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    429
    Hi @Demigiant

    I tried your direct support via the website form but haven't heard back (it's a few weeks ago now) so trying here. Hopefully someone can help.

    I'm confused about the use of Sequences. I'm using DoTween to change the value of a variable on an IK component (to animate a 'look at' behaviour on an NPC)

    Script is here: https://pastebin.com/8sGHv3Se

    Here's an explanation of what I'm doing and what's not working for me:


    I'm trying two different ways of creating and playing back a sequence. Caching it in Start and creating one each time, but in both cases I get odd 'jumping' of the variable's value which I don't understand. I'm really keen to learn as I know that Sequences are the way for me to go, so would really appreciate an explanation from someone with the patience to talk me through it :)
     
  6. stroibot

    stroibot

    Joined:
    Feb 15, 2017
    Posts:
    91
    Can somebody tell me why when I call this function more than once it doesn't animate it again?

    Code (CSharp):
    1. transform.DORotate(rotation, duration).SetEase(Ease.OutCubic);
     
  7. xcb

    xcb

    Joined:
    Mar 5, 2015
    Posts:
    8
    Hi. I would expect that this would make the rigidbody rotate following the targetAngle (which changes as the time goes on), but the GameObject doesn't rotate at all. Any Ideas? Thanks.
    Code (CSharp):
    1. rotationTweener = rb.DORotate(targetAngle, 1f);
    2. rotationTweener.OnUpdate(() => rotationTweener.ChangeEndValue(targetAngle, true));
     
  8. xcb

    xcb

    Joined:
    Mar 5, 2015
    Posts:
    8
    Ok I understand now that this doesn't work, because the tween gets killed on completion. Also it would not work anyway, because the original position would get reset. Now I do this every frame:
    Code (CSharp):
    1. rotationTweener = rb.DORotate(targetAngle, rotationSpeed);
    I know I can set DoTween to reuse tweens, but anyway I hope it's an ok solution. If there is a better one I'd be thankful for tips.
     
  9. kendev

    kendev

    Joined:
    Aug 9, 2015
    Posts:
    10
    Installing DOTween (HOTween v2) to a new project installs only to the point to when the Utility Panel shows with the message 'Completing import process...' and then does nothing. I'm using Unity Version 2020.3.26f1 and DOTween version 1.2.632. Has anybody experienced this?
     
  10. hive32

    hive32

    Joined:
    Dec 12, 2021
    Posts:
    2
    Okay, I am definitely misunderstanding some basic concepts.

    I am trying to create and reuse a Tweener to yoyo my sprite renderer's color between two values while the character is poisoned.

    Declared here:
    Code (CSharp):
    1. private Tweener poisonColorTweener;
    Set here:
    Code (CSharp):
    1.     public void Poison(PoisonStats poison)
    2.     {
    3.         isPoisoned = true;
    4.         currentPoison = poison;
    5.         poisonColorTweener = DOTween.To(() => Color.white, x => spriteRenderer.color = x, new Color(0, 1, 0), 1);
    6.         poisonColorTweener.SetLoops(-1, LoopType.Yoyo);
    7.     }
    And killed here when the duration is up:
    Code (CSharp):
    1.             if (currentPoison.poisonDurationTimer > currentPoison.poisonDuration)
    2.             {
    3.                 isPoisoned = false;
    4.                 currentPoison.poisonDurationTimer = 0;
    5.                 poisonColorTweener.Kill();
    6.                 poisonColorTweener = null;
    7.             }
    The thing is, the tweener never seems to actually stop. I confirm that the Kill() call is hit, but the color change continues.

    I thought this was how storing a reference to and killing tweeners worked, but obviously there is something I am not getting...Any ideas?
     
  11. matthewcook

    matthewcook

    Joined:
    Dec 21, 2020
    Posts:
    2
    I would like to be able to run several DOMove tweens on the same object at the same time and have them combine their effects. Is there a way to do this?

    For example if I did one tween to move up, and one to the right, then playing them in a sequence at the same time should move the object in a diagonal path up and to the right.

    This is the code I tried, but it only results in the second tween.

    Code (CSharp):
    1. DOTween.defaultAutoPlay = AutoPlay.None;
    2. Sequence sequence = DOTween.Sequence()
    3.     .SetRelative(true);
    4. Tweener A = transform.DOMove(new Vector3(1, 0, 0), 1.0f);
    5. Tweener B = transform.DOMove(new Vector3(0, 1, 0), 1.0f);
    6. sequence.Join(A);
    7. sequence.Join(B);
    8. sequence.Play();
    I know that I could use DOMoveX and friends for this simple example, but I would like to stack moves with all 3 components.
    I tried using ChangeEndValue in an update callback, but it can't be used on a sequence.
    I tried nesting objects in empty game objects and tweening those separately but that got ugly fast.

    Is there a way to combine motion like this?

    Thanks in advance for any help.
     
  12. travislyu

    travislyu

    Joined:
    Mar 1, 2020
    Posts:
    3
    Hi! I'm trying to use DOTween to move my objects, but I wasn't sure how the tweeners work.
    I'll have to frequently update the destination for my object, for example, DOMove will set to :

    Code (CSharp):
    1. transform.DOMove(new Vector3(x, y, z), 1.0f);
    This in the first frame, but several frames later I will actually want my object to move to x2, y2, z2 instead of x, y, z.

    Are there ways to update the destination of tweeners that are already active? Or will this code:

    Code (CSharp):
    1. transform.DOMove(new Vector3(x2, y2, z2), 1.0f);
    Just gonna kill the tweener automatically and start a new tweener? I was thinking I might just kill the tweener every time I fix the destination but that might not be very efficient since in the worst case the destination can update every frame. I want to figure out what will be the most efficient way to achieve this.

    Thank you!
     
  13. ManjitSBedi

    ManjitSBedi

    Joined:
    Mar 8, 2014
    Posts:
    58
    Hello,

    I have just recently starting DOTween. It is working quite well. However, I am having some trouble getting SetLookAt to work in a particular way. I shall elaborate:
    • we have player ships moving aligned to a hexagonal tilemap made with the Unity tile map package
    • a path is created from the tilemap positions and then an array of vector3 positions is created from the tile positions
    Using DOTween to move along the path is working but when I try to use SetLookAt the player's ship is rotating all around the tilemap but I would like to constrain the SetLookAt to only rotate the vehicle on the z axis. The tilemap is oriented with the tilemap vertically in the scene (Y is up on the screen).


    Code (CSharp):
    1.          
    2. List<Vector3> positionList = new List<Vector3>();
    3.  
    4.  foreach (Vector3Int tilePos in tilePosPath)
    5.  {
    6.       Vector3 position = tilemap.CellToWorld(tilePos);
    7.        positionList.Add(position);
    8.  }
    9.  
    10.  movementPath = positionList.ToArray();
    11.  
    12.  if (animateLookAtPath)
    13.  {
    14.       // This is not working as desired.
    15.       // Want to be able to constrain the look at to only one axis
    16.       Tween t = playerShip.transform.DOPath(movementPath, speed, PathType.Linear)
    17.           .SetLookAt(0.001f);
    18.        t.SetEase(Ease.Linear).SetSpeedBased(true);
    19.  }
    20.  else
    21.  {
    22.       Tween t = playerShip.transform.DOPath(movementPath, speed, PathType.Linear);
    23.        t.SetEase(Ease.Linear).SetSpeedBased(true);
    24.   }
    I also tried

    Code (CSharp):
    1. Tween t = playerShip.transform.DOPath(movementPath, speed, PathType.CatmullRom, PathMode.Full3D)
    2.        .SetOptions(false, AxisConstraint.None, AxisConstraint.X | AxisConstraint.Y)
    3.        .SetLookAt(0.001f);
    4.                 t.SetEase(Ease.Linear);
    I tried the above to constrain the angle rotation but it did not work. I see there is a discussion on GitHub - does this mean it is not possible to lock the X & Y axis rotation?

    https://github.com/Demigiant/dotween/issues/167

    I did try to use the WayPoint callback to modify the angle but I think any rotation I apply is over-riden by the pathing code. Here is some ugly code that has been getting hacked.

    Code (CSharp):
    1.      
    2. private void OnWaypointChange(int waypointIndex)
    3. {
    4.             // Look ahead to the next way point and rotate the player's ship to face it
    5.             if (waypointIndex < movementPath.Length - 2)
    6.             {
    7.                 var nextPos = movementPath[waypointIndex + 1];
    8.                 Vector3 dir = nextPos - playerShip.transform.position;
    9.                 float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90.0f;
    10.                 // Apply the rotation to the z axis.
    11.                 Debug.Log($"OnWaypointChange {waypointIndex} angle {angle}");
    12.                 var eulerAngles = new Vector3(-90, 0, angle);
    13.                 playerShipContainer.transform.eulerAngles = eulerAngles;
    14.             }
    15. }

    And I am using Cinemachine to have a follow camera move with the player's ship. So it can be quite funny as the follow camera is rotating with the ship being rotated (the next task to dive into next, I almost have it figured out) .
     
    Last edited: Jun 8, 2022
  14. Lucideus

    Lucideus

    Joined:
    Dec 7, 2015
    Posts:
    25
    Hello! I have a question regarding 'stableZRotation'. It doesn't seem to work, unless I'm misunderstanding something.
    Here's the code:

    Code (CSharp):
    1.     IEnumerator SpawnRoutine(Vector3 position, int loops)
    2.     {
    3.         for (int i = 0; i < loops; i++)
    4.         {
    5.             var instance = _enemyPool.PullGameObject(position);
    6.  
    7.             instance.transform.DOPath(
    8.                             path: CreateWaypoints(),
    9.                             duration: 50f,
    10.                             pathType: PathType.CatmullRom)
    11.                         .SetLookAt(
    12.                             lookAhead: 0.1f,
    13.                             stableZRotation: true)
    14.                         .SetSpeedBased(true)
    15.                         .SetEase(Ease.Linear);
    16.  
    17.             yield return _spawnIntervalTimer;
    18.         }
    19.     }
    So to my understanding, this is meant to keep the enemy that I spawn (via my enemy pool) upright. However, it doesn't. It spawns and tweens just fine, but the z-rotation is still being affected.

    Image link


    Left is what is happening. Right is what I want to happen(I've just manually set it to 0 there in the inspector).
    To my understanding, stableZRotation was meant to keep it upright but that isn't happening. Am I missing something?

    Edit: Tried adding ".SetOptions(lockPosition: AxisConstraint.None, lockRotation: AxisConstraint.Z);" but that doesn't seem to prevent it from affecting the Z-axis either...

    Edit 2: Using lockRotation for X locks both X and Z. Y does both Y and Z. Z however does absolutely nothing whatsoever. Is there no hope for this to be resolved?

    Edit 3: Well, for now I've solved it by "counter-rotating" the child object(model).
    Code (CSharp):
    1.     public Transform ParentTransform;
    2.  
    3.     void Update()
    4.     {
    5.         if (ParentTransform.rotation.z != 0)
    6.             this.transform.eulerAngles = new Vector3(
    7.                 ParentTransform.rotation.eulerAngles.x,
    8.                 ParentTransform.rotation.eulerAngles.y,
    9.                 0);
    10.     }
    That's the simple script I use for that. No idea how good of a solution this really is, but it's the only way I've managed to make it actually do what I want it to do.
     
    Last edited: Jun 26, 2022
  15. leonhogan1

    leonhogan1

    Joined:
    Apr 21, 2020
    Posts:
    13
    Im using DoTween Pro, and i added it to my new project and i get this error:

    System.MissingMethodException: Method not found: void DG.DOTweenEditor.UI.DOTweenUtilityWindow.add_OnRequestDOTweenProMissingScriptsFix(System.Action`1<bool>)
    UnityEditor.EditorAssemblies:processInitializeOnLoadAttributes (System.Type[])

    How do i fix this?
     
    Last edited: Jun 17, 2022
  16. MXTrealityAssets

    MXTrealityAssets

    Joined:
    Feb 6, 2018
    Posts:
    1
    Has Tween.PathGetPoint(x) been removed? I'm using DoTween Pro and am unable to call it, I get a compiler error.
     
  17. leonhogan1

    leonhogan1

    Joined:
    Apr 21, 2020
    Posts:
    13
    Also, i tried signing up on the dotween website, but they wont send a a confirmation email to 2 of the emails i tried with them. Is their website broken?
     
  18. ManjitSBedi

    ManjitSBedi

    Joined:
    Mar 8, 2014
    Posts:
    58
    I had the same problem; I tried to sign up to the dedicated DOTween forum & never received any emails to confirm the account sign up. This was over a week ago.
     
  19. astanid

    astanid

    Joined:
    Apr 5, 2021
    Posts:
    145
    I'm trying to use DODynamicLookAt to make turret and barrel look at the player (in fact it's camera position in my game)
    turret.transform.DODynamicLookAt(target.position, rotateSpeed,AxisConstraint.Y);
    that works ok, but barrel moves wrong
    barrel.transform.DODynamicLookAt(target.position, rotateSpeed,AxisConstraint.X);
    it rotates around global X axis, not local
    that's global axis
    upload_2022-6-26_11-19-21.png
    that's local
    upload_2022-6-26_11-20-3.png
    what am i doing wrong ?
     
  20. alexandergikalo

    alexandergikalo

    Joined:
    Oct 24, 2019
    Posts:
    19
    Hi.
    What is is the right way to Instantiate go before use it in tween?
    I tried to do it witn private variable and AppendCallback, but it not work((( MoveProjectileToPlaceMarker return null ref (_projectileController is null).

    Code (CSharp):
    1. private ProjectileController _projectileController;
    2.  
    3. DOTween.Sequence().
    4.     AppendCallback(() => CreateProjectile(positionFrom)).
    5.     Append(MoveProjectileToPlaceMarker(positionTo)).
    6.     AppendCallback(() => DestroyProjectile())
    7.  
    8. private void CreateProjectile(Vector3 positionFrom) =>
    9.   _projectileController = Object.Instantiate(_projectilePrefab, positionFrom, quaternion.identity).GetComponent<ProjectileController>();
     
  21. curbol

    curbol

    Joined:
    Oct 29, 2015
    Posts:
    8
    I have the same issue. Is there a solution to this? I've tried creating 3 paths (start, middle, end), but as mentioned, easing the start and end results in faster speeds than the input move speed using setSpeedBased(true) which makes the speeds not sync up correctly. I've also tried easing the timescale, which kind of works, but that changes the duration, which is okay except that it's very difficult to calculate what the duration will be and ends up resulting in the path completing before or after the timescale tween has completed. Changing the timescale would work fine if I could calculate what the actual duration would be, but this seems like calculus territory. As the timescale changes non-linearly, it warps the duration like a black hole.

    Basically, there would ideally be a way to tween to a speed, not a duration. For example, move from waypoint 0 to 1 and end up at 5 units per second. The duration can be whatever it needs to be. This might be somewhat easy to calculate with a linear ease, but I'm finding it almost impossible with any other ease like InQuad.

    Also the biggest issue is easing out. Easing the timescale in works okay because it looks fine to not finish the easing at exactly the next waypoint. However at the end of the path if the ease out doesn't finish exactly at the last waypoint it either eases down to a slow speed too early, or ends the path still moving too quickly. You don't end up with a "slow to a stop" effect.

    Update:
    In case it helps anyone else, I found a solution that roughly calculates the duration of an eased timescale. It's close enough for my needs.
    Code (CSharp):
    1.   public static float ScaleWithEase(this float value, float from, float to, Ease ease, int samples = 10)
    2.     => Enumerable.Range(0, 10)
    3.         .Select(a => a / samples) // get intervals 0.1, 0.2, 0.3, etc.
    4.         .Select(b => DOVirtual.EasedValue(from, to, b, ease)) // sample ease function
    5.         .Select(c => value / (c * samples)) // scale 10th of the value
    6.         .Sum();
    This can be used like this:
    Code (CSharp):
    1. scaledDuration = duration.ScaleWithEase(minTimeScale, 1f, easeIn);
    2. sequence.Append(pathTween.DOTimeScale(1,  scaledDuration).SetEase(easeIn));
    Basically what the function is doing is sampling 10 intervals of the ease function and scaling a 10th of the input value by that sampled interval. Then just sum up the 10 intervals to get the new scaled value. The sampling can be increased (to 100 for example) to get a more accurate value, but 10 samples was good enough for me. I think this is a rough approximation of an an integral over the ease function.
     
    Last edited: Jul 5, 2022
  22. atk_defender

    atk_defender

    Joined:
    Jun 26, 2018
    Posts:
    25
    Can dotween's warning some print and some no print?
    I use dotween to write buff timer, sometimes the charactor is delected, then the warning rise up. (I don't need this.)
    But some other dotweens is about core, their warning is necessery.
     
  23. Znimator

    Znimator

    Joined:
    Apr 12, 2021
    Posts:
    2
    DOFade tweens Alpha value instantly.
    What do i do.

    Tile selection:
    Code (CSharp):
    1. if (lastTile != null && lastTile.obj.m_Id != currentTile.obj.m_Id)
    2.         {
    3.             Character newCharacter = currentTile.owner?.GetComponent<Character>();
    4.             Character lastCharacter = lastTile.owner?.GetComponent<Character>();
    5.  
    6.             lastCharacter?.ShowHearts(false);
    7.             newCharacter?.ShowHearts(true);
    8.         }
    Effects:
    Code (CSharp):
    1.     private IEnumerator IShowHeart(GameObject heart)
    2.     {  
    3.         Vector3 localPos = new Vector3(heart.transform.localPosition.x, 0.55f, 0);
    4.         TweenParams tParams = new TweenParams().SetEase(Ease.OutBack, 3f);
    5.         SpriteRenderer sRenderer = heart.GetComponent<SpriteRenderer>();
    6.      
    7.         sRenderer.DOFade(255f, 0.25f);
    8.         heart.transform.DOLocalMove(localPos, 0.25f).SetAs(tParams);
    9.         yield return null;
    10.     }
    11.  
    12.     private IEnumerator IHideHeart(GameObject heart)
    13.     {
    14.         Vector3 localPos = new Vector3(heart.transform.localPosition.x, 0.5f, 0);
    15.         TweenParams tParams = new TweenParams().SetEase(Ease.OutSine);
    16.         SpriteRenderer sRenderer = heart.GetComponent<SpriteRenderer>();
    17.  
    18.         sRenderer.DOFade(0f, 0.25f);
    19.         heart.transform.DOLocalMove(localPos, 0.2f).SetAs(tParams);
    20.         yield return null;
    21.     }
     
  24. SavedByZero

    SavedByZero

    Joined:
    May 23, 2013
    Posts:
    124
    Hey all. Does DOTween offer blurring? I see something in the documentation regarding it, but it's listed as an EPO, without any real explanation of what that means that I can find.
     
  25. alexandergikalo

    alexandergikalo

    Joined:
    Oct 24, 2019
    Posts:
    19
    Hi.
    When DotWeen callbacks at "Order of execution for event functions" ?
    Are they before Update or can they be execute during it?
     
  26. LuiBroDood

    LuiBroDood

    Joined:
    Mar 13, 2019
    Posts:
    84
    does there exist a .pdf version of the Documentation ? thanks
     
  27. Anvarito

    Anvarito

    Joined:
    Sep 13, 2017
    Posts:
    8
    Hi, I am constantly faced with the fact that when the level is rebooted, he writes to me in the console that the Rect Transform object is lost, and the scene does not load, the link in the message leads to the DOTween script. do I need to terminate processes before rebooting somehow? Or I don't know something else, thank you
     
  28. MasterOfKMJ

    MasterOfKMJ

    Joined:
    May 6, 2022
    Posts:
    3
    Hi, anyone there. I'm using 2021.1 unity. All the coloring related DOTween function seemed not working? Anyone has any idea?

    and be honest, I've looked aorund, only to found DOTween dev have no any repo and support regard this plugin since around Q1 of 2021. Is this plugin is stll supported? What happened?
     
  29. yyylny

    yyylny

    Joined:
    Sep 19, 2015
    Posts:
    93
    Can I get a Tweener animation to jump immediately to the last frame? For example, I want to move an object from point A to point B but sometimes I want it to jump immediately to point B in one frame.
     
  30. andorix

    andorix

    Joined:
    Mar 30, 2020
    Posts:
    9
    Hi all! :D

    I'm getting this error when switching scenes:
    "Target or field is missing/null () ► The object of type 'Transform' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object."

    I have some tweens running on an infinite loop, and I'm aware that when a new level loads the objects get destroyed, producing this error. I know that Safe Mode automatically takes care of this.

    My question is, what is the correct way to deal with this? My fix at the moment is to kill all DOTween IDs right before loading the next level. Is there a better/easier way than having to do this before every new scene loads (assuming I have infinite loops running in the previous scene)? Btw, I'm using DOTween with Playmaker. Thanks!
     
  31. roman_sedition

    roman_sedition

    Joined:
    Nov 6, 2016
    Posts:
    13
    Is there going to be direct support for UI Toolkit?

    Atm if I wanted to animate moving some element of my UI up on the Y axis a bit I am doing this

    Code (CSharp):
    1.             scrollView.style.top = 50;
    2.             DOTween.To(()=> something.style.top.value.value, (x)=> something.style.top = Length.Percent(x), 48, .3f);
    But I kinda don't want to have to use the top line of assigning a value to the inlined styles and would rather have it default to whatever the value is in the stylesheet. If I use resolved styles, it instead gives me a float value instead of the Length.Percent value, and I would rather be dealing with Percent values.
     
    wphd likes this.
  32. Ayrnas

    Ayrnas

    Joined:
    Jul 6, 2018
    Posts:
    5
    I have this method that's just supposed to make a character blink when damaged. It changes the value of a shader. However, it seems like it is not killing off the tweens and constantly increasing the amount. Should I be adding some "Destroy" somewhere?

    DOTWEEN ► Max Tweens reached: capacity has automatically been increased from 200/50 to 500/50. Use DOTween.SetTweensCapacity to set it manually at startup

    Code (CSharp):
    1.     public void CharacterEffectBlip(Color color, float intensity)
    2.     {
    3.         mat.SetColor("_HitEffectColor", color);
    4.  
    5.         DOVirtual.Float(0, intensity, .2f, v =>
    6.         {
    7.             mat.SetFloat("_HitEffectBlend", v);
    8.         })
    9.         .SetEase(Ease.InOutElastic)
    10.         .OnComplete(() =>
    11.         {
    12.             DOVirtual.Float(0, intensity, .2f, v =>
    13.             {
    14.                 mat.SetFloat("_HitEffectBlend", 0);
    15.             })
    16.              .SetEase(Ease.OutFlash);
    17.         });
    18.     }
    Thanks!
     
  33. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    Did the author actually answers these questions? I've seen that he locked his forums and redirected the Pro Versions users here.

    I have a question on why the DoRotate node (DotweenPro and visual scripting) sometimes will rotate all the axis 360° instead of just one axis as in the example provided. So both world axis and local axis does this.
    tweenProblem2.gif
    dotween.png
     
  34. Rusted_Games

    Rusted_Games

    Joined:
    Aug 29, 2010
    Posts:
    135
    Found a bug in DOTween Pro v1.0.330 -> DOTween Animation Component, Animations not starting when entering Play mode in Editor. It is working as expected with previous v1.0.244
     
  35. Dreezert

    Dreezert

    Joined:
    Jan 25, 2017
    Posts:
    3
    Good Day! I am new with DOTween, may I ask if is it possible to animate a Page or Image to look like it is being Curled, or like flipping the next page of a book? Thank you!
     
  36. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @dorussoftware Was pointed here by the author of this issue. I'm not sure the two issues are related, but it looks like a bug that I'm afraid I created in the last update when fixing another very rare bug with rotation. Problem is that I can't replicate it at the moment: if you could create a sample project that replicates it and attach it to the github issue it would be great.
    @Rusted_Games Answered on git (in short, it seems you were toggleing the wrong AutoPlay toggle—will try to use a clearer nomenclature)
    @Dreezert You can animate any property with the generic DOTween method, but you will need to have an existing property that changes the curl/flip of a page when its value changes, and then you can animate that
     
  37. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    is just a prefab with a collider and a camera, nothing else, in the scene just add a visual scripting graph with those nodes as in the screenshots, with those variables.

    one thing I've notice now, maybe is an issue because the visual scripting graph is on the same game object that is rotating? The graph is inside the prefab itself. is why the target is left as "this". maybe this has something to do with the issue? I don't recall if I've tried to "control" the prefab rotation from a third object. I wanted simplicity actually, just send the event from the ui to the player prefab.

    maybe the code is not able to figure out he should rotate the prefab in the scene? I don't get it.
     
  38. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @dorusoftware Surely no issue if the visual scripting graph is in the same gameObject. I just managed to reproduce and it's definitely my bug, sorry. Working on a fix!
     
  39. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    awesome! thank you!
     
  40. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    P.S. As a temporary fix while I work on it, setting the rotation to "Fast" or "FastBeyond360" instead of "WorldAxisAdd", and marking the rotation as relative (SetRelative) works correctly. I don't see a "relative" option in the visual scripting graph, but there should be a way to add it (I'm not very familiar with that system)
     
  41. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    yes, the asset doesn't synergies well with the visual scripting as it is right now, it could help having a set of custom visual nodes that have the ability to output a reference to the tween where you can keep track when it ended.

    there are custom nodes for playmaker, i have those, would really be great if someone could make a similar set for visual scripting/ex-bolt.

    I've already had this fixed as you have explained, I've created a custom visual scripting node that can do the tween by code and have the ability to send back the onComplete event to the graph.

    Basically what I have is two of these nodes, one for rotation and one for movement. Here is the script for the rotation as an example.

    Code (CSharp):
    1. using UnityEngine;
    2. using Unity.VisualScripting;
    3. using DG.Tweening;
    4.  
    5. public class YDoTweenRotate : Unit
    6. {
    7.     [DoNotSerialize]
    8.     public ControlInput inputTrigger;
    9.  
    10.     [DoNotSerialize]
    11.     public ControlOutput outputTrigger;
    12.  
    13.     [DoNotSerialize]
    14.     public ValueInput inputTransform;
    15.  
    16.     [DoNotSerialize]
    17.     public ValueInput endValue;
    18.  
    19.     [DoNotSerialize]
    20.     public ValueInput duration;
    21.  
    22.     private Transform internalTransform;
    23.     protected override void Definition()
    24.     {
    25.         inputTrigger = ControlInput("inputTrigger", (flow) =>
    26.         {
    27.             flow.GetValue<Transform>(inputTransform).DORotate(flow.GetValue<Vector3>(endValue), flow.GetValue<float>(duration), RotateMode.Fast).OnComplete(SendOnCompleteEvent);
    28.  
    29.             internalTransform = flow.GetValue<Transform>(inputTransform);
    30.  
    31.             return outputTrigger;
    32.         });
    33.  
    34.         outputTrigger = ControlOutput("outputTrigger");
    35.  
    36.         inputTransform = ValueInput<Transform>("Transform");
    37.  
    38.         endValue = ValueInput<Vector3>("End Value");
    39.  
    40.         duration = ValueInput<float>("Duration", 0.0f);
    41.     }
    42.  
    43.     private void SendOnCompleteEvent()
    44.     {
    45.         internalTransform.GetComponent<StateMachine>().TriggerUnityEvent("EnableInput");
    46.     }
    47. }
    48.  
    in the graph it looks like this, I just have a bool which if false, the code triggered by a button will not be executed till the tween has ended. then there is an event called from the script above that sets the boolean to true.

    Annotation 2022-10-06 143151.png
     
    Last edited: Oct 6, 2022
  42. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Hello, got a quick question. I'm using DoTween Pro by the way.

    Here is what I want to achieve. I want to have blinking icon where the blink increase frequency over specific amount of time. Comparison would be SuperMario Bros. where Mario picks up a star and he blinks while star is active. In my case I would want that blink to increase in frequency (blink faster) as the "start power" is about to expire. I would also like to use a tweener that I can reuse (so SetAutoKill to false).

    My though was to use SetLoops to Yoyo with each second OnStepComplete use ChangeEndValue with timer changing (becoming smaller). If I want the blinks to end at specific time I would have to do some calculations as to what the timer value for each ChangeEndValue would have be, but I think that it's doable. Would you agree with this approach or is there something in DoTween that would work better for my use case.

    Thank You for any advice you can offer. Regards.
     
  43. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    you can also just use the option to detect when a tween has ended so you create a new one with a different time value. So if power time left is 5 seconds, you can create a tween for 2 seconds, then when that is ended you create a new tween for 1 second, then I don't know half a second. it remains 1.5 seconds, you can divide that further.
     
  44. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Thanks for getting back. I just assumed that reusing the tweener would avoid mem allocation and thus garbage collector. Is that the case?
     
  45. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    If you store a reference to the Tween and set AutoKill to False, then you will recycle the same one without allocations.
     
  46. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Thanks, that's what I've been doing. All I was saying is that I didn't actually verify no allocation in the profiler. In any case, I'll go with my original design then.
     
  47. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    You could also try playing with the Flash Ease to see if that gets you most of the way there (or a custom animation curve)
     
  48. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Are you just saying that because your username is flashframe? jk

    Not sure what you mean. Do you mean to use one of the easing functions in SetEase? I don't see any documentation on flash ease showing up in DoTween webpage.
     
  49. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Haha!

    It's listed in the documentation here, under SetEase
    http://dotween.demigiant.com/documentation.php#controls

    You can see how setting the period to -1 can strengthen the value towards the end.

    But you could also set up a custom animation curve with the shape of the flash you want and use that to drive the value of the opacity directly over the time of the tween.
     
  50. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797