A Hat in Time Guide

Creating A Custom Weapon for A Hat in Time

Creating A Custom Weapon

Overview

This guide will help you get started into making your first weapon mod!

Getting Started

This is my first guide, so bear with me. I’m going to be very thorough.

Alternatively, you can go watch the video tutorial I made here.

The things you’ll need first in order to follow along in this guide will be listed here:
  • Blender[www.blender.org]
  • A Hat in Time – Modding Tools
  • Some sort of image editor Maybe PaintDotNet?[www.dotpdn.com]
  • A text editor like Notepad++[notepad-plus-plus.org]

Don’t worry if you don’t know where to get the modding tools, as I’ll be going through that soon!

Ok, to Download the modding tools, go to Library>Tools and then search for “A Hat in Time” and install it.

After you finished installing it, open it up and create a new mod.

Be sure to name it something! I would recommend using Pascal casing (WhichIsLikeThis) when naming your mod folder or mod packages. Don’t forget to click save when you’ve finished naming it and/or editing the description.

Now you’re ready to open the Editor! Click the blue cube on the bottom-left to open it.

Getting a Model

While waiting for the Editor to open, you might want to get a model if you haven’t already.

If you’ve already made one, then you can skip this section and go onto the next one.

I would recommend The Models Resource[www.models-resource.com] for all of your model needs. Feel free to search in other places too!

I’ll be using Lip’s Stick used in SSB as an example.
(Make sure you download it, lol)

Setting up the Model for use in the Editor

You’ll have to position it correctly and add a bone for it to fit correctly in Hat Kid’s hand!
Open up blender, Delete everything in the scene by right-clicking, hitting x, and then clicking each object, and import your newly downloaded model.
Navigate to your file and then click import on the right.
Yeah, this model is WAY too big for Hat Kid. Let’s resize it.

But first, if your model is in multiple pieces like this:

Shift-Click each object; on the right toolbar. And press Ctrl+J.
If that doesn’t work, select one at a time.

Now we can resize.
If your model isn’t already highlighted in orange, hit “a” on your keyboard and select it. Then press “s” and move your mouse inwards.

The size is much better now, but what about the rotation?

You can skip this step if your model is already facing upwards.

Zoom in with the scroll wheel, (sorry Apple users) and take a look at the little axis on the bottom left for reference. You’ll need it.

From what I can determine, it needs to be rotated counter-clockwise on the y-axis, and clockwise on the x-axis.

Hit “r” and then “y”, “x”, or “z” depending on which way you need to rotate it. Then move your mouse accordingly.

It doesn’t have to be perfectly straight up and down, but try to make it as good as you can.

Now we need to move the model. Click and drag the arrow to move it.

Or you might first want to set the origin point in the model. You can do this by going to Object>Transform>Origin To Geometry.

Then press Shift+S and click “Selection to Cursor”.
This will move the model to the center of the workspace. If it didn’t, you probably moved the 3D cursor. You can reset the cursor position by pressing Shift+C.
Now just move it up.

Now it’s time to add a bone! Go to Add>Armature>Single Bone.

Now move it up to the top of the model and scale it down with “s”.
I moving and scaling it is optional, but I wouldn’t skip it. ¯_(ツ)_/¯

Now on the right bar, select the mesh, and then shift-click the bone in that order.
Then click Ctrl+P, and click “With Automatic Weights”.
Once you’re done with that, we can move on to exporting.

Exporting the model

Now it’s time to export.

No matter what your file type was before, you need to export it in .fbx format.

Now after clicking on FBX, name it something, and then on the bottom left under geometries, set smoothing to “edge” and under Armature, uncheck “Add Leaf Bones”

Now that you’re done, click Export FBX, and you’re done with the export!
Just don’t close blender yet, just in case if you need to resize the model at all.

Importing into the Editor

Now, in the editor, in the Content Browser click on Import
Then navigate to where you saved the .fbx file and click “open”.

Now here’s where you want to use either Pascal casing or camel casing again. For the Package Name, name it something related to what your mod weapon is, but not what the Mod Folder’s name is. This conflicts for some reason. Just name it something like (Part of your steam name)Weapon. For example, “personLipsStick”. Just don’t put any spaces or special characters. Then click OK.

If these messages pop up, don’t worry. I haven’t any problems with it so far, so just hit OK, and move on.

Now right click it and click Edit Using Anim Set Viewer.

While we’re in the Anim Set Viewer, we’ll add a socket for the Hookshot. Otherwise, there will be no chain.
First, click this button that looks kind of like an arrow pointing at a floating red island. I’m pretty sure this is supposed to mean socket, though.
The Socket Manager should now open up.

Now you need to create a new socket.
So click the New Socket button and then click OK on the button in the new little window.

Name it “HookshotPoint” like so:

It should be at the top like this:

Tada!

Keep in mind that if you don’t want the Hookshot to be just a stick, you can replace line 10 of “SteamName_WeaponName_Weapon.uc” with the Full Name of the model. This is in the Scripting section.

“But wait! Mine doesn’t look right!” I hear you say. “What am I supposed to do?”
Fear not. You just need to add a material now. Hopefully, your model came with a texture. You can close the Anim Set Viewer now. It was just to see what it looks like. Remember to open it whenever you want to see it again before we give it to Hat Kid.

Remember the Import button? You’ll need to click it again. But this time, navigate to where the original model is before you edited it with blender, and open the texture instead.
If it uses multiple textures, you’ll have to go to the A Hat in Time Official Discord[discord.gg] for help.
Just use discretion for which one to choose.
Click OK to import it without changing any settings.
Also, make sure to save every now and then. You can do this by right-clicking on the package and clicking Save.

Now your items probably disappeared. Don’t worry, they’re still there. It’s now under HatinTimeGame>Mods>(Package Name).

Creating a Material

Now, I’m no expert at making materials, but I did this just fine on my own. It wasn’t that difficult.
First, you have to find the material that the Umbrella uses. Click the big “All Assets” button under the Unreal Engine “U” and then type in the search box “UmbrellaV2”. It’s not case sensitive, so you don’t have to type it exactly as I do, but you still need to spell it correctly.
The circled material is the one you’ll need to copy. But you can’t just “Copy paste” objects from different packages. Right click and open it with the material editor. It’s in the same spot as the Anim Set Viewer.

It should look something like this.

Now back in the Content Browser, navigate back to your item under HatinTimeGame>Mods>(ModName) and then right click on a blank area and select New Material.
I would name it something like (WeaponName)_Mat. But you can name it whatever.

Now that the new material is made, it should automatically open. Then move it, and the Umbrella in the material editor side by side so you can see it better.
You can use the scroll wheel to zoom in and out in the editor.
Now, we need to select everything except the first part on the left. We can do this by holding down Ctrl and click-drag across while zoomed out.
As I cannot get a picture of this, I’ll just give an explanation of what it should look like while you’re doing this.

As you click and drag, a red selection box should follow your mouse. And when you let go, the items in the editor should be highlighted yellow, like this:
Now you can hit Ctrl+C on your keyboard, go to the material you’ve created, and paste it there with Ctrl+V.
Your new material should now look like this:
Be sure to leave the umbrella material open, so you can use it for reference.

For now, we’ll leave everything in the workspace how it is, and we’ll go on to something else.
Click on an empty space in the workspace in your material, and everything should now be deselected.

Now at the bottom, there should be a properties box. Under Material, Change Opaque to Masked, and Phong to PBR, like so.
It could lag a bit, but don’t worry. This is normal. (for me at least)

Now scroll down a bit and under Usage, check the box “Used With Skeletal Mesh”
It should lag a bit there too.

Leave everything else unchecked.

Now add a preview mesh so you can see what it looks like when you’re finished!

This is optional, as you can just drag the weapon into the workspace after you give it a material.

Go to the Content Browser, right click on your weapon’s model and click “Copy full name to clipboard”

Back in the Properties box in your material, scroll down to the bottom, and open up Material Interface. You can then paste it in the box.

Now we’ve got to connect everything. Click and drag the black square things to connect it to the other object.

It should then look like this when you’re finished.

But wait, it’s still using the umbrella’s texture!
click and drag, or zoom out until you can see the texture on the top right here and click it to select it:

Now back in the content browser, click on the texture you imported so it’s highlighted in yellow like this, and then click the green arrow to change the material’s texture from the umbrella to the texture you imported.

Then click the green checkmark at the top, and then this message should pop up.
It’ll take a while unless your computer’s fast.
[/previewimg]
[previewimg=15930501;sizeFull,floatLeft;fiftyone.PNG][/previewimg] Now we are finished with the material! You can close the material editors now. We no longer need them. In the Content Browser, right-click your model and open it in the Anim Set Viewer if you don’t have it open already, then click on your material in the Content Browser. Back in the Anim Set Viewer, click on the green arrow as you did before on Material 0, and then your model should now have the texture on it! [previewimg=15930545;sizeFull,f

And if you did the preview mesh, it should now have the texture like this:

Now we are finished with the material! You can close the material editors now. We no longer need them.

In the Content Browser, right-click your model and open it in the Anim Set Viewer if you don’t have it open already, then click on your material in the Content Browser.
Back in the Anim Set Viewer, click on the green arrow as you did before on Material 0, and then your model should now have the texture on it!

Don’t forget to save your package!

Tada!

Scripting

Now, I don’t have any experience with whatever the scripting language this uses.

DO NOT CLOSE THE EDITOR YET

We still need it open. I closed it like an idiot because I thought we didn’t need it anymore, but we do! You need to get the Full Name of the model you imported!
Good thing I’ve got screenshots for reference. 😛

Back in the Mod Manager, click Browse Mod.

Then file explorer should open to the Mod Folder.
There should be a Content Folder, and a file called modinfo.ini

We’ll need to create a Classes Folder and a Localization Folder.
So do that now.

In the Localization Folder, create an INT Folder. In the INT Folder, create a txt file, and rename it collectibles.int.

Be sure to have File Name Extensions on.

Now go into the Classes folder that you created earlier, and create two new Text documents. You’ll need to name them something like “SteamName_Mod_WeaponName.uc”, and “SteamName_WeaponName_Weapon.uc”.

Open up the “SteamName_Mod_WeaponName.uc” one first, as I’ll be putting it’s script first. Be sure to open it in Notepad++.
Here’s the script so you can copy and paste it:

class Person_Mod_LipsStick extends GameMod config(Mods); event OnModLoaded() { HookActorSpawn(class’Hat_Player’, ‘Hat_Player’); GiveItem(true); } event OnHookedActorSpawn(Object NewActor, Name Identifier) { if (Identifier == ‘Hat_Player’) GiveItem(true); } function GiveItem(bool b) { if (b) Hat_PlayerController(GetALocalPlayerController()).GetLoadout().AddBackpack(class’Hat_Loadout’.static.MakeLoadoutItem(class’Person_LipsStick_Weapon’), false); else Hat_PlayerController(GetALocalPlayerController()).GetLoadout().RemoveBackpack(class’Hat_Loadout’.static.MakeLoadoutItem(class’Person_LipsStick_Weapon’)); } event OnModUnloaded() { GiveItem(false); }

On line 1, You’ll need to paste in the name of the file, or “SteamName_Mod_WeaponName.uc”, and on line 18 and 20, you’ll need to paste the name of the other file you created. Or “SteamName_WeaponName_Weapon.uc”. Like this:

Now you can Ctrl+S to save it, and go back to File Explorer and open up the other file.

Here’s the script so you can copy and paste:

class Person_LipsStick_Weapon extends Hat_Weapon_Umbrella; defaultproperties { Begin Object Name=Mesh0 SkeletalMesh = SkeletalMesh’personLipsStick.LipsStick’ Materials(0) = None OpenMesh = None; ShaftMesh = None; End Object /*If you want a ShaftMesh, you’ll have to create a new object and add the full name of the mesh. “SkeletalMesh’personLipsStick.LipsStick'”, in my case. Uncomment the next part of this script by removing the slash and star on each side if you want to do so. I haven’t tested it, though..*/ /* Begin Object Name=MeshShaft SkeletalMesh=SkeletalMesh’personLipsStick.LipsStick’ PhysicsAsset=PhysicsAsset’HatInTime_Weapons.Physics.umbrella_shaft_Physics’ bOnlyOwnerSee=false CastShadow=true bCastDynamicShadow=true CollideActors=false BlockRigidBody=false MaxDrawDistance=6000 bUpdateSkelWhenNotRendered=false bIgnoreControllersWhenNotRendered=true bAcceptsStaticDecals=false bAcceptsDynamicDecals=false End Object Components.Add(MeshShaft); ShaftMesh=MeshShaft; */ CoopTexture = None; //You might want to add an icon so the player can tell the difference between your weapon and the umbrella. This is optional, though. //HUDIcon = Texture2D’texturename’ HitSound = SoundCue’HatinTime_SFX_Metro.SoundCues.Weapon_Baseball_Bat_General_Hit’ WeaponName = “WeaponLipsStick” WeaponDescription(0) = “WeaponLipsStickDesc” IsUmbrellaWeapon = false } function OnAttackParticle(ParticleSystemComponent PSC) { PSC.SetMaterialParameter(‘Material’, MaterialInstanceConstant’HatInTime_Costumes3.Materials.AttackSwing_BaseballBat’); }

Like the other one, on line 1, you’ll need to paste the name of the file. Or “SteamName_WeaponName_Weapon.uc”.

Line 6, you’ll need the Full Name of your mesh. It’s the same as what the preview mesh uses for your material.

Also, on line 11, you could change the texture of the weapon for Bow Kid. instead of “None”, you change it to the texture’s Full Name.

This is completely optional, though.

Line 13 is optional, but if you want to, you can import a preview image into the editor, copy its Full Name, and paste it after the “=”.
By the way,
“//”
means the text on that line is a comment. You can also remove the multiline comment, which is like this: “/*comment
comment*/”
The script doesn’t read it. So when you do decide to add a HUDIcon, be sure to remove those two slashes.

On line 16 and 17, name it something unique like what I’ve done here. Just don’t name it the same as I did, or that’s not unique, and it might mess with my collectibles.int file.
WeaponName is what it’ll appear as in the HUD, and WeaponDescription(0) is the description of it. That’s just the names though, and the real name and description will be added in the collectibles.int file.

Ctrl+S to save, and now we move onto the collectibles.int file in Localization>INT>collectibles.int

We’re nearly finished now. In the home stretch.

In the collectibles.int file, you’ll need to write something like:

[Weapons] WeaponLipsStick = Lip’s Stick WeaponLipsStickDesc = It’s Lip’s Stick!

If you remembered correctly, line 2 is the name, and line 3 is the description!
You’re nearly finished with the scripting now, so Ctrl+S to save, and go back to the Mod Manager.

There, click the box on the left with the box that looks like a command prompt. When you’re there, click refresh, and then click compile scripts. This will take around 40-300 seconds, depending on how fast your computer is.
You’re done with the scripting part now! Congrats! We’ve got a few more steps though, so keep reading.

Cooking and Testing

You’ve got to cook your mod before you can test it or release it!

Click on the rocket ship on the left, and then click “Cook Mod”. It’ll take 100-400 seconds now, depending on your computer.

If there are any errors, tell me in the comments, and I’ll try my best to help you. You could also join the Official A Hat in Time Discord[discord.gg] for help, too. It’s a really nice community. Don’t get too impatient if your question doesn’t get answered right away, and if it gets buried in other questions or comments, ask it again.

Now it’s time to test it. Close the command prompt looking window, and click Test Mod. I would create a new save file for testing your mods, as playing on your normal save file removes any mod items you’ve gotten before through the Rift Roulette. I don’t really mind this, however.
You can play on your original save file if you don’t care about your modded Rift Roulette items.

Ok, this is ridiculously giant. That’s Ok, we can resize it in blender, and then reimport it in the editor.

You’ll have to reopen the editor though.

Ok, so in blender, you resize it with “s”, and move it down a bit. Then export it as the same file name and type as before.

Then in the editor, you right-click the model in your package, and click “Reimport skeletal mesh.” This will update the model to whatever changes you did before!

I love reimport. It saves so much time.

Now when you test it, it should be smaller!
You now know how to make a weapon mod! Now all that’s left is to upload it to the steam workshop so other people can use it!

Releasing the Mod

Releasing the mod is as simple as clicking ONE button!

You

have

to upload an Icon to use first, so let’s do that.

Take a picture of Hat Kid with the weapon or something like that, and then open up your image editor.
Then put it in there and make it a multiple of 2. i.e 512×512, 1024×1024. It needs to be a square.
Now after you save it as PNG or JPG, click the little guy on the top right and navigate to your saved icon.

Now you can release it to the steam workshop!

I hoped this guide helped you!

I’m interested in the mods you’ll make using this guide! Post them in the comments (if you can) I’d love to see them!

Here’s a link to the mod created in this guide:
[link]

Black Umbrella with no Texture Issue

If your weapon has a black umbrella like this when you’re using in-game assets


Then you should add

Components.Remove(Mesh2) Components.Remove(Mesh1)

right before Begine Object Name=Mesh0, like this:

Components.Remove(Mesh2) Components.Remove(Mesh1) Begin Object Name=Mesh0 SkeletalMesh = SkeletalMesh’ChocIceWeapon.rollerblade’ Materials(0) = None End Object

That should remove the black umbrella.

Mods created with the help of this guide

ChocIce75’s Weapon Pack: [link]

Seal Weapon: [link]

Energy Sword (Halo): [link]

SteamSolo.com