I have a spawn point that I would like to spawn an object from when the player is within a certain distance and presses the appropriate button. How would I go about this?
At the moment I just have the object spawning at Start:
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectSpawner : MonoBehaviour {
public GameObject DefenseShield;
public Transform Spawner;
private void Start()
{
Instantiate(DefenseShield, Spawner.position, Spawner.rotation);
}
}
`
Thanks