Skip to content

Instantly share code, notes, and snippets.

View benloong's full-sized avatar

benloong benloong

View GitHub Profile
@benloong
benloong / CameraShake.js
Created December 6, 2012 03:36
Simple CameraShake
function CameraShake () {
var hitTime = Time.time;
var originalPosition = cam.transform.localPosition.x;
var shakeCounter = numberOfShakes;
var shakeDistance = startingShakeDistance;
while (shakeCounter > 0) {
// Make timers always start at 0
var timer = (Time.time - hitTime) * shakeSpeed;
cam.transform.localPosition.x = originalPosition + Mathf.Sin(timer) * shakeDistance;
@benloong
benloong / SimpleFSM
Created November 12, 2012 03:19
simple FSM using delegate and coroutine
using UnityEngine;
using System.Collections.Generic;
public class SimpleFSM : MonoBehaviour {
public delegate IEnumerator StateHandler();
public enum State {
Idle,
Attack,