Problem in photon cloud
Options
Dont send position and rotation, instantiate objects locally in clients: Use A* pathfind and character controller locally do move unitys, this game is a real time strategy single prototipe. Like starcraft (save projects sizes ). Need only send movement (pos and rot), the unitys instantiate ok in network, but move only locally. i need help.
[code2=csharp]using UnityEngine;
using System.Collections;
public class controleUnidadeNET : Photon.MonoBehaviour {
private Vector3 correctPlayerPos;
private Quaternion correctPlayerRot;
private Transform meuTransform;
void Start(){
this.meuTransform = transform;
correctPlayerPos = meuTransform.position;
correctPlayerRot = meuTransform.rotation;
}
void Update(){
if (!photonView.isMine){
meuTransform.position = Vector3.Lerp(meuTransform.position, this.correctPlayerPos, Time.deltaTime * 500);
meuTransform.rotation = Quaternion.Lerp(meuTransform.rotation, this.correctPlayerRot, Time.deltaTime * 500);
}
}
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){
if(stream.isWriting){
stream.SendNext(meuTransform.position);
stream.SendNext(meuTransform.rotation);
}else{
correctPlayerPos = (Vector3)stream.ReceiveNext();
correctPlayerRot = (Quaternion)stream.ReceiveNext();
}
}
}[/code2]
[code2=csharp]using UnityEngine;
using System.Collections;
public class controleUnidadeNET : Photon.MonoBehaviour {
private Vector3 correctPlayerPos;
private Quaternion correctPlayerRot;
private Transform meuTransform;
void Start(){
this.meuTransform = transform;
correctPlayerPos = meuTransform.position;
correctPlayerRot = meuTransform.rotation;
}
void Update(){
if (!photonView.isMine){
meuTransform.position = Vector3.Lerp(meuTransform.position, this.correctPlayerPos, Time.deltaTime * 500);
meuTransform.rotation = Quaternion.Lerp(meuTransform.rotation, this.correctPlayerRot, Time.deltaTime * 500);
}
}
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){
if(stream.isWriting){
stream.SendNext(meuTransform.position);
stream.SendNext(meuTransform.rotation);
}else{
correctPlayerPos = (Vector3)stream.ReceiveNext();
correctPlayerRot = (Quaternion)stream.ReceiveNext();
}
}
}[/code2]
0
Comments
-
Is this on a GameObject, which in turn is a prefab, which is in a Resources folder?
Any logged errors in the Console?0