Octohunter Posted June 2, 2011 Author Share Posted June 2, 2011 Hey all,I was just wondering if there was an existing function that would allow the game to detect whether there was a solid object between two points. I'm in the process of coding a ranged weapon system, and I'm just about done except for the actual bullet and this. Any help would be appreciated :) Link to comment Share on other sites More sharing options...
GrimReaperReborn Posted June 2, 2011 Share Posted June 2, 2011 I don't believe there is a preexisting one. But making one shouldn't be difficult. Run a loop that goes through all the tiles in the direction the player is facing that checks for blocks and other players. Link to comment Share on other sites More sharing options...
Octohunter Posted June 2, 2011 Author Share Posted June 2, 2011 That's not how my ranged system works, though. Basically, you target an NPC and press the attack button. If you have a ranged weapon equipped, it will hit the NPC if it is in range. What I want is to program a function that will allow the game to detect whether there is a solid between the x and y coordinates of the player and the x and y coordinates of the npc. Thanks, anyway. Link to comment Share on other sites More sharing options...
Joyce Posted June 3, 2011 Share Posted June 3, 2011 Then run a function to check whether there is anything between X1,Y1 and X2,Y2 :) Or rather, write one.. There's plenty of material around on google for this stuff in Grid Based games, I'm sure you can find some base code for it. ^^ Link to comment Share on other sites More sharing options...
Robin Posted June 3, 2011 Share Posted June 3, 2011 Read up on 2D line-of-sight. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now