- Home /
Networking Synchronize Problem.
Hello guys and ladies. I've been trying to make a network game...The connection to the server was good.But when the client and the server gets online, i don't see the other's movement. My character only Instantiates but when i move/rotate it does't update on the other pc/client. Also i made a script to place blocks(minecraft style)...which is working nice.But when im on network, only the one who places them sees them.
Movement Script using UnityEngine; using System.Collections;
 public class ExtendedFlycam : MonoBehaviour
 {
     
     public float cameraSensitivity = 90;
     public float climbSpeed = 4;
     public float normalMoveSpeed = 10;
     public float slowMoveFactor = 0.25f;
     public float fastMoveFactor = 3;
     public int gamemode = 1;
 
     private float rotationX = 0.0f;
     private float rotationY = 0.0f;
     
     void Start ()
     {
         Screen.lockCursor = true;
     }
     
     void Update ()
     {    NetworkView nView = GetComponent<NetworkView>();
         if (!nView.isMine) {
             rotationX += Input.GetAxis ("Mouse X") * cameraSensitivity * Time.deltaTime;
             rotationY += Input.GetAxis ("Mouse Y") * cameraSensitivity * Time.deltaTime;
             rotationY = Mathf.Clamp (rotationY, -90, 90);
         
             transform.localRotation = Quaternion.AngleAxis (rotationX, Vector3.up);
             transform.localRotation *= Quaternion.AngleAxis (rotationY, Vector3.left);
         
             if (Input.GetKey (KeyCode.LeftShift) || Input.GetKey (KeyCode.RightShift)) {
                 transform.position += transform.forward * (normalMoveSpeed * fastMoveFactor) * Input.GetAxis ("Vertical") * Time.deltaTime;
                 transform.position += transform.right * (normalMoveSpeed * fastMoveFactor) * Input.GetAxis ("Horizontal") * Time.deltaTime;
             } else if (Input.GetKey (KeyCode.LeftControl) || Input.GetKey (KeyCode.RightControl)) {
                 transform.position += transform.forward * (normalMoveSpeed * slowMoveFactor) * Input.GetAxis ("Vertical") * Time.deltaTime;
                 transform.position += transform.right * (normalMoveSpeed * slowMoveFactor) * Input.GetAxis ("Horizontal") * Time.deltaTime;
             } else {
                 transform.position += transform.forward * normalMoveSpeed * Input.GetAxis ("Vertical") * Time.deltaTime;
                 transform.position += transform.right * normalMoveSpeed * Input.GetAxis ("Horizontal") * Time.deltaTime;
             }
           }
      }
 }
Place Bocks Script(JS)
 var blockLayer : LayerMask = 1;
 var range : float = Mathf.Infinity;
 var hit : RaycastHit;
 var BLOCK  = ChooseMenu.selected;
 var blocks_rem : int = 50;
 Blocks.rem = blocks_rem;
 var pl : GameObject;
 var slowmo = 0;
 
 function Update () {
 
 
 if(Input.GetMouseButtonDown(0)){
  Build();}
 }
 
 function Build(){
 if(HitBlock()) {
 var cube = Instantiate(ChooseMenu.selected); /* Tried with Network.Instantiate(ChooseMenu.selected, hit.transform.position, Quaternion.identity, 0); If i use this, i can't place Blocks */
 if(hit.transform.position == pl.transform.position){
 return;}else{
 cube.transform.position = hit.transform.position + hit.normal;
 }
 }}
 
 
 var diff : int = 5;
 var black : int = 20;
 
 
 function HitBlock() : boolean {
 return Physics.Raycast(transform.position, transform.forward, hit, range, blockLayer);
 }
  
What can i do so both players see the other one moving and placing blocks? Sorry for my bad english :(
Thanks for your time!
Your answer
 
 
             Follow this Question
Related Questions
Photon network issue with script priority 1 Answer
Making a bubble level (not a game but work tool) 1 Answer
Problem with iTween and instantiated path 0 Answers
Please help with this code!! 1 Answer
Unity2D moving on the y-axis 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                