Detecting the tile next to the player...

Get help using Construct 2

Post » Tue Feb 10, 2015 10:38 am

Okay, imagine this, it's simple really:

You are on a playfield that is a tilemap. When the player is NEXT to a particular tile, I want a variable (let's call it "speed") to be set to 2, and when it's NOT NEXT to that tile, it should be set to 4.

The problem is when I go to add the event, I'm using "Tilemap -> Compare Tile At -> player.X-32,player.Y = 11" then "set varSpeedLeft to 2" (I figured I would need various speed vars for each direction)

This will say "If the tile to the left of the player is 11 (swamp) then set speed to 2"

Of course the action is to set the speed to 2 if the tile is tile number 11. However it doesn't seem to be picking up on this at all. Is there a step I'm missing?

Keep in mind: my movement is all custom, not 8dir or anything else.
Posts: 255
Reputation: 3,651

Post » Tue Feb 10, 2015 1:42 pm

"Compare tile at" need a tile coordinate not a pixel coordinate, so you have to convert it first. Like this:

Therefore its often in my opinion a lot easier to keep track of each objects TileX and TileY in some variables, so you don't have to convert the coordinates all the time. But can just use these to check vs the tilemap.
Posts: 1,159
Reputation: 6,542

Return to How do I....?

Who is online

Users browsing this forum: Thirstyy and 13 guests