Hi Everyone,
TurretBuilder Script have to choose which turret we have to build,
I set the “Turret” that belong to “TurretBuilder” - in the console.
When we press on the Picture of turret (GameObject) ,
And
ToBuild script , is actually build the turret choosen, which set before in TurretBuilder script…
Actually , I got this error:
UnassignedReferenceException: The variable TTB of ToBuild has not been assigned.
There is the scripts:
Please help
ToBuild Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ToBuild : MonoBehaviour
{
public Transform TTB;
public void GetTurretToBuild(Transform _TTB)
{
TTB = _TTB;
}
void OnMouseDown ()
{
Instantiate(TTB, transform.position, transform.rotation);
Debug.Log("We Instantiated object");
}
}
TurretBuilder Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TurretBuilder : MonoBehaviour
{
public Transform turretGO;
public Transform turretSet;
void Update ()
{
turretSet = turretGO;
}
void OnMouseDown ()
{
Debug.Log("We Click TuerrtBuilder");
GameObject placer = GameObject.Find("ToBuild");
placer.GetComponent<ToBuild>().GetTurretToBuild(turretSet);
}
}