Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First we need to configure the object able to pick up and put this object in the world scene.

Create a new layer for pickup objects.
Now we can create the script for the PickUp System called PlayerPickUp.cs.
Add the script to the player object
We're going to start set up the project with NetworkBehavior scripts using the FishNet.Object

As usual, we are going to use OnStartClient() to be able to compare using the base.
Are few variables we need to set up before continue, first we want to have reference to the camera, also we want to know if we already have one object in our hand, also want to know what object we have in the hand, and we need a refence to the world obj Transform.
First of all, we are going to configure the object holder from world objects.

And we need to pass the camera refence to the main camera
With
cam = Camera.main;
Now we make the KeyDown update
Now in the new function PickUp we want to check where is the camera is look at.
And we want to know the layer we are picked up the object.
Now we pass to PickUp parameters.
Here we want to check if we hold the object in our hand and take another object we want to drop the previous object, well to make that after creating the function we need to start configuring the server RPC.
Let's create a Server RPC with a requiredOwnerShip.
First we need to set if the object is in the hand, to do that we need to configure also the observer.

Now we want to know what object we hit, we also want to know the position and the rotation from where we want to place it and what player has grabbed the object.
And from the server we are going to set the object in hand for the observer.
Now in the player object we need to create a new layer for where should be the object when player pick.
So now we can reference that into the script.
And now we can set the object in hand server, and to this object we will give what object we are hiting and the pickup position, also the rotation for last we give that to the player.
Now we have all this data, want to set the position of the object for the position we sent also for the rotation, also want sent the transform to the player.

If there is some collision we need to set the rigid body to is kinematic in the observer.
After this we should be able to know what object we have on hand, also if we have and object in hand.

Now we need to set the ray cast Distance in the editor.
So now we want to have a drop button

Now let's make a drop function First we need to see if we have an object in our hand, and we make the same for Server Rpc and Observer Rpc, this time we want to know which object is dropped we can take this information from Gameobject, and we want to know the transform of the world object.
Now we can drop the ObjectServer geting the object in hand to the Object world.
And once again we can make a check if the object have a RigidBody(Colision).
So if we have an object in hand, we want to drop first.
It is important in the drop function, we set the hasObjectInHand to false and the ObjectInHand to null.
Remember to set the tag name in the worldObjects
To be able to interact with the object we need to make sure network object are enabled
Also, you can't forget to add a rigid body

Also remember to set the pickup position in player object
Player can take an object and drop.

