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

New Enemy

Ok! so I made a new bird and gave it some waypoints and even gave it a "Animator component"! every thing works but for some reason it wont play the animation for the bird... GGRRRRR!......any help would be nice Please. ill past my code in a comment below! hope to here from somebody soon! till then back to work

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI;

public class BlinkyMove : MonoBehaviour { public Transform[] points; private int destPoint = 0; private UnityEngine.AI.NavMeshAgent agent; private Animator blinkyAnimator;

void Start()
{
    blinkyAnimator = GetComponent<Animator> ();
    agent = GetComponent<NavMeshAgent>();

    // Disabling auto-braking allows for continuous movement
    // between points (ie, the agent doesn't slow down as it
    // approaches a destination point).
    agent.autoBraking = false;

    GotoNextPoint();
}


void GotoNextPoint()
{
    // Returns if no points have been set up
    if (points.Length == 0)
        return;

    // Set the agent to go to the currently selected destination.
    agent.destination = points[destPoint].position;

    // Choose the next point in the array as the destination,
    // cycling to the start if necessary.
    destPoint = (destPoint + 1) % points.Length;
}


void Update()
{
    // Choose the next destination point when the agent gets
    // close to the current one.
    if (!agent.pathPending && agent.remainingDistance < 0.5f)
        GotoNextPoint();
}

}

1 Answer

WOOOOOO! never mine I fix it haha ! yeah baby I feel good to day !