texts:
I'm working on a simple 2d game with direct3d 9. It's a isometric game with diamond tiles and a staggered map. This is what I have:

As you see I have some kind of fog which is acomplished by having a fog matrix which is true  (clear terrain) or false (obscure terran). But the result is very chunky. The fog moves as the player moves by tiles but not by pixels. Basically I check for every tile if there is fog, if so I just change the color of that tile:

D3DCOLOR tile_color = 0xffffffff;
if(scene->fog[i+mapx][j+mapy] == FOG_NONE) { tile_color = 0x666666FF; }
g_pSprite->Draw(texTilesNew,&rect,NULL, &D3DXVECTOR3(pantx,panty,0.0f), tile_color);

Where parameter tile_color is:

  A Color structure. The color and alpha channels are modulated by this
  value. The Transparent value maintains the original source color and
  alpha data.

I also would like the fog to be smoother, for that I followed this "tutorial" but I haven't managed to work it it out becuase I think the tutorial implements a diferent kind of fog than I am.

http://www.appsizematters.com/2010/07/how-to-implement-a-fog-of-war-part-2-smooth/


texts: How do I draw text once a countdown ends?

texts:
I created a countdown in Game Maker using a variable of time. The countdown works properly and is displayed at the proper coordinates. However, when the countdown reaches zero, I want to make the countdown disappear and display "GO" instead.

How can I do that?


texts: How to apply friction vector to acceleration in top-down 2D game?

texts:
I'm making a top-down view 2D RPG game, meaning the player can move in any direction on a 2D plane, and I'm trying to implement a somewhat realistic non-orthogonal acceleration/friction physics model for movement.

For instance, if the player's acceleration value is "100", holding the right arrow key will change the player's "input force" vector to (100, 0). If holding both right + down, the force will be roughly(71, 71) since 712 + 712 ≈ 1002. This part is working correctly right now.

The function I'm currently using to update the position looks something like this (Note: I'm not a physics expert):

void GameEntity::updateSpritePos( const float timeStep )
{
  // Store old velocity.
  const Vec2D<float> curVel( m_v2Velocity );

  // Get force.
  Vec2D<float> force( m_v2InputForce );

  // Calculate friction.
  Vec2D<float> friction;
  if( curVel.getLength() < m_fFriction * timeStep ) // Make sure the friction doesn't overextend.
    friction = ( -curVel / timeStep );
  else
    friction = -curVel.getNormalized() * m_fFriction; // getNormalized() returns the unit vector.

  // Apply friction.
  force += friction;

  // Calculate acceleration.
  const Vec2D<float> accel( force ); // Since we're not taking mass into account, acceleration = resultant force.

  // Calculate new velocity based on acceleration.
  const Vec2D<float> newVel( curVel + ( accel * timeStep ) );

  // Calculate how much to move using "improved Euler" integration.
  const Vec2D<float> avgVel( ( curVel + newVel ) * 0.5f );
  const Vec2D<float> moveAmount( avgVel * timeStep );

  // Update variables.
  m_c2Position += moveAmount;
  m_v2Velocity = newVel;
  m_v2LastMoved = moveAmount; // Storing this for collision resolution.
}

Where m_fFriction is a constant float value that can be anywhere above 0.

The problem is the way that friction is being applied: If walking in a given direction and then simply letting go of the key, you will glide for the appropriate distance.

But if letting go of the key while also accelerating in a perpendicular direction at the same time, you will glide much further in the original direction. This is not the behavior I want, I want the player to always glide the same distance.

Since I'm currently doing this:

friction = -curVel.getNormalized() * m_fFriction;

Friction will always be applied in the opposite direction of the current velocity. I'm not sure if this is correct.

I could solve it by doing something like this:

if( curVel.x > 0.0f )
    friction.x = -m_fFriction;
else if( curVel.x < 0.0f )
    friction.x = m_fFriction;

if( curVel.y > 0.0f )
    friction.y = -m_fFriction;
else if( curVel.y < 0.0f )
    friction.y = m_fFriction;

But then it doesn't work right when walking in a non-orthogonal direction (i.e. diagonally). This is especially bad since I also want to implement joystick support in the future where the force will be applied in the exact direction you're holding the stick.

Is there an easy way to fix this that I have overlooked, or am I getting into deep water here?

Note: I don't want to change my code to use a fixed timestep for a number of reasons, and I don't want to use damping (e.g. vel *= 0.99timeStep) since this doesn't create linear deceleration (unless there's a way to make it do that).


texts: Unity profiler spikes with vsync vs smooth no vsync

texts:
I'm trying to profile my game, this is a webgl game, and the browser forces vsync.

My problem is, when I disable vsync in unity I get a pretty smooth profiler, while with vsync I get huge spikes.

I cant tell if this is an editor issue or this spikes exist in the webgl version as well (I do have stuttering when playing in the browser, but cant tell if these spikes are the same ones)

I don't display the WaitForTargetFPS in profiler as it is not interesing.

no vsync:

with vsync:

Any ideas friends?


texts: Determine which face of a cube is facing the camera

texts: I have a Cube with a unique color for each face. I made a script where I can swipe and rotate the Cube in increments of 90 degrees in each direction. what's the best way to determine which face of a the Cube is facing the camera.


texts: using Playerprefs on Android Mobile Platform

texts:
I have a question about playerprefs on my android mobile game not initializing properly. I have already pre-set my playerprefs data on a variable with a value of 3. In my play mode on unity the value is showing 3 through the textmesh that I have it scripted on. But when I install and test it on my android mobile device it is 0. can someone help how to properly initialize my playerprefs data to the right value on android platform?

 public static Game GM;
 int maxAntiBody;
 public TextMeshProUGUI antibodyTexMesh;

void Start () {
    if (GM == null)
    {
        GM = this;
    }
 maxAntiBody = PlayerPrefs.GetInt("MaxAntiBody");
 antibodyTexMesh.text = maxAntibody.toString();
}

void Update () {
debugging();
}

//I use this method for setting or resetting my desired value for the playerprefs data I'm working with. In this case I choose 3 as a value.
void debugging() {
    if (Input.GetKeyDown(KeyCode.M))
    {

        PlayerPrefs.SetInt("MaxAntiBody", plus++);
        Debug.Log("max anti body value is : " + PlayerPrefs.GetInt("MaxAntiBody"));
    }
    else if (Input.GetKeyDown(KeyCode.R))
    {
        plus = 0;
        PlayerPrefs.SetInt("MaxAntiBody", plus);
        Debug.Log("max anti body is now reseted to : " + PlayerPrefs.GetInt("MaxAntiBody"));
    }
}


texts: Best way to reduce texture size and ensure a minimum quality

texts:
We've been working on this mobile game for about a year now, and we're very close to the end but we've started to face many problems.

Mainly, our game crashes and has a huge size for a 2D game (on iOS only).

Those of you who are a Unity developer please take a look at this editor log (the other please keep reading cause this is not a Unity specific thread)

  Textures 783.1 mb 95.0%

  Meshes 0.0 kb 0.0%

  Animations 342.2 kb 0.0%

  Sounds 24.1 mb 2.9%

  Shaders 22.7 kb 0.0%

  Other Assets 2.3 mb 0.3%

  Levels 8.6 mb 1.0%

  Scripts 1.1 mb 0.1%

  Included DLLs 3.9 mb 0.5%

  File headers 622.9 kb 0.1%

  Complete size 824.2 mb 100.0%

As you saw there the Textures size in near 800mb, which is HUGE for a 2D mobile game.

And the main reason we're having this is because the artists made all the game assets to look great for a 1080p screen, so whenever they are working on something, the start a 1920x1080 canvas and start drawing.

This is my first experience working with artists on a game like this so I really didn't think it's going to be a problem, specially that the first builds where around 30mb on Android and ~80mb on iOS which was ok.

But the game kept getting bigger and bigger, specially on iOS (it's still ~100mb on Android) but also these huge texture size is causing some crashing in some levels on iOS too, so we really need to fix this.

Obviously the must-do solution is reducing the Texture size, and I've been trying to do that in Unity by changing the texture import setting and we kinda reached a bottleneck of a certain quality that we can't go under and the game is still HUGE, so we're thinking about re-drawing some of the graphics assets, for that I need to know what we should keep in mind when making this, that 1080p canvas approach was a bad idea right? What should I tell the artists to do instead?

Any other advice is more than welcomed.


texts: Detect when any part of a collider leaves a trigger zone on Unity 3D

texts:
I've searched all over for a simple solution on this, and found posts as old as 2011, with a bunch of hackish ways to badly work this out.

I want to detect when ANY part of a collider leaves a trigger area.

Some solutions I found and why they won't work on my case:

Using onTriggerExit will only trigger when the collider is COMPLETELY out of the trigger area, making it not ideal for boundaries of maps.

Calculating using bounds may work, but a bit complex when using a polygon collider with convex shapes.

I'm new to Unity and I'd guess this would be a pretty simple, default behaviour for many games.. Really surprised me that I found zero good answers for this on the web (both in stack exchange and Unity forums). Any help would be appreciated.


texts: Cocos2dx launcher - how do I set a newer engine version?

texts:
Why doesn't Cocos(V3.10) detect my newer engine version (3.14) which I downloaded and placed into the engine folder? ( I mean the launcher, the all-in-one version where you can create your project much easier)

thanks in advance!


texts: C# graph library to be used from Unity3D

texts:
I'm looking for a C# graph library to be used inside Unity3D script.

I'm not looking for pathfinding libraries (I know there are good one available).

I could consider using a path finding library only if it gives me direct access to underlying graph classes (I need nodes and edges, and classic graph algorithms)

The only product I've seen that seems intersting is QuickGraph.

I have the following question:

Is it possible to use QuickGraph inside Unity3d?
If yes. Is this a good idea? Does it have any drawbacks? Is it a quite fast and well written/supported library? Does anyone has ever used it?
Are available other C# graph library that can be easily integrated in Unity3d?


texts: How do I replace the enemy with a different graphic when it gets hit?

texts:
I am able to draw my space ship and a an enemy (called "bug_one" in the code below) and move my bullet. When the bullet hits the enemy, it draws a collision bmp.

But currently my code draws both the collision bmp and the enemy bmp after the enemy got hit.

What I want instead is that after the bullet hits the enemy, to no longer draw the enemy bmp and draw the collision bmp instead. I'd like also the collision bmp to disappear after some time. here is my reworked code

        bool draw_flag_coll = false;
    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.Clear(Color.Black);
        e.Graphics.DrawImage(ship, 350 + x, 530);
        e.Graphics.DrawImage(bullet, 375 + x, 520 + y);
        e.Graphics.DrawImage(bug_one, 350, 0);
        if(draw_flag_coll==true)
        {
            e.Graphics.DrawImage(coll, 350, 0);
        }
    }
    int count = 0;
    private void timer2_Tick(object sender, EventArgs e)
    {
        if (y <= -510 && x >= -15 && x <= 15)
        {
            draw_flag_coll = true;
            count++;
            if(count == 100)
            {
                this.Invalidate(true);
                count = 0;
            }
        }
    }


texts: Continuously flip sprite in unity script

texts:
I'm trying to flip a sprite on the X-axis continuously at a certain delay. That is, when the game starts the enemy sprite should keep flipping until destroyed.

I first tried adding it via animator but for some weird reason FlipX via animator was not working, scale and rotation would work but FlipX would have no effect. Maybe some bug?

Then I tried adding it as a script. I did some reading here and found that it can either be done via Invoke() or Coroutine(). I wrote the script below from examples but it is not working. It flips the sprite at start and then stops. How do I make it flip continuously?

private bool flipState;

    // Use this for initialization
    void Start () {
        flipState = false;
        StartCoroutine("Flippy");

    }

    void Update()
    {

    }

    IEnumerator Flippy()
    {
        while (true)
        {
            GetComponent<SpriteRenderer>().flipX = !flipState;
            yield return new WaitForSeconds(1f);
            GetComponent<SpriteRenderer>().flipX = !flipState;
        }

    }


texts: Accelerometer or on screen controls for mobile UI in 3D games?

texts:
I can think of several 2D games which use the Accelerometer successfully, but in my experience as a player, character control in a 3D environment tends to be frustrating.  Mostly because a 3D environment often involves a wider, continuous field of view which prevents me from sitting comfortably while playing.

Is this an unfair generalisation? Are there examples of the Accelerometer working well for 3D games on mobile devices? There is the obvious tradeoff here, screen real estate unobscured by thumbs, but is it worth it?


texts: In Unity, is there a way to Set a new MeshRenderer?

texts:
Here is what I want to do in Unity for a given GameObject go = new GameObject(). I want to create a MeshRenderer, change its properties and only in the end set it as the component of go. For instance:

MeshRenderer newmeshrenderer;
(...) //do stuff with newmeshrenderer
go.AddComponent<MeshRenderer>() = newmeshrenderer;
(or)
go.GetComponent<MeshRenderer>(newmeshrenderer);

But both way fail. What is the correct way of setting a MeshRenderer previously created to be the MeshRenderer of an object?


texts: How to simulate camera turbulence for in-game cinematics

texts:
Are there any good algorithms for generating a convincing turbulence effect that can be applied to an in-game camera.

For example, in use cases such as the viewpoint of a plane flying low and fast over a landscape.


texts: Speed seems random with constant impulse

texts:
I'm shooting an object from the top vertex of a triangle using Box2dWeb. The issue I'm having is that the projectile speed seems to be fairly random, even with applyimpulse set to a constant. The gravity is set to zero.

I thought it could be the physics step, changing these settings hasn't made a difference. The projectile will shoot out at very very fast speeds, then it will shoot out at its defined speed.

bodyman[0].GetBody().ApplyForce(
    bodyman[0].GetBody().GetWorldVector(new b2Vec2(0,-50)),
    bodyman[0].GetBody().GetWorldCenter());


texts: What needs to be done to port a Windows Flash game to Android?

texts:
My team has developed a game using Flash (with Lua embeded) that targets Windows. And we want to port that game to Android (also iOS in the future).

It's acceptable to rewrite the Flash part of client. And some other team in our company recommended Unity3D to replace the Flash part.

Since we have no experience in Android/iOS development, we would need to learn some new tool/language anyway. So we would like that learning still be useful after the porting and when we starting a new game.

Any thoughts?

Edits:

I think it is worth noticing the background of the game : the project is started by a tester and developer, both without knowing much about flex and actionscript. They built the game while learning, so most of the code is hard to maintain. I and other two developers joined the project after a year or so when one has leave (and the other be our manager). The other two developers are just graduates with little experience and little knowledge of flex. I am good at the server part and the c# language.

Based on the fact that the code is hard to maintain (and we do need to change a lot of code to make the game easier to playe in a mobile device), and I am good at c# (and learning). I still tend to do the porting with Unity, which could get better performance and possibly save time.


texts:
I'm experiencing short lag spikes after some voxel chunks have been created while not moving the camera around. I profiled the application: the JVM implementation uses a lot more memory, about 2.5 times more, compared to c++ exact implementation. Also, according to the profiler, the cause of the lag is the garbage collector. But there is nothing to collect ! All voxel data is static, references are kept, nothing gets allocated while profiling. I also turned off all the rendering to make sure that native memory is not leaking. Still lagging.

What could be it ? If you need any code, I'll add it here. (Writing in scala)


texts:
(Unfortunately couldn't find the answer myself)

Does a neat way to cache the geometry shader results in Direct3D10 or OpenGL exist? (preferably Direct3D10).

I'm building my geometry based on texture sampling and I want to do it only once. So, when the first frame of the scene is rendered, this geometry is build and I want to substitute the geometry building process with simple vertex / index buffer rendering.

I hope this can be achieved without intervening into the non-shader code, but if it doesn't, what should I do? I guess the geometry can somehow be "snapshotted" right before the rasterizing stage, can it?


texts: Frame-rate independent friction on movement in 2d game

texts:
I have been trying to implement a simple physics system for a 2D space game I am making. I have it pretty much working, but I have encountered an issue with the way I apply friction. I have tried several different ways of solving it, with different guides found online, but my math skills are lacking and it's difficult for me to translate the solutions to fit my problem.

I made a unit test that shows my problem:

            //Simulate a low FPS.
            //Accelerate body1 with 100 pixels/second, for a deltaTime of 1 (A single frame that took 1 second)
            body1.accelerate(100, 1);
            //Performe the physics with the dame deltaTime.
            body1.doPhysics(1);

            //Simulate a higher fps.
            //Accelerate body2 10 times, with 100 pixels/second for a deltaTime of 0.1 (A single frame that took 1/10'th of a second.
            for(int j=0; j< 10; j++) {
                body2.accelerate(100, 0.1);
                body2.doPhysics(0.1);
            }

            Debug.Log("Straight movement result "+body1.getPosition()+" --- "+body2.getPosition());

Which gives the result:
"Straight movement result [0.0, 50.0] --- [0.0, 39.31200662855]"

My acceleration does not seam to be a problem. I have a unit test like the other one, to test the acceleration, and it shows no problems.

public void accelerate(double acceleration, double deltaTime) {
        Vector2f accel = new Vector2f(0, (float)(acceleration));

        //If power is negative, we want to go backwards.
        if(acceleration < 0)
            accel.setTheta(angle+90 - 180);
        else
            accel.setTheta(angle+90);

        velocity.x += (accel.x * deltaTime);
        velocity.y += (accel.y * deltaTime);
    }

In the doPhysics method, is where I calculate the friction. If I remove the friction calculations, the two values printed from the unit test are equal.

private static final float friction = 1.0f;//0.96f;

    private void doPhysics(double deltaTime) {
        //Save the velocity before applying friction.
        Vector2d velBefore = new Vector2d(velocity);

        //Then apply friction, with deltaTime.
        velocity.x -= (velocity.x * friction) * deltaTime;
        velocity.y -= (velocity.y * friction) * deltaTime;

        //And then calculate the average of the friction before and after friction and factor in deltaTime
        double realVelX = ((velBefore.x + velocity.x) * 0.5) * deltaTime;
        double realVelY = ((velBefore.y + velocity.y) * 0.5) * deltaTime;

        //Add the calculated velocity.
        position.x += realVelX;
        position.y += realVelY;
    }

I hope someone can see what I am doing wrong. I would really like my physics to be frame-rate independent and simple enough for me to understand.


texts:
I'm hoping that some experienced programmers can give me their point of view. I'm writing a large game in Windows with dx11. So far, I've got global objects of the class that interfaces with dx11, the class holding the position of the camera, the terrain data class, and a few other classes. In future, if I kept going with this way, I'd also have objects for all the game data, and so on.

I'm thinking it might be best to rejig the code to only have local variables, because generally this is regarded as a Good Thing, but mainly because I personally have come to prefer using them. Here's some rough c++-ish pseudo-code of how I imagine local variables would be implemented:

WinMain()
{
  cDirectX dx;
  cCamera cam;
  cTerrain terrain;
  ...
  while (msg.message != WM_QUIT)
  {
    ...
    gameLoop(dx, cam, terrain, ...)
  }
}

void gameLoop(cDirectX &dx, cCamera &cam, cTerrain &terrain, ...)
{
  ...
  renderTerrain(dx, terrain);
  ...
}

Is this (very roughly!) a good way to organise such a project? I suppose WinMain is the only function where the locals can be instantiated?

The only disadvantage I can see is that top level function calls (by which I mean, functions like gameLoop(), functions at the bottom of the call stack) will have very long lists of arguments. Perhaps this doesn't matter.

Thanks, Paul


texts: Collision detection between circle and rectangle in 2D

texts:
In a game im developing in 2D, im have one or more circles (balls) that can collide with several rectangles (bricks).

Im trying to figure out a collision detection strategy, and have come up with the following plan.

For each loop of the game ticker get the x,y point of the start and destination of the ball.
Form a rectangle (blue color in fig1.) at the start and dest point that has the balls rotation as well as setting the rectangle width as the balls radius times two.
check if the rectangle intersects with anyting in the play area using Separation of Axis
if the balls path, defined trough the rectangle intersects with anything in the play area, move the ball to the collision point, and after setting a new start and dest point,  rerun from point 2 for as long as there are collisions or the ball has not travelled 100% of its planned distance.

With this strategy i can have collision detection with high ball speeds as well as high precision.

Im a quite new to game development so theres a high probability that im overdoing this, and that there probably exists alternatives to this. Any help/insight on this is greatly appreciated.


texts: Why would somebody want to turn off v-sync?

texts:
From this recent article about technical limitations of UWP, I've found inability to turn off v-sync listed as a negative point.

I understand lowering graphics settings like texture quality, various effects and changing resolution, which very noticeably affect framerate and resource consumption, but vertical synchronization doesn't seem to do any harm.

From what I know, it only removes image tearing, and as a side-effect may result in displayed framerate change from 60 to 59 (or max_fps-1) in some games due to faulty framerate counting algorithm, which some users may see as literally unplayable. From my experience, in game streams with low framerate, disabled v-sync shows as a lot of tearing frames and disgruntled viewers.

Are there any advantages to disabling v-sync? Does it cost anything performance-wise to worry about?


texts: Can I clip a collection of geometry to render only inside a particular worldspace volume?

texts:
I am making a VR app in Unity.  I have a giant map that I want to display on a virtual table.  The map is too large to fit on the table, and I cannot change its size.  (It is a third party asset, and does not easily have that capability.)

How can I tell the camera not to render the parts of the map that fall off of the table?  Perhaps something along the lines of:

Camera.DoNotRender(new Vector3(100, 0, 0));

I have been looking into using some MonoBehaviour messages such as OnPreRender, OnRenderObject, etc.  But I do not know which one can help me, if any.  Ideally, the pixels behind the non-rendered pixels should be rendered, but that is not my priority.

The map is made up of 100s of little renderers:

How can I have my Camera not render specific world space pixels?


texts: OpenGL - Understanding the relationship between Model, View and World Matrix

texts:
I am having a bit of trouble understanding how these matrixes work and how to set them up in relation to one another to get a proper system running.

In my understanding the Model Matrix is the matrix of a object, for example a cube or a sphere, there will be many of these in the application/game.

The World Matrix is the matrix which defines the origin of the 3D world. the starting point.

And the View Matrix is the "camera" everything gets translated with this to make sure you have the illusion of an actual camera when in fact everything is moving instead of this matrix?

I am a bit lost here. So I was hoping someone here could help me understand this properly.

Does every modelMatrix get translated/multiplied with the world matrix and the worldMatrix then with the viewMatrix? Or does every modelMatrix get translated/multiplied with the viewMatrix and then that with the worldMatrix?

How do all these matrixes relate and how do you set up a world with multiple objects and a "camera"?

EDIT:

Thanks a lot for the feedback already. I did some googling aswel and I think I do understand it a bit better now, however would it be possible to get some pseudo code advice?

projectionMatrix = Matrix;
makePerspective(45, width, height, 0.1, 1000.0, projectionMatrix);

modelMatrix = Matrix;
identity(modelMatrix);
translate(modelMatrix, [0.0, 0.0, -10.0]);  // move back 10 on z axis

viewMatrix = Matrix;
identity(viewMatrix);
// do some translation based on input with viewMatrix;

Do I multiply or translate the viewMatrix with the modelMatrix or the other way around? and what then? I currently have a draw method up in such a way that it only needs 2 matrixes for arguments to draw.

Here is my draw method:

draw(matrix1 matrix2) {

            bindBuffer(ARRAY_BUFFER, cubeVertexPositionBuffer);
            vertexAttribPointer(shaderProgram.getShaderProgram().vertexPositionAttribute, cubeVertexPositionBuffer.itemSize, FLOAT, false, 0, 0);

            bindBuffer(ARRAY_BUFFER, cubeVertexColorBuffer);
            vertexAttribPointer(shaderProgram.getShaderProgram().vertexColorAttribute, cubeVertexColorBuffer.itemSize, FLOAT, false, 0, 0);

            bindBuffer(ELEMENT_ARRAY_BUFFER, cubeVertexIndexBuffer);

            setMatrixUniforms(shaderProgram, matrix1, matrix2);

            drawElements(TRIANGLES, cubeVertexIndexBuffer.numItems, UNSIGNED_SHORT, 0);

}

What are those matrixes suppose to be?
Thanks a lot in advance again guys.


texts:
Sorry if the title isn't exactly what my question is, I don't really know how to describe it.

I have an image for my city floor and an image (same size) for all the walls or trees that the player is supposed to be hidden behind, if he walks past behind it. My result doesn't even look so bad:

The problem is that if the player walks infront of the wall, he vanishes, because the layerorder of the wall is above the  order of the player:

Is there a rather simple way to fix this, or do I have to add all those objects manually and connect them to some scripts?


texts: Tetris - Rotations using Linear Algebra (Rotation Matrices)

texts:
I'm making Tetris in Java and am at the point of rotations... Originally I was hardcoding each rotation:

if (direction.equals("right")) {
            if (shape.equals("Bar")) {
                if (rotationsCounter == 0) {
                    currXs[0] += 1;
                    currYs[0] += -1;

                    currXs[1] += 0;
                    currYs[1] += 0;

                    currXs[2] += -1;
                    currYs[2] += 1;

                    currXs[3] += -2;
                    currYs[3] += 2;

                    rightRotate1 = new int[] {currXs[0], currYs[0], currXs[1], currYs[1], currXs[2], currYs[2], currXs[3], currYs[3]};
                }
                if (rotationsCounter == 1) {
                     etc...

Then, I have this to set the correct coordinates based on what the rotated counter is

   if (direction == "right") {
            if (shape == "Bar") {
                if (rotationsCounter == 0) {
                    pieceRotations = rightRotate1;
                }
                if (rotationsCounter == 1) {
                    pieceRotations = rightRotate2;
                }
                if (rotationsCounter == 2) {
                    pieceRotations = rightRotate3;
                }
                if (rotationsCounter == 3) {
                    pieceRotations = rightRotate0;
                }
            }
        }
        if (direction == "left") {
            if (shape == "Bar") {
                if (rotationsCounter == 0) {
                    pieceRotations = leftRotate3;
                }
                if (rotationsCounter == 3) {
                    pieceRotations = leftRotate2;
                }
                if (rotationsCounter == 2) {
                    pieceRotations = leftRotate1;
                }
                if (rotationsCounter == 1) {
                    pieceRotations = leftRotate0;
                }
            }
        }
        return pieceRotations;

But found that was a very tedious way to go...

People suggested I use rotation matrices in Linear Algebra.

So I tried rotating 1 coordinate in a Tetris piece just to see if I was doing it correctly... the point (1, 1) seems to rotate just fine...

So then I thought that the way to rotate the whole block was to get all the coordinates of each tile in a Piece (4 tiles, 16 coordinates), and rotate each one... but I was wrong.

So my questions is...

In the first picture, I choose (1, 1) as my rotation axis... How do I move the rest of the coordinates in relation to that point?

Thanks!


texts: Unable to draw single particle effect at two places

texts:
I am using Libgdx ParticleEffect to draw a fire particle effect .

The issue I have is that when I try to render a ParticleEffect at two different locations within single game loop, only the last draw call has the effect drawn on screen. I update the Particle effect only once per game loop but set its position to two distinct locations and draw it. Is this a trivial problem with Libgdx ParticleEffect:

ParticleEffect effect = new PartcleEffect();
effect.load(gdx.files.internal("data/effect.particle"),atlas,"");
effect.start();

In render :

effect.update(deltaTime);

effect.setPosition(x1,y1);
effect.draw(batch);

effect.setPosition(x2,y2);
effect.draw(batch);

Can someone tell me why it isn't working?


texts: Ruby Vs. C# - Better for Game Programming

texts: I have seen some games made in C#, such as using the XNA. I saw some games made in Ruby by using the RGSS1-3 API as well. I just can't decide on my own which would be easier to learn and apply for game programming. I want your opinion on which is better to make games with, is it Ruby or C#? What are the advantages and disadvantages of each?


texts: What sorts of stats do games companies track when people play their games ?

texts:
I've seen interviews with certain games companies where they talk about getting stats back from their users, particularly with games on facebook.
This data allows the companies to monitor and adjust the difficulty of levels, see what's keeping people engaged etc.
I am just wondering exactly what sort of data would they be collecting?
How common is this practice and would developers of Android and iOS games be involved in similar practices?


texts:
I have a Model(I use the MVC pattern), that holds an 2D Array with Tile objects.

A tile object have a member, whether it burns or not, a member how long it takes until the neighboring tiles get fire too and a member with the elapsed time how long the fire already burns on this tile.

My problem is, that my only solution is, to iterate threw all tiles and check whether the tile burns.
If yes, count down the elapsed time.
Than check, whether the maximum time is reached and set the fire member of the neighboring tiles to true.

In small maps it works, but in bigger maps not(Too many computing power).
Whats the fastest way to filter the burning tiles out of the array, so I can do logic with them ?

A idea from me was to create a extra list that holds a reference to burning tiles, but that's difficult, because the list can be get out of sync with the array(Because the MVC pattern the array is public so it can be modified without to change the list with the fire tiles).

I have problems to implement this.
So maybe someone can show me a code example.
Here my current state:
I have a class Tile:

public class Tile
{
    public static final int TILE_NORMAL = 0;

    private int type;
    private boolean burning;

    public Tile(int type)
    {
        this.type = type;

        burning = false;
    }

    public int getType()
    {
        return type;
    }
    public void setType(int type)
    {
        this.type = type;
    }

    public boolean getBurning()
    {
        return burning;
    }
    public void setBurning(boolean burning)
    {
        this.burning = burning;
    }
}

Than I have a class TileMap, too:

public class TileMap
{
    private Tile[][] tiles;

    public TileMap()
    {
            // That's only provisionally, later loading from a file
        tiles = new Tile[2][2];
        tiles[0] = new Tile[2];
        tiles[1] = new Tile[2];

        tiles[0][0] = new Tile(Tile.TILE_NORMAL);
        tiles[1][0] = new Tile(Tile.TILE_NORMAL);
        tiles[0][1] = new Tile(Tile.TILE_NORMAL);
        tiles[1][1] = new Tile(Tile.TILE_NORMAL);

        tiles[0][0].setBurning(true);
    }

    public Tile[][] getTiles()
    {
        return tiles;
    }
    public void setTiles(Tile[][] tiles)
    {
        this.tiles = tiles;
    }
}

This class(TileMap) is placed into another class named "World".
The world class is the big Model that contains all other models like players enemies ....
To render the world I have a world renderer, that has a reference to the world object and every time I call the render method from the renderer, the renderer take for example the tile map from the world reference and iterate threw all tiles to draw them.

At last, I have a tile map controller.
This class have a reference to the world, too.
Every time the update method from it is called it do the logic for all world objects/models.

So now back to the actual question.
How would you implement the event queue for the fire and maybe for such things like that?
I am sorry and thanks for the patience :)


texts: In platformer games, what are "hole in the ground" obstacles called?

texts:
In most jump and run games, holes in the ground are common obstacles: You need to jump over them, or you'll fall down and lose a life.

It would be helpful to know for documentation, variable naming and discussion: What are those holes called?


texts:
I want to animate ball in html canvas like this.

ctx.beginPath();
ctx.arc(75, 75, 10, 0, Math.PI*2, true);
ctx.closePath();
ctx.fill();

start position is left top corner and ball's maximum height position is always the same

also I don't want to use javascript physics libraries

thanks


texts: Set box collider size in meters instead of percents

texts:
TL;DR: Can I set the size of a collider in meters instead of fractions of the size of the object it's in?

I'm implementing a classic NES game, and my scale is 1 meter = 16 pixels. I have an 8x1x1m prism with a rigidbody, and I need its box collider to be smaller than it by one pixel on every side- to have the dimensions (8 - 1/16 - 1/16) x (1 - 1/16 - 1/16) x (1 - 1/16 - 1/16). (I'm subtracting the width of two pixels from each dimension because each dimension corresponds to two sides.)

When I set the size of the collider to (0.5, 1, 1), though, it interprets those numbers as fractions of the size of the prism instead of as meters. This results in a 4x1x1m collider instead of a 0.5x1x1m collider. Is there a way I can set the size in meters instead of percents? I'll save me a little bit of math, and, more importantly, it could prevent some floating point errors, especially if I switch to a scale with more pixels per meter.


texts: What's the easiest way to get a JavaScript game to save?

texts:
I'm doing a re-skin of and old open source web game, the current game is in HTML, CSS and JavaScript.

I'm trying to redo the save game bit as I can't make sense of it and want something I can understand. I think it's relying on a database or Dropbox? Though I've tried removing the Dropbox links it still seems to work perfectly?

So it works but I don't understand what it's doing and I'd rather want something where I can see how its done, saving the state ie variable values and open panels etc.


texts: What state is stored in an OpenGL Vertex Array Object (VAO) and how do I use the VAO correctly?

texts:
I was wondering what state is stored in an OpenGL VAO. I've understood that a VAO contains state related to the vertex specifications of buffered vertices (what attributes are in the buffers, and what buffers are bound, ... ). To better understand the correct usage of VAO's, I'd like to know exactly what state they hold.

How I assume VAO's should be used

From simple examples, I've understood that correct usage of VAO's is as follows:

Setup

Generate VAO
BindVAO
---- Specify vertex attributes
---- Generate VBO's
---- BindVBO's
-------- Buffer vertex data in VBO's
---- Unbind VBO's
Unbind VAO

Rendering

Bind VAO
---- Draw
Unbind VAO

From this, I assume that at least the vertex buffer bindings and the vertex attribute specifications are stored in the VAO. I'm unsure however how this usage pattern extends to situations where (multiple) textures and (multiple) shader programs come into play. Is the active shader program stored in the VAO? And are the texture bindings (with their sampling/ wrapping settings) stored in the VAO as well? Ditto for uniforms?

Therefore, my questions are:

What exact state is stored in an OpenGL VAO? (VBO bindings, attribute specifications, active shader program, texture bindings, texture sampling/wrapping settings, uniforms ... ?)
How do I correctly use VAO's in a more complex rendering setup where (multiple) textures with associated sampling/wrapping settings, (multiple) shader programs and uniforms are involved?


texts: LibGdx: set TextButton font to a TrueTypeFont

texts:
I am making my first LibGdx game, and having an hard time understanding font scaling on TextButtons.

Here is a comparison between the rendering on my Kindle Fire 7 and an high resolution tablet:

I tried using the scale() method, but the result is a pixelated mess.

I've read about TrueType fonts, and I'd like to set the font size by calculating the screen density.

I've tried to create a TextButtonStyle containing a font with the following:

//Generate the font
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/Merriweather-Regular.ttf"));
TextButtonStyle style = new TextButtonStyle();
FreeTypeFontParameter param = new FreeTypeFontParameter();

//Set the font size (12 as an example)
param.size = 12;
style.font = generator.generateFont(param);

//Set the new style to the button
button = new TextButton("START GAME", style);

The TextButton correctly gets the new font, BUT loses the actual button as only the text gets rendered; I guess that's because the new TextButtonStyle only contains information about the font and is otherwise empty.

I tried setting the new font to a Skin also, but only ended with further confusion; most resources I found online don't mention font rendering on TextButtons, or end up being confusing with convulted methods.

Is there a simple way to achieve what I want? Thanks.


texts: Are sockets required when developing a browser based MMOG?

texts:
I'm in the very early phases of developing a browser based MMOG, kinda like this game but not as cartoonish and with more features.  I'm an experienced web developer, yet not once have I ever used websockets.

Are websockets required for something like this?


texts: Custom Transparent Shader rendering order is wrong on iOS

texts:
In Unity Engine, I wrote a custom transparent shader(I use blend to achieve) for crystal effect and it's totally fine on Windows. However, when it's on iOS platform, the crystal always culls everything so that if a wall is on the front of the crystal, you still can see the crystal while on Windows you only see the wall.

I tried to change ztest to Greater, on Windows if something culls the crystal it will render so it's what I want while on iOS, the crystal will never render.


texts: Body's initial velocity is too fast when created after minimax algo

texts:
I don't know if my question is right but I cannot address the real problem.
I am dropping connect 4 game chips under gravity but when I apply minimax with a depth of 3, it starts with great velocity.
My code for render loop is:

private List<List<Chip>> chips;

public void render(float delta){
    world.step(1/60f, 6, 2);
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    game.batch.begin();

    for(List<Chip> chipList: chips){
        for(Chip chip: chipList) {
            chip.setPosition(chip.getBody().getPosition().x-chip.getRadius(), chip.getBody().getPosition().y-chip.getRadius());
            chip.draw(game.batch);
        }
    }

    if(chipready){
        chip.createBody();
        chips.get(yellowIndex).add(chip);
        chip.draw(game.batch);
        chipready = false;
    }

    game.batch.end();
}

Here Chip is a subclass of Sprite.

Code for my contact listener:

    world.setContactListener(listener = new ContactListener() {
        @Override
        public void beginContact(Contact contact) {
            Fixture fixA = contact.getFixtureA();
            Fixture fixB = contact.getFixtureB();
            if (fixA.getUserData() == "chip" && fixB.getUserData() == "floor" || (fixA.getUserData() == "floor" && fixB.getUserData() == "chip"){
                yellowIndex = BestMove.minimaxutil( board, AI_PIECE);
                chip = new Chip(world, x, y, radius);
                chipready = true;
            }
        }
    }


texts:
I have a BIG problem!! I want to make something like old space shooter games like “Asteroids”, where the ship, when going out of the screen, is reappearing at the other side. For example, when the ship go out at the top of the screen, it come back at the bottom. But in my game, there’s a camera following the player, showing only a quarter of the world, and I want to simulate an infinite world this way! Here’s a picture showing what I mean :

What I thought doing was simulate the scroll by only moving game objects, stored in an array, but not the player, and calculating at every frame if the objects are out of the world boundary and re-adding them at the other end of the world (i.e going out at the left would add it back at the right).

But I don’t really like that way of doing… I’d like something more… intuitive..?

Do you guys have any idea of how doing it? Like, any tutorial on the web or just the right words to explain what I mean so I could do a bright research on google (I’m french, so I had a really hard time writing that question)!

Thank you in advance!


texts: what is the standard solution to pathfinding towards a moving target?

texts:
I am working on a 2D RTS like game, basic A* works perfectly for moving a unit from point A to point B.

But now I facing the continuous path-finding problem, like A attack a moving object B, call A* at each frame once Object B's position changed seems inefficient.

so what is the standard method to this problem?


texts: How do I render an entire frame to a Texture2D?

texts:
I asked a question here: C# XNA Make rendered screen a texture2d

But, I ended up not getting the exact result I was looking for since I didn't ask the question right.

In a game I am writing, I render an extremely large city out of objects, this can cause lag when moving the camera to view things that are off screen. I need a way to render then ENTIRE city, even the stuff that is off screen, and make it into a Texture2D.

The answer I chose for the last one didn't work entirely right because it only gets what is on screen, not what is off.


texts: How to prevent a certain textured quad from the effect of the pixel Shader at the run time in slimdxdirect3d9 or directx9?

texts: I am having a video and and image slide show being rendered simultaneously. Both video and the image is being rendered by the help of texture and two different quads. Video is being rendered on the whole screen but the image of the slide show is being rendered along the video on some particular area of the screen. I am using pixel shader to give effects in my slide show but the pixel shader is affecting both the textures being rendered that is my video and the image slide show. But I want it to give effect only to the image slide show. For this I am doing Device.PixelShader=null when the video quad is being drawn but giving my pixel shader to the device when the the image is being drawn. But I want to know that is there any other way that can prevent my video quad from the effect pf the pixel shader.


texts: How can I stop the Unreal Editor's UI from being blurry?

texts:
My Unreal Engine UI does not look sharp and is blurred on my 1080p monitor. Subsequently, the viewport is slightly blurry and edges are jagged. I have changed the setting of the viewport to "Cinematic," yet this still persists.
I have two images available where the first is mine and as you can see, the image is slightly blurred and text on the left-hand side is not sharp.

The second image is from a YouTube video which has been compressed (by YouTube) yet it still looks better.

How can I make the UI more crisp and prevent the blurring?
Anyone?


texts: Send a Push Notification from a device to another device (Unity, Firebase)

texts: I have setup Firebase authentication in my game for Android. I need to implement a feature in my Android game, where a user can challenge another player. I need to implement it this way: The user is shown the list of all users registered on Firebase on the Game. To any user, he can tap on a button for respective user to send a challenge. When, he taps, a push notification is to be recieved by that user. When he taps on the notification, he is redirected to a specific part of the game. Maybe a specifc scene for now and he is shown there the Challenger's name. I have explored the Firebase documentation, but it does not provide information for client-client push notifications. Maybe there are other options available like GameSparks and OneSignal. But I don't know if there is a requirement of own Server for implementing it.


texts:
I have a tiled forward render pipeline (also called forward+). It assigns a list of lights for every 16*16 block of pixels (tiles) on the screen. Lights are accumulated additively so their order doesn't matter inside the list.

The problem comes when I add decals to the light list. Decals need to be evaluated before the lights (because they can modify surface properties), and even their order among themselves matter because their texture is alpha blended on top of each other.

Because the lights and decals are culled in parallel, and added to the list by keeping a shared pointer to the end of the list which is incremented atomically when a light is added, the order of them can not be guaranteed. This is how I add a light to the tile's light list from a thread:

// I have a [numthreads(16,16,1)] thread group
for (uint i = groupIndex; i < g_nNumLights; i += 16 * 16)
{
  Light light = GlobalLightArray[i];
  if(IsLightVisible(light))
  {
    uint index;
    InterlockedAdd(LightCount, 1, index); // LightCount is a groupshared uint (the whole threadgroup can see it)
    LightArray[index] = i; // A light is always added to the back of the per tile light array
  }
}

I thought I should try to sort the light list after the culling and the creation of the list has ended, but I have no experience with highly parallel sorting algorithms. I however came across a nice presentation: Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
. From the 8th slide it has a brief explanation of the bitonic sort algorithm with pseudocode and nice pictures. I get the idea, but I have no idea how to implement it or if it could be even done efficiently for my case because my light list is variable in size for each tile. Maybe it could be done in the same dispatch when the culling occurs, on this array (which hold a variable amount of light indices <= 1024):

groupshared uint LightArray[1024]

I have also seen a DirectX11 example of the algorithm of this kind of sorting, but on a different kind of dataset and across multiple dispatches and other post-processing transposing which is not clear to me at all.

Or maybe there is a completely different approach that I should take which doesn't involve sorting? Maybe when adding lights to the back of the array, the order of addition could be enforced somehow?

I have also learnt that the new Doom game also renders its decals this way.


texts: Animation fails due to a NullPointerException which I'm certain shouldn't be thrown (LibGDX / Java)

texts:
What the title says basically. I've been stuck on this error for a few hours I got it to work earlier but I honestly can't see why its failing now (ctrl + z'd back to the working stage). Here's my code:

public class Animator {
    private Animation animation;
    private TextureRegion[] walkFrames;
    private TextureRegion[] jumpFrames;
    private TextureRegion[] enemyFrames;
    private Texture jumpSheet;
    private Texture walkSheet;
    private Texture enemySheet;
    private TextureRegion currentFrame;
    private Animation enemyAnimation;
    private Animation jumpAnimation;
    private Animation walkAnimation;
    private TextureRegion[][] animationType;
    private TextureRegion[] animateJump;
    private TextureRegion[] animateWalk;
    private TextureRegion[] animateEnemy;
    private GameObject object;
    private float stateTime;

    public Animator(GameObject object) {
        this.object = object;
        jumpSheet = new Texture(Gdx.files.internal("jumpsheet.png"));
        walkSheet = new Texture(Gdx.files.internal("walksheet.png"));
        enemySheet = new Texture(Gdx.files.internal("enemySheet.png"));
        enemyAnimation = animate(1, 4, enemySheet);
        jumpAnimation = animate(1, 7, jumpSheet);
        walkAnimation = animate(1, 4, walkSheet);
        stateTime = 0f;
    }

    public Animation animate(int rows, int cols, Texture spriteSheet) {
        TextureRegion[] frames = new TextureRegion[cols * rows];
        animationType = TextureRegion.split(spriteSheet, spriteSheet.getWidth()
                / cols, spriteSheet.getHeight() / rows);
        int index = 0;
        for (int i = 0; i < frameRows; i++) {
            for (int j = 0; j < frameCols; j++) {
                frames[index++] = animationType[i][j];
            }
        }
        animation = new Animation(0.25f, frames);
        return animation;
    }

    public void render(SpriteBatch batch) {
        stateTime += Gdx.graphics.getDeltaTime();
        if (object.getType() == ObjectType.PLAYER
                && object.getState() == ObjectState.JUMPING) {
            currentFrame = jumpAnimation.getKeyFrame(stateTime, true);
        } else if (object.getType() == ObjectType.PLAYER
                && object.getState() == ObjectState.NORMAL) {
            currentFrame = walkAnimation.getKeyFrame(stateTime, true);
        } else {
            currentFrame = enemyAnimation.getKeyFrame(stateTime, true);
        }
        batch.draw(currentFrame, object.getxPos(), object.getyPos()); // Null Pointer
    }
}

I get the NullPointer on the last line, and if I run in debug mode with breakpoints it tells me that currentFrame is null (at every stage of the if statement). Can anyone see why?

Any help is highly appreciated, thanks.


texts: Allowing a unit to equip only certain types of weapons

texts:
I'm making a FireEmblem style game, and I am working on items at the moment. I have a Weapon class from which Sword, Axe, etc. are derived. I also have character classes like Swordsman, Mage, etc. I would like to have a way to allow classes to only equip certain weapons (Swordsman can equip Sword but not Axe). One way I thought of was to have a global enum for WeaponType, and each weapon has a const weapon_type value. Then, each character class has a list of allowed WeaponTypes and you would check if a weapon's weapon_type is in the allowed list.

Is there a better way to implement this without using any casting?


texts:
Background

I've recently reached a bottle neck in my game's code that forced me to completely decouple the logic/networking from the graphics. Thanks to the nature of my board game, I was able to build the following architecture:

Logic update loop:

+--> wait for event -> process event -> dispatch graphic events --+
|                                                                 |
+-----------------------------------------------------------------+

Graphics update loop:

+--> wait for event -> process event -> wait for animation --+
|                                                            |
+------------------------------------------------------------+

Question

From the previous design, tracking animation timing and knowing when they end is crucial, since that marks the end of the third phase in the graphics loop, allowing us to proceed to the next phase.

I'm using Unity, and I am not sure how to go about this. I am using Unity's animation system as well as LeanTween to perform animations on the 2D NGUI level as well as the 3d game scene level.

Proposed Solutions

Solutions that have occurred to me so far are:

Callbacks

Pass on a callback, and make the animation system trigger that callback when the animation finishes. This has proven to be high maintenance and redundant, as I have to manage passing data back and forth maintaining the overall animation state somehow (if multiple animations were triggered).

Global Monitor

Animations register under a global monitor, and I can emit a signal when the monitor becomes empty, triggering the end of the animations phase. I must make sure animations are registered immediately at the beginning of the animation phase, which I should be able to do. I should also maintain a list of animation IDs or a simple "anonymous" counter, which animations increment and decrement. Kinda like manual memory management. I might do this.

Any of those seem viable? Am I overlooking details about this system? Any better alternatives come to mind?


texts:
I am creating a project in Unity 5 free and using external dlls. I have a scene that is running normally within Unity but when I try to build the project as a standalone windows game I get this error which stops the build

Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.

  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)

  at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0

  at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0

  at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0

  at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0

  at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0

  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0

  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0

The following assembly referenced from C:\MyProject\Assets\Plugins\MyPlugin.Unity.dll could not be loaded:
     Assembly:   UnityEditor    (assemblyref_index=3)
     Version:    0.0.0.0
     Public Key: (none)
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (C:\MyProject\Assets\Plugins\).

Could not load file or assembly 'UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
Could not load file or assembly 'UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

I guess there must be a mistake in the way the dll is loaded or something? What is causing this error?

EDIT The Visual studio projects build properly with no errors


texts:
I'm learning the basics of writing the game engine. Now I'm on the rendering the scene aspect using  the page flipping method. I roughly understand the theory but as of the implementation i can't find simple examples showing this technique.
Can someone please be so nice and provide me some c++ code showing the simplest direct vs page flipping rendering allowing me to see the difference as of problems like the image flickering or image tearing?


texts: How do I control multiple Pawns without possesing them (RTS style)?

texts:
I am making a multiplayer RTS but I have a problem controlling spawned units (let's call them Vessels), specifically moving them around with AI MoveTo bp.
Vessels can be created by both Clients and Server and are visible for everyone but neither clients nor Server can move Spanwed Vessels.
Only Vessels placed on the map beforehand can be moved and ONLY by the Server.
Also, the server sees all Client CameraPawn movements and clients see Server CameraPawn movements BUT clients don't see each other's CameraPawn Movements (if this is related somehow...)

How can I control a pawn in multiplayer from all clients for starters?
How can I limit control to a specific controller?
Why "preplaced" Vessels work(move) for Server only?


texts: Load uncontrolled 3D asset at runtime in Unity

texts:
I'm trying to load assets at runtime in Unity.
I can load images this way: https://docs.unity3d.com/455/Documentation/ScriptReference/Texture2D.LoadImage.html

But how can I do the same with 3D assets? From what I read, loading .fbx/.obj and alike need importers. But importers are created by users, and support might be bad.

I read you can import using https://docs.unity3d.com/ScriptReference/WWW.html
But that seems only to work with unity3D files

Or do I follow the wrong track? Is there another way to do this?


texts: How to locate assets on different computers? JavaFX

texts:
i've programmed a little game in javafx in Eclipse. It uses 3 file-path url's to locate the images, sounds and savefile folders. My problem is that those url's have been hardcoded and therefor obviously only work on my computer. Like this:

    public static String imageDir = "FILE:///D:/Users/tlins/eclipse-workspace/SpaceWars3.0/src/images/";

I want to export my game in a jar file and then the programm should figure out for itself where the assets are located. I originally assumed that it would start looking in the same folder as the main class, and that i could just type

public static String imageDir = "images/";

But it gave me an exception error "url not found" regardless.

So im just here to ask how you people normally do this? This can't be an uncommon thing right?

Should i somehow let the program figure out the EXACT path like shown (far) above? Or is there a way to inform it that it should start looking from the folder of main class?


texts: Unity 2D: Why does my character stutter if I add deltaTime to moveSpeed?

texts:
So I'm following a tutorial on youtube, first time Unity user, but been making games in other frameweorks before. In the tutorial he does not use deltaTime for movement, which has always been the standard for me, so I added it my self, but it makes my character "stutter/lag" really weirdly (does not stutter without deltaTime). Surely I must use deltaTime for movement in the Update()method?

Script for Player movement:

void Update () {

     playerMoving = false;

     if (!playerAttacking) {
         Vector2 direction = new Vector2();

         if (Mathf.Abs (Input.GetAxisRaw ("Horizontal")) > 0.5f) {
             Debug.Log ("Moving on X");
             playerMoving = true;
             direction.x = Input.GetAxisRaw ("Horizontal");
             lastMove.x = direction.x;
             lastMove.y = 0;
         }

         if (Mathf.Abs (Input.GetAxisRaw ("Vertical")) > 0.5f) {
             Debug.Log ("Moving on Y");
             playerMoving = true;
             direction.y = Input.GetAxisRaw ("Vertical");
             lastMove.y = direction.y;
             lastMove.x = 0;
         }

             if (playerMoving) {
                 myRigidBody.velocity = direction.normalized * moveSpeed * Time.deltaTime;
             } else {
                 myRigidBody.velocity = Vector2.zero;
             }
     }

My Camera (Stutters unless I use fixedUpdate):

void FixedUpdate () {
    targetPos = new Vector3 (followTarget.transform.position.x, followTarget.transform.position.y, transform.position.z);
    transform.position = Vector3.Lerp (transform.position, targetPos, moveSpeed);
}


texts: Project transfer, will re-importing all my models damage my project at all?

texts:
Recently I had to transfer my Unity game project to another computer and downloaded the same version of Unity I was using for my 3D project and checked that all the files and folders were in the same place and everything.

When I start up the game though my models have vanished and in the hierarchy it just says missing prefab instead of telling me what it was, like it used to if I'd move a model to another folder or something like that.

It shows all my files there and I was about to reimport them all but I got a warning that said:

"Rebuilding assets is only if your project has been corrupted due to an internal Unity bug. It can take several hours to complete, depending on the size of your project.

Please submit a bug report detailing the steps leading up to here."

I am sure that re-importing all my models will fix this but I want to ask if this will have any negative effects on my project or possibly damage anything?

This game is extremely important to me and I've been working on it for the past 3 years(being self taught which is why it's taken so long and I'm still learning)

Thank you guys in advanced! :D


texts:
I'm working in an action/strategy proyect. Consider it a RTS game. The game is in 2D (with LibGDX), and I have a lot of soldiers moving along. Now I have to implement the AI. Let me say some things about my current design:

The map has been constructed with tiles. However, I want to allow the soldiers to move in every direction -so using the tiles as graph for A* is not a good idea.
The obstacles are given by collision rectangles. Maps will have a lot of free space, and collision rectangles don't fit the tiles -that makes even worse the election of A* with tiles.
Waypoints, for the same reason, are not a good idea. I would need a very big net and soldiers would move in strange ways, as pointed out here: http://www.ai-blog.net/archives/000152.html
I've taken a look to the LibGDX-AI library. I would like to make soldiers follow the captain or use some kind of formation. Looks like this library is a good choice to make that.

Some things I know:

I also have read about potential/vector fields and navigation mesh. The fields look interesting, but I'm not sure of how to implement them for my case. They could be good for pahtfinding, but some soldier have to follow the captain and move in formation.
I think nav meshes won't solve my problem. As I've said, I have a lot of free space, and soldiers can move whatever they want, so the question "how to move the soldier inside the mesh?" remains.

QUESTIONS:

How to make a free-space AI pathfinding which avoid my collision rectangles?
How to make this compatible with formations like following the player across the map?
Is there any way to use LibGDX-AI to do this?


texts: Checking distant 2D objects from the player in pure javascript

texts:
I'm checking if the objects are too far from the player to be able to disable some things, I'm doing so:

const obj1 = {
     x: 0,
     y: 0
};

const player = {
   x: 0,
   y: 0
};

const sqrMagnitude = (x, y) => {
    return (x * x + y * y);
};

const isAwayFromPlayer = (entity, targetEntity, distanceMax) => {
    if(sqrMagnitude((targetEntity.x - entity.x), (targetEntity.y -
entity.y)) > distanceMax * distanceMax){
        console.log("yes!");
    }else{
        console.log("no!");
    }
};

awayFromPlayer(obj1, player, 250);

but when walking with the player, sometimes I approach the objects and I get the console.log("yes!"), sometimes I move away and also I get, but it was only to work if I were away from them, I'm forgetting to do some conversion to absolute value with Math.abs for example? I remember that this is how it was when I needed some time ago, but something is not working properly.


texts: Rotate object such that a child object is facing a target (3D)

texts:
Given a parent object A and a child object B, how do I find the rotation of A such that B is pointing toward the position of a target C.

This is a simplified way of solving 'what angle does the torso need to be so that the hand is aiming a weapon at a target?'.

I can solve easily in 2D by iteratively checking how much B needs to turn to look at C and then applying that rotation delta to A, but in 3D this method seems to breaks down.

Does this problem have a known name, and what types of algorithms should I be researching in order to solve it?

Initial state

Desired state


texts: Is making a sandbox feasible in Godot/Unity (w/o open world)?

texts:
I want to make a 3D multiplayer game. It will inherit the basic principles of the MOBA genre: players choose from the variety of characters each having 4-8 unique abilities, then battle it out. I also want some abilities to affect terrain.
I try to keep the concept simple to be able to make this game alone. It would be good if I manage to finish the first playable prototype in no more than 6 months (keeping in mind that I'll be able to work on the game mostly on weekends). Multiplayer AND 3d in themselves make things much harder, so deciding which mechanics to implement and how is essential. Thus I want to make sure I won't have to redo much after I start programming.
To implement the destructible terrain I decided to stick with a Minecraft-ish approach, where everything consists of blocks. The sandbox is a very hard genre in terms of game development, but after doing quick research, I concluded that most difficulties arise from the fact that the game is open-world. This isn't my case. I won't need too many blocks to construct the arenas.
Now I need to come up with the engine I'm gonna use. I like Godot due to its development paradigm, but I'm not sure whether it is a good choice for a game like this. Maybe Unity is the better choice in my situation. Or something else.
Maybe I need to remove some mechanics from the concept to make the development a lot faster.
Can you comment on it? Thanks!
P. S. I have 7 years' programming experience (with Haxe and Python being my main languages) and a good mathematical background. I have been developing my multiplayer game for 3 years now (but it is a 2D game, I have no experience in 3d gamedev beyond the Godot tutorial). It is okay if I need to learn different things before starting to make a game, but I want to make the learning process as effective as possible.


texts: What is the best way to follow this book using XNA 4.0 instead of XNA 2.0

texts:
I found a reference to this book on the Microsofot Indie games forums: http://www.amazon.com/dp/1430209798/ref=pe_385040_30332200_pe_309540_26725410_item

I'm really interested in it, because the example project is very close to the style of gameplay I'm looking for in my next game. The downside is, I was hoping to write the game in XNA 4.0 and maybe even Monogame.

Would the best option here be to just follow along with the book using xna 2.0, and then try to rewrite/update the app in xna 4 or monogame? Or, would it be better to start my project as an XNA 4.0 project, and then code along with the book, fixing any discrepancies as I come across them?


texts:
I want to animate my player from bigger size to smaller size and then smaller size to bigger size continuously.
We can use setScale() method to re-size any sprite but is there any way to animate with it?

And one more thing, if I scale any sprite after creating it's physics body, the sprite is visually scaled but the physics body does not scaled.

So is there any optimum solution to animate the physics body from bigger to smaller and then smaller to bigger?


texts:
I'm having problems understanding how to properly rotate a Turret.
Using Unity Editor, I've simulate turret movement, so I take note that turret can move with this clamp factor (for instance):

( value expressed in euler angles )

X = 1-4

Y = 0-0

Z = 98-100

I've write this code but it not works properly:

float rotX = Random.Range (Cannon1MinX, Cannon1MaxX);
float rotY = Random.Range (Cannon1MinY, Cannon1MaxY);
float rotZ = Random.Range (Cannon1MinZ, Cannon1MaxZ);

Cannon1.transform.Rotate (new Vector3 (rotX, rotY, rotZ),Space.World);

Every time I've to work with rotation i become mad :(

What is wrong ?
Thanks


texts: How to draw connecting lines in plain color?

texts:
Since there is no option for flat shading in OpenGL ES2, is there a workaround to disable the color interpolation when different color is being passed to each of the vertices?

Update:
I'm working with OpengGL ES 2.0 in android. I'm given with these vertices which I used to draw shapes by connecting them with lines. Now I need to change color of each of these lines individually. I tried passing a color matrix for each vertex through vertex shader to fragment shader but the color gets interpolated (which actually makes sense, since I'm giving different color to two vertices). I did some googling about that and found out glSmoothShader cannot be disabled in OpengGL ES.

Is there a way to color those lines without the colors getting interpolated?

Or is there a way to use multiple triangles to draw a line between two vertices that way i can flat color each of those triangles.


texts:
How do you usually solve collisions between entities and the ground? Sending collision events hardly seems appropriate since almost everything touches the ground at almost all points in time. Calling collision handling functions doesn't sound any better.

How is this normally achieved? Is handling of slopes significantly harder?


texts: Critical input from server arrives late... it must not!

texts:
To preface, my understanding of networking is mostly from Source Multiplayer Networking and 1000 Archers on a 28.8.  For various reasons I have decided to go with a client-server model instead of peer-to-peer.

My C#/Unity multiplayer game is ruled by an authoritarian server, which uses UDP. Each network instruction has a time index, and is inserted into PlayoutBuffer's data collection.  The buffer executes stored commands at the correct local time index, based on a fixed update loop.

The server is slightly ahead of time, and clients will pause if they have not received any regular update from the server, allowing them to catch up.

Each client will simulate object movement and this movement is corrected by the server (ten times a second).  I've got the basic system working, but when I'm testing it in two windows on the same machine sometimes input arrives late, and is dropped.

Usually the late message is 1 time index too late.  The fixed loop is 50 ticks per second.  The server is 5 ahead of time, and commands are scheduled 5 ahead of time (assuming negligible lag, since ping hasn't been implemented yet and is on the same machine).

This is a problem.  Inputs from server are grouped into a few specific channels:
Ping, Serialise, Inputs, Criticals, Corrections.

Ping has yet to be implemented.  Serialise packs and unpacks mostly pregame multiplayer lobby stuff.  Inputs are player commands; select unit, issue move order, etc.  Criticals are essential updates; create unit, shoot unit's weapon, damage unit, etc.  Corrections are mostly movement updates.

All channels are unordered and with the exception of Corrections all channels are "Reliable" in Unity terms (see Unity documentation).  Given that movement updates happen regularly, if a few are dropped or arrive late this is not a critical system failure.  But if a critical is lost, this would effectively result in a desync.

How can I prevent and handle critical data arriving late from the server?
My first thought is to implement a custom ping. This is used to set the time index for the data relative to the time the last ping took to get back from the client, plus server time index.

But I doubt that would be enough... and if it fails?  Should the client pause or catch up based on the difference between local time index and the time index in the late critical?  Does the PlayoutBuffer need to become an AdaptivePlayoutBuffer to resolve these issues to handle CPU and network lag?  If so, how so?  Any other ideas welcome!

EDIT: The reason inputs were arriving one time index too late sometimes was because the buffer's for loop which read inputs counted from 0 to list.count, and removed items as it iterated... when I changed it to reading from list.count to 0, it fixed the issue and no inputs arrived late.  Whoops.


texts:
So I am currently creating a game based on static voxels, there is no manipulation of voxels, which allows me to optimize it more.

Now, my friend was kind enough to teach me modern OpenGL. Currently I use OpenGL 1.1, and the primitive glBegin/glEnd methods. We went straight into VBOs because I wanted to render voxels using modern OpenGL, but we went too far because I didn't understand much about the fundamentals, such as vectors. That's been resolved and I asked what a VBO is, and he responded with an answer that I think it isn't the right one.

"It stores static vertices on the gpu", I'm not sure if this is correct, so please answer what a VBO is.

TL;DR: read the last sentence.

Thanks in advance!


texts: How do you handle uneven tiles while rendering a tile map?

texts:
Here is what I want to do with my tile map that I am unsure of. As you can see the top walls are way larger then the bottom and side ones (this is also an issue with my corners which are odd shapes [more like an L then a square] as well as larger then the 40x40px that my current tiles are).

I have also attached the tile sheet I am using for the tiles to show you what the corners and tops look like compared to the rest of the tiles.

What I’m thinking is I might be able to just draw them using the same array I have if I use the tiles width and height instead of a set WxH? I dont know how well this will work, but were the blocks that will have different values will be blocks the player/NPCs can’t step on then it may not be an issue, again I’m not even sure if that is a viable solution.

My code in case you want to see how I'm currently handling it: Map.java (pastebin)
(edit:im not handling it, meant how I'm currently doing the map)

tl;dr - how can I take take my 2d looking tile map and change it to have different size tiles? or is there a better way to do what I am trying to do? Is there a name of a method that I should be looking for while googling?


texts:
I am trying to determine the best way to dynamically discover new levels in my Windows Phone game. This is necessary because I will be selling some levels separately to those included with the initial game purchase. I assume that it is possible for such purchases to be automatically downloaded and merged into the same directory that contains the game itself.

All my levels are pre-processed and stored as XNBs. Ideally, I would be able to obtain an enumeration of all XNBs of a particular type (ie. Level) within my game directory, but I cannot find a means of doing this. Alternatively, if I could get a list of all XNB names then I could use a naming convention to identify levels. Unfortunately, I can't find a way to do that either.

Am I barking up the wrong tree here? Can anyone shed any light on how I might dynamically discover content in my game?


texts: Physics in my game confused after restructuring the Game loop

texts:
I'm on my way with making a game in Java. Now I have some trouble with an interpolation based game loop in my calculations.

Before I used that system the calculation of a falling object was like this:

Delta based system

private static final float SPEED_OF_GRAVITY = 500.0f;

@Override
 public void update(float timeDeltaSeconds, Object parentObject) {

parentObject.y = parentObject.y +
          (parentObject.yVelocity * timeDeltaSeconds);

parentObject.yVelocity -= SPEED_OF_GRAVITY  * timeDeltaSeconds;
    ......

What you see here is that I used that delta value from previous frame to the current frame to calculate the physics. Now I switched and implement a interpolation based system and I actually left the current system where I used delta to calculate my physics.

However, with the interpolation system the delta time is removed - but now are my calculations screwed up and I've tried the whole day to solve this:

Interpolation based system

private static final float SPEED_OF_GRAVITY = 500.0f;

@Override
public void update(Object parentObject) {

parentObject.y = parentObject.y +
        (parentObject.yVelocity);

parentObject.yVelocity -= SPEED_OF_GRAVITY;
    ......

I'm totally clueless - how should this be solved? The rendering part is solved with a simple prediction method. With the delta system I could see my object be smoothly rendered to the screen, but with this interpolation/prediction method the object just appear sticky for one second and then it's gone.

The core of this game loop is actually from here deWiTTERS Game Loop, where I trying to implement the last solution he describes.

Shortly - my physics are in a mess and this need to be solved.

Any ideas? Thanks in advance!


texts:
I am trying to draw text onto the screen but it always ends up being pixelated no matter what I try. A lot of people say that adding the Linear TextureFilter works or offer other solutions but they don't really work for me. This is what I have now (I'm also using a ttf font):

public BitmapFont generateFont(String path, double size)
{
    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(path));
    FreeTypeFontGenerator.FreeTypeFontParameter parameters = new FreeTypeFontGenerator.FreeTypeFontParameter();

    parameters.genMipMaps = true;
    parameters.color = Color.BLACK;
    parameters.size = (int) Math.ceil(size);
    parameters.magFilter = TextureFilter.Linear;
    parameters.minFilter = TextureFilter.Linear;
    generator.scaleForPixelHeight((int) size);

    return generator.generateFont(parameters);
}

I've also changed the parameter size to (int) Math.ceil(2 * Gdx.graphics.getWidth() / 9); and while that makes things a little bit smoother, it's nowhere near as crisp as some other texts are.

I'm wondering what I need to do in order to get smooth text along with how I can maintain that smoothness in different text sizes across different resolutions (I'm only targeting desktop right now since I'm really just messing around with Libgdx). It just seems like there are several different ways of doing this but I just want to know what's the best way to go about doing this.


texts: Canvas animation drops to 30fps every 3-4 seconds

texts:
Ok! I solved the problem.

Chapter One - Multiple Canvases

I started to make pong utilizing requestAnimationFrame and I noticed that the ball was stuttering and slowing down every 3-4 seconds.  So I implemented a crude FPS function to write the current fps to the screen and realized that the slow down was accompanied by an fps drop to 30fps. I thought it had something to do with my collision detection function, but it was not the case.

MarkR noticed that I had two canvases drawing and updating the player/ball separately, he suggested that I combine the two canvases into one. This produced better performance and now I could only see the slow-down/stuttering every 15~ seconds.  The problem was, the stuttering was still happening.

Chapter Two - Vsync, Chrome Developer Tools

In comes Dreta!  Dreta said that the fps was dropping to 30fps because canvas is trying to Vsync.  I had no idea what he was talking about, so I asked Mr. Google and found a really good explanation of how Vsync/double-buffering/triple-buffering works. It's a medium read, but it it definitely worth checking out if you want to learn more about how your graphics card/monitor works.

He also told me that I can look at the fps of the game in Chrome by using the Developer Tool(which can be accessed by right-clicking -> inspect element -> Timeline tab and clicking on the black circle at the bottom-- the circle will turn red when recording).  You can also look at the memory usage and I noticed that it was periodically shooting up to 4mbs of memory used.  Dreta suggested it was a memory leak--

Chapter Three - Memory Leaks

To locate a memory leak, use the following process: Found at microsoft site (http://msdn.microsoft.com/en-us/library/ms859415.aspx)
Find the memory leak – Detect the presence of a memory leak in the system, given a particular reproducible sequence. You should be able to identify a specific process, but demonstrating an overall increase in committed system memory can qualify a memory leak as well.

Isolate the memory leak – Determine the exact location in the source code where the un–freed allocation occurs. This can be a lengthy and tedious process, requiring specific tools, trial–and–error, and teamwork with the original author of the code.

Fix the memory leak – After the first two steps are completed, this is easy. Fixing the memory leak usually involves adding some code to free the memory in the questionable code path.

Dreta suggested that I use heap profiling to find memory leaks. I personally have not read up on it yet, but here's a link to chrome's explanation of heap profiling developers.google.com/chrome-developer-tools/docs/heap-profiling.

He said:

  Each time you update the player, you're creating a function. You probably want to change the Player class from:

this.update = function() {
$("#c").mousemove(function(event) {
  tempY = event.pageY;
});
this.y = tempY;
}

which creates a function every 16ms I update the player

  to:

var that = this;

$("#c").mousemove(function(event) {
  that.y = event.pageY;
});

This helped optimize the game further.

Chapter Four - I'm stupid, yeah... Chrome Tabs + Memory

I remembered that there was an issue with chrome with multiple tabs open, and I decided to quit out of and restart chrome anew. Behold! Constant 60fps and 1-2.5 mb memory usage(where it was 2-4mb memory usage before).

Moral of the story... close down all tabs and restart chrome before determining the problem, and use heap profiling to locate memory leaks.

Thank you everyone for your help!
I really do appreciate it.

Here's the code on github. Please let me know if you find more stupid mistakes or you have general tips on working with canvas/programming.

Feel free to email me yangsunwoo@gmail.com


texts:
I don't know if this question is more of Blender / 3D or gamedev / Unreal question, but I decided to ask here first.
What I want to do is make a character, simple robot. The bottom part rides around on wheels, controlled by keyboard, while the top part is a turret that turns towards player cursor (which works as a crosshair).
I made the model in blender, using only two bones, one for the bottom part and one for the turret. I created 4 poses for aiming each direction.
Then, in Unreal, I created 2D aim offset (as I only need one dimension). And after some coding, it works... almost. When I aim forward, and then to the right, it transitions, nice. Then towards the back, also works. But if I then move to the left, instead of rotating extra 90 degrees, the turrent rotates back forward and then to the left.
How can I fix it? Is there some settings in Unreal that I could use, or should I create the model in blender differently? Is the whole rig / bones solution not gonna work?
TLDR: I want the turret on my robot to rotate infinitely to whatever I aim at.


texts: Is there a way to increase the collision check efficiency of a system of n objects?

texts:
I'm making a game that consists of many onscreen objects, one of which is the player. I need to know which objects are colliding every iteration.

I made something like this:

for (o in objects)
{
   o.stuff();
   for (other in objects)
      if (collision(o, other))
          doStuff();

   bla.draw();
}

This has O(n^2), which I'm told is bad. How do I do this more efficiently, is it even possible? I'm doing this in Javascript, and n will usually be lower than 30, will it be a problem if this stays the same?


texts: Monogame pipeline is throws exceptions when trying to build .tmx files

texts:
I have correct referenced the monogame extended pipeline dll file to the monogame pipeline
the importers and processors of the .tmx file are not missing/unknown
but when I try to build the it it throws a System.notSupportedException
Here's a screenshot if that helps


texts:
I want to ask player to replicate a simple shape (triangle, square, star, anything that can be done in single stroke) with mouse or on a touchscreen.

Orientation matters, size does not.
Example:

Can anyone give me directions to what techniques can be used?


texts:
I am trying to understand : How does multi-sampling rasterization effects pixel shader output?

In a nutshell (i am skipping some steps to stay on point of question):

Vertex data is fetched.
Vertex shader is executed.
Rasterizer - rasterizes the geometric region, this is where it is decided which pixels are covered by the mesh/geometry.
Pixel shader is executed.

Multi-sampling Anti aliasing rasterization which is a rasterization rule, helps to decide weather full color output by pixel shader will be drawn on screen or it will be blended based on multi-sampling result (not by Blending-operation as I am aware that Blending(srcAlpha oneMinusSrcAlpha) happens later in the pipeline before pixel is drawn on screen).

Example MFAA : which uses sampling
https://www.youtube.com/watch?v=T2UMqmne4RA

My question is where does this sampling information get stored for every pixel and at which step of rendering pipeline, color given by pixel shader is changed based on sampling result done by rasterizer?

Thanks


texts:
I'm drawing a hierarchy of 3D objects in C# XNA where each objects has a transform that holds position, rotation and scale.

I get my expected results If I draw my objects from my root node in this fashion:

public void Draw(Matrix world, Matrix view, Matrix proj)
{
    foreach (var item in Children)
        item.Draw(world * item.Transform, view, proj);
}

However, I want to draw my objects by starting with a child node, drawing upwards, and achieving drawing from a child-object relative space. How would I do this?

I've tried a number of ways or drawing the parent nodes with inverted transform, but I'm not getting the correct results, I'm guessing I need to take care of the multiplication order, but I don't know what that is if I'm going up instead of down.


texts: How to proper manage a world composed by multiple scenes?

texts:
I have a UI-only scene for my game that have only Unity UI elements (those that need a Canvas), separate from the world scene.
In the UI scene I have a MonoBehaviour that manage all the effective actions and all the interactions between different UI elements, and In the world scene I have another manager responsible for controlling all the other things in the game scene.
This design worked pretty well until I faced the following situation: in a specific moment the player need to click in BoxColliders that are in the world scene but it is actually a UI-related action. This action of clicking in these BoxColliders are essentially the player clicking in buttons that in this case happen to be 3d objects that need to be composed in the environment, thus need to be in the world scene.
In the situation described above the clicks on those BoxColliders should be managed by the UI Manager, that is alive in the UI scene.
So the problem is: how should I approach this whole situation without breaking a lot of clean code rules? What is tipically done when developing in Unity to solve this kind of problem when you need a reference for an object that lives in another scene without keeping a hard reference for this object (or just calling GameObject.Find in the scene startup)?


texts: Fast, simple procedural 2d island generation

texts:
I need to generate tile data for an island based rpg, my goal is have something that looks like this (mountains not required):

For the past few days I have been trying to figure out a satisfactory way to generate tile data that will give me varied and natural islands, such as in the example above.

I've tried using Unity's Mathf.PerlinNoise but the results are far too random, and I can't see a way to get it to generate a single island.

Using LibNoise I was able to get slightly better results, although the generation seems to be significantly slower and perhaps better suited to 3d terrain. Similarly however, I can't see a way to set the Octaves/Frequency/etc, so that I get a nice single island each time.

While there are a fair amount of resources online for perlin/noise in general, it mostly seems to be aimed at 3d terrain and height, where I simply have a 2d array of int for my tile data, that maps to either water, sand or grass and needs to be generated in such a way that sand/grass are grouped together logically to form an island.

Any help would be greatly appreciated!


texts: How do I create a World Healing Wave effect?

texts:
I want to change my dark and depressing background to a happy grassy background, in real-time, such that the happy background is shown in a radius around a game character.

A forcefield of happiness, if you will.

How can this be done as performantly as possible when rendering to a canvas in a custom view?

UPDATE:
Here's how it works in my head:

    private int hModeX, hModeY;
    private float hModeRadius = 0.1f;
    private float hModeStart = 0;
    happyModeBg = Bitmap.createScaledBitmap(happyModeBg, getWidth(),getHeight(), true);
    hModeX = getWidth()/2;
    hModeY = getHeight()/2;

private void initHappyMode(Canvas canvas){
    hModeRadius = 75 * thread.getDelta();

    if(hModeRadius > 500) {
        hModeStart = timestep; //What is timestep?
    }

    //context.arc(x, y, radius, 0, 2 * Math.PI, false); <- your version
    canvas.save();
    canvas.drawArc(oval, startAngle, sweepAngle, useCenter, paint) // <- my version
    //context.clip(); <- dont know what this does or if there is an equivilant
    canvas.drawBitmap(happyModeBg, 0, 0, null);
    canvas.restore();
    //requestAnimationFrame(step); <- dont know what this does since I cant seem to find it for android

}

I'm using canvas.drawArc() to make a circle, but I'm definitely missing something.


texts: How to create realism similar to scenes rendered in Vray?

texts:
I am tasked to make a game which requires very realistic interior scenes. Unity's bedroom demo(http://blogs.unity3d.com/2015/11/10/bedroom-demo-archviz-with-ssrr/) really caught my eye. See I know how to code but I am not good at modelling in 3DS. I see some amazing images only generated in 3DS using vray. But those are static images and the moment the same models are imported into Unity, they end up looking unrealistic. But somehow in the demo, Unity managed to create a very realistic looking scene. So here are my questions :

How do I create realistic game scenes like the ones rendered by vray in 3DS Max? Is it possible to bake the image rendered by vray into a UV map? I couldnt find how to do this.
Also, pls refer to the image in this link, from evermotion http://www.evermotion.org/files/tutorials_content/uploads/nr_AI44_002_cam_001_pp_051.jpg and also this image : http://www.evermotion.org/files/tutorials_content/uploads/nr_ae44s02__0041_Layer_2_022.jpg. The second pic is very unrealistic but the first pic after vray rendering looks amazing. I am sure the bedroom demo assets looked the same and assuming the answer to my first question is it cannot be done, then how do I go about creating the same level of realism as in the first pic?

Guys this is a really long question and might not be clear. So sorry, tried to describe it the best I can. Appreciate any answer, tips or advice. Thanks guys


texts: I'm creating a labyrinth in opengl, and I'm trying to create a minimap. For that, I thought of creating a viewport inside of a viewport. I already tried following a tutorial from Lazy Foo, and I can create the second viewport, but instead of putting a map inside the second viewport, it  puts my whole game there. How can I fix this?


texts: Collision Scenario, Detection and Response

texts:
I have AABB, BSphere, a Polygon Soup, a Triangle, a Plane, a Point and a Ray objects with a collision test that returns 'bool' if two objects collide or not.

How can I use the above objects to implement an appropriate collision detection for my game?

It's a simple game where a player walks inside a rooms, and does the 'escape the room' scenario.

My levels is much like old Resident Evil with those 'static' cameras inside the rooms, some items inside containers, a monster and few items laying around so you can pick them up if you want.

A room is just a 'Sector' - it would be a 'Polygon Soup'
A player and all Entities are AABB

My question is:

Is my collision tests that returns (true/false) is enough for appropriate collision detection or do I need extra  info like the normal vectors?
Should I go writing this myself or stop playing around and use some open/free physics engine for a simple game like this?


texts: Why do game engines convert models to triangles instead of using quads?

texts:
I've worked using Maya for animation and more film orientated projects however I am also focusing on my studies on video game development. Anyways, I was talking with one of my professor and we couldn't figure out why all game engines (that I know of) convert to triangles.

Anyone happen to know why game engines convert to triangles compared to leaving the models as four sided polygons? Also what are the pros and cons (if any) of doing this?


texts: How do I avoid obstacles on a predefined path?

texts:
I want is a character to walk along a path defined as a waypoint sequence. For example, a soldier patrolling around a castle.

However, I want the soldier to avoid (dynamic) obstacles, without deviating from the path too much.

How can this be done?


texts:
On my quest to understand Unity in a zero to hero sort of manner, I've run into a new problem I can't seem to really solve.

From computer science I know that updating GUI on the same thread as everything else is the worst thing you can do, so naturally I'd like to start a separate thread to update GUI Elements. I am not sure if this is how you are supposed to do it in Unity, or if it takes care of that on it's own but my guess is it doesn't.

So I went to Google and after a bit I found Color.Lerp(Color,Color,float) which seemed to do the job nicely. But applying it as a function over time have been harder than I anticipated. Below you see my code:

using UnityEngine;
using System.Collections;

public class GUITextTriggerController : MonoBehaviour
{
    public GUIText guiText;
    public float fadeDuration;
    private bool IsTriggered;

    public void Start()
    {
        guiText.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
        IsTriggered = false;
    }

    void OnTriggerEnter(Collider other)
    {
        if (IsTriggered == false)
        {
            IsTriggered = true;
            StartCoroutine(UpdateTextColor());
        }
    }

    IEnumerator UpdateTextColor()
    {
        yield return new WaitForEndOfFrame(); // So that I return something at least.
        float t = 0;
        while (t < 1)
        {
            guiText.color = Color.Lerp(new Color(1.0f, 1.0f, 1.0f, 0.0f), new Color(1.0f, 1.0f, 1.0f, 1.0f), t);
            t += Time.deltaTime / fadeDuration;
        }
    }
}

My understanding of Unity is still very much beginner so bear with me. From my understanding, using Co-routines and yield is essentially Unity's answer to Threading (correct me if I am wrong) so I thought the above could do the trick but rather than changing over time, the texts color changes instantly as soon as I enter my trigger volume.