Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

força de jogar o objeto #257

Open
StefanWerW opened this issue Jun 27, 2016 · 0 comments
Open

força de jogar o objeto #257

StefanWerW opened this issue Jun 27, 2016 · 0 comments

Comments

@StefanWerW
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant