0 votes

Hello.
I need some help with my player that is supposed to scale down as it moves up (as it is getting far away from location) and scale up as the player comes back. Can anyone help?

Godot version 3.3.2
in Engine by (72 points)

1 Answer

0 votes
Best answer

Use the scale property of the KinematicBody2D to scale it.
To get the value to scale to, you can use the distance_to ( Vector2 ) method of the Vector2 class and make it negative, to scale down on higher distances and vice versa.
Example script of the kinematic body:

func _process(delta):
    scale = -(ORIGIN_LOCATION.distance_to(position)) * FACTOR

You will have to adjust the FACTOR constant that is responsible for how fast the body will scale up to meet your requirements.

by (160 points)
selected by

Hi, can you please explain what do you mean by Origin_location, I have no luck scaling my character.

The ORIGIN_LOCATION is the variable that contains the location the player is moving away from. The greater the distance from the player to this distance is, the smaller the player will be scaled.

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.