public class SpiralMovement : MonoBehaviour
{
[SerializeField] Transform moveable;
[SerializeField] public Transform destiny;
[SerializeField] float speed;
// As higher as smoother approach, but it can not be more than 90, or it will start getting away.
[SerializeField][Range(0f, 89f)] float angle = 60f;
void Update()
{
Vector3 direction = destiny.position - moveable.position;
direction = Quaternion.Euler(0, 0, angle) * direction;
float distanceThisFrame = speed * Time.deltaTime;
moveable.transform.Translate(direction.normalized * distanceThisFrame, Space.World);
}
}
2条答案
按热度按时间mrfwxfqh1#
我想那能如你所愿吗?它逐渐向旋转点移动,然后旋转,给人一种恶化轨道的感觉。
r7s23pms2#
如果你来这里寻找工作的2D解决方案,你在这里。
从this blog post .我构建了以下可配置脚本: