How to smooth rotation and position?
Options
How can I smooth the player rotation and position?
I've tried this but it doesn't work when there is multiple players in the server.
I've tried this but it doesn't work when there is multiple players in the server.
using System.Collections; using System.Collections.Generic; using UnityEngine; public class NetworkCharacter : Photon.MonoBehaviour { Vector3 realPosition = Vector3.zero; Quaternion realRotation = Quaternion.identity; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if(photonView.isMine) { } else { transform.position = Vector3.Lerp(transform.position, realPosition, 0.1f); transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, 0.1f); } } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if(stream.isWriting) { stream.SendNext(transform.position); stream.SendNext(transform.rotation); } else { realPosition = (Vector3)stream.ReceiveNext(); realRotation = (Quaternion)stream.ReceiveNext(); } } }
0