[Solved] Inverted "point inside object" condition not working as expected

Hello, I’ve run into an issue getting a certain event to work properly.

I’m working on a game with tile-based movement, and have set up events that allow for this. Currently, Player moves in all cardinal directions as desired. Now, I’m trying to start implementing walls in my game, which should prevent Player from being able to move into their tile. (Player and each Wall is exactly 1 tile large)

In order to stop movement into Walls, I’ve set up the move event in the following way: if there is no Wall in the space that Player is attempting to move into, then allow Player to move into that space. I’ve set it up inside the “w key is pressed” event for now.

However, when I try running this code, movement isn’t stopped by Walls at all, and Player can move as though this condition doesn’t exist. On the other hand, when left un-inverted, the condition works as I would expect: Player can only move up if a Wall exists above them.

Have I implemented the event incorrectly? Does the inversion of “point inside object” not work as I’m trying to implement it? I can think of alternative ways to implement this behavior, I’d just like to know how this specific condition works.

Here’s a picture of the events I’ve set up:

And here’s a .zip of the project if it’s needed:

Thank you, any help is appreciated. :slight_smile:

@AriMaeda Hi. I can’t look at the file right now, but by looking at the event screenshot, your highlighted code seems to be describing the following logic:


  • W is pressed AND variable canwalk is equal to 1 AND the center point of the Player (x+32,y-32) is NOT inside Wall:


  • Assign variable canwalk the value 0
  • Reset the time walk of Player
  • Add a permanent force of 256 pixels with an angle of 270° (upwards direction / north) to the Player Object.

The last part means that the character will keep moving indefinitely, but I see you have a timer conditional at the bottom, set to stop the character, however this only means the Player will stop automatically because of the timer, not because it was inside or outside of the Wall object.

So, the problem I see, is that you need to explicitly define a condition where the Player force is stopped when it is inside a Wall.

This could be accomplished by copying and pasting the same “is inside” condition but without the “invert” toggle and then add the same actions that are on the timer to the new event. You could also use an “OR” condition image so the actions happen when, either the timer fires, or the Player point is inside the Wall.

Although to be honest in here it could be better to use the Collision condition event instead to handle pixel-perfect collisions
This will require you to use collision masks for the Player and the Wall Sprite Objects, which usually default to the size of the sprite.

The you can handle and process the collision for your tile based movement, so you don’t have to implement a complicated collision system by yourself (unless that’s your intent of course).

Conversely you don’t need a Permanent force either, if you use an Instant force, you can move the character every frame while the key is pressed, as the force will be applied per frame only, and once you release the key the character will stop on it’s own, this would also help to avoid needing to use the Stop action and the timer, because if you stop pressing the key the force will not keep pushing the character (unless that’s what you want)

In the latter case, If you want to keep the rounding of the player position to integers, you can use a “Key Released” event instead.

Also, I can’t be sure, but just in case you’re using Object Groups be careful as there is apparently a bug where any condition that uses group objects will return True regardless of comparison.

Good luck :+1:

I’ve verifed the condition, it’s working well.

Your bugis like joseMoreno said in your logic :confused:
Player x + 32 and player y -32, give the position on top right above 32 pixels of your player.
X+ is right, X- is left, Y+ is down, Y- is top, more about coordinates


the center point of the Player (x+32,y-32) is NOT inside Wall :

(x+32,y-32) is testing the middle of the tile directly above the Player, not the center point of Player:

My aim is to determine if the tile is even an eligible place to move to. If there’s a Wall, you can’t move there; no collision necessary! :slightly_smiling_face:

With some more experimentation, I’ve figured out more about the “point inside object” condition and why it’s not doing what I want:

I was acting under the assumption that it meant “if the specified point is inside the collision mask of an instance of that object”, but instead it seems to be “for each instance of the object, test the specified point”. Because of that, even though there’s a Wall directly above Player, I can still move up because the test point returns false for a different wall and the event executes. In my demo, if you delete all of the other walls, it works as intended!

To better illustrate it, here’s a simple game. I have three boxes, animation 0 is red, animation 1 is blue:


The behavior I (previously) expected was that if you click anywhere outside of the boxes, they turn blue. If you click within the bounds of any of them, nothing happens since the condition is true (and inverted). Instead, clicking the last box does this:


It’s executing the event three times, once for each box. It’s not the behavior I was expecting, but knowing that I can solve my issue. Thank you guys for your time!


This problematic is encounter by lot of users.
Indeed peoples think one object, but the engine is design for think instances of object.

You need condition for verify all case.


For anyone who comes across this in future, @Silver-Streak made an excellent suggestion in How to use Inverted "Point Inside" with more than one instance on scene? - #4 by Silver-Streak where they said:

I think this is the one instance where you need to use the advanced “NOT” condition, rather than inverted.

That certainly worked for me!

1 Like