Increasing the size of an object as time passes

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By merpis

I’m a complete noob and have been following this tutorial - https://www.youtube.com/watch?v=WEt2JHEe-do&t=4078s and I would differ from the tut and add a mechanic where the enemies get larger as time progresses to make it harder. But, sense I’m a noob, I don’t know how to do that. I did try this though:

extends RigidBody2D

export var min_speed = 150.0
export var max_speed = 250.0
var size = $AnimatedSprite.scale(2, 2)
var size_collision = $Collision.scale(2,2)

func _ready():
$AnimatedSprite.playing = true
var mob_types = $AnimatedSprite.frames.get_animation_names()
$AnimatedSprite.animation = mob_types[randi() % mob_types.size()]

func _on_VisibilityNotifier2D_screen_exited() → void:
queue_free()

func _on_SizeTimer_timeout() → void:
size += 1
size_collision += 1

and it no work :confused: error message was: attempt to call function ‘scale’ in base ‘null instance’ on a null instance

:bust_in_silhouette: Reply From: ramazan

var size = $AnimatedSprite.scale(2, 2) # error
==>
onready var size = $AnimatedSprite

var a : int # 0 // write 1 here
var b : int # 0 // write 1 here
func onSizeTimertimeout():
a += 1
b += 1
size.scale = vector2(a,b)