Skip to content

Instantly share code, notes, and snippets.

@Jake-346
Jake-346 / SoundRandomiser.cs
Created August 23, 2022 15:40
A simple Unity script to add variation to sound effects such as doors opening. It will randomly select one of the chosen audio clips and vary the pitch according to the user-set parameter each time.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SoundRandomiser : MonoBehaviour
{
[SerializeField] private AudioClip[] audioClips = new AudioClip[1];
[SerializeField] private float pitchVariation;
private AudioSource audioSource;
@Jake-346
Jake-346 / MAPField
Created August 20, 2022 17:32
For app with working title Medical Assessment Portal. Used for medic training exercises to quickly fill in information while treating a patient and compile it into a simple text format. Several types inherit from MAPField.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MAPField : MonoBehaviour {
[SerializeField] protected Text textBox;
[SerializeField] protected string prefix;
[SerializeField] protected string suffix = "";
@Jake-346
Jake-346 / LadderWall.cs
Created August 20, 2022 17:12
Handles the placement of ladders onto certain walls in VR mission planning app. Includes MLAPI functions for LAN multiplayer.
using UnityEngine;
using UnityEngine.Networking;
public class LadderWall : NetworkBehaviour
{
[SerializeField] private Transform ladder;
[SyncVar(hook = "OnLadderStateChange")]
public bool ladderActive = false;
@Jake-346
Jake-346 / CameraClipping.cs
Created August 20, 2022 17:09
For Major Incident Response (MIRA) app, where the user can zoom into and see details of individual buildings in a large site. This script hides building models the camera clips into, while ensuring buildings which are children of larger buildings or areas, which could include the one the user is looking at, are not hidden.s
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraClipping : MonoBehaviour
{
private GameObject currentBuilding;
private GameObject[] objectsNotToHide;
MeshRenderer[][] meshesNotToHide;
@Jake-346
Jake-346 / MultiplayerController.cs
Created August 20, 2022 17:03
Basic function for launching LAN multiplayer sessions for VR mission planning app. Uses the Unity MLAPI framework.
using UnityEngine;
using UnityEngine.Networking;
public class MultiplayerController : MonoBehaviour
{
[SerializeField] private bool alwaysHost = false;
private NetworkManager netManager;
private int playerCount = -1;
private void Start()
@Jake-346
Jake-346 / GRGController.cs
Created August 20, 2022 17:00
Script control the function of the GRG/map in a VR mission planning app. Can be toggled to appear on the users arm, and displays their live location and orientation.
using UnityEngine;
public class GRGController : MonoBehaviour
{
[SerializeField] Vector3 centrePoint;
[SerializeField] private float scale;
[SerializeField] private Transform player;
private GameObject map;
private Transform dot;
@Jake-346
Jake-346 / gist:615ec42b743ea5ec8b0ca103c23e9234
Last active October 25, 2019 15:11
Gravipult Acceleration and Aiming Functions
// Runs through each planet in the level to calculate its acceleration to each
void Acceleration()
{
if (gameMode != 2)
{
for (int i = 0; i < noOfPlanetoids; i++)
{
if (!hitPortal && (!hitPlanetoid || planetoidHit == i)) AccelerateTo(new Vector2(planetoids[i].transform.position.x, planetoids[i].transform.position.y), planetoidFieldStrength[i], planetoidRadius[i]);
}
@Jake-346
Jake-346 / gist:53451f16f96bab36bae6ac2ab6aee662
Created October 25, 2019 13:36
Unity Tool - Sprite Atlas Checker
// Unity tool that checks all sprites and images on all children of a parent object and determines and lists all the sprite atlases
// used and many times. Gives a warning if any atlas is used for fewer sprites than a user-set threshold.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.U2D;
using UnityEngine.UI;
using UnityEditor;
@Jake-346
Jake-346 / gist:9bc299b45a0478a3ccec81f90bb57405
Created October 25, 2019 12:45
WWII Simulator Infantry Class
// Class for the Infantry unit, inheriting from the Soldier class
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Infantry : Soldier {
void Start()
{
@Jake-346
Jake-346 / gist:306668abb11639677f14e9ecbb59a320
Created October 25, 2019 12:18
WWII Simulator Unit Class Declarations
// Start of the Unit class, from which soldiers (infantry, sniper, grenadier), tanks (heavy tank, medium tank) and heavy weapons
// (machine gun, at gun) inherit
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Unit : MonoBehaviour {
public int type;