Help with collision in a 2D RPG

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Skydome

Hello I am making a 2D RPG game and I needed help with making the collision work. I want my character to be able to move like this
But if I create a collison shape it causes a problem.
What is the best way to solve this? Should I make some kind of script in the func _process of the tree to track the player? Will that be too intensive especially if there’s too many trees like a forest map? Should I attempt to create a custom Ysort node which will also adjust the collision shapes of objects while Ysorting?

I also wanted to ask how to create selective collision. I want an object to collide with one object but not with other like projectiles that don’t hurt friendlies. I saw layers in the Kinematicbody2d and staticbody2d is that how you create selective collision? Because maybe selective collision shapes can solve this somehow?

:bust_in_silhouette: Reply From: hilfazer

I’d use a circle shape that only covers legs of your character.
Similar to how Baldur’s Gate & friends did this.
You can do this also for trees.

Selective collision is done with Layers, yes. Layers and Masks. Layers of one object are compared with Masks of another object.

Yes I have also been thinking of doing it that way. The problem is that my game will be an action game rather than a turn based strategy, a bit like the game little fighter or Dragon ball z Buu’s fury for GBA. So if I put the collision shape in the legs than a sword strike to the chest or blow to the head will not work. Or perhaps using multiple static bodies for object and kinematic body for players could solve that.
What do you think? Also thank you for the answer.

Skydome | 2019-05-05 07:22

Yes, use multiple bodies.
Capsule shape you already have could be scanned by weapons to detect hits. Circle shape i talked about would be used for movement collision detection.

hilfazer | 2019-05-05 07:43