Unity - OnTriggerEnter 未被调用 [英] Unity - OnTriggerEnter is not being called

查看:48
本文介绍了Unity - OnTriggerEnter 未被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做一个水族馆,里面有各种各样的鱼.

I'd like to make an aquarium where diverse fishes are existing.

我尽量不让鱼穿过立方体,但是即使物体进入触发器,OnTriggerEnter 函数也不起作用.

I tried not to let fishes pass through cubes, but the OnTriggerEnter function doesn't work even if objects enter the trigger.

这些图片代表了鲸鱼和立方体检查员的每一个因素.

These pictures represent each of whale and cube inspector factors.

推荐答案

你只需要为你的鱼添加一个Collider,(与Flock同级)脚本,或在子 GameObject 上).

You only need to add a Collider to your fish, (at the same level of the Flock script, or on a child GameObject).

OnTriggerEnter 只会在 Collider 进入 Trigger Collider

OnTriggerEnter will only fire when a Collider enters a Trigger Collider

参见 MonoBehaviour.OnTriggerEnter(Collider)

这篇关于Unity - OnTriggerEnter 未被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆