Unity——螺旋運動

一、目的

效果圖如下

 二、代碼如下

想要Z軸方向也可以動手加上去

using UnityEngine;
using System.Collections;

public class Spiral : MonoBehaviour
{
	
	public Transform target;
	
	public float degree;
	public float xFactor,yFactor;

	void FixedUpdate ()
	{
		transform.Translate(Time.deltaTime*xFactor,Time.deltaTime*yFactor, 0);
		transform.RotateAround(target.position,Vector3.up,degree*Time.deltaTime);
	}
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章