godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.03k stars 21.17k forks source link

PhysicsBody2D fails to generate collision shapes when the shape is added to a PhysicsBody2D instanced subscene #7151

Closed HeartoLazor closed 7 years ago

HeartoLazor commented 7 years ago

Operating system or device - Godot version: Windows 10 Godot 2.1.1 stable

Issue description (what happened, and what was expected): PhysicsBody2D fails to generate collision shapes when the shape is added to a PhysicsBody2D instanced subscene. Also creating a subscene with the Shape, Instance it and edit the shape from the Collision shape with editable children doesn't work, the Collision Shape retains the collision from the instance before the edits. This seems to be a bug, because the user should expect always a working PhysicsBody2D if they have a children shape. Editable children flag in the subscene doesn't fix the issue.

In my game I want a generic collider with a script which only objetive is to damage enemies or player, the main requirement is this collider should have different shapes, for example a bullet could be a circle shape or a big rectangle, etc. So I created an Area2D subscene with my script without a shape, and my plan is to add custom shapes to subscene instances. That idea failed when the engine failed to create the collision shapes in this case.

Steps to reproduce:

Link to minimal example project: Press play and wait for rigid bodies to collide with floor, subscene ones don't collide: https://dl.dropboxusercontent.com/s/ffi6rapu9co0p7m/custom_collision_shape.zip

vnen commented 7 years ago

Duplicate of #2314.