Jump to content


Photo

if place_meeting() - getting id of the 'met' obj.


  • Please log in to reply
5 replies to this topic

#1 arirish

arirish

    GMC Member

  • GMC Member
  • 1283 posts
  • Version:GM:Studio

Posted 01 September 2011 - 08:26 PM

I feel like this is something really easy and obvious (I actually feel like it's something I've done before), but I can't for the life of me think it out.

In the Step event I have:

                    if place_meeting(x,y,o_block1) 
                        {with(other) {instance_destroy()}}

which, of course, doesn't work, because 'other' isn't referencing anything. I need the 'met' o_block1 to be destroyed. I can't move this to the collision event. Someone put me out of my misery, please?
  • 0

GM:Studio


#2 Sinaz

Sinaz

    MCP Killer

  • GMC Elder
  • 2751 posts
  • Version:GM8

Posted 01 September 2011 - 08:35 PM

Instance_place() seems to do the same thing as place_meeting() but with the refinement of returning the ID of the instance met.
  • 0
S I N A Z

That's SINAZ... He fights for the Users.

I am retired from providing GML Mentorship, but I am available to answer questions about career and educational goals & strategies to members who are interested in pursuing game development as a life long profession. Just PM me!

Please please please: pin a shortcut or link to the GM manual to your Start Menu. Open it up whenever you are offering advice on functions you are not 100% familiar with and refer to it before committing your post.

#3 arirish

arirish

    GMC Member

  • GMC Member
  • 1283 posts
  • Version:GM:Studio

Posted 01 September 2011 - 08:53 PM

Instance_place() seems to do the same thing as place_meeting() but with the refinement of returning the ID of the instance met.

GM is always turning up surprises for me. That handy little function will smarten up a ton of my code. Thanks for pointing it out!
  • 0

GM:Studio


#4 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 24501 posts
  • Version:GM:Studio

Posted 01 September 2011 - 09:00 PM

On a side note (since Sinaz has already answered your question) you may find this tutorial by Torigara of interest..

http://gmc.yoyogames...howtopic=481823
  • 0

lz6lxdC.pngd7ZQQ3F.gifFlvJzyf.png

40799.png


#5 arirish

arirish

    GMC Member

  • GMC Member
  • 1283 posts
  • Version:GM:Studio

Posted 01 September 2011 - 09:03 PM

On a side note (since Sinaz has already answered your question) you may find this tutorial by Torigara of interest..

http://gmc.yoyogames...howtopic=481823


Thanks, that's a handy link! I'm more or less familiar with the nuances of each, but the instance_ functions are new to me. Then again, I come back to GM every couple of years, and have to relearn from scratch each time!
  • 0

GM:Studio


#6 DamnICantFly

DamnICantFly

    GMC Member

  • GMC Member
  • 16 posts
  • Version:Unknown

Posted 27 April 2012 - 11:02 AM


On a side note (since Sinaz has already answered your question) you may find this tutorial by Torigara of interest..

http://gmc.yoyogames...howtopic=481823


Thanks, that's a handy link! I'm more or less familiar with the nuances of each, but the instance_ functions are new to me. Then again, I come back to GM every couple of years, and have to relearn from scratch each time!


I'm using this code in my sort of Tetris idea atm:
if place_meeting(x,y+2,Block_Green)
        {
            instance_destroy()
            position_destroy(x,y+32)
        }
At this way, it will check or there is a green block 2 below the block where I program it in
if place_meeting(x,y+2,Block_Green)
Then if there is, it will destroy itself
instance_destroy()
And then it will destroy anything that is 32 below the block
position_destroy(x,y+32)

This is a bit a different code then the rest of the replys, so I thought, maybe this can come in handy for some people.

Edited by DamnICantFly, 27 April 2012 - 11:03 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users