- Home /
2D UFO Tutorial, UFO turns invisble after 6th pickup?
I have followed the beginners' tutorial on the 2D UFO game.
All is working well, except that my Player object routinely turns invisible after the 6th pickup (on some occasions after the 8th) and will then after a few more pickups return to being visible and sometimes not at all. The whole thing doesn't seem to be consistent at all and I wouldn't know what part of the code should trigger this behavior.
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("PickUp"))
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
}
Would anyone have an idea what could cause this semi-random behavior of the player object?
Answer by Almightyblob · Jan 11, 2017 at 02:24 PM
With some testing, I found that I the script wasn't the problem. They player object was assigned to the default sorting layer; after I assigned it its own layer, the error was gone. Still doesn't seem to be quite logical to me, but it did the trick.
(the pickups were already assigned to their own layer, so I still don't understand the relation in the player object disappearing).
Your answer
Follow this Question
Related Questions
Player invisible on respawn 2 Answers
Mission Objectives 1 Answer
Need help with 2D Attack, attacking in every direction 0 Answers
Seeking tutorial for bejeweled -like game? 1 Answer
2D Sidescroller Issues Please help. 1 Answer