2

I'm making a 2D co-op game, with puzzles that involve moving physics objects.

I'm using the Unity 5 engine, and the UNET tools

One of the weapons the player has is a weapon that imitates the behaviour of the Half-Life 2 Gravity Gun;

  1. You right click in a certain direction
  2. It makes a raycast in that direction, with a limit distance
  3. If it finds a gameobject with a collider and a certain tag, it stores it as "grabbedObject"
  4. It sets the grabbedObject position making it float in front of the player
  5. You right click again and you drop it.

That works perfectly on Server side, and client side you can see it working. But when you try to do it as a client, it's not changing the grabbedObject position on the server, and it goes back to the original position as soon as you drop it

user3071284
  • 6,955
  • 6
  • 43
  • 57
NeoHL
  • 31
  • 4
  • Hi @NeoHL, it seems like you were building towards a question but didn't put it in. It really helps if you put in a question and some code. – user3071284 Sep 02 '15 at 15:02
  • 1
    add code please and yeah many people have the same problem with unet all over stackoverflow that some times client dont work and sometimes server, I have found that changing things using isServer bool removes many problems – LumbusterTick Apr 09 '16 at 23:06

1 Answers1

1

I wanted to comment as I'm not sure this is a proper answer - but I'm just 5 points shy of being able to do so. But I had similar trouble trying to sync object color changes in my game.

Here is my question and my answer (as I had a LOT of trouble finding answers online), I think it may help you find your solution:

How do I sync non-player GameObject properties in UNet/Unity5?

Community
  • 1
  • 1
Michael S
  • 726
  • 1
  • 10
  • 23
  • So the solution really is to spam server with position changes commands and let the server propagate the changes to other clients? – Aleksei Petrenko Mar 17 '18 at 14:16
  • Basically... The idea is that the server is the main control which propagates to all players. At least a couple of years ago it was, I'm not sure if that is still the pattern to follow. There are optimizations you can do, Such as: you don't need to send all data - send only what is necessary to calculate the rest in the client; you can throttle the frequency of the updates and have the client interpolate between the updates; and probably a lot more optimizations I haven't thought of yet – Michael S Mar 17 '18 at 23:39