Is it more optimal to use a collider to prevent players from leaving screen ?
Is it more optimal to use a collider to prevent players from leaving screen ? I have seen some tuts coding the numbered location that the player cannot exit screen and doing this all in code...
so is it better to use colliders to stop them from leaving screen or coding it? and please explain whats the difference pros and cons of each
Thanks
Answer by romatallinn · Nov 12, 2016 at 08:57 PM
It is difficult to determine which one is the best. Both are acceptable. The only things that may affect your choice is your purposes and preferences. For example, I have a game that have a circular gameplay. Camera rotates around specific point only. The player is on the screen. I could use colliders (I actually did this at the beginning, but there was a bag), but for me it is much easier to use code to keep the player where I want. Also, somebody likes that everything might be changed in code, but others like to use editor staff (so, using colliders). Of course, you should avoid some complex colliders due to performance. However, using a few standard colliders to keep the player within the screen is completely fine.
so it sounds like coding a player to not leave screen bounds is more optimal correct?
I think so since theres no objects just simple code preventing him from doing so. . again it makes no difference to me I just want to know which is less of a load on game so less heavier, also this game will be parallax scrolling so im not sure just yet how to make ongoing colliders so coding sounds more optimal