如何阻止敌人立即杀死玩家?

时间:2019-02-27 22:33:58

标签: c# unity3d

一旦敌人用敌方投射脚本射击了玩家游戏对象,我就试图让玩家的健康脚本降低健康值,如何使这个健康脚本起作用?我将脚本附加到了播放器上,但是播放器中的播放器游戏对象立即死亡。我添加了一种碰撞方法来获得部件弹丸,我是否走在正确的道路上?欢迎任何反馈。

import numpy as np
import pandas as pd

survey_data = pd.read_csv("Food_Dummy.csv")
survey_text = survey_data[['Id','Team','Food_Text']]

# Getting s as pandas series which has split on full stop and new sentence a new line         
s = survey_text["Food_Text"].str.split('.').apply(pd.Series,1).stack()
s.index = s.index.droplevel(-1) # to line up with df's index
s.name = 'Food_Text' # needs a name to join

# There are blank or emplty cell values after above process. Removing them
s.replace('', np.nan, inplace=True)
s.dropna(inplace=True)
x=s.to_frame(name='Food_Text1')
x.head(10)

# Joining should ideally get me proper output. But I am getting original dataframe instead of split one.
survey_text.join(x)
survey_text.head(10)

1 个答案:

答案 0 :(得分:3)

也许我完全误解了这个问题,但是我认为您只需要一个if语句。

public void ApplyDamage(int damageToTake)
{
    Debug.Log(Time.frameCount + ": ApplyDamage was called.");
    currentHealthPlayer -= damageToTake;
    if (currentHealthPlayer <= 0)  //Only apply death effect if health goes to zero
    {
        Debug.Log("Player met an unfortunate end. Time of death: " + Time.frameCount);
        GameObject fx = Instantiate(deathFX, transform.position, Quaternion.identity);
        fx.transform.parent = parent;
    }
}
相关问题