#How to make a input that increases a lights strength when held down?

7 messages · Page 1 of 1 (latest)

limpid vapor
#

Hey i was wondering if anyone knew a way for me to make a input that increases the strength of a light when held down, and removes strength of it when released?
I cant seem to find any tutorials on how to do this, i could have missed someone talking about it, but ive been stuck on this for a while now and cant really seem to figure it out. Any help would be appreciated 👍

rotund fern
#

is this what youre looking for?

extends Node3D

@onready var omni_light_3d = $OmniLight3D

func _process(delta):
    if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
        omni_light_3d.light_energy = 5
    else:
        omni_light_3d.light_energy = 1
limpid vapor
#

ill give it a try and come back to let you know 👍

#

close, im trying to make it to where the input slowly increases the strength over time, like increasing the strength the longer the input is held down more, with a limit ofc. and slowly decreasing the strength over time when the input is released, sorry if i wasnt specific enough.

rotund fern
#
extends Node3D

@onready var omni_light_3d = $OmniLight3D

func _process(delta):
    if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
        if omni_light_3d.light_energy < 5:
            omni_light_3d.light_energy += 0.1
    else:
        if omni_light_3d.light_energy > 1:
            omni_light_3d.light_energy -= 0.1
#

like this?

limpid vapor
#

exactly! thanks for the help man, new to coding so the help was much needed.