Checking if an object is being looked at
Quote from Soundlogic on June 5, 2011, 8:35 pmI decompiled valves map to try to figure out how to check if an object is being looked at, and I copied the entity they used, edited it slightly, but it doesn't seem to be working. If anyone could give me some advice on what is wrong with my setup I would appreciate it.
Thank You,
Sound Logic
I decompiled valves map to try to figure out how to check if an object is being looked at, and I copied the entity they used, edited it slightly, but it doesn't seem to be working. If anyone could give me some advice on what is wrong with my setup I would appreciate it.
Thank You,
Sound Logic
Quote from yohoat9 on June 5, 2011, 8:50 pmLol, I got the vmf and put it in the maps folder, then realized that I already have a map called looktest XD
Lol, I got the vmf and put it in the maps folder, then realized that I already have a map called looktest XD
Quote from taboo54 on June 5, 2011, 9:39 pmTo set this up, all you need is two entities. A brush based entity http://developer.valvesoftware.com/wiki/Trigger_look and the entity that you want the player to look at.
To trigger an output, the player must be in the volume, and looking at the entity in the "look target" box.
I've provided an example map, because it's easier than explaining it in detail. Just make sure you learn something from it.
To set this up, all you need is two entities. A brush based entity http://developer.valvesoftware.com/wiki/Trigger_look and the entity that you want the player to look at.
To trigger an output, the player must be in the volume, and looking at the entity in the "look target" box.
I've provided an example map, because it's easier than explaining it in detail. Just make sure you learn something from it. ![]()
Quote from KenJeKenny!? on June 5, 2011, 9:43 pm@ taboo54;
If he won't... I will!
@ taboo54;
If he won't... I will! ![]()
Quote from Soundlogic on June 6, 2011, 6:58 pmI know how to do that, but the goal I am trying to achieve is to be able to tell if the player is looking at an object. Not just have a trigger the first time they look, but to be able to tell at any given moment if they are looking at the object. Make sense?
I know how to do that, but the goal I am trying to achieve is to be able to tell if the player is looking at an object. Not just have a trigger the first time they look, but to be able to tell at any given moment if they are looking at the object. Make sense?
Quote from Kasc on June 6, 2011, 9:17 pmAs far as I can tell (I've not done any testing, only looked at the wiki) but...
Create a trigger look that sets the value of a info_branch, named player_is_looking to the value of 1.
The trick is in changing this back 0 when the player is no longer looking. If the trigger_look does not automatically refire once it is triggered then you could kill the brush and respawn another with a point_template.
i.e A trigger_look is in place, when a player is looking at the area the trigger sets the logic_branch to one, then kills itself, then spawns another of itself, and resets a timer which if left to run, will set the logic_branch back to 0.
I can make an example if this isn't making any sense to you.
As far as I can tell (I've not done any testing, only looked at the wiki) but...
Create a trigger look that sets the value of a info_branch, named player_is_looking to the value of 1.
The trick is in changing this back 0 when the player is no longer looking. If the trigger_look does not automatically refire once it is triggered then you could kill the brush and respawn another with a point_template.
i.e A trigger_look is in place, when a player is looking at the area the trigger sets the logic_branch to one, then kills itself, then spawns another of itself, and resets a timer which if left to run, will set the logic_branch back to 0.
I can make an example if this isn't making any sense to you.
Quote from NocturnalGhost on June 6, 2011, 9:56 pmThe trigger_look is capable of what you are asking, although this feature seems to be undocumented on the wiki.
Firstly, you need to uncheck "fire once" in the flags, and check "clients". Now, the part that is undocumented is the fact that, when fire once is not checked, the "timeout" value resets the triger, and cancels any pending outputs. So, to give an example, a light (let's call it "red_light") that comes on when you look at the correct place:
"Look target" to the object you want to look at (obviously)
"Look time" to "0", so the triggering is instant
"Field of view" to "0.0" (which equates to 90 degrees, change this as needed)
"Timeout" to 0.5 (again, change to suit. Ignore the description, when used in this manner it is the refire rate of the trigger)Now, for the outputs:
OnTrigger>>Target "red_light">>via input"Turn On">>delay "0"
OnTrigger>>Target "red_light">>via input"Turn Off">>delay "0.6"Now, as you can see, the light is set to turn back off after 0.6 seconds. However, this doesn't happen, since the trigger resets itself and refires after 0.5 seconds. If you aren't looking in the right direction at that time, the sequence is allowed to complete, and the light turns off.
I'm not sure how taxing it is to the game to have the trigger performing in this manner, but it works okay in testing. I'll attach the vmf. I used a light so you would be able to see it's effect even when you aren't directly looking at it, but i see no reason why it wouldn't work with other entities.
look_light_test.vmf
The trigger_look is capable of what you are asking, although this feature seems to be undocumented on the wiki.
Firstly, you need to uncheck "fire once" in the flags, and check "clients". Now, the part that is undocumented is the fact that, when fire once is not checked, the "timeout" value resets the triger, and cancels any pending outputs. So, to give an example, a light (let's call it "red_light") that comes on when you look at the correct place:
"Look target" to the object you want to look at (obviously)
"Look time" to "0", so the triggering is instant
"Field of view" to "0.0" (which equates to 90 degrees, change this as needed)
"Timeout" to 0.5 (again, change to suit. Ignore the description, when used in this manner it is the refire rate of the trigger)
Now, for the outputs:
OnTrigger>>Target "red_light">>via input"Turn On">>delay "0"
OnTrigger>>Target "red_light">>via input"Turn Off">>delay "0.6"
Now, as you can see, the light is set to turn back off after 0.6 seconds. However, this doesn't happen, since the trigger resets itself and refires after 0.5 seconds. If you aren't looking in the right direction at that time, the sequence is allowed to complete, and the light turns off.
I'm not sure how taxing it is to the game to have the trigger performing in this manner, but it works okay in testing. I'll attach the vmf. I used a light so you would be able to see it's effect even when you aren't directly looking at it, but i see no reason why it wouldn't work with other entities.
Quote from Soundlogic on June 6, 2011, 10:08 pmWow. Thanks. That is clever. Someone should really put that in the wiki. That is really clever. Thank you.
Wow. Thanks. That is clever. Someone should really put that in the wiki. That is really clever. Thank you.
Quote from Kasc on June 6, 2011, 10:35 pmYep that's certainly a much cleaner method than my own
I've not really been experimenting with all the different entities yet, I would like to though!
Yep that's certainly a much cleaner method than my own
I've not really been experimenting with all the different entities yet, I would like to though!
