示例#1
0
    public void SlowDown(float slowingAmount = 0.01f, float dontSlowY = 0.0f)
    {
        if (thisObject.velocity.x != 0)
        {
            var     counterDirection = -Mathf.Sign(thisObject.velocity.x);
            Vector2 walkVector;
            if (GlobalFuncs.Dif(thisObject.velocity.x, walkSpeed * slowingAmount) < Mathf.Abs(walkSpeed * slowingAmount))
            {
                walkVector = new Vector2(-thisObject.velocity.x, dontSlowY);
            }
            else
            {
                walkVector = new Vector2(walkSpeed * slowingAmount * counterDirection, dontSlowY);
            }

            thisObject.velocity += walkVector;
        }
    }