I’m attempting to mark ‘muscular’ as enabled = false which should hide a big chunk of the model, but it’s visible.
Code is as follows:
var Hide = pc.createScript('hide');
// initialize code called once per entity
Hide.prototype.initialize = function() {
this.entity.findByName("Muscular").enabled = false;
};
// update code called every frame
Hide.prototype.update = function(dt) {
console.log(this.entity.findByName("Muscular"));
this.entity.findByName("Muscular").enabled = false;
};
// swap method called for script hot-reloading
// inherit your script state here
Hide.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// http://developer.playcanvas.com/en/user-manual/scripting/
It does find the entity and as you can see in the code I am doing a console log of the muscular entity which prints out that enabled is false…
// Use W-A-S-D keys to move player
// Check for key presses
if (app.keyboard.isPressed(pc.KEY_A)) {
x -= right.x;
z -= right.z;
}
if (app.keyboard.isPressed(pc.KEY_D)) {
x += right.x;
z += right.z;
}
if (app.keyboard.isPressed(pc.KEY_W)) {
x += forward.x;
z += forward.z;
}
if (app.keyboard.isPressed(pc.KEY_S)) {
x -= forward.x;
z -= forward.z;
}
Thank you for your help! I must admit I am a bit confused by your explanation but will go through your link and hopefully can work it out - I’m pretty sure there’s only one instance of Muscular but will double check.
Ah yeah that is a bit annoying, still easy enough to work around. Would be good to get the full hierarchy working like how Unity3D does it but easy enough to work around.