smokys
October 7, 2024, 10:47am
1
Hello guys so in todays episode i have question for how tweening an opacity works, i have tried this method similiary to what i found on the forum but console throws back Type Error
setTimeout(function() {
var cloneOpacity = {value: 1};
clone.tween(cloneOpacity).to({value: 0}, 0.5, pc.Linear)
.on("update", function(){
clone.element.opacity = cloneOpacity.value;
})
.start();
//clone.destroy();
}, 1500);
i tried it few other ways but none of them worked for me, it either did nothing or had errors in console
what specific console error do you get?
smokys
October 7, 2024, 10:59am
3
TypeError: clone.tween(cloneOpacity).to({value: 0}, 0.5, pc.Linear)
.on("update", function(){
clone.element.opacity = cloneOpacity.value
}.bind(this))
.start is not a function. (In 'clone.tween(cloneOpacity).to({value: 0}, 0.5, pc.Linear)
.on("update", function(){
clone.element.opacity = cloneOpacity.value
}.bind(this))
.start()', 'clone.tween(cloneOpacity).to({value: 0}, 0.5, pc.Linear)
.on("update", function(){
clone.element.opacity = cloneOpacity.value
}.bind(this))
.start' is undefined)
clone is an entity i want to change opacity, its text element
The on
function no longer exists (see tutorial and API )
So it’s undefined and you try to call start
on it.
Use onUpdate
instead
var cloneOpacity = {value: 1};
clone.tween(cloneOpacity).to({value: 0}, 0.5, pc.Linear)
.onUpdate(function(){
clone.element.opacity = cloneOpacity.value;
})
.start();
1 Like
smokys
October 7, 2024, 11:16am
5
Thats great, my bad i didnt check API only tutorial. but good to know there were changes, thank you it worked