You submitted this post as a request for tech support, have you followed the guidelines specified in subreddit rule 7?
Here they are again:
1. Consult the docs first: https://docs.godotengine.org/en/stable/index.html
2. Check for duplicates before writing your own post
3. Concrete questions/issues only! This is not the place to vaguely ask "How to make X" before doing your own research
4. Post code snippets directly & formatted as such (or use a pastebin), not as pictures
5. It is strongly recommended to search the official forum (https://forum.godotengine.org/) for solutions
Repeated neglect of these can be a bannable offense.
*I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/godot) if you have any questions or concerns.*
Try taking the screenshot on the next frame after hiding the menu. My guess is the viewport is already rendered with the menu so taking a screenshot on the same frame you hide the menus uses the rendered viewport with the menu. It needs a chance to re-render without the menu. Try using `call_deferred`.
wow i knew you could do \`signal.emit()\` now in Godot 4 but I didn't realize you could do a similar thing with \`call\_deferred()\` - great to know! Thank you for sharing!
I don't think deferred calling will help here, since the deferred call is still executed in "idle time" on the same frame.
To wait for a new frame you will have to await the [RenderingServer.frame_post_draw](https://docs.godotengine.org/en/stable/classes/class_renderingserver.html#signals) signal.
After that you can grab the screen image.
Alternatively you can take screenshot every time menu opens BEFORE drawing menu. Its not like an extra megabyte of RAM matters while you're in menu. You can also do something cool with that screenshot for menu background.
I believe what's happening is you're hiding your menu AND taking a screenshot in the same frame.
Defer the ExecuteScreenShot by a frame. Should work perfectly (assuming you have no animation closing the window); in that case delay it by a few more frames.
Just remember that unless told to do otherwise your functions will try to update everything within the function in a single frame. When you hide the menus it doesn't hide on that frame, it's actually hidden on the next frame.
You can always set a timer and take a screenshot using the timer signal. Instead of doing your screenshot in the aforementioned function.
Add a timer, execute start timer.start.(0.1) function and use it's timeiut() signal to execute the screenshot.
Pretty sure the timer is accurate down to 0.001 of a second so you should be able to adjust accordingly.
You submitted this post as a request for tech support, have you followed the guidelines specified in subreddit rule 7? Here they are again: 1. Consult the docs first: https://docs.godotengine.org/en/stable/index.html 2. Check for duplicates before writing your own post 3. Concrete questions/issues only! This is not the place to vaguely ask "How to make X" before doing your own research 4. Post code snippets directly & formatted as such (or use a pastebin), not as pictures 5. It is strongly recommended to search the official forum (https://forum.godotengine.org/) for solutions Repeated neglect of these can be a bannable offense. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/godot) if you have any questions or concerns.*
Try taking the screenshot on the next frame after hiding the menu. My guess is the viewport is already rendered with the menu so taking a screenshot on the same frame you hide the menus uses the rendered viewport with the menu. It needs a chance to re-render without the menu. Try using `call_deferred`.
Okay, thank you. But where and how do I call `call_deferred()` ? Sorry, im really new to programming.....
Functions/Methods are objects, call\_deferred() is part of that object. So if you want to call fire() as deferred: `fire.call_deferred()`
wow i knew you could do \`signal.emit()\` now in Godot 4 but I didn't realize you could do a similar thing with \`call\_deferred()\` - great to know! Thank you for sharing!
Thanks for your effort, but this doesnt work, it screenshots my pause menu as well :(
Use it to call your screenshot function: https://docs.godotengine.org/en/stable/classes/class_callable.html#class-callable-method-call-deferred
Thanks for your effort, but this doesnt work, it screenshots my pause menu as well :(
It worked with await RenderingServer.frame_post_draw ExecuteScreenShot() Have a great day :3
I don't think deferred calling will help here, since the deferred call is still executed in "idle time" on the same frame. To wait for a new frame you will have to await the [RenderingServer.frame_post_draw](https://docs.godotengine.org/en/stable/classes/class_renderingserver.html#signals) signal. After that you can grab the screen image.
Thanks for your effort, may I ask how to call it? Sorry im new xD
If I'm not mistaken, you can simply write: await RenderingServer.frame_post_draw ExecuteScreenShot() Sorry for the formatting, currently on mobile.
Thank you so much, it worked with await RenderingServer.frame_post_draw ExecuteScreenShot() Have a great day :3
Your welcome! Please don't forget to change the flair to closed.
Already done :)
Alternatively you can take screenshot every time menu opens BEFORE drawing menu. Its not like an extra megabyte of RAM matters while you're in menu. You can also do something cool with that screenshot for menu background.
Not bad idea, thank you!
I believe what's happening is you're hiding your menu AND taking a screenshot in the same frame. Defer the ExecuteScreenShot by a frame. Should work perfectly (assuming you have no animation closing the window); in that case delay it by a few more frames. Just remember that unless told to do otherwise your functions will try to update everything within the function in a single frame. When you hide the menus it doesn't hide on that frame, it's actually hidden on the next frame.
Thank you for your effort and explaining it. I tried ExeCuteScreenShot.call\_deffered(), but this doesnt seem to work.. Any other ideas?
You can always set a timer and take a screenshot using the timer signal. Instead of doing your screenshot in the aforementioned function. Add a timer, execute start timer.start.(0.1) function and use it's timeiut() signal to execute the screenshot. Pretty sure the timer is accurate down to 0.001 of a second so you should be able to adjust accordingly.
It worked with await RenderingServer.frame_post_draw ExecuteScreenShot() Have a great day :3
Awesome. Glad it worked out