items changes

items now return back to their original position when owner collides with it
This commit is contained in:
Glence 2023-01-25 18:20:26 +08:00
parent 7f787f2593
commit 7d9ab7a381
4 changed files with 16 additions and 9 deletions

View File

@ -95,6 +95,9 @@ public partial class LeafAttack : BehaviourTreeNode
//Catch player when in range for long enough //Catch player when in range for long enough
//Debug.Log("Success: Caught"); //Debug.Log("Success: Caught");
player.GetScript<PlayerController>().currentState = PlayerController.RaccoonStates.CAUGHT; player.GetScript<PlayerController>().currentState = PlayerController.RaccoonStates.CAUGHT;
if (player.GetScript<PlayerController>().stateMachine && !player.GetScript<PlayerController>().stateMachine.IsState(typeof(PlayerCaughtState)))
player.GetScript<PlayerController>().stateMachine.SetState(typeof(PlayerCaughtState));
status = BehaviourTreeNodeStatus.SUCCESS; status = BehaviourTreeNodeStatus.SUCCESS;
onExit(BehaviourTreeNodeStatus.SUCCESS); onExit(BehaviourTreeNodeStatus.SUCCESS);
return status; return status;

View File

@ -49,6 +49,11 @@ public class Item : Script
Audio.PlaySFXOnce2D("event:/Props/impact_hard"); Audio.PlaySFXOnce2D("event:/Props/impact_hard");
playSound = false; playSound = false;
} }
if (info.GameObject.GetScript<Homeowner1>())
{
returnBack = true;
}
} }
protected override void onCollisionExit(CollisionInfo info) protected override void onCollisionExit(CollisionInfo info)

View File

@ -117,13 +117,6 @@ public class PickAndThrow : Script
RetrieveItemComponets(); RetrieveItemComponets();
} }
} }
if (pc.currentState == RaccoonStates.CAUGHT && itemScript)
{
itemScript.returnBack = true;
pc.holdItem = true;
ResetItemObject();
}
} }
protected override void fixedUpdate() protected override void fixedUpdate()
@ -230,7 +223,6 @@ public class PickAndThrow : Script
return false; return false;
} }
return false; return false;
} }

View File

@ -31,7 +31,7 @@ public class PlayerController : Script
public Camera cam { get; set; } public Camera cam { get; set; }
public CameraArm camArm { get; set; } public CameraArm camArm { get; set; }
private PickAndThrow pat; private PickAndThrow pat;
private StateMachine stateMachine; public StateMachine stateMachine;
public bool holdItem { get; set; } public bool holdItem { get; set; }
public bool isAiming { get; set; } public bool isAiming { get; set; }
@ -370,6 +370,13 @@ public class PlayerController : Script
if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState))) if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState)))
stateMachine.SetState(typeof(PlayerIdleState)); stateMachine.SetState(typeof(PlayerIdleState));
tranform.LocalPosition = respawnPoint.GetComponent<Transform>().LocalPosition; tranform.LocalPosition = respawnPoint.GetComponent<Transform>().LocalPosition;
if (pat && pat.item.GetScript<Item>())
{
holdItem = false;
isAiming = false;
pat.item.GetScript<Item>().returnBack = true;
}
} }
} }