From fb4d9b85c90162c58d530a628125b25b5333142a Mon Sep 17 00:00:00 2001 From: Tom Gerrits Date: Mon, 30 Nov 2020 10:56:39 +0100 Subject: [PATCH] Fix generic lerp never reaching target This will not pose a problem in practice most of the time, because float and double have specific overrides that do work. The generic implementation however always returned a0, which means that the promise of a1 being returned when t = 1 never holds true. If lerping is not supported for a type, the generic implementation should probably always return a1 instead, unless t = 0, immediately reaching the destination. Otherwise, interpolating values gradually over the network will keep trying to get closer to the destination value in YourGeneratedNetworkObject.InterpolateUpdate, but will never reach its destination. --- .../BeardedManStudios/Scripts/Networking/BeardedMath.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ForgeUnity/Assets/BeardedManStudios/Scripts/Networking/BeardedMath.cs b/ForgeUnity/Assets/BeardedManStudios/Scripts/Networking/BeardedMath.cs index 158b6639..78d5702c 100644 --- a/ForgeUnity/Assets/BeardedManStudios/Scripts/Networking/BeardedMath.cs +++ b/ForgeUnity/Assets/BeardedManStudios/Scripts/Networking/BeardedMath.cs @@ -1,4 +1,4 @@ -namespace BeardedManStudios +namespace BeardedManStudios { /// /// A class that is to be extended to support math models that are not currently available in any @@ -21,7 +21,7 @@ public static double Lerp(double a0, double a1, float t) public static T Lerp(T a0, T a1, float t) { - return a0; + return t == 0f ? a0 : a1; } ///