SetObjectScale: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Improve example.) |
||
(14 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{client function}} | {{Server client function}} | ||
This function changes the visible size of an object. | This function changes the visible size of an object. | ||
{{Note|setObjectScale '''does not''' affect the collision models for the object, as such is unsuitable for use for interaction with players, vehicles or other objects.}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool setObjectScale ( | bool setObjectScale ( object theObject, float scale [, float scaleY = scale, float scaleZ = scale ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[object]]:setScale|scale|getObjectScale}} | |||
===Required Arguments=== | |||
*'''theObject''': the [[object]] you wish to change the scale of. | |||
*'''scale''': a float containing the new scale. 1.0 is the standard scale, with 0.5 being half the size and 2.0 being twice the size. If the scaleY is set, this will be scaleX. | |||
=== | ===Optional Arguments=== | ||
*''' | *'''scaleY''': a float containing the new scale on the Y axis | ||
*''' | *'''scaleZ''': a float containing the new scale on the Z axis | ||
===Returns=== | ===Returns=== | ||
* ''true'' if the scale was set properly. | |||
* ''false'' otherwise. | |||
==Example== | ==Example== | ||
This example creates an antenna, and changes the size of it. | This example creates an antenna, and changes the size of it. | ||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | -- Get the position of the player | ||
local x, y, z = getElementPosition( | |||
-- | local x, y, z = getElementPosition(localPlayer) | ||
if | -- Create the object | ||
-- | |||
setObjectScale ( | local antennaObject = createObject(1595, x + 2, y, z) | ||
-- | |||
if antennaObject then -- If it was created | |||
-- Set the scale to half the normal scale | |||
setObjectScale(antennaObject, 0.5) | |||
-- Remove the collision | |||
setElementCollisionsEnabled(antennaObject, false) | |||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{ | {{Client_object_functions}} |
Latest revision as of 14:37, 2 September 2022
This function changes the visible size of an object.
Syntax
bool setObjectScale ( object theObject, float scale [, float scaleY = scale, float scaleZ = scale ] )
OOP Syntax Help! I don't understand this!
- Method: object:setScale(...)
- Variable: .scale
- Counterpart: getObjectScale
Required Arguments
- theObject: the object you wish to change the scale of.
- scale: a float containing the new scale. 1.0 is the standard scale, with 0.5 being half the size and 2.0 being twice the size. If the scaleY is set, this will be scaleX.
Optional Arguments
- scaleY: a float containing the new scale on the Y axis
- scaleZ: a float containing the new scale on the Z axis
Returns
- true if the scale was set properly.
- false otherwise.
Example
This example creates an antenna, and changes the size of it.
Click to collapse [-]
Client-- Get the position of the player local x, y, z = getElementPosition(localPlayer) -- Create the object local antennaObject = createObject(1595, x + 2, y, z) if antennaObject then -- If it was created -- Set the scale to half the normal scale setObjectScale(antennaObject, 0.5) -- Remove the collision setElementCollisionsEnabled(antennaObject, false) end
See Also
- createObject
- getObjectScale
- moveObject
- setObjectScale
- stopObject
- getObjectMass
- getObjectProperty
- setObjectMass
- setObjectProperty