How to scale a collisionshape at runtime?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gokudomatic2
:warning: Old Version Published before Godot 3 was released.

Hi

I have a rigidbody with a collisionshape (like capsule) which I want to rescale during the game. It only needs to change size when it is created (instance()) and not after. So far, it seems to ignore any call of set_scale(). Funny thing is, if I set the scale in the editor, it accepts. I know that at the beginning Godot compiles the shape, which is only a helper, and then works only with the compiled object, but I think it was changed and now man can change the size of the helper and also update the compiled version.
Is there something I missed?

I would try to edit the collisionshape with CollisionObect2D.set_shape_transform
You can also create a CapsuleShape2D from code and add it to the rigidbody

atze | 2016-04-19 12:12

Shape node is still a helper, it’s present in runtime because this way it’s easier to change shapes during runtime (you can use shapes that are predefined in editor). However it’s planned in future for ShapeNodes to be something more than helpers. For now try to use set_shape_transform just like @atze suggest.

kubecz3k | 2016-04-19 19:09

One of you can transform your comment in an answer because it worked. Of course I had to use set_shape_transform since it’s a 3d collision object.
In any case, thank you.

Gokudomatic2 | 2016-04-20 09:22

@atze you were first so I will leave this privilege to you :slight_smile:

kubecz3k | 2016-04-20 09:28

:bust_in_silhouette: Reply From: atze

I would try to edit the collisionshape with CollisionObect.set_shape_transform

I didn’t find in documentation description of this method (3D version). In what space should I pass transform to set_shape_transform? In local space of the current CollisionObject or in global space?

gammaker | 2017-08-18 17:24