mixed-reality-extension-sdk
mixed-reality-extension-sdk copied to clipboard
Adding behavior to GLTF action with a box collider creates an error.
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."
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.
Sounds like there are two opportunities for improvement:
- The error message should suggest a fix.
- "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 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.
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.
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?"
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:
- When I add the script for the first time, it loads and works as expected.
- After exiting the room and entering again, the behaviours won't work no matter how many times I reload it.
- 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?