Help with custom Melee Weapon

Hello friends. I am a beginner in Unreal Script, still learning. I am trying to recreate (or make something similar) to Gears of War Chainsaw Executions in UDK. I am beginning with the first step which is the player play the chainsaw attack anim. The second step is getting the enemy bot to play the chainsaw death animation at the same moment the player pawn plays the attack animation (synchronization). Then the last step is to have a camera animation to play to change from behindview to showing (close) both the player pawn and enemy.

So for the first step, I have followed this awesome tutorial:
mavrikgames.com/tutorials/melee-weapons/melee-weapon-tutorial-part-1

However, as I am extending the UT Base Classes, I have done something a bit different from the above tutorial, and I have created a normal pickup weapon to use it as a melee weapon. In fact, is not a real melee, is an instant hit weapon that has a very small range and no projectile, so is a kind of fake melee (I am doing something very basic).

The point is that I want that whenever the player presses the fire button, then the pawn (player mesh) will play a custom attack animation.

Here is the Animation Tree I created, and there is the PlayCustomAnimation node:


Everything is working almost perfectly, however, the problem is that I don`t know why and how that only the default UDK Animations work, play. If i setup in my code the name of any custom animation I created and imported inside the AnimationSet, it does not play.

However, the animation works perfectly inside UDK, I used the “Import FBX Animation” inside the Skeleton Mesh Preview, the animation imports and plays perfectly.

Here are the animations playing inside UDK:

However, whenever I add my custom animation name in the weapon code to play this animation, it does not work. However, whenever I change the animation to anyone of the UDK animations (Taunt_Victory, i.e), the code works perfectly, the animation plays whenever I press the fire button. But whenever I point to anyone of my custom animations, the pawn just freezes all his animations. It seems like there is another class on which I need to mention the name of my custom animations, because it seems that UDK is not finding my custom animations.

I am using the default UT3_Male Template 3dsmax biped and skeleton (70 Bones) to create my animations.

This is my pawn code. In the pawn code there is a function to find the animation node:

ChainsawAnim = AnimNodePlayCustomAnim(SkelComp.FindAnimNode(‘ChainsawAnim’));


//this pawn class is just for setting up a basic third person view
//the default player mesh (CharClassInfo) is defined in UTPlayerReplicationInfo

class UDKUltimatePawn extends UTPawn;

//this variable will store the animation node chainsaw attack
var AnimNodePlayCustomAnim ChainsawAnim;

//this function will find the animation node and store this to another variable
simulated event PostInitAnimTree(SkeletalMeshComponent SkelComp)
{
	super.PostInitAnimTree(SkelComp);

	if (SkelComp == Mesh)
	{
		ChainsawAnim = AnimNodePlayCustomAnim(SkelComp.FindAnimNode('ChainsawAnim'));
	}
}

//override to make player mesh visible by default
simulated event BecomeViewTarget( PlayerController PC )
{
   local UTPlayerController UTPC;

   Super.BecomeViewTarget(PC);

   if (LocalPlayer(PC.Player) != None)
   {
      UTPC = UTPlayerController(PC);
      if (UTPC != None)
      {
         //set player controller to behind view and make mesh visible
         UTPC.SetBehindView(true);
         SetMeshVisibility(UTPC.bBehindView);
      }
   }
}

simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
{
   local vector CamStart, HitLocation, HitNormal, CamDirX, CamDirY, CamDirZ, CurrentCamOffset;
   local float DesiredCameraZOffset;

   CamStart = Location;
   CurrentCamOffset = CamOffset;

   DesiredCameraZOffset = (Health > 0) ? 1.2 * GetCollisionHeight() + Mesh.Translation.Z : 0.f;
   CameraZOffset = (fDeltaTime < 0.2) ? DesiredCameraZOffset * 5 * fDeltaTime + (1 - 5*fDeltaTime) * CameraZOffset : DesiredCameraZOffset;
   
   if ( Health <= 0 )
   {
      CurrentCamOffset = vect(0,0,0);
      CurrentCamOffset.X = GetCollisionRadius();
   }

   CamStart.Z += CameraZOffset;
   GetAxes(out_CamRot, CamDirX, CamDirY, CamDirZ);
   CamDirX *= CurrentCameraScale;

   if ( (Health <= 0) || bFeigningDeath )
   {
      // adjust camera position to make sure it's not clipping into world
      // @todo fixmesteve.  Note that you can still get clipping if FindSpot fails (happens rarely)
      FindSpot(GetCollisionExtent(),CamStart);
   }
   if (CurrentCameraScale < CameraScale)
   {
      CurrentCameraScale = FMin(CameraScale, CurrentCameraScale + 5 * FMax(CameraScale - CurrentCameraScale, 0.3)*fDeltaTime);
   }
   else if (CurrentCameraScale > CameraScale)
   {
      CurrentCameraScale = FMax(CameraScale, CurrentCameraScale - 5 * FMax(CameraScale - CurrentCameraScale, 0.3)*fDeltaTime);
   }

   if (CamDirX.Z > GetCollisionHeight())
   {
      CamDirX *= square(cos(out_CamRot.Pitch * 0.0000958738)); // 0.0000958738 = 2*PI/65536
   }

   out_CamLoc = CamStart - CamDirX*CurrentCamOffset.X + CurrentCamOffset.Y*CamDirY + CurrentCamOffset.Z*CamDirZ;

   if (Trace(HitLocation, HitNormal, out_CamLoc, CamStart, false, vect(12,12,12)) != None)
   {
      out_CamLoc = HitLocation;
   }

   return true;
}   

defaultproperties
{

  Begin Object Name=WPawnSkeletalMeshComponent
    AnimTreeTemplate=AnimTree'UDKUltimate_Test.AnimTree.AnimTreeTutorial'
	AnimSets(0)=AnimSet'UDKUltimate_Test.AnimTree.AnimSet_Test'
  End Object
  
Health=250
HealthMax=250

	bPhysRigidBodyOutOfWorldCheck=TRUE
	bRunPhysicsWithNoController=true

	LeftFootControlName=LeftFootControl
	RightFootControlName=RightFootControl
	bEnableFootPlacement=true
	MaxFootPlacementDistSquared=56250000.0 // 7500 squared	
}

This is my Weapon Code. In the weapon code there is a code for “injecting” the custom animation on the empty animation node sequence that is connected to the animnodeplaycustom animation:

UDKUltimatePawn(Owner).ChainsawAnim.PlayCustomAnim(‘Chainsaw_Attack’, 1.0);


class UTWeap_GOWChainsaw extends UTWeapon;

//this variable will store the chainsaw animation name
var() const name ChainsawAnimationName;

simulated function FireAmmunition()
{

	if (HasAmmo(CurrentFireMode))
	{
        
		//this function will play the custom animation once the player presses the fire button, i.e FireAmmunition
		UDKUltimatePawn(Owner).ChainsawAnim.PlayCustomAnim('Chainsaw_Attack', 1.0);
		PlayWeaponAnimation(ChainsawAnimationName, GetFireInterval(CurrentFireMode));
		super.FireAmmunition();
	}
}

defaultproperties
{
    Begin Object class=AnimNodeSequence Name=MeshSequenceA
        bCauseActorAnimEnd=true
    End Object
	
    Begin Object Name=PickupMesh
        SkeletalMesh=SkeletalMesh'WP_GOW.Mesh.WP_GOWRifleAssalto_P3'
        Scale=0.9000000
    End Object

    PivotTranslation=(Y=0.0)
	
	bInstantHit=true;	
    WeaponFireTypes(0)=EWFT_InstantHit
    InstantHitDamage(0)=30	
    WeaponRange=50	

	//ammo fire speed functions///////////////////////////////
	FireInterval(0)=0.15
	//ammo fire speed functions///////////////////////////////
	
	//ammo properties
    MaxAmmoCount=1000
    AmmoCount=1000
   
	//sounds
    WeaponEquipSnd=SoundCue'WP_GOW.Sounds.CogRifleRaise_Cue'
    WeaponPutDownSnd=SoundCue'WP_GOW.Sounds.CogRifleLower_Cue'
    //WeaponFireSnd(0)=SoundCue'WP_GOW.Sounds.CogARifleFire08_Cue'
    PickupSound=SoundCue'WP_GOW.Sounds.CogRifleRaise_Cue'

    //CrosshairImage=Copy texture from Content Browser
    CrossHairCoordinates=(U=0,V=0,UL=0,VL=0)

    //<DO NOT MODIFY>
    Mesh=FirstPersonMesh
    DroppedPickupMesh=PickupMesh
    PickupFactoryMesh=PickupMesh
    AttachmentClass=Class'UTAttachment_GOWChainsaw'
	
}

Any help?

Cheers and sorry for the long post.

When your weapon’s at Firing

UDKUltimatePawn(Owner).PlayAnAnim();



In your UDKUltimatePawn:

simulated function PlayAnAnim()
{
	if( TopHalfAnimSlot != None )
	TopHalfAnimSlot.PlayCustomAnim('TheNameOfTheAnimToPlay', 0.7, 0.3, 0.3, false, true);
}


This is how my Tree’s setup
Imgur

var() const name ChainsawAnimationName;

PlayWeaponAnimation(ChainsawAnimationName, GetFireInterval(CurrentFireMode));

Where do you set the value for that variable (ChainsawAnimationName) ?
It seems to be empty.

Hello friends,

Thanks for the tips. I solved the problem, it made me feel so stupid :smiley:

The problem is that UDK was not finding my custom animations to play them, because my pawn was configured to use the default UDK Animation Set for characters, and I was importing the animations on another animation set. So I simply imported the animations on the default UDK Animation Set for characters, and now it is working.

At least, the first step I have done, now I need the second step which is to play a custom animation on the enemy once attacked by this chainsaw.

Cheers…


if(damageType == class'utak47_dmgtype')
	{
               FullBodyAnimSlot.SetActorAnimEndNotification(true);
               FullBodyAnimSlot.PlayCustomAnim('headshot', 1.0, 0.05, 0.05, true, false);
        }


somewhere in your takedamage function for the enemy pawn.

WOW MAN!!! THANKS!!! HOW I DID NOT THINK ABOUT THAT!!! I WILL TRY THAT SOON AND POST THE RESULTS.

I am almost sure this will work because as I am extending UT Weapon Classes, so for each weapon I created a custom damage type class, so it will work indeed.

**I trully love the Unreal Engine Comunity. The people here are so willing to help. I have learned a lot about Unreal Scripting just by browsing this forum.
**
Thanks for all

Hello my friends!!!

I am very very very happy!!!

I was able to reproduce the infamous GOW Chainsaw Execution in UDK!!!

Here is what I got so far:

I know it is far away from perfect, however, for a beginner in Unreal Scripting, I think I have done a good job :smiley:

But I need the help of this great comunity to polish this effect more.

Continuing my previous posts on this thread, I correctly imported the Chainsaw animations (Attack and Death) to the animation set, and created the playcustomanim nodes in the Animtree (I edited the default UDK AnimSet and AnimTree).

So the basic logic of this effect is that there is a weapon (chainsaw) which is not trully melee, is an instant hit gun with a very close fire range, giving the impression that it is melee (I just wanted something fast to try this effect), and whenever the player (Pawn) shoots the weapon, it plays a custom animation on the Pawn (Chainsaw Attack Anim).

About the chainsaw sound, I got the original sounds from GOW, however, to make things simple, I just edited the sound, got the chainsaw engine begin sound, the chainsaw engine loop sound, the chainsaw engine end sound and edited them using Adobe Audition to make them match exactly the same timing of the animation. I just used this as the weapon fire sound, however I added a fire interval of almost 4 seconds which is the same duration of the attack animation, to avoid that the sounds play before the animation.

About the camera animation, it was the easiest part!!! I trully had no idea how to make the camera animation, however, it was just using the code PlayCameraAnim inside the enemy pawn take damage event.

The camera animation itself was done in a new matinee sequence. I added Marcus Fenix Skeletal Mesh and Locust Skeletal Mesh, each one on front of other, and on marcus I played (loop) the attack animation, and on the locust I played (loop) the death animation. I added a new camera actor, and positioned it as most close as the default UDK BehindView Camera. Then I just made a simple translation and rotation animation on the camera, simulating the Gears of War Chainsaw Camera. Then after the animation finished, I right clicked on the camera track on matinee editor and select export to camera anim, so then I saved this new camera anim and called it on the Locust Pawn code:


The way to make the pawn detect it was hit by the chainsaw weapon (to activate the death animation and camera animation) is to use this litle piece of code which 661gaz told me: if(damageType == class’UTDmgType_GOWChainsaw’). So long as I have extended the default UTWeapn, so because this each weapon I created has its own damage class, so this worked perfectly.

However, I need your help guys to polish this effect more. This is the LocustChainsaw Class:




//this pawn class is for setting up a basic NPC (enemies) system
//UTFamilyInfo_GOW_Locust
//I called it LocustChainsaw because this classes is especially designed to receive the chainsaw execution animation (like Gears of War)

class LocustChainsaw extends UTPawn

  placeable;

var SkeletalMesh defaultMesh;
var MaterialInterface defaultMaterial0;
var AnimTree defaultAnimTree;
var array<AnimSet> defaultAnimSet;
var AnimNodeSequence defaultAnimSeq;
var PhysicsAsset defaultPhysicsAsset;

//add custom taunt and voice class to pawn
var class<UTVoice> VoiceClass;

//this variable will store the camera animation name
var CameraAnim MyCameraAnim;

static function class<UTVoice> GetVoiceClass()
{
	return Default.VoiceClass;
}

//override to do nothing
simulated function SetCharacterClassFromInfo(class<UTFamilyInfo> Info)
{
  Mesh.SetSkeletalMesh(defaultMesh);
  Mesh.SetMaterial(0,defaultMaterial0);
  Mesh.SetPhysicsAsset(defaultPhysicsAsset);
  Mesh.AnimSets=defaultAnimSet;
  Mesh.SetAnimTreeTemplate(defaultAnimTree);
}

simulated event PostBeginPlay()
{
  Super.PostBeginPlay();
}

//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)
{
	
	local int OldHealth;
	
	//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 chainsaw weapon
	//if yes, then it will play the Chainsaw Death Animation
	if (DamageType == class'UTDmgType_GOWChainsaw')
	{

	//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)
    {
      UTPlayerController(localplayer).PlayCameraAnim(MyCameraAnim,,,,,false);
    }	
	//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
	
	   //this statement will play the chainsaw death animation on the enemy pawn
       FullBodyAnimSlot.SetActorAnimEndNotification(true);
       FullBodyAnimSlot.PlayCustomAnim('Chainsaw_Anim_Death_Final', 1.0, 0.05, 0.05, true, false);
	}
	
	// Attached Bio glob instigator always gets kill credit
	if (AttachedProj != None && !AttachedProj.bDeleteMe && AttachedProj.InstigatorController != None)
	{
		EventInstigator = AttachedProj.InstigatorController;
	}

	// reduce rocket jumping
	if (EventInstigator == Controller)
	{
		momentum *= 0.6;
	}

	// accumulate damage taken in a single tick
	if ( AccumulationTime != WorldInfo.TimeSeconds )
	{
		AccumulateDamage = 0;
		AccumulationTime = WorldInfo.TimeSeconds;
	}
    OldHealth = Health;
	AccumulateDamage += Damage;
	Super.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);
	AccumulateDamage = AccumulateDamage + OldHealth - Health - Damage;

}

defaultproperties 
{
  defaultMesh=SkeletalMesh'UT3_Model_Locust.UT3_Model_Locust'
  defaultAnimTree=AnimTree'CH_AnimHuman_Tree.AT_CH_Human'
  defaultAnimSet(0)=AnimSet'CH_AnimHuman.Anims.K_AnimHuman_BaseMale'
  defaultPhysicsAsset=PhysicsAsset'CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_Physics'
  
  Begin Object Name=WPawnSkeletalMeshComponent
    AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_Human'
  End Object
  
  Drawscale=1.075 

    CurrCharClassInfo=class'UTGame.UTFamilyInfo_GOW_Locust'
    SoundGroupClass=class'UTGame.UTPawnSoundGroup_Locust'
    //add custom taunt and voice class to pawn
    VoiceClass=class'UTGame.UTVoice_Locust'

Health=350
HealthMax=350


	bPhysRigidBodyOutOfWorldCheck=TRUE
	bRunPhysicsWithNoController=true

	LeftFootControlName=LeftFootControl
	RightFootControlName=RightFootControl
	bEnableFootPlacement=true
	MaxFootPlacementDistSquared=56250000.0 // 7500 squared

//here we inform the camera animation name
MyCameraAnim=CameraAnim'GOW_Cameras.ChainsawCam'

}



1- I need first of all that the chainsaw death animation plays on the enemy (locustchainsaw) after 2 seconds of the take damage even occurs, because the chainsaw attack animation takes almost 2 seconds from the beginning untill it “touches” the enemy body. You can see on the video that the locust plays its death animation almost 1 second before being “hit” by the chainsaw.

2- I want that after 3 seconds from the enemy being hit (take damage event), the enemy dies (ragdoll), because 3 seconds is the total time of the chainsaw attack animation. I tried to add self.Destroy(), however the enemy simple dissapears. And I still did not learn how to add a kind of timer in Unreal Scripting.

3- I need that both the player and the enemy become immobile, no movement as soon as the execution sequence begins. Because on this test I made, if I move the player, he will move away from the enemy whilst the attack animation will be playing so “breaking” the animation effect.

4- Last, but not least, I need to make a kind of condition, a master condition that will let the execution effect play only if this condition is met. In example, that both the player and the enemy are close to each other and facing each other, one looking at other (i.e, not aproaching from behind)

Please guys, help me!

Cheers.




event TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
{

local float enemyDist;

enemyDist = VSize( Location - EventInstigator.pawn.Location );


     if(enemydist <= 1001 && EventInstigator == boltonspc)
	{

	if(damageType == class'UTDmgType_arrow')
	{
               groundspeed = 0;
               EventInstigator.groundspeed = 0;
               SetTimer(1.0f,false,nameof(returntonormalspeed));
               EventInstigator.SetTimer(1.0f,false,nameof(returntonormalspeed));

        }
        }

simulated function returntonormalspeed()
{
              groundspeed = ???; 
}



im not sure how to check if they are facing each other,ive not mastered that yet.

for number 2 use suicide();

instead of self.destroy();

661Gaz pretty explained it, so this is supplemental - several ways of looking at the same thing may help out.

My code has different reactions to different weapons. The code is for my civilians - 1 hit and they go thru dying sequences according to what hit them. There are timers in use as you can see, even as 661gaz above has timers.



event TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
{
	if((damageType == class'DamageGlock')|| (damageType == class'DamageShotgun')
	||(damageType == class'DamageHeadshot')||(damageType == class'DamageKnife')
	||(damageType == class'DamageRocket') ||(damageType == class'DamageBB'))
        	{
			bWounded = true;
			DieFromBullets();
			TheBloodEffects();
			UpdateDamageMaterial();
	super.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);
		}
		else if ((damageType == class'DamageBurning') ||(damageType == class'DamageNapalm'))
		{
			bWoundedFire = true;
			SetTimer(0.5, false, nameof(TheBurnEffects));

	super.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);

		}
		else if((damageType == class'DamageStun') && KCC !=none)
		{
			bStunned=true;
			SetTimer(0.1, false, nameof(TheShockAnim));
		}
		else if ((damageType == class'DamageHEAL'))
		{
			return;
		}
		else
		{
			super.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);
}}


below is the way the pawn dies if hit buy the InstantHit weapons in the TakeDam list



/////////Only the effects played by the pawn after it's hit
simulated function TheBloodEffects()
{
	local vector BurnsLoc;

	if(bIsFem && !bIsMale && Health > 0)
		{
			PlaySound(CivFemScream, false, true, true, vect(0,0,0), false);
		}
		else if(bIsMale && !bIsFem)
		{
			PlaySound(CivMaleScream, false, true, true, vect(0,0,0), false);
		}
		else
		{
			return;
		}
			if(bIsMale || bIsFem)
			{
				BloodPSC = Spawn(class'EmitKFZBloodA',,,BurnsLoc);
				Mesh.GetSocketWorldLocationAndRotation(BurnSocketA, BurnsLoc,);
				BloodPSC.SetBase(self, , self.Mesh, BurnSocketA);
				BloodPSC.SetTemplate(ParticleSystem'KFTex6_effects.Particles.BloodFromWound');
			}	
			else
			{
				return;
		}
}


And also from TakeDamage



simulated function DieFromBullets()
{
	if(Health > 0 && FullBodyAnimSlot != None )
	{
         	FullBodyAnimSlot.PlayCustomAnim(ShotWoundedAnims[Rand(3)], 0.8, 0.5, 0.5, TRUE, TRUE);  ///the chosen 'ShotWoundedAnims' is repeated until the pawn dies
	        SetTimer(5.0 + FRand() * 5.0, false, 'Suicide');
	}
}


Move the bot on to the final death. The burn hits end in the same place, Suicide()



/////////Finally and as  says, suicide is the best option

function Suicide()
{
        super.Suicide();
}


Hope it’s of some use.

@Snipe34 and 661gaz:

Hello guys,

THANKS FOR THE HELP!!!

I will try all your tips and then I post here the results.

Cheers.

:smiley:

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.


UDKUltimatePawn(utpawn(Pawn)).FullBodyAnimSlot.PlayCustomAnim('Chainsaw_Anim_Attack_Final', 1.0, 0.05, 0.05, true, false);

if your extending utpawn,try this.

a keep up the good work,youre doing great.

Hello bro, thanks for the tips, however, it did not work, I received the error on compiling: ‘UDKUltimatePawn’ bad command or expression

:frowning:

By the way, do you know how to use the weapon function CanAttack()?

as udkultimatepawn is the player I guess it is the only one in the game,if so then you can do this




var udkultimatepawn theultimateplayer;


function getthehero()
{

local udkultimatepawn theplayer;

foreach WorldInfo.Allpawns(class'udkultimatepawn , theplayer)
        theultimateplayer=theplayer;

}




you then have theultimateplayer as a reference to the pawn to use throughout the script.

don’t know about CanAttack() but I will take a look tomorrow.