#Parenting different labels to multiple prefabs(or scenes) that I want to stay the same
32 messages · Page 1 of 1 (latest)
You could make the label a child of the lid in the box scene / prefab, give the boxes an export property like:
@export var number: int = 2
and then have each box set their own label's text like:
# Script for box_prefab
func _ready():
$Lid/Label.text = str(number)
Wohoo! That is wonderful, gotta try.
However, if I was to make a custom mesh/meshInstance object and wanted to parent that to the lid (or change a lid's child object inside the prefab with another) only for a specific prefab, would that be possible?
For example, would that be possible if I parent 3 different objects to the prefab's lid inside the prefab scene and then hide them - and via script unhide them case per case basis?
Not getting this work, sadly.
Maybe I don't know how to reference correct node.
This is my prefab's sctructure
extends Node3D
var number = 2
func _ready():
$/root/boxy/boxy_base/boxy_lid/text_label.text = str(number)
Yes, absolutely! :D
Try changing the node's path to
$boxy_base/boxy_lid/text_label
Since the script is on the boxy node, node paths in that script (i.e. the path from boxy to text_label) are relative to it, so we don't need the /root/boxy/ part
YES! now it works, yay
except....waaaitaminute, ah yes, didn't understand that a node can have only one script assigned to it
I even did:
@export var teksti = "A"
So that I can define the string in Inspector and now works very nicely, thank you!
@manu regarding your second question which, if I understood it correctly, has to do with having alternative children to objects that are otherwise identical - the proper way is to use dynamic composition rather than "hard-coded" hidden alternatives
@hollow anvil like this
wonderful! But I don't know how to do that
@hollow anvil That's why I created it for you. I can upload this example and we can discuss it further if something is unclear
oooh! by all means! :D
Just a moment : )
https://github.com/JanneKro/dump the "composition.zip" contains this project. I hope it runs as is even if it has Blender connection
excellent, I think I understand.
a question:
is TreasurePosition some sort of 'empty'?
Yes exactly. Marker3D is what the type is called I think. Just a lightweight node to be able to offset other items
also interesting to use prefabs inside of prefabs
A good spawning point for bullets, for example
I thought Node3D was the empty
Node3D is the base-class for all 3D nodes. I honestly haven't looked into "Marker2D/Marker3D". I just started a few days ago and saw that it is being used as placeholders
I guess "prefab" is some Unity term? But as I understand it, everything is scenes/nodes within nodes, so there isn't really anything strange about this either, more than it's more dynamic than you dragging a "player" into a "world scene". Now you can drag whatever you want into it (as long as it works with your interfaces, that is)
another question:
If I have a huge hierarchy, with a couple of child Node3D's even, with a node named as 'superobject' for both objects, is it still possible to reference those by typing $superobject in the root node or a node that's their parent at least?
- How to access parent node or a grandgrandparent? is it get_node("./../../../superobjectparent") ?
Are you for trying that open-voice channel? I can practice on my finnish as long as no one else is around. : D
okay, why not, but I don't have other questions, I think
Sure, but I think it's easier to show a few things regarding refererring up/down along the chain
yes! let's do that
Sorry, wife was panicking due to a fault-code in the dishwasher. One moment 😄
@hollow anvil https://github.com/JanneKro/dump/blob/main/signals.zip