Odd behavior with getting variable from parent node
Asked Answered
O

5

0

I'm trying to get the value of a variable in the parent node of the current node using get_parent().get_parent().CardSize
when I print this value it works fine, returning the Vector. But the Debugger throws the following error: Invalid get index 'CardSize' (on base: 'MarginContainer (card_base.gd)'). See screenshots for output. I'm confused as to what's causing this and would appreciate help!


Ogive answered 21/9, 2023 at 14:58 Comment(0)
G
0

Ogive Looks like you didn't fetch the right node. Hard to tell exactly without seeing your node tree.

Ghirlandaio answered 21/9, 2023 at 15:20 Comment(0)
O
0

Ghirlandaio But if it wasn't the right node, how is the print printing the correct value? Here's the tree from debugger. The code is in card_base.gd

Ogive answered 21/9, 2023 at 15:31 Comment(0)
G
0

Ogive The code is in card_base.gd

Yeah, but where is card_base.gd in the scene tree?

Ghirlandaio answered 21/9, 2023 at 15:35 Comment(0)
O
0

Ghirlandaio It's attached to CardBase (parent node Cards, the other margin containers in Cards are instances of CardBase)

Ogive answered 21/9, 2023 at 15:39 Comment(0)
G
0

Ogive Post the whole expanded tree and mark the node with the script and the node it wants to access.

Ghirlandaio answered 21/9, 2023 at 15:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.