Actors creation from multiple meshes
Two types of actors (pawn) have been created:
- An actor called tank constituted of 5 meshes (tank body, track*2, turret and barrel).
- An actor called turret constituted of 3 meshes (mortar body, turret and barrel).
Note that I didn't created these meshes.
A landscape has been created with Terragen and it heightmap has been exported to Unreal. The landscape is displayed in the image below.
Code architecture and description
In total, 9 classes have been created, the name of the classes as well as their dependencies are shown in the pictures below. All these classes are used by the actor "tank" and all the classes boxed in blue are also used by the actor "turret". The code source of these C++ classes is available here. Note that:
- "Input" is not a C++ class, therefore it has been highlighted in green and the related dependency is shown with a dotted arrow
- Unreal implements a garbage collection scheme whereby UObjects that are no longer referenced or have been explicitly flagged for destruction will be cleaned up at regular intervals. Therefore the following classes (derived from UObjects) does not have a destructor.
Aiming component: The purpose of Aiming Component is to:
- Compute a launch velocity for a projectile to hit a specified point.
- Move barrel and turret toward the direction where player is aiming.
- Monitores the tank firing state. There is 4 different states: "isOutOfAmmo", "isReloading", "isBarrelMoving", "isReady". These states are used to determine the color of player's aiming reticule and are also used to determine when AI and player are allowed to fire.
- Fire a projectile, i.e. spawn and launch an object.
Projectile: The purpose of Projectile class is to:
- Add particle effects on projectile.
- Enable/disable particle effects, emit a radial force and apply damages when projectile hit physics objects.
- Destroy projectile after it hits a physic object.
- Apply damages when it hits actors
Barrel: The purpose of Barrel class is to provide a procedure allowing to rotate barrel (pitch axis).
Turret: The purpose of Turret class is to provide a procedure allowing to rotate turret (yaw axis).
Player Controller: The purpose of Player Controller class is to:
- Convert current player's aiming reticule position to World Space 3D direction.
- Trace a ray from player's aiming reticule against the world using a specific channel and return the first blocking hit (current target).
- Execute every frames the procedure from the Aiming Component allowing to move barrel and turret toward the current target.
AI Controller: The purpose of AI Controller class is to:
- Makes tanks controlled by AI go toward player.
- Execute every frames the procedure from the Aiming Component allowing to move barrel and turret toward player's location.
- Fire a projectile toward player's location.
Tank: The purpose of Tank class is to:
- Reduce tank health when tank is hit by a projectile.
- Monitor the tank health state. There is 4 different states: "dead", "low", "half", "high". These states are used to determine tank's health bar color.
- Send a notification to the "Player Controller" class when player's tank has no more health.
Movement Component: The purpose of Movement Component class is to allow AI and player to move their respective tank through a Fly-by-wire system.
Track: The purpose of Track Class is to provide a procedure allowing to apply a force on tank's tracks.