Skip to content

Instantly share code, notes, and snippets.

View kurtdekker's full-sized avatar

Kurt Dekker kurtdekker

View GitHub Profile
// Originally from:
// http://forum.unity3d.com/threads/script-simple-script-that-automatically-adjust-anchor-to-gui-object-size-rect-transform.269690/
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using System.Collections;
public class AnchorExtensions : MonoBehaviour {
@kurtdekker
kurtdekker / TTL.cs
Created June 3, 2021 21:23
TTL - TimeToLive
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TTL : MonoBehaviour
{
public float AgeLimit;
float age;
public System.Action<GameObject> Callback;
using UnityEngine;
public class Ballistic : MonoBehaviour
{
public Vector3 velocity;
void Update ()
{
velocity += Physics.gravity * Time.deltaTime;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MyScript : MonoBehaviour
{
// Always call this to create MyScript objects so we know they are complete.
// Never use AddComponent<MyScript>() outside of this class.
public static MyScript Create(
string resourcesPath,
@kurtdekker
kurtdekker / MoteSystem.cs
Created July 1, 2021 16:44
Mote System (particle system) for Jetpack Kurt
using UnityEngine;
using System.Collections;
public class MoteSystem : MonoBehaviour
{
public Transform target;
System.Func<Vector3> GetPlayerVelocity;
const float limitDistance = 15.0f;
const int BASE_NUM_MOTES = 300;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// @kurtdekker random spawn utilities from my Jetpack Kurt game (And other games)
public static class SpawnUtilities
{
public static bool ProgressiveLiftAndCastDown( ref Vector3 position, out Vector3 normal)
{
Vector3 pos = position;
@kurtdekker
kurtdekker / DelayedActivation.cs
Created July 5, 2021 15:38
Delayed activation of GameObjects in Unity3D
using System.Collections;
using UnityEngine;
// @kurtdekker - delayed-activates things in your scene:
// To use:
// 1. put this script on fresh blank GameObject
// - NOT the same one that you are delayed-activating
// - NOT a child of the one(s) you are delayed-activating!
// - MAY be above other child GameObjects you activate (eg at top of hierarchy)
// 2. set the amount of delay in TimeToDelay field
@kurtdekker
kurtdekker / AttackSequencingDemo.cs
Created July 8, 2021 16:41
Simple attack sequencing, timers, no coroutines, just state machine with timers
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// @kurtdekker
//
// from Unity forums: https://forum.unity.com/threads/logic-to-create-turns-of-attacks.1137946/
//
// goal: a random attack starts in 2-5 seconds, you have 1 second to defend against it
//
@kurtdekker
kurtdekker / HyperSimpleFlightControls.cs
Created July 8, 2021 17:05
Hyper-cheesy-simple non-aerodynamic flight controls.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// @kurtdekker
//
// Hyper-cheesy non-aerodynamic flight controls
//
// To use:
// - slap this on your camera
@kurtdekker
kurtdekker / AttackSequencingDemo2.cs
Last active July 8, 2021 19:50
Same as AttackSequenceDemo but with coroutines
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// @kurtdekker
//
// from Unity forums: https://forum.unity.com/threads/logic-to-create-turns-of-attacks.1137946/
//
// Rewriting AttackSequencingDemo as coroutines, as per GroZZler's suggestion.
//