码迷,mamicode.com
首页 > 移动开发 > 详细

Unity3d修炼之路:对一个简单对象Cube的移动 旋转和缩放

时间:2014-11-17 22:56:13      阅读:512      评论:0      收藏:0      [点我收藏+]

标签:io   ar   os   sp   java   for   on   cti   as   

#pragma strict

private var m_nFrameCount : int = 0;
private var m_isSubCount : int = 0;//false


function Update () {
    var fSpeed : float = 1.0f;
	var fAngle : float = 50.0f;
	var pCurrentPoint : Vector3 = transform.position;
	var pAxis : Vector3 = new Vector3(1.0f,0.0f,0.0f);
	
	//沿着x轴移动
	pCurrentPoint.x -= Time.deltaTime * fSpeed;
	transform.position = pCurrentPoint;
	
	//沿着给定的轴旋转
	transform.Rotate(pAxis,Time.deltaTime*fAngle);
	//transform.Rotate(pAxis*Time.deltaTime*fAngle);
	//transform.Rotate(transform.forward*Time.deltaTime*fAngle);
	
	
	//transform.localScale += new Vector3(2.0f,0.0f,0.0f);
	
	//到100帧的时候缩放一下
	if(m_nFrameCount>=100)
	{
		transform.localScale = new Vector3(0.5f,1.0f,1.0f);
		m_nFrameCount = 100;
		m_isSubCount = 1;
	}
	else if(m_nFrameCount <= 0)
	{
	 	transform.localScale = new Vector3(1.0f,1.0f,1.0f);
		m_nFrameCount = 0;
		m_isSubCount = 0;
	}
	
	if(m_isSubCount == 1){
		--m_nFrameCount;
	}else{
		++m_nFrameCount;
	}
}

Unity3d修炼之路:对一个简单对象Cube的移动 旋转和缩放

标签:io   ar   os   sp   java   for   on   cti   as   

原文地址:http://blog.csdn.net/xiaxiang123/article/details/41217671

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!