Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View brettmjohnson's full-sized avatar

Brett Johnson brettmjohnson

View GitHub Profile
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;
using UnityEngine;
using System.Collections;
public class TrajectoryCalculation : MonoBehaviour
{
public Rigidbody projectile;
public Transform target;
[Header("CalculateBestThrowSpeed")]
public float timeToTarget = 1f;
[Header("CalculateTrajectory")]
@brettmjohnson
brettmjohnson / Easing.cs
Last active May 6, 2019 16:39 — forked from Fonserbc/Easing.cs
Compact and simple easing functions for Unity
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,
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));
@brettmjohnson
brettmjohnson / JsonPlayerPrefs.cs
Created December 13, 2017 20:11
A replacement for Unity's PlayerPrefs that stores data in a JSON file.
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