How to draw bounding box of sprite with some color

How can I draw bounding box around this bird.
Screenshot (17)

You can use drawLine or similar functions to render the box via the world positions of the corners:

How??. Could you please post it here.

You can get the 4 corners of the bounding box via and

And you can use drawline in the update function to draw lines between the corners like a box

1 Like

Can I get examples related to bounding box collision of 2 sprites in Play Canvas. How can we detect collision between sprites in play canvas.

Can you help to find bounding box of poles & bird and draw its outline.
I have used following code to find Bounding box but when drawn outline for the same it seems like too big.How can I resolve it.
I have attached screenshots of Enitites hierarchy , code snippet and output screenshot.
Thank you

Here is a simple example of rendering a Bounding Box:

Use WASD to move one of the boxes, when it intersects with another box, the bounding box changes color.

In your project, you shouldn’t be using scale to define the size of the bounding box. The bounding box uses world units for the half extents.

You can see in my project how I’ve got an attribute to say how big the bound box should be.

1 Like