public virtual void UpdatePosition()
 {
     if (currentActor != null && gameObject.activeSelf)
     {
         transform.position   = currentActor.ComputeWorldRenderBounds().center;
         transform.localScale = currentActor.ComputeWorldRenderBounds().size *scaleMod;
     }
     else
     {
         SetVisiblity(false);
     }
 }
Esempio n. 2
0
    public void OnLateUpdate()
    {
        if (targetActor == null)
        {
            return;
        }
        // Copy/pasted from BehaviorTool for now.
        effectInstance.transform.position = targetActor.ComputeWorldRenderBounds().center;
        float scale = Mathf.Sqrt(Mathf.Pow(targetActor.ComputeWorldRenderBounds().size.x, 2) + Mathf.Pow(targetActor.ComputeWorldRenderBounds().size.z, 2)); //* 1.5f;

        effectInstance.transform.localScale = Vector3.one * (scale + .5f);                                                                                   // currentFocusedActor.GetWorldRenderBounds().size;

        // Also make sure we match the layer, ie for offstage.
        Util.SetLayerRecursively(effectInstance, targetActor.gameObject.layer);
    }
Esempio n. 3
0
    IEnumerator ScanRoutine(VoosActor actor)
    {
        float timeMod = 3;

        Quaternion arcBegin = Quaternion.Euler(0, -Mathf.PI / 2f, 0);
        Quaternion arcEnd   = Quaternion.Euler(0, Mathf.PI / 2f, 0);

        transform.localScale = Vector3.zero;

        float lerpVal = 0;

        while (lerpVal < 1)
        {
            lerpVal = Mathf.Clamp01(lerpVal + Time.unscaledDeltaTime * timeMod);
            Bounds  actorBounds   = actor.ComputeWorldRenderBounds();
            Vector3 actorCentroid = actorBounds.center;

            Quaternion rot = Quaternion.Lerp(arcBegin, arcEnd, lerpVal) * Quaternion.LookRotation(actorCentroid - transform.position);
            // transform.LookAt(actorCentroid);
            transform.rotation = rot;

            float dist = Vector3.Distance(transform.position, actorCentroid);
            transform.localScale = new Vector3(.2f, actorBounds.size.y, dist);
            yield return(null);
        }
        transform.localScale = Vector3.zero;
        OnScanComplete?.Invoke(actor);
    }
Esempio n. 4
0
    public void ExplicitUpdate()
    {
        if (targetActor == null)
        {
            gameObject.SetActive(false);
        }
        else
        {
            Bounds bounds = targetActor.ComputeWorldRenderBounds();

            Vector3 bottomCenter = bounds.center - Vector3.up * bounds.extents.y;
            Vector3 bottomDelta  = bottomCenter - targetActor.transform.position;

            Vector3 currentPosition = targetActor.transform.position + bottomDelta;

            if (currentPosition.y < .01f)
            {
                gameObject.SetActive(false);
            }
            else
            {
                gameObject.SetActive(true);
                Vector3 bottomPosition = currentPosition;
                bottomPosition.y = 0;

                mainBottomTransform.position = bottomPosition;
                topTransform.position        = currentPosition;
                connectingLine.SetPosition(0, bottomPosition);
                connectingLine.SetPosition(1, currentPosition);
            }
        }
    }
Esempio n. 5
0
    void UpdateFeedback(bool updateAll = false)
    {
        if (targetActor == null)
        {
            SetActor(null);
            return;
        }

        bool updateCurrentPosition = false;
        bool updateResetPosition   = false;

        if (currentPosition != targetActor.transform.position)
        {
            updateCurrentPosition = true;
        }

        if (resetPosition != targetActor.GetSpawnPosition())
        {
            updateResetPosition = true;
        }

        if (!updateAll && !updateResetPosition && !updateCurrentPosition)
        {
            return;
        }

        Bounds  bounds       = targetActor.ComputeWorldRenderBounds();
        Vector3 bottomCenter = bounds.center - Vector3.up * bounds.extents.y;
        Vector3 bottomDelta  = bottomCenter - targetActor.transform.position;

        if (updateCurrentPosition || updateAll)
        {
            currentPosition = targetActor.transform.position;
            Vector3 currentPositionWithBoundsOffset = currentPosition + bottomDelta;
            if (currentPositionWithBoundsOffset.y < .01f)
            {
                currentPositionWithBoundsOffset.y = .01f;
            }
            currentPositionTransform.position = currentPositionWithBoundsOffset;
        }

        if (updateResetPosition || updateAll)
        {
            resetPosition = targetActor.GetSpawnPosition();
            Vector3 resetPositionWithBoundsOffset = currentPosition + bottomDelta;
            if (resetPositionWithBoundsOffset.y < .01f)
            {
                resetPositionWithBoundsOffset.y = .01f;
            }
            resetPositionTransform.position = resetPositionWithBoundsOffset;
        }

        Vector3 circleDelta = (currentPositionTransform.position - resetPositionTransform.position).normalized * CIRCLE_RADIUS;

        connectingLine.SetPosition(0, currentPositionTransform.position - circleDelta);
        connectingLine.SetPosition(1, resetPositionTransform.position + circleDelta);
    }
Esempio n. 6
0
    public override void MoveCameraToActor(VoosActor actor)
    {
        // Vector3 groundCenter = navigationControls.GetGroundPoint(actor.GetPosition().y, true);
        // focusPoint = groundCenter;

        // Vector3 delta = actor.GetPosition() - groundCenter;
        // delta.y = actor.GetPosition().y + cameraVerticalOffset - mainTransform.position.y;
        // Vector3 desiredCameraPosition = mainTransform.position + delta;
        // mainTransform.position = desiredCameraPosition;

        Bounds  bounds       = actor.ComputeWorldRenderBounds();
        Vector3 closestPoint = bounds.ClosestPoint(navigationControls.userBody.transform.position);
        Vector3 closestPointPaddingVector = (closestPoint - bounds.center).normalized * FOCUS_ACTOR_PADDING_MAGNITUDE;

        focusPoint = closestPointPaddingVector + closestPoint;
        //   if (Vector3.SqrMagnitude(velocity) < .01f) velocity = Vector3.zero;

        // focusPoint = actor.GetPosition();
        //cursorVelocity = Vector3.zero;
        cursorControlledMovement = true;
    }