Checking tilemap below player

Get help using Construct 2

Post » Sun May 08, 2016 11:44 am

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.
Posts: 46
Reputation: 544

Post » Sun May 08, 2016 7:36 pm

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

'checked' = 0
-------------------Call function"CheckEmpty" param(0) = 'YtoCHeck'
if returned param. > 0
------------------ add cell heigh to 'Ytocheck'
------------------ 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.
Posts: 2,493
Reputation: 21,450

Return to How do I....?

Who is online

Users browsing this forum: kinunatzs and 4 guests