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 How to Make a Video Game Score, Enemies, and Game State Monitor Player Health

Alex Ly
Alex Ly
909 Points

Particles not appearing when in contact with the bird

I did everything correctly and there are no errors but when I play and the bird touches me there are no particles.

3 Answers

christopher allen
christopher allen
6,495 Points

i had the same problem but realized the "o" in OnTriggerEnter needs to be capitalized for it to work, i hope this helps!

Alex Ly
Alex Ly
909 Points

I didn't notice that.. Thank you so much!

David Kirk
David Kirk
5,319 Points

I had the same happen when I added particles to fly at first go. Make sure the PlayerParticles prefab is in the Player Health script "pickup Prefab" field. And ensure you have selected Apply on the inspector to save the player object.

Alex Ly
Alex Ly
909 Points

Sorry for the late reply, I did exactly that and it still doesn't show the particles. I also don't die when i get in contact with the bird

David Kirk
David Kirk
5,319 Points

Ok the playerhealth script that object needs to be attached to your player object script, and the "alive" checkbox should be unchecked. and the PlayerParticles script inside of the Pickup Prefab Serialized field. i think the part of the script that detects player alive = false is in that script. this is what i have there hopefully the answer is close.

public bool alive;
[SerializeField]
private GameObject pickupPrefab;

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

private void OnTriggerEnter(Collider other)
{
    if (other.CompareTag("Enemy") && alive == true)
    {
        alive = false;
        // create the pickup particles
        Instantiate(pickupPrefab, transform.position, Quaternion.identity);
    }
}