How can I identify what node has an Object ID: xxxx given in an error message

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Godene

I am doing a 2D tutorial involving a player, enemies, coins and tilemaps etc.

I am having a problem where an enemy seems to be having a problem with a tile. Error says Invalid call. Nonexistent function ‘ouch’ in base ‘TileMap’. I am not sure why this would occur. Everyone was getting ok until some change occurred.

I have had to replace one way tiles with solid tiles so that the enemy would go there now.
a ‘body’ Object ID 1356 is apparently a solid Tilemap according to the node path. The other, Object 1410, is an enemy. The error looks at line 47 at function: _on_sides_checker_body_entered. The enemy also has a floor and cliff checkers, which maybe where the problem arises? Here is the code in the enemy node…
extends KinematicBody2D

var speed = 50
var velocity = Vector2()
export var direction = -1
export var detect_cliffs = true

func _ready():
if direction == 1:
$AnimatedSprite.flip_h = true
$floor_checker.position.x = $CollisionShape2D.shape.get_extents().x * direction
$floor_checker.enabled = detect_cliffs
if detect_cliffs:
set_modulate(Color(1.2,0.5,1))

func _physics_process(delta):

if is_on_wall() or not $floor_checker.is_colliding() and detect_cliffs and is_on_floor():
	direction = direction * -1
	$AnimatedSprite.flip_h = not $AnimatedSprite.flip_h
	$floor_checker.position.x = $CollisionShape2D.shape.get_extents().x * direction	
	#helps raycast detect cliffs from side in direction going

velocity.y += 20

velocity.x = speed * direction

velocity = move_and_slide(velocity, Vector2.UP)

func _on_top_checker_body_entered(body):
$AnimatedSprite.play(“squashed”)
speed = 0
set_collision_layer_bit(4,false)
set_collision_mask_bit(0,false)
$top_checker.set_collision_layer_bit(4,false)
$top_checker.set_collision_mask_bit(0,false)
$sides_checker.set_collision_layer_bit(4,false)
$sides_checker.set_collision_mask_bit(0,false)
$Timer.start()
body.bounce()
$SoundSquash.play()

func _on_sides_checker_body_entered(body):
print(“ouch!”)
body.ouch(position.x) #tells steve.gd info for jumping

func _on_Timer_timeout():
queue_free()

:bust_in_silhouette: Reply From: njamster

The error tells you, that you’re calling a method called ouch on a node that’s based on a TileMap and doesn’t have that function. So you need to either:

  • add a function with that name to your TileMap-script
  • or stop calling that function on the TileMap-node

When you post a question, please make sure that your code is formatted properly (each line has to start with 4 spaces, each additional 4 spaces equal an indentation layer). If you don’t, underscores are interpreted as markdown and indentation is lost, which makes your script a lot harder to read for others trying to help you.