diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-16 21:30:24 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-16 21:30:24 -0300 |
| commit | adb86dd1725276457c13e9a4d37372fda628dea3 (patch) | |
| tree | 1eca59920466de74cf66dc606464bd7b31674d59 | |
| parent | 5c265ada0d1ec531fa97ad132b87c99cb9e81b1a (diff) | |
Verificar se o tile é nulo.
Resolve o problema #2
| -rw-r--r-- | project.godot | 1 | ||||
| -rw-r--r-- | scripts/Actor.cs | 6 |
2 files changed, 5 insertions, 2 deletions
diff --git a/project.godot b/project.godot index 0e7d507..52042ee 100644 --- a/project.godot +++ b/project.godot @@ -11,6 +11,7 @@ config_version=5 [application] config/name="projeto-fantasia" +config/tags=PackedStringArray("based") run/main_scene="uid://u5h6iqyi8wd0" config/features=PackedStringArray("4.4", "C#", "Forward Plus") config/icon="res://icon.svg" diff --git a/scripts/Actor.cs b/scripts/Actor.cs index e3c74a4..d196940 100644 --- a/scripts/Actor.cs +++ b/scripts/Actor.cs @@ -18,8 +18,10 @@ public abstract partial class Actor : Node2D { TileData tile = Map.GetCellTileData(toMovePos); - if (tile.HasCustomData("isWalkable") && (bool) tile.GetCustomData("isWalkable")) { - Position = Map.MapToLocal(toMovePos); + if (tile != null) { + if ((bool) tile.GetCustomData("isWalkable")) { + Position = Map.MapToLocal(toMovePos); + } } Energy -= baseWalkCost; |
