I am trying to get the local coordinates of a specific cell by inputting TileMap
coordinates. So basically using MapToLocal()
with some Vector2I
as an argument. Here is what my code looks like:
TileMapManager.Instance.MapToLocal(BoardPositions.Positions[1,1].BoardPosition);
This line of code is currently in a different class, but the TileMapManager
uses a singleton to which I am calling the method from. But moving this line of code to the TileMapManager
class has not changed the outcome. Receiving the following error:
E 0:00:00:0831 Godot.NativeInterop.NativeFuncs.generated.cs:345 @ void Godot.NativeInterop.NativeFuncs.godotsharp_method_bind_ptrcall(IntPtr , IntPtr , System.Void** , System.Void* ): Condition "!tile_set.is_valid()" is true. Returning: Vector2()
<C++ Source> scene/2d/tile_map.cpp:3227 @ map_to_local()
<Stack Trace> Godot.NativeInterop.NativeFuncs.generated.cs:345 @ void Godot.NativeInterop.NativeFuncs.godotsharp_method_bind_ptrcall(IntPtr , IntPtr , System.Void** , System.Void* )
NativeCalls.cs:371 @ Godot.Vector2 Godot.NativeCalls.godot_icall_1_42(IntPtr , IntPtr , Godot.Vector2I* )
TileMap.cs:701 @ Godot.Vector2 Godot.TileMap.MapToLocal(Godot.Vector2I )
TileMapManager.cs:53 @ void TileMapManager._Ready()
Node.cs:2093 @ Boolean Godot.Node.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Godot.NativeInterop.godot_variant& )
CanvasItem.cs:1374 @ Boolean Godot.CanvasItem.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Godot.NativeInterop.godot_variant& )
Node2D.cs:516 @ Boolean Godot.Node2D.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Godot.NativeInterop.godot_variant& )
TileMap.cs:764 @ Boolean Godot.TileMap.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Godot.NativeInterop.godot_variant& )
TileMapManager_ScriptMethods.generated.cs:31 @ Boolean TileMapManager.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Godot.NativeInterop.godot_variant& )
CSharpInstanceBridge.cs:24 @ Godot.NativeInterop.godot_bool Godot.Bridge.CSharpInstanceBridge.Call(IntPtr , Godot.NativeInterop.godot_string_name* , Godot.NativeInterop.godot_variant** , Int32 , Godot.NativeInterop.godot_variant_call_error* , Godot.NativeInterop.godot_variant* )
I know for sure that I have a tile set in the Tilemap, I do have a tile used up in the map coords [1,1], I even set it both in the inspector and the class code. I can see the results when the game runs, so I should have a cell there. But I don’t understand why I am receiving this error. Any ideas?