Skip to content

Instantly share code, notes, and snippets.

View MattRix's full-sized avatar

Matt Rix MattRix

View GitHub Profile
@MattRix
MattRix / slow_down_device.verse
Last active March 31, 2023 18:09
A device that shows some kind of memory leak in UEFN/Verse (creating and removing a bunch of UI widgets every frame)
using { /Verse.org/Simulation }
using { /Verse.org/Verse }
using { /Verse.org/Colors }
using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/UI }
using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }
@MattRix
MattRix / movechecker_device.verse
Created March 29, 2023 19:11
A Verse script that detects when the player starts and stops moving
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
movechecker_device := class(creative_device):
@MattRix
MattRix / FormatRoundedFloatAsString.verse
Last active October 13, 2024 18:54
A function to write a float to a string with a certain numer of decimal places in Verse
FormatRoundedFloatAsString(Input : float, NumDigitsAfterDecimal : int) : string =
if:
Multiplier := Pow(10.0, NumDigitsAfterDecimal * 1.0)
RoundedValue := float[Round[Input * Multiplier] * 1.0] / Multiplier
BeforeDecimal := Floor[RoundedValue]
AfterDecimal := Abs(Round[(RoundedValue - BeforeDecimal * 1.0)*Multiplier])
var AfterDecimalString : string = ToString(AfterDecimal)
#pad the number after the decimal with leading zeroes
for (It := 0..(NumDigitsAfterDecimal - AfterDecimalString.Length - 1)):
@MattRix
MattRix / movement_detector_device.verse
Last active January 9, 2025 00:44
Movement Detector Device in Verse for UEFN
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
movement_detector_device := class(creative_device):
@editable
MinimumMovementDistance : float = 100.0
@MattRix
MattRix / SpriteShapeUtils.cs
Last active February 2, 2022 18:49
Copy and paste sprite physics shapes between TextureImporter, SpriteRenderer and PolygonCollider2D using their context menus.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
#if UNITY_EDITOR
using UnityEditor;
public class SpriteShapeUtils
{
@MattRix
MattRix / AdventOfCode_Day12_Faster.cs
Last active December 12, 2021 23:25
AdventOfCode Day 12 C# faster solution with zero allocations while searching (runs in 25ms on my 8-year-old cpu)
var input = File.ReadAllText(Path.GetDirectoryName(Util.CurrentQueryPath) + @"\..\Inputs\aoc_day12.txt");
var lines = input.Split('\n').Select(line=>line.Trim()).ToArray();
var connections = new Dictionary<int,List<int>>();
var nodes = new List<string>();
foreach(var line in lines)
{
var nodeA = line.Split('-')[0];
var nodeB = line.Split('-')[1];
@MattRix
MattRix / AdventOfCode_Day12.cs
Created December 12, 2021 19:31
Solution for Advent of Code Day 12 that (runs in ~150ms)
var input = File.ReadAllText(Path.GetDirectoryName(Util.CurrentQueryPath) + @"\..\Inputs\aoc_day12.txt");
var lines = input.Split('\n').Select(line=>line.Trim()).ToArray();
var connections = new Dictionary<string,List<string>>();
foreach(var line in lines)
{
var nodeA = line.Split('-')[0];
var nodeB = line.Split('-')[1];
if(!connections.TryGetValue(nodeA, out var listA)) connections[nodeA] = listA = new List<string>();
if(!connections.TryGetValue(nodeB, out var listB)) connections[nodeB] = listB = new List<string>();
@MattRix
MattRix / readme.txt
Created July 8, 2021 20:12
Cake Monsters (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@MattRix
MattRix / FolderNoteEditor.cs
Last active July 13, 2022 20:17
FolderNoteEditor.cs - put notes on any folder in Unity.
#if UNITY_EDITOR //this allows the user to put it in a non-editor folder if they want, since it's not accessing anything else
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(DefaultAsset))]
public class FolderNoteEditor : Editor
{
bool isFolder;
string path;
AssetImporter importer;
@MattRix
MattRix / FancyColorSwap.shader
Created March 17, 2021 02:11
Fancy Color Swap
Shader "Futile/FancyColorSwap"
{
Properties
{
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_ColorR ("Red Replacement Color", Color) = (1,0,0,1)
_ColorG ("Green Replacement Color", Color) = (0,1,0,1)
_ColorB ("Blue Replacement Color", Color) = (0,0,1,1)
}