Asset - Extension Water Physics - GM Studio 2 and 1

B

BuffaloBillDevelo

Guest
This asset is amazing and has been working really great for me for some time now. I have however recently run into some performance problems when using a lot of water. The problem seems to come from "wp_rectangle_update_simulation", especially while trying to update it multiple times per frame. Probably not that strange as I'm trying to use so much water. But is there any convenient way of only updating parts of the simulation? Like only in and slightly around the view.
 

Dragon47

Member
This asset is amazing and has been working really great for me for some time now. I have however recently run into some performance problems when using a lot of water. The problem seems to come from "wp_rectangle_update_simulation", especially while trying to update it multiple times per frame. Probably not that strange as I'm trying to use so much water. But is there any convenient way of only updating parts of the simulation? Like only in and slightly around the view.
Thank you. It's not a built-in feature, but it's possible if you study the code. You're on the right track with the idea; that's a good way of doing it in a large-scale world.
 

Yal

🐧 *penguin noises*
GMC Elder
But is there any convenient way of only updating parts of the simulation? Like only in and slightly around the view.
Deactivating any objects outside the view? It temporarily makes them not exist. (It's usually the best to run deactivation in an alarm, e.g. every 10-20 game steps depending on how fast the player can move around). There's some caveats (like, you need to figure out how to make moving objects not get stuck in walls that randomly start existing again if they're at the very edge of the activation range) but it's worth learning to use the activation system - it also has the added bonus that offscreen enemies won't attack you until you get close (because they don't exist)... with no need for you to code any special behavior for them.
 

Vovan

Member
Hi. I purchased your extension, but ran into some problems. Help me if it's not difficult. Firstly, I did not understand how to make the room immediately have an area filled with water. Secondly, I can't adjust the position of the refraction, for some reason it shifts to the side relative to the real position of the object. I can't figure out how to fix it
 

Attachments

Dragon47

Member
Hi. I purchased your extension, but ran into some problems. Help me if it's not difficult. Firstly, I did not understand how to make the room immediately have an area filled with water. Secondly, I can't adjust the position of the refraction, for some reason it shifts to the side relative to the real position of the object. I can't figure out how to fix it
Hi, thank you for purchasing :) To fill an area with water, you can use the script wp_rectangle_set_volume. You can use an "amount" argument of 1 if you want to completely fill the area. The script contains documentation for its parameters, so you can find more details there.
As for the issue in your screenshot, it seems to be more than just refraction that is placed incorrectly there. It might relate to view/camera or window setup. You can try tweaking the x and y arguments (or the padding or width/height arguments) of the calls to wp_rectangle_add_reflections_and_draw or wp_rectangle_draw scripts to see if you can get it drawn in the correct spot.
Good luck!
 

Vovan

Member
Hi, thank you for purchasing :) To fill an area with water, you can use the script wp_rectangle_set_volume. You can use an "amount" argument of 1 if you want to completely fill the area. The script contains documentation for its parameters, so you can find more details there.
As for the issue in your screenshot, it seems to be more than just refraction that is placed incorrectly there. It might relate to view/camera or window setup. You can try tweaking the x and y arguments (or the padding or width/height arguments) of the calls to wp_rectangle_add_reflections_and_draw or wp_rectangle_draw scripts to see if you can get it drawn in the correct spot.
Good luck!
I don't need to fill the area with water, I need a pond to already exist in the room when loading. wp_rectangle_set_volume starts filling up when the game starts. I need it to be like in the example. How to do it?
 

Vovan

Member
The example is wonderful, but too complicated, there are a lot of scripts that make it difficult to track how things work. I just need to create a rectangular area half filled with water. I've been trying to figure out the example for a month, but nothing comes out, too much unnecessary information
 

Dragon47

Member
@Vovan Ah, so you need to create savefiles to load on startup, like the ones I made for the example? I don't have the code in front of me right now, and it's been quite some time, but I think I use wp_rectangle_buffer_to_surface to load the savefiles I made in the example code. This script converts a CPU-side buffer (which can be saved/loaded from disk) to a GPU-side surface. I think there's documentation for the script if you open it. If you want to create such savefiles yourself, you can use another script which does the reverse operation; wp_rectangle_surface_to_buffer, which converts a surface into a buffer, which can then be saved as a file on your computer. I might even have this saving process included in the example code, perhaps commented out (if so, just search for the script name in the project to see it). Bundle these files with the project like I do in my example, and you can load it in the same way. You might need to load/save a separate buffer for blocks and water volume. Feel free to ask if you've got any questions! :)
 
Top