PHOTON SPAWN ISSUE!

ok when I spawn a player with device 1 into a spot in the world, he spawns there! (which is perfect!). When I spawn another player with device 2 at a different spot, he spawns! (which Is good also!). Now, I can move around and everything but according to player 1, he sees that player 2 is at position 0.0.0. Player 2 sees that player 1 is at position 0.0.0 according to his device. WHY IS THIS?!?! I haven’t been able to find an answer is over two months and im so frustrated! Please help i’d gladly appreciate it!! (BTW yes, I have PhotonView attached to both and they are observing the NetworkCharacter which is responsible for sending out its position and receiving others! I will post the NetworkCharacter script and the NetworkManager script, which is responsible for spawning players)

2150563–141962–NetworkCharacter2.cs (4.48 KB)
2153119–142142–NetworkManager.cs (6.19 KB)

Your problem is that the spawn happens at 0,0,0?
Or is your problem that the remote players never move?
The code looks ok. I didn’t run it but NetworkCharacter2.cs seems fine.
In doubt, put some Debug.Log(“methodname”) in each of the methods. It’s spammy but you can check if every method is called like you expect.

You need to create a script to send the position and location through Photon and update the players position and rotation, you’ll see them at 0,0,0 because your machine isn’t entirely sure where they are in real-time unless you synchronize the position and rotation.

@JakeBilbe yes that’s what the Network Character does. On PhotonSerializeview its finds realposition, real rotation of other players and also sends out the same to the server.

@tobiass The problem is kinda both. If you would have this game on your android device, it would appear as if you are connected to the server and moving around in realtime, however. if another player joins, they see that You are in position 0.0.0 and not moving nor rotating, even if you are! Visa Versa, the device your on sees that a player joined but hes stuck at 0.0.0?

Also guys I forgot to mention but theres another part of this , a script called PlayerController. The PlayerController Script is responsible for sending movement inputs to the NetworkCharacter script which sends it out to the server. However, im not good at mobile movements sooooo… this could probably be the problem. I have no idea.

2153002–142131–PlayerController.js (1.76 KB)

See, if you were controlling both it would be as simple as disabling the movement scripts on instantiate and enable them solely for the player but the few times I’ve had this issue is due to two things:

  • The object isn’t being instantiated via Photon or is already in the Scene.
  • Synchronizing Networking movement isn’t coded properly.

Though from what you’ve posted it’s neither, so the only issue could be your Spawn placement. Could you post the code that spawns your player into the server?

ok. its within the the Network Manager. Theres one for void SpawnMyPlayer and void SpawnFreddy

2153119–142142–NetworkManager.cs (6.19 KB)

Also, I forgot to mention that when I decided to disable the NetworkCharacter script and Make Photon View observe the Transform instead, it works perfectly!! However, viewing the transform is not recommended because it looks so slow and updates not a lot of frames to the server, not very smooth. But the fact it works with transform makes me happy. So when I put the Photon View back to observing the Network Character script(which is supposed to make the character move pretty smoothly across network) it still appears as 0.0.0 :frowning: im guessing theres something with the Network Character script but @tobiass says its fine sooo im stuck now.

Have you tried checking if the code is being run at all? Try putting in a few named debug statements, checking each function in turn, and see what happens? ie., “Debug.Log(“SomeFunction”);” or “Debug.Log(“ThisIfStatement”);”

Yes, the code is always active with all players. Debug.logs show too, that it is working

Okay a few things for you to try.

1) In your script you are getting the ObjectType, try adding a tag instead and adding the GameObjects to the Array through the tag. So replace these:

spawnSpots = GameObject.FindObjectsOfType<SpawnSpot>();

with these:

spawnSpots = GameObject.FindGameObjectsWithTag("SpawnSpot");

2) You’ve also not used the chosen Spawner in your Spawn code:

GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerController", new Vector3(.5f, 0f, -4f), Quaternion.identity, 0);

This may be why, you’ve only set the Bunny to use the SpawnSpot that’s been chosen, Freddy and the Player have Vectors set so this could be the reason? I’m not sure if it’s been fixed or if it was ever a bug but I remember Photon being a little picky when using Vectors inside an Instantiate call.

@JakeBilbe ok I will try the first solution and as far as the second one, I had Security and Freddy both spawn at spawn spots originally. just like the line codes in Bunny but when I had them spawn at spawn spots, there was no difference, they ended up at position 0.0.0 (but spawned right at the spawn spot according to that player), so I decided to use Vector3 but theres no difference

Could you try something for me, spawn both players in and on the Editor drag the players around, do any move? If so which ones and what are they controlled by? (Editor or Game Build).

@JakeBilbe glad you mentioned that because I tried to move the client around by dragging it but immediately it snap back to their position (0.0.0). The one on the editor is moveable though. Also,i had converted the Network Character script to JS and I noticed it had real position as a editable variable in the inspector! The real position had a x_ y_ z_ space where they all had 0,0,0 (of course). So I changed one of them to 1 and the other client moved! Not only moved but stayed there!

2153345--142155--assa.png

sorry forgot to mention that client = game build

That’s good news! Is it all working now?

Also, I tried your advice with adding a tag instead and adding the GameObjects to the Array but I got two errors:
(30,41): error CS0117: UnityEngine.GameObject’ does not contain a definition for FindObjectsWithTag' (29,43) error CS0117 UnityEngine.GameObject' does not contain a definition for FindObjectsWithTag’

I think it might be GameObject.FindGameObjectsWithTag, not entirely sure if this is the same for JS though but it should be.

Unfortuantly, no :frowning: It does the same exact thing >.< I can change the XYZ coordinates however, so when i change them then the person gets spawned to that position, yet, are still unable to move. So the only thing different from this Network Character script (JS) than the original Network Character script (C#) is that there are public coordinates. What the ultimate goal is, is to have those coordinates automatically update by themselves when a joystick is moved without an editor

Could I see the Synch code for the players? It could be that it’s public, but as long as you don’t have a script changing them it shouldn’t matter.

thx, but now I get two errors:
Cannot implicitly convert type UnityEngine.GameObject[ ]' to SecuritySpawnSpot[ ]’
Cannot implicitly convert type UnityEngine.GameObject[ ]' to FreddySpawnSpot[ ]’