Game Development Community

PickLine Problems[solved]

by Drethon · in Torque Game Builder · 01/29/2013 (5:33 am) · 6 replies

I'm working on a platformer and I want to detect edge drop off before an NPC hits the edge so they turn around. I used a pickline function with a point that starts a bit ahead of the NPC (adjusted for direction) and then drops straight down between 0.1 and 5.0 (tried a few to see what happens). The result is always detecting the tile layer, regardless of if the NPC is on ground or way up in the air.

What am I doing wrong here?

(see my last reply for solution)

#1
01/29/2013 (11:58 am)
I don't write platformers so I may be missing something, but I think this is an old problem (www.garagegames.com/community/forums/viewthread/34106). At the end of this thread he mentions that the pickLine function picks the tile layer because it covers the whole scene.
#2
01/29/2013 (12:48 pm)
Guess I missed that one, thanks. Though pickLine would work like castCollision but apparently not. I'll have to find a different way to detect collision that is off the vector of the character.
#3
01/31/2013 (8:27 am)
Just in case anyone is ever interested...

I solved this problem by picking the appropriate tile out of the tilemap, using the position of the NPC, and then looking at if the tile is collide-able or not.
#4
01/31/2013 (10:38 am)
It is interesting you bring this up. It was causing me problems when I was fiddling with particle collision. In your case, though, I don't think pickLine() can tell the difference between a collision-enabled tile an a collision-disabled tile - it just hits the tile layer because the tiles are not individual objects.
#5
01/31/2013 (7:26 pm)
Sorry, could have been more specific. I used the t2dTileLayer functions pickTile and getTileType to identify the tile at a given location (and those around it as needed), instead of pickline.

In particular I found the tile under the bottom half of the player (player is two tiles tall) and the moved one down, one in the direction of player movement and checked for tile collision info to find a dropoff.
#6
01/31/2013 (7:48 pm)
No, no - I got that. I was just pointing out that the pickLine() function looks for objects, and tiles aren't actually objects - though the tileLayer itself is. Tiles are just logical areas defined within the tileLayer object, so pickLine() finds the tileLayer object no matter what tile it's over.