- Home /
Question by
zak666 · Jul 20, 2017 at 06:22 AM ·
rotationphotonsynchronization
Syncing Rotation in Photon. (Moves but won't rotate)
Hey Game Got this Online Biss working awesome Accept when I pop in My Position changes on Clients screens, however Player Rotation is not passed though.
Spawns, Yes, Shoots, less, Rotates no.
always shoots on the same direction yet on Clients will be aimed in other directions.
(everything is set to be on One game object.)
Vector3 trueLoc;
Quaternion trueRot;
PhotonView pv;
void Start(){
pv = GetComponent<PhotonView>();
if (photonView.isMine == true) {
gameObject.tag = "ThisIsMyPlayer";
}
}
void Update()
{
if (!pv.isMine) {
transform.position = Vector3.Lerp (transform.position, trueLoc, Time.deltaTime * 5);
transform.rotation = Quaternion.Lerp (transform.rotation, trueRot, Time.deltaTime * 5);
}
}
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
//we are reicieving data
if (stream.isReading)
{
//receive the next data from the stream and set it to the truLoc varible
if(!pv.isMine){//do we own this photonView?????
this.trueLoc = (Vector3)stream.ReceiveNext(); //the stream send data types of "object" we must typecast the data into a Vector3 format
this.trueRot = (Quaternion)stream.ReceiveNext();
}
}
//we need to send our data
else
{
//send our posistion in the data stream
if(pv.isMine){
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
}
}
}
}
Comment
Answer by muttsang · Oct 24, 2020 at 11:58 AM
hi,
I am facing the same problem. Since, noone has replied back and the original post is from 2017, i assume you've solved the problem?
If so, could share how you did it?