Topic: 2D marker rotation
Hi Alex, I´m trying to use CameraOrbit with 2D markers but when I turn 180 degrees the markers keep upsidedown. Any way to make the 2D markers rotate the opposite way like User Locations does?
Thank you very much!
You are not logged in. Please login or register.
Infinity Code Forum → Online Maps Help → 2D marker rotation
Hi Alex, I´m trying to use CameraOrbit with 2D markers but when I turn 180 degrees the markers keep upsidedown. Any way to make the 2D markers rotate the opposite way like User Locations does?
Thank you very much!
Hello.
Example:
using UnityEngine;
public class RotateMarkersByCamera : MonoBehaviour
{
private OnlineMapsCameraOrbit cameraOrbit;
private void Start()
{
cameraOrbit = OnlineMapsCameraOrbit.instance;
cameraOrbit.OnCameraControl += OnCameraControl;
}
private void OnCameraControl()
{
foreach (OnlineMapsMarker m in OnlineMapsMarkerManager.instance)
{
m.rotation = cameraOrbit.rotation.y / 360;
}
OnlineMaps.instance.Redraw();
}
}
Thank you very much. The code above works by rotating the 2Dmarks, but the markers also don´t stop spinning when I move the device around and deaccelerate to spinning up to the position, like a helicopter. I tried to change the code below to control the 2DMarker Lerp but when I drag the map only the 2Dmarkers (including the Player) move but the map is still frozen.
public class RotateMarkersByCamera : MonoBehaviour
{
private OnlineMapsCameraOrbit cameraOrbit;
private OnlineMapsMarkerManager marker;
private void Start()
{
cameraOrbit = OnlineMapsCameraOrbit.instance;
marker = OnlineMapsMarkerManager.instance;
cameraOrbit.OnCameraControl += OnCameraControl;
}
private void OnCameraControl()
{
foreach (OnlineMapsMarker m in OnlineMapsMarkerManager.instance)
{
float markerRotation = m.rotation.y;
var markerRotationY = Mathf.Lerp(markerRotation, cameraOrbit.rotation.y, cameraOrbit.speed.y);
m.rotation = markerRotationY;
}
OnlineMaps.instance.Redraw();
}
Attached is a video of the spinning markers before my changes.
Thanks again.
Oops... I forgot that marker.rotation takes values from 0 to 1 and cameraOrbit.rotation.y gives values 0-360.
Updated the script in post 2.
Perfect!! it´s running like a charm now! The 2Dmarkers are keeping the orientation while moving the device. Thanks for the help.
Infinity Code Forum → Online Maps Help → 2D marker rotation
Powered by PunBB, supported by Informer Technologies, Inc.