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.

Regards

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

extends Node2D

var tilemap

func _ready():
tilemap = $TileMap

func input(event):
if event.is
actionpressed("PlaceTile"):
var mouseposition = get
globalmouseposition()
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 )
neighbors.append(getNeigbor)
for i in 16:
tilemap.setcell(0, neighbors[i], 0, Vector2i(0,0))
tilemap.set
cell(0, tile, 1, Vector2i(0,0))
else:
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.