[SOLVED] App.root is not defined

I am creating a script file with some physics formulas, I intend to do a simulator, and I would like to get some stats of a sphere or a cube, how could I get these information from the entitys, and also use global variables? I have tried to use app.root.findByName(‘Ball’) , but it returned app.root is not defined. I have added an atribute and worked (this.targetStats.rigidbody.mass the atribute was targetStats), but this is the unique method to do so?


use ‘this’ with app.

1 Like

Now it returns: this.app is undefined
Here is the code:
var PhysicsAsset = pc.createScript(‘physicsAsset’);
var ball = this.app.root.findByName(‘Ball’)

PhysicsAsset.prototype.initialize = function() {};
PhysicsAsset.prototype.update = function(dt) {};

You can learn how to use scripts from the user guide:


I’ve decided to just define the variable, like “var ball” and inside the initialize “ball = this.app.root.findByName(‘Ball’)”

1 Like