Skip to content

Instantly share code, notes, and snippets.

Ferran Bertomeu Fonserbc

View GitHub Profile
@Fonserbc
Fonserbc / SwipeInput.cs
Last active Jul 8, 2020
A simple swipe detector for touchscreens for Unity3D. Four cardinal directions.
View SwipeInput.cs
using UnityEngine;
/*
* Swipe Input script for Unity by @fonserbc, free to use wherever
*
* Attack to a gameObject, check the static booleans to check if a swipe has been detected this frame
* Eg: if (SwipeInput.swipedRight) ...
*
*
*/
@Fonserbc
Fonserbc / PseudoRandomBoolean.cs
Last active Aug 29, 2015
A boolean, written for use in Unity3D, that evaluates to true pseudo-randomly. Given a *baseProbability* from 0 to 1, it follows a Pseudo-Random Distribution inspired by http://wiki.teamliquid.net/dota2/Pseudo_Random_Distribution Every time it evaluates false, it increases the probability to evaluate true.
View PseudoRandomBoolean.cs
using UnityEngine;
using System;
/**
* Source at https://gist.github.com/Fonserbc/d061905a48555e583edc
* Made by @fonserbc
* Inspired by Valve's PRNG in use in Dota 2
*/
public class PseudoRandomBoolean {
@Fonserbc
Fonserbc / EdgeCollider2DEditor.cs
Last active Apr 19, 2020
A small editor script for Unity3D to edit EdgeCollider2D points on editor
View EdgeCollider2DEditor.cs
using UnityEditor;
using UnityEngine;
using System;
public class EdgeCollider2DEditor : EditorWindow {
[MenuItem("Window/EdgeCollider2D Snap")]
public static void ShowWindow() {
EditorWindow.GetWindow (typeof(EdgeCollider2DEditor));
}
@Fonserbc
Fonserbc / Easing.cs
Last active Jul 14, 2020
Compact and simple easing functions for Unity
View Easing.cs
using UnityEngine;
/*
* Most functions taken from Tween.js - Licensed under the MIT license
* at https://github.com/sole/tween.js
* Quadratic.Bezier by @fonserbc - Licensed under WTFPL license
*/
public delegate float EasingFunction(float k);
public class Easing
You can’t perform that action at this time.