Changing ball direction according to GUI object.
Assuming you want it framerate independent, maybe you can divide the difference in time between frames by an appropriate interval to provide a function to tell you your "direction" change, then represent this variable in the UI. You wouldn't read the UI to get the direction, but use the direction value to set the UI. When it's clicked, you just check the time it was clicked and compare it to the previous time and direction to derive the appropriate direction for that click time.
Say, you want it to travel one degree of your 120 each milisecond. You would check the time at the point of drawing your frame, compare it to the previous one (subtract), and then divide by a milisecond. Then add that to the previous direction value to get your new one.
If it's going back and forth, you may want to toggle a bool when you go over/under a certain degree, and add/subtract the difference to account for the "bounce" that happened between frames.
I think you're approaching this backwards.
Assuming you want it framerate independent, maybe you can divide the difference in time between frames by an appropriate interval to provide a function to tell you your "direction" change, then represent this variable in the UI. You wouldn't read the UI to get the direction, but use the direction value to set the UI. When it's clicked, you just check the time it was clicked and compare it to the previous time and direction to derive the appropriate direction for that click time.
Say, you want it to travel one degree of your 120 each milisecond. You would check the time at the point of drawing your frame, compare it to the previous one (subtract), and then divide by a milisecond. Then add that to the previous direction value to get your new one.
If it's going back and forth, you may want to toggle a bool when you go over/under a certain degree, and add/subtract the difference to account for the "bounce" that happened between frames.
I could not use GUI object but, I found different way, I am moving ball to right side to left then left to right, for this I used 2 cubes near the ball, the cubes are applying force to ball :)