- Home /
Best way to have Game Boundaries using "Translate to move"
Hey gang just wondering the best way to implement game boundes the player cant go past while using translate to move, since collisions do not work with translate :)
Answer by Hanoble · Oct 05, 2017 at 05:56 PM
There are several ways you could do this, but the one that makes most sense probably still uses collision. You can attach colliders marked as triggers to your moving object and boundaries, and within your custom movement check for any of the OnTriggerEnter callbacks and handle the case accordingly.
You could alternatively, or even in conjunction with the OnTriggerEnter logic, insert raycast checks into your movement code and only allow movement in valid directions where the raycast has ensured there is still room to move.
Alternatively, depending on your game you could even use a simple distance check from an arbitrary starting point, and consider anything outside of a defined range outside of the boundaries.
Without knowing the requirements of the game it is a very vague question, but there are a slew of options out there even if you are not using the built-in physics. It comes down to what makes sense for your game and what is practical.
Your answer
Follow this Question
Related Questions
getting udp package info inside unity (GlovePIE) 0 Answers
Setting boundary for Z axis 1 Answer
Progress lost after resetting game 2 Answers
Selling Games made with Free Assets 4 Answers
lightmapping vs realtime for racing cars 0 Answers