Characters move jerkily on large maps.
I tested using the Overworld Map from the Sample Map, which has a tile size of 140x100, and set scroll type to loop both
When running the test, I noticed that The character's movement stutters significantly.
Even in the build version, this issue still persists.
How can I fix this issue if I want to use a large overworld map and enable looping both vertically and horizontally, similar to the overworld maps in most RPG games?
-
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.
- Save the map as an image
- Delete all the tiles
- On the background layer, use the saved image as the background (don't forget to set collisions)
- 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.
- Open ProjectFolder/Assets/RPGMaker/Codebase/Runtime/Map/Component/Character/CharacterOnMap.cs in a script editor
- 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();
}
} - 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();
}
} - Save it, go back to Unite, let it refresh, and playtest
- The normal walking jitter should be gone!
Hopefully these workarounds can help while they tackle the performance issues of massive tiled maps.
0 -
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
请先登录再写评论。
评论
2 条评论