Adding a collision through script

Hey guys i tried to add a box collision to my entity, but not sure if this is a right way of setting its scale

image

when im changing radius and height of cylinder collision it works but box has different attributes probably

image

Hi @smokys,

For a box collider you need to do it this way:

        newBox.addComponent("collision", {
            type: "box",
            halfExtents: new pc.Vec3(5, 5, 5)
        });
2 Likes

The properties can be found in the API docs here: https://developer.playcanvas.com/en/api/pc.CollisionComponent.html

2 Likes

Thank you, working… solved

1 Like