コード例 #1
0
    public void getPushed(Vector2 direction, KinematicPlayer script)
    {
        currentState = state.PUSHED;

        // reduce collider size, so that adjacent tiles aren't accidently hit
        reduceColliderSize();

        // check if we're inside a block. if we are, destroy ourselves
        RaycastHit2D[] results = new RaycastHit2D[8];
        if (c2d.Cast(Vector2.one, rockFilter, results, 0) > 0)
        {
            HitDestroy();
        }

        gameObject.layer = projectileLayer;
        rb2d.bodyType    = RigidbodyType2D.Dynamic;
        rb2d.velocity    = pushSpeed * direction;

        if (!owner)
        {
            owner = script;
        }

        c2d.isTrigger = false;
        timePushed    = Time.time;

        if (attachedObject)
        {
            attachedObject.DestoryObject();
        }
    }
コード例 #2
0
    public bool getGrabbed(KinematicPlayer script)
    {
        if (currentState != state.FIXED)
        {
            return(false);
        }
        gameObject.layer = noColLayer;
        currentState     = state.HELD;
        rb2d.bodyType    = RigidbodyType2D.Dynamic;

        owner         = script;
        c2d.isTrigger = true;

        if (otherObject)
        {
            otherObject.DestoryObject();
        }

        return(true);
    }