Hello! For the game I’m making, I need to create objects made up of three parts:
Top part: has its own area2d, size doesn’t change;
Middle part: has it’s own area2d, vertical size varies from object to object (some are taller than others);
Bottom part: has its own area2d, size doesn’t change.
(I’m using Area2D because the player can be “inside” these objects)
My question is: what would be the best way to create such objects during game runtime? I need those objects to spawn as obstacles, and the middle part should vary in size. I thought of a solution which involved spawning the bottom part, then the middle part of needed size on top of it, then the top part on top of that, but would that be inefficient? I feel like there must be an easier solution I’m not thinking of.
Hello! This object is a pillar obstacle that the player has to avoid hitting. I am splitting it into three parts because the top and bottom are wider than the middle part, and they also do not change their size when the height of the pillar changes. I don’t need to differentiate the collision between the different parts.
Technically the object could be made of just one part, but I don’t know how to change the size of the middle part while keeping the top and the buttom the same.
Thank you for the answer! Still, I’m having some problems implementing it. I have divided the pillar sprite into three parts, how do I position them? Do I apply sprites as children of each collision shape? That doesn’t seem good.
Also I heard that scaling collision shapes is bad. Is that true?