- Home /
Interact script not working but has worked before.
Hi there, I've made a script that lets me interact with objects, it worked before and now it doesnt. What could be the cause of this?
using UnityEngine;
using System.Collections;
public class Interact : MonoBehaviour {
public GameObject shop;
public GameObject shopui;
// Use this for initialization
void Start () {
if (shop == null) {
shop = GameObject.FindWithTag("Shop");
}
shopui.active = false;
}
// Update is called once per frame
void Update () {
if(Vector3.Distance(transform.position, shop.transform.position) < 1 && Input.GetKeyDown(KeyCode.Tab))
{
runInteractionScript();
}
if(Input.GetKeyDown(KeyCode.Escape)) {
shopui.active = false;
GetComponent<FPSInputController>().enabled = true;
GetComponent<MouseLook>().enabled = true;
}
}
void runInteractionScript() {
shopui.active = true;
GetComponent<FPSInputController>().enabled = false;
GetComponent<MouseLook>().enabled = false;
}
}
Comment
"it doesn't work" doesn't give any clues regarding unexpected behaviour, error messages, etc. please elaborate.
Unity doesnt give any errors, just that when i press tab, the gui doesnt open. It worked before...
Your answer
Follow this Question
Related Questions
Item Object Null When Spawned in as a Prefab Clone 1 Answer
How to Show 'buy' button relevant to character selected ? 1 Answer
In-game Shop / Market/ Buying / inventory system? 3 Answers
GUI grid of buttons issue. 1 Answer
PlayFab: KeyNotFoundException: The given key was not present in the dictionary. 0 Answers