There are a lot of ways to detect collision. I have never seen this method.
All I can say is get rid of this method and try this one.
- Put a area2d node inside your rigid body. Like so
---Collision2d (This is if you don't want the object to go through objects)
- Now select your Area2D, and go to your Node tab in the editor(It's a tab in the same place as the inspector)
3.You should have signals loaded up. Under Area2D signals there is body_enter( Object area )
Double Click on it.
4.You will get a pop up window, with "please confirm..." select your RigidBody2D
Then at the bottom of the pop up window press connect.
5.Now you should have a
body_enter( Object area ) inside your RigidBody2D script.
This is where you can preform your collision functions.
Also for future reference you can have a
body_exit( Object area ) in case you want a function to continue until you leave a object's collision.