Skip to content

Instantly share code, notes, and snippets.

View valentinwinkelmann's full-sized avatar
🏠
Working from home

VWGAMEDEV valentinwinkelmann

🏠
Working from home
View GitHub Profile
@valentinwinkelmann
valentinwinkelmann / EBSBag.cs
Last active May 4, 2024 12:41
An Easy Build System save system to save building data directly in GameCreator 2 SaveGame System.
using System;
using System.Collections;
using System.Collections.Generic;
using GameCreator.Runtime.Common;
using GameCreator.Runtime.Inventory;
using EasyBuildSystem.Features.Runtime.Buildings.Part;
using UnityEngine;
/// <summary>
/// This will save GameCreator's bag inventory inside the EBS Properties of a BuildingPart.
@valentinwinkelmann
valentinwinkelmann / ItemTestCreator.cs
Created March 21, 2024 10:26
Generates a Unity GameCreator 2 Item Asset and fills its fields by Reflection, also adds custom instructions onEquip and onUnequip
using GameCreator.Runtime.Inventory;
using UnityEditor;
using System.Reflection;
using UnityEngine;
using GameCreator.Runtime.Common;
using vwgamedev.GameCreator.Runtime.UMA;
using UMA.CharacterSystem;
public class ItemTestCreator : MonoBehaviour
{
@valentinwinkelmann
valentinwinkelmann / HumanoidGrabber.cs
Created November 16, 2023 23:26
A Unity helper script allows you to grab objects like hats or other props attached to your character. The script must be placed on the same object as the animator. Then an event must be assigned to animations in the animation import dialog. This must be named "Grab" and as a string parameter it contains the bone to be grabbed (e.g. the hand) and…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;
public class HumanoidGrabber : MonoBehaviour
{
public int resetFrames = 5;
private List<Transform> grabbedObjects = new List<Transform>();
private Animator animator;
@valentinwinkelmann
valentinwinkelmann / MixamoExportHelper.py
Created November 16, 2023 15:48
A small help script for Cinema4D, which should facilitate the clean export of Mixamo Controll Rig modified characters. It selects only what is necessary to export it in an FBX and then use it in Unity ( or other programs ).
from typing import Optional
import c4d
doc: c4d.documents.BaseDocument
op: Optional[c4d.BaseObject]
def find_object_by_name(obj: c4d.BaseObject, name: str) -> Optional[c4d.BaseObject]:
while obj:
if obj.GetName() == name:
return obj
@valentinwinkelmann
valentinwinkelmann / MySingletonSO.cs
Last active August 31, 2023 06:34 — forked from Oxeren/MySingletonSO.cs
Auto singleton Unity ScriptableObject. Derive your class from this class (and use your class as the generic type), create an instance in the Resources folder (name of the instance must be the same as the name of your class). Then you will be able to access the singleton via static Instance property without having to add boilerplate code. Now wor…
// Example Scriptable Object. Instance must be placed in Resources folder and have the same name as the class, type of generic parameter must be your class.
using UnityEngine;
namespace Custom.Namespace
{
[CreateAssetMenu(fileName = "exampleObject", menuName = "Singelton/Example"), SingletonScriptableObjectInspector]
public class exampleObject : SingletonScriptableObject<exampleObject>
{
// Here goes your data. This class can be called by the static Instance property, which will automatically locate the instance in the Resources folder.
public string myString = "Hello World!";
@valentinwinkelmann
valentinwinkelmann / docker-compose.yml
Created August 14, 2023 10:31
Directus + Nakama docker-compose.yml (PostgreSQL )
version: '3'
services:
postgres:
container_name: gameserver_postgres
image: postgres:12.2-alpine
environment:
- POSTGRES_DB=nakama
- POSTGRES_PASSWORD=localdb
volumes:
- pgdatanamaka:/var/lib/postgresql/data
@valentinwinkelmann
valentinwinkelmann / EyeBlendShapes.cs
Last active February 10, 2023 12:27
Allows to control blendshapes based on eye movements. Comes pre-configured with the configuration for CC4 blendshapes. Simply attach it to an object, add the mesh renderer and link the two eyeballs, then you need the remaining positions of the two eyes, these are the rotations where the eyes are looking absolutely straight ahead, their zero posi…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EyeBlendShapes : MonoBehaviour
{
public skinnedMeshRendererContainer[] meshRenderers;
public Quaternion LeftEye_RestPosition;
public Transform LeftEye;
public Quaternion RightEye_RestPosition;
@valentinwinkelmann
valentinwinkelmann / Action_FirstPersonBoneTarget_Freeze.cs
Created March 21, 2021 13:23
An extended GameCreator FirstPersonCamera that allows to bind the camera directly to a bone of the character. It also has a clamp function which is useful when the character has to sit down and can only move the camera in a limited field of view. An additional freeze action allows to freeze the camera. Should be executed when the character sits …
namespace GameCreator.Core
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using GameCreator.Camera;
[AddComponentMenu("")]
public class Action_FirstPersonBoneTarget_Freeze; : IAction
@valentinwinkelmann
valentinwinkelmann / GetNewArea.cs
Created March 14, 2021 10:37
A simple example of how to execute a function every x meters in Unity. I use it to generate a new navmesh in a procedurally generated world as soon as the player exceeds a certain point.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GetNewArea : MonoBehaviour
{
private Vector3Int current;
public int ClampValue = 20;
@valentinwinkelmann
valentinwinkelmann / TerrainLayer_Generator.cs
Created March 7, 2020 21:12
Because I find it very annoying to manually create a terrain layer for the materials imported with Megascans I simply programmed a little helper script. Just click on the included Megascans material and then go to "Megascans -> Create TerrainLayer from Material". Afterwards a TerrainLayer with the textures is created in the same folder.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
public class TerrainLayer_Generator
{
/// <summary>
/// Just right-click on the material generated by Megascans and then click on "Megascans -> Create TerrainLayer from Material"