texts: How would I successfully split a vector to increase game performance?

texts:
Okay so I have a vector for all of the monsters that are spawned in my game. All of these monsters are in a single vector and are "active" according to what zone they are in relative to the player's zone.

If the player is in the same zone as the monster, then have the monster move around and commit actions such as attacking other monsters or the player.

This is all done on a very powerful computer: my main computer.

-BUT-

If I were to attempt using this game on my medium-end computers, the game runs on a steady 2 FPS(where on the main does 50+)

What I attempted is splitting the vector into an array of vectors
vector SpawnList to vector SpawnList[100] as a quick example

Now with this code the monsters are in separate vectors according to their zones(zone is the area that the monster is spawned in)

Note: I use Ogre3D for rendering and bulletPhysics for the physics, and I haven't figured out a way to split the monsters' rendering accordingly.

And with this new idea, my main computer even faces severe slowdowns.

I am wondering if maybe the vectors have been created wrong or it is not a good idea to have an array of vectors.

Is there a better way of having the monsters grouped together where the performance is almost maximum on any computer?

EDIT: I have Profiled my code and here are the updated results. I hope they are of help to this situation: http://pastebin.com/v0PFQf0X


texts: How do I lock drawn lines to be orthogonal to an existing one?

texts:
I'm making a 2D game in Corona for Android/iPhone that is similar to Volfied. In my game, the user has to touch the screen to draw a line for the character to move along. How can I force the lines to be orthogonal, as opposed to being free-drawn?

I can detect the swipe's direction with atan2 and the difference of X and Y, but I am having trouble determining the pivot points of the line. How can I determine when the line should make a turn?

You can see what I am trying to accomplish in this video of Volfied gameplay.


texts:
Possible Duplicate:
  Moving from A(x,y) to B(x1,y1) with constant speed?

My problem is that I can't get my bullet movement right. The current update code I have for it is:

speedX = deltaX;
speedY = deltaY;

x += speedX / 100;
y += speedY / 100;

deltaX and deltaY are the distances needed to travel on each axis, which I get from the bullet starting coordinates and the mouse coordinates. I use the divider to prevent the bullet just teleporting to it´s destination.

The problem here is that when you press far from the bullet start point the bullet goes quickly. But when you click near the bullet start point it goes really slow. I can´t figure out what I should do to repair it.


texts: How to Create Device with D3DFMT_A32B32G32R32F

texts:
I'm trying to create a DirectX9 device to copy video frame data from one memory buffer to another while processing it through a HLSL shader. I will need half-float or float precision for each channel. For now, D3DFMT_A32B32G32R32F will do.

I can create the device when passing D3DFMT_X8R8G8B8 in the presentation parameters, but it will fail when passing D3DFMT_A32B32G32R32F. I don't want to display this on the screen nor convert it between formats. Both the source and destination texture buffers have the same format.

How can I create a device that will allow me to display the output into another texture of type D3DFMT_A32B32G32R32F?


texts:
What is the best approach to designing an AssestManager that will hold references to graphics, sounds, etc. of a game?

Should these assets be stored in a key/value Map pair?  I.e. I ask for "background" asset and the Map returns the associated bitmap?  Is there an even better way?

Specifically I'm writing an Android/Java game, but answers can be generic.


texts: Some UI button script not working in apk build!

texts:
There are a lot of posts regarding this problem in various website and even in this one but no one has given a feasible solution to this problem. I have a button that has a custom sprite. I also have a custom script attached to that button which when pressed down (IPOINTER DOWN) changes the color of particular sprite renderer. All this works in pc but not on apk build. Why?
I have two canvas, so I thought there might be raycasting issues, so I disabled one but still no luck.
The buttons are in world space in canvas. So, I thought I might not use a canvas but IPointer only works on clickable UI elements.
The scene looks like this, star is the clickable button and the borders are a sprite(district).
The script attached to the button is:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;// Required when using Event data.

public class OnHighlighted : MonoBehaviour, IPointerClickHandler, IPointerDownHandler// required interface when using the OnPointerEnter method.
{
    // HoldByeach button

    private GameObject correspondingImage;

    void Start ()
    {
        correspondingImage = GameObject.Find(gameObject.name);
    }

    public void OnPointerClick(PointerEventData pointerEventData)
    {
        GetComponent<Image>().color = new Color32 (36,53,53,255);
        correspondingImage.GetComponent<SpriteRenderer>().color= new Color32 (36,53,53,255);
    }

    public void OnPointerDown(PointerEventData pointerEventData)
    {
        GetComponent<Image>().color = new Color32 (47,255,0,255);
        correspondingImage.GetComponent<SpriteRenderer>().color = new Color32 (47,255,0,255);
    }
}


texts: I am starting to try and figure out polygon collision detection in my Android game. I am currently doing pixel level collision detection and it just seems to be too slow (though it works). I was looking at this tool and it seems like it would be really handy to give me a set of vertices for my images. Does anyone have any ideas about how I should go about implementing this? Basically once I have a list of vertices that form a polygon, how can I detect if polygon A intersects polygon B? I can see that these vertices can be used easily with Box2D but I want to try to do this without Box2D first.


texts:
For a game of table tennis, the goal is that when the player hits the ball, the opponent (the computer) will move to the position where the ball will land in order to hit it back to the player.

Said another way, given a ball in 3D space with an XYZ vector for its velocity, how can I calculate an XYZ velocity vector that will result in the position of the computer player being approximately where the ball will land?

For my coordinate system is, Y is up/down, Z is left and right of the table, and X is forward backward (toward or away from the table)...  So, I know I can simply just set the player's z velocity to match the ball's z velocity to match the direction, but I need to know how to find the appropriate X velocity so that the player will move backward / forward depending on how fast the ball is traveling + taking into account the height of the ball + gravity, etc.

UPDATE

Seeing that the initial ball height is different than the table and the floor, I did some research and learned that the quadratic formula was the best way to solve this problem...

serveToTable = (-ball.vel.y + Math.sqrt((ball.vel.y * ball.vel.y) - (4 * (gravity * 0.5) * (tableY - ball.pos.y)))) / gravity;
tableToFloor = (-ball.vel.y + Math.sqrt((ball.vel.y * ball.vel.y) - (4 * (gravity * 0.5) * (floorY - ball.pos.y)))) / gravity;
duration = serveToTable + tableToFloor;
player.pos.x = ball.pos.x + (ball.vel.x * duration);
player.pos.z = ball.pos.z + (ball.vel.z * duration);

This, kind of works..  But it seems the player will go to the ball 2-4 times and then miss the ball.  Sometimes by quite a lot.


texts: Improve (adding randomness) minmax algorithm for Connect Four

texts:
I have implemented the minmax algorithm for the Connect Four game. It works well (almost...), but if the player does the same moves, the computer will do the same moves as well, for each match. There is no randomness in the computer choices. This is the code for the minmax:

private int[] minmax(int depth, Seed player) {
    // Generate possible next moves in a List of int[2] of {row, col}.
    List<int[]> nextMoves = generateMoves();

    // mySeed is maximizing; while oppSeed is minimizing
    int bestScore = (player == mySeed) ? Integer.MIN_VALUE : Integer.MAX_VALUE;
    int currentScore;
    int bestRow = -1;
    int bestCol = -1;

    if (nextMoves.isEmpty() || depth == 0) {
        // Gameover or depth reached, evaluate score
        bestScore = evaluate();
    } else {
        for (int[] move : nextMoves) {
            // Try this move for the current "player"
            cells[move[0]][move[1]].setContent(player);
            if (player == mySeed) { // mySeed (computer) is maximizing player
                currentScore = minmax(depth - 1, oppSeed)[0];
                if (currentScore > bestScore) {
                    bestScore = currentScore;
                    bestRow = move[0];
                    bestCol = move[1];
                }
            } else { // oppSeed is minimizing player
                currentScore = minmax(depth - 1, mySeed)[0];
                if (currentScore < bestScore) {
                    bestScore = currentScore;
                    bestRow = move[0];
                    bestCol = move[1];
                }
            }
            // Undo move
            cells[move[0]][move[1]].setContent(Seed.EMPTY);
        }
    }
    return new int[] { bestScore, bestRow, bestCol };
}

/**
 * Find all valid next moves. Return List of moves in int[2] of {row, col}
 * or empty list if gameover
 */
private List<int[]> generateMoves() {
    List<int[]> nextMoves = new ArrayList<int[]>(); // allocate List

    boolean[] columns = {false,false,false,false,false,false,false};

    // If gameover, i.e., no next move
    if (hasWon(mySeed) || hasWon(oppSeed)) {
        return nextMoves; // return empty list
    }

    // Search for possible moves and add to the List
    for(int row = GameMain.ROWS - 1; row >= 0; row--) {
        for(int col = 0; col < GameMain.COLS; col++) {
            if(columns[col] == false && cells[row][col].getContent() == Seed.EMPTY) {
                columns[col] = true;
                nextMoves.add(new int[] { row, col });
            }
        }
    }

    return nextMoves;
}

/**
 * The heuristic evaluation function for the current board
 *
 * Counts open 3 in a row for each player
 */
private int evaluate() {
    int score = 0;

    // very good move for computer
    if(hasWon(mySeed)) {
        return Integer.MAX_VALUE;
    }

    // very bad move, player wins!
    if(hasWon(oppSeed)) {
        return -Integer.MIN_VALUE;
    }

    // counts open 3 in a row for the computer and the player
    int myThree = openThree(mySeed);
    int oppThree = openThree(oppSeed);

    score = myThree - oppThree; // if negative, player advantage, otherwise computer advantage

    return score;
}

I have omitted the openThree method for brevity.

Bug: the computer skips his turn when is destined to lose.

Ps: the main code for minmax is taken from a tutorial.

This is a situation in which the computer skips his turn:

Red is the player, blue is the computer.

The computer does not freeze, he can continue to play, but not always. For example in this situation if i place my red circle over 15, the computer will skip his turn again, while if i place my red circle over 9, the computer will win placing his blue circle over this last one placed by me.

Project zip


texts:
I have a cube in opengl. It's position is determined by multiplying it's specific model matrix, the view matrix, and the projection matrix and then passing that to the shader as per this tutorial (http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/). I want to rotate it relative to the camera.

The only way I can think of getting the correct axis is by multiplying the inverse of the model matrix (because that's where all the previous rotations and tranforms are stored) times the view matrix times the axis of rotation (x or y).

I feel like there's got to be a better way to do this like use something other than model, view and projection matrices, or maybe I'm doing something wrong. That's what all the tutorials I've seen use.

PS I'm also trying to keep with opengl 4 core stuff.

edit: If quaternions would fix my problems, could someone point me to a good tutorial/example for switching from 4x4 matrices to quaternions. I'm a little daunted by the task.


texts: Method to make character roam map isn't working

texts:
I'm an absolute beginner in Unreal Engine, so sorry for any strange mistakes, formatting, etc. I'm trying to make a game for a project where an enemy chases the player through a maze when it spots the player, but when there's no player it roams around the maze. I have the following blueprint:

Every time I run it, it has varying outcomes. Sometimes the enemy will move around a few times, then randomly stop. It won't return a fail message or move. Other times, it will send a single fail message as soon as the program is run, then not return anything else. And other times, it won't send anything at all or move and just stand there. It'll also sometimes simply turn ~95 degrees to the left then stop.
There's also the issue that the enemy takes the same path every trial, even though it's supposed to choose a random point and move to it.
The enemy easily chases the player through the maze and won't get stuck anywhere, but for some reason the enemy stops moving when it's executing the roam method.
I tried adjusting the radius in the GetRandomPointInNavigableRadius part, but that didn't affect anything. I also tried making the character smaller in case it was getting stuck on certain turns, but that also didn't affect it. Removing the delay made it work a few times, but then it went back to not working after a few trials.
Here's the rest of the code for reference:

and a picture of the maze:

and the enemy's width relative to the maze path:

Thank you for any help!


texts: Issue creating a dynamic seemless cube map

texts:
I have a function for building a cube map, given a location in space. I also have a system for displaying cubemaps (either loaded from images or given as a texture handle), and they work fine and are used for displaying things such as a skybox as well as are used for reflections.
The issue is, when trying to create a cube map on the fly,  I can't get it to be seemless, and it ends up looking like it is zoomed in, thus the right side of the image isn't complete.
This is what my scene looks like at an FOV of 90:

The left pillar isn't fully visible on the front side of the cube map, as well as the right pillar isn't even on that texture at all. The texture appears "zoomed in" so the last part of the image on the right side isn't even visible. This pattern occurs for each side of the cubemap.
If I increase the camera's FOV to 100, the pattern becomes even more clearer:

The way I'm trying to capture a cubemap is like this:
// Create camera, position at 0,0,0, rotate 0,0,0, 90 FOV
DCamera camera(QVector3D(0,0,0), QVector3D(0,0,0), 90.0f, 0x0004, 1.0f );
camera.setPerspective(512,512);

glBindTexture(GL_TEXTURE_CUBE_MAP, cubeTextureTarget);
for (int x = 0; x < 6; x++)
{
    QQuaternion q;
    switch (x) {
    case 0:
        q = QQuaternion::fromAxisAndAngle(0,1,0,90);
        break;
    case 1:
        q = QQuaternion::fromAxisAndAngle(0,1,0,-90);
        break;
    case 2:
        q = QQuaternion::fromAxisAndAngle(1,0,0,90);
        break;
    case 3:
        q = QQuaternion::fromAxisAndAngle(1,0,0,-90);
        break;
    case 4:
        q = QQuaternion::fromAxisAndAngle(0,1,0,0);
        break;
    case 5:
        q = QQuaternion::fromAxisAndAngle(0,1,0,180);
        break;
    }

    QMatrix4x4 mat;
    mat.rotate(q);
    mat.translate(camera.getPosition());
    camera.setModelMatrix(mat);

    /*... RENDERING LOGIC ...*/
}

When I set the camera's perspective projection, I do this:
void DCamera::setPerspective(int w, int h)
{
    projection = QMatrix4x4();
    projection.perspective( (fov), (float)w/(float)h, 1.0f, 1000000.0f );
}

In case it matters, my cubemap texture is formatted like this:
glBindTexture(ftype, cubeTextureTarget);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
for (int x = 0; x < 6; x++)
    glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+x, 0, GL_RGBA32F, WindowWidth, WindowHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT6, GL_TEXTURE_CUBE_MAP_POSITIVE_X, cubeTextureTarget, 0);

Of course, I increment the texture target within the actual loop for rendering into the cubemap

I'm having trouble finding the proper resources for creating a cubemap. 99% of the hits I'm getting is for rendering a cubemap, not generating one...


texts: Best approach for destructible car in Unity

texts:
I'm developing a simple racing car game.
I'm wondering what is the best approach to manage visually car destruction.
For instance: i think one option (expensive) is to build car 3d model with 'separate' mesh, each for any component (bump, door, glass) and relative cooliders..
Other options ?
Thanks


texts: Two game object efficient and fast on-off switch

texts: I have two game-object, on GUI button click i am toggle between them but the problem is one game-object which is small contains less vertx etc., is loading fast while the other which heavy taking time. How do i efficiently and quickly load it ? I don't want to show loading window i want to load that game-object quickly?


texts:
Could somebody point me to resources that would explain what full screen actually is?

What's the point of it? It seems to be more than just a window that has the client are taking the whole screen.


texts: What are the minimum requirements for UDK on iOS?

texts:
Infinity Blade asks for 3GS or better devices, which I'm told is because it uses OpenGL ES 2.

Will every game made with the iOS version of the UDK only work with 3GS devices and up?


texts: Why is my client laggy despite 60 update packets a second?

texts:
I am developing a small multiplayer game with XNA. It's a usual client-server architecture -- I have a server and many clients communicating with it through UDP (via .NET's Socket class). These clients send data to the server (for example, the player's position) and the server handles it and decides what to do (send it to every other client or drop it).

What's the most efficient "correct" way to send position of moving object from a client to a server? Currently, I send the client's ID and player position 60 times a second (XNA's default update rate) while a player is moving. When I see my own player on the screen, it moves very smoothly, but other don't, despite every client having the same update rate. What am I doing wrong?


texts:
How can we get one way collisions using Tilemaps in Unity?

There doesn't seem to be much online regarding this topic yet.

From this link: https://answers.unity.com/questions/1471156/how-to-make-one-way-platforms-using-a-tilemap.html, I got that we should use a Tilemap Collider 2D for collisions and not use a Composite Collider 2D. Finally, we need a Platform Effector 2D with One-Way enabled.

However, the resulting tiles all behave like normal tiles in that collisions occur along all edges.

Here's what the inspector looks like for the tile map in question.

The scene setup looks like this:

It looks like the tiles in the scene all have collision edges all the way around.

What needs to be done to allow for one way platforms? Thanks!

EDIT

Here is the setup of the character:

Here is a view of what it looks like in game:
When jumping, the character unfortunately collides with the block above and is unable to pass through.


texts: Collision not working in phaser node multiplayer

texts:
I'm writing a tank trouble clone just for fun using phaser and node, so this is my tank instantiation

tank = game.add.sprite(Math.random() * 800, Math.random() * 640, 'tank');
tank.anchor.setTo(0.5, 0.5);
tank.scale.setTo(0.5, 0.5);
game.physics.arcade.enable(tank);
tank.body.immovable = true;
tank.body.collideWorldBounds = true;

This is how an enemy tank is defined at the client

var Enemy = function (game, id, x, y, angle) {
    this.id = id;
    this.x = x;
    this.y = y;
    this.angle = angle;
    // set the tank properties
    this.tankEnemy = game.add.sprite(this.x, this.y, 'enemy');
    this.tankEnemy.anchor.setTo(0.5, 0.5);
    this.tankEnemy.scale.setTo(0.5, 0.5);
    // game.physics.arcade.enable(this.tankEnemy)
    // this.tankEnemy.body.immovable = true;
    // this.tankEnemy.body.collideWorldBounds = true;
}

The problem is in the above case I have enemy tank at the client as a non body (which means I'm checking the collision between a "body" and a "non body") and when I try to check collision

game.physics.arcade.collide(tank, enemies[i].tankEnemy);

It doesn't work.

So I tried making it a body by un-commenting the code, now the enemy tank behaves more weirdly than before. Whenever a client moves, it gains velocity for other clients, making it go beyond the map and becoming invisible. Whereas I'm just changing the coordinates for other clients -

function tankUpdate (data) {
    // when the update event is fired
    var moveTank = findTank(data.id);
    if (!moveTank) {
        console.log('tank not found');
        return;
    }
    // update the tank location
    moveTank.tankEnemy.x = data.x;
    moveTank.tankEnemy.y = data.y;
    moveTank.tankEnemy.angle = data.angle;
}

This is how a client emits update event -

socket.emit('update location', {x: tank.x, y: tank.y, angle: tank.angle});

The server in turn broadcasts this update, which leads to the calling of tankUpdate.

What is the right way to implement this? I just want to prevent the collision between tanks.

EDIT

After a long discussion with @Hexus on slack we concluded with these points which solved the issue -

I was not sending the velocity to the server. (@Hexus mentioned it in his answer).
I was setting the sprite.x property which was conflicting with the position of body. sprite.body.x is the right property to set.
I was updating the position and velocity as soon as I received from the server which leads to a shaky and not-so-smooth movement. The idea is to create a buffer and then update.
Lastly but the most important, if you are testing the game without two instances running on the same machine/browser make sure you set game.stage.disableVisibilityChange = true; in your create method.

Again thanks a lot to @Hexus for helping!


texts: How do I organise the code for an episodic game?

texts:
We're working on a game that's going to be split into three episodes, which we'll release one after another, as they get finished. I'm worried that our typical somewhat-monolithic architecture is not a good fit for this model.

The game code consists of basically three parts:

_Engine_: Renderer, physics, UI etc.
_Logic_: The concrete scenes and entities.
_Scripts_: Levels and dialogs.

_Engine_ and _Logic_ are native code, _Scripts_ are shipped with the game data and executed at runtime.

I think I can safely assume that:

_Engine_ will be the same for all episodes.
_Logic_ will be largely the same for all episodes. but have some specific parts.
_Scripts_ will differ significantly for each episode.

I see three options for organising this:

Create episode two by copying all the code from episode one, adjusting as needed. I believe this is how sequels are typically done; id Tech 4 appears to be part of the "Doom 3" code, not clearly separated.
Keep all the shared code in one place, making it possible for each episode to override parts of it.
Create a reusable engine, completely separating _Engine_ from _Logic_ and _Scripts_, to be used by all episodes. Shared _Logic_ will either be duplicated for each episode, or generalised and moved into _Engine_. This is how the folks behind "Penumbra" apparently did it.

The major drawback I see with the first approach is that I'll have to back-port any fixes and refactoring to episode one, manually.

The major drawbacks I see with the second approach is that it's more upfront work, and that I'll have to make changes to already released episodes, requiring me to keep testing them.

The major issue I have with the third approach is that it's a big amount of upfront work. and smells a bit like premature generalisation. I cannot fully predict what changes I'll have to make for episodes two and three; it depends on their unfinished design. On the other hand, it would probably give us more flexibility, and speed up development, later.

What is the typical way of organising the code for episodic games? Do I have options, other than the three I can think of?


texts:
I'm hoping someone else has experienced this and subsequently found a solution as I am about to light my own hair on fire in frustration.

Simply put, I was creating a Cocos2D app using XCode 3.2.6 and SDK 4.2. I used two devices for testing: iPhone 3GS and iPhone 4, both at IOS 4.2, I believe. When testing on either device I was getting solid 60 FPS performance.

The disaster first hit when I upgraded to XCode 4.2. With no trouble I was able to open my project directly into this new version and run it. Everything is the same except that I am now in XCode 4.2. To my shock and horror I found that I was now getting FPS in the 45 to 50 range, and it will drop into the 30's at times, none of which ever happened before.

At this point I decided to upgrade to Lion, XCode 4.3, and SDK 5.1. Unfortunately, this changed nothing.

I then upgraded both phones to the latest IOS, and still the performance problem continued.

Finally, I upgraded to the latest version of Cocos2D, but to no avail.

I have tried a number of remedies that involved release versus debug modes, compiler settings, etc. Nothing helps.

I found something that might be a hint, but I do not know enough about Open GL ES at this time for it to make a lot of sense. On another forum someone had complained about the very same problem and said that if they disabled Vertex Buffer Object (VBO) support, it resolved the problem. I found where this is enabled within Cocos2D, disabled it, and to my surprise I was back up to 60 FPS. The app does not perform as strong as it did when compiled under XCode 3.2.6, but it is much better with VBO support disabled under XCode 4.3. The problem with this is that disabling VBO support is not recommended as it is suppose to enhance performance when enabled.

Some of the testing I have done seems to point to graphics being the issue. When the app does drop into the 45 FPS range all I have is 12 to 20 sprites moving on the screen. If I remove these sprites and allow everything else to continue operating, I get back to 60 FPS, even with VBO enabled. When I was developing under XCode 3.2.6, I at times would have 100+ sprites moving along (both in view and out) and the the FPS remained at 60.

So in short (sorry, too late for that), does anyone have any idea how the exact same code would run great when compiled through XCode 3.2.6, but rather badly under XCode 4.3? I have tried many different compiler settings to no avail. My guess is that there is some simple setting somewhere that perhaps defaults to a different value between XCode 3 and XCode 4.

Any help would be appreciated.

Thanks!


texts: how to calculate smooth normals for 10,000,000 vertices?

texts: I am trying to calculate smooth normals with angle weight for a huge mesh with 10 million vertices. Currently, i am using map/dictionary to store the traingles connected to a vertex. That is, for each vertex,  I loop through the entire mesh to find triangles connected to a single vertex and store them in a map for that vertex. I am doing this for 10 million triangles. So, i iterate 10 million x 10 million times to calculate normals for the whole mesh. It takes around 8 seconds to create the map itself. I also have to animate this mesh dynamically calculating the normals for 10 instances. Is there a possibility to move these computations to shaders?


texts: Can I use my self made piano version of a popular copyrighted song as my game background music?

texts:
I am making a game, the theme of the game is kind of romantic, and I, myself, have made a piano version of a modern pop song that would fit with that theme. The song in question is still under copyright, and I'm not the owner of the copyright.

Can I use it as a background in my game? Would there be any legal issue regarding copyright/IP etc?


texts: When mapping the surface of a sphere with tiles, how might you deal with polar distortion?

texts:
It's easy to deal with the way locations interact on a clean Cartesian grid.  It's just vanilla math.  And you can kind of ignore the geometry of the sphere's surface for a bunch of it if you want to just truncate the poles or something.  But I keep coming up with ideas for games where the polar space matters.  Geo-coded ARGs and global roguelikes and stuff.

I want square(ish?) locations -- reasonably representable by square tiles of the same size across the globe, anyway.

This has to be a solved problem, right?

What are the solutions?

ETA:

At the equator -- and assuming that your square locations are reasonably small, it's close enough to true that you can get away with having one square in the rows north and south of the most equatorial row.  And you could probably get away with that by just hand-waving the difference up to like 45-degrees or so.  But eventually, you need to have fewer squares in a pole-ward circumferential row.  If I reduce the length of the row by one and offset the squares by 1/2 then they're just like hexes  and it's relatively easy to do the coding to keep track of the connections.  But as you get pole-ward, it gets more and more extreme.

Projecting the surface of the world onto the surface of a cube is tempting.  But I figured there must be more elegant solutions already in use.

If I did the cube thing (not dissecting it further through geodesy) Are there any pros and cons related to placing the pole at the center of a face or at the vertex of three sides?


texts: Sampler referencing in HLSL - Sampler parameter must come from a literal expression

texts:
The following method works fine when referencing a sampler in HLSL

    float3 P = lightScreenPos;
sampler ShadowSampler = DPFrontShadowSampler;
float depth;

if (alpha >= 0.5f)
{
    // Reference the correct sampler
    ShadowSampler = DPFrontShadowSampler;

    // Front hemisphere 'P0'
    P.z = P.z + 1.0;
    P.x = P.x / P.z;
    P.y = P.y / P.z;
    P.z = lightLength / LightAttenuation.z;

    // Rescale viewport to be [0, 1] (texture coordinate space)
    P.x = 0.5f * P.x + 0.5f;
    P.y = -0.5f * P.y + 0.5f;

    depth = tex2D(ShadowSampler, P.xy).x;
    depth = 1.0 - depth;
}
else
{
    // Reference the correct sampler
    ShadowSampler = DPBackShadowSampler;

    // Back hemisphere 'P1'
    P.z = 1.0 - P.z;
    P.x = P.x / P.z;
    P.y = P.y / P.z;
    P.z = lightLength / LightAttenuation.z;

    // Rescale viewport to be [0, 1] (texture coordinate space)
    P.x = 0.5f * P.x + 0.5f;
    P.y = -0.5f * P.y + 0.5f;

    depth = tex2D(ShadowSampler, P.xy).x;
    depth = 1.0 - depth;
}

// [Standard Depth Calculation]
float mydepth = P.z;
shadow = depth + Bias.x < mydepth ? 0.0f : 1.0f;

If I try and do anything with the sampler reference outside the if statement then I get the following error:

Sampler parameter must come from a literal expression

This code demonstrates that

    float3 P = lightScreenPos;
sampler ShadowSampler = DPFrontShadowSampler;

if (alpha >= 0.5f)
{
    // Reference the correct sampler
    ShadowSampler = DPFrontShadowSampler;

    // Front hemisphere 'P0'
    P.z = P.z + 1.0;
    P.x = P.x / P.z;
    P.y = P.y / P.z;
    P.z = lightLength / LightAttenuation.z;
}
else
{
    // Reference the correct sampler
    ShadowSampler = DPBackShadowSampler;

    // Back hemisphere 'P1'
    P.z = 1.0 - P.z;
    P.x = P.x / P.z;
    P.y = P.y / P.z;
    P.z = lightLength / LightAttenuation.z;
}

// Rescale viewport to be [0, 1] (texture coordinate space)
P.x = 0.5f * P.x + 0.5f;
P.y = -0.5f * P.y + 0.5f;

// [Standard Depth Calculation]
float depth = tex2D(ShadowSampler, P.xy).x;
depth = 1.0 - depth;
float mydepth = P.z;
shadow = depth + Bias.x < mydepth ? 0.0f : 1.0f;

How can I reference the sampler in this manner without triggering the error?


texts: Problem when trying to use rb.MoveRotation in Unity

texts:
OK so I learned that rb.MoveRotation is different from rb.transform.Rotate(). But I am having trouble using it and hoping you can help me.

I usually use transform.translate(Vector3.forward)  (after using transform.Rotate(x,y,z)) , so that I know that will always make object move in the direction its facing. But this isnt working when I use rb.MovePosition. The object rotates when i remove the MovePosition line, but then for some reason doesn't when its there. I've tried multiple things as you'll see in the code.

I cant understand also why, if I use the bottom commented attempt in my code, and then press D in game, it will go in the direction its facing and then get
stuck. I've commented in my code to try to explain whats happening.

What is the correct way to move the position of the player now I am using MoveRotation? I want to base my movement of the direction that the object is facing and not in world coordinates.

Thanks

    void HandleKeys()
{
    if (Input.GetKey(KeyCode.A))
    {
        if (!facingLeft)
        {
            rb.MoveRotation(Quaternion.Euler(0,-90,0));
            facingLeft = true;
        }
        //rb.transform.Translate(Vector3.forward * speed * Time.deltaTime); // if I remove this line, the character does turn and face left . But when its in he doesn't and both keys make him move right (and face right)
        // also tried:
        //rb.MovePosition(transform.position += Vector3.forward * speed * Time.deltaTime); // this results in it going Vector3.forward in world coords
        //**rb.MovePosition(transform.position += rb.transform.forward * speed * Time.deltaTime); // this makes him go RIGHT>?? and the objects facing RIGHT why????
    }
    if (Input.GetKey(KeyCode.D))
    {
        if (facingLeft)
        {
            rb.MoveRotation(Quaternion.Euler(0f, 90f, 0f));
            facingLeft = false;
        }
        rb.transform.Translate(Vector3.forward * speed * Time.deltaTime); // if i leave this in, and the one marked * above, then it works but only once, so if I press A then, D he heads right but wont turn round, if I press D first he just goes right
    }
    if (Input.GetKeyDown(KeyCode.Space) && IsGrounded())
    {
        rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
    }

}


texts: Quadtree terrain splitting - I don't get it

texts:
Most of the papers i've read base their terrain in some form or another on a quadtree. See this at page 38:

http://www.slideshare.net/repii/terrain-rendering-in-frostbite-using-procedural-shader-splatting-presentation?from=ss_embed

Doesn't the first point contradict the bottom two? How can you have a fixed 33x33 vertex grid per leaf yet talk about adaptive division in a quad tree? The terminology is confusing and i'd appreciate any clarity on this!

Here are my assumptions:
Re-placing the patches everytime the quadtree changes would be a hit wouldn't it?

Quadtree starting at terrain bounds.

Iterate down to observer location.

Constrained version (no more than 1 level difference between neighbours)

Frustum cull.

Place terrain patch in each resulting leaf, where the scale differs but the resolution is always 33x33.


texts: Smooth out movement of the snake in a 2d Snake game

texts:
I am working on a 2-D snake game in C++ with the SFML library. I would like to smooth out the movement of my snake as it looks extremely choppy currently.
How the Snake moves
The snake is made up of a list of parts. If I want to move the snake, I simply remove one part from the back (.pop_back()) and then add a new part in the front accrding to the velocity. This works perfectly. The speed of the snake must be the same as the distance between the parts.  So if the distance is 15, the will be 15. But a speed of 15 is extremely high, so I need to only update the snake every few frames or use sf::Sleep(). Since the snake moves such a high distance every frame, the movement doesn't look smooth at all. And since the speed must be equal to the distance between the parts, reducing the speed doesn't work too. How can I come about tackling this?


texts: What does this Yellow Outline represent in Unity Text Mesh Pro?

texts: What does this Yellow Outline Represent around Text Mesh Pro Text objects in Unity?  I don't see any regarding them in the inspector making it so that I have eye-ball it in the scene view to make it smaller. But it's caused me nothing but trouble such as causing overlap issues with other Text Mesh Pro Text objects making only the most recently rendered button usable. What is it? And how do I modify it's values and/or make it go away?


texts: What are some valuable conferences for game developers?

texts:
Lately I was thinking of visiting a Game Developer Conference and so I search the Internet, but I didn't find a thorough list of available Conferences. Now I know some of them, like the GDC in San Francisco but I was wondering, what other Game Developer Conferences are out there.

So my question is: What Game Dev Conferences do you know, that are valuable for Game Developers and Game Designers? Have you visited one of these Conferences yourself? Is there a skill level needed to appreciate such a Conference?

I am aware, that there is no "true" answer to this question, but I think, that an overview over existing Conferences could be usefull for all levels of game developers.


texts: Managing Character Bones in Unity 3D at runtime

texts:
I'm trying to do the following:

Have a rotation only (no transforms) with x,y,z.
Each rotation axis above respectfully having a minimal and
maximum rotation angle with a current angle.
This will be for each bone of said character's skeleton, note
the weights will be applied as per usual when doing animations,
however there will be no animation data.

bones to rotation info, apply changes, info back to bones, apply changes, info back to bones...

Q: SetBones And GetBones, how would I get and set the bone data?

//imports...

public class BoneControllerClass : MonoBehaviour {
    //used to modify the bone data struct for each bone (ediable via Unity Editor)
    public BoneConstraintData[] BoneData;

    //gets refs to bone data from character
    public Bones[] GetBones(){ /*..Help..Here..*/ }
    public BoneConstraintData[] SetBoneConstraints(BoneConstraintData[] _BoneData) { /*..CODE..HERE..*/}
    public void SetBones(BoneConstraintData[] _BoneData){ /*..Help..Here..*/ }

    public void Start(){
        // generate bone data with zeros
        BoneData = GetBones();
        // set bone data constraints
        BoneData = SetBoneConstraints(BoneData);
    }

    public void Update(){
        // do something for smooth clamping, optionally this could be applied above as with Delta Time...
        // CODE EXAMPLE HERE, optionally another function can be added...
        BoneData[0].currentXAngle = 12.0f * Time.DeltaTime; //or BoneDataNew[0].currentXAngle = 12.0f;
        // END CODE EXAMPLE HERE

        // applies new bone rotation information, (note each bone carries the bone information of rotation like in IK Bone Logic...)
        SetBones(BoneData);
    }
}

//holds Min, Max, Current Angles And Bone Ref.
public class BoneConstraintData{
    string bone_name;
    float minXAngle, maxXAngle, currentXAngle;
    float minYAngle, maxYAngle, currentYAngle;
    float minZAngle, maxZAngle, currentZAngle;
}

I'm using version 5.x.x of Unity 3D.


texts: Behaviours: Should I always return a reference to the behaviour on its methods?

texts:
I'm writing a small game to sharpen my programming skills, and I've chosen to use behaviors (that basically is a class that modifies its parent, to do things like movement, damage and stuff) to avoid duplicating code... maybe...

Whenever I need to modify the properties of a behavior, I need to get it from the "Actor", like this:

actor.getBehaviour(BehaviourType).method();

It's OK until I need to modify multiple properties, like following:

actor.getBehaviour(BehaviourType).method();
actor.getBehaviour(BehaviourType).setFoo(10);
actor.getBehaviour(BehaviourType).setBar("privet", "russian_hello");

Wouldn't that be more convenient if I just return a reference to the behavior on every method (every method needed)?:

actor.getBehaviour(BehaviourType).method().setFoo(10).setBar("privet", "russian_hello");

I apologize for any mistakes or broken logic (including broken grammar).

Thank you very much and have a nice day/afternoon/night/pokemongo/vim>sublime but i use sublime anyways!


texts: How can I handle mouse input and cursor in a WinAPI window?

texts:
Hello I'm studying game engine programming, but I got stuck with mouse input.

As for now I have only WinAPI window, which has a message pump and processing. For the mouse I used RAWINPUT, but there is a problem: I can't find any elegant way of handling the mouse cursor, for example making a menu in a shooter.

Raw input provides relative movement data directly from mouse driver, but how can I control the cursor with it? Or maybe I should make 2 message processing queues with filters on the mouse? I haven't found any real solutions in my searching yet.


texts:
I already have an idea for a game. I also have a few years of experience with casual programming and game dev, and I know the messy while loop I had until now will not be enough for my next project.

The game I want to make is a top down tile based puzzle game. Some elements are buttons activated by boxes pushed on top of them and doors that open as a response. The player can also use a mechanic to "warp" to a different level, taking things with him to the other level and using these to solve the puzzle that's in there. It's not that simple, but I don't want to over complicate anything. I also have a lot more ideas but lets start with the core of the game.

I already implemented some of the mechanics as a prototype but it's too unorganized and I don't think it is worth coding how I did. For that reason I am thinking about game architecture. Multiple articles I read suggest that I should use a messaging / event system that connects between different systems of the game. Those could be the renderer, sound, game logic, physics, etc...

These systems are very general and I am wondering where are the game objects themselves? Do I have a separate system for the player, another one for the level elements? and one just for GUI? or are they all in one system?

Another aspect of the systems is the communication between one another. If I have a separate system for the player and for the renderer, then how does the renderer know where the player is? Having different systems seems logical at some cases but complete nonsense in others. so to summarize: Which systems are required for the type of box-pushing puzzle game I'm making?


texts: Object detection in bitmap JavaScript canvas

texts: I want to detect clicks on canvas elements which are drawn using paths. So far I have stored element paths in a JavaScript data structure and then check the coordinates of hits which match the element's coordinates. Rendering each element path and checking the hits would be inefficient when there are a lot of elements. I believe there must be an algorithm for this kind of coordinate search, can anyone help me with this?


texts: Why doesn't the current player on the server spawn after a new client connects?

texts:
I have a running server that can change maps. When a client joins the server, it automatically loads the scene because the server uses ServerChangeScene () to change the scene.

The problem is that the client does spawn the objects on the server, but it spawns them on the first scene it loads into. How can I make it spawn the objects on the actual scene it loads into?


texts: Given face normal and vertices of a triangle, how to find the acyclic order of vertices?

texts:
I'm in the process of constructing a custom 3D triangle mesh.
I found the vertices of the triangle in the 3D space and it's face normal. How do I find the acyclic order of vertices?

If I draw the vertices in the wrong order, I can't see some of the faces which should be visible when back face culling is enabled.


texts: How to "merge" multiple intersecting circles so that only the outer edges of each show?

texts:
In my RTS (In Unity) each unit or building has strategic circles in a similar fashion to SupCom. If you have multiple units or buildings selected it looks like the picture to the left. I want to make it look like the picture to the right, where anything inside the outer edges of their circles is no longer shown.

I draw these using vectrosity, mentioning this just in case vectrosity provides a way of doing this, or can be modified to do this.

The circles are essentially just an array of points with lines drawn in between them. How would I go about "merging" the circles inside of their overlapping area?

This is similar to: How to make unit selection circles merge?, however I am not interested in a shader solution.

Edit: To re-explain the above.:

I'm not seeing how the answers are applicable. I've read through the other thread before posting, which is why I posted it here to avoid this exact thing (being marked as a duplicate). I have an array of points with straight lines in-between them to create a circle-like effect. This is not a true circle, but a really granular polygon. I am interested in solutions that are achievable in C# within Unity, not with shaders or with rendering mechanics.

Edit2: Another picture based on one of Roberts suggestions

This seems viable, though computationally expensive. If I have a circle made up of 250 points, and 50 circles all intertwined that's 615,500 checks in a worst-case scenario.


texts: Tile-based collision problem with corners

texts:
I am currently making a tile based collision system. But I encountered a big problem I can't seem to figure out.

Use the image bellow for reference.

Gray lines represent the border between tiles. White square is void and grey square is a wall.
Purple is a collision box and red lines represent the collision tested.

Fig 1. is the way I'm currently testing for collisions. I test for the tiles adjacent to the box.

Fig 2. is my problem. If the box slightly enters a tile in a corner, the collision will not be tested. I see you coming and tell me to test for diagonal collisions. See Fig3.

Fig 3. If I test for diagonal collisions, then if the box slides along a wall, it will hit the diagonal tile and completely stop (green line)

So I'm not really sure what to do at this point. I tried to look for 2D based tile collision detection and resolution, but nothing I found could solve my problem.


texts: Space invaders 2d array to represent scene

texts:
For code optimization purposes, I want to create a 2d array that contains 40 equal squares (10x10px). Each square represents 1\40 of the displayed window (400x400px).

I populate the 2d array with the standard double for-loop methodology.

    int col = 40;
    int row = 40;
    int boxSize = 0;
    Integer[][] boxes = new Integer[40][40];

    for (int i = 0; i < col; i++) {
        for (int j = 0; j < row; j++) {
            boxes[i][j] = boxSize;
            boxSize += 10; //Creates a 10px box.
        }
        boxSize = 0; //Resets box size for next column
    }

There are several circles in this program. We have a ship(circle) that fires missiles(circles) toward enemies(circles).

I want to run collision detection ONLY when there is a bullet + an enemy in one of the squares. This will greatly optimize the code.

The question is... how do I create these squares off of a 2d array? How do I select each square? How do I test if the missiles and the enemies are inside the same square?

Thanks.


texts: How would I apply force to a bullet in 2D?

texts:
I wrote the code below in order to try to get a bullet to fire at a specific angle for my top-down shooter. However when I press space the bullet just spawns in front of the game object despite it having a bullet speed. I made sure that my bullet prefab has a rigidbody and I am calling to it in my script.

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

public class FireAway : MonoBehaviour
{
private Vector3 mouse_pos;
private Vector3 object_pos;
private float angle;
private float bulletSpeed = 1;
public GameObject ammo;
private Rigidbody2D rb2D;

void Start()
{
    rb2D = ammo.GetComponent<Rigidbody2D>();
}

// Update is called once per frame
void FixedUpdate()
{
    // Point the cannon at the mouse.
    mouse_pos = Input.mousePosition;
    mouse_pos.z = 0.0f;
    object_pos = Camera.main.WorldToScreenPoint(transform.position);
    mouse_pos.x = mouse_pos.x - object_pos.x;
    mouse_pos.y = mouse_pos.y - object_pos.y;
    angle = Mathf.Atan2(mouse_pos.y, mouse_pos.x) * Mathf.Rad2Deg - 90;
    Vector3 rotationVector = new Vector3(0, 0, angle);
    transform.rotation = Quaternion.Euler(rotationVector);

    if (Input.GetKeyDown("space"))
    {

        GameObject BulletPlayer = (GameObject)Instantiate(ammo,
transform.position, transform.rotation);
        //bullet.transform.LookAt(mouse_pos);
       rb2D.AddForce(BulletPlayer.transform.forward * bulletSpeed);
    }
}
}


texts: How do I convert a Source engine NPC model to a player model?

texts:
The Source engine's NPC and player models differ: An NPC model applied to the player has no animations. It cannot walk and holds its arms out to the side by about a foot. The weapon is held in the right hand and you can see the player switch weapons, but the weapons also have no animation.

How do I convert between these model types?


texts: Quaternion rotations & transforms from global to local space

texts:
I am trying to solve this problem and getting no where,
could really use some assistance.
Rotation is defined as X (rotate left/right), Y(rotate up/down), Z(roll)
Coordinates are X: Forward/backward, Y: Left/right, Z: up/down

I have two objects in simulated space, both have galactic coordinates (XYZ)
and a quaternion representing their rotation.

ObjectA
  Coordinates: 0.593 0 0 (directly ahead of ObjB)
 RotationQuat: w: 0, x: 1, y: 0, z:0 (Rotated 180 yaw, facing backwards)

ObjectB
 Coordinates: 0 0 0
 RotationQuat: w: 1, x: 0, y: 0, z: 0 (No rotation, facing towards ObjA)

Given the above information, how do I translate ObjA's location into ObjB's
 local space?

If ObjA fires at ObjB (or vise versa), I need to calculate which side will be
 hit. Forward, Aft, Port, Starboard, Ventral or Dorsal.

My project is written entirely in C. Actually this is an old project, created
by someone else that I am converting to using quaternions due to gimbal lock.

Any advice?


texts:
Substance Painter appears to add colors together wrongly when selecting "Normal Blending Mode"
The right side is what photoshop does correctly, meaning R+G+B values in the border region never exceed 255. On the left side is what Substance Painter does incorrectly, the green dot appears to have a glow around it.

If there is no quick way to fix this, I will have to export Red and Green and Blue layers individually and blend them together in Photoshop.


texts: Linking one uniform variable to many shaders

texts:
Let's say, that I have 3 programs, and in each of those programs there is a view matrix uniform, which should be the same in all those programs.

Right now, when my camera moves, I need to re-upload the modified matrix to every program separately. Is it possible to create some kind of global uniforms which are constant for all programs linked to it, so I could just upload the matrix once?

I tried creating a globalUniforms object which looked kinda like this:

var globalUniforms = {
    program: {},
    // (...)
    vMatrixUniform: null,
    // (...)
    initialize: function() {
        vMatrixUniform = gl.getUniformLocation(this.program, 'uVMatrix');
    }
};

So I could just link it to proper programs like this: program.vMatrixUniform = globalUniforms.vMatrixUniform;, and then pass the matrix like this:

if (camera.isDirty.viewMatrix !== false) { camera.isDirty.viewMatrix = false;
    gl.uniformMatrix4fv(globalUniforms.vMatrixUniform, false, camera.viewMatrix.element);
}

but unfortunately it throws an error:

  Uncaught exception: gl.INVALID_VALUE was caused by call to:
  getUniformLocation called from line 272, column 2 in () in mysite/js/mesh.js:
      vMatrixUniform = gl.getUniformLocation(this.program, 'uVMatrix');

Summing up: is there a more efficient way of managing shaders which follows my logic?


texts: Cycling through colors with the same brightness

texts:
Ok.  So I have a game I am working on with a bunch of colored particles.  Each of them gets their own color however they are all close to a specific shade.

To explain that better I am using the HSV color space, and I have a global variable that is cycling from 0-360 (H) and each of the specific particles add or subtract a random amount from that.

I use HSV because it is the easiest way for me to cycle through colors because you can just change H.

This looks very nice and all, however the particles are supposed to be pure light that is colored.  Right now all they are are circles colored with the shade, but later on I might add glow effects and other shading techniques.

The problem is that not all shades (I dont mess with H or V) are equal as far as the brightness our eyes see, and this causes problems.  For example when all of them are shades of blue things look pretty dark.

Obviously in the shader I have to convert these HSV colors to RGB colors and doing some math I quickly saw what was wrong... the colors didn't have equal luminance!

As I understand it luminance is roughly (0.2126*color.r + 0.7152*color.g + 0.0722*color.b) which is why everything is off.

Is their a way to get it so I can still get all of the different chroma (colors on the wheels degrees) while maintaining a high luminance? Perhaps I should work with a different type of color then HSV, or perhaps their is a formula that finds a color at degree x on the color wheel with luminance of y?

Thanks much!


texts: How do I stop a moving object when colliding with a static wall or falling to a static ground

texts: I'm writing my very first 2D game engine in C++ and SDL2. I wrote a very simplistic RigidBody class that computes the resultant force, applies forces and simulates gravity. I also wrote a BoxCollider class and a QuadTree class which as any game dev would know manages collisions. Every thing seems to be working fine, however I'm facing a pit stop I can't wrap my head around. How do I stop a GameObject when it collides with a static wall or ground. I tried setting the velocity to zero but that literally freezes the object and I can't move it using my controls. Also setting the gravity to zero doesn't stop the object since it still has a non zero velocity and it sort of digs it's way through the ground. How can I implement this and if there are any decent tutorials regarding my question please do share them. Thanks!


texts: Am I using libGDX Asset Manager correctly?

texts:
My understanding is that you initialize the AssetManager as a non-static object in your main class and load the sprites you need...

    manager = new AssetManager();
    manager.load("sprite_sheet.txt", TextureAtlas.class);
    manager.finishLoading();

I then modified my abstract State class by adding AssetManager to the constructor...

 State(GameStateManager gsm, AssetManager manager) {
    this.gsm = gsm;
    this.manager = manager;

Now say I have 5 blocks in my sprite sheet called block0, block1... block5 would it be appropriate to create a BlockTextures class like this?

private static TextureAtlas textureAtlas;

public BlockTextures(AssetManager manager) {
    textureAtlas = manager.get("sprite_sheet.txt", TextureAtlas.class);
}

public static AtlasRegion get(int id) {
    return textureAtlas.findRegion("block" + id);
}

public static void dispose() {
    textureAtlas.dispose();
}

Where I call BlockTextures.dispose() in my Game.dispose() method?

public void dispose() {
    BlockTextures.dispose();
}

While this code seems to work fine I feel like I am not using AssetManager correctly.


texts: Implementing Valve's checkerboard rendering technique

texts:
I've been trying to implement Valve's VR checkerboard rendering technique (original document) and was wondering which way would be the best to proceed.

The thing is that I need to "abort" the execution of 2x2 blocks of fragments in a checkerboard pattern considering how GPUs work in blocks of pixels.

I've thought of several approaches which are the following :

Discard fragments in the fragment shader using a condition like this one :

float mod2 = gl_FragCoord.x + gl_FragCoord.y;
float res = mod(mod2, 2.0f);
if (res == 0.0f)
   discard;

Use the stencil buffer and write a checkerboard pattern on it using an image or such.
Use some kind of clipping method where I have several quads in front of the camera forming a checkerboard pattern.

The first approach seems to be the worse because I have to branch and after, discard fragments. And considering the fact that GPUs work in blocks of 2x2 pixels, I need to find a way to abort block by block so that I don't get the fragment shader processed anyway (even with a discard). And I'm not even sure this would force a block to abort and skip the fragment shader.

The second method seems OK, but I'm not sure if there's a better way to do it. Would the fragment shader be processed anyway ?

The third seems to need to process more polygons which is not really a good idea I guess even though it does not require a lot of processing considering they would be simple quads.

What would be the most efficient method (listed here or not) for skipping these blocks ?


texts: Checking collision of bullets and Asteroids

texts:
I'm trying to detect collision between two list of bullets and asteroids. The code works fine, but when the bullet intersects with an asteroid, and that bullet passes through another asteroid, the code gives an assertion, and it says about it can't increment the iterator.
I'm sure there is a small bug in that code, but I can't find it.

for (list<Bullet>::iterator itr_bullet = ship.m_Bullets.begin();
     itr_bullet!=ship.m_Bullets.end();)
{
    for (list<Asteroid>::iterator itr_astroid = asteroids.begin();
         itr_astroid!=asteroids.end();
         itr_astroid++)
    {
        if(checkCollision(itr_bullet->getCenter(),itr_astroid->getCenter(),
           itr_bullet->getRadius(), itr_astroid->getRadius()))
        {
            itr_astroid = asteroids.erase(itr_astroid);
        }
    }
    itr_bullet++;
}


texts: How to randomly generate biome with perlin noise?

texts:
I want to generate a procedural world using perlin noise. As expected, my terrain is generating with a repetitive patern. I'd like to add biomes, zones separated with higher or lower amplitude to simulate mountains or plain.
I first thought I could randomly select rectangles of verticesof random sizes and then give them bigger amplitude to simulate mountains. The problem with that is that It wont seem natural, since I will only have rectangle biomes and also I don't know how to make it so the mountains would connect with the plain to avoid things like this
Here is my script:
public int size = 10;
public float amplitude;
public float frequence;
void GenerateTerrain(float amp, float freq)
{
    Mesh meshy;

    MeshRenderer meshRenderer = GetComponent<MeshRenderer>();
    meshRenderer.sharedMaterial = new Material(Shader.Find("Standard"));
    MeshFilter meshFilter = gameObject.GetComponent<MeshFilter>();

    List<Vector2> uv = new List<Vector2>();
    Vector3[] vert = new Vector3[size * size];
    List<int> tri = new List<int>();
    List<Vector3> norm = new List<Vector3>();
    meshy = new Mesh();

    for (int i = 0, x = 0; x < size; x++){
        for(int z = 0; z < size; z++){
            float y = Mathf.PerlinNoise(x * amp, z * amp) * freq;
            vert[i] = new Vector3(x, y, z);
            i++;}}

    for (int i = 0; i < vert.Length; i++){
        norm.Add(-Vector3.forward);}

    for (int x = 0; x < size - 1; x++){
        for (int z = 0; z < size - 1; z++){
            int i = size * x + z;

            tri.Add(i);
            tri.Add(i + 1);
            tri.Add(i + size);
            tri.Add(i + size + 1);
            tri.Add(i + size);
            tri.Add(i + 1);}}

    for (int i = 0; i < vert.Length; i++){
        uv.Add(new Vector2(vert[i].x, vert[i].z));}

    meshy.vertices = vert;
    meshy.triangles = tri.ToArray();
    meshy.uv = uv.ToArray();
    meshy.normals = norm.ToArray();
    meshFilter.mesh = meshy;
}

void Update()
{
    if (Input.GetKeyDown("u"))
        GenerateTerrain(frequence, amplitude);
}


texts: How to import camera from Blender into Unity3D

texts:
I have a few cameras in Blender to export to Unity3D. They're exported as empty GameObjects, and that's what is expected. The idea is to have the main camera be a child of one of the camera empty GameObjects.

In Blender, for the world, +Y is forward, +Z is up. But the camera is -Z is forward, +Y is up. In Blender, I have to set the camera's rotation to (90, 0, 0) just to have the camera not face down. But it the camera doesn't face the same direction as the camera in Blender.

I tried rotating the camera game objects by Y+180 so that the camera faces +Z, parent the camera GameObject, then zero out its position and rotation.

How can I have a 1:1 export from Blender to Unity3D for camera objects?

Edit: I am exporting FBX binary 7.4 files.

Edit: Here is a table:

 Blender RotXYZ     Unity global RotXYZ    Expected rotation
( 0,  0,  0)        (  0, -90,  90)        ( 90,   0,   0)
(90,  0,  0)        (  0, -90,   0)        (  0,   0,   0)
( 0, 90,  0)        ( 90, 180,   0)        (  0, -90, -90)
( 0,  0, 90)        (  0, 180,  90)        ( 90, -90,   0)

If I input any of the Blender RotXYZ values into Blender's camera rotation, export the FBX, I get the corresponding value in the Unity global RotXYZ column. But Expected rotation is what it should be.

Edit: Here is a poorly drawn image of what I'm seeing when I export from Blender to Unity.

Edit: I'm seeing inside fbx_utils.py (FBX exporter) that the camera gets rotated to have +X be the camera's forward direction.


texts: AS3 Client not sending movement to server

texts:
I am having trouble with multiplayer player movement in my game.

The client is in AS3 and the server is in C#.

Here is my problem: When I first launch the game, it connects to the server, and everything works fine. But... when I try to move my player, it isn't sending the UTF8 bytes over to the server. I even have it trace output after the socket sends the bytes. I sent the exact same bytes to the server when the game started just to see if the server recognized it, and it did.

I am not sure why it isn't even sending it at all. This is very frustrating.

private function keyDown(event:KeyboardEvent):void
    {
        switch(event.keyCode)
        {
            case Keyboard.W:
                up = true;
                break;

            case Keyboard.S:
                down = true;
                break;

            case Keyboard.A:
                left = true;
                break;

            case Keyboard.D:
                right = true;
                break;
        }
    }

    private function keyUp(event:KeyboardEvent):void
    {
        switch(event.keyCode)
        {
            case Keyboard.W:
                up = false;

                break;

            case Keyboard.S:
                down = false;
                break;

            case Keyboard.A:
                left = false;
                break;

            case Keyboard.D:
                right = false;
                break;
        }
    }

    private var playerSpdTemp:int = 5;

    private function enterFrame(e:Event):void{
        if (up){
            archer.y -= playerSpdTemp;
            socket.writeUTFBytes("move--"+archer.x+":"+archer.y);
            trace("Sent...");
        }
        if (left){
            archer.x -= playerSpdTemp;
        }
        if (down){
            archer.y += playerSpdTemp;
        }
        if (right){
            archer.x += playerSpdTemp;
        }
    }

I tried putting the socket.writeUTFBytes() in the keyDown and keyUp functions but nothing happens either...

And yes, I have the correct event listeners set up.
The player moves correctly but not the socket.


texts:
I have hit a problem with my player, I have been following a tutorial on building a platformer. I have put in the UI buttons and linked then to the functions with a script like this:

public GameObject player;// link to player script;
    Player playerVariable;
    // Start is called before the first frame update
    void Start()
    {
        playerVariable = player.GetComponent<Player>();
    }

    public void MobileMoveLeft()
    {
        playerVariable.MobileMoveLeft();
    }

    public void MobileMoveRight()
    {
        playerVariable.MobileMoveRight();
    }

    public void MobileStop()
    {
        playerVariable.MobileStop();
    }

    public void MobileFireGun()
    {
        playerVariable.MobileFireGun();
    }

    public void MobileJump()
    {
        playerVariable.MobileJump();
    }

When I press the up arrow on the keyboard the player jumps and the animation jump is played, but when I press the UI jump button the player still jumps however the jump animation is NOT played.

public void Jump()
{
     if (SantaOnGround)
     {

         SantaOnGround = true;
         rb.AddForce(new Vector2(0, JumpForce));
         Animation.SetInteger("state", 2);
     }
}


texts: Why does Everyplay indicate recording is not supported in this code?

texts:
I am using Everyplay in my game and when I run my game on mobile. It showing me as recording supported as false. I put the Client ID and client secret as well and checked on Android enabled. Can somebody tell me whats wrong with my code or did I miss something? I am using onePlus2 with marshmallow. And using Unity 4.6.4f1 with latest SDK of Everyplay from Asset Store (2110-1530). Here's my code:

private bool readyForRecord = false;
private bool recordingInProgress = false;

void OnEnable(){

    Everyplay.ReadyForRecording += EveryPlayRadyForRecording;
    Everyplay.RecordingStarted += RecordingStarted;
    Everyplay.RecordingStopped += RecordingStopped;

}

void OnDisable(){

    Everyplay.ReadyForRecording -= EveryPlayRadyForRecording;
    Everyplay.RecordingStarted -= RecordingStarted;
    Everyplay.RecordingStopped -= RecordingStopped;
}

// Use this for initialization
void Start () {
    Everyplay.Initialize ();
    Debug.Log  ("Is recording supported =  " + Everyplay.IsRecordingSupported ());
  }

#region Recording Operations

public void StartRecording(){
    if (Everyplay.IsReadyForRecording ()) {

        Debug.Log ("Recording Started");

        recordingInProgress = true;
        Everyplay.StartRecording ();

    }

    if (recordingInProgress)
        StopRecording ();

}

public void PauseRecording(){
    Debug.Log ("Recording Paused!");

    if(!Everyplay.IsPaused())
        Everyplay.PauseRecording ();

}

public void ResumeRecording(){
    Debug.Log ("Resuming Recording");

    if (Everyplay.IsPaused ())
          Everyplay.ResumeRecording ();

}

public void StopRecording(){
    if (recordingInProgress) {
        Everyplay.StopRecording ();
        recordingInProgress = false;
        Debug.Log ("Recording Stopped!");
    }

}

public void ShowRecording(){
    Debug.Log  ("Showing Recording...please wait!");

    if (!recordingInProgress)
        Everyplay.ShowSharingModal ();

}

#endregion

#region Everyplay Callback Events

private void EveryPlayRadyForRecording(bool ready){
    Debug.Log ("Ready for recording =  " + ready);

    if (ready)
        readyForRecord = ready;

}

private void RecordingStarted(){
    Debug.Log ("Recording started");
}

private void RecordingStopped(){
    Debug.Log  ("Recording stopped");
}

private void SharingInProgress(int videoID, float progress){
    Debug.Log  (" Uploading " + videoID + " " + progress + "%" + " completed.");

}

private void SharingCompleted(int videoID){
    Debug.Log  (" Uploading Sucessful =  " + videoID);
}

#endregion


texts: Inflating a balloon while the user touches & holds the screen

texts:
I'm trying to create a simple balloon which will enlarge as the user touches and holds the screen.

So I wrote something like this:

while ( Input.GetMouseButtonDown(0) ) {
        transform.localScale += new Vector3(1, 1, 1);
        yield return new WaitForSeconds(1);
}

It causes a compiler an error:

  The body of 'enlargeBalloon.Update()' cannot be an iterator block because 'void' is not an iterator interface type

How can I fix this?


texts: Am I hurting myself by not knowing C++ for game design?

texts:
Right now, I feel I am strong in both Java a C#. (Not much of a leap from one to the other really).

While I don't expect a game designer/programmer is an attainable goal early on in my career, This is a goal I will reach later on in my career.

With this in mind, I feel that ignoring C++ and game design tools associated with it are eventually going to hurt me or slow me down in my ability to reach my goal.

Is this the case? Or can I continue to hone my C# skills using XNA and WPF for personal projects that can elevate me into such a career?


texts: dual contouring concept and term translations

texts:
I am working on a 3D sandbox mmo with destructible terrain, using Java and LWJGL. I looked at most options to achieve this and found that dual contouring would probably be the best option for me. I've read about every paper i could find on the internet about how to implement such a thing and, since i have a very basic experience in game/3d/complex programming, I've had quite a hard time. but I think I've found the solution i was looking for and would like to check with some more experienced programmer if my solution seems right and if I really successfully wrapped my mind around some of those pesky terms that were haunting my nights for the last few months;

Edit: I will try and add some more precise detail as to what i already do here in bold

so, first of all, I've created an object called voxel when I say object, i refer the the user side's way of handling the data received from the server. I already compress the data as to have it fit a byte or a short and use bitwise operations. Voxels are loaded once from the server then stored to memory unless the server returns a change to that voxel (not sending entire chunks for a small change), a voxel knows it's type and it's "integrity" (in this case, how much that stone voxel has been mined for example. I think it refers the the volume i often read about?). Those voxels "will" be created from a pre generated world map for a persistent world. Yes, the world will have overhangs and most of all, tunnels players can mine.

then i got a chunk, composed of at most 32x32x32 voxels. A chunk knows it's world position and has a 3D array of voxels passed from the server when first loaded to memory, then the client/server only updates the voxels that have changed since the last update. A chunk also knows it's neighbors (if such neighbors have been loaded into memory, or creates a default chunk of 32x32x32 air voxels)

To find the surface, inside a chunk, i check every voxel from the bottom,left,near (I think it is the right order to fit with the way OpenGL read it's coordinates?) to the top,right,far. each time, i take the current voxels and all it's 7 neighbors in a cube shape and check whether their is a type change from solid to air in any of them, indicating a surface running through that cube. If there's a type change, i compare every edges to see if there's a type change and if so, place the entersection of that edge using and average of both corners integrity. doing so for all 12 edges allows me to average all the planes to a single point inside that cube and create a vertex and store it in an array.

The point where I'm confused is this: what should i do next? I think I should check along one edge that displays a type change to find the 3 other cubes that has the same edge and find their vertices. Since i know what direction the ground is (comparing the type change along the edge axis) I can deduce the front and back of the quad. taking 3 of those 4 vertices should allow me to get a normal from their dot product and from there, go around that normal CCW and send those vertices to the GPU for the rendering phase. I guess the real question here is: How do I get the right order of vertices to form triangles that OpenGL can draw correctly from that large collection of vertices generated while finding the surface?

In theory, in my mind, it makes sense! but I find it so much simpler than all those papers I've found, that i fear I've missed the boat completely! I get lost when it comes to Isosurface (I guess here, the formula they're talking about would be the average of integrity along any type change?) and hermite data (here, should i read voxel collection instead?) and most maths are slightly beyond my understanding yet (working on it tho and I progressed quite a bit) please, can you help me out here and guide me a bit?


texts: How to store and update presentation strings describing effects with parameters?

texts:
Consider this spell:

As you can see in my design a Spell is a composition of one or more Effects. An Effect has properties on it like value, range, etc. So, I can say that the Spell Description is an aggregate description of the composition of effects.
Presentation Layer
In my presentation, I want to decorate part of the description string in HTML tags and display as rich text. I also want to ensure that my string's numeric values come from data.
Solution 1
Simply hard code the string. In this case the spell description would look like: Choose a target within <#f4b350>4</color> squares. Deal <#f33613>4</color> damage to that target and restore your HP by <#3cf73c>50%</color> of the damage done.
This approach has some obvious issues, namely:

Changing the color value of a particular tag would be a nightmare when there are hundreds of abilities

Changing the damage value of a spell means updating it in two places, the string and the data

Solution 2
Create a tag series separated by _ that indicates various properties. I could for example, do something like Deal {subtractive_value} damage to that target with the idea that when I go to parse the string, subtractive could be a tag indicating a red color, and value can be a tag indicating that its the effect's value that should go there.
This is all fine except that a spell can have multiple effects. I need a way to associate the part of the description with the specific effect that drives it.
Modification to Solution 2
So then I suppose I could just add IDs to the spell effects such that the string defined in data becomes:
Choose a target within {neutral_damageEffect_range} squares. Deal {subtractive_damageEffect_value} damage to that target and restore your HP by {additive_healEffect_value}.
But now you see that its getting a bit cumbersome and I'm dubious of how scalable that solution is.
Non-Goal
Lastly I figured I'd mention a non-goal. If you take my approach thus far to its ultimate conclusion, you would probably end up with trying to find a way to generate your description text from the effect themselves. While this is an interesting idea, I think it's a bit too ambitious, so I'm specifically not trying to do that. That said, if you feel like that's easier than I think it is, feel free to make that suggestion!
Question
So, given what I've tried and the problem I'm trying to solve, there's no way this is a unique problem to me. Is there a battle-tested solution to this problem? What's a good way to go about it or some patterns to use I might not know about?
EDIT
Some have asked for some code, it is lengthy though so I can just link to a gist here:
https://gist.github.com/jsandersr/ef6d560ad95f1d63b1f8e3b2099038a5


texts: Unity3D Problem Temporarily Stop Players Movement When Playing a specific Animation

texts:
This is my first time in Unity3D and programming so forgive me if i'm a bit vague on this. I'm working on my own project in Unity3D but I couldn't get the player to stop moving when I press the key. I avoided using the GetButton since it triggered the animation to play twice. After bout 2 hours, I still can't find any answer to my problem.

Can someone help me please?

Here's part of the code of the the player script.

    if (Input.GetButtonDown("Fire1"))
    {
        animator.SetTrigger("AttackSword");
        Debug.Log("Animation called");
    }

    if(!animator.GetBool("AttackSword"))
    {
        Move(inputDir, running);
    }

If you would like me to add the full code of the script, let me know.


texts:
We have made different types of prefabs, if we want to change small thing in all prefabs, we do drag all those prefabs to scene ,create script which will do its required work .All is fine till now after that problem arises for saving those prefabs.We need to manually click "Apply" on all prefabs.

Has there anyway where we can dynamically use "Apply" feature via script?


texts: Calculate the starting position of a turning aircraft with inertial force to make it stop at desired position and heading

texts:
Continued from the answer here, I have some problem when the aircraft in my game has inertial forces after going forward and turning itself. To illustrate, from the following image (https://imgur.com/a/Xvqu2A7) the aircraft is moving from the point A -> B -> C'-> D. I planned to maneuver the aircraft from the point C' which is the point that would make the aircraft stop at the point D after turning with its full performance (using minimum turning radius).

The question is how do I calculate the position of the point C' to make the aircraft roughly stop at the point D with the desired position and heading (It is roughly since there is also an inertial force after stopping the aircraft's engine.)?
Any suggestions and answers would be appreciated.


texts: LibGDX: Scrollpane won't scroll to bottom after adding children to contained table

texts:
To my game I want to add a gui element that displays text and textButtons whenever something is happening or it wants you to make a decission (an answer while talking to a person for example). To keep track of your actions you shall be able to scroll it. Similar to text adverntures or dialog boxes in rpgs.

I use Scene2Dui for my GUI, so I put a scrollPane in my GUIs root table. I have methods for adding stuff to the contained table and tell the scrollPane to scroll to the bottom.

In general the idea works, but the thing doesn't scroll to the bottom but only to the bottom of the element I added before the current one. I'm puzzled.

Here's the code, leaving out the skins and styles part:

public class TextBox {

ScrollPane box;
Table table;
Label.LabelStyle lStyle;
Skin skin;

TextBox() {

    table.setFillParent(false);

    box = new ScrollPane(table, scrollStyle);

    box.setScrollingDisabled(true, false);
    box.setOverscroll(false, false);
    box.setFillParent(false);

    table.align(Align.topLeft);
    table.row();
}

void writeDecissions(GameEvent[] events) {

    Table tableD = new Table();
    tableD.setFillParent(false);

    if (events != null) {

        for (int i = 1; i < events.length; i++) {

            if (events[i] != null) {

                String s = Character.forDigit(i, 10) + " - "
                        + events[i].getDecision();

                TextButton button = new TextButton(s, style);
                button.getLabel().setWrap(true);
                button.getLabel().setAlignment(Align.left);

                tableD.add(button).width(box.getWidth() - 40).spaceBottom(20).spaceTop(20);

                tableD.row();

            }
        }
    }

    table.add(tableD).align(Align.left).pad(20);
    table.row();

    box.setScrollY(table.getHeight());
}

This is the way I test it:

public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 0);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    stage.act();
    stage.draw();

    if (Gdx.input.justTouched()) {
        gui.textBox.writeDecissions(events);
    }

I tried box.setScrollY(box.getMaxY) as well as setting overscroll to true (don't really know what that is tough). With the same result.

Finally a screenshot:

Help appreciated.


texts: How to create Elastic rope / Rubber band in box2d?

texts:
I am trying to create the rubber band type or elastic rope.

i ant to do something like bellow link.
http://heyalda.com/smash-turtle/

Thanks,


texts:
How do I create shadows and lights in a 2D top down perspective game? I want to achieve an effect similar to this game (also made in unity) where some objects like a torch, different sprites, and the player have a light source while the rest of the map is dark.

Do you anyone know how to achieve this, and could link me to some good resources on how to implement it in unity?


texts: Pure ECS, How to copy all components from one entity to another

texts:
I am attempting to create component payloads using prefabs. My goal is to use

var entity = EntityManagerExtensions.Instantiate(EntityManager, ai_steeringPipelinePrefab[i].Prefab);

to get all the components I need copied over to another entity (including there data)

The only way i have found so far is to get the component types from the payload entity and add them to the recieving entity with

EntityManager.AddComponents(entity, componentTypes);

But this does not copy the data.

Thoughts?


texts: Rectangle touch sides of another rectangle

texts:
I am making a platformer game and im trying to make the player collide with all the blocks, here's a picture:

The blocks is stored in List and im trying to get the side's of the block usin

static class RectangleHelper
{
    public static bool TouchTopOf(this Rectangle r1, Rectangle r2)
    {
        return (r1.Bottom >= r2.Top &&
                r1.Bottom <= r2.Top + (r2.Height / 2) &&
                r1.Right >= r2.Left + r2.Width / 4 &&
                r1.Left <= r2.Right - r2.Width / 4);
    }

    public static bool TouchBottomOf(this Rectangle r1, Rectangle r2)
    {
        return (r1.Top >= r2.Bottom &&
                r1.Top <= r2.Bottom + (r2.Height / 2) &&
                r1.Right >= r2.Left + (r2.Width / 4) &&
                r1.Left <= r2.Right - (r2.Width / 4));
    }

    public static bool TouchLeftOf(this Rectangle r1, Rectangle r2)
    {
        return (r1.Right <= r2.Right &&
                r1.Right >= r2.Right - r2.Width  &&
                r1.Top <= r2.Bottom - (r2.Width / 4) &&
                r1.Bottom >= r2.Top + (r2.Width / 4));
    }

    public static bool TouchRightOf(this Rectangle r1, Rectangle r2)
    {

        return (r1.Right >= r2.Right &&
               r1.Right <= r2.Right + r2.Width &&
               r1.Top <= r2.Bottom - (r2.Width / 4) &&
               r1.Bottom >= r2.Top + (r2.Width / 4));
    }
}

I got this code from a Youtube video and i changed it a little bit.. (the original code didnt work well)

the problem im having is:
the TouchBottomOf & TouchRightOf functions doesn't work well...(The collision occur randomly, sometimes on top of the block, sometimes little below it (TouchBottomOf), same with TouchRightOf)

Is there a better way to check it?
thanks.


texts: What would be best practice of client comunication in a multiplayer game

texts:
Assume that we have a multiplayer game and the users are moving their characters (might be a circle) on the game area. At every game loop some changes can be happened. Should clients send their changes at every game loop to the server ? What would be best practice to comunicate clients each others by avoding overloading server?

Note: I'm asking this question for mostly HTML5 multiplayer games and will be using Box2D.


texts: NPC interaction depending on conditions stored in XML

texts:
I am developing a RPG game for Android using LibGDX, at this moment the NPCs in the game have some moving AI (pathfinding), like random directions and stuff.
Now I am working on the dialogue system, for that I have the following:

DialogueManager class that just renders the current dialogue on the screen if any
A Dialogue class which consists of an ArrayList of Strings which are the lines of the dialogue
The NPC class holds a Dialogue object, so I can just add(text) to the dialogue.

The result of this is the following

The player is near a NPC and presses Action key
A window is opened showing the current line of the dialogue
When the players touches the screen, the line is replaced by the next one until there is no more lines left and the dialogue window closes and the player can move again
If the player talks to the same NPC, the same dialogue lines are presented

It works fine, but that is not what I really want. I need to make the dialogue to be different depending on some conditions the player has. My dialogues are stored in an XML file:

<npc>
    <name>Alice</name>
    <interaction>
        <dialogue>
            <line>Hello there!</line>
            <line>This is a simple dialogue</line>
        </dialogue>
    </interaction>
</npc>

But I want to have something like this (and I have it in the XML):

<npc>
    <name>Alice</name>
    <interaction>
        <dialogue condition="timesTalked" value="0">
            <line>Hello there!</line>
            <line>You are talking to me the first time!</line>
        </dialogue>
        <dialogue condition="timesTalked" value="1">
            <line>Hmmm...I remember you! Have we met before?</line>
        </dialogue>
        <dialogue condition="haveItem" value="Apple">
            <line>Is that an apple? Gimme!</line>
        </dialogue>
    </interaction>
</npc>

So for example "timesTalked" is a real variable name and "value" is the condition, so the first condition would say

if(timesTalked == 0)
   // do stuff

Now the problem, how can I implement that? I know how to parse the XML, but how can I make it so the conditions work? I don't want to have it all hardcoded in Java, also I dont want to use a scripting language, I think it is good to have XML because is lightweight and easy to use.
Thankyou!


texts:
I have a camera which has the following attributes:

pos (position of the camera in the scene)
look(either direction in which camera will face, or target vector)
up vector( y axis)

I am using cylindrical coordinates system for moving camera around centre of scene. my question is 'how can I find look vector of the camera in a such a way that it will be pointing out in the origin of the scene under 45 degree?'.

According to this thread there is not such a way.

  And you can never look directly down at the focal point, no matter how high up you go.

P.S: I need somehow to get look vector if it's possible.

Thank you for you attention


texts: Character doesn't move anymore after gameover and clicked play

texts:
When my character died it displays gameover and goes back to main menu, then if I clicked play I can see my character however I can't make it move anymore. Any suggestions?

For game over:

#pragma strict
import UnityEngine.UI;
private var StopGame: boolean=false;
private var showGUI: boolean=false;
var GUIstop: GameObject;
var StopMenu;

private var canvas : Canvas;

function Awake()
{
    canvas = GetComponent.<Canvas>();
    canvas.enabled = false;
}

function Update ()
{
    // If the player has run out of health...
    if(HealthControl.LOVES==0)
        Pause();
    //  }
}

public function Pause()
{
    canvas.enabled = !canvas.enabled;
    Time.timeScale = Time.timeScale == 0 ? 1 : 0;
    StopGame=true;
}

public function Quit()
{
    #if UNITY_EDITOR
    EditorApplication.isPlaying = false;
    #else
    Application.Quit();
    #endif
}

For character movement:

   function Update () {

       transform.rotation.z=0;

       if(Input.GetKey(KeyCode.UpArrow)){
           transform.position.y+=moveSpeed*Time.deltaTime;
       }
       else if(Input.GetKey(KeyCode.RightArrow)){
           transform.position.x+=moveSpeed*Time.deltaTime;
       }


texts: Why am I hitting a small character limit when rendering with SDL_TTF?

texts:
I'm making a text based game using SDL2 and SDL_TTF. I just started working with TTF, and I've noticed there is some kind of character limit regarding how much text you can render at a time! I can only render about 15 characters, after that, (16 characters or higher) the screen is just blank.

I really want to render large bodies of text (multiple sentences at a time) so how do I overcome this issue? For rendering text, I have this function:

void drawDialog(const char* content) {
    //Draws a dialog box with set text

    TTF_Font* font = TTF_OpenFont("assets/times.ttf", 900);
    SDL_Color textColor = { 255, 255, 255 };
    SDL_Surface* message = TTF_RenderText_Solid(font, content, textColor);
    SDL_Texture* tex;

    SDL_Rect destRect;

    destRect.x = 50;
    destRect.y = 730;

    destRect.w = 200;
    destRect.h = 30;

    tex = SDL_CreateTextureFromSurface(renderer, message);
    SDL_FreeSurface(message);
    SDL_RenderCopy(renderer, tex, NULL, &destRect);
    SDL_RenderPresent(renderer);
}

So, any advice for overcoming this limit? Any help would be greatly appreciated!


texts:
I am developing a multiplayer RPG-like strategic combat game.

If I use the formulas of Pokemon games in this game for damage calculation, does I risk any copyright issue ? What areas of the game is copyrighted ?


texts: Do you need a license for US military badges, awards, decorations?

texts:
We would like to use in our game names and images of real US military badges, awards and decoration.

http://en.wikipedia.org/wiki/Awards_and_decorations_of_the_United_States_military
http://en.wikipedia.org/wiki/Badges_of_the_United_States_Navy

I would like to know, if they are copyrighted or protected in any other way, or are they considered to be in public domain.

Regards and thanks
Piotr


texts:
Is it possible to Construct a perspective matrix by multiplying a perspective transformation with a parallel projection ?

I want a perspective projection in 2D space which is calculated by multiplying a perspective transformation matrix with a parallel projection matrix.
The final form should look like the image I posted above.


texts: Is there a way to bypass Directx Effect Files?

texts:
I am now trying to abstract my rendering pipeline, and I've been able to abstract OpenGL fairly easily. But now I have ran into a rather ugly problem with Directx.

Most of my knowledge about Dx9, 10, and 11 makes use of effect files. Something that openGL distinctly lacks. I know that this file does not have to be used. However, by the way all of DX's documentation had been written, it seems like it is required and there is no way around it.

Can anyone give me a lead here?


texts: How to play a video and run content at the same time

texts:
Alright, so I have a video loaded, and other game content.

Earlier this morning, when I was just learning how to actually play a video, I magically happened to get the video running in the background, and also keep everything else drawn above it. I was thrilled and thought I will easily manage to do the rest.

Now that I'm almost done, I have several videos that I want to draw. I made a loop that will only run one time as an intro, and then after it stops, it sequences one of the other videos, but the thing is, this next video is drawn above everything else, while the rest of my game content, is "under" the Rectangle where the video Texture is running, can anyone help me on how to get a Rectangle variable "behind" everything? almost as a background? Thanks a lot!


texts:
I'm just wondering about the implementing of the collision response of bullets and the fours obstacles.
https://www.youtube.com/watch?v=LCNTwG3MGEg

When a bullet hit, a one black pixel is overwritten. How would one implement it in modern games, because what I feel that they overwrite the framebuffer, but right now I will only swap the sprites or images of different hit-obstacles.

If we say we will draw it as a pixels of bitmap, should then I make then a pixel to pixel collision detection If I want to clone the same behavior?


texts: Bullet simulation stops after windows inactivate

texts: I am having trouble when inactivating window (event resizing); all the contents get rendered and input works. Even the physics work but the btDiscreteDynamicsWorld stepSimulation function does not get called. I am using SFML for window and clock. If any more information is needed please let me know.


texts: Should my game's entities use global variables?

texts:
I have a base class called Entity and several sub classes like Player and Goblin. They all have the method update(delta), but that's not enough to update Goblin for example, which also requires setTargetPosition(vec2) to get updated properly.

All sub classes are stored together in a single vector vector<Entity*> entities.

Solution 1 is to use some C++ version of JavaScript's instanceof and depending on class call methods like update() and setTargetPosition().

Solution 2 is to have a source file with global variables like Goblin's target position and thus only update() is necessary because all the data that's needed is in the file with global variables.

What solution is better than those above?


texts:
Note: I'm programming this in Javascript, but it should be language agnostic in the most part.

I am thinking about converting my engine to an ECS based one.

I get the basic idea (note: this is wrong, see my answer):

Entities are game objects.
Components are bits of functionality (reactToInput()) or state (position) which can get "glued" to entities.
Systems have a list of entities they manage and update.

But, I'm not quite sure that I get the implementation and some details...

Question: can a system operate on different kinds of entities? I usually give the example of a class called Scene in my engine, and it will serve this purpose now, as well. A scene is a container of all objects that can be rendered, updated, affect the rendering (lights), and maybe, in future, even 2DSoundEmitter objects. It has a high-level interface so the user doesn't need to worry about the type of the object he's scene.add()ing, and all that kind of stuff.

I realize that the Scene could be a system. It takes in entities, stores them, and then it can call their update methods, and maybe even do some state changes. But, there is a problem: as I described above, the Scene can be fed different types of objects! What should I do in, say, a situation where a scene has both renderable objects ("drawables") and lights in it? Should I make it type-check entities before interacting? Or, should I solve it at an even lower level: make a LightSource component which can be added to any object, and the light would just be an entity with LightSource and Position components. Is that acceptable?

Also, is it a good practice to still use conventional inheritance and traditional classes? For example, I just can't figure out what would my Renderer be! It's not a system, as its only function is to take in a camera and a scene, render everything and apply effects (such as shadows). It also manages the context, the width and the height of the game, makes translations... But it's still not a system!

Edit: could you maybe link any resources you found on the ECS? I'm having trouble finding good ones.


texts: Blend trees does not get effect on some animations

texts:
I have created generic animations in unity where bike rotate to its left or right depending on what axis user is pressed.

I have created several right turn animations though out of those animations,only couple of work when blend tree parameter gets changed.Other remain same and does not effect bike.

When I use "loop" to true in other animations ,it do work but loops continuously.

I am using only one right anim at a time.

Plz help in


texts:
I was watching this video made with IForce2D, its about creating soft bodied wheels in box2D.

http://www.youtube.com/watch?v=F-aDMZUVw0c

I wanted help in being able to increase the Radius of the Wheel gradually.

I tried increasing the natural distance of spring joint (Distance Joint) between central body and outer body.
But since outer bodies are connected by revolute joint, which force the outer bodies to not change their positions.

I then changed the Anchor Points of Revolute Joint to match the increase in Radius of Wheel. Now, the outer bodies start moving away from center body towards their natural Distance. But gradually some outer bodies rotate and move away from each other.

Check out this video i made showing what i have done:
https://drive.google.com/file/d/0B-CQHvLBg5TQNlBEZXpRaVc5MDQ/edit?usp=sharing

Note:- I am using Unity3D 4.3.4 with 2D Physics, Gravity is Off.

Any ideas?


texts: How can I clear the animations associated with bones in 3DS Max 2009?

texts:
I was given a model by an artist and it was boned and skinned for me. The .max file that he provided also included an animation to show what he would be able to do. (A basic running animation.)

However, this was the last I heard from him and I want to construct my own animation. I was wondering if there was any quick and easy way of removing the rotation animation on the bones, back to default values. (i.e., 0 on all axis or to the default biped positions.)

I have removed all the keyframes and the default pose seems to be the first frame of the animation that was created by the artist. I have tried setting the values in the X, Y, Z boxes at the bottom, nothing happens, I think its relative to the current position?

I have also tried setting the biped to figure mode, copying the pose and pasting the pose back to the original biped. That only seemed to work in bits and pieces, some of the bones didn't seem rotate, like the pelvis and the spine bones, and also after a while the bones seemed to revert back to the default running stance, or some bones would just take on a weird, random rotation.

Any ideas?