#Modular collisions?
12 messages · Page 1 of 1 (latest)
I'm pretty sure as long as the root node is a physics body, you should be able to just add as many collision objects as you want.
Are you wanting a root object, and child objects that can move independently?
Or just a root object with different colliders, but all move together from collisions?
the second one, the goal was to have a system where every child can independently detect their own collisions so that the child can run it's own logic on collision (taking damage, exploding, etc) while the parent handles the physical response.
Unfortunately I've come to realize that:
A) There's no way to detect a collision without calling a move_and function;
Which doesn't even matter because
B) Godot will not calculate characterbodies that are children of other characterbodies
To be clear in my original idea both parent and child were characterbodies
Unless I'm misunderstanding you, you can add as many of these as children to your root CollisionBpdy3D node: https://docs.godotengine.org/en/stable/classes/class_collisionshape3d.html
Inherits: Node3D< Node< Object A node that provides a Shape3D to a CollisionObject3D parent. Description: A node that provides a Shape3D to a CollisionObject3D parent and allows to edit it. This ca...
That at least gets a starting point... not sure how to best detect collisions like that...
You will need to do some fancy coding to do that
First for your child node, perhaps making it as area would work
Then when you parent it, duplicate child collision shape, then add it to parent
Child node can process its logic with area while parent get additional colshape
I know Area has signals you can connect for this purpose...
You could also treat the move_and function call in _physics_process as a polling mechanism. When it returns a kinematic collision object with collision info, use the info to decide which child to send the info to to react on.
I messed around with having rigidbody children of a character body and came to some of the same realizations you did. What I did instead was making all of the rigidbodies siblings under a non-moving parent node2d. Then I made joints between the different rigidbodies I needed. In my case I wanted DampedSpringJoint2d - but painfully discovered the documentation is incorrect. They work, but there is no "maximum length" at the physics layer.
RigidBodies automatically handle collision to prevent "overlapping" and simulate physics. If you want two 2d balls bouncing off one another, that's what you should use.
It sounds like you want uniquely detectable hitboxes with their own logic processing on a single parent, kinda like a spaceship with various different modules on the surface. You can use a single CharacterBody2d as the parent with a collision area that covers the whole ship. Set the collision masks for layer 1, and make any physical object that you need to prevent overlapping also on layer 1.
Then you can add other child nodes that are area2ds with their own colliders, and link signals for their collisions back to the parent ship's script. Set those to different layers if you want them to collide with different things.