mirror of
https://github.com/ConjureETS/PillowFight.git
synced 2026-03-26 01:50:57 +00:00
Add a temporary "push" method for when the player will get knocked back by
a pillow
This commit is contained in:
parent
e76e32efe7
commit
d439d7dce5
@ -21,6 +21,7 @@ public class Child : MonoBehaviour
|
||||
public Transform target;
|
||||
|
||||
private int _index;
|
||||
private bool _isPushed = false;
|
||||
|
||||
public int Index
|
||||
{
|
||||
@ -72,6 +73,15 @@ public class Child : MonoBehaviour
|
||||
{
|
||||
// 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 rightDir = Camera.main.transform.right;
|
||||
|
||||
@ -83,6 +93,7 @@ public class Child : MonoBehaviour
|
||||
|
||||
_rb.velocity = forwardDir + rightDir;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsGrounded()
|
||||
{
|
||||
@ -168,6 +179,12 @@ public class Child : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void Push(Vector3 force)
|
||||
{
|
||||
_isPushed = true;
|
||||
_rb.AddForce(force);
|
||||
}
|
||||
|
||||
private void TakeLavaDamage()
|
||||
{
|
||||
// TODO: Lose a life (probably) and become immune for ~ 2 or 3 seconds
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user