🔴Game Maker Studio 2 | Advanced - Laser or a kamehameha for beginners

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ต.ค. 2024

ความคิดเห็น • 83

  • @theblackkoopa2329
    @theblackkoopa2329 4 ปีที่แล้ว +6

    Useful as always. Nobody else covers these advanced topics as well. I think I speak for us all when I say we appreciate your efforts.

    • @1upIndie
      @1upIndie  4 ปีที่แล้ว +2

      Thank you for the kind words! I guess I understand why nobody sticks around too long, lots of work...

    • @theblackkoopa2329
      @theblackkoopa2329 4 ปีที่แล้ว +1

      ​@@1upIndie The rule of thumb is that the more advanced you get, the less people are going to watch. Just know that your work is incredibly useful to the people watching it ^^

  • @JAMPLEYDEV
    @JAMPLEYDEV 19 วันที่ผ่านมา +1

    Really useful for new mechanic of my game, thanks!

    • @1upIndie
      @1upIndie  19 วันที่ผ่านมา

      Glad to hear I could help a fellow dev out!

  • @nicolasrizzi3789
    @nicolasrizzi3789 3 หลายเดือนก่อน +2

    one easy altenative to draw the laser and much less taxing is:
    var _dis = distance_to_point(xEnd, yEnd);
    draw_sprite_ext(s_laser,0,x,y,_dis,1,direction,-1,1);
    This way (the sprite has to be 1 pixel wide) instead of looping, it just draws one sprite and stretched it.

    • @1upIndie
      @1upIndie  3 หลายเดือนก่อน

      Hm, but how do you get the (end) point here? The whole laser thing is super taxing because it loops until a near/collision point is being found. Do you have a some more code for me to check out? You may have something I don't see.

  • @AgnisNeZvers
    @AgnisNeZvers 5 ปีที่แล้ว +1

    In forum Advanced programming section people found out that you can optimize for loops by having VAR you are checking in a loop (for example i < length) and optimize further in cases you already know loop count then use repeat instead.

    • @1upIndie
      @1upIndie  5 ปีที่แล้ว

      Interesting, by how much? Is that still relevant, because PCs are very powerful today and problems 10 years ago (resource optimisation) are not such a hot topic any more (at least for 2d games). You got a link so I can check it out?

    • @AgnisNeZvers
      @AgnisNeZvers 5 ปีที่แล้ว

      @@1upIndie well that's if you want to really optimize and be prepared for YYC compilation, most cases you can ignore that. You can read it here - forum.yoyogames.com/index.php?threads/optimizing-code-for-yyc.62937/

  • @andresarnasgil3678
    @andresarnasgil3678 3 ปีที่แล้ว +2

    Works great, thanks!

  • @Aringtorulethemall
    @Aringtorulethemall 2 ปีที่แล้ว +1

    Can something like this be done by using tile collisions or I'm better off using an object wall for lasers?

    • @1upIndie
      @1upIndie  2 ปีที่แล้ว +1

      This simple laser you can do with both, the advanced (video tutorial) I would recommend objects, but it is also possible with tiles (so invisible horizontal and vertical tiles collision checks).

  • @hyoon1366
    @hyoon1366 4 หลายเดือนก่อน +1

    thats sooooo great and a nice channel i love it

    • @1upIndie
      @1upIndie  4 หลายเดือนก่อน

      Thanks, hope you get your times worths here.

  • @slickygreasegames
    @slickygreasegames 3 ปีที่แล้ว +1

    This is a fantastic tutorial. I got a question. I want to use a laser like weapon for my, but I do not want have my laser rotate 360 degrees. How I have it is the player is snapped into position when firing at a 45 degree angle(up and down) or straight when running or standing still. I was wondering how I can program it in such a way that I won't rotate it?

    • @1upIndie
      @1upIndie  3 ปีที่แล้ว +1

      Well, you can "lock" the laser in specific positions by input commands. Something like that: You press up and attack on your keyboard, laser is focused on an upward beam. Same for up + right + attack for an 45degree locked laser. In my video the laser is locked to on the direction calculated between the player and the mouse, here you only kill the line "direction = point_direction = (o_player...." and define instantly the direction to 90 for up, 45 for up + right ect.

    • @slickygreasegames
      @slickygreasegames 3 ปีที่แล้ว

      @@1upIndie I have this script I use for shooting. I was wondering how I would apply to what you said on here?
      // / @desc Normal Shooting
      function scr_normalshoot(){
      if key_shoot && canShoot
      {
      canShoot = false
      alarm[0] = shoot_delay
      var dir = 0;
      if gamepad_axis_value(0,gp_axislh) = 0
      && gamepad_axis_value(0,gp_axislv) = 0
      {
      if image_xscale < 0 //if facing left
      {dir = 180}
      //an else isn't needed cus the dir is already 0
      }
      else
      {dir = point_direction(0, 0, gamepad_axis_value(0,gp_axislh), gamepad_axis_value(0,gp_axislv))}
      with (instance_create_layer(x,y,"BULLETS",obj_projectile))
      {
      direction = dir + random_range(-3,3) ;
      speed = 20
      }
      }
      }

  • @flerponius429
    @flerponius429 2 ปีที่แล้ว +1

    I have found that if the direction of the beam changes too fast, it will pass over enemies without harming them. Is there a way to fix this?

    • @1upIndie
      @1upIndie  2 ปีที่แล้ว

      Hm, it depends how you setup the collision event. So if you use the traditional collision event in the object (collision with) or in the step event a "normal" collision, then it can skip instances that clip it. To apply each step a collision with all instances on the thing (here a laser) use collision_"list" (rectangle, circle, etc.) in your step event, which will defently get all instances.
      So this maybe what you are looking for since this is not being talked about a lot plus, you have per second 60 times the chance to harm enemies. So the chances are pretty slim that you can actually skip here. If that is not what you are looking for and you have ultra high speed values that change the direction, well then you need to create an additional system on top which is not part of the drawing and a seperate system.

  • @b3moy648
    @b3moy648 2 ปีที่แล้ว +1

    Hello. I have a question. Is it possible to make such a collision on an object (npc for example). When the player comes close, a collision is triggered like at the wall, when the player is standing nearby (in the reach of the NPC), then you can activate the dialog box.

    • @1upIndie
      @1upIndie  2 ปีที่แล้ว +1

      Yes, you can do that and use the collision as a trigger.

    • @b3moy648
      @b3moy648 2 ปีที่แล้ว

      @@1upIndie thank you for your response . Could you describe it to me in more detail please?

    • @b3moy648
      @b3moy648 2 ปีที่แล้ว

      @@1upIndie I know how to do it, if the object is static. But what about dynamic objects like npcs. They are walking around. And there should be a way, to connect npc with another dialogue trigger collision box

  • @e_buffturtle
    @e_buffturtle 8 หลายเดือนก่อน +1

    Great video but I noticed an issue, every time you press the button to spawn the laser, it starts at the top left of the level and then teleports to the player (this is for like a frame). I want to use this to make a hitscan weapon rather than a laserbeam but that weird issue will always make my aim off (since my laser object will only exist for a single frame). Does anyone know how to fix the issue?

    • @1upIndie
      @1upIndie  8 หลายเดือนก่อน

      One way would be a delay of 1-2 frames, so you have a variable that blocks the draw event and you don't have the glitch. Or you have to do the calculation of the direction and length being done upfron in the mouse click to void that. Hope that helps.

  • @enzomedina3118
    @enzomedina3118 5 ปีที่แล้ว +2

    Hi man !
    Greats videos !
    +1 sub!
    Just need some help after 27:00, how can I make a lazer that kills only one ennemy even if there is many ennemies on the same line ?
    Here is what i tried :
    var hits = collision_line(x, y, xEnd, yEnd, obj_asteroid, 0, 0)

    if (hits > 0)
    {
    instance_destroy(obj_asteroid);
    }
    the problem is : i'm killing all the asteroid. I knew it but idk how to make that it just destroy the asteroid which is hit by my lazer.
    I would prefer decrease the x_scale/y_scale of the asteroid but let's first see if I can destroy them.

  • @stardreamix786
    @stardreamix786 9 หลายเดือนก่อน +1

    Amazing!!!

  • @derDeydrihmOrcsTale
    @derDeydrihmOrcsTale 3 ปีที่แล้ว +1

    9:08 - we go for... Jot? XD

  • @SuperRapda
    @SuperRapda 5 ปีที่แล้ว

    You explained about light effects with shaders, are you planning about doing a tutorial about that?

    • @1upIndie
      @1upIndie  5 ปีที่แล้ว +1

      Yes that will be part of the channel. But my plan is to grow the channel starting with easy basics, jump from time to time into advanced topics (particle, the laser etc. ) and then go for the holy cow of video game design and wrestle with really hard candy like shaders. I don't want to scare off people when see a nice and easy video on lets say lengthdir and then I knock you down with a shader video.
      The question is only when. Is this something you are really interested in? Then I would need to make a basics on shaders and then an useful way to use it.
      Which shader in paticular were you refering to. The glow shader, the color distrotion shader or pixelate shader?

    • @SuperRapda
      @SuperRapda 5 ปีที่แล้ว

      ​ 1up Indie Is something I'm interested in, although I've managed to do some basic shaders I needed I'd like to go deeper. But I didn't find any guides for it.
      But you are right and covering the basics is what should be first. If you want my point of view when I was starting what I looked for in youtube was a guide to start a game from zero. Like "Do a final fantasy game type from scratch!"
      Even though your current tutorials would help more people like me lol
      Anyway, good luck! I'm sure it's just a matter of time you start getting more subs if you keep doing this amazing content!

    • @1upIndie
      @1upIndie  5 ปีที่แล้ว +1

      ​@@SuperRapda Thanks, the guide from zero was my first idea too. But then I saw a lot of good channels that do excatly that.
      The only missing thing that frustrated me was that you get a "here is how you make particles" etc., but no real practical application is shown, just basics.
      So my aim is to satisfy very specific needs, use the channel rather like a wiki/repository for most common useful things. I try to cover the needs of people like you, because you are an advanced user (you can use shaders, puts you above most hobby programmers, keep it up! ) and you are most likely to finish a game.
      And I guess, I will burn through all easy topics in about 3 months. So if you have any specific things that are of relevance to you and (hopefully) all others, I can do it.
      Drop me a line in the comments or discord. Shaders are coming, just tell me which specific you really want and it will be done.

  • @murdocc9
    @murdocc9 3 ปีที่แล้ว +1

    sorry my english, do you know how to detect 2 or more objects with the raycast????

    • @1upIndie
      @1upIndie  3 ปีที่แล้ว

      For that you need a list collision (which stores all collided instances in the ds_list) -> collision_rectangle_list

    • @murdocc9
      @murdocc9 3 ปีที่แล้ว

      @@1upIndie i'm using GameMaker:Studio 1.4, that function doesn't exists

    • @1upIndie
      @1upIndie  3 ปีที่แล้ว

      @@murdocc9 Then ypu cannot do that directly. The only way to check for a collision is: collision_rectangle.

    • @murdocc9
      @murdocc9 2 ปีที่แล้ว

      @@jeffreyfaphere thanks jeffrey

  • @i.joelmasters
    @i.joelmasters 3 ปีที่แล้ว

    Hey man, I'm not sure if you'll answer this but my game starts to slow down when I press and hold, I did make the max length smaller(from 750 to 64) but that didn't help. Any ideas on how to fix this?

    • @1upIndie
      @1upIndie  3 ปีที่แล้ว +1

      To be honest I don't know where the issue lies in your game. But useing this laser code (from the video) is kind of hard on performance overall because you need to do tons of collision checks and we draw tons of mini lines on the screen. So use this method (even if it looks pretty cool) sparingly.

    • @i.joelmasters
      @i.joelmasters 3 ปีที่แล้ว

      @@1upIndie okay thanks, I just want to be able to create a laser that shoots straight down from the player(s), using a key press. Also I want to be able to create a tractor-beam in the same way, any ideas? I'm new to all this so I'm kinda lost lol.

  • @DrJurdenPeterbergsteinlerwitz
    @DrJurdenPeterbergsteinlerwitz 4 ปีที่แล้ว

    Noob Question: How would I make the laser beam continue until it hits a wall/solid object, instead of having it stop at mouse_x/mouse_y coordinates? Sorry if my question does not make sense.
    For example: A rotating enemy turret that shoots a laser that is only stopped/blocked by a wall/solid object.

    • @1upIndie
      @1upIndie  4 ปีที่แล้ว

      Are you refering to a collision? So the laser goes until it hits a wall object/player etc..

    • @DrJurdenPeterbergsteinlerwitz
      @DrJurdenPeterbergsteinlerwitz 4 ปีที่แล้ว

      @@1upIndie Yes! My idea was to have an enemy turret rotate in a 360 cycle (or maybe a fixed angle) while shooting out an 'endless' laser beam. The laser beam itself would only collide with a wall object, forcing the player to quickly evade it, or hide under a wall object until it passes.

    • @DrJurdenPeterbergsteinlerwitz
      @DrJurdenPeterbergsteinlerwitz 4 ปีที่แล้ว

      @@1upIndie Something similar to this: th-cam.com/video/xPyl4c7__BQ/w-d-xo.html
      Sorry if it hard to see but it's best/shortest clip I could find.

    • @1upIndie
      @1upIndie  4 ปีที่แล้ว

      @@DrJurdenPeterbergsteinlerwitz Have you watched my "advanced laser" tutorial?? That is exactly what you need.

    • @DrJurdenPeterbergsteinlerwitz
      @DrJurdenPeterbergsteinlerwitz 4 ปีที่แล้ว

      @@1upIndie Is 'advanced laser' not this video we are commenting on right now? Sorry, I might be stupid because I totally thought the laser stopped at mouse_x/mouse_y but I can now see that is not the case! I'll re-watch it straight away! Thanks for your replies and help and have a good day!

  • @orlandoneto9589
    @orlandoneto9589 ปีที่แล้ว

    hey man, what if i want to do the collision with the tili set?

    • @1upIndie
      @1upIndie  ปีที่แล้ว

      Ehm, then you use the collision function for tilesets.

  • @mix-ousoy3485
    @mix-ousoy3485 5 ปีที่แล้ว +1

    you deserve more sub

    • @SuperRapda
      @SuperRapda 5 ปีที่แล้ว

      So underrated channel, I'm sure he'll grow up soon

    • @1upIndie
      @1upIndie  5 ปีที่แล้ว +2

      Your right! Were do I sign up. :D
      But to be honest, gamemaker programming is not the most popular thing on youtube. I have to very slowly grow the legit way or do it like those "big popular" channels and buy subscribes (not gonna do that).

  • @danb9238
    @danb9238 5 ปีที่แล้ว

    hi man! thnx for video.
    Buddy, could you make a video in the development of this video clip, where there will be an enemy who shoots a laser, as he needs time to aim , or that the laser followed the player, something like that?

    • @1upIndie
      @1upIndie  5 ปีที่แล้ว +1

      Sure thing. But be more specific what you actually want. Just write down a short scenario and I can pull (hopefully) it off. This is 2 generic for me.
      Maybe something like this: Enemy locks onto player, draws a faint line on player, then short cooldown, then laser is statically being fired on last player positon.

    • @1upIndie
      @1upIndie  5 ปีที่แล้ว +1

      There was a question about game_restart(), but you deleted it? Sorry, youtube message system sometimes does some funny stuff with the messages send...
      When you do game_restart, everything will be killed and all freshly initalised. So everythings should work. When it works before game_restart(); then It should work after that too.

  • @karellBXL
    @karellBXL 5 ปีที่แล้ว

    Hey man, how do you make it go in the same line as the character instead of following the direction of the mouse?
    direction = point_direction(o_Player.x, o_Player.y, mouse_x, mouse_y ); -> can the angle be the enemy in front of you? or just throwing in front of you? can you do that?
    Thanks !

    • @1upIndie
      @1upIndie  5 ปีที่แล้ว +1

      Hey, not sure if that answers your question:
      That code is fixed on 2 points, then player (startpoint) and the mouse (endpoint).
      And then function "point direction" gives back the angle between those 2 points.
      Then the laser starts expaning from that startpoint towards the endpoint.
      So if you want change the target (endpoint), just give it the x and y from the enemy or whatever target you desire.
      Was that helpful?

    • @karellBXL
      @karellBXL 5 ปีที่แล้ว

      @@1upIndie Hey,
      my bad let me rectify:
      for example: instead of clicking with the mouse to throw the rocket or laser beam, can you replace it with a character that performs an action to throw the rocket when pressing on the keyboard?
      another example is when throwing the rocket or laser beam, instead of having a wall can you have an enemy and make the impact explode?

    • @1upIndie
      @1upIndie  5 ปีที่แล้ว

      @@karellBXL Yes you can do all of that. Instead of "mouse_check_button(mb_left) you can check the keyboard like this: relace it by "keyboard_check_pressed(ord("M"))"
      Here you press m and when you press it, the laser is being fired.

    • @1upIndie
      @1upIndie  5 ปีที่แล้ว +1

      You know what, I can do tomorrow a video on basic input mechanics, that will maybe clarify things for you.

    • @karellBXL
      @karellBXL 5 ปีที่แล้ว

      @@1upIndie thank you that would be much appreciated !!!

  • @riemerdijkstra5974
    @riemerdijkstra5974 4 ปีที่แล้ว

    so i build the laser and it works great, but when i have multible lazers i run into some massive lagspikes

    • @1upIndie
      @1upIndie  4 ปีที่แล้ว

      Yes, that is because the for loop is very taxing on the cpu. You can kind of remedy that if you tweek how many times the for loop is being refreshed or you predefine a lenght, because you know how far it needs to go ( very resouce saving).

    • @riemerdijkstra5974
      @riemerdijkstra5974 4 ปีที่แล้ว

      @@1upIndie thank you for the help but i think i'm going to look for an alternitve way to do my lazer

  • @nemo9396
    @nemo9396 4 ปีที่แล้ว

    7:18 the actual laser

  • @anthonyjuniorpimentelherre3200
    @anthonyjuniorpimentelherre3200 2 ปีที่แล้ว

    I love your video and I completely agree with "TheBlackKoopa232 - useful" I love this tutorial. Just what I wanted but there are some things that are not shown in your video and I'd like you to show them to us so that we can see how they are made.
    So, is the "particlesystem" and other codes scripts? If so.
    You didn't show us what they contain so I'd like you to show what they contain.

    • @anthonyjuniorpimentelherre3200
      @anthonyjuniorpimentelherre3200 2 ปีที่แล้ว

      I will rewatch it and tell you other things I'd like you to show.

    • @1upIndie
      @1upIndie  2 ปีที่แล้ว

      Hey mate, thanks. I am not sure what you mean by hiddend/how it was made content. The video pretty much shows all what you need to make this. Please keep in mind that this video is for advanced users, so I knowing all the basics is pretty much recommended here so you can fill in all the gaps (things like, lengthdir, arrays, how drawing works etc. ).
      If you are a beginner, I would recommend watching my basics videos on the topic that you need or other content creators.

    • @anthonyjuniorpimentelherre3200
      @anthonyjuniorpimentelherre3200 2 ปีที่แล้ว

      @@1upIndie Thanks for replying to this. You're right.

    • @anthonyjuniorpimentelherre3200
      @anthonyjuniorpimentelherre3200 2 ปีที่แล้ว

      @@1upIndie I'd like to ask you a favor: I want to know if you can create a tutorial for this: I don't know if you have ever watched "Avatar: the last airbender". That's a Cartoon/series. They have powers to control the natural elements "water, fire, earth, and air". At first I thought of creating an object called like: "water shoot" to shoot enemies with water as they do in the cartoon, but I realized that if I had another object called "fire shoot" and they collided, they would destroy each other no matter how big or small one of them is over the other. So I said: "I'm going to create little particles of water and fire and I will make them join together so that they create a column of water, so when those little particles collide of water and fire, they are going to be destroyed and if there's more water, some water would remain as a shoot but I also thought that if I had lots of particles (particles like pixels) together, they can slow down my game but when I saw your tutorial about lasers I realized that is possible to make an object and elongate it just by adjusting a few variables, so I wanted to see if you could create a tutorial regarding this, and to be more specific, to create an object like water: "imagine that in front of the character there's a river and from that river, the character raises a column of water and at the upper part of that column they either rotate or curve, or make a circle with the water without affecting (curving, etc...) the column, which looks like a straight line, that is raising from the river, just as they do in Avatar, the last airbender. They raise a column of water from a river and they rotate/curve it as they wish but the column raising from the water is like a straight line and it changes the direction at the end/upper part. well, it would also be interesting to see how you create an effect like the movement of a snake for both, you know that water and fire is not always straight, an effect like that you did with the laser using the yscale parameter, something like that with the snake movement. I'll provide this example:
      th-cam.com/video/1rzUMK0v8PI/w-d-xo.html
      The first part of the video shows the avatar and how he creates a tornado (column) with water and the when he's out of the sea, he curves the upper part of the water down to fall on the ship. Then he rotates the water around him creating a circle and after that he makes it bigger to hit his enemies. This is what I mean, some movement like that. Like a laser that at first can be straight and the you can curve it or rotate it without affecting the first part. Just giving the front part of the laser a new direction and changing from that point on the direction of the laser, of course, without changing the first part as shown in this video. I hope it's clear. I'd really appreciate it.

    • @1upIndie
      @1upIndie  2 ปีที่แล้ว

      @@anthonyjuniorpimentelherre3200 Uff, what you need is a vfx artists that can realize these kinds of graphical shenanigans like tornados, water effects etc. . Here I must disappoint you, visual effects are not my expertise and GameMaker isn't the best (at least in performance and ease to use) for those jawdropping effects. Where I can come in is to use already good screen filling filters or some minior effects. But I guess you want screen filling effects, which I am not good at.
      There are great channels that do cover these topics, but on the Unity side because they have a superior Particle creation system which makes these awesome effects. That we may get in the future (at least that is what I saw in the roadmap 2022 and upwards).
      A really good visual effects channels:
      th-cam.com/users/XorDev
      th-cam.com/channels/z-2zAhi2M3aStq0H-WIG-A.html

  • @mythology100
    @mythology100 5 ปีที่แล้ว

    nice!

  • @sibel9272
    @sibel9272 4 ปีที่แล้ว

    For some reason the line goes briefly outside the laser for me

    • @1upIndie
      @1upIndie  4 ปีที่แล้ว +1

      I guess it needs 1 frame to update. If you want to avoid that, you maybe want to draw the line after one or two frames.

  • @CursedUkiku
    @CursedUkiku ปีที่แล้ว +1

    I just kind of wish you put your code in the comments or some other place so we dont have to spend 40 minutes typing out code and such

    • @1upIndie
      @1upIndie  ปีที่แล้ว

      I do that on longer videos where there is much code, but on simpler ones I simply skip on posting the code in the comment section.

  • @andycarr3711
    @andycarr3711 5 ปีที่แล้ว +1

    Why is there a for loop in draw for the sprite?, it's drawing 100's of times, incredibly inefficient, sprite only needs to be drawn once, no loop.

    • @1upIndie
      @1upIndie  5 ปีที่แล้ว

      Because the sprite has only a width of 1 pixel. That would be a very short laser :D

    • @andycarr3711
      @andycarr3711 5 ปีที่แล้ว

      Take your beam sprite, you lose no detail stretching or squashing. So stretch to needed length, do your direction, offset for position and draw. Your laser looks good though, just looking to improve the code.

    • @1upIndie
      @1upIndie  5 ปีที่แล้ว

      @@andycarr3711 Why not, optimized code is always better. Can you make a video on that? Then I can post it here as an alternative and the community wins!

    • @andycarr3711
      @andycarr3711 5 ปีที่แล้ว +4

      @@1upIndie well here is the code, this just does the laser, without the collision list etc.
      //Create code
      length = sprite_get_width(Laser)
      max_length = 900
      //Step code
      if mouse_check_button_released(mb_left) and image_number > 7 instance_destroy()
      else
      {
      if image_index > image_number -1 image_speed = 0
      x = player.x
      y = player.y
      direction = point_direction(x,y,mouse_x,mouse_y)
      image_angle = direction
      var distance = point_distance(x,y,mouse_x,mouse_y)
      if distance > max_length distance = max_length
      image_xscale = distance/length
      }
      Cheers, thanks for your polite replies to my not so polite original reply!.