Page 1 of 1

nsmbCamera.lua UPDATE 1.1

Posted: Wed Apr 16, 2025 6:51 pm
by Davice
NSMB Camera UPDATE 1.1

An alternative camera logic which mimics the camera behavior of New Super Mario Bros / Super Mario Maker.
That means the camera is not staticly fixed to the player, instead the camera smoothly follows the player.

This script is about 90% compatible with customCamera.lua (zoom blocks and camera blockers are tested, using boundaries and custom screen sizes can cause problems) and with warpTransition.lua

While using warpTransition.lua you have to paste the following code line at line 464 because my script automatically makes inner section transitions, otherwise there would be conclifcts and bugs.

Code: Select all

warpTransition.sameSectionTransition = warpTransition.TRANSITION_NONE
How to import in your level:
When you want to import the script into your whole episode place the script file in your episode folder, open your episode luna.lua and paste the following code line:

Code: Select all

local nsmbCamera = require("nsmbCamera")
When you want to import the script into a specific level without influencing other levels in your episode place the script file into your level folder, open your level luna.lua (if there is none just create one) and paste also the same code lineas for using in your whole episode.

Settings
If you want to deactive the level start zooming feature or the whole script for a specific level or inside a function you can use one or both of the following code lines as an example (do not forget to import the script first in your script file):

Code: Select all

nsmbCamera.enabled = false

Code: Select all

nsmbCamera.levelStartZoom = false
Downlaod:
https://workupload.com/file/NAUhW6FFARm

Re: nsmbCamera.lua

Posted: Wed Apr 16, 2025 6:56 pm
by mariobrigade2018
Neat, although there is a better way to add comparability to warpTransitions without manual editing for the player. I’ll see if I can make an in depth explanation on it soon.

Re: nsmbCamera.lua

Posted: Wed Apr 16, 2025 8:54 pm
by dulushich_ViiU
Image

I liked that the camera was moving so steeply.
But I definitely didn't expect that, please fix it.

Re: nsmbCamera.lua

Posted: Wed Apr 16, 2025 9:15 pm
by Maximum
dulushich_ViiU wrote:
Wed Apr 16, 2025 8:54 pm
Image

I liked that the camera was moving so steeply.
But I definitely didn't expect that, please fix it.
I have that same problem too.

Re: nsmbCamera.lua

Posted: Wed Apr 16, 2025 9:40 pm
by Davice
dulushich_ViiU wrote:
Wed Apr 16, 2025 8:54 pm
Image

I liked that the camera was moving so steeply.
But I definitely didn't expect that, please fix it.
what the hell? i tried to find as much errors as possible but i have never seen that. can you describe when this happens so i can fix it better?

Re: nsmbCamera.lua

Posted: Wed Apr 16, 2025 9:47 pm
by RimeNTreason
happened to me as well. just sorta ignores the level's walls. i personally added this to make it work:

Code: Select all

local sec = Section(player.section)
targetX = math.max(sec.boundary.left + (camera.width / 2) / cam.zoom, math.min(sec.boundary.right - (camera.width / 2) / cam.zoom, targetX))
targetY = math.max(sec.boundary.top + (camera.height / 2) / cam.zoom, math.min(sec.boundary.bottom - (camera.height / 2) / cam.zoom, targetY))
put that under:

Code: Select all

targetY = math.max(playerY - yMargin, math.min(playerY + yMargin, targetY))
this does NOT fix the zoom at level start still zooming out of bounds, but idk what to do about that rn so i just disabled it on my end.

Re: nsmbCamera.lua

Posted: Wed Apr 16, 2025 9:49 pm
by Davice
Maximum wrote:
Wed Apr 16, 2025 9:15 pm
dulushich_ViiU wrote:
Wed Apr 16, 2025 8:54 pm
Image

I liked that the camera was moving so steeply.
But I definitely didn't expect that, please fix it.
I have that same problem too.
do you use a custom resolution? thats one of the few things i never tested

Re: nsmbCamera.lua

Posted: Wed Apr 16, 2025 11:05 pm
by dulushich_ViiU
Davice wrote:
Wed Apr 16, 2025 9:49 pm
Maximum wrote:
Wed Apr 16, 2025 9:15 pm
dulushich_ViiU wrote:
Wed Apr 16, 2025 8:54 pm
Image

I liked that the camera was moving so steeply.
But I definitely didn't expect that, please fix it.
I have that same problem too.
do you use a custom resolution? thats one of the few things i never tested
In short, it happens when you go to the edge of the map and you see blackness.
Image

as for me, your resolutions are strange, the screens are all so stretched that it doesn't bother your eyes

Re: nsmbCamera.lua

Posted: Thu Apr 17, 2025 2:21 am
by Maximum
RimeNTreason wrote:
Wed Apr 16, 2025 9:47 pm
happened to me as well. just sorta ignores the level's walls. i personally added this to make it work:

Code: Select all

local sec = Section(player.section)
targetX = math.max(sec.boundary.left + (camera.width / 2) / cam.zoom, math.min(sec.boundary.right - (camera.width / 2) / cam.zoom, targetX))
targetY = math.max(sec.boundary.top + (camera.height / 2) / cam.zoom, math.min(sec.boundary.bottom - (camera.height / 2) / cam.zoom, targetY))
put that under:

Code: Select all

targetY = math.max(playerY - yMargin, math.min(playerY + yMargin, targetY))
this does NOT fix the zoom at level start still zooming out of bounds, but idk what to do about that rn so i just disabled it on my end.
I tried your code, and it still doesn't work properly.

Re: nsmbCamera.lua

Posted: Thu Apr 17, 2025 9:32 am
by Doodoxing
Not working for me either. I put this additional code in proper place in lua file. It helped a bit, but have not fixed it entirely.

Image

Don't mind WarpTransition. It has nothing to do with it. Problem is happening even without it.

Re: nsmbCamera.lua

Posted: Thu Apr 17, 2025 11:20 am
by Shaktool
I hate to say this, but this is obsolete as this already exists.

And besides, why go yourself the hassle of making one thing when that thing is litteraly already done by another guy? i dont get it

Re: nsmbCamera.lua

Posted: Thu Apr 17, 2025 11:33 am
by KurttheKing
Retro wrote:
Thu Apr 17, 2025 11:20 am
I hate to say this, but this is obsolete as this already exists.

And besides, why go yourself the hassle of making one thing when that thing is litteraly already done by another guy? i dont get it

Uh, customCamera works through multiple sizeables across your entire level, this is essentially plug-and-play as it requires no in-editor setup. Also, it's meant to work in unison with customCamera, though you may have not seen that

Re: nsmbCamera.lua

Posted: Thu Apr 17, 2025 10:10 pm
by dulushich_ViiU
Doodoxing wrote:
Thu Apr 17, 2025 9:32 am
Not working for me either. I put this additional code in proper place in lua file. It helped a bit, but have not fixed it entirely.

Image

Don't mind WarpTransition. It has nothing to do with it. Problem is happening even without it.
How did you do 16:9

Re: nsmbCamera.lua

Posted: Fri Apr 18, 2025 12:42 am
by Doodoxing
It's a basic stuff about setting mainbuffersize. It's a well known piece of code.

I think that it is actually the custom resolution to cause that problem.

Re: nsmbCamera.lua

Posted: Fri Apr 18, 2025 3:58 am
by dulushich_ViiU
Doodoxing wrote:
Fri Apr 18, 2025 12:42 am
It's a basic stuff about setting mainbuffersize. It's a well known piece of code.

I think that it is actually the custom resolution to cause that problem.
Not well, where to make or download it ?

Re: nsmbCamera.lua

Posted: Fri Apr 18, 2025 4:44 am
by Doodoxing
Put this into luna.lua:

Code: Select all

function onStart()
Graphics.setMainFramebufferSize(960,540)
end
function onCameraUpdate()
camera.width,camera.height = Graphics.getMainFramebufferSize()
end

Re: nsmbCamera.lua

Posted: Fri Apr 18, 2025 5:51 am
by dulushich_ViiU
Doodoxing wrote:
Fri Apr 18, 2025 4:44 am
Put this into luna.lua:

Code: Select all

function onStart()
Graphics.setMainFramebufferSize(960,540)
end
function onCameraUpdate()
camera.width,camera.height = Graphics.getMainFramebufferSize()
end
Thanks

Re: nsmbCamera.lua

Posted: Fri Apr 18, 2025 8:19 am
by RimeNTreason
Doodoxing wrote:
Fri Apr 18, 2025 4:44 am
Put this into luna.lua:

Code: Select all

function onStart()
Graphics.setMainFramebufferSize(960,540)
end
function onCameraUpdate()
camera.width,camera.height = Graphics.getMainFramebufferSize()
end
this does not fix it for me. ill stick with my solution for now.