Checking for position to be empty before moving...

0 favourites
From the Asset Store
Vector illustration of a UFO with an alien in three different positions.
  • Hi everyone,

    I'm new to Construct 3 and went through the ghost shooting tutorial. So I'm now trying to make a simple puzzle game to get my feet wet.

    What I'm trying to do is when the player clicks a tile, I want the tile to move to the left IF there isn't already a tile there. Below is an image of the events I put in but it isn't working as intended. The tile will move whether or not there is a object in the way.

    Any assistance is appreciated.

  • You can check if the tile at Mouse position is empty or not by this condition:

  • So I think there are 2 issues with that...

    1. I'm not using a tilemap.

    2. I'm not wanting to check where is the mouse is being clicked.

  • If your tile is a sprite, and you need to check if it's overlapping another tile, you need to check overlapping between the sprite and the family. (this way they act as different objects)

    Tile is NOT overlapping TilesFamily -> Tile move...

    .

    Also, check out the Tile Movement behavior, there is a demo template in C3.

  • Ok, this may be my bad. But my family called Tiles is a collection of 5 objects/sprites. They are no tiles.

    I looked at the tile example per your instructions, but I do not see the relevance to my dilemma.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok, then make a copy of this family and use "Tiles is not overlapping TilesCopy"

  • I'm not sure how that would have worked, but I tried it anyway and there was no different.

  • It will be much easier to help if you could share your project file.

  • Here you go:

    drive.google.com/open

  • Create a new family TilesCopy, change the event to this:

    Also, the origin image point in your sprites is way off, you need to set it in the center.

  • Ok, that worked. I was wondering why my tiles were off, but I couldn't figure out how to see the points again. But I figured it out. Thank you.

    So here is my really big question... why does it need to be a copy of the family and not use the same family? Some age old family rivalry?

  • "On Tiles clicked" event picks one instance of Tiles object. Inside this event Tiles now refers to only 1 picked instance, and that's why you can't check overlapping with other instances of Tiles. And TilesCopy acts as a different object.

  • If your game is tile based then you could use the "Can move to" condition of Tile Movement. Internally it already has to check if it can move into a cell before starting the movement animation, I just exposed that method for users ( seemed handy ).

  • Hmmm... I will look into that because that sounds perfect, but I don’t remember seeing that option.

  • Gadgetkk as I said it's a condition of Tile Movement, so it's only available on objects with the tile movement behaviour.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)