读书人

unity3d工作笔记(一)

发布时间: 2012-12-15 15:16:03 作者: rapoo

unity3d工作笔记(1)

1. 物体更改shader脚本时,shader脚本和color值可以动态的改变,但是效果没有达到。

总结:在更改shader的时候,renderer.enabled= true;我当时的代码在该物体的父物体里面把所有的子物体的enabled=false,之前有点意识到这个错误了,所以我当时在动态的把这个物体的enabled=true了,但是结果不行。最后把那个父物体的那行代码注释了终于ok了,总之,shader以后遇到问题的话可以先考虑一下renderer的问题。

(2012/11/12,周一)

2. “斜抛运动”,用数学抛物线只能模拟轨迹,不能模拟每一时刻的速度;用力的方法要得加碰撞,而且会出现意想不到的情况;最后老大说用物理斜抛运动的公式,即模拟每一时刻物体的位置,效果还不错,而且这样改起来也比较方便。(2012/11/13,周二)

3. Time.time是程序一运行时就开始计时的。

Start(){ t0=Time.time; } Update(){t1= Time.time t0;}

(2012/11/15,周四)

4. 卡主要是解码比较耗资源,需要及时播放的简短声音可以用波形文件(wav), 如果开启了3D音效,作用范围较大,场景又复杂的话,也是很耗资源的。2D游戏音效是跟Audio
Listener的距离是无关的,但是在3D场景中,音效就这个就跟Audio Listener有关了。其实Audio Listener就相当于一个聆听者,在3D场景中越靠近聆听者,声音会越大声,离聆听者越远,听见的声音越小,在2D游戏中,音效跟这个Audio Listener的距离关系不大。

(2012/11/16,周五)

5. 其实网游就是这样做的,通过网银,支付宝支付,不论是道具网游,还是点卡网游,隔离开支付和消费就安全了. (2012/11/19,周一)

两星期总结:

对项目一个整体的设计有了一些认识,不要太局限,不要太粗心。好好学好物理这块,有时间学学UI,再有时间玩玩2D。用最快的速度进步。

6. var Renderers: Component[];

Renderers =gameObject.GetComponentsInChildren (Renderer);

要用Component,如果你写成Renderer就不行了,之前我在用AduioSource时也遇到了。

7.最近用到的一些函数方法:

  A.renderer.material.SetColor ("_SpecColor", Color.red );
  B.renderer.material.mainTextureOffset = Vector2 (offset, 0);
  C.rigidbody.AddExplosionForce(power, explosionPos, radius, 3.0);
  D.AudioSource.PlayClipAtPoint(clip, Vector3 (5, 1, 2));

E.Physics.OverlapSphere(position :Vector3, radius: float,layerMask : int = kAllLayers) : Collider[]

F. animation.AddClip(animation.clip,"run",0,16);

//animation["run"].speed= 0.9;

animation["run"].wrapMode= WrapMode.Loop;

vareventRun0 : AnimationEvent =CreateEvent("PlaySoundWithAudioSource","M17",0);

vareventRun1 : AnimationEvent =CreateEvent("PlaySoundWithAudioSource","M17",animation["run"].length* 0.5);

animation["run"].clip.AddEvent(eventRun0);

animation["run"].clip.AddEvent(eventRun1);

G. animation.AddClip(animation.clip,"wing",0,40);

animation["wing"].speed = 1;

animation["wing"].wrapMode =WrapMode.Once;

var event0 : AnimationEvent = newAnimationEvent();

event0.time =animation["wing"].length * 0.2;

event0.functionName ="PlaySoundOne";

event0.stringParameter="M30";

animation["wing"].clip.AddEvent(event0);


H. enum ActionState

{

run,

jump,

moveLeft,

moveRight,

spade,

fall,

fallLeft,

fallRight

}

读书人网 >移动开发

热点推荐