This script is to be placed on an empty game object with a sphere collider marked as trigger infront of an arcade machine.
using UnityEngine;
using System.Collections;
public class ArcadeMachine : MonoBehaviour
{
public GUIText playGame;
private GameObject player;
void Awake()
{
player = GameObject.FindGameObjectWithTag("Player");
playGame.text = "Press 'P' to play!";
}
void Start()
{
playGame.enabled = false;
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject == player)
{
playGame.enabled = true;
}
if(Input.GetKeyUp(KeyCode.P))
{
Debug.Log("Playing Game");
}
}
void OnTriggerExit(Collider other)
{
if(other.gameObject == player)
{
playGame.enabled = false;
}
}
}
I just want a message to return, letting me know that everything is working,as a a filler until I can set up the desired code. I get the “Press P to play” GUI, which disappears once I exit the collider, but once I am within the collider, and press P, I get no message in the console. Does anyone know how to fix this?