Skip to content

Instantly share code, notes, and snippets.

View Kellojo's full-sized avatar
💭
Coding all day long 👨‍💻

Kellojo

💭
Coding all day long 👨‍💻
View GitHub Profile
@Kellojo
Kellojo / WeaponSway.cs
Last active March 21, 2024 14:43
Camera tilt/weapon sway based on player movement and look input for the Unity game engine. Can be easily slapped onto any existing character controller or gun system.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using KinematicCharacterController;
using NaughtyAttributes;
public abstract class WeaponSway : MonoBehaviour
{
[SerializeField] Transform TargetTransform;
@Kellojo
Kellojo / RuntimeState.cs
Created April 10, 2023 11:13
A simple struct that can hold a JSON and implementes the INetworkSerializable interface of Unitys Netcode for GameObjects multiplayer package. Can be used to serialize an arbitrary class/struct and transfer it over the network using RPCs, network variables and more. Licensed under the MIT license.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Unity.Netcode;
[System.Serializable]
public struct RuntimeState : INetworkSerializable {
JObject jObject;
string JSON;
@Kellojo
Kellojo / WaveFunctionCollapse.cs
Created December 12, 2022 21:43
A simple wave function collapse algorithm implementation useful for procedural generation
using Kellojo.Utility;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WaveFunctionCollapse<T> where T : IWfcTile<T> {
public WfcCell<T>[,] Cells;
public int Entropy {
@Kellojo
Kellojo / Gradient.cs
Created December 24, 2019 11:55
A simple helper class, which allows you to create radial gradients. This can easily be applied to a texture or to a noise function.
using UnityEngine;
public class Gradient {
/// <summary>
/// Evaluated a radial gradient at the given x,y position
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="sizeX"></param>
@Kellojo
Kellojo / MaterialChanger.cs
Created December 24, 2019 11:52
Allows easy temporary swapping of materials for highlighting i.e. different status of the GameObject (think building systems, obstructed red material, valid green material, placed restore default materials).
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MaterialChanger {
private GameObject gameObject;
private Dictionary<MeshRenderer, Material> defaultMaterials = new Dictionary<MeshRenderer, Material>();
public MaterialChanger(GameObject gameObject) {
this.gameObject = gameObject;