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 trialNorbu Wangdi
7,187 Pointsnew 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
7 Answers
Simon Andersson
6,880 PointsSetFloat 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
7,187 Pointsusing 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
7,187 PointsYep 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
6,880 PointsYou 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
7,187 PointsMy bad! Thank you so much Simon. Your help is apreciated.
Norbu Wangdi
7,187 PointsI 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
6,880 PointsI'm glad you solved it. Good luck =)
Simon Andersson
6,880 PointsSimon Andersson
6,880 PointsDo 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: