Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Game Development How to Make a Video Game Score, Enemies, and Game State Add a Start and End

John Moron
John Moron
1,658 Points

BirdMovement 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);

}

}

Damien Watson
Damien Watson
27,419 Points

Hi 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

9 Answers

John Moron
John Moron
1,658 Points

It 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
Damien Watson
27,419 Points

If 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
John Moron
1,658 Points

I'm just as confused as you are maybe I have load the the folder from a different file location.

John Moron
John Moron
1,658 Points

I 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
Damien Watson
27,419 Points

Cool, 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
John Moron
1,658 Points

Now 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
Damien Watson
27,419 Points

What 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
John Moron
1,658 Points

Oh I'm using 5.3.2f1, so If I updated it then it will fix the code automatically?

John Moron
John Moron
1,658 Points

I'm Still getting the same error I don't know what else to do.

Damien Watson
Damien Watson
27,419 Points

The 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
John Moron
1,658 Points

So my whole project I'll send you a link with Dropbox thank you!

John Moron
John Moron
1,658 Points

Hi 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
Damien Watson
27,419 Points

Thanks John, I will have a look in a few hours and let you know how I go.

Damien Watson
Damien Watson
27,419 Points

Did 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
John Moron
1,658 Points

Ohh ill check i thought I uploaded the right file I'm sorry!