• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [SOLVED] Making background follow camera?

A

AGW

Guest
Hello, what I want to do in my game is to make the background follow the camera.
Any idea on how this would be made?

Thanks in advance.
 
D

DKR_87

Guest
You could draw a sprite the size of your display and just make it follow your camera view.
 

KamilSeven

Member
Create an object to manage your background movement and add this code to its step event. (Don't forget to put this object into your room)

Code:
background_x[0] = view_xview;
background_y[0] = view_yview;
[0] this number for your background, if you have more than one bg. change the number according to your bg.

I also suggest you watch Pixelated Pope's parallax scrolling tutorial. It will make you grasp the concept much better.


[Post-Edit]
I just realized you are trying to achieve this in GMS2. I'm not sure if there are any syntax differences for view or background. But I presume above code would work. Still, I suggest you learn about Parallax Scrolling. Which will make you able to create more with backgrounds, such as creating a depth illusion.
 
Last edited:
  • Like
Reactions: AGW
A

AGW

Guest
Create an object to manage your background movement and add this code to its step event. (Don't forget to put this object into your room)

Code:
background_x[0] = view_xview;
background_y[0] = view_yview;
[0] this number for your background, if you have more than one bg. change the number according to your bg.

I also suggest you watch Pixelated Pope's parallax scrolling tutorial. It will make you grasp the concept much better.


[Post-Edit]
I just realized you are trying to achieve this in GMS2. I'm not sure if there are any syntax differences for view or background. But I presume above code would work. Still, I suggest you learn about Parallax Scrolling. Which will make you able to create more with backgrounds, such as creating a depth illusion.
Unafortunately, backgrounds work differently in GM:S 2, so this code won't work. Still, thanks for helping tho. I will see what can I do.
 
D

DKR_87

Guest
Did you try drawing a sprite image as the background and set it to follow the camera's view position?
 
A

AGW

Guest
Did you try drawing a sprite image as the background and set it to follow the camera's view position?
I would do that, but my background is divided in many images for a parallax scrolling, so it would be a little complicated to do.
Still, thanks for suggesting a solution
 
A

AGW

Guest
Nevermind everyone, I found a tutorial on youtube on how to do what I wanted.
Still, thank you, everyone, for trying to help with my problem.
 
H

HoTerMin

Guest
Nevermind everyone, I found a tutorial on youtube on how to do what I wanted.
Still, thank you, everyone, for trying to help with my problem.
Do you still have this tutorial, because I have such problem too and i can`t find the solution?
 
S

seorin

Guest
I doubt it's the same tutorial, but I'd recommend this one by Shaun Spalding:

I haven't quite gotten to that one yet, but the earlier videos in the same series are great.
 
Top