GameMaker Studio 2: Complete Platformer Tutorial (Part 3: Shooting & Recoil)
HTML-код
- Опубликовано: 7 фев 2025
- ▶ Source code: shaunjs.itch.i...
▶ Part 1: • GameMaker Studio 2: Co...
▶ Support my work: / shaunjs
▶ Assets www.shaunspaldi...
New parts to this series released every other Friday.
the satisfaction of figuring out something before Shaun says it :)
Yeah
I did that with the random_range formula for the bullet angles and it was sooo satisfying haha
Guessing how a code works feels like:
ruclips.net/video/i9ncrR6uItU/видео.html
@@zFrost fr
yes
I'm a (retired) IT teacher with a reasonable knowledge of a number of HLLs. I just want to say that after looking at all sorts of tutorials, books etc. your material is far and away the best I've come across. If I were still teaching, I'd be contacting you about using your videos in the classroom! Thanks.
Bro my shooting is slower than this tutorial i also put image speed= 25 but mine is slower than his
@@RickyTheRoster There's no point in commenting that on this guy's comment
@@RickyTheRoster then increase the image speed
@@RickyTheRoster depends on your models and version of GameMaker.
@@RickyTheRoster just in begin step of oGun change the number of firingdelay on 3
OK, so, This tutorial is helping me sooooo much, you won't even believe it
I started 2 days ago and now I have a dungeon with enemies, bullets and guns and all the other stuff, thank you soo much
You are a great tutor
Ik this is old but can you post a video of the gameplay? (Also put a download lol xd)
When i shoot nothing happens this is the script i wrote can someone help me?
x = oPlayer.x;
y = oPlayer.y+10;
image_angle = point_direction(x,y,mouse_x,mouse_y);
firingdelay = firingdelay - 1;
if (mouse_check_button(mb_left)) and (firingdelay < 0)
{
firingdelay = 5;
with (instance_create_layer(x,y,"Bullets",oBullet))
{
speed = 25;
direction = other.image_angle;
image_angle = direction;
}
}
Hey doubt in the second tutorial at the end my object can't turn while in air any idea why that may be??
@@kishi2403 make sure that "oBullet" is the name of the bullet object you are trying to shoot. for example, if my bullet object name is obj_bullet, i would writeif (mouse_check_button(mb_left)) && (firingdelay < 0)
{
firingdelay = 5;
with (instance_create_layer(x,y,"Bullets",obj_bullet))
{
@@croccoalex6957 x = oPlayer.x;
y = oPlayer.y-3;
image_angle = point_direction(x,y,mouse_x,mouse_y);
firingdelay = firingdelay -1
if(mouse_check_button(mb_left)) and (firingdelay < 0 ){
firingdelay = 5;
with (instance_create_layer(x,y, "PistolBullets", oPistolBullet)){
direction = other.image_angle;
image_angle = direction;
}
}
// This is what my code was try copying and pasting it also don't foget to change oPistolBullet towhatever u usedas well as any others that don't match
I know this is old and idek if you read these comments anymore, but dude.. out of all the tutorials i've watched you're the first to actually explain why I'm using a code, instead of being like yeah type this and this happens, but you go into detail about what each variable, command all that actually tells the code to do. I'm so glad I was shown your guide video.
3 years later and this tutorial is still making wonders for me, this is really helpful, in less than 2 days, i have a working animation, movement and cool sprites that i made on my own thx for the tutorials man
yeah your right me too, thx shaun
daa
I have been following your tutorials for around 3 years now and I can say that this was the most awe inspiring, technique jam packed single tutorial from you to date! Bloody excellent Shaun. If you have the energy to keep these coming, I reckon all of us have the absolute enthusiasm to follow them for as many minutes as they may be in length!
total beginner and I have been able to follow the last three fairly well, a few subtle issues but really looking forward to more! Thank you!
I do really hope you finish this series at least! I picked up GMS2 with the intent of one day making a platform shooter of my own, so this is in invaluable tutorial. I appreciate the effort man
Please do. Thanks fam.
i am a total beginner as well and thanks for ur tutorials they really help me out in learning gml.
keep up the good work
i agree. after about 2 years, i'm outgrowing scratch (visual programming language), and these tutorials make it much easier.
made a custom cursor for the game in this episode using -
window_set_cursor (cr_none)
cursor_sprite = spr_CustomCursor ;
in the create event for the player object
cool thx
thx
epic
Thanks man
When i shoot nothing happens this is the script i wrote can someone help me?
x = oPlayer.x;
y = oPlayer.y+10;
image_angle = point_direction(x,y,mouse_x,mouse_y);
firingdelay = firingdelay - 1;
if (mouse_check_button(mb_left)) and (firingdelay < 0)
{
firingdelay = 5;
with (instance_create_layer(x,y,"Bullets",oBullet))
{
speed = 25;
direction = other.image_angle;
image_angle = direction;
}
}
A fun tip for people who want "glowing" bullets:
Select a brush size of 4 and change click the smooth box next to the brush size. Click once somewhere where it wont interrupt your main sprite. take the colour picker tool and select the lighter part of the smooth box. Grab the circular brush that is small. Place it in the middle of your main sprite, and keep extending the size for a nice "realistic glow" without using any code.
where tf is the smooth box ;n;
Take the erase tool, under "Effects" at the top you have the size and at the right you have "smooth" or "smooth box". I'm french so my english is not very good sorry ;)
Okay. I got a little question.
With the gun object, I'm currently using gamemaker 8.1, and there was no instance_create_layer but only instance_create which only accepts 3 arguments. And no matter how I tried, my bullets don't come out. Can someone help me? Thanks
Great tip
If you want your bullet to emit a particle effect when it hits a wall, do this:
1. add a "Destroy" Event to the bullet, it looks like a trashcan.
2. Make an object called whatever you want the affect to be, and make a sprite for it too.
3. in the Destroy event, do instance_create_layer(x,y, "Bullets", obj_(your particle object name) )
4. In that object, put an Animation End event into it and put instance_destroy() inside of it.
Hope this works and helps!
does this only work on one plane? how would i make it rotate to match the ground, as opposed to the walls, for example?
@@darkchild130 I'm assuming you wanted a sparking effect? I meant a particle effect like a puff of smoke, so I'm not sure how I would do that, essentially if you made a sparking sprite it should work fine
@@Koistork I have made a flat sided impact effect that works fine when shooting at the right wall, but I need to rotate it 90 degrees to hit the floor properly and 180 degrees to hit the left hand wall.
Currently the animation displays in one direction only.
@@darkchild130 I'm no master coder, I'll open up the project I was working on and see how I can get it working later, I think I have an idea on how I would get it to work though.
@@Koistork thanks dude
Holy crap, I just bought Gamemaker and thought I'd do this as a way of learning the basics. When I saw there was over 20 videos I think the realisation that I'm truly about to go down the rabbit hole dawned. I had to rewatch a lot because there's just so much information to take in at times. Amazing job man. Subbed.
man if you create games like you play the guitar you gonna be a great developer
ayo BOUGHT gamemaker? it's free
@@QuackQuack6 You do know there are subscriptions to gamemaker that has a lot of features and using the free plan is not really using the entire tool
@@Hugowertop buying the plan just makes that you can publish your game on other platforms it doesn't give you new tools...
if not, it was the case
I find it nice that some people are sharing their own bit and pieces of code in the comments, thanks to all of you!
I actually fixed the gun pointing direction when u mentioned it in the beginning and got surprised of how of a complex way u did it at the end .. here's the code
if(mouse_x > x) image_yscale = 1; else image_yscale = -1;
keep up the good work
*THX Man!*
you're welcome ;3
Not complex at all.
That's a great way of going about it. However, shaun's method also covers you if you aren't using mouse for gun control, as it sources the direction from the gun's sprite directly, whereas yours relies on the input. This can be a problem if you support gamepads, keyboard only, plus kb/m controls. His has you set, yours you'd have to add a new calculation for each input. If you are only planning on using the mouse, then I love the way you have yours worked out.
I did the same woked well...
Adding the recoil mechanics and effect before he got to it made me feel like a god! His explanations are amazing, I feel like I can take on the world at this point.
This is an amazing resource... Best pandemic project... EVER!!!
I see the number of views is steadily decreasing from the first video. Part of me is saddened that so many folks quit... But the competitor inside me is getting a rush... Like passing someone on a marathon...
It's going to be awesome reaching the end of this series. Thank you, Shaun!!!!!!!
This is the first series I am warching on this channel, and I just wanna thank you for all the help ^^
I will certainly check your other stuff aswell^^
I got GameMaker Studio 2 in a Humble Bundle a while ago and always wanted to get around to learning it. I learned web development by trying to mimic people better than me and experimenting based on that, but I've never done any kind of game development so I was hoping to find a good tutorial. Today I decided to stop putting it off and start learning. Your tutorials are exceptional! Thanks so much!
if you ever want an object to stick to another object more rigidly taking the code at 4:45 and putting it in an end step event seems to work pretty well.
Probably more obvious to others than it was for me, but I prefer the rigidity on the horizontal, but not vertical. I like the weighty feeling when falling and jumping. So I did what you said but only for X. It took me a while to also figure out that you need to place the x = x - lengthdir_x(recoil, image_angle) in the step event as well. In case anyone else had the same thought.
Scrolled the comments for a solution to one of my problems only to improvise a fix by changing some numerical values. When I figured out the fix man did the endorphins hit. Thank you for this tutorial. Learning Code is tough but I feel like I'm at a toddlers reading level exploring a new language. When something clicks it's quite enjoyable.
14:00 To have W or up arrow instead of space bar for jumping:
key_jump = keyboard_check_pressed(vk_up) || keyboard_check(ord("W"));
thanks
Thank you so much for these tutorials. Being familiar with other languages GameMaker wasn't totally panic inducing, but I am not good enough to not need a teacher, so thank you!
I had an issue with my animations where my jump animation was a few pixels up from the resting or running animation. This caused the gun to appear to bob. It being worse before I moved a few statements into an End Step in order to tighten up the floatiness of the gun, I was determined to fix this. I managed to have the gun move up a few pixels whenever the player hits jump. I was happy to do something for myself! As you said previously, the more custom I make my game compared to what you are doing the more I will learn! In my case my gun is "mounted" as a rigid turret on the player, so I'd rather it stay put.
Shaun i am a begginer and i jsut started to use GameMaker Studio 2 and this videos were very helpful but please make it so that this series comes out every week please :)
I'm new too. Only had the program a week and I'm following these videos too. Please check my first ever game progress on my channel
okay, WOW
Keep making these tutorials Shaun, i had NO PROBLEM with my game this time, and that happens rarely you know, keep making these, i love them and i hope that your channel will get even bigger sometime soon, you deserve way more attention than this, you're the one that made game maker a fun program for me :) Mad props.
The more tutorials I see the more I learn but the more I realize how behind I am in the learning curve. Game making is a learning process that takes years to learn and implement. I can jump in and start a shooting game with basic functions but I think it’s better to continue learning gathering knowledge until you’re actually ready
how did your game turn out?
@@Tropix_02 only really worked on a some mechanics that was able to get working. Using unity and the help of gpt. I’m pretty happy with that at least.
These tutorials are absolutely superb even 6 years later
Fr I just started this one
Just excellent stuff man. You've been the best teacher I've found for this material. Unfortunate I can't hit like more times.
Wow! This is such a good series. It is so easy to follow along with what you're doing and at the same time understand what it is you're doing. I'm literally learning this stuff from no prior experience and I get so happy and proud when I run the game and see it work just like it did for you. Thank you for making something that seems so daunting actually digestible and fun to learn!
For those who dont want the latency on the gun, Put the code from the start of the video in the end step(instead of begin)
thanks you
Hi I know this video has been up for ages but I’m knew I’ve made it to episode 3, but I’m stopping here bc I would like to try and do the rest on my own. I just wanted to say how easy your tutorials were to follow and that this was a major help, so thank you so much.
To flip my gun, I just used the line
image_yscale = sign(mouse_x - oPlayer.x);
Worked like a charm. I also set up
image_xscale = sign(mouse_x - oPlayer.x);
so that my player faced the mouse too!
The above code means that the gun dissapears when the mouse has the same x coordinates as the player (as the yscale is set to 0)
@@rorysimmonds bro my shooting is slower than the tutorial please help i also put image speed 25
@@RickyTheRoster Hey man, so to clarify you've set the 'speed' variable in the oGun object to 25? If it's not behaving like the tutorial then I would check that the rest of the code is set up like the tutorial, but also check your game's frame rate is the same as Shaun's in the tutorial (I think he has it set as 15 or 30 but can't quite remember!)
@@rorysimmonds bro the frame rate was 30 i solved that thx
@@rorysimmonds bro is there any way to make my game maker and the game tester full-screen it's not like that now when i open it the task bar is also at bottom
if your gun looks weird in a single way, or you want the character to face where you are firing, use this code for your gun:
if (mouse_x < oPlayer.x)
{
image_yscale = -1;
}
if (mouse_x > oPlayer.x)
{
image_yscale = 1;
}
then this code for your player:
if (mouse_x > oPlayer.x)
{
image_xscale = 1;
}
if (mouse_x < oPlayer.x)
{
image_xscale = -1;
}
This will cause your character to only face where your mouse is, and flip accordingly with the gun
ty for the tutorials shaun 👍
when you've had enough of getting bullied 0:45
Wow
lmao
may i know that why the bullet is not firing through my gun
L m a o .
GUN
I used my own assets but It's actually mimicking your assets but I made my gun to look like a Shotgun. It didn't quite make sense for a shotgun to be firing like a machinegun so I read the documentation to find out how I can spawn 4 bullets at once so It would look like a spread shot and I was so happy when I was able to achieve what I set out for. This is the code:
if (mouse_check_button(mb_left)) && (firingdelay < 0)
{
recoil = 4;
firingdelay = 15;
repeat(4){
with(instance_create_layer(x,y,"bullets",obj_bullet))
{
speed = 25;
direction = other.image_angle + random_range(-9,9);
image_angle = direction;
}
}
This is one of the best tutorials on GMS 2 ever, even compared to the pay to access one on Udemy. Keep doing what your doing man It's really Inspiring.
you can use firingdelay -= 1 instead of firingdelay = firingdelay -1. Works with adding too
Bro, your videos are literally amazing! never seen any better explainor than you so far, i learn so much from these videos!! thank youuu!
i'm still so proud of myself that i managed to add wall jump just by copying 4 lines of code and transfering them into something new
Dude, thank you so much!!! With the help of your way of explaining, not only was I able to follow along well, I was able to add a double-jump, running speed, *AND* a widening bullet spray the longer the trigger is held down.
Bless you for your videos, man. I hope you have a wonderful Christmas season!
Just in case anyone didn't pickup on how to fix the muzzle flash being in the wrong place. All you need to do is fiddle with the origin point of sBullet.
thx
Coding seems to be nothing but math, logic, and efficiency. I always thought i would hate it, but now that im starting to understand it, i may love it
Your... the... best....
Jordan The One he is
Jordan The One you're
Thanks? :P :D
Jordan The One xD
no mate. you are
hey, that tutorial help so much peoples that wanna learn game maker, pls continue!
19:05
Visual Basic developers: It IS confusing!
Java and C/C++ developers: * intense twitching *
your tutorials are really informative, and are a great backbone and inspiration for my own ideas to be added into later on. I find this a great way to test my coding skills and knowledge, as i then run into my own problems, and find solutions to them on my own. But i wouldn't have done any of that without your videos to teach me the backbone of these projects in the first place. Thanks.
Hello, I am wondering instead of having the gun follow the mouse, what code do you have to write to make the gun point and shoot the direction the character is facing. Either right or left.
dude ive been struggling with this for like 5 hrs lmao
@@Kelso_Belso I kknow it's been 7 months but do you know how to fix this
Super wyjaśnienie ciężkiej do zrozumienia dla początkujących funkcji lengthdir_x i lengthdir_y :) Dla tych co szukają właśnie tego wyjaśnienia: 39:00
Great explanation of lengthdir_x and lengthdir_y functions. They are quite difficult to understand for begginers :) For everyone who is looking for just it: 39:00
29:50 so if you want your bullets to be affected by gravity, you gotta do the x y player movement thing right?
In that case probably the easiest solution would be assigning a gravity-variable to the bullet, a very low value, like 0.05, and a, lets call it "Bulletdrop"-Variable, that increases by the gravity-variable each frame and then moves the bullets Y-coordinate by that amount.
Thats would I would try, at least, havent tested it, and Im not sure how the already set speed would affect it
Jam-packed with quality learning material indeed. Loving these tutorials.
Shaun Spalding Could you make a video in this series about weapon selection, both a selection menu and how to change the weapon in the players hand. I have tried to make an arraysystem for the weapons in a game I am making, but something that I can't figure out what's wrong with is the alarms. However, I really like your game maker tutorials.
I second this
Shaun Spalding I totally understand, thanks for responding. Btw I really like your videos, keep on going 👍.
i dont know how to make a selection menu, but i know a way of how to change from gun using the mousewheel,q or e, just use this code and put it in one of the gun objects:
if (keyboard_check(ord("E"))) or (keyboard_check(ord("Q"))) or mouse_wheel_up() or mouse_wheel_down()
{
instance_change(oGun, true)
}
where oGun is, you need to change it to the name of your object you want it to change into, also put this code in the object you want to change to change it back into the other gun, also put here the name of the object.
I hope it helps for now!
So by inserting this code, i'm going to be able to swap weapons ?
Oh my god ! Thank you so much ! That works ! I can't thank you enough !
i accidently discovered a really cool game mechanic. instead of setting the speed direction and image angle of the bullet through gun script, i set it in the bullet. but instead of using the create event i accidently used the begin step. and now the bullets are like homing missiles, following my mouse angle wherever. i can see this being a hella fun puzzle and shooter game bro.
I used the recoil system to do a stab attack with a sword
oooooooooo that sounds cool
é br é
Okay. I got a little question.
With the gun object, I'm currently using gamemaker 8.1, and there was no instance_create_layer but only instance_create which only accepts 3 arguments. And no matter how I tried, my bullets don't come out. Can someone help me? Thanks
@@illtcmusic2319
shouldn't it just be
with instance_create(x,y,obj_bullet) yada yada in obj_gun stepevent or in this tutorials case the begin step event.
it might not work the same in that version but I know in 1.4 it worked without choosing a layer
@@frankiewennerIV thanks i got it solved
Hey shaun keep up the good work.... This is very helpful. Not just with gml the basic logic is explained very well by you which helps when using different engined and/or languages. As always awesome tutorial... And keep it coming.. I finished the beginner on GM1 but this tutorial taught me still more... Keep it coming
Dude i stardet my own game dev a few days ago and this seems like when your creating a game your basically playing a game cause you incountare a lot of problems and challenges but the result is always worth it
one small thing i noticed was when the gun faces the other way the recoil makes the gun go down rather than up. Its hard to notice on small recoils but if you increase it it is very noticeable. If anyone else has this problem you can just move the:
image_angle = point_direction(x,y,mouse_x,mouse_y)+recoil;
to the if(angle) statements and just put - instead of + for the flipped image. But excellent tutorial, really enjoying getting into GMS2 and this is an great introduction to it!
Hi Shaun,
in the final minute you used the if statement to check whether facing left or right and changing the gun accordingly.
I took the liberty of writing it as follows:
// flip image if upside down
image_yscale = sign(mouse_x-x);
It looks a little nicer in terms of code. Are there any downsides to this?
Cheers for the awesome tutorials!
Max de Kroon the gun may disappear for one frame when you move your mouse from one side to the other ( when x - mouse_x = 0)
great series so far! thanks a bunch for creating these tutorials!
i turned the gun in to a shot gun
put this in the begin step for the gun:
x = oPlayer.x;
y = oPlayer.y+10;
image_angle = point_direction(x,y,mouse_x,mouse_y);
firingdelay = firingdelay - 1;
recoil = max(0,recoil -1)
if (mouse_check_button(mb_left)) and (firingdelay < 0)
{
recoil = 6
firingdelay = 35;
with (instance_create_layer(x,y,"Bullet",oBullet))
{
speed = 10;
direction = other.image_angle;
image_angle = direction;
}
with (instance_create_layer(x,y,"Bullet",oBullet))
{
speed = 10;
direction = other.image_angle - 3;
image_angle = direction;
}
with (instance_create_layer(x,y,"Bullet",oBullet))
{
speed = 10;
direction = other.image_angle + 3;
image_angle = direction;
}
}
x = x - lengthdir_x(recoil,image_angle);
y = y - lengthdir_y(recoil,image_angle);
if(mouse_x > x) image_yscale = 1; else image_yscale = -1;
enjoying this tutorial so far, the first tutorial i have followed that dosnt involve unsolvable crashes, though also the first tutorial that uses code and not drag and drop.
but everthing works so far, thanks for the tutorial, now i just have to rewatch and redo about 50 times more, then i know how it works ! xD
Hey Shaun, I love your tutorials. I was wondering if it was possible if you could make a shooting tutorial, but more of a Mega Man type style gun, with only shooting in the direction of the player.
i know this is 2 year old comment but did u ever figure it out
@@eggrollwithashooter6209 i know its been a month but did u figure it out?
@@Hina-fo1tk never did
@Bschgr Great. Thank you.
up
Hey just wanted to say: thank you so much! I've been using game maker for years but always used the drag and drop because I am a nightmare with coding, but thanks to your video im using some coding and it is really exciting!
When shooting my bullets, the "flash" occurs for more than the first frame. It follows the bullet at least 3 or 4 frames then changes to normal bullet.
For those who might have the same issue: check if you forgot to set the bullet sprite animation speed at 60fps. (Mine was at 15)
@@leodacosta1 Hey, I know this was a month ago but this helped me, So i wanted to say thanks!
tsym I'm new to game maker but I'm making huge progress because of your videos. I save almost all of your videos as a reference.
For some reason whenever I shoot my gun the bullets come out below where they should. I tried changing their spawn using x and y modifiers but they don't work. I was wondering if there is any solution to this problem.
had the same problem; mine was a few pixels away from the gun. didn't find a way to solve this but as a beginner platformer game, it looked fine. did you find a way to fix this ; I would try to change sprite and canvas size
@@rikirubiks3769 Not sure if you've fixed it yet as it's been a month but what worked for me was putting the origin point of the collision mask in the sprite of the bullet to be middle centre.
@@rikirubiks3769 got the same problem. I fixed it by moving the origin point outside the sprite
I am under 15 and I have to say, that i learned soooo much from your tutorials shaun. Thanks for all
Hi Shaun. I find your tutorials easy to understand. As a beginner, I understand step 3, too! But what can I do with the code for "oGun", instead of mouse-Control, if I would like to have a simple gun- and bullet-turn to -x? I just wanna have an character with a gun, shooting to the right when his face (gun) shows to right (vk_right), and shooting to the left when his face (gun) is to the left (vk_left)?
I often tried to change the code, but it does´t work. Any hints? Best wishes, Marc
I know its been 5 years but do you know how to fix this
Really enjoying the series. Started with the DnD top down and its all so easy to follow. Great teaching!
so i may have strayed a bit and made my own player sprite; he'a a robot boy who has a hovering idle animation :) but this is creating an issue where the gun stands still while the player sprite is hovering. is there a way to make the gun match the exact sprite frame position?
Im learning this as a beginner and am assuming you found a solution and i wanna ask how you accomplished this
dude ik its been 5 yrs but do you still remember how you fixed this? :(
@alexausderlobby6730 the only thing I can think of is setting the origin for each of the frames of the idle animation to where you'd want the gun to be. Not sure if this would help- I'm a beginner as well!
@ this really helped, tysm :D
Awesome! Love that you are doing the Platformer tutorials for GMS2 now
So the coding for image_yscale makes my gun really tiny
I love the weight aspect, it makes my player look like he's running aggressively which is perfect
my recoil "animation" doesnt work
You are seriously a god tier teacher. Thank you so much.
i followed this all in the trial. then I got the full. Now I have to do all this again. FUUUUUUUU
wait why is that?
Isiah Sweeting
He/she just said, He/she did this project in the trial and now he got the full version he/she has to do it again!
ScreamMario 51 lol I know what they said. I wanted to know why was that. Why does following this tutorial in the trail messup in the full version
Isiah Sweeting
I guess you can't import trial files to full version.
You can
Really lovely visualization for the lengthdir/recoil segment
Thank you!
Do you know where is explained how the bulled gets destroyed
@@floris8392 Yup, check at 21:05
why my instance_create_layer is not working?
same here. I'm getting a malformed if statement on line 13 in the gun object's begin step.
The engine updates allot, that's the problem, i cant tell more, sry mates, try going on the site to see if thee a virtual manuel
@@fahren1884 thanks!
@@tomharris2499 I know i'm a little bit toooo late with this but if anyone is wondering here is the solution, you get the error, actually because if you read it, it's says instance_create_layer "Bullets" doesn't exists, now it's bc you did put in "Bullets" before instance_create_layer(x,y,"Bullets",o_bullet)) but what that mean? It mean you want to create your o_bullet on the Bullets instance layer witch maybe you named wrong in the room, so go and check if it match the name or not the instance layer name MUST be Bullets or if it's not Bullets change it to it, or change the "Bullets" inside of the code whatever your instance layer is.
Your tutorials has taught me so much,
like I did on my own to change the cursor to a crosshairs
obj_cursor ( step )
cursor_sprite = spr_cursor; // spr_cursor is own sprite drawn
to remove the arrow cursor
Resources: Options / Main then
Platform Setting / Windows
Windows / Graphics
then uncheck the Display cursor
thank you, Sensei
heres the code and details of this video for you guys so u don't have to take long in the code(if there are problems let me know) tip for when u copy this code into game maker 2, make sure u delete any spaces in the begging of the code and replace them by pushing the "tab" key, but yea this code u are about to see will include all the code u need BUT U STILL HAVE TO ADD THE SPRITES IN AS EXACTLY HOW HE DOES IT thank you.
sGun code: click begin step on sGun obj add the following code
(line 2 is optional code, you can or don't have to add "+10" at the end if u don't need to)if the gun looks out of place u can adjust this code to whatever works or erase it completely
x = oPlayer.x;
y = oPlayer.y+10;
image_angle = point_direction(x,y,mouse_x,mouse_y);
END OF GUN CODE DO NOT COPY THIS PLEASE
oPlayer obj code: if you hadn't already, click on "oPlayer" under objects then "step" then (type/replace the following on line 2-3) if u already did EXACTLY what he did on his previous videos
key_left = keyboard_check (vk_left) | | keyboard_check(ord("A")) ;
key_right = keyboard_check (vk_right) | | keyboard_check(ord("D")) ;
END OF THIS CODE SO FAR DO NOT COPY THIS PLEASE
sBullet sprite details:"15:15" (in case you need to understand this code here is the time this starts)
oBullet code: (you really need to do this first)(16:40) then when your ready click on the obj then add "other" then "animation end" this should start u off with the bullet code
image_speed = 0;
image_index = 1;
DO NOT COPY THIS PLEASE MORE STEPS ON THIS BELOW
(you will have to then add "draw" then click "post-draw")
if (place_meeting(x,y,oWall)) instance_destroy() ;
END OF CODE PLEASE DO NOT COPY
oGun code: 23:36 (click "create" you should have a fresh code w a line 1 then put the following)
firingdelay = 0;
recoil = 0;
END DONT COPY THIS PLEASE
(Then click back on begin step and add)
(line:6) firingdelay = firingdelay - 1;
recoil = max(0,recoil - 1);
if (mouse_check_button(mb_left)) && (firingdelay < 0)
{
recoil = 4;
firingdelay = 5;
with (instace_create_layer(x,y"Bullets",oBullet))
{
speed = 25;
direction = other.image_angle + random_range(-3,3);
image_angle = direction;
}
}
x = x - lengthdir_x(recoil,image_angle);
y = y - lengthdir_y(recoil,image_angle);
if (image_angle > 90) && (image_angle < 270)
{
image_yscale = -1;
}
else
{
image_yscale = 1;
}
THANK YOU GUYS FOR CHECKING OUT MY COMMENT ILL BE DOING MORE ON THE NEXT VIDEO!
your the fucking best man
Tortellini Deal thx 🅱️ 😂
Just copy and pasting this won't teach you anything though. Which is the point of this video.
with (instance_create_layer(x,y"Bullets",oBullet))
not with (instace_create_layer(x,y"Bullets",oBullet))
absolutley amazing video! i have never had a lick of experience with coding, after 3 days, i can make guns shooting walls and everything XDDD thank you soo much for this series, onto part 4
"It's as simple as that, just change the X's To Y's." Fantastic Life Advice
yes.
This series taught me so weel that I managed to make an ammo and trload sistem completely on my own, in just 3 episodes!
can't wait til you get to the melee attacks
definitely jam-packed with quality material :P
My muzzle flash and bullet dont start at the tip of my gun but they start a little in front and higher the the gun Any help?
Same Problem
you can change the speed of the bullet, just try different speeds of the bullet, and that way you can change the place where the muzzle flash begins
streeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeetch
Make sure your Bullet sprite origin is in Middle Center
goddamn i don't have words to say how much ur cool
ur the best and ur tutorials too
i don't understand how u have just 100k subs u need more than 1mill!
tysm for this tutorial
Question though, can I make it so that I don't have to use the mouse for the gun direction? I am only 10 mins in so idk if you covered that or not. But I want to know because I dont want to write all the codes for the mouse control and then get confused if I wanted to change it.
basically, I want the gun to point left and right but doesn't turn around on all directions, so just using the keyboard...if that makes sense.
JellyfishGaming i want to know how to do this aswell
Yeah like in Contra or Metal Slug.
Same, been trying to figure out how to tell the direction to be 180 degrees when facing left and 0 degrees when right. Haven’t been successful.
In the Player Object's Step event:
if (hsp != 0) image_xscale = sign(hsp);
In the Gun Object's Begin Step event:
x = oPlayer.x;
y = oPlayer.y+10;
image_xscale = oPlayer.image_xscale;
Hope this helps.
Thank youuuu
You'rt always apologizing for a long video, but it's so clean and useful. Ty!
Those 4 dislikes are Unity Fanbois
those SEVENTEEN
@@wyzolol ooooooooooooooooooooooooooooooooooooooooooooooooohhhhhhhhhhhhhhhhhhhhhh
THOSEAREEIGHTEENADSAHGFJACBEHAUGSDHAGFJAGFZUABGUAEGHFAVGCBEFZBCAghFCBGAUFCBGAUFCBGUZEASEXHJAGKDJABHZDGAUHDS
20 UNITY FANBOIS
@@chamber_hiro256 yeah XD
Really helpful tutorial, you taught me a lot with this one!
25:15 why dont you just use -=?
really good vid btw!
This was really good tutorial , didnt know about the "Begin Step" , made the gun look much better, thanks :D
How are you supposed to get a bigger playing screen?
Just make the room bigger
I don't know if you cover this in a later tutorial, but if you are using some character that requires multiple sprites, just put it in the main step event, and it will not lag.
This can cut down massively on required animations if your character has actions that they might do at the same time as other animations. (For example, if you wanted your character to have a melee attack at the same time as walking, you might animate their upper body independently from their lower body. You could even make something as complicated as a rigged skeleton system, though as inexperienced as I am, I don't know how good for optimization that would be.)
Also, if you want to make things easier on yourself (if you always want to have the gun at all times), instead of placing the gun in the level, just make the player object create the gun object when it is created, or when changing rooms. (If the gun object has important things tied to it, then make it persistent, and ignore the part about creating it when changing rooms.)
32:07 to remember where i finished watching for today XD
Excellent series first one I’ve seen but you got a new subscriber! 👌
who is watching in 2019?
me
@Devin Hanson I'm not watching?
When i shoot nothing happens this is the script i wrote can someone help me?
x = oPlayer.x;
y = oPlayer.y+10;
image_angle = point_direction(x,y,mouse_x,mouse_y);
firingdelay = firingdelay - 1;
if (mouse_check_button(mb_left)) and (firingdelay < 0)
{
firingdelay = 5;
with (instance_create_layer(x,y,"Bullets",oBullet))
{
speed = 25;
direction = other.image_angle;
image_angle = direction;
}
}
2023
@@SureHi-po6gmsame
These tutorials have been super helpful so far! Thanks so much.
Can you make at least 2 videos a week for this series? I know its hard but I love your tutorials and waiting a week is too much.
B-Rabbid its two weeks mate... A video every other friday
Harinandan Nair wtf
bruh i wait months for more one punch man manga
Thanks for this tutorials really like them
more
lengthdir_x equals to the coordinate of the gun but since we don't know that, we move differently in x than in y .... because... degrees is...... *snoreee*
Very good tutorials tho keep up the good work, Shaun
Thanks for the awesome tutorials. They're so detailed and helpful! without you it'd be much harder to figure out how to do all this stuff.
I created resources such as sprites and sounds months before starting this. I am glad I did. I highly recommend the free app 8bitPainter