-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node.replace_by() has strange behavior with instanced scenes #28746
Comments
The part of it which you want is just:
That being said, the documentation is quite lacking. Retagging. |
Yes, that's what I've been doing, and it's working fine, I was just curious why that method wouldn't do the same, considering what I thought it should do. So I was wrong about that--still, (In any case, documentation could at least make that more obvious indeed!) |
If it's used by editor and works weirdly for games, maybe it should be made hidden/private from the user? |
Improving the documentation should be enough. If it's useful in the editor it can be useful in games and tools running in the editor. |
Godot version:
3.1
Issue description:
Using
Node.replace_by
to replace an instanced scene with another one created from script appears to merge the two subscenes instead of actually replacing.Steps to reproduce:
main
,other
,yetanother
, each with a simpleNode2D
as base node. Then add different sprites toother
andyetanother
to distinguish between them.main
scene, instantiate theother
scene (say, asOther
) as a child with the editor.main
scene's base node, instantiate ayetanother
scene withload('res://yetanother.scn')
and call.instance()
on it (call the resulting variableyetanother
).$Other.replace_by(yetanother)
to the following line.Instead of replacing the initially instanced scene node with the new one, this results in merging the two scenes together (which can be confirmed by looking at the Remote tab's scene tree during execution).
As an additional note,
print($Other)
will print[Object:null]
then (because the node also took the new node's name), which imho is a bit counter-intuitive, though this is easily fixable withyetanother.name = 'Other'
. I believe the replaced node should take the initial node's name by default, but that may be intended for reasons I'm missing.Minimal reproduction project:
replace_by_bug.zip
The text was updated successfully, but these errors were encountered: