0 votes

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?

asked Jun 23, 2019 in Engine by Turnovus (36 points)

2 Answers

+1 vote
Best answer

The easiest would be to stick 4 rectangular static bodies at the edges. Give them collision shapes but no sprites and they'll be invisible.

answered Jun 23, 2019 by kidscancode (17,776 points)
selected Jun 24, 2019 by Turnovus

Indeed, so far works alright for me, just make sure the walls are thick enough to avoid any possibility for objects to go through them.

0 votes

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.

answered Jun 23, 2019 by Magso (2,867 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.