跳到主内容

搜索

Characters move jerkily on large maps.

评论

2 条评论

  • Baz コミュニティモデレーター

    Running both does produce lag on such a large level. The performance decrease is coming mainly from the amount of tiles being placed on such a large map.

    There is a trick you can do that increases the performance.

    1. Save the map as an image
    2. Delete all the tiles
    3. On the background layer, use the saved image as the background (don't forget to set collisions)
    4. Playtest and the lag should be gone

    Additionally you can get rid of the normal walking jitter by changing out some code in the CharacterOnMap.cs script.

    1. Open ProjectFolder/Assets/RPGMaker/Codebase/Runtime/Map/Component/Character/CharacterOnMap.cs in a script editor
    2. Go to line 619 where it has this function:
              protected virtual void MoveToPositionOnTileByFrame(Vector2 destinationPositionOnWorld, Action callBack) {
                  Vector2 currentPos = gameObject.transform.position;
                  if (currentPos != destinationPositionOnWorld)
                  {
                      //メニュー開き中は進まないようにしておく
                      if (MenuManager.IsMenuActive) return;

                      var newPos = Vector2.MoveTowards(
                          currentPos,
                          destinationPositionOnWorld,
                          Time.deltaTime * (_isRide ? _moveSpeedVehicle : _moveSpeed) * (_canDash && _isDash && !_isRide ? DashMoveSpeedMultiplier : 1.0f));

                      SetGameObjectPositionWithRenderingOrder(newPos);
                  }
                  else
                  {
                      callBack();
                  }
            }
    3. Replace the function with this code:
              protected virtual void MoveToPositionOnTileByFrame(Vector2 destinationPositionOnWorld, Action callBack)
              {
                  Vector2 currentPos = gameObject.transform.position;
                  if (MenuManager.IsMenuActive) return;

                  // Calculate the current movement speed
                  float currentSpeed = (_isRide ? _moveSpeedVehicle : _moveSpeed) *
                      (_canDash && _isDash && !_isRide ? DashMoveSpeedMultiplier : 1.0f);

                  var newPos = Vector2.MoveTowards(
                      currentPos,
                      destinationPositionOnWorld,
                      Time.deltaTime * currentSpeed);

                  SetGameObjectPositionWithRenderingOrder(newPos);

                  // Check if we've reached the destination
                  if (Vector2.Distance(newPos, destinationPositionOnWorld) < 0.01f)
                  {
                      SetGameObjectPositionWithRenderingOrder(destinationPositionOnWorld);
                      callBack();
                  }
            }
    4. Save it, go back to Unite, let it refresh, and playtest
    5. The normal walking jitter should be gone!

    Hopefully these workarounds can help while they tackle the performance issues of massive tiled maps.

    0
  • soony

    Thank you! I tested the code fix you suggested, but the issue with movement and stopping between tiles still persists.

    I also tried converting the tile map into a background image, which fixed the issue, but the tile animations disappeared. Additionally, when moving to the edge of the map, the area beyond it appears empty.

    It seems that the current system may not support the loop for backgrounds properly.

    0

请先登录再写评论。