// Contrain the velocity per update // Collect item on trigger enter private void OnTriggerEnter(Collider other) { // Try getting collectable component from other collider Collectable collectable = other.GetComponent <Collectable>(); // If its not null if (collectable) { // Collect the item collectable.Collect(); } }
private void OnTriggerEnter(Collider other) { //try to grab collectable from collider Collectable collectable = other.GetComponent <Collectable>(); //if collectable is not null if (collectable) { //collect the item collectable.Collect(); } }
// Collect item on trigger enter private void OnTriggerEnter(Collider other) { // Try checking if player hits a killbox if (other.name.Contains("KillBox") || other.name.Contains("Enemy")) { // Then we are gonna die Death(); } // Try getting collectable component from other collider Collectable collectable = other.GetComponent <Collectable>(); // If it's not null if (collectable) { // Collect the item collectable.Collect(); } }