Code:
transform.position = Vector3.MoveTowards (transform.position, realPosition, 0.1f);
transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, 0.1);
thanks for the help!
Code:
transform.position = Vector3.MoveTowards (transform.position, realPosition, 0.1f);
transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, 0.1);
thanks for the help!
I fixed it! I wasn’t updating the realPosition to the transform.position.
Final Code:
using UnityEngine;
using System.Collections;
public class NetworkCharacter : Photon.MonoBehaviour {
Vector3 realPosition = Vector3.zero;
Quaternion realRotation = Quaternion.identity;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(photonView.isMine){
//Do nothing
}else{
transform.position = Vector3.Lerp (transform.position, realPosition, 0.1f);
realPosition = transform.position;
transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, 0.1f);
realRotation = transform.rotation;
}
}
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){
if(stream.isWriting){
//Our player
stream.SendNext (transform.position);
stream.SendNext (transform.rotation);
}else{
//Someone else's player
transform.position = (Vector3)stream.ReceiveNext();
transform.rotation = (Quaternion)stream.ReceiveNext();
}
}
}