How to get tweening to work?

Hi @lubos,

Trying to figure out how to get Tweens to work.

When using below code the cube is resized, but there is no 5 sec tween. The cube is 0.1 scale right away at start.

package arm;

class Cube extends armory.Trait {

    public function new() {
        super();

        notifyOnInit(function() {
            iron.system.Tween.to(object.transform.scale, 5.0, object.transform.scale = new iron.math.Vec4(0.1, 0.1, 0.1, 1.0), null, 0.0, iron.system.Tween.LINEAR);
        });
    }
}

When using below code I can see that both tweenScale() and onTweenScaleCompleted() after 1 and 1+5 sec, but nothing happens to the scale of the cube.

package arm;

class Cube extends armory.Trait {

    public function new() {
        super();

        notifyOnInit(function() {
            iron.system.Tween.timer(1.0, tweenScale);
        });
    }

    public function tweenScale(){
        trace("tweening scale");
        iron.system.Tween.to(object.transform.scale, 5.0, object.transform.scale = new iron.math.Vec4(0.1, 0.1, 0.1, 1.0), onTweenScaleComplete, 0.0, iron.system.Tween.LINEAR);
    }

    public function onTweenScaleComplete(){
        trace("tweening completed");
    }
}

Can you give me some simple example of how I should use Tween to get it to animate over time?

Thanks!

Kind Regards,
Martin

@lubos in the second case, I added a prints to check the value of object.transform.scale, and the scale is actually updated. But the scale is updated instantaneously, and the change is not visible on screen.

// update() printouts
(1, 1, 1, 1)
(1, 1, 1, 1)
(1, 1, 1, 1)
(1, 1, 1, 1)
tweening scale
(0.1, 0.1, 0.1, 1)
(0.1, 0.1, 0.1, 1)
(0.1, 0.1, 0.1, 1)
(0.1, 0.1, 0.1, 1)

(More progress on this issue at GitHub: https://github.com/armory3d/armory/issues/201).

package arm;
import iron.Scene;
import iron.math.Vec4;
import iron.system.Tween;

class Cube extends iron.Trait {
public function new() {
super();

	notifyOnInit(function() {
		
		iron.system.Tween.to({
			target: object.transform,
			props: { loc: new Vec4(4, 0, 0) },
			duration: 2.0,
			ease: QuartInOut
		});
	});		

	// notifyOnUpdate(function() {
	// });

	// notifyOnRemove(function() {
	// });
}

}

Example: https://drive.google.com/open?id=1lxZJKzKl9Q1Dx85JbDjzuEFIyN5EczB8

https://armory3d.org/manual/api/iron/system/Ease.html