如何检测其他对象上的命中检测已禁用 [英] How do I detect that the hit detection is disabled on other object
本文介绍了如何检测其他对象上的命中检测已禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经挣扎了这么久了,我已经尝试了很多东西。
在警察剧本中!如果他的健康状况达到0,那么他的盒子对撞机就会被禁用
在敌人的剧本中,如果他击中警察对手ATTACK(工作精细)我就知道了。
否则如果警察对撞机被禁用则行走! (不工作)
任何帮助都会帮助我通过上锁的门。
我尝试过:
I have struggled with this for so long now, I have tried so many things.
in the police script! if his health reaches 0, then his box collider is disabled
in the enemy script, I have that if he hits police collider ATTACK ( WORKING FINE)
else if police collider is disabled then WALK! (NOT WORKING)
Any help would really help me pass the locked door.
What I have tried:
<pre lang="c#">
void OnTriggerEnter2D (Collider2D other)
{
if(other.gameObject.CompareTag("policeFootCol"))
{
moveScript.WalkSpeed = 0f;
SkelAnim.state.SetAnimation(0,attack,true);
}
else if (PoliceScript.FootStopperPolice.activeSelf == false)
{
moveScript.WalkSpeed = 1f;
SkelAnim.state.SetAnimation(0,walk,true);
}
推荐答案
根据您的描述:
对于警察活动的if测试应该在对撞机(警察)的if中......(主动与不活跃的警察对撞机)。
如果处理多个碰撞器以保持一个人的头部,你应该有一个开关。
Based on your description:
The "if" test on "PoliceScript" for active should be in the "if" for the "collider" (police) ... (active vs not active "police" collider).
You should have a "switch" if dealing with multiple colliders to keep one's head straight.
在我放的更新方法中解决。
Solved in the update method I put.
if (state == State.ATTACKING && currentTarget && !currentTarget.activeSelf)
{
walking();
}
这篇关于如何检测其他对象上的命中检测已禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文