- Home /
Question by
tripathi_kush · Mar 19, 2018 at 10:21 AM ·
directionchangerotate objectrotatearoundorbit
how to change orbit direction when button clicked?
i'm trying to develop a simple game. my question is i am using following code to move object into clockwise orbit. i like to change the the direction ob object into anticlockwise orbit when button is pressed. please help me
//Increase the speed from 1 to 10 over 60 second.
currentSpeed = Mathf.SmoothStep(1f, 10f, time / accelerationTime);
// Decides speed of the ball.
newSpeed += Time.deltaTime * currentSpeed;
// Move the ball in Circular position accordingly speed.
transform.position = new Vector3(Mathf.Sin(newSpeed) * 40, 5, Mathf.Cos(newSpeed) * 40);
//Increase time with actual time.
time += Time.deltaTime;
if(Input.GetMouseButtonDown(0) )
{
transform.position = new Vector3(Mathf.Cos(newSpeed) * 40, 5, Mathf.Sin(newSpeed) * 40);
}
else { }
Comment