Here's a few timestamps for the different camera modes: follow_object: 9:12 follow_mouse_border: 11:21 follow_mouse_peek: 16:25 move_to_target: 17:45 move_to_follow_object: 19:21 follow_mouse_drag: 20:52
other tutorials cause to my game a very shaky movement when my player stops, probably because the fact that the camera was literaly following the player xD, but you tutorial works just perfect for me, thank you so much.
Hello, Sensei Cosmonaut! Wonderful tutorial. I wrote a quick screenshake camera mode, I wanted to share it with everyone. (You'll also have to add "screenshake" to the enum, and "shake_amount", "shake_timer", "starting_shake_timer", and "starting_shake" to the create event, setting them at whatever numbers you wish). case cammode.screenshake: var ran_x = random_range(-shake_amount, shake_amount); var ran_y = random_range(-shake_amount, shake_amount); if(!instance_exists(following)) break; cx = following.x - (view_w/2) + ran_x; cy = following.y - (view_h/2) + ran_y; shake_timer -= 1; shake_amount -= random_range(0,1); if shake_timer
For all who interested how exactly lerp() function works: my_variable = lerp(10, 30, 0.2) is equal to my_variable = 10 + ((30 - 10) * 0.2) my_variable = 14 So, if you want "a" slowly approach "b" by 10%, you can write: // Create event a = 20; b = 50; c = 0.1; // 10% = 0.1 // Step event a = lerp(a, b, c); // or write a = a + (b - a) * c Now each frame "a" will be equal to: 20 20 + (50 - 20) * 0.1 = 23 23 + (50 - 23) * 0.1 = 25.7 25.7 + (50 - 25.7) * 0.1 = 28.13 and so on... Yep! As simple as that :-)
@@Cyber_Shark1209 I just like to understand how things work ;-) Also fun fact - I use Godot now instead of GameMaker Studio 2 - it's more powerful (and it's Open Sourced and not owned by a shady company- YoYo Games is owned by Opera now which is owned by Chinese shady financial organization...) xD
@@igorthelight You probably could be a good teacher. Can you please explain the problem with Yoyo a little more, now because of the relationship with Opera, is it embarrassing to use GMS2? I'm just from Ukraine and have not even heard about it, but I checked it and it's true. Do you think it is promising for me to create projects and content in GMS2?
@@Cyber_Shark1209 I would be 100% open and neutral: Opera's owner is not "really" a problem. They didn't do anything suspicious as far as I know. But being a Chinese-based company makes them comply to their strict Government policies (you can't refuse them ;-) ). Also, being owned by a microinvestment company imply that it "may" do some shady business. Or may not xD We don't know! So I just switched to another engine which is more powerful and has a more "clean" background. So could you use GMS2 - you can! Should you try something less shady in future - I think you should try ;-) But you don't have to delete GameMaker Studio 2 right now, just because it's owner may be shady a little bit. I'm from Moldova btw ;-) We are polarized about the situation in Ukraine. Most of my friends agree that this war could be avoided. While other people (even from my relatives...) believe Russian propaganda. Of course - those are more older people, who lived too long in USSR... Take care and stay strong!
Hi i have just stumbled upon your videos and they are very well presented and informative. I am a game developer and watching your methods of coding is inspiring, thank you i will subscribe :)
Awesome video, but I have a question about the "follow_mouse_peek: 16:25" Instead of adding a lerp to the mouse, is there a way to add a setted value to the mouse/view? Like, if the mouse is to the left of the player the camera will move 30 pixels to the left.. If the mouse is over the player the camera will move 30 pixels up.. It will consider only the direction of the mouse and not how far/close it's. I'm trying to do it for a few minutes without success... Any idea would be welcome. Thankss
Oh you're right! I don't think I'd ever actually used strings before in an enumerator beyond seeing if the syntax threw an error in the editor. Thanks for letting me know - my apologies for the mistake!
Hello, I am trying to implement a follow_mouse_peek: 16:25 method, but when I do this my player character starts wobbling when moving diagonally. Can someone help?
Very interesting tutorial! I'm still having a very hard time understanding how the new camera system works in GM2 though... I have been struggling with an issue I don't quite understand, even when trying from a brand new project. If I set a view to follow a character (view is half the size of the room), some objects appear duplicated and offset when the camera moves. It's hard to explain without showing exactly what's happening but basically, if I draw a string in the character's Draw event (in order to see its coordinates at any time), the text will move faster than the object. I don't understand why it's happening since I'm using room coordinates for both, basically setting the text to match the X/Y coordinates of that character in the room. Why would the camera affect where the string is displayed and how to fix it? I'm clueless and I've spent days trying to figure this out... It's also happening with a custom mouse cursor (an object following the mouse location), in which case it could be because view coordinates and world coordinates are not the same; but why is it different for an object and a string when both are using world coordinates? It basically breaks everything related to my UI, so I absolutely need to understand what's going on before even trying to fix it! The functionality seems intact though, it's just a matter of where objects appear to be. I've added many coordinates to debug this, the coordinates themselves are consistent, things just don't appear where they should. Even though the coordinates used in the draw event of objects are based on world coordinates, they seem to be affected by the camera position.
Nevermind, I noticed some objects were using DrawGUI instead of Draw events, forcing coordinates to be based on the current view. I had to modify quite a few events and rearrange the code accordingly but in the end it was much simpler than I thought.
Hello. Thank you very much for this great video. I noticed that, when changing from - move_to_follow_object to - follow_mouse_drag the screen jumps to a different position on screen, and so does the mouse cursor. This is best noticed at 0.25 speed in the video. Any ideas on what may cause this jump? It only happens if we click and drag somewhat far away from the player. Kee up the good work and... Thank you once again, FriendlyCosmonaut. =)
Hey, thanks for the tutorial! It really helped me. Would it be possible to add zoom in or out too? I'm interested specially in the follow_mouse_border state.
Yes, that's the next video that will come out :). Though I have to say, I'll probably be returning to "hiatus" to work on my personal projects again after.
@@FriendlyCosmonaut yeah I have checked and rechecked in which the following object is set to my player object named "objPlayer" in which everything else is the same as it is in the video.
Has anyone managed to get a camera zoom mode working? Have been trying to incorporate a mode for when I talk to an NPC the camera smoothly zooms in a bit and then back out when dialogue is over. I've got something close but running into issues and I feel like there is a much easier way to do it.
Thank you for the video but i didn't understand the "follow_mouse_drag" part... In that mode mouse_xprevious shouldn't be instantly equals to mx and same thing with mouse_yprevious?
Is it possible to make camera rotation like in 3d strategies? For example when you hold middle mouse button and moving mouse. I now it's 2d, but still. And objects have different angle sprites and it's changes when you're rotating camera, is it possible???
Great videos, how would you do a camera to zoom in where ever the mouse currently is, the mouse being a standard mouse not as an object... without leaving the game window?
I want to try somthing like clásic resident evil switch camar position on a 3d game, each time object Reach a point camar show a different perspective, sems like no one nows how to do that :( any help its welcome
Good day! as you all it works if you have not created a camera through camera_create ? I want the player to move the card with his finger or mouse and do everything as in your video, but nothing works. Answer please
I can't promise it will be anytime soon but I would like to do one on this topic at some point. In the meantime, a couple suggestions for this are just to simply iterate through your tileset at the room start and assign tiles a depth depending on their position in the room (you can do the same thing with sprites in asset layers). Alternatively there are some more advanced techniques like this one: www.yoyogames.com/blog/458/z-tilting-shader-based-2-5d-depth-sorting
Well yeesh, Enumerators are sure gonna make data structure management a lot better. I say yeesh because my game has been in development for a year and a half now, and good god Data management is a nightmare
How would you adapt this to a splitscreen format? could you code multiple viewports in the same camera that would show up on the screen at the same time?
I have a question do you know if there is a tutorial which learns you to make a system for an interior of a moving object like a spaceship and that the player can move around in it
I don't know a specific one for that, but I'd say it would just involve switching rooms and saving the positions of objects in each room when you do so!
Hey FriendlyCosmonaut, I really appreciate all the tips! And just wanted to let you know that for some reason your Patreon link in the description of this video is broken. It seems fine on newer videos and directly from your UA-cam. Not sure if it's broken on older videos as well, just noticed it here.
So... I don't mean this in a horrible way, but I'm super glad that Patreon pushed through that donation. I miss your videos. TT. Is there any chance of you streaming or doing videos of your development of your new game? I need my FC fix!
Haha, thank you! I've been meaning to do some streaming or devlogs for aaages, I've just been a bit hesitant as it's still early-ish stages. I hope that changes in the coming months though!
Here's a few timestamps for the different camera modes:
follow_object: 9:12
follow_mouse_border: 11:21
follow_mouse_peek: 16:25
move_to_target: 17:45
move_to_follow_object: 19:21
follow_mouse_drag: 20:52
FriendlyCosmonaut nice tutorial ;) usfull, can u make video about level editor?
other tutorials cause to my game a very shaky movement when my player stops, probably because the fact that the camera was literaly following the player xD, but you tutorial works just perfect for me, thank you so much.
best camera tutorial in the world.
Hello, Sensei Cosmonaut! Wonderful tutorial. I wrote a quick screenshake camera mode, I wanted to share it with everyone.
(You'll also have to add "screenshake" to the enum, and "shake_amount", "shake_timer", "starting_shake_timer", and "starting_shake" to the create event, setting them at whatever numbers you wish).
case cammode.screenshake:
var ran_x = random_range(-shake_amount, shake_amount);
var ran_y = random_range(-shake_amount, shake_amount);
if(!instance_exists(following)) break;
cx = following.x - (view_w/2) + ran_x;
cy = following.y - (view_h/2) + ran_y;
shake_timer -= 1;
shake_amount -= random_range(0,1);
if shake_timer
One of the best channels about GameMaker Studio. Congrats.
For all who interested how exactly lerp() function works:
my_variable = lerp(10, 30, 0.2) is equal to
my_variable = 10 + ((30 - 10) * 0.2)
my_variable = 14
So, if you want "a" slowly approach "b" by 10%, you can write:
// Create event
a = 20;
b = 50;
c = 0.1; // 10% = 0.1
// Step event
a = lerp(a, b, c); // or write a = a + (b - a) * c
Now each frame "a" will be equal to:
20
20 + (50 - 20) * 0.1 = 23
23 + (50 - 23) * 0.1 = 25.7
25.7 + (50 - 25.7) * 0.1 = 28.13
and so on...
Yep! As simple as that :-)
This is a great explanation - I think I glossed over this far too quickly in the video.
so smart
@@Cyber_Shark1209 I just like to understand how things work ;-)
Also fun fact - I use Godot now instead of GameMaker Studio 2 - it's more powerful (and it's Open Sourced and not owned by a shady company- YoYo Games is owned by Opera now which is owned by Chinese shady financial organization...) xD
@@igorthelight You probably could be a good teacher. Can you please explain the problem with Yoyo a little more, now because of the relationship with Opera, is it embarrassing to use GMS2? I'm just from Ukraine and have not even heard about it, but I checked it and it's true. Do you think it is promising for me to create projects and content in GMS2?
@@Cyber_Shark1209 I would be 100% open and neutral: Opera's owner is not "really" a problem. They didn't do anything suspicious as far as I know. But being a Chinese-based company makes them comply to their strict Government policies (you can't refuse them ;-) ). Also, being owned by a microinvestment company imply that it "may" do some shady business. Or may not xD We don't know! So I just switched to another engine which is more powerful and has a more "clean" background. So could you use GMS2 - you can! Should you try something less shady in future - I think you should try ;-) But you don't have to delete GameMaker Studio 2 right now, just because it's owner may be shady a little bit.
I'm from Moldova btw ;-) We are polarized about the situation in Ukraine. Most of my friends agree that this war could be avoided. While other people (even from my relatives...) believe Russian propaganda. Of course - those are more older people, who lived too long in USSR... Take care and stay strong!
Thank you so much! This has been such a positive learning experience.
You are awesome! Thanks for these tutorials, this is very helpful to me!
That some nice looking pixel art!
Hi i have just stumbled upon your videos and they are very well presented and informative. I am a game developer and watching your methods of coding is inspiring, thank you i will subscribe :)
Wow!!! thank you very much!!!! this is very helpful to me!
Looool Im glad that you uploaded today. I was hoping that a new video was out. Guess my wishes were answered
I can't wait your next tutorial *quack* :D
Awesome video, but I have a question about the "follow_mouse_peek: 16:25"
Instead of adding a lerp to the mouse, is there a way to add a setted value to the mouse/view? Like, if the mouse is to the left of the player the camera will move 30 pixels to the left.. If the mouse is over the player the camera will move 30 pixels up.. It will consider only the direction of the mouse and not how far/close it's.
I'm trying to do it for a few minutes without success... Any idea would be welcome. Thankss
maybe using clamp?
Your tutorials are very helpfull, thanks a lot!
You can't use strings in enums ( 5:21 ). Just learned this :( See "Data Types > Enum" in the GameMaker documentation.
Oh you're right! I don't think I'd ever actually used strings before in an enumerator beyond seeing if the syntax threw an error in the editor. Thanks for letting me know - my apologies for the mistake!
I just simply love you. THANK YOU!
Thanks for the tutorials!
Hello, I am trying to implement a follow_mouse_peek: 16:25 method, but when I do this my player character starts wobbling when moving diagonally. Can someone help?
Glad to see another video! :D
Very interesting tutorial! I'm still having a very hard time understanding how the new camera system works in GM2 though... I have been struggling with an issue I don't quite understand, even when trying from a brand new project. If I set a view to follow a character (view is half the size of the room), some objects appear duplicated and offset when the camera moves. It's hard to explain without showing exactly what's happening but basically, if I draw a string in the character's Draw event (in order to see its coordinates at any time), the text will move faster than the object. I don't understand why it's happening since I'm using room coordinates for both, basically setting the text to match the X/Y coordinates of that character in the room. Why would the camera affect where the string is displayed and how to fix it? I'm clueless and I've spent days trying to figure this out... It's also happening with a custom mouse cursor (an object following the mouse location), in which case it could be because view coordinates and world coordinates are not the same; but why is it different for an object and a string when both are using world coordinates? It basically breaks everything related to my UI, so I absolutely need to understand what's going on before even trying to fix it! The functionality seems intact though, it's just a matter of where objects appear to be. I've added many coordinates to debug this, the coordinates themselves are consistent, things just don't appear where they should. Even though the coordinates used in the draw event of objects are based on world coordinates, they seem to be affected by the camera position.
Nevermind, I noticed some objects were using DrawGUI instead of Draw events, forcing coordinates to be based on the current view. I had to modify quite a few events and rearrange the code accordingly but in the end it was much simpler than I thought.
Hello. Thank you very much for this great video.
I noticed that, when changing from
- move_to_follow_object
to
- follow_mouse_drag
the screen jumps to a different position on screen, and so does the mouse cursor.
This is best noticed at 0.25 speed in the video. Any ideas on what may cause this jump?
It only happens if we click and drag somewhat far away from the player.
Kee up the good work and... Thank you once again, FriendlyCosmonaut. =)
"Peeking out" - ha! Reminds me of my younger, more influenced years.
@FriendlyCosmonaught How would I combine the 'Peaking Out' mode with 'Boarder Mode'? i.e. when mouse is at edges, it peaks out a bit?
Hey, thanks for the tutorial! It really helped me. Would it be possible to add zoom in or out too? I'm interested specially in the follow_mouse_border state.
Great tutorial! Will you be continuing the Farming RPG series soon too?
Yes, that's the next video that will come out :). Though I have to say, I'll probably be returning to "hiatus" to work on my personal projects again after.
Followed all of the steps so far but when you test the follow_object it doesn't follow the object (the player) that I have put in.
Hmm I'm not sure. I can only suggest making sure that the variable for what object to follow is being set properly.
@@FriendlyCosmonaut yeah I have checked and rechecked in which the following object is set to my player object named "objPlayer" in which everything else is the same as it is in the video.
Its not working for me :( i have made all of the video too
Has anyone managed to get a camera zoom mode working? Have been trying to incorporate a mode for when I talk to an NPC the camera smoothly zooms in a bit and then back out when dialogue is over. I've got something close but running into issues and I feel like there is a much easier way to do it.
Ma gosh, best tutorial i've ever seen in this life. Thanks a lot! Your patreon link isn't work...
thanks for the tutorial! your game is available or in production stage?
I have a couple personal projects in the works right now, yes!
Thank you for the video but i didn't understand the "follow_mouse_drag" part... In that mode mouse_xprevious shouldn't be instantly equals to mx and same thing with mouse_yprevious?
Is it possible to make camera rotation like in 3d strategies? For example when you hold middle mouse button and moving mouse. I now it's 2d, but still. And objects have different angle sprites and it's changes when you're rotating camera, is it possible???
Yes!! Welcome back!!!
Great videos, how would you do a camera to zoom in where ever the mouse currently is, the mouse being a standard mouse not as an object... without leaving the game window?
I want to try somthing like clásic resident evil switch camar position on a 3d game, each time object Reach a point camar show a different perspective, sems like no one nows how to do that :( any help its welcome
Good day! as you all it works if you have not created a camera through camera_create ? I want the player to move the card with his finger or mouse and do everything as in your video, but nothing works. Answer please
Hey, can u make a video of how the depth works on tilesets? i have more trees and bushes on my tilemap but player stay at them.
I can't promise it will be anytime soon but I would like to do one on this topic at some point. In the meantime, a couple suggestions for this are just to simply iterate through your tileset at the room start and assign tiles a depth depending on their position in the room (you can do the same thing with sprites in asset layers). Alternatively there are some more advanced techniques like this one: www.yoyogames.com/blog/458/z-tilting-shader-based-2-5d-depth-sorting
Would it be possible to achieve the result of the second to last camera mode in GMS 1.X?
Thanks!
Well yeesh, Enumerators are sure gonna make data structure management a lot better. I say yeesh because my game has been in development for a year and a half now, and good god Data management is a nightmare
THANK YOU!!! 😍
How would you adapt this to a splitscreen format? could you code multiple viewports in the same camera that would show up on the screen at the same time?
I have a question do you know if there is a tutorial which learns you to make a system for an interior of a moving object like a spaceship and that the player can move around in it
I don't know a specific one for that, but I'd say it would just involve switching rooms and saving the positions of objects in each room when you do so!
Hey FriendlyCosmonaut, I really appreciate all the tips! And just wanted to let you know that for some reason your Patreon link in the description of this video is broken. It seems fine on newer videos and directly from your UA-cam. Not sure if it's broken on older videos as well, just noticed it here.
So... I don't mean this in a horrible way, but I'm super glad that Patreon pushed through that donation. I miss your videos. TT.
Is there any chance of you streaming or doing videos of your development of your new game? I need my FC fix!
Haha, thank you! I've been meaning to do some streaming or devlogs for aaages, I've just been a bit hesitant as it's still early-ish stages. I hope that changes in the coming months though!
Well, I think you should just start! Anything is better than nothing. It doesn't have to be perfect.
You are great!!!!
women
Hey, can u make a video of how the depth works on tilesets? i have more trees and bushes on my tilemap but player stay at them.