Topic was automatically imported from the old Question2Answer platform.
Asked By
Turnovus
I’m working on a top-down space shooter using rigidbodies like in Asteroids, but I intend to allow the player to travel through a very large area. However, I don’t want the play area to be infinite, so I plan to add invisible walls so that the player will be bounced away when they go farther than I want them to be able to go. What is the best way to implement this?
If you’re using add_force or apply_impulse you can use colliders and give the player a bouncy physics material. Another way would be to use an area and use body_exited when the player exits it, direct the player back in or towards the area using translate or look_at, or you could clamp the translation x and y values but that would stop the player instantly.