我创建了一个游戏鸟跳,我已经在我的角色脚本中创建了得分系统,并且当鸟通过物体时工作正常但是当我尝试在我的角色脚本中使用玩家偏好在下面创建高分系统时我不起作用,请检查我的代码在字符脚本中,如果你能帮助我修复我的字符脚本中的代码,谢谢
private int Points = 0;
public Text ScoreText;
[SerializeField] private AudioSource SoundEffect;
// Use this for initialization
void Start ()
{
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update ()
{
rb.velocity = new Vector2(moveSpeed, rb.velocity.y);
if (Input.GetMouseButtonDown(0))
{
rb.velocity = new Vector2(rb.velocity.x, flapHeight);
}
if (transform.position.y > 18 || transform.position.y < -19)
{
Death();
}
}
public void Death()
{
rb.velocity = Vector3.zero;
transform.position = new Vector2(0, 0);
}
private void OnCollisionEnter2D(Collision2D collision)
{
SceneManager.LoadScene("LosingGame");
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "LinesScore")
scoretextSoundEffect.Play();
{
Points++;
ScoreText.text = Points.ToString();
}
}
如果你能帮助我在我当前的角色脚本中创建高分,我解释了一切,谢谢