|Topic was automatically imported from the old Question2Answer platform.
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?
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:
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.
Hi, can you please explain what do you mean by Origin_location, I have no luck scaling my character.
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.
Spyrex | 2021-10-22 13:58