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
You are not logged in. Please login or register.
Infinity Code Forum → Online Maps Help → 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
Hello.
Yes, of course it's possible.
If you are using Camera Control - OFF, you can control the camera as you want.
Can you make a example how to do it with the device 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.
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
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);
}
}
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?
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.
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?
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.
Infinity Code Forum → Online Maps Help → Rotate Map with gyroscope
Powered by PunBB, supported by Informer Technologies, Inc.