texts: how to check a condition for too many objects in a list that you dont know count of them

texts:
I'm working on a defense game that I need a way of knowing if every enemy in a wave is dead. I wanted to use a counter for it:

foreach (GameObject g in group1)
{
    if(g == dead) {
        deadCount++;
    }
}
if(deadCount == allEnemiesInWave)
{
    goToNextWave();
}

but I think it's not a safe or accurate way. Is there any better way?

Edit:
This question is not like Check if all gameobjects are destroyed. In my question, I wanted to make a condition on many objects, in the other one, OP wanted to check if such objects existed.


texts:
I'm trying to start LWJGL 3 development and I am having an issue with getting things working. I have created a new Gradle project and successfully built the HelloWorld example from https://www.lwjgl.org/guide but when I run I get an error. However the error seems to be different each time. Here is one example:
Hello LWJGL 3.2.3 build 13!
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fff6d4fe829, pid=4595, tid=5891
#
# JRE version: Java(TM) SE Runtime Environment (14.0.1+7) (build 14.0.1+7)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (14.0.1+7, mixed mode, sharing, tiered, compressed oops, g1 gc, bsd-amd64)
# Problematic frame:
# C  [libobjc.A.dylib+0x6829]  objc_msgSend+0x29
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/rob/Projects/Personal/cc/hs_err_pid4595.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Another:
Hello LWJGL 3.2.3 build 13!
[thread 9731 also had an error]
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fff34cc1027, pid=4579, tid=775
#
# JRE version: Java(TM) SE Runtime Environment (14.0.1+7) (build 14.0.1+7)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (14.0.1+7, mixed mode, sharing, tiered, compressed oops, g1 gc, bsd-amd64)
# Problematic frame:
# C  [CoreGraphics+0x73027]  CGClipRelease+0xe
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/rob/Projects/Personal/cc/hs_err_pid4579.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

What should I start looking at to resolve this?


texts:
I've made an animation in 3ds Max and want to export it to .fbx and import it into Unity. I've done this once without problems. But this time, my .max file is 2,8MB and my .fbx file came out a huge 630MB!

There's nothing wrong with my model: I exported it from a Blender model (to .fbx) and imported it to 3ds max (converted it to an editable poly) to do my rigging and animation. As soon as I import some .bip animations, I get these huge files.

Is there a safe way to get smaller file sizes? I don't mind redoing the rigging if I can solve this.


texts: How to create a tile map texture in Oxygine?

texts:
I started playing around with Oxygine and Ogmo last night when I stumbled upon this GitHub that read in the Ogmo level.

I ended up fixing the doRender method as it did not work (could just be due to it being an old version of Ogmo or something):

void OgmoLevel::doRender(const RenderState& rs) {
    auto tileLayers = this->tileLayers;
    Sprite sprite;
    for (size_t layerIndex = 0; layerIndex < tileLayers.size(); ++layerIndex) {
        auto tileLayer = &tileLayers.at(layerIndex);

        auto resAnim = project->resource->getResAnim(tileLayer->tileset->name);
        resAnim->getFrame(0).getDiffuse().base->setLinearFilter(false);

        sprite.setResAnim(resAnim);

        int gridXSize = tileLayer->definition->gridWidth;
        int gridYSize = tileLayer->definition->gridHeight;

        size_t columns = roomWidth / gridXSize;
        size_t rows = roomHeight / gridYSize;

        auto tiles = &tileLayer->tiles;
        size_t tilesSize = tiles->size();

        size_t i = 0;
        float yy = 0;
        for (size_t y = 0; y < rows; ++y) {
            float xx = 0;
            for (size_t x = 0; x < columns; ++x) {
                int tileID = tiles->at(i);
                if (tileID != OGMO_BLANK_TILE)
                {
                    int tWidth = tileLayer->tileset->tileWidth;

                    int actualRow = (tileID * tWidth / tWidth) / tWidth;
                    int actualColumn = (tileID - (actualRow * tWidth));

                    sprite.setColumnRow(actualColumn, actualRow);
                    sprite.setPosition(xx, yy);
                    sprite.render(rs);
                }

                xx += tileLayer->definition->gridWidth;
                ++i;
            }
            yy += tileLayer->definition->gridHeight;
        }
    }
}

The issue I see with this, is that the same exact rendering is happening every single frame. Normally for the tile maps, there are checks to determine whether or not the tile is on the screen. Now that is fine and all, but this time around, I know it is fully static 99% of the time and I want to render it to a texture and just continue to render that.

I've looked at the MemoryTexture and ImageData classes, but there wasn't really anything online I could find to tell me how to properly use them. Does anyone have any idea how I can achieve caching this?

(not enough rep to create proper tags)


texts: Java - simultaneous ground and wall collision

texts:
I've been working on a Line2D based collision system:

public void update() {
    for (int i = 0; i < lines.size(); i++) {
        line = lines.get(i);
        if (line.line.intersects(player.hitbox))
            playerCollision();
    }
}

public void playerCollision() {
    if (Math.abs(line.angle) <= 45) {
        player.jumped = false;

        if (player.speedY > 0)
            player.speedY = 0;

        // inefficient?
        while (line.line.intersects(player.hitbox)) {
            player.centerY--;
            player.hitbox.setRect(player.centerX - player.WIDTH / 2, player.centerY - player.HEIGHT / 2,
                    player.WIDTH, player.HEIGHT);
        }

        player.centerY++;
        player.hitbox.setRect(player.centerX - player.WIDTH / 2, player.centerY - player.HEIGHT / 2, player.WIDTH,
                player.HEIGHT);

    } else if (line.angle > 0) {
        while (line.line.intersects(player.hitbox)) {
            player.centerX--;
            player.hitbox.setRect(player.centerX - player.WIDTH / 2, player.centerY - player.HEIGHT / 2,
                    player.WIDTH, player.HEIGHT);
        }

    } else if (line.angle < 0) {
        while (line.line.intersects(player.hitbox)) {
            player.centerX++;
            player.hitbox.setRect(player.centerX - player.WIDTH / 2, player.centerY - player.HEIGHT / 2,
                    player.WIDTH, player.HEIGHT);
        }
    }
}

Overall, it works pretty well. There is, however, one problem I haven't been able to fix. When the player collides on a place where a wall and the ground meet, both the ground and wall collisions are executed, however, only one should be.

The result is that the player is abruptly pushed off a cliff when approaching one, or that the player is abruptly moved up when jumping alongside a cliff.

When approaching a cliff:

After one step to the right:

I've been able to come up with a method to determine which collision should be executed:

if (player.hitbox.getMaxY() - player.speedY > line.line.getY1())
    // execute wall collision only
if (player.hitbox.getMaxY() - player.speedY <= line.line.getY1())
    // execute ground collision only

However, I haven't been able to come up with how to implement this. I can't check all lines for collision first and execute the collision later, as the collision is executed per line. Does anyone know how I can fix my collision system?

P.S. I'm a beginning game developer, so my collision detection system might be bad or inefficient. If there's a better way to do this, that doesn't have the same problems, I'd love to hear about it. Please keep in mind, though, that I'm trying to keep the code simple and efficient.


texts: How do I determine the draw order of isometric 2D objects occupying multiple tiles?

texts:
My current sorting method works only for objects that occupy 1 tile and fails for multi-tile objects. For examle, the bed in the above picture occupies 1×2 tiles, and the sorting fails.

Also that bed picture is 1 whole image that covers 2 tiles.

How can I change my sort method to accomodate this?


texts: Should chunks be procedurally generated client-side or server-side?

texts:
I'm developing a game with a friend that involves a procedurally generated map. My question is... Should the client generate the chunks, or should the client make a request to the server, and the server responds with the procedurally generated chunks? I can think of some advantages to both sides.

If it is generated client-side:

there will be a whole lot less load on the server
perhaps some game performance improvements too?

If it is generated server-side:

I can implement anti-cheating algorithms a whole lot more easily and efficiently
chunks can be "dynamically modified" by the server. Meaning the server can modify chunks for the clients before sending them if needed.

Another option would be for them to work together. The client would generate the chunks on-the-go, but would make a request to the server for modified tiles. I still can't implement the anti-cheating algorithms in this method though. But the advantages to this method are:

not much load on the server
server can dynamically modify chunks
moderate game performance

What is the best option, if any? And what do people usually do? Are there any advantages to any of these methods I'm missing?

EDIT: I know Minecraft chose the server-side method. I wonder what their reasons were?


texts: Why can we use planes and military vehicles, but not other things?

texts:
Something sounds a little odd. It seems to me the status quo that if I wanted to put a real car or motorcycle into a video game, say a Toyota or a Ferrari, everyone would say that the default position is that you're not allowed, and that you'd need to ask permission first, and that most likely permission wouldn't be granted, and that the license to place such a thing in my game would cost a fortune.

On the other I've noticed that people are much more confident about placing planes and military vehicles into a game, or display or render. I guess I'll start off with WW2 examples, and move from there. If we take the example of the P-51 Mustang fighter plane, it was manufactured by North American Aviation. That company doesn't exist anymore exactly, but was merged into North American Rockwell, which then became named Rockwell International, and now is part of Boeing.

OK, so there's no problem including a P-51 Mustang in your production. I guess you might say that the rights ownership transitioned so many times and over such a long period that Boeing really doesn't care if you include a P-51 Mustang in your production.

Let's take another example, Boeing P-26 Peashooter, a 1930s fighter plane. In this case the manufacturer was all along Boeing. I am confident there is still no problem in including this in your production. In this case you might say that the plane is so old Boeing doesn't care if you include it in your production.

You might say the same about the Mitsubishi and Kawasaki WW2 era planes.

Even more recently, with the F-16 you'd think rights holders would be General Dynamics or Lockheed Martin. I'm pretty sure you won't have a problem with including an F-16. One of the designers of the F/A-18 Hornet was McDonnell Douglas (now Boeing). Same thing goes here.

In fact you can fast forward all the way to the present to the F-35 Lightning II, which was designed and built by Lockheed Martin. I doubt very much there would be issues with including this plane in your production.

So the thing in common with all the above planes is that they're military.

If we consider civilian planes like the 737 and 747, I feel there is no problem displaying these and putting them into productions. GPL'd flight simulators have been taken and commercialized (sold), with these models in it, and I doubt very much either that permission was sought, or in the case that it was sought I'm almost sure they didn't pay for any license to have them in their game.

So with civilian planes I feel this is very much the same thing. Correct me if I'm wrong.

On the other hand if I said I was I going to include a Porsche 912 from the 60s in my production, you would say I would be crazy to do so without permission, and to get a license to do so would cost me a fortune. However I'd expect a completely different reaction to for example the Porsche 597 from the 50s.

So I'm noticing two things:

Military vehicles seem to be able to be used more permissively (a lot a more permissively).
Civilian aircraft seem to be able to be used more permissively) than civilian land vehicles.

As for boats and ships, it's something I haven't thought of that much. And in the case of VERY old civilian land vehicles, such as maybe the first Chevrolet from 1913, though I'd be guessing, I imagine wouldn't be a problem using its likeness in a production such as a film or game or something. It's very interesting, I feel if someone used the likeness of one of the earliest Ford motor cars, the problem would be to a much greater extent using the trademarked Ford logo than that the likeness of the actual Ford model. Does anyone know roughly speaking why there are these differences in the status quo?


texts: Would it be a good idea to offload tasks like navigation to the GPU?

texts:
So I was reading through my copy of GPU Pro 2 and I came across a chapter for building a rendering pipeline for real-time crowds. The implementation uses render targets on the GPU to update agents and finite state machines while also performing frustum culling and level of detail sorting. With this approach, the test case in the chapter is able to easily render about 8,000 characters walking in a crowd.

My question is have any games started taking advantage of the GPU for task other than rendering and physics such as game object updating and AI? And if so, are there any conceivable disadvantages to their implementations?

I ask this because I'm thinking about going this route with my game using D11 DirectCompute to create and simulate large scale space battles. Off the top of my head, I think the GPU would at least be a good tool in calculating and blending steering behaviors.


texts: Why is Unity UI Image color not being animated?

texts:
Animation is changing the color of an UI Image but the color only changes only in the inspector but not Game/Scene view.

In this video I demonstrate the problem clearly.


texts: Use code to disable player input unreal engine

texts: I have seen a lot of ways to use the node based visual scripts to stop player input; However, I have not seen a single example of how to disable the player input in visual studio?


texts: why is my OnCollisionStay is not calling?

texts:
I am very new to unity, i have used onCollitionStay() method but its not doing anything, i wanted to do in my code is "if zombie stays for 20 seconds with player the player life should be reduced", could anyone can help me out with this?
my code is

void OnCollisionStay(Collision collisionInfo) {
    if (collisionInfo.collider.tag == "zombie") {
        transform.GetComponent<Renderer>().material.color = Color.red;
        dieTime += Time.deltaTime;
        if(dieTime>20.0){
            noOfLivesLeft--;
            if(noOfLivesLeft<=0){
                transform.localScale = new Vector2(0,0);
                Application.LoadLevel ("GameOver");
            }
        }
    }
}


texts: Make player to always move along the terrain

texts:
I'm working on a 2D platformer side scroller game. I am giving high impulse to player, the player starts moving and if it hits a slope on terrain, it gets a vertical movement and starts to fly over (Box2D physics).

What I need is that the player should always be on the terrain and move along the ground.

I would like to know if it's possible using Box2D engine.


texts: Raise/Lower Object Height Based on Distance, with Easing

texts:
I'm trying to make an indicator object appear higher up in the sky the farther away a player is, up to a certain distance.

Basically, if the player is < 5 distance away, the object's height should be 1.
If the player is > 60 distance away, the object's height should be 50.
If the player's distance is between 5 and 60, the height of the object should be calculated based on the given scale, with an easing function applied so that it moves gradually to it's top and bottom locations.

This can be best illustrated with the attached graph that I created. The graph may not be perfect, but it should be close enough to get the general idea of what I'm hoping to achieve.

That said, I'd assume you'd need at least 5 variables... groundHeight, maxHeight, minHeight, maxDistance, and minDistance, but how would I use this information to calculate the expected height for a given distance?

This isn't related to a specific game engine and language isn't important. I happen to be working with Lua on my current project, but JavaScript, C#, or even pseudo-code solutions would help me understand how this is achieved.


texts:
I would like to know which idea is better in terms of performance.

The map is 5000x5000 tiles and I plan to expand it even more. It is split into 50x50 regions and camera doesn't move with player, the map just switches to next one when player reaches border of the screen.

I have few possible approaches to store and load a big map like this.

Case 1: I store every 50x50 region in a seperate JSON file, and just load them dynamically with XHR when player reaches border of the screen (native not jquery, since it is much faster)

Case 2: I store every 50x50 region in a seperate bitmap files, and then load that image dynamically using canvas and read it's pixels to generate map.

Case 3: I store images in bigger chunks (ex. 1000x1000) and preload them all at the beginning of game and also read pixel by pixel when needed.

Which case is possible/best? I need performance, it comes first before code readability etc. My main concerns are the memory leak of XHR, and also which is faster: XHR loading and parsing JSON or loading and reading image pixel by pixel.

Thank you!


texts:
I am developing a 2D game, and using an option of the game, it will open a minigame. I planned to set it as a separate scene, but I don't know how could I load a Scene into another scene as a window.

To give you an example, it would be something like Mass Effect and Piracy puzzle (as you can see, the game opens another game in a separate window).

Example:

As you can see, the Minigame is in some kind of Window, and in the background is the main game.

Anybody knows how could I do that?

Thank you


texts: How to display three dimensional Objects in a 2D Game using OpenGL and orthographic Projection?

texts:
I am creating a 2D (2.5D) game using OpenGL and orthographic projection.

It is simple to have relatively flat objects, e.g. characters.
I simply use a quad with a texture of the character and move that about.

However, what is the best way to draw big objects that have depth, e.g. a big house?
Do I use one quad with a three dimensional looking represantation of the house on it, or do I use multiple quads (e.g. front, side, top)?

I prefer using one quad with a three dimensional looking texture on it. What are the drawbacks to this approach?


texts: What is the purpose of the beginning of HL1, from the perspective of game design?

texts: At the beginning of Half Life 1, player is locked into watching an introductory film that can't be skipped and doesn't teach anything about game mechanics. Player can only move their camera around. A similar technique was applied in Deus Ex 4. Given that it's irritating not to be able to skip it on subsequent gameplays, what is the purpose of those?


texts:
Hello I wan't to do model collsion in JBullet but that don't won't to work. Models look like have some invisble holes.

Here the code for creating collsion shape:

int triangles_count = (int) ((mesh.getVertices().length) / 3);
    int vertices_count = (int) (mesh.getVertices().length);

    ByteBuffer index = BufferUtils.createByteBuffer(vertices_count * 3 * 4).order(ByteOrder.nativeOrder());
    index.clear();
    for(int i=0; i < triangles_count; i++) {
        index.putInt(i);
    }

    ByteBuffer shape = BufferUtils.createByteBuffer(triangles_count * 3 * 4).order(ByteOrder.nativeOrder());
    shape.clear();
    for(int i=0; i < triangles_count; i++) {
        shape.putFloat(mesh.getVertices()[i].getPos().x());
        shape.putFloat(mesh.getVertices()[i].getPos().y());
        shape.putFloat(mesh.getVertices()[i].getPos().z());
    }

    shape.rewind();
    index.rewind();

    TriangleIndexVertexArray triangle_mesh = new TriangleIndexVertexArray(triangles_count, index, 3 * 4, triangles_count, shape, 3 * 4);
    BvhTriangleMeshShape out_shape = new BvhTriangleMeshShape(triangle_mesh, true);

    return out_shape;

When I change first for loop to this:

for(int i = 0; i < vertices_count; i++)

I have exception  java.lang.IndexOutOfBoundsException produced in this line of code:

BvhTriangleMeshShape shape = new BvhTriangleMeshShape(trimesh, true);


texts:
I want to delete Google Play Services in the Google Play Developer Console, but I can't. Here is what I did:

I published my game to Google Play without Google Play Services.

I decided that I want Google Play Services in my game, so I integrated them in the source code.
After that I created Google Play Services for my game in the Google Play Developer Console.

But the created Google Play Services didn't work. The were Unpublished at that moment. I read that in order for them to work, you have to publish them. I published them, they still don't work and I can't delete them. In order to delete them I must unlink the game, but since the game is published I can't unlink it. I asked Google Support what to do, they told me to delete the project in the Google API Console and after 7 days the game will be unlinked. There has been 15 days since then and nothing happens. Please tell me what can I do.


texts:
I'm making a TBS using a hex grid. Player can move units from one hex to another using bridges, which will be randomly generated. I'm using cubic and axial coordinate system for my grid, it's well described in Red Blob Games' Hexagonal Grids.

I don't know how to make a hex understand connection with another one and then calculate best path for units.

I'm not sure how to approach the issue - should I make six slots for bridges in my hex class and then calculate path or should I make movement system somehow and then use absence of bridge as a "blocker"?


texts: Line strokes also adding borders to other shapes?

texts: When you run the project, you can see that the first circles have a black border around them. When I remove the Game.drawLines(), the circles don't have the border around them anymore. Any help is appreciated!


texts: How do I change the direction of a circle when it hits a corner?

texts:
I have a 2D Ball that might go against a wall.
If the Ball goes against the wall perpendicularly, it will just invert its direction (assuming no air resistance and no bounces that should make its speed change).
My problem is: how the velocity of the Ball changes when it goes against a corner?
This is the case I didn't figure out how to handle:


texts:
Okay so i have two files one named Player.lua and one named Main.lua

Main:

function love.load()
end

function love.update()
end

function love.draw()
end

Player:

function player.load()
end

function player.update()
end

function player.draw()
    love.graphics.setColor(255, 0, 0)
    love.graphics.rectangle("fill", 50, 50, 50, 50)
end

Output is just a black screen!


texts: Unity using raw mocap data without actually moving the character

texts:
I play around with animations and unitys raw motion capture data asset pack. My problem is as followed:

I have an idle, walkforward and a runforward animation and play them based on the keyboard input. But i realized when i move my character backwards (using a movement script) but still playing the walkforward animation the character basically moves backward and forward at the same time.

So how can i play the animation but without actually effecting the position of the character?

Thank you


texts: How to implement a pixelated screen transition shader?

texts:
I am interested in creating a screen transition seen in a lot of retro games. The transition is just a kind of pixelated distortion that increases or decreases in granularity over time.

The effect is present in Super Mario World, and can be seen recreated in this clip.

Also, here is an image depicting the transition (ignore the gradual lightening of the screen):

I want to achieve this by animating the uniforms of a GLSL shader.

Unfortunately, I don't know how to design the shader.

I know how to sample gradient textures to create various screen wipes, as well as how to sample noise textures to create simple distortion effects. But I can't figure out exactly how to create this effect.

Any advice on how to set up a shader to achieve this effect?


texts:
I've been having a lot of trouble trying to get a OpenGL blend function to work as I'd expect it to with like what I'd expect (or from any sensible image editing program). As an example, I'll use these two images to blend (bit difficult to see on white backgrounds so the colors are labeled):

Images to be blended

This is what I expect to happen (and what happens in paint.net):

Expected Result

Obviously opengl's default blend function makes it look like this (very wrong):

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

After a ton of testing, this is the closest I could get to creating a "good" blend function:

glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA)

Looking back at the original expected result though, you'll notice that some of the colors are a bit dimmer than they should be (the middle left part). Specifically, they are premultiplied to half their color value (because of the .5 alpha), and I can't seem to make a function that does not do this (without causing odd blending issues with the barely visible red transparent part).

Does anyone know a solution to this issue? One that I had was to use premultiplied alpha in the sources (while I dont want to do this because it requires extra work to convert every color I use in my game to premultiplied or just write some stuff in each shader) and do it like that:

glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA) (No premultiplication)

Obviously thats wrong too, but this is actually the only correct result I've gotten so far:

glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA) (Premultiplied inputs)

Only problem is, how would I get rid of the premultiplication to display it on the screen? It would probably require an additional render cycle for each thing I blend and that seems way too complex for this issue, so I'm still looking for an answer (its interesting that I cant find anything on this, because OpenGL is so widely used that I'd image someone else ran into this problem).

Sources:

Online blend function testing - http://www.andersriggelsen.dk/glblendfunc.php
Bottom Layer Image - http://i.stack.imgur.com/XjLNW.png
Top Layer Image - http://i.stack.imgur.com/9CN6w.png


texts:
I have started to make a fantasy 3d fps swordplay game and I want to add animations. I don't want to animate everything by hand because it would take a lot of time, so I decided to use procedural animation.

I would certainly use IK (starting with simple reaching an object with hand ...).
I also assume procedural generation of animations will make less animations to do by hand (I can blend animations ...).
I want also to have a planner for animation which would simplify complex animations; those which can be split to a sequence - run and then jump, jump and then roll - or which are separable - legs running and torso swinging with sword -.

I want for example a character to chop a head of a big troll. If troll crouches character would just chop his head off, if it is standing he would climb on a troll. I know that I would have to describe the state ("troll is low", "troll is high", "chop troll head" ..) which would imply what regions animation will be in (if there is a gap between them character would jump), which would imply what places character can have some of legs and hands or would choose an predefined animation.

My main goal is simplicity of coding, but I want my game to be looking cool also. Is it worthy to use procedural animation or does it make more troubles that it solves? (there can be lot of twiddling ...)

I am using Blender Game Engine (therefore Python for scripting, and Bullet Physics).


texts: How can I export a .FBX file from Unity3D at runtime?

texts:
I want to export an object as a .fbx at runtime in Unity3D.

I've made a C# script to export a mesh filter or skinned mesh renderer to a .obj file at runtime, but I want the animation and skin support that only .fbx supports.

After some research, using the Autodesk FBX SDK or some other external .dll seems like my best option. How do I call Autodesk's FBX SDK at runtime? Is there another external .dlls I could use for this?

Another option could possibly be to write the mesh information as a text file, then convert to .fbx to export.


texts: Flickering / tearing with glfwSwapBuffers

texts:
I recently separated my logic and rendering threads to fix this problem:

GLFW window freezes on title bar hold/drag

This means the logic and rendering are no longer running in lock-step as they were before, so it is possible that the logic has not finished executing by the time we are ready to render. To handle this case, the rendering thread will keep sleeping for 1ms until the logic has finished executing.

Pseudo-code

Logic thread

while (!exiting) {
    timeBefore = now();
    updateGame();
    renderingDue = true;
    timeElapsed = now() - timeBefore;
    sleep(MS_PER_FRAME - timeElapsed);
}

Rendering thread

while (!exiting) {
    if (renderingDue) {
        render();
        renderingDue = false;
        GLFW.glfwSwapBuffers(window);
    } else {
        // Not yet ready to render, but try again in a short while
        sleep(1);
    }
}

This seems to work fine for me, at least with vsync disabled. When I tested with vsync enabled I encountered stuttering, which I suppose is because if we miss a rendering frame, we have to wait until the next monitor refresh interval before we can catch up.

However, on some other systems, in particular low-end laptops, there is a lot of flickering / tearing during gameplay. I don't understand what would cause this, since we are always calling glfwSwapBuffers() after rendering, not during.

Is there something fundamentally wrong with my approach?

I know ideally the rendering thread should take a delta value so that it can render the state "between" logic threads (yes, I have read Fix Your Timestep!), but I am nonetheless curious about what is happening here.


texts: Handling Different Aspect Ratios for a Multiplayer Game

texts:
I'm currently designing a competitive 2D, side-scrolling multiplayer game and I want support full screen play at any aspect ratio (e.g., 4:3, 5:4, 16:10, 16:9). Doing that is not so much a problem, my concern is that the viewable area of the game for a player with a 4:3 monitor will differ from that of a player with a 16:9 monitor quite a bit. In a competitive multiplayer game where being able to see more of the game world gives a player a significant advantage over players who cannot this is a serious problem.

So far I've come up with two possible solutions for this:

Just support different aspect ratios and don't worry about it.
Pick a specific aspect ratio (say 16:9) and do a best fit on all other aspects (i.e., letterbox or pillarbox)

Option 1 doesn't suit me because it's a lazy cop out. Option 2 is much better but then a portion of the screen will be unused for some players. Certainly not the end of the world but not incredibly desirable either. This could be mitigated by rearranging the UI based on the aspect ratio and filling the letter/pillarbox with UI elements instead of simple black bars making better use of available screen real estate.

How is this sort of thing handled in games like Quake, CoD, StarCraft and Battlefield?


texts: What does an engine like Frostbite look like in the early early stages?

texts:
I have been having great fun playing Battlefield, and am blown away by how it all looks and sounds. I was just wondering what a game engine starts life as. At what point of writing code does it finally do something, and what did it do before it started rendering all the textures, light and particles, perfectly?

Are there any good articles, online, or examples anyone's seen?


texts: Map terrain generation to texture instead of color

texts:
I have some terrain being generated using the following algorithm

double rand1 = rand.NextDouble() + 1;
double rand2 = rand.NextDouble() + 2;
double rand3 = rand.NextDouble() + 3;

float offset = screenHeight / 2;
//does what it says.
float peakheight = 30;
//really just adjusts the amount of "waves" in the generation
float flatness = 70;

for (int x = 0; x < screenWidth; x++)
{
    double height = peakheight / rand1 * Math.Cos((float)x / flatness * rand1 + rand1);
    height += peakheight / rand2 * Math.Cos((float)x / flatness * rand2 + rand2);
    height += peakheight / rand3 * Math.Cos((float)x / flatness * rand3 + rand3);
    height += offset;
    terrainContour[x] = (int)height;

Now to display the "terrain" on the screen I use this block of code to color it

Color[] foregroundColors = new Color[screenWidth * screenHeight];

for (int x = 0; x < screenWidth; x++)
{
    for (int y = 0; y < screenHeight; y++)
    {
        if (y > terrainContour[x])
            foregroundColors[x + y * screenWidth] = Color.Black;
        else
            foregroundColors[x + y * screenWidth] = Color.Transparent;
    }
}

foregroundTexture = new Texture2D(device, screenWidth, screenHeight, false, SurfaceFormat.Color);
foregroundTexture.SetData(foregroundColors);

Is it possible to set a texture to draw the terrain instead of the Color.Black property?
If I had a square texture and I used it to draw the terrain then it would look somewhat blocky and I would then be able to further implement collisions easier.


texts: How do I enlarge a SpriteFont without it becoming blurry?

texts: How do I make spritefonts not blurry when I make them bigger? I have searched Google and haven't found any useful answer.


texts: Tree of objects in 2D space - children relative to parent

texts:
Question

How do we track the position of child objects, relative to a parent?

Context

I have a simple structure that keeps track of a point in space, along with zero or more children:

function Point(x, y){
  this.x = x;
  this.y = y;
  this.children = [];
}

Given the relationship:

const a = new Point(100, 100);
const b = new Point(10, 10);
a.children.push(b);

When these are rendered, I want point b to render at world location [110, 110].

After moving a and only a:

a.x += 10;

Both points move and the distance between the two must remain the same.

After moving b and only b:

b.x += 10;

Only b moves and the distance between both points must now be different.

In other words, a child's (x, y) is the same as its offset from its parent.


texts: How does my GPU know what game is running?

texts: I am trying to understand how game ready drivers work. How does my gpu know what application i am running and which application to use a specific driver optimization. For example the new nvidia driver makes some improvements to devil may cry 5 . how does my gpu know that I am running DMC 5. Is there a code in that application the driver recognizes? or does it not care what application i am using and treats every application the same.


texts: Getting different x and y coordinates for touched location on a zoomed view

texts:
I'm using Cocos2d for developing a game. I need to be able to pan and zoom when necessary, so for this reason I've added CCLayerPanZoom extension to my project. Recently I've noticed a problem with zoomed layers. The thing is if I touch on a zoom-panable layer before doing zooming or panning I get correct x,y coordinates. But if I zoom the layer, the touched location coordinates are different than the earlier ones. Here's how I get the touch location:

-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *touch=[touches anyObject];
    CGPoint touchedLocation=[touch locationInView:touch.view];
    touchedLocation=[[CCDirector sharedDirector] convertToGL:startPoint];
}

You might ask how I determine whether the two points are different before and after zooming. I have a sprite located on a predetermined point in the view. When I touch the sprite I log the position of both the sprite and the touchedLocation. Before zooming these points are almost the same, only a few units of difference in x and y. But after zooming they're totally different points and I guess this difference is directly proportional with the zoom scale. I don't want to ask how to have the touched location the same before and after zooming, I rather want to ask what I should do in this case.


texts: Irrlicht engine game wont compile on linux. Undefined refrences(opengl and xfree)

texts:
I'm trying to port over my game I'm developing to Linux. But when i compile i get a lot of undefined references to mostly functions that look like they belong to OpenGL. Most are titled gl...  But one of them is called XFree.

I compiled it with this command:

g++ main.cpp -L../../../LIB/irrlicht-1.8.3/lib/Linux/ -lIrrlicht -I../../../LIB/irrlicht-1.8.3/include/

one of the errors:

/home/owner/LIB/irrlicht-1.8.3/source/Irrlicht/COpenGLDriver.cpp:3746: undefined reference to `glVertex3f


texts: How can I change some tree's radius and length in C# script in Unity3D?

texts:
So, I have this little tree stem. It only has its initial node.
All I would like to do is make it grow in length and radius in Update(). How can I do that?


texts:
I'm trying to get the basics of 3d with opengl 2.0(I know, I know, it's deprecated etc, etc. It's just for the sake of prototyping). I'm trying to get a cube on the screen which you can move around. I have rendered the cube, and I can navigate the "world"(black background with the colored cube). However, when I try to rotate the camera, and then move, the camera moves independently of the camera's direction. For example, I rotate 90 degrees to the left, then I press "w" and it looks like I'm strafing to the right.
I use sdl2 to get keyboard input, and when the user presses a key, I increase deltaX, deltaY, deltaZ, rotationX and rotationY accordingly(that's right, no rotation around the z axis).

And the rendering occurs as follows:

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    // Apply transformations
    glRotatef(rx, 1, 0, 0);
    glRotatef(ry, 0, 1, 0);
    glTranslatef(dx, dy, dz);

    // Draw each face with a different color
    glColor3f(1.0, 1.0, 0.0);
    glDrawArrays(GL_QUADS, 0, 4);
    glColor3f(1.0, 0.3, 0.4);
    glDrawArrays(GL_QUADS, 4, 4);
    glColor3f(0.0, 1.0, 0.5);
    glDrawArrays(GL_QUADS, 8, 4);
    glColor3f(1.0, 1.0, 1.0);
    glDrawArrays(GL_QUADS, 12, 4);
    glColor3f(0.3, 0.8, 0.0);
    glDrawArrays(GL_QUADS, 16, 4);
    glColor3f(0.0, 0.0, 1.0);
    glDrawArrays(GL_QUADS, 20, 4);

How can I do this?

EDIT: forgot to add, I would like to do this without glu. I don't like linking against a lot of libraries, especially when it's only to get a few functions.

EDIT2: I got forward movement to work using trigonometry like this:

case SDLK_w:
    posZ += (float)cos(rotY * M_PI / 180); // I use rotY * PI/180 to convert rotY to radians
    posX -= (float)sin(rotY * M_PI / 180);
    break;
case SDLK_s:
    posZ -= (float)cos(rotY * M_PI / 180);
    posX += (float)sin(rotY * M_PI / 180);

And now the only thing to add is strafing, which I thought would be something like this

case SDLK_a:
    posX += (float)sin(rotY * M_PI / 180) + (float)cos(rotY * M_PI / 180);
    posZ += (float)sin(rotY * M_PI / 180);
    break;
case SDLK_d:
    posX -= (float)sin(rotY * M_PI / 180) + (float)cos(rotY * M_PI / 180);
    posZ -= (float)sin(rotY * M_PI /180);
    break;

But it doesn't work, if you strafe when looking down the x axis, you move backwards in the z axis(wtf?)

Thanks!

EDIT3: Never mind, solved it by doing

case SDLK_a:
    posX += (float)cos(rotY * M_PI / 180);
    posZ += (float)sin(rotY * M_PI / 180);
    break;
case SDLK_d:
    posX -= (float)cos(rotY * M_PI / 180);
    posZ -= (float)sin(rotY * M_PI /180);
    break;

I don't know if this is the best way to do it, but it works. Thanks everyone for helping me!


texts: How to prevent fleeing monster from backing himself into a dead end?

texts:
I've been building a rogue-like for more than a year now, and so far I've only ever implemented very simple monster behaviour - such as moving toward the player when he's in the line of sight, and attacking.

I would like to implement fleeing behaviour for certain monsters that realize they're outmatched.

I have these priority based behaviour types for monsters:

Flee
Attack/Defend
Investigate (event)
Socialize / Explore / Patrol

The only code I have for fleeing is a flood fill routine which attempts to find tiles which "look" like they are doorways leading to corridors. The question is, how can I improve this to stop it from finding such tiles that deceptively look like doorways, but actually lead to dead ends?


texts: How to make a catapult work with physics and colliders?

texts:
This should be my final question regarding getting a catapult to throw something in unity. On my last question, someone suggested starting with something simpler (which I apologize for not doing earlier). It worked, so in my test project I put some shapes together to roughly approximate my catapult to see if it could throw something.

here's the code on arm rotation parent(which I made so that the arm rotated like a catapult arm)
if (Input.GetKey(KeyCode.Space))
        {
            _rigidbody.AddTorque(new Vector3(0,0,1));
        }

This version rotated and pushed the ball along with it,but it didn't throw it very much. Weird things started to happen when I increased the z magnitude of the torque vector(to 5). Here are my physics settings

Arm rotation parent

rigidbody with interpolate on, frozen every way except z rotation

ball guide

kinematic rigidbody with interpolate on
mesh collider with its shape

floor

default cube box collider
kinematic rigidbody with interpolate on

cube(this is the arm connecting the cup to the center)

default box collider for cubes
kinematic rigidbody with interpolate on

ball

sphere collider
gravity rigidbody with interpolate on

When I spin the arm, the ball almost completely passes through the floor, barely affected by it. On the next rotation, it does the same thing. here's a gif of what it does:

How do I get the cup of the catapult to interact more accurately and completely with the ball? I increased the physics fps to 100 to see what would happen, and that didn't fix it. Let me know if you need more info, thanks!


texts:
I have made a card game, and have two methods that sort the players hand.

sortHandBySuit();
sortHandByValue();

I would like one method to be called when the user slides their finger from left to right across the screen, and the other from right to left.

public class InputHandler implements InputProcessor{
  .............
  public boolean touchDragged(int screenX, int screenY, int pointer) {
    world.getHand().sortHandBySuit();
    return false;
  }
  .............
}

How can I use touchDragged to call my methods?


texts: In a 2D tile engine, how do I figure out which tiles are culled and which to draw?

texts:
I'm trying to make a simple 2d tile engine here, and I've got a problem with getting a proper cells from a tile grid map when I'm trying to cull off tiles which aren't needed to be drawn.

I've got a tile which is 16 by 16 pixels and
 a tilemap represented as a grid of 0, 1 etc

For example

{1,1,1,1}
{1,1,1,1}
{1,1,1,1}
{1,1,1,1}

Then I translate it to a Tile[,] matrix like this

public void SetMap(Int32[,] tileCodes, int sizeX, int sizeY, TileTextures tileTextures) {
        //A simple check that sizes are equal
        if (sizeX == mapBounds.width && sizeY == mapBounds.height) {
            for (Int32 i = 0; i < mapBounds.width; i++) {
                for (Int32 j = 0; j < mapBounds.height; j++) {
                    if ((TileType) tileCodes[j, i] != 0)
                        map[j, i] = new Tile(new Vector2(i, j), (TileType) tileCodes[j, i], tileTextures.GetTexture((TileType) tileCodes[j, i]));
                }
            }
        } else
            Console.WriteLine("Map.SetMap: Unable to set map of diffent size than defined one");
    }

So it's basically tile grid now (tile[x,y]), but I can't figure out, which tile I should draw. I've already got a vissible area as a rectangle (va):

public void Draw(SpriteBatch spriteBatch) {
        // How to get positions in tile[x,y]?
        int startX = va.area.Left/ 16;
        int endX = va.area.Right/16;
        int startY = va.area.Top/16;
        int endY = va.area.Bottom/16;

        for (Int32 i = startX; i < endX; i++) {
            for (Int32 j = startY; j < endY; j++) {
                Tile tile = map[i, j];
                tile.Draw(spriteBatch);
            }
        }
}

Any ideas?


texts:
I've been working on coding a new 3D engine in Java. For the moment at least I'm sticking to openGL...

Currently I'm reworking how meshes get transformed and then drawn. ATM each mesh created has its own VBO and IBO along with its own draw method so if I wanted to draw multiple meshes it would look like this:

mesh1 = MeshLoader.loadMesh("cube.obj");
mesh2 = MeshLoader.loadMesh("pyramid.obj");

mesh1.addToBuffers(); //adds vertex and index data to vbo and ibo
mesh2.addToBuffers();

mesh1.draw();
mesh2.draw();

The draw method defined in class Mesh enables vertex attribute arrays, binds the bufffers, and then draws elements based on the ibo.

Then I send my projection matrix (transformation and perspective) as a uniform to the vertex shader.

QUESTION:

Games are made of many many meshes and each has to be identified so that transformation can be applied. I want to be able to apply transformations (translate, rotate, scale) directly to a given mesh, independent of the other meshes. In other words I want to move mesh1 and only mesh1 5 units to the right (on its own axis) without it affecting mesh2.
How do I do all this without making a million draw calls to the gpu?

Any advice appreciated.


texts: How do I find the intersection point from the Expanding Polytope Algorithm?

texts:
I've successfully implemented a 2D version of the GJK and EPA algorithms which gives me correct collision information, including collision normal and penetration depth.

What it doesn't give me however is the intersection point of the collision. And after much searching I haven't found a decent explanation of how, given the result of the EPA, I'm supposed to calculate the intersection point.

Could somebody please explain the algorithm for finding the intersection point?


texts:
Imagine a fridge and a bunch of random foods. I want to take one food item, automatically put it somewhere in the fridge, and repeat. I can stop at any time.

Basically, the filled fridge should look like it has been gradually stocked over the course of a week or so (as opposed to deliberately organized at once) by a calm human being (as opposed to by someone who's just thrown things into it).

Formally, this procedure has to satisfy the following:

Similar items should stack or be next to each other given that there is sufficient space (ex. egg cartons cases go in one stack, 2L milk cartons go side by side)
Other items should not stack until there is no more space left at the bottom
Placed items should be as upright as possible (ex. plastic-wrapped leftovers shouldn't be sideways), unless limited space requires rotation
Items should be put somewhere in the center of the fridge when it is relatively empty (instead of being squished to one side)
The procedure should automatically stop when the fridge no longer has any room left

Ignoring any dividing racks that may be present in the fridge (say it's just one big container), how should this be done? What variables would I need to define with an Item, and/or what algorithms should I use to determine where to put the next item and how to find out which angle of rotation will give me the fit?


texts:
I have a model structured like this:

 1. Root model

     1.1.Child model 1

     1.2 Child model 2

     1.3 Child model 3

     1.4 .....

The model in question is the "sponza" model used in many research articles, for example viewed here, in an otherwise unrelated video: https://www.youtube.com/watch?v=uhmH1PaY9Sw

I have implemented a view frustrum culling alghorithm that produces INSIDE, OUTSIDE or PARTIAL  results for each model. The problem is I'm not sure how to apply it when building my renderqueue.

Here's my current alghorithm:

If model AABB it OUTSIDE, skip it and all its children
If model is INSIDE || (PARTIAL && no child models), render it
If model is PARTIAL and has children, dont render it but repeat process for its children

Is this the correct approach? I don't notice any particular performance benefits, unless the view frustrum is completely outside the root model...

void Engine::CullModels(const std::vector<ModelPtr>& allModels, const Mat4& viewProjectionMatrix, const Mat4& parentTransform)
{
    // TODO: not very cache-friendly
    // this could be a CPU-hotspot for complex scenes
    FrustrumIntersection aabbIntersection(FRUSTRUM_INTERSECTION_INSIDE);
    for (const ModelPtr model : allModels)
    {
        if (!model)
            continue;

        Mat4 worldMatrix = parentTransform;
        if (model->mSceneNode)
            worldMatrix *= model->mSceneNode->GetNodeTransform();
        const Mat4 worldViewProjMatrix = viewProjectionMatrix * worldMatrix;

        aabbIntersection = IsAABBInFrustum(model->GetAABBCenter(), model->GetAABBExtent(), worldViewProjMatrix);
        if (aabbIntersection == FRUSTRUM_INTERSECTION_OUTSIDE)
            continue;

        if (aabbIntersection == FRUSTRUM_INTERSECTION_PARTIAL && model->mMesh != INVALID_MESH_ID)
        {
            const MaterialPtr material(model->mMaterial);
            if (material)
                mRenderQueue.emplace_back(Renderable(model->mMesh, worldViewProjMatrix, worldMatrix, model->mMaterialTilingFactor,
                                                    Vec4(material->mDiffuseColor, 1.0f), Vec4(material->mAmbientColor, 1.0f), Vec4(material->mSpecularColor, 1.0f), Vec4(material->mEmissiveColor, 1.0f),
                                                     material->mDiffuseTexture, material->mNormalTexture, material->mSpecularFactor));
            else
                mRenderQueue.emplace_back(Renderable(model->mMesh, worldViewProjMatrix, worldMatrix));
        }

        CullModels(model->mChildren, viewProjectionMatrix, worldMatrix);
    }
}


texts: How do I simplify this code with an Array and counting int up in Unity?

texts:
I want to simplify my code. I had the idea of making an Array of waypoints[] and and int i to count up each time I arrive a new point of waypoint but it should be the same way my code is but instead of waypoint1.position... waypoint3.position I thought it should be like waypoint[i].position and it counts up everytime I reach another waypoint this would simplify a lot and would make the code much shorter.
The code is for moving an Object from A to B from B to C and so on..

I commented some lines how it would look like but ignore the //MOVE //ROTATE comments

Code:

public float speed;
public float turnSpeed;

//Starting with these somehow
//public Transform[] waypoints;
//private int i = 0;

public Transform player;
public Transform waypoint;
public Transform waypoint1;
public Transform waypoint2;
public Transform waypoint3;

public bool b0 = true;
public bool b1 = false;
public bool b2 = false;
public bool b3 = false;
public bool b4 = false;

void FixedUpdate ()
{
        if(b0)
        {
            //MOVE
            player.position = Vector3.MoveTowards(player.position, waypoint.position, speed * Time.deltaTime);
            //ROTATE
            var rotation = Quaternion.LookRotation(waypoint.position - player.position);
            player.rotation = Quaternion.Slerp(player.rotation, rotation, turnSpeed * Time.deltaTime);

            float distance = Vector3.Distance(player.position, waypoint.position);
            //Debug.Log (Mathf.Round(distance));
            if(distance <= 1)
            {
                // i++;
                b1 = true;
                b0 = false;
            }
        }

        if(b1)
        {
            //MOVE
            player.position = Vector3.MoveTowards(player.position, waypoint1.position, speed * Time.deltaTime);
            //ROTATE
            var rotation1 = Quaternion.LookRotation(waypoint1.position - player.position);
            player.rotation = Quaternion.Slerp(player.rotation, rotation1, turnSpeed * Time.deltaTime);

            float distance1 = Vector3.Distance(player.position, waypoint1.position);
            //Debug.Log (Mathf.Round(distance1));
            if(distance1 <= 1)
            {
                b1 = false;
                b2 = true;
            }
        }

        if(b2)
        {
            //MOVE
            player.position = Vector3.MoveTowards(player.position, waypoint2.position, speed * Time.deltaTime);
            //ROTATE
            var rotation2 = Quaternion.LookRotation(waypoint2.position - player.position);
            player.rotation = Quaternion.Slerp(player.rotation, rotation2, turnSpeed * Time.deltaTime);

            float distance2 = Vector3.Distance(player.position, waypoint2.position);
            //Debug.Log (Mathf.Round(distance1));
            if(distance2 <= 1)
            {
                b2 = false;
                b3 = true;
            }
        }

        if(b3)
        {
            //MOVE
            player.position = Vector3.MoveTowards(player.position, waypoint3.position, speed * Time.deltaTime);
            //ROTATE
            var rotation3 = Quaternion.LookRotation(waypoint3.position - player.position);
            player.rotation = Quaternion.Slerp(player.rotation, rotation3, turnSpeed * Time.deltaTime);

            float distance3 = Vector3.Distance(player.position, waypoint3.position);
            //Debug.Log (Mathf.Round(distance1));
            if(distance3 <= 1)
            {
                b3 = false;
                b4 = true;
            }
        }
}


texts:
My goal is to convert clip() to GLSL, version 1.5. I'm currently doing a basic:

if (x < 0) discard;

But if x is not a scalar, obviously I can't use the "<" operator.

So I'm wanting to understand exactly how HLSL treats a vector (or a matrix) in the clip function so I can account for those as well. Any resources would be much appreciated, as I couldn't find any detailed info about the function. Thank you!


texts:
I have done mostly tile based games, but never really bothered with optimization. I always just rendered all the tiles that convered the viewport.
I am currently working on platformer for a mobile device, which has some performance issues, ecspecially when using multiple layers of tiles.

Most tiles are pretty static without animations. I wouldn't really have to render them each frame. The clear() -> draw() loop is really printed into my brain, I'm having a hard time thinking how the handle rendering without clearing the screen each frame.

I'm currently doing this:
 - start game, render screen once
 - Once a tile changes, save this in a "tile_changed" array
 - Each frame, re-render all the changed tiles and clear the array

This works pretty fine, and there is a notable boos in performance. However, there are a view issues
 - The PlayN framework offers no way to "erase" drawn items. Whenever I want to erase a single tile I have to completely clear the screen and redraw every tile. (PlayN SurfaceLayer). I'm using a scroll background, so can't just fill an empty tile with the background color.
I can imagine low level libraries like opengl having this same issue, do they use some sort of workaround for this?

I'm not sure how to recognize when new tiles come into the screen whenever the camera moves. I would normally just render the tiles in view each frame, so this never posed a problem.
I have no idea if having such a big drawn rendertarget in memory is a good idea. The player could have walked across a huge map and have thousands of tiles drawn. Should I worry about this?

Any other optimiztions that I'm missing are appreciated.

The awnsers note that most engines draw all tiles every frame. But I know that on some less powerfull platforms this is not the case. I believe flashpunk is using some sort of buffer that only draws new tiles when you make changes in the grid.
Unfortunately this is not possible for me because I have no way of clearing a single tile without clearing the entire buffer.

I'm looking into optimazations like this, which enable me to have a very large amount of tiles on the screen.


texts: Should I still display splash screens for middleware that has been discontinued?

texts:
Usually, you would include splash logos at the beginning of a game to credit various middleware that you've used. Say the company has dissolved or for open source the supporting group has simply moved on and declared the project over. In the hypothetical situation where a middleware project has been discontinued and you still have the legal right to use it, wouldn't you still include the logo for that project at the beginning?

Only concerned with the opening splashes, since I'm pretty sure it would be polite to credit the individuals who worked on that piece in the text credits or at the end.


texts: How can I create scenes programmatically from a deployed build in Unity?

texts:
This is somewhat of an extension to this question.

I have a client who would like to create an entire game only using XML files. This is how the process should go like:

Build and run a "GameCreator" project.
Read an XML file that has the attributes of all the scenes.
Create new scenes, fill it with new GameObjects, and load some prefabs.
Deploy this new project as a standalone build.

All of the above should not use the Unity Editor. Is that possible?

I used Unity to create a framework, and now the client wants to use this framework to generate more games without using the Unity Editor, only through XML files.

I know that one can read XML files with Unity, but how can one create a scene, fill it with GameObjects, and load prefabs all using a standalone build, not the editor? Is there any other way to do what I've described?


texts: Generate a HexMap where each tile has a different tile on each edge

texts:
I’m trying to generate a 7*13 hexmap, with 9 different types of tiles, numbered 0 through 8. I need the map to be randomly generated on each run and it has to be so that each tile has a different numbered tile on each edge.

I’m having trouble with this algorithm. I can generate my map just fine, but there will always be many tiles where they’ll have the same number on multiple sides.

Any tips would be appreciated. Currently, I’m think I’ll have to iterate through the 2d grid, picking my first tile, let’s say 1. And then make sure there is no other 1 spawn in a two block distance. Any better ideas I can use?

Thanks


texts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Threading;

//Top of the script
#pragma warning disable 0649

public class Player : MonoBehaviour {

    // Initialize variables.
    private Rigidbody rb;
    private bool isMovingRight = false;
    private bool hasPlayerStarted = false;
    public float speed;
    public float maxspeed;

    [HideInInspector]
    private bool canMove = true;

    [SerializeField]
    GameObject particle;

    [SerializeField]
    GameObject gems;

    [SerializeField]
    private Text scoreText;
    private int score = 0;

    public Text ScoreText { get => ScoreText1; set => ScoreText1 = value; }
    public bool CanMove { get => CanMove1; set => CanMove1 = value; }
    public bool CanMove1 { get => canMove; set => canMove = value; }
    public Text ScoreText1 { get => scoreText; set => scoreText = value; }

    // Use this for initialization
    void Start () {
        rb = this.GetComponent<Rigidbody> ();
    }

    // Update is called once per frame
    void Update () {
        if (Input.GetMouseButtonDown (0) && CanMove1 == true) {

            // If the game hasen't started yet.
            if (hasPlayerStarted == false) {
                hasPlayerStarted = true;
                StartCoroutine (ShowGems (2.5f));
            }

            ChangeBoolean ();
            ChangeDirection ();
        }

        if (Physics.Raycast (this.transform.position, Vector3.down * 2) == false) {
            FallDown ();
        }

        // increase speed
        if (speed < maxspeed)
            speed += 0.1f * Time.deltaTime;

    }

    // Hide the gems for the first 2.5 seconds (avoiding bugs).
    IEnumerator ShowGems (float count) {
        yield return new WaitForSeconds (count);

        // Checks if player hasn't fallen off before showing grms.
        if (CanMove1 == true) {
            gems.SetActive (true);
        }
    }

    // Control player direction.
    private void ChangeBoolean() {
        isMovingRight = !isMovingRight;
    }
    private void ChangeDirection() {
        if (isMovingRight == true) {
            rb.velocity = new Vector3 (speed, 0f, 0f);
        }
        else {
            rb.velocity = new Vector3 (0f,0f,speed);
        }
    }

    // When the player falls off the platform.
    private void FallDown() {
        CanMove1 = false;
        rb.velocity = new Vector3 (0f,-4f,0f);

        // Return to main menu.
        StartCoroutine (ReturnToMainMenu (1.8f));
    }

    // Return to main menu.
    IEnumerator ReturnToMainMenu (float count) {
        yield return new WaitForSeconds (count);
        SceneManager.LoadScene(0);
    }

    // When the player hits a gem.
    void OnTriggerEnter(Collider other) {
        if (other.gameObject.tag == "Gem") {

            // Remove the gem.
            Destroy (other.gameObject);

            // Create the particle effect.
            GameObject _particle = Instantiate (particle) as GameObject;
            _particle.transform.position = this.transform.position;
            Destroy (_particle, 1f);

            // Update the score.
            score++;
            ScoreText1.text = "Score: " + score.ToString();
        }
    }
}


texts: Turning around an enemy when hitting a wall or after x time

texts: I have an enemy that is supposed to go in one direction and after hitting the wall or if a certain amount of time passes, it should turn around and go back. After hitting another wall, it should turn around again and keep doing this in a loop.


texts: How should my game characters store their abilities/spells?

texts:
I'm new to game development and a bit confused about how to effectively store an object's access to certain spells/abilities.

The player and mob objects are all generated from the same class. However, each object may have access to different abilities and spells. How do I keep track of a specific object's access to these?

Example: My player object might have access to Fireball and Haste, while a goblin might have access to Confusion.

I followed the RogueBasin Python Libtcod tutorial, and I understand how to attach a spell function to scroll use. I'm just not sure how to emulate a character memorizing a spell and using it as an ability.


texts: How to implement map scrolling inertia formulae

texts:
I'm looking for a mathematical formulae to calculate map scrolling inertia. Basically I have an HTML5 Canvas displaying part of a map and I capture the mousedown / mousemove / mouseup to calculate my new offset.

And when I scroll the map I want the map to continue scrolling for a few moments after the user stopped dragging the cursor.

I do have a sample implementation but I'm not really satisfied with it. I'd be looking for a nice clean math formulae to achieve this. I'd like my map to behave for example like in Civ-5 when you scroll the map around.

Here is part of my implementation: (working jsfiddle: https://jsfiddle.net/CowWarrior/dkxnj5d8/1/)

//mouseup
stopMapDrag: function (e) {
    var movementX = (e.pageX - this.startX);
    var movementY = (e.pageY - this.startY);
    this.mapOffsetX = parseInt(this.mapOffsetX) + movementX;
    this.mapOffsetY = parseInt(this.mapOffsetY) + movementY;
    this.isDragging = false;
    this.displayMap();

    //calculate last vector
    ui.vectorX = parseInt(e.pageX - ui.absStartX);
    ui.vectorY = parseInt(e.pageY - ui.absStartY);

    //show inertia
    setTimeout(function(){ ui.dragInertia(2); }, 30);
    console.log("(vectorX:" + ui.vectorX + ", vectorY:" + ui.vectorY + ")");

    $('#canViewport').css('cursor', 'default');
},

//need to find a good formulae for inertia
dragInertia: function (factor) {
    var movementX = parseInt(ui.vectorX / factor);
    var movementY = parseInt(ui.vectorY / factor);
    ui.mapOffsetX = parseInt(ui.mapOffsetX + movementX);
    ui.mapOffsetY = parseInt(ui.mapOffsetY + movementY);
    ui.displayMap();

    if (factor < 8)
        setTimeout(function(){ ui.dragInertia(factor * 1.2); }, 30);
},


texts: 2D Terra(ria)in generation - Accidental noise

texts:
I'm currently trying to implement terrain generation as described on the following page:
http://accidentalnoise.sourceforge.net/minecraftworlds.html.

But I have issues understanding how to interpret the noise function values.

1) What does the gradient function in the ANL library exactly do? I see its purpose is to create the gradient, but I don't understand what the output/input for it exactly is. You input the line segments (0,0,0,1) but what does it return?

2) How should / can perlin noise values be interpreted? In my project I have ported the 2d noise function defined by stefan gustavson to python but I don't know what to do with the values itself? People keep posting images of "perlin" noise, but I assume that are the values mapped to a RGB code?

3) For the Fractional brownian motion, is this algorithm the result of combining several noise functions with each other? (I.e the output of a perlin noise function gets combined with another perlin noise function but with different parameters?

4) In essence, I'd love (if possible!) an explanation on how the image below gets generated from the fbm fractal. (In the hopes it makes the click that I'm missing*)


texts: Masking an area inside/outside a line strip

texts:
I have some point lights in my game which are just sprites implemented with help of HLSL. Currently I'm trying to implement dynamic shadows and I managed to make the program calculate the area in which the light should be drawn (area that is not behind walls etc).

Here is what it looks like when I draw a line strip between the calculated points:

So I was wondering how I would draw the light sprite only inside that line strip? For example if a pixel is inside that area, then draw it, etc. Can it be done with HLSL (I'm not that good at HLSL), or perhaps I should just do it in XNA?


texts: How do I split a button graphic into a 9 patch?

texts:
I understand what a nine patch is but I don't understand how to create one with code. I've made an image with a 1-pixel black border, but how do I turn that into a nine patch?

How do I make a nine patch that is not a cube image?

This is what is happening when I run:

patch = new NinePatch(new Texture(Gdx.files.internal("nineEmpty.9.png")), 4, 4, 13, 28);

I want it cut like this:


texts: Entity Component Architecture and Scripting without using threads

texts:
I am working on a small game engine for practicing purpose and also for putting
some of my ideas into action. What I have so far is a couple of systems for
rendering, sound etc. The next step is to put all these things together.
I already looked into entity component systems, in particular the following
article:
http://www.gamedev.net/page/resources/_/technical/game-programming/implementing-component-entity-systems-r3382

I think that this approach would suit my needs to a certain level, but I also
would like to implement the game logic itself inside scripts. I came up with a
slightly different approach:

The rendering, sound, physics, input and simulation systems perform actions
on the data, which is basically a level object and a list of entities
(for technical reasons I have to distinguish between entities and level
geometry). The particular systems only perform actions on those entities which
match their criteria (e.g. the physics system only handles entities with a
bounding volume). In my approach the systems do not directly implement behavior.
Instead they are either creating output (rendering, sound) or input
(physics, input). The simulation system manages the scripts which may be
assigned to entities. The script of an entity consists of two parts, first the
initialization code which is executed when the entity is added to the scene,
and second the code which is executed once per frame (or less, depending on
whether the code contains a wait-statement). Additionally every entity may
implement event handlers which are called whenever the input or physics system
throws an event (e.g. a CollisionEvent, KeyDownEvent etc.). Entity scripts may
define parameters, which can be modified inside the level editor.

My question is, whether this architecture has some severe weaknesses. Since I
want to avoid threading, my scripts will be scheduled by the simulation system,
which lead me to the restriction that an entity script is called once per frame
(which means that loops should be avoided, since basically everything already is
inside a big loop). Is this reasonable or is there any better way?


texts: Rendering (rasterization / ray tracing / others)

texts:
I'm completely new to this graphics and game development. I have read about Rendering (drawing a 3D graphic on a display 2D) and there are many ways of rendering, Rasterization, Ray tracing, radiosity, ray casting. And my doubt is if OpenGl implements one of these. I mean with OpenGL I can draw lines, circles and so on, so there should be a rendering algorithm on OpenGL, am I right? Which one is it?

What if I want to implement a different rendering algorithm, does this mean I'm no longer using OpenGL?


texts: How can I convert screen coordinates from a click to 2D scaled world coordinates?

texts:
I need a way to convert screen coordinates obtained from mouse clicks to world coordinates in my 2D game.

To create a zoom effect controlled by the user, before drawing a model I will scale all of it's points by a world scale value.

The screen origin (0,0) is at the top left corner while the world has it's center (0,0) at the center of the screen (width/2, height/2).

I need a function to convert the coords obtained by mouse clicks (screen coords) to the corresponding scaled-world coordinates, so that I can determine what world element is clicked by the user in this scaled world.

Any of my approaches worked as required and unfortunately none of the found solutions where aplicable to my case.

This is a very simple example JS Bin:

Use the mouse wheel to zoom in/out
Click on the screen to set a point

Thanks!


texts: If I understand correctly, the main point of protecting a single player flash game is to keep it sitelocked. How to do this right and are there any other reasons to do this?


texts: Pathfinding with Less Desirable Squares that are still passable

texts:
I have been looking at different path-finding algorithms for my game. I have almost settled upon D* Lite, but have a question. (perhaps I missed it in the documentation) -
Are there any algorithms, D* included, that allow for squares that are less desirable to pass over, but still possible, should there be no other way? I believe that I saw this in A* but I believe that I need it dynamic, as I will be having objects placed and removed from the map.

UPDATE: Is it possible to have levels of undesirable squares? Eg. Some still arent desirable, but are better than really undesirable ones


texts: Disabling depth write trashes the frame buffer on some GPUs

texts:
I sometimes disable depth buffer writing via glDepthMask(GL_FALSE) during the alpha rendering of a frame. That works perfectly fine on some GPUs (like the Motorola Droid's PowerVR), but on the HTC EVO with the Adreno GPU for example, I end up with the frame buffer being complete garbage (I see traces of the meshes I rendered somewhere, but the entire screen is mostly trashed).

If I force glDepthMask to be true the entire time, everything works fine.

I need glDepthMask to be off during parts of the alpha rendering. What can cause the framebuffer to get destroyed by turning the depth writing off?

I do clear the depth buffer initially, and the majority of the screen has pixels rendered with depth writing turned on first before I do additional drawing with it turned off.


texts:
I'm trying to separate an arbitrary number of randomly sized rectangles, while still keeping them snapped to the grid, and somewhat packed together nicely.  The goal is to start with something like this...

And end with something like this..

I've managed to get initial generation of random rectangles drawn in, that's the easy part;
I've also done some reading up on separation algorithms but I can never seem to get things just right.  They always spread out a bit (slowly, meaning lots of iterations) then just jitter around with massive gaps between them.

My (simple) separation function can be seen here, but it's very possible I'm doing something terribly wrong, or going about it all wrong!
Here's also the current code in action (click/anykey to run the separation function)

Is there perhaps a better way to achieve this desired result, or something?
Any help or suggestions would be great!


texts:
Let's assume having a (2d-) gameobject with 3 images: Head, body, feet.
By using RaycastHit2D I can find out if the gameobject was hit (for example by the mouse):

RaycastHit2D newSelectedObject = Physics2D.Raycast(cameraVector, Vector2.zero);

Now I'd like to find out if the head, body or feet was hit. How can I do that?


texts:
So I'm starting a project which aims to make a good AI for my game monsters.

So far I have set up the GA and got some results.

There's two genes, with one chromosome each.

The monster either 'attacks on sight' or 'flee on sight' depending on the gene it got. The fitness function is based upon time alive and the crossover is just eliminating the worst gene.

As expected the 'flee on sight' gene got better result.

What I'm here to ask is what are some good uses of GA in developing AI. Which genes/chromosome/fitnessfunction/crossover should I implement in order to have a challenging AI.

The game is a rogue-like, it's still pretty simple, not much added, so I can make the game around the GA instead of the other way around.

This may be a too broad question, but bear in mind that I don't have any experience in gamedev and AI as a whole.

EDIT:

To make this question a bit more narrow.

Since my fitness function is just 'survive' it's quite obvious that all the enemy generations would get better at fleeing. So,

What should I put in consideration to a good fitness function.

Damage to the player is also quite one-way solver, a monster-healer which doesn't have any attack power would drop his staff and punch the player.

The perfect fitness function for me should translate to 'make the player struggle', but I don't know what that would mean in the game terms, and specially code terms.


texts: I keep getting this error when I run my game so far

texts:
I have a tags script:

public class Tags {
    //Tags
    public static string PLAYER_TAG = "Player";
    public static string PLATFORM_TAG = "Platform";

    //Player Animation Tags
    public static string ANIMATION_IDLE = "idle";
    public static string WALK = "walk";
    public static string ANIMATION_RUN = "run";
    public static string ANIMATION_JUMP = "jump";
    public static string ANIMATION_JUMP_FALL = "jumpFall";
    public static string ANIMATION_LEDGE_FALL = "ledgeFall";
    public static string ANIMATION_JUMP_LAND = "jumpLand";

}
 Then I have my player animation script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerAnimation : MonoBehaviour {

    [SerializeField]
    private Animation anim;

    void Awake () {
        anim = GetComponent<Animation>();
    }

    public void DidJump () {
        anim.Play(Tags.ANIMATION_JUMP);
        anim.PlayQueued(Tags.ANIMATION_JUMP_FALL);
    }

    public void DidLand()
    {
        anim.Stop(Tags.ANIMATION_JUMP_FALL);
        anim.Stop(Tags.ANIMATION_JUMP_LAND);
        anim.Blend(Tags.ANIMATION_JUMP_LAND, 0);
        anim.CrossFade(Tags.ANIMATION_RUN);
    }

    public void PlayerRun()
    {
        anim.Play(Tags.ANIMATION_RUN);
    }
}

When I run the game, the player doesn't run like he's supposed to and I get this error:

NullReferenceException: Object reference not set to an instance of an object
PlayerMovement+<StartGame>c__Iterator0.MoveNext () (at Assets/Scripts/Player Scripts/PlayerMovement.cs:83)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

What am I doing wrong here?


texts:
I'm interested is there a game or at least example which shows how minecraft-like world turn to sphere?

Idea is that there is sphere which consists from cubes like in minecraft but they are on the surface of it. This have to make that player can go around the world.

Math? Code? Examples?


texts: My Earthbound-like Movement Script works in Unity Gameview, but runs differently in Gamebuild

texts:
First programming question I've ever made in my short journey. I'm trying to create a script which moves members of your party in a line behind you (think Chronotrigger or Earthbound). Here's a clip of what I want it to look like.
Problem:
Everything looks fine in the Game window when I play, but when I build the game to test, the characters begin to stack one on top of each other. I assume it has something to do with Update() frames dramatically increasing the frequency with which I enqueue the positions of the leading character (although I'm not experienced enough to say for sure, clarification on this would be helpful).

I've tried increasing the offset, but this solution is variable
depending on the players computer fps so that wont work.
I've tried running both scripts in FixedUpdate() but a lot of my other
systems run on Update() and so everything stutters.
I've tried enqueue'ing from an IEnumerator and waiting for .1 second
between each enqueue but that stutters as well..

What I'm doing:
The leading character has a script called PlayerTrail which creates a Queue of Vector3s. In Update the game object's transform.position is enqueued. The following character has a script called PlayerFollower which looks at the Queue and Vector3.MoveTowards the position, then dequeues that position and repeats. Each character only looks at the trail of the character in front of it.
Everything seemingly works fine and well in the Unity program, this issue only arises once I build the actual game.
Code Supplied Bellow:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerTrail : MonoBehaviour
{
    public Queue<Vector3> LeaderTrail;
    public Vector3 LastMovement;

    private void Start()
    {
        LeaderTrail = new Queue<Vector3>();
    }

    private void  Update()
    {
        if (this.transform.position != LastMovement)
        {
            LastMovement = transform.position;
            LeaderTrail.Enqueue(this.transform.position);
        }

    }
}

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

public class PlayerFollower : MonoBehaviour
{
    public GameObject leaderObject;
    public int Offset;
    public int moveSpeed;

    private PlayerTrail leaderTrail;
    private Animator animator;

    void Start()
    {
        animator = gameObject.GetComponent<Animator>();
        leaderTrail = leaderObject.GetComponent<PlayerTrail>();
    }

    void Update()
    {
        if (leaderTrail.LeaderTrail.Count < Offset)
        {
                animator.SetBool("isMoving", false);
                return;
        }
        else
        {
            Vector3 direction = (leaderTrail.LeaderTrail.Peek() - transform.position).normalized;
            this.transform.position = Vector3.MoveTowards(this.transform.position, leaderTrail.LeaderTrail.Peek(), moveSpeed * Time.deltaTime);

            animator.SetBool("isMoving", true);
            animator.SetFloat("moveX", direction.x);
            animator.SetFloat("moveY", direction.y);

            Debug.DrawRay(this.transform.position, direction);

            leaderTrail.LeaderTrail.Dequeue();
        }
    }
}


texts:
I'm having problems with texturing in LWJGL. The texture is not being stretched to a quad.
As you can see, the texture is not being sized to the quad, marked with pink border. The problem doesn't exist when using square quad and square texture. Scaling the texture to 960x320 px doesn't help
The texture size is 96px width and 32px height.(1 tile is 32x32, this object is 3 by 1)

The code:

//rendering the textured quad. This method also renders everything else
public static void renderTile(Texture tex, int x, int y, int sizex, int sizey) {
    tex.bind();

    glBegin(GL_QUADS);
    glColor4f(1, 1, 1, 1);
    glTexCoord2f(0, 0);
    glVertex2f(x, y);

    glTexCoord2f(1, 0);
    glVertex2f(x + sizex, y);

    glTexCoord2f(1, 1);
    glVertex2f(x + sizex, y + sizey);

    glTexCoord2f(0, 1);
    glVertex2f(x, y + sizey);
    glEnd();
}

//opengl initialization code, called before any rendering
public static void initOGL(){
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 800, 600, 0 , 1, -1);
    Log.info("Display W=" + Display.getWidth() + " H=" + Display.getHeight());
    glMatrixMode(GL_MODELVIEW);
    glEnable(GL_TEXTURE_2D);
    glEnable (GL_BLEND);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}


texts: Even tiles wide pathfinding on square based tilemaps?

texts:
By editing my A* algorithm as such that:

a tile is valid if all of its neighbours are valid (checking this N-1 deep)

I can find N wide paths, where N is odd, and my unit just follow the "center" tiles.

But what if my unit is even tiles wide?

Yes, I generate a 2 tiles wide path, and then traverse it with an offset, so my unit will walk on the overlapping edge between the 2 tiles. (maybe there is a better solution, suggestions are welcome)

But how do I find even wide paths?

(Or my whole approach is bad?)


texts: What size should i use for my game design?

texts: i am currently working on a android game by using libgdx and i am designing graphics with ps for it. I want my game looks the same quality for different screen sizes but i dont know in which size should i design my graphics. For example if i design the graphics 200x200 size and for a bigger screen i should make it bigger by resizing with code. But this will demage the graphic which is something i dont want. What i think is to make a much bigger graphic then shrink for ever screen sizes. is that right approach to do? Or there is a better way. And also if this approach what size should i use for portrait game. Like 800 width is good? Thanks for ur answers.


texts: How to call an event of level blueprint from NPC blueprint?

texts:
I have the following situation:

1 NPC that follows a path containing 3 parts. Target Point 1, Tower and Target Point 2.

It turns out that the first NPC that passes through the tower destroys it.

This destruction is not instantaneous. The tower has 100 hit points and while in contact with the NPC, it loses 10 life points every second.

With this, the next NPCs will only have to go to Target Point 1 and finally to Target Point 2.

I created a boolean variable for target control (varTowerDestroyed). So if it is false, the second target becomes the tower, otherwise it becomes the target point 2.

Blueprint showing the variable (varTowerDestroyed) being set to true, right after the tower's destruction:

Display of the control in the target definition:

It turns out that each NPC has its own variables, so there's no use in defining the value of the variable of just one of them. I would need a variable that would control all at the same time.

I thought of doing the verification based on a variable of the own tower, but as the tower will be destroyed, I imagine the variable will disappear. Impossible to verify:

At the Level Bueprint I created an event that will be called soon after the tower's destruction. This event will set the Boolean variable to true, setting all Boolean variables of the NPCs that are created and still generated to be true:

I would calmly call an event if the event was in the blueprint of the tower, but being on the blueprint level I was unsuccessful.

I thought about using the sleep function. I also thought about creating an actor who was sort of an actor manager (I still want to, but only when I start using HUD). I also thought about doing a check of the existence of tower actors, but this I do not know how to do.

Links from places I searched:

https://answers.unrealengine.com/questions/78622/how-can-i-call-an-event-in-my-level-blueprint-from.html

https://answers.unrealengine.com/questions/702964/how-can-i-call-a-event-from-actor-blueprint-in-lev.html

EDIT 1 (Attempt made based on 2 videos I've seen)

Link of videos:

https://www.youtube.com/watch?v=k-MAALv3P-Y

https://www.youtube.com/watch?v=IbiocEDwosw

I tried to use the Event Dispatcher.

I created an Event Dispatcher called Disp, in the NPC blueprint.

Soon after I set it on the Level Blueprint.

Level Blueprint:

Nothing happens, nor the impression.


texts:
I'm studying Perspective projection in a computer graphics course and i'm really confused about a detail. The study material says there are 3 cases:

Case 1: View plane parallel to the xy plane and Projection reference point (0,0,0)
Case 2: View plane coincident to the xy plane and Projection reference point (0,0,z)
Case 3: View plane parallel to the xy plane and Projection reference point (0,0,z)

In all these cases seems that all the objects to which we apply the perspective transform have a negative z. So my question is: Why all z are negative? Is it related to the previous step (so the camera transform?)?


texts: What is the base framework of making a minimalist mobile game?

texts: I've seen plenty of minimalist games throughout the years recently like Blue Box, Loop, Colorolo and Ultraflow. Games that use simple shapes. What's not talked about is the design process of making such games, specifically with a clean, vector-like visual presentation.


texts: How can I directly write pixel data in an SDL window using surfaces?

texts:
I'd like to directly modify pixels in my window in SDL 2. I expect this code to display an entirely red window, but instead I'm getting an all black window.
I'm able to get it working if I directly write to window_surface with the same technique, but not by blitting another surface. I'd like to get it working this way at least just for the purposes of understanding.
#include <SDL.h>

int main()
{
    SDL_Init(SDL_INIT_EVERYTHING);

    SDL_Window *window = SDL_CreateWindow("Window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1600, 900, 0);

    SDL_Surface *window_surface = SDL_GetWindowSurface(window);

    SDL_Surface *canvas = SDL_CreateRGBSurfaceWithFormat(
        0, 1600, 900, 32, SDL_PIXELFORMAT_RGBA8888
    );

    Uint32 *buffer = (Uint32*) canvas->pixels;
    int row    = 0;
    int column = 0;
    int offset;
    Uint32 color;
    SDL_UnlockSurface(canvas);
    while (row < 900)
    {
        column = 0;
        while (column < 1600)
        {
            offset = row * 1600 + column;
            color = SDL_MapRGBA(canvas->format, 255, 0, 0, 255);
            buffer[offset] = color;
            column++;
        }
        row++;
    }
    SDL_LockSurface(canvas);

    int quit = 0;
    SDL_Event event;
    while (!quit)
    {
        while (SDL_PollEvent(&event))
        {
            if (event.type == SDL_QUIT)
            {
                quit = 1;
            }
        }

        SDL_BlitSurface(canvas, 0, window_surface, 0);
        SDL_UpdateWindowSurface(window);

        SDL_Delay(10);
    }

    SDL_Quit();

    return 0;
}


texts:
I am working on some functions to use in my enemy state machines.

I want to write a function which determines whether the platform the enemy is standing on is connected to the platform the player is standing on.

Platforms have associated rectangles, and by connected, I mean there is a chain of rectangles from the first rectangle to the second rectangle.

Here's an illustration:

Here are my assumptions:

The rectangles contain their perimeters.
Two rectangles touching only on their perimeter are connected.
Two rectangles overlapping are connected.
The rectangles are guaranteed to be axis-aligned.
The rectangles will be at integer coordinates (the grid is 1x1).
Every rectangle has attributes like topleft, bottomright, etc.
Directly connected rectangles won't necessarily have any corners in common.

My question: What is an efficient way to determine the connectedness of rectangles in 2D space?

NOTE:
I asked a more specific version of this question in a Godot forum, but given that this is a general game dev question, I figured I'd ask this variation here.


texts:
I created a 2D tile-based jump and run game for Windows Phone and I want to draw a shadow under the character. How can I do that? The shadow must also be drawn on the tiles if the character jumps. The character and the tiles are rectangles.

How can I draw a shadow under my character?

The shadow should look similar to the shadows in this picture:

UPDATE:
I tried to solve the problem like described in Gamefreak0's answer, but it's not working.
I created a ShadowChecker object and I check in a foreach-loop if it collides with a platform. If it collides, the variable ShadowPosition gets changed.
But it's not working correctly. I made a picture, and in this picture you see that the shadow isn't on a platform. Why is the shadow not getting drawn on the pink platform?

The character(black rectangle) is above the pink platform, so the shadow should be on the pink platform.

I update the shadow's position with this code:

 protected override void Update(GameTime gameTime)
    {
        Rectangle CollisionRect = new Rectangle(-1000, -1000, 0, 0);
        ShadowChecker = CharacterRect;

        //FloorRect is the brown rectangle at the bottom. There is no other platform under the FloorRect.
        while ((CollisionRect.Height == 0) && (ShadowChecker.Bottom <= (FloorRect.Y + FloorRect.Height / 2)))
        {
            ShadowChecker.Y += 1;
            foreach (Rectangle r in PlatformRectangles)
            {
                if (ShadowChecker.Intersects(r))
                {
                    CollisionRect = r;
                    break;
                }
            }
        }
        if (CollisionRect.Height != 0)
        {
            // Draw the shadow on this position
            ShadowPosition = new Vector2(CharacterRect.X, CollisionRect.Y - CollisionRect.Height / 2);
        }

        base.Update(gameTime);
    }


texts: Why object spawn duplicate and double sides.?

texts:
I have a script, I am using this script to instantiate new path and also wall (as border) to generate new path and wall. Before some time all scripts work fine. but at this time my player enter in empty trigger collider 3 times to generate new path.

I am using capsule as player and also capsule collider. when my game start my player enter 2/3 times to empty collider(PathSpawnCollider) so it give me unwanted path and boundary walls.

Any one can help me what is problem here in my code.?

PathSpawnCollider.cs

using UnityEngine;
using System.Collections;

public class PathSpawnCollider : MonoBehaviour {

public float positionY = 0.81f;
public Transform[] PathSpawnPoints;
public GameObject Path;
public GameObject DangerousBorder;
public Transform[] BorderSpawnPoints;

void OnTriggerEnter(Collider hit)
{
    //player has hit the collider
    if (hit.gameObject.tag == "Player") {

            //find whether the next path will be straight, left or right
            int randomSpawnPoint = Random.Range (0, PathSpawnPoints.Length);
            //int randomBSP = Random.Range (0, BorderSpawnPoints.Length);
            for (int i = 0; i < PathSpawnPoints.Length; i++) {

                //instantiate the path, on the set rotation
            if (i == randomSpawnPoint) {
                Debug.LogError ("Value of if i : " + i);
                Instantiate (Path, PathSpawnPoints [i].position, PathSpawnPoints [i].rotation);
            }
                else {
                Debug.LogError ("Value of else i : "+i);
                    //instantiate the border, but rotate it 90 degrees first
                Vector3 rotation = BorderSpawnPoints [i].rotation.eulerAngles;
                    rotation.y += 90;
                Vector3 position = BorderSpawnPoints [i].position;
                    position.y += positionY;
                    Instantiate (DangerousBorder, position, Quaternion.Euler (rotation));
                }
            }
        }
    }

}


texts:
I am making an inventory system. Different inventory item will have different uses so i am thinking about making a base class called InventoryItem and derive Wood, Gold, Weapons and so on. This way all InventoryItems will share some basic functionality and can have their unique as well.

My questions are:

If instead i use a interface i cannot count on specific fields or variables as it only takes methods. Is there any reason to use interfaces?
If i use derived classes and have a List with mixed items from different derived classes i would need some code that goes through each class and casts it to the proper class to use its unique abilities. How is this best handled?


texts: How can i rotate the camera around an object, using compass?

texts:
I want the camera to rotate around an object in Y axis, when you rotate your phone. how can i do this?

i already have the code to do it using mouse, but i need it to turn with compass. here's the code for movement with mouse:

    mouseX = Input.GetAxis("Mouse X");
    offset = (Quaternion.AngleAxis(mouseX * cameraSpeed, Vector3.up) * offset);
    transform.position = point + offset;
    transform.LookAt(point);

i know that setting the mouseX value to change with compass direction is my answer, but how can i do it?


texts: BoxCollider2D fails verification, where CircleCollider2D does not

texts:
I have a 2D game object with no parent and a 2D box collider set with trigger enables. The dimensions are quite large.

When I place the game object in the scene, manually, it works just fine. However, when I instantiate the prefab, it doesn't work; in the inspector view, under the collider component a notification appears:

  The collider did not create any collision shapes as they all failed verification. This could be because they were deemed too small or the vertices were too close. Vertices can also become close under rotations or very small scaling.

When I switch to scene view, while the game is in play mode, I can not see the collider boundaries. Surprisingly, everything works fine, if I use the circle collider.  Does anyone know what the problem could be?


texts: Target Lower API Level than Package or Plug-In Requirements

texts:
I am working on a project that I want to use local mobile notifications for Android using Unity as game engine. I want to reach as much as users I can, so I want to target API level 16 for the lowest Android API level. As expected, when targeting Android API level 16 for a build, build fails with that error:

  Execution failed for task ':processReleaseManifest'.   Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:androidnotifications-release:] C:\Users\Tumay Varel.gradle\caches\transforms-2\files-2.1\71d39d4badfde5815e850866bcf079c9\AndroidManifest.xml as the library might be using APIs not available in 16
       Suggestion: use a compatible library with a minSdk of at most 16,
           or increase this project's minSdk version to at least 19,
           or use tools:overrideLibrary="com.unity.androidnotifications" to force usage (may lead to runtime failures)

In documentation , it is explicitly saying that the package supports Android 4.4 (API 19) and higher API levels. I can handle this problem by targeting lowest API level 19, however I want to ask: Is there a way to use this package or any other package or any plug-in  for required and higher API levels while not using for lower API levels than requirement at the same project?