- Home /
Question by
The0Warrior · Apr 10, 2018 at 11:26 AM ·
scripting problemscript.note
Interactable trigger responding weirdly
Hi,
I have made a read note script which enable when player enter trigger and press LMB
but the problem is that it's responding really weirdly, sometime it respond sometimes not
using UnityEngine;
using System.Collections;
using UnityStandardAssets.Characters.FirstPerson;
using UnityEngine.UI;
public class Notees1 : MonoBehaviour {
public GameObject Pic;
public AudioClip sound;
public GameObject text;
public GameObject playerObject;
public Behaviour blur;
private bool on = false;
void OnTriggerStay(Collider plyr) {
if (plyr.tag == "Player" && Input.GetKeyDown (KeyCode.Mouse0) && !on)
{
Pic.SetActive(true);
AudioSource.PlayClipAtPoint (sound, transform.position);
text.SetActive (true);
playerObject.GetComponent<FirstPersonController>().enabled = false;
blur.enabled = true;
on = true;
}
else if (plyr.tag == "Player" && Input.GetKeyDown (KeyCode.Mouse0) && on)
{
Pic.SetActive(false);
AudioSource.PlayClipAtPoint (sound, transform.position);
text.SetActive (false);
playerObject.GetComponent<FirstPersonController>().enabled = true;
blur.enabled = false;
on = false;
}
}
}
can you guys help me, thank you.
Comment
Your answer
Follow this Question
Related Questions
How can i make the walls creation in the loop to be in slow speed ? 1 Answer
How can I apply a text variable to a prefab 2 Answers
Trying to change character model on mouse down 1 Answer
How to share varibles betweent scripts 4 Answers
A Javascript trying to access an image effect C# script 1 Answer