Run-and-capture/Assets/Scripts/Bonus/BonusCollisionController.cs
2021-08-19 23:07:26 +03:00

22 lines
674 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BonusCollisionController : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
var playerBonusController = other.gameObject.GetComponent<PlayerBonusController>();
if (playerBonusController)
{
var currentBonus = GetComponent<BonusVisuals>().bonus;
bool bonusPickedUp = playerBonusController.AddBonusToPlayer(currentBonus);
if (bonusPickedUp)
{
Debug.Log("picked up " + gameObject.name);
Destroy(gameObject);
}
}
}
}