Hi everyone,
I’m currently creating a mix of pool and 2048 in Unity 2D, and I’m having some trouble combining GameObjects with the same values. Here is my code for this so far:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class ValueBallManager : MonoBehaviour
{
public int bv;
public RectTransform rt;
public TextMeshPro tmp;
public Collider2D col;
void Start()
{
}
void Update()
{
tmp.text = "" + bv;
}
private void OnTriggerEnter2D(Collider2D collision)
{
string collisionValue;
TextMeshPro collisiontmp = collision.gameObject.GetComponent<TextMeshPro>();
collisionValue = collisiontmp.text;
if (collisionValue == tmp.text)
{
bv = bv * 2;
Debug.Log("hi!");
}
}
}
I’m using TextMeshPro to display the values since regular text wasn’t working as well. Whenever I try and test this code, the console doesn’t return anything. Is there something I’m doing wrong?
(I’m also really new to Unity so please excuse any lack of general knowledge I might demonstrate)