Add a temporary "push" method for when the player will get knocked back by

a pillow
This commit is contained in:
Patrice Vignola 2015-08-22 10:08:59 -04:00
parent e76e32efe7
commit d439d7dce5

View File

@ -21,6 +21,7 @@ public class Child : MonoBehaviour
public Transform target; public Transform target;
private int _index; private int _index;
private bool _isPushed = false;
public int Index public int Index
{ {
@ -72,6 +73,15 @@ public class Child : MonoBehaviour
{ {
// We move the child depending on the camera orientation // We move the child depending on the camera orientation
if (_isPushed)
{
if (_rb.velocity == Vector3.zero)
{
_isPushed = false;
}
}
else
{
Vector3 forwardDir = Camera.main.transform.forward; Vector3 forwardDir = Camera.main.transform.forward;
Vector3 rightDir = Camera.main.transform.right; Vector3 rightDir = Camera.main.transform.right;
@ -83,6 +93,7 @@ public class Child : MonoBehaviour
_rb.velocity = forwardDir + rightDir; _rb.velocity = forwardDir + rightDir;
} }
}
private bool IsGrounded() private bool IsGrounded()
{ {
@ -168,6 +179,12 @@ public class Child : MonoBehaviour
} }
} }
public void Push(Vector3 force)
{
_isPushed = true;
_rb.AddForce(force);
}
private void TakeLavaDamage() private void TakeLavaDamage()
{ {
// TODO: Lose a life (probably) and become immune for ~ 2 or 3 seconds // TODO: Lose a life (probably) and become immune for ~ 2 or 3 seconds