Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development

bird not colliding with frog

I have followed all the steps for the frog game to set up the bird following the frog. Everything is fine but after completing the last section of setting up the player health. The bird just walks up to the frog, does the idle animation and nothing happens. I not sure what I am missing the bird is tagged as "Enemy" and I have been over the code. Could anyone give me any Idea what I need to do

public class PlayerHealth : MonoBehaviour {

public bool alive;
[SerializeField]
private GameObject pickupPrefab;

// Use this for initialization
void Start () {
    alive = true;
}

void onTriggerEnter (Collider other) {
    if (other.CompareTag ("Enemy") && alive == true) {
        alive = false;

        // create pick up particales
        Instantiate(pickupPrefab, transform.position, Quaternion.identity);
    }
        }

}

Thanks

1 Answer

Alan Mattanó
PLUS
Alan Mattanó
Courses Plus Student 12,188 Points

Go to the point where "idle animation and nothing happens". Try to understand what are the conditions you need for triggering what you are looking for. Try to debug in console each condition: is "alive" true? Is the tag set to "Enemy"?.

      `
      if (alive) Debug.Log("Is alive !" );
      `

You can pause the game modify your code and debug the conditions.

Thanks, That helps and I have managed to fix where I went wrong :)