Last active
August 21, 2022 04:34
-
-
Save Mylab6/5a2354d79804587a8d2ff8fff3f0bab7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
public class TriggerMeshRenderOff : MonoBehaviour | |
{ | |
public AudioSource audioSource; | |
public AudioClip audioClip; | |
private void Awake() | |
{ | |
if (audioSource == null) | |
{ | |
audioSource = new AudioSource(); | |
} | |
} | |
private void OnTriggerEnter(Collider other) | |
{ | |
OffMeshRenderer(); | |
PlayBasicSound(); | |
} | |
// For now, just make stuff public , if your unsure of what your doing. | |
// Forgive me Jeff. | |
// However, imagine two friends sharing details about a vacation. | |
// Some things, like you getting a parking ticket should be private | |
private void GotParkingTicket() | |
{ | |
Debug.Log("You got a parking ticket, no one else cares"); | |
} | |
// But you'd want to talk about the movie you saw | |
public void SawSpaceJam() | |
{ | |
Debug.Log("Saw space jam it was fun"); | |
} | |
// Returning varibles to other classes, maybe you want to send a postcard to a friend | |
// | |
public string SendPostCardToFriend(string friendName) | |
{ | |
return "Hi " + friendName + " we are having fun."; | |
} | |
public void PlayBasicSound() | |
{ | |
audioSource.PlayOneShot(audioClip); | |
} | |
public void OffMeshRenderer() | |
{ | |
GetComponent<MeshRenderer>().enabled = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment