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

0 favourites
  • 6 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • 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 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)

  • Every tick-(Player) Set Y to int(Player.Y)

  • 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

  • if you get 191..set collision polygon for mud to X=0 Y=1

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • yeah I noticed, I did something like "int(Player.Y) + 1" and worked but your method work aswell

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