4
\$\begingroup\$

I'm trying to decrease size of instanced RigidBody2D scene, through code. With scale(), 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.


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 two different if conditions, each with a different scale() and size. Sadly, both remain the same size. The strange part is that it does display the scale values as been altered, yet the newBlood instance is not visually changing. Why is this?

\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

According to this issue https://github.com/godotengine/godot/issues/179 you cannot change rigid bodies scale. What is suggested is to scale your nodes instead, for example:

var sprite = newBlood.get_node("./Sprite")
sprite.scale(Vector2(0.5,0.5))

This "limitation" only occurs in Rigid and Character modes, by the way.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .