From ac1cdf9e47136d03836bdf75490e881b228f26b1 Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Mon, 12 Apr 2021 04:46:35 -0400 Subject: [PATCH 1/3] Fix anticipation for mage-bolts through walls Updates the Anticipation logic for FXProjectileTargetedActionFX so that it can properly anticipate when a mage-bolt is going to slam into a wall. --- .../Game/Action/FXProjectileTargetedActionFX.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs b/Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs index 17275e929..2b5806a8a 100644 --- a/Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs +++ b/Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs @@ -147,6 +147,20 @@ public override void AnticipateAction() { base.AnticipateAction(); PlayFireAnim(); + + // see if this is going to be a "miss" because the player tried to click through a wall. If so, + // we change our data in the same way that the server will (changing our target point to the spot on the wall) + if (Data.TargetIds != null && Data.TargetIds.Length > 0) + { + var targetId = Data.TargetIds[0]; + NetworkObject targetObj = MLAPI.Spawning.NetworkSpawnManager.SpawnedObjects[targetId]; + if (targetObj != null && !ActionUtils.HasLineOfSight(m_Parent.transform.position, targetObj.transform.position, out Vector3 collidePos)) + { + // we do not have line of sight to the target point. So our target instead becomes the obstruction point + Data.TargetIds = null; + Data.Position = collidePos; + } + } } } } From 0919f2873f1c560ea0bea61214a66ccba381b64d Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Mon, 12 Apr 2021 04:54:37 -0400 Subject: [PATCH 2/3] use var keyword --- .../Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs b/Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs index 2b5806a8a..c0bc03bf2 100644 --- a/Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs +++ b/Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs @@ -152,8 +152,7 @@ public override void AnticipateAction() // we change our data in the same way that the server will (changing our target point to the spot on the wall) if (Data.TargetIds != null && Data.TargetIds.Length > 0) { - var targetId = Data.TargetIds[0]; - NetworkObject targetObj = MLAPI.Spawning.NetworkSpawnManager.SpawnedObjects[targetId]; + var targetObj = NetworkSpawnManager.SpawnedObjects[Data.TargetIds[0]]; if (targetObj != null && !ActionUtils.HasLineOfSight(m_Parent.transform.position, targetObj.transform.position, out Vector3 collidePos)) { // we do not have line of sight to the target point. So our target instead becomes the obstruction point From 9a75a3f704ae4bde7d561412a07364c4304b03d5 Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Tue, 13 Apr 2021 01:03:22 -0400 Subject: [PATCH 3/3] Handle untargeted mage bolts --- .../Game/Action/FXProjectileTargetedActionFX.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs b/Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs index c0bc03bf2..68e56dd8f 100644 --- a/Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs +++ b/Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs @@ -150,16 +150,22 @@ public override void AnticipateAction() // see if this is going to be a "miss" because the player tried to click through a wall. If so, // we change our data in the same way that the server will (changing our target point to the spot on the wall) + Vector3 targetSpot = Data.Position; if (Data.TargetIds != null && Data.TargetIds.Length > 0) { var targetObj = NetworkSpawnManager.SpawnedObjects[Data.TargetIds[0]]; - if (targetObj != null && !ActionUtils.HasLineOfSight(m_Parent.transform.position, targetObj.transform.position, out Vector3 collidePos)) + if (targetObj) { - // we do not have line of sight to the target point. So our target instead becomes the obstruction point - Data.TargetIds = null; - Data.Position = collidePos; + targetSpot = targetObj.transform.position; } } + + if (!ActionUtils.HasLineOfSight(m_Parent.transform.position, targetSpot, out Vector3 collidePos)) + { + // we do not have line of sight to the target point. So our target instead becomes the obstruction point + Data.TargetIds = null; + Data.Position = collidePos; + } } } }