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

Resizing instanced CollisionShape2D resizes all instances (and original) #38066

Closed
LotsaBugs opened this issue Apr 21, 2020 · 5 comments
Closed
Labels

Comments

@LotsaBugs
Copy link

Godot version:
3.2.2 beta 1
OS/device including version:
Windows 10.18362
Issue description:
I have a scene like this:

Button
-- Area2D
-- -- CollisionShape2D

It has this script:

tool
extends Button

func _on_resized():
	var CS2D: CollisionShape2D = self.find_node("CollisionShape2D")
	var half_size := self.rect_size/2
	CS2D.position = half_size
	CS2D.shape.extents = half_size


func _ready():
	self.connect("resized", self, "_on_resized")

When resizing an instanced button in the editor, all the other instances have their CollisionShapes resized, even the original scene.
Clicking Make Sub-Resources Unique doesn't do anything.

Area2D Bug

Steps to reproduce:
Open the Minimal reproduction project or create your own scene as described and give it the script provided above.
Resize any instanced button to see the bug.

Minimal reproduction project:
Area2D Bug -1.zip

@Calinou
Copy link
Member

Calinou commented Apr 21, 2020

As far as I know, you need to edit the CollisionShape resource and check Local to Scene in the Inspector to avoid this.

@LotsaBugs
Copy link
Author

Ah, that fixes it, thanks!
However, that property is really hidden.
Do you think Local to Scene should be enabled by default?

@Calinou
Copy link
Member

Calinou commented Apr 21, 2020

@LotsaBugs No, as this would duplicate every resource even if they're not being modified individually. This would result in worse performance.

@LotsaBugs
Copy link
Author

I see. Thanks for your help! Closing.

@city41
Copy link

city41 commented Sep 11, 2020

I had the same issue. I need to programatically resize a CollisionShape2D's sub shape resource. I had the same problem of all my scenes sharing the same RectangleShape2D. Choosing "Local To Scene" solved my problem.

However, when choosing the shape for a CollisionShape2D, there is the option of "Make Unique"

image

Choosing "Make Unique" does not seem to do anything. My scene's .tscn file does not change and the resource is still shared across scene instances. Is this "Make Unique" option supposed to do the same thing as "Local To Scene", or something else?

I am using Godot v3.2.2.stable.official on Ubuntu

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

No branches or pull requests

4 participants