In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you what are the notes related to unity automatic pathfinding, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Let's take a look at it.
First select the terrain where the character is located, click window- > Navigation to open the Navigation window, select "Navigation Static" from the object tab under Navigation to keep the default, and then click "Bake" in the lower right corner. If there is an obstacle, and the obstacle does not belong to the terrain object, you need to bake the obstacle by selecting the obstacle, check "Navigation Static" in the Object tab under Navigation, "Navigation Layer" select "Not Walkable", open the Bake tab, modify the relevant parameters as needed, and then click "Bake" in the lower right corner to bake. For the role of auto-pathfinding, you need to add a "NavMeshAgent" component by clicking "component- > Naviga- > NavMeshAgent" in the menu bar so that the relevant settings for auto-pathfinding are completed; you also need to add code for the role so that he can automatically find the way:
Public PlayerControl:MonoBehavior
{
Private NavMeshAgent agent
Public float speed=6
Void Start ()
{
Agent=GetComponent (); / / get the NavMeshAgent component
}
Void Update ()
{
If (Input.GetMouseButtonDown (0))
{
Ray ray=Camera.main.ScreenPointToRay (Input.mousePosition)
RayCastHit hitInfo
If (Physics.RayCast (ray,out hitInfo))
{
If (! hitInfo.Collider.name.Equals ("Terrain"))
Return
Else
{
Vector3 point=hitInfo.point
Transform.LookAt (new Vector3 (point.x,transform.position.y,point.z))
Agent.speed=speed
Agent.SetDestination (point)
}
}
}
}
}
These are the matters needing attention related to unity automatic pathfinding, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.