Skip to content
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 leaves duplicates #55710

Closed
Shadowblitz16 opened this issue Dec 7, 2021 · 2 comments
Closed

Node.replace_by leaves duplicates #55710

Shadowblitz16 opened this issue Dec 7, 2021 · 2 comments

Comments

@Shadowblitz16
Copy link

Shadowblitz16 commented Dec 7, 2021

Godot version

3.4

System information

Kubuntu 20.04 GLES3 Ryzan 7 5700G with Radeon Graphics

Issue description

Node.replace_by seems to leave odd duplicates in the remote tree

func _process(delta):
	if  _can_shoot && InputMap.has_action(projectile_action) && Input.is_action_pressed(projectile_action):
		if  _projectile_scene != projectile_scene:
			_projectile_scene  = projectile_scene
			BULLET.replace_by(_projectile_scene.instance(), true)
			
		if  _projectile_scene != null:	
			_can_shoot = false
			emit_signal("fire")

image

Steps to reproduce

Minimal reproduction project

See above

@KoBeWi
Copy link
Member

KoBeWi commented Dec 8, 2021

It's not a bug, just undocumented behavior. Seems like replace_by doesn't replace whole branch, but only that one node and moves all its children to the new node. In your case the two bullets will have their children lists merged.

@KoBeWi KoBeWi added documentation and removed bug labels Dec 8, 2021
@Shadowblitz16
Copy link
Author

Shadowblitz16 commented Dec 10, 2021

I hear that excuse not a bug a lot here.
Maybe instead of having weird behaviors in the engine that don't make sense you should consider fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants