Canseespr: Difference between revisions
No edit summary |
No edit summary |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
canseespr <spriteID1> <spriteID2> <returnvar> | '''canseespr''' <spriteID1> <spriteID2> <returnvar> | ||
The three parameters are [[gamevar]]s. | The three parameters are [[gamevar]]s. | ||
Line 5: | Line 5: | ||
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. | 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 | |||
[[Category:EDuke32 specific commands]] | |||
[[Category:Gamevar manipulation]] |
Latest revision as of 10:09, 5 December 2009
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