[Unity] [NavMesh] use OffMeshLink components how to play Animation climb a ladder to jump parkour animation

Disclaimer: This blog seriousness nonsense, the article content can not reference. This article is a blogger original article, shall not be reproduced without the bloggers allowed. Pictures are resources for learning to share use for reference purposes only, not for commercial behavior of the blog used. Communicators conceited. If this blog article written infringe your rights, please reach out to leave a message, we will promptly remove content. https://blog.csdn.net/BuladeMian/article/details/90374913

 

References 1,2,3 OffMeshLink there is provided a detailed configuration of components of NavMeshAgent.

So the question is, when the role of NavMeshAgent time on OffMeshLink components, how to judge players jump, climb, climb a ladder of animation.

 

 

FIG logic


Analyzing method:

Scheme 1. Comparative StartTransform EndTransform OffMeshLink assembly and the object (the position of small yellow square and the small blue square object)

 if (agent.currentOffMeshLinkData.offMeshLink != null)
        {
            Debug.Log("     agent.isOnOffMeshLink::" + agent.isOnOffMeshLink + "/" + agent.currentOffMeshLinkData.offMeshLink.area);

            //vector3 = 小黄方块 的坐标 - 小蓝方块 的坐标
            Vector3 vector3 = agent.currentOffMeshLinkData.offMeshLink.endTransform.position - 
                agent.currentOffMeshLinkData.offMeshLink.startTransform.position;

if (vector3.x > 0
                && vector3.y == 0
                && vector3.z == 0)//播放翻越围栏 动画
            {

            }

if (vector3.x > 0
                && vector3.y < 0
                && vector3.z == 0)//播放向下爬 动画
            {

            }

if (vector3.x != 0
                && vector3.y > 0
                && vector3.z == 0)//播放爬梯子 动画
            {

            }


}

 

方案2.NavMeshAgent.currentOffMeshLinkData.offMeshLink.area

if (agent.currentOffMeshLinkData.offMeshLink != null)
{

            //当Navigation的Area为ClimbLadder序号为4
            if (agent.currentOffMeshLinkData.offMeshLink.area == 4)
            {
                //播放 爬梯子的 动画
            animator.SetInteger("actionInt",4);
                agent.speed = (float)(agent_speed*0.02);//需要改变NavMeshAgent的速度
            }

            //当Navigation的Area为JumpOverWall序号为5
            if (agent.currentOffMeshLinkData.offMeshLink.area == 5)
            {
                //播放 攀越栏杆的 动画
            animator.SetInteger("actionInt",5);
                agent.speed = (float)(agent_speed * 0.2);//需要改变NavMeshAgent的速度
            }


            //当Navigation的Area为ClimbDown序号为6
            if (agent.currentOffMeshLinkData.offMeshLink.area == 6)
            {
                //播放 向下爬的 动画
            animator.SetInteger("actionInt",6);
            }
}
else
{
            animator.SetInteger("actionInt",0);
            agent.speed = agent_speed;//需要 初始化 NavMeshAgent的速度
}

     


Emerging issues:

Q1: Click reaction without corresponding OffMeshLink

A1: AreaMask NavMeshAgent components of the player character is not checked climbing walls, over the railing of the Area. They can check the corresponding Area.

 

Q2: Click on the appropriate OffMeshLink no displacement

A2: AutoUpdatePosition OffMeshLink containing components is not checked, it is necessary to manually operated position.

 

Description, content-related parameters are in Resources. Some deviations from the code, the actual results shall prevail.


References:

1. Unity comes wayfinding Navmesh Start Tutorial (a)

2. Unity comes wayfinding Navmesh introductory tutorial (b)

3. Unity comes wayfinding Navmesh Getting Started tutorial (Three)

4.NavMeshAgent.currentOffMeshLinkData

5. Nvanashagent . Isonofarfanashlaidak

6. OffMeshLinkData

7.OffMeshLink.area

8.

 

 

 

 

 

Guess you like

Origin blog.csdn.net/BuladeMian/article/details/90374913