2014-10-15-函数--StaticMesh运动

来源:互联网 发布:java spring 异步调用 编辑:程序博客网 时间:2024/05/14 09:15

MasterinUnrealScript

E:/udnweb/udn script/udn.epicgames.com/Three/MasteringUnrealScriptFunctionsCH.html              #第六章 –函数

 


 

UC文件

MasterTest

classMasterTestextends simplegame;

 

AmbientCreatureNode


 

AmbientCreature_Fish

classAmbientCreature_FishextendsActor

    placeable;

 

var()array<AmbientCreatureNode>MyNodes;

var()floatSpeed;

 

functionPostBeginPlay()

{  

    Super.PostBeginPlay();

    SetRandDest();

    //`log(coerce string Msg, optional bool bCondition=true, optional nameLogTag='ScriptLog' );

}

 

functionSetRandDest()

{

    localIntIdx;

    localAmbientCreatureNodeDestNode;

    localVectorMoveDirection;

 

    Idx=Rand(MyNodes.Length);

    `Log(Idx); //输出变量的值到日志

    worldinfo.Game.Broadcast(self,Idx);    //输出变量的值到self的屏幕

    //`Log("CustomController up控制类");    //输出字符串:CustomController up 控制类

    //worldinfo.Game.Broadcast(self,"Idx$编号");    //输出字符串:Idx编号

                                         //例如变量A=0.233,变量B='名字:',变量C="ABC",那么可以这样串接: Broadcast(self,A$"编号成员的"$B@C) 最后输出的结果为: 0.233编号成员的名字: ABC 注意:和ABC之间有个空格,因为$是直接串接,@ 是加空格后串接

    DestNode=MyNodes[Idx];

    MoveDirection=DestNode.Location-Location;

    Velocity=Normal(MoveDirection)*Speed;

    SetTimer(5,false,'SetRandDest');  

    

}

 

defaultproperties

{

    Speed=170

 

    BeginObjectClass=DynamicLightEnvironmentComponent Name=MyLightEnvironment

   EndObject

   LightEnvironment=MyLightEnvironment

   Components(0)=MyLightEnvironment   //组件不附加就不能使用,等于没有定义组件,和Components.Add(MyStaticMesh)类似。任何时候您使用某种类型的组件时,为了使它们有效,都需要把它们分配给Components数组。

 

    BeginObjectClass=StaticMeshComponent Name=MyStaticMesh

         StaticMesh=StaticMesh'Chapter_06_Functions.ClownFish'

          Scale3D=(X=0.250000,Y=0.250000,Z=0.25000)//测试有效

          LightEnvironment=MyLightEnvironment  //注释掉,静态网格物体没有光照--没有光照的物体是什么颜色??

     EndObject  

   Components(1)=MyStaticMesh     //注释掉在场景中就看不到定义的网格物体了,和Components.Add(MyStaticMesh)类似

 

     CollisionComponent=MyStaticMesh//启用静态网格物体自身的碰撞体,添加碰撞属性后的静态网格物体就可以和其它物体产生碰撞了

     DisplayMesh=MyStaticMesh

     bCollideWorld=true   //添加碰撞属性后的静态网格物体就可以和其它物体产生碰撞了,有碰撞属性的物体运动到一块儿时就不会有穿插,虽然物体间有碰撞,但是和世界碰撞与否需单独设置

     Physics=PHYS_Projectile

     bStatic=false

     bMovable=true

}

 

NOTICE

SetRandDest函数

DestNode在Editor中的设置,若不设置log会提示找不到DestNode

 

 

小结:

函数实现静态网格物体简单地直线运动

 

A:一个Actor自带哪些基础功能函数变量和信息(物理,碰撞,位置,旋转,SetDrawScal,动态物体动态光照Move,变量修饰符,类的修饰符,

Function,PreBeginPlay,PostBeginPlay,Super,return,function变量类型,function(out变量类型),,,,,,,,,,,,,,

 

1.  理解Log在程序调试中的用处

2.  理解SetTimer()时间驱动函数

3.  一些Actor自带的常用函数

 

0 0
原创粉丝点击