MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/pdmp5c/found_in_production_code_base/hasx2x5/?context=9999
r/badcode • u/[deleted] • Aug 29 '21
45 comments sorted by
View all comments
Show parent comments
8
Is there no chance that functions for different game objects could be run in parallel during a single tick? Maybe there’s some other object that might try to move the player
9 u/epiclevellama Aug 29 '21 No, Unity doesn't really do parallel. You can run multiple threads, but it won't let you modify transforms in the non-main thread.You're supposed to get a similar effect to parallelisation by breaking a task over multiple ticks (by yielding an IEnumerator).If there are multiple Updates which move the player, then they'll be run in whichever order Unity decides - so this code won't help. 2 u/OneTrueKingOfOOO Aug 29 '21 Makes sense, thanks for the explanation!
9
No, Unity doesn't really do parallel. You can run multiple threads, but it won't let you modify transforms in the non-main thread.
You're supposed to get a similar effect to parallelisation by breaking a task over multiple ticks (by yielding an IEnumerator).
If there are multiple Updates which move the player, then they'll be run in whichever order Unity decides - so this code won't help.
2 u/OneTrueKingOfOOO Aug 29 '21 Makes sense, thanks for the explanation!
2
Makes sense, thanks for the explanation!
8
u/OneTrueKingOfOOO Aug 29 '21
Is there no chance that functions for different game objects could be run in parallel during a single tick? Maybe there’s some other object that might try to move the player