All Questions

Community

ltsdw

Spells manually selected from the inspector in the inherited scenes would be drawn a top of another.

So I created a sprite sheet because I wanted to know the experience to create one and decided to create an inherited scene from the robot, and it works nice.


except when I need to manually select another spell for my inherited scene, then it will draw the two spell a top of another.

I don't know why, but the spell.queue_free() was never getting called, changing that part of code to after the yield seems to solve it.

func set_spell_scene(scene: PackedScene) -> void:
    spell_scene = scene

    # If the node hasn't been added to the scene tree yet, pause the function until it emits its "ready" signal.
    # This is necessary if you assign a spell scene in the Inspector, as Godot will try to run this function right after creating this node in memory, before adding it to the scene tree.
    if not is_inside_tree():
        yield(self, "ready")

    if spell:
        spell.queue_free()

So I don't know if I shouldn't inherit from the robot and this is supposed to work this way. But now it work if I manually select the spell from the inspector and if the spell is changed through pickups.

  • Nathan Lovato replied
    Solution

    We haven't designed the robot to support inherited scenes so it's likely that you'll get unexpected behavior by doing so.

    This code is designed to work with pickups, and with a spell equipped at the start of the game.

    func set_spell_scene(scene: PackedScene) -> void:
        spell_scene = scene
        if spell:
            spell.queue_free()

    It's possible that if you try to change the spell at the start of the game, through your inherited scene, before the node was added to the scene tree, it will fail.

  • ltsdw replied

    Oh ok, it's working right now, but I think I'll just write a new script to use it with this skeleton scene then. Thank you!