JB
23 Mar 2021
Example for you to make your Cube to move in circle:
public MeshRenderer Renderer;
float timeCounter = 0f;
float speed = 5.0f;
float height = 5f;
float width = 5f;
void Start()
{
transform.position = new Vector3(3, 4, 1);
transform.localScale = Vector3.one * 1.3f;
Material material = Renderer.material;
//Static Color
material.color = new Color(0.5f, 1.0f, 0.3f, 0.4f);
}
void Update()
{
timeCounter += Time.deltaTime * speed;
float x = Mathf.Cos(timeCounter) * width;
float y = Mathf.Sin(timeCounter) * height;
float z = 1f;
transform.position = new Vector3(x,y,z);
}
}
Example for you to make your Cube to move in circle:
public MeshRenderer Renderer;
float timeCounter = 0f;
float speed = 5.0f;
float height = 5f;
float width = 5f;
void Start()
{
transform.position = new Vector3(3, 4, 1);
transform.localScale = Vector3.one * 1.3f;
Material material = Renderer.material;
//Static Color
material.color = new Color(0.5f, 1.0f, 0.3f, 0.4f);
}
void Update()
{
timeCounter += Time.deltaTime * speed;
float x = Mathf.Cos(timeCounter) * width;
float y = Mathf.Sin(timeCounter) * height;
float z = 1f;
transform.position = new Vector3(x,y,z);
}
}
Made with