I have a very very Big/Huge scene to load and I can't load it at once.
What I have tried so far is I divided the scene into multiple scenes and loading it into async manner as my character controller move. I am moving my character controller and accordingly loading (its near)scenes by matching its position. But it is not smooth. . .
How do I load big scene smoothly? what will be the strategy? Is this right strategy which I am doing or there is any other feasible and easy to use solution available.?
Try separate your scene into small chunks. When you move your character - just load new chunks and unload old. For example, this strategy uses minecraft.
You can't decrease loading time to zero milliseconds, but loading will be smooth. You can use chunks about 5x5x5 meters. And load from manager with coroutines.
Don't forget to use object pool pattern (because Instantiate it very costly) :)
UPD:
For example, this way use in plugins:
Uniblocks Voxel Terrain
MapMagic World Generator
Also, this plugins uses open world generation from 2d/3d noises (Perlin noise, etc.)
Related
I'm a student using the latest version of Microsoft XNA for learning purposes.
I need to load a whole lot of texture from the Content folder (or more specifically a folder called Tiles inside the Content folder) and I really don't want to type the following code 100 times:
texture = Content.Load<Texture2D>("texture");
I realize I could change the names of the files and run through a loop to load them, but this seems inefficient for finding specific tiles if there's a way I could keep the names. I am just looking for a way to load all of these that saves development time.
Also, the files are in .BMP form, if that matters.
Keep in mind that every texture needs to be loaded at least once.
So using
texture = Content.Load<Texture2D>("texture");
is fine to repeat for different textures, as long as you don't repeat it for the same texture.
I've learned is to load all textures in the LoadContent() of game1.cs, that method is only called once at the moment the game starts. So they're all ready to be used for the rest of the game.
There's also a Lazy Loading practice, where the texture is only loaded for when the object appears. But you should be aware that the texture loading won't repeat itself for each object.
I have a really peculiar question. I want to deteriorate the graphics in Unity of just a part of the screen. For example, if I'm playing a game with the screen split in two, one player can be playing with ultra graphics and the other, low ones. Is there a simple way of doing this, like setting the graphics quality on each camera? Thank you so much for your help!
I don't imagine and easy way to do that.
Graphics are the conglomerate of multiple things (at least for me); the number of polygons of an object, the size of the textures, etc.
So the only thing I know you can do, is to duplicate the scene (like if you are making and on-line game) and load this duplicate scene with different materials, models and textures on one player scene. Then synchronize the rest of the scene, so both players are looking the "same" scene.
Also you can "deform" the image, with shaders or camera filters, like a Blurr effect! But this won't really affect the "graphics".
I don't think that's currently possible. The game would have to render the same objects on 2 different ways, but that's just not possible in a good-performance scenario. You could very simple use prefabs with a lower quality on one of the screens or images with a lower resolution in the UI.
Do you really need this for your game? If u do some changes in the quality settings or change your game core mechanics, maybe the performance becomes good enough to skip this.
In my Unity game players are able to chop down trees using for example an axe. The tree then gets removed from the terrain and replaced by a falling tree prefab. This works fine in small scale. I am looking for a more effective way to do this though, because:
The entire terrain needs to be reloaded if a tree is cut down. If the terrain is very large and complex this means that the entire game freezes for a few seconds whenever a tree is cut down.
It works very poorly in multiplayer. In order for the terrain to stay in sync, all players terrain needs to be reloaded each time a tree is cut down. This means everyone's game freezes every few minutes.
I have thought about "chunking" the terrain but the entire terrain is already built and I don't know of a way to break it up into parts after it has been made.
Any ideas will be appreciated! I'm about an intermediate level programmer so I don't need anyone to write the code for me here, I just need an idea or suggestion as to the best way to do this?
I've been using Monogame for a awhile now and I was just wondering what is the best way to load my content? Lets say i have an intervals system that constantly creates objects on the screen, so should I load the object's sprite in the game class and put the sprite variable in the constructor or should I put the content variable in the object constructor and load the sprite from within the object?
Btw by best way I mean I try to keep the framerate and use less memory, thx in advance!
Best way for frame rate is to load it before game loop starts. But the best way for less memory is right when you need it and dispose of it after your done. Not necessarily mutually inclusive... pick your poison.
You have 3 different solutions, and each will fit a different type of game.
Load everything in LoadContent
This will cause a longer initial startup time, but after everything is loaded, you wont have to wait for anything anymore. However keep in mind that this is only suited for small games such as Tetris, Arcanoid or Chess. Games that generally doesn't have a lot of content. Keep in mind that the more content you load, the more memory it will consume.
Load everything needed for the current scene
This is what most games does, since you wont load data for scenes that you never use, and you wont load data for scenes you're not yet accessing.
Load everything needed for the current scene (Extended)
Like the previous answer, but with a small twist. If possible, load content while displaying other content. For instance, as soon as the player finished the last step for completing a scene, initiate the loading of the next scene.
Arcanoid example: As soon as the ball hits the last block (or if you're brave, even as soon as you can calculate that the ball WILL hit the final block), initiate the loading of the content for the next scene. Let this load while the ball flies towards the final block, and also while displaying the score for the current scene (Time, deaths, bonuses, etc.)
And should the player actually close the dialogues before the scene has been loaded, show another loading scene while the data finishes loading. That way, there might only be 1-2 seconds of loading time instead of 10.
Remember to perform all this loading in a background thread.
I'm creating a program that simulates that of the Breakout Game using C#.
I've been learning various techniques on how to create the bricks, paddle and ball for the game but cannot work out on how to add them all into one picture box in Visual Studio.
The main issue I'm facing is that in order to move the ball for example, I have to clear the 'canvas' by using the following section of code:
paper.Clear(Color.White); This basically clears the picture box to the colour white in order for the new coordinate (of the ball for example) to be dawn within the picture box and this is where my issue begins.
Each of the components within the Breakout game (that I have practised) all use the paper.Clear(Color.White); code. This means that if for example I want to move the paddle, display the bricks and bounce the ball simultaneously, the program just decides to do one function at a time. If I remove paper.Clear(Color.White); from one of my assets then the program just won't function in the way I want it to.
Is there a way for all these components to run simultaneously within the game without missing any of them out completely?
At its simplest you need to change your approach to have the 'layouting' or 'painting' be centrally controlled, presumably on a timer or similar, and do a single 'clear' operation and then redraw all your components. In other words, do not have each component clear the canvas, they should just be concerned with their own rendering.
The above is the simplest approach. Beyond that you could take an approach of only redrawing what has changed from one frame to another. This can make for much more optimized performance, especially if your game canvas is large or has many components. However it requires a completely different, and in some ways more complex design. You would need to determine the rectangle / rectangles that have had 'movement' or other modifications to them from the prior frame, clear only those rectangles and ask those components that are wholly or partially in those rectangles to re-draw themselves.