Class CharacterController2D
Class representing a 2D character controller as a game behavior.
Inherited Members
Namespace: Genesis.Core.Behaviors
Assembly: Genesis.dll
Syntax
public class CharacterController2D : IGameBehavior
Constructors
CharacterController2D()
Default constructor for CharacterController2D.
Declaration
public CharacterController2D()
Properties
AllowJump
Gets or sets the jump cooldown duration in milliseconds.
Declaration
public bool AllowJump { get; set; }
Property Value
Type | Description |
---|---|
bool |
CameraFlags
Gets or sets the camera flags for character control.
Declaration
public CameraFlags CameraFlags { get; set; }
Property Value
Type | Description |
---|---|
CameraFlags |
ColliderHeight
Gets or sets the follider height
Declaration
public float ColliderHeight { get; set; }
Property Value
Type | Description |
---|---|
float |
ColliderRadius
Gets or sets the collider radius
Declaration
public float ColliderRadius { get; set; }
Property Value
Type | Description |
---|---|
float |
DownKey
Gets or sets the key for moving the character down.
Declaration
public Keys DownKey { get; set; }
Property Value
Type | Description |
---|---|
Keys |
JumpCooldown
Gets or sets the jump cooldown in milliseconds
Declaration
public long JumpCooldown { get; set; }
Property Value
Type | Description |
---|---|
long |
JumpKey
Gets or sets whether jumping is allowed.
Declaration
public Keys JumpKey { get; set; }
Property Value
Type | Description |
---|---|
Keys |
JumpSpeed
Gets or sets the jump speed of the character.
Declaration
public float JumpSpeed { get; set; }
Property Value
Type | Description |
---|---|
float |
LeftKey
Gets or sets the key for moving the character right.
Declaration
public Keys LeftKey { get; set; }
Property Value
Type | Description |
---|---|
Keys |
Mass
Gets or sets the mass of the character.
Declaration
public float Mass { get; set; }
Property Value
Type | Description |
---|---|
float |
MoveDirection
Gets the last movement direction from the character
Declaration
public MoveDirection MoveDirection { get; set; }
Property Value
Type | Description |
---|---|
MoveDirection |
MovementFlags
Gets or sets the movement flags for character control.
Declaration
public MovementFlags MovementFlags { get; set; }
Property Value
Type | Description |
---|---|
MovementFlags |
RightKey
Gets or sets the key for making the character jump.
Declaration
public Keys RightKey { get; set; }
Property Value
Type | Description |
---|---|
Keys |
Rigidbody
Gets or sets the Rigidbody2D component for character physics.
Declaration
public Rigidbody2D Rigidbody { get; set; }
Property Value
Type | Description |
---|---|
Rigidbody2D |
Speed
Gets or sets the speed of the character movement.
Declaration
public float Speed { get; set; }
Property Value
Type | Description |
---|---|
float |
UpKey
Gets or sets the key for moving the character up.
Declaration
public Keys UpKey { get; set; }
Property Value
Type | Description |
---|---|
Keys |
Methods
CharacterProcess(Game)
Processes character movement and behavior based on user input.
Declaration
public void CharacterProcess(Game game)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
CreatePhysics(PhysicHandler)
Creates default physics for the character with no specified factors.
Declaration
public void CreatePhysics(PhysicHandler physicHandler)
Parameters
Type | Name | Description |
---|---|---|
PhysicHandler | physicHandler | The physics handler for creating the physics. |
CreatePhysics(PhysicHandler, ControllerPreset)
Creates physics for the character based on the specified controller preset.
Declaration
public void CreatePhysics(PhysicHandler physicsHandler, ControllerPreset controllerPreset)
Parameters
Type | Name | Description |
---|---|---|
PhysicHandler | physicsHandler | The physics handler for creating the physics. |
ControllerPreset | controllerPreset | The preset for the controller. |
CreatePhysics(PhysicHandler, Vec3, Vec3, bool)
Creates physics for the character with specified factors and physics enabling.
Declaration
public void CreatePhysics(PhysicHandler physicHandler, Vec3 linearFactor, Vec3 angularFactor, bool enablePhysics)
Parameters
Type | Name | Description |
---|---|---|
PhysicHandler | physicHandler | The physics handler for creating the physics. |
Vec3 | linearFactor | The linear factor for the physics. |
Vec3 | angularFactor | The angular factor for the physics. |
bool | enablePhysics | Specifies whether physics should be enabled initially. |
OnDestroy(Game, GameElement)
Destruction method called when the game ends or the behavior is removed.
Declaration
public override void OnDestroy(Game game, GameElement parent)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
GameElement | parent | The parent GameElement of the behavior. |
Overrides
OnInit(Game, GameElement)
Initialization method called when the game starts.
Declaration
public override void OnInit(Game game, GameElement parent)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
GameElement | parent | The parent GameElement of the behavior. |
Overrides
OnRender(Game, GameElement)
Rendering method called during the rendering phase.
Declaration
public override void OnRender(Game game, GameElement parent)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
GameElement | parent | The parent GameElement of the behavior. |
Overrides
OnUpdate(Game, GameElement)
Updates the character state on each frame.
Declaration
public override void OnUpdate(Game game, GameElement parent)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
GameElement | parent | The parent GameElement of the behavior. |