• 2D
  • How I can to change size of CollisionShape2D to some direction among some axis?

Or just imitate that function, but it's must be perfectly like there, no one pixel to right or left. Because it can cause on problems with collisions.

Example illistration

Assuming we're dealing with box shapes, change shape's position by the same amount you changed its extents.

15 days later

@xyz said: Assuming we're dealing with box shapes, change shape's position by the same amount you changed its extents.

So, it's right, but collision after that working incorrect. Let's go on into concrete case. I'm doing wall grabbing and it's necessary when my character do this his collider is narrow. It's need to player can wall slide in some narrow entry. But when I change collider it's cause to collision bugs. Like a micro jumping out and wall grabbing again(I can notice that by dust(in my game realized dust), that appearing when player wall-grab). Also happening some stucks, some changes of wall sliding speed. Overall it works, but those bugs looks ugly. Is there are some godot features to debug collisions when CollisionShape2D changing?

Hard to tell without seeing the actual code that handles collisions. Perhaps you could simply disable grabbing state change in the frame you're shrinking the collider... Again, we'll need to see collision code for more specific advice.

One useful thing for debugging is enabling collision shape display in main editor menu: Debug->Visible Collision Shapes.

I've used multiple collision objects on my game. Where only 1 is enabled at a time and if you say duck, the standing collision object is disabled and the ducking collision shape is enabled. Seems to work. Changing the shape of a collision body at run-time seems like it will mess up the physics engine. It also may be how you are doing it. Scaling never works and you should never scale anything related to physics. But adjusting the extents of a collision shape might work. But, in any case, using separate objects is easier for development and debugging.

Okay, I managed with it. There is solution that working for changing size of objects that work very closely with physics My final solution: First of all it's need to separate collision shapes by roles(for default state, ducking etc) and switch them by $CollisionShape2DThatWeNeedToDisable.disabled=true one and $CollisionShape2DThatWeNeedToEnable.disabled=false another. (Also I advice to change visible-parameter - it's good for further debugging things) I made that, though now I think it's not necessary(but it's, as said cybereality: "using separate objects is easier for development and debugging"). In contrast with next point... You absolutely can't change scale of collision shape, it's mess up physics engine to hell! You better to change position, rotation, especially shape parameters(image below), but only not scale. That's all. Thank's to xyz and cybereality for advice all things that contained in this post.