# Player position is not an integer number (and it should be?)

Get help using Construct 2

### » Tue Oct 28, 2014 3:31 pm

Hi everyone. This is my first post here in the forums.
I'm a really recent Construct 2 user and I have a lot to learn, so I've been doing some tutorials and experiments and I found a small problem so I hope someone can help me.

So, I'm using 64x64 tiles, with "snap to grid" on, the grid is also 64x64.
In the editor, it shows the real position of the player in the layout (the player is the 64x64 light brown square), with the Y = 192
(picture 1)

However in the game, it shows a decimal number, which is really really close to the real number (192) but it's not. And this is a big problem when I'm doing events in which I have to compare the Y position of the player (in ths case, I wanted to do something like if the player Y position is equal to the tile with grass Y position, something happens), because 192 is not equal to 191,999.... etc.
(picture 2)

Can someone give me some help? (I've attached the .capx)

Thanks
You do not have the required permissions to view the files attached to this post.
B
8
S
2
Posts: 12
Reputation: 583

### » Tue Oct 28, 2014 5:41 pm

You probably don't want to test what type of tile your player is touching that way.

An easier way to check if your player is touching a tile that has grass in your example is to use the Is Overlapping at Offset trigger

Offset X =0
Offset Y = - 20 (or however far down from the origin of the player you need to check)

First check if its overlapping a ground tile, then test if that tile is a "grass" tile (by comparing the animation frame number, or grass tile sprite depending on how you set it up)
B
82
S
39
G
15
Posts: 982
Reputation: 16,712

### » Tue Oct 28, 2014 6:37 pm

Every tick-(Player) Set Y to int(Player.Y)
B
63
S
23
G
7
Posts: 1,480
Reputation: 10,796

### » Tue Oct 28, 2014 7:03 pm

yea, that worked!

I was trying to do something like pinning a transpartent sprite to the player, a little bigger than the player and checked if that sprite was overlapping the grass tile. It worked, but it's not very practical.

Your method is much easier, thanks
B
8
S
2
Posts: 12
Reputation: 583

### » Tue Oct 28, 2014 7:12 pm

if you get 191..set collision polygon for mud to X=0 Y=1
You do not have the required permissions to view the files attached to this post.
B
63
S
23
G
7
Posts: 1,480
Reputation: 10,796

### » Wed Oct 29, 2014 9:42 am

yeah I noticed, I did something like "int(Player.Y) + 1" and worked but your method work aswell
B
8
S
2
Posts: 12
Reputation: 583