I have a character with platform behaviour. It interacts with solid objects (like floor or cealing) normally.
If i attach another object to the character (for exemple an head), the head does not interact with solid objects, so if i jump the head go through the ceiling, ignoring the collision box.
how can I make it works making the attached object "solid" too?
Develop games in your browser. Powerful, performant & highly capable.
Usually the player body and head are the same object, is there any gameplay mechanic reason why it must be attached separately?
Like moving the body with the directional arrows and moving the head with the mouse (like in a tank for exemple where the turret is controlled with the mouse and the body with the keyboard).
The same problem applies even with attachable weapons, if the object is not solid it simply goes through the walls.
Is going through walls really a problem in a 2D game? Usually the player is a box and you play a sprite animation. Even if the weapon was attached separately, overlapping a wall wouldnt be an issue, either you push against a wall and he plays a different animation and the weapon moves, or you can overlap the wall. If you chose to have the weapon separate from the character as design then I don't think making it solid is a good thing to do.
Well, regardless of it being or not being a good choice, is a doable thing?
How is it possible to achieve it if it's doable?
There are roundabout ways to achieve similar result or just living ignoring the problem and move on, but I just wanted to know if there is a way to achieve it
You need a separated mask object, a square or rectangle sprite that will act as the hitbox with the platform behavior, your character parts must be pinned or positioned to the mask's position (if pinned, position only, not angle in your case)