Hi So I’m using Dotween in my object and I’m trying to pause or kill the tween in my current object however its not working as I’m expected.
Please look into the line.
bool shouldAnim = true;
void Start()
{
if (!shouldAnim)
return;
villainTransform.GetComponent<SpriteRenderer>().flipX = false;
villainTransform.position = new Vector3(leftBound.position.x,villainTransform.position.y);
villainTransform.DOMoveX(rightBound.position.x, 2f).SetEase(Ease.Linear).OnComplete(RunReverse) ;
}
private void RunReverse()
{
//StopMovement();
if (!shouldAnim)
return;
villainTransform.GetComponent<SpriteRenderer>().flipX = true;
villainTransform.DOMoveX(leftBound.position.x, 2f).SetEase(Ease.Linear).OnComplete(Start);
StopMovement();
}
public void StopMovement()
{
Debug.Log("Hit");
DOTween.Kill(gameObject);
DOTween.Pause(gameObject);
Debug.Log(DOTween.Kill(gameObject, false));
shouldAnim = false;
}
tried everything what i want is
object is moving left and right now i want whenever i call stopmovement method it should kill the tween and never run. but I’m not able to make this code work.I’m new to Dotween so any help will be appreciated.
Thanks in advance.