Couldn't find mesh component


I just started to learn Babylon JS + Unity exporter. I watched video tutorials (rotating cube).
However, I couldn’t find few things.

  1. Script component - So in Unity when I try to make mesh component script, it doesn’t have. So I made script using “Script components” instead. is it fine?

  2. on Rotator.ts
    in the update funciton,
    “this.mesh.rotation.y” is not working. is there any new wait to access the unity gameObject components (Mesh) ?

  3. on Unity, I can’t add "using Unity3D2Babylon " anymore.

Thank you!

Welcome aboard!

Adding @MackeyK24 who is the creator of the Unity exporter.

Documenttation for the new version has not been updated yet. But basically… There is NO Mesh, Camera or Light component any more… There is just the BABYLON.ScriptComponent

The script component has a transform so to move a transform from script

this.transform.position.z += 0.25;

Take a look at the video from this thread… i setup a new project and bake light

Thanks for your explanation and video.

I made Rotator.cs and attached my cube game object in Unity.
and here is Rotator.ts which is baking class for Rotator scrip.

protected awake(): void {
        /* Init component function */
        this.rotateSpeed = this.getProperty("rotatorSpeed", 1.0);

protected update(): void {
        this.transform.rotation.y += (this.rotateSpeed * this.scene.deltaTime);
        console.log("tranform value = " + this.transform.rotation.y);

The result is … not rotating. However when I see the console log, the transform value is changing. Is there any missing parts?

Thank you!

That’s because gltf uses quaternions by default…

So while transform.rotationQuaternion is not null… transform.rotation is ignored

So can update transform.rotation from the transform.rotationQuaternion.toEularAngles and then null transform.rotationQuaternion = null in the awake function … then your code will work

Or for simplicity just use transform.addRoation

1 Like

Thanks for your quick answer!