- Home /
Question by
gameorchard · Jun 15, 2016 at 06:17 AM ·
javascriptbug
Variable value not changing when using OnTriggerStay()
Hey guys,
For some reason my papers variable will not change when I press a key within OnTriggerStay()
The two gameobjects carry out a function, but the variable does not.
function OnTriggerStay(Col : Collider)
{
if(Col.tag == "Player")
{
if (Input.GetKeyDown('e'))
{
papers = papers + 1;
Debug.Log( "A paper was picked up. Total papers = " + papers );
Destroy(gameObject);
Destroy(Cassette);
}
}
}
function Update()
{
if(papers == 7){
Application.LoadLevel("UndergroundCutscene");
}
}
I know the variable value stays the same because I used this code to allow me to see the value.
InvokeRepeating("Paper", 0.1, 0.01);
function Paper () {
Debug.Log("Papers = " + papers);
}
Thank you for your time, all answers are greatly appreciated.
Comment
Your answer
Follow this Question
Related Questions
Fade out effect isn't working if loaded at the second time. 2 Answers
Make sure levels assets are loaded before switching? 1 Answer
Cannot read Array Length 2 Answers
Entering Data into a 2d array overwrite issue. 1 Answer
Audio Repeating. 1 Answer