- Home /
Question by
Psilocybe · Aug 18, 2015 at 03:05 PM ·
javascriptscripting problemport
JS error when transferring from Unity 4 to 5
I had been making a simple endless runner type game in Unity 4. I decided to switch to 5 and when I did so, some scripts broke. I have managed to fix most of them, but the following has me stumped.
The script is attached to the pickup prefabs and handles the scoring when the player collects them. It worked in Unity 4...
The error message I get is: BCE0019: 'Instance' is not a member of 'UnityEngine.GameObject'.
#pragma strict
var GameController : GameObject;
function OnTriggerEnter2D(other : Collider2D)
{
if (other.gameObject.tag == "Player")
{
dead();
GameController.Instance.SendMessage("ScoreAddTen", 10);
}
}
function dead ()
{
Destroy(gameObject);
}
Comment
Answer by tanoshimi · Aug 18, 2015 at 03:08 PM
The error is pretty explicit: Gameobjects don't have Instances. Did you mean:
GameController.SendMessage("ScoreAddTen", 10);
?
Your answer
Follow this Question
Related Questions
Is this "scene switcher" script set up the right way? 1 Answer
Why isn't my teleport on collision script working? 0 Answers
Building on android. 1 Answer
2d Character runs in place via animator 0 Answers