Skip to content

Instantly share code, notes, and snippets.

View r2d2m's full-sized avatar

r2d2m

View GitHub Profile
@r2d2m
r2d2m / GravityFPSWalkerModified.cs
Created September 19, 2023 14:29 — forked from Kimeiga/GravityFPSWalkerModified.cs
A better version of Gravity FPS Walker for Unity FP games
using UnityEngine;
/* -------------------------------------------------------------------------------
GravityFPSWalkerModified
This component is added to a GameObject with a RigidBody. It allows the player
to move the RigidBody using the vertical and horizontal inputs, and to jump
using the jump button.
The RigidBody is pushed towards its own custom Gravity vector. The body will
@r2d2m
r2d2m / PlayerLoop.cs
Created April 28, 2023 09:50 — forked from LotteMakesStuff/PlayerLoop.cs
Player Loop Visualizer: Built to explore the new PlayerLoopSystem api in Unity 2018.1b2. This tool shows you all the PlayerLoop systems that unity uses to update a frame, and demos how to add your own and even remove systems from the player loop. For more info see the patreon post https://www.patreon.com/posts/unity-2018-1-16336053
// Put this in an editor folder
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Experimental.LowLevel;
using UnityEngine.Profiling;
@r2d2m
r2d2m / NetworkingTools.cs
Created April 28, 2023 09:49 — forked from LotteMakesStuff/NetworkingTools.cs
Since Unity 2018.3 we've had this cool new tool called [SettingsProvider] that we can use to add custom settings menu into Unitys settings screens. This short example shows how i use [SettingsProvider] and some [MenuItems] to help build and run test clients when im developing a multiplayer game. My usecase is that i want a quick way to build and…
using System.Collections.Generic;
using System.Diagnostics;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;
using Debug = UnityEngine.Debug;
public static class NetworkingTools
{
By “world generation” we mean natural landscapes - not because we’re not interested in urban landscapes, but because we have a larger margin of error with the former. It’s not the “cities aren’t actually that interesting” effect - isn’t raw nature just as repeating? It’s the problem of simulating, in a way that isn’t trivial, all the possible ways humanity can both inhabit an environment, and shape it to its structures - determinism in both directions.
A high-level view. We’ll use Dwarf Fortress, Minecraft, Sir, You are Being Hunted, and The Witcher 3 (that is, the REDengine 3) as our prototypical examples. Be familiar with the first two. (TW3 isn’t meaningfully procedural - but substantially procedural enough to work on, and high-detail.)
We also refer to Morrowind as a source world we intend to model.
We begin with concrete analyses, work out the design space, and then try to locate ourselves within it - although you can read it backwards if you want to see choices before justifications.
A concrete exam
@r2d2m
r2d2m / InspectorButtonsTest.cs
Created May 20, 2022 10:23 — forked from LotteMakesStuff/InspectorButtonsTest.cs
Code running pack! two property drawing scripts that make it super easy to trigger code via buttons in the inspector, and get feedback! [TestButton] draws you little buttons that call a method on your MonoBehaviour, and [ProgressBar] give you a great way to show feedback from long running methods. These are *super* helpful for things like proced…
using UnityEngine;
using System.Collections;
public class InspectorButtonsTest : MonoBehaviour
{
[TestButton("Generate world", "DoProcGen", isActiveInEditor = false)]
[TestButton("Clear world", "ClearWorld", 2, isActiveInEditor = false)]
[ProgressBar(hideWhenZero = true, label = "procGenFeedback")]
public float procgenProgress = -1;
@r2d2m
r2d2m / HighlightAttribute.cs
Created May 20, 2022 10:22 — forked from LotteMakesStuff/HighlightAttribute.cs
Having trouble finding the right property on a component cos theres just so many identical looking fields? Add some color to you inspectors! mark important property with a bright color so it always stands out, or supply a validation function so highlights show on values that would effect the current ingame logic!
// NOTE DONT put in an editor folder
using UnityEngine;
public class HighlightAttribute : PropertyAttribute
{
public HighlightColor Color;
public string ValidateMethod;
public object Value;
@r2d2m
r2d2m / Flicker.cs
Created May 20, 2022 10:20 — forked from LotteMakesStuff/Flicker.cs
Quake/Halflife style light flicker
using UnityEngine;
public class Flicker : MonoBehaviour
{
public string LightStyle = "mmamammmmammamamaaamammma";
private Light light;
public float loopTime = 2f;
[SerializeField]
private int currentIndex = 0;
@r2d2m
r2d2m / TrafficLightAttribute.cs
Created May 20, 2022 10:18 — forked from LotteMakesStuff/TrafficLightAttribute.cs
TrafficLight control/layout/property drawer: Adds a new editor control that draws lil Traffic Lights in the inspector. its really useful for visualizing state. For example, checkboxes can be hard to read at a glace, but a Red or Green status light is easy! Recommend you use the attached package, as it has all the icon image files.
// Non Editor code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class TrafficLightAttribute : PropertyAttribute
{
public bool DrawLabel = true;
public string CustomLabel;
public bool AlsoDrawDefault;
@r2d2m
r2d2m / Archetype.cs
Created February 25, 2022 13:25 — forked from herohiralal/Archetype.cs
HiraBots sample 1
using UnityEngine;
using UnityEngine.AI;
namespace AIEngineTest
{
public class Archetype : MonoBehaviour,
IHiraBotArchetype<NavMeshAgent>,
IHiraBotArchetype<Animator>,
IHiraBotArchetype<ConsolidatedSensor>,
IHiraBotArchetype<HiraLGOAPRealtimeBot>,