simulate a circle move

I wanted to make sure that my item would make a 180 ° turn. I tried something like this but did not come back. You know you help me?

#pragma strict
 
var incr : float = 0.1;
var angle : float = 0.0;
 
 
function Start () {
 
 
}
 
function FixedUpdate () {
 
     while(angle < 180 * 6.28 / 360 ){
 
 
   transform.position = Vector3(30*Mathf.Sin(angle)*Time.deltaTime, 30*Mathf.Cos(angle)*Time.deltaTime,0);
    angle+=0.1;
     
       
        }
 
}

You have two problems here. First, Mathf.Sin() takes radians, not degrees. Second is your use of while(). You want do a bit of work each frame, not do multiple moves per frame. Try this:

#pragma strict

var incr : float = 0.1;
var angle : float = 0.0;

function FixedUpdate () {
     if  (angle < 6.28){
   		transform.position = Vector3(30*Mathf.Sin(angle)*Time.deltaTime, 30*Mathf.Cos(angle)*Time.deltaTime,0);
    	angle+=0.1;
     }
}

In the end the problem was nell’if. I had used the wile. With this code, I got what I wanted. Thanks for your help! :slight_smile:

#pragma strict
 
var incr : float = 0.1;
var angle : float = 0.0;
 
function FixedUpdate () {
     if  (angle < 180 * 6.28 / 360){
           transform.position = Vector3(100*Mathf.Sin(angle)*Time.deltaTime, 100*Mathf.Cos(angle)*Time.deltaTime,0);
        angle+=0.1;
     }
}