SyncedTransform only works with DragControls?

You can also have a look at the code in @needle-tools/engine/engine/engine_networking_files_default_components.ts which is the code we previously used when dropping files via DropListener. It’s currently disabled but it should work the same

Where?

This works for me:

import { AssetReference, Behaviour, GameObject, serializable, SyncedTransform } from "@needle-tools/engine"

import { IPointerEventHandler } from "@needle-tools/engine/engine-components/ui/PointerEvents";
import { InstantiateIdProvider } from "@needle-tools/engine/engine/engine_networking_instantiate";

import { IGameObject } from "@needle-tools/engine/engine/engine_types";

import { Object3D } from "three"

export class Teste extends Behaviour implements IPointerEventHandler {

    @serializable(AssetReference)
    cube?: AssetReference;
    @serializable(AssetReference)
    capsule?: AssetReference;

    private instantiatedCube: IGameObject | undefined;
    private instantiatedCapsule: IGameObject | undefined;

    private i = 0;

    async start() {
        
        const idProvider = new InstantiateIdProvider(this.guid);

        this.instantiatedCube = await this.cube?.instantiate(this.gameObject) as IGameObject;
        const st = GameObject.addNewComponent(this.instantiatedCube, SyncedTransform, false);
        st.guid = idProvider.generateUUID();

        this.instantiatedCapsule = await this.capsule?.instantiate(this.gameObject) as IGameObject;
        const st2 = GameObject.addNewComponent(this.instantiatedCapsule, SyncedTransform, false);
        st2.guid = idProvider.generateUUID();
    }

    // @ts-ignore
    async onPointerClick(args: PointerEventData) {
        if (this.i++ % 2) {

            await this.instantiatedCube?.getComponent(SyncedTransform)?.requestOwnership();
            this.instantiatedCube!.position.x += .1;

        } else {

            await this.instantiatedCapsule?.getComponent(SyncedTransform)?.requestOwnership();
            this.instantiatedCapsule?.position.setY(this.instantiatedCapsule.position.y + 0.1);

        }

    }

}

I didn’t get why, but I was adding the β€˜?’ after the β€˜st’ and this was breaking the code :joy:

Example:

st?.guid = idProvider.generateUUID();

by user 918470773134483507

Thank you so much again @marcel :cactus: !

Now my code is working :facepunch::facepunch:

by user 918470773134483507

Ah thats not allowed yes. You can not assign a value to undefined (thats what you basically say with st? - its an object or undefined)