I am building a merging game where I want to check if a tower of the same kind is placed on the node beside the first one. Basically I want to check if a game object of the same kind is beside the current game object. I have tried different ways that I thought were familiar but have had no progress. (also, this happens within a button output).
My sort of script*
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Merge : MonoBehaviour
{
//a radius that covers 8 nodes
public float nearTurret = 6f;
//the prefab that is going to be merged
public GameObject slingshot;
//On click event =
public void TowerMerge()
{
if () // < I don't know what to put here, what I want to do is (if slingshot is in radius of nearTurret) then ...
{
Debug.Log("Fuse towers");
}
else
{
Debug.Log("No tower near");
}
}
//Radius Gizmos
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.white;
Gizmos.DrawWireSphere(transform.position, nearTurret);
}
}