I’m trying to make yet another Tetris game to learn using UE4.
I’m kinda stuck at the very beginning.
My idea would be declaring a class Tetraminos for the single tetris’s pieces like this
That said, I would create a Blueprint out of the Tetraminos class so that it uses the myShape and myColor variables to choose the material for the object (I have created the materials that I want to “link” to the myColor variable) and, most important, the shape.
The “linking” part itself shouldn’t be troublesome, what I really don’t know how to work out is to “tell” the blueprint that if I get the L Shape variable, I want 4 static mesh cubes positioned so that they form an L.
I’m really clueless right now so any advice (even something that would completely change the class) is more than welcome.
I think the best approach (Unless you’d like to allow for custom shapes) would be using L, I, …] shaped meshes instead of combining cubes during runtime. This way you have to worry about way less stuff
Ok so an idea would be creating several Blueprints which have 4 cube components, each Blueprint with a different shape, but this would also mean I would have to implement the same exact code for each single blueprint (no matter the shape, every tetraminos falls, rotates etc) and this is definetely not appropriate.
So I’d like to know if the only way to work around this is having several Blueprints that are children of the Tetraminos class (so that they all share the same methods) and each Blueprint has a different shape.
Not exactly what i meant.
However if you want to implement the logic once it will be enough to use inheritance as you said.
You want to create a parent blueprint called, say, ParentShape, implement the location/rotation logic there, and then derive as many children as you want for each shape. The only thing you will have to change is the mesh on the children (which I suggest you to be only one solid mesh instead of using a composition of cubes)