Hello Ask Gamers!
Welcome to part two of our tutorial series on Construct3.
If you’re new to the series, we’re building a action-platformer, step by step in Construct3,
without using any code!
In part one we talked about planning, and worked on basic movement, and shooting.
You can check out part 1 here.
Are you ready to take things to the next level?
In today’s video we are going to introduce variables, add a target, and give Super Teal
Robot a new weapon!
We are Ask Gamedev aka The Devenant, aka The Gurus of Game Engines, aka The DirectX-pendables
and this is How To Make a Game in Construct3: Super Teal Robot.
Part 2
Welcome back!
If you’re new to Ask Gamedev, we make videos to help you learn about the games industry
so that you can elevate your games and Inspire others.
If you’re on a gamedev journey, consider subscribing as our community works together
through videos and comments to share insights and best practices that will help your game
development.
Let’s recap!
In part 1 of this tutorial we established the workflow that we’ll be following:
* Step 1: Create your objectives * Step 2: Create your asset list.
* Step 3: Figure out the logic.
Once we had everything figured out on paper, we fired up Construct3, created a new project,
imported our assets, and gave Super Teal Robot the ability to walk, and shoot.
We looked at the sprite editor, adding animations, and adding image points.
We added behaviours to objects.
And we also created events in the event sheet.
At the end of the video, we asked you for feature suggestions for future tutorials,
and the response was amazing.
We had so many great suggestions like the ability to crouch, to roll, and to double-jump.
We also had great powerup and weapon suggestions like a jetpack, and a flamethrower.
We’re putting them all on the ideas and to-do list - so keep them coming!
Today though, we’ll be adding a feature suggested by JAIME Vildosola, a grenade launcher!
Thanks Jaime!
Before we dive back into Construct3 though, don’t forget the ASK Rule!
Always Start Knowing!
Know what you’re going to make before you start trying to make it.
To this, we need our objectives.
Thanks to the Ask Gamedev community, we know our first objective:
Objective 1.
Give Super Teal Robot a grenade launcher!
Now let’s think about this.
We’re giving Super Teal Robot a second weapon.
Think about the player.
How is the player supposed to select that weapon?
That leads us to:
Objective 2: Give the player the ability to switch weapons.
And finally, with a new cool weapon to try out, shouldn’t we give the player something
to shoot at?
Objective 3 will be give Super Teal Robot a target to shoot at.
Now that we know our objectives, let’s go over the assets for each.
Objective 1: Give Super Teal Robot a grenade launcher.
For this we’ll keep his arm cannon, so we don’t need an actual grenade launcher, just
grenade launcher ammo.
What does it look like when the grenade explodes?
We’ll also need an explosion animation.
In terms of a shoot animation, we can use what we already have, so there’s no need
for a new one.
Objective 2: Give the player the ability to switch weapons.
What will we need for this?
Well we’ll need a way to signal to the player that they’ve indeed switched weapons.
There are a lot creative ways to do this, but for this tutorial we’ll keep it as simple
as possible.
We’ll add icons to the top of the screen that represent each weapon, and will highlight
the weapon that is currently equipped.
For this we’ll need 4 icons.
We have 2 weapons, and we’ll need 2 icons for each: One in an on position, and one in
an off position.
Objective 3: Give Super Teal Robot a target to shoot at.
For this we’ll just need a dummy.
Alright we know what we want to accomplish, and the assets that we have to create or source.
Let’s go over the final step of pre-production and figure what our behaviours and events
will be.
For Objective 1, giving super Teal Robot a grenade launcher, there are a few.
* When the player presses shoot, we need to have Super Teal Robot shoot a grenade.
* When the grenade launches, we needed it act like a grenade.
This means it needs to bounce.
* And finally, we need it to explode after a few seconds.
Objective 2, give the player the ability to switch weapons, is a little more complicated.
For this, we’ll be introducing global variables, but we’ll get to that in engine.
For now we know we have to make a few things possible:
* The player needs to be able to change their weapon to the grenade launcher
* The player also needs to be able to change their weapon back to the default.
* And we need to be able to indicate to the player which weapon is currently equipped.
And finally for Objective 3, we need the dummy to be able to react to both the standard bullet,
and the grenade.
Alright we have our objectives, our assets, and our events.
With that, fire up the project, and let’s begin!
Let’s recap Objective 1 - Give Super Teal Robot a grenade launcher.
Assets needed: Ammo, and an explosion animation Events: Super Teal Robot needs to shoot a
grenade when told to, the grenade needs to bounce around, and after a while the grenade
needs to explode.
Let’s bring our assets in.
Import the grenade asset.
Import frame 1 of the explosion.
Open the sprite editor for the explosion, and import the rest of the frames.
Tweak the timing as you like, just make sure the animation does not loop.
Now that we have the assets imported, let’s add our events.
We need Super Teal Robot to shoot when the player presses the shoot button.
Luckily we already created a similar event in tutorial one.
Copy and paste the previous bullet spawn event.
For now disable the old event.
We’ll get back to that during objective two.
Open the event that you just created, and change the bullet to the grenade.
Test it out.
It’s not really doing what we want… we still need it to bounce around, and eventually
to explode.
The first thing we need to do is assign a physics behaviour to the grenade, so that
it can bounce around like one.
You can play around with the settings, but we chose a density of 6.2, a friction setting
of 0.1, and an elasticity setting of 0.6.
Because it’ll bounce on the floor, we need to give the floor a physics behaviour as well
- and we’ll also check the “immovable box” so it doesn’t fall off the screen.
We’re almost there.
Let’s add one more action to the shoot event.
We want the grenade to lob upwards, so let's apply a physics force of 1000, at and angle
of 300.
Test it out.
It’s looking good!
Now for the final event of this objective: after a few seconds the grenade needs to explode.
Let’s add an event.
The condition will be on the creation of a grenade.
For the actions, we have 5.
We got a little creative with this - feel free to go as simple or as complicated as
you’d like.
Here’s what we did: 1.
Wait 2.5 seconds 2.
Apply a physics force to the grenade of 2000, at angle 270
3.
Wait 0.3 seconds 4.
Spawn the explosion object 5.
Destroy the grenade We also have another event that destroys the
explosion object after 1 animation cycle.
After the grenade is shot, it should bounce around for 2.5 seconds, then shoot straight
up, and explode shortly after.
Test it out!
Now to objective 2.
Let’s recap.
We want the player to be able to switch weapons.
In terms of assets we’ll need 2 icons for each weapon.
And for events, we need the player to be able to press a button to pick a specific weapon,
and we also need to be able to indicate to the player which weapon is currently equipped.
This one is a fun one because we get introduce a new concept: Global Variables!
What is a global variable?
A global variable is a variable that can be called and also affected by any event.
In Construct3, you can use global variables in your conditions as well your actions.
Global variables can be used for a number things like keeping track of the number of
lives a player has, or how many points or xp a player has.
For this objective, we are using a global variable to keep track of which weapon the
player has equipped.
Let’s create one.
Head over to the event sheet.
Right-click and click “add global variable”.
Call it “WeaponSelect” and make the initial value “1”.
Now let’s give the player the ability to change this variable.
Create a new event.
Select the keyboard, and select “on key pressed”.
For the key, let’s use “2”.
Now for the action, select System, then select “Set Value” under the “Global & local
variables” section.
For the variable select “WeaponSelect”, and enter “2” as the value.
Click done.
This means that when the player presses “2” on the keyboard, the global variable that
we just created “WeaponSelect” will change it’s value from 1 to 2.
We need the player to be able to change the value back to 1, so just repeat the process,
but with the “1” key, and a value of “1”.
Now the player has the ability to change the WeaponSelect variable to “1” or “2”
whenever they please, simply by pressing the “1” or “2” key.
Please note: that we could have used any keys instead of “1” and “2”.
We could have used “q” and “w” or even “8” and “9”.
We just chose “1” and “2” to keep it simple.
So now the player has the ability to change a global variable, but while that’s pretty
cool, it doesn’t really have an effect in the game until we add more logic.
The weapons aren’t actually changing, and the player doesn’t even see anything when
they press the buttons.
Let’s fix that.
First let’s give the player some visual feedback.
For this we’ll need the weapon icons.
Import the grenade tile, and the regular weapon tile.
Place them in the top corner of the screen.
We have to add a “selected” state for each now.
Double-click the regular bullet icon to open it’s sprite editor.
Create a new animation, call it “Selected”, and add the selected frame.
Repeat the process for the grenade tile.
Now let’s tie each state to the global variable “WeaponSelect”.
Create an event.
Click system, and click “Compare variable”.
For the variable use “WeaponSelect”, for the comparisons select “Equal to”, and
for the value enter 1.
This means the system will check if the “WeaponSelect” variable is set to 1, and if so, it will do
what we ask.
In this case, the “ask” is that we want the tile to set it’s animation to “Selected”.
Obviously if the variable isn’t at 1, we don’t want the “Selected” state to run.
Therefore we need an else statement.
Right click on the event, and click “Add”, then click “Add else”.
For the action, we want to set the tile to its default state.
Repeat the same same process for the grenade tile, only this time check for the “WeaponSelect”
variable value of 2.
Test it out.
Press 1 and 2, you’ll see the tiles toggle their on and off positions.
The last part is tying the variable to the actual ammo that Super Teal Robot shoots.
Remember that event that we disabled during objective 1?
Turn it on again and let’s add some conditions.
All we have to do for each shoot event is add a condition, and that condition will be,
you guessed it, checking the WeaponSelect variable value.
Right-click on the condition of the regular bullet firing event, and click “Add” then
click “Add Another Condition”.
Click “System”, then click “Compare variable”.
For the variable enter “Weapon select”, for the comparison select “equal to”,
and for the value enter “1”.
Do the same for the grenade event, but use “2” for the value.
Test it out.
It works!
Alright, now that he shoots, let’s build objective 3 - give Super Teal Robot a target.
For assets we just need the dummy.
And for interaction, we just need the bullet and grenade to affect the dummy.
First thing’s first.
Import the dummy - size to your liking, and make sure his collision box is right near
the target.
Give the dummy a physical attribute, because it would be cool to see the grenades push
the dummy.
Also give him a flash attribute, so that we can indicate when he’s been shot.
Now we just have to add 2 events.
Create an event where the condition is the bullet colliding with the dummy.
On impact destroy the bullet, and then make the dummy flash a few times.
Do the same for the grenade.
Only it won’t be the actual grenade that sets off the action, it will be the explosion
of the grenade.
Test it out!
There you have - we have given Super Teal Robot a new weapon, the ability to change
weapons, and a little dummy to play around with!
We hope you learned a thing or two this week!
What do you want to learn about in part 3?
What features, powerups, or weapons would like you like to see?
Let us know in the comments, and we’ll implement them in future tutorials!
If you’d like to check out more engines that don’t require coding, check out a recent
video we did on that topic, here.
Thanks for watching we are Ask Gamedev and we make videos on game development, the game
industry, and more!
If you like our channel, the best thing you can do to help is to upvote the video or leave
a comment.
We publish new content every week on how to elevate your games so consider subscribing
and hit the bell below to be notified as soon as a new video is available.