Closed TravisBarryDick closed 5 months ago
I also just noticed that updating the shape as follows has the intended behavior:
func _ready():
var new_shape = CircleShape2D.new()
new_shape.radius = 100
$CollisionShape2D.set_shape(new_shape)
Interesting. Will investigate, thanks for the bug report.
It seems when a shape is changed, the shape is destroyed and recreated(probably this can be optimized, this seems to be just code ported from godot physics). But the collider is only destroyed, and the shape itself with all properties isn't destroyed. That's why this happens. I'm trying to also destroy the shape when it needs updating, see if there are any lose ends. If not i'll try to update the shape instead of deleting it.
Ran the tests, there isn't any issue after the change. Seems to fix this. Only issue I could think of with this approach is if there are any dangling references of the shape handle, but the only place the shape handle reference is kept is on the shape itself, so there wouldn't be any problem. Will take a note of this bugfix for the rust rewrite also and make sure to re-implement it there as well.
Describe the bug
When a script changes the radius of a RigidBody2D's CollisionShape2D's CircleShape2D, the body still collides as though the radius was not changed.
To Reproduce Steps to reproduce the behavior:
Note: The attached zipped project has the above setup.
Expected behavior
The RigidBody2D should land and rest on top of the StaticBody2D. This is also what happens using the Godot 2D physics engine.
Screenshots
Environment (please complete the following information):
Example project(zip)
SettingRadiusHasNoEffect.zip