Im currently working on a game and i ran to little bit of problem
core of the game is merging units to upgrade which is merging a lvl 1 and another lvl 1 into lvl 2 similar to the games like merge tower defence etc. i wanna do the aswell but dunno how
i wanted to know how it works from a script i dont need a whole script i just need explanation i can make it myself with trial and error and little bit of testing.
The game context in question is: army Merge Defence (my game that I’m working on)
and as the name says the core gameplay of it is merging units basically merging lvl 1 to another lvl 1 to turn it to lvl 2, I already went through npc behavior of shooting using a gun but I haven’t done the merge mechanic as I don’t know exactly sure how it works but I do know it has something to do with/using values.
I’m still a beginner at coding lua so I might ask questions
Also sorry if my grammar is bad English is my 2nd language
It sounds like in your workspace you have two assets (models?) that are the same and that on merging them the two single assets should be destroyed and a new asset appears?
If that is roughly the logic you will need a mechanic to trigger the process ( I havent ever played a merge game but I imagine it might be a click detector ( or proximity prompt) and when the player clicks on it there is a check to see if another L1 asset ( or model ) is in X range and if that condition is met then both models are destroyed and the new L2 asset is cloned in from replicated storage to the workspace at the same spot where the model with the click detector was?
If you are new to coding and this logic feels approximately correct, then you will need a local script in the model to check the condition and send a remote event to the server to validate that it was a valid merge and then clone the model to the workspace.
I noticed that you mentioned attributes you might have an integer attribute that states the level of the asset i.e. “1” and have the code search to see if two assets with attribute 1 are within range. You might also have other attributes for type like archer or melee.
If you have some screenshots and samples of code so far im sure someone here can help out!
Are the next level units always going to be the same when you merge the two (always the same lower level units), and so on, level by level? A lot of the things you see in a game is smoke and mirrors, meaning it is not what you think you’re seeing. If this is simply upgrading to the next level unit, cloning it from storage is most likely what you want. You can be as fancy as you like with how they “merge” graphically, and then slip in the clone of the higher level unit while doing that..
Maybe I’m misunderstand you here, are there other things to consider?