Hello, I am doing some tryings with this playcanvas editor and it is very good, but I do not know if I am doing it wrong (sure) but i am reading docs and forum and tryings things since 3 days and I do not get how to read the value of an atribute from a script of another entity.
I want this in order to check some value and call one function or another depending of this value.
Here are links to my project and also here I write some code.
https://playcanvas.com/editor/scene/524666
I know that are some other questions related but I read them and I dod not get it yetā¦
I have an entity with an script with some values of a game interface:
var PropertiesUI = pc.createScript('propertiesUI');
PropertiesUI.attributes.add('player', { type: 'number', default: 0, min: 1, max: 2});
PropertiesUI.prototype.initialize = function()
{
PropertiesUI.player = 2;
console.log(PropertiesUI.player);
//in console log appears "2"
};
var MainJs = pc.createScript('mainJs');
MainJs.attributes.add('propiedades', {type: 'entity'});
//and parse the entity that has PropertiesUI script
MainJs.prototype.initialize = function()
{
console.log(PropertiesUI.entity);
console.log(PropertiesUI.attributes);
console.log(propiedades);
console.log(propiedades.attributes.get('player'));
//this returns an object but without any value
};
The only result I obtain is an object, or undefined, or something like āScriptAttributes {index: Object, scriptType: function}ā or āFunc {name: āpropertiesUIā, tags: Tags, _labels: Object, localPosition: Vec3, localRotation: Quatā¦}ā
How do I read the variable player from MainJs, which is in another entity?
Thank you for your help