Skip to content

Commit

Permalink
Change interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jul 8, 2024
1 parent a444f81 commit 8f22dde
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Fika.Core/Coop/Players/ObservedCoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class ObservedCoopPlayer : CoopPlayer
{
#region Fields and Properties
public CoopPlayer MainPlayer => (CoopPlayer)Singleton<GameWorld>.Instance.MainPlayer;
private readonly float interpolationRatio = 0.5f;
private float observedFixedTime = 0f;
private FikaHealthBar healthBar = null;
private Coroutine waitForStartRoutine;
Expand Down Expand Up @@ -537,10 +536,12 @@ public override void OnPhraseTold(EPhraseTrigger @event, TaggedClip clip, TagBan

public PlayerStatePacket Interpolate(in PlayerStatePacket newState, in PlayerStatePacket lastState)
{
float interpolate = Time.fixedDeltaTime;

method_58(newState.HasGround, newState.SurfaceSound);

Rotation = new Vector2(Mathf.LerpAngle(MovementContext.Rotation.x, newState.Rotation.x, interpolationRatio),
Mathf.Lerp(MovementContext.Rotation.y, newState.Rotation.y, interpolationRatio));
Rotation = new Vector2(Mathf.LerpAngle(MovementContext.Rotation.x, newState.Rotation.x, interpolate),
Mathf.Lerp(MovementContext.Rotation.y, newState.Rotation.y, interpolate));

HeadRotation = newState.HeadRotation;
ProceduralWeaponAnimation.SetHeadRotation(HeadRotation);
Expand Down Expand Up @@ -607,11 +608,11 @@ public PlayerStatePacket Interpolate(in PlayerStatePacket newState, in PlayerSta

if (!IsInventoryOpened)
{
Move(Vector2.Lerp(newState.MovementDirection, lastState.MovementDirection, interpolationRatio));
Move(Vector2.Lerp(newState.MovementDirection, lastState.MovementDirection, interpolate));
}

Vector3 newPosition = Vector3.Lerp(MovementContext.TransformPosition, newState.Position, interpolationRatio);
CharacterController.Move(newPosition - MovementContext.TransformPosition, interpolationRatio);
Vector3 newPosition = Vector3.Lerp(MovementContext.TransformPosition, newState.Position, interpolate);
CharacterController.Move(newPosition - MovementContext.TransformPosition, interpolate);

if (!Mathf.Approximately(MovementContext.Tilt, newState.Tilt))
{
Expand Down

0 comments on commit 8f22dde

Please sign in to comment.