Reputation: 11
I am new to C# and I need some help with this code. After I added code to make the shift key move the object faster it makes unity freeze. This is my code that makes Unity Crash. The only changes are the added variable shift_speed_multiplier and the while statement. https://i.sstatic.net/AGnhs.png
Upvotes: 0
Views: 56
Reputation: 430
That while
statement is being constantly run while the shift key is pressed. Therefore, nothing else (not even other game entities) can be updated. The solution to that is simply to use an if
instead of a while
, that will only update the speed once, without running in a loop.
Upvotes: 1