Looped Animation
There are tokens on my chessboard, if selected by clicking leftbutton I want them to rotate, if I click again it should stop. What would be the proper way to do that in unity? I tried to write a simple function with no success yet. I either have a unending loop or the token only moves for 1 frame. Here is what ive tried... Every variable was declared.
--------------In my update function-------------------------
if(selectionX > 0 && selectionY > 0 && (Input.GetMouseButtonUp(0)))
{
SelectToken();
}
private void SelectToken() { Vector3 vec = Vector3.up;
SelectedToken = Tokens[selectionX, selectionY];
while(SelectedToken != null)
{
vec.y *= (90 * Time.deltaTime);
Tokens[selectionX, selectionY].transform.Rotate(vec);
if(Input.GetMouseButtonUp(0))
{
SelectedToken = null;
}
}
Your answer
Follow this Question
Related Questions
Can´t find the infinite loop in this script 0 Answers
Add Event in animation from another Gameobject 5 Answers
UI event with non-instantiated Prefab as event handler. What happens? 2 Answers
Whty would ScreenPointToLocalPointRectangle return a negative position? 0 Answers
animatedtile event 0 Answers