Exemple #1
0
    void FixedUpdate()
    {
        if (Input.GetMouseButton(1)) //Этот метод вызывается каждый кадр, если зажата ПКМ, не путать с Input.GetMouseButtonDown
        {
            RaycastHit2D hit = Physics2D.Raycast(body.position, Util.AimDIr(), 1000f, Util.LayerAllPhysObjects());
            Debug.DrawRay(body.position, Util.AimDIr()); //DrawRay не умеет в длину луча, действительный луч имеет длину в 1000f

            if (hit.collider != null && !Util.IsInLayerMask(hit.collider.gameObject.layer, Util.LayerStaticPhysObjectsOnly()))
            {
                if (!grab.holding)
                {
                    grab.Pull(hit.collider.gameObject);
                }
            }
        }
        if (grab.holding)
        {
            grab.Hold();
        }

        horizontal = Input.GetAxis("Horizontal");
        vertical   = Input.GetAxis("Vertical");

        if (horizontal != 0)
        {
            climp(horizontal);
            if (body.velocity.y < 0)
            {
                hangOn(horizontal);
            }
        }

        if (!hangedOn)
        {
            body.velocity = new Vector2(horizontal * speed, body.velocity.y);
        }

        if (telekines.working)
        {
            telekines.Work();
        }
    }