Jump to content


Photo

How Do I Check If An Object Exists?


  • Please log in to reply
3 replies to this topic

#1 Tapey

Tapey

    GMC Member

  • GMC Member
  • 228 posts

Posted 26 June 2009 - 12:11 PM

I've got a small problem with my game where after the player dies, all enemies start firing at 0,0 in the room. To stop this I was just planning on adding a check in the code for shooting which is basically,

if obj_player exists then
{
//code for shooting//
}
else
{
do nothing
}

I can't figure out what the code for checking if obj_player exists is however, and likewise what I would put as an alternative at the bottom to basically say to do nothing. Any help would be appreciated :skull:

Edited by Tapey, 26 June 2009 - 12:23 PM.

  • 0

#2 MitchGraham

MitchGraham

    GMC Member

  • Banned Users
  • 524 posts

Posted 26 June 2009 - 12:14 PM

Sorry, I can't understand your question. You want to check if instance_exists(object_index)?

:skull:

Edited by MitchGraham, 26 June 2009 - 12:19 PM.


#3 Weird Dragon

Weird Dragon

    GMC Member

  • Global Moderators
  • 1930 posts
  • Version:GM:Studio

Posted 26 June 2009 - 12:16 PM

if instance_exists(obj_player)
  • 0

#4 Tapey

Tapey

    GMC Member

  • GMC Member
  • 228 posts

Posted 26 June 2009 - 12:22 PM

if instance_exists(obj_player)


Thanks!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users