A RayCast2D doesn't only detect contact at the end of the line. It extends from a point a certain distance (
cast_to) and reports the first collision it detects along that line. This should work fine for your purposes.
Alternatively, give the spike an Area2D and use a LineShape2D as its shape. Then you can use the
body_entered() signal to notify you when the player touches the line.