how do i sync a GameObject? HELP PLZ!!
Hi guys i made a FPS game like Brackeys “Making a Multiplayer FPS in Unity” i actually followed him. But i added something to my game a GameObject with rigidbody. But when a player shoot or hit it, it only happens in his server and doesnt move in others. All i want is when someone shot it or hit it the same thing happes to it for all the players. Maybe Something like this https://www.youtube.com/watch?v=q3WEenAbkBw i searched everywhere and tried to find any thing but found nothing.
But I actually got this script but it didnt work dont know why but it should work. I put the script to the GameObject but nothing happend still the same problem. Did i do something wrong?
using UnityEngine;
using System.Collections;
public class GameObject : MonoBehaviour {
public void OnSerializeNetworkingView (BitStream stream, NetworkMessageInfo info)
{
if (stream.isWriting)
{
Vector3 position = transform.position;
stream.Serialize(ref position);
}
else
{
Vector3 position = Vector3.zero;
stream.Serialize(ref position);
transform.position = position;
}
}
}
It doesn’t sync the gameobject, or should i add something more to the gameObject than the script? and maybe to the NetworkManger?
Please could any one tell me how to do it or maybe give me a new simple script. :/
Your answer
Follow this Question
Related Questions
How to sync RPC function Photon Network? 1 Answer
NetworkTransform did not working with RegisterSpawnHandlers 2 Answers
[UNET] Transform sycing problem,[UNET] TRANSFORMATION SYCING PROBLEMS 0 Answers
Unity Networking(old) Question.(Teleporting player) 1 Answer
Syncing ragdoll across the network? 1 Answer