Tag Info

New answers tagged

0

This question already has been answered. See the second link here: http://stackoverflow.com/questions/12794428/calculating-world-space-coordinates-in-the-pixel-shader


0

Okay so, finally achieved my goal. view = Matrix.CreateScale(new Vector3(1, 0.75f, 1)) * Matrix.CreateTranslation(-playerpos.X, -playerpos.Y, 1); world = Matrix.Invert(view); projection = Matrix.CreateOrthographicOffCenter(0, view.Width, view.Height, 0, -1, 1); Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0); projection = halfPixelOffset ...


0

In case if everybody will be looking for something similar, I have found what I have been looking for in the youtube tutorial made by Stuart Spence "Unity3D - Unity 4.6 UI Objects Created at Runtime". Also the release of Unity 4.6 brought the functionality which I wanted. Hope it'll help somebody.


2

From Unity 4.6 on the GUI system easily allows you to place any texture or sprite in screen space. It allows you to build complex HUDs including helath bar. See this video for an introduction


0

It's unclear what you're asking, but based on everything you stated I don't see any issues. Position is (0, 0), the texture dimensions are 20 x 20 and the origin which you specified in the Draw method is new Vector2(texture.Width / 2, texture.Height / 2). What I see in the screenshot appears to be correct, with the top left corner of the texture being at ...


0

This is a debugging issue. The image gets drawn where you are telling it to be drawn. The problem is you are not telling it to draw in the correct place. Use the debugger to examine Position when you enter the Draw() method. My guess is that Position will not have the value that you are expecting. If this is the case, look through your code, and find where ...


0

The line we're interested in is Position * 20 which, if Position is (0,0), is equal to (0,0) and you say it behaves correctly for Position * 20 + new Vector2(10,10) which is equal to (10,10) I'm guessing that the problem is a misunderstanding of order of operation. Adding parenthesis to show what happens first, we would have: (Position * 20) + new ...


0

You want method 1 or 3 probably. 2 is generally not preferred because you need to update 2 points whenever the rect moves as oppose to 1 point in method 1 or 3.


1

World position is vertex position multiplied by world matrix, not view matrix. So it should be like this in the vertex shader: output.WorldPos = mul(input.Pos,World); Unless you want View position to work with. I haven't checked the code for bugs if you want to use that.


0

I would suggest Perlin Noise to do this. Basically, generate N perlin noise values for each different factor, or, if you prefer 1 perlin noise value that gets hashed to a class (like planet, or emptiness): int x, y; // coordinates float scale; // The scale of the universe. Adjust this number to affect smoothness. float value = Perlin(x * scale, y * ...


0

GUI and 2D game objects are fundamentally different. Generally speaking, a GUI element is a 2D element (texture/text) that will accept some input and could potentially live in some screen hierarchy (e.g. a panel in a container). A 2D game object/element is... well, it's whatever a game object is in your game. It can move on its own, it could react to ...



Top 50 recent answers are included