I'm developing a game where the player flies around fighting some enemies, but I'm having trouble checking if an enemy has a clear line of sight to fire at the player.
I need to be able to check if all the tiles between the xy point of the enemy and the xy point of the player are empty?
If you take a look at the Tile Shader code it has a Los function that you could modify (this will give you the range of tiles to check).
http://impactjs.com/forums/code/tile-based-shader-plugin
Thanks, that looks great, but I'm also having trouble checking if the enemy ships (sometimes quite large) can fly to the player without getting stuck on map items that they can't fly through.
Currently I'm periodically spawning a ghost ship (invisible but of the same size), and flying it straight at the player with very high velocity, if it reaches the player, it has a clear trajectory, if not, find another route.
The problem I'd have with the Los code is that it doesn't take into account the size of the ship?
Argh, turns out there's a function built into Impact that I just didn't find, stupid me.
If anyone else is having trouble with this, your answer is solved right here
http://impactjs.com/documentation/class-reference/collisionmap#trace
Can you explain what is meant by a "trace result" and how that can be used to find a clear line of sight to enemy targets? I'm considering writing a line of sight cone class that centres on enemies and rotates Metal Gear Solid style. Are there any examples of how this can be done in Impact?
Running a collision map trace from A to B, where A is an entity's position and B typically is its next, extrapolated position (pos + vel), returns a res object that indicates whether or not the entity will collide with collision tiles, assuming that their placement mirrors that of your game's walls and other obstacles.
By replacing B with the position of another entity, e.g., A is sentry position and B is player position, trace's returned res will indicate whether or not there are any obstacles or walls between both entities, hence line of sight checking.
Thanks the explanation luckily I was able to follow along with an example posted on these forums to make it work.
The problem I've found with the trace method is it doesn't take into account existing entities. See my post for more details.
http://impactjs.com/forums/help/collision-map-trace-method-ignores-entities
Page 1 of 1
« first
« previous
next ›
last »