3D instance_create_ext

phillipPbor

Member
i was trouble with finding the script for the instance_create

not the instance_create(x,y,obj)

you see I was trying to create my oun instance_create_ext(x,y,z,obj)
because I having trouble create object in game, I notice there was no z axes function in this.

so I went on a quest to find a formula for the instance_create function. no avail.

this code is new to me actually.


this is the example someone made it.
Code:
///place_meeting_ext(x,y,z, obj)

var _xx  = argument0;
var _yy  = argument1;
var _zz  = argument2;
var _obj = argument3;


//note:  xmin,xmax,ymin,ymax defined in obj_player, and in obj_star, and obj_gems, and obj_gemsviolet, and par_solid
var _x0 = _xx + xmin;
var _x1 = _xx + xmax;
var _y0 = _yy + ymin;
var _y1 = _yy + ymax;

var _z0 = _zz;
var _z1 = _z0 + height;
with (_obj) {
    var _x01 = x + xmin;
    var _x11 = x + xmax;
    var _y01 = y + ymin;
    var _y11 = y + ymax;   
    var _z01 = z;
    var _z11 = z + height;
    if (_x0 <= _x11) and (_x1 >= _x01)
    and(_y0 <= _y11) and (_y1 >= _y01)
    and (_z0 <= _z11) and (_z1 >= _z01) {
        return true;
    }
}
return false;
this is for the collision on the 3d brick
 
...I don't understand the issue. You want a simple instance_create() that also accounts for the z axis? Then create a script which creates an instance and then feeds it whatever z value you have as an argument.
 

phillipPbor

Member
...I don't understand the issue. You want a simple instance_create() that also accounts for the z axis? Then create a script which creates an instance and then feeds it whatever z value you have as an argument.
is there a tutorial about that?

its hard to understand code.
 

Evanski

Raccoon Lord
Forum Staff
Moderator
Code:
/// @desc create an instance with x,y,z,depth
/// @param Instance_ID
/// @param X
/// @param Y
/// @param Z
/// @param Depth


var _instance = argument0;
var _x = argument1;
var _y  = argument2;
var _z = argument3;
var _depth = argument4;
 
is there a tutorial about that?

its hard to understand code.
It's not too difficult. instance_create returns the id of the created instance. Assign a local variable to that and then assign a z variable.
Code:
///instance_create_ext(x, y, z, obj)
var _obj = instance_create(argument0, argument1, argument3);
_obj.z = argument2;
return _obj; // In case you need to pass id
Please note this only works in GMS versions pre-GMS2. I assume you're using GMS1 because you keep mentioning instance_create as opposed to instance_create_layer or instance_create_depth.
 
Last edited:

phillipPbor

Member
It's not too difficult. instance_create returns the id of the created instance. Assign a local variable to that and then assign a z variable.
Code:
///instance_create_ext(x, y, z, obj)
var _obj = instance_create(argument0, argument1, argument3);
_obj.z = argument2;
return _obj; // In case you need to pass id
Please note this only works in GMS versions pre-GMS2. I assume you're using GMS1 because you keep mentioning instance_create as opposed to instance_create_layer or instance_create_depth.
thank you
 
Top