Why am I experiencing performance issues with DoTween?

104 Views Asked by At

I'm using the DOShake function inside a coroutine which is started by user input and I don't understand why I'm experiencing those performance issues.

enter image description here

Here there is the code from which the function is called. It is a punch charging animation: I move the glove gameObject back with DOLocalMove and shake it's child (which only contains the actual sprite)

Vector3 gloveLocalPosition = transform.localPosition;
Vector3 pointerToGlove = transform.position - (Vector3)Input.PointerPosition;
Vector3 chargeOffset = pointerToGlove.normalized * ChargeMaxDistance;


var shake = transform.GetChild(0).DOShakePosition(FullChargeSeconds, ChargeVibration, 50, 90, false, false, ShakeRandomnessMode.Harmonic);
var moveBack = transform.DOLocalMove(new Vector2(1.2f * Mathf.Sign(transform.localPosition.x), -0.35f), FullChargeSeconds).SetEase(ChargeEaseType).SetAutoKill(false);
var fullChargeShake = transform.GetChild(0).DOShakePosition(30, FullChargeVibration, 50, 90, false, false, ShakeRandomnessMode.Harmonic).SetLoops(-1).SetAutoKill(false);
var sequence = DOTween.Sequence();
sequence.Append(moveBack).Join(shake).SetAutoKill(false).OnComplete( () => fullChargeShake.Play() ).Play();

yield return new WaitWhile(IsPunchButtonHeld);

float chargePercentage = moveBack.ElapsedPercentage();

sequence?.Kill();
fullChargeShake?.Kill();
transform.GetChild(0).localPosition = Vector3.zero;

...
1

There are 1 best solutions below

1
Fraspo On

Resolved re-importing the DoTween package