Wall colliders getting out of screen unity - c#

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.

Related

OpenTK/GL Texture has weird lines going through it unless camera is in a sweetspot

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.

RTS Camera: The y and z values seem to be mixed up

I've been trying to figure out how to use the RTS plugin from the unity Asset Store but there seems to be a problem. I have no idea why this is happening, but the z and y values are mixed up. I can scroll left and right perfectly but whenever I press "W" the screen zooms out instead of moving upwards. The same applies to scrolling. When I scroll, the screen moves upwards/downwards and doesn't zoom out like its supposed too. I tried creating my own RTS camera via Brackeys and the same thing happened. His game would zoom, mine would just move upwards. I'm not for sure whats wrong. Im fairly new to all this unity jazz. ANY help would be appreciated
it's a little hard to know exactly why this is with the information you have provided. But if I were you the first thing I would check is your input manager! Have you done that and made sure your inputs correlate to exactly what you want?
It's sounds like your settings may be not be the default, causing the differences?

How can I stop tiles from auto scaling in visual studio (RESOLVED)

I have been working on a windows forms game in visual studio, it's pretty basic, but i'm mostly making it to learn more about C#. Anyway, in the main dungeon for the game, I drew a basic tile, and put it on a tiling picture box. In the inspector, it looks good, the tile is the same size as the player image, and the tiles line up with the edge of the picture box. However, once I hit play, the tiles auto scale, and become far too large, they don't fit with the character, and more importantly, they don't line up with the picture box. I have spent probably an hour and a half scanning through the inspector tools looking for a way to fix this weird error, but I can't seem to find anything.
I am wondering if there is any way to code in the tile attributes to make it work out. I have attached a picture of before I hit play (left), and after (right) so you guys get a better idea of what exactly I mean. Any fix would be greatly appreciated.
Thank you to everyone who answered, my visual studio was resizing itself in the edit mode, so I changed that setting everything works now.

Add plane boundary point on touch ARCore?

I am working with ARCore in Unity and would like to be able to add points to ARCore's boundary plane by touching a point on the screen. Is this possible?
More specifically, I want to be able to touch a point on the screen that I think should be part of ARCore's current plane and have that point be added to the plane's mesh.
I've looked around a bit through their documentation and on stackoverflow and haven't been able to find an answer.
This is not able and there is a grand chance that this will never be able.
Reason:
AR works with 3D reality, so it not a 2D dimension. This said when you click on your screen how the app will know how far you wanna click?
If the app is not recognising the plane it will have difficult to know if your click is for 30cm from the screen or 2m from the screen or 35cm from the screen.
Got the problem? if the app know the distance for sure it can decide by itself if is a plane.
The solution would be "put" fiscally the app in places that you wanna build a plane, like 3 coordinates and crate a plane between then. But this is not in the direction for User Experience with AR, so I expected today that no one will stop to do something like...

What is best way to create scrolling WORLD?

In this game im trying to create, players are going to be able to go in all directions
I added one single image(1024x768 2d texture) as background, or terrain.
Now, when player moves around I want to display some stuff.
For example, lets say a lamp, when player moves enough, he will see lamp. if he goes back, lamp will disappear because it wont be anymore in screen
If Im unclear, think about mario. when you go further, coin-boxes will appear, if you go back they will disappear. but background will always stay same
I thought if I spawn ALL my sprites at screen, but in positions like 1599, 1422 it will be invisible because screen is only 1024x768, and when player moves, I will set place of that sprite to 1599-1,1422-1 and so. Is it a good way to do this ?
Are there better ways?
There are two ways you can achieve this result.
Keep player and camera stationary, move everything else.
Keep everything stationary except the player and the camera.
It sounds like you are trying to implement the first option. This is a fine solution, but it can become complicated quickly as the number of items grows. If you use a tile system, this can become much easier to manage. I recommend you look into using a tile engine of some sort. There are a lot of great tile map editors as well.
Some resources for using Tiles:
Tiled -- Nice Map Editor
TiledLib -- XNA Library for using Tiled Maps
What you're describing there is a Viewport, which describes a portion of the 'world' that is currently visible.
You need to define the contents of your 'world' somehow. This can be done with a data structure such as a scene graph, but for the simple 2D environment you're describing, you could probably store objects in an array. You would need to bind your direction keys to change the coordinates of the viewport (and your character if you want them to stay centered).
It's a good idea to only draw objects that are currently visible. Without knowing which languages or packages you are using it's difficult to comment on that.
I would look into Parallax scrolling. Here is an example of it in action.
If this is what you require, then here is a tutorial with source code.
XNA Parallax Scrolling
After you are finished with basic scrolling, try to implement some frustum culling. That is only draw objects which are actually visible on the screen and avoid unnecessary drawing of stuff that cannot be seen anyway.
I would prefer solution number 2 (move player and camera) - It would be easier for me, but maybe its just personal preference.

Categories

Resources