Camera control help

Need help with any SMBX game-related issues? Ask your questions here.
KoolGamer32
Bob-Omb
Bob-Omb
Posts: 20
Joined: Tue Jan 19, 2021 11:35 am
Flair: Life is cool and stuff so yeah!
Pronouns: he/him
Contact:

Camera control help

Postby KoolGamer32 » Wed Aug 04, 2021 8:22 pm

I was wondering how the whole camera control thing works. I can't find really any sources I can understand clearly and was wondering if anyone had a kind of basic guide on how that all works. For example for my one level I want to zoom in to a point and zoom out a few seconds later.

User avatar
marioman2007
Spike
Spike
Posts: 264
Joined: Tue Aug 25, 2020 3:19 am
Pronouns: He/Him

Re: Camera control help

Postby marioman2007 » Wed Aug 04, 2021 9:26 pm

Just learning Lua and Importing Graphics

The Super Cool Pack:
Image
https://discord.gg/78w3gGAptB

I support:
Image
Image

KoolGamer32
Bob-Omb
Bob-Omb
Posts: 20
Joined: Tue Jan 19, 2021 11:35 am
Flair: Life is cool and stuff so yeah!
Pronouns: he/him
Contact:

Re: Camera control help

Postby KoolGamer32 » Thu Aug 05, 2021 10:41 am

thanks for the help on that area but I am still a bit confused. I also need help with how to even load it if i need a script or what. I would also like to know how to trigger camera control at specific points in the level similar to an event triggered by a trigger

User avatar
Hoeloe
Foo
Foo
Posts: 1403
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Camera control help

Postby Hoeloe » Thu Aug 05, 2021 12:07 pm

KoolGamer32 wrote:
Thu Aug 05, 2021 10:41 am
thanks for the help on that area but I am still a bit confused. I also need help with how to even load it if i need a script or what. I would also like to know how to trigger camera control at specific points in the level similar to an event triggered by a trigger
You need to load handycam with the line:

Code: Select all

local handycam = require("handycam")
From there, you can then use the onEvent function to use SMBX events to trigger zooming in and out:

Code: Select all

function onEvent(name)
   if name == "Zoom In" then
       handycam[1].zoom = 2
   elseif name == "Zoom Out" then
       handycam[1].zoom = 1
   end
end
If you want to get really fancy, you can, instead of just setting the zoom level, use the queue function, like so:

Code: Select all

handycam[1]:queue{ zoom = 2, time = 1 }
To allow for some transitioning. Note the use of a colon instead of a dot, and the use of curly braces instead of brackets.

KoolGamer32
Bob-Omb
Bob-Omb
Posts: 20
Joined: Tue Jan 19, 2021 11:35 am
Flair: Life is cool and stuff so yeah!
Pronouns: he/him
Contact:

Re: Camera control help

Postby KoolGamer32 » Thu Aug 05, 2021 2:14 pm

thanks that completely solves that issue but I am still unsure of how to place the camera in a specific spot. I have tried adding x and xoffset to this line of code handycam[1]:queue{ xOffset = 10, zoom = 2, time = 4 } nothing. I have tried adding it as a separate line entirely handycam[1].xOffset = 10. But the camera doesnt move and just zooms in to the center. I thought maybe camera target would probably get the result i want but im not sure how to code that. tldr: I want the camera to transition to a specific spot that isnt the center as well as zooming in. (which i know how to zoom in already thanks to the previous reply)

User avatar
Hoeloe
Foo
Foo
Posts: 1403
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Camera control help

Postby Hoeloe » Thu Aug 05, 2021 6:38 pm

Hrm, xOffset should work just by adding it to the queue like you did... You can also assign any object with an x and y coordinate as the "target" in a queue call. Not really sure what's wrong there... (though 10 is quite small - it's less than a third of a block's width, so maybe that's the issue?)


Return to “Help and Support”

Who is online

Users browsing this forum: No registered users and 5 guests