• 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
Question by Querke · Mar 18, 2015 at 01:58 PM · ainavmeshnavmeshagentpathfinding

Possible to edit the movement of NavMeshAgent ?

Hello!

I am fiddling with my first pathfinding behaviour. I am using a navmesh and the built in NavMeshAgent and it works great so far!

But I want the agent to take a wider, curved turn (because the agent-object is a vehicle) [Check the illustration below to see what I mean].

If I could edit the navmesh properties at some extend or even create my own navmesh agent, I could say that the agent can only go forward and Slerp the rotation towards the target.

Does anyone know of a editable NavmeshAgent template code??

Or have any other good tips on how to get the navmesh-agent to do a wider curved vehicle-like turn/rotation?


What I have tried:

  • A empty gameobject with the unity NavMeshAgent component that goes towards a destination target

  • A object with the vehicle model and a script saying it should only go forward and rotate towards the navmeshagent (this creates a nice and wide vehicle-like turn/rotation)

But the problem with this is that vehicle-object goes of the navmesh and collides with obstacles, because it takes a wider turn than the navmeshagent.


Illustration showing how the NavmeshAgent turns at the moment VS how I want it to turn:
alt text

Thanks for any kind of help!

Comment
ForceMagic
dikar771
Dailyalex

People who like this

3 Show 0
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

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by UNZoOM · Mar 19, 2015 at 10:53 PM

 This js should work.
 Attach it to the nav mesh agent ( your car ) and it shall serve the purpose.
 To make it smoother play with the nav Agents ( Angular speed value ).
 
 targets is an array of Transforms where you can plugin the waypoints.
 currentTarget can be your 1st way point ( targets[0] , or you can drag in the inspector )
 navigation is your NavMeshAgent.
 
 
 public var currentTarget : Transform;
 public var targets : Transform[];
 public var navigation : NavMeshAgent;
 var incr:int;
  
    
 function Start ()  
 {       
   navigation.destination = targets[i].position;   
 } 
  
  
 
 function Update () 
 {   
     var dist = Vector3.Distance(targets[i].position,transform.position);
     currentTarget = targets[i]; 
     if (dist < 5){     
 
     if (i < targets.Length - 1)
         {   
              i++; //change next target
              incr++;
              navigation.destination = targets[i].position;   
              
          }
     }
 
 }

Comment

People who like this

0 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 Querke · Mar 20, 2015 at 03:02 PM 0
Share

But that only searches for the next waypoint, right?
I am afraid that does not solve my problem, as I know how to search for waypoints. Thanks for trying though :)

avatar image

Answer by 10yaseen1 · Aug 29, 2015 at 02:47 PM

I am not sure if you still need a answer to this but how about using RotateTowards

method? It works rather smoothly for basic humanoid characters as far as I have noticed, might work with a car as well, although I don't think creating a car AI that way would do any good.

Comment

People who like this

0 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 Dailyalex · Dec 16, 2022 at 06:43 AM 0
Share

The problem is that he doesn't know how to override default navmesh agent rotation. It happens automatically under the hood.

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.

Update about the future of Unity Answers

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta later in June. Please note, we are aiming to set Unity Answers to read-only mode on the 31st of May in order to prepare for the final data migration.

For more information, please read our full announcement.

Follow this Question

Answers Answers and Comments

24 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

Related Questions

NavMesh Agent glitches in trees 3 Answers

Editing NavMesh Paths? 0 Answers

Ignoring or overruling a NavMeshAgent destination 0 Answers

Find the closest point of an Invalid or Partial path 0 Answers

Horde of NavMeshAgents - stops to recalculate path. 4 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