The scale supplied to factory.create must be greater than 0. This does not make sense (#3710)

Zero is the proper scale amount.
With go.set we can set scale to 0. The factory.create (and go.set_scale) should allow do that too.
Value 0.000001 that replaces zeros in editor also looks like ugly hack.

1 Like

Having zero as an allowed scaling might simplify some things, but there are certainly other things that get more complicated. Very often, things in a render/physics engine rely on the fact that the transform matrices are valid (i.e. having non-zero scale).

One solution would of course be to have explicit if-statements in all the relevant places to check if the scale is zero, and handle it that way. That can have quite negative performance impacts.

Also, when it comes to 3rd party code, you might not be able to use that solution since they require you to have a non-zero scale. Take for instance Bullet 3D and Box 2D, which will assert on a zero scale, which is why we put out check in place to begin with. What do you think should happen in those cases?

So, it’s not totally straightforward how to solve this issue, and I’ll happily take suggestions on how to cater for both use cases.

Imho, considering this, I think scaling to a small constant seems like a good workaround to avoid a much bigger (and probably error prone) change.

2 Likes

I talk about gameobject scaling. Zero in that case is valid value. Engine should allow user set gameobject scaling to any valid value. If user care about physics, this should be his responsibility.

Do your know any other engine that restrict scaling to non-zero values?

And what you can say about “With go.set we can set scale to 0”?

The game object scaling affects the components since they will get the parent object’s transform.

I see your side of it, and I’m all in favor of creating a good solution. However, I do disagree that 0 is a very good scaling value. The reason is that most often, the engine will at some point need to do 1 / scale, and that is not defined when scale is zero.

Do your know any other engine that restrict scaling to non-zero values?

Only the few 2-3 non-public ones I’ve worked on, and this public one. I haven’t tested this in either Unity or Unreal.
And what about the other way around, what engines allow setting 0 on a game object with a physics object?

If user care about physics, this should be his responsibility.

We aim to strike a good balance between usability and correctness. And simply putting all responsibility in the users hands drastically increases the burden, for both beginners and more advanced users, so while your suggestion is one approach, I’d first try to find a solution that works for both scenarios.

1 Like

I’ll also have to double check the status of the new feature of scaling physics objects at runtime (not just at creation time), since that might also already have such a check in place. That could possibly be the best option.

1 Like

I don’t say that. I talk about gameobject.

Only the few 200-300 non-public ones I’ve worked on, and Unity, Unreal, Godot, Gamemaker, and surely any other public ones.

And what you can say about “With go.set we can set scale to 0”?

Each game object can have other game objects as children, so a parent game object with 0 scale will affect a child object, which might have a physics object.

Only the few 200-300 non-public ones I’ve worked on, and Unity, Unreal, Godot, Gamemaker, and surely any other public ones.

And, when those game objects have physics objects as children, how do they handle it?

And what you can say about “With go.set we can set scale to 0”?

I’m sorry I misread that one. That’s a very good point. I’ll have to check the code. Hang on…

I don’t know. In Unity for example, I am be able to add component “Rigidbody 2d” to gameobject, and then set scale of this gameobject to (0, 0, 0). Same in Godot.

Well, all I really want is do this:
factory.create(url, position, rotation, properties, 0) <-- Not something like 0.0001
instead of scaling gameobject (go.set(url, “scale”, 0)) to zero in init().
It is conviniet & logical.

Interesting to know. thanks.

Looking at the code I can confirm what you say, that go.set() simply just sets the scale value.
It of course has the problems I outlined, but since it’s been there “forever” (I only checked back to 1.2.100), we don’t seem to have much trouble with it, and we should be able to do what you ask for. I’ll discuss with @britzl too. Unfortunately, it misses today’s release though, so it should be possible to add for 1.2.168.

4 Likes

GitHub Issue: https://github.com/defold/defold/issues/3710