What do you mean with 'de-spawning'?
The easiest way is to create the object outside the viewport and move it into it.
For example:
System| Every x seconds -> System | create object Sprite on layer 0 at (-sprite.width-1, y)
This will spawn an object on the left. -Sprite.width-1 pixel outside of the left border.
If your sprite has the width of 32 it will be created at x=-33, y.
Now you have to move it:
System| every tick -> Sprite| Move forward -1 pixel.
If you want to spawn it at the right side:
System| Every x seconds -> System | create object Sprite on layer 0 at (OriginalWindowWidth+Sprite.width+1, y)
System| every tick -> Sprite| Move forward 1 pixel.
OriginalWindowWidth is the Windows width in the project settings.
This will work as long as the screen doesn't scroll, then you have to use viewportleft and right
Thanks for the response!
With the code I tried in the picture in my OP the object spawns randomly on the viewport but than just vanishes, I am trying to have it so that multiple objects randomly fly in from outside the viewport onto the viewport and do not de-spawn upon landing in the viewport.
I understand how to have a sprite randomly appear in different places inside the viewport, what I do not understand is how to have a random object fly in from outside the viewport and land inside the viewport and stay there, I am also trying to do this for all directions, left, right, bottom & top.
I.E I do not want the object to just magically appear inside the viewport lol.