Use: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Nesciuse moved page Use/en to Use without leaving a redirect: Move en subpage to basepage)
No edit summary
Line 1: Line 1:
{{LanguageBar}}
{{LanguageBar}}


All entities have a [[Use]] [[input]], though many do nothing in response to it. Typically, it performs the action players most expect when interacting with the entity (e.g., opening/closing a door, picking up a physics object). There are four methods to invoke it:
All entities have a [[Use]] [[input]], though many do nothing in response to it. Typically, it performs the action players most expect when interacting with the entity (e.g., opening/closing a door, picking up a physics object). There are five methods to invoke it:
#A player looking at the entity and using the <code>+use</code> console command (commonly bound to the {{key|E}} key).
#A player looking at the entity and using the <code>+use</code> console command (commonly bound to the {{key|E}} key).
#An entity [[output]] that specifies the <code>Use</code> input, or not specifying any input.
#An entity [[output]] that specifies the <code>Use</code> input, or not specifying any input.
#Directly calling the C++ function.
#Directly calling the C++ function.
#If an entity without a use function is parented to one which does, it will passthrough the input to the parent.
#If an entity without a use function is parented to one which does, it will passthrough the input to the parent.
# The {{cmd|firetarget}} [[cheat]] command.


==Programming==
==Programming==

Revision as of 08:19, 13 May 2025

English (en)中文 (zh)Translate (Translate)

All entities have a Use input, though many do nothing in response to it. Typically, it performs the action players most expect when interacting with the entity (e.g., opening/closing a door, picking up a physics object). There are five methods to invoke it:

  1. A player looking at the entity and using the +use console command (commonly bound to the E key).
  2. An entity output that specifies the Use input, or not specifying any input.
  3. Directly calling the C++ function.
  4. If an entity without a use function is parented to one which does, it will passthrough the input to the parent.
  5. The firetarget cheat command.

Programming

Although there is always a Use input, the actual Use function of an entity starts null. It can be assigned at any time with SetUse( void *SomeFunc(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) ).

It doesn't appear possible to specify USE_TYPE or value through the I/O system.