Skip to main content
1 of 2
Kil'jaeden
  • 141
  • 1
  • 3

How to scale down (decrease size) of an instanced Node/Scene?

I'm trying to decrease size of instanced RigidBody2D scene through code.

With "scale()" method I'm trying to decrease the size of the image/sprite that's attached to the RigidBody2D. The problem is, it's not working.

No matter how much I try to scale down, the size of the blood drop circle remains the same.

Why is this?

This is my example code.

const blood_druple_scn = preload("res://Scenes/blood.tscn")

func spawnBlood():
    var newBlood = Blood_druple_scn.instance()
    
    rotationAdd = rotationAdd + 30
    
    if(switchBloodSize == 0):
        set_scale(Vector2(2,1)) //This part is my problem
        print("blood size: ", newBlood.get_scale())
        add_child(newBlood)
        switchBloodSize = 1
    
    elif(switchBloodSize == 1):
        newBlood.scale(Vector2(0.5,0.5)) //This part is my problem
        print("Blood size: ", newBlood.get_scale())
        add_child(newBlood)
        switchBloodSize = 0
    
    newBlood.set_pos(Vector2(100,100))
    rotate(rotationAdd)

As you can see I have 2 different If conditions each with different scale() size. Sadly they are both remain the same size even tho I gave different values to each of them.

Strange part is, it does print that the scale values has been altered. So I guess Blood instance isn't visually changing.

Kil'jaeden
  • 141
  • 1
  • 3