A Hat in Time

A Hat in Time

39 ratings
Creating a Custom Playable Character
By Crash and 3 collaborators
This guide will server as a template to make a basic character mod, it also will help to teach how to add items into the HUB and creating custom hats and weapons!
   
Award
Favorite
Favorited
Unfavorite
Pre-Notes
Welcome! This guide assumes you understand the basics of a 3d modeling program and a little bit about the hat in time editor, if there's anything I could do or add to make this easier to follow just let me know! For the sake of blender being its own challenge I'll try to provide better resources than what can be explained via text.
If this is your first time working with Hat's class file system, don't fret, you can open a .uc file withe notepad++[notepad-plus-plus.org], which is what I'll be using in the guide!
Getting the Skeleton
The first step in creating a playable character is to get Hat Kids Skeleton from the editor!

Once the editor is open, under the Preferences tab at the top of the screen be sure to disable simplified editor




then in the content browser look for
SkeletalMesh'HatInTime_Characters_HatKid.models.HatKidHead'



from here drag the model into the scene and double click it to open the properties and look up in the search tab location, set the location to 0,0,0 so that it is at the world origin.



From here you can right click Hat Kid's head in the scene and export as fbx. you can just name this file whatever.

Rigging to the Skeleton
I recommend using blender to import the model, as this is what this guide will mostly follow,
Make sure when import to enable ignore leaf bones.





From here I recommend following through this amazing guide by Classytimes to fix the skeleton on blender import.

https://steamcommunity.com/sharedfiles/filedetails/?id=2344379306&searchtext=skeleton

Next, import your model, (Note that if your model is a .blend you'll want to open that file first then import the Hat Kid fbx), you'll want to align and scale your model to be roughly the size of Hat Kid,

Once your model is scaled to your liking select your model then hold shift and click the skeleton bones, then press ctrl and p and select with Empty Groups.



With those assigned I recommend following a weight painting tutorial if you're unfamiliar with the process, as it is different for every model, I recommend: https://www.youtube.com/watch?v=Tl4qTgwQwYw

This is often considered the worst part of making a playable as it can take a long time to get everything just right, but don't be discouraged and take breaks if needed!

If you want this playable to support costumes then split the model into 3 parts for the head, body, and legs. You'll want to export each piece separately, additionally exporting one "full body" model with all pieces together. This is called the Three Mesh Playable, because you use three pieces, and because it will be able to support costumes unlike one fullbody mesh.

I'll cover the differences in scripting in two separate sections, as the process is largely similar for the two but with some differences.
Getting it in the Editor
(Hi quick note! I got kinda lazy here and don't have any easy to use player models I can upload for hat, so I'll just be using 3 cubes that define the 3 different body parts, thanks in advance!)

Once you're ready to put everything into the content browser, there's 2 main ways to import your models and textures into the content browser.

The first method is by just dragging and dropping into the content browser, and changing the import package name, most often it's a prefix followed by the player name (In this case I'll be using Kido_CubePlayer)


The other method is to click the Import button and select each file individually, also changing the package name.


Common issue


The easiest fix for this is to save your texture as a TGA, also be sure that the size of the image is a power of 2,

(anything past 4096 is excessive), most common texture size being 512x512 or 1024x1024

Creating the Materials
For each texture you've imported, the next step is to create a material.
Right click anywhere in the background of the content browser and create a new material, one for each texture.


Next click on All Assets, and search for
MaterialFunction'HatInTime_CharacterShading.Templates.PlayerShader'

then drag and drop it into the Material as shown below


Next click on the grey main node in the center, and change the Blend Mode to Masked and Lighting Model to PBR. then connect the nodes as seen in the picture below


Then, you'll want to return to your package and drag the texture into the material, and connect the Purple output into the Diffuse slot.

The end result should look like this, feel free to mess around and add more flair to it if you so desire!


Repeat these steps for each texture you have.

More more in-depth materials with dyability I recommend reading this guide

Applying the Materials to the Model
Once each texture has been created we'll want to apply it to the models.
First right click one of the materials and Copy Full Name to Clipboard.
Double click on the model and look in the bottom left, look for a tab called Materials and paste the material you copied before into the proper slot.



Do this for each model, don't let the lighting of the material in the preview deceive you, it'll look a lot better in-game.
Sockets - The Addition
Sockets are very "trial and error" based, these define where hats and other attachments should go on the player, to add these we'll first need to go back to
SkeletalMesh'HatInTime_Characters_HatKid.models.HatKidHead'
instead of placing this in the world we'll want to open it, and find the red trapezoid button in the top left


With this open we'll want to copy all the sockets into our own model, find but button that looks like scissors


from here we'll want to go back to our model (The head mesh if we're setting up a model that uses the three parts), go into the socket editor and this time click the clipboard to paste


I'll try to run through every socket and what it is in a table here, you can assign a preview mesh my pasting a mesh into Preview Skel Mesh or Preview Static Mesh, depending on the prefix.
Sockets - A List
Socket Name
What is it used with?
Preview Mesh
AlienEyes
The effect used in She Came From Outer Space when the player is "muddy"
ParticleSystem'HatInTime_PlayerAssets.Particles.SpecialEyes'
BandMarsal
The Parade hat used in the Big Parade, and given in Death Wish
SkeletalMesh'HatInTime_Costumes.models.moon_parade_hat'
Beanie
The Cat beanie ice flair
SkeletalMesh'HatInTime_Costumes.models.KatBeanie'
BombOnBack
The bomb used in the Dead Bird Studios boss fight
StaticMesh'HatInTime_Levels_Moon_Habboi.models.dead_bomb'
bow
Bow Kid's bow
SkeletalMesh'HatInTime_Characters_Coop.models.bowkid_bow_skm'
CarryPoint
Not used, as Hat Kids "Carry Point" is calculated by the bones themselves
None
ChairBound
Unused Status Effect for when the "Heart to Heart" sequence occurred in the Dead Bird Studios boss fight
None
ChemicalFlask
Where Hat Kid holds the brewing potion when preparing to throw
StaticMesh'HatInTime_ScienceOwlAssets.models.owlbrew.science_owlbrew_remade'
ChickenMask
Chicken mask sprint flair
SkeletalMesh'HatinTime_Costumes_Z.models.Rooster_Hat'
crown
Online Party Crown
StaticMesh'HatInTime_Items.models.capsule_crown'
DetectiveHat
The Detective hat used in the level Murder on The Owl Express
StaticMesh'HatInTime_Levels_Murder_Dan.Model.Detective_Hat'
DetectiveHatSkeletal
The Detective hat given as a reward in Death Wish
SkeletalMesh'HatInTime_Costumes2.models.Detective_Hat'
DinoHat
The Dino Hat sprint flair
SkeletalMesh'HatInTime_Costumes.models.dino_hat'
DwellerMask
The Dweller mask
SkeletalMesh'hatintime_creatures.models.Mask_Fox'
EndingBroom
The broom used in the final cutscene on the spaceship
SkeletalMesh'HatInTime_HUB_H.models.mr_broom'
Eyes
Where NPCs will look when looking at the player
None (It looks at the socket itself so eyeball it)
Flag
Unused socket
None
FuzzyHornHat
The fuzzy horn hat ice flair
SkeletalMesh'HatInTime_Costumes.models.FuzzyHornHat'
Glasses
The stylin' shades aquired in dead bird studio
SkeletalMesh'HatInTime_Costumes.models.glasses_double'orSkeletalMesh'HatInTime_Costumes.models.glasses_single'
Hachimaki
Unused hat flair
SkeletalMesh'hatintime_levels_mafiahq_dan_2.Model.Hat_Hachimaki_Skeleton'
Headband2
The Nyakuza Mask
SkeletalMesh'HatInTime_Costumes3.SkeletalMesh.nyakuza_ears'
Heart
The heart that appears during time stop
StaticMesh'HatInTime_Items.models.healthrecovery'
Holiday Hat
The Santa hat ice flair
SkeletalMesh'HatInTime_Costumes.models.Holiday_Hat'
HyperlightHat
Crossover Hat, not in game files but are in that mod's files
None
icehat
The ice hat
SkeletalMesh'HatInTime_Costumes.models.ice_hat_2017'
Idle_Doll_Kiss
The Particle effect that plays when the dolls "Kiss"
ParticleSystem'HatInTime_PlayerAssets.Particles.kiss'
Idle_Doll_L
The Mafia Doll Hat Kid holds during her Idle animation
StaticMesh'HatInTime_Hub_Vince.models.Mafia_Doll_Mafia_doll'
Idle_Doll_R
The Owl Doll Hat Kid holds during her Idle animation
StaticMesh'HatInTime_Hub_Vince.models.Owl_Doll_owl_doll'
ItemEnd
Where Kid generally holds items, doesn't need touching
None
KidHat
Hat Kid's hat!
SkeletalMesh'HatInTime_Costumes.models.KidHat'
LeftHand
Hat Kid's left hand position, doesn't need to be touched generally
None
LilacHeadpiece
Crossover Hat, not in game files but are in that mod's files
None
MagnifyingGlass
Unused Magnifying Glass weapon
StaticMesh'HatInTime_Levels_Murder_Dan.Model.Magnifying_Glass'
ManorKey
The Key Hat Kid holds in Vanessa's Manor
 SkeletalMesh'HatInTime_Levels_Manor_Mecha.models.key_01_center'
Mouth
The cookie you can get in cruise
There's not actually a mesh for this as it's an object attached, and that object is scaled differently
OneShotHat
The Niko hat used in the official hat mod
StaticMesh'HatinTime_Costumes_Z.models.Niko_Hat'
PresentGift
General location where Hat Kid holds some items, doesn't need to be touched
None
PsychonautsHat
Crossover Hat, not in game files but are in that mod's files
None
RaccoonHat
Unused Racoon hat (some mods make use of it)
SkeletalMesh'HatInTime_Costumes.models.RacHat'
RightHand
Hat Kid's right hand position, doesn't need to be touched generally
None
ShovelKnightHat
Crossover Hat, not in game files but are in that mod's files
None
SnailHat
The Snail hat ice flair
SkeletalMesh'HatinTime_Costumes_Z.models.Snail_Hat'
SprintHat
The Sprint hat
SkeletalMesh'HatInTime_Costumes.models.sprint_hat_2017'
Taunt_HeadProp
The props that appear when Hat Kid flips her cap in the Idle animation
StaticMesh'HatInTime_Hub_Vince.models.Mafia_Doll_Mafia_doll'
ThorHat
Thor hat flair
SkeletalMesh'HatInTime_Costumes.models.thor_inventor_cap_final'
Ticket
The card held by Hat Kid when running through the Metro gates
StaticMesh'hatintime_levels_metro_h.models.metro_gate_card'
TimmyHat
Timmy hat flair
SkeletalMesh'HatInTime_Costumes.models.Timmy_Hat'
Umbrella
Hat Kid's umbrella
SkeletalMesh'HatInTime_Weapons.models.umbrella_closed'
WaterFlask
The waist held position of the flask (used in a few mods)
StaticMesh'hatintime_levels_sandsails_dan.Model.Flask_Flask_1'
WaterFlaskRightHand
Where Hat Kid holds the water flash when taking a drink (Used in a few mods)
StaticMesh'hatintime_levels_sandsails_dan.Model.Flask_Flask_1'
WeaponHat
WidowHat
The Time Stop hat
StaticMesh'HatInTime_Costumes.models.time_stop_hat_static'
WitchHat
The Brewing hat
SkeletalMesh'HatInTime_Costumes.models.hat_witch_hat_2017'
Player icons and Ice Statues
Extra Goodies
Player Icons
You can also import and additional texture for the player icon, it'll be used when a co-op player is too far away from you, or when using this mod. To do so import your players icon as you did with the player textures, ensuring that it is a power of 2. We'll reference this file later in script.

Ice Statues
Back in blender we're going to want to pose our model how we want to see the ice statue in-game
If you don't know how to pose I reccomend watching some guides on youtube, as it's not that hard of a concept, but explaining it in text can be difficult, https://www.youtube.com/watch?v=yLSquDzNar8

Once you've posed the model to you liking you'll want to do a few things,


We'll want to go back into object mode and select our model, then press ctrl+a, and apply all transforms.


Go into the model's Modifiers tab, and apply the skeletal mesh,


With that applied you should be able to delete the skeleton, the only major thing to do with the model is to merge all the materials into one, as the editor will only use one,


Another thing people will do to add some "flair" is make it shaded flat as to follow what the ingame ones look like, and decimate the model to make it lower poly,


Some people will also add a baseplate like Hat Kid and Bow Kid have, when you're ready, export the model as an fbx and you can import that into the editor, into your package, we'll use this in script later!
Creating a One-Mesh Playable
Most of the Scripts for playable characters is copying and pasting, I'll provide a template playable character files for pasting into here[drive.google.com]

A One-Mesh playable is useful for those who would rather just have one model that doesn't support costumes (can still support dyes if setup), most commonly used if the character is a port of a character from another game.

I'll only go over what to replace here, and provide a more in-depth walk through on functions and what they do in the script itself!

In the file named Kido_Player_[PLAYERNAME]
any instance of [PLAYERNAME] needs to be renamed to whatever your players name is, for example my character here is Cube Player, so the first Kido_Player_[PLAYERNAME] would be Kido_Player_CubePlayer, avoid using spaces or non-alphabetic characters.

Do note that the file name should match what what the first line defines the class as, for example if my class is named Kido_Player_CubePlayer, it should be named Kido_Player_CubePlayer.uc




With a simple one-mesh playable the only other replacement we need to define is the model itself,
in the editor right click the player model and select Copy Full Name to Clipboard, then in the script you can paste it in the spots marked [PLAYERMESH]

For example my CubePlayer model is
SkeletalMesh'Kido_CubePlayer.FullModel'





If you added any of the Extra Goodies from above there's still a few more steps!
In the file named Kido_ObjectiveActor_[PLAYERNAME]
We'll want to rename the [PLAYERNAME] like above, the [ICON] will be our texture from the editor we imported earlier. like the model we'll right click the texture and Copy Full Name to Clipboard, mine looks something like
Texture2D'Kido_CubePlayer.PlayerIcon'


Setting up the ice statue
In the file named Kido_Player_[PLAYERNAME]
If you imported an ice statue model before, you can copy its full name from the editor and paste it in [ICESTATUE]
Creating the Three-Mesh Playable
Custom Sounds
Nyoom Kaboom, sounds are a vital part to expressing a characters emotions! (unless you're Link or Kirby of course)

If you wish for the player to stay mute you can always remove the // before the overrides


























If you want to use custom sounds you can also import wav files into hat and create Sound Cues

Like how we imported our player we can import the sound files the same way!
While importing tick the Auto Create Cue checkbox,








From here we can right click the newly created Audio Cue and paste it over the None in script, like below



I'd like to create a more indepth guide on how the sounds in hat work with things like randomization between sounds and whatnot, but for the sake of my sanity this is all for now!
Custom Expressions
( o`ω′)ノExpress yourself!

Expressions are a big part of making a playable character unique and interesting,

[INSERT MATERIAL SETUP HERE FOR FACE AND EYES]


The Scripting

The Expression component template can be found here[drive.google.com].

The only notable thing worth changing is that FaceIndex and EyeIndex need to be changed to match your characters material indexes, if you don't use one of them set it to -1.

In the Player class in the Default Properties be sure to also change the Indexies there and add
Begin Object Class=[EXPRESSIONCLASS] Name=Expression1 End Object Components.Add(Expression1); ExpressionComponent = Expression1;
Like shown below



as well as in ConvertNPCPlayer changing
//exp = new [ExpClass];
into
exp = new [ExpClass];
like shown below

Adding a Hub Swapper
Adding a hub swapper can seem difficult, but it's just about placement!

With the editor, you'll want to open the hub map so we can find where we'll want to place our player
the map can be found in
...\Steam\steamapps\common\HatinTime\HatinTimeGame\CookedPC\Maps\hub\hub_spaceship.umap

When you open the map you may see some errors and warnings, you can safely ignore those,
You may notice that the map is all dark, don't fret, you'll just want to enable unlit mode in the editor by finding the set of boxes in the top left, look for the brightest one and click that,


From here you can use your player model, or
SkeletalMesh'HatinTime_GhostParty.SkeletalMeshes.OneMeshHatKid'
and place it in the scene,
Note, nothing you do here saves, so feel free to mess around and find somewhere that works

You can press space to swap between location, rotation, and scale, when placing,
once you've found your desired location double click the model to open the properties and look up location,


Copy this XYZ location somewhere important, as we'll use this later

After that you'll want to search up Rotation and do the same thing, save it somewhere important,


Next we'll create the conversation trees for when you interact with your player, and when you swap back as player 1 and 2.
Going back to our content package we'll want to right click and create three new Conversation Trees,


Each tree should have 4 parts, starting the with base Root node already


To add a new node right click anywhere in the tree, you'll want to create 1
Hat_ConversationNodeChoice and 2 Hat_ConversationNodeContinues, when connecting each node it will give a list of options, choose Hat_ConversationLink


Then click the light blue Choice Node and on the bottom tab next to message write the "Swap to" message,

A list of writing effects that can be used can be found here[cdn.discordapp.com]. Written by the wonderful Werti and Habijob.

Then right click the output green node and you should be presented with 2 "Standard Link" options,


Select the top option and on the bottom you can set the "Fine Name", The top option is always the "Yes" option, the bottom is always the "No" option.


Once you have all three conversation trees done,
one for swapping to your player
one for swapping to player one (Hat Kid)
one for swapping to player two (Bow Kid)
we can begin writing the scripts!

You can of course nab the templates from here[drive.google.com] under the Hub Swapper folder

In the Kido_PlayerMod_[PLAYERNAME].uc file
You'll want to rename all of the [PLAYERNAME] lines to be your players name that you've used in the other class files,
You'll want to replace the X Y and Z and the Roll Pitch and Yaw with the values you copied earlier, for the Roll Pitch and Yaw leave *DG as that converts the rotation to be proper in-game.

An example,


Sometimes people will copy the rotation from the editor and it will add a degree symbol to the end, be sure to remove it before posting it into the class file or else the compile will fail later on.

In the Kido_PlayerSwapper_[PLAYERNAME].uc file
Replace the [PLAYERNAME] with your player's name like above,
alongside copying your playermesh like you did in the player class into the [PLAYERMESH] spot.

However in this file we also need to do two additional things, in the editor copy the fullname of the conversation tree to swap to our custom player and paste this in the spot of [CONVOTREE PLAYER], as well as replacing the [ANIMNAME] with what idle animation we want the player to use when idle, you can find the animations inside
AnimSet'HatInTime_Characters_HatKid.AnimSet.HatKidV2_Anims'
, however the most common idle is just called 'Idle'

In the Kido_PlayerSwapper_[PLAYERNAME]_undo.uc and Kido_PlayerSwapper_[PLAYERNAME]_undo2.uc file
replace [PLAYERNAME] like in every file,
in _Undo you'll want to replace [CONVOTREE PLAYER1] with your convo tree to swap to player 1 or Hat Kid.
in _Undo2 you'll want to replace [CONVOTREE PLAYER2] with your convo tree to swap to player 2 or Bow Kid.

Lastly replace the [ANIMNAME] with your chosen idle animation name from above

With the three Playerswapper classes setup and the PlayerMod file, you're ready to continue!
Compiling for Usage!
This is the fun part, the part where we get to see all of our hard work pay off and our creation come to life!

Assuming you haven't already, you'll want to create a New Mod in the Mod Manager,

From Here you can set the Mod Name and Mod Folder, Note: The mod folder cannot be the same name as your content package we created earlier

You'll then want to open the mod folder by clicking the Browse Mod button.


In this folder we'll want to make 2 Subfolders, one named Classes and one named Content


You'll want to put any .uc files in the Classes folder
Likewise .upk files should be placed in the Content folder


Once we have our files moved we can go back to our mod in the Mod Manager and click the icon that looks like a console, if the screen says that "No script files, no need to compile scripts!" click the Refresh button below it, and click Compile Scripts.


If you've done everything properly you should have No errors!
There's a few warnings that may occur but most can be safely ignored, the only major ones to keep an eye out for is a missing object reference, in which you want to make sure your content package is in the correct place and that you copied the correct name.

NOTE: if you click into this window and select text it will freeze the log, if it seems to be taking an oddly long amount of time to compile make sure you don't accidentally have something selected!

Once the log is done compiling you'll want to close out of that window and in the mod manager go to the tab that looks like a rocket ship, in there we'll want to click the Cook Mod button


Another small pop-out window should appear, like above clicking and selecting will freeze it so be certain to not do that.

The finished product will look similar to the above, you might get warnings for missing content from other mods, you can safely ignore those here!

From here we'll want to test the mod as we see fit, Do note that using the "Test Mod" button will only load local mods and not workshop mods, just boot the game normally and all mods will be loaded

Any time you make a change in the upk package or the uc class files you will need to recompile and recook the mod!

Once you've tested to your hearts content and are ready to upload we can add an icon to the mod, an icon can be any image that is a square and less than 1mb in size! To do this click the button that looks like a holographic sticker of a silhouette,


Once we've done that we can click the Save Changes button and the Submit to Steam Workshop as Playable Mod button should be available, Once you click that the mod will begin to upload, if you get Success! then congratulations!

If you get an error it could be a few things, a Steam UGC error means that you need to open the modding tools via steam, or that steam servers are down.

If you are updating the mod make sure the patch notes only use letters and numbers, common practice is just make the patch notes a single letter, then change it from steam itself!
Need help?
If there's anything that I could do better or just need help understanding how a part is done don't be afraid to shoot me a message on discord: Crash#3972 or my steam.

There's also the wonderful community of Hatcord[discord.gg] where you can ask in the modding help chats!
Happy Modding!
19 Comments
Crash  [author] Jan 16 @ 6:15am 
The object needs to be placed in world, not from the editors content browser, which is why we turn off simplified editor to allow us to export the fbx properly iirc simplified editor is under tools? I think the guide says at the start though
TheSpiderKing Jan 15 @ 8:53pm 
Im having the same issue as Useydess. The after, I move the fox mask to 0,0,0 right click the model. There's no option to export the model. If I try viewing the model in the content browser an export it that way. The editor says the operation can't be performed on a cooked object.

The editor doesn't seem to beable to allow lod fbx models in the content browser after your in the model viewer to replace a object. Which, you get the same issue.
Useydess Jun 22, 2024 @ 12:29am 
hey so im currently trying to export the head as a .fbx but when i right click HatkidHead i don't see anything that allows me to export to .fbx. anyone know why?
Crash  [author] Nov 6, 2023 @ 10:29am 
Is it an error or just a warning, could you link an image?
Finlayfin212 Nov 5, 2023 @ 5:43am 
i get an error saying Expression has no effect when compiling scripts. I am making a one mesh model/.
Crash  [author] Aug 6, 2023 @ 5:28pm 
It’s not loading the package which would be why the model doesn’t show up in game, is the package named the same as one in another mod?
Melora Aug 6, 2023 @ 5:17pm 
I keep getting an error that say ambiguous package name whenever I try to open Hat in Time and the character model won't show up.
CreativeCreeper May 11, 2023 @ 11:06pm 
It's fine man, I'm just happy to actually have a guide on HOW to make a playable character and not a stupid show case
Crash  [author] May 11, 2023 @ 10:54pm 
cheers, and sorry for never getting around to that, I'm just not as much into hat as I used to be and don't exactly have the drive to finish that section
CreativeCreeper May 11, 2023 @ 9:49pm 
Mk, I'll try and contact ya if I get stuck again