MuvucaGames / MuvucaGame01

Repository para o primeiro jogo da MuvucaGames. Nome sera alterado quando Titulo oficial do game for escolhido.
GNU General Public License v3.0
21 stars 55 forks source link

força de jogar o objeto #257

Open StefanWerW opened 8 years ago

StefanWerW commented 8 years ago

Será que a força que o herói joga o objeto carregavel não deveria ser um parâmetro do herói?

public void ReleaseObject(){
        Carriable carriable = CarriedObject.GetComponent<Carriable> ();
        float fator = (carriable.isHeavy()?1.5f:1);
        SliderJoint2D sliderJoint = GetComponent<SliderJoint2D>();
        sliderJoint.connectedBody = null;
        sliderJoint.enabled = false;
        if (Crouched) {
            CarriedObject.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, 0);
            CarriedObject.transform.rotation = new Quaternion(0, 0, 0, CarriedObject.transform.localRotation.w);
            CarriedObject.transform.position = new Vector2 (transform.position.x + facingDirection * transform.localScale.x/2 + facingDirection * CarriedObject.transform.localScale.x/2, transform.position.y - transform.localScale.y + CarriedObject.transform.localScale.y + offsetCarryObjHero*fator);
        }
        else
        {
            CarriedObject.GetComponent<Rigidbody2D> ().velocity = new Vector2 (rigidBody2D.velocity.x, 0);
            CarriedObject.GetComponent<Rigidbody2D> ().AddForce (new Vector2 (fator * facingDirection * 5f, fator * 1f), ForceMode2D.Impulse);
        }
        Carrying = false;
        CarriedObject = null;
        carriable.isBeingCarried = false;
        animator.SetBool ("carry", false);
    }

Esse factor, esse valor 5f dentro do addforce, etc, deveriamos juntar tudo em um parâmetro, e o GD define a força. O que acham?