Advertisement
GUPPYYYY

Sound and Enemy

Sep 10th, 2024
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayOnSpaceBar : MonoBehaviour
  6. {
  7.     public AudioSource Jump;
  8.     public AudioSource Dead;
  9.     void Start()
  10.     {
  11.        
  12.     }
  13.  
  14.     // Update is called once per frame
  15.     void Update()
  16.     {
  17.         if (Input.GetKeyDown(KeyCode.UpArrow))
  18.         {
  19.             Jump.Play();
  20.         }
  21.        
  22.     }
  23.     public void OnCollisionEnter(Collision other)
  24.     {
  25.         if (other.gameObject.CompareTag("Enemy"))
  26.         {
  27.             Dead.Play();
  28.         }
  29.     }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement