# How to make a gameObject Transform Position move in a circle while making its Transform Position move forward?

 // I'm using Unity2D =)

// I'm trying to move the Transform.Position in a circle pattern and also move it forward.
// I'm not trying to move transform.rotation at all just the transform.position.

// This one moves in a circle pattern but unfortunately shakes violently which I don't want.
// Also it does not move forward which I do want it to do.

// Most importantly, I don't want it to immediately move on Start. I want it to move after something is true. When I put it on FixedUpdate it moved too quickly.

// Thank you for any help! =)

void Start()
{
StartCoroutine(MoveCircularly());
StartCoroutine(MoveForward());
}

IEnumerator MoveForward()
{
while ( condition )
{
g.transform.Translate(Vector2.right);
yield return new WaitForEndOfFrame();
}
}

IEnumerator MoveCircularly()
{
while ( condition )
{
//move in a circle
yield return new WaitForEndOfFrame();
}
}


It sounds like you're describing a curve called a helix:

You can do this in a single function:

IEnumerator MoveInHelix(Matrix4x4 space, float radius, float frequency, float linearSpeed) {

float progress = 0;

while(true) {
progress += Time.deltaTime;
float angle = progress * frequency * Mathf.PI * 2f;
transform.position = space * new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), progress);
}
}

• Thank you for the response it looks reasonable, I was able to solve it but I can also try your code out. Much appreciated =) Sep 7, 2019 at 1:07

what you are looking for is polar coordinates in 2d and variable z. maybe its called cylinder coordinates.

in polar or circular coordinates, position is defined by radius and angle. as unity and other simulation systems use cartesian coordinates, then you have to do a change coordinate to show it in unity.

 private void FixedUpdate()
{
foreach (var item in PolarElements)
{

float x = item.radius * Mathf.Cos(item.myAngle);
float y = item.radius * Mathf.Sin(item.myAngle);

item.position = new Vector3(transform.position.x+  x,transform.position.y+y,transform.position.z);
item.myAngle += item.speed;
}
}


you can replace **transform.position.z** with any z value you want

• Thank you for the response =). This one looks great for 2D which I needed and simpler to configure, I'll check this code out. Cheers! Sep 7, 2019 at 16:58

I solved it by having one Game Object move in a circle and add a Game Object into the Game Object moving in a circle and have it move forward. That's the best I can do since IEnumerator wasn't working both functions at the same time for me.