Example #1
0
    private void HandlePhysicsInput()
    {
        if (!Input.anyKey)
        {
            return;
        }

        // Dash
        if (Input.GetKey(KeyCode.Space))
        {
            if (canDash)
            {
                Dash(StaticOperations.TargetUnitVec(body.position,
                                                    cam.ScreenToWorldPoint(Input.mousePosition)));
            }
        }

        // Regular movement
        if (canMove)
        {
            Vector2 vec = GetMovementInput();
            if (vec.magnitude > 0)
            {
                if (Input.GetKey(KeyCode.LeftShift) && SprintUpdate())
                {
                    // sprinting
                    Move(vec, movementForce * 1.5f, sprintMaxVel);
                }
                else
                {
                    Move(vec, movementForce, MAX_VEL);
                }
            }
        }
    }
Example #2
0
 protected Vector2 GetDirectionToPlayer()
 {
     return(StaticOperations.TargetUnitVec(body.position, player.body.position));
 }