Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

The test room runs great, I think what's tanking performance is updating the projector image the way I am (which is probably not the best way but i don't know a better way).


This is the code I have that gets the video into the projector:


extends SpotLight3D

@export var video_viewport: SubViewport

var projector_texture:ImageTexture

var timer:Timer

var image:Image

func _ready() -> void:

    timer = Timer.new()

    timer.connect("timeout",update_image)

    #Only update the projector video every 1/24 of a second (the video framerate)

    timer.wait_time = 0.042

    add_child(timer)

    timer.start()

    image = video_viewport.get_texture().get_image()

    projector_texture = ImageTexture.create_from_image(image)

    light_projector = projector_texture


func update_image() -> void:

    image = video_viewport.get_texture().get_image()

    projector_texture.set_image(image)

Don’t use a timer for updating the image, not a great way of doing it. I don’t understand your code and what you’re trying to achieve very well to give better advice.

For updating the frame, use _process and use the delta for having the correct time to update the frame.

You might get more useful help in the discord server in the GoZen channel ;)