Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by jpthek9 · Jan 30, 2015 at 09:57 PM · multiplayernavigationsynchronizationrts

Using Unity Navigation in a fixed timestep

I want the navigation to have some semblance of determinism so it can be used for multiplayer. I'm using CalculatePath instead of SetDestination so there can be a synchronized start. The problem is running navigation in a fixed timestep so it can interact with the rest of my multiplayer game and be more deterministic. Is there a way I can run Navmesh Agent with FixedUpdate instead of Update?

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

1 Reply

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

Answer by DanSuperGP · Jan 31, 2015 at 12:11 AM

Your best bet is to set NavMeshAgent.UpdatePosition and NavMeshAgent.UpdateRotation to false. Then the NavMeshAgent will do the pathfinding but no longer control the motion of your characters.

You can then control the position and rotation of your characters yourself using animation or physics code and just use the NavMeshAgent for the pathfinding portion. You can access the NavmeshAgent.path property to get the NavMeshPath.

You will need to write some code to keep track of the path and control your movement, but I suspect this is what you really want anyway.

There is a functional difference to be aware of between Unity 4 and Unity 5.

In Unity 4, a NavMeshAgent with UpdatePosition = false will still internally keep track of it's position.

In Unity 5, a NavMeshAgent with UpdatePosition = false will not internally keep track of it's position. When you move the agent you need to manually update the position by setting NavMeshAgent.nextPosition

If you look in the documentation for Unity 4 and Unity 5 you will notice that there are changes to the documentation of NavMeshAgent.nextPosition

Comment
Add comment · Show 4 · 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 DanSuperGP · Jan 31, 2015 at 12:18 AM 1
Share

Oh...

Just to mention... I'm pretty sure if you have UpdatePosition and UpdateRotation set to false, you can use DesiredVelocity to tell you where it wants to go.... and it will update with the path as long as you keep it's internal positional tracking updated (which only needs to be done manually on Unity 5)

avatar image jpthek9 · Jan 31, 2015 at 12:44 AM 0
Share

Oh, thanks a lot! Is it possible to use this method and also take advantage of the crowd control as well?

avatar image DanSuperGP · Jan 31, 2015 at 12:57 AM 0
Share

Yes, essentially it is still doing everything except actually changing the position and rotation of the Agent. So if it's trying to do crowd avoidance and the like... it will be reflected in DesiredVelocity.

avatar image jpthek9 · Jan 31, 2015 at 01:06 AM 0
Share

That makes a lot of sense. Thanks!

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

20 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

Related Questions

RTS Multiplayer, Lock-step simulations and fixed game timings 1 Answer

[PhotonNetwork] How can I stock a allocateViewID from a player and reuse it later with another player ? 2 Answers

[UNET] Unable to run [Command]s on remote client 1 Answer

[PUN] Sync gameobjects layer over network 0 Answers

Multiplayer Custom Object Spawning (ClientScene.RegisterSpawnHandler) Out Of Sync Error 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