Unity移动障碍物设置

来源:互联网 发布:app相册制作软件 编辑:程序博客网 时间:2024/04/30 16:03

这里写图片描述

//做这个移动障碍物的设置时,我们首先需要添加 Nav Mesh Obstacle 这个组件
这里写图片描述

添加完组件后
第一步:
对之前的所有的对障碍物设置的静态 属性全部取消勾选
第二步:
设置Nav Mesh Obstacle 相关属性
Carve选项的属性:
Move Threshold 模型 移动某个距离后进行烘焙
Time To Stationary 指定模型在某个位置停止一段时间 后 在进行烘焙
Carve One Stationary 勾选后,模型移动时不会实时烘焙

博主的Gif里面是加入了上一篇的鼠标点下去控制移动的脚本,和一个控制障碍物左右移动的脚本
下面为移动的脚本:

using UnityEngine;using System.Collections;public class MoveEnemyHyp : MonoBehaviour {    // Use this for initialization    void Start () {     }    int num = 1;    // Update is called once per frame    void Update () {          if (transform.position.x<-7.6)        {            num = 1;              }        if (transform.position.x>7.6)        {            num = -1;           }        transform.Translate(Vector3.right * Time.deltaTime*num);    }}
阅读全文
0 0
原创粉丝点击