示例#1
0
        public void TransitionToUser()
        {
            if (!inTransition)
            {
                originalPosition = transform.position;
            }

            if ((currentlyFocusedTarget != null) && (currentlyFocusedTarget != this))
            {
                currentlyFocusedTarget.ReturnHome();
            }

            currentlyFocusedTarget = this;
            isInNearFocusMode      = true;
            inTransition           = true;
        }
示例#2
0
        private void TransitionToCamera()
        {
            if (inTransition)
            {
                //Vector3 destination; //= CameraCache.Main.transform.position + (CameraCache.Main.transform.forward * DistanceToCamera);
                Vector3 destination = (isInNearFocusMode) ?
                                      (CameraCache.Main.transform.position + (CameraCache.Main.transform.forward * DistanceToCamera))
                    : originalPosition;

                Vector3 incr = (destination - gameObject.transform.position) * Time.deltaTime * speed;
                //Debug.Log("target is moving "+ incr.magnitude);

                if (Vector3.Distance(destination, transform.position) < minDistToStopTransition)
                {
                    gameObject.transform.position = new Vector3(destination.x, destination.y, destination.z);
                    inTransition = false;

                    if ((!isInNearFocusMode) && (currentlyFocusedTarget == this))
                    {
                        currentlyFocusedTarget = null;
                    }

                    if (isInNearFocusMode && setToAutoRotateIfFocused)
                    {
                        if ((ActivateBehaviorsWhenInFront != null) && (ActivateBehaviorsWhenInFront.Length > 0))
                        {
                            for (int i = 0; i < ActivateBehaviorsWhenInFront.Length; i++)
                            {
                                ActivateBehaviorsWhenInFront[i].enabled = true;
                            }
                        }
                    }
                }
                else
                {
                    Vector3 oldPos = gameObject.transform.position;
                    gameObject.transform.position = new Vector3(oldPos.x + incr.x, oldPos.y + incr.y, oldPos.z + incr.z);
                }
            }
        }