• Godot HelpProgramming
  • Need design advice on using multiple collision shapes on a single KinematicBody2D node

Greetings!

My Project: I work on a typical 2D Platform game. A typical 2D player character does the usual 2D movements like walking, jumping, crouching, climbing, etc.

What Works: I have no problem programming the movements so far. For crouching, I use 2 CollisionShape2D nodes, a tall and a short one and I disable/enable each one alternatively based on the state of my player character (whether it crouches or not). This works well, since I can have my player character fit into tight spaces when crouching and also becoming a smaller target for enemy projectiles.

My Problem: I am in need of design advice on using multiple collision shapes at the same time, with each collision shape interacting with different nodes in different ways, at the same time.

I came onto this problem, where in order to make my player character climb in a reasonable fashion, I need to make its collision shape really thin (for interacting with the Area2D climb area). But I don't want to make it a smaller target for enemy projectiles and I don't want to mess with the collision shape that interacts with StaticBody2D nodes (like ground and obstacles).

Basically I need for my character: One collision shape to interact only with StaticBody2D nodes One different collision shape to interact only with Area2D nodes

My Proposed Solution: It involves using 2 KinematicBody2D nodes or using 1 KinematicBody2D and 1 Area2D in my player character node tree. However, it kind of feels to me like an unusual way to do things. What do you think? Would you propose some other way?

Thanks for any help!

Yes, this is not uncommon, Especially for stuff like climbing or hanging on ledges, you basically need multiple collision shapes. Also fighting games may have like 8 or 10 hitboxes for 1 character. So this is normal. I would recommend not having multiple KinematicBodies on the same character. Probably use 1 KinematicBody and then add Area nodes as needed. You can also use RayCasts, this can help with some stuff, and you can make as many RayCasts as you want. This is good for checking if the character is about to fall off an edge (but hasn't actually stepped off yet) or for grabbing onto things.

So, I was reading the Area2D documentation more carefully and discovered the body_shape_entered and body_shape_exited signals. These signals can be received by PhysicsBody2D nodes entering or exiting the Area2D and the resulting function can tell which specific collision shape enters or exits the area, which is great.

At least for now, I won't need an additional Area2D node in my player node tree, I guess.

Thanks for the answer!

a year later