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
0
Question by Turkeybag · Oct 18, 2014 at 12:09 PM · c#navmeshnavmeshagent

Problem getting player to switch navmesh layers

Alright so I have a character and my navmesh is set up into two layers. Default which the player can always walk on and phase (user layer 0) which the player cannot walk on usually. What I want to do is let the player use an ability that allows him to walk on the phase areas of the navmesh. There doesn't seem to be any documentation on how to do this anywhere so I have come here to see if you guys know the answer. The closest I got was:

 Agent.walkableMask.Equals(9);

Agent is a reference to the players NavMeshAgent. From what I understand this should let the player walk on the default layer and user layer 0 (phase) but it has no effect at all and I get no error messages after compiling or in game. What's the correct way to do this?

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
1
Best Answer

Answer by HarshadK · Oct 20, 2014 at 06:53 AM

You need to provide a proper layer number as input.

Read the answer to this question: NavMesh WalkableMask

This will tell you how to select the proper layer to provide as input to the WalkableMask.

You set is as:

 Agent.walkableMask = 9;
 

Setting it to

 Agent.walkableMask.Equals(9);
 

will just make a comparison and not actually set it.

Comment
Add comment · Show 3 · 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 Turkeybag · Oct 20, 2014 at 07:09 AM 0
Share

Ahh yes that is actually where I got my number 9 from :P Problem is I have the number I just don't know where to put it and the line I put in the OP is as close as I got but that has no effect. I pretty much just don't know the right syntax for the function I'm trying to call.

avatar image HarshadK · Oct 20, 2014 at 07:14 AM 0
Share

You set is as:

 Agent.walkable$$anonymous$$ask = 9;

Setting it to

 Agent.walkable$$anonymous$$ask.Equals(9);

will just make a comparison and not actually set it.

avatar image Turkeybag · Oct 20, 2014 at 07:32 AM 0
Share

Thank you so much! I was stuck on that for like 2 days. Glad I can finally move on :D

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

27 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

Related Questions

How to make enemy AI with NavMesh 2 Answers

All my NavMeshAgents are tilted 1 Answer

Move gameobjects in the direction the player is facing 1 Answer

Root motion handled by script. How to still use root motion with disabled navmesh agent? 0 Answers

PhotonNetwork.IsClient, how to set tags for players? 2 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