The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

This is my code:

extends Node2D

func _process(delta):
    #NodeD2 = center of the viewport.

    if Input.is_action_just_pressed("ui_accept"):
        if $NodeD2.scale.y == 1:
            $NodeD2.scale.y = -1
            $NodeD2.scale.y = 1
    if Input.is_action_just_pressed("ui_cancel"):
        if $NodeD2.scale.x == 1:
            $NodeD2.scale.x = -1
            $NodeD2.scale.x = 1

    var cell = $NodeD2/TileMap.world_to_map($Player.get_position())
    var tile_id = $NodeD2/TileMap.get_cellv(cell)
in Engine by (122 points)

1 Answer

0 votes
Best answer

it is equal to INVALID_CELL and means that cell on that tilemap is empty

if you think it should not be empty:
try print(cell)to ensure it is reasonable or passing in a cell that you know is not empty?

print($NodeD2/TileMap.get_cellv(Vector(12, 12)))
by (1,975 points)
selected by

i.e (2, 24)
The tiles which the player can stuck when flipped only vertically:
(-1, 11), (15, 10) and (23, 11)
Yeah, definitely there's a problem with the coordinates. Thanks!

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.