Tutorial: How to make DLL mod (Gravity Mod) - SolidJuho/SolidFGWMods GitHub Wiki

Hardest part of modding is research how can you make your mod functional. It took me easily one day to find what i want, so using notepad and finding functions you want will easily save hours and hours.

Here is what i did to create Gravity mod.

Open Assembly-Csharp -> Assembly-Csharp.dll -> - -> FPSRigidBodyWalker. (Image is here to help you)

It is recommended have your functions under LateUpdate void, because it makes sure they don't activate too early and don't work. Of course there are expections.

Find part that you want to modify, its for me FPSRigidBodyWalker. On update right click and Edit method (ctrl+Shift+E).

Now you have to add C# code so here is how i have made gravity mod.

Here is the code `

if (Input.GetKeyDown("c"))
{

    Physics.gravity = new Vector3(0f, -5f, 0f);
}

if (Input.GetKeyDown("v"))
{

	Physics.gravity = new Vector3(0f, -1f, 0f);
}

if (Input.GetKeyDown("b"))
{
	Physics.gravity = new Vector3(0f, 20f, 0f);
}`

After that you press Compile. Then file -> Save module -> Ok

Launch game and make sure everything is working correctly.

Welldone!

You have now added Gravity mod for your game! Now you can either keep rolling with .dll mods or go next part and learn how to add custom textures/models/sound effects at next chapter. Or keep reading and learn how to create fields for custom values.

Fields

Biggest difrence when modding game with dnSpy is that you cant just add "public bool IsRich;" for new values. You need to right click green folders to create new field where you can type new values.

  1. Right click -> new Field
  2. Type name and press Ok.

  1. By default fields are ints, so you need to Edit Class

  1. After you have compiled, its ready to be used.