Hello guys!!!
Finally I finished the GOW Chainsaw Execution inside UDK:
https://www.youtube.com/watch?v=V3BqY_-v1QE
Is not perfect, however for a beginner on unreal Scripting, I think the results are very good and I even created a basic and fast blood on screen effect.
So now for the tech.
Thanks @Snipe34 and @anonymous_user_3aed06e4, your tips helped me a lot, especially the SetTimer function.
So the way to make the pawn “freeze” was not only groundspeed = 0, because it only makes him stop moving, but does not avoid him of turning and worse, shooting.
So i added these other native pawn functions (too much study on UDN untill find those):
Super.DetachFromController();
Super.StopFiring();
GroundSpeed=0;
Then I have setup a timer to call the suicide() function:
SetTimer(2.0,false,nameof(KillLocust));
simulated function KillLocust()
{
Super.Suicide();
}
It was very easy.
Now the problem was to freeze the player. Unfortunately EventInstigator.groundspeed = 0 did not work, by the way, any property I used with EventInstigator did not work.
So after too much study and search, I found these player controller functions and I used:
UTPlayerController(localplayer).IgnoreLookInput(true);
UTPlayerController(localplayer).IgnoreMoveInput(true);
UTPlayerController(localplayer).ConsoleCommand("God");
Then I setup another timer to come back to normal:
SetTimer(3.0,false,nameof(ReturnNormal));
//this function will make the player comeback to movement
simulated function ReturnNormal()
{
local Playercontroller localplayer;
//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 chainsaw
ForEach LocalPlayerControllers(class'PlayerController', localPlayer)
{
//this will freeze the player movement and other cool effects like slo-mo and invencibility.
//I placed here because console command only works when accessed by player controller
UTPlayerController(localplayer).IgnoreLookInput(false);
UTPlayerController(localplayer).IgnoreMoveInput(false);
UTPlayerController(localplayer).ConsoleCommand("God");
}
}
So the effect is there, not perfect, however, for myself it was a GREAT ACHIEVEMENT.
About the camera, it`s a bit jerky and glitchi because I have setup a very primitive 3rd person camera in kismet (target view camera actor), because the 3rd person camera I am using on my custom gametype is based on the BehindView command (UDK | CameraTechnicalGuide Third Person Camera), and by my tests, it seems that the behindview DOES NOT ACCEPT camera animations, so because that I wanted a very basic 3rd person view just to test the chainsaw execution.
Now I have only 2 more doubts left:
1- I want that the player pawn only plays the Attack Animation if close to a certain distance from the enemy. In this code, what plays the animation is the weapon chainsaw, whenever the player presses the fire button:
simulated function FireAmmunition()
{
if (HasAmmo(CurrentFireMode))
{
//this function will play the custom animation once the player presses the fire button, i.e FireAmmunition
//the animation node was setup on the UDKUltimate Pawn, because the animation will be played on the player pawn actor
//and not on the weapon
UDKUltimatePawn(Owner).FullBodyAnimSlot.SetActorAnimEndNotification(true);
UDKUltimatePawn(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();
}
}
I have seen that there is a weapon function called CanAttack which checks if the weapon is inside its range to damage the enemy, and thats exactly what I need, that the attack animation only plays if the player is close to the enemy. The problem is that I don`t know the correct syntax of this function.
I tried the following, but received compile errors:
simulated function FireAmmunition()
{
if (HasAmmo(CurrentFireMode))
{
if (CanAttack(Locust))
{
//this function will play the custom animation once the player presses the fire button, i.e FireAmmunition
//the animation node was setup on the UDKUltimate Pawn, because the animation will be played on the player pawn actor
//and not on the weapon
UDKUltimatePawn(Owner).FullBodyAnimSlot.SetActorAnimEndNotification(true);
UDKUltimatePawn(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();
}
}
}
Any tips?
2- I want to know how can I have the enemy pawn trigger an animation on the player pawn. Like I said in the above, the player pawn attack animation is triggered by the weapon on the event fire, and the enemy pawn death animation is triggered by the enemy pawn itself inside the takedamage event.
I tried the following code on the enemy pawn to trigger the attack animation on the player pawn:
//this statement will play the chainsaw death animation on the enemy pawn
UDKUltimatePawn(Pawn).FullBodyAnimSlot.SetActorAnimEndNotification(true);
UDKUltimatePawn(Pawn).FullBodyAnimSlot.PlayCustomAnim('Chainsaw_Anim_Attack_Final', 1.0, 0.05, 0.05, true, false);
However, it did not work, I received the compile error saying that UDKUltimatePawn is and unknown class. However, UDKUltimatePawn is my custom gametype pawn.
My idea is that if we can have the enemy pawn class to trigger both the animation on itself and on the player, this will open the door to having multiple execution animations. In example, I know we can randomize an array of multiple animations sequences, however, it will be hard to randomize the animations and have both kill and death matching. In example, we could have one enemy class that will trigger the Death_A_Attack and Death_A_Death, other enemy class will trigger the Death_B_Attack and Death_B_death, and so on.
Please any tips will be of immense help.