I believe that I am trying to get the asset into the Asset Registry so that it can be added to an entity. However when I create a new script, it appears with a dot in front of it and cannot be added to an entity.
It might be that I am still having legacy vs 2.0 problems. Not sure because I haven’t figured out how to correctly convert files to the new system.
Here is the script.
var Collider = pc.createScript(‘collider’);
// initialize code called once per entity
Collider.prototype.initialize = function () {
this.entity.collision.on(‘collisionstart’, this.onCollisionStart, this);
};
Gotcha. I fixed that. The script still doesn’t work though. It does attach to the entity but when the player bumps into a wall, it doesn’t get destroyed.
I’m still confused why when I create a script by going to assets and clicking on the + sign it creates a script with a dot in front of it. And a script with a dot in front of it won’t attach to an entity.
If I add a script component in the entity and then choose + New Script, I can attach a script that way. Is this a bug or am I doing something wrong when I just try to add scripts directly to the library?