mirror of
https://github.com/ConjureETS/PillowFight.git
synced 2026-03-24 00:50:59 +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,16 +73,26 @@ public class Child : MonoBehaviour
|
||||
{
|
||||
// We move the child depending on the camera orientation
|
||||
|
||||
Vector3 forwardDir = Camera.main.transform.forward;
|
||||
Vector3 rightDir = Camera.main.transform.right;
|
||||
if (_isPushed)
|
||||
{
|
||||
if (_rb.velocity == Vector3.zero)
|
||||
{
|
||||
_isPushed = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 forwardDir = Camera.main.transform.forward;
|
||||
Vector3 rightDir = Camera.main.transform.right;
|
||||
|
||||
forwardDir *= _zValue * Speed;
|
||||
forwardDir.y = _rb.velocity.y;
|
||||
forwardDir *= _zValue * Speed;
|
||||
forwardDir.y = _rb.velocity.y;
|
||||
|
||||
rightDir *= _xValue * Speed;
|
||||
rightDir.y = 0f;
|
||||
rightDir *= _xValue * Speed;
|
||||
rightDir.y = 0f;
|
||||
|
||||
_rb.velocity = forwardDir + rightDir;
|
||||
_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