Pickline and tileLayers
by Phil Shenk · in Torque Game Builder · 07/04/2006 (1:19 pm) · 4 replies
If I have a tile layer with no tiles on it, should pickline register the layer as hit? If there are only a few tiles that have their collision polys set up, should pickline only pick the layer if it crosses those tiles?
That's what I want it to do. If I have a tile layer, and only several tiles have collision polys set, I want to be able to tell if if a line is intersecting those tiles.
BUT, it seems like it is just checking if the line crosses the sceneobject, in this case the whole tileLayer.
In other words, I want a super-fast way to do a straight-line collision check.
That's what I want it to do. If I have a tile layer, and only several tiles have collision polys set, I want to be able to tell if if a line is intersecting those tiles.
BUT, it seems like it is just checking if the line crosses the sceneobject, in this case the whole tileLayer.
In other words, I want a super-fast way to do a straight-line collision check.
About the author
#2
It seems this would be a valuable feature though.
In case I wasn't clear before, what is wanted is a way to to do a collision check against tiles (that have their collision polys set)
For what you're wanting, to just get a list of scene objects along a ray, pickline() should work for you.
My particular issue was that it wasn't working against tiles, only the whole tileLayer. It's been awhile since I've looked at it though. Maybe this got addressed. Anybody have any up to date info?
12/11/2006 (11:08 pm)
No, never resolved this. I got sidetracked working on other stuff.It seems this would be a valuable feature though.
In case I wasn't clear before, what is wanted is a way to to do a collision check against tiles (that have their collision polys set)
For what you're wanting, to just get a list of scene objects along a ray, pickline() should work for you.
My particular issue was that it wasn't working against tiles, only the whole tileLayer. It's been awhile since I've looked at it though. Maybe this got addressed. Anybody have any up to date info?
#3
12/16/2006 (9:41 pm)
You can create a scene object with a small collision poly and use it to cast collisions to see if anything is in the way.
#4
I have a tilemap with floor tiles and collideable walls. I have a player shooting a gun.
When the player shoots, I want to do a line of sight check between the players position and the mouse position (the mouse is the aiming crosshair) to see if there are any walls in between.
Pickline appears to fail because it picks up the ENTIRE tilemap as an object. So I followed Thomas' advice and create a small SceneObject. I set it to MoveTo the target location at some arbitrary speed. I then did a CastCollision call to see if it collided with any walls.
That appeared to work!
The next step I wanted to try was determining exactly where the collision happened. If I tried to shoot through a wall, for example, I figured I might want to put a small graphic or particle effect where the bullet hit.
However, when I looked at the results from CastCollision, the X and Y position appeared to be the FINAL destination of my little projectile object, NOT the place where it collided with the wall.
Does that sound familiar to anyone out there? I'm really having a hard time wrapping my head around tilemaps and doing collisions. I've read the "Platformer" tutorial on TDN, but that doesn't really answer my questions.
To summarize:
1) PickLine, PickRect, etc seem like VERY useful methods, especially to do Line of Sight work. If they truly don't work in TileMaps, that's really unfortunate.
2) Collisions seem to work in TileMaps, however the results from CastCollision were confusing.
Anyone have any more comments?
Adman
01/09/2007 (11:15 am)
I'm kind of up against the same issue. I wanted to to line-of-sight in my game (for all intents and purposes, a clone of the original "Gauntlet" arcade game).I have a tilemap with floor tiles and collideable walls. I have a player shooting a gun.
When the player shoots, I want to do a line of sight check between the players position and the mouse position (the mouse is the aiming crosshair) to see if there are any walls in between.
Pickline appears to fail because it picks up the ENTIRE tilemap as an object. So I followed Thomas' advice and create a small SceneObject. I set it to MoveTo the target location at some arbitrary speed. I then did a CastCollision call to see if it collided with any walls.
That appeared to work!
The next step I wanted to try was determining exactly where the collision happened. If I tried to shoot through a wall, for example, I figured I might want to put a small graphic or particle effect where the bullet hit.
However, when I looked at the results from CastCollision, the X and Y position appeared to be the FINAL destination of my little projectile object, NOT the place where it collided with the wall.
Does that sound familiar to anyone out there? I'm really having a hard time wrapping my head around tilemaps and doing collisions. I've read the "Platformer" tutorial on TDN, but that doesn't really answer my questions.
To summarize:
1) PickLine, PickRect, etc seem like VERY useful methods, especially to do Line of Sight work. If they truly don't work in TileMaps, that's really unfortunate.
2) Collisions seem to work in TileMaps, however the results from CastCollision were confusing.
Anyone have any more comments?
Adman
Torque Owner Mark Rose
I basically want to do a ray-cast check and get a list of stuff I collide with so that I can choose when my enemies should fire bullets and have a clear line of sight etc.