I have been reading up on coroutines, and I am sort of confused by them. I know they can yield and such and their useful for code that goes from one step to another.
I have read in various places that if you use a coroutine to perform calculations instead of doing it in the update and you use yield return new WaitForSeconds ( 0.1f ), or something to that extent, and it will make the game run smoother.
I have a script that has code that produces 3 rays (3 methods) that detect tiles, but also in the script I have the code for a character to pick-up and place blocks.
I made the 3 methods into coroutines, but when i was watching the Main Threads Ms, it seemed to be slower than just having the methods in update. Is this because coroutines do not run separate from the main thread and its detecting one ray first, then the next, then the next and also when doing the block pick-up and place code, its stopping until that code is done?
If this is not the way to optimize the code, what is?
Wow, that is a long question, if nobody answers it, that is ok, but thanks if you do!