gamemaker studio

// Step 1: Declare a variable to hold the instance ID of an object
int objID;

// Step 2: Check if the instance exists using instance_exists() function
if (instance_exists(obj_enemy)) {
    // Step 3: Assign the instance ID of the object to the variable
    objID = instance_find(obj_enemy, 0);

    // Step 4: Check if the instance ID is valid
    if (objID != noone) {
        // Step 5: Perform actions using the valid instance ID
        // For example, destroy the object
        instance_destroy(objID);
    }
}

This code in C++ with GameMaker Studio checks for the existence of an object of type obj_enemy. If it exists, it retrieves its instance ID and performs an action with it, such as destroying the object.