- Home /
when moving a Game Object in a circle through it Transform Position, how can I control which arch of the circle to start moving on?
// Unity2D
// sort of like a rainbow arc motion starting from left to right and vice versa.
private float rotateSpeed = 1.0f;
private float radius = 9.0f;
private Vector2 _centre;
private float _angle;
public void Start()
{
_centre = transform.position;
}
private void FixedUpdate()
{
TransportPlayer();
}
public void TransportPlayer()
{
if (true)
{
_centre = transform.position;
_angle += rotateSpeed * Time.deltaTime;
var offset = new Vector2(Mathf.Sin(_angle), Mathf.Cos(_angle)) * radius;
transform.position = _centre + offset;
}
else
{
return;
}
}
Comment
Answer by Content1of_akind · Apr 10, 2019 at 03:57 AM
This link answered my question, the logic is still there. https://gamedev.stackexchange.com/questions/157642/moving-a-2d-object-along-circular-arc-between-two-points