Jump to content


Photo

Question about "var = instance_create();"


Best Answer Floofpaws, 28 March 2016 - 08:21 AM

weakPoint will be a variable belonging to the instance it's in, and will continue to contain the ID of the created instance until it is changed. So you can set it anywhere in the instance and use it anywhere else in the same instance after it's set.

Go to the full post


  • Please log in to reply
2 replies to this topic

#1 lilrony26

lilrony26

    GMC Member

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

Posted 28 March 2016 - 06:54 AM

So I have this boss idea, and one of the requirements to beat him is to open up his weak point. I was thinking about having the boss spawn a hitbox with something like:

if (vulnerable) {
    weakPoint = instance_create(x + (facing * 32), y, oBossWeakPoint);

    // from here, check if the weakpoint is gone (because when the player attacks it, it'll destroy itself)
    if (!instance_exists(weakPoint)) {
        hp--;
        vulnerable = false;
    }
}

I can't have it work so that it directly collides with the player attack, because my organization of the game and my progress will prohibit that. My question is that, will I be able to specifically check if the weakPoint that the boss created exists? instance_create() from what I'm guessing only applies to the create event of the object, so does that mean it won't work unless you were to hit it on the very frame? Sorry if this makes no sense, I can clarify if needed.

 

Thanks!


  • 0

8vXeNrn.gif

 

WIP. Coming soon hopefully.


#2 Floofpaws

Floofpaws

    Fox

  • GMC Member
  • 2161 posts
  • Version:Unknown

Posted 28 March 2016 - 08:21 AM   Best Answer

weakPoint will be a variable belonging to the instance it's in, and will continue to contain the ID of the created instance until it is changed. So you can set it anywhere in the instance and use it anywhere else in the same instance after it's set.


Edited by Floofpaws, 28 March 2016 - 08:22 AM.

  • 0

#3 lilrony26

lilrony26

    GMC Member

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

Posted 29 March 2016 - 01:03 AM

weakPoint will be a variable belonging to the instance it's in, and will continue to contain the ID of the created instance until it is changed. So you can set it anywhere in the instance and use it anywhere else in the same instance after it's set.

Thank you, makes sense now.


  • 0

8vXeNrn.gif

 

WIP. Coming soon hopefully.