0 votes

I want to make a path around the whole screen that spawns enemies, but when the screen's height is higher than the base height that is set in the Project Settings, even tho the Stretch/Aspect is set to expand, the enemies will start spawning that much higher up when they are supposed to spawn at the bottom. I want to make it flexible so it works properly on every phone.

I guess I should use the OS.getwindowsafearea() in the Path2D.curve.addpoint(), but I don't know how. Or I might be completely wrong.

in Engine by (12 points)

1 Answer

0 votes

Hello. I would like to propose a solution that worked for me.

In Main scene script I would write:

func _ready():
screen_size = get_viewport_rect().size
# Clear all Vector2 points

# Set 1st vector
# Set 2nd vector
$MobPath.curve.add_point(Vector2(screen_size.x, 0))
# Set 3rd vector
$MobPath.curve.add_point(Vector2(screen_size.x, screen_size.y))
# Set 4th vector
$MobPath.curve.add_point(Vector2(0, screen_size.y))
# Set 5th vector
$MobPath.curve.add_point(Vector2(0, 0))
by (14 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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.