1 (edited by LazzLab 2022-10-07 09:56:41)

Topic: Orbit rotation camera.

Hi Alex.
An orbital rotation of the chamber is possible with speed and direction to infinity?
I tried with OnlineMapsCameraOrbit.instance cameraOrbit.rotation.y = float * Time.deltaTime but it doesn't work.
Any suggestions? Cheers

Re: Orbit rotation camera.

Hello.

Unfortunately, I didn't understand your question.
Please rephrase it.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Orbit rotation camera.

I am working on this:

public float animationTime = 3;   
    public AnimationCurve animationCurve = AnimationCurve.EaseInOut(0, 0, 1, 1);
    private float time;
    private bool isReset;   
    private float camY;
    private OnlineMapsCameraOrbit cameraOrbit;

    public void ButtonInteract()
    {       
        camY = cameraOrbit.rotation.y;
        isReset = true;       
    }

    private void Start()
    {
        cameraOrbit = OnlineMapsCameraOrbit.instance;
    }

    private void Update()
    {
        if (!isReset) return;       
        time += Time.deltaTime;
        float t = time / animationTime;       
        if (t >= 1)
        {
            // Reset values
            time = 0;
            isReset = false;
            t = 1;
        }       

        float f = animationCurve.Evaluate(t);       
        cameraOrbit.rotation.y = Mathf.Lerp(camY, -360 * 2, f);     
    }

The problem is that in this way I can only do 2 laps and I don't understand the behavior. I would like to spin the Chamber around its map center.

Re: Orbit rotation camera.

You wrote this code based on ResetCameraRotationExample, right?!
Try replacing:

cameraOrbit.rotation.y = Mathf.Lerp(camY, -360 * 2, f);     

to

cameraOrbit.rotation.y = Mathf.LerpAngle(camY, 0, f);
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Orbit rotation camera.

With LearpAngle the camera will always stop at zero (North). It has to keep turning and always in a direction that I choose. As you suggest, if I start from the west it goes north clockwise and stops. If I start from the east it goes north counterclockwise and stops. I want to choose which direction to turn and stop it when I want. The "narrator" will read a text (story = time) while the camera orbits around a marker and at the end of the (story = time) the animation of the orbiting camera stops.

Re: Orbit rotation camera.

Ahhh, I get it.
In this case, everything is much easier:

using UnityEngine;

namespace InfinityCode.OnlineMapsSupport
{
    public class RotateMap : MonoBehaviour
    {
        public OnlineMapsCameraOrbit cameraOrbit;
        public float duration = 3;
        private int direction;

        private void OnGUI()
        {
            if (GUILayout.Button("Left")) direction = 1;
            if (GUILayout.Button("Right")) direction = -1;
            if (GUILayout.Button("Stop")) direction = 0;
        }

        private void Update()
        {
            if (direction == 0) return;

            cameraOrbit.rotation.y += 360 * Time.deltaTime / duration * direction;
        }
    }
}
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Orbit rotation camera.

Exactly ! Perfect ! Thanks Alex! Thank you