This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

The following code gives the following error and I'm not sure why or what its implying. I'm using a square so think that there should only be eight neighbours but when I loop over just 8 I only get 4 neighbours returned.


E 0:00:01:0740 @ input(): Method/function failed. Returning: pcoords
<C++ Source> scene/2d/tilemap.cpp:3490 @ getneighbor_cell() @ _input()

extends Node2D

var tilemap

func _ready():
tilemap = $TileMap

func input(event):
var mouseposition = get
var tile = tilemap.localtomap(mouseposition)
var checkCell = tilemap.getusedcells(0)
if !checkCell.has(tile):
var neighbors = []
for i in 16:
var getNeigbor = tilemap.getneighborcell(tile, i )
for i in 16:
tilemap.setcell(0, neighbors[i], 0, Vector2i(0,0))
cell(0, tile, 1, Vector2i(0,0))
print("Tile already here")

Godot version 4.0 latest stable
in Engine by (31 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.