Skip to content

Instantly share code, notes, and snippets.

View ashblue's full-sized avatar

Ash Blue ashblue

View GitHub Profile
@ashblue
ashblue / .editorconfig
Created November 17, 2015 00:38
Proposed .editorconfig
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
# @NOTE You can add specific files to the .editorconfig, see https://github.com/angular/angular.js/blob/master/.editorconfig
# Ex. [htmlparser.js]
# My properties
root = true
@ashblue
ashblue / Vector3Ext.cs
Created October 6, 2015 22:42
Vector3 extension class
using UnityEngine;
using System.Collections;
static public class Vector3Ext {
/// <summary>
/// Gives absolute distance instead of returning a negative value.
/// </summary>
/// <returns>The all.</returns>
/// <param name="pos1">Pos1.</param>
/// <param name="pos2">Pos2.</param>
@ashblue
ashblue / save.json
Created October 5, 2015 21:17
Save data example
{
"strings": {
"checkpoint": "TestingNorth",
"RespawnLastScene": "TestingNorth"
},
"ints": {},
"floats": {},
"bools": {
"5611dcfb-00c3-4c00-bd6e-e81a8ac221b1_on": true,
"442792d8-8fe0-4f56-b614-e903bcb43609_on": true,
@ashblue
ashblue / RandomBetweenColors.cs
Created July 16, 2015 01:32
PlayMaker library action. Randomly choose a color between two colors.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions {
[ActionCategory(ActionCategory.Color)]
[Tooltip("Select a random Color between two Colors.")]
public class RandomBetweenColors : FsmStateAction {
public FsmColor color1;
public FsmColor color2;
[RequiredField]
@ashblue
ashblue / Camera2DFollow.cs
Created July 4, 2015 23:17
Camera 2D follow
using UnityEngine;
using System.Collections;
namespace Adnc.Cam {
public class Camera2DFollow : MonoBehaviour {
Vector3 currentVelocity; // Velocity used for damping camera movement
[Tooltip("Draws debug lines representing the camera's move logic (easing only)")]
[SerializeField] bool debug;
@ashblue
ashblue / ParticleThrower.cs
Created June 17, 2015 01:39
Unity particle thrower.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ParticleThrower : MonoBehaviour {
public class ParticleData {
public Rigidbody2D body;
public Vector2 force;
public float torque;
@ashblue
ashblue / HealthManager.cs
Created June 12, 2015 14:02
Unity health management component.
using UnityEngine;
using System.Collections;
namespace Adnc.Combat {
[System.Serializable]
public class StatHealth {
[Tooltip("Set health manually")]
[SerializeField] int health;
int healthMax;
@ashblue
ashblue / normalize-slope.cs
Last active March 16, 2023 20:08
Unity 2D slope normalizer for walking up and downhill with corner snapping. Based upon https://www.youtube.com/watch?v=xMhgxUFKakQ
// @NOTE Must be called from FixedUpdate() to work properly
void NormalizeSlope () {
// Attempt vertical normalization
if (grounded) {
RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up, 1f, whatIsGround);
if (hit.collider != null && Mathf.Abs(hit.normal.x) > 0.1f) {
Rigidbody2D body = GetComponent<Rigidbody2D>();
// Apply the opposite force against the slope force
// You will need to provide your own slopeFriction to stabalize movement
@ashblue
ashblue / camera-fader.cs
Created May 3, 2015 15:36
Unity camera fader script. Supports cross fades, callbacks, and delays. Works with Unity 4.6 and above. You'll need a canvas overlay image of pure black attached to the overlay property in order for this to work.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class CameraFade : MonoBehaviour {
public static CameraFade current;
public delegate void Callback();
[SerializeField] bool debug;
@ashblue
ashblue / PlayerInputMonitor.cs
Created February 25, 2015 14:09
Unity player input monitoring wrapper
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using BehaviorDesigner.Runtime;
public class PlayerInputMonitor : MonoBehaviour {
// Behavior variables
Behavior behavior;
Dictionary<string, SharedBool> behaviorBools;
Dictionary<string, SharedFloat> behaviorFloats;