Thursday, 28 October 2010

Week 7: Continuation of (week 6) Player Melee Scripting on a custom character with custom animations.

         I continued to find and search over the web for the custom character animations but I only got the weapon code from the forums and some video tutorials, but i managed to find some working how to deal it in kismet.


The AnimNodeBlendByPhysics has several functions to animate the whole sequence, I had to try and connect it and see if it works. and here is the script in the pawn class:

var AnimNodeSequence Strike1;
var AnimNodeBlend CombatNode;

simulated event PostInitAnimTree(SkeletalMeshComponent SkelComp)
{
super.PostInitAnimTree(SkelComp);

Strike1 = AnimNodeSequence(SkelComp.FindAnimNode('AtkStrong'));
CombatNode = AnimNodeBlend(SkelComp.FindAnimNode('CombatNode'));
}

exec function PlayStrike()
{
`log("<<<<< play Strong Attack >>>>>>");
Worldinfo.Game.Broadcast(self, "<<< Play Strong Attack >>>");
        CombatNode.SetBlendTarget(1.0f, 0.01f);
Strike1.SetPosition(0.0f, true);
        Strike1.PlayAnim(true, 1.0f, 0.0f);

}


When I use a AnimNodeBlendList for my CombatNode (like in the image.)
I get an error in the log saying Accessed None 'CombatNode'.

Alternatively when I used a AnimNodeBlend instead (which doesn't give me enough room for sequences) I had no errors...but when I type 'playstrike' from the console, The log and broadcast play...but no animation plays.

Then I was asking to myself what am I doing wrong here?

I had referenced the skeletal anims at following:

But sooner i realised its a big mess and it takes very long time to make everything into account. So I finally decided to dig this in the third year for my final project assessment.

Thursday, 21 October 2010

Week 6: Continuation of (week 5) Player Melee animation Scripting (*Weapon Code)

            I couldn't find any good forums or ideas on how to implement on the melee animation script but then I got into UDK forums itself, helped me in some ways but still had lots to do compared to the original work we fit into. I wanted to make a simple melee attack for just a single character, but it had a lot of crashes and bugs over the game engine and I figured that it was no use of embedding this semester with such features so I decided to continue this next year as a part of my final portfolio for my assignment.


            Here are some bits of  I've been working on a melee weapon, a lightsaber to be precise. I can't figure out how to make it play a 'melee animation' in third person. I figured I could make it do the "hoverboardjumpstart" animation, since it looks like a melee attack. I apparently had to animate the player instead of the weapon in order for this to work in third person. Here's the weapon code which I referenced: 





class FFWeap_saber1 extends starwarsweapon;


var rotator pawndir;
var name AttachmentSocket;
var name WeaponAttachmentSocketName;
var SkeletalMeshComponent WeaponMesh;


defaultproperties
{
     AttachFlashLightInterval=1.25  
     OnFlashLightInterval=0.65 //  "WeaponLightSwitch"
     AttachKolInterval=2.35 // 
     ReloadInterval=12.290000 // 
     bHasIronSights=false
     WeaponSlincerOnAnim="SupON" //
     WeaponSlincerOffAnim="SupOFF" //
   //bKollimator = false //
    EmptyReloadInterval=32.200000 // 
    RunStartInterval=0.200000 // 
    RunEndInterval=0.200000 // 


    ClipCount=39999 // 
    RecoilAmount=18 
    AmmoCount=9999 // 
    MaxAmmoCount=999999
WeaponRange=1
    bPrimaryWeapon=True


    PlayerViewOffset=(X=5.0,Y=2.5,Z=-4.5)
    IronSightViewOffset=(X=-0.35,Y=-3.1,Z=-4.15)
    IronSightViewOffset1=(X=2.35,Y=-3.15,Z=-3.3)


    ReloadCameraAnim=CameraAnim'WP_MP5.CameraAnims.C_WP_MP5_ReloadEmptyMotion'
    ReloadEmptyCameraAnim=CameraAnim'WP_MP5.CameraAnims.C_WP_MP5_ReloadMotion'
    ReloadSound=SoundCue''
    ReloadEmptySound=SoundCue''
    FireCameraAnim(0)=CameraAnim''


    InventoryGroup=3
    AttachmentClass=Class'FFAttach_MP5'
    InventoryGroup=2
    AttachmentClass=Class'FSWeaponAttachment'
    AttachmentClass=Class'attach_saber1' 
   
 WeaponFireSnd(0)=SoundCue''
 WeaponPutDownSnd=SoundCue''
 WeaponEquipSnd=SoundCue'Package_1.weaponsound.saberignite1_Cue'
 FlashLightSwitchSnd=SoundCue''


   MuzzleFlashPSCTemplate=ParticleSystem'WP_ShockRifle.Particles.P_WP_ShockRifle_Beam'
   MuzzleFlashLightClass=Class'FF_MP5_MuzzleFlashLight'
   MuzzleFlashDuration=0.5100000


     aimerror=600.000000


// WeaponFireTypes(0)=EWFT_InstantHit
    // WeaponFireTypes(1)=EWFT_None
     FireInterval(0)=1.36190000
ShotCost(0)=1
     Spread(0)=0.060000
    // InstantHitDamage(0)=30.000000
    // InstantHitMomentum(0)=1000.000000
    // InstantHitDamageTypes(0)=Class'FFDmgType_MP5'
// RotChgSpeed=3.0
// ReturnChgSpeed=3.0
    // EquipTime=0.7        
    // PutDownTime=0.5
    // bInstantHit=True


// Begin Object class=AnimNodeSequence Name=hoverboardltjumpstart
// End Object


Begin Object Name=SkeletalMeshComponent0
SkeletalMesh=SkeletalMesh'CodaTest.CodaSwordShape'
    //   AnimSets(0)=AnimSet'CH_AnimHuman.Anims.K_AnimHuman_BaseMale'
// AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_Human'

//Animations=hoverboardltjumpstart
Translation=(Z=1)
Rotation=(Roll=-400)
Scale=0.9
Scale3D=(X=0.340562,Y=1.000000,Z=1.000000)
WeapAnimType=EWAT_Pistol
End Object
Components.Add(SkeletalMeshComponent0)
Mesh=SkeletalMeshComponent0


WeaponFireSnd[0]=SoundCue'Package_1.weaponsound.saberswing1_Cue'
   // WeaponIdleAnims[0] = 'hoverboardjumpstart';

Scale3D=(X=0.340562,Y=1.000000,Z=1.000000)

MuzzleFlashSocket=MF
MuzzleFlashPSCTemplate=WP_ShockRifle.Particles.P_ShockRifle_MF_Alt
MuzzleFlashAltPSCTemplate=WP_ShockRifle.Particles.P_ShockRifle_MF_Alt
MuzzleFlashColor=(R=200,G=120,B=255,A=255)
MuzzleFlashDuration=0.33
MuzzleFlashLightClass=class'UTGame.UTShockMuzzleFlashLight'
CrossHairCoordinates=(U=256,V=0,UL=64,VL=64)
LockerRotation=(Pitch=32768,Roll=16384)


IconCoordinates=(U=728,V=382,UL=162,VL=45)


WeaponColor=(R=160,G=0,B=255,A=255)


bAutoCharge=true
RechargeRate=0.0
FireOffset=(X=12,Y=10,Z=-10)
WeaponProjectiles(0)=class'lightsabershot' // UTProj_LinkPowerPlasma if linked (see GetProjectileClass() )

EffectSockets(0)=MuzzleFlashSocket
EffectSockets(1)=MuzzleFlashSocket

MuzzleFlashSocket=MuzzleFlashSocket
MuzzleFlashPSCTemplate=ParticleSystem'WP_LinkGun.Effects.P_FX_LinkGun_MF_Primary'
MuzzleFlashAltPSCTemplate=ParticleSystem'WP_LinkGun.Effects.P_FX_LinkGun_MF_Beam'
bMuzzleFlashPSCLoops=true
MuzzleFlashLightClass=class'UTGame.UTLinkGunMuzzleFlashLight'
WeapAnimType=EWAT_Pistol
//begin object Name=KollimatorMesh
/// SkeletalMesh=SkeletalMesh'WP_MP5.Mesh.Kollimator_SK'
// scale=1.0
// FOV=55.0
//end object


//KollimatorAttachment=KollimatorMesh


//Begin Object Name=FlashLightComponent 
   //   Begin Object Class=LightFunction Name=MyLightFunction 
   //      SourceMaterial=Material'WP_MP5.Materials.M_FFWeapon_Flashlight_Ring'
   //      Scale=(X=240.000000,Y=240.000000,Z=240.000000)
   //   End Object
  //    InnerConeAngle=22.000000
  //    OuterConeAngle=30.000000
  //    Radius=600.000000
  //    Brightness=1.500000
//      LightColor=(B=230,G=255,R=255,A=0)
 //     Function=MyLightFunction
//    End Object


// FlashLightAttachment=FlashLightComponent


  //  Begin Object Name=PickupMesh 
 //     SkeletalMesh=SkeletalMesh'WP_MP5.Mesh.WP_SK_MP5_3P'
//   Translation=(Z=1)
// Rotation=(Roll=-400)
// Scale=0.9
//    End Object


//    PickupFactoryMesh=PickupMesh
}

Referenced from: http://forums.epicgames.com/

Thursday, 14 October 2010

Week 5: How to export animations using ActorX and Maya & Player Melee animation Scripting

            I tried to look into forums, searched many links and watched video tutorials for to find the character rigging and player animation scripts. I had to make a decision on how to export animations using ActorX and Maya, yet ActorX is another tool set editor plugin for Maya. 
The steps involved in achieving how to export it in step by step is:

Install the Plug-In


  1. Downloaded the ActorX plug-in for Maya and copied it to plug-ins directory.
  2. Launched Maya, then enabled the plug-in (go to Settings->Plug-In Manager) by checking the "loaded" check-box. I Check "auto load" Maya.























 

 

Setting up your scene

The plugin will recognize both regular polygonal, textured geometry as well as skin clusters. The main requirement is that your mesh consists of a single hierarchy, linked together with joints. The exporter doesn't care what methods are used to animate the joints; the entire scene is sampled through the desired frame range, and at each frame the end result is what gets exported.
Be aware of the axes and orientation: typically, in Maya Y is up, X points to the right, Z points towards the viewer out of the screen. On export to a .PSK, the Y coordinate signs are flipped to comply with Unreal's handedness (relative orientation of axes.) In Unreal, the Z axis is up, Y points to the right, and X out of the screen toward the viewer. So you will usually need to adjust the mesh back to the desired orientation using the Mesh properties tab in the Animation browser - expand "Mesh", then expand the Rotation variable, which offers Pitch, Roll and Yaw - these are 16 bit integers, where 65536 equals a full 360 degree rotation.
Multiple materials can be used in the scene. They will end up as multiple material slots in the final mesh, and the order will be arbitrary by default, unless you force it by appending "skinXX" tags to the names of the materials - i.e., if the material names are Body and Head , renaming them to Body__Skin00 and Head__Skin01 will tell the exporter to obey that order when creating the .PSK file. In the Maya exporter, any characters following the double underscore will be cleaned up from the final .PSK. Maya has several levels of named materials and textures; the exporter retrieves the names from the "ShadingEngine" tags - that is, the first tag that comes up in properties when you double click on a shader in the multilister. This not only affects the order of slots for skeletal (and static) meshes, but can be used to influence rendering order as well.
Note that in Maya 5.0, the effect of IK handles on animation may not get exported correctly unless you ensure they have their "Sticky" attribute set.









Export the skeleton and mesh

  1. Loaded a scene containing the actor to export.
  2. Brought up the ActorX dialog by typing "axmain" in the MEL command window at the bottom of Maya.
  3. Filled in the various fields as follows:
    • Output folder: enter the name of the directory where you wish to save the .PSK file. We recommend putting an "Unreal Files" directory under your actor's folder. The browse button is very useful here.
    • Mesh file name: enter the name for the .PSK file. We recommend the name of your actor.
  4. Clicked the "Save mesh/refpose button. I did this with any frame of the animation. It is recommended that the model's reference pose be in a relaxed, spread eagle pose for ease of use.
After saving the mesh/refpose,



Export the animations

There are two steps for exporting animations. First, I loaded the scene containing the animation(s) and "digest" an animation to read it into memory. I Repeated for as many animations as I could like to export this session. Second, I added these new animations to a PSA file and save it back out.

Digest an animation

  1. Loaded the file containing the animation.
  2. Brought up the ActorX dialogue by typing "axmain" in the MEL command window at the bottom of Maya.
  3. Filled in the various fields as follows:
    • Output folder: same as for skeleton/mesh above.
    • Animation file name: The same as the mesh file name (they will have a different extension to help to tell them apart). Entered the name of the existing .PSA file it asks  if you wish to add this animation to that existing .PSA
    • Animation sequence name: this is how the animation will be identified within the .PSA file.
    • Animation range: specified the frames in the current scene that define this animation. (Format is `4-45'; number, hyphen, number)

Add your animations to a .PSA file

Once you have digested one or more animations you are ready to add them to a .PSA file.
  1. Brought up the "axmain" dialog.
  2. Clicked the "animation manager" button to display the animation manager.
  3. I added the animations to an existing .PSA file, click "Load" to load the .PSA file. (assumes that you already provided the name of the animation file in step 3b of the previous section. If not, then use the "Load As..." button)
  4. On the left in the "animations" list I saw the animations that you have just digested. On the right I would see any animations that already exist in the .PSA file. This will be empty if you are creating a new .PSA file.
  5. Select your new animations and click "-->" to add your animations to the output package.
  6. Click "Save" to save the .PSA file back out. (assumes you already provided the name of the animation file previously)




Additional MEL commands

axwritesequence: A quicksave command for skeletal animations which writes out the currently loaded scene, with its entire animation range as a single sequence with the sequence- and .PSA filename identical to the Maya source art filename.
axprocesssequence: always saves the .psa to the source art folder, and otherwise works just like "axwritesequence".
axwriteposes: Similar to axwritesequence, but dumps each frame in a single-pose PSA file, and attaches the frame number to each file and internal sequence name. Note: Some versions of the editor's animationbrowser importer don't properly handle importing/displaying single frame sequences.
See also the new persistent "no popup confirmations" checkbox in thec"axoptions" window to make these commands effectively interaction-free.
Since Version 2.24, there's the axexecute command line with options to perform both skin- and animation export entirely from the MEL command line with the following, mostly self-explanatory options, which can be combined in random order:
axexecute [options and switches]
  • -path "[destination path]"
  • -skinfile [.psk skin file name]
  • -autotri
  • -unsmooth
The skin file will be saved immediately, to the destination path as specified on the command line (or if not present, the command line as last specified in the interactive interface.) Because of MEL command restrictions the path can only contain forward- instead of backward- slashes, and should be in quotes to prevent confusing the MEL command line parser with special characters.

  • -sequence [sequence name]
  • -range [startframe] [endframe]
  • -rate [rate]
Sequences will be digested with the optional frame range parameters and rate. If specified, the range must be two valid whole frame numbers and cannot contain any dashes, dots or commas. The default range is the entire scene's time range and the default rate the one as set in the interactive interface. The digested animation sequence data is stored in memory just like they would with the interactive interface. Only when the -saveanim switch is part of the command line, will the sequences be saved to a new .psa file:

  • -saveanim
  • -animfile [.psa anim file name]
By default, if no -animfile filename is specified, the skin base filename will be used with the .psa extension. The destination path is the one specified with -path.


Vertex Exporting

Simple old style, non-skeletal vertex animation data can be exported through a separate window, called up with "axvertex". Note that using vertex animation is discouraged - the skeletal rendering is more efficient, and has an interactive import art path into the animation browser in the editor, and offers far more options like rigidizing parts and LOD sprites, that vertex animated meshes don't have.
The options in the popup window are self-explanatory - for documentation on the vertex animation art path, see UnrealVertexAnimation. (Referenced from: http://udn.epicgames.com/Two/UnrealVertexAnimation.html)


Troubleshooting


Plugin failing to initialize

Verified that I have the MSVCR71.dll installed on my system ( either in your Windows\System32 folder, or alongside the Maya plugin )- it can be downloaded from the ActorX page. It should also be present after installing the Microsoft .Net 1.1 framework redistributable, though there have been reports that despite doing this a manual installation of the DLL was still necessary.

UV mappings come out wrong

There have been known instances of meshes that appear in Maya without any visible problems, showing up with (partially) corrupt UV mapping in the editor. This typically happens after they were saved from an older version of Maya and loaded into- and exported from a newer version of Maya. Usually Maya will give some compatibility warning when loading in the older version's art; even when your scene appears to looks correct, never ignore such warnings. It is always safest to set up your skin linkings, assign UV mappings and apply materials in the same version of Maya that you will be exporting your data from. If your textured art came from other packages (e.g. Motion Builder), try to re-convert it with tools meant specifically for the version of Maya that you will be exporting it from.


Tuesday, 12 October 2010

Week 4: Continuation of Custom Charater with Custom animation


4. Making UDK recognize the stuff which I added in


I changed some of the .uc files in [UDK folder]/Development/Src/UTGame/classes.
I made a back-up of the files.

First I Opened the UTPawn.uc file. Scrolled down to defaultproperties and the line 
Quote is: AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_ Human' 
and changed it toAnimTreeTemplate=AnimTree'YourPackage.YourGroup.Yo urAnimTree' 
This is where the Unreal engine has to know which AnimationTree the Playercharacter should use.

And then I opened the UTFamilyInfo_Liandri_Male.uc file
Scrolled down to defaultproperties and the line Quote:
CharacterMesh=SkeletalMesh'CH_LIAM_Cathode.Mesh.SK _CH_LIAM_Cathode' 
and changed it to:
CharacterMesh=SkeletalMesh'YourPackage.YourGroup.Y ourCharacter' 
In the same file the line Quote is:
AnimSets(0)=AnimSet'CH_AnimHuman.Anims.K_AnimHuman _BaseMale' 
and changed it to Quote:
AnimSets(0)=AnimSet'YourPackage.YourGroup.YourAnim Set' 
This is where the Unreal editor has to know which character to show and which AnimSet to use.

If the character doesn't show up and Unreal editor shows the default character with no animations then I have to open the UTFamilyInfo_Liandri.uc file and do the same things as in UTFamilyInfo_Liandri_Male.uc so had to avoid it again.



5. Animations for Melee Attacks


This was a bit easy to do, rest of it took a bit of research from youTube
I Opened the UTFamilyInfo.uc file and added some FamilyEmotes as EmoteAnim entered the name of the Melee Attack animations.

Once again I opened a UTWeapon_XXXXX.uc file the LinkGun would be pretty handy since it is the default weapon
found the line
Quote:
super.ConsumeAmmo(FireModeNum); 
and added below 
 
Quote:
UTPawn(Instigator).PlayEmote('(The name of the EmoteTag that should be played)', -1); 
Now the character should be playing the Melee Attack animation when you press fire.

Tuesday, 5 October 2010

Week 3: Creating and Achieving melee attack in UDK

At first, I was set a task to achieve the melee attack, customer character and animations into the UDK. I managed to find tutorials on how to do so on: 
http://www.youtube.com/watch?v=rM7EbIC42VE 


but very unfortunately we didn't have much time to focus on custom made characters and then importing from 3D Max, as could not achieve it in a short term in a given time we had, it was very difficult in creating everything in such a short time. So the fact that I did try was to fiddle with both the editors. Haven't used Maya or Max before, through self study and my friend's guidance I achieved some bits of it such as:

  1. Importing the external package into the UDK.
  2. Creating sockets.
  3. Creating a basic AnimTree.
  4. Making UDK recognise the stuff which I added in.
  5. Animations for Melee attack.
1. Import into UDK

Ok, the first step what I did was, Clicked on import, chose your Character.PSK file and open it.
The Importer has an options for Maya Coordinates. I rotated the character by 90,0,90 degrees before I exported it. I noticed that the Character has to face the positive X-Axis and the Z-Axis should be the Up-Axis. I used the “Rot Origin” (rotate origin) inside the AnimSet-Viewer.





























I right-clicked in the Content Browser and chose New AnimSet.
After creating AnimSet I opened it.
Choose File -> Import PSA and opened Animations.PSA

In the Browser Tab under Skeletal Mesh I selected Character.
In the Properties Tab click on AnimSet and checked the option "Anim Rotations Only?"
I Clicked on "Use Translation Bones" and created at least 2 Translation Bones.
The first one is rootbone and the next one your pelvis/hip bone.
I created Translation Bones for every bone that should take translation from your animations.
It looked something like this:



I figured that I don't need to do this, the Character will still be able to move/jump but it will NOT play any animations like Taunts or Melee Attacks.


2. Creating Sockets

In the AnimSet Editor click on Mesh and choose Socket Manager.

I Clicked on New Socket, Chose the right-hand-weapon-bone clicked OK, entered WeaponPoint as socket name and clicked OK again. Clicked on New Socket again, chose the left-hand-weapon-bone clicked OK and entered DualWeaponPoint as socket name, clicked OK again.
Clicked on New Socket, chose the right-ankle-bone, entered R_JB as socket name.
Did the same for the left-ankle-bone.
Clicked on New Socket again, chose the neck and head bone and entered HeadShotGoreSocket.


3. Creating a Basic AnimTree
(For reference take a look at the AT_CH_Human AnimTree)

I Right-Clicked the Content Browser and chose the New AnimTree.

I thought I did a mistake while setting it out, then I realised that this sorting need to tell Unreal when and how it should play the animations. So I opened the AnimTree by double-clicking on it.

The first Node which is needed is a AnimNodeBlendByPhysics. This Node contains pretty much every situation the character can be in.

Connected the Out Option of the AnimNodeBlendByPhysics with the Animation Option of the AnimTree. Now Created a UTAnimBlendByIdle Node and connected the Out Option with the Walking Option of the AnimNodeBlendByPhysics Node. Created a UTAnimNodeSequence and entered the name of the idle animation as Anim Seq Name in the properties tab. Connected it to the Idle option of the UTAnimBlendByIdle Node. Created a AnimNodeBlendDirectional Node and 4 UTAnimNodeSequence Nodes. Entered the names of the forward run, backward run and strafe animations and connected the Nodes to the right slot. Created a UTAnimBlendByFall Node and 8 UTAnimNodeSequence Nodes. This is where I defined the jump animations or the animations that  played when the character is in the air.
I noticed that if I don't have all the necessary animations I would have to improvise or just export parts of the jump animations for this. Connected the UTAnimNodeSequence Nodes to the UTAnimBlendByFall Node. The character should now be able to move and jump.