Scaling Collision Object when Game Object is scaled (DEF-521) (SOLVED)

Why didn’t you manage to solve the problem in the new version? :persevere: Defold 1.2.156 has been released

1 Like

Because we finished the work on joints instead. And we added support for programmatically changing the gravity.

Solving physics scaling is next on our list though. But it is dependent on another engine change where we need to make it cheaper to know when a transform hierarchy has changed. We really don’t want to poll for scale changes every frame but rather have a system where we have some kind of dirty flag or similar.

2 Likes

I guess recreating physics bodies each frame is not the best route. Maybe add a message or a call to reapply scaling? So the developer chooses when to update.

2 Likes

I am really looking forward to this fix! It has been a pain for a really long time.

1 Like

Any updates on this? This is very useful feature

1 Like

+1 For this feature. Need to create objects with variated col box sizes in my game, dynamically.

1 Like

Definitely collision objects should follow the transform of game object as well as sprite component does. I have a ton of multiple game objects with different collision objects just as a workaround, it’s not convenient.

+1 for this!

(EDIT: I already +1 it earlier! :smiley: )

I keep bumping into this one. Destroying and recreating the game object would be fine; that’s how it’s usually done in Box2D. That doesn’t work because factory.create() doesn’t support arbitrarily scaled collision objects.

Any update on this?

You mean non uniformly scaled objects?

Ja. :slight_smile:

+1 over here XD :stuck_out_tongue:

Still encounterd this bug today.
I thought it was something wrong with my script.

I think we should be able to pick this issue up again very soon though.

7 Likes

Solved in 1.2.170

1 Like

I’m testing non-uniformly scaled collision objects now with Defold v1.2.174. It still seems to work only when uniform. What did the “solved” refer to?

You can now set/animate the scale after the object has been spawned. It wasn’t possible before.

4 Likes

Also running into this issue with non-uniformly scaled objects. This isn’t the end of the world for us as the work is a performance boost, but would be nice to see in future.

1 Like

We haven’t really considered it previously, as it’s not something physics engines usually support.
E.g. A non uniformly scaled circle is an ellipse, and that isn’t supported by Box2D (or Bullet 3d iirc)

Currently, we support the runtime scaling for boxes in Box2D by manipulating the actual vertices at run time. So there ot would be possible. However ot would make it quite weird that you could apply non uniform scaling on only some object types.

How does it work in other engines? Can they scale circles non uniformly?

3 Likes

Hi Mathias, thanks for the quick reply. The objects we are scaling are all boxes so I will investigate manually scaling the vertices, though I’m not sure the amount of work will be worth it until we actually run into performance issues.

Lack of non-uniform scaling for circles makes sense, I couldn’t suggest a good solution. As for other engines, I’m not sure as this is my first time using one. I normally build my own physics implementations.

Oh wow, I didn’t realise the vertices were changed at runtime, I had assumed the object was deleted and recreated. Nice.

I think scaling only rectangles non uniformly would be fine, as long as the limitation of circles is mentioned in the docs. I hadn’t thought of circles, I think scaling circles is an unusual use case.

Of course when Defold supports chain shapes, those could be used to scale and defoem a circular shape. :slight_smile: