- If you shoot at the center of him you will heal him,
- You need to shoot in head to make real damage,
- It will be slow,
- He will use melee damage,
Fix Pick Location Task
Open MainAI_Pawn and create new float variable: ProcentageOfRoute. Default should be 0.7.
Open PickLocation task and change random Min to ProcentageOfRoute. Thanks to that we will have option to change this functionality in other enemies.
Import Golem from Unity - if you don't know how to do that read post about importing Sci-fi pack.
Create new Animation Blueprint from SkelMesh. Add one bool variable: IsNearPlayer. Create new blueprint - Golem_Pawn extending from MainAI_Pawn and add the same variable to it.
Now in Animation Blueprint read out this variable from Golem_Pawn
At this point reading variables from your characters should be easy. If it's not - read earlier posts! Don't be lazy!
Now we need to:
- Start moving Golem to Target,
- When we hit him - play hit animation,
- When he is near player - he need to play attack anims,
You should read this documentation about Animation Montages. So in our Anim Graph create something like this. We are blending from ArmoredGolemSpine1 bone.
Thanks to this we will be able to play our animations from anim montages.
If you right click on your animation you will be able to create Animation Montage from it. Create Animation Montages from Hit1, Hit2 and Hit3. Remember to name your slot like here (it's used in Animation Blueprint)
Create another animation montage from Attack1. Open it. Create two montage sections: Attack1 and Attack2. If you right click on Montages you can create new ones.
Drag your Attack1 animation to Attack1 montage section and do the same with Attack2 animation.
For me the dragging isn't always working so you need to keep trying. You should have something like this when everything will be ready:
So basically this montage is playing 3 animations. What I weren't able to find is to play them with random. It can be done using blueprints but I will leave it now.
Now open your Golem_Pawn and add one bool variable: isDead. Assing your mesh and your animation blueprint to the Pawn, and setup Walking Speed in CharacterMovement component. You should change SpawnManager to spawn Golem_Pawn to be able to change everything.
Create new Begin Play funcion in Golem_Pawn. We need to check where is player to change the isPlayerNear bool and run the attack animation.
And add Point Damage event to run the hit montages.
At this point Golem should walk to Target, play hit animation and attack animation when he is near.
Shooting at Golem and healing/killing him.
Open Golem skel mesh and one socket: Heal (from ArmoredGolemSpine3) and Head (from ArmoredGolemHead).
Now open MainAI_Pawn and we would need to change Crit Damage hardcoded values to be editable. So create new float variables: HowNearHeart (10), CritMultiply (2) and connect them.
Still in MainAI_Pawn point damage. Create custom Event: WasCrit and connect it where you know that there will be critical damage.
Thanks to that we can now implement some custom functionality when crit.
Open Golem_Pawn and attach Hearth to Head socket in begin play event.
So the head will move now with the socket.
Go to the Event Graph and add new WasCrit event - connect your hit animations to it like here:
Now let's move to healing him. Make sure your Heal socket is in center of his "reactor".
Go to Golem_Pawn and add new vector variable HitLocation which you will set in Take Point Damage. If we hit near the socket we won't be dealing any damage, we will heal the Golem for 10%.
Let's move to killing the Golem. Later in your Point Damage we will randomly run animation or ragdoll.
Make sure you have your ragdoll setup properly. I needed to use SetWalkSpeed because weren't able to StopMovement while it's moving from AI Tree. It's a hack, and what you should do is to prepare your AI Tree so it will be able to stop when you want.
Basically in games that use melee attack you should do the traces from your weapon and check if collide with something. In our example it would be much more simpler.
We will use Custom Anim Notify to let the blueprint know that there was player hit. We have created custom anim notify earlier so you should read older posts.
Create new blueprint extending from AnimNofity. Name it EnemyAttack. Open MainAI_Pawn and create custom event, name it Attack.
Now in AnimNofity Enemy attack let's call Attack in MainAI_Pawn.
Now you just need to add EnemyAttack notify in your animations. I've added to AttackAnimMontage.
We will use this Nofity later after we add player health. For now it's done.
Footsteps: here you can find some sounds I've mixed them with metal sounds. Just try to do the sound cue by yourself, and create SoundNotify in your walk animation to trigger the sound.
Here you can find some sounds that can fit:
Hit sound: this should be helpful:
Now in your Golem_Pawn blueprint go to WasCrit function and play your soundcue.
At this point you should be able to find the sounds you like, create sound cues and play them in animation or blueprint.
In next post I will add another enemy.