Hello! I made a door scene that I can add to my maps to transition to other levels when clicked. The transition logic is inside this door scene, but I would like the doors to have different sprites. The problem is I can't change the sprite individually for a instantiated scene. I would also like to give them different animations on mouse hover. Is there a way to do this?

    Godoten The problem is I can't change the sprite individually for a instantiated scene

    Why?

      xyz I don't see how. The sprite is a node inside the scene. But when I instantiate it, I can't access the individual nodes of said scene. I can't also give it a new CollisionPolygon2D, which would be perfect for what I'm trying to do!

      • xyz replied to this.

        Godoten I can't access the individual nodes of said scene

        How so? You should be able to access them via get_node()

          xyz Do you mean there is a way of accessing the nodes inside an instantiated scene through get_node() at run time?

          That would make it difficult to position the doors how I would like. Let's say I want a big medieval door. All the logic should be the same as other doors, but I want the sprites, positions and area2D to be different. It would be a lot harder to do this by code, instead of just positioning it inside the scene.

          Is there a way to "export" the sprite and the Polygon area? If not, maybe I just need to make a superclass that can pass the logic, and create the doors individually inside any scene...

          • xyz replied to this.

            Godoten There's no "instantiated scenes" at runtime. Once you instantiate a scene, it becomes a regular clump of nodes. When you add its top node to the main scene tree, the whole thing becomes just an ordinary branch of the scene tree. You can access any of its nodes via correct relative or absolute paths. Check the remote scene tree at runtime to see the actual live situation. The scene tree doesn't really know or care which of its branches were instantiated from "scenes"

            Interesting! I could access the inside nodes of the instantiated scenes through the "Remote" tab. But how do I modify them? They disappear when I stop the game.

            • xyz replied to this.

              Godoten You do it through code.
              If you need a different variant of a scene, make an inherited scene and edit it manually.

                You need to keep a reference of the door, to access it (easier that way). Make a variable or a array of doors, put it there and then when you need to change something just take it from that array

                Godoten The solution to this is very simple

                just go to your main door scene and then click on the parent node and copy it, then open a new scene and click the "paste from clipboard" button that should appear in the node tree, you should have a 2nd copy of your door scene now, change the name of the parent node in this 2nd door scene to something else, and then save it as a new scene, and you can even attach a different script to this 2nd door scene that's different from the first one

                and yeah now you have 2 different door scenes that are completely independent from each other, you can give each one different sprites and different animations and different code and everything

                • xyz replied to this.

                  xyz inherited scenes make my head spin XD I'd rather just copy paste everything haha, been working fine with me

                  • xyz replied to this.

                    buzzbuzz20xx inherited scenes make my head spin XD I'd rather just copy paste everything haha, been working fine with me

                    ... until you have a lot of variants and need to make frequent adjustments to common functionality parts 😉

                      xyz oh yes that's gonna be an issue ! I should probably learn more about inherited scenes and how to use them

                      xyz This makes more sense. I could create a base scene called "door" so that other doors can inherit the logic and structure from it. But it occurred to me that maybe I could add a sprite2d node as a child of the instantiated scene. Would this be bad practice?