Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Moving non-player objects on remote client

Discussion in 'Multiplayer' started by Collywobbles, Dec 3, 2018.

  1. Collywobbles

    Collywobbles

    Joined:
    Nov 10, 2014
    Posts:
    14
    This should be a fairly basic and simple thing to do in a networked game, but for some reason it seems to be extremely difficult to achieve. From the host/client everything just works and remote clients get updated.

    All I want to do is add a force to a network spawned non-player object on a remote client, which should be visible on the host /client.

    This action is done by the player so it has to run locally to appear responsive and be replicated across the network to the host/client. There are a lot of posts on the Internet asking the same thing but I have yet to find one with a solution that actually works.

    Amongst other things I've tried using Commands to replicate the force on the server, using SyncVar to pass on the required force, but it produces a completely different result on the server - no idea why...

    I've tried SyncVar with the tranform position, but things just got in complete mess.

    I would love to see a simple working example of this, but I can't find one anywhere: player adds force to object, from remote client, object updates on all other clients and host. I can't figure why it's so difficult, I mean I've been at it for 2 weeks now... Please help!
     
  2. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    292
    Timing issues, non-deterministic physics, etc etc. It is a complex and complicated issue (as are almost all issues dealing with real time network games, especially when dealing with physics and local simulation vs. server authority). Maybe try reading Glenn Fiedler's Intro to Network Physics - https://gafferongames.com/post/introduction_to_networked_physics/ - will give you an idea of why things work/don't work... Good Luck!!
     
  3. Collywobbles

    Collywobbles

    Joined:
    Nov 10, 2014
    Posts:
    14
    That's a great article, thanks!
     
    Jos-Yule likes this.
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You cannot use SyncVars to send information from clients to the server. Only Commands and Unet Messages. SyncVars are one way, only from server to client.
     
  5. Collywobbles

    Collywobbles

    Joined:
    Nov 10, 2014
    Posts:
    14
    Yeah, I was thrown by the so called 'solutions' I found on the net. Not only were they using SyncVars, they were using them with GameObjects which also isn't possible. When you're new to something, it's easy to be led down the wrong path which is why I came looking for a sensible example. The above article link is helping me find the right path.