Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am making a small puzzle based game. I want the number of instances of an object to be equal to the ammo count plus 2.

Each time a new room is loaded, the main object's creation method with run this script:

var ammo = instance_count(jellyfish)+2;

Then each time a bullet is fired, I subtract one. When there is no ammo left, the player goes to the 'failure' room.

However, I get the error: Unknown function or script: instance_count.

I have see this script on Google, but am not sure if it has deprecated or not. Is there a way I can do this?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The function you want is instance_number(obj) (documentation found here).

This functions returns the number of instances of a object that exist in the current room.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.