通过声明gameobject对象,实现一个脚本用于多个对象
#pragma strict //code:myhaspl@myhaspl.com //date:2014-08-12 var rotate_object:GameObject; var translate_object:GameObject; var fuhao:int; fuhao=-1; function Update () { if (rotate_object!=null){ rotate_object.transform.Rotate(1,1,-1); } if (translate_object!=null) { if (translate_object.transform.position.y<9 ){ fuhao=1; } if (translate_object.transform.position.y>15) { fuhao=-1; } translate_object.transform.Translate (0,fuhao*0.1,0); } }
麦好的AI乐园博客所有内容是原创,如果转载请注明来源
http://blog.csdn.net/myhaspl/
在unity3d下如下布局:
运行效果如下链接所示:
http://mygame.myhaspl.com/test2/test2.html