I am trying to fade out the “opacity” of a material from an entity, that is to decrease the “intensity” from 1 to 0. But unfortunately it is not able to get the property. What am I doing wrong here?
var PositionTrans = pc.createScript('positionTrans');
PositionTrans.attributes.add('targetSphere01', { type: 'entity' });
PositionTrans.attributes.add('duration', {type: 'number', default: 5.0});
// initialize code called once per entity
PositionTrans.prototype.initialize = function() {
this.entity.button.on('click', function(event) {
var tween1 = this.targetSphere01.tween(this.targetSphere01.material.opacity).to(0, this.duration, pc.SineInOut);
tween1.start();
}, this);
};
I get the error - Cannot read properties of undefined (reading 'material')
.