texts:
I'm starting to learn how to DIY physics, and I have a question about implementing integration at the most basic level (i.e. this is not a  Euler vs. RK4 question).

Nearly every example I come across has some integrate() function which gets the timestep since the last update, and updates the acceleration (and/or velocity and/or position) since the last update.

In the simplest form: position += velocity * deltaTime

However, I don't understand why it's accumulated like this when it could just as easily be gotten by changing a function. For example: getPosition = makeNewFunction() which could return something that has the signature of Time -> Position, and the inner workings of that function are generated via the appropriate mathematical formula.

That way, there is no accumulation... whenever the position needs to be gotten, it calls that function with the current time.

My newbie understanding is that this would also avoid the errors that come from accumulation... so why does this not work, what am I missing?

(fwiw I did put together a basic proof of concept of this idea- though it's also testing a few other things at the same time so it's not the cleanest example: https://github.com/dakom/ball-bounce-frp)

EDIT 1: as mentioned in the comments, it's probably important to point out that I have not learned about changing acceleration yet, or dealing with jerk and other things that require higher-order integration than constant acceleration.

EDIT 2: here is some basic sample code of the idea, and pseudo javascript syntax - note that getKinematicPosition is partially applied so it is returning a new function of just Time -> Position:

I'm sticking to position here but it could be something else, like getVelocity, I guess...

getKinematicPosition = initialVelocity => acceleration => time =>
  ((.5 *acceleration) * (time * time)) + (initialVelocity * time);

getPosition = getKinematicPosition ([0,0,0]) (GRAVITY);

onTick = totalTime => {
   position = getPosition (totalTime);
   onCollision = () => {
     getPosition = changeTheFunction(totalTime);
     //changeTheFunction uses totalTime to base updates from 0
     //it could use getKinematicPosition or something else entirely
   }
}


texts: Does one need normals for a strictly 2d Game?

texts:
I'm starting to learn OpenGL by creating a pure 2D game.

I have to decide on the format of the Vertices. Do I need a normal component? Or is this for a 2d component not needed?

My gut feeling says I won't need it since everything is flat. But perhaps I need it for some shader or other thing I don't see yet.


texts: XNA How do I detect if my mouse if hovering over a specific sprite?

texts:
How do I detect if my mouse if hovering over a specific sprite?

For example I'm making a custom button and I want to check if my mouse is hovering over it so I can make animations.


texts: How to detect collisions between sprite and a user generated shape of some sort?

texts:
How to detect a collision between a sprite and a user-generated shape of some sort.

For example. There are some objects on the screen. The user takes their finger and draws a circle shape around an object (The selection rule is painting circle around the sprite, but the painting shapes may be various). I need to detect which object selected, which just like:

(demo images):


texts: I'm trying to implement a render abstraction over Direct3D9, and one of the functions I'm implementing is clearing a render target, which includes a depth buffer. However, the IDirect3DDevice9::ColorFill method I've been using doesn't seem to be able to clear depth buffers. Is the only means to clear depth buffers to use Clear() to clear depth buffers which have been bound to the rendering pipeline?


texts: What is the advantage of binary FBX files over ASCII ones?

texts:
I know that the size does matter but except for this advantage, are their any other advantages to using binary files instead of the ASCII format in real production workflows?

ASCII files have a lot of advantages: human-readable, easier to integrate and debug, VCS, etc.


texts: How to make Minesweeper always reveal a large area on first click?

texts:
I'm making a Minesweeper app.
I read that if you click mine on the first turn, Windows Minesweeper moves that mine to the top left corner.
It's simple, but I can't find an easy way to always reveal a '0' cell on the first click.


texts: How do you find the collision between 3D boxes and 3D QUAD face meshes?

texts:
I have an axis aligned bounding boxes for 3D object collision, but I have a complex 3d mesh that's divided into 3d faces so I want to check for bounding boxes and collision with the faces of that object.

I know that this might cost efficiency since there are more faces to check, but I can fix the efficiency by only checking certain faces, which I think would give me a more accurate collision test than just using a bounding box for this complex object and an efficient check utilizing certain faces that more likely to collide.

However, I don't know the math to check 3d boxes and 3d faces, so I want to know how to create a collision test for this situation.


texts:
I'm trying to map a brick texture on the edge of a fountain and I'm using gluDisk for that. How can I make the right coordinates for the disk? My code looks like this and I have only found a function that takes the texture along with the camera.

I want the cubic texture to be alongside of the fountain, but gluDisk does a linear mapping. How do I get a circular mapping?

void Fountain::Draw()
{
    glPushMatrix(); // push 1
    this->ApplyWorldMatrixGL();
    glEnable(GL_TEXTURE_2D); // enable texturing
    glPushMatrix(); // push 2
    glRotatef(90,-1,0,0); // rotate 90 for the quadric

    // also drawing more here...

    // stone texture
    glBindTexture(GL_TEXTURE_2D, texIDs[0]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    glPushMatrix(); // push 3
    glTranslatef(0,0,height);

    // spherical texture generation
    // this piece of code doesn't work as I intended
    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
    glEnable(GL_TEXTURE_GEN_S);
    glEnable(GL_TEXTURE_GEN_T);

    GLUquadric *tub = gluNewQuadric();
    gluQuadricTexture(tub, GL_TRUE);
    gluDisk(tub, radius, outerR, nrVertices, nrVertices);
    gluDeleteQuadric(tub);
    glDisable(GL_TEXTURE_GEN_S);
    glDisable(GL_TEXTURE_GEN_T);

    glPopMatrix(); // pop 3
    // more drawing here...
    glPopMatrix(); // pop 2
    // more drawing here...
    glPopMatrix(); // pop 1
}

To refine my question a bit. This is an image of what it is at default (left) and of what I want (right). The texture should fit in the border of the disk, a lot of times. If this is possible with the texture matrix, than that's fine with me as well.


texts: XNA Rotation results in a pixelated image

texts:
I have a "problem" with XNA 4 and spriteBatch. When I draw a rectangle and rotate it, the sides get quite pixelated and look bad: example:

What do I need to do to make the edges look smooth?

spriteBatch.Draw(box, new Rectangle(350, 350, 100, 100), null, Color.Red,MathHelper.ToRadians(65), new Vector2(50, 50), SpriteEffects.None, 0.0F);

EDIT: Found the solution.

As Tetrad's comment suggested, one needs to activate anti-aliasing. Under XNA4.0 you can use this code

GraphicsDeviceManager graphics;
graphics.PreferMultiSampling = true;
graphics.ApplyChanges();


texts:
I am working on simple parallax shader and I have problem with sampling height texture for value.
My aproach amples texture and give me RGB values of picture:

tex2D(TextureHeightSampler, input.BaseOutput.TexCoordAndViewDistance.xy)

But I am not sure how to convert RGB data to height value. How to solve that?


texts: How To Architect My Game To Keep the Same Scene Loaded

texts:
My Unity game has a large planet GameObject that serves as the map. I want to keep this planet loaded, but still create different levels where enemies and the player are spawned at different locations on the planet, depending on the level. Therefore, the objectives, targets, and vehicle the player must use and accomplish are different at each level, but the map itself is not.

I have had a couple of thoughts. My first idea is to use transforms as locations for where vehicles spawn, and assign a vehicle to each location. Perhaps then each set of locations can be saved as a prefab that represents a level.

One possible solution is to use different scenes for every level, with the main scene containing the planet being kept throughout. I am not sure how the different components can communicate with each other, however.

My difficulty with all this is how to conceptualize how all the elements will work together. Say I make a class called Level, which includes the Objective that must be accomplished to win, the Vehicle the player will use, and the Locations where objects are to spawn, etc. Then I create scripts called Level1, Level2, etc. that inherit from Level and allow custom scripting for each level. However, there is also a state where the menu shows the scene, but no objective is being accomplished. Is that a viable solution? Is there a better solution from experience?


texts:
I'm trying to create a game with a hex based map with the points at the top. I have most of it working, however the path finding is being a little awkward. The heuristic I'm using is called Euclidean I believe and is like so:

var dx:Number = destinationNode.c - node.c;
var dy:Number = destinationNode.r - node.r;

return Math.sqrt((dx * dx) + (dy * dy));

Node is the node the unit is currently on, c is the node's column number and r is its row number. I'm using these as a simpler x and y coords. I'm trying to limit the unit to 3 hex moves in one round, so initially I thought it'd be as simple as IF returned heuristic < 3 unit can move to that hex, however it's not working out quite like that.

As you can see in the pic above, the bottom right selected hex with the "1 + 9 = 3.162277" is moveable to in 3 moves, however the hex with "9 + 1 = 3.162277" on the far right would need 4 moves to reach it. Can anyone offer any advice on how to make this work?

EDIT: My problem was being caused because I was using a Cartesian coordinate system and was just staggering every other Y coord. Fixed this by making the Y axis go down at a 60 degree angle. Thanks to amitp for the links that showed me what I was doing wrong.


texts: Why isn't the texture correctly loading onto sphere?

texts:
I am trying to make a moon object. I have a (mostly) spherical object model that I want to place the moon texture on top of. The moon texture is an equirectangular projection as seen below.

However, the moon drawn is rendered like this:

As you can see, not all of the north pole is rendering. Roughly 3/4 of the moon seems to have rendered, but it doesnt seem to have any of the red transition color in the north pole.
The moon model was made in Blender by simply creating a UV Sphere and then exporting it with triangulation enabled. No changes were made. The moon obj file can be found here in text version. Maybe the normals aren't correct? I tried using an ico sphere as well, but the results with that were even worse. Any advice for why it isn't rendering correctly?
Here is the sphere mesh if that helps:


texts: State / Screen management in Entity Component Systems

texts:
My entity/component system is happily humming along and, despite some performance concerns I initially had, everything is working fine.

However, I've realized that I missed a crucial point when starting this thing: how do you handle different screens?

At the moment, I have a GameManager class which owns a component manager and entity manager. When I create an entity, the entity manager assigns it an ID and makes sure it's tracked.

When I modify the components that are assigned to an entity. an UpdateEntity method is called, which alerts each of the systems that they may need to add or remove the entity from their respective entity lists.

A problem with this is that the collection of entities operated on by each system is determined solely by the individual Systems, typically based on a "required component" filter. (An entity has to have a Renderable component to be rendered, for instance.)

In this situation, I can't just keep collections of entities per screen and only Update/Draw those collections. They'd have to either be added and removed depending on their applicability to the current screen, which would cause their associated components to be removed, or enable/disable entities in a group per screen to hide what's not supposed to be visible.

These approaches seem like really, really crappy kludges.

What's a good way to handle this? A pretty straightforward way that comes to mind is to create a separate GameManager (which in my implementation owns all of the systems, entities, etc.) per screen, which means that everything outside of the device context would be duplicated. That's bothersome because some things are always visible, or I might want to continue to display the game under a translucent menu window.

Another option would be to add a "layer" key to the GameManager class, which could be checked against a displayable layer stack held by the game manager. *System.Draw() would be called for each active layer, in the required order as determined by the stack. When the systems request an iterator for their respective entity collections, it would be pre-filtered to a (cached) set of those entities that participate in the active layer. Those collections could be updated from the same UpdateEntity event that's already used to maintain each system's entity collections.

Still, kinda feels like a hack. If I've coded myself into a corner, feel free to throw tomatoes as long as they're labeled with a helpful suggestion.

Hooray for learning curves.


texts:
Is there a possibiltiy to create a texture from a meshpart in xna. By getting a flat version of the mesh. So I can create a texture for it and edit that texture(via rendertarget)? I need to get the texture(wich is not yet a texture) so I can put another texture on it.

I can create a texture and put it on a certain mesh. But I just cant figure out how I can create a texture with the right size.

I also already found out i can use text2dproj in hlsl. But when i do this i get a gray stripe in the look.

Is there a better solution?


texts:
Would it be better to actually draw the board in a script and attach colliders to each piece or get a picture and add the colliders before the game starts?  Is the difference in processing power needed significant?

Which way would be the easiest for figuring out where a specific piece is?


texts:
I am looking for character animation library which can be included in my game engine.

I prefer FOSS but, paid is good if it's price is reasonable.

So, far what Ive found is Cal3d.

Can anyone tell, what are the other options?

I am also interested in Havok Animation which comes in the free bundle of Havok. Any thoughts about this one?


texts: How do I get a Model to add a name to it's Texture(s) in the XNA Content Pipeline

texts:
I know that a texture's name is not preserved when it's loaded in.  I also know that you can give it a name.  For example:

Texture2D texture = content.Load<Texture2D>("MyTexture");
texture.Name = "MyTexture"; //Or whatever else you want to call it

However, what about when you load a model?  It automatically loads in the right texture for each ModelMeshPart, and drops the Name (no idea why though).  This is fine, right up until the point where you actually want to identify which texture that ModelMeshPart is using.  I found someone else having the same problem here.  Shawn Hargreaves gave this solution:

  If you need access to this data at runtime, you will need to extend the pipeline to store it somewhere else. For instance you could use a custom processor to store texture filenames in the ModelMeshPart.Tag property

I figured that was easy enough. Yeah...feel free to point and laugh.  I got as far as creating a custom proccessor class and inheriting the standard ModelProcessor before I realised that I didn't know exactly where the ModelMeshPart's texture was stored and I've spent the past few days trying to find out.

I just want to preserve each part's texture name so that I can do something like

Model model = content.Load<Model>("MyModel");
BasicEffect effect = (BasicEffect)model.Meshes[0].MeshParts[0].Effect;
string texName = effect.Texture.Name;

Also Merry Christmas.

EDIT

For the record, I'm importing a .x model.


texts: Failed to understand how to use glm::unProject (OpenGL 4.3)

texts:
Situation:
I use OpenGL 4.3, FreeGLUT 3.0, and GLM library.

Let say i have a simple 2D object (a ball) and it moves accordingly to the simple equations:

x = x_0 + v_0 * t * cosf(alpha);

y = y_0 + v_0 * t * sinf(alpha) - 0.5 * g * t * t;

So i can be sure what are x and y in every time step.

My GLUT mouse callback is:

void onMouse(int button, int state, int mx, int my) {
    if (state != GLUT_DOWN)
        return;
    view = glm::lookAt(glm::vec3(0.0, 0.0, 10.0), glm::vec3(0.0, 0.0, 0.0), glm::vec3(0, 1, 0);
    projection = glm::perspective(45.0f, 1.0f*640 / 480, 0.1f, 10.0f);
    glm::vec4 viewport = glm::vec4(0, 0, 640, 480);
    glm::vec3 wincoord = glm::vec3(mx, 480 - my, 0.0f);
    glm::vec3 objcoord = glm::unProject(wincoord, view, projection, viewport);
}

So, when the ball moves and i click on it, i suppose to get (objcoord.x,  objcoord.y) very close to the center of the ball (x,y).

Coordinates of the ball itself (x,y) are calculated correctly. But when i click on the ball, (objcoord.x, objcoord.y) are not even close to the (x,y).
I always get very small values like (0.0012, 0.099) wherever i click on the screen.
I feel that it might be due to some Z (depth) issues, but i don't have enough knowledge here and ask for help now.


texts:
So more often than not I have a case where two agents get the same destination vector3.

This causes some hiccups because they won't be able to get to their target because they block for one another.

I was thinking that I am not the only one who has faced this issue and was wondering what you guys do to fix such an issue?

An example of this could be if I want my agents to go to the nearest tree and chop it down. Since both agents have the destination which is the trees transform they will go to the same position.


texts: I'm completely fresh to game development and came up to a problem which I'm not sure how to solve. I have textures which are quite too big for screen. So i used SpriteBatch.Method which uses rectangle as parameter which allows me to get custom size of texture. But I need as well Vector position for movement to specific direction. So I used method which uses Vector position and float scale to make it smaller. And now I can't check really if it Intersects with other objects or simple width, height properties. It seems that I cannot pass both vector position and rectangle as well. Isn't there a way to specify just a rectangle for texture's height/width to be rendered and vector for position?


texts: Coordinates different between Tiled editor and my game

texts:
So I have been using Tiled map editor to create my map for my game. I'm using Libgdx to load and draw the map.

The problem is that the coordinate from objects placed in tiled do not seem to be the same when they are using in my game. It seems to be just the y value, as I have tried a few different positions and the x value seems to be okay.

I think it may be because Libgdx coordinate systems starts in the bottom left instead of the top left, but I'm not sure. And I'm not sure how to get around it.

In Tiled:

In game:

The black square is being drawn at the x and y values grabbed from the object.

I get the values from this function once the map loads:

    public Vector2 getStartingPosition()
{
    for (TiledObjectGroup group : map.objectGroups) {
        for (TiledObject object : group.objects) {
            if ("playerSpawn".equals(object.name))
                return new Vector2(object.x, object.y);
        }
    }

    //Was not found, return default spawn
    return new Vector2(0,0);
}


texts: 2D Camera Movement Temporal Reprojection

texts: Having an Orthographic Camera with its View Projection Matrix given from the current and last frame, how to reproject the previous frame to the new one?


texts: What to think about when designing a simple GUI for a quiz game

texts:
I am coming close to finish my first iPhone game ever, as a matter of fact also my first programming experience ever, which is a quiz game. I have all the functionality i want and is currently polishing it both from a code point of view as well as looking at the GUI.

My initial idea was not to use any specific graphics but rather focus on the game experience and simplicity and by that only using background color, orange, and white text as well as buttons. The design is based on that all ages, from learning to read, should be able to host and play this game.

However, as i am now getting close to the finish line i am starting to think what is needed from a GUI point of view.

I would like to ask for some advice what to think about when designing a GUI. Is it considered OK without any 'fancy' graphics, what is the risk without it etc.?

Also, what colors goes well together if i choose to use a simple GUI. I am thinking about color blindness etc.

In other words how do i design a good and effective GUI for a simple game as mine?

Thanks


texts:
When I am working with cocos2d I can add CCSprites to the layer or 'stage' and manipulate them.

Now, to do my ongoing calculations for movement AI and such, things that will always run, should I:

subclass CCSprites and add methods to manipulate themselves and run schedules?

-OR-

create a controller class that 'owns' all of the CCSprites and manipulate them from the 'outside'? I am not really sure what would be accessible from the outside though.

My guess is that I should probably subclass the CCSprite object, I could have a different object that inherits from CCSprite for each type of sprite needed.

Player, Enemy, PowerUp, Bullet, etc...

Or what do you think?


texts: How can I make a player-interactable bookshelf?

texts:
In the player's house Interiors->WhiterunBrezeehouse (FormID 000165A8) I duplicated a bookshelf (CommonShelf03 FormID 000ce784 near the fire pit) and the book proxies, container, triggers, collision boxes, et cetera.

When I enter the house the duplicated book shelve is there and it shows the "E to interact" text, but when I press E nothing happens (I'm supposed to get up the book shelf manager).

Any clue of what it might be? What do I need to support proper interaction between a player and the shelf?


texts: How to load one of Unity's built-in UI Sprites at runtime?

texts:
I have some code that creates objects with an Image component, in which I want to replace the Source Image with one of the default built-in sprites, through the code.

Example:

Code:

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

public class PotionManager : MonoBehaviour {

    Image sourceImage;
    private float timer=25;
    static int COUNT_OF_ORDERS = 0;
    public Transform parent;
    public List<PotionAsset> potionList = new List<PotionAsset>();
    private float posX,posY,posZ;

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;
        if (timer >= 30)
        {
            CreateOrderHolder();
        }
    }

    void CreateOrderHolder()
    {
        posX = 160 * COUNT_OF_ORDERS + 80;
        posY = -70;
        posZ = 0;

        COUNT_OF_ORDERS++;

        GameObject temp = new GameObject("Potion Order " + COUNT_OF_ORDERS, typeof(RectTransform));
        temp.transform.SetParent(parent);
        temp.transform.localPosition = new Vector3(posX, posY, posZ);
        temp.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
        temp.GetComponent<RectTransform>().anchorMax = new Vector2(0, 1);
        temp.GetComponent<RectTransform>().anchorMin = new Vector2(0, 1);

        CreatePotionHolder(temp.transform);

        timer = 0;
    }

    void CreatePotionHolder(Transform parent)
    {
        posX = 0;
        posY = 13.5f;
        posZ = 0;

        GameObject temp = new GameObject("PotionHolder", typeof(RectTransform), typeof(Image));

        temp.transform.SetParent(parent);
        temp.transform.localPosition = new Vector3(posX, posY, posZ);
        temp.transform.localScale = new Vector3(1, 1, 1);
        temp.GetComponent<RectTransform>().sizeDelta = new Vector2(100,50);

        sourceImage = temp.GetComponent<Image>();
        sourceImage.sprite = Resources.Load<Sprite>("Resources/unity_builtin_extra/UISprite");
        Debug.Log(sourceImage.sprite);
    }

}

In the end, sourceImage.sprite returns null. I tried to add at the end of the file path the file extension like png, psd, but this did not help.


texts:
By back press on Android, I want to close all the open windows first then exit the game, I see everywhere it's suggested to check input key in Update:

void Update()
{
    if (Input.GetKey(KeyCode.Escape))
    {
        if (AreAllWindowsClosed())
            Input.backButtonLeavesApp = true;
    }
}

But my issue with this is that it's calling the code in every frame and also may handle a single press multiple times!

Isn't there a single BackPressed event in Unity for this simple task?


texts: Websocket-based realtime multiplayer game client and server communication?

texts:
I am building my client/server realtime MMO game using websocket which is based on TCP. My game will be server authoritative and will use non-lockstep. That means all game logic (not graphical) will run on the server and players can join and leave the game any time they want.

Although I have read the Valve Network model and Quake 3's snapshot architecture and all the entity interpolation stuff on http://gabrielgambetta.com/, I am not very clear about the actual communication between the server and the clients because the models are specifically targeted against UDP transport.

One question is that do I still need to synchronize the ticks on clients and the server if I use websocket? So far as I know, TCP guarantees that the packets are sent orderly and if part of the packets are lost they will be resent. With this in mind, the state (of other players) on the client should always be one tick before the state the server is ready to send out to the client. Please correct me if I am wrong. And the server will probably need to maintain a queue to store all the input commands the client just sent out. On the next tick of the server, the server executes the input commands and send out new states to the client.

So I imagine the process should look like this:

client send input commands to the server =>
server receives commands and queue the input commands =>
on next tick server update the game state using all the input commands in the queue and send the game state out =>
client receives new game state and interpolate other players on client from current state to the new state.

I am not sure if this is the correct way to do it. How about the edge case? When the game starts new player joins the game after the server has run certain amount of ticks, I guess I wouldn't need to worry about the tick number?
Hope someone can give me some guidance here.


texts:
I'm trying to build lightmaps for an engine I'm working on. I'm using DirectX 9 w/c++ but my questions are related to the methodology behing the generation of light maps.

I have a scene built from collections of mesh objects. The scene is divided into an octree. I want to generate a light map for each of the octree nodes or possibly 1 light map for a subdivision( 8 nodes ).

I've read the tutorial on flipcode.com(  here  ). For the explanation on "calculating/retrieving light map texture coordinates the tutorial refers the reader to a broken link.

I'd appreciate a list of instructions on 'what' to do in order to complete this process...I've found bits and pieces from different sites that have different implementations and its hard to piece it together. How do I assign a polygon to a specific area of the light map?


texts: What are Hull, Domain and Geometry shaders used for?

texts:
I've done my fair share of 3D game programming for my (former) employer, and also in my own custom engines for my own indie games.

Initially, I started with Direct3D 9, and D3DX9, which pretty much did everything for me, and didn't require me to think in terms of shaders at all.

After that, I wrote my first Direct3D 9 shaders, but mostly used one very simple shader for everything I did.

In the most recent iteration of my game engine, I moved to Direct3D 11, and with that I created lots of shaders. I did GPU skinning, GPU calculated particles, lots of lighting and post processing effects, all in the GPU. Really cool stuff.

So far I have only used vertex and pixel/fragment shaders. Even though there are still lots of things I still haven't done, I believe I have a solid knowledge of what the vertex and pixel/fragment shaders do, and how that all fits into the entire 3D pipeline.

Catching up with more recent developments, I've become very interested with the newer shader stages. That is, the Geometry Shader, and even newer, the Hull and Domain shaders.

I have never used these stages, but from what I know, the Geometry shader, if enabled, is run after the vertex shader, once for each transformed vertex (or once per primitive?) and allows you to discard vertices (and primitives?), and create new ones (which I guess go back to the beginning of the pipeline?).

My guess is that the main use of the geometry shader would be to programatically generate geometry in the GPU. A common usage would be to create billboard quads based on a single vertex, but I don't really visualize many other common scenarios apart from generating fractals and other stuff you can generate 100% programatically.

As for the Hull and Domain shaders, it seems like they're related to tessellation (creating smoother surfaces out of rough surfaces?), and must be used together or not at all. The term "patch" also seems to be common in here.

Would anybody care to explain to me, in practical terms, what these new-ish shader stages are for, how they fit into the 3D pipeline, and in which cases should I consider using them?


texts: Unity : Objects become black when size is changed to smaller

texts:
While working with Unity 5.4, my models become black when I resize them to a smaller scale. When I make the models bigger they are fine. I am using a directional light . On the image below as you can see on the left the model is fine. But the others are black.

HOPE YOU CAN HELP.


texts: Is there a gold standard for touch controls in scrolling shoot-em-ups?

texts:
Is there currently a "standard" for touch controls in shooters on platforms such as iPhone or Android? I've noticed that many of them enable auto-fire by default, or control the character via direct touch on the sprite, but don't know if this is something that is emerging as a standard or not.

I've also seen virtual joystick and button solutions, but this seems so wonky.


texts:
I'm currently building a game that utilizes many of its own 'windows' to display various information and dialogue to the user.  Since there are multiple sizes and proportions these windows must be displayed at, we need a consistent way to draw the frame around the window itself so that it does not become stretched as we change the default size/proportion of the art asset during runtime.

The solution we have currently come up with is drawing the frame in pieces, and the background of the windows separately.  We would have the background, a 'corner piece', and a 'connector piece'.  The background would be drawn and resized to whatever size and proportion not caring about if this particular piece was stretched .  The corner would be drawn and rotated to fit at each corner of the window.  Finally the connectors would be 1 pixel wide pieces that would be drawn and rotated/stretched to fill the gap between the 4 corner pieces.

While I feel this is an adequate solution to the problem I am not sure if this is the solution most games use when they have windows they would like to keep consistently framed.  Is there a more commonplace solution for this issue, or does what we've come up with pretty much nail it on the head?


texts: How to get the physical camera sensor size on iOS / Android in Unity

texts:
I'm trying to get the physical camera sensor size on iOS and Android mobile devices for intrinsics calculations.
On Android the sensor size should be found in the SENSOR_INFO_PIXEL_ARRAY_SIZE (Android CameraCharacteristics API). However I don't find a way to access that array via ArFoundation. I can imagine to write a plug-in for that, but I would also require a plug-in for iOS so I don't know if that's the right way to go.
Is there maybe another (easier) way to get the physical sensor size?


texts: How can I make 2D fog like in Graveyard Keeper?

texts:
I really like Graveyard Keeper's fog effect but I can't work out how to make it.

It's 2D, and made in Unity. The characters all seem to be 'under' the fog, but the tops of tall trees and buildings poke out. It looks like this:

The developer has given a bit of information about how it's made on Gamasutra:

http://www.gamasutra.com/blogs/SvyatoslavCherkasov/20181023/329151/Graveyard_Keeper_How_the_graphics_effects_are_made.php

  "As you see, the tops of houses and trees are seen from the fog. In fact, this effect is really easy to make. The fog consists of a great deal of horizontal clouds spread across all the picture. As a result the upper part of all the sprites is covered with a fewer amount of fog sprites:"

I used the information from this article, and one of the developer's tweets that included this picture:

I attempted to recreate it this fog effect. When the character moves up or down the screen, it flickers as it crosses each fog sprite:

What have I missed?

All of the sprites are on the default sorting layer and have sorting order 0.

The project, in Graphics Settings -> Camera Settings has the custom axis and sort axis (0,1,0). The tree and character are on the same z position, and the fog is spread out over several z positions:


texts: Determining bordering irregular shapes from an image

texts:
Given only an image, I have to find a way of determining whether any two irregular bodies in that image are bordering one another. This is a map of districts, each with their own name, and my goal is to build a database which stores, for each district, which districts border it. I could manually create an entry for each district, and simply list which districts are bordering them. There are hundreds of districts, however, and I'm sure there's some way to automate this process. Not to mention, this map of districts is subject to change.
I've tried so far by defining a central point for a handful of districts, then testing if a line could be drawn between a pair of points and only cross over a border line once. This would mean the two districts were bordering, but this solution only works with districts that have simple geometry.
Any help here would be much appreciated!


texts: How do I check if an item no longer exists in GameMaker Studio?

texts:
Let's say I have an array of objects[i,j], which has been fully populated by objects obj_example. I want to delete the obj_example at position [1,2]. That's simple, as objects[1,2] is currently pointing to that object (or is the object, or whatever logic Gamemaker uses).

But now, the object at objects[1,2] is destroyed.

What if statement would I use to check that makes objects[1,2] return an undefined(or null) value (but, clearly, not make the other, populated objects return such)?

Or how would I otherwise know that the objects[1,2] were destroyed?

EDIT: I added the following to my little project, after object_handler (which was made equal to the objects[i,j] to be deleted) was deleted. It returned "this is defined."

if (is_undefined(object_handler))
{
    show_message("this is undefined");
}
else{
    show_message("this is defined");
}

So...is_undefined(n) does not work for this purpose.


texts: How do you cope mentally with one very long piece of work

texts:
This is my first games industry job and my task is to take out one major game component and put in a newer one.

So far it's been 5 weeks, and I'm still just staring at errors. I think it could be months before it's at the point that it can compile. It's really getting me down. I'm just changing things over, I'm not really writing anything myself. it's just endless. I fix a thousand errors and nine thousand take their place.

I'm sure this must be a common thing, so I was just wondering, how do you cope with this? It doesn't seem like I can break it down into little chunks at all.


texts: New Unity Post Processing - Default Project '3d With Extras' - What effect is causing this transparency in distant objects?

texts:
I've recently seen in Unity you can start a new project with Extras included. Which is basically some post processing to make it look nicer as standard, as well as some assets/materials etc to get you started.

I have started a new project like this. And you can drive a car around a fixed camera. But if the car goes a few metres (well maybe 10-30 metres or so) into the distance there is a sort of grey fog there and it makes much of the cars mesh become more and more transparent the further you go.

It doesnt look nice at all because parts of the car (like the windscreen) can still be seen,  whilst the car body is not visible.

My question is, what is this effect called and where do I alter/disable it:


texts: Graphic hardware texture formats shaders relational speed

texts:
I'm interested to know, is there a direct correlation to the speed that a shader will run based on the bit depth of a texture upon which it is running. For example: If I have a 2 bit stencil texture and I'm accessing data from this, will the access time be 16 times *'FASTER' than accessing the data in a 32 bit texture or is it primarily used for the memory saving capabilities.

*[SEE EDIT]


texts: Low complexity shader to indicate the sides of a polyline

texts:
I have a bunch of polylines that I draw using GL_LINES. They can have thousands of points. They actually represent the separation of land and water on a map. I don't have complete polygons, just the ordered set of points.

I'm looking for a neat but efficient way to visually convey Side A and Side B as being different. For example I could offset the polyline in one direction a few times and fade it out (but every offset is doubling the number of points), or offset it once to make a "ribbon" and give one side a 'glow' like effect to mimic the outer glow or shadow of a polygon).

This is for a mobile application and I'm using OpenGL ES 2. I'd like to keep the effect as simple as possible from a complexity stand point. I'm looking for some additional ideas; maybe there's a clever shader technique out there or a visual effect I haven't considered.


texts: How to fake a 3d character displacement by sprite scaling in GameMaker?

texts:
I want my 2D sprite to become bigger when moving down the screen (closer to the camera), smaller when walking away and to maintain the same size when moving left or right.

The scaling along the y axis is fine but when I move left the sprite remains facing right. I have tied the y_scale to the x_scale so the sprite retains the correct proportions. Here is the problem:

For example, if the image_yscale is currently 9 and I want to move left, setting the image_xscale to -1 causes the sprite to shrink again. How can I flip the sprite along the x_scale while retaining the current size?

Here is my code:

// Sprite Scaling

if keyboard_check(vk_up)
{
    image_yscale -= 0.01
}

if keyboard_check(vk_down)
{
    image_yscale += 0.01
}

image_xscale = image_yscale

if image_yscale < 1
{
    image_yscale = 1
}

Thanks for any help in advance.


texts: Texturing (or seeing through) the back of a plane

texts:
I've got a basic textured quad forming a plane. When I move the camera or rotate the plane to see the back of it, there is no texture there.

The effect I want is as if the plane were a clear piece of glass, so that I'd be seeing the texture from through the other side. I was hoping this was going to happen automagically. Is there an easy way to accomplish such a thing, or am I going to have to manually flip the texture and assign it to the back?

Thanks!


texts: What kind of data structure to use for planetary populations?

texts:
I am in the process of building out the prototype for my space strategy game, which is focused on empire building type gameplay.

One of the most important elements of the game are the various planets and the population groups on them. I have looked at Unity and Amazon Lumberyard before settling on Unreal Engine 4 to build the prototype on, but I am not sure what the best way to store information about the populations and planets are.

For now, planets are a class of object and store their characteristics as variables (no issue there). The problem arises with the populations, as each distinct group of population will have unique characteristics (i.e. species traits, faction alignment, education level) and game objects that they have possession of (weapons, armor, industrial machinery, trade goods).

What would be the most efficient way to tie the objects owned by the population to them, and to tie the population group to their planet of residence, such that I could compute things like:

For Faction X, on Planet Y, what is the product of their population's (Education x Industrial Machinery x Planet Mineral Rating)?

I considered implementing Population as a struct stored inside the Planet class, but that seemed problematic if I needed to move the population to a transport ship and then to a different planet, or add new groups of population during runtime.


texts:
I created a small Windows Phone game with XNA, but I have some trouble with loading a text file from Content. I added the text file to my Content project and marked the Build Action to "Content". The static text file should be loaded when the game starts, but I always get an exception in this line of the method:

if (File.Exists(filename))

  An exception of type 'System.MethodAccessException' occurred in
  mscorlib.ni.dll but was not handled in user code

If there is a handler for this exception, the program may be safely continued.

What is wrong? How can I load a text file from Content?

private const string filename = "Level1.txt";
public void LoadfromContent()
    {
        if (File.Exists(filename))
        {
            using (StreamReader reader = new StreamReader(File.OpenRead(filename)))
            {
                strs = reader.ReadLine().Split(';');
                game1.HowManyEnemies = int.Parse(strs[1]);
            }
        }
    }


texts: Using tilemaps for an isometric football game with cocos2dx

texts:
I am writing a simple soccer game in cocos2d-x and recently found out that older iOS versions do not support cocos2d sprites larger than 1024x1024px.

I was thinking about using isometric tilemaps to create a larger football field.

Is this the way to go ? If so, how can i convert a  convert my 2048x2048px football field image into several isometric tiles ?


texts: How to include moai in lua code for running it using luajit?

texts:
I'm running moai from ubuntu for some simulation purposes.

I have a lua script that is executed using luaJIT.

Now I want to run a simulation written based on moai from within this script.

As of now, i can run the simulation like this : moai sim.lua

I want to see if i can do it lie this : luajit sim.lua ?

Is there a way to include moai just like other modules (require 'moai') and start using it ?

Thanks.


texts: Is this the typical approach to modern OpenGL UI & Text rendering, for mobile?

texts:
I'm implementing GUI in OpenGL ES 2.0 to fit with my application framework's existing structure. I'd like to have the UI rendering eat as little mobile processing capacity as possible. So to confirm...

Is the following general approach standard these days, for mobile games?

Use the following for each of controls and text:

One VBO - one glDrawElements() call for all elements
One texture atlas (certainly just one for text, preferably just one for control backgrounds)
Many quads batched in VBO, each quad corner having appropriate UVs to access the character or detail texture in question
For overlapping UI "panels", turn on depth buffer & use different float depths per panel
Modifiable textfields have their own small, separate VBO modified using glBufferSubData() or glBufferData() (to shorten on backspace/delete) as noted here.

Please confirm / deny / correct existing points or add missing details where necessary.


texts: In tactical combat games, why does shooting end your turn?

texts:
I was wondering about this particular game mechanic in tactical combat games, like XCOM2, where you have two actions, which may be:

move+move
reload+move
move+reload
move+attack

...but not attack+move, because when attacking, it ends your turn.

If I compare this to tabletop D&D 5e, with its move+attack actions, it shouldn't be that different, but this restriction seems to make things completely different.

What is the game design purpose for this kind of restriction?


texts:
I tried using SDL2_image (2.0.3) with SDL2 (2.0.7) to load png files,
but when I start the application I get

SDL_image entry point SDL_acosf not found in SDL2_image.dll

This even happens when I just include SDL_image.h without actually using any of it`s functionality.

I`m using x86 versions of both libraries. Dlls are in SysWOW64.
Compiling with VS 2017.

What am I missing?

Update:
This happens when I link against SDL2_image.lib. I don't even need to include SDL_image.h.
Also SDL_acosf doesn't seem to exist in SDL2 or SDL2_image.

thanks


texts: How to create complex Physics scenes with the Havok Content Tools

texts:
For example, Havok Content Tools allows you to define physic bodies, properties, connections, etc in Maya, 3d Studio Max, etc.

For creating full scenes/levels is this really the correct approach or is there some better way to do things.


texts: SDL2 and OpenGL: flickering with double buffering, what am I doing wrong?

texts:
I'm currently fiddling with SDL2 and OpenGL to get an understanding on how they work and, moreover, how shaders are done and work.
Right now, I'm following this tutorial, using SDL instead of glfw; and in a SDL window I render 2 triangles via shader and change their color dynamically, but an obnoxious flickering effect shows, even though I'm sure double buffering is active.

Now, to the code:

    //Here they are SDL attributes for OpenGL
    SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
    SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 );
    //Double buffer should be on by default, but I set it anyway
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );

    //SDL window creation
    mWindow = SDL_CreateWindow( "Window Title",
                            SDL_WINDOWPOS_UNDEFINED,
                            SDL_WINDOWPOS_UNDEFINED,
                            mWidth,
                            mHeight,
                            SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE );

    // Use Vsync
   if( SDL_GL_SetSwapInterval( 1 ) < 0 )
   {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Warning: Unable to set VSync! SDL Error: %s\n", SDL_GetError() );
  }

    //OpenGL initialization
    glClearColor(0.f, 0.f, 0.f, 1.f);

    glEnable( GL_TEXTURE_2D );

    glEnable( GL_BLEND );
    glDisable( GL_DEPTH_TEST );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

while one of the shaders (no point in pasting the other one, too, as the issue is the same) I use is:

vertex shader:

#version 330
layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;
out vec3 LSampleFrag;
void main()
{
    gl_Position = vec4(position, 1.0);
    LSampleFrag = color;
}

fragment shader:

#version 330
out vec4 color;
uniform vec4 LSampleFrag;
void main()
{
    color = LSampleFrag;
}

Binding of vertex data to the shader:

    glClearColor(0.f, 0.f, 0.f, 1.f);

    //VBO data
    GLfloat vertexData[] =
    {
        0.5f, -0.5f, 0.0f,
        0.5f, 0.5f, 0.0f,
        -0.5f,  0.5f, 0.0f
    };

    glGenVertexArrays(1, &gVAO);
    glGenBuffers(1, &gVBO);
    // Bind the Vertex Array Object first, then bind and set vertex buffer(s) and attribute pointer(s).
    glBindVertexArray(gVAO);

    glBindBuffer(GL_ARRAY_BUFFER, gVBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW);

    // Position attribute
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), nullptr );
    glEnableVertexAttribArray(0);

    glBindVertexArray(0);

and its render function is this one, where I change, everytime is called shade of green:

GLfloat timeValue = SDL_GetTicks();
GLfloat greenValue = (sin(timeValue) / 2) + 0.5;
GLint vertexColorLocation = glGetUniformLocation(mProgramID, "LSampleFrag");
glUniform4f(vertexColorLocation, 0.0f, greenValue, 0.0f, 1.0f);

glBindVertexArray(gVAO);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);

//in the main render function, after rendering the shader
SDL_GL_SwapWindow( window_->getSDLWindow());

As I've already said, double buffering is active but flickering is still an issue: am I missing something? I really don't understand why it is happening.


texts: What is the difference of target frameworks for unity3d?

texts:
In Visual Studio in properties I can change target framefork.

I cannot find anywhere what means all of these magic titles.

What does it all mean (full, micro base, subset, web base)?

And...Can I use functionality of .NET 4.6.1 ?


texts: What's so different/complicated/useful about vectors?

texts:
Forgive me if this isn't considered a real question, but it is something I am genuinely confused about.

I constantly hear other game developers talk about how using vectors are very useful, but also how everyone is intimidated by vector math and vectors can seem daunting. I have never got around to learning about them.

So, finally I looked Vector on Wikipedia, and I was surprised. Unless I am somehow mistaken, a vector(for sake of simplicity, say it's 2D), is just an x and y coordinate.  If I have misunderstood, please correct me.

So here is my question: doesn't that mean that any representation of two(or three) dimensional coordinates is a vector? If so, then a vectors and coordinates are the same thing. And it's pretty much impossible to create a game without using coordinates, so how are vectors confusing or new to someone who has done any amount of game programming?

This is something I could use some clarification on. Any help is appreciated.


texts: How to approach debugging of java.lang.NullPointerException in android build of unity app?

texts:
We are getting an obscure java.lang.NullPointerException when building a Unity app for android.  There's not much information here that I can trace back to our code. Does anyone have advice about how to approach debug this?

All I have to go on at the moment are logCat logs:

Uncaught exception thrown by finalizer
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
    at java.lang.reflect.Proxy.getInvocationHandler(Proxy.java:891)
    at bitter.jnibridge.JNIBridge.disableInterfaceProxy(Unknown Source:0)
    at bitter.jnibridge.JNIBridge.delete(Native Method)
    at bitter.jnibridge.JNIBridge$a.finalize(Unknown Source:15)
    at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:250)
    at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:237)
    at java.lang.Daemons$Daemon.run(Daemons.java:103)
    at java.lang.Thread.run(Thread.java:764)

(Unity version : 2018.1.0b10)


texts:
I have an empty scene with a single object in it, a cube.

The cube renders initially as pink, when it has no material attached.

When I attach a material though.  Any material.  Odd things happen.

I have created some extremely basic materials, which are just colours.  Some metallic, some not.  If I apply when of these the cube does not go the colour expected.  The exception of this is the Green and Blue materials, although I suspect they're the wrong shade.

Please see below:

Why could this be happening?  My settings look pretty standard on the cube...

If I create a brand new cube and set the materials up the exact same thing happens.

I have downloaded some sample materials from the asset store, and they behave strangely too.  A brown wood/bark texture does the following:

And here is that texture, definitely no sign of blue.

There are no lights set up, and the cube is the only item live on the scene, everything else is switched off.

I have also added a camera and rendered the scene.  Same thing.

Is there some sort of ambient light setting or something I am missing quite obvious?  Really not sure what to do here.


texts: ColorMaterial:AmbientAndDiffuse equivalent for CG\HLSL

texts:
I have this shader written on shaderlab, which replaces Ambient and Diffuse values of the material, because I need to tweak vertices colors from the script.

Shader "VertexSimple"
{
    Properties
    {
        _MainTex ("Base (RGB)", 2D) = "white" {}
    }

    SubShader
    {
        Pass
        {
            ColorMaterial AmbientAndDiffuse
            Lighting Off

            SetTexture [_MainTex]
            {
                Combine texture * primary
            }
        }
    }
    Fallback "VertexLit"
}

I need to write an equivalent of this shader on CG\HLSL to do some other routines in it. Ideally it should be vertex\pixel shaders, not surface one. How can I do this?


texts: Player gets stuck on edges between TilemapCollider2D tiles

texts:
I'm currently working on a simple 2D Physics-Based Platformer Project. However, I ran into the following issue:
I'm using a Tilemap and a TilemapCollider2D to display the world. When I move the player object, it sometimes gets stuck on the edges between the different squares of the TilemapCollider2D.
Here is a little gif showcasing my problem. Please note that I'm continually pressing A/D to move over the surface. The stopping is the bug I mentioned:

Here is my player code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{

Rigidbody2D rb2d;

[Header("Background Variables")]
public float speed = 5.0f;
public float maxSpeed = 10.0f;
public float jumpStrength = 10.0f;
public float friction = 2.5f;

public bool isGrounded = false;
public int walling = 0; // 0 = no wall collision; 1 = left side collision; 2 = right side collision

private void Start()
{
    rb2d = GetComponent<Rigidbody2D>();
}

private void LateUpdate()
{
    if(rb2d.velocity.x > maxSpeed)
    {
        rb2d.velocity = new Vector2(maxSpeed, rb2d.velocity.y);
    }
    else if(rb2d.velocity.x < -maxSpeed)
    {
        rb2d.velocity = new Vector2(-maxSpeed, rb2d.velocity.y);
    }

    if(Input.GetAxisRaw("Horizontal") != 0.0f)
    {
        rb2d.AddForce(speed * Vector2.right * Input.GetAxisRaw("Horizontal"), ForceMode2D.Impulse);
    }
    else
    {
        rb2d.velocity = Vector2.Lerp(rb2d.velocity, new Vector2(0.0f, rb2d.velocity.y), friction);
    }

    if(Input.GetButtonDown("Jump"))
    {
        rb2d.velocity = new Vector2(rb2d.velocity.x, jumpStrength);
    }
}

// These two methods currently have no effect, but I plan on extending them later
public void SetGrounded(bool isGrounded)
{
    this.isGrounded = isGrounded;
}

public void SetWalling(int walling)
{
    this.walling = walling;
}
}

My player uses a Rigidbody2D and BoxCollider2D.
Is there any good way to prevent this from happening or at least a workaround?
Thank you in advance!


texts: What are the advantages of tangent space shading/lighting, and what about attenuation?

texts:
In several topics here it was suggested by people that doing lighting in tangent space is better than doing it in world space. Right now I am doing it in camera space, but it's really similar to world space.
My question is, why would tangent space be a better choice for this (I am using normal maps if it matters)?
Secondly, when going from model space to world space and vice-versa, a scale is applied. This produces a problem when it comes to attenuated light, because the distances are quite different than in world space, which is where my light positions are. How would I deal with this?
Thanks in advance

EDIT:
Attenuation problem illustrated


texts: What is the best option to implement buttons as player controls?

texts:
I am familiar with programming, but new to Unity. There seems to be a million ways to implement a right and left button for turning the plane. I'm wondering what the standard/easiest/best way to do this would be.

Do I make a single script that references the two sprites "left" and "right" and then detects mouse clicks and figures out whether they are over the sprite?

Should the buttons even be sprites / game objects? Or is there a better option for UI objects?

Should the left and right buttons both have their own scripts?

ps. I absolutely can't stand video tutorials, and it seems like that's all there is for unity :'( so if there is a good written tutorial on unity desgin patterns, let me know please :)


texts:
I converted my project's .xnb files to .png files using a program and I can't seem to find a way to transform .png back to .xnb. I don't want to lose the work I've done. How can I change the images back?

P.S. GXView shows an error when I try to save as .xnb


texts: How to spawn enemies within a minimum distance of each other randomly? 2D

texts:
So I'm making an 2D infinite runner. So I try to spawn obstacles randomly in x-coordinate, but these just spawn most of the time in the same position and too frequently. generationPoint is just a small Empty a medium distance from the camera that's where the obstacles spawn. Even if I make them spawn at a small random rate It's still impossible to play.

{

public GameObject thePlatform;
public Transform generationPoint;
public float distanceBetween;

private float platformWidth;

public ObjectPooler theObjectPool;

public float randomEnemyThreshold;
public ObjectPooler enemyPool;

public float randomReindeerThreshold;
public ObjectPooler ReindeerPool;

void Start () {
    platformWidth = thePlatform.GetComponent<BoxCollider2D>().size.x;

}

void Update () {

    if (transform.position.x < generationPoint.position.x)
    {
        transform.position = new Vector3 (transform.position.x + platformWidth + distanceBetween, transform.position.y, transform.position.z);

        GameObject newPlatform = theObjectPool.GetPooledObject();

        newPlatform.transform.position = transform.position;
        newPlatform.transform.rotation = transform.rotation;
        newPlatform.SetActive (true);

        if (Random.Range (0f, 100f) < randomEnemyThreshold)
        {
            GameObject newEnemy = enemyPool.GetPooledObject();

            Vector3 enemyPosition = new Vector3 (-10f, 0.5f, 0f);

            newEnemy.transform.position = transform.position + enemyPosition;
            newEnemy.transform.rotation = transform.rotation;
            newEnemy.SetActive(true);

        }

        if (Random.Range (0f, 100f) < randomReindeerThreshold)
        {

            GameObject newDeer = ReindeerPool.GetPooledObject ();

            Vector3 reindeerPosition = new Vector3 (5f, 0.5f, 0f);

            newDeer.transform.position = transform.position + reindeerPosition;
            newDeer.transform.rotation = transform.rotation;
            newDeer.SetActive(true);
        }
    }

}

}


texts: Transform.forward having problems after rotation

texts:
I have this script,

void Update () {

        float pitch, yaw, roll;

        pitch = Input.GetAxis ("Mouse Y");
        yaw = Input.GetAxis ("Mouse X");
        roll=Input.GetAxis ("Roll");

        transform.Rotate (-pitch, yaw, -roll);

        if (Input.GetKey (KeyCode.W))
            Rigid.AddRelativeForce (transform.forward * 50);
        else if (Input.GetKey (KeyCode.S))
            Rigid.AddRelativeForce (-transform.forward * 50);
        else if (Input.GetKey (KeyCode.D))
            Rigid.AddRelativeForce (transform.right * 50);
        else if (Input.GetKey (KeyCode.A))
            Rigid.AddRelativeForce (-transform.right * 50);
        else
            Rigid.velocity = Vector3.zero;

        if (Input.GetKey (KeyCode.Space)) {

            transform.rotation = Quaternion.Euler (Vector3.zero);
            Rigid.velocity=Vector3.zero;
            Rigid.angularVelocity=Vector3.zero;
        }

    }

My "Roll" is defined as 'q' and 'e' keys. "Rigid" is rigidbody object.

I simply want to implement 6DoF on this cube, the pitch, yaw and roll works fine , but when it comes to movement it behaves in very unusual way after the object is rotated, I tried moving by using localPosition still no result. I also used relative torque for rotation but it resulted in worse, that is why rotation is controlled by transform.rotation not torque.

I suppose I am not handling gimbal lock or something? Or am I doing it completely wrong?


texts: Finding the normal from one 3d vector/line to any point on another 3d vector/line

texts:
Say I have two 3d vectors, v1 and v2 (you can consider them both lines if you like). I'm trying to figure out a normal for v1 so that it intersects along any point of v2.

I keep drawing blanks on this one. It's easy enough to find a vector that points from v1 to v2 (just do v2 - v1), but that result isn't always perpendicular to v1.

How would you go about making that result perpendicular to v1?


texts: What is the rationale behind this method of computing the w-component from MD5 mesh files?

texts:
In tutorials regarding the MD5Mesh format, like this one, we often see code like

float t = 1.0f - (q.x * q.x) - (q.y * q.y) - (q.z * q.z);

if (t < 0.0f) {
   q.w = 0.0f;
} else {
   q.w = -sqrt (t);
}

for computing the w-component of a unit quaternion given x, y, z.
Why do we obtain w in this manner?


texts: Keeping simulations in sync over long periods of time

texts:
I'm working on a multiplayer game which involves a huge amount of predictable AI enemies, and a few other players. The enemies are the most important to be accurate, because the game involves pixel perfect dodging.

In deciding how to network this game, there are two main objectives:

Smallest possible bandwidth usage.
Game remains playable over bad connections, like wifi & mobile.

I have thought of this system:

On connection, send full server state to client.
Client & server both simulate all enemies.
Server sends updates on what tick it is currently on, and anything that's non-predictable (other player movement, etc), but does not include the enemy details.
Ensure simulation is deterministic by sharing implementation, using fixed timestep, share random seed, etc.
If client gets out of sync, can re-sync by requesting all information again. Can check via tick number or via some checksumming mechanism.

The problem:

How to deal with clients & servers going out of sync due to tick rate discrepancies?

Normally I'd use a delta based on the last tick for the simulation, but the need for a fixed timestep (to avoid floating point error) means that's impossible. If the client or server is running slightly slow or fast, it'll get more and more out of sync. If the sync gets bad enough, we can re-sync.

My basic testing with a Chrome client shows that skew can happen fast and consistently, getting about a tick out of sync every second (at 30fps). Even 1 or 2 ticks off can really ruin the game experience since it's a pixel perfect avoidance game. It seems we'd need to resync every second or so, which may also be jumpy and look weird, though interpolation could smooth it out.

Is my system fundamentally flawed, or is this something that can realistically be smoothed out?


texts: How to export from Eclipse with LWGJL using JarSplice?

texts:
I am in the process of developing a 2D tile-based RPG with Eclipse, LWJGL, and Slick utilities.

For some reason eclipse seems to be lagging heavily which doesn't make sense as all I have rendering is a 64x64 test map using 16x16 tiles, the character, and text when i press enter.

To see if it is a problem with my code or with eclipse, I am trying to export it into a jar or exe and run it outside of eclipse.

Since I use png spritesheets and xml files to supply coordinates and map data, I need to also include a resource folder.

I've tried exporting from Eclipse as a jar, then adding that jar, the Slick jar, and LWJGL jar into JarSplice, but it says error opening zip file, which I assume is that the resource folder is zipped when Eclipse creates a jar.

I need to know how to get the jar to run, and where I need to place the resource folder, and if I need to change any code to be able to access the resource folder. I think I saw something about the appdata folder being where you place such things, but I do not know how to use it.

P.S My code uses 3 spritesheets (Tiles, Character, Text), 4+ xml files (one for each spritesheet + one for each map), and uses Immediate mode rendering, so if the problem is that immediate mode isn't fast enough, should I go up all the way to VBO's, or would display lists suffice?

EDIT:
I normally wouldn't think it was Eclipse, however Eclipse itself seems very slow lately.

Sometimes when I run my code, it works without lagging at all, and others it seems as if the frame-rate is less than 10.

Also sometimes basic functions in my code decide not to work. For instance, I implemented a way so when the enter key is down three lines of text appear, sometimes when I run, they show up sometimes they don't.

Another instance (I run in fullscreen mode) is that sometimes when I hit run, my view will size up to fullscreen, but it still just shows Eclipse, and I have to take my battery out to exit.


texts: What are the most common ways of closing an open world?

texts:
In many open world games, there are several ways to limit them. From original ones such as Desynchronisation(Assasins' Creed) to invisible walls.

What are the most common ways to close open worlds?


texts: Why is GL_TEXTURE_MAX_ANISOTROPY_EXT undefined?

texts:
So I'm writing my texture class in my opengl game, I get to the part where I would normally set GL_TEXTURE_MAX_ANISOTROPY_EXT, and I'm shocked to discover that it's undefined!  This exact same extensions worked perfectly in a different application, so I know it's not a typo or something.

It's worth noting that I'm getting my extensions using glcorearb.h, instead of glext.h, because I have no intention of supporting the compatibility profile.  Could this be my problem, and if so, how do I work around it?


texts: How to smoothly rotate a vector in a direction?

texts:
I'm looking for an easy way to achieve the following:

Object A, B
{
    Vector2D position;
    Vector2D orientation;
}

update(elapsed)
{
    //rotate A's orientation in B's direction by x * elapsed degrees
    //until A's orientation equals the direction from A to B
}

I am trying to align object A with an object B.
Object A should rotate in B's direction by certain degrees/sec, e.g. max 45/sec.

I calculate the direction from A to B with normalize(B.position - A.position),
but I don't know how to rotate A's orientation vector stepwise in B's direction.


texts: How can I render to texture in single mip-level?

texts:
I'm trying to implement Hi-Z Screen-Space Cone-Traced Reflections using Direct3D9. I already know how to render to specific mip-level texture using Direct3D11, but not using Direct3D9.

Has anyone tried the same before?

How would I generate a custom mip-texture using D3D9? Not just switch between two different sized textures from system memory.

Maybe something involving StretchRect functions might work?


texts:
What will be the best algorithm or logic that can be used for game like greedy spiders.
As far as I can think it is based on A* algorithm ? Where the shortest path has to be a search between the spider and the flies.

Is there any better logic to implement that game?

I would like to learn the concept behind it. How they will be managing nodes and edges concept?


texts: How to Refresh Dependencies after Adding FreeType Extension in Android Project

texts: I'm planning to use FreeType fonts in my game (LibGDX and Android Studio) and I already added the freetype dependencies in my project. How can I refresh the dependencies after adding them? I have found few similar questions regarding this topic but didn't offer much help. Here is an image of the dependencies:


texts:
I have a 2d platformer game where my slope can be set at any angle, so I've setup a middle raycast that points to the ground onto the player to handle the collision. This works perfectly fine on a flat platform, but when I rotate it to a slope the player is offset increasingly more.

Player falls onto the platform with no rotation (works fine).

The player falls onto a platform at an angle with no rotation on the player.

Then when I rotate the player to the angle of the platform.

As you can see the player is offset wrong. Do I have to rotate the rays attached to the player and then push him out of the platform? Or is this overkill and I'm doing something wrong?


texts: Can I use a creative common licensed CC BY 4.0 model in a commercial indie game?

texts:
I want to use this keyboard model in my commercial indie game.
The site says the asset is available with a "CC Attribution" licence, linking to the information page for the CC BY 4.0 licence.
From what I understood, you are able to use the creative common asset if you modify it. As the site says:

Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material
for any purpose, even commercially.

As you can see it doesn't say anything about using the Creative Commons asset, which made me wonder if I can actually use it (with credit).


texts: Using EntityManager from inside a system

texts:
I am using Entities v0.8

I am trying to build a Spawner, and this is the system

using UnityEngine;
using Unity.Entities;
using Unity.Transforms;

public class ChunkSpawnerSystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entities.ForEach((ref ChunkSpawnerComponent spawner) =>
        {
            if (!spawner.needsRender) return;

            EntityArchetype chunkArchetype = EntityManager.CreateArchetype(new ComponentType[] { typeof(Translation) });

            for (int id = 0; id < spawner.size; id++)
            {
                Debug.Log("Rendering chunk " + id);
                Entity entity = EntityManager.CreateEntity(chunkArchetype);
                EntityManager.SetName(entity, "Chunk " + id);
            }

            spawner.needsRender = false;

        }).Schedule();

    }
}

But I get the following error

  ChunkSpawnerSystem.cs(9,9): error DC0002: Entities.ForEach Lambda expression invokes 'get_EntityManager' on a ChunkSpawnerSystem which is a reference type. This is only allowed with .WithoutBurst() and .Run().

Apparently I cannot seem to be able to use EntityManager inside the lambda function. Why is this?


texts:
I have a game where you walk around picking up items. They are supposed to go into the next empty slot in your inventory, but when I pick up an item all the empty inventory spots get filled with it.

How can I only have the first empty one be filled by the item that is being picked up:

Here is my code:

for (int i = 0; i < c.toArray().length; i++) {
  c.get(i).tick();

  for (int i1 = 0; i1 < play.items.p.toArray().length;i1++) {
    if (c.get(i).holdingid == 0) {
      // check if the player walks onto the item which means it should
      // be picked up:
      if(play.items.p.get(i1).r.intersects(play.p.r)) {
        // remove the item from the ground:
        play.items.p.get(i1).remove = true;
        // change the empty inventory spots to be filled with the item
        // that has been picked up
        c.get(i).holdingid = play.items.p.get(i1).holdingid;
      }
    }
  }
}

The problem is it fills all the inventory spots how can I make it only fill the first inventory spot.


texts: stencil shadows - doom 3 engine - precision errors - shadow cracks - why?

texts:
I am testing the limits of the Doom 3 engine - in regards to maximum map size.

I noticed some stencil shadow precision errors that become more pronounced when objects get further and further away from the map origin.

at position: -10901 -18214 -11204

at position: -10802 -26483 -19383

at position: -10802 -34683 -27540

I believe these errors have been referred to as "shadow cracks" but I am not positive what these artifacts have been previously called.

Nearly all of the artifacts appear along the bounds of the lights/shadows - which can be seen here:

Has anyone seen this type of graphical artifact before with stencil shadows? What are they called? What is the cause?

More examples:

This is the vanilla Doom 3 Engine as found here: https://github.com/TTimo/doom3.gpl

I noticed while testing the r_useOptimizedShadows cvar (which handles the shadow volumes of the worldspawn geometry) that the artifact disappeared. Then I worked my way to this function:

R_LinkLightSurf( &vLight->globalShadows, tri, NULL, light, NULL, vLight->scissorRect, true /* FIXME? */ );

which I changed to this:

R_LinkLightSurf( &vLight->globalShadows, tri, NULL, light, NULL, vLight->scissorRect, false /* FIXME? */ );

That gets rid of the artifacts - but now it assumes that we are never inside shadow volumes of the worldspawn geometry. So whenever we do go inside a shadow volume, that shadow volume is not rendered properly.


texts:
Inside of my main class file I am initializing a number of game components which are used to represent game scenes i.e. main menu and game. I am initilizing each component inside of XNAs LoadContent method without issue and set the default scene as the main menu. I then switch to the game scene.

My issue then occurs when I switch back to the main menu scene and then try to start a new game by switch from the menu to the game scene. When I switch from the game to the menu I dispose of the game scene using the GameComponent.Dispose() method provided by the XNA framework.

private void UnloadScene(GameScene scene)
{
     scene.Dispose();
}

As I have disposed of the game scene I attempt to re-initialize the game scene component with the following method.

private void LoadScene(GameScene scene)
{
     scene = new GameScene(this, graphics.GraphicsDevice);
     Components.Add(scene);
}

I then switch from the menu scene to the game scene using the following method. This method is called in my Update method after the user has selected new game on the main menu.

public void SwitchScene(SceneManager manager)
{
     sceneManager.HideScene();
     sceneManager = manager;
     manager.ShowScene();
}

This time when the game scene loads I am met with a cornflower blue background and no assets on screen. I have placed a breakpoint within the above method and seen that the game scene is given all of the required data yet nothing is being drawn.

However if I explicitly place the following code above the SwitchScene() method after the player has selected new game then the scene is drawn without issue.

scene = new GameScene(this, graphics.GraphicsDevice);
Components.Add(scene);

Below is what the code looks like with the second approach mentioned.

if (InputHandler.IsHoldingButton(0, Buttons.A, out throwAway))
{
     switch (menuScene.Index)
     {
          case 0:
              gameScene = new GameScene(this, graphics.GraphicsDevice);
              Components.Add(gameScene);

              SwitchScene(gameScene);
              break;

          case 1:
              this.Exit();
              break;
     }
}

Is this behaviour intentional, if so how would I attempt to produce the first approach correctly?

Below is a screenshot of the graphics device after the second attempt to load the game scene. Note the data in this image is identical to the graphics device when loading the game scene for the first time.

Below is the code for the SceneManager class.

public class SceneManager : DrawableGameComponent
{
    private readonly List<GameComponent> components;

    public List<GameComponent> Components
    {
        get { return components; }
    }

    public SceneManager(Game game)
        : base(game)
    {
        components = new List<GameComponent>();

        // Indicates whether draw should be called
        Visible = false;

        // Indicates whether GameComponent.Update should be called
        // when Game.Update is called
        Enabled = false;
    }

    public virtual void ShowScene()
    {
        Visible = true;
        Enabled = true;
    }

    public virtual void HideScene()
    {
        Visible = false;
        Enabled = false;
    }

    public override void Update(GameTime gameTime)
    {
        for (int i = 0; i < components.Count; i++)
        {
            if (components[i].Enabled)
                components[i].Update(gameTime);
        }

        base.Update(gameTime);
    }

    public override void Draw(GameTime gameTime)
    {
        for (int i = 0; i < components.Count; i++)
        {
            GameComponent component = Components[i];

            if ((component is DrawableGameComponent) &&
                ((DrawableGameComponent)component).Visible)
            {
                ((DrawableGameComponent)component).Draw(gameTime);
            }
        }

        base.Draw(gameTime);
    }
}


texts: What is the name for a single 2D polygon on a UV Mapped texture?

texts:
When UV Mapping a polygon/texture, is there name that describes a single polygon on the texture.

Does this name differentiate if from the same geometry once it has been mapped to a face?

Would sometime like "UV Tile" or "UV Face" be clear?


texts: Are wheeled vehicles usually controlled by force applied to wheels or is movement simulated by a force applied to the vehicle?

texts:
I'm building a tank in my game and I was hoping to have moving wheels with rotation and shocks. I can get the wheels to bounce and rotate but they do not actually propel the car forward.

Should I not be trying to apply a force to the wheels and instead just show the wheel rotating as I apply a force to the body of the tank?

EDIT: ALRIGHT! I did it! I rigged the tank! But the question still remains, is vehicle movement with spinning wheels usually just an animation with a force applied to the car or is it not ridiculous to apply a force to the wheels?


texts: How to create a generic character entity in Entity System?

texts:
In the below code is the way I create a character in Entity System. But I think this is the decouple, I'm having hard time decoupling this class.

1st approach

public enum CharacterType {

     PLAYER_CHARACTER,      // PC or a character controlled by a player
     NON_PLAYER_CHARACTER   // NPC or a character controlled by a computer it self (artificial intelligence), but notice that it is a friendly character

}

public class Character {
     // Player-Character can be controlled by the player it self
     // None-Player-Character is a autonomous and cannot be controlled
     // Player-Enemy target a player-character
     // Player-Allied target a player-enemy and friendly to a player-character
     // All character is moving
     CharacterType type
     CharacterMovement movement
}

// or

public class PlayerCharacter extends Character {

}

public class NonPlayerCharacter extends Character {

}

public class Merchant extends NonPlayerCharacter {

}

public class Enemy extends Character {

}

public class CharacterComponent implements Component {
     public Character character;
}

2nd approach

public class PlayerComponent implements Component {
     public static final int IDLE = 0;
     public static final int MOVE_UP = 1;
     ...
}

public class NonePlayerComponent implements Component {
     public static final int IDLE = 0;
     public static final int MOVE_UP = 1;
     ...
}

public class EnemyPlayerComponent implements Component {
     public static final int IDLE = 0;
     public static final int MOVE_UP = 1;
     ...
}

public class AlliedPlayerComponent implements Component {
     public static final int IDLE = 0;
     public static final int MOVE_UP = 1;
     ...
}

Noticed in the 2nd approach that it has a redundant data.


texts: Making only parts of a mesh destroy in UE4

texts: I am making a 3d, 3rd person shooter game where I want everything to be destructible. UE4 makes this possible by making meshes destructible, but the problem is that when the mesh is damaged, it destroys completely. This is not what I want, I would like to keep the destruction limited to some volume of the mesh proportional to the bullet's size. Also, the ground must be vulnerable to explosives and must crater as a result. I was just wondering if there was a way to limit the effect of the destruction to some part of a mesh only.


texts: How can I switch between cinemachine free look cameras by script?

texts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;

public class CamerasManager : MonoBehaviour
{
    public CinemachineFreeLook[] freeLookCameras;
    public float timeBeforeSwitching;

    // Start is called before the first frame update
    void Start()
    {
        StartCoroutine(SwitchCameras(timeBeforeSwitching));
    }

    // Update is called once per frame
    void Update()
    {

    }

    IEnumerator SwitchCameras(float TimeBeforeSwitching)
    {
        yield return new WaitForSeconds(TimeBeforeSwitching);

        for(int i = 0; i < freeLookCameras.Length; i++)
        {
            freeLookCameras[i].en
        }
    }
}

If I have two or more cameras I want that after X seconds start switching between all the cameras in the array by disabling/enable the cameras. disable the first enable the second then disable the second enable the third and so on.


texts:
I have a client server build in Unity 5. I want to send a command from the client to the server with a GUI button click, this is for testing purposes. So on my client all I want is to click a button and then have the server display a message on its console window. Reading through http://docs.unity3d.com/Manual/UNetActions.html this seems to require a player object. With the demo I am trying to create there is no player. So I created an empty game object and called it player and assigned it a player script:

public class Player : NetworkBehaviour {

void Update ()
{   //receive message from camera follow script to run command from client to server
    if (isServer)
        return;

    if (GameObject.Find("Main Camera").GetComponent<CameraFollow>().sendCommand)
    {
        CmdTurnOnNetworkTransformOnServer ();
    }
}

[Command]
void CmdTurnOnNetworkTransformOnServer()
{
    UnityEngine.Debug.Log ("Received");
}
}

This script checks if a boolean is true on another script (the script that contains the GUI button that when clicked sets the bool to true). if it is true then I would like the server to display "Received" on the console in the editor. However I get the error "Trying to send command for non-local player." From what I can see I am following the above link properly to just display a simple message. I realise there is another route with http://docs.unity3d.com/Manual/UNetMessages.html however I would like to see if I can get a command working instead.

Full Error: Trying to send command for non-local player.
UnityEngine.Networking.NetworkBehaviour:SendCommandInternal(NetworkWriter, Int32, String)
Player:CallCmdTurnOnNetworkTransformOnServer()
Player:Update() (at Assets/Player.cs:37)

How come I am getting this error?

This error appears in the client console window


texts: How would I swap a character when a player touches a collider?

texts:
I wrote a simple script to attempt to do this and I created an empty game object and applied the script to it and dragged both of my sprites into my script and I receive no errors but nothing happens when my player enters the collider and the "Calm" version of the sprite is still active.

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

public class JetAnglerSwap : MonoBehaviour {
public GameObject CalmAngler;
public GameObject AngryAngler;
// Use this for initialization
void Start () {

}

void OnTriggerEnter2d(Collider2D other)
{
    if (other.CompareTag("Player"))
    {
        SwapAnglers();
    }
}
    void SwapAnglers()
{
    CalmAngler.gameObject.SetActive(false);
    AngryAngler.gameObject.SetActive(true);
}
}


texts: What is the reason that people avoid PlayerPrefs to store character data and coins etc?

texts: PlayerPrefs are easy to implement and i think it can be used to store important game data like selected character and coins and completed quests for small games, but i have read too much to make me ask this question that why not use it, and what is the other options for storing important game data in


texts: OpenGL ES 2 shaders for drawing buildings and roads like Google Maps does

texts:
I'm trying to create a shader that'll give me an effect similar to what buildings and roads look like on 3D Google Maps. You can see the effect interactively if you enable WebGL at maps.google.com, and I also found a couple of screenshots that illustrate what I'm trying to achieve:

Thing I noticed:

There's some kind of transparency thing going on with the roads/ground and the buildings, but not between the buildings themselves. It might be that they're rendering the ground and roads after the buildings with the right blend functions to achieve that effect.
If you look closely, you'll see parts of the building profiles have an outline. The roads also have nice clean outlines. There are a lot of techniques for outlining things with shaders... but I'm curious to find out what might have been used in this case considering mobile hardware and a large number of entities with outlines (roads and buildings)
I'm assuming that for the lighting, some sort of simple diffuse per-vertex shader is being used for the buildings though I could be wrong.

I'm especially curious about the 'look' they achieved with buildings (clean, precise outlines/shading). It reminds me a little of what you'd see when designing stuff with CAD applications like SolidWorks:

I'd appreciate any advice on achieving this kind of look with ES 2 shaders.


texts: How to achieve a sheet of paper unfolding from the center in XNA 2D?

texts:
I need to create an effect like a folded sheet of paper unfolding.

I was thinking about transforming an image so it "scales" from the center to the borders by cutting the image in half and scaling both parts to create this effect.

Is there a better way?


texts:
I'm very new to game development, but an experienced software engineer. As an introduction to game dev, I'm making a 2D zombie game in Python, using pygame. The game is almost done, but I still have to write the AI for the other humans and the different zombies in the game.

Should I have a centralized AI module that looks for the position of each character and zombie and determines the best way to move each of them? Or should each instance of a zombie or human be responsible for its own behavior?

In my mind it is more straight forward to make each unit responsible of it's own behavior and I think that it would be easier to give them a more "natural" look implementing it this way. However it's probably a lot more inefficient in memory and processing time that a centralized one. Again, I'm super new to games so any example of how is the AI implemented in some major games would be appreciated.

I understand this is probably a very subjective question, but I'm looking for an answer that covers something like pros vs cons, industry standard or known cases of each one.


texts: How can I apply steering behaviors to a car controlled with turning and acceleration?

texts: I feel like I've got my head around steering behaviors,  but I've having trouble applying them to a car. The steering behaviors return forces that one could apply to an object that can move in any direction, but a car can essentially only move forward and turn. I'm having trouble determining how hard the car should turn or how much it should accelerate forward based on the steering force. How can I translate a steering force into the car's input?


texts: What are good, simple action games/action RPGs to emulate?

texts:
There is standard advice for game development to start off emulating simple games you know and build up from there. Which makes me wonder. What are good examples of action games or action RPGs that are very simple to begin with to try and emulate? What is necessary and what is superfluous?

Please link to the game's site (or Wikipedia page if it's defunct) if you can, and only one game per answer please.


texts: Using Racing Wheel force feedback with a JavaScript game

texts:
I have a Thrustmaster T80 Racing Wheel that I am using while developing an online game with ThreeJS.

I have already made it so I can drive the car with the wheel and the game knows when I crash the car. But looking online I couldn't find a way to make the wheel 'rumble' or shake when the car crashes.

The wheel does support this on other (downloaded exe) games but it would be amazing if it was possible to achieve in a JS game, but I couldn't find any mention of doing this online.


texts: Optimization for Normal maps with lots of wasted space?

texts: I'm working on level/character assets where I'm finding that I use only very little amounts of normal mapping on them, resulting in 2048x2048 textures that are mostly blue/purple. Is there any method to better optimize this, perhaps use one normal map for several assets?


texts:
I'm currently attempting to implement BRDF lighting, and am hitting a bit of a snag with my specular term - the specular highlights aren't rendering correctly.

To make things simple, I'm using a single directional light rendering down the Z axis only, and manually specify the gloss/specularity of each of the following spheres.

Glossyness increases left to right, and Specularity increases bottom to top. Notice how the highlights seem shifted nearly 90 degrees upwards:

Calculating the specular BRDF

I use the generic Fresnel Shlick eq:

For the NDF, I use the GGX Trowbridge-Reitz eq:

And for the Geometric Shadowing function, I use the Smith / Shlick-Beckmann eq:

vec3 BRDF_Specular(vec3 F0, vec3 1minusF0, vec3 WorldPos, vec3 Normal)
{
    vec3 LightDirection         = vec3(0, 0, -1);
    vec3 ViewDirection          = normalize(EyePos - WorldPos);
    vec3 HalfVec                = normalize(LightDirection + ViewDirection);
    float NdotL                 = clamp(dot(Normal, LightDirection), 0.0, 1.0);
    float NdotV                 = clamp(dot(Normal, ViewDirection), 0.0, 1.0);
    float NdotH                 = clamp(dot(Normal, HalfVec), 0.0, 1.0);
    float VdotH                 = clamp(dot(ViewDirection, HalfVec), 0.0, 1.0);

    float Roughness             = max(1.0f - Gloss, 0.0); // Turn into roughness
    float Roughness_2           = (Roughness * Roughness);
    float NdotH_2               = NdotH * NdotH;

    /*  Normal Distribution Function
        GGX (Trowbridge-Reitz) */
    float D0                    = (NdotH_2 * (a_2 - 1.0f) + 1.0f);
    float D                     = a_2 / (M_PI * (D0 * D0));

    /*  Fresnel
        Shlick  */
    vec3 Fs                     = F0 + 1minusF0 * pow(1.0 - VdotH, 5.0);

    /*  Geometric Shadowing
        Smith / Shlick-Beckmann */
    float k                     = a_2 / sqrt(2.0 / M_PI);
    float GV                    = NdotV / (NdotV * (1.0 - k) + k);
    float GL                    = NdotL / (NdotL * (1.0 - k) + k);
    float G                     = GV * GL;

    vec3 brdfspec               = vec3(max(( Fs * D * G ) / (4.0f * NdotL * NdotV), 0.0));
    return brdfspec;
}

I've been following so many different resources and mimicked many other implementations, and even reducing it down to this basic level I'm still having this issue. I don't know why I'm not getting proper results

I'm using a deferred renderer, I derive the World position of each fragment from the depth buffer, and store my normals in viewspace.
I don't use a "Metalness" map, but instead use a single rgb specular map, hense why my Fresnel calculation uses Vec3's instead of floats.


texts: Is it useful to distinguish between two different kinds of events?

texts:
i have thought about this for a long time and i think i just going in circles. I need someone to tell me if im just simply overthinking it.

So, first of all im coming from a 'classical' ECS approach: You got entities that are basically just Ids, Components to these IDs in different colors (PosComponent, 2dGraphicComponent, etc.) and your systems working on those components. Im still working on an game engine, so none of these components are fix.

Now i have an event manager that accepts events. Currently these events are like MouseButtonClicked, KeyPressed, WindowResized etc. These are events, certain systems have to react to these events immediately and can't wait to be resolved in the next game loop. So the polling for these events is at the beginning of the loop. Since the event manager does not know, that system handles this event, every system needs to be called in order, until one system handles the event and gives a positiv feedback. So for example if you click on the gui, you don't want to shoot a bullet.

Then there are events, that always have some context attached to it. Like an event onCollision, where a sound should be played and the player takes damage. In this case this event would need to be handled by two different systems and in context of the collided object. Bumping spikes might actually kill you, while colliding with an enemy may just hurt you. And of course the sounds are different.
Additionally, you may have events that are delayed to trigger. Faraway sounds like gunshots only move with the speed of sound, so delay it in regards to the distance. Or Buffs and Debuffs that run out. So these events should have a connection to a component or entity (id) and some sort of time to dispatch.

These two event types seem so distinct that i can't even think of realizing both as one class, or at least not the all the assumptions i made.

Maybe this is a stupid question, but should i create two different event types and thus eventManager? In my internet searches i have not found anything about this problem, but maybe my Google Fu is a bit rusted.


texts: Multiplayer game, design of server  client communication

texts:
I'm thinking about programming a multiplayer game.
For communication, I will use a Server <-> Client design like the following:

  Client <-> Server <-> Client

The Game will be a kind of Tower Defense. Where two players can fight each other by sending soldiers to the enemy to destroy their base or build towers to defend.

To keep the games in sync, each action must be sent to the other player.

e.g. Player 1 set a tower on position x, y so Player 2 must know about this tower (It would be pretty unfair if the enemy has invisible towers)

To sync the two games I can think of two methods:

First method:
The client(Player 1) set a tower to position x, y and send a message to server: "I have placed a tower on position x, y". The server sends this message forward to the other client(Player 2)

//client 1
buildTowerOnPosition(x, y);
sendToServer(BuildTowerMessage(x, y))

//server
receiveMessageFromClient(BuildTowerMessage(x, y))
sendFurtherToOtherClient(BuildTowerMessage(x, y))

//client 2
receiveMessageFromServer(BuildTowerMessage(x, y))
buildEnemyTowerOnPosition(x, y)

By this method:
The server doesn't need to know the current game status and serves only as a bridge between the clients

Second Method:
The client(Player 1) send a message to server: "I will build a tower on position x, y" the server build a tower to position x, y and send the changes(New tower on position x, y) to the clients

//client 1
sendToServer(BuildTowerMessage(x, y))

//server
receiveMessageFromClient(BuildTowerMessage(x, y))
buildTowerOnPosition(x, y)
sendFurtherToBothClients(BuildTowerMessage(x, y))

//both clients
receiveMessageFromServer(BuildTowerMessage(x, y))
buildTowerOnPosition(x, y)

By this method:
The server needs to know the current game status

My thoughts are:

By the first Method
The server only needs to forward the message and the main calculation is on the client side which relieves the server.

By the second Method:
The server can control the actions of the clients. For example: When both players set a tower on the same position at the same time, the first tower will be set and the second cannot be built anymore.
In the first Method the second tower will overbuild the first or in the worst case, both clients have different towers.

Now to my question:
Which method should I use for my game?
Is there more pro and contra by the methods?
Are there other methods?
Are there kinds of games where I should prefer another method than in my game?

Thank you for your advice


texts: Smooth Scene transitions with SceneManager and additive scene in Unity

texts:
I'm trying to work with the new SceneManager class with Unity, I'd like to have smooth transitions between scenes.
Currently I suppose that the only way to do those transitions is to manually implement them on the scene objects leveraging on the fact that scenes can be loaded additively.

In pseudo code I image something like:

for gameObject in previousSceneGameObjects
    gameObject.animateSceneExit()
endFor

for gameObject in nextSceneGameObjects
    gameObject.animateSceneEnter()
endFor

I feel that there is something I'm missing :P which is the best approach that you'd suggest? Is it my approach valid?