Platform Player Controller

Updated On: April 12, 2013

This Controller will convert a Spatial component into a fully functioning platform character. There are a number of properties that will give you a custom feel to your character from the amount of jumps the character is allowed to the amount of velocity that is applied to the character when moving or damaged.

**Note: This component will only work with a "Collision Spatial" component.

The Platform Player Controller


The same functionality could be setup in GBS piece by piece but this is the beauty of a plugin that wraps a bunch of functionality and controls into one component that can be easily applied to any entity.

Here is a rundown of the properties:

  • Maximum Available Jumps - The amount of jumps the player is allowed when pressing the jump key.
  • Jump Speed - The amount of velocity that is applied to the player in the negative Y axis to push player upwards.
  • Extended Jump Speed - Is additional velocity applied if the player holds the jump key for an extended period of time.
  • Air Jump Dampening - A multiplier used to reduce the amount of speed applied on secondary jumps. Normally a value between 0 and 1.
  • Maximum Horizontal Speed - The fastest speed that the player can move from left to right.
  • Incremental Acceleration Speed - The amount of incremental velocity the player will move from left to right before it reaches its max.
  • Enemy Kill Speed - The amount of velocity the player must travel to kill an enemy.
  • Enemy Kill Bounce Back Speed - The amount of velocity the player will bounce back when hitting an enemy.
  • Wall Slide Speed - The amount of velocity applied to the player when sliding down a wall.
  • Damage Duration - The amount of time the player stays in the damage state given in seconds.
  • Dynamic Friction - The amount of friction applied to the player when user releases the controls.
  • Damage Velocity - The amount the player bounces back when it gets hit by an enemy along the X or Y axis.
  • Auto Flip Attached Renderer - By selecting this box the renderer attached to the spatial being controlled by this controller will be scaled in the X axis to -1 and vice versa depending on the direction of the player.

Platform Player Controller - States


Every platform player has a bunch of states that it enters based on what it is interacting with in the game. The basic states based on the functionality of this component have been included for you already. If you want to react to these state changes as they happen throughout the game you need to add a "State Machine" component to the same entity and create all the states you see above. You can then select that component from the drop-down and match all states up to what is in the state machine. This will tell the component to change the states directly on the state machine. Then add a "State Logic" component to listen for those state changes and trigger different actions.

This could be used to animate the characters sprite sheet for example to reflect activities like walking or jumping. You can read more about this in the "How To Control Animations With Game States" tutorial.

Collision Filtering


You can manage all of the collision filtering on the spatial object which this controller will respect or you can provide more information to this controller by telling it what objects are enemies or what is the ground so that it knows how to behave correctly in your custom game. If you do not provide any filters this functionality is just ignored when the controller is running.

Follow Us For Updates