• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Michael Santer
      Hi!
      We're currently two programmers and a game designer working on a turn-based tactics fantasy board game. For reference you can search for images of "Tactics Arena Online", a fairly dated game that used to have a lot of depth and complexity.
      Our goal is to use the same combat concepts, but giving it a much needed modern touch as well as a whole new set of heroes to choose from with additional abilities. The game is a mix of isometric and 3D and we plan to release the game on Steam and hopefully Android & iOS as well.
      We are looking for someone to work with us pro-bono (just like we're doing) as a 3D character artist. The skills needed are creativity, a hard working attitude and an ability to make minor animations (things like idle, walk, block and very rudimentary attack animations). A perk to have would be the ability to make some VFX. If the game makes it on steam and money starts coming in, you'd obviously be compensated for your hard work, but as it stands this is a hobby project to garnish your portfolio.
      A bit more about the game:
      This game will be an online multiplayer game where each user gets to pick up to 10 characters to place on his half of the board (this would be done before even entering matchmaking. Think runes in League of Legends for example). The user can place his 10 units of choice anywhere he likes on his half board. Some units can be used more than once. So if you want 4 knights and 2 mages or even if you want 10 clerics, you can do as you please. You can then save your setups for future use. The goal of the game is to wipe out the enemy team.
      Each character or Hero (except premium and abyss characters) start with 1 ability and they can ascend (either by playing a certain amount of matches with the character or by forcing the ascension with real money) to gain a new ability or passive. Acquiring a new character can be done by using in-game currency that you earn from playing matches or using real money with the exception of Abyss characters which can only be acquired by winning certain rare matches. The goal is to offer a freemium game with lots of customizable elements while making sure that no user can "buy power" with real money. We want everything that a paying user can get to be available to non-paying users who play the game a lot.
      Ultimately we want this to become a competitive game that people can enjoy and really get invested in. Each character is designed with options for counterplay in mind and synergy with other heroes.
       
      We sincerely believe in what this game can become and we home to find someone just as passionate as we are to get involved in this project!
    • By CrazyApplesStudio
         Hello , i would like to showcase my first game project, a simple endless casual arcade game called Apples Mania : Apple Catcher. The game has simple goal , scoring as high as possible by collecting falling apples while the difficulty gradually increases. Different apples are worth different amount of points and there are also 2 power-ups to help you in your challenge.
        The game took me about 2 months to complete and polish and i made everything except for the music tracks and some of the sound files. Made in unity and blender3d.
        Would appreciate any kind of feedback.
      Google Play Link
       
        A trailer showing basic game-play:
       
    • By Paszq
      Troglodytes are a playable races in Arpago - they usually don't talk much and most of them lives near water sources.
    • By Paszq
      a Fox in a dungeon :)
    • By Paszq
      Fox Folk is one of 3 playable races in Arpago.
  • Advertisement
  • Advertisement
Sign in to follow this  

Unity Can't get enemy shoot at a certain point in game maker studio

This topic is 693 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I have been making a simple game and I have a problem about my enemy not shooting when the event triggers. I tried doing the following.

 

Create event for enemy object

 

hspeed = 4;

counter = 20;

 

Step event for enemy object

if counter = 0;

{

instance_create(x,y,obj_bullet);

}

 

I want it so that when the counter reaches 0, the bullet is suppose to fire from the enemy and this has to be looped over again. I can do this for alarms but I'm not able to figure out how to set alarms in the step event and the problem with alarms is that I don't know how to reset them when triggered. Basically, I want the enemy to repeat the procedure over and over again and after a certain point, it loops another action over and over again and so on. Bullet is working fine so I got no problem there....its looping the event that I'm struggling.

 

I could ask this in the game maker Studio community but the forums are now gone and I don't know how else I can get to the game maker community. If anyone knows, please let me know.

Edited by Cap'n VG

Share this post


Link to post
Share on other sites
Advertisement

Hi :)

 

In your step event, simply decrement your counter variable. Something like:

counter--;
or
counter -= 1;

So, counter will go from 20 to 0. When it hits 0 (in your conditional statement), you should both create the bullet and reset counter to 20.

Share this post


Link to post
Share on other sites

Fixed the problem! Thanks!  :)

 

So I got a question. Do I need to make multiple variables inorder for specific events to happen in the step event or is it possible to do many sequences in just one variable? like is it possible for another bullet to appear after 15 steps alongside the one for 20 steps using just one variable?

Edited by Cap'n VG

Share this post


Link to post
Share on other sites

As long as you are indeed decreasing the variable each step, there is nothing stopping you from doing an if statement..

if(counter == 15)
{
    //do something
}
if(counter == 10)
{
    /do something else
}
if(counter == 0)
{
    counter = 20;
}
counter--;

 

Also, there is nothing stopping you from using the alarm event to do things.  You would then save having the code in your step event(though for performance it is really irrelevant since the code is happening in GMC's runner anyway).  As part of the alarm responding event, you reset the alarm using "alarm[0] = 20" and then it will count down again.  You could also do it in the D&D blocks, but it is quicker to just add the line of code there.

 

And yes, I understand the pain of the GMC forum no longer being available.  I have been a member for years having done plenty of hobby stuff in GMStudio.  I use Unity now though, so I probably won't be signing up for the new forum when it gets set up.

Share this post


Link to post
Share on other sites

As long as you are indeed decreasing the variable each step, there is nothing stopping you from doing an if statement..

if(counter == 15)
{
    //do something
}
if(counter == 10)
{
    /do something else
}
if(counter == 0)
{
    counter = 20;
}
counter--;

Also, there is nothing stopping you from using the alarm event to do things.  You would then save having the code in your step event(though for performance it is really irrelevant since the code is happening in GMC's runner anyway).  As part of the alarm responding event, you reset the alarm using "alarm[0] = 20" and then it will count down again.  You could also do it in the D&D blocks, but it is quicker to just add the line of code there.

 

And yes, I understand the pain of the GMC forum no longer being available.  I have been a member for years having done plenty of hobby stuff in GMStudio.  I use Unity now though, so I probably won't be signing up for the new forum when it gets set up.

 

Ok now here's what I want to do.

 

You know how arcade games tend to go faster to increase the difficulty? Well, that's what I kinda want to do for the object to shoot bullets only for it to shoot them faster periodically. How can I do this? I know that I need the step event but if I do the code from the previous post, it won't make the object go faster but it would just reset the speed and start again. I want it so that the object can shoot bullets to the fastest it can to the point that sharp skills are needed for the player to get the highest score.

 

Also, since the forums are now gone, is it possible that I can send you private messages whenever I have questions regarding game maker? I'm just too fond of game maker and honestly, I like it a lot more than Unity because Unity requires programming a lot and I'm not good at c# or C++ but rather GML code.

Share this post


Link to post
Share on other sites

About difficulty, if you are trying to make the bullets faster, you will need a few variables, and maybe another object.  I would have another object that would be a controller object.  It would store variables for things like the current difficulty, and could also store the current bullet speed if there is only one type.  Then, in the create event of the bullet, you would access the variables in the other object and use that speed instead of just using the default speed.

 

Your controller object would then track whatever you need it to in order to increase difficulty.  If it is a matter of time, then you could have an array(a concept you should learn soon anyway if you don't know it) to hold a group of bullet speeds based on difficulty.  If difficulty is level 1, then access the first value in the array, which would be the lowest speed.  Then if you increase the difficulty number, it accesses the numbers further in the array, which you should have as larger numbers for the bullet speed to be faster.  Now, since you have decided on time as the factor, say after 60 seconds, you use an alarm event(set to 60 times the room speed amount of steps), and increase the difficulty at that point.  You also have to have a check somewhere, say if you have 5 difficulty levels, the speed never goes higher than that.

 

Another option is to use some formula to calculate things.  It takes a bit of math to figure it out, though you can do things simple too.  For example, you could say the bullet speed is simply a formula based on how long the game has gone, with a max of some number.  Say you start with a speed of 2, and want a max of 10, increasing 1 per minute, then somewhere you store in your controller a counter for how many steps have gone, and each time it gets to a minute worth(depending on your room speed), you add one to another variable for minutes.  When you create a bullet, you set it with the speed of 2+(the minute variable).  Somewhere, either the minute variable, or the bullet speed setting, you have to designate the max, unless you expect the player to never get to the point where the speed would be too high for gameplay purposes.

 

As far as contacting me for help, I don't mind.  I check the forums often during the evenings(US Central Time, I'm in North Texas), but I work all day and usually get home around 6-7PM, so if I don't respond right away, that is why.

 

And also, I understand completely you wanting to use GMS over Unity.  I used it for years, not so much because I couldn't use Unity, but because of how quick and easy it is.  Eventually, I got to wanting to work on things that GMS is simply not good at and needed to make the switch, but if I want to make a project that fits GMS I will be glad to use it, the best tool for the purpose.

Share this post


Link to post
Share on other sites

About difficulty, if you are trying to make the bullets faster, you will need a few variables, and maybe another object.  I would have another object that would be a controller object.  It would store variables for things like the current difficulty, and could also store the current bullet speed if there is only one type.  Then, in the create event of the bullet, you would access the variables in the other object and use that speed instead of just using the default speed.

 

Your controller object would then track whatever you need it to in order to increase difficulty.  If it is a matter of time, then you could have an array(a concept you should learn soon anyway if you don't know it) to hold a group of bullet speeds based on difficulty.  If difficulty is level 1, then access the first value in the array, which would be the lowest speed.  Then if you increase the difficulty number, it accesses the numbers further in the array, which you should have as larger numbers for the bullet speed to be faster.  Now, since you have decided on time as the factor, say after 60 seconds, you use an alarm event(set to 60 times the room speed amount of steps), and increase the difficulty at that point.  You also have to have a check somewhere, say if you have 5 difficulty levels, the speed never goes higher than that.

 

Another option is to use some formula to calculate things.  It takes a bit of math to figure it out, though you can do things simple too.  For example, you could say the bullet speed is simply a formula based on how long the game has gone, with a max of some number.  Say you start with a speed of 2, and want a max of 10, increasing 1 per minute, then somewhere you store in your controller a counter for how many steps have gone, and each time it gets to a minute worth(depending on your room speed), you add one to another variable for minutes.  When you create a bullet, you set it with the speed of 2+(the minute variable).  Somewhere, either the minute variable, or the bullet speed setting, you have to designate the max, unless you expect the player to never get to the point where the speed would be too high for gameplay purposes.

 

As far as contacting me for help, I don't mind.  I check the forums often during the evenings(US Central Time, I'm in North Texas), but I work all day and usually get home around 6-7PM, so if I don't respond right away, that is why.

 

And also, I understand completely you wanting to use GMS over Unity.  I used it for years, not so much because I couldn't use Unity, but because of how quick and easy it is.  Eventually, I got to wanting to work on things that GMS is simply not good at and needed to make the switch, but if I want to make a project that fits GMS I will be glad to use it, the best tool for the purpose.

 

So you're saying that I should do something like this?

 

obj_controller

 

Create event

 

array[1] = 20;

array[2] = 30

array[3] = 30

 

step event

array[1]- =1

array[2]- =1

array[3]- =1

 

if array[1] = 0

{

vspeed = 9

}

 

and the same for the other two arrays?

Share this post


Link to post
Share on other sites

Not exactly...if you want the values to "upgrade" at different speeds, then yes, you need more than one variable for the counters(or an array).  But the idea was to just have a single counter variable counting down, and one single variable for the current "level/difficulty" that you increase each time the variable goes down.

 

//create event of objController
speedarray[0] = 2;
speedarray[1] = 3;
speedarray[2] = 4;
speedarray[3] = 6;
counter = 360; //let's say room speed is 60 and you want 6 seconds, so it is 360 steps
difficulty = 0;
//step event of objController
counter--; //or counter = counter - 1  or counter-=1 work too
if(counter == 0)
{
    counter = 360;
    if(difficulty < 3)//3 is the highest I went in my arrays
    {
        difficulty++;
    }
}
//bullet creation event
speed = objController.speedarray[objController.difficulty];
 

 

Note that you can add more array values as well in order to get higher speeds if you want.  Also, pay attention to how I did "objController.speedarray[]".  This assumes you have a single(important that it is only one) objController in the room, and that it is already set up, as in created, which means the create event ran, creating the array variables.  This syntax allows you to access variables that actually belong to the objController object, and you can do this from any other object, which is why it works no matter how many bullets you did.

Share this post


Link to post
Share on other sites

Not exactly...if you want the values to "upgrade" at different speeds, then yes, you need more than one variable for the counters(or an array).  But the idea was to just have a single counter variable counting down, and one single variable for the current "level/difficulty" that you increase each time the variable goes down.

//create event of objController
speedarray[0] = 2;
speedarray[1] = 3;
speedarray[2] = 4;
speedarray[3] = 6;
counter = 360; //let's say room speed is 60 and you want 6 seconds, so it is 360 steps
difficulty = 0;
//step event of objController
counter--; //or counter = counter - 1  or counter-=1 work too
if(counter == 0)
{
    counter = 360;
    if(difficulty < 3)//3 is the highest I went in my arrays
    {
        difficulty++;
    }
}
//bullet creation event
speed = objController.speedarray[objController.difficulty];
 

Note that you can add more array values as well in order to get higher speeds if you want.  Also, pay attention to how I did "objController.speedarray[]".  This assumes you have a single(important that it is only one) objController in the room, and that it is already set up, as in created, which means the create event ran, creating the array variables.  This syntax allows you to access variables that actually belong to the objController object, and you can do this from any other object, which is why it works no matter how many bullets you did.

 

I didn't understand the step event logic there. How is it that you're giving counter == 0 and then giving it 360 if in the create event you already gave it 360?

 

And another thing that I want to request is where do you get tutorials that teach you coding in studio? the tutorials that studio provides don't offer enough of coding and don't follow the codes that you do. I know that Studio is something where coding is more of a thing than drag and drop unlike the other previous versions where I don't know if coding was just as powerful as studio.

Edited by Cap'n VG

Share this post


Link to post
Share on other sites

There is a big difference between '=' and '==' in my code.  I have an IF statement there.  In the create event, I'm giving(assigning) it 360.  In the step event, I'm saying "IF counter is equal to 0, do whats in the {}, so if counter is at 0, it will do the code in the braces, putting counter back at 360 again, and IF difficulty is currently less than 3, it will increase that variable as well.

 

I prefer to use the double equals in the comparison syntax, and in many languages you actually HAVE too.  There was a time in GML where you could use either single or double equals in an IF statement.  I don't know if that ever changed, as they made some changes when they changed things up upon releasing GMStudio, and even if they haven't, it is a good habit to get into, as in the future they are likely to make that change.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement