Need help with BabylonToolkit : Physics and Components

Hi is there a way to access the component of a pickedResult from raycast? and is there also a way to access a ScriptComponents physics component? to change mass / add force etc.

In my scriptcomponent i try to find the PhysicsImposter attached to the transform, but it returns null.

console.log("1 " + this.getComponent("BABYLON.PhysicsImpostor"));
console.log("2 " + BABYLON.SceneManager.FindScriptComponent(this.transform, "BABYLON.PhysicsImpostor"));

Also documentation is quite lacking so im pretty lost to be honest. Thanks in advance, whoever is reading this. are you still actively developing this @MackeyK24 ?

cc @MackeyK24 the daddy of the Unity Toolkit

1 Like

bump, if thats ok. i really need your help @MackeyK24

if its a BABYLON.PhysicsImposter it would be on mesh.body or mesh.imposter its not a toolkit component.

the SM.FindScriptComponent would only be for actual toolkit components that came across in the gltf and is a quick way to access the instances that are stored under node.metadata.unity.components.componentName.instance (it might not be that exact param path but its something like that)

If you are actually creating lets say a “PhysicsComponent” script and have that attached to a transform in the editor, you would access it during runtime in the manor that you have shown above. You could then on that scripts ready collect all the Physics properties that you would need to access and use that as your point of access for all the methods and property setters/getters you would need.

also a quick line saver is to use ‘‘SM’’ instead of ‘‘BABYLON.SceneManager’’

1 Like