0 votes

Hi,

I have a simple projectile that is an Area2d with a sprite in it. I am moving towards a set position. I want to scale down based on how far along I am - 50% of the way there should be 50% smaller etc.

node.scale(Vector2(0.5, 0.5)) seems to be additive because my node (projectile) disappears quickly. What am I doing wrong here?

var percentleft = targetpoint.distance_to(self.get_global_pos())/initialflightdistance
self.scale(Vector2(percentleft ,percentleft))

I am thinking that I need some other approach, like a global scale. This call seems to be "additive" to the existing scale on the object? So I might scale to 90% then 90% of that 90% then 90% of that and so on.

Thanks,

Judd

in Engine by (41 points)

2 Answers

0 votes

This seems like the perfect opportunity to use a Tween:
http://docs.godotengine.org/en/2.1/classes/class_tween.html

Set the Tween to interpolate the transform/scale property.

by (19,651 points)

I will look into that. Thank you.

0 votes

You want to use set_scale() if you want to specifically set it, scale() applies the value against the current scaling.

by (5,192 points)

So "scale" scales the value you already have, and set_scale is absolute then? That makes sense based on what I am seeing.

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.