走路和跳跃
来源:互联网 发布:tensorflow c api 编辑:程序博客网 时间:2024/04/29 20:50
This is the second 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
WallJumping & Running
Sources:
Unreal Documentations
UnrealWiki
In this tutorial we will be covering how to make a wall running and wall jumping action.
Things we need:
A wall jump animation with motion buildt in.
A wall jump animation with motion buildt in but cut short.
Wall running animation.
Class we will be working in:
Pawn
WallJumping
First start with the wall jumping.
1.Create two bool variables.
var bool bLTrace;
var bool bJump;
2. 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'));
}
}
3. 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));
}
Second we need to create a Trace function. We will use this to detect if there is a wall nearby.
function LTrace()
{
local vector loc, norm, end,Start; local TraceHitInfo hitInfo; local Actor HitActor;
if ( Physics == PHYS_Walking || Physics == PHYS_Falling || Physics == PHYS_Flying )
{
end = Location + (CylinderComponent.CollisionHeight-85)*Vect(0,0,1) + normal(vector(Rotation+Rot(0,-16384,0)))*30;
Start = Location + (CylinderComponent.CollisionHeight-85)*Vect(0,0,1);
HitActor = trace(loc, norm, end, Start, true,, hitInfo);
}
Third we will place are Trace function (LTrace()) in side the Tick:
function Tick( float DeltaTime )
{
Super.Tick(DeltaTime);
LTrace();
}
Now if you compile your code and play it and press Tab and type ShowLineCheck you will be able to see the trace.
Fourth we well create the function that controls are Walljump:
exec function WallJumpLeft()
{
if(bLTrace == false )
{
return;
}
if (Physics == PHYS_Walking )
{
Velocity.Z = JumpZ/2;
CustomAnimPBG.PlayCustomAnimByDuration('WallJumpLRun',1.2, 0.2,0.5 , False, true );
SetTimer(1.00, false, nameOf(PysFall));
}
if (Physics == PHYS_Falling)
{
Velocity.Z = JumpZ/2;
CustomAnimPBG.PlayCustomAnimByDuration('WallJumpLFall',1.00, 0.2,0.5 , False, true );
SetTimer(0.90, false, nameOf(PysFall));
}
CustomAnimPBG.SetActorAnimEndNotification(true);
SetPhysics(PHYS_falling);
CustomGravityScaling=1.0;
RootMotionOn();
bjump = false;
return;
}
}
Fifth we need to create the function that are timer is going to call:
exec function PysFall()
{
SetPhysics(PHYS_falling);
ClearTimer(nameOf(PysFall));
RootMotionOff();
CustomGravityScaling=1.0
}
Sixth inside the DoJump() function add (see green):
unction bool DoJump( bool bUpdating )
{
if (bJumpCapable && !bIsCrouched && !bWantsToCrouch && (Physics == PHYS_Walking || Physics == PHYS_Ladder || Physics == PHYS_Spider))
{
if ( Physics == PHYS_Spider )
Velocity = JumpZ * Floor;
else if( bLTrace== true )
bJump = true;
else if ( Physics == PHYS_Ladder )
Velocity.Z = 0;
else if ( bIsWalking )
Velocity.Z = Default.JumpZ;
else if (bAction == true)
Velocity.Z = JumpZ + 50;
else
Velocity.Z = JumpZ;
if (Base != None && !Base.bWorldGeometry && Base.Velocity.Z > 0.f)
{
Velocity.Z += Base.Velocity.Z;
}
SetPhysics(PHYS_Falling);
return true;
}
return false;
}
Seveth we will place the function WallJumpLeft() into the function LTrace() (see green):
function LTrace()
{
local vector loc, norm, end,Start; local TraceHitInfo hitInfo; local Actor HitActor;
local string WallRunLT;
local bool banim;
if ( Physics == PHYS_Walking || Physics == PHYS_Falling || Physics == PHYS_Flying )
{
end = Location + (CylinderComponent.CollisionHeight-85)*Vect(0,0,1) + normal(vector(Rotation+Rot(0,-16384,0)))*30; // trace to "infinity"
Start = Location + (CylinderComponent.CollisionHeight-85)*Vect(0,0,1);
HitActor = trace(loc, norm, end, Start, true,, hitInfo);
if( HitActor.bWorldGeometry && Physics == PHYS_Falling)
{
if(bjumb == true)
{
WallJumpLeft();
bjumb = false;
return;
}
}
if( HitActor.bWorldGeometry )
{
if(bjumb == true )
{
WallJumpLeft();
bjumb = false;
return;
}
bLTrace = true;
}
if( HitActor == none)
{
bLTrace = false;
}
}
Eight we will create a function call Boost, we will activate this with a anim notify. ( If you want to know more about anim notify you can look them up in the documentation.)
function boost()
{
Velocity.Z = JumpZ - 40;
Velocity.Y = Velocity.Y/3;
Velocity.X = Velocity.X/3;
SetPhysics(PHYS_Falling);
RootMotionOff();
}
Now if we compile and run we should have a wall jumping function. Run up next to the wall and press jump.
For the other side just repeat.
Hint (for a trace to the right use:)
end = Location + (CylinderComponent.CollisionHeight-85)*Vect(0,0,1) + normal(vector(Rotation+Rot(0,16384,0)))*30; to
Start = Location + (CylinderComponent.CollisionHeight-85)*Vect(0,0,1);
WallRunning
First we need to create a bool variable:
var bool bAction;
Second we need to create a function to call are bAction:
exec function Action()
{
bAction = true;
Enable ('Tick');
}
exec function ActionOff()
{
bAction = false;
}
Third 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
Add this in your Game Contoller Bindings in the DefaultInput.ini .
.Bindings=(Name="XboxTypeS_RightShoulder",Command="GBA_Action")
Fourth inside the LTrace function add (see green):
function LTrace()
{
local vector loc, norm, end,Start; local TraceHitInfo hitInfo; local Actor HitActor;
local string WallRunLT;
local bool banim;
if ( Physics == PHYS_Walking || Physics == PHYS_Falling || Physics == PHYS_Flying )
{
end = Location + (CylinderComponent.CollisionHeight-85)*Vect(0,0,1) + normal(vector(Rotation+Rot(0,-16384,0)))*30; // trace to "infinity"
Start = Location + (CylinderComponent.CollisionHeight-85)*Vect(0,0,1);
HitActor = trace(loc, norm, end, Start, true,, hitInfo);
if( HitActor.bWorldGeometry && Physics == PHYS_Falling)
{
if(bjumb == true)
{
WallJumpLeft();
bjumb = false;
return;
}
}
if( HitActor.bWorldGeometry )
{
if(bjumb == true )
{
WallJumpLeft();
bjumb = false;
return;
}
else if(bjumb == false && bAction == true)
{
WallRunL();
banim = true;
}
bLTrace = true;
}
if( HitActor == none)
{
// we use this to make sure if there is no wall then fall//
if(CustomAnimPBG.GetCustomAnimNodeSeq().AnimSeqName == ('WallRunL') || CustomAnimPBG.GetCustomAnimNodeSeq().AnimSeqName ==('WallJumpLRun'))//CustomAnimPBG.bIsPlayingCustomAnim && banim == true)// && Physics == PHYS_Falling )
{
CustomAnimPBG.StopCustomAnim(0.3);
CustomGravityScaling=1.0;
banim = false;
}
bLTrace = false;
}
}
}
Fifth we create are Wallrunning function:
exec function WallRunL()
{
if(CustomAnimPBG.bIsPlayingCustomAnim)
{
return;
}
if (bLTrace == true)
{
CustomAnimPBG.PlayCustomAnimByDuration('WallRunL',1.8, 0.3,0.4 , False, true );
}
SetPhysics(PHYS_Falling);
Velocity.Z = JumpZ/2+50;
// use the CustomGravityScaling to adjust the height of your run//
CustomGravityScaling=0.5;
CustomAnimPBG.SetActorAnimEndNotification(true);
SetTimer(1.70, false, nameOf(PysFall));
}
Now you WallRunning Action should be ready to go. Just run beside the wall and push the the button you binded the Action function to.
- 走路和跳跃
- 走路
- 走路
- 走路
- 走路
- 学走路--第一天:总结和启程
- 跳跃
- 如何实现跳跃中的减速和自由落体
- 如何实现跳跃中的减速和自由落体
- 数据结构和算法系列 - 跳跃表 SkipList
- 跳跃表的实现和测试
- 走路call
- 四条腿走路
- 走路Call
- 怎么走路
- 面试题,逻辑题-坐飞机和坐车走路早到20分钟的问题!
- 面试题,逻辑题-坐飞机和坐车走路早到20分钟的问题
- 给自己的警告------说话和走路时应注意的地方
- 根骨骼控制/旋转
- android 基础学习博客
- 二叉树的深度优先遍历与广度优先遍历 [ C++ 实现 ]
- Google 发布 Android 性能优化典范
- git 平时使用命令
- 走路和跳跃
- PHP可变函数
- 源代码安全管理中的日志分类查询
- Shape属性详解
- Java Web入门之jsp要点
- 树的遍历与二叉树的遍历区别
- 跨栏运动(hurding)
- 事务和JDBC事务隔离级别(转,比较全面)
- 服务端管理工具编写(四)——鼠标右键菜单及会议管理