texts: Camera movement using WASD on x/z plane only

texts:
I've been wearing my enter key down on google searches - I have a camera script based on the MouseOrbit.js asset. That's all working fine, but in addition to the basic orbiting and the zooming that I've added, I would like to use the WASD keys to move the camera around the world.

The W key would move the camera straight forward, however it would ignore the y axis. For example, using

transform.Translate(Vector3.Forward*Time.Delta*20);

moves the camera forward relative to the camera. This results in you quickly hitting the ground. Moving back obviously does the opposite. The desired effect is sliding across the world without getting any closer/farther to it, regardless of the angle the camera is at.

The closest I can get is using the Space.World parameter of Translate(), but this does not take into account the rotation of my camera. I think if I could take that into account, this would be solved but I'm not clear on how to do that.


texts: How to change frames for the same object

texts: Lets say I have four frames A,B,C and D. In idle condition, I want the game object to repeatedly running on frame A and B . When using the method OnMouseDown, the same object change to frame C and D and OnMouseUp it return to the original frame A and B again. I'm not sure what command to look for on the internet. Would appreciate if someone can attach a link or example so I can start learning this myself.


texts: I want to rotate my game object around a point in the space instead of the origin, so how can I do it ?


texts: Why does Unity not follow the z-value when drawing text?

texts:
I'm currently working on the credits of our game. For this I'm using multiple elements in a canvas:

I want the order that these elements are drawn in to be as follows, I gave them a z-value based on this:

 Z    Object                             Object type
=========================================================
 0    Text (The actual credits)          Text
---------------------------------------------------------
-1    Hider (Green for demonstration)    Sprite
---------------------------------------------------------
-2    Divider (The grey line)            Sprite
-2    Gametitle                          Text

The camera has a z-value of -10. The canvas is in "Screen Space - Camera" render mode.

But for some reason Unity is not drawing these items based on these Z-values:

As you can see, the Divider is drawn over Text, but Text is above Hider and Gametitle. Why is this happening and what can I do so the credits get properly drawn?


texts:
I am trying to program TopDown Car using python and Box2D (similar to this tutorial: http://www.iforce2d.net/b2dtut/top-down-car ) The steering is so far limited to thres states of wheel rotation, that I will need to solve later, now
I have problem with controlling the car velocity.

The problem is that the vehicle moves rather uncontrollably, I press "W" to move forward, "A" or "D" to steer, but then I ofttimes need to press "S" key to keep going in forward direction (which is of course counter-intuitive).

EDIT: I tried to convert world/object coordinates, it helped partially because now my car is moving from the beginning in straight line (it was always going slightly obliquely to the right, but now it has problems with turning, it turns uncontrollably and there is still the problem with messed-up directions (when I need the car to go forward after turning i have to press S

This is the main game loop: it should be updating PyGame frame 60 times per second, in Every frame I am cancelling lateral velocity of a body and then I am trying to controll the body

while running:
# Check the event queue
    screen.fill((255, 255, 255,0))
    for body in world.bodies:
        for fixture in body.fixtures:
            fixture.shape.draw(body, fixture)

        # Cancelling lateral velocity
        for wheel in Wheels:

            if wheel in range(2):
                continue # Rear wheels are not powered
            else:
                Current_Normal = wheel.GetWorldVector((0,1))
                Current_N_Squared =  b2Dot(Current_Normal, wheel.linearVelocity) * Current_Normal

                Right_Normal = wheel.GetWorldVector((1,0))
                Right_Normal_Squared = b2Dot(Right_Normal, wheel.linearVelocity) * Right_Normal

                Impulse = -Right_Normal_Squared * wheel.mass
                if Impulse.length >max_lateral_impulse:
                    Impulse *= max_lateral_impulse/Impulse.length

                wheel.ApplyLinearImpulse(Impulse, wheel.worldCenter, True)

                # Allowing skidding

                aimp = 0.05 * wheel.inertia * -wheel.angularVelocity
                wheel.ApplyAngularImpulse(aimp, True)

                current_forward_speed = Current_N_Squared.Normalize()

                drag_force_magnitude = -2 * current_forward_speed
                wheel.ApplyForce(drag_force_magnitude * Current_N_Squared,
                                        wheel.worldCenter, True)

        # Moving forward/backward
    if event.type == KEYDOWN and event.key == K_w:
        Left_Wheel.ApplyLinearImpulse(impulse=Left_Wheel.GetWorldVector((0, 10)), point =Left_Wheel.GetWorldVector((Left_Wheel.position)),wake = True)
        Right_Wheel.ApplyLinearImpulse(impulse=Right_Wheel.GetWorldVector((0, 10)),point = Right_Wheel.GetWorldVector((Right_Wheel.position)),wake = True)

    elif event.type == KEYDOWN and event.key == K_s:
        Left_Wheel.ApplyLinearImpulse(impulse=Left_Wheel.GetWorldVector((0, -10)), point =Left_Wheel.GetWorldVector((Left_Wheel.position)),wake = True)
        Right_Wheel.ApplyLinearImpulse(impulse=Right_Wheel.GetWorldVector((0, -10)),point = Right_Wheel.GetWorldVector((Right_Wheel.position)),wake = True)

If you want to play with my code in order to better see where the problem is I can give you the whole script (270 lines in total)

I know that to move more realistically I need to play with the aimp or max_lateral_velocity values. But first I need the car to be controlled better

EDIT 2: I am sorry, I was probably able to solve this problem by applying this:

Left_Wheel.ApplyLinearImpulse(b2Vec2(Left_Wheel.GetWorldVector((0, 10))), Left_Wheel.position,True)
Right_Wheel.ApplyLinearImpulse(b2Vec2(Right_Wheel.GetWorldVector((0, 10))), Right_Wheel.position,True)

This seems to be working, many thanks to Aleš Koblížek for patience Now my problem seems to be solved


texts:
I'm making a pixel-art game in Unity. The sprites are set to 16 PPU, and currently to guarantee that the pixels scale nicely (integer intervals), I'm setting the Camera's orthographic size.

In 16x9 aspect ratio on a 1920x1080p monitor, this gives me an orthographic size of 8.4375, effectively scaling up my art 4x.

The problem comes with rotations. When you rotate the pixel art using a standard rotation shader, the shader considers screen pixels but not the art pixels. I know there are solutions to this problem on the Asset store, but I'd like to create my own (I have checked other stack posts on this subject, but there doesn't seem to be a solution).

Currently, I have a rotation shader that rotates the vertices in the vertex function. However, like I mentioned above, this rotates in screen pixels. One idea I had was to first scale the sprite down to its art pixel dimensions (by scaling the vertices in the vertex shader), then rotate it, then scale it back up (in another pass?). I couldn't figure out how to make this work, and I'm not sure if it's the most efficient way.

Another idea I had was to create a copy of the texture that's being rotated in a script, save it in a larger texture, then handle all my rotations within the new texture (using SetPixels and Apply). This would ensure that the rotations are being done in art pixels, but is probably slower (and more inconvenient) than using a shader.

Note: Rendering to a back buffer and then scaling up everything is not a solution for me (this isn't a purist pixel art game, I just want pure pixel art rotations).

Any ideas? What approach should I take? I don't need the code written out for me, I just need an approach that'll work. Thank you!

Here is an example of what I'm talking about (credit for images goes to this stack overflow post, although it didn't have the solution I'm looking for).

Rotation on screen pixel level

Rotation on art pixel level

This is not a duplicate of this stack post. The solution that was accepted in that post does not perform rotation on the art pixel level, and because of that, it's not a valid solution in my case.


texts: How to call animation event from another GameObject

texts: I have an animation event but I want it to call a function from a script that is attached to a different GameObject that I'm not animating. Is this even possible?


texts:
I am trying to implement a simple beam tracing simulation. Basically it models the path of a beam within a pipe:

In the picture, the beam starts emitting from p1, hitting the boundary at p2 and reflects to p3. I was thinking of the algorithm of such a system. Assuming that all equations of the 2 blue curves are known:

1) Get the parametrized representation of original line from p1, say p1(t).

2) Equate p1(t) with both curves.

3) Find the first intersection p2, determined by the lowest value of t.

4) Get the normal at the intersection and get the equation of the reflected beam, p2(t).

5) Equate p2(t) with both curves, eventually solving for p3.

6) Repeat for as many iterations as needed.

My question is that, is there more sophisticated way of doing this? Or is there a library out there that implements this kind of functionality directly? Currently I am using C#, and looking into WPF and also OpenGL, but I am afraid that OpenGL may be too low level (?) and requires much code to achieve this.


texts:
Im downloading some free 3d models off the internet to test things in my game. When I download the package, it gives me a bunch of texture files and the obj model. What I dont understand is what I do with those textures? Are they used as source image files within the object? If so how can I export the uv map of the model with all these textures on it? Ive been trying to get a working example of this and havent been able to. Can someone guide me in the right direction? I edit my files with blender, and realize this question is a little bit off topic, but im lost!

EDIT:

Example of the textures I am using now:


texts: SRTM data represented in 3D using Unity Terrain

texts:
I am new to using Terrain height maps in Unity.

I'm trying to use real-world terrain height data, using sources including:

The US Geological Survey (files like N24E054.hgt)
Google Maps (SRTM hdr files, tfw files, and tif files)

I want to import this high definition terrain data into a Unity terrain.

In Unity, it seems like terrain can only import Raw data representation.

How can I use an hgt file to shape a Unity Terrain?


texts: Is JavaScript viable for serious multiplatform 2D game development?

texts:
Ever since I was a little kid, my dream has been to develop games. Well, now that I am older, more mature, and have some programming experience, I would like to start. However, I would like to turn this into a career.

I would like to develop strategy games like "Stronghold" and "Age of Empires".

The problem is that my language of choice is JavaScript.


texts:
Im currently trying to implements AdMob into my libgdx game, but it seems that all tutorials are deprecated.

For example in the offical libgdx wiki the google play services get imported into eclipse, but google split the google play services up. Also I need to implement Firebase to the game (u need to now), but it doesnt say anything about that either. I also looked at the offical tutorials for Android Studio, but doing it in LibGDX doesnt seem to work (Cant resolve AdView).

All help is appreciated, thanks.


texts: Proper approach to handle transformation matrix and extract its components

texts:
Basically I have a Transformation component object with following structure(pseudo):

TransformComponent{
  Vec3 position;
  Vec3 rotation; //in euler angles
  Vec3 scale;
  Mat4 worldMatrix; //transformation matrix in world space
  Mat4 localMatrix; //transformation matrix relative to parent transform
  Mat4 worldToLocal; //Matrix to convert children worldMatrix in localMatrix
  TransformComponent parent;

  /* calculates worldMatrix using position,rotation & scale.
   * Also calculates inverse of worldMatrix and stores it in worldToLocal;
   */
  void CalculateWorldMatrix();

}

Then I do some transformations like:

    transform.position = [1,1,1]; //set new position

    transform.CalculateWorldMatrix(); //recalculate worldMatrix with new translation coordinates.

    //Multiply worldToLocal with worldMatrix in order to get localMatrix.
    localMatrix = transform.parent.worldToLocal * transform.worldMatrix;

After that, I have localMatrix with position, rotation etc relative to parent transform.
But I can't figure out how to get components(position,eualerAngles,scale) out of localMatrix. As far as I googled I found some really difficult solutions, which I couldn't understand, and as I'm writing on JavaScript I hope there is a simple solution.
Maybe I am using wrong structure for transform object?
What is the common approach here?
I read that its preferred to use quaternions, but only advance they give is about gimbal lock, at this moment because of simplicity I would like to stick with euler angles if it's possible.


texts: Unity3D - Change player input axes on trigger

texts:
Hope someone can help me with this, it seems like it should be a simple problem but that only makes it more frustrating!

I have a simple game where you roll a ball around by applying force to the horizontal and vertical axes. What I want to happen is, on a trigger, the axes switch from say the X and Y, to the X and Z, changing the way the player controls without changing the input buttons... The script I use to move the player is below:

{
  float moveHorizontal = Input.GetAxis ("Horizontal");
  float moveVertical = Input.GetAxis ("Vertical");

  Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
  rb.AddForce (movement * speed);
}

(Where rb is the player ball object) - I'm thinking I'm going to have to change the way the player is controlled as I can't any reference to a 3rd axis in the Input.GetAxis documentation... any help with this would be great!

Thanks!


texts:
I have pretty much zero experience working with shaders as my first couple phone games were just 2d games that didn't use any sort of shaders. Now I'm working on a PC game that has a day and night cycle so I found a tutorial and implemented a shader effect with only a basic understand of how it's working. Enough so that I've been able to accomplish what I've desired with darkness and lighting. This is a 2d game as well. Anyway here's my shader effect that I'm using:

texture lightMask;
sampler mainSampler : register(s0);
sampler lightSampler = sampler_state{Texture = lightMask;};

struct PixelShaderInput
{
    float4 TextureCoords: TEXCOORD0;
};

float4 PixelShaderFunction(PixelShaderInput input) : COLOR0
{
    float2 texCoord = input.TextureCoords;

    float4 mainColor = tex2D(mainSampler, texCoord);
    float4 lightColor = tex2D(lightSampler, texCoord);

    return mainColor * lightColor;
}

technique Technique1
{
    pass Pass1
    {
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}

And Implement like so:

drawMain();
drawLightMask();

ScreenManager.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
lightingEffect.Parameters["lightMask"].SetValue(lightMask);
lightingEffect.CurrentTechnique.Passes[0].Apply();
ScreenManager.SpriteBatch.Draw(mainScene, Vector2.Zero, Color.White);
ScreenManager.SpriteBatch.End();

I didn't notice any problem at first on my 27" S-IPS 2560x1440 monitor. When I change primary monitors to my 1920x1080 LCD monitor the shaders don't appear to work the same. It doesn't have the soft gradient lighting from my lightmask. It's kind of difficult to describe. The outside edge of the lightmask isn't a fade into darkness. It's more of an abrupt change from being lighter to darker. I've tested on another computer and it's not working right on that other computer either. It has a 22" or so LCD monitor. Anyway I'm just confused as to why it's displaying different based on the monitor. I do scale but I start at 0.6f * hudScale so the lightmask is fairly large and starts even scaled down.

I really don't understand much about shaders so perhaps someone out there can help me understand why there is this difference of how the shader is displaying between monitors. My primary monitor is displaying it exactly how I like it, but more people have 1920x1080 LCD monitors than one like my 25560x1440 S-IPS LED so I want to to display the for all setups.


texts: How do I implement efficient collision avoidance in 100 enemies

texts:
I am developing a libgdx game. It is a top down shooter and I am trying to make a good AI. I have tried to implement A* from the AI library from libgdx and it works fine but when i have a lot of enemies it starts to slow down the game. Have tried implementing a Pathfinding manager to manage threads and path requests but I have trouble implementing it and still slows down.

Also I know A* is a bit overkill for my game, which is a big open zone mostly (see pic of my map)

So I tried to implement this collision avoidance Steering Behaviors: Collision Avoidance but it doesn't go well when the player is inside houses.

My question is, does exists some type of algorithm that fits perfectly for what I am asking? There are a lot of games with hundreds of enemies going to kill you so I bet there is a way, just I cant find out

pd: Any doubt ask and I will provide more information if necessary


texts: How to create two objects from one vertices array with translate?

texts:
I have an object and I can render it but I want to use its vertices twice but I don't know how to.

this is my code reading object from txt:

fin.open("piyon.txt");
fin >> vertexCountpiyon;
verticespiyon = new SimpleVertex[vertexCountpiyon];

for(int i=0; i<vertexCountpiyon; i++)
{
    fin >> verticespiyon[i].Pos.x >> verticespiyon[i].Pos.y >> verticespiyon[i].Pos.z;
    fin >> verticespiyon[i].Tex.x >> verticespiyon[i].Tex.y;
    fin >> verticespiyon[i].Normal.x >> verticespiyon[i].Normal.y >> verticespiyon[i].Normal.z;
}
fin.close();

bd.ByteWidth = sizeof( SimpleVertex ) * vertexCountpiyon;
ZeroMemory( &InitData, sizeof(InitData) );
InitData.pSysMem = verticespiyon;
hr = g_pd3dDevice->CreateBuffer( &bd, &InitData, &g_pVertexBuffer_piyon );
if( FAILED( hr ) )     return hr;

and my render code:

  g_pImmediateContext->IASetVertexBuffers( 0, 1, &g_pVertexBuffer_piyon, &stride, &offset );
    cBuffer.vMeshColor = XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f );
    XMMATRIX mTranslateBeyazPiyon = XMMatrixTranslation( -17.5F, 0, -12.5F );
    cBuffer.mWorld = XMMatrixTranspose( mTranslateBeyazPiyon );
    g_World_Piyon = mTranslateBeyazPiyon;
    g_pImmediateContext->UpdateSubresource( g_pConstantBuffer, 0, NULL, &cBuffer, 0, 0 );
    g_pImmediateContext->VSSetShader( g_pVertexShader, NULL, 0 );
    g_pImmediateContext->VSSetConstantBuffers( 2, 1, &g_pConstantBuffer );
    g_pImmediateContext->PSSetShader( g_pPixelShader, NULL, 0 );
    g_pImmediateContext->PSSetConstantBuffers( 2, 1, &g_pConstantBuffer );
    g_pImmediateContext->Draw( 7050, 0 );


texts: How do I get line numbers in a unity headless server's stack trace?

texts:
For some reason Unity 5 doesn't allow me to do a developement build of a headless server, and this is quite a problem when debugging, since I get stack traces without line numbers, such as:

NullReferenceException: Object reference not set to an instance of an object
  at ClientServer.Update () [0x00000] in <filename unknown>:0

Trying the xvfb trick to run a pseudo-headless server, which doesn't prevent enabling debugging symbols, doesn't work (it crashes mono for some reason).

I'm really at a loss on how to debug an headless server… is there something I'm missing?


texts: I need to make a scrolling 3D text, which is not a gui. I have a 3d box display over which I should render a long scrolling text. I can render and move text, but how do I cut/make invisible the part that goes out of the display area?


texts: How do you create a cbuffer or global variable that is gpu modifiable?

texts:
I'm implementing tonemapping in a pixel shader, for hdr lighting.

The vertex shader outputs vertices with colors.  I need to find the max color and save it in a global.

However when I try and write the global in my hlsl code,

//clamp the max color below by this color
clamp( maxColor, output.color, float4( 1e6,1e6,1e6,1e6 ) ) ;

I see:

error X3025: global variables are implicitly constant, enable compatibility mode to allow modification

What is the correct way to declare a shader global in d3d11 that the vertex shader can write to, and the pixel shader can read?

I realize this is a bit tough since the vertex shaders are supposed to run in parallel, and introducing a shader global that they all write to means a lock..


texts: Low CPU/Memory/Memory-bandwith Pathfinding (maybe like in Warcraft 1)

texts:
Dijkstra and A* are all nice and popular but what kind of algorithm was used in Warcraft 1 for pathfinding?

I remember that the enemy could get trapped in bowl-like caverns which means there were (most probably) no full-path calculations from "start to end".
If I recall correctly, the algorithm could be something like this:

A) Move towards enemy until success or hitting a wall

B) If blocked by a wall, follow the wall until you can move towards the enemy without being blocked and then do A)

But I'd like to know, if someone knows :-)

[edit] As explained to Byte56, I'm searching for a low cpu/mem/mem-bandwidth algo and wanted to know if Warcraft had some special secrets to deliver (never seen that kind of pathfinding elsewhere), I hope that that is more concordant with the stackexchange rules.


texts: Hi,Dynamically modifying meshes in Unity3D

texts:
I'm working in Unity3D and I want to remove sections from a mesh at runtime similar to the idea of
bombs removing sections of walls. In 3D modelling software this is a pretty standard Boolean operation, but it doesn't seem to be standard (or simple to implement) in game engines.

I know this is possible because of projects such as SabreCSG,
MegaFiers,
and
the various
C# implementations
of CGS.js

Unfortunately, SabreCSG doesn't seem to be usable at runtime, MegaFiers costs €134, and the C# versions of CSG.js mostly lack documentation and leave a whole mess of unnecessary polygons that mess with performance.

There must be a better way. Do any of you wise folks know what that better way might be?


texts:
I have a fragment shader which needs lots of semi-random access to 32x32 texture patch.  Fortunately, the patch is constant for each poly, so there should be no issue storing the whole thing to the texture cache.

So my question is, is there any way in GLSL to prefetch texture patches?  Normally, I would be fine letting the FS load the texture naturally, but with the nondeterministic access pattern, I'm afraid that could be producing a ton of unnecessary thrashing while it sorts itself out.


texts: Using coroutines and texture array for talking animation?

texts: I was thinking of having random textures from a texture array being chosen every 0.5 seconds through a coroutine to imitate talking if something like talking=true. Not sure how I could set this up and such so I appreciate any help!


texts: Android Java: Way to effectively pause system time while debugging?

texts:
In my project, I call nanoTime and use that to get a deltaTime which I pass to my entities and animations.

However, while debugging (for example, stepping through my code), the system time on my phone is happily chugging along, so it's impossible to look at, say, two sequential frames of data in the debugger (since by the time I'm done looking at the first frame, the system time has continued to move ahead by seconds or even minutes).

Is there a programming practice or method to pause the system clock (or a way for my code to intercept and fake my deltaTime) whenever I pause execution from the debugger?

Additional Information:

I'm using Eclipse Classic with the ADT plugin and a Samsung SII, coding in Java.
My code invoking nanoTime: http://pastebin.com/0ZciyBtN
I do all display via a Canvas object (2D sprites and animations).


texts: Where to place cards drawn from a deck of cards to a tableau

texts:
I've never written card games before and am currently coding up a simple card game, I have a deck of cards and they need to be shuffled (done) and then draw from the top deck into a tableau (centre of table) from which the user(s) can pick from.

The only issue is I'm not sure how I can figure out where the cards drawn from the top deck go to.

Let's say the draw deck is drawn at 100,100.

Let's say the tableau starts at 200,200 and can have 6 cards in them.

How do I know where the cards are going to appear on screen within the tableau?

My current thoughts are that we fill the tableau "empty" card objects at set X/Y co-ordinates so that I know without having to do too much programming where the cards should go to.

But I'm not sure if this is the best way to do it because of screen sizes, etc.

ie: Tableau. A card width is 50, and the distance between them is 20

> Card slot #1 = 200,200 (State: Empty)
> Card slot #2 = 270,200 (State: Empty)
> Card slot #3 = 340,200 (State: Empty)

So the first card drawn would animate from 100,100 to 200,200 and change it's state to Filled
The second to 270,200, changing its state
The third to 340,200, changing its state
And so on..

But I'm still unsure if using hard number co-ordinates is really the best way forward, especially if the screen sizes change; or even if there's a better way to animate cards from a draw pile to a tableau.

My question therefore is -- how do I make the computer know where to put cards drawn from a deck of cards to a tableau?

Many thanks


texts:
How exactly does a collision engine work?

This is an extremely broad question. What code keeps things bouncing against each other, what code makes the player walk into a wall instead of walk through the wall? How does the code constantly refresh the players position and objects position to keep gravity and collision working as it should?

If you don't know what a collision engine is, basically it's generally used in platform games to make the player acutally hit walls and the like. There's the 2D type and the 3D type, but they all accomplish the same thing: collision.

So, what keeps a collision engine ticking?


texts:
Hi guys I am trying to calculate the correct elapsedTime for each frame in my animation.

Example I have a sprite called stance that has 20 frames I want to give each frame a tick delay property that determines how long that frame will last until next frame.

the question is how do I use the gameTime.elapsedTime to calculate the current elapsedTicks say for example the first frame has 20 ticks then

currentElapsedTicks += gameTime.ElapsedTime.Ticks?


texts: What options are there for developing on the Nintendo platforms?

texts: I know of Wario Ware DIY but is this the only option?


texts: How can I organize code for views efficiently?

texts:
I'm making a video game for the Android platform and I need advice on the overall set up of the activities and views in the code. I don't need actual code, psuedocode will do, but actual code always helps. I will basically have the following:

A surface view that draws bitmaps in a 2d scene and rearranges them according to what ever is happening on the screen.
A main UI interface that needs to be shown on top of the surface view at all times that has buttons like the attack, defend, hotkeys and so on.
A start menu as a seperate activity that the user can choose options like volume, orientation, graphics quality, save & exit and so on.

Also I want dialogs throughout the games that pop up when interacting with NPCs and these dialogs need to display pictures as well.

That pretty much encompasses the first version of the game. I will add complexity to it maybe later on down the road but for now I would just like a general plan of how to set all of this up in a functional way. Again code would be nice but I really just need an idea of how to efficiently do these things without wasting memory resources and utilizing the Android APIs capabilites with smart programming methods.


texts:
Is it possible to export my UDK 2 project to UDK 3 ?
What kinds of things aren't transferable?


texts:
I need to draw contour around 2d objects in 3d space. I tried drawing lines around object(+points to fill the gap), but due to line width, some part of it(~50%) was covering object. I tried to use stencil buffer, to eliminate this problem, but I got sth like this(contour is green):

http://goo.gl/OI5uc (sorry I can't post images, due to my reputation)

You can see(where arrow points), that some parts of line are behind object, and some are above. This changes when I move camera, but always there is some part, that is covering it.
Here is code, that I use for drawing object:

    glColorMask(1,1,1,1);
    std::list<CObjectOnScene*>::iterator objIter=ptr->objects.begin(),objEnd=ptr->objects.end();
    int countStencilBit=1;
    while(objIter!=objEnd)
    {
        glColorMask(1,1,1,1);
        glStencilFunc(GL_ALWAYS,countStencilBit,countStencilBit);
        glStencilOp(GL_REPLACE,GL_KEEP,GL_REPLACE );
        (*objIter)->DrawYourVertices();

        glStencilFunc(GL_NOTEQUAL,countStencilBit,countStencilBit);
        glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE);
        (*objIter)->DrawYourBorder();

        ++objIter;
        ++countStencilBit;
    }

I've tried different settings of stencil buffer, but always I was getting sth like that.
Here is question:
1.Am I setting stencil buffer wrong?

2. Are there any other simple ways to create contour on such objects?

Thanks in advance.

EDIT:

1. I don't have normals of objects.

2. Object can be concave.

3. I can't use shaders(see below why).


texts: How to draw realtime 3D amoebas in OpenGL?

texts:
How would one draw 3D amoebas in real-time in OpenGL? The key components I'm looking for are:

Curved closed surface that changes shape
Generally transparent
Something translucent inside showing the volume is occupied

It has to be in real-time, and be able to handle many (100's) of these moving and animating on screen simultaneously.

What techniques might one use to accomplish this?


texts: I'm a total newbie to UE4. I need to make a game which downloads levels, actors, materials etc. every time it starts from the web. What is the best practice to do that? Is it possible using UE4 only or should I "wrap" it in something? Thank you


texts: How can I create a body with a hole in the middle?

texts:
I want to create a shape that looks like the black contour in this picture:

The shape must be empty in the middle(white surface). The white surface must not be part of the shape, just the black contour should be a shape.

How can I create such a shape?

I already tried it with the BayazitDecomposer, but it's not working. The BayazitDecomposer makes a shape of the entire picture(white surface+black contour).

UPDATE:

It's not working. I tried it with TriangulationAlgorithm.Delauny but it doesn't create the hole. You can see the result in this debug view picture:

My code:

List<Vertices> list = new List<Vertices>();
Vector2 _origin;
float _scale;

HoleSprite = Content.Load<Texture2D>("hole");
uint[] data = new uint[HoleSprite.Width * HoleSprite.Height];
HoleSprite.GetData(data);
Vertices textureVertices = PolygonTools.CreatePolygon(data, HoleSprite.Width, false);
Vector2 centroid = -textureVertices.GetCentroid();
textureVertices.Translate(ref centroid);
_origin = -centroid;
textureVertices = SimplifyTools.ReduceByDistance(textureVertices, 4f);
list = Triangulate.ConvexPartition(textureVertices, TriangulationAlgorithm.Delauny);
_scale = 1f;

//scale the vertices from graphics space to sim space
Vector2 vertScale = new Vector2(ConvertUnits.ToSimUnits(1)) * _scale;
foreach (Vertices vertices in list)
{
  vertices.Scale(ref vertScale);
}

Body Contour = BodyFactory.CreateCompoundPolygon(world, list, 1.0f, BodyType.Dynamic);
Contour.BodyType = BodyType.Dynamic;


texts: Who should be contacted to request permission, for commercial songs (and cost ballpark)

texts:
While playing to Fifa, it occurred to me that there is probably a license that EA pay to musicians to play their songs in their game.

Does anyone know if there is a standard license for indie games, to be able to play commercial songs in the game? Either for the intro and for the game itself, like FIFA does.

I did a brief search and the suggestion is to contact the publisher of the specific group/singer; but 90% of the time they probably won't even read such email. Is this the only way?

Of course this won't apply for free music that is distributed to be freely used for any use; my question is specifically for commercial music from decently known artists.


texts: Fragment shader for lighting in isometric perspective

texts:
What I'm trying to do is to achieve basic lighting in 2D from an isometric perspective.

Here I have 2 textures that are used as tiles for the ground:

Color:

Normal map:

I have a fragment shader that was adjusted a bit to my needs, but mostly made from this tutorial: https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson6

Here is my fragment shader:

uniform sampler2D texture;
uniform sampler2D normal_texture;

//values used for shading algorithm...
uniform vec2 Resolution;      //resolution of screen
uniform vec4 AmbientColor;    //ambient RGBA -- alpha is intensity

uniform vec3 LightPos[3];        //light position, normalized
uniform vec4 LightColor[3];      //light RGBA -- alpha is intensity
uniform vec3 Falloff[3];         //attenuation coefficients

void main()
{
    vec4 DiffuseColor = texture2D(texture, gl_TexCoord[0].xy);

    vec3 NormalMap = texture2D(normal_texture, gl_TexCoord[0].xy);

    vec3 Sum = vec3(0.0);
    for (int i = 0; i < 3; i++) {
        //The delta position of light
        vec3 LightDir = vec3(LightPos[i].xy - (gl_FragCoord.xy / Resolution.xy), LightPos[i].z);

        //Correct for aspect ratio
        LightDir.x *= Resolution.x / Resolution.y;

        //Determine distance (used for attenuation) BEFORE we normalize our LightDir
        float D = length(LightDir);

        //normalize our vectors
        vec3 N = normalize(NormalMap * 2.0 - 1.0);
        vec3 L = normalize(LightDir);

        //Pre-multiply light color with intensity
        //Then perform "N dot L" to determine our diffuse term
        vec3 Diffuse = (LightColor[i].rgb * LightColor[i].a) * max(dot(N, L), 0.0);

        //pre-multiply ambient color with intensity
        vec3 Ambient = AmbientColor.rgb * AmbientColor.a;

        //calculate attenuation
        float Attenuation = 1.0 / (Falloff[i].x + (Falloff[i].y*D) + (Falloff[i].z*D*D));

        //the calculation which brings it all together
        vec3 Intensity = Ambient + Diffuse * Attenuation;
        vec3 FinalColor = DiffuseColor.rgb * Intensity;

        Sum += FinalColor;
    }

    gl_FragColor = gl_Color * vec4(Sum, DiffuseColor.a);
}

This shader WORKS with traditional 2D perspective. That's because in traditional perspective the ground tiles normal map would have a color scheme closer to something like this, just wouldn't be tilted to fit an isometric perspective of course.

The issue: How do I go about adjusting the math in my fragment shader to fit an isometric perspective and work with the "greenish" ground normal maps.

Here's what I'm currently getting with this shader. Light should be equally going in all directions, but it's as if it's going down a slope.


texts: Dealing with multiple animation state in one sprite sheet image using html5 canvas

texts:
I am recently creating a Game using html5 canvas .The player have multiple state it can walk jump kick and push and multiple other states my question is simple but after some deep research i couldn't find the best way to deal with those multiple states
this is my jsfiddle : http://jsfiddle.net/Z7a5h/5/

i managed to do one animation but i started my code in a messy way ,can anyone show me a way to deal with multiple state animation for one sprite image or just give a useful link to follow and understand the concept of it please .I appreciate your help

 if (!this.IsWaiting) {
    this.IsWaiting = true;
    this.lastRenderTime = now;
    this.Pos = 1 + (this.Pos + 1) % 3;
 }
  else {
    if (now - this.lastRenderTime >= this.RenderRate) this.IsWaiting = false;
 }


texts: How to Integrate Unity with Google Play Game Services for iPhone and Android games

texts:
I want to integrate Google Play Game Services for Apple's iOS and for Android.
How can I do this efficiently?


texts: Vector normalization gives very imprecise results

texts:
When I normalize vectors I receive very strange results. The lengths of the normalized vectors range from 1.0 to almost 1.5. The functions are all written by me, but I just can't find a mistake in my algorithm. When I normalize I just divide all components of the vector by the vector's length.

public double length(){
    return Math.sqrt(x*x + y*y);
}

public void normalize(){
    if(length() > 0){
        x /= length();
        y /= length();
    }
}

Is this supposed to happen? I mean I can see the length ranging from 0.9 to 1.1 at worst, but this is just overwhelming.

Cheers


texts: How can I extend the FindObjectsByTag to filter multiple parents of the found objects?

texts:
private List<GameObject> FindDoors(string[] parents)
    {
        GameObject[] doorsLeft = GameObject.FindGameObjectsWithTag(c_doorLeft);
        GameObject[] doorsRight = GameObject.FindGameObjectsWithTag(c_doorRight);

        List<GameObject> allDoors = doorsLeft.Union(doorsRight).ToList();

        List<GameObject> toRemove = new List<GameObject>();
        for (int i = 0; i < allDoors.Count; i++)
        {
            for (int x = 0; x < parents.Length; x++)
            {
                if (allDoors[i].transform.parent.name != parents[x])
                {
                    toRemove.Add(allDoors[i]);
                }
            }
        }
        foreach (var it in toRemove)
        {
            allDoors.Remove(it);
        }

        foreach (GameObject door in allDoors)
        {
            Debug.Log("Door Parent : " + door.transform.parent);
        }

        return allDoors;
    }

Usage :

var allDoors = FindDoors(new string[]{ "Wall_Door_Long_01", "Wall_Door_Long_02" });

But in the function FindDoors the return allDoors is empty.
I think the problem is at this IF :

if (allDoors[i].transform.parent.name != parents[x])

Once it's Wall_Door_Long_01 so if it's Wall_Door_Long_01 it will not remove the item but next it's Wall_Door_Long_02 so now the it's true and will remove the even if the parent name is Wall_Door_Long_01 and same if it's Wall_Door_Long_02

And then in the end it will remove all the items.
But I want it to remove only doors that the parents of them is not Wall_Door_Long_01 and not Wall_Door_Long_02


texts: How to implement deceleration and stopping over a certain distance

texts:
So I have a a character, say a spaceship. It needs to move distance R, and in direction T (Theta). So say if The object is at (0,0), and it needs to get to (4,3), it has R = 5 and T = about 36 degrees.

Essentially I know where the endpoint is, and the distance away. I want my spaceship to start decelerating when R becomes 8, and the object come to a halt when it reaches the location.

How can I do this. (Kinematics in answers is welcome)


texts:
Unity has a Slerp method:

public static Vector3 Slerp(Vector3 a, Vector3 b, float t);

Where it returns an interpolated position between a and b by the percentage of t.  So if t = 0.5, and a = Vector3.zero, and b = Vector3.one, it returns a Vector3 of (0.5, 0.5, 0.5).

But what does SlerpUnclamped do?

public static Vector3 SlerpUnclamped(Vector3 a, Vector3 b, float t);

t is not clamped between 0 and 1.  So what what is t relative to?  How do you use this method?


texts: What's a good way to handle game screen management in WPF?

texts:
What would be the preferred way of handling game screens in WPF (conforming to MVVM)? I'm not asking about game states but the actual mechanics of presenting various screens.

Do I implement screens as user controls? Do I collapse and show controls or dynamically add and remove controls from main window? How do I handle transitions (MenuToOptions, OptionsToMenu, GameToOptions, et cetera)?


texts: Is it possible to develop multiplayer games with HTML5?

texts:
I know HTML5 is great for web games, but I don't really know if it's possible to develop online games with multiple users, keeping everybody synchronized and handling logins, et cetera.
Is it possible to do this?


texts: How to properly use prefabs with 2D game?

texts:
I have a concern about prefab's purpose.

When I create a npc like a monster with all it's animations, script etc, I then create a prefab to instantiate it.
When I want to insert different monster which are quite similar to the first one I created I wonder to understand what's the Unity base idea to deal with. My thought is that the prefabs should be kept the minimum essential numer possible and to call different functions to initialize time by time differently depending on specific needs.
But, how to deal with animators and animations in general? There is any shortcut of creating one prefab for each monster? I'm asking because I can't find any clear way to dinamically attach animators to a generic gameObject. Since I cannot have one Animator where I replace dinamically sprites involved the simplest (but not so smart) way I found is to create duplicates of prefab and attach editor side all these graphic components.

What would be the best approach to deal with this?


texts:
Imagine a soccer game. While the player is playing a match, he is seeing the billboards all the time.

I want to include that kind of advertisements in my game (obviouly, making profit). Just a brand logo, not a banner the user has to click.

Does this even exist? Is there any AdMob like which allows this kind of advertisement?


texts: Which data structure should be used to represent voxel terrain?

texts:
According to the Wikipedia page about voxels, "[...] the position of a voxel is inferred based upon its position relative to other voxels (i.e., its position in the data structure that makes up a single volumetric image)."

How should one implement such a data structure?  I was thinking about an octree but I'm wondering if there's something else that I never heard about.


texts: Collision detection with Java streams and access of collisionable objects

texts:
I'm trying to learn some things about collision detection, and I've never known how to cleanly detect this for multiple objects in multiple classes without just copy pasting a lot of code.

I now came up with all collisionable/solid things implementing a class and then using Java streams to return whether one or more things in the list of solid things is colliding with the thing you are checking. Is this the way to do this? Or is this really performance heavy or unconventional? I also didn't know a good way of getting the collisionable objects to the player/other creatures, so I simply used a getter, but that means that player class will get access to all the things in the arraylist and I don't know if this is save.

And are there good resources on collision detection for Java(8)?

And if this were to be for a partially grid based game with unwalkable positions in the grid, but also moving objects that cannot be walked through, would something like this still be the correct way to go about it?

Relevant code:

GameScreen.java

class GameScreen implements Screen {
private Stage stage;
private Game game;
private Player player;
private ArrayList<Solid> solids;

GameScreen(Game game) {
    this.game = game;
    stage = new Stage(new ScreenViewport());

    solids = new ArrayList<>();
    solids.add(new Wall(500, 0, 200, 200));
    solids.add(new Rock(200, 600, 100, 100));

    player = new Player(this);
    stage.addActor(player);
}

public ArrayList<Solid> getSolids() {
    return solids;
}
}

Rock.java (Wall.java is exactly the same but with Rock replaced by Wall)

class Rock extends Group implements Solid {

private int x;
private int y;
private int width;
private int height;

Rock(int x, int y, int width, int height) {
    this.x = x;
    this.y = y;
    this.width = width;
    this.height = height;
}

@Override
public boolean collidesWith(float oX, float oY, float oWidth, float oHeight) {
    return (oX + oWidth > x && oX < x + width)
            && (oY + oHeight > y && oY < y + height);
}
}

Player.java

class Player extends Group {
private final float STEP = 10f;
private GameScreen gameScreen;
private int playerHeight = 130;

Player(Screen gameScreen) {
    setBounds(300, 300, playerHeight / 6.5f * 5, playerHeight);
    this.gameScreen = (GameScreen) gameScreen;
}

private boolean collidesWith(ArrayList<Solid> solids, float x, float y) {
    return solids.stream().filter(o -> o.collidesWith(x, y, getWidth(), getHeight())).findAny().isPresent();
}

@Override
public void act(float delta) {
    super.act(delta);

    if(Gdx.input.isKeyPressed(Input.Keys.W)) {
        if (!collidesWith(gameScreen.getSolids(), getX(), getY() + STEP)) {
            this.setPosition(getX(), getY() + STEP);
        }
    }
    if(Gdx.input.isKeyPressed(Input.Keys.S)) {
        if (!collidesWith(gameScreen.getSolids(), getX(), getY() - STEP))
            this.setPosition(getX(), getY() - STEP);
    }
    if(Gdx.input.isKeyPressed(Input.Keys.A)) {
        if (!collidesWith(gameScreen.getSolids(), getX() - STEP, getY()))
            this.setPosition(getX() - STEP, getY());
    }
    if(Gdx.input.isKeyPressed(Input.Keys.D)) {
        if (!collidesWith(gameScreen.getSolids(), getX() + STEP, getY()))
            this.setPosition(getX() + STEP, getY());
    }
}

}

Solid.java

interface Solid {
  boolean collidesWith(float oX, float oY, float oWidth, float oHeight);
}


texts: How do I add materials to a glTF model in Godot Engine?

texts: I'm using glTF Embedded files because I was told they are the best files to use with Godot, so I got a pack of a bunch of really lovely trees and other things to use in my game. But when I import it, it has all the materials on the side with the base being completely white. I know how to add textures onto things but it seems there is no way to add anything to the model? How would I use these materials then? Is this my fault or the model creator's fault?


texts:
I'm running Unity3D in a virtual instance of Windows, using the Virtual Box software on Linux.  I have guest additions installed with DirectX support.  I've tried using Windows XP SP3 32-bit, and Windows 7 64bit.  My host is Ubuntu 12.04 64bit.

I installed and registered Unity on both.  It loads up fine, and then crashes my entire VirtualBox instance (equivalent of a computer shutting off with no warning).


texts: Retro-game development - how did 8-bit computers store large level maps and build a screen from them?

texts:
Not sure whether this would be better in the retro-computing exchange, but I'm trying in game development first.
During the 80s I played a lot of what would now be called "arcade adventures" on the BBC Micro; games like Citadel, Camelot, Jet Set Willy, etc.
Jet Set Willy could support 64 rooms, Citadel had over 100.

Presumably, some form of encoding was used to compress the maps to fit in the limited storage space that these machines had, but does anyone have any information on how these games actually managed to cram screen layout and object types and locations into this limited space, then decode these into a tilemap and game objects?


texts: A good place to learn about Game Programming with Mathematical Vectors?

texts:
I am looking for a place in the web where I can turn my current game development process into a vector based approach. I am sorry If this question has been asked once.

According to my google search analysis, few places I've found pretty interesting are Tony Pa's tutorials and Metanet. But, due to limited explanations, I found it little bit tough to implement. I could try out the same examples as provided there, but when I have to use it in my games, I am STUCK. I want to know about the dot products and cross product stuff, Its uses and detecting collisions and predicting collisions with these mathematical techniques.

Please, write down some links and a brief description of the link. Thank you


texts:
My GameObject is able to jump towards a moving target (another GameObject), thus adjusting its trajectory - while simulating gravity (as in the .gif).

I want to make the "jumper object" rotate. But I am unable to rotate my GameObject properly. When the GameObject jumps, it doesn't complete its rotation and rotates abruptely. How can I fix this? How can I properly rotate the cube GameObject you see in the .gif? Any fixes are appreciated.

Wanted rotation:

What I get:


texts: How viable ogre3d is for a commercial project?

texts:
Well, I don't really what else to add to the question, since I don't really know what competitors have that OGRE doesn't.

Of course I'm talking game rendering quality here, I don't really think there are very complicated programming stuff left, maybe AI...

Since torchlight is the best game done with OGRE (I think), is it still a good solution for future games, whatever the 3D graphics technologies will be ?

What prevents OGRE3D from not being the best engine ? (consoles excluded, since they used some specific graphic library, except the xbox360 maybe...)


texts: How to develop multi-player game without involving server side code?

texts:
There have been lot of cloud based frameworks released in past few years. They provide real-time communication among users but does not allow developers to write server side code.
So, how can we use these frameworks to develop mulitplayer games.

I want to know how we can deal with network latency and write prediction algorithm to recover network lag.


texts: Making a master server in Photon Unity Network?

texts:
I am trying to make a game that requires a dedicated server running 24/7 and I would like to use Photon Networking but can Photon Network handle/do a dedicated server setup?

The reason I ask is because every tutorial I watch/read is talking about client hosting and not server to client.

Another question I have is that if PUN can handle dedicated servers will I have to make separate applications, one for the server and one for the client? To me that seems to make the most sense.

The third question is that if I do have to make a server and client application how do I connect to my server application with my client application?

Does PUN provide a URL which I can connect to or is there something else that I have to do?

If you guys have any tutorials you could point me to working with PUN and dedicated servers that would be awesome and if you guys have any information you are willing to bestow upon me that would be greatly appreciated!


texts: Changing CharacterController's height causes jittering issue in Unity

texts:
As title said changing height of Character Controller causes jittering issue.

For example when I reduced the height of CharacterController, it seems CharacterController was floating at each frame and it keeps falling to the ground. Opposite situation has same issue, different is collider is actually already passing the ground so it just push up the object by physics engine.

(I saw some similar issue with Terrain, in this case it's worse, it just falling through the terrain)

Anyway someone told that I have to change center of CharacterController too, with foot offset(I don't know what exactly that is), so I tried to change the center of CharacterController when resizing height but it still have same problem, nothing different.

This is the code that I'm using:

void Update() {
    if(Input.GetKeyDown(KeyCode.LeftControl)) {
        isCrouched = !isCrouched;
    }

    float newHeight = isCrouched ? crouchingHeight : originalHeight;
    controller.height = Mathf.Lerp(controller.height, newHeight, Time.deltaTime * smooth);

    Vector3 newCenter = isCrouched ? new Vector3(0, 0.2f, 0) : Vector3.zero;
    controller.center = Vector3.Lerp(controller.center, newCenter, Time.deltaTime * smooth);

    float newCamPos = isCrouched ? origCamPos.y - 0.2f : origCamPos.y;
    Vector3 newPos = new Vector3(cam.localPosition.x, newCamPos, cam.localPosition.z);

    cam.localPosition = Vector3.Lerp(cam.localPosition, newPos, Time.deltaTime * smooth);
}

Is there a way to rid off that jittering issue while changing height of Character Controller? Any advice will very appreciate it.


texts: Add 1 to a PlayerPref float if a day has passed in Unity 2D

texts:
I'm making a daily rewards system in my Unity 2D game. For each real-life day the user logs in (not necessarily consecutive) the player earns a Reward Point. Reward Points do two things:

Increase the rarity of what the player may obtain from Reward Chests.
Increase the frequency that a player may open a Reward Chest. The frequency starts at 24 hours, and for each Reward Point, it is decreased by 24 hours. (The frequency a player earns a Reward Point is not increased, just the frequency that the player can open a chest.)

I am asking how to check if a day has passed since the player last opened the game, and, if they have, add 1 to a PlayerPrefs float (this float contains the amount of Reward Points). I am familiar with Time, but I'm not sure how to accomplish my goal with it.
.


texts: How important is a character's sexuality when it come to audience appeal

texts:
I ask because I came across this comment about putting gay characters in games:

The necessity of exposing the larger playerbase to the homosexual tendencies of two of its cast mates is never really expounded upon by ScreenRant. That’s not to mention that only a tiny percentage of people even identify as on the LGBTQ spectrum, even according to Gallup, which puts the national average at 4.5%. So why exactly would Blizzard force the majority of their straight players to have to engage with the homosexual tendencies of two of its non-straight characters?
(Source)

And here:

So what better way to get back at the core gamers who dropped one-liners and zingers that have become memes of legend, than to strip away from gamers the last remaining normal character in Overwatch?
Most people figured Soldier 76 would be safe. He’s a patriotic military man, a hard-fighting soldier with undying loyalty, and a code of honor. He’s the perfect representation for what the majority of gamers like to see out of a hero. And besides, you need at least one normal sized, healthy, properly muscled straight, white male with all of his limbs intact to cater to the majority of your playerbase. Right? … RIGHT?!
The average male gamer typically gravitates toward a game where there’s a character who looks like he can kick butt and take names, and Soldier 76 was that guy.

....

The last bastion for masculinity in a game that’s constantly bleeding testosterone faster than the Overwatch League bleeds viewership,
(Source)

It's obvious that this guy thought that 76 was straight before this. So his outrage that his face character was revealed to be gay when there was no evidence to say otherwise beforehand is pretty sad.
Beyond this there is a point he makes that is interesting. Is a characters sexuality really that important? Yes most gamers are straight, but does that automatically mean that every game character needs to be straight? Or is this an appeal to the majority fallacy?


texts: How do I connect Unity to a server backend developed in .net core?

texts:
I'm currently running to a wall in my game development and I need now some discussion to clear my mind... In my mind I have a plan for some little online game (focused around clicking and idling), which I imagined could be served both on website and winapp, and in future even in mobile platforms.
I have chosen C# for it, build some server backend (join server, game server), but 'cause I want this server components be runned on linux, I have chosen .net core. Which is now my problem, because I'm building the game client in Unity, which only works in .net standard.
My main problem now is that I have build some "base network library" for communication, written in .netcore with plenty of NuGet packages, which I now have implement to Unity to get it work, but there are now conflicts (the main one is that unity is using another version of System.Threading).
Now I am wondering what steps should I choose nexts... There are some work behind now (but not so much, there are only some basic proceses for login and creating game worlds), so probably make that base network package compatible with .netstandard and .netcore.
Or I am thinking if it isn't more suitable to choose some another technology like c++ and some 2D engine in it (which to choose?).
What are you opinions? And what would you do in this situation?


texts: Do I have to use new keyword for unity single game object?

texts:
I'm using Unity4.
Do I have to use new keyword for single game object? look at the following code.

1.
GameObject obj = new GameObject();
obj = Resources.Load("Prefabs/Ball", typeof(GameObject)) as GameObject;

2.
GameObject obj;
obj = Resources.Load("Prefabs/Ball", typeof(GameObject)) as GameObject;

is it the same?


texts: Stop Animated Tile from looping Unity2D C#

texts:
I am using the animated Tile script and starting the animation when I need it, by replacing a static tile with an animated one. Currently on collision with the player, however, I need the animation to run to its end and then stop when it finishes.

My current code is  trying to find if the current sprite on the position is the same as the last one of the animation and if that is true it should just replace it with a static tile. However, that happens instantly after the animation has been triggered.

Check if the animation is finished:

if (playingAnimation)
    {
        if (tilemap.GetSprite(lastPPosition) == destructableLast.sprite) // if animation ended
        {
            Debug.LogWarning("Destructable Animation finished; Returning to end sprite");
            tilemap.SetTile(lastPPosition, destructableLast);
            playingAnimation = false;
        }
    }

Code for setting the animated tile:

private void AnimatedTile_Destroyable(TileBase type, Collision2D collision, Vector3Int pPos)
{
    if (type == destructable0)
    {
        tilemap.SetTile(pPos, destructable1Animation);
        lastPPosition = pPos;
        playingAnimation = true;
    }
}

I did find this in the Animated Tile script:

public override void GetTileData(Vector3Int location, ITilemap tileMap, ref TileData tileData)
    {
        tileData.transform = Matrix4x4.identity;
        tileData.color = Color.white;
        if (m_AnimatedSprites != null && m_AnimatedSprites.Length > 0)
        {
            tileData.sprite = m_AnimatedSprites[m_AnimatedSprites.Length - 1];
            tileData.colliderType = m_TileColliderType;
        }
    }

Which confuses me, because from what I see, the sprite that is used as the animated tile sprite is the last one from the animation. Shouldn't the sprite change constantly when the animation plays, and is there a way to stop the animation once it has finished?


texts: deferred rendering and point light radius

texts:
I use a common attenuation equation for point lights:
attenuation = 1 / kc + kl * d + kq * d^2.

I use deferred rendering so I need to know a light radius. An example light has following intensity: vec3(10, 1, 8). RGB components can be greater
than 1.0 beacuase of HDR/Tone Mapping. How to calculate a light radius ?

Edit1
An attenuation equation can be defined this way (link) and we get following equations:

attenuation = 1 / ( (d / r) + 1) ^ 2
attenuation = (attenuation - cutoff) / ( 1 - cutoff)
attenuation = max(attenuation, 0)
lightRadius = r * (sqrt(Li / cutoff) - 1)
cutoff = minLuminance / lightLuminance
Li = lightLuminance

Let's assume that d = 40, r = 1, lightLuminance  = 10 and minLuminance = 0.01. Then: lightRadius = 99 but attenuation = 0. What is wrong ?


texts: How can I implement fast, accurate 2D collision detection?

texts:
I'm well aware of how to detect if two or more 2D objects collide but I'm interested in how to decide whether to check for a collision. In previous projects, I just had every object check against every other object (I know, O(n^2) level of stupidity) and it created a less than fluid gameplay.

Various forums hail the greatness of Quadtrees, B-Trees, and any other kind of tree or structure you can think of.

What is the most efficient structure for determining whether a collision should be checked?


texts: Calculate 8 different directional input based on arrow keys combinations

texts:
Considering I have four variables event binded to each arrow key, that can be 0 or 1

My current approach to this issue is simply 8 nested ifs checking each combination or keys

Is there a more math-y clever way to solve this issue?


texts: Basically I created 2 quads side by side and I added a road texture. I used transform.translate so that the road moves, but I am trying to make the road endless by making the 2 quads reposition themselves in front of the current quads repeatedly so that when I add a player the road is endless. Any way I could do this?


texts: How does one test the effectiveness of a game engine?

texts:
A few friends and I are working on a home-brewed engine for a selection of games we wish to produce in the future. We're making it to satisfy a few key requirements that we haven't found were properly handled in professional game engines. But we were wondering, how can we test how effective our engine is at solving the problems we set out to solve?

For example, our games require a very specific internal OOP architecture, and the engine facilitates that, making it easy for us to do what we want. How are we supposed to make sure the engine actually helps us?

The reason I ask is because I've written unit tests before, but they've usually been to test whether or not something is correct. Does the engine properly determine collisions between convex polygons? Does the event propagator properly respond to user input? Is the implementation of Bresenham's line algorithm for rendering line primitives correct? Things like this.

When it comes to testing effectiveness of the application as a whole, however, there is no notion of right or wrong. It's fuzzy, it could be pretty effective, very effective, or not effective at all. Is the only solution just to make a game using the engine, and determine the engine's effectiveness from there? I want to say no, because the point of testing is to catch errors early on right, so if we make a game to test effectiveness, we have to build the entire engine beforehand.

How would tests like these even be included? If we integrated "test games" using the same program we use to integrate unit tests, they'd get run every time the engine builds. But we don't want our stupid test games to start running every time we build.

So is there another solution?


texts: Replace generated meshes with imported meshes in Unity

texts:
I generated a lot of meshes for my project, but they have no import settings and I happen to need them. So I exported the objs, deleted the old assets and imported those files (that were exported using OBJexporter), making sure that the names DO match. Issue is, none of my scene objects recognize the new objects.

I could easily undo the harm, but I really need to change those mesh assets to the ones with import settings. How do I do that, so the engine does recognize them?


texts: Is it possible to control the difficulty of a multiplayer game?

texts:
I'm developing a multiplayer game, played between 2 players. But in these types of games, there can only be 1 winner and 1 loser for per match. So for each player who wins, another player had to lose. This means that roughly 50% of all players in the game are having a bad time (losing more than they win).

In a single-player game, it's easy to solve the problem of "50% of players lose more than they win." You just make the game easier to beat (reduce difficulty). Unfortunately, you can't do this with a multiplayer game, since players' opponents are other players. I don't know if there's a way to control the difficulty of a multiplayer game, but is this even possible?


texts: Guidelines for determining what should be a component?

texts:
Background:

So I'm developing my first 2d C++ fighting game (for learning purposes) and I have a setup where I have 'components' which are really just data holders with maybe some simple utility functions such as GetComp(), AddToComp(), etc. All components get passed to component systems which are just functions which act on certain components (e.g. MovementSystem(PositionComp pos, VelocityComp vel), etc.) which are split up into their respective domains (Graphics, Animation, Physics, etc.). All components are held by 'Fighter' class which acts as the component holder that keeps everything together.

Issue:

The problem I'm having is I'm not sure how I decide what exactly should be made into a component vs what shouldn't. For example, for my animations I have a system which essentially takes a 'spriteComponent' and a 'animationClip' obj like so SetAnimation(spriteComponent sprite, animationClip anim). As it stands, my animationClip class is not considered a component and is not currently attached within my Fighter class, though I guess I could implement it that way. How do I decide what classes/types should be made into components? How is this typically handled in other ECS like systems?


texts:
Situation

I've got a large map divided into 16*16 parts (comparable to Minecraft) for x and z. For every part a VBO is generated and stored using GL_STATIC_DRAW.

Problem

The technique described above works fine and with good performance, however it restricts (due to the nature of GL_STATIC_DRAW) modifications that may happen frequently, especially texture animations (that is incrementing texture coordinates to select another sub rectangle in the texture).

Now I'm asking myself how to solve that problem. Switching to GL_DYNAMIC_DRAW seems like an overkill to me, since most of the geometry is static, thus better placed in GPU's memory.

Generating a separate VBO (or even a vertex array?) is an option that came into my mind, however this would greatly increase complexity. Any ideas?


texts: How do I use delta-times to determine the speed of a frame-by-frame animation?

texts:
I have a character spritesheet with 8 images. How do I animate it?

At the moment, the sprite changes to a different image every frame, which makes the animation speed vary with framerate.  I have a delta time that calculates the time in ms between each frame.  Is there a smart way to make sprite animations use it?

I'm using JavaScript and canvas on my own engine, for practice.


texts: How to include a new file js in a project cocos2d js?

texts:
I'm trying to include a new js file containing a new scene on a cocos2d js project, but every time try occurs the following error:

  Uncaught ReferenceError: GameScene is not defined.

I included my file in jsList and in appList:

"jsList"        : ["src/game_scene.js"],
    "appFiles"      : ["src/game_scene.js"]

The code of my scene looks normal:

var GameScene = cc.Scene.extend({
    onEnter:function(){
        this._super();

        var gameLayer = new GameLayer();
        this.addChild(gameLayer);
    }
});

The code on app.js to call my scene looks good too:

var gameScene = new GameScene();
cc.Director.runScene(gameScene);

What should I do?


texts:
My character follows camera direction. my issue is when i look at sky and walk or run my character goes up ! the same thing happen when i look down and walk back.

    float moveHorizontal = Input.GetAxis("Horizontal");
    float moveVertical = Input.GetAxis("Vertical");

    movs = new Vector3(moveHorizontal, 0.0f, moveVertical);
    movs = cam.TransformDirection(movs);

    rb.AddForce(movs * speed);

    float maxVelocity = 5f;
    rb.velocity = Vector3.ClampMagnitude(rb.velocity, maxVelocity);

What I need is make it work normally. like GTA or GoW.


texts: Detecting image curve to move a truck on this surface

texts:
I have an image background in surface view

I want to move something according to black surface.But i can not do this using height of this image as it return same height.and one more thing bitmap.getPixel is also not working.and my background is moving.So what is the way to achieve this feat


texts: detecting the coordinates where a bullet hits a mesh

texts:
I have a lot of complex objects in a scene and im looking for an efficient way to find which object a fired bullet hits and to find the hit coordinates.
It would be best if there was a lightweight library to do this.
it seems that PhysX can do this, but i didnt find a way except to give every face in every mesh a physX system and that seems to become a bottleneck.

thanks in advance.


texts: How does my program know which variables to link to the shader?

texts:
I am using DirectX and C++. I never understood how my VertexDeclaration knew what variables were the UV map and which were linked to the position. I have in my shader Position : POSITION and Texture : TEXCOORD1

In my variables for vertex format I have int X, Y, Z, U, V.

In my declaration I have

    D3DVERTEXELEMENT9 Decl[] =
    {
        {
            0,
            0,
            D3DDECLTYPE_FLOAT3,
            D3DDECLMETHOD_DEFAULT,
            D3DDECLUSAGE_POSITION,
            0
        },
        {
            0,
            0,
            D3DDECLTYPE_FLOAT2,
            D3DDECLMETHOD_DEFAULT,
            D3DDECLUSAGE_TEXCOORD,
            0
        },
      D3DDECL_END()
   };

My FVF is D3DFVF_XYZ | D3DFVF_TEX1

How does it know to link X, Y, Z with position? and U, V with the first texcoord? What would the variables for the second texcoord be? Is there some pattern?


texts: HIGH energy consumption in Empty Scene Unity iOS

texts:
I am struggling from quite long about this issue where I am having High Energy Impact in Unity 2019.2.16f1 on iOS platform and it doesn't matter which device I am using. It occurs on iPhone6 to iPhoneX also I tried in an empty scene and checked stats through xCode and still bar is in Very High. Can someone explain to me what is going on? because of this device gets heat up quickly.

Below are stats with empty scene.

I have tried following still Very High:

Framerate to 30
SetResolution to 720 x 1080
Compressing Textures
Multi-threaded Rendering enabled and disabled
Auto Graphics API turned on and off in player setting

Though I am making game and I don't want to set resolution too low or to compress textures, I want as much attractive graphics as unity can offer.

Also is this estimation of GPU Utilization calculated on based on total capacity of GPU vs how much the app is taking at the moment? I am totally blocked here and I need to improve energy impact of my app.


texts:
I'm trying to implement an OpenGL deferred renderer, in order to process multiple lights.

I have a structure defined in both C++ and GLSL that defines a simple point light, thus:
C++

struct LightData
{
    glm::vec4 colour;
    glm::vec4 position;
    glm::vec4 attenuation;
    float intensity;
};

GLSL:

struct LightData
{
    vec4 colour;
    vec4 position;
    vec4 attenuation;
    float intensity;
};

Upon examination, using sizeof(LightData), I find that the size of the C++ struct is 52 bytes, which makes sense. (3x 16 bytes, plus 4 bytes, plus 3x 4 bytes padding for memory alignment)

However, given that I am writing a deferred renderer to work on multiple lights, I populate a GL Uniform Buffer with an array of such structs, and access them like so:

layout (std140) uniform PointLights
{
    LightData points[MAX_NUM_POINT_LIGHTS];
};

Upon examination of the data on the GPU, using Nsight, I find that after the first light, all following light structs are accessed differently as if the alignment is off. From examining the offsets of the struct members in Nsight, it seems that the light struct in GLSL is padded up to 64 bytes in size, causing it to read values from the incorrect memory address

                    C++ offset              GLSL offset
0    vec4 colour;           0                       0
0    vec4 position;         16                      16
0    vec4 attenuation;      32                      32
0    float intensity;       36                      48
1    vec4 colour;           52                      64
1    vec4 position;         68                      80
1    vec4 attenuation;      84                      96
1    float intensity;       100                     112

How would I go about fixing this discrepancy so that the data is retrieved from the correct memory address?


texts:
void AddItem(Item item)
{
    int indexOfDuplicateItem = System.Array.IndexOf(itemsInInventory, item);

    if (indexOfDuplicateItem > -1)
    {
        quantityText.text = (stackSize[indexOfDuplicateItem] += 1).ToString(); // Problem occurs here
    }
    else
    {
        for (int i = 0; i < numSlots; i++)
        {
            if (itemsInInventory[i] == null)
            {
                itemsInInventory[i] = item;
                GameObject itemImage = Instantiate(itemImagePrefab, slots[i].transform);
                itemImage.GetComponent<Image>().sprite = item.itemSprite;
                quantityText = slots[i].GetComponentInChildren<Text>();
                stackSize[i] = item.itemQuantity;
                quantityText.text = stackSize[i].ToString();
                return;
            }
        }
    }

The indicated line behaves differently if I write quantityText.text = (stackSize[indexOfDuplicateItem]++).ToString();

I'm a relative beginner to both C# and Unity. Can someone explain why the behaviour of (stackSize[indexOfDuplicateItem]++).ToString() is different from (stackSize[indexOfDuplicateItem] += 1).ToString()?

using += 1 to increment behaves correctly, but ++ ends up being the correct answer - 1.


texts: Bitmap to a custom coordinate pair when touched

texts: I am completely lost and needed some help.  I have a ontouchListener for a bitmap and know how to check if the touch was within the boundaries of the bitmap. But say I want the center of the image to be at a custom coordinate like [0,0] and the entire image to be in the range of [-319...319] and [-239...239] . Does any one have any thoughts on how to best implement an eventX and eventY to a custom coordinate pair?


texts: Is an iOS development license with Unity free?

texts: I'm coding in Unity Personal and I'm going to try to put my game onto the App Store (through the Unity --> XCode --> App Store process). In the past, Unity has charged money to get a iOS license for this. The price was $400 I believe. I've certain articles that say that it has changed, and some that say it still costs money. So, I'm not sure which one is true. Is creating and publishing a commercial game with Unity Personal now free? (meaning that there is no license required). If there is a price, how much is it, and is it a one-time fee or per month/year/game published etc. Thanks! Also, can I legally make money with this game using the Unity Personal?


texts: Handling of data sharing between framework module

texts:
I am currently developping a 3D game using C# / XNA 4.0 and i am currently thinking about how i should structure my game. The actual game is in fact not really important as the framework i am working on right know is pretty generic.

1st layer :

BaseFrameWork : This BaseFrameWork is managing all the different game modules

2nd layer :

ContentProvider : This module is a layer loading all the needed content (texture/sound/models) and providing it when needed
SoundManager : This module is handling all the audio request (music activation, music change, sound activation, ect)
InputEventHandler : This module is handling all the inputs of the player. Some flags are provided to each module to operate (for example there is a flag "toggleMusic" which is turned on when the player is pressing "M" while in game.
ObjectFactory : This module is creating all the different objects when it is needed (for example creating a floor, boxes and other stuff)
Player : This module is exclusively dedicated to the player.
HeadUpDisplay : This module is dedicated to write the HUD (2D) of the game

Currently the 3rd layer is not developped (i have a few different objects for the ObjectFactory but that's all).

My first question is : "Knowing how is structured my game, do you think i should do it differently, and why ? For example, should player be part of the ObjectFactory "

My second question is about the way these different modules should be linked together.

The easiest option, but (i think) the nastiest one, is to provide to each module a reference of the other ones with everything public. Really easy to implement, really easy to use ingame, but really REALLY nasty.
One other option could be to let the BaseFrameWork get the useful informations of a module to give it to an other module.
Other options ?

These questions may seem basic and common sense, but last time i have been part of a game development, it looked nice (http://yapt.free.fr/) but i think we/I could have done better by spending more time into the game architecture beforehand instead of just diving the head in water.

Thanks for your comments/advice

Al_th


texts:
I'm developing a minesweeper game. I'm having a problem with reshaping(resize) the window. I'm using Ubuntu Linux. Following are the code snippets and the entire code is here:

This is my initializing code that I write at the starting of main()

glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (400, 300);
glutCreateWindow ("MineSweeper");
glClearColor (1.0, 1.0, 1.0, 0.0);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);

This is my display() func that I pass into glutDisplayFunc() which actually draws the grid requires for minesweeper game.

glClear (GL_COLOR_BUFFER_BIT);

glColor3f (0.0, 0.0, 0.0);
glLineWidth (3);

float i;
for(i = step; i< 1; i+=step) {
    glBegin(GL_LINES);
        glVertex3f(i,0,0);
        glVertex3f(i,1.0,0);
    glEnd();
    glBegin(GL_LINES);
        glVertex3f(0,i,0);
        glVertex3f(1.0,i,0);
    glEnd();
}

glFlush ();

I searched many forum and finally tried this code for reshape() function in the glutReshapeFunc()

void reshape (int width, int height) {
   glViewport(0, 0, width, height);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(0, width, 0, height, -1.0, 1.0);
   glFlush();
}

But it didn't work and the output was a plane window.


texts: So I've created my own obj loader and it loads normal's, UV's, vertices, indices and faces.. but it will only draw the whole obj a single color. I would like my loader to display the model as if it were in blender. So my question is how do i use the material file to give my model its "color".. the material file doesn't say very much nor anything i find useful, soooo do i have more work to do to create a texture out of each side or?... any help is appreciated.


texts: How to resolve combat of stacks of units to mitigate numerical advantage

texts:
I just started designing an strategy game where player's armies consist of stacks of units. For my design I was aiming to reproduce the following behaviour for a full combat of multiple turns (for simplicity assume both stacks are the same unit):

1 vs full stack: the single unit is killed, the full stack hardly notices.
half stack vs full stack: the half stack is killed, the full stack sustain noticeable damage.
almost full stack vs full stack: full stack wins but gets almost wiped out. If randomness is involved, any of both may win, although the bigger one has statistical advantage.

My first approach was to add up the stats and treat each stack as a single unit, resolve the combat and then calculate how many units are killed.

That didn't produced the expected results, as even the slight numerical advantage in one side produced it to win by a huge margin.

The reason is that after each turn, the bigger stack would kill more enemies than the smaller, widening the power difference for the next turn. This different increases exponentially until the smaller stack is quickly obliterated.

As a second approach I treated each unit in a stack individually for the combat (something that I wanted to avoid), which produces much better results. However now I have many choices about how to resolve the combat.

Should it be a series of 1 vs 1 or should I allow units to gang up on others?

Should I pair each evenly or randomly?

Should I leave extra units unpaired as "reserve", or all units should fight at least once?


texts: Why does the pitch affect the x component of the front vector?

texts:
In every tutorial for implementing a camera in OpenGL, the front vector is calculated with something like this :

front.x = cos(pitch)*cos(yaw);
front.y = sin(pitch);
front.z = cos(pitch)*sin(yaw);

What I don't understand is why the pitch affects the x component? Shouldn't it just be :

front.x = cos(yaw);

Also, for the z component, why do we multiply cos(pitch) with sin(yaw). I understand that the pitch and the yaw both affect the z component, but why multiply? Why not add or something else?


texts: Java advice (Printing game data to the window)

texts:
Does anybody know the best method for taking game data and setting up java to read the data then print it to the window... of which you want the game loop to start the game and read the data...

Here is what my code is right now mabe some advice would be in order..

import java.io.File;
import java.util.Scanner;

import DATA_Data.Data.readfile;

public class ReadFile {

private Scanner x;

public void openFile() {

    try {

        x = new Scanner (new File("DATA_1.Pak"));
        x = new Scanner (new File("DATA_2.Pak"));
        x = new Scanner (new File("DATA_3.Pak"));
        x = new Scanner (new File("DATA_4.Pak"));
        x = new Scanner (new File("DATA_5.Pak"));
        x = new Scanner (new File("DATA_6.Pak"));
        x = new Scanner (new File("DATA_7.Pak"));
        x = new Scanner (new File("DATA_8.Pak"));
        x = new Scanner (new File("DATA.Pak"));
        x = new Scanner (new File("DATAA_1.Pak"));
        x = new Scanner (new File("DATAA_2.Pak"));
        x = new Scanner (new File("DATAA_3.Pak"));
        x = new Scanner (new File("DATAA_4.Pak"));
        x = new Scanner (new File("DATAA_5.Pak"));
        x = new Scanner (new File("DATAA_6.Pak"));
        x = new Scanner (new File("DATAA_7.Pak"));
        x = new Scanner (new File("DATAA_8.Pak"));
        x = new Scanner (new File("DATAA.Pak"));
        x = new Scanner (new File("DATAE_1.Pak"));
        x = new Scanner (new File("DATAE_2.Pak"));
        x = new Scanner (new File("DATAE_3.Pak"));
        x = new Scanner (new File("DATAE_4.Pak"));
        x = new Scanner (new File("DATAE_5.Pak"));
        x = new Scanner (new File("DATAE_6.Pak"));
        x = new Scanner (new File("DATAE_7.Pak"));
        x = new Scanner (new File("DATAE_8.Pak"));
        x = new Scanner (new File("DATAE.Pak"));
        x = new Scanner (new File("DATAL_1.Pak"));
        x = new Scanner (new File("DATAL_2.Pak"));
        x = new Scanner (new File("DATAL_3.Pak"));
        x = new Scanner (new File("DATAL_4.Pak"));
        x = new Scanner (new File("DATAL_5.Pak"));
        x = new Scanner (new File("DATAL_6.Pak"));
        x = new Scanner (new File("DATAL_7.Pak"));
        x = new Scanner (new File("DATAL_8.Pak"));
        x = new Scanner (new File("DATAL.Pak"));

    }
    catch (Exception e) {

        System.out.println("Could not read file");

    }

}

    public void readFile() {

        while(x.hasNextLine()) {

            String a = x.next();
            String b = x.next();
            String c = x.next();

                System.out.printf("%s %s %s\n", a,b,c);

        }

    }

        public void closeFile() {

            x.close();

        }

public static void main(String[]args) {

 readfile r = new readfile();

 r.openFile();
 r.readFile();
 r.closeFIle();

}

}


texts: How to load data for specific level at runtime?

texts:
I'm trying to create a game with many levels loaded from XML files. In my game I have many objects in each level.

At present my game contains 20 levels, and I load all the textures at once on startup. But I think the correct way to do it is to only load textures used in the current level. I don't know how to do that. So please explain this by providing some example code.

At present I create a class for each type of entity by extending my Sprite class. This subclass loads the appropriate image. I know this is not the best way to do things.

Basically I want to know how to load large levels efficiently in Andengine.  What is the proper method for loading textures, level data and background images from files when the level is run?


texts: How can spotlights be implemented with a perspective projection?

texts:
I was reading Shadow Mapping with Directional Lights
and noted that spotlights are implemented by rendering with the perspective projection, stating that the spotlight worked just like the camera. However, I don't see how this could be, as the cross section of a spotlight is a circle, but cross section of the perspective projection frustum is really a rectangle, so wont there either be extra information or too little? Or am I missing something. If you have any questions please feel free to ask I will try to respond as quickly as possible. Thanks a lot for your time!


texts: Replicating a worldspace sphere on screen space

texts:
I have quite some struggle with a post processing shader that I'm working on.

I use Unity, and I have a shader in which I want to, in screen space as part of post processing, render a sphere that looks like it was drawn in world space.

Now, I've tried some different approaches.

For all attempts, I've given the shader a world position of the sphere,a screen position of the sphere and a camera position named:

uniform float4 _SpherePositionCamera;
uniform float4 _SpherePositionCamera;
uniform float4 _SpherePositionWorld;

That is, the same point in respectively world-space camera-space and screen-space.

I've tried to project the fragment in screen space into camera space using the inverse projection matrix, and tested in the xy coords minus the screen space center of the sphere are of length < 1. This gives a circle on the screen that does not really follow a world space shere very well.

the vertex program of the gc code is

v2f vert (appdata_img v){
                v2f o;
                o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
                o.uv = MultiplyUV (UNITY_MATRIX_TEXTURE0, v.texcoord.xy);
                o.camPos = mul (inverseProjection, float4((o.uv * 2) - 1, _SpherePositionCamera.zw));
                return o;
            }

And the fragment program is

        fixed4 frag (v2f i) : COLOR
        {
            // Get the original screen color
            fixed4 screenColor = tex2D(_MainTex, i.uv);

            if ( length(_SpherePositionCamera.xy - i.camPos.xy) < 1 )
            {
                screenColor = ( screenColor + fixed4(1,0,0,1) ) / 2;
            }

            return screenColor;
        }

I have been working on this for quite some time, so I'm sorry if I'm somewhat failing at explaining the problem, but I hope that someone has some pointer to what I'm missing.

Thanks.

EDIT

I figured a better formulation. I think it might be done by casting a ray from each fragment and testing for intersection with the sphere in world space.

So all I need now is to construct a ray that originates from the near clipping plane and is directed in the "projection" orientation.

could this easily be done?


texts: How to await player input using Coroutines

texts:
How can I accept player input using Coroutines, pausing execution of Unity while the player has not yet provided input? It seems like a simple problem, but I can't seem to figure it out. Here is my latest attempt. In this program I want to do some logic and pause in the middle, continuing only when the player has inputted some data. Someone please tell me I'm on the right track :O

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InputTester : MonoBehaviour
{
    int choice = -1; // valid choices for this example are 0 and 1

    void Start()
    {
        StartCoroutine(DoSomeLogic());
    }

    IEnumerator DoSomeLogic()
    {
        print("Starting...");
        print("Awaiting your choice - 0 or 1. :: ");
        // yield return StartCoroutine(WaitForKeyDown(KeyCode.Alpha0) || WaitForKeyDown(KeyCode.Alpha1));
        // how to combine these two into a single method that gives the player a choice?
        print("Continuing...");
        switch (choice)
        {
            // logic based on the choice
        }
    }

    IEnumerator WaitForKeyDown(KeyCode k)
    {
        while (!Input.GetKeyDown(k))
            yield return null;
        SetChoiceTo(k);
    }

    private void SetChoiceTo(KeyCode keyCode)
    {
        switch (keyCode)
        {
            case (KeyCode.Alpha0):
                choice = 0;
                break;
            case (KeyCode.Alpha1):
                choice = 1;
                break;
        }
        //StopAllCoroutines(); // how do I stop all the coroutines that accept player input?
        print(choice);
    }
}


texts: What is causing this character overlap during text rendering?

texts:
I'm trying to display text with a texture and font description created with BMFont in OpenGL 3.3, but whenever I display the text there is some overlap between certain characters.

Here is the text at normal 1.0x scale:

As you can see, the 'e' in "Hello" overlaps the next 'l' a bit (with the same happening for the 'r' in "world") and the 'w' in "world" overlaps the 'o' quite a bit. Here is a 3.5x scale image to make the overlap a bit more apparent:

I was wondering if someone would be able to explain to me why this is occurring and, if possible, explain how to fix it.

My method for generating the vertex mesh is as follows: (C++)

// position control variables
const float tscalex = 1.0f / _font.GetTexture().GetSize().x;
const float tscaley = 1.0f / _font.GetTexture().GetSize().y;
const float hspace  = _font.FindGlyph( ' ' ).XAdvance;
const float vspace  = _font.GetInfo().LineHeight;
float x = 0.0f;
float y = 0.0f;

// generate a quad for each character
char pchar = 0;
for ( uint i = 0; i < _text.length(); ++i )
{
    // apply kerning
    char cchar = _text[ i ];
    x += _font.FindKerning( pchar, cchar );
    pchar = cchar;

    // handle special characters
    switch ( cchar )
    {
        case ' ':
            x += hspace;
            continue;
        case '\t':
            x += hspace * 4;
            continue;
        case '\n':
            y += vspace;
            x = 0.0f;
            continue;
    }

    // get the character's glyph
    const Font::Glyph& glyph = _font.FindGlyph( cchar );

    int width  = glyph.Width;
    int height = glyph.Height;
    int left   = glyph.X;
    int top    = glyph.Y;
    int right  = glyph.X + width;
    int bottom = glyph.Y + height;
    float yy   = y + glyph.YOffset;

    float u1 = float( left   ) * tscalex;
    float u2 = float( right  ) * tscalex;
    float v1 = float( top    ) * tscaley;
    float v2 = float( bottom ) * tscaley;

    // create the quad
    uint16 count = uint16( _mesh.Vertices.Size() );
    _mesh.Vertices.Add( Vertex( Vec3( x,         yy,          0 ) * _scale, Vec3(), Vec2( u1, v1 ) ) );
    _mesh.Vertices.Add( Vertex( Vec3( x,         yy + height, 0 ) * _scale, Vec3(), Vec2( u1, v2 ) ) );
    _mesh.Vertices.Add( Vertex( Vec3( x + width, yy + height, 0 ) * _scale, Vec3(), Vec2( u2, v2 ) ) );
    _mesh.Vertices.Add( Vertex( Vec3( x + width, yy,          0 ) * _scale, Vec3(), Vec2( u2, v1 ) ) );
    _mesh.Indices.Add( count + 0 );
    _mesh.Indices.Add( count + 1 );
    _mesh.Indices.Add( count + 2 );
    _mesh.Indices.Add( count + 2 );
    _mesh.Indices.Add( count + 3 );
    _mesh.Indices.Add( count + 0 );

    // advance
    x += glyph.XAdvance;
}


texts: Need help with rally point and spawning in StarCraft 2 map editor

texts:
I want to make a Tower Defense game using the StarCraft 2 editor.

How can I make a rally point to control AI appear at one point and go to specific point? How do I make creep spawn properly at specific times?


texts: Native vs Framework development for simple board game development

texts:
I have been working on a simple word game like Hangman Pro but for a different language and I have been using libgdx blindly. After a lot of hassle and unnecessary distractions, I am beginning to wonder if it is an overkill to use the library to do such a simple game. So my question is, is it possible or even professional to do such a game with just the native android libraries ? Will that be an uphill battle in itself.

P.S. I am not an android newbiew but am not a professional either. It is a hobby thing.


texts: Unity : control time interval when using getAxis() in bolt visual scripting

texts:
i use bolt visual scripting. I add ‘input.getAxis’ in Bolt and set the axis name to ‘Vertical’ so to get response when i press ‘w’ and ‘s’. When running the game and press the ‘w’ key, the output data (acceleration) will increase from 0 to 1. The problem is the increasing time is too fast or too short. How to make it slower/longer? Let say i want it to take 3 seconds to reach 1.
Edit :
This is what i want to achieve  (at time 6:10 to 6:25) : https://youtu.be/m8rGyoStfgQ?t=370 And the code is at the same video at time 6:00 . That codes works perfectly fine. And this is all i want to achieve but i want to do it in Bolt (visual scripting) rather than manual scripting.
So that line of code at 6:00 on that video : Velocity = time.Deltatime * acceleration
That code is controlling how fast or slow the acceleration can go from 0 to 1 when pressing ‘w’ key. But in Bolt, i use ‘getAxis’ and by using default sensitivity setting, if i press “w” it will take less than half a second for the acceleration to go from 0 to 1. I want to make it slower so i can go from 0 to 1 in 3 seconds or 5 seconds.
In fact , this the same as setting up the sensitivity in input manager to low value, but i want to keep this setting as default and want to control it inside bolt.
Pls check my video here : getAxis


texts: Boolean checks with a single quadtree, or multiple quadtrees?

texts:
I'm currently developing a 2D sidescrolling shooter game for PC (think metroidvania but with a lot more happening at once). Using XNA.

I'm utilising quadtrees for my spatial partitioning system.

All objects will be encompassed by standard bounding geometry (box or sphere) with possible pixel-perfect collision detection implemented after geometry collision (depends on how optimised I can get it).

These are my collision scenarios, with <> representing object overlap (multiplayer co-op is the reason for the player<>player scenario):

Collision scenarios (true = collision occurs):
Player              <>      Player          =   false
Enemy               <>      Enemy           =   false
Player              <>      Enemy           =   true
PlayerBullet        <>      Enemy           =   true
PlayerBullet        <>      Player          =   false
PlayerBullet        <>      EnemyBullet     =   true
PlayerBullet        <>      PlayerBullet    =   false
EnemyBullet         <>      Player          =   true
EnemyBullet         <>      Enemy           =   false
EnemyBullet         <>      EnemyBullet     =   false
Player              <>      Environment     =   true
Enemy               <>      Environment     =   true
PlayerBullet        <>      Environment     =   true
EnemyBullet         <>      Environment     =   true

Going off this information and the fact that were will likely be several hundred objects rendering on-screen at any given time, my question is as follows:

Which method is likely to be the most efficient/optimised and why:

Using a single quadtree with boolean checks for collision between
the different types of objects.
Using three quadtrees at once (player, enemy, environment), only testing the player and enemy trees against each other while testing both the player and enemy trees against the environment tree.