|Topic was automatically imported from the old Question2Answer platform.
So, I’m making a platformer and am currently working on enemy-player collisions. I figured the best way to do this was to make Physics collisions and damage collisions different types of collisions - Physics collisions will generally use kinematic bodies and be for interacting with the environment primarily, while damage collisions will use Area2Ds to detect when two hostile objects come into contact.
This almost works, but for some strange reason, the Area2D nodes are interacting physically. Here’s a gif to show how I mean:
At first, you might be able to see the behavior acting correctly - on the condition that the creature and the player directly collide head-on. However, any other way and the two act as physical barriers to each other. I know the Area2D is doing this, because when I turn off the relevant masks on the Area2Ds, the two objects don’t interact at all.
For clarity, I have both of their physics bodies on distinct layers(a player layer and an enemy layer respectively), and both of them interact with environment masks, and only those masks.
The player area occupies the player layer (along with the player physics body) and only interacts with two masks - enemies and enemy attacks.
Similarly, the creature area occupies the creature layer (again, along with its physics body) and only interacts with two masks as well - the player and player attack masks.
One thing that might be causing it, though I couldn’t imagine why, is that the physics body and the area for each object are using functionally the same collision shape. I duplicated it because I thought it would make sense that the damage hitbox and the collision hit box for each object would be the same.
Is there something I’m missing? Are Area2Ds supposed to behave this way?
I appreciate the assistance.
One additional potentially relevant detail: The Area2Ds are child nodes of the KinematicBody2Ds. Though, I’ve been testing code which makes them sibling nodes(or attempts to do so, at least), and so far I’m getting the same exact results when I seem to re-parent the nodes successfully.
tyo | 2018-11-06 19:38