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

**URL:** <https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547>\
**Category:** Bugs\
**Created:** [November 25, 2015, 11:23am UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547 "2015-11-25T11:23:07Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![notbadgun](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/notbadgun/32/14901_2.png) [@notbadgun](https://forum.defold.com/u/notbadgun)\
**Post date:** [June 11, 2019, 6:22pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/41 "2019-06-11T18:22:05Z")

</div>

Why didn’t you manage to solve the problem in the new version? 😣 [Defold 1.2.156 has been released](https://forum.defold.com/t/defold-1-2-156-has-been-released/54508)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [June 11, 2019, 7:17pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/42 "2019-06-11T19:17:51Z")

</div>

> [@notbadgun](#):
>
> Why didn’t you manage to solve the problem in the new version?

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.

---

<div class="post-metadata">

**Author:** ![sergey.lerg](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sergey.lerg/32/3970_2.png) [@sergey.lerg](https://forum.defold.com/u/sergey.lerg)\
**Post date:** [June 11, 2019, 8:39pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/43 "2019-06-11T20:39:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jonathan.backstrom](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/j/54ee81/32.png) [@jonathan.backstrom](https://forum.defold.com/u/jonathan.backstrom)\
**Post date:** [June 13, 2019, 5:51am UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/44 "2019-06-13T05:51:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sposia](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@sposia](https://forum.defold.com/u/sposia)\
**Post date:** [July 27, 2019, 9:42am UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/45 "2019-07-27T09:42:12Z")

</div>

Any updates on this? This is very useful feature

---

<div class="post-metadata">

**Author:** ![uncle.kairat](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/uncle.kairat/32/14754_2.png) [@uncle.kairat](https://forum.defold.com/u/uncle.kairat)\
**Post date:** [April 30, 2020, 8:11pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/46 "2020-04-30T20:11:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [April 30, 2020, 8:18pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/47 "2020-04-30T20:18:01Z")

</div>

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! 😃 )

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [May 11, 2020, 3:26pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/48 "2020-05-11T15:26:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [May 11, 2020, 5:34pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/49 "2020-05-11T17:34:49Z")

</div>

> [@totebo](#):
>
> That doesn’t work because factory.create() doesn’t support arbitrarily scaled collision objects.

You mean non uniformly scaled objects?

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [May 11, 2020, 8:49pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/50 "2020-05-11T20:49:19Z")

</div>

Ja. 🙂

---

<div class="post-metadata">

**Author:** ![maloforgeron](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/maloforgeron/32/22071_2.png) [@maloforgeron](https://forum.defold.com/u/maloforgeron)\
**Post date:** [May 22, 2020, 1:05pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/51 "2020-05-22T13:05:09Z")

</div>

+1 over here XD 😛

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [May 28, 2020, 1:44pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/53 "2020-05-28T13:44:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AGulev](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/agulev/32/4541_2.png) [@AGulev](https://forum.defold.com/u/AGulev)\
**Post date:** [June 22, 2020, 7:36pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/54 "2020-06-22T19:36:05Z")

</div>

Solved in [1.2.170](https://forum.defold.com/t/defold-1-2-170-has-been-released/65631)

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [November 30, 2020, 2:00pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/55 "2020-11-30T14:00:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [November 30, 2020, 2:01pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/56 "2020-11-30T14:01:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thebillington](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/thebillington/32/22748_2.png) [@thebillington](https://forum.defold.com/u/thebillington)\
**Post date:** [December 1, 2020, 8:31pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/57 "2020-12-01T20:31:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [December 2, 2020, 7:03am UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/58 "2020-12-02T07:03:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![thebillington](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/thebillington/32/22748_2.png) [@thebillington](https://forum.defold.com/u/thebillington)\
**Post date:** [December 2, 2020, 7:49am UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/59 "2020-12-02T07:49:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [December 2, 2020, 8:40am UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/60 "2020-12-02T08:40:34Z")

</div>

> [@Mathias\_Westerdahl](#):
>
> 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.

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. 🙂

---

<div class="post-metadata">

**Author:** ![WhiteBoxDev](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/whiteboxdev/32/36080_2.png) [@WhiteBoxDev](https://forum.defold.com/u/WhiteBoxDev)\
**Post date:** [February 15, 2022, 11:49pm UTC](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547/61 "2022-02-15T23:49:49Z")

</div>

> I think scaling only rectangles non uniformly would be fine, as long as the limitation of circles is mentioned in the docs.

Wondering if this was ever considered? Having a lot of trouble finding a trick to scaling a rectangular collision object horizontally or vertically.

[Previous page](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547.md?page=2)

[Next page](https://forum.defold.com/t/scaling-collision-object-when-game-object-is-scaled-def-521-solved/547.md?page=4)
