仅当特定敌人死亡时,使用一个脚本来禁用 2 个不同的脚本。 Unity2D

问题描述 投票:0回答:0

我有这个用于我所有敌人的敌人健康脚本。当敌人死亡时,我需要它来禁用敌人的移动。我有多个不同的敌人移动脚本,因为有些敌人的移动方式不同。当敌人死亡时,我怎样才能阻止敌人的移动?我怎样才能像 GameObject 那样做? This in these pictures, for Enemy Movement, how can I make it so I can just drag and drop the script I want disabled into that box? Second picture here.

我现在在技术上可以正常工作。我做了一个

public string EnemyMovement;
,然后在统一检查器选项卡中输入了我需要禁用的脚本名称。然后在我的敌人健康脚本中,当敌人死亡时,我运行这个命令:
(this.GetComponent(EnemyMovement) as MonoBehaviour).enabled = false;
.

unity3d c#-3.0
© www.soinside.com 2019 - 2024. All rights reserved.