Topic: RealTileSetExample & FollowGame with rotation of map

Hi,
I use the scripts "FollowGameObject" and "RealTilesetSizeExample". They work well together.
However, by default the map's north points to -z. For my use case I want to point the map's north to +z axis. So I added a 180 deg rotation around y. If I do this, the map won't follow the game objects properly any more but with an offset. I assume this is due the rotation pivot point of the map.

Is there another way of telling the map which axis should be used as north? Or is there a way to make the FollowGameObject work, even if the map is rotated?

Thank you

Re: RealTileSetExample & FollowGame with rotation of map

Hi.

To fix the problem, replace FollowGameObject.UpdateMap to:

private void UpdateMap()
{
    // Store last position of GameObject
    lastPosition = target.transform.position;

    // Size of map in scene
    Vector2 size = control.sizeInScene;

    // Calculate offset (in tile position)
    Quaternion rotation = map.transform.rotation;
    Vector3 offset = rotation * (lastPosition - map.transform.position + control.center);
    float offsetScale = map.zoomFactor / OnlineMapsUtils.tileSize;
    offset.x = offset.x * offsetScale / size.x * map.width;
    offset.z = offset.z * offsetScale / size.y * map.height;

    // Calculate current tile position of the center of the map
    tx -= offset.x;
    ty += offset.z;

    // Set position of the map center
    if (Mathf.Abs(offset.x) > float.Epsilon || Mathf.Abs(offset.z) > float.Epsilon) map.SetTilePosition(tx, ty);

    // Update map GameObject position
    map.transform.position = lastPosition - rotation * control.center;
}
Kind Regards,
Infinity Code Team.

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

Re: RealTileSetExample & FollowGame with rotation of map

Thank you, Alex. That did the trick.

4 (edited by munich_dev Yesterday 09:51:04)

Re: RealTileSetExample & FollowGame with rotation of map

Is there a way to change the size of the tile that is shown? I assume the size is calculated by this code:

             Vector2 distance = OnlineMapsUtils.DistanceBetweenPoints(control.map.topLeftPosition,
                control.map.bottomRightPosition);

            // Set tileset size
            control.sizeInScene = distance * 1000;


But I do not know where the topLeft/bottomRight Positions are coming from. I want to increase the clipping of the map.

Alternativly: Is there a way to have multiple "cutouts" of the map? So, cutouts following multiple game objects?

Re: RealTileSetExample & FollowGame with rotation of map

topLeft/bottomRight come from the current map view, and are calculated based on the center point and map resolution.

You cannot increase the clipping of the map.
But you can manipulate the map zoom and the distance multiplier.

You can have multiple “cutouts” in only one way - you have multiple maps, each following a different GameObject.

Kind Regards,
Infinity Code Team.

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