Invalid call. Nonexistent function "is_colliding" in base "GDScriptNativeClass"

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

So, I recently started using Godot and I decided that I want to start my game developer jouney from making turn based RPGs. I decided to start with making grid based movement following this tutorial: (
In the end, my code is basically exactly the same as in the video(in the video, the code is completed at 15:56), but for some reason “Invalid call. Nonexistent function “is_colliding” in base “GDScriptNativeClass”” pops out when I try to lunch the game. I have a feeling the problem might be in a typo, but either I can’t see it, or the problem is in something else.
What’s wrong?

Here is my code

extends Sprite

var speed = 200
var tile_size = 20

var last_pos = Vector2()
var target_pos = Vector2()
var movedir= Vector2()

onready var ray = RayCast2D

func _ready():
	position = position.snapped(Vector2(tile_size, tile_size))
	last_pos = position
	target_pos = position
func _process(delta):
	if ray.is_colliding():
		position = last_pos
		target_pos = last_pos
		position += speed * movedir * delta
		if position.distance_to(last_pos) >= tile_size - speed * delta:
			position = target_pos

	if position  == target_pos:
		last_pos = position
		target_pos += movedir * tile_size

func get_movedir():
	var L = Input.is_action_pressed("ui_left")
	var R = Input.is_action_pressed("ui_right")
	var U = Input.is_action_pressed("ui_up")
	var D = Input.is_action_pressed("ui_down")
	movedir.x = -int(L) + int(R)
	movedir.y = -int(U) + int(D)
	if movedir.x != 0 && movedir.y != 0:
		movedir = Vector2.ZERO
	if movedir != Vector2.ZERO:
		ray.cast_to = movedir * tile_size / 2

From the error, it looks like the variable ray is of the type GDScriptNativeClass. Though how it gets assigned that is beyond me.

Ertain | 2020-06-19 13:34

:bust_in_silhouette: Reply From: jgodfrey

The immediate problem is that this:

onready var ray = RayCast2D

should instead be this:

onready var ray = $RayCast2D

Note the addition of the $ sign…