Overview | Videos | Documentation | Demos | Integrations | API | Support

Doc Home > How To > Modify Code for Easy Updating

The ability and item system reduces the amount of code modifications needed to add in your own functionality. However, changes to the core Third Person Controller code is inevitable for some games so we recommend that you inherit from the Third Person Controller classes rather than directly modifying them. This makes updating to new Third Person Controller versions extremely easy because you don't have to do any merging. By inheriting classes you are able to add in your own functionality, expose variables, and override methods without having to change any of the core classes.

As an example, lets say that you want to access the m_Force field within the Jump ability. This field is protected so to access it without any core class changes you'll want to inherit the Jump class. From there you can a public property to this inherited class and access the Force field by getting a reference to your inherited class. The code for this would look like:

using Opsive.ThirdPersonController.Abilities;

public class InheritedJump : Jump
    public float Force { get { return m_Force; } set { m_Force = value; } }
From here you can add your InheritedJump class to your character and now access the Force field:
character.GetComponent< InheritedJump >().Force = 5;

<- Fix "Unable to Transition to" Error
Prevent the Character from Colliding with Triggers ->