Skip to content

Instantly share code, notes, and snippets.

Avatar

Brett Johnson brettmjohnson

View GitHub Profile
@brettmjohnson
brettmjohnson / Easing.cs
Last active May 6, 2019 — forked from Fonserbc/Easing.cs
Compact and simple easing functions for Unity
View Easing.cs
using UnityEngine;
// Functions taken from Tween.js - Licensed under the MIT license at https://github.com/sole/tween.js
public static class Easing
{
public enum EasingType
{
Linear,
SineIn,
SineOut,
@brettmjohnson
brettmjohnson / JsonPlayerPrefs.cs
Created Dec 13, 2017
A replacement for Unity's PlayerPrefs that stores data in a JSON file.
View JsonPlayerPrefs.cs
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
/// <summary>
/// A replacement for Unity's PlayerPrefs that stores data in a JSON file.
/// </summary>
[Serializable]
public class JsonPlayerPrefs
View TrajectoryCalculation.cs
using UnityEngine;
using System.Collections;
public class TrajectoryCalculation : MonoBehaviour
{
public Rigidbody projectile;
public Transform target;
[Header("CalculateBestThrowSpeed")]
public float timeToTarget = 1f;
[Header("CalculateTrajectory")]
View FirstPersonLookAt.cs
using UnityEngine;
using System.Collections;
// On first-person controllers, the camera and body are separate objects,
// so to perform a smooth look-at, they must rotate along different axes, in unison.
// NOTE: You will likely have to disable the look/camera controller in order for this to work.
public class FirstPersonLookAt : MonoBehaviour
{
public Transform body;
View PerlinShake.cs
using UnityEngine;
using System.Collections;
// based on http://unitytipsandtricks.blogspot.com/2013/05/camera-shake.html
public class PerlinShake : MonoBehaviour
{
public float duration = 2f;
public float speed = 20f;
public float magnitude = 2f;
public AnimationCurve damper = new AnimationCurve(new Keyframe(0f, 1f), new Keyframe(0.9f, .33f, -2f, -2f), new Keyframe(1f, 0f, -5.65f, -5.65f));