Implemented charge cancelling

Stop charging with mouse 2 and still stick to things
This commit is contained in:
Jan Groß
2018-09-02 18:25:11 +02:00
parent a33228238f
commit da62c3af08

View File

@@ -50,7 +50,7 @@ public class LurchMovement : MonoBehaviour {
private bool stickToGround = false; private bool stickToGround = false;
[SerializeField] [SerializeField]
private float stickyOffset = 1; private float stickyOffset = 1;
private bool blockCharge = false;
[Header("Gliding")] [Header("Gliding")]
public bool canGlide; public bool canGlide;
@@ -125,7 +125,11 @@ public class LurchMovement : MonoBehaviour {
void JumpControl() void JumpControl()
{ {
if (Input.GetButton("Fire1") && currentJumpForce < maxJumpForce) if (Input.GetButtonDown("Fire1"))
{
blockCharge = false;
}
if (Input.GetButton("Fire1") && currentJumpForce < maxJumpForce && cooldown <= 0 && !blockCharge )
{ {
currentJumpForce += forceIncreaseSpeed; currentJumpForce += forceIncreaseSpeed;
lerpedColor = Color.Lerp(normalColor, fullyChargedColor, t); lerpedColor = Color.Lerp(normalColor, fullyChargedColor, t);
@@ -141,7 +145,7 @@ public class LurchMovement : MonoBehaviour {
{ {
lerpedColor = normalColor; lerpedColor = normalColor;
t = 0.0f; t = 0.0f;
currentSize = normalSize; currentSize = Vector3.Lerp(currentSize, normalSize, Time.deltaTime * 5f);
} }
@@ -151,7 +155,7 @@ public class LurchMovement : MonoBehaviour {
currentJumpForce = 0.0f; currentJumpForce = 0.0f;
} }
if (Input.GetButtonUp("Fire1")) { if (Input.GetButtonUp("Fire1") && cooldown <= 0 && !blockCharge) {
cooldown = 0.5f; cooldown = 0.5f;
lurchBody.isKinematic = false; lurchBody.isKinematic = false;
stickToGround = false; stickToGround = false;
@@ -159,6 +163,12 @@ public class LurchMovement : MonoBehaviour {
lurchBody.AddForce(theLurch.forward * currentJumpForce, ForceMode.Impulse); lurchBody.AddForce(theLurch.forward * currentJumpForce, ForceMode.Impulse);
lurchBody.AddForce(theLurch.up * currentJumpForce * upForceModifier, ForceMode.Impulse); lurchBody.AddForce(theLurch.up * currentJumpForce * upForceModifier, ForceMode.Impulse);
} }
else if (Input.GetButton("Fire2")) {
currentJumpForce = 0.0f;
cooldown = 0.5f;
currentSize = Vector3.Lerp(currentSize, normalSize, Time.deltaTime * 5f);
blockCharge = true;
}
else if (LurchOnGround() && Time.time > cooldown) else if (LurchOnGround() && Time.time > cooldown)
{ {
//stickToGround = true; //stickToGround = true;