https://playcanvas.com/editor/scene/1678072
Hi guys, I’m trying to set collisions with code, but still not working, can you help me?
var AddMeshCollision = pc.createScript('addMeshCollision');
AddMeshCollision.prototype.initialize = function() {
// Get the entity on which this script is attached
var entity = this.entity;
// Add a small delay to ensure that the collision system is fully initialized
this.app.once('collision:ready', function () {
// Create a mesh collision component and add it to the entity
var collision = entity.addComponent('collision', {
type: 'mesh'
});
// Set the mesh to use the same model as the entity
collision.model = entity.model;
});
};
I have to add many models, so I’m trying to do it a easy way.