GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2009-04-30 18:36:31

slayer64
Member
Registered: 2009-04-30
Posts: 3

place meeting for 3d

this is the same thing as instance_place, but works in 3d.
plz critique it all over.

//
//    Usage:
//        i=d3d_instance_place(x,y,z,par_solid);
//
//  Arguments:
//      x
//      y
//      z
//      obj
//
//  Returns:
//      the id of the instance of type obj met when
//      the current instance is placed at position (x,y,z).
//      obj can be an object or the keyword all. If it
//      does not exist, the special object noone is returned.
//
//  slayer 64
//

var nn;

while(1)
{
    nn=instance_place(argument0,argument1,argument3);
    if nn=noone
    {
        break;
    }
   
    if argument2+height-1>nn.z
    if argument2<nn.z+nn.height-1
    {
        break;
    }
   
    nn.x+=room_width;
    ds_list_add(global.list,nn);
}

repeat(ds_list_size(global.list))
{
    with(ds_list_find_value(global.list,0))
    {
        x-=room_width;
        ds_list_delete(global.list,0);
    }
}

return nn;

Last edited by slayer64 (2009-07-02 20:35:25)

Offline

#2 2009-05-19 20:39:41

blopit
Member
Registered: 2009-05-19
Posts: 7

Re: place meeting for 3d

Sorry, but I believe this one wouldn't work properly if there is more than one object at  "argument0,argument1" .  I think instance_place_list(x,y,obj) could be used to your scripts benefit to check which solid's "zz+height" is closer to the player's zz. Just a suggestion.

Offline

#3 2009-05-20 01:59:51

xot
Administrator
Registered: 2007-08-18
Posts: 1,240

Re: place meeting for 3d

This is useful, but it shouldn't be called place_meeting_3d or anything resembling place_meeting, rather it should named after instance_place, upon which it appears to be modeled; place_meeting returns true or false, not an instance id.

Not sure the description is correct. Doesn't this find any instance, not just solid ones?

Sorry, but I believe this one wouldn't work properly if there is more than one object at  "argument0,argument1"

I think it would work exactly the same as the other collision check functions, returning the id of the first (and not necessarily closest) instance found, if any. That said, another version that can return a list of instances, maybe even sorted by distance, would also be welcome.


Abusing forum power since 1986.

Offline

#4 2009-07-02 20:38:01

slayer64
Member
Registered: 2009-04-30
Posts: 3

Re: place meeting for 3d

BUMP!
i re-made the function. i couldn't re-name the topic name.
plz try to improve it.

Offline

Board footer

Powered by FluxBB