Gameobject animations in network

Hello,

I have a scripting-problem in my game, where I have a sliding door. The sliding is working by an “Open” animation. Now if the Host opens, it works perfectly for the client. But if the Client tries to open, it doesn’t work. Here are my codes:

Player file:

function UsingEyeLaseredObject ()
    {
            if(EyeLaseredObject.tag == "Door")
            {
                gameObject.Find(EyeLaseredObject.name).GetComponent(Door_Simple).Sum_Opening();
            }
    }

Door file:

        public function Sum_Opening ()
        {
            if(isServer)
            {
                Rpc_Opening();
            }
            else
            {
                Cmd_Opening();
            }
        }

        @Command
        public function Cmd_Opening ()
        {
            Rpc_Opening();
        }

        @ClientRpc
        public function Rpc_Opening ()
        {
            if ( DoorState == DoorPos.IsClosed || DoorState == DoorPos.IsClosing )
            {
                GetComponent.<Animation>()["Open"].normalizedSpeed = 1.0;
                GetComponent(Animation).Play("Open");
                DoorState = DoorPos.IsOpening;
            }

            else if ( DoorState == DoorPos.IsOpened || DoorState == DoorPos.IsOpening )
            {
                GetComponent.<Animation>()["Open"].normalizedSpeed = -1.0;
                GetComponent(Animation).Play("Open");
                DoorState = DoorPos.IsClosing;
            }
        }

If Client wants to Open, it seems it “stops” in the Cmd_Opening function, doesn’t go ahead to Rpc_Opening. No error or warning.

I did everything what I saw in the founded explains, but doesn’t want to work for the Clients. Any Idea?
Thanks

Not sure how it works in Javascript but I’d make sure that you’re doing this in a Player object or it won’t work. From what I remember clients can only call server commands like that from Player objects unless you have explicitly set them up to have control.

I moved the “Cmd_Opening ()” function to the player’s script (+modified the Rpc-link to the door file) but doesn’t effect.

Did you move the ‘Sum_Opening’ function there too? You have to call Cmd_Opening from within the player script too.

p.s. Even if you just have a basic function inside the player class that calls ‘Cmd_Opening’ that should be fine too - you can call that from your Sum_Opening function in the other class

Yes, I moved that, but I made a bit simplier:

Now the Player filepart looks like:

    function UsingEyeLaseredObject ()
    {
        if(EyeLaseredObject.tag == "Door")
        {          
            if(isServer)
                gameObject.Find(EyeLaseredObject.name).GetComponent(Door_Simple).Rpc_Opening();
            else
                Cmd_Opening();
        }
    }

    @Command
    public function Cmd_Opening()
    {
        gameObject.Find(EyeLaseredObject.name).GetComponent(Door_Simple).Rpc_Opening();
    }

And the Door_Simple filepart:

        @ClientRpc
        public function Rpc_Opening ()
        {
            if ( DoorState == DoorPos.IsClosed || DoorState == DoorPos.IsClosing )
            {
                GetComponent.<Animation>()["Open"].normalizedSpeed = 1.0;
                GetComponent(Animation).Play("Open");
                DoorState = DoorPos.IsOpening;
            }

            else if ( DoorState == DoorPos.IsOpened || DoorState == DoorPos.IsOpening )
            {
                GetComponent.<Animation>()["Open"].normalizedSpeed = -1.0;
                GetComponent(Animation).Play("Open");
                DoorState = DoorPos.IsClosing;
            }
        }

I really have headache about this. I’m wasting with this 4-5 days…

You might be better asking in the Networking forum then - I’m not really sure what’s going wrong.

Thank you for your replies!

But I found a strange thing: if I start a dedicated server in Unity, and connect to it with the compiled prog, I found an error:

For Host it works, so it seems to be a bug, which is under the @Command section.