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 Create Enemy Navigation and AI

Norbu Wangdi
Norbu Wangdi
7,187 Points

new field called Target in the inspector doesn't exit.

I am suppose to drag and drop player game object from hirarchy to the target field in inspector. But target field does't exit- any setting wrond? HELP

Simon Andersson
Simon Andersson
6,880 Points

Do you mean you can't find the Target field? If that is the case, make sure you have a serialized variable of type Transform under your class in the BirdMovement script.

Like this:

public class BirdMovement : MonoBehaviour {

    [SerializeField]
    private Transform target;

7 Answers

Simon Andersson
Simon Andersson
6,880 Points

SetFloat is a method which means it's case sensitive.

    birdAnimator.SetFLoat ("Speed", speed); 

to

        birdAnimator.SetFloat("Speed", speed);

Although I'm not quite sure what your error is. Can you not see the Target field in the inspector at all?

Norbu Wangdi
Norbu Wangdi
7,187 Points

using UnityEngine; using System.Collections;

public class BirdMovement : MonoBehaviour {

[SerializeField]
private Transform target;
private NavMeshAgent birdAgent;
private Animator birdAnimator;

// Use this for initialization
void Start () {
    birdAgent = GetComponent<NavMeshAgent> ();
    birdAnimator = GetComponent<Animator>();

}

// Update is called once per frame
void Update () {
    // Set the bird's destination
    birdAgent.SetDestination(target.position);

    //Measure the magnitude of the NavMeshAgent's velocity
    float speed = birdAgent.velocity.magnitude;

    //pass the velocity to the animator component
    birdAnimator.SetFLoat ("Speed", speed); 


}

}

this is the code, I cant see anything wrong. Thank you for the help in advance

Norbu Wangdi
Norbu Wangdi
7,187 Points

Yep i cannot find it. I have watched video several times too and it kept missing from the inspector window. Its strange....

//pass the velocity to the animator component birdAnimator.SetFLoat ("Speed", speed); I also get SetFloat red underlined when i save the code. But it seems to me, I have written exactly the same code. May be something missing,

Simon Andersson
Simon Andersson
6,880 Points

You get it red because you've written "SetFLoat" instead of "SetFloat".

Do you see the script BirdMovement on the bird? Also make sure to save your script.

Norbu Wangdi
Norbu Wangdi
7,187 Points

My bad! Thank you so much Simon. Your help is apreciated.

Norbu Wangdi
Norbu Wangdi
7,187 Points

I think problem lies with SetFloat method as i have wrongly typed. when i corrected, target appeared. Thank you for the help. I am continuing with the course now

Simon Andersson
Simon Andersson
6,880 Points

I'm glad you solved it. Good luck =)