我们在写放技能时候可以用到这个,因为有的技能不只是单纯向前移动,他可能会在前进的过程中有一些旋转的改变
public float speed = 5f;
public float pos;
public Transform center;
public float raudis = 1.5f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
pos += Time.deltaTime * speed;
if (pos >= 360)
{
pos -= 360;
}
float x1 = center.position.x + raudis * Mathf.Cos(pos);
float y1 = center.position.y + raudis * Mathf.Sin(pos);
transform.position = new Vector3(x1, y1, pos)+center.forward;
transform.eulerAngles = center.eulerAngles;
}
把这个脚本挂载到要移动的物体上