So I am using unity and wondering if I have an agent going to move to a position say Agent A moves to position B in x seconds guaranteed (avoids all physics or things that could disrupt the path). When agent A gets to his destination I want to trigger some effect C.

I was thinking you could do this same sequence with both colliders that are trigger and coroutines but wouldn't doing it with coroutines be more efficient and if so by how much ?

  • 2
    \$\begingroup\$ "Is A faster than B, and by how much" is a class of question that you can answer more authoritatively by building a simple test scene and profiling the results. We'd have to do the very same test in order to get the numbers to cite, so you might as well skip the intermediary and do the test yourself. If you do, be sure to post your findings as an answer below! \$\endgroup\$
    – DMGregory
    Dec 13, 2021 at 1:43
  • \$\begingroup\$ Have you considered all the edge-cases? Like what happens if B moves or disappears while A is moving towards it? \$\endgroup\$
    – Philipp
    Dec 13, 2021 at 8:45

1 Answer 1


Physics is usually the most complex part in a comparison. however, triggers aren't really physics, they're just collision detection which is quite fast for primary shapes. On the otherhand, coroutine doesn't need half the calculation triggers need. In fact, the only calculation a coroutine needs is some TIME behind the scenes, so, coroutines are much faster than collision detection, however, depening on your case, you might want to use the trigger way because you are literally looking for a collision detection. It's not that heavy even on mobiles.

  • 1
    \$\begingroup\$ This answer would be better if it included some profiling results to back up its assertions. \$\endgroup\$
    – DMGregory
    Dec 13, 2021 at 12:53
  • \$\begingroup\$ @DMGregory physics being one of the most resource-heavy computations is common among all game engines ( physics engines). if you want to go deeper, you can read online about how much CPU-GPU resource is usually in use for physics ... coroutine is by far faster than collision detection, but yes, a sampling would be nice to have a more accurate info. though I don't have the time for doing one at the moment. \$\endgroup\$
    – Cool guy
    Dec 13, 2021 at 18:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .