0 votes

How can I get the tile name when colliding with it?
This is the name of my tile:

enter image description here
This is the code which is inside a KinematicBody2D:

func _on_Collision_interacitons_body_entered(body):

    var type = body.tile_get_name()

    print(type)

But when I try to run the game I get the following error:
enter image description here

Godot version 3.2.3.stable.official
in Engine by (77 points)

1 Answer

–1 vote

you are trying to get a a tile name from a kinematic body (unless you checked "kinematic" in the tilemap inspector

try this to get names:

func _on_Collision_interacitons_body_entered(body):
     print(body.name)

but tilemaps are not bodies unless specified in the inspector (collisionusekinematic)

by (362 points)
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 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 webmaster@godotengine.org with your username.