So, I've been messing around a bit with this DOTween ( pretty cool btw ) and I kinda have an issue. So as you can see the text is perfectly working. Even if it doesn't reach the top ( y = 315 ) and I select another difficulty it will just go back as normal but those description won't... As you can in the video if I try and select another difficulty before the scale is 1 (or almost 1) the description will go down and after very fast it goes to 1... I hope you understand a bit what I wanted to explain here... I know that my code is a bit messy but for now I just want it to work, so any help would be appreciated!
#Need some help with DOTween
1 messages · Page 1 of 1 (latest)
Also the code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using DG.Tweening;
public class DifficultySelection : MonoBehaviour
{
[Header("Text")]
[SerializeField] private TMP_Text Easy_TXT;
[SerializeField] private TMP_Text Medium_TXT;
[SerializeField] private TMP_Text Hard_TXT;
[Header("DifficultyInfo")]
[SerializeField] private GameObject EasyDescription;
[SerializeField] private GameObject MediumDescription;
[SerializeField] private GameObject HardDescription;
public void EasySelected()
{
Easy_TXT.transform.DOLocalMoveY(315, 2.5f);
EasyDescription.transform.DOScale(1, 3f);
if (Medium_TXT.transform.position.y > 200 || Hard_TXT.transform.position.y > 200)
{
Medium_TXT.transform.DOLocalMoveY(0, 2.5f);
Hard_TXT.transform.DOLocalMoveY(0, 2.5f);
MediumDescription.transform.DOScale(0, 2f);
HardDescription.transform.DOScale(0, 2f);
}
}
public void MediumSelected()
{
Medium_TXT.transform.DOLocalMoveY(315, 2.5f);
MediumDescription.transform.DOScale(1, 3f);
if (Easy_TXT.transform.position.y > 200 || Hard_TXT.transform.position.y > 200)
{
Easy_TXT.transform.DOLocalMoveY(0, 2.5f);
Hard_TXT.transform.DOLocalMoveY(0, 2.5f);
EasyDescription.transform.DOScale(0, 2f);
HardDescription.transform.DOScale(0, 2f);
}
}
public void HardSelected()
{
Hard_TXT.transform.DOLocalMoveY(315, 2.5f);
HardDescription.transform.DOScale(1, 3f);
if (Easy_TXT.transform.position.y > 200 || Medium_TXT.transform.position.y > 200)
{
Medium_TXT.transform.DOLocalMoveY(0, 2.5f);
Easy_TXT.transform.DOLocalMoveY(0, 2.5f);
MediumDescription.transform.DOScale(0, 2f);
EasyDescription.transform.DOScale(0, 2f);
}
}
}
Hey, i think that is happening a conflict on your codes. When you click to open hard description, and, before it ends the animation, you click on easy button (for example), the code will run hard open, hard close and easy open animations at the same time, causing the issue. I never used DOTween, but probably if you can cancel animations you would be able to fix the bug. Is there a way to do it on DOTween?
Tried something but no good results
What happened?
Pretty weird things... Like canceling the animation before it begins ( so it won't show at all ) , the description would sometimes just disappear ( or get the scale instantly to 0 ) and some other thing like those but I somehow managed to resolve the problem by just setting the same time for the scaling and unscaling and somehow this works
So... Now is the code working?
Sounds good
If you have any more problem feel free to ask here!
I'll sure do! Thanks for suggestions mate