The code in this chapter
Let's take a look at the code again to make sure we are on the same page.
The code for Collectable.cs
:
using UnityEngine; using System.Collections; public class Collectable : MonoBehaviour { bool isCollected = false; void Show() { this.GetComponent<SpriteRenderer>().enabled = true; this.GetComponent<CircleCollider2D>().enabled = true; isCollected = false; } void Hide() { this.GetComponent<SpriteRenderer>().enabled = false; this.GetComponent<CircleCollider2D>().enabled = false; } void Collect() { isCollected = true; Hide(); GameManager.instance.CollectedCoin(); } void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { Collect(); } } }
The code for playerController.cs
:
using UnityEngine; using System.Collections; public class PlayerController : MonoBehaviour { public static PlayerController instance; public float jumpForce = 6f...