【发布时间】:2016-08-18 19:06:38
【问题描述】:
我想让我的生成对象(敌人预制件)的移动速度每玩家收集 10 点就加快一次。 这是我的移动脚本,附加到我的敌人预制件上(以便它可以在我的游戏中生成并移动):
public static int movespeed = 20;
public Vector3 userDirection = Vector3.right;
public void Update()
{
transform.Translate(userDirection * movespeed * Time.deltaTime);
}
}
这是附在我的播放器上的分数脚本:
public Text ScoreText;
public AudioClip Coinsound;
public Text Highscoretext;
public GameObject enemy;
Movement movement;
private int Score;
public int highScore = 0;
void Start ()
{
Score = 0;
SetScoreText ();
if (PlayerPrefs.HasKey ("Highscore"))
{
highScore = PlayerPrefs.GetInt("Highscore");
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag ("Pick Up")) {
other.gameObject.SetActive (false);
Score = Score + 1;
SetScoreText ();
AudioSource.PlayClipAtPoint (Coinsound, transform.position);
}
}
如前所述,我想让我的生成的敌人预制件在我的玩家每 10 点收集一次时移动得更快。谢谢你:)
【问题讨论】: