Hi, I am following the instructions to tween a material (Color) )here (Using the Tween library | Learn PlayCanvas ) but when I run the exact code on my project I get:
Cannot read properties of undefined (reading ‘material’)
TypeError: Cannot read properties of undefined (reading ‘material’)
My code is:
var color = new pc.Color(255, 0, 0);
var material = this.entity.render.material;
this.app
.tween(color)
.to(new pc.Color(1, 1, 1), 1.0, pc.Linear)
.loop(true)
.yoyo(true)
.on('update', function () {
material.diffuse = color;
material.update();
})
.start();
But the whole thing is in my update loop because I want to run the tween only when within distance to the player. Maybe this is the issue. I am completely lost with this. Cheers