Canseespr

From EDukeWiki
Jump to: navigation, search

canseespr <spriteID1> <spriteID2> <returnvar>

The three parameters are gamevars.

canseespr sets <returnvar> to 1 if the sprite with ID <spriteID1> has a line of sight with the sprite with ID <spriteID2>, otherwise <returnvar> is set to 0.

Visibility is checked from the bases of the sprites. It is as if there were cameras on the bottoms of the sprites' feet and they were trying to see each other with those cameras. As a result, the visibility check will usually come back negative on uneven ground and in other situations where the sprites should be able to see each other. To remedy this, you can move one or both of the sprites to a higher position right before the canseespr check, then move them back down again before the move has any unwanted effects.

For example:

 getactor[THISACTOR].z ZPOSITION // assuming there is already a declared variable ZPOSITION
 subvar ZPOSITION 8192
 setactor[THISACTOR].z ZPOSITION
 canseespr THISACTOR TARGET RETURN
 addvar ZPOSITION 8192
 setactor[THISACTOR].z ZPOSITION