0 votes

Is there a way of creating collisions for an AABB? I expect 6 box shapes would need to be created, sized and aligned for each of the 6 sides of the AABB, but I'm not sure exactly where to start with this?

Godot version 3.5
in Engine by (35 points)

1 Answer

0 votes

AABB is a simple 3d box shape. So You can use just one box shape collision. AABB.size is an actual scaling of this box. Other properties define position, and You don't need all of them, just use origin to set up start of a collision box.

by (7,447 points)

Ahh, I should have mentioned I need the collisions to be on the outside, since the AABB is actually the bounds of the gridmap, I want to automatically generate collision around the edge so nothing can leave it. I'm making a start:

var boundsbox_node = $BoundsBox
boundsbox_node.get_node("Left").shape.extents = Vector3()
boundsbox_node.get_node("Right").shape.extents = Vector3()

So I need to set each of the collision shapes (Left, Right, Top, Bottom, Front, Back) to match each side of the AABB?

Can't You use one collision box and code stopping elements on when they try to exit it instead ? :)

I want to be able to move_and_slide() against the edges, and I don't believe that would be easily possible this way?

Ok, lets try something first. Use collision box with AABB scaling just like I said, but make all of the extents minus sign. I wonder if it would invert the box, so collision will happen from inside to outside, and moveandcollide will work with that

How do I set the BoxShape to the size of the AABB? BoxShape has extents but AABB has nothing similar, should I take the size and position and halve it?

just the size, and halve it propably, then multiply by -1

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.