Please help to implement: connecting similar objects while dragging and creating a new object, so that you can clearly understand how this should work, I’ll drop the link to the game where I have what it takes. Human Evolution Clicker: Game about Life is very interesting to look at such a script thank you so much :)

  • He played it and wondered too. You can hang on each colider, and at the intersection check to do, if the one who collided = the one to whom they touched, connect. - Aqua
  • If you do this with the usual movement, they will also be connected, but I need it when you drag! Listen, can you help me please? - Flipsizze Nov.
  • And if at the moment of pressing the Boolean variable to true , and when to connect, then the variable is taken into account - Aqua
  • What kind of personal help will be needed, I have links in my profile (write only in case of non-compliance with the theme of the site here) - Aqua
  • Well I will know to whom to ask for help) - Flipsizze Nov.

2 answers 2

I think the answer @Andrey only correct, but a little more detail sign for.

  1. You create a script on Drag And Drop under Unity.
  2. Draw a diagram of all possible "pairings" on paper
  3. you create your own class for each possible type of object, which is inherited from BaseAnimal (which is drag and drop)
  4. In the function drag and drop you try to understand what kind of animal was thrown and

    4.1. First you create a new Animal with the coordinates of the one to which you dropped

    4.2. and then destroy both objects

    4.3 at the place of dragging an object you start an animation of smoke that will be MORE than any of the Animal objects. (hiding the moment of disappearance of two beasts and the appearance of thirds)

It is in this sequence.

Well, actually, everything.

Well, you can complicate the logic and add variation. Type when connecting 2 things with a probability of 30% you create a creature 3 and with a probability of 70 - creature 4. But as for me, this is too complicated and overkill.

PS: By the way, I assure you that this is the logic that Materia Fusion was implemented in Final Fantasy Crisis Core and in many other games :) It’s just checked: you can find an exact list on the Internet about what specifically needs to be combined to get a specific result.

PS2: To simplify the mating structure, you can create logic based on some interfaces. That is, for example, you have 3 things that are inherited from the interface IBeast1 and 3 things that inherit from IBeast2 . And their combination will give one specific result - IBeastN . Moreover, the random of 3 representatives of IBeastN :)

  • I can drag the object, can you no further help please in my free time ?! If you need a script for my movement, I can throw it off. - Flipsizze
  • do not look specifically for the implementation script drag-drop-a, I watched a little on the Internet and saw a couple, but did not check their work, of course. And dragging objects across the stage generally has a standard script in Unity, so if you wrote it yourself, then it was too much work :) - Andrew
  • To make a random result in such games - such a game design of course :) - RiotBr3aker

Alternatively, you need to know the combinations in advance and what they give. As an option, you need classes of every type. There is a bacterium, man, and so on in the same vein. It is worth getting a base class for all with the method of combining. In the method of transmitting with whom you merge. And in each class have its own list of key values. Input type and merge result. And so with everyone. Yes, a lot of work, but in any case, you need to know in advance the results of mergers. So far this is my version invented on the go. If it seems interesting to you, we can discuss the details and how to improve it.

  • This option is very interesting! Where and when can you discuss all this?) - Flipsizze
  • I have my skype profile. You can write there. try to solve this problem in the correspondence there - Andrey
  • Here is Andrew, I'm doing your idea (before you wrote), I’m dumb at the moment of the merger result. I do not have 1 out of a pair, but also a pair. What do you think? - Aqua
  • I understand that in your version there is also a common for all classes merge method which is redefined in each successor. Yes ? - Andrey
  • one
    I would say that this is the only option. Only you can still add variability (that is, when combining 2 objects of a particular type, you get a third type with a probability of 30, and type 4 with a probability of 70%). But this is an unnecessary complication. I also advise you to start with drawing graphics "pairing" objects trite on paper :) - Andrew