|
|
|
 |
Reply From: |
exuin |
So the node hierarchy is this?
Tile
- StackPosition
Then the path should be stackedBy.get_node("StackPosition")
since ..
gets the parent of the node it’s called on.
Thank you for the answer, yes that is correct that is how the hierarchy is set up. I changed the line of code, yet still the position does not update in the same way the held tile does. I’ve double checked that the bool is set correctly when it lands on another and sure enough it does output correctly that it is being changed, however it still is not moving with the tile below it.
Illyas_Onii | 2021-04-16 18:15
Is that code in the process function?
Yes it is, there is a raycast that detects the object below it, and in the process it hopefully gets the global position of the StackPosition node, and applies it to itself when the bool conditions are met.
Illyas_Onii | 2021-04-16 18:24
Can you try printing out the position of the tiles? Or looking at them in the remote tab?
ok i did that, and it appears that the numbers are the same, and when moving to the right they remain the same instead of moving with the tile.
[1]
Illyas_Onii | 2021-04-16 18:31
So the StackPosition node doesn’t move with its parent node?
that seems to be the case, I wonder if its an order of operations issue? I’m still kinda new to godot so some of its quirks like this are a bit confusing coming from unity
Illyas_Onii | 2021-04-16 18:38
I don’t think so, child nodes should move when their parent nodes are moved unless they’ve been explicitly set to not inherit their parent’s transform. Maybe there’s something else going on?
ok so to double check, I’m fairly sure I got this right, but I might have gotten the connecting lines wrong, This right here should connect the object that collides with the raycast to the “stack” signal, and also emits it to the function stack together, which is what sets the bool and updates what the object is stacked with. Perhaps there is a better solution for this I haven’t found?
if raycast.is_colliding():
var col = raycast.get_collider()
#print("col hit ", col.name)
if col != null && col.is_in_group("canStack"):
connect("stack", col, "stackTogether",[], CONNECT_ONESHOT)
self.emit_signal("stack", col)
return false
return true
Illyas_Onii | 2021-04-16 18:44
Okay, so when you emit the signal, you pass along the node that you’re emitting the signal to, which seems redundant. Do you mean to pass self
as the argument instead?
Oh wow! yes that was it thank you! I tell you the signal system is really confusing with godot, I always seem to mess those up in one way or another! I appreciate your help very much! 
Illyas_Onii | 2021-04-16 18:51