人员疏散遇到的问题

1.多人物疏散时,人物出现不按指定轨迹奔跑

原因:人物相互碰撞,导致人物不安指定轨迹逃跑

解决:用随机数随机改变人物的速度,人物分时间断通过触发点。

agent.speed = 1.0f * UnityEngine.Random.Range(1, 6);

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class run : MonoBehaviour {
    private NavMeshAgent agent;
    public GameObject target;
    private Animator animator;
    public GameObject plane;

	// Use this for initialization
	void Start () {
        agent = GetComponent();
        agent.speed = 1.0f * UnityEngine.Random.Range(1, 6);
        //agent.SetDestination(target.transform.position);
        animator = GetComponent();
        //animator.Play("run");
        plane.GetComponent().Listener += new fasong.ListenerHandler(noteMe);

    }
	
	// Update is called once per frame
	void Update () {
        
    }
    private void noteMe(Object sender)
    {
        agent.SetDestination(target.transform.position);
        animator.Play("run");
    }
}

2.在给路面烘培时,总是报错

原因:把地形Terrain一起烘培了,地形烘培会出错

解决:新建一个路面Plane,把Plane设置为静态Static,把Terrain去掉Static。

3.人物到不了指定位置、没有动画

原因:代码是否挂在对应人物和触发器上,代码书是否错误

解决:检查代码,Animator经常拼写成Animater。

 

4.人物不能上楼梯

原因:楼梯用倾斜的Cube作为碰撞体,但是Cube没有摩擦力

解决:给楼梯碰撞体Cube的属性Material添加摩擦力stair。

你可能感兴趣的:(Unity3d)