- Home /
Client movements not registering on Server
okay, as much as I try to keep my posts brief, this one is a bit long.
I'm making a game. In it, the players have to find each other in a large area, and then shoot each other. It's online. There are a few little things, but for the most part, all I need to do over the network is connect, then, I need to track the position of each player on each machine.
First I tried just attaching a networkveiw component to each player and have it observe the transforms. It appeared to be working, but I'm not sure.
then I changed the way the game worked. to allow for matches with more than 2 players I instantiate player prefabs, one for each player (you really don't want me to go into how i do this). That's when it seemed to not be working; although, it might not have ever been working (I might have always been the client when i tested).
the players only register movement on the client's game. The server (I never tested this with more than 2 people) saw himself, but not the client. the client could see everyone. I don't get it. I thought networkveiw would do that for me.
I decided to lookup a way to track network transforms, I found this script
using UnityEngine;
using System.Collections;
public class trackposition : MonoBehaviour
{
public void OnSerializeNetworkView( BitStream stream,
NetworkMessageInfo info )
{
// we are currently writing information to the network
if( stream.isWriting )
{
// send the object's position
Vector3 position = transform.position;
stream.Serialize( ref position );
}
// we are currently reading information from the network
else
{
// read the first vector3 and store it in 'position'
Vector3 position = Vector3.zero;
stream.Serialize( ref position );
// set the object's position to the value we were sent
transform.position = position;
}
}
}
This yielded the same result.
I don't know I'm not sure I'm going to be able to fix this. Could it have to do with how I insantiate the objects? I would really appreciate all help.
thanks.
Did you make the network views on your characters observe that script?
Answer by StarCrossedGaming · Oct 09, 2014 at 05:42 AM
Try using PUN(Photon Unity Networking) for your networking. It works really well. With this, find some tutorials. I suggest Quill18Creates. He goes in-depth on multiplayer, He could fix this problem, and even make your game better. try that out!
thanks for your help, but I don't want to learn a whole new documentation, but I've made some progress and narrowed down the problem a little more, so I'm going to ask a different question to get to the answer to my problem.
Here's an up vote for your time though!
Edit : heck, I'll give you the best answer too