godotengine / godotengine/godot

set_custom_data for TileData with negative y-axis in TileMap does not work correctly

Open
#89,349 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation topic:2d
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

4.2.1.stable

### System information

Windows 10 - Godot 4.2.1.stable - Vulkan (Forward+)

### Issue description

When `TileData` is obtained from the `get_cell_tile_data` function of `TileMap`, `set_custom_data` does not work well if the Y axis of the obtained `TileData` is negative. After executing `set_custom_data`, `get_custom_data` for the same TileData will contain a different value.

```gdscript
for map_point in get_used_cells(0): # Prepare a TileMap that returns [(0, -1), (1, -1)]
var tile_data = get_cell_tile_data(0, map_point)
tile_data.set_custom_data("coordinate", map_point)

var tile_data2: TileData = get_cell_tile_data(0, Vector2i(0, -1))
var coordinate = tile_data2.get_custom_data("coordinate")
assert(coordinate == Vector2i(0, -1)) # (0, -1) is expected but an error occurs
```
Maybe `get_custom_data` is not working correctly.

### Steps to reproduce

It is reproduced by running the sample project.
https://github.com/inoutch/godot_issue_set_custom_data

### Minimal reproduction project (MRP)

https://github.com/inoutch/godot_issue_set_custom_data

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked minimal reproduction project and run the negative-y example. Trace TileMap.get_cell_tile_data together with TileData.set_custom_data and get_custom_data, comparing the stored value for the reported cells. Done means the reproduction preserves the expected Vector2i(0, -1) value after set_custom_data.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, godot
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.