NeoHL
NeoHL

Reputation: 31

Unity 5 - UNET - Syncing a dragged GameObject as a client (HL2 Gravity Gun style)

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

Upvotes: 2

Views: 1204

Answers (1)

Michael S
Michael S

Reputation: 736

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?

Upvotes: 1

Related Questions