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 /
This question was closed Jun 09, 2016 at 03:30 PM by Dave-Carlile for the following reason:

Duplicate Question - http://answers.unity3d.com/questions/439309/dynamically-fixing-navmeshagent-base-offset.html

avatar image
1
Question by salsa · Jun 08, 2016 at 03:35 PM · navmeshagentgroundfloating

NavMeshAgent, my object is floating in the air.. why?? :(

Hi guys,

I'm trying to create a simple AI to my sheep but I have some problems. My sheep is floating in the air, she is not on the ground.

Anybody have any idea how to fix it? Thanks

alt text

Sheep.cs

 using UnityEngine;
 using System.Collections;
 
 public class Sheep
 {
     private GameObject obj;
     private Object prefab;
 
     public Sheep(string name, Vector3 position)
     {
         prefab = Resources.Load("Prefabs/Sheep");
         obj = GameObject.Instantiate(prefab) as GameObject;
         obj.name = name;
         obj.transform.position = position;
         obj.AddComponent<NavMeshAgent>();
         obj.AddComponent<AnimalActions>();
     }
 }



AnimalActions.cs

 using UnityEngine;
 using System.Collections;
 
 public class AnimalActions : MonoBehaviour
 {
     private NavMeshAgent nav;
     private GameObject[] waypoints;
     private int waypointIndex;
 
     void Awake()
     {
         nav = GetComponent<NavMeshAgent>();
         nav.obstacleAvoidanceType = ObstacleAvoidanceType.HighQualityObstacleAvoidance;
     }
 
     void Start()
     {
         waypoints = GameObject.FindGameObjectsWithTag("Farm");
         waypointIndex = Random.Range(0, waypoints.Length);
     }
 
     void Update()
     {
         if (nav.remainingDistance < 0.5f)
         {
             Patrol();
         }
     }
 
     void Patrol()
     {
         nav.destination = waypoints[waypointIndex].transform.position;
         waypointIndex = Random.Range(0, waypoints.Length);
     }
 }


3jsht5m.png (241.8 kB)
Comment
Add comment · Show 4
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 Hellium · Jun 08, 2016 at 02:57 PM 0
Share

Have you tried to rebake the Navmesh ?

avatar image salsa Hellium · Jun 08, 2016 at 03:13 PM 0
Share

Yes, I already try to rebake and I got the same problem, the sheep still floating :/

avatar image aal-ok salsa · Jun 08, 2016 at 03:41 PM 1
Share

and have you tried adjusting the height in the navmesh agent section? and check the collider of the sheep, try giving it a box collider if it is set to mesh

avatar image Munchy2007 · Jun 08, 2016 at 03:39 PM 1
Share

Have you checked the agent height in the bake settings, by default it is 2, and that may be too much for your sheep model.

2 Replies

  • Sort: 
avatar image
5
Best Answer

Answer by salsa · Jun 08, 2016 at 05:39 PM

I change the height and the baseOffset

         nav.height = 0.5f;
         nav.baseOffset = 0;

now looks good :)

Thanks a lot :)

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 Uzair-Hassan · Apr 21, 2020 at 06:22 PM 0
Share

$$anonymous$$aking height less worked for me.

avatar image
5

Answer by holiday100 · Jun 09, 2016 at 03:29 PM

http://answers.unity3d.com/questions/439309/dynamically-fixing-navmeshagent-base-offset.html

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

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

3rd person camera to player 2 Answers

Navmesh pathfinding "scattering"? 1 Answer

lava growing like avalanche 1 Answer

What's a good way to find the ground normal? 1 Answer

how do i to make the ground? 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