About 'Singleton Pattern Bug Fix'!

In this video (objectives)…

  1. Inserted a simple fix for bugs we are seeing with the Singleton.
  2. Immediately set the game object to inactive and then destroy it.

After watching (learning outcomes)… Fix one of the known issues with the singleton not destroying itself correctly.

(Unique Video Reference: 26b_BR_CUD)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

1 Like

Aha!!

I was getting a problem with my score not being added when the last block was destroyed and after I switched to a new level. This fixed that issue.

Also, Unity (v. 2018.3.0f2) was crashing anytime I used the Destroy(); method on a block unless I added in the “optional” delay parameter.

In other words:
If I used Destroy(gameObject); directly, I’d get a crash.
If I used Destroy(gameObject, 0.01f); this would work.

Setting the object to inactive prior to the call to Destroy(); eliminated the need for the additional parameter and fixed the crash issue for me.

That would seem to suggest that it is good practice to always “deactivate” a game object before calling Destroy();

2 Likes

Hi,

Thanks a lot to get back with a video to fix some issue. I still continu this is the best video formation that I never seen.

Privacy & Terms