https://doc.photonengine.com/ko-kr/pun/current/gameplay/lagcompensation
지연 보상 | Photon Engine
게임에 물리 객체가있을 때, 특히 두 개 이상의 게임 윈도우가 서로 나란히 있을 때 이러한 객체가 동기화되지 않을 수 있습니다. 이로 인해 게임에 심각한 문제가 발생할 수 있으며 결국 플레이
doc.photonengine.com
네트워크 연결 시 Player와 Master의 네트워크 연결 동기화상태가 일치하지않고 살짝씩 느려서 해결해보고있다.
https://devsquare.tistory.com/4
[Tip] 깔끔한 지연 보상의 처리
Photon Pun2 의 튜토리얼 가이드에서 지연보상을 코드로 직접 구현을 하는데 번거로울 뿐더러 깔끔하지도 않다. 이를 처리하기 위해 이것저것 살펴본 결과 찾아낸 해결책은 아래와 같다. PhotonTransfo
devsquare.tistory.com
https://doc.photonengine.com/ko-KR/pun/v1/demos-and-tutorials/package-demos/rpg-movement
RPG 이동 데모 | Photon Engine
이 데모는 Photon을 이용한 캐릭터의 기본 이동을 동기화 할 것 입니다. 새로운 PhotonTransformView 컴포넌트는 지점까지 이동할 때 다양한 옵션이 있고 로컬 캐릭터처럼 원격 캐릭터가 부드럽게 이동
doc.photonengine.com
using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static Oculus.Interaction.OptionalAttribute;
public class DelayReward : MonoBehaviour,IPunObservable
{
[SerializeField] private Rigidbody rb;
[SerializeField] private PhotonView pv;
private Vector3 networkPosition;
private Quaternion networkRotation;
public float damping;
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.IsWriting)
{
stream.SendNext(rb.position);
stream.SendNext(rb.rotation);
stream.SendNext(rb.velocity);
stream.SendNext(rb.angularVelocity);
}
else
{
networkPosition = (Vector3)stream.ReceiveNext();
networkRotation = (Quaternion)stream.ReceiveNext();
rb.velocity = (Vector3)stream.ReceiveNext();
rb.angularVelocity = (Vector3)stream.ReceiveNext();
float lag = Mathf.Abs((float)(PhotonNetwork.Time - info.SentServerTime));
networkPosition += rb.velocity * lag;
networkRotation = Quaternion.Euler(this.rb.angularVelocity * lag) * networkRotation;
}
}
public void FixedUpdate()
{
if (!pv.IsMine)
{
this.rb.position = Vector3.Lerp(this.rb.position, networkPosition, Time.fixedDeltaTime*damping);
Quaternion Q = Quaternion.Slerp(this.rb.rotation, networkRotation, Time.deltaTime * damping);
this.rb.rotation =Q.normalized;
}
}
}
'Giant vs Human 팀프로젝트 개발일지' 카테고리의 다른 글
[Giant vs Human/Unity] 개발일지 - 망치휘두르기 [PC기능] (0) | 2023.12.14 |
---|---|
[Giant vs Human 팀프로젝트] 해머구현 (1) | 2023.12.07 |
[Giant vs Human 팀프로젝트] Photon 멀티 동기화 (1) | 2023.11.30 |
[Giant vs Human 팀프로젝트, Mobile] 죽은 후 일정 시간 후 리스폰 (0) | 2023.11.29 |
[Giant vs Human 팀프로젝트, Mobile] 대포가 주변에 있으면 대포발사 버튼이 활성화되고 버튼을 누르면 포탄이 발사 (0) | 2023.11.29 |