-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Derived instance of CollisionShape2D using parent parameters instead of their own #13835
Comments
This happens because the only times the shape transform is updated between the visual representation and the physics world happens when it's parented and when the local transform is updated: https://github.com/godotengine/godot/blob/master/scene/2d/collision_shape_2d.cpp#L51-L77 It looks like modifying the transform in a instanced scene isn't triggering the Not sure what to do with this but maybe this info helps someone else with it. |
Note: The docs seem to imply that any changes to derived scenes should affect instances of the derived scene. So the behavior above does appear to be a bug: |
Investigation in progress... |
This is needed because the final startup values for shapes may change between parenting and entering the scene tree. For instance, if the collision shape belongs to a inherited scene. Fixes godotengine#13835.
Operating system or device, Godot version, GPU Model and driver (if graphics related):
Linux - Godot 3.0 Beta
Issue description:
Colliders in derived scenes do not use their position or size, instead they use the parent scene Collider position/size.
I would expect the derived scene CollisionShape2D to use its position and size for performing collisions, as other nodes (ie. Sprite) in the derived class make use of their own properties (ie. transform, texture).. otherwise, inheritance for character scenes will really only work for sprites/characters that are the same size.
A clear example of the problem:
Steps to reproduce:
I have the following base scene:
Character (KinematicBody2D)
|-Sprite
|-CollisionShape2D (Capsule Collider)
I derive two scenes from the above:
Note: In each of the derived scenes, the Shape2D sub-resource of the associated CollisionShape2D has been made "Local to Scene".
On the left is the parent character scene. On the right is the derived skeleton scene:
Scene setup (all nodes are at the same y position), only sprites are scaled. (right - child scene player, center - parent scene character, left - child scene skeleton).
The scale of the CollisionShape2D and the KinematicBody2D are all (1,1). The derived CollisionShape2D capsules have been re-positioned and resized (but not scaled):
After running the scene (with gravity):
Notice the physics engine appears to be using the parent capsule collider position and size rather than the derived scenes capsule collider parameters.
Even making the Shape2D sub-resource "Local to Scene" in each derived CollisionShape2D does not fix the problem. Running the test scene, I've also confirmed that each CollisionShape2D object in each of the three character scenes is different, although I don't see a way in the editor/debugger to view the Shape2D sub-resource.
The text was updated successfully, but these errors were encountered: