Commit bca7b3f8 authored by Tanner Grehawick's avatar Tanner Grehawick

wall slide only works when pushing button into wall

parent 8bfb0f0a
......@@ -99,40 +99,46 @@ public class Walk : AbstractBehavior {
body.velocity = new Vector2(airSpeed, body.velocity.y);
} else //handles wall sliding
{
isWallSliding = true;
rightTime = inputState.GetButtonHoldTime(right);
leftTime = inputState.GetButtonHoldTime(left);
isWallSliding =
(collisionState.onWallLeft && inputState.GetButtonValue(left)) ||
(collisionState.onWallRight && inputState.GetButtonValue(right));
airSpeed = body.velocity.x;
if (isWallSliding) {
//only sets a change if the button has been held for a set time
if (rightTime >= wallClingTime && collisionState.onWallLeft)
{
isWallSliding = false;
airSpeed = Mathf.Clamp(airSpeed + airAcceleration * (rightInt + leftInt), -speed, speed);
}
if (leftTime >= wallClingTime && collisionState.onWallRight)
{
isWallSliding = false;
airSpeed = Mathf.Clamp(airSpeed + airAcceleration * (rightInt + leftInt), -speed, speed);
}
/*
airSpeed = body.velocity.x;
//same as if not on wall and not pressing the buttons
if (!inputState.GetButtonValue(right) && !inputState.GetButtonValue(left))
{
if (airSpeed != 0)
//only sets a change if the button has been held for a set time
if (rightTime >= wallClingTime && collisionState.onWallLeft)
{
airSpeed += (-1) * Mathf.Sign(airSpeed) * airAcceleration;
if (Mathf.Abs(airSpeed) < airAcceleration)
airSpeed = 0;
isWallSliding = false;
airSpeed = Mathf.Clamp(airSpeed + airAcceleration * (rightInt + leftInt), -speed, speed);
}
if (leftTime >= wallClingTime && collisionState.onWallRight)
{
isWallSliding = false;
airSpeed = Mathf.Clamp(airSpeed + airAcceleration * (rightInt + leftInt), -speed, speed);
}
*/
//same as if not on wall and not pressing the buttons
// if (!inputState.GetButtonValue(right) && !inputState.GetButtonValue(left))
// {
// if (airSpeed != 0)
// {
// airSpeed += (-1) * Mathf.Sign(airSpeed) * airAcceleration;
// if (Mathf.Abs(airSpeed) < airAcceleration)
// airSpeed = 0;
// }
// }
// body.velocity = new Vector2(airSpeed, body.velocity.y);
//slow down y velocity
if(body.velocity.y < clingSpeed)
{
body.velocity = new Vector2(body.velocity.x, -clingSpeed);
}
}
body.velocity = new Vector2(airSpeed, body.velocity.y);
//slow down y velocity
if(body.velocity.y < clingSpeed)
{
body.velocity = new Vector2(body.velocity.x, -clingSpeed);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment