ipodtouch0218 / NSMB-MarioVsLuigi

Standalone Unity remake of New Super Mario Bros DS' multiplayer gamemode, "Mario vs Luigi"
https://ipodtouch0218.itch.io/nsmb-mariovsluigi
621 stars 280 forks source link

Minor Changes (Mainly Math and Raycast Target Removal) #179

Closed DonKaiStorm closed 2 months ago

DonKaiStorm commented 1 year ago

This Pull Request mainly contains a few changes.

1.) The GameManager Prefab has all the Static UI Elements (images and text) with their Raycast Target option ticked off, instead of on by default. This should help with performance in some cases, since Unity won't check for an event each time the mouse is over it. Of course, the witnessed results aren't much. 2.) The same thing as 1, but with the MainMenu elements (which is probably why it can't automatically merge...oops). 3.) Caching of the GameManager.Instance call inside the CameraController script. The instance could be cached right from the start, so that get call being avoided should save some performance. 4.) 0.24f instead of 0.25f - xDistance - 0.01f. That can easily be simplified and reduce the calculations done by a small bit. 5.) In HorizontalCamera.cs, removed the storage of the aspect float since it was only used to calculate the reciprocal. Just do 1/ ourCamera.aspect and boom. I also cached 16d/9d since the result of that was always going to be the same.

I know it's not as much a performance oriented pull request as my last one, but it was something I noticed going though the game files a second time (especially the Raycast Target option). I'm sorry about the merger errors (I can almost 100% guarantee it's due to MainMenu.scene), but I do hope that some of the minor changes get added.

Thanks in advance, DonKaiStorm

DonKaiStorm commented 1 year ago

Just made another commit to this pull request: StartrackIcon no longer calculates the position of non-moving Stars. While not a major performance improvement, it does eliminate wasted calls that are spent on calculating the same position over and over again.

DonKaiStorm commented 1 year ago

Latest Commit Details: "Caching Vector2.Up and Vector2.Zero inside of the BasicEntity allows them to be used by all classes that inherit it, all while avoiding unneeded get calls, especially if repeated inside of an Update or repreated function. There's some other caching in there as well. But it's 3AM in my timezone, and I should probably get some sleep."

My next plan is to cache the other Vector2.values to further remove unnecessarily repeated get methods from the game. The more commits I add, the more conflicts that arise...Oh no.