Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by LoKo6264 · Jun 02, 2016 at 06:26 PM · c#script.enemyfunctionmoving

SetDestination function error

Hi, I was creating game by this tutorial: https://www.youtube.com/watch?v=xUl-Agx2cLc and I got stucked when script from them doesn't work as it should. I get error "SetDestination" can only be called on an active agent that has been placed on a NavMesh. " with this script:

Here is whole code (most of functions are disables until I make these things (as in tutorial where I'm learning from)):

 using UnityEngine;
 using System.Collections;
 
 public class EnemyMovement : MonoBehaviour
 {
     Transform player;
     //PlayerHealth playerHealth;
     //EnemyHealth enemyHealth;
     NavMeshAgent nav;
 
 
     void Awake ()
     {
         player = GameObject.FindGameObjectWithTag ("MyPlayer").transform;
         //playerHealth = player.GetComponent <PlayerHealth> ();
         //enemyHealth = GetComponent <EnemyHealth> ();
         nav = GetComponent <NavMeshAgent> ();
     }
 
 
     void Update ()
     {
         //if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
         //{
         nav.SetDestination(player.position);
         //}
         //else
         //{
         //    nav.enabled = false;
         //}
     }
 }
 

I hope someone has an idea how to fix it because my enemy doesn't move there where I am but just enemy keeps his position all the time.

Comment
Add comment · Show 9
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hanoble · Jun 02, 2016 at 06:57 PM 0
Share

Have you tried moving the position of the enemy down slightly to ensure it is actually on the Nav$$anonymous$$esh?

That error is telling you that you are indeed attempting to set the destination (move) an agent without being on a Nav$$anonymous$$esh, ensure your agent is close enough to the Nav$$anonymous$$esh and that you have it baked correctly.

avatar image LoKo6264 Hanoble · Jun 02, 2016 at 07:35 PM 0
Share

Sorry but I actually don't understand what should I change exactly...Can you tell me what should I exactly change to do that what you're talking about?

avatar image Hanoble LoKo6264 · Jun 02, 2016 at 07:51 PM 0
Share

The enemy object you have that is in the scene you are trying to move, make sure that is down on the ground level with your Nav$$anonymous$$esh almost.

Here is a similar issue:

http://answers.unity3d.com/questions/507534/setdestination-can-only-be-called-on-an-active-age-1.html

Show more comments
avatar image ninja_gear · Jun 02, 2016 at 09:25 PM 1
Share

Bro, its easy to see from your screenshots you haven't baked a Nav$$anonymous$$esh onto that scene. If you had the walkable areas would be blue. Like someone already told you, you haven't finished setting up that scene to work with Nav$$anonymous$$eshAgents, look at the tutorial he linked to you.

avatar image LoKo6264 ninja_gear · Jun 02, 2016 at 09:46 PM 0
Share

What does it mean I haven't baked a Nav$$anonymous$$esh onto that scene and how to fix it? After watch tutorial I still don't understand :/

avatar image LoKo6264 ninja_gear · Jun 02, 2016 at 10:42 PM 0
Share

Ohh, I've just noticed there is button to bake it. I didn't see this. Thank you so much guys!

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

154 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

CharacterController not found the GameObject 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

my enemy is broken 1 Answer

what is wrong whis this? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges