I'm new to Unity and I'm still learning how to use it. I'm trying to make a pixel 2D game and my character is glithy around the edges and I don't know how to fix it. Thanks for the help!
I tried and watched a lot of tutorials but none of them had the same problem as mine.
Basically im developing a 2d pang game style for mobile, where you pop some balls. So i created some walls colliders, but everytime i change the resolution, the left and right walls just dont stick to the right place, or they move out of screen or they move in the screen depending on the resolution. I used them to act as boundaries for the bouncing balls. I have struggle with some many scripts, to try to fit the objects on the screen but i cant find a solution for this. I found similar issues, but there solutions unfortunatilly didnt work :/
Any ideias?
Thank you for all the help
I believe all you need are Screen.currentResolution and Camera.main.ScreenToWorldPoint(). This could make things easier. You can adjust the borders position and scale to match your screen before runtime or after changing screen resolution. Visit unity document to see more details.
There's a lot of code so I'm not going to put it here. I'm just wondering if anyone has had a similar issue to this and how they solved it.
I'm trying to create a 3d scene in C# using OpenGL and have got lighting working as well as basic primitive models and more complex models. But now I'm trying to texture the walls and I'm getting these weird lines running through the texture. Whenever I move the camera the lines change and glitch around but are always vertical lines.
I have noticed there is a sweetspot for the camera when looking directly at the wall and being at the right distance from it.
The sweetspot
Rotate left - lines appear
Camera at right angle but wrong distance - texture dissapears
I know it's not a lot to go off so I'm not expecting anyone to be able to tell me exactly what to do. I just want to know if anyone knows what these weird results could be. I'm thinking I may need to change some texture parameters but not sure which ones. Is there a clipping parameter or something? Any sort of guidance here would be appreciated
This looks a lot like z-fighting, which is caused by rendering two surfaces at the same depth. Numerical instability will cause some areas to be drawn over others in a changing pattern.
If you can find out which surfaces you're drawing twice and get rid of one of them, then this problem should go away.
I am trying to write a couple pixel shaders to apply to images similar to Photoshop effects. For example this effect:
http://www.geeks3d.com/20110428/shader-library-swirl-post-processing-filter-in-glsl/
But I noticed there is aliasing in the resulting image. What can I do to prevent this? I couldn't find any article that explains how to solve this. I read some techniques like rendering in high res and then downsizing the image, but I need to solve this in a pixel shader capacity. But if there is something that could help, I would appreciate it.
The WPF Shader Effect Library already has that same exact effect, along with many others. You can download the source from the link.
I am going to make a game like XNA example game "Platformer1" which comes with the XNA. But I need longer levels which doesn't fit in the screen (like Super Mario levels). How can I manage this kind of level? Do I need to use a 2d camera that follows the sprite? If I do this way how can I load the level? I am a bit confused and I am not sure if I could explain my problem clearly. Hope someone can help?
The tutorial based on Platformer Starter Kit in MSDN has a step Adding a Scrolling Level which guides you through creation of longer levels. The tutorial is very detailed, I highly recommend it.
I couldn't find the tutorial in the section for XNA Game Studio 4.0, but differences should be minimal. According to the comment at the bottom of the page, all you need to change is replace
spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None, cameraTransform);
with
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise, null, cameraTransform);
in the tutorial code.
If you want to create a side scrolling game, then I would look into parallax scrolling. A quick google/bing will help you find lots of tutorials. Also, another useful tip is to search YouTube for XNA videos has we a lot of posters share their source code .
Here is a link to Microsofts Parallax Scrolling.
Sounds like you have a few problems ahead of you.
But I need longer levels which doest'n fit in the screen(like super mario levels). How can I manage this kind of levels.
There are several ways to do this, but a fairly easy way would be to have a 2d array (or sparse array, depending on how large your levels are) of a class named Tile that stores info about the tile image, animation, ...whatever.
Yes, you'll probably want a "camera". This can be as simple as only drawing a certain range of that array or a more featured camera that uses transforms to zoom out and translate across your level.
Hopefully this will help get you started.
I've done a decent amount of work in XNA, and from my experience, there are 2 ways to draw a 2D scene:
1) Strictly 2D. This method is much easier, but has a few limitations. There is no "camera" per se, what you do is move everything underneath the fixed 2D "camera". I say "camera" in quotes because the camera is fixed (as far as I know). The upside is that it's easy, the downside is that you can't easily zoom in or out or do other camera effects.
2) 2D in 3D. Set up a 3D world with a 2D plane. This is more flexible, but is also more challenging to work with because you will need to set up a 3D world and 3D camera. If this is your first attempt with making a game, I would highly recommend against this method.
I'm really only familiar with the strictly 2D method, and you would want a list of map objects that have a 2D coordinate. You would also want to store which section of the map you are looking at, I do this with a Rectangle or Vector2 that stores this. This value would move forward as the character moves. You can then take your 2D map objects' coordinate and subtract the (X,Y) of the top-left of what you are looking at to determine an object's screen position. So:
float screenX = myMapObject.X - focusPoint.X;
float screenY = myMapObject.Y - focusPoint.Y;
An other thing to note, use floats or Vector2/3 to store locations, you may not think it's required now, but it will be down the line.
It might be overkill, but my SF project uses XNA to draw a Strictly 2D scene that you can move around: http://sourceforge.net/projects/asteroidoutpost/
I hope this helps.
Have a look at Nick Gravelyns tutorials. They helped me tonne when I was first starting out - Really really worth a look for learning a lot on 2D games.
All the videos are now on youtube here