Topic: Rotate Map with gyroscope

Hi

I'm trying to rotate the map with compass, without user control ON (Camera control), and rotate it around the user GPS location.

The examples only work with Camera control ON...

Is it possible?

Best regards

Re: Rotate Map with gyroscope

Hello.

Yes, of course it's possible.
If you are using Camera Control - OFF, you can control the camera as you want.

Kind Regards,
Infinity Code Team.

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

Re: Rotate Map with gyroscope

Can you make a example how to do it with the device gyroscope?

Re: Rotate Map with gyroscope

How to use a gyroscope:
http://infinity-code.com/atlas/online-m … gGyro.html
https://docs.unity3d.com/ScriptReference/Gyroscope.html

How to rotate the point (camera) around a point (center):
https://stackoverflow.com/a/13695630

The current rotation implementation can be found in OnlineMapsControlBase3D.UpdateCameraPosition.

Kind Regards,
Infinity Code Team.

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

Re: Rotate Map with gyroscope

Hi again

I've tried to follow your instructions, but im not able to make it... i think i'm confusing all.

Please can you make an example how to rotate map via gyro without user control? whith the camera fixed...

Thanks you

Re: Rotate Map with gyroscope

Something like that (in the general case):

using UnityEngine;

public class RotateMapUsingGyro:MonoBehaviour
{
    private OnlineMaps map;
    private Transform containerTransform;

    private void Start()
    {
        Input.gyro.enabled = true;
        map = OnlineMaps.instance;

        // Wrap the map in a new GameObject to rotate around the center.
        GameObject container = new GameObject("Map Container");
        containerTransform = container.transform;
        containerTransform.position = map.transform.position + new Vector3(map.tilesetSize.x / -2, 0, map.tilesetSize.y / 2);
        map.transform.parent = containerTransform;
    }

    private void Update()
    {
        Vector3 rate = Input.gyro.rotationRate;
        containerTransform.Rotate(rate);
    }
}
Kind Regards,
Infinity Code Team.

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

7 (edited by geral 2018-02-09 16:31:57)

Re: Rotate Map with gyroscope

Thanks, but the thing is i have a kind of a 3D showing map. I rotate the camera to fit a 3D perspective like shown in the image attached.

I can i use the gyro or the compass to rotate the camera and still maintain the 3D perspective?

Post's attachments

Attachment icon Capturar.PNG 135.39 kb, 66 downloads since 2018-02-09 

Re: Rotate Map with gyroscope

To do this, rotate the map only using the y-axis.

Actually you can do it using Allow Camera Control too.
Just set Camera Rotation Speed X - 0.

Kind Regards,
Infinity Code Team.

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

Re: Rotate Map with gyroscope

Alex Vertax wrote:

To do this, rotate the map only using the y-axis.

Actually you can do it using Allow Camera Control too.
Just set Camera Rotation Speed X - 0.


Thanks, that worked without using the gyroscope or the compass.

But I wanted to use maybe the compass to rotate. How can I do it with the compass then?

Re: Rotate Map with gyroscope

If you use Allow Camera Control, example:
http://infinity-code.com/atlas/online-m … ample.html

Otherwise just set

containerTransform.rotation = Quaternion.Euler (0, f, 0);

where f is the value from the example above.

Kind Regards,
Infinity Code Team.

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