Vscript question about the GetFov function
Quote from Dir.Noe on September 2, 2013, 1:25 pmI'm looking for a way to determine if the player zoomed in on something.
Logic_playerproxy has outputs for jump and duck, and game_ui has outputs for most other player key presses, but neither has any for zoom. I noticed Portal2 has a vscript function that measures field of view,
https://developer.valvesoftware.com/wiki/List_of_Portal_2_Script_Functions#CTriggerCamera. Since the player's normal fov is 90 degrees, if the player's fov is less than 90 that means they pressed zoom (assuming the map doesn't have an env_zoom entity and that the player didn't use a console command).So I tried writing a vscript function that gets called when the player steps on a trigger...
- Code: Select all
function player_zoomed() {
local field = player.GetFov();
if (field < 90) EntityGroup[6].EmitSound("turret.sp_sabotage_factory_defect_laugh05");
//the sound is just a convenient way to tell if the function is working and is played by the entity defined in my map's logic_script that happens to precache all my audio
}...but it says the GetFov index does not exist.
I think my problem is that the player's view is actually made up of multiple cameras (the normal world camera is 90 degrees, but the hud camera which contains the portalgun's viewmodel is 50 degrees) and that telling it to get the player's fov just isn't specific enough. But I don't know how to reference the different cameras in vscript and I can't find any in-game examples of the GetFov function being used.
Has anyone ever successfully used this vscript function? Or know of another way to detect zoom? (Please note I don't care what direction the player is looking, or I would just use a trigger_look and an info_target.)
I'm looking for a way to determine if the player zoomed in on something.
Logic_playerproxy has outputs for jump and duck, and game_ui has outputs for most other player key presses, but neither has any for zoom. I noticed Portal2 has a vscript function that measures field of view,
https://developer.valvesoftware.com/wiki/List_of_Portal_2_Script_Functions#CTriggerCamera. Since the player's normal fov is 90 degrees, if the player's fov is less than 90 that means they pressed zoom (assuming the map doesn't have an env_zoom entity and that the player didn't use a console command).
So I tried writing a vscript function that gets called when the player steps on a trigger...
- Code: Select all
function player_zoomed() {
local field = player.GetFov();
if (field < 90) EntityGroup[6].EmitSound("turret.sp_sabotage_factory_defect_laugh05");
//the sound is just a convenient way to tell if the function is working and is played by the entity defined in my map's logic_script that happens to precache all my audio
}
...but it says the GetFov index does not exist.
I think my problem is that the player's view is actually made up of multiple cameras (the normal world camera is 90 degrees, but the hud camera which contains the portalgun's viewmodel is 50 degrees) and that telling it to get the player's fov just isn't specific enough. But I don't know how to reference the different cameras in vscript and I can't find any in-game examples of the GetFov function being used.
Has anyone ever successfully used this vscript function? Or know of another way to detect zoom? (Please note I don't care what direction the player is looking, or I would just use a trigger_look and an info_target.)
Quote from FelixGriffin on September 2, 2013, 2:19 pmUnfortunately I've never found a way. I'm currently looking for one to remap mouse3 to switch weapons.
Unfortunately I've never found a way. I'm currently looking for one to remap mouse3 to switch weapons.