Camera Control Questions

J

jhallphx

Guest
Hello,

I'm surprised there are not more tutorials on panning the camera to create in-engine cutscenes and such. Hopefully the gurus here will have some answers. I am making a platformer game where the camera follows my player object with a viewport sized at 640x480. I have made the room six times larger than this (3840x2880). I am wanting to begin my platformer room showing the full room (zoomed out), and then zoom to the goal area, and then pan around the room along the obstacle path, eventually arriving at the player start position.

I have had the idea to use the timelines to accomplish this, and maybe switching/zooming between viewports, eventually ending in the viewport that will follow my player object. Not sure if I need an "invisible object" that needs to be followed to get the panning effect, or if I can program x/y's into the code, or if there is a simpler way to do this than timelines.

Just to clarify what I'm after...
- Begin showing the full room (roomsize 3840x2880)
- Zoom to Goal position with zoomed viewport being 640x480
- Pan camera along obstacle path
- Finish at Player start position (maintaining 640x480 viewport)
- Spawn player and then follow player through level

Look for advice on how best to do this! Thanks everyone!
 
J

jhallphx

Guest
https://docs.yoyogames.com/source/dadiospice/002_reference/windows and views/views/index.html

Read the documentation on views. You should be able to do something like this in code. A basic example is changing the view_wview and view_hview smaller every step to zoom in.
Thanks for the reply, Cloaked Games. I love when the response is read the manual lol. Unlike some, I am not lazy lol and I have read through all of the documentation on views, I have a decent understanding of how they work I believe. However, I'm asking the question here because I am either not creative enough to come up with a way to *automate* a cutscene, or something went over my head and I'm not identifying and grasping the concept explained in the manual on how to do it. I have also read the manual section regarding timelines. Most documentation on views regards manually zooming and resizing the view... I am trying to automate a cutscene, essentially a short showcase of the level before the player spawns, and there is very little on how to do that on the interwebs past forum posts where people try to advert 3rd party programs to do it. So, besides linking the manual... are there any ideas or links to tutorials I may have not come across?
 
Sorry. I guess I wasn't as helpful as I could've been. I didn't mean to assume you hadn't read it, I was just linking the manual because it helpfully contains the functions you would need to do it.

To automate this process, you could use a timeline, or just a script in a step event. For the zooming in on the player, have code in the step event that shrinks the view width and height by a certain amount each step, but leaves the port the same. Center the newly sized view on the player. Then you can check for if the view is all the way zoomed in and switch the view to one set up for following the player.

In pseudo-code, it might look like this:

Code:
if (you are still zooming)
 {
  view width and view height -= 10;
  view x and view y = player x and y - 1/2 of the view width and height;
  if (view width and height are equal to the fully zoomed in size)
   {
   you are now done zooming;
   }
 }
When you're done zooming, you can switch the active view to a different one you set up to follow the player, or use code to change the current view to do that.
 
J

jhallphx

Guest
haha no worries! I know there are a lot of "please post some code below" folks out there, but I'm really enjoying learning the theory behind everything! I like the idea there with the "if still zooming"... I may have to use timelines, but will try both methods. If I script, I'm thinking some room_speed*x variables to pause between movements... follow an invisible object. I'l play with what you wrote and see what I can come up with. Thanks!

If anyone else has anything revolutionary that Ive missed please dont hesitate!
 

sp202

Member
I recommend making a script that tweens between the current position and scale of the view and the intended position and scale of the view.
 
J

jhallphx

Guest
Thanks for the input everyone... I have tried the following, what I consider my best attempt lol, and it does nothing. The manual says you cant change the viewport of the current room, only other rooms... so not sure this is even possible? Theory was that the controller would cycle through alarms, which would zoom and then advance to next alarm, based on current view dimensions.

obj_view_controller

create
Code:
zooming = false;
donezooming = false;
zoomtimerset = false;
zoomtimer = 180;

alarm[0] = 180;

vw1alarm0 = true;
vw1alarm1 = false;
step
Code:
if (zoomtimerset = true)
{
zoomtimer -= 1;
}
else
{
zoomtimer = false;
}

if (vw1alarm0 = true)
{
alarm_set(0, 1);
}

if ((vw1alarm1 = true) && (zoomtimer <= 0))
{
zoomtimerset = false;
alarm_set(1,1)
}
alarm[0]
Code:
zooming = true;

var vw0 = camera_get_view_width(view_camera[0]);
var vh0 = camera_get_view_height(view_camera[0]);

var vw0z = camera_get_view_width(view_camera[0]);
var vh0z = camera_get_view_height(view_camera[0]);

var changew = room_set_width(room, vw0z) // not sure how to change variables within function separate room_set_viewport() ... thats why I used this function
var changeh = room_set_height(room, vh0z) // pretty sure this is trying to resize the entire room which is not what I'm trying to do...

if (zooming = true)
{
changew -= 10;
changeh -= 10;
}

if ((vw0 = 640) && (vh0 = 480))
{
alarm_set(0, -1);
vw1alarm0 = false;
vw1alarm1 = true;
zooming = false;
zoomtimer = 60;
zoomtimerset = true;
}

if alarm[0] <= 0
{
alarm[0] = 1
}
 
Last edited by a moderator:

sp202

Member
You shouldn't need to manipulate the viewport at all in-game. What you need to be doing is altering the camera view dimensions.
 
J

jhallphx

Guest
You shouldn't need to manipulate the viewport at all in-game. What you need to be doing is altering the camera view dimensions.
Ok, same create, same step... tried these functions in Alarm[0] and not getting anything:

alarm[0]
Code:
zooming = true;

var curr_x, curr_y, zoom_x, zoom_y, new_x, new_y

curr_x = camera_get_view_width(0)
curr_y = camera_get_view_height(0)

if (zooming = true)
{
curr_x -= 10;
curr_y -= 10;
}

new_x = curr_x;
new_y = curr_y;

camera_set_view_size(0, new_x, new_y)

if ((new_x <= 640) && (new_y <= 480))
{
alarm_set(0, -1);
vw1alarm0 = false;
vw1alarm1 = true;
zoomtimer = 60;
zoomtimerset = true;
}

if alarm[0] <= 0
{
alarm[0] = 1
}
 
Top