3D instance_create_ext

Discussion in 'Programming' started by phillipPbor, Jul 5, 2019.

  1. phillipPbor

    phillipPbor Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    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
    [​IMG]
     
    EvanSki likes this.
  2. BattleRifle BR55

    BattleRifle BR55 Member

    Joined:
    Jun 24, 2016
    Posts:
    954
    ...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.
     
  3. phillipPbor

    phillipPbor Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    is there a tutorial about that?

    its hard to understand code.
     
  4. EvanSki

    EvanSki King of Raccoons

    Joined:
    Apr 17, 2018
    Posts:
    520
    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;
     
  5. nacho_chicken

    nacho_chicken Member

    Joined:
    Jun 21, 2016
    Posts:
    330
    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: Jul 5, 2019
    EvanSki likes this.
  6. phillipPbor

    phillipPbor Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    thank you
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice