diff --git a/unity-renderer/Assets/DCLPlugins/ECS7/Systems/TweenSystem/ECSTweenSystem.cs b/unity-renderer/Assets/DCLPlugins/ECS7/Systems/TweenSystem/ECSTweenSystem.cs index daaae90d2b..6d1eac9685 100644 --- a/unity-renderer/Assets/DCLPlugins/ECS7/Systems/TweenSystem/ECSTweenSystem.cs +++ b/unity-renderer/Assets/DCLPlugins/ECS7/Systems/TweenSystem/ECSTweenSystem.cs @@ -55,6 +55,18 @@ private void UpdateTweenComponentModel(KeyValueSetTriplet( + entity.entityId, + ComponentID.TRANSFORM, + componentModel => + componentModel.position == entityTransform.localPosition + && componentModel.parentId == entity.parentId + ); + Vector3 midPosition = entityTransform.localPosition; + currentTime = 1f; + tweener.Goto(duration * currentTime); + systemUpdate(); outgoingMessages.Put_Called( entity.entityId, ComponentID.TRANSFORM, @@ -124,17 +136,18 @@ public void UpdateTransformComponentCorrectly() componentModel.position == entityTransform.localPosition && componentModel.parentId == entity.parentId ); + Assert.AreNotEqual(midPosition, entityTransform.localPosition); } [Test] public void UpdateInternalSBCComponent() { float currentTime = 0.666f; + float duration = 9f; Transform entityTransform = entity.gameObject.transform; // Stuff that the handler does - Tweener tweener = entityTransform.DOLocalMove(Vector3.up, 9); - tweener.Goto(9 * currentTime); + Tweener tweener = entityTransform.DOLocalMove(Vector3.up, duration); internalComponents.TweenComponent.PutFor(scene, entity, new InternalTween() { transform = entityTransform, @@ -144,10 +157,16 @@ public void UpdateInternalSBCComponent() playing = true, }); + tweener.Goto(duration * currentTime); systemUpdate(); - var sbcModel = internalComponents.sceneBoundsCheckComponent.GetFor(scene, entity).Value.model; Assert.AreEqual(entityTransform.position, sbcModel.entityPosition); + + currentTime = 1f; + tweener.Goto(duration * currentTime); + systemUpdate(); + sbcModel = internalComponents.sceneBoundsCheckComponent.GetFor(scene, entity).Value.model; + Assert.AreEqual(entityTransform.position, sbcModel.entityPosition); } } }