コード例 #1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space) && isOnGround && !gameOver)
     {
         PlayerRB.AddForce(Vector3.up * JumpForce, ForceMode.Impulse);
         isOnGround = false;
         playerAnim.SetTrigger("Jump_trig");
         DirtUnderLegs.Stop();
         audioSource.PlayOneShot(jumpSound, 0.9f);
     }
 }
コード例 #2
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.CompareTag("Ground"))
     {
         isOnGround = true;
         DirtUnderLegs.Play();
     }
     else if (collision.gameObject.CompareTag("Obstracle"))
     {
         Debug.Log("GameOver");
         gameOver = true;
         playerAnim.SetBool("Death_b", true);
         playerAnim.SetInteger("DeathType_int", 1);
         ParticleCrush.Play();
         DirtUnderLegs.Stop();
         audioSource.PlayOneShot(deathSound, 0.9f);
     }
 }