texts: Rotating voxels in 3d space amongst the x axis

texts: I have a very simple voxel engine and so far it works based on coordinates, e.g. x, y, z. I was wondering if there is a formula for rotating groups of voxels/coordinates from the x axis(e.g. [0, 1, 0][1, 0, 1] rotates to [1, 0, 0][0, 0, 1] when rotated 90 degrees anticlockwise along the x axis) from a certain point, but I hear it involves matrixes and quaternions which sound scary.


texts:
I'm working with unity and git, and for some reason, from some point - the assets started being Binary files, meaning that they're not visible as normal YAML files, and I cannot see textual git diff results on them.

Has anyone experiences it and knows how to revert to the textual format from the binary format?


texts: How do I Rigidbody.AddForce(Vector3) in Unreal Engine?

texts:
I am coming from the Unity Engine, and trying to get my feet wet with Unreal Engine 4.8.x.  I want to add a one-time force to an object.  To accomplish this in Unity 5, I would use:

void Start(){
    GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, 5));
}

Explanation:

  GetComponent<Rigidbody>() retrieves the Rigidbody Component.  The Rigidbody is
  already attached to the GameObject.
  The AddForce method is called on the Rigidbody, and applies the force of
  a Vector3.  The parameters of the Vector3 indicate the force on each
  axis which is applied.  In the example above, the GameObject would
  move forward on its z-axis.

How would I accomplish this same thing in Unreal Engine 4?  I would appreciate if you can elaborate on what exactly is happening in the code as well.  I currently have an empty AActor script, and I am struggling to find out what to put in my BeginPlay() method.

void AMyActor::BeginPlay()
{
    Super::BeginPlay();
    //What goes here?  Why?
}

As CobaltHex pointed out, UPrimitiveComponent has a UPrimitiveComponent.AddForce(FVector, BoneName) method.  However, I cannot figure out how to use it.  The real objective of this question is as a basic introduction to programming with Unreal Engine.  I chose AddForce, because it is an extremely commonly used method with a visible effect (in Unity).  All of the existing tutorials are either with an older version of unreal (which has different scripting) or are using blueprints (which has no scripting).  That is why I am trying to figure out what the actual code would be and what that code does.

Specifically, I am looking for an answer which tells me what code is missing from my Unreal Engine script, and what that code does, similiarly as is presented with my Unity Engine example.


texts: Java Game how to make image follow line?

texts:
Hello I have a game where circles rotate around the centre of the frame. When I click on two circles a line is drawn between the two circles. The circles are always moving and so is the line. I have an image at the start of the line and I want it to move along the line at stop at the end of the line. I knowhow to start the image at the start but I don't know how to move the image along the line. How can I move the image along the line?

Here is my code:

   public class ship {

public int sx,sy,ex,ey;
public boolean arrived,sel1,sel2;
public int amountOfPop = 0;

public int fc = -1,sc = -1;

public ship(int sx,int sy,int ex,int ey,int aop){
    this.sx = sx;
    this.sy =sy;
    this.ex = ex;
    this.ey =ey;
    this.amountOfPop = aop;

}

public void tick(){

}

public void render(Graphics g){
    g.setColor(Color.blue);
    g.drawLine(sx, sy, ex, ey);
}
 }

sx and sy are the starting x and starting y. ex and ey is where the image should finish.
Please help me.


texts:
I'm currently implementing ECS in "classic" sense, as defined by this wonderful post, where we have Entities, Components and Systems. And I'm having a serious (for me) performance issues. They come from the fact that System may need access to several components of the entity:

IList<int> es = _ecsManager.GetComponentEntities(ComponentType.RENDER);

int cacheRender = -1;
int cacheMovement = -1;
foreach (var entityId in es) {
    var rc = _ecsManager.GetEntityComponent<RenderComponent>(entityId, ComponentType.RENDER, ref cacheRender);
    var mc = _ecsManager.GetEntityComponent<MovementComponent>(entityId, ComponentType.MOVEMENT, ref cacheMovement);
    rc.Sprite.Position = mc.Position;
    QueueSprite(rc.Sprite);
}

the QueueSprite is my sprite batching, it's backed by regular arrays and Lists with no dynamic in long run. And GetEntityComponent is:

public T GetEntityComponent<T>(int entityId, int componentId, ref int idxCache) where T : PslComponent {
    var cs = GetEntityComponents(entityId);
    // try for cache
    if (idxCache != CACHE_NULL && idxCache < cs.Count) {
        var tmp = cs[idxCache];
        if (tmp.TypeId == componentId) {
            return (T)tmp;
        }
        // cache miss
        idxCache = CACHE_NULL;
    }
    // cache failed, sequental search
    for (var i = 0; i < cs.Count; i++) {
        var component = cs[i];
        if (component.TypeId == componentId) {
            // update cache
            idxCache = i;
            return (T)component;
        }
    }
    // not found
    return null;
}

and GetEntityComponents:

public IList<PslComponent> GetEntityComponents(int entityId) {
    return _componentsByEntity[entityId];
}

with _componentsByEntity being a array, GetComponentEntities works similarly backed by regular array too:

public IList<int> GetComponentEntities(int componentId) {
    return _entitiesByComponent[componentId];
}

the abovementioned foreach loop is taking a lot of time. More than rendering.

As you can see, I'm pretty much tried to optimize a lot of things already, removing all Dictonary<>-type lookups, replacing all by arrays and Lists. There is no dynamic allocation in long-run. The only problem, as I see it, is sequental search in entity Component loookup.

Is there any possibility to improve component lookup speed, while remaining true to classic implementation?
Is this major performance penalty is usually assumed then ECS is used? Are ECS "bad" then high performance is required?


texts: Is there a way to use the ContentManager with full directory paths

texts:
So i want to figure out a way to use the ContentManager.Load method with full directory paths, so lets say

Content.Load<T>(@"Images\SomeImage");

becomes

Content.Load<T>(@"C:\Users\UserName\Documents\Visual Studio 2013\Projects\MyProject\Content\SomeImage");

Thanks in advance.


texts:
How do I set Unity3D to run my game on Windows 8 in a fixed size frame (with a border around it) and not in fullscreen?

I tried setting this in the Unity script and in the final C# project, but nothings seems to work.

I have set the players resolution to 1366x786 (the desired size) and while this works fine with the webplayer the windows 8 solution seems really unimpressed by it. I also tinkered with the 'Default Is Full Screen' option


texts: How to track and find entities within radius in realtime game?

texts: What is best approach to implement tracking in real time for, say, 1000 npcs? Every frame update simple a square grid (remove or insert into linked list) and every time check in square radius? I tried kd-tree but its really bad in real time updates even with 100 entities I can't reach 10 FPS.


texts:
I am developing a 8 puzzle game. I went through the rules in this (see Detecting Unsolvable Puzzles) link, which tell you how to detect if an initial state is unsolvable. It says that if the number of inversions is odd, then the goal state cannot be reached and if even the goal state can be reached.

An inversion is defined as follows:

  Given a board, an inversion is any pair of blocks i and j where i < j
  but i appears after j when considering the board in row-major order
  (row 0, followed by row 1, and so forth).

There is a 8-puzzle solver (applet) here. Choose 8-puzzle from the options.

1,0,3,2,4,5,6,7,8

and

7,0,2,8,5,3,6,4,1

As you can see both of them contain an even number of inversions. Still the program says that the puzzle is unsolvable. So is the Princeton link wrong?


texts: Opengl binding shaders vs binding buffers performance

texts: Quick question for an opengl guru, I'm in the process of building a render queue and can either reduce the number of shader binding or the number of vertex buffer binding. I just want to know which one is more expensive on newer graphics cards (IE)(opengl >= 3.2)?


texts:
I've been implementing an Entity Component System into my custom toy engine so I can learn more about it. Currently I have the following problem:

I can't think of a way of implementing input as a system. Currently I just check for key presses in the main loop, like this:

if (glfwGetKey(Window, GLFW_KEY_A) == GLFW_PRESS)
    Camera.Translate(glm::vec2(-5.0f, 0.0f) * static_cast<float>(DeltaTime));

Here I check if key A is pressed, and if it is I move the camera, which isn't a component associated with an entity.

So what I thought is creating an Entity with a Input component associated (this component would have mouse coordinates, keys pressed, etc):

ECS::Entity * InputManager = EntityWorld->create();
InputManager->assign<Input>();

Then, each frame, after polling events, I would update the Entity directly like this:

InputManager->get<Input>()->MousePosition = MousePosition;
InputManager->get<Input>()->MouseWheelDelta = MouseWheelDelta;
....

Then, I'd have an InputSystem, where I can check mouse position, if some key is pressed, etc. But what I don't understand is, if the camera is not a component, how could I make it move now that I handle input through the InputSystem?  If I make the camera a component, how would I implement all the functionality to move it around, and zoom in and out?

Let me know if something it's not clear.


texts: Unity: how to apply programmatical changes to the Terrain SplatPrototype?

texts:
I have a script to which I add a Terrain object (I drag and drop the terrain in the public Terrain field).

The Terrain is already setup in Unity to have 2 PaintTextures: 1 is a Square (set up with a tile size so that it forms a checkered pattern) and the 2nd one is a grass image:

Also the Target Strength of the first PaintTexture is lowered so that the checkered pattern also reveals some of the grass underneath.

Now I want, at run time, to change the Tile Size of the first PaintTexture, i.e. have more or less checkers depending on various run time conditions. I've looked through Unity's documentation and I've seen you have the Terrain.terrainData.SplatPrototype array which allows you to change this. Also there's a RefreshPrototypes() method on the terrainData object and a Flush() method on the Terrain object. So I made a script like this:

public class AStarTerrain : MonoBehaviour {

    public int aStarCellColumns, aStarCellRows;

    public GameObject aStarCellHighlightPrefab;
    public GameObject aStarPathMarkerPrefab;
    public GameObject utilityRobotPrefab;
    public Terrain aStarTerrain;

    void Start () {
            //I've also tried NOT drag and dropping the Terrain on the public field
            //and instead just using the commented line below, but I get the same results
        //aStarTerrain = this.GetComponents<Terrain>()[0];
        Debug.Log ("Got terrain "+aStarTerrain.name);

        SplatPrototype[] splatPrototypes = aStarTerrain.terrainData.splatPrototypes;
        Debug.Log("Terrain has "+splatPrototypes.Length+" splat prototypes");
        SplatPrototype aStarCellSplat = splatPrototypes[0];
        Debug.Log("Re-tyling splat prototype "+aStarCellSplat.texture.name);
        aStarCellSplat.tileSize = new Vector2(2000,2000);
        Debug.Log("Tyling is now "+aStarCellSplat.tileSize.x+"/"+aStarCellSplat.tileSize.y);
        aStarTerrain.terrainData.RefreshPrototypes();
        aStarTerrain.Flush();
    }

//...

Problem is, nothing gets changed, the checker map is not re-tiled. The console outputs correctly tell me that I've got the Terrain object with the right name, that it has the right number of splat prototypes and that I'm modifying the tileSize on the SplatPrototype object corresponding to the right texture. It also tells me the value has changed. But nothing gets updated in the actual graphical view.

So please, what am I missing?


texts:
I'm creating a RPG/RTS game in Unity. There are a lot of characters and potentially a lot of different environments. I'm fairly confident with the coding part (so this question isn't really tied to the game engine). I also create music myself (solo work, pad-based live drums in a band, mixing for friends, etc), so I think I have a pretty good grasp of all the neccessary tools. However, I've never created sound design for a game, and I don't really understand how to do that.

How would you organize and use sound effects? For example, you have 5 different character types and 3 different grounds — grass, mud and wood, for example — would you create 5*3 footstep sounds? Is adding random pitch for variety to a sample a good idea? What about environment sounds — do you create a main loop you just launch on the background, or do you place real sounds (water, wind, tree barks moving, birds) all over the game level?

Overall, I just have too many of this stupid random questions because I don't quite understand how this system should be designed; I would be very thankful if someone gave me a link to some sort of a guide or an article on the matter.


texts: Simple shader that scales UI image from the center

texts:
I'm having trouble making a (vertex) shader that scales UI images from the center.

I can scale the image, but the image doesn't stay centered.

Here is a project showing the problem

Here is a direct link to the shader I'm working on

How can I make it scale from the center?

See how the basketballs do not stay centered in their original rects in the below image


texts: How do I query available video memory using DirectX?

texts: How do you query the amount of VRAM available when using DirectX?


texts:
Is there any smart way to think about polygon budget relating to PC gaming today?
My game will have one static 3d background scene and two fighters. No more enemies. I am thinking about having animated 3d models in the background for atmosphere, like spectators.

So how could i find out what the polygon count for the player models and background scenarios could be. I guess the question is, what is a for today typical polygon count that most PCs can handle?


texts: How should I provide a navigation system for a world with infinite space?

texts:
The world is generated by perlin noise chunks and will only be saved once that chunk has been generated. It will also not necessarily have one obvious (to the user) central point anywhere in the world, but the chunks start at 0,0 and go in all directions.

What would work to help people find their relative position to another user or buildings?

A few ideas that have crossed my mind:

Area names - creating the names procedurally might be an issue though (?) and doesn't entirely solve the issue (until you're used to the names, they will mean nothing to you)
A grid system, then there is something to be relative to - from a user's point of view, this is pretty tedious and I can't imagine it is really a good solution (UI-wise)
A compass that shows the direction to chunk 0,0 and the distance from it, this is the closest solution for me so far
A mini map of the environment would work, but only for local areas otherwise the minimap would end up taking up the entire screen or having to scroll for ages to reach other areas

Or some combination of the above.

Any thoughts on the above or other suggestions would be greatly appreciated.


texts: Questions related to rendering to texture and rendering to buffer (OpenGL)

texts:
I am experimenting with off-screen rendering. I understand there is two solutions to this:

rendering to texture (you attach a texture to one of the FBO's attachment point which can be a color, depth, etc.)
use a render buffer.

Question 1

I first experimented with using render-buffers. I have a FBO and 2 RBOs, one for color (attached to COLOR0) and one for depth (attached to DEPTH). When I want to visualise the content of what I rendered to the render buffer, I use the glBlitFramebuffer function to copy the content from the FBO to the Window frame buffer (index 0).

glBindFramebuffer(GL_READ_FRAMEBUFFER, fboId);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);

First I would like to know if this the best way? (of passing the image from the a render buffer back to the window buffer).

Question 2

My second question. The method I described above works but I can only see the "color" buffer of the FBO, not the depth buffer (I would also like to visualise the depth buffer). So I was wondering how/if this was possible using this approach? I tried to use the index of the depth render buffer in place of the fboIdx in glBindFramebuffer but it didn't change anything. Can I make it work without using render-to-texture approach?

Question 3

My end goal is to render two images using an off-screen approach and blend them together. The result of the mix between the two rendered images is what I want to display to the screen. To keep things fast, I understand this can be done in hardware. What's the best way for doing this? Can it be done using the render-buffer approach or do I need to go the render-to-texture approach (aka render to two textures and then blend these textures using a fragment shader when I do my final pass in which I render a quad stretched over the surface of the screen?


texts: Detecting if "Wall" To The Left or Right Of Player Unity3D

texts:
I am working on a 3D Platformer in Unity3D and I need to prevent the player from going through walls. The movement for my player works like this:

(A bird-eye-view representation)The areas the player can move a divided into layers. He can slide into the 2nd, 1st , or 3rd layers. The player is not a rigid-body, and is controlled using a character controller. To move the player into these layers I simply increase his Z-Axis. Currently if my player is behind the wall he will slide directly into it. How can I determine if there is a wall to the left of the player in Unity 3D? If so, I simply wont allow the user to move to the layer until they have steered clear of the obstacle. Does anyone have any suggestions of what I should do?


texts:
What's the most recommended format should I use for fonts, OTF or TTF or another?

In looking for:

Performance/Efficiency with SDL_ttf library
Free/Open-ness [1]

[1] I'm planning to use GPL3 and Open Font License.


texts:
I've just recently switched from XNA to MonoGame and now I've run into something that has never happened to me in XNA before.

I've created a 2x2 texture and filled it with a color by doing this:

//Generates a texture from the color.
Texture2D texture = new Texture2D(Constants.GAME.GraphicsDevice, 2, 2, false, SurfaceFormat.Color);
texture.SetData<Color>(new Color[] { alternateColor });

AlternateColor = texture;

What I use this texture for is for drawing rectangles of different sizes using the specified color.
This has usually worked just fine for me in XNA but when I do this in MonoGame I get this:

The screen is suppose to be black here as I'm scaling that 2x2 texture up to fill the entire screen.

I've tried turning mipmaps off, I've tried turning multisampling off and I've tried setting my sample state [0] to use PointWrap but I just can't seem to get this to work.

Any suggestions would be much welcomed.

Thanks!


texts: How to Change position + rotation of a parent while keeping X and Z Rotation

texts:
Sooo this question is a problem , a evolution by another solution of this problem here:

How can I change the parents rotation so the childs rotation is looking at a specific direction

Basically:

We have a "Eye" (HTC Vive).
We have a "Parent" which is the Parent of "Eye".

We can not change the position or rotation of the Eye in code.
We can only change the position and rotation of the Parent.

1.We want to modify the Parent Position so that Eye to goes to a certain "Target 1" position.

2.We want to modify the Parent Y-Rotation so that the Eye looks at a certain  "Target 2" position.

3.While doing this we dont want to modify the Parent X or Z , because this would lead to a Rotated game experience.

The Parent Position changes so the Eye gets to "Target 1" position.
The Parent Position changes so Y- Rotation should look at Target 2 position
The Parent X/Z Rotation should not modify the Eye X/Z


texts: gluLookAt strange behavior implementing camera

texts:
I'm having a super tough time trying to implement what I thought would be a very straightforward problem. I'm trying to demonstrate a free camera that can move forward/back, strafe left/right, fly up/down, and look up/down/left/right. The mouse will control the look and the keyboard (WSADRF) will control the movement.

The movement appears to work just fine, and the look behavior appears to be correct from my camera starting point, but as I deviate away from the camera start point, the mouse movement goes into a crazy non-linear type thing where stuff is rotating all over and going nuts. Here's my basic camera setup:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70.0, static_cast<GLdouble>(w) / h, 1.0, 10000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glm::vec3 lookat = camera_.pos - camera_.Back();
glm::vec3 up = camera_.Up();
gluLookAt(
  camera_.pos.x, camera_.pos.y, camera_.pos.z,
  lookat.x, lookat.y, lookat.z,
  up.x, up.y, up.z
  );

My camera starts off at (0, 0, 25) and is looking at (0,0,0) where my model is. The look behaviour is fine there. As I start to approach a point like (5,0,0), the look behaviour gets completely boned. Also at that point, it feels like the camera "up" vector gets screwed up. Trying to fly up/down makes the camera kind of move in/out. Here's the code I'm using to update the camera:

static float p = 0.f;
static float y = 0.f;
static float r = 0.f;
p -= 0.5f * delta_y * dtime;
y -= 0.5f * delta_x * dtime;
camera_.ori = glm::quat(glm::vec3(p, y, r));

This problem is super frustrating, because it feels like I'm so close to having everything working, but something is evading me! For reference, here's how I calculate the Up, Right, and Back vectors from the camera orientation, which I got from this site:

glm::vec3 Actor::Right() const
{
  return glm::normalize(glm::vec3(1-2*(ori.y*ori.y+ori.z*ori.z), 2*(ori.x*ori.y+ori.w*ori.z), 2*(ori.x*ori.z-ori.w*ori.y)));
}

glm::vec3 Actor::Up() const
{
  return glm::normalize(glm::vec3(2*(ori.x*ori.y-ori.w*ori.z), 1-2*(ori.x*ori.x+ori.z*ori.z), 2*(ori.y*ori.z+ori.w*ori.x)));
}

glm::vec3 Actor::Back() const
{
  return glm::normalize(glm::vec3(2*(ori.x*ori.z+ori.w*ori.y), 2*(ori.y*ori.x-ori.w*ori.x), 1-2*(ori.x*ori.x+ori.y*ori.y)));
}


texts: how to dent & deform damaged objects in unreal engine?

texts:
I am trying to simulate damages in cars using unreal engine when a body collides with it like it is done in this video - https://vimeo.com/162729920

I am trying to do it in the first person shooter game template, so that i can shoot projectiles at the object. but the object just moves and doesn't dent. I tried creating a destructible mesh but that cause the object to break down into pieces. I want it to dent when i apply a force to it. Could someone point me in the right direction?


texts: MonoGame - correct overloads for SpriteBatch.Draw flipping horizontally

texts:
I want to flip my sprite horizontally while drawing and I can't figure out how to use the correct parameters without either an error or a warning about the method being obsolete.

This is what I assume it would be:

sb.Draw(NumbersGame.Arrow, resolutionRightArrow, Color.White,
SpriteEffects.FlipHorizontally);

Except it comes up for errors for the color (cannot convert from color to rectangle) and the SpriteEffects bit (cannot convert from sprite effects to rectangle).

What is the correct way to lay out these arguments?

P.S: When I provide all the default values (says it's obsolete):

sb.Draw(NumbersGame.Arrow, resolutionRightArrow, null, null, null, 0f, null,
Color.White, SpriteEffects.FlipHorizontally);


texts: I have two object to control and I wanted to keep them at cameras view without adjusting the cameras size but the camera can move only in positive y-axis meaning ones it goes up it shouldn't move down but it's okay if one object gets out of bounds. Since its 2D the camera is Orthographic view.


texts: How do you handle iPhone graphics for both high and low DPI settings?

texts:
How do you guys create your game graphics for iPhone? Considering you need a retina version and a nomal one?

Do you create a big version of your image, save HD, then resize to smaller version, and save Normal?

Or do you create a vector image with say, fireworks, save HD, then resize, then save Normal?


texts: How to find the closest point on multiple colliders within a box?

texts:
I need to find the position of the closest point from the bounds of multiple colliders. Right now I'm using OnTriggerStay and collider.ClosestPointOnBounds().

This works great for one collider, but as when I add a new collider, it doesn't update.

I've drawn a quick picture to illustrate what I'm trying to say. The black box is the area I want to check in, the red boxes are the colliders with numbers representing the order they entered the black box. The green star is what the code currently says the closest point is, and the blue star is the expected result. The purple star is the position I'm checking for, the blue star should be the closest point to the purple star.

I found this answer to a similar question on answers.unity3d.com. However, I feel like that could be very inefficient because there will be many, probably up to 50 of these box checking scripts running at the same time.

I've also tried using Physics.BoxCast but that gave very wild results. The area it was checking was very different to what I wanted, and also what I was visualizing with gizmos. Also, the whole idea of boxcasts are very very confusing so I would rather something else.

What is the best way to find the closest point on the bounds of multiple colliders within a certain area?


texts: How do I find the circumcenter of a triangle in 3D?

texts: I want to find the circumcenter of a triangle.  Wolfram only shows how to find the circumcircle of a triangle in R2. How can I find the circumcenter of a triangle in R3?


texts: How do I correctly shift arrays on a Tetris line clear?

texts:
I'm writing a Tetris clone in C++ and I am at the last stage, I need to delete a row when it is full. Once a piece falls it is stored in a boolean array grid[20][10]. For example I check which row is full (or true), if so I call a method deleteRow, where n is a number of row:

void Grid::deleteRow(int n)
{
  for (j = 0; j < WIDTH; j++)
   {
     grid[n][j] = false;
   }
}

Once the row is deleted I call moveRowDown:

void Grid::moveRowDown()
{
  for (i = 0; i < HEIGHT; i++)
   {
    for (j = 0; j < WIDTH; j++)
     {
       grid[i+1][j]=grid[i][j];
     }
  }
}

This does not work, and all of the pieces disappear. What logic am I missing?


texts: In Unity how do I easily snap modular building pieces to the grid without overlaps or gaps?

texts:
I'm new to Unity and purchased a set of modular building pieces from the asset store. I'm trying to arrange pieces of wall. The pieces are 5 x 5 x 0.5, so I've set my world grid size to 5 units and am using align to grid to make them line up nicely. I'm running into an issue when I try to make a corner. When I align the pieces to the grid, there is some gap and overlap, as seen in this picture:

I then tried to manually move the end piece inwards, which resulted in this:

That looks slightly better, but needed a manual adjustment so I don't think doing this everywhere scales very well, and plus there is some kind of visual/lighting artifact where the pieces overlap (hard to see in the screenshot but very obvious when I move around in game mode). Then I tried resetting that end piece back to the grid and pushing the two side pieces inwards, which resulted in this:

This looks good and has no overlap, but required a bit of manual adjustment and brought the sides off of the grid.
Assuming a set of wall pieces that are 5x5x0.5, how can I configure my grid and snap settings so that everything fits together nicely?


texts: Why do I get a blank material in Unreal Engine 4?

texts:
When I'm adding a material to a box in UE4, the material loses its textures.
I want to add this material

To this

After I'm trying to drag & drop the material into the scene above (like in UDK) the material loses its textures and does not apply:

When opening the material in Material-builder, the same thing happens: the material loses its textures and I've got these two errors on "Stats":

[SM5] (Node TextureSampleParameter2D) Param2d> Requires Texutre2D
[SM5] (Node TextureSample) TextureSample> Missing input texture

I've searched and found a thread where they say I need to save the material again to get things right. When I click the save button, I have this error:

The current material has compilation errors, so it will not render correctly in feature level SM5.

NOTE: Using DepthFade node + Lerp and changing the blend to translucent didn't resolved my issue.
Any idea?


texts: XNA - Darkening background and drawing something on top

texts:
In a game a group of friends and I are working on using XNA, we wanted to create an effect where we could darken the screen and draw something else on top of the darkened portion. For example, we have a title screen that is drawn as a background sprite, a logo, a few buttons, and a lot of particle effects (all separate Texture2D's), but when you select the "Exit" button, the entire title screen darkens, and two (undarkened) buttons are drawn over-top ("exit" and "cancel" buttons).

Initially, we were going to do this by having two separate render targets, one for the title screen, and one for the yes and no buttons. Then, when we wanted to display the topmost render target, we darkened the render target that the title screen was drawn to, and then draw the new render target on top. The problem with this is that the second render target is filled with black pixels that simply get drawn over the background, blocking it out completely.

We have two ideas to fix this. The first idea is to draw the second render target on top of the first using BlendState.Additive, so that the black pixels are simply added to the background instead of drawn over-top. The problem with this is that it makes the other buttons look weird, since they're being drawn over top other things on the title screen. The second idea was to manually set every black pixel in the second render target to Color.Transparent, but we're not sure how efficient that is.

Any ideas on how we could achieve this effect?


texts: How should I separate drawing from system collision?

texts:
Well, in my game while I'm drawing I have to verify the collision between the views. After a collision, I have to draw some things. But I can't draw them with a batch but with a stage. So I have to begin and end a lot of batches and this makes my game very slow.

Here is the part of code which I talked about:

for(int i=0;i<1000;i++)
    {
        if(i<999)
            list.get(i+1).xTubo = list.get(i).xTubo + list.get(i).distanza;

        for(int j=0;j<=60;j++)
        {
            if( (xPersonaggio==list.get(i).xTubo + j || xPersonaggio==list.get(i).xTubo-j*3)&& yPersonaggio<=list.get(i).altezza-50)
            {
                batch.begin();
                if(ySalto==0)
                    batch.draw((TextureRegion) animation.getKeyFrame(time, true), orthographicCamera.position.x - 300, 60 + ySalto);
                else
                    batch.draw(textureAtlas.createSprite("h"), orthographicCamera.position.x - 300, 60 + ySalto);
                scrittaHaiPerso.draw(batch,"HAI PERSO!",orthographicCamera.position.x-50,500);
                menu.draw(batch,"MENU",orthographicCamera.position.x,300);
                batch.end();
                stage.draw();

                fineGioco=true;
            }
        }
        batch.begin();
        batch.draw(spriteTuboVerde,list.get(i).xTubo,-30,120,list.get(i).altezza);
        batch.end();
        if(xPersonaggio>list.get(i).xTubo+50)
            tubiSaltati++;
    }

In this cycle I draw a lot of views, as you can see at the bottom. At the top I have my very rudimental collision system. When a collision happens, an imagebutton appears on the screen and I have to draw it with a stage. So I have to begin and ends a lot of times the batch and this doesn't go well at all. How can I write less batches?

NOTE: The order of drawing has to be this


texts:
I'm trying to find a good solution for a bullet to hit the enemy. The game is 2D tower defense, the tower is supposed to shoot a bullet and hit the enemy guaranteed.

I tried this solution - http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-1/

The link mentioned to subtract the bullet's origin and the enemy as well (vector subtraction). I tried that but a bullet just follows around the enemy.

float diffX = enemy.position.x - position.x;
float diffY = enemy.position.y - position.y;

velocity.x = diffX;
velocity.y = diffY;

position.add(velocity.x * deltaTime, velocity.y * deltaTime);

I'm familiar with vectors but not sure what steps (vector math operations) to be done to get this solution working.


texts:
I was considering how MMO mechanics work and especially how NPC/mob decisions are calculated and distributed among players.
Say for example that you have a team of 5 fighting a boss. The boss's actions/powers etc are hardcoded into the game code, but its decision making is based upon some probabilities, are those calculated server side and then distributed to all the players? For example, when it is going to use a specific "spell" or who it is even targeting.

1)If all these are calculated server side, is the boss considered as a single entity that acts based on input from other players or is it more event based?

If that is the case then how do people deal with latency? I mean the server has to emit the action of 5 characters to the other 4 + Boss and also then calculate what the boss is going to do?

2)Is one of the player's game engine "assigned" the control of the Boss's actions and when all the actions from the other players are broadcasted then the "choose" game engine calculates and distributes not only the players actions but also the boss's.

If that is the case then won't 1 player always be in favour due to latency being zero?

Thank you


texts: Do you actually use diagrams to model games?

texts:
I mean mostly UML but any method that works is viable. So - do you actually model your games with UML/other diagrams or different methods? I had a subject at my university about modelling with UML and it seemed like more effort than actual benefit but I realise that might be only because I've never created a huge complex IT system. So is it worth the while and what types of diagrams/methods are usually* the best?

*Of course, many times concrete tools need be chosen to concrete problems but maybe there are some patterns.

Edit: I forgot one important thing - do you create diagrams before or after implementing stuff? What I mean is - when one designs and implements something one usually changes mind or something unexpected comes up and one has to make changes, sometimes major ones - and doing them in already complex diagrams seems equally hopeless as in the code itself.


texts: Unity 2D: Sprites/Diffuse is making my character weird, like an antialias

texts:
i'm trying to put light and shadows on my 2D character but when i set the material on it to Sprites/Diffuse, it's kinda putting a strange smooth on my pixels.

Without diffuse:

With diffuse:

And i saw that with diffuse it doesn't appear any shadow, it's normal?


texts: How to make shrunken textures look pretty

texts:
I am drawing lots of textures and panning and zooming in and out on them. When the camera zooms out they look really ugly.

What can I do?


texts: How should a programmer get started with creating 2D Sprites?

texts: I am a programmer. Given a sprite sheet, I can code game as per the requirements. But I do not know how to create these sprites. I use Cocos2D. And I do not know where to begin. I have never done anything art-related before. I am aware of TexturePacker. But it only packs already created sprites. So how do I get started with creating 2D sprites? Are there any dedicated softwares for this purpose? Main main concern is about creating assets for Retina Displays.


texts: Start timer when button pressed (what is wrong with my code?)

texts:
I want a timer to start when my rocket takes off and stop when it lands. Stopping works fine (using a collider and state-switching) but I can't get the timer to start when I press the boost button.

Currently the timer text is displayed at the moment I pressed the button but clearly has been counting from the moment the scene started, not the moment the button is pressed.

Any help will be greatly appreciated. If there is a better way to start the timer rather than when I press the boost button then I am open to ideas!

Here is the all relevant code (I think). It appears as though it should be working to me, but it isn't.

// Timer
public Text timerText;
private float startTime;
private bool started = false;
private bool finished = false;

  void Start ()
{
    startTime = Time.time;  // get time since scene started
}

void Update ()
{
    if (currentState == State.Alive)
    {
        ProcessBoostInput();
        ProcessRotationInput();
        ProcessFiringInput();
        if (started)
        {
            RunTimer();
        }
    }

}

    private void ProcessBoostInput()
{
    if (Input.GetKey(KeyCode.A) || (CrossPlatformInputManager.GetButton("Fire1")))
    {
        BoostShip();
        PlayBoostSound();

        if (started != true)
        {
            started = true;
        }

    }

    private void RunTimer()
{
    if (finished)
    {

        return;
    }
    else if (started)
    {
        float timeSinceTimerStart = Time.time - startTime;

        string minutes = ((int)timeSinceTimerStart / 60).ToString();
        string seconds = (timeSinceTimerStart % 60).ToString("f3");

        timerText.text = minutes + ":" + seconds;
    }
}
private void StopTimer()
{
    finished = true;
    timerText.color = Color.green;
}


texts: finding the angle of rotation of a 3d line

texts:
I have a line segment joining two 3D points AB, and a vector V which is normal to it.
I need to know the angle of AB in the plane described with V as the plane normal, that is: in the plane of the two vectors (AB) and (AB cross-product V)
EDIT: Much more information...

The points A and B (red dots) have x,y coordinates in the camera image, and an extrapolated depth (z) from the camera itself.  The vector V (white line) is calculated from two more points with the same process.
I have successfully matched rotation around the Z axis (camera view direction) so a (Unity) 3D object will track the wrist angle as it 'waves' (rotation in that single plane).  Now I want to also include twisting motion defined as rotation around the wrist bone (blue ellipse attempting to represent rotation in a plane) like tipping a cup.
This image is from a fixed webcam, but I would like the process to also work from a mobile phone (moving camera, with translation and rotation potentially) and one of my assumptions has been that if everything is camera relative via the screen projection, this will be automatically included.
By using a 'dumb as bricks' approach I have it working when the arm is horizontal... I can't work out how to make it work at other angles e.g. vertical:
            Vector3 AB = (B - A);
            return -Mathf.Atan2(AB.z, AB.y) * Mathf.Rad2Deg;

UPDATE3:
This question now seems to have two parts:

what can I use as a fixed reference direction when the plane can be orientated in any direction?
how do I get an angle between that fixed reference and the line in that plane?

In searching I've come across both Rogrigues' Rotation Formula and this answer about rotating planes, but I haven't been able to work out how to apply either of them to this particular problem (I do feel like I'm missing a really obvious trick!)
Edit: My first idea is to rotate A and B so that V is aligned with the cartesian X axis and (ABxV) is aligned with Y, then use atan2(dy, dz).  I have just started to look for a working solution to performing that rotation.
Edit2: It's been pointed out referring to a cartesian X axis is ambiguous... I'm not sure but I think camera axis (horizontal/vertical in the image plane plus depth) might serve?

An alternative description of the geometry is that I have a cylinder with its long axis aligned with V, and the points A,B are opposite sides of the end-cap circumference... and I need to know the rotation of the cylinder around its long axis described by AB (relative to any arbitrary consistent 0 angle).
UPDATE: In case it breaks assumptions, my values are all measurements from a live camera, so the 'normal' vector V may not be exactly normal to AB... it should always be pretty close though (within a few degrees).


texts: How can I create a random deck of 7 cards every time they are all used?

texts:
I'm trying to create a Tetris like game in C# (Unity) and I've run into quite a problem on how I can generate 7 cards (tetrominoes) of which none are the same and when I run out of cards, I regenerate more.

I can kind of see how I could do the regeneration part but I'm very unsure on getting 7 cards for which none are the same.


texts: Are game programmers aware of all the physics derivatives?

texts:
I am trying to study XNA for game programming. XNA has many methods that can simplify developer's life, such as reflecting the vector when it hits a solid plane.

I know these are good and developers almost always work at an abstracted level, which is also the basic fundamental of OOP. I am not comfortable with physics, nor have I studied physics anytime during my schooling and so it gets difficult for me to understand how these abstracted methods work.

Do developers need to be physics gurus in order to make good, not necessarily excellent, games? Are all professional game developers good at physics? Put simply, are they all Einstein types? Or is it just fine even we are not aware of what goes under the hood in abstracted XNA methods?


texts: How to align prefab to a accurate position with the best practice?

texts:
I'm making a plumber game, I have a pump prefab, and pipe section prefab, which allows the user to connect the pipe during game, the pipe needs to be connected seamlessly during game, which means pipe prefab needs to be aligned in pixel level, please check below

User needs to add more and more pipe to connect the with each other, pipe is fixed length prefab.I've got choices,
1.Is the pipe prefab instantiated during game play a good practice? Because it might have many pipe prefabs, if the pipe goes a long way to another position, than there will needs to be so many pipe prefabs, compared to have procedrually generated pipe mesh during runtime, then a long pipe will not have to be cut off to the same small pieces?Which is good way to adpot?
2.If I use the same pipe prefabs to fabricate the piping system, how to accurately connect each other in pixel level, I can make the whole piping system in blender, then cut the system into pieces as my prefabs, then import to Unity as my first choice, this can do pixel level connection, but it seems to have better choice solely solved pixel level connection in Unity?
3.If I do it by generating the mesh during game play, then it could be complex especially it is hard to make elbow pipe mesh during runtime, or could you please advise me of some known library or package can do the work?


texts: How to sort cards' on-screen positions by their suit?

texts:
I have a 13 cards and sort button.

When I click that button, I want all the cards of each suit to be grouped-together on screen. So if I have 4 diamond cards in my 13-card hand, all 4 diamonds must be placed together in one part of the hand. If I had 4 spades then all 4 spades must be placed together in a separate part of the hand.

Here's an example of a sorted hand of cards - note how all the cards of each suit are placed together in a row:

So far I tried to Sort using Linq. When I inspect the sort order using Debug.Log it seems to be working fine, but I don't know how to position the cards on screen according to their suits.

Here is the code I'm using so far.
Note: UserServedcards is the collection of 13 cards dealt into the player's hand.

if (!SortCardOrder)
{
    List<GameObject> cardOrder = null;
    cardOrder = this.userServedCards.OrderBy(go => go.name).ToList();

    foreach (GameObject userServedCards in cardOrder)
    {
        if (!userServedCards)
        {
            Debug.Log("Sorting -->" + userServedCards);
        }
    }
}


texts:
I cannot load the song into my game. I got error in both templates WindowsDX and WindowsGL. Monogame Develop Build 1252

Both files .wma and .xnb are exist in Content folder and Build Actions are sets to Content, and Copy Always to output dir. Checked with mp3/ogg too but with no result.

The Song works perfect with XNA, and with MonoGame I cannot load any song.

Edit SOLVED: The newest build 1478 solved the problem

DX

GL


texts: Is it possible to use SFML with the Android NDK?

texts:
I've started using SFML recently and I absolutely love it. I'd like to make games that could be ported to android, linux, mac and windows, but it seems that SFML lacks portability.

I've searched for a while and I've only found unrelated or unanswered questions on forums.

Does anyone know of any way to use SFML with the android NDK or any plans to support it in the future?


texts: How to Hold on Final Frame of Animation in Godot

texts:
I am learning Godot 3.0 and I have a question concerning animation.

I have a player object whose node structure is KinematicBody2D > Sprite > AnimationPlayer. In the AnimationPlayer, I have ascend and descend animations that I want to play until their final frames, at which point I want to hold on those frames.

For now, I initiate my animations using the following function, which looks at my player's state attribute:

func animate():
    var animation_player = $Sprite.get_node("AnimationPlayer")

    # image matches orientation
    if orientation == "LEFT":
        $Sprite.flip_h = true
    else:
        $Sprite.flip_h = false

    # animation depends on state
    if state == "idle":
        if not ["idle"].has(animation_player.current_animation):
            animation_player.play("idle")

    if state == "run":
        if not ["run"].has(animation_player.current_animation):
            animation_player.play("run")

    if state == "ascend":
        if not ["ascend"].has(animation_player.current_animation):
            animation_player.play("ascend")

    if state == "descend":
        if not ["descend"].has(animation_player.current_animation):
            animation_player.play("descend")

I have disabled looping for my ascend and descend animations and yet they still loop. Probably because when their animation finishes, the idle animation starts and is then immediately changed back to ascend or descend since the player is still in this state.

So my question is: How do I go about holding on the final frame of certain animations?

I have looked into the animation_finished() signal of the AnimationPlayer, but I can't figure out how to use it properly.

All I can think to do is use a Call Func track on the ascend and descend animations, calling a custom function at the end of these animations which switches to a different, single-frame but looped animation (ascend_static or descend_static). But surely there is a better way?


texts: How can I take screenshots with two cameras simultaneously in Unity?

texts:
I am trying to capture different parts of a scene created in Unity. I have two cameras capturing different parts of the scene. Now, I need to take screenshots using these two cameras simultaneously. Right now, every time take a screenshot, it only captures scene from one camera.
Thank you!


texts: Vertex Displacement Distortion Correction

texts:
I am developing for Mobile VR using GoogleVRSDK and Unity. My target platform is Android.
I have a shader which displaces vertices to create a reverse lens distortion.

Following is my shader,

Shader "Unlit/Cube"
{

Properties {
    _Color("Main Color", Color) = (1,1,1,1)
}

Category {

    Tags { "Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="Opaque" }

    Blend Off
    AlphaTest off
    Cull off
    Lighting Off
    ZWrite On
    ZTest LEqual
    Fog { Mode Off }

    SubShader {
        Pass {
            CGPROGRAM

           // #pragma target 3.5
           // #pragma target 2.0
           // #pragma only_renderers gles2
           // #pragma only_renderers gles

            #pragma vertex VertexProgram
            #pragma fragment FragmentProgram
            #pragma multi_compile __ GVR_DISTORTION
            #include "GvrDistortion.cginc"

            struct VertexInput {
                half4 vertex : POSITION;
                half4 texcoord : TEXCOORD0;
            };

            struct v2f {
                half4 vertex : SV_POSITION;
                half4 uv : TEXCOORD0;
            };

            v2f VertexProgram (VertexInput v)
            {
                v2f o;
                o.uv = v.texcoord;
                o.vertex = undistortVertex(v.vertex);
                return o;
            };

            fixed4 _Color;

            fixed4 FragmentProgram (v2f fragment) : COLOR
            {
                return _Color;
            }
            ENDCG
        }
    }
}

Following is my GvrDistortion.cginc

#if defined(GVR_DISTORTION)

float4x4  _Undistortion;
float     _MaxRadSq;
float     _NearClip;
float4x4  _RealProjection;
float4x4  _FixProjection;

float distortionFactor(float rSquared) {
  float ret = 0.0;
  ret = rSquared * (ret + _Undistortion[1][1]);
  ret = rSquared * (ret + _Undistortion[0][1]);
  ret = rSquared * (ret + _Undistortion[3][0]);
  ret = rSquared * (ret + _Undistortion[2][0]);
  ret = rSquared * (ret + _Undistortion[1][0]);
  ret = rSquared * (ret + _Undistortion[0][0]);
  return ret + 1.0;
}

// Convert point from world space to undistorted camera space.
float4 undistort(float4 pos) {
  // Go to camera space.
  pos = mul(UNITY_MATRIX_MV, pos);
  if (pos.z <= -_NearClip) {  // Reminder: Forward is -Z.
    // Undistort the point's coordinates in XY.
    float r2 = clamp(dot(pos.xy, pos.xy) / (pos.z*pos.z), 0,     _MaxRadSq);
    pos.xy *= distortionFactor(r2);
  }
  return pos;
}

// Multiply by no-lens projection matrix after undistortion.
float4 undistortVertex(float4 pos) {
  return mul(_RealProjection, undistort(pos));
}

// Surface shader hides away the MVP multiplication, so we have
// to multiply by _FixProjection = inverse(VP)*_RealProjection
// and then by inverse(M), in order to cancel it out and leave our
// own transform in place.
float4 undistortSurface(float4 pos) {
  float4 proj = mul(_FixProjection, undistort(pos));
  return mul(unity_WorldToObject, proj);
}

#else
// Distortion disabled.

// Just do the standard MVP transform.
float4 undistortVertex(float4 pos) {

 return mul(UNITY_MATRIX_MVP, pos);
}

// Surface shader hides away the MVP multiplication, so just return   pos.
float4 undistortSurface(float4 pos) {

  return pos;
}

#endif

This shader works completely as excepted in Samsung S6 and LG G3 and the Unity Editor.

But we are working for a phone named Venus. In that phone shader renders but the displacement of vertices doesn't happen.

I tried disabling conditional compiling.
I tried changing render targets and forcing different OpenGL versions in render.

Nothing worked.
I would love to hear a solution. Thank you.

The specs of the Venus,

GPU Adreno(TM) 405
Runs OpenGL ES 3.0
GPU SM:4.0 and VRAM 512MB
RM 2gigs
Screen 1080x1920 60hz  dpi 480
Android 5.1 API-22
CPU is ARMv7 VFPv3 NEON (8 cores)

The shader in LG G3 :

The shader in Venus :


texts: real-time multiplayer server, interpolation and prediction validation

texts:
I'm building a HTML5 / Websockets based multiplayer canvas game for Facebook and I've been working on the server code for a few days now. While the games pretty simple with a 2d top down, WSAD controls and mouseclick fires a projectile to the cursor x/y - I've never had to do real-time multiplayer before. I've read a few great documents but I'm hoping I can overview my general understanding of the topic and someone can validate the approach and/or point out areas for improvement.

Authoritative multiplayer server, client-side prediction and entity interpolation (and questions below)

Client connects to server
Client syncs time to server
Server has two main update loops:

Update the game physics (or game state) on the server  at a frequency of 30 per second (tick rate?)
Broadcast the game state to all clients at a frequency of 10 per second

Client stores three updates before being allowed to move, this builds up the cache for entity interpolation between update states (old to new with one redundency in case of packet loss)
Upon input from the user, the client sends input commands to server at a frequency of 10 per second - these input commands are time stamped with the clients time
Client moves player on screen as a prediction of what the server will return as the final (authoritative) position of client
Server applies all updates to its physics / state in the previously mentioned update loop
Server sends out time stamped world updates.
Client (if is behind server time && has updates in the queue) linearly interpolates the old position to the new.

Questions

At 1: possibility to use NTP time and sync between the two?

At 5: time stamped? Is the main purpose here to time-stamp each packet

At 7: The input commands that come in will be out of sync per different latencies of the clients. I'm guessing this needs to be sorted before being applied? Or is this overkill?

At 9: is the lerp always a fixed amount? 0.5f for example? Should I be doing something smarter?

Lots of questions I know but any help would be appreciated!!


texts: How do I smooth out the edges at the end of the threshold on noise?

texts:
I'm making a terrain generator for a game and I need it to smooth down to a float, I've tried a bunch of different things with lerping but I can't figure it out.

I need to stop this from happening by smoothing the height down to 1 once it gets to the edges.
public LevelManager level;

public float noise;
public float oceanNoise;
public float mountainNoise;

public Transform water;
public Transform land;

public void Start()
{
    level = FindObjectOfType<LevelManager>();

}
public void Update()
{
    float landNoise = noise + oceanNoise;
    noise = SimplexNoise.Noise(transform.position.x * level.deatalscale, transform.position.z * level.deatalscale);
    oceanNoise = SimplexNoise.Noise(transform.position.x * level.oceanDetailScale, transform.position.z * level.oceanDetailScale);
    mountainNoise= SimplexNoise.Noise(transform.position.x * level.mountainDetailScale, transform.position.z * level.mountainDetailScale);

    if (noise > level.thresh)
    {
        land.gameObject.SetActive(true);
        water.gameObject.SetActive(false);

    }
    else
    {
        land.gameObject.SetActive(false);
        water.gameObject.SetActive(true);

    }

    if (oceanNoise < level.oceanHhresh)
    {
        land.gameObject.SetActive(false);
        water.gameObject.SetActive(true);

    }

    if (oceanNoise < level.oceanHhresh)
    {
        land.gameObject.SetActive(false);
        water.gameObject.SetActive(true);

    }
    land.transform.localScale = new Vector3(level.planeScale, Mathf.Lerp(noise*level.height,1,noise) * level.height + level.addHeight, level.planeScale);

    if (level.landpos.Contains(transform.position))
    {
        Destroy(gameObject);
    }
}

This script goes on the terrain chunk and it uses its position to find value in noise, the level manager just holds a few settings.
Any help is appreciated, thanks in advance.


texts:
I know this is probably a popular question and can be very vague, so I'm going to be as specific as possible. I don't really know how to even form this question to be able to search Google, so I came here.

I've been following the tutorials from learnopengl.com and they have been by far the best explanations I've found on modern OpenGL anywhere. After I'm done with the tutorials, I'll be making a game. I have already started working on the game engine and it works just fine on Ubuntu and Mac OS X. Building the project is done with CMake (I've found this to be the easiest). The project uses GLFW and Glad as used in the tutorial. I can post the GitHub repo if you want.

Today I started trying to figure out how to get the project to run on Windows, but don't even know where to start. Hence coming here. I plan on using Visual Studio but haven't used it since college. How do I even start making the project? I've tried building GLFW on the machine and the building the project using CMake, but I get build tool errors that I don't know how to troubleshoot. Where do I begin?


texts:
I have observed that many big and well-known game developers often develop their own engines. Examples include Valve, Crytek, Ubisoft, Epic Games and Square-Enix.

Could it simply be because they can, or is it likely that existing engines do not meet enough requirements, so we would develop our own? I can hardly imagine a game that requires a specific engine. The likes of of Unity or Unreal are simply enough to make any kind of game; even if not, they have source code, which can be modified to satisfy even some extraordinary needs.

Why would a game developer write their own engine instead of using existing ones?


texts: Online convertible board game that is not online but based on multiple players

texts:
I'm wondering how a system can be made compatible with networking operations (client-server). By saying "networking operations" I mean a system that can handle online operations, multiple user interactions and client-server processes.  For example, in programming term, lets imagine we created a Board class for our awesome board game and this game is played with multiple players but we don't know how to make this game online (This Board class to be online for multiple users) since we don't know how to convert our board game to online, we decided to make the board game be able to convertible to online board game. For example, you made this game and posted to github.com and someone found your game very interesting and said "I want to make this online with a game library or engine". In that case, the first (positive, good) scenario is that the person that wants to make this game online will say "Yeah this game's codes can be converted to online so I can do it" and the second (negative, bad) scenario is that the person will say "This game is quite nice but the codes are as terrible as that cannot be converted to online" So if we want first scenario to happen, we have to make the codes convertible to online. But I don't know what the requirements are and how to achieve this. But I have a theory.
My theory: the board class that represents whole game must be convertible to JSON to transfer the board from server to client or from client to server. So the board that is in client can easily be synchronized with server's board by JSON data transferring. So my board class must represent methods like named "getBoardAsJSON(), toJSON()" so the JSON data that is obtained from the board can be carried to client and to server.
My questions are:

What fundamentals, features are needed for my board game to be able to converted to online?

Is JSON convertible feature enough for my board game to be online?


texts: My sweep and prune is giving false positives

texts:
My code is just giving false positives.
Every frame it reports an imaginary collision.

Here is my code

Sweep And Prune:

 public static void updateObjects() {

     List<BoundingBox> activeList = new LinkedList<>();
     boolean adding = true;
     for (BoundingBox box : axisList) {
        box.getOverlappingPairs().clear();
        if(adding) {
            activeList.add(box);
            adding = false;
        }else {
            for(BoundingBox e : activeList) {
                if(box.collides(e)) {
                    box.setOverlappingPairs(e);
                    System.out.println("COLLISION " + box + " : " + e);
                }else {
                    activeList.remove(box);
                }

Edit:

My AABB boxes are colliding with themselves.
I have debugged my classes and have narrowed it down to the sweep and prune class.

I would appreciate if someone would help me.


texts: how can i make a sprite from a spritesheet increase its size?

texts:
I want to be able to increase the size of a sprite to give the illusion that it is walking towards you (or decrease in size to move away).
how do i manipulate the size of a loaded sprite off a sprite sheet (png format, if that matters)?


texts: How can I play an animation in response to an event?

texts:
I've written a script to play an animation, but it starts immediately as my level loads. Instead, I want it only to start when triggered by some event or after a given timeout.

How can I do this?


texts: What coding issues can be significant in damaging the performance of a game?

texts:
I have just finished a 2D game in Java that I've been working on for a while.

I found that on some computers it runs fine, and on others (which are not particularly slow in general), the game runs a little slower, and with minor interruptions every second or so. Not completely smooth.

Since I am a beginner to making games, and probably since I didn't plan everything about the game in advance, the code of the game is rather long, clumsy and probably inefficient.

I want to improve this in my next projects. So my question is - In general, what would be the main causes for a common 2D game to slow down on a computer?

What should I pay the most attention to, next time, in order to design an efficient game?

Making a small amount of classes? (Even if the classes are small
ones?)
Avoiding repetition of code? (Even small sections of code, such as
short if statements).
Avoiding too many threads running?
Anything else?

Obviously, all of the above are recommended for an efficient program.

But I'd like to know, what in a game's code, could be especially significant for making an efficient application, and what would be less important and will not save significant amounts of memory.

Any advice would be welcome - could be regarding game design, or regarding more specific coding issues.

I don't know if this matters, but please note that I'm talking mainly about real-time games, using a 'game-loop' that constantly updates the game and the dispaly.

Thank you


texts: Can I use plain old C++ objects and smart pointers in UE4?

texts:
I'm a big fan of reusable code and want to make use of code that I integrate into UE4 projects outside of the engine as well. I am new to UE4 dev, so this is my first attempt of weaving the UObject world with the plain C++ world.

I have made myself familiar with UE4 GC, and as far as I understand there is no reason that this shouldn't work. However, when the game's shutting down I'm getting memory exceptions that seem to point at referencing deleted memory.

Here are two classes, one a Camera class that manages lifetime of connection to an OpenVR camera, and a UObject facade that patches the Camera functionality into UE4 land and handles UE4 specific code.

My specific question on this code would be: is there any reason I can't/shouldn't use smart pointers as a member of a UObject to manage the lifetime of objects outside UE4's purview as I have here?

// This is an RAII class to wrap and own the lifetime of a tracked VR camera handle and buffers
class Camera {
public:
    // Create a camera object operating on a specific index and frame type
    Camera(int idx, vr::EVRTrackedCameraFrameType frameType);

    // Get the size of the camera frame
    void GetFrameSize(uint32 *width, uint32 *height, uint32 *bufferSize);

    // Creates a render target that is compatible with the camera capture
    UTexture2D *CreateCompatibleRenderTarget() const;

    // Captures a camera frame to a provided render target if a new one is available
    void CaptureToRenderTarget(UTexture2D *target);

    // Clean up buffers and stuff
    ~Camera();

    const vr::TrackedDevicePose_t &Pose() const {
        return pose;
    }

private:

    const int idx = vr::k_unTrackedDeviceIndexInvalid; // openvr device index for hmd
    const vr::EVRTrackedCameraFrameType frameType;
    vr::IVRTrackedCamera *camera; // openvr tracked camera function interface

    uint64_t hndCam = 0; // openvr camera handle

    uint32 width = 0; // Width of the camera frame
    uint32 height = 0; // Height of the camera frame
    std::vector<uint8> buf; // Buffer to hold frame capture data

    vr::TrackedDevicePose_t pose; // Current pose of the tracked camera
    uint32_t lastFrame = 0; // Last successful frame index
    bool rendering = false; // Whether a render thread op is pending

};

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class MYPROJECT_API UHMDCamView : public UActorComponent
{
    GENERATED_BODY()

public:
    // Sets default values for this actor's properties
    UHMDCamView();

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

    std::unique_ptr<Camera> camera;

public:
    // Called every frame
    virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

    // Expose the render target pointer to blueprints
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="VRCAM")
    UTexture2D *RenderTarget;
};


texts: Why is my player not giving a knock back when it stays at the right side of the enemy?

texts:
So, I have this problem I am facing, for some reason my player does not get a knockback when it stays at the right side of the enemy but when it stays at the left side it gives a knockback. What's the problem?

PLAYER MOVEMENT

void Movement()
    {

        //THIS IS FOR WALKING
        if (isControlesEnabled)
        {
            moveInput = Input.GetAxisRaw("Horizontal") * runSpeed;
            myBody.velocity = new Vector2(moveInput, myBody.velocity.y);
        }

PLAYER KNOCKBACK

private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Enemy"))
        {
            health -= 0;

            if (health <= 0)
            {
                gameObject.SetActive(false);
            }
            else
            {
                ContactPoint2D contactPoint = collision.GetContact(0);
                Vector2 playerPosition = transform.position;
                Vector2 dir = contactPoint.point - playerPosition;

                dir = -dir.normalized;

                myBody.velocity = new Vector2(0, 0);
                myBody.inertia = 0;

                isControlesEnabled = false;
                Invoke("EnablePlayerControles", controlesDisablePeriod);

                myBody.AddForce(dir * knockBackForce, knockBackForceMode);
            }
        }
    }

    private void EnablePlayerControles()
    {
       isControlesEnabled = true;
    }


texts: How to create animation using sprite sheet in C++ and SFML 2.0?

texts:
I was wondering how do animation using a sprite sheet. I have a sprite sheet and the size is
height:400
width:601

The code I am using is:

#include<SFML/Graphics.hpp>
#include<iostream>
#include <string>
int main() {

sf::RenderWindow Window;
Window.create(sf::VideoMode(980, 760), "Game Engine");
sf::Texture Ptexture;
sf::Sprite playerImage;
if (!Ptexture.loadFromFile("spritesheetIdle.png")) {
    std::cout << "error file not found\n";
}
playerImage.setTexture(Ptexture);
while (Window.isOpen()) {
    sf::Event Event;
    while (Window.pollEvent(Event))     {
            switch (Event.type)
            {
            case sf::Event::Closed:
                Window.close();
                break;

            }
                }
    Window.draw(playerImage);
    Window.display();
            }

        }

If you could then can you please try to explain me about sf:IntRect() too?


texts: libgdx scene2d DelayAction and SequenceAction

texts:
I'm trying to get the delay action in scene2d working correctly. I have multiple image objects which I store in an array and I have managed to get them all displaying, scaling and moving correctly. I can't however seem to get them moving independently using the delay action.

I have tried using the sequence action and that isn’t working either…

I’m trying to create transition effects using little squares that move off the screen.

I have included a sample of the code im using below:

for (i = 0; i < scaleActions.length; i++) {
    ScaleByAction scaleAction = new ScaleByAction();
    scaleAction.setAmount(-0.1f);
    scaleAction.setDuration(0.5f);

    scaleActions[i] = scaleAction;
}

float increase = 0;
for (i = 0; i < delayActions.length; i++) {
    DelayAction delayAction = new DelayAction();
    delayAction.setDuration(0.05f+increase);
    increase += 0.1;
    delayActions[i] = delayAction;

}

for (i = 0; i < boxArray.length; i++) {
    SequenceAction sequence = new SequenceAction(scaleActions[i],moveActions[i],delayActions[i]);
    boxArray[i].setOrigin(boxW / 2, boxH / 2);
    boxArray[i].addAction(sequence);

    //boxArray[i].addAction(sequenceActions[i]);
    //boxArray[i].addAction(scaleActions[i]);
    //boxArray[i].addAction(moveActions[i]);
    //boxArray[i].addAction(delayActions[i]);
}

public void addToStage() {

    for (i = 0; i < boxArray.length; i++) {

        stage.addActor(boxArray[i]);
    }
}

Everything seems to be moving and scaling at the same time, the delay doesn’t look like it is even working.

Hope you guys can help point out what I'm doing wrong.


texts: Unity Particle not visible inside an object with vertexlit blended shader

texts: I'm developing a game with unity and I'm using a sphere with a texture on it as skybox in my game to fade 2 skyboxes when its the sunset or the sunrise. But my clouds work with a particle system and when the sphere is active, the clouds are not visible, how could I fix this? (The clouds are active on both images)


texts: best way to destroy an gameobject in unity

texts:
MissingReferenceException: The object of type 'GameObject' has been
  destroyed but you are still trying to access it. Your script should
  either check if it is null or you should not destroy the object.
  grid.objGridSize () (at Assets/scripts/grid.cs:119) grid.hit
  (System.String hitObjString) (at Assets/scripts/grid.cs:109)
  grid.Update () (at Assets/scripts/grid.cs:80)

I'm getting this error and strange results after finding a gameobject, storing it in a new GameObject variable and then destroying it:

void Update () {
    if(Input.GetButtonDown("Fire1")){ // detect left mouse click

        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        Debug.Log("clicked");

        if(Physics.Raycast(ray, out hitObj)){
            if(hitObj.collider != null){

                // send a message to the object that got hit
                hit(hitObj.collider.gameObject.name);
            }
        }
    }
}
public void hit(String hitObjString){

    Debug.Log("I got hit: "+name);

    GameObject hitTile = GameObject.Find(hitObjString);

    if( hitTile.tag == "tile"){

        Destroy(hitTile);
    }
}


texts: How to hide player when in Shadow using Unity 2D Light System?

texts:
I have been looking for this for a couple of days now and cant find an answer; how can I hide a player when they are in the shadow when am using Unity 2D Light System? I know I can choose not to cast light on objects, but when I do it still shows the object in the shadow. What am looking for is hiding the player completely when they are in shadow, and when the light hits them it would reveal the player. This effect is in the game Among Us, I know that they are using some sort of shaders and they didn't have 2D light when they were developing it.
So am assuming this would be a shader as well where it would reveal the player when they are in the light and hide them when they are in the shadow. Below are pictures of what I have and what I want it to look like.
This is what I have in Unity

So you can see that the player is not hidden in the shadows, but rather its blacked out.
But this is what am looking to recreate:

You see how the top half of the body which is in the shadow is hidden while the bottom half is revealed because its in the light? This is the effect that I want to recreate.
Is there some sort of Shader or code that can do this? I really been looking for something like this for so long and couldn't find it. Any help will be really appreciated.


texts:
I'm trying to scroll my background forever and so I'm using the background image twice. When the first one goes off screen, it should relocate to the end of the second one. However, there seems to be a black bar inbetween the two images and so it seems that the image is not being moved into place quick enough. What would be the algorithm to do such a thing to give the illusion of a continuous background?
I've got this at the moment (which loops, but with a black bar in between the background image)

 GeneralTransform gt = bg1Canvas.TransformToVisual(Application.Current.RootVisual as UIElement);
        Point bg1Offset = gt.Transform(new Point(0, 0));

 GeneralTransform gt2 = bg2Canvas.TransformToVisual(Application.Current.RootVisual as UIElement);
        Point bg2Offset = gt2.Transform(new Point(0, 0));

 bg1.TranslateX -=  playerVel.X; //bg1 and bg2 are the composite transforms for the canvas
 bg2.TranslateX -=  playerVel.X;

 if (bg1Offset.X < -bg_width)
     bg1.TranslateX -= bg1Offset.X - bg_width;
 if (bg2Offset.X < -bg_width)
     bg2.TranslateX -= bg2Offset.X - bg_width;

Any ideas?

Edit - Updated code
Edit 2: New code with three images (all same width). Works for the first few scrolls, then suddenly stops working and no background is displayed.

if (bg1Offset.X < -bg_width )
                bg1.TranslateX = bg3Offset.X+bg_width;

            if (bg2Offset.X < -bg_width )
                bg2.TranslateX = bg1Offset.X + bg_width;

            if (bg3Offset.X < -bg_width)
                bg3.TranslateX = bg2Offset.X + bg_width;


texts:
I had previously asked this for 3D but now I changed my strategy and would like to do the intersection in 2D.

The Rectangle is axis aligned and will always be in a fixed position, and has a constant shape and size, basically I want to clip the red areas of the triangles that extend outside the bounds of the rectangle.
The triangles could be in any position, shape or size, I my code I have a loop where I check the triangles one by one, however I am still clueless about the math.

I have identified 5 cases of triangle rectangle intersection as shown here.

How do I find the intersection points of the triangle and the rectangle?


texts: In track and field dash, determine starting speed from a final time with acceleration

texts:
I am developing an athletics game, and working on the mechanics of the 100 meter dash. The player controls an athlete, that during the race has acceleration and a max speed. To win the race, the player has to collect boost tokens, which will increase the max speed.

So when the dash starts, the athlete will accelerate to his max speed, then when the athlete picks up a token, the max speed will increase, and he will accelerate again to the new max speed.

The problem is, I want to set the fastest time possible. In a config file, I want to set the fastest possible 100m dash time to 9.4 seconds.

How do I determine my starting max speed, so that when all tokens are collected, the final time will be 9.4 seconds?

This code is not actual code, but to illustrate the problem, and provide an example with numbers.

const acceleration = 6; // meters / seconds^2
const numTokens = 10;
const tokenDistribution = 100 / (numTokens + 1); // one token per 9.1 meters (and not on the finish line)
const tokenIncreaseSpeed = 1; // meters / seconds
const bestTime = 9.4; // seconds

const maxSpeed = ?? // meters / seconds - value so with all tokens the final time is 9.4 seconds...
const speed = 0;
// Pseudo loop code
update(delta) {
    speed += acceleration / delta;
    if (speed > maxSpeed) speed = maxSpeed;
    if (player.collides(token)) {
        maxSpeed += tokenIncreaseSpeed;
    }
    player.y += speed / delta;
    if (player.y > finishLineY) endRace();
    render() etc...
}


texts:
I am facing a problem below is the detail.

There are two scripts(actually more than two but these have the problem) Cannon.cs and Launch.cs and three buttons(up, down, and launch) to move cannon and launch the bullet.
Cannon have bullets and each bullet has Launch.cs attached also a RigidBody2D.
When specific event occurs the Cannon.cs calls the Launch.cs's Launch(direction); method.
Parameter "direction" = Cannon.transform.right.
Bullets are being instantiated dynamically and are stored in the list Cannon.cs take one bullet and fires it(firing includes calling the Launch(direction));.
Launch(direction); will always be called once no matter what also to double sure myself I destroy the launch script on launch.

The problem is once the bullet is fired or launched in the direction specified by the direction of cannon(since direction = cannon.right) and I click on the up or down button the launched bullet changes its direction which should never happen because Launch() method is called only once in the lifetime of the bullet and also I detach the Launch.cs script on launch.

I am using rigidbody2D.velocity = direction * thrust; what I think is that rigidbody2D.velocity once called will possess the direction just like a method called by reference. I am totally lost I hope I made my question clear please do help me if you can.


texts:
I'm trying to make a simple 2D animation file format. It'll be very rudimentary: only an XML file containing some parameters (such as frame duration) and metadata, and some images, each representing a frame.

I'd like to have the whole animation (frames and XML document) packed in a single file. How do you suggest I do that? What libraries are there that would allow easy access to the files inside the animation file itself?

The language I'm using is C++ and the platform is Windows, but I'd rather not use a platform dependent library, if possible.


texts: How are animations specified by an artist but implicitly understood by the game engine?

texts:
I'm trying to understand the relationships between 3D models (files) and the games that load and use them. As a software engineer, I'm willing to make the few following assumptions:

I would assume that most (popular) 3D model formats are basically just storing coordinate positions for all the vertices that make up the model. They probably also store texture/theming information about each polygon (that is formed by combining 3+ vertices)
I would also assume that "labeled animations"" are stored in these files as well. This way, a 3D artist could make a model of some character, and animate them running all from inside whatever tool they use for modeling. Then they associate that animation with some label ("bad_guy_running") and all that info is stored inside the resultant file. Then, in the game code, the developers can programmatically access + execute those labels somehow, therein reproducing the same animation from inside the game. In our case, the bad guys starts running.

Am I way off base here? If so, please begin by correcting me, and please be gentle, as again I'm not even sure what this subject matter would be called to even do the upfront research on my own.


texts: Infinite terrain generation performance: one big heightmap or several smaller heightmap?

texts:
I'm generating a procedural terrain using (a home-made fBm based on) Perlin noise as heightmap. To make the terrain infinite, I redraw part of it while the camera moves.

There are two alternatives:

either have several (say 9) heightmap-textures and rotate them while the camera moves;
or have only one heightmap (say 9 times bigger) and redraw only part of it as necessary.

Note:

The two approaches redraw exactly the same amount of pixels each time.

But:

in the first case, I must bind 3 small textures and entirely redraw them to redraw a line of my grid;
in the second case, I bind the whole bigger texture and redraw only a line inside it.

Question: Should I expect one to be faster than the other? Does glBindTexture has higher cost for larger texture?


texts: Implementing Client-Server Delta Compression (with Protobufs)

texts:
I am writing a 2D real-time RPG in C# and I am trying to implement client-server communication using protocol buffers. I am trying to figure out how to implement delta compression to reduce message sizes.

I have read the protobuf "optional" fields take up no extra space on the wire when they are not set (obviously they still do in local memory though), so if I can just programmatically determine my deltas efficiently I would be in better shape.

Here's the problem. I can think of a few ways, but none seem to be ideal. I was wondering if someone could point me in the right direction.

Try to keep a dirty bit array for EACH message-able class that gets cleared when a message is sent and marked when a variable changes. Then to send a message you just send the members that match the Boolean fields. This has LOW maintainability, but probably decent performance.
Every message-able class keeps a "pastMessage" member that gets updated saved when a message is sent. Then just serialize your current state and diff the two messages. This would probably have LOW performance and almost DOUBLE memory overhead for the game types..
Create a new message every time a message was sent and "fill-in-as-you-go." This would provide a better performance than the above, but still would essentially double my memory overhead on my server.

Any other ideas?


texts:
I'm looking to make a water shader that colors the water based on its depth. Up until now my water shader that I've used has basically been extremely reflective and only looked somewhat blue because it was reflecting a blue sky. The effect I'm shooting for looks something like the one from the first page in this article.

I don't necessarily need exact shader code, just the gist of how I calculate the color of the pixel based on the depth, while still getting a proper reflection and refraction. I should mention that I already have the water's depth calculated, per-pixel, and I also have working reflection and refraction. All I'm lacking is a color based on depth.

I've tried a bunch of stuff, the next thing I'm considering is actually coloring the terrain that is underwater, and coloring it based on depth.


texts:
I´ve read several articles, tutorials about shadow casting and I think that I understand the way how it works. However I miss some of the steps. Here is included my order list:

Fill framebuffer with ambient light
Render light textures to the framebuffer(adding proper blending)

3. Lights have vector of shadow casters(convex polygons) and check if they touch them(by checking the distance) and if yes, I do proper math calculation to project the polygon to the right "transformation". Then I draw them as black polygons to the framebuffer

4.At the end I use this framebuffers texture and blend it with actual game textures to "do lighting (with shadows)".

As you can see I bolded the step 3 because thats where I´m lost. The first thing, how do I project the polygon? (for these polygons I have a vector of points, also a vector of edges). The second thing, is it efficient to do it this way? I mean to iterate through the possible shadow casters for each light.

Thanks for your help.


texts: How is this particular HLSL condition treated with respect to compile- or run-time evaluation?

texts:
Let's say I have this very simple pixel shader (cbuffers and other stuff omitted)

float4 PS(VertexOut pin, uniform bool useLighting) : SV_Target {
    float4 retColor = gDiffuseMap.Sample( sampler0, pin.Tex );
if (useLighting) {
    retColor = retColor * float4(gAmbientLight, 1.0f);
}
    return retColor;
}

and two techniques such as

technique11 TexTech {
    pass P0 {
        SetVertexShader( CompileShader( vs_4_0, VS()));
        SetGeometryShader(NULL);
        SetPixelShader(CompileShader( ps_4_0, PS(false)));
    }
}

technique11 TexLitTech {
    pass P0 {
        SetVertexShader( CompileShader(vs_4_0, VS()));
        SetGeometryShader(NULL);
        SetPixelShader(CompileShader(ps_4_0, PS(true)));
    }
}

The way I understand it, the useLighting condition is evaluated during compile-time and each technique will have its own version of the pixel shader function without any branching. That means the useLighting condition wouldn't have any runtime penalties. Is that correct? So it's kind of like C preprocessing?

Why can the pin variable just be left out like that in the CompileShader call? It makes sense, of course, I'm just wondering if this is some special HLSL or Effect Framework syntax?


texts: Set object rotation according to the outer vertex in unity

texts:
I am able to get the outer vertices of a mesh using this and able to generate cubes on outer edges of the mesh. Here is my code:
  mesh = GetComponent<MeshFilter>().mesh;
        Stopwatch sp = new Stopwatch();
        sp.Start();
        Vector3[] vertices = mesh.vertices;
        List<EdgeHelpers.Edge> edges =  EdgeHelpers.GetEdges(mesh.triangles).FindBoundary();

        for (int i = 0; i < edges.Count; i++)
        {

            Vector3 v3 = vertices[edges[i].v1];
            GameObject go1 = GameObject.CreatePrimitive(PrimitiveType.Cube);
            go1.transform.localScale = new Vector3(0.25f, 0.25f, 0.25f);
            go1.transform.localPosition = transform.TransformPoint(v3);
            //go1.transform.localEulerAngles = transform.TransformDirection(v3);
            //go1.transform.rotation = this.transform.rotation;
           // go1.AddComponent<CubeMakerOnEmptySpaces>();
        }
        sp.Stop();
        UnityEngine.Debug.Log(sp.ElapsedMilliseconds / 1000);

Now I want to change the rotation of each cube that each cube z should be pointing against the mesh direction (should be outside of the mesh). Maybe picture representation helpful here

Need to be like this:


texts: What are the "axes of a matrix" exactly?

texts: I am currently learning about game engines, and for the engine math, there are functions called GetXAxis, GetYAxis, and GetZAxis that returned the X, Y and Z axes for a matrix. These functions return the  x, y and z components of the first three rows of the 4x4 matrix as a normalized Vector3. The actual functions are simple enough, but I am having trouble conceptually understanding what exactly the axes of a matrix are. Are they the forward, left, and up vectors of a transformation?


texts: What are the implications of using multiple OpenGL Contexts on a single thread?

texts:
I'm trying to integrate two third-party OpenGL rendering pipelines into the same application, namely Cinder's OpenGL API for 3D drawing and backbuffer rendering, and Google Skia's API for 2D drawing. Unfortunately, Skia tends to trigger a lot of GL state changes in general use, and offers no functionality to reset the GL state. To make matters worse, Cinder (GLNext branch) tries to keep an internal record of all of its GL state changes so that they can be easily 'unwound', but bad things can happen if its internal representation becomes different from the actual GL state.

The easiest way to alleviate these problems was to create a new OpenGL context for use exclusively by Skia, performing context switches only when 2D updates were necessary. However, I've noticed some weird behaviours when I'm required to switch context more frequently, like certain draw calls failing or blend states flickering. Everything I've read about GL contexts indicates that they're meant for use in multiple threads or multiple windows. I've also read about context switches failing in certain circumstances? Is there anything terribly wrong with switching context in a single-threaded, single-windowed application?


texts:
Currently i have three buttons that can be toggled with only one being active at once. When one button is selected by the player it sends a signal to the other two buttons to toggle off. Before the recent Godot update this set up worked fine, but now when the player toggeles a button on, the button thats being turned off now sends its toggeled signal thus turning off the very button the player clicked.

So im looking for a way to block a signal in code to prevent this loop.

Code for reference:

Player button:

func _on_Ally1_Button_toggled(button_pressed,check):
    print("on ally1 toggeled P")
    self.set_pressed(false)

func _on_Ally2_Button_toggled(button_pressed,check):
    print("on ally2 toggeled P")
    self.set_pressed(false)

Ally1 Button:

 func _on_Player_Button_toggled(button_pressed,check):
    print("on player toggeled A1")
    self.set_pressed(false)

 func _on_Ally2_Button_toggled(button_pressed,check):
    print("on ally2 toggeled A1")
    self.set_pressed(false)

Ally2 Button:

 func _on_Player_Button_toggled(button_pressed,check):
    print("on player toggeled A2")
    self.set_pressed(false)

func _on_Ally1_Button_toggled(button_pressed,check):
    print("on ally1 toggeled A2")
    print(check)
    self.set_pressed(false)

The check varible being passed in is how i plan stop the loop i just need a way stop signal.

Thank you in advance for the help.


texts:
I have trouble to make my sprite(Arrow) to point at the position of my mouse cursor but i don't get the Right results. I've tried this:

SDL_Point Center{ 40,40 };
int Delta_x; int Delta_y;
int mouse_x, mouse_y;
double Result;
SDL_GetMouseState(&mouse_x, &mouse_y);
Delta_x = xPos - mouse_x;
Delta_y = yPos - mouse_y;

Result = (atan2(Delta_x, Delta_y) * 180.0000)/ 3.14159265;
m_Sprite->Render(Result, Center);

RendercopyEx:

SDL_RenderCopyEx(m_Renderer, m_Texture, NULL, &m_Rect, Angle , &Center, SDL_FLIP_NONE);

This is the result I get (in the original picture, the arrow is pointing up):


texts: how to set up a contract between a Client and Server in C#

texts:
I am trying to make a turn based game, so first should I use UDP or TCP for the client server set up and why?

Second how do I implement it? I have seen a lot of code that just sends byte strings to each other but that is not sufficient enough to make a game... I have heard of Remote Method Invocation, and I haven't found a good explanation of it or a good implementation of it, so if you could show some of that as well.

Lastly, on MSDN there was the WCF (the tutorial on MSDN does not work on my computer at least) so it does not help me understand what it does

So how should I try and set up my server? and how to I call methods from the Client, and from the server? and how to I make the client or server respond to each other?

Thanks for any response that may help!


texts: Elegant way to handle packet loss in a lockstep P2P RTS?

texts:
What's an elegant way to handle packet loss in a lockstep simulation peer-to-peer RTS where only player input data is sent over the network?

For example, let's say it's tick 1000 and player 1 sends a message saying that he is going to start attacking player 2 at tick 1002. All the other players receive the message except player 2 who is being attacked. Player 2 receives the message very late, at tick 1020. The other players have been running their simulation according to the fact that at tick 1002 player 1 started attacking player 2. And by tick 1010, player 2 is dead. Not only that, but by 1020 his entire dying animation sequence, according to the accurate game state, is already finished. He is completely dead.

Because the network protocol has a reliability layer which resends unacknowledged packets, player 2 eventually receives the message. He can replay the simulation from tick 1002 and arrive at the same game state: that he is dead at tick 1010 and his animation is already finished at 1020. The simulation must correct itself, moving player 2 back where he should be and setting the appropriate animation frame.

From a gameplay standpoint, what's the elegant solution here? Does player 2 immediately just jerk into a fully dead animation? Or does a little dying animation happen anyway (which would mean the game state might not truly be in sync)?


texts:
I'm looking for a tool that I came across a few months ago but can't track down anymore. This tool helped create "adaptive" music, where adaptive music refers to music that changes depending on what the player is doing.

This tool allowed you to define a set of input variables, and then define how the music should move between various segments. For example: Loop over this 60 seconds of music until the player reaches 50% through the level, then continue onto this track, but only once the first track plays through to its end.

I think it was open source, and I think it exported the information as JSON. Any ideas?


texts: How to manage data relationships when designing a crafting system?

texts:
I'm trying to determine all the items, crafting methods and recipes to put in my game, and the relationships between them. I need a tool that allows me to do this both top down (boat needs sails and planks, sails need fabric which needs weaving technology and thread ...) and bottom up (hit rocks together to make sharp rock, tie it to a stick with thread to make an axe ...). I also need to ensure that all items, crafting methods and recipes conform to some template, which will be dynamic, at least in the development phase. I need the tool to be informative about which items conform to the template and which items do not, as well as what they are missing.
Below is an example item:

Item: Oak plank

Item family: Wood plank
Crafting method: Sawing

Item: Oak log

And here is an example item template:

Item

Optional item family
Mandatory crafting method

Choice (Item / Item family)

So this item conforms but I need a some way to ensure this and highlight if it was missing, for example, the crafting method. I also need to be able to check if an Oak log Item entry is also in the list and well formed according to the schema, and be able to change the schema easily. For example, I could later define an optional "Ship" tag in the schema for items that would enforce speed and strength values when used.
I will frequently update the templates and I want this to be a low overhead operation. Therefore I've eliminated databases. Due to the cross-referencing needs, I've eliminated spreadsheets and now I'm working on writing a tool that uses an xml schema to define the templates and list the items, crafting methods and recipes in an xml file, using xml validation to check conformity.
The problem is that the tool is taking too long to write and preventing me to work on the core features of the game. Are there any available tools or workflows for this purpose?


texts: Game stopped working after adding savegame feature?

texts:
I'm trying to make a text based adventure game with my limited c++ knowledge.. But I ran into trouble with saving and loading gamestates.. The functions I made are

int currentslot;
void savegame(int savestate)
{
fstream plfile("player.dat",ios::in|ios::app|ios::binary);
player temp;
if(currentslot==1)
{
    plfile.seekg(0,ios::beg);
    plfile.read((char*)&temp,sizeof(player));
    temp.savestate=savestate;
    plfile.seekg((-1*sizeof(temp)),ios::cur);
    plfile.write((char*)&temp,sizeof(player));
    plfile.close();
}
else if(currentslot==2)
{
    plfile.seekg(1*sizeof(player),ios::beg);
    plfile.read((char*)&temp,sizeof(player));
    temp.savestate=savestate;
    plfile.seekg((-1*sizeof(temp)),ios::cur);
    plfile.write((char*)&temp,sizeof(player));
}
else if(currentslot==3)
{
    plfile.seekg(2*sizeof(player),ios::beg);
    plfile.read((char*)&temp,sizeof(player));
    temp.savestate=savestate;
    plfile.seekg((-1*sizeof(temp)),ios::cur);
    plfile.write((char*)&temp,sizeof(player));
}
}
void loadgame()
{
int plno;
cout<<"\n\n\n\n\n\t\tSelect which player to load game from:";
cout<<"\n\n\t\t1.Player 1";
cout<<"\n\n\t\t2.Player 2";
cout<<"\n\n\t\t3.Player 3";
cout<<"\n\n\t\tEnter your choice: ";
cin>>plno;
currentslot=plno;
fstream plfile("player.dat",ios::in|ios::binary);
plfile.seekg((plno-1)*sizeof(player),ios::beg);
plfile.read((char*)&p,sizeof(player));
game(p.savestate);
}
void newgame()
{
int plno;
cout<<"\n\n\n\n\n\t\tSelect which slot to save game to(If there is no player         1, don't choose other slots):";
cout<<"\n\n\t\t1.Player 1";
cout<<"\n\n\t\t2.Player 2";
cout<<"\n\n\t\t3.Player 3";
cout<<"\n\n\t\tEnter your choice: ";
cin>>plno;
currentslot=plno;
fstream plfile("player.dat",ios::app|ios::binary);
if(plno==1)
{
    plfile.seekg(0,ios::beg);
    plfile.write((char*)&p,sizeof(p));
}
else if(plno==2)
{
    plfile.seekg(1*sizeof(p),ios::beg);
    plfile.write((char*)&p,sizeof(p));
}
else if(plno==3)
{
    plfile.seekg(2*sizeof(p),ios::beg);
    plfile.write((char*)&p,sizeof(p));
}
game();
}

With the addition of these functions however, the game() function does not seem to be accepting any values (but no error) related to the class:

class player
{
public:
char pl_name[10];
int hp;
int atbt;
int chk_sword;
int chk_bow;
int chk_healthpotion;
int savestate;
player()
{
    strcpy(pl_name,"Unnamed");
    hp=100;
    atbt=0;
    chk_sword=0;
    chk_bow=0;
    chk_healthpotion=1;
    savestate=0;
}
void namegive()
{
    cout<<pl_name;
}
void nameset()
{
    gets(pl_name);
}
void atbtset()
{
    cin>>atbt;
    if(atbt==1)
    {
        chk_sword=1;
    }
    else if(atbt==2)
    {
        chk_bow=1;
    }
}
}p;

I've spent a lot of time trying to figure it out.. Help and/or advice is very much appreciated.
Thanks


texts: Why are examples of game textures often represented on a sphere model?

texts:
I have recently started working with Unity and was looking for textures for the background (castle walls and such pieces) on a game that I am thinking about eventually building. I noticed that the textures are often represented as ball shaped, such as for example in this sample image here:

For example, why are the texture patterns not shown as simply flat squares? I guess there is a reason behind this that has to do with mapping to 3d surfaces but I was not sure so I wanted to check here.

Why are textures often represented in spherical shapes in examples and previews?