- Home /
My character is falling and standing/jumping at the same time?
if my players y velocity is less than -1 then fall is true. if my players y velocity is greater than or equal to 0 then stand = true. I have a debug log showing when my player is falling or standing. However they are both counting when either action is performed.
public float slideFriction;
public float normalFriction;
public Collider2D coll;
void Start ()
{
coll = GetComponent<Collider2D>();
fall = false;
stand = false;
}
void FixedUpdate();
playerVelocityY = Player.velocity.y;
if (playerVelocityY >= 0f)
{
stand = true;
}
if (playerVelocityY <= -1f)
{
fall = true;
}
if (fall)
{
Debug.Log ("FALL");
coll.sharedMaterial.friction = slideFriction;
}
if (stand)
{
Debug.Log ("JUMP / STAND");
coll.sharedMaterial.friction = normalFriction;
}
When falling i want my characters friction to become slideFriction (for slowed wall sliding) and when jumping or standing I want my characters friction to become normalFriction (so that when I jump against a wall I have very little resistance against my jump).
My jumping code is fine the only problem is this. Please help. Thanks in advance.
Comment
Your answer