Skip to content

Instantly share code, notes, and snippets.

@jakevsrobots
jakevsrobots / Footsteps.cs
Created November 25, 2013 21:25
Footsteps script (counter version). Attach this to the first person controller and add an AudioSource component.
using UnityEngine;
using System.Collections;
public class Footsteps : MonoBehaviour {
public AudioClip[] footsteps;
public CharacterController controller;
float stepTimer = 0;
int stepCounter = 0;
@jakevsrobots
jakevsrobots / CameraShake.cs
Created November 25, 2013 21:23
A sample Unity camera shake script that works with the prefab first-person controller. Add this to the "first person controller" object.
using UnityEngine;
using System.Collections;
public class CameraShake : MonoBehaviour {
public float shakeStrength = 5;
public float shake = 1;
Vector3 originalPosition;
void Start()
@jakevsrobots
jakevsrobots / SharecartOneThousand.cs
Last active September 3, 2019 19:05
A helper script to read/write SHARECART1000 save files. See http://sharecart1000.com/ for more info!
/*************************************************
SHARECART1000 helper script:
This script reads/writes data according to the
shared savegame file specified here:
http://sharecart1000.com/
Put this script on some game object in your
scene. You can use a sample text file in the
sharecart format and assign it to the property
@jakevsrobots
jakevsrobots / SphereTrigger.cs
Created November 11, 2013 21:49
Example script that destroys a player when they enter a trigger, and also turns the trigger's object red.
using UnityEngine;
using System.Collections;
public class SphereTrigger : MonoBehaviour {
void OnTriggerEnter(Collider other) {
renderer.material.color = Color.red;
if(other.gameObject.tag == "Player") {
Destroy(other.gameObject);
}
@jakevsrobots
jakevsrobots / TriggerSound.cs
Created November 11, 2013 21:47
Example script to fade in an audio player when entering a trigger. There should be an AudioSource component also attached to this game object, and it should probably be in "loop" mode.
using UnityEngine;
using System.Collections;
public class TriggerSound : MonoBehaviour {
float targetVolume = 0;
void Start() {
audio.Play();
}
@jakevsrobots
jakevsrobots / SizeBox.cs
Created November 11, 2013 20:07
Sample script to resize a cube based on Sharecart 1000 value.
using UnityEngine;
using System.Collections;
public class SizeBox : MonoBehaviour {
float targetX;
// Use this for initialization
void Start () {
targetX = ShareCartOneThousand.MapX;
}
@jakevsrobots
jakevsrobots / ShareCartOneThousand.cs
Created November 11, 2013 20:06
Demo script to load data in from a sample Sharecart 1000 file.
using UnityEngine;
using System.Collections;
public class ShareCartOneThousand : MonoBehaviour {
public TextAsset testingFile;
public static int MapX;
public int MapY;
public int Misc0;
public int Misc1;
@jakevsrobots
jakevsrobots / PickUpObject.cs
Last active July 10, 2021 00:13
Script for picking up objects in Unity.
using UnityEngine;
using System.Collections;
public class PickUpObject : MonoBehaviour {
public Transform player;
public float throwForce = 10;
bool hasPlayer = false;
bool beingCarried = false;
void OnTriggerEnter(Collider other)
@jakevsrobots
jakevsrobots / RotatingPatternEmitter.ino
Created July 13, 2013 22:51
A sketch for the Ardcore module.
// ============================================================
//
// Program: ArdCore Rotating Pattern Emitter (multi-length)
//
// Description: Given a clock, output two patterns based on divisions
// of the clock. These patterns are preset but can be
// rotated with knobs.
//
// I/O Usage:
// Knob 1: Pattern 1 select
// ============================================================
//
// Program: ArdCore Rotating Pattern Emitter
//
// Description: Given a clock, output two patterns based on divisions
// of the clock. These patterns are preset but can be
// rotated with knobs.
//
// I/O Usage:
// Knob 1: Pattern 1 select