朋友帮忙写的代码
--------------每次旋轉60度---------------------
var rotating : boolean = false;
var rotateSpeed : int = 12;
function OnGUI()
{
???? if(GUILayout.Button("Rotateme"))
? {
??rotating=true;
??SendMessage("Rotateme");
? }?
}
function Rotateme()
{
?? if (rotating)
?? {?
????? var curRotate : float = 0;
????? var startRotate : float = transform.eulerAngles.y;
????? while (curRotate < 60)
?? {
???????? curRotate += rotateSpeed * Time.deltaTime;
?? print(curRotate);
???????? transform.eulerAngles.y = startRotate + curRotate;
???????? yield;
????? }
????? transform.eulerAngles.y = Mathf.Round(startRotate + 60);
????? rotating = false;
?? }
}
-----------旋轉朝向目標--------------------------
var targetTransform: Transform;
var rotationSpeed : float=5.0;
function Update ()
{
?var direction:Vector3=targetTransform.position-transform.position;
?direction.y=0;
?transform.rotation = Quaternion.RotateTowards (transform.rotation, Quaternion.LookRotation(direction), rotationSpeed);
}
轉載于:https://www.cnblogs.com/softimagewht/archive/2010/12/22/1913972.html
總結
- 上一篇: 五、Chain链的作用
- 下一篇: 明年的方向是JAVA+SAP