mixed-reality-extension-sdk icon indicating copy to clipboard operation
mixed-reality-extension-sdk copied to clipboard

Adding behavior to GLTF action with a box collider creates an error.

Open shanewhitfield opened this issue 4 years ago • 6 comments

Adding a behavior to a GLTF actor with a box colliderType produces an error

Error: "App Behaviors will not function on Unity host apps without adding a collider to this actor first. Recommend adding a primitive collider to this actor."

shanewhitfield avatar Aug 14 '20 19:08 shanewhitfield

glTF loading is asynchronous, so any operations you do on a glTF actor without waiting for it to load are going to be done in the dark. If you try to add a behavior immediately after starting the load, then this error is justified: that actor has no collider at the time of behavior initialization. It will work after the collider loads in, but throwing this warning is still desired behavior I think.

It's also worth noting that the collider argument to AssetContainer.loadGltf or Actor.CreateFromGltf has a different behavior than one might expect. It does not place a collider around the root glTF actor, but instead it places a collider of the specified shape on each child actor with a mesh.

stevenvergenz avatar Aug 20 '20 23:08 stevenvergenz

Sounds like there are two opportunities for improvement:

  1. The error message should suggest a fix.
  2. "It does not place a collider around the root glTF actor, but instead it places a collider of the specified shape on each child actor with a mesh." -- is this actually desired? What I actually want is a fitted box around the whole mesh.

afarchy avatar Aug 21 '20 17:08 afarchy

@afarchy Which error message are you referring to? The one that exists for behaviors being set with no collider does have the suggested fix in the error.

tombuMS avatar Aug 21 '20 17:08 tombuMS

Yes, but it's the wrong suggestion, as stevenvergenz mentioned - what I should actually do is wait for the GLTF to load before setting the behavior.

afarchy avatar Aug 21 '20 22:08 afarchy

The behavior system has no context on whether the actor is being loaded from a gltf, is an empty actorm primitive actor etc. This is why there is a general suggestion to add the collider. We could change to something like "Are you waiting until the actor is fully loaded? Does your actor have a collider on it?"

tombuMS avatar Aug 24 '20 16:08 tombuMS

I am trying the Hello World sample and I am getting the same error, even though the sample waits for the model to load.

What I noticed is:

  1. When I add the script for the first time, it loads and works as expected.
  2. After exiting the room and entering again, the behaviours won't work no matter how many times I reload it.
  3. It will be fixed if i) I delete the object and add it again or ii) I change the Session ID. However, it will stop working again after exiting and entering the room again.

Is there any other way to load a model without running into this problem?

silasalves avatar Jul 06 '21 23:07 silasalves