Material Update not working

I have been wanting to make a material with texture movement, I had already done it in another project and it worked well for me, but in this project it does not work for me.
this is my code for the animation of the material.

The method update works fine, the texture changes the value of its offset in Diffuse and Emissive, but the problem is that the material update does not make it visual.

I hope you can help me, thank you.
This is my scene:

Hmm, for some reason, this.entity.render.material is returning the default material which doesn’t look right.

For the moment, the following will work:

var MagmaMovement = pc.createScript('magmaMovement');
// initialize code called once per entity
MagmaMovement.prototype.initialize = function() {
    this.tmp = new pc.Vec2();
    this.speed=new pc.Vec2(0.5,0);
    this.material_magma = this.entity.render.meshInstances[0].material;
// update code called every frame
MagmaMovement.prototype.update = function(dt) {
    var tmp = this.tmp;
    tmp.set(this.speed.x, this.speed.y);
        this.material_magma.diffuseMapOffset = this.material_magma.diffuseMapOffset.add(tmp);
        this.material_magma.emissiveMapOffset = this.material_magma.emissiveMapOffset.add(tmp);


1 Like

Thank you so much yaustar its working! :smiley:

Reported bug: