mirror of
https://github.com/ConjureETS/PillowFight.git
synced 2026-03-24 00:50:59 +00:00
Add the ability to sleep on a bed anytime
This commit is contained in:
parent
f27b67061e
commit
0a1931c7d0
Binary file not shown.
Binary file not shown.
@ -62,7 +62,9 @@ public class Child : MonoBehaviour
|
||||
|
||||
private bool IsGrounded()
|
||||
{
|
||||
Collider[] colliders = Physics.OverlapSphere(GroundCheck.transform.position, 0.149f, 1 << LayerMask.NameToLayer("Ground"));
|
||||
int mask = (1 << LayerMask.NameToLayer("Ground")) | (1 << LayerMask.NameToLayer("Bed"));
|
||||
|
||||
Collider[] colliders = Physics.OverlapSphere(GroundCheck.transform.position, 0.149f, mask);
|
||||
|
||||
return colliders.Length > 0;
|
||||
}
|
||||
@ -87,12 +89,21 @@ public class Child : MonoBehaviour
|
||||
{
|
||||
_isSleeping = IsOnBed();
|
||||
|
||||
// Temporary (only for visual cue until we get the animation)
|
||||
if (_isSleeping)
|
||||
{
|
||||
transform.localEulerAngles = new Vector3(90f, transform.localEulerAngles.y, transform.localEulerAngles.z);
|
||||
}
|
||||
|
||||
return _isSleeping;
|
||||
}
|
||||
|
||||
public void WakeUp()
|
||||
{
|
||||
_isSleeping = false;
|
||||
|
||||
// Temporary (only for visual cue until we get the animation)
|
||||
transform.localEulerAngles = new Vector3(0f, transform.localEulerAngles.y, transform.localEulerAngles.z);
|
||||
}
|
||||
|
||||
private bool IsOnBed()
|
||||
|
||||
@ -60,10 +60,12 @@ public class ChildController : MonoBehaviour
|
||||
|
||||
if (input.Actions.Contains("Sleep") && _child.Sleep())
|
||||
{
|
||||
Debug.Log("SLEEPING");
|
||||
InputManager.Instance.PushActiveContext("Sleeping", (int)PlayerNumber);
|
||||
}
|
||||
else if (input.Actions.Contains("WakeUp"))
|
||||
{
|
||||
Debug.Log("AWAKE");
|
||||
_child.WakeUp();
|
||||
InputManager.Instance.PushActiveContext("Awake", (int)PlayerNumber);
|
||||
}
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user