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

Luka Gril
Luka Gril
10,540 Points

Can't see target field in inspector

Hello,

i can't get the target field to be visible in inspector. Some people already asked about this, but they managed to solve. They had some synthax mistakes in their code, but I belive my code is correct, at least i can't see any mistakes.

using UnityEngine; using System.Collections;

public class BirdMovement : MonoBehaviour {

[SerializeField]
private Transform target; // this should be visible in inspector 
private NavMeshAgent birdAgent;
private Animator birdAnimator;



void Start () {
    birdAgent = GetComponent<NavMeshAgent> ();
    birdAgent = GetComponent<Animator> ();
}

void Update () {
    birdAgent.SetDestination (target.position); 
    float speed = birdAgent.velocity.magnitude;
    birdAnimator.SetFloat("Speed", speed); 
}

}

Luka Gril
Luka Gril
10,540 Points

Found mistake minute after I posted the question. I initialized birdAgent twice instead of initializing birdAnimator.