Drop Item at player's position

Options
Hey Guys,

I thought I'm doing it right but the last step of Drop Item script doesn't work how it should. I already know the reason, but I don't know the right method to call.

When my player drops an item, I want to activate the item over network and set its position to my player's position. I don't want the position of all items to be synched all the time, that's why my item's Photon View observe-option is set to off, and only updated, when the object takes change through RPC.

The activation of my item is working in pun, but the position of the item where it is dropped is set to ALL players. Means:

- Player 1 picks an item, Player 2 and 3 don't see the item anymore -> perfect.
- Player 1 drops an item to the floor, the item's position is now different in every client, because on Client 1 the Position is Client 1's player position, On Client 2 it is Client 2's player position, On Client 3 it is Client 3's position. But it should be set to Player 1's position on every of the three clients.

This happens, because my item via RPC is set to the player's position - Player's position in this case means the local position of every player.

I need a function where I tell the other clients, that the position of the item is MY player's position, and not every Player's position. How can I do this?

I looked over the Pickup Item Demo, there is one line in the "PickupDemoGui"-Script:

GameObject playerCharGo = PhotonNetwork.player.TagObject as GameObject;

and few lines later it says:

Vector3 itempos = playerCharGo.transform.position + this.DropOffset * random;

item.Drop(itempos);

I was then trying to do it similar like in the pickup Demo, but it is not working for me, don't know why.

I am sure this is something really simple, but how can I just over RPC the Position of MY player to everyone else?

Hope u can understand my problem.

Greetings



Comments

  • Dochder
    Options
    Come on guys, this cannot be so complicated or am I wrong?
  • Dochder
    Dochder
    edited July 2018
    Options
    I know now why it didn't work, if you want to put a reference to your own player the reference should be deactivated at the beginning, and when the player is connected, then activated again, else the "player"-will be every new player who joins and therefore when u drop an item the program puts it on the last player's position.