Skip to content

Instantly share code, notes, and snippets.

@Mylab6
Last active August 21, 2022 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mylab6/5a2354d79804587a8d2ff8fff3f0bab7 to your computer and use it in GitHub Desktop.
Save Mylab6/5a2354d79804587a8d2ff8fff3f0bab7 to your computer and use it in GitHub Desktop.
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