GMS2 Cameras: As Simple as Possible

Поділитися
Вставка
  • Опубліковано 3 сер 2024
  • Hey GameMakers!
    Confused by GMS2 cameras? My previous tutorial didn't help much, but this one should set you straight. Let me know what you think of this type of tutorial, especially the white board feature!
    --------------------------------------------
    Links!
    Join My Discord: / discord
    Listen to obj_podcast: objpodcast.com/
    Support me on Patreon! / pixelatedpope
    Follow me on twitter / pixelated_pope
    --------------------------------------------
    Credits!
    In Game Art created by GrogDev: / grogdev
    BGM: The Origin by Legna Zeg
    • No Copyright Chiptune ...
    ♪-Official▶www.legnazeg.com
    ♪-Twitter▶ / legnazeg
    ♪-Facebook▶ / legnazeg
    ♪-Instagram▶ / legnazeg
    ♫-Legna tracks and songs:
    ♪-bandcamp▶ legnazeg.bandcamp.com/releases
    ♪-Soundcloud▶ / legnazeg
    ♪-iTunes▶smarturl.it/AudioSuction
    Camera Icon made by "Roy and Co" from FlatIcon.com www.flaticon.com/authors/roy-...
  • Ігри

КОМЕНТАРІ • 354

  • @PixelatedPope
    @PixelatedPope  5 років тому +39

    Here's the code I use in my create event when using the aspect ratio management stuff.
    /// @description
    #macro cam view_camera[0]
    #macro view_w camera_get_view_width(view_camera[0])
    #macro view_h camera_get_view_height(view_camera[0])
    aspect_ratio = display_get_width()/display_get_height();
    view_height= 250;
    view_width=round(view_height*aspect_ratio);

    if(view_width & 1) view_width++;
    if(view_height & 1) view_height++;
    max_window_scale = min(floor(display_get_width()/view_width),floor(display_get_height()/view_height));
    if(view_height * max_window_scale == display_get_height())
    max_window_scale--;

    window_scale = max_window_scale;
    window_set_size(view_width*window_scale,view_height*window_scale);
    alarm[0]=1;
    surface_resize(application_surface,view_width*window_scale,view_height*window_scale);

    • @realistindenial
      @realistindenial 5 років тому

      I found your series on aspect ratios extremely helpful and happily subscribed to your channel--thank you!
      I have quick question regarding GMS2. Which script is the most current for GMS2: the script here or the one in pastebin.com (referenced in one of your older videos)? I assume the one here, but just wanted to confirm. Thanks again!

    • @PixelatedPope
      @PixelatedPope  5 років тому +2

      @@realistindenial Everything I personally do with GMS2 cameras is based off of this video (and then I mix in some of the aspect ratio and pixel perfect scaling stuff from the older videos). If you have any more questions, definitely join my Discord server. I or someone else will be able to personally answer any questions you might have. discord.gg/By6u9pC

    • @realistindenial
      @realistindenial 5 років тому

      @@PixelatedPope Thanks for your response. Thanks for the invite to Discord. I'll see you there! :-D

    • @ulascantepe1326
      @ulascantepe1326 5 років тому +1

      Why are you making those macros? I don't see them being used anywhere in the code.

    • @PixelatedPope
      @PixelatedPope  5 років тому +3

      @@ulascantepe1326 it's more likely you'll use them elsewhere in your code. It's just a nice way to get the view's current dimensions.

  • @bamb00zld
    @bamb00zld 5 років тому +106

    Finally, a GMS video that isn't 2 years old.

  • @nathanconstable4633
    @nathanconstable4633 5 років тому +38

    It’s so nice to see how fast you help people on discord

  • @rockerhelgeson
    @rockerhelgeson 5 років тому +18

    I'm about to binge watch everything you put out. Thank you for this stuff, it is so helpful, can't say it enough! You rock man.

  • @megasupernewbie
    @megasupernewbie 5 років тому +8

    Hey, I just wanted to thank you for all your videos. It helps immensely in learning game maker :)

  • @megabytegames
    @megabytegames Рік тому

    Thank you for posting this!
    The simplified and persistent camera object really helps. I was having trouble letting the user adjust the window size and was led here. I used your simple camera setup and added a 'surface_resize(application_surface,camera_view_width,camera_view_height)' whenever the window changes size, or when the room changes, and it seems to work well so far.

  • @kwishy6902
    @kwishy6902 5 років тому +1

    THANK YOU! The camera function in gms2 is such a mess to understand for someone like me and I didn't know how to simplify it.
    It's good to know what I should avoid doing to avoid bad habits. That's a very informative video, you're awesome!

  • @thimblebirb
    @thimblebirb 5 років тому +19

    Great video for beginners, especially with you using the whiteboard to visually show what's happening behind the scenes.

  • @moosemeep3694
    @moosemeep3694 3 роки тому

    Thanks so much, this was really helpful. Especially with the stuff about how the camera always follows the top left of the player. It was really confusing before, but it was understandable the way you showed it.

  • @ironworksentertainmentstud2493
    @ironworksentertainmentstud2493 2 роки тому

    Thank you so much!! I have watch several other videos on views and non of them explained it well and I was getting frustrated until I found your video, You explain it so well I will be watching more of your videos from now on

  • @Impscraft
    @Impscraft 4 роки тому

    Wow, this video was fantastic. It was simple and straight to the point. Helped a ton, thanks!

  • @chegmj
    @chegmj Рік тому

    thank you so much for this!! clear, concise, easy to understand, definitely the best tutorial on basic gamemaker cameras

  • @nathanag362
    @nathanag362 2 роки тому

    The scaling problem has been causing a headache for me and this video solved it. Thank you very much!

  • @Nekuvsnoise
    @Nekuvsnoise 4 роки тому

    i've been dying for videos like this!

  • @rcrrcr4552
    @rcrrcr4552 2 роки тому

    I have watched this video 15 times, every time I start a new project. You are a savior.

    • @PixelatedPope
      @PixelatedPope  2 роки тому +6

      Just between you and me, I have to watch it every time I start a new project.

  • @chef2654
    @chef2654 5 років тому +1

    Nice dude, been waiting for this :)

  • @jarirepo1172
    @jarirepo1172 6 місяців тому

    At the time when I start thinking of all of this stuff this video is a best thing I could ever find. Thank you, it would have taken me unthinkable amount of time to figure all this out on my own.

    • @jarirepo1172
      @jarirepo1172 6 місяців тому

      All right, basic setup seems to work, camera follows at the center of my player, all fine, except the sprite of the player moves in totally different speed, not staying in the position of the player. What's up with that? Actually sprite is already drawn in a different location when I start the game, weird. Position should be absolute I think, why is it offset by that much? If I take out the camera code everything works as it should, something makes my sprite drawn in wrong place. EDIT: I found it, I had draw_self() function at draw GUI... which apparently is wrong choice. :D

  • @NoLootStudios
    @NoLootStudios Рік тому

    Thanks a lot, man! That little extra explanation there about the view compared to the "room" was very helpful knowledge! Thanks! Subbed!

  • @steviegillen82
    @steviegillen82 5 років тому +3

    Yoyo Games should be paying you for your content. Top notch as usual

  • @patriciaduffy2479
    @patriciaduffy2479 3 роки тому

    Great tutorial! Thanks for helping! Whiteboard was nice touch

  • @WorldIsNotMine
    @WorldIsNotMine 5 років тому +1

    i'm a subscriber. you uploaded videos recently. i want more your many tips. by the way have a nice christmas.

  • @mallen1846
    @mallen1846 5 років тому +5

    Simple but clear and concise 👍

  • @johnroberts8088
    @johnroberts8088 5 років тому +8

    Best video on the subject ever!!!!!

  • @chet_awesomelad
    @chet_awesomelad 3 роки тому

    God fucking bless you, PixelatedPope. Your tutorials are an absolute LIFESAVER. Cannot thank you enough for this!

  • @Picklesushinoobface
    @Picklesushinoobface 5 років тому

    Definitely going to use this!

  • @andresgrimminck8674
    @andresgrimminck8674 5 років тому

    That's a great tutorial!! Thanks!

  • @aaronpillert5874
    @aaronpillert5874 4 роки тому

    You, sir, are a scholar and a saint! Thank you!

  • @magnomaol
    @magnomaol 4 роки тому +7

    Following the tutorial I had pixel distortion but because I was working with a very small resolution,240x135 (1920/8 x 1080/8) since my characters are 16x16.
    When setting up for the camera to follow the player we have "var _y = obj_player.y - view_height/2" at 8:55.
    Since in my case the view_height==135, my camera "y" coordinate was always in a fraction position.
    So I just used floor() there("var _y = obj_player.y - floor(view_height/2)"), and whenever I used "view_height/2"and everything is ok :).
    Also my app surface was the size of the view(very small, 240x135), if I set it to be the size of the game window(6x bigger) it would hide this bug.
    tl:dr
    I had pixel distortion because I was accidentally setting up my camera to be in a fractional position, make sure you don't do that =)

  • @Heesmaster
    @Heesmaster 3 місяці тому

    Thanks for showing me this video, very nice!

  • @hoodedwizard
    @hoodedwizard Рік тому

    This was awesome! Love it. Thank you very much.

  • @NeZversSounds
    @NeZversSounds 5 років тому +2

    It's for sure way easier.
    Now I can simplify my setup.

  • @Isseinoyuu
    @Isseinoyuu 5 років тому

    Hey, thanks a lot for this, this is exactly what I was looking for. I like to make traditional style games with strict resolutions / pixel grids. By using surface_resize to set the application surface size to the view size it enforces a strict limit. What I had to do before was floor any x and y values that weren't integers before drawing, but this simplifies things. The only downside I've found so far is that I usually print some debug information to screen, but now that's forced to the same resolution limits as well so it takes up a lot more screen space than before.
    It's also a lot easier to adjust the camera position this way than wrestling with the auto-follow in the room editor.

    • @PixelatedPope
      @PixelatedPope  5 років тому +1

      So, if you output debug information to the gui layer, you can resize the gui layer using display_set_gui_size(), and you can set it to the same size as your window! Then you debug text will be super small and crisp.

    • @Isseinoyuu
      @Isseinoyuu 5 років тому

      @@PixelatedPope hey, thanks! I'll try that. The solution I found was to create a custom font with aa turned off and make it as small as possible. It works and I like the fact that it doesn't break the pixel density, but screen real estate can still be an issue.

  • @ilikecakeandbiscuits
    @ilikecakeandbiscuits Рік тому

    So bloody useful!

  • @larryteslaspacexboringlawr739
    @larryteslaspacexboringlawr739 5 років тому

    thank you for gamemaker tutorial

  • @DeadManRising36
    @DeadManRising36 3 роки тому +2

    for those who cant seem to run the game even though the code is identical!
    In your End Step event of obj_Camera Do NOT put a ';' behind the line containing "#macro View view_camera[0]"

    • @PixelatedPope
      @PixelatedPope  3 роки тому +1

      Yup. No semi colons on your macros!

    • @DeadManRising36
      @DeadManRising36 3 роки тому

      @@PixelatedPope by the way what settings do I need in my game graphics options?

    • @PixelatedPope
      @PixelatedPope  3 роки тому +2

      @@DeadManRising36 Default settings should be fine. Most important is the "Keep Aspect ratio" scaling option. Everything else can be changed as needed.

    • @mallen1846
      @mallen1846 2 роки тому

      I would add, with newer version of GM2, placing macros in objects will raise an exception (at least it does in this example). Create a script file and place them all in there and it will then run error free.

  • @torbacz2335
    @torbacz2335 6 місяців тому

    finnaly a video that explains everything perfectly

  • @mythitorium
    @mythitorium 4 роки тому +3

    Finally, A religion that I can get on board with.

  • @paullishchynskyi6442
    @paullishchynskyi6442 5 років тому +2

    Awesome! Fixed all the jittery pixels for me, as well as answered a couple of other questions. Thank you so much!

  • @graydaydinya9383
    @graydaydinya9383 2 роки тому

    thank you so much, man

  • @神烦狗
    @神烦狗 Рік тому

    legend, thanks this really helps.

  • @simonbooth4888
    @simonbooth4888 2 роки тому

    I've been playing with Level Of Detail for sprites which works nicely with responsive screen layouts. Basically if your art is rendered rather than drawn it's easy to render out at power of two scales with transparency maintaining detail and ketting really good results even with 1.5x scaling as you have something close to it available.
    I'm going to try this approach using MipMaps for tiles that don't need transparency - constructing the images out of RGB should be fun...

  • @KormVerde
    @KormVerde 2 роки тому

    Oh my god, you just saved my project. Thank you very much for the info about cameras cus I couldn't find anything helpful in the documents.

  • @betatester03
    @betatester03 5 років тому

    Concise and insightful, as usual.
    Love the whiteboard. What software were you using for that? That could be pretty helpful when creating class follow-up videos for my students.

    • @PixelatedPope
      @PixelatedPope  5 років тому +2

      It's a bit of a cludge :D It's a drawing app called Leonardo running on my Surface Book 1. I then used Chrome Remote Desktop to show the Surface on my desktop.

  • @super_bits
    @super_bits 2 роки тому

    Niceeee! Need more video tutorial!!

  • @randokaratajev2617
    @randokaratajev2617 3 роки тому

    Jesus man. I'm so grateful for your tutorials. I've dropped my project for months because I couldn't understand why some tiles were stretched during camera movement. I haven't yet tried your dynamic scaling solution but once I get off from work, I'll try it out. I really hope this solves the problem. I still have one question tho: Is it possible to get an invite to your discord server and ask you or the other experts for advice if any errors or problems might occur. Do I need to pay for the help or how do you provide it? free if the time suits you? I'd be also glad to show you my not so impressive platform game in the progress.

  • @boxedgamedev9462
    @boxedgamedev9462 2 роки тому

    was super helpfull I was able to make an infinit room in a fullscreen window (also added some camera movment code myself) much more customizable than the settings in the room editor

  • @lloyd011721
    @lloyd011721 4 місяці тому

    this video is super helpful

  • @cjtodd6244
    @cjtodd6244 3 роки тому +1

    THANK YOU SO MUCH I LOVE YOU

  • @H0JuSan
    @H0JuSan Рік тому

    Cheers mate, you're a legend

  • @killerkartoffl
    @killerkartoffl Рік тому

    Very nice Video

  • @squidman3113
    @squidman3113 5 років тому

    Hey thanks for the tut, I've got a small problem though, while the camera works and follows the player, it doesn't do that slow drag back to the center of the screen for the player character. Did you maybe change something in the other parts of the camera events and not show it? Or am I just missing something?

  • @alexandervladimirov4365
    @alexandervladimirov4365 2 роки тому

    thank you!

  • @LeonacYT
    @LeonacYT 5 років тому

    Thank you

  • @davidwillison6926
    @davidwillison6926 5 років тому

    Nice job explaining the new system. The one part of setting the view within the room editor that was missing is the concept of view border. I assume that if you wanted to include this aspect with your system, you would calculate it manually rather then using the built-in functions (camera_set_view_border)?

    • @PixelatedPope
      @PixelatedPope  5 років тому

      Right. Basically, you take full control over the logic of your camera, so if you only want the camera to move when the object is close to the edge, you can handle that with logic.

  • @laserlemons1577
    @laserlemons1577 5 років тому

    This makes much more sense than any other tutorial I've seen about cameras, thanks! Now it's time for me to go back and rip out all my old camera code...

  • @ThiagoJaqueta
    @ThiagoJaqueta 5 років тому

    4:20 - Just a quick heads-up, from my experience, a Low Res app surface will increase the performance on Low end GPUs (I'm talking about potatoes here, like the GT 710, HD 6450 and APUs).
    Add an option for the player if possible (Or just scale down if the Frametime is too High).

  • @hiddenname7232
    @hiddenname7232 5 років тому

    YES, thank you. I only want one view and I make a lot of different projects, and it gets frustrating to have to figure how the hell I have to set my camera up again EVERY time. So many features I don't need. (They're nice... on that rare occasions you want to use them but...) Why can't they just have a simple 2d camera as another option?

  • @meh3643
    @meh3643 3 роки тому +1

    finally a working code!

  • @SonictheHedgehogInRealLife
    @SonictheHedgehogInRealLife 4 роки тому

    This is a good video

  • @ajinkyax
    @ajinkyax 7 місяців тому

    wow this works even in 2023 GM version. thanks

  • @hylt0n
    @hylt0n 5 років тому +5

    i love you

  • @diddlenfiddle7311
    @diddlenfiddle7311 5 років тому

    So I've been getting really disheartend with the room editor's camera controls. Thank you soo much! I can carry on with my project now!

    • @PixelatedPope
      @PixelatedPope  5 років тому +2

      Nice! If you are ever feeling disheartened and want to commiserate with other GM users, make sure you join the Discord server! We'll help you get over whatever has ya down! discord.gg/By6u9pC

    • @diddlenfiddle7311
      @diddlenfiddle7311 5 років тому

      @@PixelatedPope I don't know why it took me so long to see this! Thank you again

  • @McDumDum
    @McDumDum 3 роки тому

    how would you go about making the camera move only if the object is within the view's bounding box? I'm making a fighting game and I'm not sure if I can figure this out.

  • @MagicPlayaFTW
    @MagicPlayaFTW 5 років тому +1

    0:35 is why I subscribed. I don't know if you intentionally subverted my expectations with that punchline, but damn, I thought he was going to say, "I'm interested in what game you're making." or something to that effect.

  • @teinimon2395
    @teinimon2395 5 років тому +1

    I see that when you start the game, the view moves from where it is positioned in the room (top right) to where the player is. I haven't tested this but to make the view start right at where the player is when you run the game, adding this code in the ROOM START event should do the job.
    if instance_exists(o_player) {
    x = o_player.x;
    y = o_player.y;
    }

    • @PixelatedPope
      @PixelatedPope  5 років тому +4

      You would need to duplicate the entire code of the end step event without the lerp and that would do it.
      view_enabled=true;
      view_visible[0]=true;
      if(instance_exists(obj_player))
      {
      var _x = clamp(obj_player.x-view_width/2,0,room_width-view_width);
      var _y = clamp(obj_player.y-view_height/2,0,room_height-view_height);

      var _cur_x = camera_get_view_x(view);
      var _cur_y = camera_get_view_y(view);

      camera_set_view_pos(view,_x,_y);
      }

    • @teinimon2395
      @teinimon2395 5 років тому

      @@PixelatedPope Yeah, that works. Thanks for correcting. I should've tested that before commenting.

  • @KaziiTheAvali_inactive
    @KaziiTheAvali_inactive 3 роки тому

    i love it however personally i would when room load set it where the player is in the middle aslong as its not on the edge (then i would have it clamped) to prevent it moving from top right to player smoothly

    • @PixelatedPope
      @PixelatedPope  3 роки тому +1

      Yup! Great idea to snap to the player's position in the room start event. Or it can look cool to do it a bit above or below the player once you have a fade implemented, so it looks like it's just sliding into place as the fade completes.

  • @MrKingJavo
    @MrKingJavo 5 років тому +1

    Love the work you're doing. Keep it up! Not sure about anyone else but I prefer no music on these tutorials. It's like playing music when in class trying to learn something. Just my 2 cents.

    • @PixelatedPope
      @PixelatedPope  5 років тому

      Alright, thanks for the feedback! I'll continue to monitor opinions on this, and adjust future videos accordingly. Thanks for watching!

    • @chef2654
      @chef2654 5 років тому

      I agree with you, if you want a temporary fix tho,, Youn change your equalizer setting to boost vocals :)

    • @PixelatedPope
      @PixelatedPope  5 років тому

      @@chef2654 It doesn't help that my audio quality was ass in this video. Fortunately that will be fixed from now on!

  • @GradoniusTheWise
    @GradoniusTheWise 3 роки тому

    Thank you for your videos! I have once used two views for a single-player game and I am curious if you can share why I am wrong as it seemed correct at the time. This was back before GMS by the way. I used one view to follow the character and then a second view layered on top of that but in the bottom right corner as a mini-map / radar. This seemed like a pretty good use case for 2 views on a single-player game but let me know!

    • @PixelatedPope
      @PixelatedPope  3 роки тому +1

      Absolutely! It "seems" like a good idea, but it's actually terrible! When you have a second view, every single object in that room runs its draw event for that view. Every. Single. One. I imagine not a single thing visible in your first view was meant to be seen in your second view. Or at least, a very limited number of them. But since you used a second view, EVERY object lined up to run their draw event again. Not to mention other non-object related drawing like all of your backgrounds and tiles. Everything draws for every view. I don't think I need to explain why this can be very bad.
      Radars and minimaps can be easily created using a surface, and then you have full control over what is drawn to that surface. This will be much better for performance and it's way easier to manage than positioning views in a room.

    • @GradoniusTheWise
      @GradoniusTheWise 3 роки тому

      @@PixelatedPope Thank you for the good insight! I am still new to utilizing surfaces but I am looking forward to explore them.

  • @ocoro174
    @ocoro174 4 роки тому

    is there ANY way to fix jittery camera caused by parallax? especially noticeable when the camera is moving slow

  • @flye5003
    @flye5003 3 роки тому +2

    I got a black screen :/
    anyone has a clue of what could have caused that?

    • @PixelatedPope
      @PixelatedPope  3 роки тому

      Could be any number of things, but youtube comments aren't great for debugging. I recommend joining the GM Discord server. Many of the members there are very familiar with this camera solution and can help you figure it out. If I'm available, I'll help myself!

  • @tyleranders9972
    @tyleranders9972 5 років тому

    Great stuff very informative and easy to understand

  • @drsquash2003
    @drsquash2003 4 роки тому +1

    What would be the best way of implementing view scaling or 'fov' based off the camera's speed? (ie the faster the camera moves, the wider the fov becomes)
    I thought about just creating a muliplyer:
    var _fov = 1 + (point_distance(_x, _y, _cur_x, _cur_y) * .1
    Then applying that to the:
    camera_set_view_size(view, view_width * _fov, view_height * _fov)
    But as you stated, the view size needs to be established prior to calculating it's coordinates, soooo...

    • @PixelatedPope
      @PixelatedPope  4 роки тому +1

      Yeah, changing the size of the view at any time immediately complicates things. I usually operate on a "base" size and scale things off of that. So instead of referencing the current view size to get your view_width and height, you would have a static variable that represents your base size.

    • @drsquash2003
      @drsquash2003 4 роки тому

      @@PixelatedPope Hi again. Thanks for taking the time. I'm getting a strange "overlapping effect" with collisions. If I remove the camera from the room, and test collisions, they appear pixel perfect. I am using subpixel movement, and using this code:
      // Check for collisions and move player
      if(place_meeting(x + move_speed, y, obj_solid))
      {
      x = round(x);
      repeat(ceil(abs(move_speed)))
      {
      if(!place_meeting(x + sign(move_speed), y, obj_solid)) x += sign(move_speed);
      else break;
      }
      }
      else x += move_speed;
      I snagged this code from a forum, and it seemed to work, up until implementing the camera. Just to clarify. Collisions are functioning normally. It's just the appearance that is off.
      Side note: I raised the window_scale to 16, as it drastically improved the smoothness of the camera

  • @IRBenHunter
    @IRBenHunter 5 років тому

    This is great - one question out of curiosity: why do you start your var names with underscores (eg _x, _y, _spd). is this a common naming convention or just personal habit?

    • @PixelatedPope
      @PixelatedPope  5 років тому +2

      Both? Sometimes I tell myself I started the trend. It was more important back in GMS1 and earlier when variables didn't have different colors, but it's a good idea to differentiate your vars from your instance variables. And the easiest way to do that consistently and make it immediately recognizable at a glance is with some sort of special character. The other advantage is being able to reuse common variable names.
      For example, say you are looping through the rows and columns of a ds_grid with a for loop. Many would do something like this:
      for(var i=0; i

    • @IRBenHunter
      @IRBenHunter 5 років тому

      @@PixelatedPope thanks, great explanation!

  • @MANNLIERMANNCO
    @MANNLIERMANNCO 5 років тому

    Hi, um first of all, im a huge fan and i don't know what i would've done without your aspect ratio videos haha.
    I followed this tutorial and my one concern is that when the game starts it sort of expands into the window for a split second, as if decompressing.
    I noticed it kinda happens in your example aswell, any ideas how to get around it?

    • @PixelatedPope
      @PixelatedPope  5 років тому +2

      Yup. Typically we start with a pure black screen and then "fade in" to your title screen or company logo, etc.

    • @MANNLIERMANNCO
      @MANNLIERMANNCO 5 років тому

      @@PixelatedPope Oh yeah, that makes sense hahaha. Thanks so much for the reply my man !

    • @MANNLIERMANNCO
      @MANNLIERMANNCO 5 років тому

      Hey!, i didn't wanna nag you anymore but i encountered a bit problem while playtesting. When on Fullscreen there's kind of a tearing on vertical movement, it's very subtle and it looks kind of like static on an old tv. It appears to not happen when zooming in or manually resizing, so an easy fix outta be to just avoid fullscreen.
      May be an unique problem to my setup, but i'm following pretty much all your tutorials regarding aspect ratio and cameras so i dunno if it's a recurring problem amongst other people.
      It's very much minor so feel free to dismiss this haha! thanks!

  • @CopyCopyOriginal
    @CopyCopyOriginal 3 роки тому

    ty for the content! when you say 'set zoom up here' what do you mean? I keep fiddling with this camera_set_view_size function to get the camera to zoom in on the player during certain events, but it doesn't focus the player.

    • @PixelatedPope
      @PixelatedPope  3 роки тому +1

      Yeah, it can be a bit tricky. You need to change the size of the view to zoom in/out and THEN position the view. Because when we are positioning the view we are always moving the top left corner, if you center it on the player, then resize it to be smaller, your player will move down and to the right.
      So resize, then center. And you have to center based on the new size, not the original, so don't get the size, resize and then center based on the previous size.

  • @reubenmoloney4628
    @reubenmoloney4628 2 роки тому

    There can be uses for two cameras without split-screen. Using the built in view-ports is a valid option.

    • @Squidmoto3
      @Squidmoto3 2 роки тому +1

      no its not, you're horrible at programming

  • @Stefan-bn4wh
    @Stefan-bn4wh 5 років тому +1

    Hi! Great tutorial! Thanks so much again! I could easily combine it with your display manager. The only thing that I couldn't solve is that the player is always jittering when camera "lerps" towards him at the end. Do you, by chance, have a solution for this issue? thx in advance. steve

    • @PixelatedPope
      @PixelatedPope  5 років тому +1

      Are you using sub pixels? If not, that would be a quick way to fix it. If not... man, you get into some sketchy territory. Much discussion has been had about how to move the camera in a locked pixel grid without jittering... it's a definitely challenge.

    • @Stefan-bn4wh
      @Stefan-bn4wh 5 років тому

      @@PixelatedPope Do you mean by "are you using sub pixels?" that I round the x,y positions? No I don''t.

    • @PixelatedPope
      @PixelatedPope  5 років тому

      @@Stefan-bn4wh Is your application surface larger than your view size?

    • @Stefan-bn4wh
      @Stefan-bn4wh 5 років тому

      @@PixelatedPope No I don't think so. I use your display_manager & the simple as possible camera. So my application surface is exactly as large as my view size right? Should I change it? .... Oh acutally my the size of my view is ideal_width & ideal_height right? (So zoom-x times smaller)

    • @PixelatedPope
      @PixelatedPope  5 років тому +2

      @@Stefan-bn4wh Yeah, that would be the quickest way to smooth things out. Try setting your app surface to be 2 or 3 times the size of your view, depending on your base view size (but don't exceed the size of your window), and see if that helps smooth things out. If not, something else might be going on and I recommend hitting me up on Discord for further investigation.

  • @roastedzerg
    @roastedzerg 4 роки тому

    You mentioned split screen, how would you go about making a split screen using the new gms2 cameras? Im only finding old solutions pre-gms2 that don't seem to work anymore. The old way isnt working for me and no matter what port size i do, the camera goes fullscreen. Thank you

    • @PixelatedPope
      @PixelatedPope  4 роки тому +1

      I'm honestly not sure. I haven't even attempted it in GMS2, yet. I imagine you'd need to hook up a camera to the second view, and then manipulate the port variables to position and size them to both fit on screen.

  • @theeclipse8492
    @theeclipse8492 Рік тому

    the velocity of the camera looks like the hotline Miami's camera XD

  • @MetalJoshi156
    @MetalJoshi156 2 місяці тому

    *ME LIKE A COMPLETE DUMBASS, MISSING THAT ONE SMALL WARNING IN THE BEGINNING* ("Don't use the room settings.")
    Thank you, thank you, THANK YOU. The scrolling is now completely smooth as butter, at all possible refresh rates without animations breaking.
    To anyone rolling their eyes at my mistake, yes I'm a complete idiot. But small oversights like my one could happen to *you* as well for another silly reason. Be VERY careful!

  • @jeffjensen2263
    @jeffjensen2263 5 років тому

    Been trying to mesh together your first one with this one, but would really love a completely fresh from scratch video based on GMS2. Also a bit confused as to some of the magic numbers, like view_width=1920/6 - you just say that the higher the division number, the better, but don't really go further into it. Any chance you would consider making something like the old part 3, but from scratch in GMS2?

    • @PixelatedPope
      @PixelatedPope  5 років тому +1

      Yeah, I've helped a few people with this exact thing. I could do a future video on that, sure, but who knows when I'll get around to that. For the time being, join my Discord server and ask there, and I or someone else familiar with the topic will help walk you through it and answer any questions you might have. discord.gg/By6u9pC

    • @PixelatedPope
      @PixelatedPope  5 років тому +1

      Alternatively, you could check the pinned comment which is how I've personally meshed the old tutorial and this one. But feel free to reach out with any specific questions.

  • @samehat
    @samehat 4 роки тому

    One question I didn't see answered:
    For this approach, I know we don't use room for viewports but... do you have Enable Viewports ON or OFF in the Room Editor?
    I assume OFF, but wanted to be certain since it's default ON... :)

    • @PixelatedPope
      @PixelatedPope  4 роки тому

      Yup! You shouldn't have to set anything view related in the room editor ever with this method. The room start event checks that box for you.

  • @matyastomoga9944
    @matyastomoga9944 4 роки тому +9

    The only problem is that the things you've talked about in those 3 videos don't really work with GMS2.

  • @badwrong
    @badwrong 5 років тому +1

    I was wondering, why is camera_set_view_size called every step? Can it just be called if the resolution changes?

    • @PixelatedPope
      @PixelatedPope  5 років тому

      Yup! I usually call it in the step event because a. it doesn't really "cost" anything significant. And b. if I decide to do zooming or something, I'll end up having to move it into the step event anyway.

    • @badwrong
      @badwrong 5 років тому

      @@PixelatedPope thanks! The part about "cost" was what I was also getting at. Now I'm fiddling around with getting stuff working with isometric view.

  • @steviegillen82
    @steviegillen82 5 років тому

    When I switch to fullscreen the fps drops from 60 down to 30, then back to 60 when exiting fullscreen. What would be causing this issue? I'm thinking the application surface is being stretched and slowing the performance

    • @PixelatedPope
      @PixelatedPope  5 років тому

      That's very possible, especially on something like a 4K monitor. Ideally, you wouldn't always size your app surface to be the same size as your window; it's not really necessary. Instead pick a nice multiple that gives you enough smoothness without being super high res. You could even make it an option for your players to choose smoothness over performance.

  • @slickygreasegames
    @slickygreasegames 3 роки тому

    I loved this tutorial and I know its going to help me a ton. I was using another camera system before, but I find this one to be more useful. I do have a question through. For some reason , when i play my game my camera zooms in to my character a bit too much( i think it is because I have the width at 1920/6 and height at 1080/6 in the create event. Is there someway i can fix this because you said the higher the number, the better it is going to look but I do not want the camera to zoom in too much.

    • @PixelatedPope
      @PixelatedPope  3 роки тому

      Yeah, just go down to 5! The higher the better but not at the cost of how you want your game to look. If it's too close, just step it back. I wouldn't go below 3... but 2 is technically okay as well if you are okay with your game looking absolutely awful on old laptops.

    • @slickygreasegames
      @slickygreasegames 3 роки тому

      @@PixelatedPope Another question, how about the aspect ratio, so the pixels will look nice and clean (I'm using hand drawn sprites). I was wondering how that would be set up with this system. I saw your other tutorials about aspect ratio, but I don't know which code to put in. And one more question, this may be a dumb one but on the left where you can change the size of the screen in the room, with this code I won't have to do that anymore?

    • @PixelatedPope
      @PixelatedPope  3 роки тому

      @@slickygreasegames Yup, don't mess with the camera / view settings in the room editor anymore. This code does all that for you.
      As for aspect ratios, I would recommend not worrying about them. You don't need to support ultra wide screen, or 16:10 or whatever. Just support 16:9 and be okay with some black bars. Nobody is going to care, and it's really not worth the effort for 99% of GM projects.

    • @slickygreasegames
      @slickygreasegames 3 роки тому

      @@PixelatedPope One more question. Since my camera zooms in on the character with those settings I have, would I need to shrink the size of the sprites and the background assets to fit with the room?

    • @PixelatedPope
      @PixelatedPope  3 роки тому

      @@slickygreasegames Not necessarily. You can always increase the size of the view. You also mentioned "hand drawn" sprites... if you aren't doing "pixel art" with hard edges and precise pixels... well, almost none of this matters. You can make your view almost any size you want, including 1920x1080 if your sprites are just that large.

  • @sar9565
    @sar9565 5 років тому

    @PixelatedPope I have tried a lot with the camera most of them works with my game, but there is one main problem (which happens every time) whenever I add or do something with the camera the same obj moves in a weird way, like the sprite is moving , can you help?

    • @PixelatedPope
      @PixelatedPope  5 років тому

      I can probably help with that. Join my Discord server and I or some other member of the server will try to assist. discord.gg/By6u9pC

  • @Isseinoyuu
    @Isseinoyuu 5 років тому

    I have a couple questions:
    Why do you update the camera view size every step? As far as I can tell you only need to do that once unless you're changing the view size dynamically.
    When I start my game there's a small graphical glitch where it displays a squashed frame before filling out the window. Did I do something wrong, is there a way to fix that, or is that just the way it has to work?

    • @PixelatedPope
      @PixelatedPope  5 років тому +5

      That's the way it has to work. Typically you want the first frame of your game to just be black, and then fade into the next thing you want the player to see. Then nothing ugly will be on screen.
      As for updating the camera size... there's no reason not to. And if your game supports zooming in or out, then you wouldn't have to change much to support that with this setup. You are welcome to set the view size in the room start event when you enable the view and never touch it again if that's all you need for your project, though.

    • @Isseinoyuu
      @Isseinoyuu 5 років тому

      @@PixelatedPope thanks for the reply. What you suggested about starting on a black frame is what I ended up doing. It felt like I was missing something so it's good to know I wasn't.

  • @RoyalGuardians
    @RoyalGuardians 4 роки тому

    Hey pope, i know it's a little bit later, but there's anyway to make my camera no shivering? that's because my player_speed are 1, and i've read that view x and y can't be a cracked number, liker 0.50 or 1.50, my player movements cut hspd and vspd in half in diagonals, so, when i move, my player just don't stop shivering, and if i try to floor, the player stops shivering, but the scenario, start to get a little bit unfocused, sorry for my bad english c-c

    • @PixelatedPope
      @PixelatedPope  4 роки тому

      View positions actually CAN be non-whole numbers. But the easiest way to fix this is to use sub-pixels. Resize your application surface to be the same size as your window, and you'll notice things should stop jittering.

  • @MsPinky1306
    @MsPinky1306 4 роки тому

    nice

  • @InCognito-bc4ce
    @InCognito-bc4ce Рік тому

    In search of a solution to the problem of pixel distortion, I found myself here, in front of your playlist. These guides were very useful for me, but I still have a question about views and cameras. Is it possible to add a mini-map for a 2D game with camera? If not, are there any alternative methods to manage game resolution and aspect ratio with such possibility?
    I'm quite unskilled at GMS.

    • @PixelatedPope
      @PixelatedPope  Рік тому

      It's absolutely possible, yes. UA-cam comments aren't exactly the best way to get help with GameMaker, though. I highly recommend joinging the GameMaker Discord server and asking your question there. If I'm around, I'll help you myself. If I'm not, there are lots of friendly, helpful people there to answer questions. Here's a link: discord.gg/gamemaker

  • @cjtodd6244
    @cjtodd6244 3 роки тому +1

    For some reason my camera does not move slowly towards my player, just stays on it the same it would without the added code. Can't seem to figure out why, triple checked the code but there is always something to miss.

    • @PixelatedPope
      @PixelatedPope  3 роки тому +1

      Often this is because something else is moving the camera, likely because you had a different solution in place in the project before implementing this solution. So you have to "undo" everything you had before. This could be a different object moving the camera, or it could be the "object following" setting in the room settings.
      Or, and this happens a lot, it could be that you position the camera on the player, then calculate the gradual position, and then move the camera again. Make sure you don't have camera_set_view_pos() called twice in your code.

    • @cjtodd6244
      @cjtodd6244 3 роки тому

      @@PixelatedPope You were right I did the mortal sin of having the camera follow an object and didn't realize. New problem is the camera doesn't start on the player between room transitions. I might just scrap that part of the code tho because it doesn't seem like I honestly need it for my game. Thanks for the response though!

    • @Kuzyn
      @Kuzyn 2 роки тому

      @@cjtodd6244 Hey, where you had this? That camera followed an object? I'm trying to figure out same problem that my camera doesnt move slowly towards player.

  • @ignaciosb8779
    @ignaciosb8779 5 років тому

    4:41 I like the goal a lot.
    I have a doubt though.. making the camera_obj persistent will not cause any conflict in menu screens?
    For example the main menu screen before starting a game.
    I mean, I guess the view settings will have the same values for every room.
    So, in static menu screens where I want everything to be visible at once.. should I make sure that the size of the whole menu fit with the view height and width..?

    • @PixelatedPope
      @PixelatedPope  5 років тому +1

      Yup! Your menu screens should use the size of your view if they are full screen.

    • @ignaciosb8779
      @ignaciosb8779 5 років тому

      @@PixelatedPope Thanks.

  • @lksxxtodin5292
    @lksxxtodin5292 Рік тому

    These tutorials are amazing!
    Why did you stop making videos?

  • @alexkennedy4990
    @alexkennedy4990 5 років тому +1

    I don't doubt there's a reason, but can you explain why we shouldn't set up the view in the room editor?

    • @PixelatedPope
      @PixelatedPope  5 років тому +2

      How many rooms does your game have? Is it 1? Then go ahead and set up your view in the room editor. Is it 100? Using the room editor suddenly feels a bit tedious, no? But, hey you only have to do it once and then it's done. Until you decide you don't like your original resolution you chose. Now you get to go back through all 100 rooms again and fix it. There's nothing inherently "bad" about setting up your views in the room editor, but on larger projects it is impractical.

    • @alexkennedy4990
      @alexkennedy4990 5 років тому +1

      @@PixelatedPope I see, that makes sense. I thought it might be an inherent problem, similar to the problems with persistent rooms that you mentioned in another video. Thanks for the reply. Thanks for making the palette swapping thing on the marketplace too, by the way. Really useful for my project, there's no way I was figuring out that on my own.

    • @PixelatedPope
      @PixelatedPope  5 років тому +1

      @@alexkennedy4990 No problem! Thanks for watching and good luck with your project!

    • @alexkennedy4990
      @alexkennedy4990 5 років тому +1

      @@PixelatedPope Thanks!

  • @SirBenjeh
    @SirBenjeh 5 років тому

    Could you make a tutorial on how to make a camera that follows more than one object on screen?

    • @PixelatedPope
      @PixelatedPope  5 років тому

      That's not too difficult a problem, but I'd need more information. Would you want the view to stay centered on all objects? Would you want it to zoom in and out as they spread out or got closer together? Best to ask in the discord server and I can help you there.

  • @TheToxicHub
    @TheToxicHub 4 роки тому

    Really loving this camera object, but I've been having a couple problems with it. Everything works great until needing to switch rooms, then the camera bugs out. Having the obj_camera be persistent doesn't fix anything, nor does creating a new obj_camera in the new room.
    I have no clue why this problem is occurring, but any tips would be incredibly helpful!

    • @PixelatedPope
      @PixelatedPope  4 роки тому +1

      I would recommend joining the GM discord server and asking me there. UA-cam comments aren't great for troubleshooting. discord.gg/By6u9pC

  • @KlausWulfenbach
    @KlausWulfenbach 5 років тому

    I have one question: I already know how to make objects "wrap" from one side of the level to the other (if x exceeds room_width, then x -= room_width, if x < 0, then x += room_width and so on), but how can I use a single view camera to have a wrapping view (move close enough to the right side, I'll actually see part of the left side, and the objects wrapping from one side to the other just appear to move normally)? Does this require multiple views?

    • @PixelatedPope
      @PixelatedPope  5 років тому +1

      Hmm... That might be a good use case for multiple views. What I usually do for room wrapping like that is have like... a surface or something of the room drawn to the left and the right of the room itself. Then each object draws itself in its room position, but also draws itself x-room_width and x+room_width. So there are these sort of "clones" of your object but it's not actually the object itself. Multiple views multiplies the time it takes to draw your game, since each object will be drawn multiple times. So you really should avoid it as much as possible.

    • @KlausWulfenbach
      @KlausWulfenbach 5 років тому

      @@PixelatedPope Thanks!

  • @0x44_
    @0x44_ 2 роки тому

    Any chance of making a split screen camera video that scales? Not too many resources on the subject.

  • @aaronofalbion
    @aaronofalbion 5 років тому

    So in another video, I watched they used a split screen to make a minimap for the game. Is there a better way?

    • @PixelatedPope
      @PixelatedPope  5 років тому +1

      MUCH better. Surfaces.

    • @aaronofalbion
      @aaronofalbion 5 років тому

      @@PixelatedPope Now... if only I can decode what you just said and somehow apply it to my game. lol anyway, nice video. I tried it but it did not work for me for some reason.

    • @PixelatedPope
      @PixelatedPope  5 років тому +1

      @@aaronofalbion If you want some help, I recommend joining my discord server (link in the description). Lots of people, including myself, who can help you with anything GM related!

    • @aaronofalbion
      @aaronofalbion 5 років тому

      @@PixelatedPope thanks man. X'D