I've been making a simple grid-based movement just for a little project and for some reason no matter how I use maptoworld or worldtomap it keeps giving me this error whenever I give any input. Here is my code:
##All extensions and imports that the script needs:
extends Sprite
onready var map = get_node("TileMap")
##All Exported Variables
export var TileSize = 16 ##This is the size of the tileset.
export var MoveAllowance = .25 ## this is the time that the player must wait before the next move is taken.
##All Internal Variables:
var timeDelay = 0
var mapGoal = Vector2(0,0)
var pos = Vector2(0,0) ##This will be where the player is.
var goalPos = Vector2(0,0) ## This is where the player wants to be.
##This will happen Only at the beginning of the game.
func _ready():
self.position = Vector2(8,0) ## this is an alignment thing. for some reason if it isn't started with (+8,+0) it doesn't line up.
##This will happen at every tick of the game.
func _process(delta):
pos = self.position
if timeDelay == 0:
if goalPos.x != 0 || goalPos.y != 0:
self.position = map.map_to_world(goalPos)
goalPos.x = 0
goalPos.y = 0
timeDelay = 1 ##this can be edited to determine how long the player must wait before moving.
else:
getInput()
timeDelay = 0
else:
timeDelay += -MoveAllowance*delta
##getInput Simply loads the next input into the _process function for processing.
func getInput():
if goalPos.x == 0:
if Input.is_action_pressed("ui_right"):
goalPos.x += 1
elif Input.is_action_pressed("ui_left"):
goalPos.x += -1
if goalPos.y == 0:
if Input.is_action_pressed("ui_up"):
goalPos.y += -1
elif Input.is_action_pressed("ui_down"):
Sorry about how messy it is, I just recently got back into coding. Any help would be appreciated