Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | li_fran |
Hi! I’m having problems when trying to use Raycast2D inside a Node2D. If I put the Raycast2D directly as a child of my KinematicBody2D do this:
func _print_raycast_check():
if raycastCheck.is_colliding():
print("Is colliding")
, it works fine. But if I put the Raycast2d inside a Node2D as in KinematicBody2D => Node2d => Raycast2D, and do:
func _print_raycast_check():
for raycast in Node2d.get_children():
if raycastCheck.is_colliding():
print("Is colliding")
, then it doesn’t work anymore. Also, while using this code sometimes I get an error message saying nonexistent function ‘get_children’ in base ‘Node2D’, but not consitently.
Am I missing something here?
Thanks in advance!
I’m curious as to why you’re calling your collision check for the raycast inside of a loop. Do you have multiple raycasts that you want to perform checks on?
l.riehl | 2020-07-05 15:57