![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | rellekd |
im trying to recreate iron lung’s submarine mechanic by take a picture of what a camera sees by exporting the contents of a viewport. my stucture is:
- kinematic body 3d
- collision shape
- node3d
- a bunch of mesh instances to make the shape of the submarine the player is inside
- viewport
- camera (with script attached)
the script is:
extends Camera
func _ready():
takePhoto()
func takePhoto():
var vpt = get_viewport()
var txt = vpt.get_texture()
var image = txt.get_data()
image.flip_y()
image.save_png("break.png")
break.png appears but it is just a black image. i tried attaching the script to the viewport instead but it gave me the same result. sorry if this is a bad question, this is my first time using viewports