Exemple #1
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.tag == "floor" || editMode)
        {
            MovementModel.Landed();

            if (!currentCollisions.Contains(collision.collider))
            {
                currentCollisions.Add(collision.collider);
            }

            if (Mathf.Abs(collision.contacts[0].normal.x) > 0.4f)
            {
                //for future implementation of wall velocity transfer.
                //impactAngle = SMath.VectorToDegree( collision.relativeVelocity );
                //impactVelocity = collision.relativeVelocity;

                wallHugDirection = collision.contacts[0].normal.x;
            }

            CurrentState.CollisionChange(collision, CollisionState.ENTERING);
        }
        else if (collision.collider.tag == "Environment")
        {
            resetCharacter();
        }
    }