Wednesday, 28 November 2018

Unreal: Enemy Health

Bullet Collision
In Unity, a method of detection is by using tags. This is also available in Unreal, but I decided to use another approach which adds a collision to the bullet and will be detected by our AI.



In the physics menu, we can set the constraints to be OverlapOnlyPawn, the pawn being a reference to our Enemy AI. This means we can detect when the bullet hits the AI.

Enemy Collision


In the enemy blueprint file, selecting the mesh brings up the details panel where we can enable 'Generate Overlap Events'.

This is essentially the same process as I would expect to use in Unity with collision detectors. In Unreal objects involved in a collision can be set to respond by blocking, overlapping or ignoring.

Dealing damage to the enemy


By using the Event ActorBeginOverlap we detect when this actor overlaps another - detecting the collision with the bullet in this case. On collision, we use the float - float node to subtract 0.2 / 1 (20%) from the health variable belonging to the enemy AI. Then we check to see if the health variable equals 0, if it does then we destroy the actor using DestroyActor (enemy AI).

This is a very simple way to implement killing enemies, however, the enemy currently vanishes and a death animation would improve the game a huge amount. There are sound effects that the zombie makes which are currently not stopping when the enemy has died and needs to be investigated as this can cause misleading signals to the player. The damage volume that is responsible for dealing damage to the player is not being destroyed either, which is a child actor of the AI which is even more of an issue than the audio.

No comments:

Post a Comment

Unreal: Project Evaluation

Unreal is visually enticing and appears to be extremely user-friendly. In the beginning stages, I found it really nice to use and I was exc...