Today I implemented a simple enemy mechanic in my Kitty Maze Unreal project.
First, I found an enemy asset in the Unreal Marketplace and imported it.
Then, I set up the blueprint for this enemy and implemented the poison effect. When the player collides with the enemy, the player’s max movement speed decreases and the “poisoned” status effect shows on screen for five seconds.
PoisonPlayer() and RemoveStatusEffect()
void AKittyMazeGameMode::PoisonPlayer()
{
if (!_hasStatusEffect)
{
_hasStatusEffect = true;
// Show poison UI
_hud->ShowStatusEffect(true);
// Slow down the player
if (_character != nullptr)
{
_character->SetSpeedModifier(StatusEffectSlowdownModifer);
}
// Start the status effect timer
GetWorldTimerManager().SetTimer(_statusEffectTimerHandle, this, &AKittyMazeGameMode::RemoveStatusEffect, StatusEffectTimerAmount, false, StatusEffectTimerAmount);
}
}
void AKittyMazeGameMode::RemoveStatusEffect()
{
GetWorldTimerManager().ClearTimer(_statusEffectTimerHandle);
_hud->ShowStatusEffect(false);
if (_character != nullptr)
{
_character->SetSpeedModifier(1);
}
_hasStatusEffect = false;
}
Next, I am going to set up a system to make the enemy follow a path. I estimate this will take about two work days.
Try not to get poisoned! And remember that bad times are just times that are bad.
