'CreateObject' function (EN) - Archie-osu/ProjectDELTA GitHub Wiki

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.
⚠️ **GitHub.com Fallback** ⚠️