根骨骼控制/旋转

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.

Create a AnimNodeBlend
Create a AnimNodeSequence
Link the AnimNode Sequence to the Custom slot on the AnimNodeBlend
Link the AnimNodeBlend to the AnimTree Node and the link the Normal slot to the AnimNodeBlendByPhysics.


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//

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值