+1 vote

Hello all,

So coming from Unity I wanted an engine that was less bloated and more geared towards 2D. I am literally a few days into this so this could be a bonehead question.

So I downloaded Godot 3 and created a Node2D with a Sprite and Tween as children:


The sprite is the blue godot included image. Then put a script on the Node2D:

extends Node2D

onready var tween = get_node("Tween")
onready var sprite = get_node("Sprite")

func _ready():
    tween.interpolate_property(sprite, "transform/scale", Vector2(10,10), Vector2(1,1), 1.0, Tween.TRANS_ELASTIC, Tween.EASE_OUT)

But when I run it, nothing happens. As a sanity check, I downloaded version 2.1.4 and created the same scenario and script, and when I run it the animation plays fine. I can't imagine such a 'simple' thing would be broken from v2 to v3 so hoping someone can provide some guidance.

in Engine by (16 points)

1 Answer

+3 votes
Best answer

One of the big changes from 2.1 to 3.0 was in naming things. The property name is now "scale" (which you can see by hovering over the property in the Inspector.

In addition, here's a couple of other tips:

  • GDScript in 3.0 includes a shorthand to avoid typing all those get_node()s. You use $<node_name> to mean the same thing. In my mind, it leads to much more readable code.

  • pass is a placeholder for an empty function. You should delete it.

For example, here's how I would rewrite this script for 3.0:

extends Node2D

func _ready():
    $Tween.interpolate_property($Sprite, "scale", Vector2(10,10), Vector2(1,1), 1.0, Tween.TRANS_ELASTIC, Tween.EASE_OUT)
by (20,379 points)
selected by

Thank you so much! Looking forward to watching some of your videos =)

whew I've been looking for this answer for weeks.

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.