Skip to content
This repository was archived by the owner on Jul 30, 2023. It is now read-only.

'CreateObject' function (EN)

Archie edited this page May 23, 2021 · 1 revision

CreateObject function

Creates an in-game object on user-specified coordinates.

Syntax

<RValue> CreateObject(
    <string> ObjectName,
    <real> XCoord,
    <real> YCoord
);

Parameters

ObjectName

Type: String

The name of the object. Examples: obj_mysteryman, obj_gasterblaster.

XCoord

Type: Real Number

The X position (horizontal) of the created object.

YCoord

Type: Real Number

The Y position (vertical) of the created object.

Return Value

Type: RValue

The instance ID of the created object.

You can use this ID with GameMaker functions like instance_destroy.

Example

local id = CreateObject("obj_savepoint", 340, 230); -- Create an obj_savepoint at { 340, 230 }, and save the instance ID in the "id" variable
print(id.realval); -- Print the real value of the "id" RValue. This is the created instance ID.

Clone this wiki locally