Keeping the scene inside the screen - Unity - c#

beginner-ish Unity developer here.
I have made a simple Unity game and I have a problem when building it. I cant get the game to stretch to fit the size of the game window when built outside of Unity.
In the Unity scene when I am working, I set the camera to encompass a specific area of the scene that has my background objects and level and everything inside the camera view. The problem is when I build the game out of Unity the screen is a different size depending on the resolution setting, and the game objects(backgrounds, etc) doesnt stretch to fit anymore. So I either get the game going on in the center of the screen with the blue Unity space all around it where there is nothing, or the screen is too small and parts of the game are cut out(missle count, score) at the edges of the game.
I know there is a way to set this stuff up, but I am not sure where to start. Can anyone give me some info or point me in the right direction?
Thanks!

See link.
http://docs.unity3d.com/Manual/class-PlayerSettingsStandalone.html
Also when designing GUIs see example
GUI.Button (new Rect((Screen.width / 2) - 510, (Screen.height / 2) + 150, 200, 30)
http://answers.unity3d.com/questions/307330/gui-scale-guis-according-to-resolution.html

Related

Unity - healthbar as outlined line around the screen

I have a game in Unity.
The idea of the game is that an object is spawned on the screen.
It exists for several seconds.
You need to click on it, while it exists.
What I want to do, is that while it exists - I want to show a timer, but not with numbers, but with an outlined line on the perimeter of the screen.
I know, how to make a make a slider and how to make circular health bar, yet I do not really have an idea to make a slider, that is decresing from everywhere to the centre as you can see on the screenshots below.
I would be thankful for the inspiration!
This should be a very good fit using alpha cutoff with a custom shader.
Here's a video explaining it in detail (it's only the first half you will need).
The basic idea is to create a texture with a graded alpha depending on how you want the texture to appear/disappear. In this case the alpha value at the top and the bottom would be close to 0 and then gradually around the line on both sides towards the middle increase to 1. The shader then cuts off the texture below a cutoff threshold which you can change depending on the value of the timer.
As a dumb and simple approach:
Have two images with fill, one goes middle towards top the other middle towards bottom.
Just imagine the pnguin is your outline ^^

Unity 3D Cloth stretch

I developed a game where the user adjusts the angle and power to launch the ball with to try to score in the goal. I designed a Plane with a large amount of vertices for the mesh and imported it to unity. The ball hits the net well although the net not always stretches. for example if i set the angle to 17 degrees and power 100, for some reason, the cloth doesnt work. But regarding an issue im having with it is that I want to not simulate at the beginning, and should only simulate when the ball hits the cloth. The other thing: Is there anyway to make the cloth stretch even more and engulfs the ball in a way ? Thanks

Skybox Renders in Unity but anything else doesn't

sorry if the solution is quite obvious but I'm still a learning student.
I'm teaching myself on the side by making a 2D game and was working with Unity but got stuck when I noticed the Game screen and the Camera Preview display the game properly, but the moment I run it, it only shows the Skybox and nothing else in front of that... The Main Camera is behind the Background so I'm a lil confused why it only renders the Skybox.. any advice?
I put some pics below as an example of the settings (yes the camera follows the player and some usages are a bit outdated)
After another look, and close inspection, I would like to point you at where your objects are actually located, your max and min for your camera is: -4 and 0.66 your BG and your camera are starting at -100 something. so when the game starts your camera is moving to -4 from -110 that is why you cannot see them.

Particles not appearing in Unity

I have made a smoke particle effect that I instantiate everytime the player shoots, its working but can not be seen with the background. If I delete the background it's visible, I've tried changing the ordering layer, creating a new layer and putting it above the default, but no matter what it's still below the background. Any ideas?
Assuming you are developping a 2D game, you can use the z axis to set the distance of the elements to the camera (what will be the equivalent to the order of render)
Usually in a 2D game you will have the main camera at -10 in the z axis. So moving in the inspector the backgroun to, lets say z=5 or z=10, and keeping in you particle system in z=0 should solve your problem.
Try this easy trick and let me know if you are still facing problems.
You can check the second half of this video for a better understanding
Also, if you are making a 3D game you can go to the material of the particles and make sure that render face is set to both. I just had that problem and it was annoying me. but that fixed it.

VR score text display

I am trying to make a VR game with google cardboard in unity. However we can not find a way to display score text right in front of the player. However when I add 2D text it is only on one side and therefore on one side of the eye and getting the position right for 2 texts is hard. If I use 3D text and set in front of the players position I think it will go into the wall if a player hits one. Is their any way to display a score on google cardboard / Unity VR.
You can either use native Unity Canvas UI or Googles hack to render OnGUI calls onto a texture.
I would definately recommend Canvas as that is the way Unity is working on their UI features, and it has much better layout capability.
To use canvas, Right click in the hierarchy and add UI->Text. You will automatically get a canvas. The important part is set the canvas to world-space (not screen space overlay). Then drag the canvas game object so it is a child of the Google Cardboard Main head object. Scale it down (like x:0.001,y:0.001,z=0.001) because by default it will be massive. To avoid going through walls position it about 0.5m in front of the camera - within any collider you may have.
there is another approach as well which you can place that canvas under camera make it world space, and then adjust it as you want, after that where ever you look at it will be seen easily ( as suggested by earlier user in answers) as you can see below in picture i placed canvas > Text > under camera which i used for oculus/ google camera

Categories