Make the game#

You will need to specialize 3 classes in C++.
ACPPlayerState
to expose SetScore to blueprint, this will be used to create a custom reward functionACPPawn
to make the pawn hostile to everybody, this makesAISense_Sight
sense all the pawn that are in rangeACPGameMode
to provide a customHasMatchEnded
that is used to reset the environment
From there everything can be done in blueprint. You will need to create the blueprints below.
Level:
CartPole
GameMode_CartPole
inherited fromCPGameMode
Pawn_Cart
(inherited fromPawn
)Pawn_Pole
(inherited fromCPPawn
)PlayerState_Cart (inherited from
CPPlayerState
)PlayerController_Cart (inherited from
PlayerController
)
Note
Both PlayerState_Cart
and PlayerController_Cart
are left empty.
Your input handling could be moved to PlayerController_Cart
if you wanted.
GameMode_CartPole#
Pawn_Cart#
Add a
FloatingPawnMovement
component to enable the cart’s movementThe cart is composed of a single cube followed by a cylinder rotated 90 degrees i.e
(0, -90, 0)
The cube is translated
(200, 0, 0)
so it can be seen from the default camera
Pawn_Pole#
The pole is a single cylinder
Enable physics on the cylinder.
You can modify Linear Damping and Angular Damping properties to make the pole easier to balance.
You should now be able to play the game