Help fixing rescale code.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DevBadger10

I am trying to make it so that when you scroll, a node changes size. It’s not working. Here’s my code:

    if Input.is_action_pressed("downscroll"):
			self.scale.x -= 0.5
			self.scale.y -= 0.5
    if Input.is_action_pressed("upscroll"):
			self.scale.x += 0.5
			self.scale.y += 0.5

It should work but it isn’t. I have upscroll and downscroll all set up. This is in the _process() function, and only works when the mouse is in the area, which works with all other input.

why has noone seen my question lol

DevBadger10 | 2023-03-28 00:45

Welp guess it’s lost in the sea. Hopefully someone might see it soon.

DevBadger10 | 2023-03-28 03:01

How are you scrolling ? Are you using ScrollContainer or not ? And scale is between 0 and 1 isnt using 0.5 too high of a value ?

Enfyna | 2023-03-28 08:20

It’s on the input map. And the scale can be more than 1, by default it’s 2

DevBadger10 | 2023-03-28 08:22

func _input(event):
    if Input.is_action_pressed("upscroll"):
	    $node.scale += Vector2(0.05,0.05)

You can try using the _input(event) function. And I know scale can be higher than 1 but if you set it to 0.5 it will scale down or up very quick it wont even look good I guess.

Enfyna | 2023-03-28 08:38

Thanks for the help!

DevBadger10 | 2023-03-28 09:30

Could you make it an answer so I can add it as the selected one?

DevBadger10 | 2023-03-28 09:31

:bust_in_silhouette: Reply From: Enfyna
func _input(event):
    if Input.is_action_pressed("upscroll"):
        $node.scale += Vector2(0.05,0.05)

You can try using the _input(event) function and use a smaller number.