Well first off get_collider()
doesn't take a parameter so that code is just wrong.
It is failing because at the time you are calling the get_collider()
function (if it even works with being called with "/root/Proto/Player"
as the parameter) the engine can't find a child node of the node that this script is attached to named Raycast2D2
so $Raycast2D2
returns null
and null
is just a fancy way of saying nothing. null
has no function named get_collider()
so it crashes.
That is absolutely awful code so I highly recommend following another tutorial. Check out the Youtube channels: GDQuest, KidsCanCode, Heartbeast, or Game Endeavor to learn how to properly create games in Godot.