Game Modules 4 Integration
Last updated
Last updated
Game Modules 4 and Projectile Factory work great together, and can be connected with just a few steps.
This document will walk through the setup required to get a character who uses Game Modules 4 for stats, conditions, and other game data to spawn projectiles that can cause damage to other Game Module Actors in the scene.
This guide assumes you have imported the latest Game Modules 4 and Projectile Factory packages from the Package Manager.
GameModules4Integration.unitypackage
filesFind GameModules4Integration.unitypackage
and import it into your project. It will be located at Assets/Magic Pig Games/Projectile Factory/Game Modules 4 Integration/GameModules4Integration.unitypackage
The IAmGameModulesActor
interface should be added to your "Actor" object -- this is the object which has the data that inherits from GameModulesActor
.
The interface has a CustomAction()
method defined. To take advantage of this, you'll need to create a custom interface that has custom methods. For this, we will require a TakeDamage()
method.
You'll need to update the signature to fit your project, allowing you to pass in the required data needed to propertly compute damage.
This interface is custom for your project. It can have additional methods and properties as needed. You can call any defined methods in the same way shown later in this setup process, using the CustomAction()
method defined in IAmGameModulesActor
.
Your actor class should implement IAmGameModulesActor
. In the snippet below, you can see my AttackableObject
implements IAmGameModulesActor
.
The Actor
class (data
, below), is a GameModulesActor
, so the required properties all pull from there.
If you don't have either of these objects available, you can create them. Right click in your project and select Create/ProjectileFactory/...
and then find either Spawn Behavior Mod
or Collision Behavior
and then the correct object, as named below.
This will create the object in your project, and the Projectile window will find them. No additional setup is required for either of these objects.
The "Connect Game Modules" Spawn Behavior Modification is used to connect the Projectile with another compnent we'll add later.
The "Game Modules Connection Hit" Collision Behavior calls the proper method on the connection component (the one we'll add later), on collision. This is what actually starts the "Take Damage" process.
ProjectileGameModulesConnection.cs
Find and load ProjectileGameModulesConnection
in your script editor. There are sections we need to update to work with the Interface
you created earlier.
The two sections we are updating are in the DoDamage()
method, and have comments that start with "SEE THE DOCUMENTATION..." along with Debug.LogWarning()
messages.
➡️ First, remove the Debug.LogWarning() messages, and the "SEE THE DOCUMENTATION..." comments.
➡️ Uncomment the attackedActor lines as well.
CustomAction()
action callThe CustomAction()
method will call another method you have defined on your custom Interface, including the TakeDamage()
method withe the signature required for your project.
In the example below, my "TakeDamage" method passes in the damage and the attacking actor.
If your TakeDamage()
method is properly connected to actually remove health and do all the other fun stuff that happens in your game, you should be all set, and can test it out.