diff --git a/Assets/Scripts/Bed.cs b/Assets/Scripts/Bed.cs index e70f0e1..fb4e896 100644 --- a/Assets/Scripts/Bed.cs +++ b/Assets/Scripts/Bed.cs @@ -41,6 +41,11 @@ public class Bed : MonoBehaviour _nextSpawnDelay = GetNextSpawnDelay(); } } + else if (_currentPillow.IsOwned) + { + _currentPillow = null; + _elapsedTime = 0f; + } } private void SpawnPillow() @@ -89,17 +94,6 @@ public class Bed : MonoBehaviour _isTaken = false; } - void OnCollisionExit(Collision col) - { - Debug.Log(_currentPillow != null && col.gameObject == _currentPillow.gameObject); - - if (_currentPillow != null && col.gameObject == _currentPillow.gameObject) - { - _currentPillow = null; - _elapsedTime = 0f; - } - } - /* void OnCollisionEnter(Collision col) { diff --git a/Assets/Scripts/Child.cs b/Assets/Scripts/Child.cs index c3dcba8..6cbad46 100644 --- a/Assets/Scripts/Child.cs +++ b/Assets/Scripts/Child.cs @@ -66,6 +66,7 @@ public class Child : MonoBehaviour pillow.transform.parent = transform; // make the pillow a child of Child pillow.transform.localPosition = new Vector3(0f, 1.5f, 0f); pillow.GetComponent().isKinematic = true; // dont make pillow obey to gravity when in a child's hands + pillow.IsOwned = true; // TODO: place the pillow correctly or animate or something... } @@ -189,6 +190,8 @@ public class Child : MonoBehaviour pillow.Throw(direction * ThrowForce); + pillow.IsOwned = false; + pillow = null; } } diff --git a/Assets/Scripts/Pillow.cs b/Assets/Scripts/Pillow.cs index 09a0246..5a66288 100644 --- a/Assets/Scripts/Pillow.cs +++ b/Assets/Scripts/Pillow.cs @@ -10,6 +10,13 @@ public class Pillow : MonoBehaviour { private Collider _col; private Rigidbody _rb; + private bool _isOwned; + + public bool IsOwned + { + get { return _isOwned; } + set { _isOwned = value; } + } // Use this for initialization void Start () {