SpriteKit Game - How to detect end of platform before falling off it?

I am trying to develop a platformer using Swift/Spritekit/Scene Editor and am struggling a bit with one element of my game. So in the game I have some platforms raised off the ground and want the enemy to be moving left/right changing direction when reaching the end of the platform.

What is the easiest way to determine if my sprite which is running an SKACTION for movement is reaching the end? I could of course put a small object at the end of each platform and use collision detection but I want the platform completely flat.

I have searched all over the place and as yet have not come across anything that addresses this question.

Any help or advice would be very much appreciated.

Couldn’t you use an invisible object that still gives you a collision detection notification that you use only for avoiding the edge of the platform?

I did wonder that myself as to whether that might be an option however I do need to be able to have my player still walk through it and also if I make it invisible/hidden doesn’t that mean that it doesn’t exist in the physics world?

I have used the suggestion to use an invisible object to detect collisions and it does work

In the scene editor I add a simple object and give it a name. Then in code check through the scene and for those objects make the alpha equal 0.

The physics engine still detected collisions even tho the object is invisible.

So befny, did you work around the problem of the object registering collision with the player (or maybe it didn’t matter in your case)?

One solution would be to give the invisible objects the same collisionBitMask as the player object, then no collision will be registered.

Yes I used contact test bit mask to register the contact but not collision bit mask so the objects did not physically collide.