Skip to content

Instantly share code, notes, and snippets.

@almyu
almyu / Bezier.cs
Created November 6, 2019 10:52
A bunch of cubic Bézier functions
using System.Collections.Generic;
using UnityEngine;
public static class Bezier
{
public static Vector3 Cubic(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float t) {
float r = 1f - t, r2 = r * r, t2 = t * t;
return (r2 * r) * a + (3f * r2 * t) * b + (3f * r * t2) * c + (t2 * t) * d;
}
@almyu
almyu / CoroutineAction.cs
Created October 10, 2019 02:51
Coroutine action for NPBehave
using NPBehave;
using System.Collections;
public class CoroutineAction : Task
{
System.Func<IEnumerator> starter;
IEnumerator coro;
public CoroutineAction(System.Func<IEnumerator> starter) : base("CoroutineAction") {
this.starter = starter;
@almyu
almyu / Panda BT.sublime-syntax
Created February 9, 2017 13:02
Panda BT syntax highlighting for Sublime Text 3
%YAML 1.2
---
name: Panda BT
file_extensions: [BT.txt, BT.lib.txt]
scope: source.panda
contexts:
main:
- match: \b(tree|sequence|fallback|parallel|race|random|repeat|while|not|mute)\b
scope: keyword.control.panda
@almyu
almyu / ShakeRoutine.cs
Last active February 9, 2017 11:11 — forked from GeorgiyRyaposov/ShakeRoutine.cs
Shake routine
public Vector3 shakePower = new Vector3(0.03f, 0.03f, 0.03f);
public float shakeDuration = 1f;
private IEnumerator ShakeRoutine()
{
for (var t = 0f; t < shakeDuration; t += Time.unscaledDeltaTime)
{
var offset = transform.rotation * Vector3.Scale(Random.onUnitSphere, shakePower);
transform.position += offset;