SetObjectScale: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 9: Line 9:
{{OOP||[[object]]:setScale|scale|getObjectScale}}
{{OOP||[[object]]:setScale|scale|getObjectScale}}
===Required Arguments===
===Required Arguments===
*'''theObject''': The object you wish to change the scale of.
*'''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.
*'''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.


Line 17: Line 17:


===Returns===
===Returns===
Returns ''true'' if the scale was set properly, ''false'' otherwise.
* ''true'' if the scale was set properly.
* ''false'' otherwise.


==Example==
==Example==

Revision as of 22:51, 4 October 2014

This function changes the visible size of an object.

[[{{{image}}}|link=|]] 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

bool setObjectScale ( object theObject, float scale [, float scaleY, float scaleZ ] )

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(getLocalPlayer())
-- create the object
antenna = createObject (1595, x + 2, y, z )
if ( antenna ) then -- if it was created
	-- set the scale to half the normal scale
	setObjectScale ( antenna, 0.5)
	-- remove the collision
        setElementCollisionsEnabled (antenna, false)
end

See Also