- Edited
I am trying to follow along with a maze tutorial for my game design class and I got this error and have no idea on how to fix it. The error : Invalid operands 'Vector2' and 'int' in operator '+'.
Here is the code I have and I think it is saying the error is on line 27.
extends Area2D
export (int) var speed
var tile_size = 64
var can_move = true
var facing = 'right'
var moves = {'right': Vector2(1, 0),
'left': Vector2(-1, 0),
'up': Vector2(0, -1),
'down': Vector2(0, 1)}
onready var raycasts = {'right': $RayCastRight,
'left': $RayCastLeft,
'up': $RayCastUp,
'down': $RayCastDown}
func move(dir):
$AnimationPlayer.playback_speed = speed
facing = dir
if raycasts[facing].is_colliding():
return
can_move = false
$AnimationPlayer.play(facing)
$MoveTween.interpolate_property(self, "position", position,
position + moves[facing] + tile_size,
1.0 / speed, Tween.TRANS_SINE, Tween.EASE_IN_OUT)
$MoveTween.start()
return true
func _on_MoveTween_tween_completed(object, key):
can_move = true
It's also saying there is an issue with line 12 of this script:
extends "res://character/Character.gd"
signal moved
signal dead
signal grabbed_key
signal win
func _process(delta):
if can_move:
for dir in moves.keys():
if Input.is_action_pressed(dir):
if move(dir):
emit_signal('moved')
func _on_Player_area_entered(area):
if area.is_in_group('enemies'):
emit_signal('dead')
if area.has_method('pickup'):
area.pickup()
if area.type == 'key_red':
emit_signal('grabbed_key')
if area.type == 'fly':
emit_signal('win')
Any help is appreciated I am a total noob