So, I'm kind of new to coding in general, and I'm trying to make a game of Pong, but like a super customizable fancy version, (I've made just a basic version based off of ClearCodes tutorial already.) Anyway, one of the settings I'm trying to implement is to have the ball delete itself if it hits either a player, a wall or another ball. For this I've created a function, "check_player(collider)" that is called whenever the setting is enabled and the ball collides with something.
My plan was that I would call this variable with the collider as an argument and it'd check for the first child of each collider, which would be the PaddleCol for any of my player controller scenes, or Ball_Collision for my balls, and if the collider had neither, it was obviously a wall; returning 1, 2, & 0, respectively.
func check_player(collider):
var child = collider.get_child(0)
if child == "PaddleCol":
return(1)
elif child == "Ball_Collision":
return(2)
else: return(0)
Unfortunately, this just crashes the game and returns the error: "Invalid operands 'Object' and 'String' in operator '=='." Does anybody know a better way of doing this?