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

Daniel Wise
Daniel Wise
9,119 Points

Error trying to bake a mess on "How to make a video game"

Hello I was following along with "How to make a video game, Score, Enemies, and Game State", the 4th part. When I try to bake the mesh settings in the environment I get these errors in the console "Frogs and Logs is not a valid directory name. Please make sure there are no unallowed characters in the name.", "Could not create asset directory Assets/_Scenes/Frogs and Logs .". This leads to some issues when I try to run the game and the bird fails to run after me and the follow error appears in the console ""SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.NavMeshAgent:SetDestination(Vector3) BirdMovement:Update() (at Assets/Scripts/BirdMovement.cs:22)" Any ideas on why the mesh won't bake and how these errors are occurring?

1 Answer

Alan Mattanรณ
PLUS
Alan Mattanรณ
Courses Plus Student 12,188 Points

Hi Daniel! I follow the course "How to make a video game" and i did't hit this problem. The problem can be in the script BirdMovement.cs at line 22.

         birdAgent.SetDestination (target.position);

Is birdAgent in red when you open it in VS or Mono? Is birdAgent declaretion ok? Do birdAgent has a NavMeshAgent componente? The code "GetComponent" is correct?

birdAgent = GetComponent<NavMeshAgent> ();

Pass the link to the video tutorial so I can look into the source.

Daniel Wise
Daniel Wise
9,119 Points

Hello Alan I took another look at my script and this is how it looks

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 looks very similar to the final code written for BirdMovement.cs in the video and I am still getting said error.

Daniel Wise
Daniel Wise
9,119 Points

Hello again Alan nope birdAgent is not red when I open it so I figure the birdAgent is ok. It appears I am not getting any errors in mono. My GetComponent code is the same as yours

birdAgent = GetComponent<NavMeshAgent> ();

Here is the link to the tutorial

https://teamtreehouse.com/library/how-to-make-a-video-game/score-enemies-and-game-state/create-enemy-navigation-and-ai