我正在使用FSMDeathState来确定当敌人死亡时,它将丢弃一定的buff,这取决于生成的数字,问题是,因为模型有它的支撑,所以buff在地面上实例化,我该怎么改变呢?
这是代码
public void DeathState(){
if(randomBuff == 1){
Rigidbody instanced = Instantiate(dropHpBuff, enemyDropPoint.position, enemyDropPoint.rotation) as Rigidbody;
}else if(randomBuff == 2){
Rigidbody instanced = Instantiate(dropAtkBuff, enemyDropPoint.position, enemyDropPoint.rotation) as Rigidbody;
}else if(randomBuff == 3){
Rigidbody instanced = Instantiate(dropDefBuff, enemyDropPoint.position, enemyDropPoint.rotation) as Rigidbody;
}
GameObject.Destroy(gameObject);
}
答案 0 :(得分:1)
将Empty GameObject
放在您喜欢的位置,将其命名为DropPoint
。您可以在Editor
中执行此操作。然后你可以找到它并保留对它的引用。
private Transform dropPoint;
void Awake()
{
dropPoint = transform.Find("DropPoint");
}
public void DeathState()
{
if(randomBuff == 1)
Instantiate(dropHpBuff, dropPoint.position, dropPoint.rotation);
}