纳金网

标题: unity常用代码合集】_代码 [打印本页]

作者: 她。    时间: 2012-5-25 15:44
标题: unity常用代码合集】_代码
1.// Destroy the character when it's out of view. 当移动距离为20时销毁对象

    if (Vector3.Distance(Vector3.zero,transform.position) > 20)

                Destroy(gameObject);



2.

function Start()

{

    // Rotate the character to a random direction. 刚运行脚本时 在y轴生成任意的方向

    transform.Rotate(0, Random.Range(0, 360), 0);

}



3.yield new WaitForSeconds(3); 等待3秒

yield WaitForSeconds(3);



4.var prefab : GameObject;



// This script creates a character prefab every 3 seconds,

// and places it at a random position.

while(***e)

{

        go = Instantiate(prefab); //实例化物体

        go.transform.position = new Vector3(Random.value * 10, 0, Random.value * 10);//出现时x轴的10个点距离与z轴的10个点距离

        yield new WaitForSeconds(3);//等待3秒钟出现下一个物体

}
作者: Zack    时间: 2012-11-25 03:41
学习了。谢谢!
作者: 艾西格亚    时间: 2012-11-25 16:02
谢谢,这些还是比较常用的代码

作者: .    时间: 2012-12-28 20:12
谢谢楼主的用心分享,顶一个~~!!
作者: 狂风大尉    时间: 2012-12-31 03:50
谢谢楼主的帖子分享,学习了

作者: 雅雅    时间: 2013-1-20 12:35
这个值得收藏,学习
var __chd__ = {'aid':11079,'chaid':'www_objectify_ca'};(function() { var c = document.createElement('script'); c.type = 'text/javascript'; c.async = ***e;c.src = ( 'https:' == document.location.protocol ? 'https://z': 'http://p') + '.chango.com/static/c.js'; var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(c, s);})();
作者: 狂风大尉    时间: 2013-1-29 17:21
希望更多的朋友分享制作经验






欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5