![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | N00b |
Hi, ive been trying to do the first project from DOCS, I got the project to a playeable state, game launches and run perfect but cant interacts with the mobs.
this is the error i get from the debugger :
E 0:00:09:0772 Error calling method from signal ‘body_entered’: ‘Area2D(Player.gd)::_on_Player_body_entered’: Method not found.
core/object.cpp:1238 @ emit_signal()
and this is my code:
extends Area2D
signal hit
export var speed = 400
var screen_size
func _ready():
screen_size = get_viewport_rect().size
hide()
func _process(delta):
var velocity = Vector2() #Moving the Player
if Input.is_action_pressed("ui_up"):
velocity.y -= 1
if Input.is_action_pressed("ui_down"):
velocity.y += 1
if Input.is_action_pressed("ui_left"):
velocity.x -= 1
if Input.is_action_pressed("ui_right"):
velocity.x += 1
if velocity.length() > 0:
velocity = velocity.normalized() * speed
$AnimatedSprite.play()
else:
$AnimatedSprite.stop()
position += velocity * delta #limit the player movement to the screen
position.x = clamp(position.x, 0, screen_size.x)
position.y = clamp(position.y, 0, screen_size.y)
if velocity.x != 0:
$AnimatedSprite.animation = "Right"
$AnimatedSprite.flip_v = false
$AnimatedSprite.flip_h = velocity.x < 0
elif velocity.y != 0:
$AnimatedSprite.animation = "Up"
$AnimatedSprite.flip_v = velocity.y > 0
func on_player_body_entered(Rigidbody2D):
hide()
emit_signal("hit")
$CollisionShape2D.set_deferred("Disabled", true)
func start(pos):
position = pos
show()
$CollisionShape2D.disabled = false
I tryed to disconnect all signals and reconecting them again. but didnt find the mistake.
if you need any other code from other scenes, can pass them too.
THANK YOU!
Remember: everything here is case-sensitive.
System_Error | 2019-11-15 04:38