所以,这是我的错误!我设计了一个FPS游戏的统一和im脚本的人工智能敌人(现在它只是随机移动),我也使用NeoFPS,应该是所有的背景信息的方式,为发生什么:我可以看到敌人在现场视图,我可以看到它在游戏视图之前,我按游戏,当我按下“游戏”时,敌人会消失在游戏视图中,但我仍然可以看到它试图在小盒子周围移动,我把它放进去了,还有其他的东西,通过导航网等等,敌人的对撞机还在那里,但是当我进入盒子时,我看不到它,我无法看到它,我对它没有任何伤害,我会包括截图和下面的人工智能代码(白色的胶囊是敌人的AI脚本在一个小盒子里,相机是FPS玩家)。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class AICharacterController : MonoBehaviour
{
private NavMeshAgent m_Agent;
private void Awake()
{
m_Agent = GetComponent<NavMeshAgent>();
}
Vector3 movePosition;
void Update()
{
if (movePosition == Vector3.zero
|| Vector3.Distance(transform.position, m_Agent.destination) < 1)
{
SelectNewDestination();
}
}
void SelectNewDestination()
{
Vector2 pos = Random.insideUnitCircle * 50;
movePosition.x = pos.x;
movePosition.y = pos.y;
NavMeshHit hit = default;
if (NavMesh.SamplePosition(movePosition, out hit, 4, NavMesh.AllAreas))
{
m_Agent.SetDestination(hit.position);
}
}
public void Die()
{
Destroy(gameObject, 0.25f);
}
}(如果您没有看到下面的图像,那么堆栈溢出将其替换为一个链接,并且它无法工作)
发布于 2022-03-08 13:12:28
如果物体在摄像机中是不可见的,但在场景视图中是不可见的,那么这就意味着相机上的“剔除掩蔽”属性被设置为忽略对象所在的层。NeoFPS使用一个产卵系统,所以很有可能,在角色中生成的相机与你正在观看的场景中的相机有不同的筛选掩码设置。要解决这个问题,您必须在字符预置的层次结构(通常称为PlayerCameraSpring)中找到相机,并将您的AI层添加到其筛选掩码中。
https://stackoverflow.com/questions/71386454
复制相似问题