[SOLVED] Problem with halfextents

Hello all,

In my game I am spawning a large number of tiles that will be individually scaled in the y direction. I have been trying to change the halfextent of the collision component to match the entity, but for some reason changing the halfextent in the code does not seem to be reflected at run time.

Here is the relevant code:

var tile = new pc.Entity();
tile.addComponent(“model”, {type: ‘asset’, asset: this.model});
this.app.root.addChild(tile);
tile.addComponent(“collision”, {type: ‘mesh’, asset: this.model});
tile.setLocalScale(1, stretch, 1);
tile.collision.halfExtents = new pc.Vec3(0.5, stretch / 2, 0.5);

You are adding a mesh collider… halfExtents are for box colliders.

I might say, I hope you have a powerful target system if all of your tiles are going to be mesh colliders. I’d recommend trying to use primitive colliders where at all possible or you’ll have performance issues down the road.

My (incomplete) collision geometry overlaid in red and green:

2 Likes