diff --git a/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafAttack.cs b/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafAttack.cs index 71a23115..86ac07e0 100644 --- a/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafAttack.cs +++ b/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafAttack.cs @@ -95,6 +95,9 @@ public partial class LeafAttack : BehaviourTreeNode //Catch player when in range for long enough //Debug.Log("Success: Caught"); player.GetScript().currentState = PlayerController.RaccoonStates.CAUGHT; + if (player.GetScript().stateMachine && !player.GetScript().stateMachine.IsState(typeof(PlayerCaughtState))) + player.GetScript().stateMachine.SetState(typeof(PlayerCaughtState)); + status = BehaviourTreeNodeStatus.SUCCESS; onExit(BehaviourTreeNodeStatus.SUCCESS); return status; diff --git a/Assets/Scripts/Gameplay/Item/SC_Item.cs b/Assets/Scripts/Gameplay/Item/SC_Item.cs index ab729d43..8d8ffb62 100644 --- a/Assets/Scripts/Gameplay/Item/SC_Item.cs +++ b/Assets/Scripts/Gameplay/Item/SC_Item.cs @@ -49,6 +49,11 @@ public class Item : Script Audio.PlaySFXOnce2D("event:/Props/impact_hard"); playSound = false; } + + if (info.GameObject.GetScript()) + { + returnBack = true; + } } protected override void onCollisionExit(CollisionInfo info) diff --git a/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs index e8820034..5789ffb6 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs @@ -117,13 +117,6 @@ public class PickAndThrow : Script RetrieveItemComponets(); } } - - if (pc.currentState == RaccoonStates.CAUGHT && itemScript) - { - itemScript.returnBack = true; - pc.holdItem = true; - ResetItemObject(); - } } protected override void fixedUpdate() @@ -230,7 +223,6 @@ public class PickAndThrow : Script return false; } return false; - } diff --git a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs index c9e7b81e..0122a30e 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs @@ -31,7 +31,7 @@ public class PlayerController : Script public Camera cam { get; set; } public CameraArm camArm { get; set; } private PickAndThrow pat; - private StateMachine stateMachine; + public StateMachine stateMachine; public bool holdItem { get; set; } public bool isAiming { get; set; } @@ -370,6 +370,13 @@ public class PlayerController : Script if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState))) stateMachine.SetState(typeof(PlayerIdleState)); tranform.LocalPosition = respawnPoint.GetComponent().LocalPosition; + + if (pat && pat.item.GetScript()) + { + holdItem = false; + isAiming = false; + pat.item.GetScript().returnBack = true; + } } }