¿How to store variables?

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

Hello, sorry if i didnt explain well in the title, but i am making a slime kind enemy, im trying to make it divide after being shot, and then reduce his size, ive already solved the size thing, but im having problems into make it divide, i saw a post in godot related to this and i used
var Slime = PackedScene.new() Slime.pack(self) var slime = Slime.instance() var scene_root = get_parent() scene_root.add_child(slime)
It does divide the slime, but it ends with a small one and a normal size one, the question is, how can i store the size variable to replicate it in the child? sorry i think i still cant explain myself well.

:bust_in_silhouette: Reply From: db0

Assuming original_slime is pointing to the original slime node which is now resized and new_slime is pointing to the new slime you just added, and you’ve used scale to resize it:

new_slime.scale= original_slime.scale

:bust_in_silhouette: Reply From: dethland

Maybe you could add a bool variable to the slime’s script called “isBigSlime”. This variable will be set as true by default. Then, you could change this variable to false when you create a smaller slime instance of it. You could use this bool in the _ready function to rescale it when it is false.