BulletTime: Charge Shot

  • 44 favourites


3,278 visits, 4,679 views



This tutorial hasn't been translated.


This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Let's add some variety in our shooting. I mentioned in the another tutorial that a charge shot can do the trick. It can help change the timing, speed and accuracy of shots making the game more challenging.

If you aren't already familiar on how to set up a shooting arrangement I suggest taking a look at the Straight Shot tutorial first.

Picking up from the Straight Shot, we'll start by changing the shooting conditions.

The first thing to notice is the global variable. "charge_shot" is created to equal 0. The second thing to notice is that the mouse condition has been set to when Left button is down instead of clicked. This allows a separation between when the button is pressed and when it is released. So, right now the "charge_shot" variable changes to 1 when the Left mouse button is pressed down.

Next we will set the actions for what happens when "charge_shot" equals 1.

These conditions state that when "charge_shot" is equal to 1 the system will trigger these actions once. It is important to trigger it only once otherwise it will complete the actions every tick as long as the variable is 1. Also, this condition is a sub-event of the one above it meaning it only works when the above condition is true.

The actions we want to trigger are to create a Bullet sprite at the barrel of the Gun and set its bullet speed to zero. The Bullet shouldn't move until we release the mouse button.

Now we set the conditions for when the mouse button is released. The "charge_shot" variable changes back to 0, when this happens the Bullet will be set to the same as angle of the Gun and the speed will be set to 20 times the height of the Bullet. (There is a reason why the speed is set this way. Just wait.)

Notice that the conditions are a little different. This event only triggers once AND only when the speed of the Bullet is 0. If the Bullet speed condition wasn't there these actions would apply to EVERY Bullet sprite, even the one's you've already shot! (If you want to you can disable that condition and see what happens for yourself.)

We're not quite done yet, so don't go testing it just yet.

Let's go back to the first condition when the mouse button is down.

This is another sub-event for line 2, when the Left mouse button is down and "charge_shot" is 1. What is happening here is that when the Bullet speed is 0, the Bullet will be positioned at the Gun image point AND the Bullet size will change by adding 0.5 to its own width and height.

Now, go ahead and test it. What it is doing is while the Left mouse button is down a Bullet is created, its speed set to zero, its position set to the tip of the Gun, and it grows! Once the button is released the Bullet sets its angle to the angle of the Gun so that it shoots in the right direction. It also travels at a speed proportional to its size. The more you charge it the faster it goes.

Bonus tip

One final thing we can add here is a limitation on how much the shot can charge. This can be done by splitting off the size changing action into another sub-event.

Now the Bullet only grows in size as long as its height is less than 50. If you test it out again, the shot can't charge forever and stops at a maximum.

Various Ways to Use: Beginner

Extra damage

What better way to use a charging shot, but as a charging shot. Just like how the speed is set to 20 times the size, the level of damage the shot does can be a multiple of the size too. This way there is a benefit to charging a shot before firing.

Arched charge shot

Just like with the simple Straight Shot, the bullet behavior of the Bullet sprite can be changed pretty easily. Just by altering the gravity the shot can be made to arch. Now shooting a basketball can have variable strengths, or it could be a mortar, or grenade, or football, etc.

Various Ways to Use: Advanced

Variable changes

Instead of having the size of the sprite change when you are charging the shot, a variable can change instead. This gives you more control over what the shot looks like and how it can behave.

For example, the variable can be connected to different states of animation. It could also be connected to the strength of gravity. The variable could also be linked to a separate charging animation to show how much has been charged. Or you can do them all!

Different shots, different behaviors

Here we only have one type of shot. Add more. Give them all different behaviors and then you'll have a whole range of weapons to choose from.

Precision charging

Something else that could be done is placing restrictions on the charging aspect. If charged too much it may overheat, for instance, and the shot stops working. The charging could also bounce back and forth making timing of the release more important.


  • Order by
Want to leave a comment? Login or Register an account!