Hello guys
I am trying to polish my “Stealth Kill” script, which I used here:
It basically plays the kill and death animation synchronized on the player (kill anim) and on the enemy (death anim), then it kills the enemy.
On this video, this system did not work like I want and like it is mean to work.
On that chainsaw execution, this custom gun (UTWeap_Chainsaw) plays the kill animation on the player mesh as soon as the player shoots the weapon inside the simulated function FireAmmunition()
UTPawn(Owner).FullBodyAnimSlot.SetActorAnimEndNotification(true);
UTPawn(Owner).FullBodyAnimSlot.PlayCustomAnim(‘Chainsaw_Anim_Attack_Final’, 1.30);
PlaySound(SoundCue’A_VoicePack_GEARSofWAR_Marcus.****You_02_Cue’, false, true, true, vect(0,0,0), false);
super.FireAmmunition();
And the enemy pawn plays the death animation as soon as hit by the gun (event take damage)
But this is not correct, the right thing to do is to just play the animation whenever the player hits the enemy with the gun.
Also, I have many variations of synchronized animations (death and kill) that I want to use. I found an easy way to use it is by having many enemy pawn classes, each one with a unique pair of animations (death and kill), like enemy_death_kill_A, enemy_death_kill_B, but for this to work I need that the enemy pawn triggers the animation on the player pawn, which I DON’T KNOW how to do it.
I tried this, however i received the error message “Cast from Controller to UTPawn will always fail”.
Any help?
//all the animation will be played inside the TakeDamage Event
event TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
{
//this variables will be used to play the camera animation on the player controller
local Playercontroller localplayer;
//this statement will check if the enemy was attacked by the knife weapon
//if yes, then it will play the knife Death Animation
if (DamageType == class’UTWeap_Knife’)
{
//this is the function to play the camera animation
//we placed this function here because it must only play the animation if the enemy is hit by the knife
ForEach LocalPlayerControllers(class’PlayerController’, localPlayer)
{
UTPlayerController(localplayer).PlayCameraAnim(‘MyCameraAnim’,false);
UTPlayerController(localplayer).ClientSpawnCameraLensEffect(class’knifeCameraBlood’);
}
//this statement will play the knife death animation on the enemy pawn
FullBodyAnimSlot.SetActorAnimEndNotification(true);
FullBodyAnimSlot.PlayCustomAnim(‘knife_kill_1_enemy’, 1, 0.25, 0.25);
//this statement will play the knife kill animation on the player pawn
//THIS IS NOT WORKING
**UTPawn(EventInstigator).FullBodyAnimSlot.SetActorAnimEndNotification(true);
UTPawn(EventInstigator).FullBodyAnimSlot.PlayCustomAnim(‘knife_kill_1_player’, 1, 0.25, 0.25); **
//this will freeze the enemy pawn
Super.DetachFromController();
Super.StopFiring();
GroundSpeed=0;
//this is a timer that will call for the function deathsequence and come back to normal
setTimer(2.0, false, ‘KillEnemy’);
}
}