// Update is called once per frame void Update() { if (ptc.isOn) { gm.PlaySE(coinSE); gm.AddScore(myScore); Destroy(this.gameObject); } }
// Update is called once per frame void Update() { if (!oc.playerStepOn) { if (sr.isVisible || nonVisibleAct) { // 接触している場合は逆を向く if (checkCollision.isOn || gc.IsAboutToFall()) { rightTleftF = !rightTleftF; } int xVector = -1; if (rightTleftF) { xVector = 1; transform.localScale = new Vector3(-1, 1, 1); } else { transform.localScale = new Vector3(1, 1, 1); } rb.velocity = new Vector2(xVector * speed, -gravity); } else { rb.Sleep(); } } else { if (!isDead) { animator.Play("enemy_down"); rb.velocity = new Vector2(0, -gravity); isDead = true; bcol.enabled = false; gm.PlaySE(deadSE); gm.AddScore(myScore); Destroy(gameObject, 3f); } else { transform.Rotate(new Vector3(0, 0, 5)); } } }