void OnTriggerEnter2D(Collider2D hit) { if (hit.CompareTag("star")) { carryingStar = true; playerInventoryDisplay.OnChangeCarryingStar(carryingStar); Destroy(hit.gameObject); } }
void OnTriggerEnter2D(Collider2D hit) { if (hit.CompareTag("Star")) { totalStars++; playerInventoryDisplay.OnChangeCarryingStar(totalStars); Destroy(hit.gameObject); } }
//-------------------------- void OnTriggerEnter2D(Collider2D hit) { // IF we hit something tagged 'Star' if (hit.CompareTag("Star")) { // set our flag to TRUE carryingStar = true; // update the UI display of our star carrying status playerInventoryDisplay.OnChangeCarryingStar(carryingStar); // destroy the star object that we collided with Destroy(hit.gameObject); } }
//------------------------ // cache a reference to the PlayerInventoryDisplay object // that is in the parent GameObject // // and then ensure UI display matches this initial state // of whether we are carrying a star or not void Start() { playerInventoryDisplay = GetComponent <PlayerInventoryDisplay>(); playerInventoryDisplay.OnChangeCarryingStar(carryingStar); }
//------------------------ // cache a reference to the PlayerInventoryDisplay object // that is in the parent GameObject // // and then ensure UI display matches this initial state // of whether we are carrying a star or not void Start() { playerInventoryDisplay = GetComponent<PlayerInventoryDisplay>(); playerInventoryDisplay.OnChangeCarryingStar(carryingStar); }
//------------------------ // Ensure UI display matches this initial state // of whether we are carrying a star or not void Start() { playerInventoryDisplay.OnChangeCarryingStar(carryingStar); playerInventoryDisplay.OnChangeStarTotal(totalStars); }
//------------------------ // Ensure UI display matches this initial state // of whether we are carrying a star or not void Start() { playerInventoryDisplay.OnChangeCarryingStar(carryingStar); }