+2 votes


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?

in Engine by (697 points)

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

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.

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

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

1 Answer

0 votes
Best answer

I would try to edit the collisionshape with CollisionObect.set_shape_transform

by (486 points)
selected by

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?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.