Tag Info

New answers tagged

1

It simple, follow these steps Select the main camera Click on "GameObject" in the top panel Click on "Align View to Selected" It seems you are a fan of Clash of Clans ;)


0

Usually for portrait games you need to set camera as fixed height , that is how it already works in Unity. And for landscape games like side scrollers you need to use fixed width. You need to write some additional code to achieve this functionality. You can find the explanation in the following tutorial at 37 mins Unite 2014 - 2D Best Practices In Unity


1

GUI is actually rendered according to the screen view port and not according to the camera. In other words it is camera independent. You can try having a 3D text view or sprite in order to achieve the desired functionality. There are lot of other options also . Try Unity 5 GUI system or check out the NGUI plugin for unity. If you still want to use the ...


0

You need to tweak the shader file. Most probably there will be calculations based on the z axis. You need to take out all the z axis consideration from the calculation. For Example:- o.pos.xy += offset * o.pos.z * _Outline; Change to o.pos.xy += offset * _Outline; As every shader is different, I don't know if it will work for you, but it definitely ...


1

I had this class in previous project public class ExtendedCamera extends OrthographicCamera { public Player player; public ExtendedCamera(Player player) { super(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT); this.player = player; } public void followPlayer() { if (player.body.getPosition().x - position.x > ...


1

If you're using a tilemap, this transition is fairly easy to do. You will probably already have some sort of camera class. The thing is you only move the camera when the player reaches the edge. Suppose your screen is 20 tiles wide and 10 high, the camera shows 0, 0 to 19,9. If the character reaches the border of tile 19-20 set the camera to a 'transition ...


2

When centering the camera using lookAt you need to clamp the y value to be the max of the body's y and the y of the ground plus half the viewport height (possibly adjusting for the height of the ground). Something like this might make sense; float x = body.getWorldCenter().x; float y = Math.max(body.getWorldCenter().y, ground.getWorldCenter().y + ...


0

Here is how I would do it : Modify the material used by the terrain rendered with first camera to enable alpha blending (Blend SrcAlpha OneMinusSrcAlpha). So now the fragmentshader needs to output something to the alpha component (gl_FragColor.a, or the equivalent in Unity), for now use 1.0. Modify the vertex shader to compute view space depth and store ...


0

Parent the gun to the player not the camera. The camera movement is changing the transform of the gun. The capsule for the player still tips forward and backwards so parenting it to the player will alleviate the issue. Otherwise you can code a fixed transform that only allows for verticle and horizontal transform change instead of a forward transform change ...


0

The Unity Camera will always fit to the height , and it will scale its width towards left and right. You don't need to do anything to the camera to adapt it to 960x544. For testing purpose you can add a custom screen size to see how the actual game will look like. Go to Game window and select the drop down beneath to add a custom screen size. Reference ...


9

Ok, that's awkward. My last edit revealed the answer to my problem (that I've been struggling with all day): QGraphicsView casts the camera x/y position to integers... This is the solution: void SceneView::centerOn(const QPointF &pos) { if (mScene) { mScene->setX(int(-(pos.x() - width() / 2))); mScene->setY(int(-(pos.y() - ...


0

Set a radius around the player and if another player enters the radius then it starts screen recording for both people. You then wait to see if anyone is killed. If so then you find the killer and take their recording and rewind the amount of time elapsed since the kill plus the length you want the video to be and rewind and play it for the one who was ...


0

The trick is I think you misunderstood my original answer to your previous question. The camera's position should only be taken into account when drawing (using blit). You're offsetting all drawn objects in the screen by the camera's position. So two specific problems with the code you have shown: The blit that does use the camera position should subtract ...


0

This may, or may not, be the correct answer for you, BUT In your code, when you draw the platforms images to the screen, you add the camera's position to their x/y positions. This would not be necessary because you would then have problems with colliding, because your adding the cameras scroll to it so you wouldn't see them in their colliding positions. ...


2

It should work if you change these parts in show(): viewport = new ScalingViewport(Scaling.fillY, GAMESCREEN_WIDTH, GAMESCREEN_HEIGHT, camera = new OrthographicCamera()); and add a resize method: @Override public void resize(int width, int height) { int SCREEN_WIDTH = width; int SCREEN_HEIGHT = height; viewport.setWorldSize(GAMESCREEN_WIDTH, ...


0

You could use shaders instead. Here is a link of one that may help http://wiki.unity3d.com/index.php/SurfaceReflection.


0

I found that, physics system was late with matrix synchronization. In the result, scene node wasn't updated on time with the desired matrix. When I got new projection matrix for rendering, world matrix had updated matrix, but view matrix was calculated with old matrix. I realized that GLM library good accuracy in this respect, as for this, because DirectX ...


1

First, your entire map needs to be loaded (all "rooms/zones") like a single image. Next, you have a viewport that displays the Zone your in, say 0,0 to 50,50. next, you set collision to if player collides with zoneWallRight start a render loop that will render the map scroll in that direction. (move the view port x,y) at least, this is how I would do it. ...



Top 50 recent answers are included