Enemy boundaries problem

Hi everyone, I’m trying to make a sprite respect screen boundaries. I already have something similar done for the player but it’s not the same: the player starts on screen, so it’s easy with “separate objects” to make it respect the screen boundaries (I simply made an invisible object and separate it from player); meanwhile other sprites (such as enemies) first have to enter the screen and then respect those boundaries. I tried to make a condition that checks if the center of the sprite is within an interval (between 0 and camerWidth()-(Sprite.Width()/2)+1 ) and it kinda works. The problem comes when sometimes the check doesn’t work and the sprite passes through and I don’t why it happens. Any idea?

You need to close th map :v:
How can you do this? (Create a big rectangle and put around the map, but you can’t look the rectangle in the game.) The sprite touch this “wall” can’t go more distance.
(This aren’t the best method, but is an example, you need look new horizonts)
Other examples of limits:
Objects or terrain in limits to block player
Magic pilar, attack player when pass X point
Water
Big crack or Altitude

Could you just apply the events that make the enemies respect the screen boundaries with a condition that compares their position to the invisible objects and makes sure they’re between the two? Something like:

CONDITION
The X position of Enemy is > BeginningInvisibleObject.X()+BeginningInisibleObject.Width()
The X position of Enemy is < EndInvisibleObject.X()-Enemy.Width()

ACTION
**stuff that makes Enemy respect screen boundaries**

You could mess around with the X positions and points to get it working how you want.

I swear that’s what I’m doing. I tried with invisible boundaries and sometimes, RANDOMLY, it goes through. I tried with coordinates but it does a “jump” at the beginning that I don’t like. If I try to add a condition to the latter method it simply doesn’t work. This all happens on the right side and I don’t get why, I’m going crazy.

It might help if you post screen shots of your events and the level/screen showing what’s happening versus what you want to happen.

Nevermind I KINDA resolved it by changing the whole thing, I basically added a period where the enemy has a time to enter in the screen and then the boundaries activate