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 trialJohn Moron
1,658 PointsBirdMovement Code won't load
The BirdMovement won't load correctly tried everything that might let but it's not working please help. I know my code is correct. This is whats holding me back from finishing the course.
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 destinaton
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);
}
}
9 Answers
John Moron
1,658 PointsIt shows an error in the bird inspector tap. And I just noticed that the target tab is there, it was before now it's gone, please help!
Damien Watson
27,419 PointsIf you have errors in your code, public variables (ie the target input) may not appear. I pasted your code into my project and the target input appeared as expected, so I don't believe it's an error with the bird script.
Not sure what you mean by an error in your bird inspector tab, what does it say / look like? Sorry, I'm just guessing now as there is not enough information to help you fix it.
John Moron
1,658 PointsI'm just as confused as you are maybe I have load the the folder from a different file location.
John Moron
1,658 PointsI solved my issue, what happened was unity couldn't fined my script for both birdmovement and playermovent. So I recreated the script and copied and pasted it. I Put A 1 after the name to trick unity and it worked! Thanks for the help I didn't know how to explain my problem because I didn't know what the issue was.
Damien Watson
27,419 PointsCool, glad you got it figured out. One of those issues you can only solve at the keyboard. Hope the rest of the course goes smoothly for you. :)
John Moron
1,658 PointsNow I'm having issues with my scripts saying the partial system needs to be updated. I found the code for it and I put it in the particul scripts but I'm getting a pearsing error. I'm really frustrated and can't fix it.
Damien Watson
27,419 PointsWhat version of Unity are you using, could it be that? I just updated to the latest 5.3.4f1 and it's all good.
John Moron
1,658 PointsOh I'm using 5.3.2f1, so If I updated it then it will fix the code automatically?
John Moron
1,658 PointsI'm Still getting the same error I don't know what else to do.
Damien Watson
27,419 PointsThe only way I can think of helping you solve this is for you to upload the code somewhere and share the link. If I can see the error in front of me, I should be able to help you fix it. The zip will be around 300MB, so emails out of the question.
John Moron
1,658 PointsSo my whole project I'll send you a link with Dropbox thank you!
Damien Watson
27,419 PointsThat would be great. :)
John Moron
1,658 PointsHi Sorry for the late response here is the download link for my project. Would you mind editing for me and explain what you did that would be wonderful. I used google drive instead I didn't have enough space in my dropbox. Thanks for helping me:) https://drive.google.com/folderview?id=0BxublZm34OEfNnI2X1BzUWNsdGc&usp=sharing
Damien Watson
27,419 PointsThanks John, I will have a look in a few hours and let you know how I go.
Damien Watson
27,419 PointsDid you upload the correct version? In scripts it only has 'DontDestroy' & 'GameQuality'. Opening it converted from 5.1.3f1 to my version 5.3.4f1. But it ran fine and without errors.
John Moron
1,658 PointsOhh ill check i thought I uploaded the right file I'm sorry!
John Moron
1,658 PointsHere is is the right file like sorry for the in convince. https://drive.google.com/folderview?id=0BxublZm34OEfOG9LbW9KWUIwMm8&usp=sharing
Damien Watson
27,419 PointsDamien Watson
27,419 PointsHi John, as you've said, your code looks to be correct. What do you mean by the BirdMovement won't load correctly? Does it come up with an error, or runs fine but nothing happens?
Have you dragged your frog object onto the target? (I think the frog is the target, testing the memory;).
If you can give any more details I'll try and help you out. Cheers