2014-10-17-State状态

State:

E:/udnweb/udn script/udn.epicgames.com/Three/MasteringUnrealScriptStatesCH.html

 

指南 11.1 – 状态触发器, 第一部分:函数重载

前期准备

原文件地图文件扩展名为ut3,UDK2013.07编译时地图要另存为扩展名为udk,添加一个PlayerStart否则提示找不到地图文件


新建文本文档在项目中添加现有项

 

UDKGame\Config目录下的DefaultEngine.ini文件中没有添加Chapte11_State文件包,编译后脚本中不产生相关的.u文件。

 

DefaultEngine.ini文件中添加Chapte11_State文件包后,在Editor的Contenbrowser中才可以找到MU_StateTrigger,否则在Contenbrowser中不会显示出MU_StateTrigger

class MU_StateTrigger extends Actor

   placeable;

 

defaultpropertiesTranslation=(X=0.000000,Y=0.000000,Z=-40.000000)意味着网格物体在Editor中位置处于坐标下方40个单位处

 


 

 

 

函数重载测试完成的代码:

CH_State

Class CH_State extends utGame;

 

MU_StateTrigger

class MU_StateTrigger extends Actor

   placeable;

 

 

event Touch(Actor Other, PrimitiveComponent OtherComp,vector HitLocation,vector HitNormal)

{

    WorldInfo.Game.Broadcast(self,"This is theStateTigger class.");

    GotoState('Dialog');     //碰撞发生后,把当前面Actor放到Dialog状态下(让它处在Dialog状态)

}

 

state Dialog

{

    eventTouch(ActorOther, PrimitiveComponentOtherComp, vectorHitLocation, vectorHitNormal)

    {

       WorldInfo.Game.Broadcast(self,"This is thebase dialog state's output");

    }

}

 

 

 

 

defaultproperties

{   //defaultproperties代码块为Actor提供了网格物体和碰撞几何体。由用于达到actor的可视化效果的StaticMeshComponent子对象和用于作为actor碰撞的CylinderComponent子对象构成。

    //定义三个子对象StaticMeshComponent(组件),CollideActors=false;定义了一个CylinderComponent组件CollideActors=true

    BeginObject Class=StaticMeshComponent Name=StaticMeshComponent0

         //StaticMesh=StaticMesh'LT_Deco.SM.Mesh.S_LT_Deco_SM_PodiumScorpion'

         StaticMesh=StaticMesh'Chapter_06_Functions.ClownFish'

         Translation=(X=0.000000,Y=0.000000,Z=-20.000000)

         Scale3D=(X=0.50000,Y=0.50000,Z=0.5000)

         CollideActors=false

         bAllowApproximateOcclusion=True

         bForceDirectLightMap=True

         bCastDynamicShadow=False

         LightingChannels=(Dynamic=False,Static=True)

    EndObject

    Components.Add(StaticMeshComponent0)

 

 

    BeginObject Class=StaticMeshComponent Name=StaticMeshComponent1

         StaticMesh=StaticMesh'LT_Deco.SM.Mesh.S_LT_Walls_SM_FlexRing'

         Translation=(X=0.000000,Y=0.000000,Z=-40.000000)

         Scale3D=(X=0.500000,Y=0.500000,Z=0.500000)

         CollideActors=false

         bAllowApproximateOcclusion=True

         bForceDirectLightMap=True

         bCastDynamicShadow=False

         LightingChannels=(Dynamic=False,Static=True)

    EndObject

    Components.Add(StaticMeshComponent1)

 

    BeginObject Class=StaticMeshComponent Name=StaticMeshComponent2

         //StaticMesh=StaticMesh'LT_Light.SM.Mesh.S_LT_Light_SM_LightCone01'

         StaticMesh=StaticMesh'LT_Light.SM.Mesh.S_LT_Light_SM_Light01'     //UDK2013.07中contenbrowser中自带的文件

         Translation=(X=0.000000,Y=0.000000,Z=-40.000000)

         //Scale3D=(X=2.000000,Y=2.000000,Z=-1.000000)

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

         CollideActors=false

         bAllowApproximateOcclusion=True

         bAcceptsLights=True

         CastShadow=False

    EndObject

    Components.Add(StaticMeshComponent2)

 

    //BeginObject Class=DrawCylinderComponent NAME=CollisionCylinder   先用Draw,把Component在Editor中看一下效果。测试发现,Draw出来的东西不具备计算碰撞的功能。

    BeginObject Class=CylinderComponent NAME=CollisionCylinder

    CollideActors=true

    CollisionRadius=+0040.000000

    CollisionHeight=+0040.000000

    EndObject

    CollisionComponent=CollisionCylinder

    Components.Add(CollisionCylinder)

 

    bCollideActors=true

    bStatic=true

    bMovable=False

    bEdShouldSnap=True

 

}

 

指南 11.2 –状态触发器, 第二部分:状态继承

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值