0 votes

I'm trying to make a gun scope for my shooter game. I designed an overlay but since it's a square I want to fill the rest of the screen with a black border.
I created a mockup to show how the player's screen is going to look like:
https://imgur.com/a/m2Yggzy
I have no Idea how to do the black borders.
NOTE: The player should still be able to see the game in the entire screen size, the view should only be limited once they aim.

Godot version v3.4.2.stable.official
in Engine by (82 points)

2 Answers

0 votes

Couldn't you just make the image a rectangle or use a ColorRect to fill the blank space?

by (7,769 points)

Thank you for your quick answer!
I tried using a color rect and a HBoxContainer but I'm unsure how I can ensure the image is as big as possible.
Making the image a rectangle also wouldn't work since the window can have different sizes.

0 votes

Add a canvas layer with the black border as a sprite on that canvas layer. The control whether it is on the screen with the .visible attribute.

See the documentation here for some more info on that
https://docs.godotengine.org/en/stable/classes/class_visibilitynotifier2d.html

Set up a function and when you go into a "sniper" mode set the canvas layer sprite as visible and when the player comes out of "sniper" mode set the canvas layer sprite as not visible.

by (1,635 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.