This is the first in a series of tutorials I will be writing of creating actions within UDK script. I am self taught when it comes to scripting and over the last couple months I have been learning Unrealscript. In the Unreal community forums alot of people ask about rootmotion, wallrunning, grabing and ext. As did I when I first started. My tutorials will cover how I found such solutions to preforming these actions.
My second reason for writing said tutorials is a attempt to get exposure within the community to make a transition form my current job in the Industial feild to Gaming. I am currently looking for a position as a modeler, texturer, concept artist, animator, and scriptor.
All animations, models, textures and script where created by me.
These are my fisrt attempt in writing tutorials, if something does not work or you have a better method or questions please let me know.
UDK forum ID: BennyG
CustomAnimNodeSequence, Rootmotion, Rolling
Sources:
Unreal Documentations
UnrealWiki
In the following tutorial we are going to use the CustomAnimNodeSequence and Rootmotion to drive are rolling animations
Class we will modify:
Pawn
PlayerController
Things we need:
Rolling Animations for each direction.
1. load your animations into your AnimSet
2. we will go into the AnimTree and create are link-up for are CustomAnimNodeSequence.
Pawn
3. we will go into are Pawn class and create the code to access are CustomAnimNodeSequence.
First Create a variable for your AnimNode Bend:
var AnimNodePlayCustomAnim CustomAnimPBG; |
第二步,初始化动画树:
simulated event PostInitAnimTree(SkeletalMeshComponent SkelComp) { if (SkelComp == Mesh) { CustomAnimPBG = AnimNodePlayCustomAnim(SkelComp.FindAnimNode('CustomAnimPBG')); } } |
第三部,创建一个函数激活滚动(roll):
exec function RollR() { if(CustomAnimPBG.bIsPlayingCustomAnim ) { return; } RootMotionOn(); CustomAnimPBG.PlayCustomAnim('RollR',1.4, 0.4,0.4 , False, true ); SetTimer(1.35, false, nameOf(RootMotionOff)); }
exec function RollL() { if(CustomAnimPBG.bIsPlayingCustomAnim ) { return; } RootMotionOn(); CustomAnimPBG.PlayCustomAnim('RollL',1.4, 0.4,0.4 , False, true ); SetTimer(1.35, false, nameOf(RootMotionOff)); }
exec function RollF() { if(CustomAnimPBG.bIsPlayingCustomAnim ) { return; } RootMotionOn(); CustomAnimPBG.PlayCustomAnim('RollF',1.4, 0.4,0.4 , False, true ); SetTimer(1.35, false, nameOf(RootMotionOff)); } exec function RollB() { if(CustomAnimPBG.bIsPlayingCustomAnim ) { return; } } |
第四部:激活/不激活根骨格运动:
function RootMotionOn() { Mesh.RootMotionMode = RMM_Accel; Mesh.bRootMotionModeChangeNotify = TRUE; CustomAnimPBG.SetRootBoneAxisOption (RBA_Translate, RBA_Translate, RBA_Translate); } function RootMotionOff() { Mesh.RootMotionMode = RMM_Ignore; Mesh.bRootMotionModeChangeNotify = False; ClearTimer(nameOf(RootMotionOff)); }
|
Now if you run the Roll function in game it will work.
PlayerController
Now we will create the Input to control the roll directions. We will do this inside are PlayerController Class
.
First we will create a bool variable:
var bool bRolling;
Second we will create a function to use in are DefaultInput.ini:
function RollGo()
{
bRolling = true;
WorldInfo.Game.Broadcast(self,"RollG0");
}
Third we will create code in are PayerMove function to to tell are pawn what direction to roll in. I copied the PlayerMove function from UDKPlayerController and pasted it into my PlayerController and then added my Code underneath (DoubleClickMove = PlayerInput.CheckForDoubleClickMove( DeltaTime/WorldInfo.TimeDilation );) :
if( PlayerInput.aStrafe == 0 ) { //void for now// } if( PlayerInput.aStrafe > 1 ) { if(bRolling == true) { PBGPawn(Pawn).RollR(); bRolling = false; } }
if( PlayerInput.aStrafe < -1 ) { if(bRolling == true) { PBGPawn(Pawn).RollL(); bRolling = false; } } if( PlayerInput.aForward < -1 ) { if(bRolling == true) { PBGPawn(Pawn).RollB(); bRolling = false; } } if( PlayerInput.aForward > 1 ) { if(bRolling == true) { PBGPawn(Pawn).RollF(); bRolling = false; } } if( PlayerInput.aForward == 0 ) { //void for now// } |