Skip to content

Instantly share code, notes, and snippets.

@TheCuttlefish
TheCuttlefish / EnemyAI.cs
Created May 11, 2018 20:35
Enemy patrol AI
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyAI : MonoBehaviour {
public List<Transform> patrolPos = new List<Transform>();
public int posIndex = 0;
int morse[15] = {2,2,1,1,0,1,1,1,1,0,1,2,0,2,1};//zhan in morse
int total;
int current = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(LED_BUILTIN,OUTPUT);
@TheCuttlefish
TheCuttlefish / Spawner.cs
Last active November 14, 2019 13:23
Basic Spawn
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawner : MonoBehaviour {
int spawnCounter = 0;
void Update () {
@TheCuttlefish
TheCuttlefish / Drag And Drop Unity
Last active December 6, 2018 23:14
Drag and drop object (mouse to screen position)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DragAndDrop : MonoBehaviour {
bool active = false;
public Color selectedColour;
public Color idleColour;
@TheCuttlefish
TheCuttlefish / Look at 2D Unity
Created December 6, 2018 23:12
Look at 2D Unity (object and mouse)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LookAt2d : MonoBehaviour {
public GameObject target;
void LookAtObject () {
@TheCuttlefish
TheCuttlefish / Drag and Drop with wall avoidance Unity
Created December 7, 2018 01:19
Drag and Drop with wall avoidance
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DragAndDropBoundaries : MonoBehaviour {
bool active = false;
public Color selectedColour;
public Color idleColour;
public float velocityMulitplier = 2f;
@TheCuttlefish
TheCuttlefish / AlignToNormals2D
Last active January 18, 2019 17:35
Skateboarding Mechanic in 2D (align to ramp normals)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AllightToNormal : MonoBehaviour
{
public float speed;
@TheCuttlefish
TheCuttlefish / PlayerClass.cs
Last active November 6, 2019 13:47
Exposed class in Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerClass : MonoBehaviour
{
// Start is called before the first frame update
[System.Serializable]
public class Player{
@TheCuttlefish
TheCuttlefish / LorenzoAttractor.cs
Last active November 6, 2019 13:44
Lorenz attractor
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LorenzoAttractor : MonoBehaviour
{
float x0, y0, z0, h, a, b, c, depth;
float steps;
@TheCuttlefish
TheCuttlefish / MouseInput.cs
Last active October 30, 2019 02:15
Simple Drag and Drop in Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseInput : MonoBehaviour {
Vector3 offset = new Vector3 (0, 0, 10);
bool follow = false;
void OnMouseDown () {
follow = true;