Esempio n. 1
0
        public void MoveCall(Vector3 newPosition)
        {
            Bounds  originalBounds = GetBounds(false);
            Vector3 oldPosition    = this.position;

            Move(newPosition, 0);
            if (Pillar != null)
            {
                Vector3 subPosition = Pillar.position + newPosition - oldPosition;
                Pillar.Move(subPosition, Pillar.angle);
            }
            Bounds fullbounds = GetBounds(false);

            MoveItTool.UpdateArea(originalBounds, true);
            MoveItTool.UpdateArea(fullbounds, true);
        }
Esempio n. 2
0
    // Triggers

    void OnTriggerStay(Collider other)
    {
        if (other.tag == "PushableObjectPad")
        {
            //Push
            if (!pushing && isOnGround && interactButton)
            {
                PushableObjectPad pad = other.gameObject.GetComponent <PushableObjectPad>();
                if (!pad.CanPush())
                {
                    return;
                }
                rb.velocity    = Vector3.zero;
                pushing        = true;
                pushableObject = other.gameObject;
                Vector3    targetPos = pad.transform.position + pad.relStartPos;
                Quaternion targetRot = Quaternion.Euler(transform.eulerAngles.x, pad.yRot, transform.eulerAngles.z);
                StartCoroutine(ClampToSpot((bool end) => {
                    anim.SetTrigger("startPushing");
                }, targetPos, targetRot, 1));
            }
        }
        else if (other.tag == "Pillar")
        {
            if (!interacting && isOnGround && interactButton)
            {
                PushableObjectPad pad    = other.gameObject.GetComponent <PushableObjectPad>();
                Pillar            pillar = other.gameObject.transform.parent.GetComponent <Pillar>();

                // Align character
                Quaternion targetRot = Quaternion.Euler(transform.eulerAngles.x, pad.yRot, transform.eulerAngles.z);
                transform.rotation = Quaternion.Slerp(transform.rotation, targetRot, Time.deltaTime * clampTurningSpeed);

                interacting = true;
                anim.SetTrigger("interact");

                pillar.Move(pad.direction);
                GameSound.Play("Slide");
            }
        }
        else if (other.gameObject.tag == "Platform")
        {
            transform.parent = other.transform.parent.transform;
        }
    }