Skip to content

Instantly share code, notes, and snippets.

View andrew-raphael-lukasik's full-sized avatar
🏴‍☠️

Andrew Raphael Lukasik andrew-raphael-lukasik

🏴‍☠️
View GitHub Profile
@andrew-raphael-lukasik
andrew-raphael-lukasik / MinimumFsmBasedAiController.cs
Last active April 13, 2024 14:54
Goal: to write the most simple yet most useful FSM that convinces Unity devs who still use bool fields to keep track of ai states to change their misguided ways for the better.
using UnityEngine;
public class MinimumFsmBasedAiController : MonoBehaviour
{
public enum EState : byte
{
START = 0,
PATROL,
INVESTIGATE,
ATTACK,
@andrew-raphael-lukasik
andrew-raphael-lukasik / .VoxelCollisionGenerator.cs.md
Last active April 22, 2024 10:36
Tool to voxelize a Mesh Collider into multiple Box Colliders

GIF 21 01 2024 01-20-34

note: This is toy implementation, output is sub-optimal.

@andrew-raphael-lukasik
andrew-raphael-lukasik / .PhysicsJointDebugSystem.cs.md
Last active January 14, 2024 17:56
System to inspect `PhysicsJoint` and `PhysicsConstrainedBodyPair` data

System to visually inspect PhysicsJoint and PhysicsConstrainedBodyPair data

Written for entities 1.0.16, physics 1.0.16

Screenshot 2023-11-29 165444

// src* https://gist.github.com/andrew-raphael-lukasik/b00a59509cbe8fa2b15b1949fa4f4ad2
using System.Collections.Generic;
public struct MinHeap <T>
where T : System.IComparable<T>
{
List<T> _stack;
public int Length => _stack.Count;
public int Count => _stack.Count;
@andrew-raphael-lukasik
andrew-raphael-lukasik / .billboard-shadow.shadergraph.md
Last active December 5, 2023 11:33
Shader Graph files to create billboard trees with billboard shadows. Exported from Unity 2023.2 and Shader Graph 16.0.4

Shader Graph files to create billboard trees with billboard shadows. Exported from Unity 2023.2 and Shader Graph 16.0.4

GIF 17 11 2023 14-38-35

Note: Shaders written for default Quad meshes in mind.

To make sure shadows are being drawn always behind tree billboards change shadow material’s Sorting Priority to a negative value:

Screenshot 2023-11-17 145239

@andrew-raphael-lukasik
andrew-raphael-lukasik / .TV_Noise.shadergraph.md
Last active November 12, 2023 19:52
Shader graph to render pixelated, old TV-like noise

GIF 10 11 2023 13-40-46

@andrew-raphael-lukasik
andrew-raphael-lukasik / .ColorPickerElement.cs.md
Last active November 8, 2023 15:36
basic color picker for UI Toolkit

Color picker / UI Toolkit

GIF 08 11 2023 01-37-22

Answers a question: "How to make enemies surround player"

  • AttackSpotProvider.cs provides attack positions to attackers.
  • Attacker.cs simulates an attacker

GIF 05 10 2023 20-52-29

@andrew-raphael-lukasik
andrew-raphael-lukasik / .NativeQuadTree.cs.md
Last active October 14, 2023 22:15
Quadtree built on `Unity.Collections`, `Unity.Jobs` and `Unity.Burst`

Quadtree built on Unity.Collections, Unity.Jobs and Unity.Burst

Screenshot 2023-10-12 170345

@andrew-raphael-lukasik
andrew-raphael-lukasik / .QuadTree.cs.md
Last active October 12, 2023 15:13
experiment: create a Quadtree that allocates all the nodes in 100% predictable array order

note: this was a programming experiment

Initial goal

To create a Quadtree where

  • all nodes are kept in linear order one index next to the other
  • nodes and points are stored in separate, dedicated array/list buffers

Lessons learned: