跨栏运动(hurding)

This is the Third 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. (please forgive my animation they are blocked out until I have time to fine tune them.)

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

 

In this tutorial we will be covering how to make Hurdling action.


Things we need:


Two diiferent Herdle animations with rootmotion.


Class we will be working in:


Pawn


Hurdling


First getting things ready.

Create an bool variables and a float variable.

var bool bFTrace;
var float Distance;

Make sure you can access  a CusotmAnimSequence in your code.

 

See the Rootmotion/Rolling tutorial if you do not know how to do this.

var AnimNodePlayCustomAnim CustomAnimPBG;

simulated event PostInitAnimTree(SkeletalMeshComponent SkelComp)

{

     if (SkelComp == Mesh)

    {

                    CustomAnimPBG = AnimNodePlayCustomAnim(SkelComp.FindAnimNode('CustomAnimPBG'));

    }

}

 


1.Make sure you know how to use Rootmotion.See the Rootmotion/Rolling tutorial if you do not know how to do this.

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));

}

 


2.we need to create two Trace function. We will use this to detect if there is a wall nearby.


First trace:

function FTraceTest()

{

    local vector loc, norm, end,Start; local TraceHitInfo hitInfo; local Actor HitActor;

     if ( Physics == PHYS_Walking && !bIsCrouched || Physics == PHYS_Falling || Physics == PHYS_None || IsInState('Hanging') )

    {

        end = Location + normal(vector(Rotation+Rot(0,0,0)))*85; // trace to "infinity"

        Start = Location;

        HitActor = trace(loc, norm, end, Start, true,, hitInfo);

        Distance = VSize(location - loc);

        if( HitActor.bWorldGeometry) 

        {

           bFTrace = true;

           return;

        

        if( HitActor == none)

        {

            bFTrace = false;

        }

     }

}

 

Second trace:
Description: C:\Users\Phillip\Desktop\pbgWeb\Tutorial\Hurdling\STrace.jpg

function FTrace()

{

    local vector loc, norm, end,Start;

    local vector locB, normB, endB, StartB;

    local TraceHitInfo hitInfo, hitInfoB;

    local Actor HitActor, HitActorB;

  

    if ( Physics == PHYS_Walking && !bIsCrouched || Physics == PHYS_Falling || Physics == PHYS_none )

    {

        // trace to "infinity"

        end = Location + (CylinderComponent.CollisionHeight-65)*Vect(0,0,1) + normal(vector(Rotation))*85;

        Start = Location + (CylinderComponent.CollisionHeight-65)*Vect(0,0,1);

       // trace to "infinity"   

        endB = Location + (CylinderComponent.CollisionHeight+1)*Vect(0,0,1) + normal(vector(Rotation))*85;

        StartB = Location + (CylinderComponent.CollisionHeight + 1)*Vect(0,0,1);

        HitActor = trace(loc, norm, end, Start, true,, hitInfo);

        HitActorB = trace(locB, normB, endB, StartB, true,, hitInfoB);

        if( HitActor.bWorldGeometry && HitActorB.bWorldGeometry && bLTrace == false && bRTrace == false)

        {

           if(CustomAnimPBG.bIsPlayingCustomAnim || Physics == PHYS_Falling )

           {

               return;

           }

           if ( HitActorB == none )

           {

              bFTrace = false;

           }

           else

           {

              bFTrace = true;

              return;

           }

           if ( HitActor.bWorldGeometry && Physics == PHYS_Walking && BFTrace == true )

           {

              // trace to "infinity"

              end = Location + (CylinderComponent.CollisionHeight-50)*Vect(0,0,1)+ normal(vector(Rotation+Rot(0,0,0)))*90; 

              Start = Location + (CylinderComponent.CollisionHeight)*Vect(0,0,1)+ normal(vector(Rotation+Rot(0,0,0)))*90;

              // trace to "infinity"

              endB = Location + (CylinderComponent.CollisionHeight-65)*Vect(0,0,1)+ normal(vector(Rotation+Rot(0,0,0)))*35; 

              StartB = Location + (CylinderComponent.CollisionHeight-65)*Vect(0,0,1);

              HitActor = trace(loc, norm, end, Start, true,, hitInfo);

              HitActorB = trace(locB, normB, endB, StartB, true,, hitInfoB);

              if(HitActor.bWorldGeometry && HitActorB.bWorldGeometry && Physics == PHYS_Walking)

              {

                 if(CustomAnimPBG.bIsPlayingCustomAnim)

                 {

                    return;

                 }

                 if(Distance < 20)

                 {

                     ClimeStanding();

                 }

                  return;

               }

               if(HitActor.bWorldGeometry && HitActorB == none)

               {

                  if(Distance > 75)

                  {

                     bFTrace = true;

                     HerdleHop();

                     return;

                  }

               }

          }

     }

}

 

Third we will place are Trace function (FTraceTest ()) in side the Tick.

function Tick( float DeltaTime )

{

   if (bAction == true)

   {

       FTrace();

   }

}

 


Fourth we need to create a function to call are bAction so when we activate it are trace is run:

exec function Action()

{

       bAction = true;

       Enable ('Tick');

}


exec function ActionOff()

{

        bAction = false;

}

 


Fifth we need to add are Action() and ActionOff() functions in the DefaultInput.ini and bind them to a key:

Add this:

.Bindings=(Name="GBA_Action",Command="Action | ActionOff")

Underneath:
;-----------------------------------------------------------------------------------------
; BINDINGS USED TO ORGANIZE ALL GAME BINDABLE ACTIONS IN ONE PLACE FOR SYSTEMS SUCH AS UI
; GBA - GAME BINDABLE ACTION
; "_Gamepad" - IS USED WHEN A CONTROLLER IS USING AN ALTERED MAPPING FOR AN ACTION

 

Description: C:\Users\Phillip\Desktop\pbgWeb\Tutorial\Rolling\Spinning.jpg


Add this in your Game Contoller Bindings in the DefaultInput.ini .


.Bindings=(Name="XboxTypeS_RightShoulder",Command="GBA_Action")

 

Forth we well create the function that activate are hurdle animations.

exec function HerdleHop()

{

        SetPhysics(PHYS_none);

        RootMotionOnTranslate();

        CustomAnimPBG.PlayCustomAnimByDuration('HerdleJump',1.5, 0.2,0.1 , False, true );

        CustomAnimPBG.SetActorAnimEndNotification(true);

        SetTimer(1.20, false, nameOf(PysWalk));

}


exec function ClimeStanding()

{

       SetPhysics(PHYS_none);

       RootMotionOnTranslate();

      CustomAnimPBG.PlayCustomAnimByDuration('HerdleClimeUp',2.5, 0.01,0.5 , False, true );

      CustomAnimPBG.SetActorAnimEndNotification(true);

      SetTimer(2.35, false, nameOf(PysWalk));

}

 

5.we need to create the function that are timer is going to call and also turns off are rootmotion.

function PysWalk()

{

   SetPhysics(PHYS_walking);

   ClearTimer(nameOf(PysWalk));

   RootMotionOff();

   CustomGravityScaling=1.0;

   groundspeed = 300;

 

Now if we compile and run we should have a hurdle action.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值