Topic: Marker Position Changes chaotically after zooming map out
Hi, I have a problem I don't know how to fix, i will describe it and hope there is a way to fix it. In the code I create player
playerMarker = OnlineMapsTileSetControl.instance.AddMarker3D(position, playerPrefab);
and I use player camera as the main one. Then at some point I switch to the map view disabling player camera and enabling map camera
void ActivateMapCamera ()
{
playerCamera.depth = 0;
playerCamera.enabled = false;
playerCamera.gameObject.SetActive (false);
initialZoom = OnlineMaps.instance.zoom;
mapCamera.gameObject.SetActive (true);
mapCamera.enabled = true;
mapCamera.depth = 1;
}
then in script on the mapCamera I have this update function:
void Update ()
{
if (mapControlDisabled)
{
if (Input.touchCount == 2)
{
OnlineMapsTileSetControl tileSetControl = OnlineMapsTileSetControl.instance;
tileSetControl.allowUserControl = false;
Zoom ();
}
if (Input.touchCount < 2)
{
OnlineMapsTileSetControl tileSetControl = OnlineMapsTileSetControl.instance;
tileSetControl.allowUserControl = true;
}
}
}
where Zoom() is function which changes mapCamera.orthographicSize. And it contains if-statement which checks if we have zoomed out enough
void Zoom ()
{
...
if (mapCamera.orthographicSize == maxOS)
{
OnlineMapsTileSetControl tileSetControl = OnlineMapsTileSetControl.instance;
tileSetControl.allowUserControl = true;
tileSetControl.allowZoom = true;
mapControlDisabled = false;
}
// Change player size to increase visibility on the map
playerMarker.scale = LerpPlayerScale();
}
and thats when problem starts : player postion starts rapidly changing (swapping between two positions: actual one and the wrong one) and further map is zoomed out further apart these positions are. Interesting moment that if I remove (comment) whole if-statement then no problems arise, but I need the functionality to change map zoom in comfortable for the user way. I hope I can find help here.
P.S. It is code that was written on the 2.5 version of the Online Maps, but I has updated it to the newest version atm which is 3.5 hoping it would fix the problem but no it didn't.