Tweening a value always stays at zero

Im trying to get my emissive intensive to loop back and forth betwen 0 and 0.25 but when I debug this code the value during the tween always prints 0. Whats going on?

this.emissive_strength = 0;
var material = this.entity.render.material;

    this.app
    .tween(this.emissive_strength)
    .to(0.25, 1.0, pc.Linear)
    .loop(true)
    .yoyo(true)
    
    .on('update', function () {

            console.log("TWEEING COLOUR>> "+this.emissive_strength ) // ALWAYS PRINTS 0
            material.emissive.intensity = this.emissive_strength;
            material.update();

    }.bind(this))
    .start();

Hi @Grimmy!

Please check the post below, I think this will help you.

Thanks, I can now see the value changing correctly in the debug each frame, but the emissive doesnt actually change on the object. When I manually change this value in the editor I can see the difference. Any idea why it might not be changing the emissive intensity?


material.emissive.intensity = data.value;
console.log("Intensity >> "+material.emissive.intensity ); //NOW Prints correctly...easing up /down value
material.update();

Below another topic that probably can help you as well.

1 Like

Thank You. Unfortunately though, even using ‘emissiveintensity’ I still dont see a change in the emissive on the object. What could be the problem? Here is my code:

 const material = this.entity.render.material;
 console.log("The material noame is "+material.name);
    var data = {
       intensity: 0
   };

    this.app
    .tween(data)
    .to({intensity:0.25}, 1.0, pc.Linear)
    .loop(true)
    .yoyo(true)
    
    .on('update', function () {
        
            
            this.doing_color_tween=true;
            
            material.emissiveintensity = data.intensity;
            console.log("Intensity >> "+material.emissiveintensity  );
            material.update();

        
    }.bind(this))
    .start();

SOLVED
it should be:
emissiveIntensity
not
emissiveintensity
or
emissive.intensity

1 Like