Trying a multiplayer game with characters with is own camera

You probably want to rewrite your start function like this:

    start(): void {
        this._rb = this.gameObject.getComponent(Rigidbody);
        const isLocal = this.playerState?.isLocalPlayer || false;

        this.enabled = isLocal;

        if(this._rb) {
            this._rb.enabled = isLocal;
            this._rb.lockRotationX = true;
            this._rb.lockRotationZ = true;
        } 
    }

EDIT: move the this.enabled out of the if clause so rigidbody doesn’t affect other systems.

Mind that the lockRotationX are not functions, but variables. You have to set a state to them. If they would be functions you would be missing () as well.

The lines you had there before, just returned the state of the axis lock and didn’t execute anything. Not sure if that was your intention or just some work in progress. Commenting that just in case :slight_smile:

Okey okey. Thank you for your comments, I will try it. :slightly_smiling_face:

by user 632418299711324161

Also, the logic was inverted it seems, so that could have cause some issues.

You are missing also a SyncedTransform setup. But you say your players do move, so let’s see if that was just the local input or if you’ve setup the synced transform somewhere else.

Otherwise, you should add this to your code:

    @serializable(SyncedTransform)
    syncedTransform?: SyncedTransform; 

    // in start
    if(this.playerState?.isLocalPlayer() || false) {
        this.syncedTransform?.requestOwnership();
    }

Okey okey. I wll set it and try.

by user 632418299711324161

Thank you

by user 632418299711324161

Is there some detail documentation about networking that you recommend me @kipash :cactus: ?

by user 632418299711324161

The documentation has the main page describing networking. Networking | Needle Engine Documentation

We are working on the networking samples that i’ve referenced which will contain a readme and should explain the basics more clearly.

Also we are working on an FirstPersonController sample with multiplayer capabilities that is in a finished state, but lacks a few underlaying fixes to work correctly.
https://github.com/needle-tools/needle-engine-samples/tree/samples/fps/package/Runtime/FirstPersonController

You can also reference that, the script is bit large tho.

There is also the open world sample which is quite older sample that is very similar to your concept, but i’m unsure about the state. We’ll have to polish it up to work again probably.

Let me know if you would be struggling. Multiplayer can be sometimes daunting.

Thanks Kipash, I will try some things and investigate a bit. If I get stuck, I will tell you. Thanks

by user 632418299711324161

Understanding how Needle is used helps us in improving and making it more friendly to developers. Let us know what feels too complicated then it should be :slight_smile: Or what through your journey was the key information that made certain aspect clear.

Main issue here was incorrect Camera class import. Three and Needle both have the Camera class.

Issue resolved in DMs.