0 votes

Hi,

I'm new to Godot, so this might seem a simple question, but how do I go about changing the scale/size of the player controlled character via a keypress?

Searching for scale just seems to bring up the wrong kind of scaling for gscript that I think I need.

Thanks.

in Engine by (12 points)

1 Answer

+1 vote

You'd modify the scale variable. However it is a Vector2, so you'll have to set/modify it with a Vector2, or modify the Vector2's values:

var scale_speed = .5

func _process(delta):
    if Input.is_action_pressed("ui_down"):
        scale -= scale_speed * delta * Vector2(1, 1)

    if Input.is_action_pressed("ui_up"):
        scale.x -= scale_speed * delta
        scale.y += scale_speed * delta

    if Input.is_action_pressed("ui_accept"):
        scale = Vector2(1, 1)
by (64 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.