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 zachnudels · Oct 14, 2018 at 10:31 AM · navmeshnavmeshagentagent

Disable and Enable NavMesh Agent Unable to Move to Destination

Hi,

I'm trying to develop a 3D platformer. One of the powerups allows the user to sit back while a NavMesh Agent takes them up a few platforms.

If I start the NavMesh Agent in the scene and allow it to move to it's goal destination, it does so perfectly. However, if I only instantiate (or even enable it if it's already instantiated) during gameplay (as opposed to the beginning), it does not move to its goal destination.

Further, if it is going from the beginning and I disable and reenable it, it also does not work correctly and does not move to its goal destination.

Here is the code to get it to move to its goal destination:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using System.Linq;
 using UnityEngine.AI;
 using UnityStandardAssets.Characters.ThirdPerson; 
 
 public class MoveTo : MonoBehaviour {
     
     public ThirdPersonCharacter character;
     NavMeshAgent agent;
     public indexFinder[] platforms;
 
 
     void Start () {
         
         platforms = FindObjectsOfType<indexFinder>().OrderBy( go => go.name ).ToArray();
         agent = GetComponent<NavMeshAgent>();
         agent.destination = platforms[platforms.Length-1].transform.position; 
         Debug.Log (agent.destination);
         agent.updateRotation = false;
     }
 
     void Update(){
         if (agent.remainingDistance > agent.stoppingDistance) {
             character.Move (agent.desiredVelocity, false, true);
         } else {
             character.Move (Vector3.zero, false, false);
         }
     }
 }

Any help would be hugely appreciated. Thanks

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 zachnudels · Oct 14, 2018 at 12:07 PM 0
Share

I'm now able to activate it. However, I have realised that the problem lies in trying to set the position/rotation of the agent before activation.

I have used Warp() as well as setting the transform directly. Neither have worked.

I've also tried a combination of disabling the Agent, setting the transform, enabling the agent, enabling the $$anonymous$$oveTo script.

Nothing worked correctly

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by RohanP · Feb 01, 2021 at 07:25 PM

Even i have the same issue.If anyone finds a fix please inform.

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.

Follow this Question

Answers Answers and Comments

95 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

Related Questions

Failed to create agent because it is not close enough to the NavMesh 0 Answers

How to prevent NavMeshAgents from colliding when warped to same position? 0 Answers

Making NavMesh areas? 0 Answers

Is it possible to store NavMeshAgents paths and assign them to other NavMeshAgents later? 1 Answer

"SetDestination" can only be called on an active agent that has been placed on a NavMesh. 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