Fix a bug in the pillow spawner script

This commit is contained in:
Patrice Vignola 2015-08-23 02:21:51 -04:00
parent f94cca5844
commit f6ae2d05c0
3 changed files with 15 additions and 11 deletions

View File

@ -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)
{

View File

@ -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<Rigidbody>().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;
}
}

View File

@ -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 () {