I needed the player to damage an enemy by poking his character’s head into it. So I stuck a small sprite to the player’s head, which, when touching an enemy, reduced it health.(is this the optimal solution, or are there much better options?)
And everything seemed to work just fine until the moment I attached the same hitbox to the enemy. I was able to remove the fact that the enemy causes damage to itself with it own hitbox, but another problem arose.
Due to the fact that the enemy is touched by it own hitbox, it does not take damage from any other hitbox. As a result, the enemy does not take damage until I remove the it head hitbox. The same goes for the player. It constant collision with it own hitbox prevents it from getting damage from the enemy’s hitboxes.
Disable the collision between the player/enemy and their own hitboxes.
Go the other way and let the player/enemy take damage from several hitboxes at once.(Preferable, probably.)
Both options at once.(Very preferable)
But I have not been able to implement any of the methods. And so, is there any way to implement a complete shutdown of the collision between objects or create a multi-collision?
(I hope the translator translated this text correctly)
I can use different hitboxes for the player and the enemy(and it works great), but the problem persists when dealing enemy-enemy damage.
The main problem is that an object can only be damaged from one source. If an object is in collision with two hitboxes, then the damage is not summed up, but is applied only from the first hitbox. In the case of an enemy, he touches only his own hitbox, which does not cause damage to him, but at the same time no longer takes damage from collisions with other hitboxes.
My game is something like the Hunger Games, where I want everyone to attack everyone until only the winner remains. So I just need the hitboxes of each object to work the same way.
If you just go straight for mario like jumping on head
You can use point inside object
And in condition you would check for that point (i did not make any special point i simply check for existing center point + some offset in your case it would be CenterY point + more than half of your players height
So for example your character height is 30 so you check for Object.CenterX() Object.CenterY()+16
And +16 not 15 since 15 is half and you need something MORE than half
It could be +17 but not more)
And in addition to that you check if player is in collision with object
Also you could add multiple conditions
Like double check
Object.CenterX()-3 Object.CenterY()+16
Object.CenterX()+3 Object.CenterY()+16
This -3 +3 will offset center point 3 pixels to the left and right
So and if you put these two conditions in same events
Then it will check if both of them are inside your enemy
This will give you some range how much to the left and right your player can be from center of enemy
So for example yo do not inflict damage if you are on edge of your enemy
ALSO you could add condition (if you are using platformer behavior) player is falling
So it does not happen when you jump up but only when you are falling down
BEST thing to do would be to create object like red small square
And place it at these positions with change positions actions
Object.CenterX()-3 Object.CenterY()+16
Object.CenterX()+3 Object.CenterY()+16
And now you would see exactly where these points are
Later you would remove them from your project
But for now you would use them as visualisation to see where are these point and where your player need to be to inflict damage