Merging two Gameobjets into one!

Hey guy’s,
I’m trying to figure out a way to merge two game objects the way I want them to, but I have no idea how to even begin… Here’s the deal:

I’ve got a 2D platformer where you can shoot projectiles called blobs. Those blobs are just cubes with dimestions of 0.1, 0.1, 0.1 for now. I’d like them to merge into a bigger “blob” when they collide (or come close to each other) and this bigger blob should have the same properties so that when a smaller blob hits it, they merge and the blob gets even bigger. So that 2 blobs merge into one blob with dimensions of 0.2, 0.2, 0.2 and when another small blob hits it, they merge into a blob with dimensions of 0.3, 0.3, 0.3 and so on.

I hope I wrote that in a way that it is understandable, because like I said, I have no idea how to even begin…
To make things a bit more simple, you can just give me some tips to how I can do that, instead of writing the whole code for me, since I’m in the process of learning and wouldn’t mind if I had to figure out the specifics myself (that doesn’t mean I’d dismiss written code ^^).

When you need more information’s about the blobs (or anything really), I will of course try to provide them as fast as I can!

Thank you in advance, and have a nice day!


If I understand you correctly you want to scale a current GameObject by another GameObject. Try the following (you can also modify any other properties here)

using UnityEngine;
using System.Collections;

public class BlobManager : MonoBehaviour
    public GameObject MergeBlob(GameObject originalBlob, GameObject newBlob)
        Vector3 originalScale = originalBlob.transform.localeScale;
        Vector3 newScale = newBlob.transform.localeScale;
        Vector3 mergedScale = new Vector3(originalScale.x * (1 + newScale.x),
                                          originalScale.y * (1 + newScale.y),
                                          originalScale.z * (1 + newScale.z));
        originalBlob.transform.localeScale = mergedScale;
        return originalBlob;