invalid set index 'cast_to' (on base: 'RayCast2D') with value of type 'int'

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Anastasia
func _ready():
	state_machine = $Node2D/AnimationTree.get("parameters/playback")
	emit_signal("player_stats_changed", self)
	if facing == true:
		$RayCast2D.cast_to = -150
	else:
		$RayCast2D.cast_to = 150

Please help! Why do i get this error? What does it mean?

:bust_in_silhouette: Reply From: Ertain

The cast_to property takes a Vector2 object. You’re trying to assign an int to it. So maybe the value should be Vector2(0, -150) or Vector2(0, 150)?

Thanks! But for some reason the raycast won’t turn around?

Anastasia | 2020-02-23 18:32

If you need to turn it around, have you tried the rotation() function? E.g. $Raycast2D.rotation(theta), where theta is the desired amount of rotation in radians.

Ertain | 2020-02-24 00:25