texts:
I'm in the process of creating a prototype for a 3d space game (3rd person). My question is this:

How can a 3d space game have Zelda-like (or similar) dungeons in open space?

Problems:

Space has no walls (obviously) - how to restrict movement?
No movement restrictions - no doors.
No doors, no interesting mechanics of opening them.
No backtracing (for example after acquiring new power at the end that enables access to a place at the beginning of the dungeon).

More info: The Legend of Zelda: Oracle of Ages and Seasons' dungeon design - to see how some Zelda games do it.

The dungeon should be in 1 star system.

The EVE Online example is a good one, in the sense that it has been done before and it works, but for me it always somehow felt like cheating because in EVE you can travel anywhere... but not to a pocket of space right behind the dungeon gate. Even if you had a bookmark there.

And since my game will most likely feature even more free-form travel then EVE (think Elite: Dangerous) then what I'm saying is I'm looking for something that could improve that can be found in EVE.


texts: Calculating Damage from from object collision

texts:
I need to calculate the damage resulting from a crash of two objects.

I found the formula of the resulting kinetic energy:

E = m * v² / 2

I guess I also have to use the masses or sizes of the objects as well.

It will make a difference if the spaceship collides with a mountain (which certainly will make both of them dealing heavy damage), or the spaceship is colliding with a floating tennisball in which case neither of them are dealing damage.


texts: android: How to apply pinch zoom and pan to 2D GLSurfaceView

texts:
I want to apply pinch zoom and panning effect on GLSurfaceView. It is Image editor, so It would not be 3D object. I tried to implement using these following links:
https://groups.google.com/forum/#!topic/android-developers/EVNRDNInVRU

Want to apply pinch and zoom to GLSurfaceView(3d Object)
http://www.learnopengles.com/android-lesson-one-getting-started/

These all are links for 3D object rendering. I can not use ImageView as I need to work out with OpenGL so, had to implement it on GLSurfaceView.

Suggest me or any reference links are there for such implementation.
**I need it for 2D only.

I am able to do both now, but where I am getting problem is to set the pivot point while panning can any one help me to set the translation respective to pivot point?

Matrix.setIdentityM(mScaleMatrix, 0);
        Matrix.scaleM(mScaleMatrix, 0, scaleX, scaleY, 0);
Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mScaleMatrix, 0);
Matrix.setIdentityM(mTranslateMatrix, 0);
        Matrix.translateM(mTranslateMatrix, 0, deltaX, deltaY, 0);
Matrix.multiplyMM(mProjectionMatrix, 0, mProjectionMatrix, 0,
                    mTranslateMatrix, 0);
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);


texts: Is normal mapping cpu overhead or gpu overhead?

texts:
In Unity3D Engine,

I usually apply normal mapping using fragment shader.

In this case,

this normal mapping is cpu overhead or gpu overhead?


texts:
I'm coding a small "Binding of Isaac"-like game, with a little help from the official "Scavengers" Unity tutorial, since it's my first game.
In the tutorial every level is comprised of only one room. The player moves around and, when it reaches the ending, the whole scene is reloaded, creating a new procedurally generated map, but I wanted to do something different on my game.
My idea is to have levels comprised of a procedurally generated maze of many many rooms and the player should be able to navigate across them back and forth at will, but I'm unsure about using a scene per room or per level.

Q: What is the ideal size (in terms of gameplay content) for a scene?
Is the act of loading scenes resource-expensive (therefore prohibiting it's frequent use)?
Are there relevant performance differences between using many small scenes versus using one big scene?
Should I make every room a scene just like the tutorial, or should I make a bigger scene for the whole level?


texts: Does using an licensed game engine prevent you from open sourcing a defunct work?

texts:
I'm curious as my previous company is asking us (people who developed the game) on what to do to the game since it's no longer financially viable.

My suggestion was to open source it so people can still enjoy the game at the same time it could at least be improved.

But we did use a licensed Torque engine which was mostly recoded/reworked. Not sure if their license allows for the move though.

(Also not sure if this is an appropriate question to ask here)


texts:
I want to program a game.
In this game there is a tile map and objects that interact with it and them self.

For that I made first a TileMap class, in it is only the data of the tile map.
Its a very simple tile map without layers and a tile have only and integer id.

Secondly I have a class TileMapRenderer that draws the map.
It iterate threw all tiles and draw them dependent on there id.

So now I don't know how I can go further.
How I handle different objects like players, animals, table, chests and let them "clean" interact with the tile map.....
Has someone a idea?

And at last another problem with collision.
[URL=http://www.directupload.net][IMG]http://s1.directupload.net/images/140303/q2n5ebsm.png[/IMG][/URL]
If in this example the speed is smaller than 48, its perfect but if it bigger than 48 there is a problem.
Because normally I check whether on the new Position (current position + velocity) would be a collision and if yes put it a tile before.
But in a second case the player would be glitch threw on tile.
How I should handle collision in relationship to a object system.

I hope there is someone how know a good solution.


texts:
I wanted to start on a little project of making a simple 3d engine, but I can't seem to find anywhere how 3d engines actually make frames. (I don't mean the math behind the 3d projection). Do they use bitmaps and edit the pixels, or do they use the GPU in some way? Also is editing the pixels in a bitmap using CPU or GPU?
EDIT:

I only mean after they do the math and find each pixel value for the frame how do they display the frame? Do they change the pixels in a bitmap while rendering a scene, or do they have an array that has all the pixels color values then use the GPU do display the pixels?


texts: Fitting Android game to different screen sizes

texts: I am making an Android game that is only in portrait screen orientation.  It works great when I run it on my phone, but when I run it on a tablet, even though the screen size is bigger, all of the bitmaps are the same size. Is there any way to make the bitmaps stay the same proportion even on different size screens?


texts: Techniques for bot movement in (first person) shooter games

texts: I was wondering what kind of technologies were used in FPS games to move bots around the level. I know the pathfinding is done using waypoints or navigation meshes but how do the bots actually rotate and move over those paths? Is something like opensteer used for that, if so, which particular parts?


texts: Sort Textures by name before looping through them

texts:
im using a system to get textures from the device persistent data path and assign them to an array in order to show them in the game scene. So far everything works as expected, images are getting pulled into the array and are selected based on the level index. My issue is that on some android devices each time the image is loaded its either random or its a different image than it should be.
  public void LoadTextureArray(string _dirname)
    {

        var fileNames = Directory.GetFiles(Application.persistentDataPath + "/" + _dirname + "/", "*.jpg");

        source = new Texture2D[fileNames.Length];

        int index = 0;
        foreach (var fileName in fileNames)
        {
            source[index] = LoadTextureFromPath(fileName);
            source[index].name = fileName;
            index++;
        }
    }

    public Texture2D LoadTextureFromPath(string path)
    {
        if (string.IsNullOrEmpty(path))
        {
            Debug.LogError("Texture path is null or empty");
            return null;
        }

        if (!File.Exists(path))
        {
            Debug.LogError($"File not found: {path}");
            return null;
        }

        byte[] bytes = File.ReadAllBytes(path);
        Texture2D texture = new Texture2D(2048, 2048, TextureFormat.RGB24, false);
        texture.LoadImage(bytes);
        Debug.Log("success");
        return texture;
    }

and i assign them based on another variable with this code here
 if (LevelSystemManager.Instance.CurrentLevel < source.Length)
                    {
                        selectedText = source[LevelSystemManager.Instance.CurrentLevel];
                        DifficultySet();
                        Debug.Log("selected Texture Name is :" + selectedText.name);
                    }

The LoadTextureArray function is called on Awake and on Start i do the assignment based on that index. Now in both Unity editor and my phone everything works fine and no matter how many times i load the level its the same image. Whereas on my wifes it either skips a couple of images from the array (displaying the 5th for instance as index 1) or everytime i open the level i see a different one!
Thank you!
Edit : it seems my problem is that i need to sort them out before assigning them to that array so any help would be appreciated!


texts:
I'm researching new ways to optimize games for better performance. Currently I am working on texture atlasing, which is giving me a hard time. I made the atlas using Texture2D.PackTextures and saved the offset and height and width values to a text file.

Now when I insert the values to a material the texture is shown correctly, but since batching requires that the same material is used - how I can I use the same material with different offsets?

Picture: All the cubes use the same texture. Only the two on the right batch as they use the same material.


texts: How would I move something around inside of a sphere without it going outside of the sphere?

texts:
I want to be able to do this, but not go outside of the 4.4 meter limit, the radius is 4.4 meters, and it has zero gravity and no friction. I have a hard time explaining this, but imagine holding a hollow sphere with a little ball inside, when you shake it around the ball goes around the inside, I need something like that, but with zero gravity and no friction. I wasn't really sure how to do this, but I tried:

void Slide() {
if (slide) {
    for (uint32_t deviceIndex = 0; deviceIndex < vr::k_unMaxTrackedDeviceCount; deviceIndex++) {
        glm::vec3 position = devicePos[deviceIndex].xyz();
        if (sqrt(pow(position.x - 0.35, 2) + pow(position.y + 1.75, 2) + pow(position.z + 0.85, 2)) >= 4.4) {
            if (abs(position.x) > abs(position.y) && abs(position.x) > abs(position.z)) {
                if (position.x > 0) {
                    velocity.x = ((abs(velocity.y)) + (abs(velocity.z))) / 2;
                }
                else {
                    velocity.x = ((abs(velocity.y) * -1) + (abs(velocity.z) * -1)) / 2;
                }

            }
            if (abs(position.y) > abs(position.x) && abs(position.y) > abs(position.z)) {
                if (position.y > 0) {
                    velocity.y = ((abs(velocity.x)) + (abs(velocity.z))) / 2;
                }
                else {
                    velocity.y = ((abs(velocity.x) * -1) + (abs(velocity.z) * -1)) / 2;
                }

            }
            if (abs(position.z) > abs(position.x) && abs(position.z) > abs(position.y)) {
                if (position.z > 0) {
                    velocity.z = ((abs(velocity.x)) + (abs(velocity.y))) / 2;
                }
                else {
                    velocity.z = ((abs(velocity.x) * -1) + (abs(velocity.y) * -1)) / 2;
                }
            }
        }
    }
}

}


texts: Unity3D - Generate a position within a circular band around the player

texts:
Given a certain condition in my game I need to generate a position around the player.  It needs to be at least 8 meters away from him and within 10 meters, in a circular matter, as in the dotted green area in the picture below.

Can anyone point me into the right direction?
Thank you.


texts:
Please refer to this Answer.

DMGregory script is working for me, although I have a problem I can't fix because I don't talk shader :)

The tiling will be applied correctly on geometry aligned on XY plane BUT if you have an orthogonal plane (let's think a common room with 4 walls), the texture will stretch through the plane. Do you know how to fix that? I would like to apply world coord to texture for all 4 walls. (Note that the "plane" I am using is a simple quad made of 2 triangles.)

Here is a screenshot:

EDIT: After digging a while I found this guy here which did something similar.

My guess was to use the plane normal to set up the texture but, not knowing the syntax, the result was... well nothing :)

Here you can see the shader. Anyway, as pointed by DMGregory, it doesn't work for all wall angles. Notice the one in diagonal, shown in the picture.

Shader "Diffuse - Worldspace"
{
  Properties
  {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB)", 2D) = "white" {}
    _Scale ("Texture Scale", Float) = 1.0
  }

  SubShader
  {
    Tags { "RenderType"="Opaque" }
    LOD 200

    CGPROGRAM
    #pragma surface surf Lambert

    sampler2D _MainTex;
    fixed4 _Color;
    float _Scale;

    struct Input
    {
      float3 worldNormal;
      float3 worldPos;
    };

    void surf (Input IN, inout SurfaceOutput o)
    {
      float2 UV;
      fixed4 c;

      if(abs(IN.worldNormal.x)>0.5)
      {
        UV = IN.worldPos.yz; // side
        c = tex2D(_MainTex, UV* _Scale); // use WALLSIDE texture
      }
      else if(abs(IN.worldNormal.z)>0.5)
      {
        UV = IN.worldPos.xy; // front
        c = tex2D(_MainTex, UV* _Scale); // use WALL texture
      }
      else
      {
        UV = IN.worldPos.xz; // top
        c = tex2D(_MainTex, UV* _Scale); // use FLR texture
      }

      o.Albedo = c.rgb * _Color;
    }
    ENDCG
  }

  Fallback "VertexLit"
}


texts: Can't seem to get Sprite to face left in sfml c++

texts:
I am having some small issues getting my sprite character to flip around. Basically I have a character that can walk to the right.. I am looking to flip it so that it looks like it is walking left.  I haven't found a working solution at the moment so any help would be amazaing!

I am using:

SFML 2.1
C++

I have tried:

  guy.setTextureRect(sf::IntRect(guy.getGlobalBounds().width, 0, guy.getGlobalBounds.width * -1, guy.getGlobalBounds.height));


texts: HLSL SetVertexShader Texture2DArray Sample

texts:
I want to do some texture samples in the vertex shader, but it seems this cannot be done in the same was as when using the Pixel shader.

The code is basically..

Texture2DArray   gTexture;

VS()
{
    gTexture.Sample(samPoint, float3(x, y, z)
}

PS()
{
    gTexture.Sample(samPoint, float3(x, y, z)
}

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

The PS() will compile and work fine but I also need to do this sort of thing in VS().

When putting this code in the VS() I get:
Error   X4532   cannot map expression to vs_4_0 instruction set ....

I have done some googling and it looks like you can sample a texture in the VS but I cant get enough detail together to make this work.

Any help on this would be good.

Just for reference:
I am using
DirectX11
VS2015


texts: Get blocky look on textures some textures

texts:
If I do this:

GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap;

All textures I draw are blocky.

GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

All of my textures are blurred a bit.

What do I have to do so that only some of my textures are blocky and some are blurred?


texts: Theoretic question about rendering in sfml and in general

texts:
I have read whole tutorial section on sfml-dev.org and have some question.

What are exactly views and how to use them ?

Should I render things in views or in renderwindow ?


texts: Unity C# - Change color, or material of specific line segments on Line Renderer

texts:
We're making a game that plays with a LineRenderer, and we want to give it a different visual feedback relative to the side of the screen that it's on.

We want to change the feedback of the specific line segments that are on the other side (when they past the middle point).

The API lets you map the segments positions, but isn't there a way that you can change the material/color of that specific segment? I just see that you can do it, but only for the whole Line Renderer, not segment-by-segment.


texts:
Today I learned some cool tricks about sizing containers and its children, I mainly using this, because I need to build some forms.

But now... It is some preffered way how to handle forms? Or some unity component? I imagine something like get values of all InputFields, when the button is clicked.
Originaly I had script, which cycled through all children of container, registered them and I could from the script call method to get values in array. But now I have input fields in the more complex structure, for using of unity scripts for sizing and placement, so the cycle is now not so easy.
So, does unity have some script, or there is some unified way how to do this? How do you handle the forms? And of course, the biggest question, how do you handle standard behaviour as tabing through input fields and submit all on enter press?


texts: (real) 3d map rendering in wpf without an engine - how to handle the map data?

texts:
I'm just doing some research before embarking on rendering a 3D map inside a wpf app. I've never delved into 3D before, and hence the question..

I have map data (in several formats, and many files) which I need to render - probably in a wpf viewport3D. All the map data is in 2D, but I can add a height-map and convert to 3D. This data can be altered (updated) by the user without my knowledge, but a bit of data-crunching can be done before application start, so it doesn't need to be entirely realtime.

I've googled around but can't find a framework for how to represent my world. Do I write a terrain-tile stream server to handle requests from the viewport about which area to display?
Do I create a collossal map, and hope it fits into memory?

Are there tutorials about how to deliver large terrains for rendering? Most of them seem to be about building a world inside an editor..

My world could be about 1000km * 1000km, with roads, parks, forests, power lines, street addresses (etc) - it's going to be a fair bit of data..

The machines that this software has to run on are ruggedized laptops - so not terribly fast (Core 2 duo?) and probably without DX10, but we can insist on heaps of RAM and HDD (SSD?).

Thanks - I'm looking forward to getting into this project..


texts: 100 points between 0-1000 on an increasing scale

texts:
Basically, it's for roleplay, I need to generate 100 points along a scale. Level 1 is the starting amount, and is at point 0 on the scale. Level 100 is the highest amount planned at this point, and it needs to be at 1,000 on the scale.

My problem is generating points 2-99 between those two. I could do it cheaply and just go with one level at every 10 points. But that's not how I want it to function.

Ideally, I'd like a sloping curve, so that in the early stages, levels might be only a number or two apart. Such as:

Level 1 - 0
Level 2 - 2
Level 3 - 4

But then as the level increases, the number also goes up.

Level 98 - 960
Level 99 - 980
Level 100 - 1000

Can someone help me figure this out?


texts: Which are the option to promote my app game in different app stores?

texts:
We've few Android App projects at the moment anmd we're looking for a way to publish our appGames in differents AppStores around the globe.

Do someone know a fast way to submit or some management tools for App publishers?

Thanks


texts: Finding specific coordinates on a rotating line

texts:
I'm currently working on a mobile game which mainly consists of a rotating line and a ball. The line rotates 0.500 degrees clockwise around its center every frame. The ball is at first positioned in the centre of the line. When the user touches the screen, the ball should move along the line and when the user stops touching the screen the ball should move in the opposite direction.

I have the line rotation, and the coordinates of the line(top-left corner).

I need to find the position of the ball if the ball moves along the line at a speed of 5.


texts: 2D: Scaling a character with multiple RigidBody2Ds?

texts:
So, this example is in the Godot Engine, but other engines porbably have this kind of problem, too:

I have a character with multiple RigidBody2Ds, that also has a bone skeleton for animation over them. Now, the problem is, that Godot's physics engine handles the transforms of the bodies, so they won't scale properly. If you scale the children (CollisionShape2Ds and Sprites) the positions will be off. Is anybody aware of a proper way to work around this? Being able to scale these kind of characters would be awesome.

Thanks for all your answers.
Greetings, Footurist


texts: Is using something like MakeHuman frowned upon while developing 3D games?

texts:
I came across this interesting application called MakeHuman, and I was wondering what developers in the gaming community thought about creating and exporting characters to Unity using this application. I'm not an artist, so a tool like this helps me create characters without having to pay someone else to model them from scratch.

If I were taking a class in game development, would it be permissible to use something like this to create characters rather than create them myself (in Blender or Maya, for example)? What benefits are there to consulting an artist rather than using tools like this?


texts: Make virtual joystick preserve aspect ratio Android in Unity

texts:
When I start my game on Android my virtual joysticks stops being round.

Here you can see it:

Here is the project on PC at the same time:

Here are my UI settings for the Joystick:

Please, help me to find a way to preserve the roundness on the Android phone. It feels to me that the solution to the problem is straightforward, but my lack of knowledge prevent me from getting it. What I tried to do is to tweak settings in Editor, in particular I checked preserve ratio on all elements images as you can see on screenshots, but it did not help. I think it did not due to the fact that there is a code executed every time which is this:

Screen.orientation = ScreenOrientation.LandscapeLeft;

And I think that it changes ratio even though I preserved it in Editor. So, help me out of the problem, please.


texts:
When I wrote my first application in SDL, it looked like this:
while (!quit)
{
    SDL_PollEvent(&event);

    switch (event)
    {
         // ...
    }
}

But then one time I left my app running while I went to do something else, and when I came back my laptop was boiling hot. I checked the system monitor and one of my cores was maxed out by my program! So I did some research, and now my loop looks like this:
while (!quit)
{
    SDL_WaitEvent(&event);

    switch (event)
    {
         // ...
    }
}

Great, so now my program doesn't max the CPU. But now I need to introduce rendering, and the problem is, currently this loop runs one iteration per event. If input and other events don't occur, my program won't render the next frame, no matter where the rendering code goes in the loop. So that's no good.
I could have threads, but that seems like a lot of extra complexity when I could just do:
while (!quit)
{
    SDL_PollEvent(&event);

    switch (event)
    {
         // ...
    }

    SDL_Delay(10)
}

This won't melt the CPU, and I can render at about 100 frames per second.
My questions are:

Which approach "should" I use? I don't see any reason to not just use (3).

What's the point of SDL_WaitEvent, if you can't use it the moment you want to do anything other than handle events in your game loop?

I assume SDL_WaitEvent does something like approach (3) under the hood, so even though ostensibly approach (3) should introduce more latency, in practice it won't. Is this correct? How low should the integer passed to SDL_Delay be to get a responsive app?


texts:
I am making a cash game like deal or no deal for use as an android app, using adobe software.

The idea is player wagers 50 pence through Paypal plays the game wins, say, £10 pounds and then cash out.

How do I create a cash pay and play system probably with Paypal? I have done the art work and the basic flash script, i.e. actions and movie.

I will also need some sort of data feedback to prevent hacking of game, I think, and to be able to send updates and be able to remotely alter win percentages according to profits and losses.

Will the user need to be connected to a server?

Can someone help guide me through what the steps I need to do?


texts: Smallest MQ/HQ Video Format for Game Software (VB.net/WPF based)

texts:
I am making a first-person computer game in the style of Carmen Sandiego or The Cluefinders. My game company is just starting up, so we have no spare money.

My animator and I decided that the best way to get movement throughout the game would be to create 640x480 videos that would serve as backdrops, and would hold everything from entering/exiting the scene to talking with other characters (especially since Flash and WPF don't play well with each other). Everything the user interacts with directly (by clicking or dragging) would be put over this video, and in cases of clicking "something in the video," we'll use empty image boxes as "hotspots".

Thus, bringing me to the question. What is the best video format to use so that we have good quality video at 640x480 res, yet does not take up too much space, as this will be running from disk. Whatever it is, it must be able to be integrated in WPF without WinHost, because I have to have WPF objects over it. And again, it must be a format I can use commercially without royalties, but also does not require me to pay for it (therefore, BINK Video is not an option).


texts: How do I use images with copyright in my game?

texts:
Our game requires to show images from movies, cartoon characters, etc. but we don't know how we can include them.

We have seen that games like QuizUp and other guess the pic like games have images from Disney characters, Pokemon or company logos, etc.

How does it work? Is this usage considered fair use?


texts: NavMesh stops working when changing scenes

texts:
In my game, upon reaching the end of the level, I change scenes to go to the next level. Most of the stuff is maintained from scene to scene using DontDestroyOnLoad, but the environment(floor) is not. So, I tried creating a new level environment in the next scene and baking it, but when the player enters that scene by reaching the end of the previous level, I get a NavMesh error stating that SetDestination can only be called on active agents. Why does this happen? Does the player have to be in the scene when baking occurs? Right now, the player does not natively reside in the scene, but gets loaded to it.

Edit: I created a new project with just the bare essentials for testing and it works as intended. Clearly, something was off with my other code which caused this kind of interference.


texts:
So I am starting a game with a friend as a small project, and we are considering what game servers would we need.

Firstly, the game is a multiplayer(player vs player) game, for example, like an online chess game. However it is real time, so the latency cannot be too high. The players basically take turns, but in a real time fashion. The platform is going to be Android (and perhaps extend to iOS in the future)

The server would need to synchronize the players' moves to each other devices.

I don't really need anything large scale and I am thinking of using PHP since the volume of data isn't really that big, this is like a web-based game with a requirement of a slightly lower latency.

What would be the advantages and disadvantage of using Apache + PHP for a game like this?

If that seems to be a bad choice, I would be grateful if you can share your experience with me. Thank you.

(We are both programmers and we are familiar with Java C++ Obj-C Apache PHP Tomcat JSP Javascript)


texts: Why won't my vertex buffer render in GLFW3?

texts:
I have started to try to learn OpenGL, and I decided to use GLFW to assist in window creation. The problem is, since GLFW3 is so new, there are no tutorials on it or how to use it with modern OpenGL (3.3, specifically).

Using the GLFW3 tutorial found on the website, which uses older OpenGL rendering (glBegin(GL_TRIANGLES), glVertex3f(), and such), I can get a triangle to render to the screen. The problem is, using new OpenGL, I can't get the same triangle to render to the screen.

I am new to OpenGL, and GLFW3 is new to most people, so I may be completely missing something obvious, but here is my code:

static const GLuint g_vertex_buffer_data[] =
{
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f
};

int main(void)
{
    GLFWwindow* window;

    if(!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW.");
        return -1;
    }

    glfwWindowHint(GLFW_SAMPLES, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    window = glfwCreateWindow(800, 600, "Test Window", NULL, NULL);
    if(!window)
    {
        glfwTerminate();
        fprintf(stderr, "Failed to create a GLFW window");
        return -1;
    }
    glfwMakeContextCurrent(window);

    glewExperimental = GL_TRUE;
    GLenum err = glewInit();
    if(err != GLEW_OK)
    {
        glfwTerminate();
        fprintf(stderr, "Failed to initialize GLEW");
        fprintf(stderr, (char*)glewGetErrorString(err));
        return -1;
    }

    GLuint VertexArrayID;
    glGenVertexArrays(1, &VertexArrayID);
    glBindVertexArray(VertexArrayID);

    GLuint programID = LoadShaders("SimpleVertexShader.glsl", "SimpleFragmentShader.glsl");

    GLuint vertexBuffer;
    glGenBuffers(1, &vertexBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);

    while(!glfwWindowShouldClose(window))
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glUseProgram(programID);

        glEnableVertexAttribArray(0);
        glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);

        glDrawArrays(GL_TRIANGLES, 0, 3);

        glDisableVertexAttribArray(0);

        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    glDeleteBuffers(1, &vertexBuffer);
    glDeleteProgram(programID);

    glfwDestroyWindow(window);

    glfwTerminate();
    exit(EXIT_SUCCESS);
}

I know it is not my shaders, they are super simple and I've checked them against GLFW 2.7 so I know that they work. I'm assuming that I've missed something crucial to using the OpenGL context with GLFW3, so any help locating the problem would be greatly appreciated.


texts: Easily get several materials from different objects onto 1 UV map/material?

texts:
Im trying to improve performance, and I found an asset called https://forum.unity.com/threads/one-batch-combine-hundreds-of-materials-into-one-draw-call.555643/ that claims to do what I need -  which is reducing many material maps across multiple objects to 1 material.

These are baked maps from blender, and Im using just a standard shader with albedo and emission really. OneBatch does not work, and I need to know within unity (or blender really) if theres a way to easily pack these maps into 1 file and/or material, without screwing up the existent UV unwrapping.

All the maps are the same size, and there are 1-3 per object (different sub meshes). What are some solutions?


texts: Why is C# method not showing up for button's On Click()

texts:
I have a C# script called MainMenu.cs

Here it is in its entirety

using UnityEngine;
using UnityEngine.UI;

public class MainMenu : MonoBehaviour
{
    public Button btnPlay;

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

    public void PlayLevel()
    {
        Application.LoadLevel(1);
    }
}

In my hierarchy, i have a Main Camera, a Canvas and EventSystem. Under Canvas i have a Button.  I add the MainMenu script to the Canvas and associate the button with Button i have in canvas.  When i go to the button and associate the MainMenu with its OnClick I am expecting to be able to chose PlayLevel() but it is not there.

Am i missing something obvious here?
(Using Unity 5.0)


texts: Game actions that take multiple frames to complete

texts:
I've never really done much game programming before, pretty straightforward question.

Imagine I'm building a Tetris game, with the main loop looking something like this.

for every frame
    handle input
    if it's time to make the current block move down a row
        if we can move the block
            move the block
        else
            remove all complete rows
            move rows down so there are no gaps
            if we can spawn a new block
                spawn a new current block
            else
                game over

Everything in the game so far happens instantly - things are spawned instantly, rows are removed instantly etc. But what if I don't want things to happen instantly (i.e animate things)?

for every frame
    handle input
    if it's time to make the current block move down a row
        if we can move the block
            move the block
        else
            ?? animate complete rows disappearing (somehow, wait over multiple frames until the animation is done)
            ?? animate rows moving downwards (and again, wait over multiple frames)
            if we can spawn a new block
                spawn a new current block
            else
                game over

In my Pong clone this wasn't an issue, as every frame I was just moving the ball and checking for collisions.

How can I wrap my head around this issue? Surely most games involves some action that takes more than a frame, and other things halt until the action is done.


texts:
Apart from using a plug in or other third party device, is there anyway Unity can support bluetooth communication between two devices?

All of the links I have found seem to relate to third party options which I want to try and avoid.


texts: Accessing 3D texture data without normalized coordinates directly, but with filtering

texts:
texelFetch() exists to access texture data with texture coordinates in "image dimensions", but texelFetch skips filtering.

In case of 2D textures, it's possible to use a rectangle texture sampler to access textures without normalized coordinates with filtering, but the same equivalent doesn't seem to exist for 3D textures.

Is this somehow possible with 3D textures?


texts: How to open two Animator views in Unity?

texts:
How can I open two Animator views in Unity editor?

What I tried so far is to lock an Animator view and go to Window=>Animator.

That did not help.


texts: I need to move an entity to the mouse location after i rightclick

texts:
Well I've read the related questions-answers but still cant find a way to move my champion to the mouse position after a right-button mouse-click.
I use this code at the top:

float speed = (float)1/3;

And this is in my void Update:

  //check if right mouse button is clicked
        if (mouse.RightButton == ButtonState.Released && previousButtonState == ButtonState.Pressed)
        {
            // gets the position of the mouse in mousePosition
            mousePosition = new Vector2(mouse.X, mouse.Y);

            //gets the current position of champion (the drawRectangle)
            currentChampionPosition = new Vector2(drawRectangle.X, drawRectangle.Y);

            // move champion to mouse position:
            //handles the case when the mouse position is really close to current position
            if (Math.Abs(currentChampionPosition.X - mousePosition.X) <= speed &&
                Math.Abs(currentChampionPosition.Y - mousePosition.Y) <= speed)
            {
                drawRectangle.X = (int)mousePosition.X;
                drawRectangle.Y = (int)mousePosition.Y;
            }
            else if (currentChampionPosition != mousePosition)
            {
                drawRectangle.X += (int)((mousePosition.X - currentChampionPosition.X) * speed);
                drawRectangle.Y += (int)((mousePosition.Y - currentChampionPosition.Y) * speed);
            }
        }
        previousButtonState = mouse.RightButton;

What that code does at the moment is on a click it brings the sprite 1/3 of the distance to the mouse but only once. How do I make it move consistently all the time? It seems I am not updating the sprite at all.

EDIT
I added the Vector2 as Nick said and with speed changed to 50 it should be OK. I tried it with if ButtonState.Pressed and it works while pressing the button. Thanks.
However I wanted it to start moving when single mouse clicked. It should be moving until reaches the mousePosition.

The Edit of Nick's post says to create another Vector2, But I already have the one called mousePosition. Not sure how to use another one.

            //gets a Vector2 direction to move *by Nick Wilson
            Vector2 direction = mousePosition - currentChampionPosition;

            //make the direction vector a unit vector
            direction.Normalize();

            //multiply with speed (number of pixels)
            direction *= speed;

            // move champion to mouse position
            if (currentChampionPosition != mousePosition)
            {
                drawRectangle.X += (int)(direction.X);
                drawRectangle.Y += (int)(direction.Y);
            }
        }
        previousButtonState = mouse.RightButton;


texts: Efficiently storing game states history for physics?

texts:
I would like to store the history of a box2d simulation. Currently I can't find any built-in mechanism for that.

I need to store the states of all non static objects in the last second, mainly for network latency correction.

I think I will use a multi dimensional array for all the rigid bodies positions and forces.

Is there a better way to achieve what I'm trying to do?


texts: Is there anyway to retrieve the properties of an individual TiledTile?

texts: I managed to get a list of all the tiles in a layer of a tmx map by iterating through the IReadOnlyList<TiledTile> Tiles in TiledTileLayer and enumerating the values into another list. But I need to be able to iterate through that list and check for a certain property. However, TiledTile has no properties variable and no getProperties() method. How would I do this?


texts: I found out how to rotate both Sphere and Cube (1) like a Turret facing a target but why is it so hard?

texts:
I just added 3 objects to my scene to a new project.
To be sure where the problem is I created a new project.

Then added to the scene: 2 Cubes and 1 Sphere 1 empty GameObject.

Cube is the target.

Sphere and Cube (1) are the Turret and both are childs of the empty GameObject.
The script is attached to the empty GameObject.

The logic say if I will rotate the empty GameObject both Sphere and Cube (1) will rotate at the same time. But I found that if I'm not setting both Sphere and Cube (1) same direction before running the game they will never face to the target only the Sphere.

I had to figure out where is the Sphere facing direction before running the game and change the Cube (1) to face the same direction of the Sphere on the Z Blue axis.

I can't figure out yet and understand why is it so hard to rotate two objects at the same time to be facing the same direction (target).

Now it's working once the sphere and the cube (1) are facing same direction before running the game. It didn't work if I made them childs or parents or changed the Cube (1) position to 0,0,0 nothing.

They were both rotating but never faced the target only the Sphere faced the target.

So now each time I want to rotate two objects at the same time to face another gameobject like a turret, or cannon or anything that is built of two parts I need first to make them facing same direction ?

I guess I did something wrong but not sure what.

The script:

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

public class Rotateturret : MonoBehaviour
{
    public float speed = 3.0f;
    public GameObject m_target = null;
    Vector3 m_lastKnownPosition = Vector3.zero;
    Quaternion m_lookAtRotation;

    private void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (m_target)
        {
            if (m_lastKnownPosition != m_target.transform.position)
            {
                m_lastKnownPosition = m_target.transform.position;
                m_lookAtRotation = Quaternion.LookRotation(m_lastKnownPosition - transform.position);
            }

            if (transform.rotation != m_lookAtRotation)
            {
                transform.rotation = Quaternion.RotateTowards(transform.rotation, m_lookAtRotation, speed * Time.deltaTime);
            }
        }
    }

    bool SetTarget(GameObject target)
    {
        if (!target)
        {
            return false;
        }

        m_target = target;

        return true;
    }
}

Here is a link for a short video clip I recorded showing what I mean:

Video clip of the problem


texts: If I design a game that has both guns and melee weapons, how do I make them equally viable?

texts:
I have a plan to make a 2D action platformer game, and I've started prototyping a bit in Godot 2D. My intention was to make the character fight with both guns and melee weapons, with gunplay like the Metal Slug series and melee mechanics akin to what's found in Dead Cells.

The gun would be bound to the right mouse button [as a secondary attack] and the melee to the left mouse button [as a primary attack], though I do plan on making it so that the player can switch their primary attack type.

The gun used and the melee weapon would be different per character - one would have a high caliber revolver and a greatsword, while another would have a high RoF assault rifle and a knife, for example.

The basics, I get (right now I use a free game art sprite set, and I can use the frame number in the animation to fire a bullet or enable the melee attack hitbox).

It's the balancing issues that got me stumped.

I want to make both ranged and melee combat viable, or as close to equally viable. Though, with the existence of guns, I'm not sure anyone would want to use the characters' melee weapons.

I know it's possible to make guns and melee weapons fulfill different functions, like guns only able to attack one target at a time (except shotguns) with varying fire rates, while most melee weapons are able to attack faster than guns but with a much shorter range, or able to attack multiple targets at once within its hitbox but much slower than guns.

For example, make the melee weapon have a large hitbox and able to apply some non-elemental Damage over Time but with low damage itself [and, when charged, able to pull an enemy in front of the character], and the gun a quad-barreled shotgun that delivers massive damage at close range but with long cooldown.

Would that be a viable option to make both melee and guns equally viable, and are there other ways to do it?


texts: libgdx - getButtonTable() missing Window method

texts:
I'm following some tutorial to create my own Inventory for my game. I have met with an insidious problem:

public class InventoryActor extends Window {
    public InventoryActor(Inventory inventory, DragAndDrop dragAndDrop, Skin skin) {
        super("Inventory", skin);

        // add an "X" button to the top right of the window, and make it hide the inventory
        TextButton closeButton = new TextButton("X", skin);
        closeButton.addListener(new HidingClickListener(this));
        getButtonTable().add(closeButton).height(getPadTop());

        // basic layout
        setPosition(400, 100);
        defaults().space(8);
        row().fill().expandX();
...
}

Everything in this code is neat and nice. There's one BUT -

getButtonTable().add(closeButton).height(getPadTop());

This method isn't implemented anywhere. Tutorial I'm following comes from 2014. Therefore I assume that it may be some deprecated/old method from Window class or something like that.
My question is - is there any way I could repair it, and how can I add this 'X' close button to the window then? Should I use some other method?
Regards and thanks in advance!


texts: How to release a new level without having to publish a new version

texts:
What can I do to extend the gameplay. So if I know that I will update the game with new levels and dont want to publish a new version every time I have a new level. How can I handle this.

Ex: I have a unity3d game with 3 levels now and I know that i will have a 4th level. So what should i do in order to extend the game play without publishing a new build after i finish making the 4th level?

I wanna download the new level on the fly instead of new release

I know i need to use external help like a server to import all the files but how would that work?

I am using same scene and different setups to implement levels. I am currently hardcoding the levels. But if that's wrong I can change it.


texts:
I have read a lot of papers recently to understand the lag compensation concept recently. They were all about the same context: shooter game where bullets move in infinite velocity.

The most important thing is checking what was in the crosshair when the client created the fire command. If another player was there at that time, then s/he's damaged. That is done by checking the world state at that time by finding a snapshot and executing commands until the fire command.

How about firing a rocket? That is slow (not to mention other differences: ignition time and area damage). That means, I cannot only check what was on the crosshair of the client at the command creation time.

If I go back and check the world state at that time (with same method above), it wouldn't be enough. I would still need to do the simulation for the next snapshots until the most recent one (server's present).

That would mean, if I have a time step of 15ms (tick rate = 66) and I want to discard a command if it is older than 1.5 seconds, I need to keep the most recent 100 (1500/15) snapshots of the world. And every time a delayed command comes, I have to re-simulate the world from that command's timestamp to present - including reprocessing the commands with timestamps after that one.

This sounds too much work on the CPU to me. Is this the same in the first scenario (infinite speed bullet)?

What about lag compensation for movement commands? Would that be different?

Or did I misunderstand something / many things?


texts: Touch a specific area on the screen in Unity 5

texts:
I am building a Roulette game in Unity 5. I want to place bets on a Roulette table when I touch specific areas on the screen with mouse(PC) and touch(mobile).

For example when i touch Number 1 on the roulette table a bet should be placed on that number. I tried using box collider iwth trigger but I think thats for only colliders.

Screenshot attached


texts:
I am trying to import in XNA an .fbx model exported with blender.

Here is my drawing code

public void Draw()
{
    Matrix[] modelTransforms = new Matrix[Model.Bones.Count];
    Model.CopyAbsoluteBoneTransformsTo(modelTransforms);

    foreach (ModelMesh mesh in Model.Meshes)
    {
        foreach (BasicEffect be in mesh.Effects)
        {
            be.EnableDefaultLighting();
            be.World = modelTransforms[mesh.ParentBone.Index] * GameCamera.World * Translation;
            be.View = GameCamera.View;
            be.Projection = GameCamera.Projection;
        }
        mesh.Draw();
    }
}

The problem is that when I start the game some model parts are overlying others instead of being behind. I've tried to download other models from internet but they have the same problem.


texts: How to use nodes in scene graph for game logic

texts: I am working on a 3D 2048-game using Java with LWJGL to gain some 3D math and OpenGL experience. I built a small scene-graph (GroupNode and Box). My problem is that the tree structure of my scene-graph is not very convenient for the game-logic. For the game-logic I would use a 2D-array to store the tile-values, merge tiles and calculate points and so on. I think it would be a good approach to separate the view (SceneNodes) from the game-logic-type (Tile). What is best practice to link them, update views, and how to care about animations? If I merge two tiles and present this by move the source tile into the target tile, I need to know when the animation finished to do the next merge-move.


texts: Is using a half-edge mesh structure feasible?

texts: Is it feasible to use half-edge mesh, in games, instead of vertex-face structure? What comes to my mind is that it could be useful in mesh simplification (dynamic level of detail). However, I'm worried it could take too much memory, or even have a negative impact on a games rendering performance.


texts:
I am getting these blank errors in unity for quite a while now, as soon as I create a new Project 2D or 3D I am presented with the following and can't enter in play mode.

And as a workaround I have to change the Scripting Runtime Version to 3.5 in the project settings to make it work.

I cannot able to work with version 4.x

I have the Window 7, .NET Framework 4.7.2 Installed, any help or advice is much appreciated.

Thank you.


texts:
I am reading a book about game development (Game Coding Complete, Fourth Edition) and there is an "Actors" topic which just explains how to use them briefly instead of explaining what it is.

Here's how the book introduces these actors:

  Games are full of objects that bring your world to life. A World War
  II game might be full of tanks and planes, while a futuristic science
  fiction game might have robots and starships. Like actors on a stage,
  these objects are at the heart of the gameplay. It seems fitting that
  we call them “game actors” because that’s exactly what they are.

  A game actor is an object that represents a single entity in your game
  world. It could be an ammo pickup, a tank, a couch, an NPC, or
  anything you can think of. In some cases, the world itself might even
  be an actor. It’s important to define the parameters of game actors
  and to ensure that they are as flexible and reusable as possible.

  There are as many ways for defining a game actor as there are games.
  Like everything else in computer programming, there is rarely a perfect solution.

I could only understand a very few things: it is an abstraction of everything in the game which can perform actions; it has it's own state; it's behaviour is usually implemented as a state machine. This is it. I am coming with systems programming background to the game development, and so I would like to know in general, what the actor is in game development meaning, how to use it, how it is used in general, what problem it solves, how and why. I would like the explanation to be such that a kid could understand.

I have tried to find this information on google but it heads me to another "actors" instead: concurrent programming most of the time or game actors but without a good explanation of it.


texts: How to retrieve a cube collision by faces

texts:
I work for a while on a minecraft game (voxel).
I am front a problem for a long time about the collision detection. I want recover the cubes collision from my highlighted black's cube like on the picture , but only on the sides. And not on the edges !
Actually i got all cubes in red and green when i check with the boundingBox method.
Actually i use the method with the class "BoundingBox" to check for collisions.
Can anyone help me or direct me on the best way for retrive the right cube ?

Code example with the boundingBox methode for check the collision

List<Node> nodeParent = regions[modelSelected.regionIndex].Nodes[modelSelected.Id].Where(m => modelSelected.BoundingBox.Intersects(m.boundingBox)).ToList();

i want to get only the green cube and not the red .. From the black cube in the middle

Thank's a lot guy


texts:
I want to make googly eyes in Game Maker Studio 2 and I'm kind of close to what I want.
I have a white circle object and a black circle object. When my black circle is colliding with the white circle its vspeed is positive, but it stops moving before it leaves the white circle.
I want the googly eyes to be attached to my player and enemies, but react randomly to walking, jumping, falling, etc.


texts: How to set end of joint that has fixed transform?

texts:
I'm implementing chains locked the door, and used Hinge joints to linked the chains like this picture:

As you can see, last chain doesn't have connected body because it is end. And when the game starts, links were broken:

How to make last chain just hang in the position like first hinge object?

Also, chains are too way swaying, is there a way to reduce it? I increased every chain's mass to 100~1000, but seems nothing changed. Give it too much mass results broken joints.

Any advice will very appreciate it!


texts: What kind of questions should I ask players in a survey after the game?

texts:
I'm finishing a HTML5 browser game, and I'd like to have some player feedback. I was planning to make players take a short survey at the end of the game. Is this the best approach? How long should it be? Should I just let them write about the game instead of answer questions?

What are good questions to ask and how?

For example, do I let them write about physics, do I let them just choose "GOOD" or "BAD" or do I have a scale from 1 to 10?


texts: Stretch the game to fit the game window, in Unity 5

texts:
(Desktop) I want to make it so that when the user re-sizes the game window, the game is stretched to fill the window.
(Similarly, for Android) I want it to be stretched to fit the screen as well.

The game's real resolution is supposed to be 720x1280 (16:9 equivalent). In the image on the left you can see the actual resolution.

I can see that unity automatically re-scales it everytime the game window is re-sized, but it kind of keeps the same aspect ratio. This results in either black bars or part of the game being off-screen. How can I scale my game based on the current window aspect ratio ? I know the graphics will get distorted.

Isn't there a way to stretch the game without keeping the same aspect ratio, within the unity interface ? If not, how could I do that within a script ?

In xna or libgdx, I would simply add a scale matrix on every spriteBatch.Begin() method call. That scale would be based on the (current window width, current window height) and the ("real" game width, "real" game height).

For example, since my game is 720x1280, if you had your window re-sized at 500x500, I would scale the graphics by 500/720 on X axis and 500/1280 on Y axis. And then I would have to scale the inputs by 1/scale matrix. I need to know how this works on unity. Perhaps, setting Camera.main.aspect to the current aspect ratio of the current window (I could calculate that everytime the window is resized), would solve the problem (?), but is there another option ?

I assumed that supported aspect ratios would do just what I needed. But when I re-size my game window to 720x1080 (4:3 equivalent) down from 720x1280 (16:9 equivalent) it just adds black bars. When I want the game to stretch, in all cases.


texts: Handling data logic on libgdx ai state machine or in ashley system?

texts:
In this below example, I've combined libgdx ashley and AI state machine. Do you think it's a good idea to handle the logic in state machine or stick on handling the data logic on System?

public enum TrollState implements State<Entity> {
     MOVE_AWAY() {
         @Override
         public void enter(Entity entity) {

         }

         @Override
         public void update(Entity entity) {
              PositionComponent position = Mappers.position.get(entity);
              ...
         }

         @Override
         public void exit(Entity entity) {

        }

        @Override
        public boolean onMessage(Entity entity, Telegram telegram) {
             if (telegram.message == 0) {
                 Gdx.app.log("Slime", "Waaaah, goo away, big daddy! yummmmmmy");
                 return true;
            }
            return false;
        }
     }
}


texts: rotate sprite and shooting bullets from the end of a cannon

texts:
Possible Duplicate:
  How to Align Gun with Bullets

Hi all i have a problem in my Andengine code,

I need , when I touch the screen, shoot a bullet from the cannon (in the same direction of the cannon)
The cannon rotates perfectly but when I touch the screen the bullet is not created at the end of the turret

This is my code:

private void shootProjectile(final float pX, final float pY){
    int offX = (int) (pX-canon.getSceneCenterCoordinates()[0]);
    int offY = (int) (pY-canon.getSceneCenterCoordinates()[1]);
    if (offX <= 0)
            return ;
    if(offY>=0)
                    return;

    double X=canon.getX()+canon.getWidth()*0,5;
    double Y=canon.getY()+canon.getHeight()*0,5 ;
    final Sprite projectile;
    projectile = new Sprite( (float) X, (float) Y,
                    mProjectileTextureRegion,this.getVertexBufferObjectManager() );

    mMainScene.attachChild(projectile);

    int realX = (int) (mCamera.getWidth()+ projectile.getWidth()/2.0f);
    float ratio = (float) offY / (float) offX;
    int realY = (int) ((realX*ratio) + projectile.getY());

    int offRealX = (int) (realX- projectile.getX());
    int offRealY = (int) (realY- projectile.getY());
    float length = (float) Math.sqrt((offRealX*offRealX)+(offRealY*offRealY));
    float velocity = (float) 480.0f/1.0f;
    float realMoveDuration = length/velocity;

    MoveModifier modifier = new MoveModifier(realMoveDuration,projectile.getX(), realX, projectile.getY(), realY);
    projectile.registerEntityModifier(modifier);
}

@Override
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {

    if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_MOVE){

        double  dx = pSceneTouchEvent.getX() -  canon.getSceneCenterCoordinates()[0];
        double  dy = pSceneTouchEvent.getY() -  canon.getSceneCenterCoordinates()[1];

        double  Radius = Math.atan2(dy,dx);
        double Angle = Radius * 180 / Math.PI;
        canon.setRotation((float)Angle);

        return  true;

    }
    else if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN){

        final float touchX = pSceneTouchEvent.getX();
        final float touchY = pSceneTouchEvent.getY();

        double  dx = pSceneTouchEvent.getX() -  canon.getSceneCenterCoordinates()[0];
        double  dy = pSceneTouchEvent.getY() -  canon.getSceneCenterCoordinates()[1];

        double  Radius = Math.atan2(dy,dx);
        double Angle = Radius * 180 / Math.PI;

        canon.setRotation((float)Angle);
        shootProjectile(touchX, touchY);
    }

    return false;
}

Anyone know how to calculate the coordinates (X,Y) of the end of the barrel to draw the bullet?


texts: Button stays highlighted after being clicked - Unity3D 4.6 GUI

texts:
Sometimes, after clicking a button created by unity's new UI Button, the button stays in its highlight state. Note that Button script has Color Tint set as it's Transition property and the Interactable checkbox is checked.

How can I solve this?


texts: Distributing an Android game with plugins via the market

texts:
I'm new to Android development, and was wondering how the following could be achieved within the confines of the Android market as a distribution channel:

One main application, which handles the main menu, networking, high scores, etc.
Several games which can be launched from the main menu, which all work within the same eco system. The main application is not just a pseudo launcher for other games, these different games will share high scores and other achievements/preferences.

In a traditional package management system such as apt, pacman or yum, this could be handled quite happily through dependencies. This does not appear to be possible via the Android market. The closest I've seen is when apps scan to check if the required app is installed, and if not, launches the market and asks the user to download the app.

This sounds like a very messy solution.

It also begs the question, would they download the game (plugin) first, which then downloads the main shell application? Or would they download the main shell application, and when they navigate to a menu item which says "Play game", then it scans for any installed games, and if none exist, redirects to the market? Also, I'm not even sure if it is possible to dig up the package from another application on the device, and start invoking classes from within (e.g. when you want to launch the game (plugin))

A final option is just to have a 3rd component which is a .jar that each game includes, which effectively contains the entire shell application. Then each game would appear to have the same menu, but it would become a nightmare as soon as you want to update the menu component and have to re-release each game. It would be especially worse if other people released games (plugins) based on the same framework and didn't update them.

Is there any other options which I haven't thought of?

Has anyone else solved this or seen a solution in any apps they've installed (doesn't have to be games)?

cheers.


texts: Cocos2D - Detect how many items an object collided with / negating more than one object

texts:
In creating a small breakout clone, I've managed to get the ball to bounce whenever it hits a block by negating (or multiplying by -1) either the X or the Y values.

This works, at least until the ball (which is really a small rect with a sprite) manages to hit two blocks at once, at which point either the X or Y values are negated twice.

The ball then proceeds to continue on its path without bouncing, resulting in a very short and very strange Breakout game.

Is there any way to detect how many items have collided with the ball, and to disregard one?

Or is there some other way to do this?

Thanks.

Here's my collision code:

if (Tools.rectsIntersect(this, g_Ball)) {
      if (g_Ball.y < this.y || g_Ball.y > this.y) {
          g_Ball.yDirection = g_Ball.yDirection * -1;
      }
      else if (g_Ball.x < this.x || g_Ball.x > this.x) {
          g_Ball.xDirection = g_Ball.xDirection * -1;
      }
      this.destroyBlock();
}

Tools.rectsIntersect = function (obj1, obj2) {box
    var aRect = obj1.collideRect();
    var bRect = obj2.collideRect();
    return cc.rectIntersectsRect(aRect, bRect);
};


texts: Display image a couple seconds after an enemy spawns?

texts:
So right now I have enemies that spawn behind objects with a delay.

What I need is to display an image on the screen 5 seconds after each enemy spawns (it's to show the player it has been "attacked") and that image has to disappear after like 2 seconds so.

I know I have to use WaitForSeconds but I don't know how because everything I've tried isn't working.

Here's my code:

 public class TimedSpawn : MonoBehaviour {

     public GameObject spawnee;
     public bool stopSpawning;
     public float spawnTime;
     public float spawnDelay;

     // Use this for initialization
     void Start () {
         InvokeRepeating ("SpawnObject", spawnTime, spawnDelay);
     }

     public void SpawnObject (){
         Instantiate (spawnee, transform.position, transform.rotation);

         if (stopSpawning) {
             CancelInvoke ("SpawnObject");
         }
     }
 }


texts: How to get/set specific properties of a video texture in pixi.js?

texts:
I managed to get a video to play in Pixi using the following line:

    this._texture = PIXI.Texture.from(require("Images/video.mp4"));

The problem is that I can't find any properties to do things such as pausing it, forwarding/backwarding, adjusting volume, adjusting playing-speed etc.

Neither the PIXI.Texture or PIXI.Sprite seem to have any properties for this. Is this legitimately all the control PIXI gives you or am I missing something?


texts: Struggling to implement A* pathfinding execution

texts:
So I've implemented pathfinding to my game which works well with a tile based map. All tiles have an x & y integer coordinate for example the tile on the top left would be 0,0 the adjecent tiles would we 0,1; 1,0 and 1,1. My pathfinding returns a path based on these coordinates.

My game however is using float coordinates. So that an entity is basically able to stand on or between two tiles at the same time. For that  the tile coordinates are multiplied by 32 (the size of one tile). That means the first tile would be 32,32  and the adjecent tiles 64,32; 32,64; 64,64

My approach was to get a target X and Y from my pathfinding to calculate the next step and multiply it by 32. So if the entity is supposed to move to the top left for example the targetX and Y would be 1*32, 1*32.

After the targetX & targetY is set i'll increase or decrease the coordination of moving entity by its movementspeed, when it's reached its targetX & targetY i'll get the next step and to the same until no steps are left.

However I'm encountering various problems because it's not really possible to set an entity to a certain field because its possible to stand on two tiles at the same time and entities only have float coordinates. Especially when an entity is supposed to move around a narrow corner its getting stuck because of the offset between the pathfinding and the float coordinates of the entity.

I hope my problem became more or less clear, how could I deal with that or how is dealt with that problematic in general? I'm glad about any advices.

Edit: No diagonal movement is intended.


texts:
I'm using XNA to test an image analysis algorithm for a robot. I made a simple 3D world that has a grass, a robot, and white lines (that are represent the course). The image analysis algorithm is a modification of the Hough line detection algorithm.

I have the game render 2 camera views to a render target in memory. One camera is a top down view of the robot going around the course, and the second camera is the view from the robot's perspective as it moves along. I take the rendertarget of the robot camera and convert it to a Color[,] so that I can do image analysis on it.

private Color[,] TextureTo2DArray(Texture2D texture, Color[] colors1D, Color[,]   colors2D)
    {
        texture.GetData(colors1D);
        for (int x = 0; x < texture.Width; x++)
        {
            for (int y = 0; y < texture.Height; y++)
            {
                colors2D[x, y] = colors1D[x + (y * texture.Width)];
            }
        }

        return colors2D;
    }

I want to overlay the results of the image analysis on the robot camera view. The first part of the image analysis is finding the white pixels. When I find the white pixels I create a bool[,] array showing which pixels were white and which were black. Then I want to convert it back into a texture so that I can overlay on the robot view.

When I try to create the new texture showing which ones pixels were white, then the game goes super slow (around 10 hz).

Can you give me some pointers as to what to do to make the game go faster.
If I comment out this algorithm, then it goes back up to 60 hz.

private Texture2D GenerateTexturesFromBoolArray(bool[,] boolArray,Color[] colorMap, Texture2D textureToModify)
    {
        for(int i =0;i < screenWidth;i++)
        {
            for(int j =0;j<screenHeight;j++)
            {
                if (boolArray[i, j] == true)
                {
                    colorMap[i+(j*screenWidth)] = Color.Red;
                }
                else
                {
                    colorMap[i + (j * screenWidth)] = Color.Transparent;
                }
           }
    }

        textureToModify.SetData<Color>(colorMap);

        return textureToModify;
    }

Each Time I run draw, I must set the texture to null, so that I can modify it.

 public override void Draw(GameTime gameTime)
    {
        Vector2 topRightVector = ((SimulationMain)Game).spriteRectangleManager.topRightVector;
        Vector2 scaleFactor = ((SimulationMain)Game).config.scaleFactorScreenSizeToWindow;

        this.spriteBatch.Begin(); // Start the 2D drawing
        this.spriteBatch.Draw(this.textureFindWhite, topRightVector, null,
           Color.White, 0, Vector2.Zero, scaleFactor, SpriteEffects.None, 0);
        this.spriteBatch.End(); // Stop drawing.

        GraphicsDevice.Textures[0] = null;
    }

Thanks for the help,

Anthony G.


texts: Term for "Massively Multiscale world browsing"?

texts:
There is a type of multi-scale world browsing that has appeared in games in the last few years and I would be interested to know if there is a specific term that this browsing is known as and more importantly, if there are already specific patterns or techniques for implementing it.

I am referring to games like:

Universe Sandbox
EVE online
Startrek Armada
Heat Signature

The common characteristic of these games is that they allow you to zoom across an incredible range of scale from "item" all the way out to "galaxy" without (apparent) loss of synchronisation between what is happening at each scale. So, it looks like the world "advances" across all of these different scales simultaneously. Also, it is likely that each browsing level is a different visualisation type which is then blended seamlessly by matching the camera viewpoints and "cutting" from one level to the next but that might just be my perception.

What I am specifically interested to know would be:

If this technique has a name already (?)
If there is a ready made component (or pattern) that sorts out the architecture for achieving this kind of browsing (?)
If the "world" is really simulated at all levels (?)


texts: OpenGL 4.4 LWJGL - How can i render text to the screen

texts: I have been told that you need to create a texture atlas for the font, and individually assign each character to a texture and add them up to create the string you want to produce. This seems a little more difficult than it should be. Is there another way? If not there must be documentation or a library someone wrote to do this. Can someone help me out?


texts: Is component-based design an architectural pattern or design pattern?

texts:
When using the component-based paradigm in game development with engines like Unity, is component-based design an architectural pattern, or a design pattern?

Can I even say that component-based design is my "main" architectural pattern for my game?

I see architectural patterns as being more high-level than design pattern. The component-based design in game development's context (like with Unity engine) seems to fit as an architectural pattern to me. However, on some sites, I read that component-based design is a behavioural pattern, much like other behavioural design patterns, and not so much like an architectural pattern like MVC.


texts: How to implement time traveling into a game?

texts:
I was wondering how to implement time travel into a game. Nothing super complex, just time-reversal like what's in Braid, where the user can rewind/fast forward time by 30 seconds or whatever.

I searched around the web a lot, but my results usually referred to using time as in like "it's 3:00" or a timer and such.

The only thing I could think of was using 2 arrays, one for the player's x position and the other for the player's y position, and then iterating through those arrays and placing the character at that position as they rewind/fast forward time. Could that work? If it would work, how large would the array have to be and how often should I store the player's x and y? If it doesn't work, what else could I try?

Thanks in advance!


texts: How can I resize a set of sprite images?

texts:
Hey StackExchange GameDev community, I'm attempting to resize series of sprites upon instantiation of the class they're located in.

I've attempted to use the following code to resize the images, however my attempts have been unsuccessful. I have been unable to write an implementation that is even compilable, so no error codes yet.

    wLeft.getScaledInstance(wLeft.getWidth()*2, wLeft.getHeight()*2, Image.SCALE_FAST);

I've heard that Graphics2D is the best option.

Any suggestions?
I think I'm probably best off loading the images into a Java project, resizing the images then outputting them to a new directory so as not to have to resize each sprite upon class instantiation. What do you think?

Photoshopping each individual sprite is out of the question, unless I used a macro.

Code:

package game;

//Import
import java.awt.Image;
import javax.swing.ImageIcon;

public class Mario extends Human {
    Image wLeft = new ImageIcon("sprites\\mario\\wLeft.PNG").getImage();

 //Constructor
    public Mario(){
        super("Mario", 50);
        wLeft = wLeft.getScaledInstance(wLeft.getWidth()*2, wLeft.getHeight()*2, Image.SCALE_FAST);
    }


texts: libgdx+android: White screen after re-create() but not resume()

texts:
I have this weird issue only on android where if I push the home button, when I get back into the game it passes through resume() and it display by background texture correctly. But if I push the back button it destroy and when I get back it the game it calls create(), but it draws the background as a white texture instead.

I searched a bit on the subject and what I know so far:

Android static variables are not reinitialized on activity recreation, so you must make sure that create() will initialize those variables.
OpenGL will free the textures when the application loses focus, so this is why they must be reloaded when the application resume.

Unfortunately, even having this information in mind while programming did not fix the issue. I'll just show important portion of the code below:

// The asset manager is created statically, but not initialized
private static AssetManager _manager;

//Then during the create() and resume() method, the manager is initialized and all the
//textures will be loaded afterwards.
_manager = new AssetManager();

//When the app is destroyed, dispose() is called and the manager is nullified
_manager.dispose();
_manager = null;

So given the code above, if the application is destroyed or resumed, they will both pass into the same initialization method that creates the assets manager and load textures.

So why it only works on resume() and not on create() when the same code is actually called.

A quick fix that worked was something I found on this forum which consisted in killing the application on disposal with the following code in the android project:

//SOURCE: https://gamedev.stackexchange.com/questions/102079/screen-not-rendering-after-restarting-game
@Override
protected void onDestroy() {
    android.os.Process.killProcess(android.os.Process.myPid()); // this line will kill process
    super.onDestroy();
}

But I am not sure it is the right way to do things.


texts:
I am writing a small game and I need some help with my quaternions.

If I have an object at rotation A (quaternion)

And I need it to be at rotation B (quaternion) in 10 steps how would I work out the step change?

For normal vectors I would do C = (B - A) / 10
And then each step simply add C to my position to move from A to B in 10 steps.
I don't believe this would work for quaternions so how do I do this?

Also there would be an infinite number of routes that could be taken to get from A to B, so I would like to calculate this for the shortest route.

I did find this http://wasted.nz/posts.php?topic=82629
But if this is correct then how do you apply the difference to the current rotation? and could this difference be divided by 10 to get the step difference?

If it helps I am using C++, DirectX 11 and Bullet Physics


texts: Render a sphere when the user clicks on the screen with libgdx

texts:
I’m really new to Libgdx, and decided to try out some codes to familiarise myself with it. I’m trying to write a program such that a sphere is rendered at the position of the user’s click.

Here’s my code:

package com.mygdx.game;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.g3d.Environment;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
import com.badlogic.gdx.graphics.g3d.ModelInstance;
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute;
import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight;
import com.badlogic.gdx.graphics.g3d.Material;
import com.badlogic.gdx.graphics.g3d.utils.CameraInputController;
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.graphics.FPSLogger;

public class Render implements ApplicationListener {
    public Environment environment;
    public PerspectiveCamera cam;
    public CameraInputController camController;
    public ModelBatch modelBatch;
    private FPSLogger fps;

    public Model model;

    @Override
    public void create() {
        Gdx.graphics.setContinuousRendering(false);

        environment = new Environment();
        environment.set(new ColorAttribute(ColorAttribute.Specular, 0.4f, 0.4f, 0.4f, 0.6f));
        environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, 0f, 0f, -1f));

        modelBatch = new ModelBatch();

        cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        cam.position.set(0f, 0f, 10f);
        cam.lookAt(0,0,0);
        cam.near = 1f;
        cam.far = 300f;
        cam.update();

        ModelBuilder modelBuilder = new ModelBuilder();
        model = modelBuilder.createSphere(1f, 1f, 1f, 30, 30,
                new Material(), Usage.Position | Usage.Normal)
        camController = new CameraInputController(cam);
        Gdx.input.setInputProcessor(camController);
        fps = new FPSLogger();
    }

    @Override
    public void render() {

        if (Gdx.input.justTouched()){
            ModelInstance Instance = new ModelInstance (model);
             Instance.transform.setToTranslation(Gdx.input.getX(),Gdx.input.getY(), 0);
            DataBase.array.add(Instance);
            Gdx.graphics.requestRendering();
        }
        camController.update();

        Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

        modelBatch.begin(cam);
        for (ModelInstance instance: DataBase.array) {
            modelBatch.render(instance, environment);
        }
        modelBatch.end();

        //fps.log();
    }

    @Override
    public void dispose() {
        modelBatch.dispose();
        model.dispose();
    }

    @Override
    public void resize(int width, int height) {
    }

    @Override
    public void pause() {
    }

    @Override
    public void resume() {
    }
}

The DataBase.array is simply an ArrayList.

What am I doing wrong? Any help would be really appreciated; thanks!


texts: What are the basics in game architecture? How do you create your game skeleton such that it doesn't stay in your way?

texts:
There must be some best practices on how you create your game architecture/skeleton.
One of the best resources that I found is:
http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/
My primely focus is for iOS games using cocos2d.

What is your know how on this topic?


texts:
I'm having some trouble copying a subregion from a source texture (2D) to a destination texture.

Both textures are mipmapped 2D textures, with dimensions (at mip 0) of 512 x 32.

Rather than tell you about each parameter, it's easier to show you, according to the Visual Studio debugger, at the call site:

So, question 1: Is there anything wrong here that would cause CopySubresourceRegion to fail? There is nothing in the Debug window (the debug layer is enabled). The destination texture is a Staging resource with the CPU Read access flag.

If that seems okay to you, here's the rest of the question:

I'm making this call as part of a unit test, and attempting to read the data right out of the destination texture immediately after. If I replace the CopySubresourceRegion call with a CopyResource instead, the answer is wrong, but there is definitely data copied across. However, after making the call to CopySubresourceRegion and then using a Map/Read/Unmap chain, the data that comes back is all zeroes. The texel type is R32G32B32A32_FLOAT (or whatever it is).

I realise that the call is made asynchronously, so I added the following code between the copy and the read:

for (UINT i = 0U; i < numDeferredContexts; ++i) {
    CHECK_CALL(deferredContextPtrArr[i]->FinishCommandList(FALSE, &outCommandList));
    immediateContextPtr->ExecuteCommandList(outCommandList, FALSE);
}

And still, all zeroes. So I went one further, and changed it to the following (desperate) code:

for (UINT i = 0U; i < numDeferredContexts; ++i) {
    deferredContextPtrArr[i]->Flush();
    CHECK_CALL(deferredContextPtrArr[i]->FinishCommandList(FALSE, &outCommandList));
    immediateContextPtr->ExecuteCommandList(outCommandList, FALSE);
}
immediateContextPtr->Flush();
Sleep(10000);

But still nothing. Finally, I turned off the multithreaded rendering so it all executes on the immediate context, but even then, still zeroes.

So I'm totally stuck, and any ideas are appreciated: How can I make CopySubresourceRegion actually copy the data?


texts: In 3D camera math, calculate what Z depth is pixel unity for a given FOV

texts:
I am working in iOS and OpenGL ES 2.0.  Through trial and error I've figured out a frustum to where at a specific z depth pixels drawn are 1 to 1 with my source textures.  So 1 pixel in my texture is 1 pixel on the screen.  For 2d games this is good.  Of course it means that I also factor in things like the size of the quad and the size of the texture.

For example if my sprite is a quad 32x32 pixels.  The quad size is 3.2 units wide and tall.  And the texcoords are 32 / the size of the texture wide and tall.

Then the frustum is:

    matrixFrustum(-(float)backingWidth/frustumScale,(float)backingWidth/frustumScale,
                   -(float)backingHeight/frustumScale, (float)backingHeight/frustumScale, 40, 1000, mProjection);

Where frustumScale is 800 for a retina screen.  Then at a distance of 800 from camera the sprite is pixel for pixel the same as photoshop.

For 3d games sometimes I still want to be able to do this.  But depending on the scene I sometimes need the FOV to be different things.

I'm looking for a way to figure out what Z depth will achieve this same pixel unity for a given FOV.

For this my mProjection is set using:

    matrixPerspective(cameraFOV, near, far,  (float)backingWidth / (float)backingHeight, mProjection);

With testing I found that at an FOV of 45.0 a Z of 38.5 is very close to pixel unity.  And at an FOV of 30.0 a Z of 59.5 is about right.  But how can I calculate a value that is spot on?

Here's my matrixPerspecitve code:

void matrixPerspective(float angle, float near, float far, float aspect, mat4 m)
{
    //float size = near * tanf(angle / 360.0 * M_PI);
    float size = near * tanf(degreesToRadians(angle) / 2.0);
    float left = -size, right = size, bottom = -size / aspect, top = size / aspect;

    // Unused values in perspective formula.
    m[1] = m[2] = m[3] = m[4] = 0;
    m[6] = m[7] = m[12] = m[13] = m[15] = 0;

    // Perspective formula.
    m[0] = 2 * near / (right - left);
    m[5] = 2 * near / (top - bottom);
    m[8] = (right + left) / (right - left);
    m[9] = (top + bottom) / (top - bottom);
    m[10] = -(far + near) / (far - near);
    m[11] = -1;
    m[14] = -(2 * far * near) / (far - near);
}

And my mView is set using:

lookAtMatrix(cameraPos, camLookAt, camUpVector, mView);

* UPDATE *

I'm going to leave this here in case anyone has a different solution, can explain how they do it, or why this works.

This is what I figured out.  In my system I use a 10th scale unit to pixels on non-retina displays and a 20th scale on retina displays.  The iPhone is 640 pixels wide on retina and 320 pixels wide on non-retina (obsolete).  So if I want something to be the full screen width I divide by 20 to get the OpenGL unit width. Then divide that by 2 to get the left and right unit position.  Something 32 units wide centered on the screen goes from -16 to +16.  Believe it or not I have an excel spreadsheet do all this math for me and output all the vertex data for my sprite sheet.

It's an arbitrary thing I made up to do .1 units = 1 non-retina pixel or 2 retina pixels.  I could have made it .01 units = 2 pixels and someday I might switch to that.  But for now it's the other.  So the width of the screen in units is 32.0, and that means the left most pixel is at -16.0 and the right most is at 16.0.

After messing a bit I figured out that if I take the [0] value of an identity modelViewProjection matrix and multiply it by 16 I get the depth required to get 1:1 pixels.  I don't know why.  I don't know if the 16 is related to the screen size or just a lucky guess.  But I did a test where I placed a sprite at that calculated depth and varied the FOV through all the valid values and the object stays steady on screen with 1:1 pixels.  So now I'm just calculating the unityDepth that way.

If someone gives me a better answer I'll checkmark it.


texts: unity3d-Find angle between 3 vector3 points obtained from swipe

texts:
I was trying to find the angle between 3 vector3 points obtained from the screen swipe. The first vector3 point is the first touch position fp, the second is some intermediate touch ip and the third, the final touch position lp.

I tried the unity's Vector3.angle to get the angle but I was getting some angle even if I swiped in a straight line.
Here is what I tried

AB = ip-fp

BC= lp-ip

Then I applied Vector3.angle(AB, BC) but the result is not what I'm looking for.
Any solutions?


texts: Directx 12 Vertex buffer/shader question

texts:
Is there a way to process individual vertex that get pumped into the vertex shader.

I have a cube and pyramid.

I want to multiply a different worldviewproj matrix for the cube. So the first 8 vertex should be a differtent matrix.

Is is possible to do such a thing in the vertex shader?


texts:
I use this code in my GLSL vertex shader, where v_position is the vertex position:
gl_Position = v_position * u_camera;

and set u_camera as follows:
meshShader.setUniformMatrix("u_camera",
camera.view.mul(camera.projection).inv());

With the camera being an PerspectiveCamera of fov 45, width = aspect ratio and height = 1
This code is working when translating the camera over the z axis:
if (Gdx.input.isKeyPressed(Keys.W)) {
        camera.translate(0, 0, CAMERA_SPEED * Gdx.graphics.getDeltaTime());
} else if (Gdx.input.isKeyPressed(Keys.S)) {
        camera.translate(0, 0, -CAMERA_SPEED * Gdx.graphics.getDeltaTime());
}

But not when doing the same thing as above on the x axis, with the A or D keys.
The mesh (a triangle) looks like this before i press A or D
(Translating with W and S is fine)

But when translating over the X axis it it looks like this:

I don't know anything of matrix math, and I made this code experimenting with the various matrices of the Camera class
EDIT : This code  camera.projection.mul(camera.view.inv()) does a similiar thing


texts: Camera not staying behind model while moving in circle

texts:
I have a camera behind a model (3rd Person) and I'm having problems KEEPING it behind the model. When I first start my game, you see the back of the model. If the model moves forward, backward or strafe left or right, the camera moves along accordingly. When the model rotates (stationary), the camera rotates accordingly with the model still pointing at the model's back. So far, so good.

The problem comes when the player is BOTH moving and rotating at the same time. Take for example a model moving in a circular pattern like running around a track. As the model moves in this motion, the model rotates slightly more with each complete rotation. Eventually, instead of looking at the model's back, eventually you will see the model in a profile view and before you know it, the model's front is facing the camera. And when you stop moving the model, the model stays in that position.

So, as long as my model is stationary and rotating in one place, the camera rotates correctly. But as soon as there is any sort movement while rotating, the model is offset by a mysterious increasing amount. How can I keep the camera maintaining the same view no matter how I move AND rotate at the same time?

 // Rotates model and pitches camera on its own axis
    public void modelRotMovement(GamePadState pController)
    {
        /* For rotating the model left or right.
         * Camera maintains distance from model
         * throughout rotation and if model moves
         * to a new position.
         */

        Yaw = pController.ThumbSticks.Right.X * MathHelper.ToRadians(speedAngleMAX);
        AddRotation = Quaternion.CreateFromAxisAngle(Vector3.Up, yaw);
        //AddRotation = Quaternion.CreateFromYawPitchRoll(Yaw, 0, 0);
        ModelLoad.MRotation *= AddRotation;
        MOrientation = Matrix.CreateFromQuaternion(ModelLoad.MRotation);

        Pitch = pController.ThumbSticks.Right.Y * MathHelper.ToRadians(speedAngleMAX);
        AddPitch = Quaternion.CreateFromAxisAngle(Vector3.Up, pitch);
        ModelLoad.CRotation *= AddPitch;
        COrientation = Matrix.CreateFromQuaternion(ModelLoad.CRotation);
    }

// Orbit (yaw) Camera around model
    public void cameraYaw(float yaw)
    {
        Vector3 yawAngle = ModelLoad.CameraPos - ModelLoad.camTarget;
        Vector3 axisYaw = Vector3.Up;

        ModelLoad.CameraPos = Vector3.Transform(yawAngle,
            Matrix.CreateFromAxisAngle(axisYaw, yaw)) + ModelLoad.camTarget;
    }

    public void updateCamera()
    {
        cameraYaw(Yaw);
        cameraPitch(Pitch);
    }


texts: "Your license does not cover Android Publishing" error

texts:
I recently installed Unity 2017.1.0f3. I imported a project from an older version of Unity it worked perfectly and allowed me to build for Android. I logged in to the Asset Store through the tab in the Unity editor, now I can no longer build for Android.

This is the error I receive:

I created my Unity account before Android was free. Is there a way to update my account to allow me to build with Android again?


texts:
I'm making a simple bullet hell game but I can't figure out how to get my character to shoot. Lets say I have bulletBody and shipBody, how would I continually spawn bulletBodies using the shipBody coordinates. I've tried a function that uses an array of b2bodies and just assigns them the bodydef and fixture but that causes the game to crash. C++ sample code would be best but any help is appreciated.

EDIT: It looks like any reference to my b2World in a function will cause the game to crash. How do I declare the bodies without using a b2World as an argument in the function.


texts: Synchronized non-local CharacterController's velocity is stuck at the last movement in Unity3D

texts:
I have CharacterControllers as players in my multiplayer scene, and they got NetworkTransforms attached, with

Sync Mode = Sync Character Controller.

When I stop running with my character, my character stops on the other players' screens as well.

I've got MonoBehaviours attached to them, where I control the character's animations based on characterController.velocity.

The problem is this:

The animations won't stop because characterController.velocity is the same as it was when I was running.

This only occurs on non-local characters, because the local player got Local Player Authority checked, so its controller isn't synced from the server but to the server.

Why and how could I fix this?
Thanks in advance!


texts: Make my NPC "see" gameobjects around him in Unity

texts:
I have a walking NPC that will "see" the wall in front or behind him (2d gameplay) and that will react accordingly.

I was thinking to attach him to an invisible collider that would react to objects at collision, but I did not manage to do so, a collider seems to always go with a visible mesh.

How should I implement it, and how can I do it in Unity?


texts: Unity: how to position items into a Scroll View?

texts:
I'm trying to add items (prefab) into a Scroll View but either if I simply add items without set positions and trying to setting position it not work.

Case 1: without setting position

Result: All items overlapping

Case 2: forcing positions (like commented row code below)

Result: Items not overlapped but X position take the same value (that not is 0)

 for (int i = 0; i < rows.Length; i++)
 {
        GameObject newObj= Instantiate(MyRowPrefab);
        newObj.transform.SetParent(ScrollViewObject.transform, false);
        //newObj.transform.localPosition = new Vector3(0, (-1 * ((i * rowHeight))), 0);
        // If i decomment this line, X isn't set to zero... why ?
  }


texts: How to create projection/view matrix for hole in the monitor effect

texts:
Lets say I have my XNA app window that is sized at 640 x 480 pixels. Now lets say I have a cube model with its poly's facing in to make a room. This cube is sized 640 units wide by 480 units high by 480 units deep. Lets say the camera is somewhere in front of the box looking at it.

How can I set up the view and projection matrices such that the front edge of the box lines up exactly with the edges of the application window?

It seems like this should probably involve the Matrix.CreatePerspectiveOffCenter method, but I don't fully understand how the parameters translate on to the screen.

For reference, the end result will be something like Johhny Lee's wii head tracking demo:
http://www.youtube.com/watch?v=Jd3-eiid-Uw&feature=player_embedded

P.S. I realize that his source code is available, but I am afraid I haven't been able to make heads or tails out of it.


texts: Choosing frame rate in PyGame with keyboard input

texts:
Using PyGame, I want to create a moving square which moves in a grid, controlled by keyboard presses of the arrows. So, pressing the "up" key moves the square to the cell directly upwards, pressing the "right" key moves the square to the cell directly to the right, etc.

In my loop, I use pygame.time.wait(x), to pause for x ms. However, choosing the correct value for x is proving difficult. If x is too large (e.g. 1000), then the square does not respond immediately, and I actually have to hold down the key to get it to move. But if x is too small (e.g. 10), then the square will move several times in a row whenever I press a key. But I just want the square to move once for every key press. How can I do this? Thanks!

Below is the important part of my code:

    x = 100
    current_pos = [0, 0]

    while True:

        pygame.event.pump()  # process event queue
        is_key_pressed = pygame.key.get_pressed()

        if is_key_pressed[pygame.K_UP]:
            current_pos[1] -= 1

        elif is_key_pressed[pygame.K_RIGHT]:
            current_pos[0] += 1

        elif is_key_pressed[pygame.K_DOWN]:
            current_pos[1] += 1

        elif is_key_pressed[pygame.K_LEFT]:
            current_pos[0] -= 1

        show_map(current_pos)

        pygame.time.wait(x)


texts:
I have a vector (8,5). It's origin is at (10,9)

I can calculate a perpendicular like so:

MyPerpendicularVector.x = -MyVector.y
MyPerpendicularVector.y = MyVector.x

Given that I now know these two axis, how do I make these axis (made up of my new vectors) now my "local" axis? for example I want to plot a vector (2,3) on the "local" axis but I have no idea how to calculate it in relation to the "global" axis

Image of the problem here:


texts: Unity Animation Controller: Is the "atomic" attribute in 4.6.3 the same as the "has exit time" attribute in 5.0?

texts:
I'm viewing a tutorial based on Unity 5.0. In this version, I see an option whose name is: Has Exit Time:

But on my Unity, version 4.6.3, I don't have this option. Instead I have an option called Atomic.

My guess is that these options mean the same thing. That is, if this box is checked, then the controller should finish playing this state before moving to a new state. But I'm not sure here. If my guess is wrong, which option is equivalent to Has Exit Time in Unity 4.6.3 ?

Thanks :)


texts:
I have an animation of a character aiming a handgun 'straight', and firing a handgun from that straight pose. I want to have the character be able to aim up and down and fire from those poses too. Think Resident Evil 1/2/3, Alone in the dark, etc. I want to save time on my animator by not having him do the aim/up down.

I'm trying to find a way to dynamically achieve this effect from code. Do I have to write an IK solver system or is there a more straight-forward way to do it?

I'm pretty sure there's a technical name for this kind of thing, I Googled aim offset, aim target, lookat target etc but all I came up with was UE4 links. We're using our own engine.

Looking at UE4 'aim offset' it looks very similar to what I want. I wonder how it's implemented internally.

I'm not asking for code but just ideas, hints or pointers are appreciated.


texts:
Let's say that I have two threads.

Both of them generates and binds to a vbo separately.

If I join and run these threads the behavior will be undefined obviously.

Because one may generate the vbo and one may Bind the vbo.

So how do AAA games like doom resolve this problem.

I chose that game because it most likely to be run in multiple threads.
Thank you