0 Favourites

Checking tilemap below player

  • Hello there ladies and gents of the internet!

    I come here again asking for help only this time i understand what it is I am after.

    I am having an event spawn at the tilemap.Y that is below the player.Y's feet.

    If there is not a tile at the players feet (If the check returns a "-1" tilemapID), then it will search the tile below that and so forth, until it either does this 6 times or there is a tile at that tilemap.Y (check yields not -1)

    So far I am using this to test for the tile below the players feet and looping until it hits the Max_Loop_Count.

    If Platforms.PositionToTileY(Player_movement.ImagepointY(1)) >-1 ---- do a thing

    This does not work consistently ans I have tried many other options too.

    I am aware that I need to run a sub-routine that loops (I will use a group for the loop) to monitor how many times it does this and then condition appropriately.

    I have naturally played around with testing and implementing varies things but to no avail.

    Any help or links to advanced tutorials of the tile mapping are welcomed.

    I look forward to hearing from you.

    Chris

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • If it returns a '-1' and this 'do a thing' includes actions that are supposed to work on that object that a '-1' returns, then non is picked. But i can not now that, you did't give that info.

    To avoid this, you better make use of a function. Functions pick from scratch, they forget the previous picked objects. So the logic would be something like :

    (variable) 'Checked' = 0

    (variable) 'YtoCHeck' = the height of the tilemap cell / 2

    while

    'checked' = 0

    -------------------Call function"CheckEmpty" param(0) = 'YtoCHeck'

    if returned param. > 0

    ------------------ add cell heigh to 'Ytocheck'

    else

    ------------------ checked = 1

    ------------------ Do youre stuff with x = player.x and y= 'YtoCHeck'

    On function "CheckEmpty"

    Player is overlapping tilemap at Y = param. (0)

    ---------------------set return parameter to tilemap.pickedcount

    This should stop because you have a floor. Or you can cap it to 6 as you desire.

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