#Built-in Physics Authoring and Transforms

1 messages · Page 1 of 1 (latest)

wooden verge
#

It seems to me that com.unity.physics does not respect the TransformUsageFlags principles.
For instance, if I understand well, transform parent relationships should only be kept after baking if some behavior declares a DYNAMIC transform usage. However, in a very simple case with two authoring game objects Collider and Sub_Collider where both only have a Box Collider authoring component and Sub_Collider is child of Collider, as shown in the screenshot, the parent relationship is preserved after baking. (And also they have both LocalTransform and LocalToWorld which seems unnecessary?)

cold merlin
#

Shouldn't you check the static box at the top of the inspector to make the baking system not set the dynamic flag ?

wooden verge
#

I somewhat considered this; though it seems that it does a lot of stuff, and in particular, it seems to enable light baking which is not what I am after.

Also I would still think a component should only add the Dynamic flag if it moves the object which is not the case for the collider. (I mean if the presence of the component implies the movement of the entity)

wooden verge
#

It would be very interesting to have the take of someone from the Unity.Physics team on this matter 😊

uncut badge
#

If you throw a static optimise entity on here does it still add dynamic

wooden verge
#

I tested with static optimise entity, and I think remembering that the issue was that this implied that any child of the entity are also then considered static.

#

Indeed, in IBaker.IsStatic(GameObject gameObject):
gameObject.GetComponentInParent<StaticOptimizeEntity>(gameObject)

uncut badge
#

That is correct but now I'm confused

#

Your colliders are static as they have no body so why does that matter?

wooden verge
#

There could be a dynamic child without a collider for instance.
And for a dynamic child with a collider, it would ideally be unparented during baking (as I think it already is the case?)

uncut badge
#

Is this a prefab or a root scene object?

wooden verge
#

It would be for prefabs (I know they are always dynamic, but I modified the entities package to prevent that); but I guess it could also apply to scene objects

uncut badge
#

Haha yeah I also have a fork that does that

#

But anyway physics declares a dynamic transform flag because it expects anything not marked static explicitly to be dynamic

#

It's kind of using the transforms flags as expected?
Maybe I just misunderstood what you're trying to do

wooden verge
# uncut badge It's kind of using the transforms flags as expected? Maybe I just misunderstood ...

I would not agree that it is using transform flags as expected.
My understanding from is that the authoring component implying the runtime movement should be the one setting the flags as dynamic.
But after looking at the physics baking code, I think they might do it this way to ensure that physic entities always have a LocalTransform component (which if I am not mistaken is not guaranteed by default).

uncut badge
#

Yes dynamic flag is how localtransform is added and if you aren't marked static, what physics uses for position