I'm working with Unity 2019.4.11f1, "Universal Render Pipeline" with "Lightweight RP" (package version 7.5.1).
I defined a "2D Renderer Data" to work with 2D Lights.
In my game I have four 2D lights:
Two "Point" 2DLights (each point light has 3 target sorting layers)
Two "Global" 2DLights. One of them with 3 target sorting layers (lights up my whole game except characters) and the other with 1 sorting layer (Illuminates only my characters).
I'm developing a 2D mobile game for kids and using 2D lights to decorate.
Only ONE "Point" 2DLight is turned on at the same time.
The "Global" light, which illuminates my characters, is always turned on.
The "Global" light, which illuminates my whole game (except characters), is ON only when the point light is OFF.
At certain times in my game, I turn on/off "Point" lights and "Global" light with the above restriction already described.
Everything works great until I use shadows on my characters.
When I use shadows, the frame rate is dropped right down to about 10 fps otherwise it's about 27.
My 2D game is pretty simple. My characters are round sprites (like a coin), so shadows are ridiculously simple.
To gain in performance, I set "Renderer Texture Scale" to 0.4 (insted of default value 1) in the object 2D Renderer Data.
While the performance has greatly improved after that, it is still low.
Each character (above 10 on screen, moving around) has a "Shadow Caster 2D (Experimental)" component and checkbox "Cast shadows" selected.
What else can I do to improve performance? I've done a lot of research and can't figure out what else I can do.
You can
Decrease the size of your sprites (or compression)
Make static gameobjects whichs are non have movement
Check your renderer graphics detail
You can make manual occlusion to your game (you can enable and disable gameobject in the scene)
You can use OnBecameVisible() function.
I am using these to optimize my urp game.
Related
is there any way to give a simple 3D cube in Unity the look of a flag without displaying the whole flag on every side. So that as example the top stripe also fill's the whole top?
The default mesh unity provides for cubes always show the same texture an all6 sides, so they are always all the same. Whatever material/texture you apply.
The one material is used an all sides, with UV values from 0 to 1 (whole texture).
Even fiddling the UV scales on the material does not help as the 6 sides all start with the same range.
I you wish to change this, you need to edit/create you own mesh for a cube which allows different UV settings for the 6 surfaces, or multiple materials. You could make one which has a second material for one of the 6 faces and assign your flag texture there.
(Unity does not really provide mesh editing. I used blender for this.)
In Unity, you could create an empty gameobject, add 6 'quad' objects, and use different textures on these. Then this set of 7 objects behaves like a cube, but with different textures (and less performance when using lots)
Why not just use a single quad for the flag?
I'm trying to figure out why my Object's textures keep turning white once I scale the object down to 1% (or less) of its normal size.
I can manipulate the objects realtime with my fingers and there is a threshold where all the textures (except a few) turn completely ghost white, as shown below:
https://imgur.com/wMykeFw
Any input to fix is appreciated!
One potential cause of this issue is due to how certain shaders can miscalculate how to render textures when scales are set to low values.
To be able to render this asset so small using the same shader, re-import the mesh with a smaller scale factor (in the mesh import settings), and that may fix it.
select ARCamera then camera, in the inspector, select the cameras clipping plane and increase it(you want to find the minimum possible clipping that works to save on memory, so start at 20000, and work your way backwards til it stops working, then back up a notch).
next (still in the cameras inspector), select Rendering Path and set it to Legacy Vertex Lit
this should clear it up for you
I'm struggling with performance in unity. I created a very simple game scene. Very low poly. 2 light sources, 1 Directional 1 Point, I have the Standard Shader with Alberdo and Occlusion texture set (this for all few 3D objects in the scene)
The issue is, I was expecting fps to be around 60 but it is 29ish..
What things I have to consider regarding performance in this scenario? it is very frutstating since it is a very, very simple scene
see images:
In your Quality settings, as mentioned by Hamza, set shadow resolution to medium setting and set V sync count to "Dont sync".
I am using Unity 5 to develop a game. I'm still learning, so this may be a dumb question. I have read about Depth Buffer and Depth Texture, but I cannot seem to understand if that applies here or not.
My setting is simple: I create a grid using several quads (40x40) which I use to snap buildings. Those buildings also have a base, made with quads. Every time I put one one the map, the Quads overlap and they look like the picture.
As you can see, the red quad is "merging" with the floor (white quads).
How can I make sure Unity renders the red one first, and the white ones are background? Of course, I can change the red quad Y position, but that seems like the wrong way of solving this.
This is a common issue, called Z-Fighting.
Usually you can reduce it by reducing the range of “Clipping Planes” of the camera, but in your case the quads are at the same Y position, so you can’t avoid it without changing the Y position.
I don't know if it is an option for you, but if you use SpriteRenderer (Unity 2D) you don’t have that problem and you can just set “Sorting Layer” or “Order in Layer” if you want modify the rendering order.
Pre-info:
I'm making a 2D game in Unity which behaves like Castle Crashers, where the player can move around forwards and backwards like in a sidescroller, but also up and down, kind of like a topdown game - but it's still a 'sidescroller'.
In Unity I'm using Rigidbody2Ds and Boxcollider2Ds for physics.
However, when wanting to simulate things like dropping items, creating gibs or any other object that needs to fall to the 'floor', this gets tricky.
The objects that need to fall to the floor don't know where the floor is, so they'll fall forever.
Question
Can Boxcollider2Ds be set to collide with an individual infinite x-axis?
Object A should collide with the red axis and Object B should collide with the blue axis.
Is this possible?
You could use layers. And in project settings -> Physics2DSettings set them not to collide with each other. There is a hard limit of 32 layers and first 8 are used by system (you can still use them for this) this leaves you with 24 discreet layers - change layer of your objects when they change their position on Y axis. The gameplay might feel awful.
Use 3D physics. tilt your camera 45 degrees on X axis, set projection to ortho, and draw 2D sprites on top of invisible 3D physics objects - then you will have real 2D plane to walk and jump on.
Don't use box2d at all: write your own - simple physics library, you need it only for jumping and falling, right ?