OnObjectHit: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Event|Client|1.0}} {{FuncDescription|Called when something ''hits'' the object. Requires EnableObjectHitEvents to be called on the object before.}} {{FuncSyntax|O..." |
No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 17: | Line 17: | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua> | |||
AddEvent("OnObjectHit", function(object, hittype, hitid, hitX, hitY, hitZ, normalX, normalY, normalZ) | |||
if IsValidObject(object) then | |||
if hittype == HIT_VEHICLE then | |||
-- A vehicle hit the object and this event was called | |||
end | |||
end | |||
end) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{ | {{ObjectClientEvents}} |
Latest revision as of 03:30, 18 August 2020
Description
Called when something hits the object. Requires EnableObjectHitEvents to be called on the object before.
Syntax
OnObjectHit(object, hittype, hitid, hitX, hitY, hitZ, normalX, normalY, normalZ)
Parameters
- object
The object which was hit. - hittype
The type of entity which hit the object. - hitid
The identifier of the entity which hit the object. - hitX
The X coordinate of this hit. - hitY
The Y coordinate of this hit. - hitZ
The Z coordinate of this hit. - normalX
Impact normal X of the hit. - normalY
Impact normal Y of the hit. - normalZ
Impact normal Z of the hit.
Example
AddEvent("OnObjectHit", function(object, hittype, hitid, hitX, hitY, hitZ, normalX, normalY, normalZ)
if IsValidObject(object) then
if hittype == HIT_VEHICLE then
-- A vehicle hit the object and this event was called
end
end
end)