mirror of
https://github.com/ConjureETS/PillowFight.git
synced 2026-03-25 09:30:58 +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;
|
public Transform target;
|
||||||
|
|
||||||
private int _index;
|
private int _index;
|
||||||
|
private bool _isPushed = false;
|
||||||
|
|
||||||
public int Index
|
public int Index
|
||||||
{
|
{
|
||||||
@ -72,16 +73,26 @@ public class Child : MonoBehaviour
|
|||||||
{
|
{
|
||||||
// We move the child depending on the camera orientation
|
// We move the child depending on the camera orientation
|
||||||
|
|
||||||
Vector3 forwardDir = Camera.main.transform.forward;
|
if (_isPushed)
|
||||||
Vector3 rightDir = Camera.main.transform.right;
|
{
|
||||||
|
if (_rb.velocity == Vector3.zero)
|
||||||
|
{
|
||||||
|
_isPushed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Vector3 forwardDir = Camera.main.transform.forward;
|
||||||
|
Vector3 rightDir = Camera.main.transform.right;
|
||||||
|
|
||||||
forwardDir *= _zValue * Speed;
|
forwardDir *= _zValue * Speed;
|
||||||
forwardDir.y = _rb.velocity.y;
|
forwardDir.y = _rb.velocity.y;
|
||||||
|
|
||||||
rightDir *= _xValue * Speed;
|
rightDir *= _xValue * Speed;
|
||||||
rightDir.y = 0f;
|
rightDir.y = 0f;
|
||||||
|
|
||||||
_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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user