I have a really complex terrain in Unity, its full of trees, grass, flowers etc.
When I run the game, the frame rate is really low, maybe 1 to 3 fps.
I read some where that the terrain resolution may be the problem since i got it cranked up high.
When I try to lower the terrain resolution, unity erases the whole terrain, which is bad since I can go spending two months to remake it all over again.
Does anybody know of a way to change the resolution of the terrain, and other terrain parameters without losing the whole terrain?
Maybe there is a script in the unity asset store that can export the terrain and lower the resolution, and re-import it, or something like that?
Anybody know of script or method to do that? I don't have time to develop a script myself, or spend huge amount of time on this.
I know one thing you can do is decreasing the resolution of the texture you used for terrain and grasees or trees on it.
What you are trying to do is very complex and will take a lot of time. An alternative way of getting higher FPS is to select all your non-moving objects, or just the prefabs in your prefabs folder and check Static in the right-hand corner of the inspector. This will boost your FPS but if you have a day-night cycle you should uncheck Lightmap Static by pressing the downwards arrow next to the Static button in the inspector.
Related
I created a 2D sprite animation using the 2d animation package and the 2D Ik package. My character is one sprite sheet (PBS file). In the PBS file all the spites (eyes, mouth, etc, - character is basically a square with a face) are arranged and bones are attached. Then I animated the character's idle animation in Unity.
The animation is complex and is a total of 1028 frames (about 17 seconds).
The scene is almost empty otherwise. There are a few sprites with colliders and rigid bodies for simple platforms. There is a background image which is 1024 px. x 1024 px.
In play mode the FPS drops down to around 30 FPS (and under).
I have another scene without the animation but with a HUGE number of assets (for a 2D scene hundreds of sprites and many of them constantly in motion). This scene runs at 210++ FPS consistently.
Why does this one animation kill the FPS? I'm just getting started with creating animation for all the characters. If I add similar animations to NPCs in the scene (enemies) then this thing will probably not function at all.
Any suggestions are appreciated.
For anyone having the same issue, make sure you have Burst and Collections packages installed (via the Package manager), it extremely improves the performance of 2D Animation.
So I spent a couple of days this week and created sprite sheet animations to replace the skeletal animation I made in Unity. As I suspected, the performance is light years ahead. I have MORE animations now and some of them are as long as 270 frames. Yet I consistently see greater than 220 FPS. It's too bad that unity's 2D animattion package is so slow. To accomplish the same animation I was looking for, I ended up rigging and animating my character in Blender 2.8 using Andreas Esau's COA Tool (Cut-Out-Animation Tools) Add-On.
COA Tools is an awesome tool but I wish it could export a rendered sprite sheet to Unity. I ended up exporting each frame as a separate image and using TexturePacker to make the 2048px square sprite sheets I needed. Once I got the sprite Sheets into unity I was able to quickly set up animation clips and test it out.
As I said, the sprite sheets are far and away better than animation created directly in Unity.
If you bothered to read all the comments on my original post, I will say that there are a lot of scripts running and a lot of computation happening. It is there in the profiler for sure. But this was definately not the main culprit for taking down the FPS. It was absolutely the animations.
Looking at your profiler screenshot, SpriteSkin.LateUpdate() takes a large chunk of your frame time. To reduce the amount of time CPU spends on deformation, you can limit the number of vertices in that are used for each Sprite Part - you can adjust it in the Skinning Editor with Edit Geometry tool. Basically, the less the amount of vertices the better the performance.
Also, make sure that each Sprite Skin component has the Enable Batching option enabled. This will enable Burst and Collections packages to speed up calculations. For more details, checkout this 2D Animation documentation.
Recently, Unity a free ebook was released that covers in details best practices and how to prepare art for 2D animation. You can find it here.
I'm making a simple space simulator project and the models and the mesh start wobbling and distorting after certain speeds. The code has no errors, so I will give you a
gameplay video.
As you can see in the gameplay video, even simple cylinders get distorted.
Then, I got an interesting
bug/error.
Is there a solution to said problem?
Make sure you’re not too far away from the origin of the scene. Things get less precise the further away you go from the origin, and it’s to do with floating point precision.
I'm having trouble figuring out how to light up large area(s) of sprites in Unity 2D. My previous knowledge on Unity's lighting is zero.
I first tried using a large amount of point lights and using the "Sprites/Diffuse" material, but about only five would actually render at a time, so I guess there's a limit on that.
Then I tried putting in an area light. That didn't do anything, so that's when I started doing research about baked lighting on sprites (and baked lighting in general). I found stuff like this but I couldn't get it to work either because it's outdated or because I don't know what I'm doing. Other answers I've come across seem to assume that the reader knows anything about lighting in Unity in the first place which, to be honest, I don't. Unity's documentation website had some information on it, but no tutorials that go into how to set up baked lighting.
I've tried a bunch of different combinations of materials (like using the "Standard" shader for the sprites instead of "Sprites/Diffuse", emission, ect.) and I enabled "Baked Global Illumination" in Lighting>Settings.
If baked lighting isn't possible on sprites (or isn't worth the trouble), what are the alternatives?
Edit: I made sure not to have the lights pointing the wrong direction, and I do realise that Unity2D is just like painting onto a piece of paper in Unity3D. I was able to get point lights to work, but only a few at a time. I don't need to do the entire screen at once, I need to do a large specific area at once.
some tips...
working with sprites your in 2d... when you add a light, switch to 3d mode, and rotate to make sure your light is pointed at your objects, and oriented so as not to be on the same plane, or level with them, as this will cast all the light behind them.
if your trying to light up everything on the screen(in camera) attach an area light to the camera at the cameras position, point it where the camera points, and then in the inspector on the right, you can change its variables. intensity, range, width, height etc.
Emissive Texture:
https://www.youtube.com/watch?v=oa6kW5HhRd4
For some reason, I never even thought about going into the asset store. I found this for free, and it looks like it will work: Light2D.
I'm creating an app to show 360 images with Cardboard.
I created a scene in Unity using Cardboard camera and sphere. I mapped 360-image to a sphere texture.
When viewing the texture is low quality and has sawtooths so the details are not good quality.
Any ideas to solve this texture problem? I tried a script which creates a different kind of sphere but it didn't solve the problem.
You need to use an icoshpere for this to work, you'll still gonna get some distortion near the polls, but it's far better than the uv ones that Unity provides.
The second thing is that you'll need a high detail icoshpere for this to work, as you'll need more vertexes.
The third thing is the textures quality and size. I think the default fov for Unity is around 60, but you'll map the texture for a fov of 360, so you'll need textures of higher size compared to the on screen texture you are using.
You can look over this article if you want more details about the differences between icoshperes and uv spheres, or just go to the bottom of the article and download the unity project. The project includes already made icoshperes and you can experiment with them to find out which one is best suited for your project. I'm using the Octahedron Sphere 4 R1. Any less polys and there are too many distortion, any higher one and the fps drops to much.
I am making an open world game and i want to know if there is a way of doing terrain streaming ( loading the terrain into mamory only if the player is close to it ) without using the LoadLevelAdditiveAsync function . i am using free version so this function is not available to me .
Don't forget as long as your terrain patches together nicely, you can always Instantiate terrain prefabs at run time.
Depending on how proficient you are at it, you can also procedurally create terrain at run time as well.
You can do it, and there are different ways to do it. I figure the easiest way to do it (but definitely not the most memory friendly) would be to define your entire level in one scene with multiple small terrains, using the TerrainStitcher tool to deal with seams. Then you could parent all objects under each terrain to a single transform, and use Instantiate to create/destroy them at runtime (in another scene). There are tools that take this approach a bit further, like this one.
But remember that in general big terrains in Unity aren't memory friendly and will reduce your performance. When using an endless terrain, where you don't care about defining the terrain before runtime you can reuse a few terrain objects and simply reposition them, but if you're designing them first, there isn't too much you can do other than lowering terrain settings like Pixel Error, and limiting details and grass.