• 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 dthoma6403 · Jun 25, 2019 at 06:46 PM · navmeshnavmeshagentnamespace

Can't Access NavMeshAgent methods

I am trying to use the UnityEngine.AI namespace and can't get any access to agent.speed or agent.destination

I have the proper namespace referenced, and for the life of me can't figure out what is going on. Has anyone else had this issue? Any ideas?

Comment
Add comment · Show 1
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 28mitu · Jun 25, 2019 at 07:51 PM 0
Share

Could you show the code?

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by 28mitu · Jun 25, 2019 at 10:00 PM

@dthoma6403 I placed this script in my project and had no errors. The class "NavmeshAgent" is already created by you i.e.,

  public class NavMeshAgent: MonoBehaviour{
     }

And again you declared it

     public NavMeshAgent agent;

Both have the same class name that's causing the problem. Change the script name with another name. Example:

 public class NavMeshAgentScript : MonoBehaviour{

}

I hope it helps.

Comment
Add comment · Share
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
0

Answer by dthoma6403 · Jun 25, 2019 at 08:14 PM

Of course, my bad @28mitu

using UnityEngine; using UnityEngine.AI; using UnityEngine.UI;

public class NavMeshAgent : MonoBehaviour { public Transform target; public NavMeshAgent agent;

 public Transform[] points;

   
 private int destPoint = 0;

 public Image newImage; 
 

 


 private void Awake()
 {
     target = GameObject.FindGameObjectWithTag("Player").transform; // store the player's position to use when needed 

     agent = GetComponent<NavMeshAgent>();

     

 }

     void Start()
 {
     
 }

 void Update()
 {


     if (points.Length == 0)
         return;

    // agent.destination = points[destPoint].position;

     destPoint = (destPoint + 1) % points.Length;
 }


}

So in the editor using UnityEngine.AI is grayed out and telling me it isn't being used, and I have the Unity extension for VS installed, have been at this for hours with no idea what's going on

Comment
Add comment · Show 1 · Share
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 dthoma6403 · Jun 26, 2019 at 12:44 AM 0
Share

i don't think i EVER would have caught that, you're a life saver that was definitely the issue. Thanks so much!

avatar image
0

Answer by Ray_Adiiwiguna · Jan 09, 2020 at 06:06 PM

How to stop at the last point so as not to return to the begining?

Comment
Add comment · Share
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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

114 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

Related Questions

Navmesh ramp 1 Answer

NavMeshAgent Calculate Jump Trajectory 1 Answer

NavmeshAgent.remainingDistance remains at 0 but the agent still moves and behaves correctly 4 Answers

Instantiating Enemy AI NavMesh Agent SetDestination Error 1 Answer

Editing NavMesh Paths? 0 Answers


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