Modding:Adding Code to the Player: Difference between revisions

m
code formatting
imported>Teamtotobot
m (Teamtotobot moved page Modding: Adding Code to the Player to Modding/Adding Code to the Player: Bot: Moved page)
m (code formatting)
Line 1: Line 1:
{{Modding Info}}
{{Modding Info}}


You can use the <code>[PlayerMutator]</code> attribute and <code>IPlayerMutator</code> interface to modify the player object before the game begins, immediately after the player GameObject is first created.
You can use the <code>[PlayerMutator]</code> attribute and <code>IPlayerMutator</code> interface to modify the player object before the game begins, immediately after the player <code>GameObject</code> is first created.


This structure allows you to run custom code on the player object. For example, you might add custom parts to the player from your mod, which is otherwise very difficult to do.
This structure allows you to run custom code on the player object. For example, you might add custom parts to the player from your mod, which is otherwise very difficult to do.


Any class tagged with the PlayerMutator attribute is instantiated after the player object is created and assigned, and the "mutate" method is called with the player as the parameter. For example:
Any class tagged with the <code>PlayerMutator</code> attribute is instantiated after the player object is created and assigned, and the <code>mutate</code> method is called with the player as the parameter. For example:


<syntaxhighlight lang="csharp">
<syntaxhighlight lang="csharp">