invalid call. nonexistent function 'cast_to' in base 'RayCast'?

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

I was just finishing work for today and for some reason this appeared to me, i really don’t know why, here’s the code:

onready var sensorFrontRight = get_node("RayCasts/RayCastFrontRight")

	if sensorFrontRight.cast_to(0, 0, sensorFrontLength) && reversing != true:
		if sensorFrontRight.is_colliding():
			avoiding = true
			avoidMultiplier -= 1.0

the node is a RayCast and on the documentation it’s says i can use the method cast_to but at the same time it isn’t working, what am i missing here?

:bust_in_silhouette: Reply From: klaas

Hi,
cast_to is a property not a method … so

sensorFrontRight.cast_to = Vector3(0, 0, sensorFrontLength)

and you have to call force_raycast_update( ) for immediate response

sensorFrontRight.cast_to = Vector3(0, 0, sensorFrontLength)
sensorFrontRight.force_raycast_update( ) 

oh, that makes sense, thanks!

StrikerSVX | 2020-07-20 20:43