Hello,
I am new to Photon and am trying to use it to give multiplayer functionality to a board game that I am prototyping.
I am currently seeing some unexpected behaviors in my program and was hoping that someone might be able to give me a nudge in a better direction to get the kind of behavior that I am expecting.
Currently, I am using the same script to click on and to move the pieces in my game.
I am using another script to tell my pieces to ignore that script if the piece is not local to the current player:
photonView = GetComponent<PhotonView>();
if (!photonView.IsMine)
{
foreach (var script in scriptsToIgnore)
{
script.enabled = false;
}
}
The plan was going to be after the piece belonging to the local player (photonView.IsMine == true) moved, I was hoping to use the Photon Transform View component to make sure that the pieces on the other machines would move to match the local player.
Instead, I got what is displayed in the attached video…
As shown in the video, any player can move any piece, but if a player moved pieces that were spawned into existence by a local instance of the game (photonView.IsMine == true), then the IsMine == false piece instances would move into the correct positions on the other instances of the game.
I may be describing it poorly, but that is why I attached a link to the video below.
https://youtu.be/G6N8b21I8Qg
So I have two questions.
First, what might be a better way to set up my pieces so that players who do not have ownership of the pieces are not able to move them..?
And secondly, In my original program, where all of the pieces were moved by players from the same terminal taking turns “round robin” style, the pieces just teleport from one position to another using the line below...
(_movementPiece.transform.position = _movementTarget.transform.position;)
In my original code and in the instance of the program where the photonView.IsMine = true, the pieces still teleport. On other instances of the program running in the same room however, the pieces slide across the board. Again, this can be seen clearly in the attached video.
Is there any reason for this..?
Is there a way to get them to teleport as in the original version of the code..?
I ask because when they slide, if they collide with another piece while sliding across the board, they delete the piece they run into, which is not the intended action. (Well... It IS the intended action, but I was not intending for the pieces to slide across the board...)
I can probably code a fix around it just by having the pieces rise up off of the board, move into position, then come back down… But if there is another way around doing that or if I could understand why the IsMine=false pieces are sliding, that might be helpful to me also.
Thank you all for any insight you may be able to give me into these behaviors as well as any feedback you may be able to give in to anything else you may see that I could be doing better.
I am using the free version of PUN2 for Unity if that helps at all.