Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Line of Sight

Author
Message
scott1686
15
Years of Service
User Offline
Joined: 27th Jan 2009
Location:
Posted: 6th Oct 2009 01:50 Edited at: 6th Oct 2009 01:51
I'm trying to do a line of sight calculation where I take the location of one character and see if it can see another character or if there's a wall in the way. I tried that static line of sight function but that didn't work, probably because the walls don't use static collision boxes (it's just one big wall object with polygonal collision detection). Next I tried creating a triangle with 2 of its vertices near the one character and one near the other and then checking if it collides with the wall object. Visually, it looks like what it's supposed to (basically a line coming out from the one character and ending at the other) but it never seems to be able to tell if it goes through a wall. Here's the code:



This code always results in the character going into attack state, even when there is clearly a wall in between it and its target (I froze the game and displayed the triangle for a few seconds after it was created to make sure of this). Any ideas how I could get this code to work or use other functions to accomplish the line of sight calculation? Thanks.
Serial Velocity
16
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 6th Oct 2009 17:55
Try doing a raycast from the character to the enemy instead of using an object, either by using dbIntersectObject() or the Raycast functions from Sparkys Collision Lib, which are MUCH faster.

Chamill
16
Years of Service
User Offline
Joined: 29th Sep 2008
Location:
Posted: 6th Oct 2009 19:11
Isn't wrong to type

if (dbObjectCollision(LINEOFSIGHT, WALLS) == 0) gotoAttackState();

?

I believe you should make it " If bla bla == 1 "
Or did i miss sum?

You can only get smarter by playing a smarter opponent.
scott1686
15
Years of Service
User Offline
Joined: 27th Jan 2009
Location:
Posted: 6th Oct 2009 20:25
Chamill - I'm checking to make sure it's not colliding, so that if there's nothing blocking the line of sight, attack the target.

Serial Velocity - Thanks for the help, I'll try out dbIntersectObject, and if that doesn't work, I'll look into that library.
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 6th Oct 2009 20:50 Edited at: 6th Oct 2009 20:51
Quote: "I believe you should make it " If bla bla == 1 "
Or did i miss sum?"


This isn't DBPro, see HERE.(unless you merely meant to tell him to change it to 1)

scott1686
15
Years of Service
User Offline
Joined: 27th Jan 2009
Location:
Posted: 6th Oct 2009 21:08
Serial Velocity - I just tried out dbIntersectObject() and it works the way I wanted it to. Thanks for the help!
Chamill
16
Years of Service
User Offline
Joined: 29th Sep 2008
Location:
Posted: 6th Oct 2009 22:10
Well for starters .. he fixed his problem so nvm me

Quote: "This isn't DBPro, see HERE.(unless you merely meant to tell him to change it to 1)"


Yes. I meant to change it to 1 =) ( And i was wrong )

You can only get smarter by playing a smarter opponent.

Login to post a reply

Server time is: 2024-10-01 14:27:26
Your offset time is: 2024-10-01 14:27:26