Skip to main content

SimuloObject

All objects in a Simulo scene, such as boxes, circles, polygons, etc, are known to the API as SimuloObjects.

A SimuloObject reference is typically obtained by:

  • Getting it with Scene:get_object_by_guid
  • Getting it with Scene:get_all_objects
  • Using self in a Component script

Fields

FieldDescriptionNoteType
guidThe guid of the objectnumber
colorThe color of the object, like 0xff0000 for rednumber
nameThe name of the objectstring

Functions

note

Make sure to use object:function() and not object.function(), or you'll get an error


:destroy()

Destroys the object. This will call any on_destroy functions of components on the object.

Example

object:destroy();

:get_position()

Returns the position of the object as a Vec2.

Example

local pos = object:get_position();

:set_position(...)

Sets the position of the object to a Vec2.

Example

object:set_position(vec2(1, 1));

:get_angle()

Gets the angle of the object as a number. Measured in radians.

Example

local angle = object:get_angle();

:set_angle(...)

Sets the angle of the object to a number. Measured in radians.

Example

object:set_angle(math.pi); -- 180 degrees is pi radians

:get_linear_velocity()

Returns the linear velocity of the object as a Vec2. Measured in meters per second.

Example

local linvel = object:get_linear_velocity();

:set_linear_velocity(...)

Sets the linear velocity of the object to a Vec2. Measured in meters per second.

Note that this will not behave realistically. You may want to use :apply_force_to_center instead.

Example

object:set_linear_velocity(vec2(1, 1));

:get_angular_velocity()

Gets the angular velocity of the object as a number. Measured in radians per second.

Example

local angle = object:get_angle();

:set_angular_velocity(...)

Sets the angular velocity of the object to a number. Measured in radians per second.

Example

object:set_angular_velocity(0.174533); -- 10 degrees per second

:apply_force_to_center(...)

Applies a world force Vec2 to the center of the object. Measured in newtons (N).

Example

object:apply_force_to_center(vec2(0, 500));

:add_component(...)

Adds a component of a Component Hash to the object.

Example

local hash = Scene:add_component(...); -- see component docs

object:add_component(hash);