texts: Version number not supported by gl2 in andengine

texts:
I am new to andengine. From various forums, i got to know that my system should support hardware virtulisation. I have installed "Intel X86" and my system didn't throw any problem regarding "HAX" now. But now i am getting error in logcat as follows

09-13 22:20:43.195: E/AndroidRuntime(1509): FATAL EXCEPTION: GLThread 83
09-13 22:20:43.195: E/AndroidRuntime(1509): org.andengine.opengl.shader.exception.ShaderProgramCompileException: Reason: ERROR: 0:1: '' :  Version number not supported by GL2
09-13 22:20:43.195: E/AndroidRuntime(1509): Source:
09-13 22:20:43.195: E/AndroidRuntime(1509): ##########################
09-13 22:20:43.195: E/AndroidRuntime(1509): uniform mat4 u_modelViewProjectionMatrix;
09-13 22:20:43.195: E/AndroidRuntime(1509): attribute vec4 a_position;
09-13 22:20:43.195: E/AndroidRuntime(1509): attribute vec2 a_textureCoordinates;
09-13 22:20:43.195: E/AndroidRuntime(1509): varying vec2 v_textureCoordinates;
09-13 22:20:43.195: E/AndroidRuntime(1509): void main() {
09-13 22:20:43.195: E/AndroidRuntime(1509):     v_textureCoordinates = a_textureCoordinates;
09-13 22:20:43.195: E/AndroidRuntime(1509):     gl_Position = u_modelViewProjectionMatrix * a_position;
09-13 22:20:43.195: E/AndroidRuntime(1509): }
09-13 22:20:43.195: E/AndroidRuntime(1509): ##########################
09-13 22:20:43.195: E/AndroidRuntime(1509):     at org.andengine.opengl.shader.ShaderProgram.compileShader(ShaderProgram.java:187)
09-13 22:20:43.195: E/AndroidRuntime(1509):     at org.andengine.opengl.shader.ShaderProgram.compile(ShaderProgram.java:143)
09-13 22:20:43.195: E/AndroidRuntime(1509):     at org.andengine.opengl.shader.ShaderProgram.bind(ShaderProgram.java:122)
09-13 22:20:43.195: E/AndroidRuntime(1509):     at org.andengine.opengl.shader.PositionTextureCoordinatesShaderProgram.bind(PositionTextureCoordinatesShaderProgram.java:86)
09-13 22:20:43.195: E/AndroidRuntime(1509):     at org.andengine.opengl.vbo.VertexBufferObject.bind(VertexBufferObject.java:162)
09-13 22:20:43.195: E/AndroidRuntime(1509):     at org.andengine.opengl.texture.TextureWarmUpVertexBufferObject.warmup(TextureWarmUpVertexBufferObject.java:97)
09-13 22:20:43.195: E/AndroidRuntime(1509):     at org.andengine.opengl.texture.TextureManager.updateTextures(TextureManager.java:257)
09-13 22:20:43.195: E/AndroidRuntime(1509):     at org.andengine.engine.Engine.onDrawFrame(Engine.java:613)
09-13 22:20:43.195: E/AndroidRuntime(1509):     at org.andengine.opengl.view.EngineRenderer.onDrawFrame(EngineRenderer.java:105)
09-13 22:20:43.195: E/AndroidRuntime(1509):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
09-13 22:20:43.195: E/AndroidRuntime(1509):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)
09-13 22:20:43.275: E/OpenGLRenderer(1509): Error while compiling shader: ERROR: 0:1: '' :  Version number not supported by GL2
09-13 22:20:43.304: E/OpenGLRenderer(1509): Error while compiling shader: ERROR: 0:1: '' :  Version number not supported by GL2

I am getting similar kind of error when i tried to execute my program in BlueStacks and my application gets crashed. Pls help me regarding this. Thanks in advance


texts: Can I extract Flash SWF sprite frames to bitmaps?

texts:
I want to create the 2D graphics of my game in Flash Studio, but then get all the frames from my SWF movies into C# for further work in Unity3D.

I find it easier to create nice smooth animations in Flash Studio. But then I also want the performance Unity gives and the multi-platform support as well.

How can I do this?


texts:
I am developing a 2D game using Cocos2d-X in C++ language. In my game, I need to implement train movement.

Here is the image about the output I want to achieve:

I tried to do the above moment using Actions from Cocos2d-X. However on the curved part of the tracks, the train movement is not accurate.

I  have following questions:

Is there a right method to create the train movement using Actions? If not, which alternate methods or algorithm can be used?
I wanted to achieve train movement similar to the game Mini Metro. How to create such train movement in Cocos2D-X?

I would appreciate any suggestions/thoughts on this topic.


texts: How can I create procedurally placed points in an infinite world?

texts:
My issue is that I need to create consistently placed points in an open world. This means that optimally, I would have some function that takes an area as an input and outputs all the points that exist in that area. It would also be great if it was possible to specify the minimum distance between points.

Something like the following would be great:

What is a good way to achieve this?


texts: In what order should collisions be resolved?

texts: I am creating my 2D game engine and I need to know if I should first move all objects and then resolve collisions with all objects or I should move and resolve collision one by one objects.


texts: What units is Box2d-AndEngine's velocity measured in?

texts:
I'm developing a game on AndEngine (with Box2d) and on iOS Sprite Kit simultaneously. I want the game's physics to be identical on both platforms. Sprite Kit uses Box2d internally for physics simulation and I'm using Box2d-AndEngine to use it in AndEngine.

In Sprite Kit, I use physicsBody.velocity.
In AndEngine's Box2d, I use body.SetLinearVelocity(x,y).

In Sprite Kit, a physics body's velocity vector is measured in meters per second.

What is the corresponding unit of SetLinearVelocity in Box2d-AndEngine?


texts:
I want to create a 3 dimensional car game. But i have a problem in moving a car in other directions and accelerating.

I have a car model and a road model placed appropriately. To move car forward, I translate the road model to negative X-axis so my car looks like it moving forward in my case as my car and road track is along the positive X-axis. Now, in the middle I want to turn left or right and for that I rotate the road model, (let's 90 degree). When I do that the car should move away from the road in sideways direction (or, we can say road to be moved), but it does not. As road was being translated to negative x-axis, after rotating the road I thought to be translated along negative x-axis relative the camera but I think the X-axis of the road object is fixed. So what should I do to solve it?

I just want to move a car which can go forward and when it turns left or right it should move forward accordingly.

P.S. I know, my question may not be clear but that's all I could elaborate it. Anyone can notify me if it's not clear and I will try again to clarify my question again.


texts: How to download material files (including shaders) from external source on runtime?

texts:
My game has a lot of different materials, shaders and textures. When a bunch of players are dropped into the same game, I want those assets to be loaded from an external source instead of being built into the game from the start.

Problem is, with C# being such a non-agile language, and UnityWebRequest being unable to read .mat or .shader from the box, I don't know how to work with those files.

Ideally, I just want to write:

UnityWebRequest req = UnityWebRequest.Get("http://pathToMaterials/material.mat");

Material material = req.downloadHandler;

Or something...


texts: How well do functional languages perform on Android?

texts:
This is a special case of this question that I feel is particularly pertinent.

I'm working on a game for Android, and I'm planning on using Scala with libgdx.  I'm planning on making a performant game, but not necessarily hyper-performant game.  I saw libgdx's documentation on Garbage Collection, and this makes me think:

Functional programming implies lots of immutable objects.
Therefore, mutating an object requires making a new object.
Thus, lots of objects get garbage collected, which degrades performance.

Is this an insurmountable problem?  Are there any other significant problems with functional style on Android?


texts:
I need some ideas in order to finish algorithm. I'm randomly placing objects (bitmaps) on canvas without overlapping. Time needed to finish it is my problem. When I need to spawn for example 80% of canvas it takes to long. So i was thinking : I should make some change when the bitmaps take off 50 % of canvas. I want to tell algorithm that it should generate new locations (x,y) where it is free space.

My question is : How to render new location (x,y) in place where is free space.

In summary:

Things I know :

object location (x,y)
4 corners (x,y) of object
object width, height
canvas width, height

Any suggestions?

Thanks for ideas. Now I've got problem.

OK, thanks for ideas. I've got a problem.

Link to picture: Picture with grid

I'm incrementing number of objects in cell after each adding object to grid. In the picture there are 9 possible locations for object.  Should I check 9 conditions which tells where I should increment number of objects in cell? I assume that if object is on both cells than I increment number of objects in both cells.


texts: How to package a Unity Asset that depends on Addressables?

texts:
I'm creating a Unity Asset that I would like to publish on the Unity Store. However, this asset depends on the Addressables package and obviously require an Addressable Database which lives in a folder called AddressableAssetsData in the root directory of the Unity project.

If I don't include this in my package, the Asset won't work and if I do include it, it could conflict with the existing AddressableAssetsData of the user who install my package.

Is it possible to move AddressableAssetsData to a sub-folder of my own package or somehow configure it to not conflict with any future user AddressableAssetsData structures from another user? What would you suggest?


texts:
I am having a hard time understanding how to go about this. I have a 2D game with some 3D models in it. I want to move a 3D model to where the mouse cursor is currently at in every frame (In other words, center a 3D model in a specific Point(x,y)).

This is my drawing code to position the model in the center of the screen:

Matrix[] transforms = new Matrix[Model.Bones.Count];
Model.CopyAbsoluteBoneTransformsTo(transforms);
ModelMesh mesh = Model.Meshes[0];
BasicEffect effect = (BasicEffect)mesh.Effects[0];
Vector3 modelPosition = new Vector3(0, 0, 0);

effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
    aspectRatio, 1.0f, 10000.0f);
effect.EnableDefaultLighting();
effect.World = transforms[mesh.ParentBone.Index] *
    Matrix.CreateTranslation(modelPosition);

    mesh.Draw();

I suppose I would need a formula to convert the (camera position,model position, aspect ratio, field of view) into pixels ? Does anyone know how it works ?


texts: How can I create a custom MeshCollider for my object, or fix my collision problem?

texts:
I have a problem with collisions in Unity and I am unsure how to fix it.

I have an octree with a depth of 2, and each node in the tree has a Bounds object attached to it for collisions. I am trying to see which nodes have been intersected by a specific object however it is giving me unexpected results.

The colliding object is a flat triangle that I have constructed myself which is acting as a cutting plane and I have attached a MeshCollider component to the GameObject.

When there is an intersection with a leaf node in the octree, the node is outlined in yellow and if there is no intersection, it is outlined in purple.

Before rotation

After rotation
In this image I rotated the triangle a small amount on the Y axis and apparently Unity found a collision even though the objects are not even touching at all.

I am drawing the octree nodes using Gizmos.DrawWireCube, providing the center and size of the cube which are used to create the Bounds object of the node. Due to this it seems that the Bounds object for the nodes are correct, however the collider for the triangle may be incorrect.

When I test this with another 3D object such as a cube, it works perfectly, however not with the object I need it to work with. How can I fix this issue?

Collision checking code:

       public bool intersects(Bounds otherBounds)
        {
//bounds refers to the node's Bounds object
//otherBounds is the one I'm checking against, in this case the triangle's bounds from the MeshCollider
            if (otherBounds.Intersects(bounds))
            {
                return true;
            }
            return false;
        }

Octree traversal:

 if (node.intersects(triangleCollider.bounds))
        {

            if (node.isLeaf())
            {
                node.colour = Color.yellow;
            }

            if (node.hasChildren)
            {
                for (int i = 0; i < node.children.Length; i++)
                {
                    findIntersections(node.children[i]);
                }
            }
        }

It seems that perhaps a quad is being wrapped around the triangle as can be seen in the image below. This image has a triangle which is intersecting the top half of the octree, however the top left octant should have no collision.

How can I create a custom MeshCollider which I can specify the vertices manually?

See accepted answer for solution

int cutterMask = 1 << 9;
Collider[] intersectedColliders = Physics.OverlapBox(node.bounds.center, node.bounds.extents, Quaternion.identity, cutterMask, QueryTriggerInteraction.UseGlobal);


texts: What are some good methods of implementing RTS-style Box selection?

texts: I'm scouting around for different methods of implementing a typical RTS box selection. This is for 3D game - so I'm looking for methods for finding units within selection box in 3D world. Here is a quick screenshot of what a box selection looks like in 2D Starcraft:


texts: Optimal batching for 2D objects with transparency

texts:
I have a collection of 2d objects with transparency. Each object has a depth value to determine draw order and a material. I'm trying to batch them in an optimal way to minimize draw calls. Assume that objects with the same material can be batched together in a single draw call.

A naive way of batching is to sort all objects by depth first, then sort by material if the depth values are the same. Consider the following set of objects with 'z' representing depth and the color of the object representing its material. In the right set, blue objects have been translated along x such that they don't overlap with red.

Sorting by [depth,material] results in the sorted object list:
{ Red, Blue, Red, Blue } for both the left and right set of objects. Either left or right would result in 4 draw calls (objects of the same material need to be adjacent in the sorted list to be batched)

However if you look at the objects on the right, its clear you can use two draw calls because there's no overlap. The ordering based on depth doesn't matter if the blue and red objects don't overlap in between a given batch's depth range. This would also hold true if you had a red object with (z > 4) or (z < 2) anywhere in the right set.

So, assuming each object has a material that can be compared, a depth value, and a bounding box (lets say each object is an axis aligned quad), what is an efficient way to get a list of draw objects with both a correct ordering for transparency and optimal groupings based on material?

Also just to note, I don't have instancing support so that's not an option here.


texts:
Background

I'm using a texture as a damage map represented by an array of floats for displaying damage effects on a space ship in a process.

An upside of this is being able to 'slice' ships in half, using an input damage map with a line down the middle, as shown in the diagram below.

Question

However, I'm encountering problems separating this split ship into two different entities. I would like to be able to split the image down the 'damage line', in a process similar to this:

I don't have much idea where to start detecting the red line above. Any advice would be welcome.


texts: load scene - some time (2 seconds) after object is destroyed in Unity

texts:
How do I check if an object has been destroyed. And do something like change scenes 2 seconds later.

this is what I tried:

float delay = 2

void OnDestroy(){

 delay-= Time.deltaTime;
 if(delay<=0){
   Application.LoadLevel("scene2");
  }
}


texts:
I know this isn't exactly C++ related, however, I was just wondering if anyone knew anything about texture mapping onto a raycaster. I'm currently trying to write my own and I'm struggling to map textures onto the walls. I know what it's doing since it's mapping the texture per ray instead of per wall, but I'm not sure how to fix it. Here's the code:
The code for the walls
void Draw3DScene()
{
  sf::Color color;
  sf::Texture texture;
  sf::Sprite sprite;

  for(int i = 0; i < NUM_OF_RAYS; i+= constant)
  {
    float correctedDistance = rays[i].totalDistance * cos(rays[i].angle - player.angle);

    float wallHeight = (TILE_SIZE / correctedDistance) * projectionPlane;

    int wallTop = (WINDOW_HEIGHT / 2) - (wallHeight / 2);
    if(wallTop < 0)
    wallTop = 0;

    int wallBottom = (WINDOW_HEIGHT / 2) + (wallHeight / 2);
    if(wallBottom > WINDOW_HEIGHT)
      wallBottom = WINDOW_HEIGHT;

    if(rays[i].wallContent == 1)
    {
      color = sf::Color::White;
      texture = texture_t[0].myTexture;
      if(rays[i].wasHitVertical == true)
      color = sf::Color(150,150,150);
    }
    if(rays[i].wallContent == 2)
    {
      color = sf::Color::Red;
      texture = texture_t[1].myTexture;
      if(rays[i].wasHitVertical == true)
      color = sf::Color(150,0,0);
    }
    if(rays[i].wallContent == 3)
    {
      color = sf::Color::Blue;
      texture = texture_t[2].myTexture;
      if(rays[i].wasHitVertical == true)
      color = sf::Color(0,0,150);
    }
    if(rays[i].wallContent == 4)
    {
      color = sf::Color::Yellow;
      texture = texture_t[3].myTexture;
      if(rays[i].wasHitVertical == true)
      color = sf::Color(150,150,0);
    }

    DrawLineWithColor(&gameWindow, sf::Vector2f(i, wallTop),  sf::Vector2f(i, wallBottom), sf::Vector2f(i + 32,wallBottom), sf::Vector2f(i + 32, wallTop), color);

    DrawTexture(sf::Vector2f(i, wallTop), sf::Vector2f(i, wallBottom), sf::Vector2f(i + 1, wallBottom), sf::Vector2f(i + 1, wallTop), texture);

  }
}

//The code for drawing the textures
void DrawTexture(sf::Vector2f point1, sf::Vector2f point2, sf::Vector2f point3, sf::Vector2f point4, sf::Texture texture)
{
  sf::VertexArray vertices(sf::Quads, 4);
  vertices[0].position = point1;
  vertices[1].position = point2;
  vertices[2].position = point3;
  vertices[3].position = point4;

  //Test

  vertices[0].texCoords = sf::Vector2f(0,0);
  vertices[1].texCoords = sf::Vector2f(0,TEXTURE_HEIGHT);
  vertices[2].texCoords = sf::Vector2f(TEXTURE_WIDTH,TEXTURE_HEIGHT);
  vertices[3].texCoords = sf::Vector2f(TEXTURE_WIDTH,0);
  gameWindow.draw(vertices, &texture);
}

I got the images from this site https://lodev.org/cgtutor/raycasting.html
Let me know if you want the whole code instead of just snippets.

This is what it looks like when I'm far back enough. If I get closer to the wall, the image becomes more distorted so to say. The thing is, the texture is being drawn per ray instead of per wall.
I apologize if I was being too vague with my question.


texts:
Okey, what I know so far;
The entity contains a component(data-storage) which holds information like;
 - Texture/sprite
 - Shader
 - etc

And then I have a renderer system which draws all this. But what I don't understand is how the renderer should be designed. Should I have one component for each "visual type". One component without shader, one with shader, etc?

Just need some input on whats the "correct way" to do this. Tips and pitfalls to watch out for.


texts: OpenGL ES texture rendered not as expected with disproportional aspect ratio triangles

texts:
I cannot seem to understand how texture coordinates work.
I try to render a texture into two triangles and this is what I get

Where the expected output is a normal continuous image as you can imagine.

Triangles coordinates (where w = 1080, h = 1920):

0, 0, w, 0, 0, h,
w, 0, 0, h, w, h

Texture coordinates

0, 1, 1, 1, 0, 0,
1, 1, 1, 0, 0, 0

Texture parameters

gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE);

gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);

gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);


texts:
Using a tutorial found on the AppHub, I've been attempted to add controls to a sample sprite sheet. I am able to get all the animations working, but for stuff like punching or stabbing, the animations require a timer to stop them from playing repeatedly. XNA uses a default framerate of 60, but I have the animations running at 10 FPS using the following code:

int punchIndex = walk.GetIndex("obj_Walk000");

punchIndex += (int)(time * animationFPS) % punchFC;
batch.Draw(punch.Texture, position, punch.SourceRectangle(punchIndex), Color.White, rotation, origin, 1.0f, SpriteEffects.FlipHorizontally, 1.0f);
break;

Where animationFPS = 10 and punchFC is 6, which is the number of frames in the animation. Using this data, I have calculated a required time of 0.5 seconds for the animation to complete, but that seems to be incorrect, so I'm looking for someone to show me how to do the math properly.


texts:
when I press back button on android, it exits the game although I ask it to go to other screen instead. It goes to the other screen for one or two seconds then it exits.:

if((Gdx.input.isKeyPressed(Input.Keys.BACK)))
    game.setScreen(new GameOverScreen(game,4));


texts: should my static class be derived from UnityEngine.MonoBehaviour instead?

texts:
I am working on creating an object to maintain state of the game, player data, etc.  It is static (singleton lifecyle) through the life of my game.

I started down the path of a static class, with a static instance, like this:

public class PlayerState
{
    private static PlayerState DATA_INSTANCE = new PlayerState();
    public static PlayerState Instance
    {
        get { return DATA_INSTANCE;  }
    }
}

Then I started looking around and I see implementations that derive from UnityEngine.MonoBehaviour and implement the instance handling differently, adding the script to a game object and using DontDestroyOnLoad() to ensure it stays in memory.

So I am wondering: what is the correct idiomatic pattern in unity for a singleton type?

Do I really need all of the unity functionality of a UnityEngine.MonoBehaviour derived type (eg: Update()) for my static type?

I admit I am uneasy about static classes, in general.  In this case, I am equally uneasy adding another type that potentially gets in the frame cycle when its not needed (I mean that unity will call the methods like  Update() for every cycle).

Thnx
Matt


texts: Fixing T-Junction artifacts in a BSP Editor

texts:
I'm starting a little BSP engine, and have begun implementing Brush CSG.  Currently I represent my brushes as the enclosed volume of surface planes (like old idTech 3 maps), with a cache for each face that is generated on rendering the brush for the first time.

Now, I subtract a cube from another cube to cut a hole into it, yielding 5 brushes. Instantly, t-junctions! As you can see below, visible cracks appear:

This isn't particularly surprising, and obviously moving onto the BSP compilation process I will have to fix up all the t-junctions in the scene. However, I notice that in e.g. GtkRadiant, if I perform the same operation, these artifacts don't show up (or at least, I don't notice them), despite the fact the new brushes ARE separate and can even be moved apart and back together in the scene.

How do I remove this rendering issue at map design time?


texts: Execute a function for ten seconds and disable it for two seconds

texts:
I have a particular function which I am calling in Update function.
For the first ten seconds, the function should get called in Update function, then it should get disabled for next two seconds, then again enable it for next ten seconds. This cycle should keep repeating? How can I execute it?


texts: What's a good way to programmatically manage a cloneable entity?

texts:
Say you have missiles or rockets that a player can fire.

What's a good way to programmatically manage the cloning of a base rocket, for example?

I can think of 2 ways to do it:

Player has a currently selected weapon (which is an int)
When player shoots, the selectedWeapon member is looked at, and the correct instance of rocket is created (with some base parameters)

Or

Player has a currently selected weapon (which is a pointer, to a "base instance" of the rocket object)
When player shoots, the base instance rocket is cloned, transformed, and shot into the game world


texts: What is an easy way to have sprites collide and react to the collision? E.g. if I'm writing a game in XNA or with Canvas 2D and need to write the code myself very simply.


texts: Cant make animation play continuously in Unity?

texts:
Alright, I have posted to Unity as well and watched tutorials but I am unable to make a walk animation work code wise. I have a complex problem being that in my game the user taps to move, thus the character is either idling, walking just one step at a time or walking continuously. So far I transition from idle to walking (in just individual steps, meaning the user isn't tapping repeatedly) with this setup and this code, and it works well -

I have an idle state and the walking clip, and the transition between the 2 is a bool "isWalking" that is either true or false.

I cannot merely trigger the walk animation without an offset because I have to alternate between left and right steps, so I use an increasing offset that (I think I did it right) should move through the whole animation, depending on if the object is moving:

     if (animOffset >= 1f) { //was full clip
                 animOffset = 0.0f;
             }

             //anim help
             currentPos = transform.position;

         if (currentPos != lastPos) {
             //print ("moving now");
             animator.SetBool ("isWalking", true);
             if (InputManager.stepCount % 2 != 0) {
                 print ("moving right");
                 animator.SetFloat ("walkOffset",animOffset);

             } else {
                 print ("moving left");
                 animator.SetFloat ("walkOffset",animOffset);

             }
             animOffset += 0.1f;
         } else {
             animator.SetBool ("isWalking", false);
         }
         lastPos = currentPos;

When the user taps repeatedly however, the animation SHOULD not start over again from its offset in individual steps - it should just play the animation for the duration of its movement. Problem is using this if I watch the blue bar on the animation states, it ALWAYS starts from the beginning if I keep a consecutive step count and set the offset to 0.0.

With just this, the walking is very glitchy if its not in individual steps as its starting again and again. Im new to animation - how can I do this?

How can I make sure an animation plays CONTINUOUSLY if the object is moving without stopping for too long? I have no idea how to do this


texts: How does a general Renderer::drawRect(0, 0, 100, 100) handle VBO's?

texts:
Lots of game engines and GUI systems have a general Renderer class with functions like:

renderer.drawRect(0, 0, 100, 100);
renderer.drawText(204, 452, "Hello, world!");

I understand how this could easily be done in old immediate-mode OpenGL 2.1, but now that VBO's are the norm, could someone explain how these renderers work internally? They surely aren't creating and deleting a VBO quad everytime drawRect() is called, right?

Keeping one VBO and updating the vertex data is out of the question, as it would be cool to set a different shader, texture or colour in between the drawRect() calls.

Is instancing a (0, 0, 1, 1) rect and then scaling up the way to go?

Any pointers?


texts: Size of .skp gets doubled after importing to Unity

texts:
I have created a 3D model in SketchUp, and it is about 1.6Mb in size. After importing it to Unity, the size more than doubled to 4Mb.

Why is that?


texts: How can I make a ball accelerate while moving down?

texts:
I am making a super monkey ball game.

I want my ball to gain velocity while rolling downwards infinitely, and I cannot find any solution to this on Google. I'm new with c# so I am having a hard time creating this code on my own, can anybody help me achieve this?

I figured the question is simple enough not to require a picture or file. In layman's terms, I want the ball to roll faster and faster while as it rolls down a slope.

I am using Unities rigidboody, which adds velocity while to falling speed, but does not add velocity to rolling speed

I decided to test it with a steeper slope and it seems the rotational velocity worked, however I cant have the game have this difficulty, as the slope has to be very steep for the angular velocity to work properly. I have no angular or normal drag, so is there a way to change the slope the ball has to be rolling at for velocity to work? Or is unities rigidbody just not very good for a game like this.


texts: How do I undo changing the color of an image in Slick2d?

texts:
This code colors the enemy red:

enemies.get(i).image.setColor(0,1,0,0,1);
enemies.get(i).image.setColor(1,1,0,0,1);
enemies.get(i).image.setColor(2,1,0,0,1);
enemies.get(i).image.setColor(3,1,0,0,1);

if I set it to:
enemies.get(i).image.setColor(0,0,0,0,1);
it turns it pure black, and if I set it to
enemies.get(i).image.setColor(0,0,0,0,0);
it turns the enemy invisiable

How do I un-color enemy red? as in return to state as it was before it was colored.

Documentation link.


texts: Isometric coordinate maths not quite right

texts:
I have written two functions, screenToCoords and coordsToScreen.

Screen being the coordinates on screen.

Coords being isometric coordinates.

So here are my functions:

Screen to isometric:

Vector2 TileMap::screenToCoords(Vector2 coords){
    coords.x -= offset.x;
    coords.y -= offset.y;
    Vector2 newCoords;
    newCoords.x = (coords.x / (TILE_WIDTH/2) + coords.y / (TILE_HEIGHT/2)) /2;
    newCoords.y = (coords.y / (TILE_HEIGHT/2) - (coords.x / (TILE_WIDTH/2))) /2;
    return newCoords;
}

Isometric to screen:

Vector2 TileMap::coordsToScreen(Vector2 coords){
    Vector2 newCoords;
    newCoords.x = (coords.x - coords.y) * (TILE_WIDTH/2) + offset.x;
    newCoords.y = (coords.x + coords.y) * (TILE_HEIGHT/2) + offset.y;
    return newCoords;
}

And these seem to work totally fine, except when dealing with mouse coordinates, as you can see here:

I can't figure out what the issue is.

Basically what's happening in this image is that I'm converting mouse coordinates into isometric coordinates, then back into screen coordinates so that I can render that highlight box.


texts: What is the performance impact of rendering a larger quad?

texts:
Lets say I have two planes and I textured them in blender with a 512*512 tiled texture. One plane is bigger than the other (for example, one plane tiles the texture 60 times but another only six times). I've import the planes in to Unity and assign that same 512*512 texture to them.

What is the difference in performance in-game? Because both of those objects use one draw call and same 512*512 texture, therefore same texture space, so what is the difference in performance?


texts: ArmA 3 Scripting: Delete vehicle depending on present players

texts:
I'm fairly new to ArmA 3 scripting, and I'd like to know how to only spawn starting vehicles depending on how many players opt in to the mission. Say, the mission has four slots, but only two people fill them. There would be four vehicles, but two would be deleted on the mission start because those players weren't present. I've tried putting this code in the initialization of each vehicle;

sleep 1; if (isNull unit1) then {deleteVehicle this} else {};

But it only gives me errors when the mission starts.


texts:
I have BIM model that I am using in 2018 version of Unity engine. When import the model into my project on 2019 OR 2020 version of the Unity engine, clippings on certain surfaces of the model occurs.
Has anyone encountered this issue with Unity 2020? Any solutions that can be suggested for me to try?
Examples attached.
Appreciate any help in advance...


texts: How is collision detection and movement typically handled in a FPS, particularly handling slight changes in ground height such as stairs (both on incline and decline)?


texts: How to iterate a sprite group correctly in Pygame avoiding "maximum recursion depth exceeded"?

texts:
I'm making a game and I have almost finished it, but I'm usually finding the error RuntimeError: maximum recursion depth exceeded when I iterate a sprite group.

This is an example and the group is self.nextStageCollision():

def nextStageCollision(self):
    for tile in self.nextStageCollision():
        if tile.rect.colliderect(self.rect):
            self.rect.x = 18*20
            self.rect.y = 20*20
            return True

    return False

The group self.nextStageCollision() has 4 sprites (tiles) and I'm checking collision between my player and those 4 tiles to go to the next stage but I have to be doing something wrong iterating the sprite group because (I don't know why) it becomes recursive and raises the maximum recursion depth runtime error. I've debugged it and when it reaches the for each line, it loops a lot of times there (althought there are only 4 sprites in that group).

I know I can increase the recursion depth, but probably it's better to not play with that and try to improve the code. So, what am I doing wrong? Is there another better way to interate a sprite group to check collisions?


texts: MonoGame deltaTime isn't the same in Draw function as in Update function

texts:
In the Update function gameTime.elapsedGameTime.TotalSeconds always gives me 0.01666666667 which is the deltaTime value for 60 FPS, no matter if the FPS is 30 it always shows me 0.01666666667 but the Draw function on the other hand shows 0.03333333333 if the FPS is 30.

Is this a bug or is this how it is meant to be? Should I just create a variable called deltaTime and make it equal to gameTime.elapsedGameTime.TotalSeconds in the Draw function? Maybe this is a problem on Macs only

(I'm on a mac and I'm using Xamarin Studio MonoMac to build the project)


texts:
How do I create a scrolling X and scrolling Y background without weird things happening like the player disappearing or not getting the offset correct?

I have code at https://vanillity.kilnhg.com/Code/Repositories/Group/Aremac

Looks like this:

      var s = game.gd.Viewport.Bounds;
      var g = game.world.Bounds;
      var p = game.player.Bounds;
      var v = viewRectangle;

      var x = p.X  0 ? p.X - s.Width/2 :
              v.Right >= 1090 ?  90 :
              p.X > s.Width/2    ? p.X - s.Width/2 :
              0;

      var y = //v.Bottom >
              p.Y > s.Height/2 ? p.Y - s.Height/2:
              0;

      var w = s.Width;
      var h = s.Height;

      //view Rectangle
      Offset        = new Vector2(x , y);
      viewRectangle = new Rectangle( x, y ,w, h);

and then:

     //source rectangle
     var x = (int)0;
     var y = (int)0;
     var g = game.world.Bounds;
     var w = g.Width;
     var h = g.Height;
     var rect =  new Rectangle(x,y,w,h);

      spriteBatch.Draw(  w.boundsTexture
                        ,rect
                        ,viewRectangle
                        ,w.Color
                        ,0
                        ,Vector2.Zero
                        ,SpriteEffects.None
                        ,1
                        );

Before center, the grey guy is holding the rock in his left hand:

After center, the rock (and the white guy) drifts evermore to the right:


texts: How can I draw an animated vector field on a map?

texts: I want to render an animated vector field map similar to this wind speed visualization. How can I do this?


texts: Get all supported resolutions for a monitor

texts:
I've been receiving complaints from users that my game doesn't support the 16:10 aspect ratio.
Currently I list everything in Screen.resolutions in a dropdown and allow the user to pick from that. I have since come to the understanding that the first element is not necessarily the native resolution of the monitor.
I've found the Display class but this appears to only give the native resolution, not all scaled resolutions. E.g. if the monitor is 1920x1080 then I need a list of 1600x900, 1280x720, 640x360 etc.
I thought about just multiplying by some scale factor but then I'm afraid I'll get something obscure like 885x497.8. And if I have a pre determined list of resolutions for a specific aspect ratio, how do I support obscure aspect ratios like widescreen for example.


texts: How to disable collider2D when another gameobject is on top of it

texts:
Each black colored square has a BoxCollider2D. How can I disable the collider after I put another game object on top of it?

Here is the sample output:


texts: How can I find the difference between rotations represented as angles in [0, 360]?

texts:
What is the easiest way to find the difference between two 2D rotations/directions?

I want to test if one rotation is within 10° of another. I would just subtract, but there are some problems because I want to keep each rotation between 0 and 359. E.g. 0 is within 10° of 359, but simple subtraction would claim that they're 359 degrees apart.


texts: How can I unpack a sprite sheet into multiple images?

texts:
I need to take a sprite sheet and convert it into multiple images, one for each frame of the sprite sheet.

How should I go about this? I would prefer an offline method or a tool to do so -- I found Alferd SpriteSheet Unpacker, but it is really slow on Windows 7 and does not seem to respond well at all.


texts: How to move towards a point in 2D, stopping at obstacles

texts: I want to do a 2D game, where you can mouse click anywhere on the map and the player will go there. If there is obstacle in the way, the player will go as close as possible to where you clicked without going into the non-walkable area. What would be the optimal way to accomplish this?


texts:
I'm writing a paper on game backgrounds and need to look at how they are implemented in different games, but I'm a bit stuck on scrolling backgrounds.

While it's easy to recognize a scrolling background, everywhere I look I also see tiles.

Are there any popular published games that use scrolling backgrounds, but that don't use tiles?

All of the classics, like Commander Keen, Mario, etc. use both scrolling and tiles.

Any suggestions? Google is not helping me on this one.


texts: Need material for character anatomy in a 2D game. Spartan Like, See Picture

texts:
I'm creating my art for an 2d based IOS game. I know some basic anatomy as you can see by the picture but I have no idea how I will make draw the pics for animation of the character walking, attacking with his sword and protecting himself with shield.

Is there any anatomy reference for 2d game out there, book or anything else?

for your information, I did try to find but all of stuff I found are very amateur and incomplete

The picture was my attempt of creating a example of the character walking, which I'm not happy with

please help, thanks

Update:

Since I am in a hurry I decided I would copy the anatomy from other 2d games, it is not that clean but at least I wanna be able to start it. The question is still open.


texts:
I was trying to find or make a function which is not equi-probable, meaning some values are less probable than others. Apparently what I want has something to deal with http://en.wikipedia.org/wiki/Normal_distribution and Gaussian Distributions.

The math and algorithmics involved in such a function seemed a little complex, and I was not sure if they were really necessary.

My goal is to make better loot more rare to get (the player can generate an infinite amount of loot events), but since I want the loot quality to be expressed with a single value, I need a function that returns values > 0.9 very rarely but will return value > 0.1 much more often.

I tried log((100*random())^(0.01*random()))  ('^' meaning exponent, so '**' to be precise) in python, I got results that seems pretty satisfying, but I'm really suspicious that I can can trust those results.

Is there some type of standard function that already do what I'm looking for ? Do you think this formula is somehow reliable ?

I don't want to have "loot tables" because they're integral values, and it would require more tweaking, and I don't intend to have special items that are much more powerful than lower tier items.

Here are the results, with 10000 picks:

('0.003', 1514, '15%', '####################')
('0.006', 1323, '13%', '#################')
('0.010', 1269, '12%', '################')
('0.014', 1169, '11%', '###############')
('0.022', 1187, '11%', '###############')
('0.027', 1089, '10%', '##############')
('0.028', 964, '9%', '############')
('0.034', 760, '7%', '##########')
('0.037', 496, '4%', '######')
('0.043', 228, '2%', '###')


texts:
I'm a bit confused. The question is: when I'm developing a XNA game for Xbox (or Windows), is it possible to use DirectX (to make use of the GPU)? Or is everything getting calculated by the CPU?

A quick Google search didn't gave any results of combining those two...


texts: How to implement the graph for pathfinding using A*

texts:
The game I am working on is based on a maze where each level is procedurally generated. The pathfinding grid is a 2D array where each node holds its connections. Path requests are handled one at a time so there can't be two path calculations going on simultaneously. So far I have each node hold its data required for the A* (H,F,G scores and its parent) and manipulate them directly in the algorithm. Since the nodes are the actual nodes and not copies of them, every time the algorithm runs the data changes permanently and I have to manually set them on default values before the next run.

So my questions are :

1) Is this a valid way of handling pathfinding in a game?

2) What other data manipulation techniques I could use in order to avoid that?

If you need a copy of the code it's all on my github under Pathfinding
and Managers/PathfindingManager.


texts: Vuforia is not rendering real world - Camera not rendering real world

texts:
I follow this guide (How-to-build-an-ar-android-app-with-vuforia-and-unity) but added my own mobile picture in database (as a marker) so that I could see animated object on my mobile and i am able to run my app but camera is not rendering the real world object in scene. instead animated object showing only.
what i am doing wrong?

Remember vuforia doesn't recognize my web-cam profile and apply default profile on it.(Is this a problem )


texts: How can i collide two bodies without filtering(collision filtering)?

texts:
I have two bodies with fixtures. One is platform or ground and other is the player itself.I want to collide the player to the platform without bit filtering.How can i do that?I can see the rectangular ghost layer(like a rectangular box) and the box2d falling through it.I want the box2d to collide.

create player


texts: How to implement simple light in 3D renderer?

texts:
I'm writing a 3D renderer from the absolute scratch with no external libraries or api but SDl2 for basic window and input handling. I've made quite a progress in my program and it's capable of rendering OBJ files, backface culling, camera movement and clipping, and last but not least texturing.
I've tried to shift my focus now to implementing a simple lighting system however I've never worked with such thing before and to be frank I have no idea where to start. I scoured the internet for a resources and references but couldn't find useful ones. Perhaps, someone could aid me on how to actually start setting up a basic light class and how the whole thing works maybe even a good website I can start getting myself acquainted with implementing a lighting system


texts: Game development for high-school with C++ and OpenGL

texts:
I've been teaching high-school students (12th grade) game programming in the last 2 years. The way I did this till now, was first to give them "half made" classes (for Point, Polygon, etc.) and they've completed them with my help/their friends/themselves, and then they were free to design their models, and write their game logic.

The programming language was C++ and I used GLUT. I gave the students the base class that does all inits for OpenGL so they didn't work on it (except some high-motivated students that wanted to extend their graphics).

My goal was to teach them the fundamentals of C++ using OOP, by implementing their own classes rather than teaching them methods from OpenGL/GLUT API. It's also important to notice that most of those students never programmed in their life and all they knowledge comes from theory in high-school computer science.

I write this post here to get your opinions about the way I handled this class until now, do you think I've done wrong not teaching the OpenGL/GLUT API? do you think I need to utilize OpenGL power to implement basic models, or it's good practice to let them implement models by themselves? Maybe I don't need to use GLUT anymore because there are modern libraries these days that does better work, or it doesn't matter as long as it's for learning purposes?

I really want to give the students motivation by demonstrating what they can do in modern game programming, but I still got my limits which I wrote here, and also time limit (the class is one year, one lesson each week).

Thanks for your help!


texts: How do I avoid 3D AABB collision response getting stuck at block edges?

texts:
I want the player to be able to slide along cubes, but without getting caught at the seam between 2 adjacent cubes.  I've gotten it so that I can do x collision, with sliding, and y, and z, but I can't do them together, probably because I don't know how to resolve it correctly.

Here's an example:

[]
[]
[]
[]O
[]

Pretend all the tiles are touching. O is the player (moving upward). The methods I was trying would get the player stuck between the cubes because the z axis was responding and kicking me out.

I don't know how to resolve this in all 3 directions, like how would I go about telling which direction I have to resolve in.  My previous methods involved me checking 4 points in a axis aligned square around the player, I was checking if these points where inside the cubes and if they where fixing my position, but I couldn't get it working correctly.


texts: Ignore collisions with some objects in certain contexts

texts:
I'm making a racing game with cars in Unity. The car has a boost/nitro powerup. While boosting, I wouldn't want to be deviated when colliding with zombies, but I do want to be deviated when colliding with walls.

On the other hand, I don't want to ignore collision with zombies, because I still want to hit them on impact.

How should I handle this? Basically, what I want is for the car to not rotate when colliding with certain objects.


texts:
I am writing a 2D game where one of the characters has some very particular requirements. This character is a body with no particular shape (similar to a fluid, but not so much), it has to be able to grow and shrink (as in actually growing, not just scaling), and it has to have collision detection (even if it's basic). Because of this requirements, it obviously can't be based on a sprite, so direct rendering of the shape should be the logical thing to do.

I assume this is no easy task, but I just couldn't find a good physics engine that covers these requirements (or at least no tutorial on how to do it; I particularly searched for Box2D tutorials).

Is there a way of doing this with Box2D, SDL, or any other physics or game engine out there?

If not, what's a good place to start? I am really clueless as far as soft-body physics are concerned.


texts: How to implement layer based collision in C++?

texts:
I need layer based collision for my game, the problem is I don't really have an idea how to implement it. I'm using C++ and a graphics library called SFML.
The only idea I got would be an array of unsigned integers that represent the collision layers the object has. However, I don't feel like this is an efficient way to implement this, because it's probably inefficient to loop through this array for every object, and for each layer it has loop through all the objects again to see if they are on the same layer.
I'm sure there is a better way but I couldn't find much on this online except for one article I couldn't understand at all.


texts: Should I design UI in raster or in vector editing software?

texts:
I am working on a IOS city builder game (more like planet builder)
but that's not the case, I was making the buttons in photoshop when something hit me:
"if I make raster icons in photoshop, they will look pixelated on ipads!"

And so I proceded to illustrator to create the same things, but illustrator has nowhere near the amount of cool tools, that made my buttons look so cool in photoshop.

The question:
Should I stick with vector graphics and make them work? so then I have resizable buttons.
or
Should I just create several sets of buttons, which are different sizes?  a set for ipads,a set for iPhone 5's a set for iPhone 6's..


texts: Using a sphere collider in combination with FoV

texts:
I have a character and some npc's in my game. I want the npc's to look out for my character using a sphere collider. Well it kind of works but of course not as i want. When the npc is looking at me and a colission occurs it should trigger some chasing behaviour, but if the npc look in another direction, it should not trigger that behaviour.

So i need something like a field of view inside the collider. I watched some tutorials like https://www.youtube.com/watch?v=rQG9aUWarwE and  https://www.youtube.com/watch?v=mBGUY7EUxXQ but it should be 3 dimensional so not only on the ground like in the tutorial. I added a picture to visualize it

How can i accomplish this?


texts: How to clip what is outside scroll view when using a custom UI element?

texts:
I have created a custom UI element (that use CanvasRenderer).

Here is code :

Mesh mesh = new Mesh();

Rect drawArea = GetComponent<RectTransform>().rect;

using (VertexHelper helper = new VertexHelper())
{
    helper.AddVert(new Vector3(drawArea.xMin, drawArea.yMin), Color.white, Vector2.zero);
    helper.AddVert(new Vector3(drawArea.xMin, drawArea.yMax), Color.white, Vector2.zero);
    helper.AddVert(new Vector3(drawArea.xMax, drawArea.yMax), Color.white, Vector2.zero);
    helper.AddVert(new Vector3(drawArea.xMax, drawArea.yMin), Color.white, Vector2.zero);
    helper.AddTriangle(0, 1, 2);
    helper.AddTriangle(2, 3, 0);

    helper.FillMesh(mesh);
}

var canvas = GetComponent<CanvasRenderer>();
canvas.SetMesh(mesh);
canvas.SetMaterial(Material, null);

It creates a simple rectangle that is same size as rect transform.

It works great. However if I put this inside a scroll view, everything that is outside scroll area / viewport is rendered (while it should be clipped).

The scrolling works as it should (rectangle get scrolled by changing position when scrollbar is used).

I have tried to call canvas.EnableRectClipping(...); but without success.


texts: Can't open nor install 2D Sprite Editor through package manager

texts:
In unity 2019.2.10f1 Personal edition on Windows 10 I wish to edit a spritesheet through the built-in sprite editor.
When I click on the "Sprite Editor" button I get a popup that says

  No Sprite Editor Window registered. Please download 2D sprite package from Package Manager.

(Fig 0)

Attempting to follow these instructions I opened the package manager (fig 1) but couldn't find an install button for the "2D Sprite" package (fig 2).

I searched on the internet if there was any way to manually download it but couldn't find any matching package.

Is this a bug, why can I not install this package ?

 (fig 0)

 (fig 1)

 (fig 2)


texts: Why does the player grab the object outside the trigger zone?

texts:
I want the player to be able to grab an object (in this case the knife) when he is in the object's trigger zone. He can get the knife but there is a problem: if I press grab button outside of the trigger zone, then he can get the knife immediately after entering the zone. I want Unity to get the input only when the player is in the trigger, otherwise it should not be working.
Here's the grab script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Grab : MonoBehaviour
{
    public GameObject player;
    private bool grabbed;
    public GameObject knifePosition;
    private bool isInTrigger;

    void Update()
    {
        if (Input.GetButtonDown("Grab"))
        {
            grabbed = true;

        } else
        {
            grabbed = false;
        }

       if (grabbed && isInTrigger)
        {
            gameObject.transform.position = knifePosition.transform.position;
       }
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject == player && grabbed)
        {
            gameObject.transform.SetParent(player.transform);
            isInTrigger = true;
            Debug.Log("Picked up");
        }
    }
}


texts: Multiple buffers and calling glBufferSubData

texts:
Originally asked this on Computer Graphics, but it might fit in better here.

In my project, for convenience I would like to use many buffers.
Many buffers in my case means 50-100 terrain patches represented by buffers with vertex coordinates, normals, indices and maybe color. The magnitude of data would be, let's say 10^4 floats per buffer. Some of this data can be shared between each terrain patch, f.ex. xz-coordinates and indices.

During the rendering loop, some terrain patches will be updated. Which means that for certain buffers I call glBufferSubData() for the whole buffer.

My question is; are there any pros/cons, performance wise between these two methods:

1) Controlling my data in many buffers (50-100), thus letting me call glBufferSubData on a complete buffer when needed.

2) Controlling my data in fewer (5-20) buffers, with more data in each. But then having to set up a system where I need to call glBufferSubData on smaller portion of a buffer. (Which leads to a more complex design in my case).


texts: What is an equivalent of Swift's UIScreen.mainScreen().bounds in Unity 2d?

texts:
Basically, I am from a Swift SpriteKit background where UIScreen.mainScreen().bounds is a CGRect which represents the screen and can be manipulated in various ways like getting the middle of the screen by using

var screenCenter = CGPointMake(UIScreen.mainScreen().bounds.width/2, UIScreen.mainScreen().bounds.height/2)

What is an equivalent of UIScreen.mainScreen().bounds in Unity (C# Scripting) that can manipulated to get various positions in a similar manner?


texts:
I want to play some videos in my XNA game. I have looked at this tutorial. I have tried it. It creates XNB file but also copies original WMV file into output content directory.

Is there some simple solution, how can I pack/hide original WMV file? I don't want user get it.

Thanks for any help.


texts: Is computing depth in a pixel shader bad? Can I reduce fillrate by moving depth calc to vertex shader?

texts:
I have a DX10 game that is fillrate bound. One of the things I've been realizing may be contributing to this is that I compute depth in the pixel shader (the game uses a logarithmic depth buffer to get extreme precision from 1cm to millions of meters away).

It occurred to me that writing the depth in the pixel shader is ruining the ability to to Early Z testing.

Can this be fixed by outputting this computed depth value in the vertex shader instead?


texts: Which part of the frustum sits at the eye position?

texts:
In Java I create a frustum projection matrix via

Matrix.frustumM(projMatrix, 0, left, right, bottom top, near, far);

and a view matrix via

Matrix.setLookAtM(viewMatrix, 0,
                               0, 0, -2.5,  // eye position
                               0, 0, 0      // look position
                               0, -1, 0);   // up direction

My question is:

Which part of the frustum originates at the eye position? Is it the tip of the pyramid, or the centre of the near plane?


texts: How are physics or graphics components typically built in a component-oriented system?

texts:
I have spent the last 48 hours reading up on Object Component systems, and feel I am ready enough to start implementing it. I got the base Object and Component classes created, but now that I need to start creating the actual components I am a bit confused. When I think of them in terms of HealthComponent or something that would basically just be a property, it makes perfect sense. When it is something more general as a Physics/Graphics component, I get a bit confused.

My Object class looks like this so far (If you notice any changes I should make please let me know, still new to this)...

typedef unsigned int ID;

class GameObject
{
public:

    GameObject(ID id, Ogre::String name = "");
    ~GameObject();

    ID &getID();
    Ogre::String &getName();

    virtual void update() = 0;

    // Component Functions
    void addComponent(Component *component);
    void removeComponent(Ogre::String familyName);

    template<typename T>
    T* getComponent(Ogre::String familyName)
    {
        return dynamic_cast<T*>(m_components[familyName]);
    }

protected:

    // Properties
    ID m_ID;
    Ogre::String m_Name;
    float m_flVelocity;
    Ogre::Vector3 m_vecPosition;

    // Components
    std::map<std::string,Component*> m_components;
    std::map<std::string,Component*>::iterator m_componentItr;
};

Now the problem I am running into is what would the general population put into Components such as Physics/Graphics? For Ogre (my rendering engine) the visible Objects will consist of multiple Ogre::SceneNode (possibly multiple) to attach it to the scene, Ogre::Entity (possibly multiple) to show the visible meshes, and so on. Would it be best to just add multiple GraphicComponent's to the Object and let each GraphicComponent handle one SceneNode/Entity or is the idea to have one of each Component needed?

For Physics I am even more confused. I suppose maybe creating a RigidBody and keeping track of mass/interia/etc. would make sense. But I am having trouble thinking of how to actually putting specifics into a Component.

Once I get a couple of these "Required" components done, I think it will make a lot more sense. As of right now though I am still a bit stumped.


texts: Sprite loses quality when converted to texture in unity

texts:
So I have a sprite that is 750 (width) by 210 (height). I have put it in the game and adjusted the pixels per unit to match the scene size. But soon I realized that I need to use a texture to make the sprite appear to be scrolling.

When I did this I noticed a loss in quality when I made a quad and applied the texture to it. It seems that the sprite changes resolution when I make it a texture. It goes from (750px x 210px) to (512px x 256px) as seen in pic below:

As a sprite:

As a Texture:

I am a complete beginner to unity and need all the help I can get.

Let me know if you need any more info.

Thanks!


texts: Transform vertices in a line differently?

texts:
With a GL_LINE, is there a way to have the vertex (or geometry) shader treat the first and second point differently?

i.e. In a line from p0 -> p1 I'd like to apply a different transform to p0 than to p1.

I know how to do this with a computer shader, but I was wondering if there is a way to do it with a vertex/geometry shader.


texts: Object moving by adding force to Rigidbody bouncing off where ground objects met

texts:
I have a object that moving by adding force to rigidbody. With just big flat plane, it works fine but with connected small planes, sometimes(actually not sometimes, a lot) the object bouncing off or rotating to another direction where the planes are met. Planes are placed well, there's no gaps between the planes.

Here's the picture for understanding:

Now next image shows that object was rotated in left direction(I was just keep pressing forward and it just keep push forward).

I tried with more mass values, like 30000-50000, still happens. I don't know why this is happening, where should I check to solve this problem?

Any advice will very appreciate it.

P.S. I forgot to mention it, object using Box Collider.


texts:
It would seem to me that vector art is more efficient in terms of resources/scalability; however, in most cases I have seen artists using bitmap/rasterized art. Is this a limitation put on the artists by the game programmers/designers? As a programmer I think vector art would be more ideal, since it allows for scaling up resolution without having to recreate the art, creating really large graphics or causing graphics to become blurry.

The questions: why aren't more people using SVG/AI to create 2D game art? Would it actually be preferred (and who prefers it)? Are bitmap graphics a standard or a limitation (or maybe neither)?

Background: I am working on an engine, and I had some kinda cool ideas for vector based graphics; however, I don't want to piss off artists in the future.

I guess this is more a question centered around pragmatism and developing games.


texts: Unity 5 - Error with code to make pitch changes based on distance

texts:
I really need help.  It's 2:00 AM here and my brain is half dead so I can't, for the life of me, find out what's wrong with this code anymore.  It's supposed to find the distance between the game object to which it's attached (the target), and another game object (the player). Then, depending on the that distance, it should change the pitch of an AudioSource inside a child (in the player). However, the pitch only changes when I'm practically over the gameobject. So, for about 9/10 of the way, nothing changes in the pitch, but when I'm right there the pitch suddenly changes (but not to maximum value of Clamp function).

What's going on? I want the pitch to, at first, stay at 0. But soon after you walk some steps in the right direction, the pitch must change gradually (and in a evenly manner), as (player) gets closer to (target). =|

ps.: The script is inside a instantiated prefab, that's why I used FindGameObjectWithTag and FindChild. Also, I'm using Unity 5.

<!-- language: lang-cs -->

[four blanks]using System.Windows.Controls;
[more indented code]

using UnityEngine;
using System.Collections;

 public class ProximitySensor : MonoBehaviour {
     public GameObject player;
     private Transform playerTrans;
     private Transform targetTrans;
     public Transform beepTrans;
     public AudioSource beepSound;
     private float distanceCurrent;

     void Start () {

         targetTrans = transform;
         player = GameObject.FindGameObjectWithTag("Player");
         playerTrans = player.transform;
         beepTrans = playerTrans.FindChild ("beepController");
         beepSound = beepTrans.GetComponent<AudioSource>();

     }

     void Update () {

         distanceCurrent = Vector3.Distance (playerTrans.position, targetTrans.position);
         beepSound.pitch = Mathf.Clamp ((1 / distanceCurrent), 0.1f, 3.0f);

     }
 }


texts: No output to screen using Multiple Render Targets and multisampling

texts:
I'm having a little trouble with XNA, but I doubt it's specific to the framework.

I draw a few 3d models to 1 rendertarget with multisampling turned on, and it works fine. If I draw the same scene to 2 rendertargets (of course the second one gets a different output (configured this in HLSL shaders)) with multisampling turned on, I get absolutely no output. Nothing. Blank. Also, when I render to both outputs but turn off multisampling, it works perfectly (but looks hideous due to a lack of antialiasing).

The strange thing is: This happens on my desktop (Nvidia GTX 560 Ti), but not on my laptop (Intel HD Graphics 4000, which sits on the CPU). On my laptop, it outputs just fine to both rendertargets and multisampling turned on.

Can anybody explain what could be wrong?  I won't copy all my code here but just to clarify:

graphics.PreferMultiSampling = True
RT_Light = New RenderTarget2D(device, ClientWidth, ClientHeight, False, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents)
RT_Scene = New RenderTarget2D(device, ClientWidth, ClientHeight, False, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents)
device.SetRenderTargets(RT_Scene,RT_Light)
'Draw

Works but looks hideous

graphics.PreferMultiSampling = True
RT_Light = New RenderTarget2D(device, ClientWidth, ClientHeight, False, SurfaceFormat.Color, DepthFormat.Depth24, 4, RenderTargetUsage.PreserveContents)
RT_Scene = New RenderTarget2D(device, ClientWidth, ClientHeight, False, SurfaceFormat.Color, DepthFormat.Depth24, 4, RenderTargetUsage.PreserveContents)
device.SetRenderTarget(RT_Scene)
'Draw

Works but obviously only draws to one rendertarget

graphics.PreferMultiSampling = True
RT_Light = New RenderTarget2D(device, ClientWidth, ClientHeight, False, SurfaceFormat.Color, DepthFormat.Depth24, 4, RenderTargetUsage.PreserveContents)
RT_Scene = New RenderTarget2D(device, ClientWidth, ClientHeight, False, SurfaceFormat.Color, DepthFormat.Depth24, 4, RenderTargetUsage.PreserveContents)
device.SetRenderTargets(RT_Scene,RT_Light)
'Draw

Works on my laptop, but not on my desktop.

Again, to clarify: The top picture is what my laptop shows (with multisampling and multiple render targets), and the bottom picture is what my desktop shows with the same settings:


texts:
I'm writing simple chat-app using Unity. The problem with Unity's default implementation of soft-keyboard visibility is that it hides itself when i'm clicking outside of keyboard panel. What i want is that keyboard stays always shown until i explicitly tells otherwise.

For a couple of days i tried to find similar questions but none of them helped me. I have very little experience in "native" android development (i.e. Java). So far i managed to create simple native plugin for Unity. I tried to manually open keyboard with this code:

imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);

The result was fine, except the keyboard had InputType set to TYPE_CLASS_NUMBER. For my app i needed TYPE_CLASS_TEXT. So i tried to research how to set InputType and stumbled on fact that this property can only be changed inside EditText object. As i'm writing my app in Unity, i had no way of finding my InputField's inside native code. So i tried to create EditText inside my native plugin. I followed the logic that if i create custom EditText, place it inside main layout and set visibility to NONE or make background transparent, then i can set focus to that element and be fine:

FrameLayout myLayout = activity.findViewById(android.R.id.content);
focusedText = new EditText(context);
focusedText.setFocusable(true);
focusedText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL);
myLayout.addView(focusedText);
focusedText.setFocusableInTouchMode(true);
focusedText.requestFocus();
focusedText.setBackgroundColor(activity.getResources().getColor(android.R.color.transparent));
imm.showSoftInput(focusedText, InputMethodManager.SHOW_FORCED);

The end result was a mess. Soft keyboard behaviour became undesirable. In order for keyboard to show, i first needed to select InputField, then i would see transparent EditText be created in the middle of my layout with all input characters visible. Even if all worked fine, it still looks like a wacky hack.

Does anyone stumbled across similar issues?


texts: How to use continious collision detection in a dynamic AABB tree

texts:
I am currently writing a game in c++ using openGL, and I am currently using a kinetic sweep and prune algorithm for the broad phase and then using GJK Raycast + GJK & EPA for the narrow phase. However I have realized that kinetic sweep and prune may not be the best choice because there are many objects in the scene that are just static and cause a lot of swapping when an object moves.
So basically I would like to implement a dynamic AABB tree for the broad phase knowing there will be only a few objects requiring continuous collision detection (but these objects are essential). However for these fast moving objects what is the best way to detect a possible collision with other objects in the broad phase? I am thinking about using an AABB that contains the object trajectory from one frame to another, is this a good idea? Or will this a lot of overhead due to many false positives?
Also I haven't read to much about dynamic AABB trees but I think I understand the idea, the idea is for each object that moved check if it's AABB if overlapping with the tree node, if it is do the same check with it's children and do so until we are at the leaves of the tree.
All help is greatly appreciated


texts: Basic procedural generated content works, but how could I do the same in reverse?

texts:
My 2D world is made up of blocks. At the moment, I create a block and assign it a number between 1 and 4. The number assigned to the nth block is always the same (i.e if the player walks backwards or restarts the game.) and is generated in the function below.
(Image shows a small portion of the game, in practice there are much more blocks)

As shown here by this animation, the colours represent the number.

function generate_data(n)
    math.randomseed(n) -- resets the random so that the 'random' number for n is always the same
    math.random() -- fixes lua random bug
    local no = math.random(4)
    --print(no, n)
  return no
end

Now I want to limit the next block's number - a block of 1 will always have a block 2 after it, while block 2 will either have a block 1,2 or 3 after it, etc.
The next block's number is taken at random from the next table:

{
   [1] = {next = {2}},
   [2] = {next = {1,2,3}},
   [3] = {next = {4}},
   [4] = {next = {1,3,4}},
}

Before, all the blocks data was randomly generated, initially, and then saved. This data was then loaded and used instead of being randomly called. While working this way, I could specify what the next block would be easily and it would be saved for consistency.
I have now removed this saving/loading in favour of procedural generation as I realised that save whiles would get very big after travelling.

Back to the present. While travelling forward (to the right), it is easy to limit what the next blocks number will be. I can generate it at the same time as the other data.

The problem is when travelling backwards (to the left) I can not think of a way to load the previous block so that it is always the same.

Does anyone have any ideas on how I could sort this out?


texts: In an asynchronous server environment where player input and timed events modify data is using an in-memory array problematic?

texts:
So let's say I have a server running on node.js, and there is an array of player objects...

At an interval, all of these player objects are looped and processed for events and changes that are based on time, such as fuel or food consumption and movement.

However players can also trigger things from the client that could modify player data as well.

Now what I'm trying to determine is if I am going to run into any problems with timing, such as if we are mid loop and somebody changes something and it throws some other calculation off balance.

Will I need to implement some kind of locking mechanism I can use as needed or is there a better way to hold this data in memory?


texts:
I'm currently developing a RPG movement system in c++, and tried to use the State Pattern/State machine for this, but AFAIK I would have to check each movement key in every state.(right?)

Is there a better design for this?, because the states have no restriction, the player can switch to any move state at any time.

can anyone help


texts:
I'm making a game in android and I need plot a function, my algorithm is this:

    @Override
    protected void onDraw(Canvas canvas) {
        float e = 0.5f;
        //from -x axis to +x evaluate f(x)
        for (float x = -z(canvas.getWidth()); x < z(canvas.getWidth()); x+=e) {
                 float x1,y1;
                 x1 = x;
                 y1 = f(x);
                 canvas.drawPoint((canvas.getWidth()/2)+x1, (canvas.getHeight()/2)-y1, paintWhite);
        }
        super.onDraw(canvas);
    }

This is how it works. If my function is, for example f(x)=x^2, then z(x) is sqrt(x). I evaluate each point between -z(x) to z(x) and then I draw them. As you can see I use the half of the size of the screen to put the function in the middle of the screen. The problem isn't that the code isn't working, actually plots the function. But if the screen is of 320*480 then this function will be really tiny like in the image below. My question is: how can I change this algorithm to scale the function?. BTW what I'm really wanting to do is trace a route to later display an animated sprite, so actually scale this image doesnt gonna help me. I need change the algorithm in order to draw the same interval but in a larger space. Any tip helps, thanks!

Current working result

Desired result

UPDATE:
I will try explain more in detail what the problem is. Given this interval [-15...15] (-z(x) to z(x)) I need divide this points in a bigger interval [-320...320] (-x to x). For example, when you use some plotting software like this one. Although the div where is contain the function has 640 px of width, you dont see that the interval is from -320 to 320, you see that the interval is from -6 to 6. How can I achieve this?


texts:
I'm making a mode7 game like mario-kart and I need to tilt the image before I draw it, I have tried using a buffer canvas to tilt the image then draw it on the games canvas but this makes it laggy (because the image of map is 1280 x 2556.)

So my question is:

How can I rotate my image before i draw it


texts:
Hello i have two points (Vector3) A and B. And have a radius r

How can i find a coords of point P in a circle by angle?


texts: Texture being stretched when using D3DTADDRESS_CLAMP

texts:
I'm trying to create a skybox using a cube and using one of this textures: http://forum.unity3d.com/threads/mundus-skybox-pack-01-released.202748/

I've got it working well, but I noticed there are some bugs on the edges of the cube, as it can be seen here:

I found that this could be fixed using clamping, so I set D3DSAMP_ADDRESSU and D3DSAMP_ADDRESSV to D3DTADDRESS_CLAMP. This, however, produced the following result:

Half of the cube wasn't being shown and the other half was only showing a one-pixel wide texture region.
I saw this similar question (which uses wrapping though), but I'm already using 4 vertices per face.
So, what could be causing this?


texts: How to handle keyboard in worker thread in XNA

texts:
I am using multithreading in my XNA application and run my update logic s in a update thread(witch is a worker thread) and rendring is being done by main thread, now the problem is updation is required there on keyboard event, and key Board handling can be done only in main thread.

Note that my application was single threaded and I have implemented threading, synchronization is being done by 'data partitioning', both the threads are working correctly, except my keyboard is not working..

if any one have any suggestion or example, please allow me to know.

thanx in advance.


texts:
I'm making my first game in Java, a top down 2D RPG.
I've handled basic collision detection, rendering and have added an NPC, but I'm stuck on how to handle interaction between the player and the NPC.

Currently I'm drawing out my level and then drawing characters, NPCs and animated tiles on top of this. The problem is keeping track of the NPCs so that my Character class can interact with methods in the NPC classes on collision.

I'm not sure my method of drawing the level and drawing everything else on top is a good one - can anyone shed any light on this topic?


texts: Unity target position never stops with Vector3.SmoothDamp

texts:
I've integrated Vector3.SmoothDamp method to have a more fluid and native movement between the character and his camera in Unity. The camera movement is perfectly in sync with the character because both uses SmoothDamp to move, but the character sometimes still looking for the final position in the x axes.

How can I fix the problem introduced by SmoothDamp without remove it?
The problem seems to be correlated to targetPosition.x which still changes but I'm not sure why because hrxMovement and velocity.x reaches 0:

float movementDuration = 0.3f;
float movementSpeed = 2.5f;

void Run () {
    float hrzMovement = Input.GetAxis("Horizontal");
    Vector2 velocity = new Vector2(Vector2.right.x * movementSpeed * hrzMovement, body.velocity.y);
    Vector3 targetPosition = new Vector3(body.transform.position.x + hrzMovement, body.transform.position.y, body.transform.position.z);

    body.transform.position = Vector3.SmoothDamp(body.transform.position, targetPosition, ref transformVelocity, movementDuration);

    print("hrzMovement: " + hrzMovement + ", velocity.x: " + velocity.x + ", targetPosition.x: " + targetPosition.x);

    if (velocity.x != 0) {
        animation.SetBool("isMoving", true);
        orientationMovement = velocity.x;
    } else {
        animation.SetBool("isMoving", false);
    }

    if (orientationMovement < 0) {
        body.transform.localScale = new Vector3(-1, 1, 1);
    } else {
        body.transform.localScale = new Vector3(1, 1, 1);
    }

}

Additional packages used:

I'm using Pixel Perfect Camera package, I hope this doesn't affect the code.


texts: How are game menus logically structured?

texts:
I've been struggling with making a game menu system in Unity for some time now. I spent time developing a way to help myself understand how game menus are connected together. Right now, I'm calling it the Screen-Menu relationship.

In this relationship, Screens (e.g. Main-Menu, Game-Over and Inventory screens) hold access to Menus (e.g. Options Menu, Level-Select menu). These Menus are accessed via MenuButtons (e.g. Options menu button via the Pause Screen).

Is this a valid way of thinking about how game menus are structured? How should I be thinking about it?


texts: Cardboard VR Mode rendering black in Unity

texts:
I've searched around and seen this problem is quite common, but none of the fixes I've read have resolved the issue: If VR Mode is enabled in the GvrViewerMain prefab, the scene will render as just a black screen.

I've set the Graphics API to OpenGLES2, I've disabled Multithreaded Rendering, I've disabled direct render, yet this continues to be an issue.

This happens both within unity itself and if it is built and run to my phone. Has anybody encountered this problem/do you know of any further steps to take to resolve the issue?


texts:
I have been learning networking for about 4 months. Wrote a single standalone Multiplayer server and succeeded with authoritative approach. Now I want to extend it by splitting the single server into clusters to allow even more players to log in to avoid latency issues. Now I have protyped the Loadbalancing server and its running pretty good so far.

This is my architecture, I have a master server which acts as a proxy, every sub servers(chat, login, game) connect to the master server as well as all the clients. when a client connects,

Client Request: Send Request -> MS(Master) -> Decides which SS(SubServer) to forward to -> Forwards Request to SS -> SS -> Analyze Message -> Send Response to MS -> Decides which Client to forward to -> Forwards Response to Client

Well, it looks like its going through lots of stages. it takes double the time to process the message than a single server approach. i feel like my model isnt the best or i may be wrong. is there any better model or the one they use in professional games? I still want a Master-SubServer approach.

I just want to clarify that I'm going in the right direction before writing all my codes. Thanks for any answer :)


texts:
I'm trying to create grass quads and have therefore disabled backface culling when rendering these quads. With each vertex normal set upwards ( 0.f, 1.f, 0.f ), all front faces are lit correctly, but backfaces are black. If I change the the Y normal to -1.f the backfaces light up and the front faces go black.

D3D11_RASTERIZER_DESC desc {};

desc.AntialiasedLineEnable  = false;
desc.CullMode               = D3D11_CULL_NONE;
desc.DepthBias              = 0;
desc.DepthBiasClamp         = 0.f;
desc.DepthClipEnable        = true;
desc.FillMode               = D3D11_FILL_SOLID;
desc.FrontCounterClockwise  = false;
desc.MultisampleEnable      = false;
desc.ScissorEnable          = false;
desc.SlopeScaledDepthBias   = 0.f;

I'm not so sure there's a problem here. Any ideas?


texts: Unity - SetLookAtPosition() - Body Jittering?

texts:
I'm working on a third person controller and I'm trying to make character look at the same point as the camera. The problem is that the character jitters all the time the SetLookAtPosition() starts working. Here is a pic:

Everything works great if don't call the LookAt function. Even commenting all the other code on FixedUpdate() and Update() functions the problem remains. The code goes like this:

void FixedUpdate()
{
    // Commented Code

    // Movimiento de Cabeza
    HeadOrientation();
}

private void HeadOrientation()
{
    animator.SetLookAtPosition(animator.GetBoneTransform(HumanBodyBones.Head).position + gameCamera.transform.forward);
    animator.SetLookAtWeight(1f, .4f, 1f, 1f, .8f);
}

Hope someone knows what's happening. Thanks and sory for my bad english!

After trying differents things, it seems that the SetLookAtPosition() function needs to be call in the Update() function, not in the FixedUpdate().

I would appreciate if someone could explain why it needs to be like this.


texts: Unity post-processing effect conflicts with UI Image blur shader

texts:
I'm unable to use a UI image blur effect when I'm also using a grayscale post-processing effect on my camera.

I activate the grayscale post-processing effect when the game is paused, which is also when I show my pause menu, which is a UI panel with a blur shader.

When the grayscale effect is enabled, the UI panel is invisible. It's there, because all my text/buttons show fine. It's just the portion the blur shader applies to, has become fully transparent.

When the grayscale effect is disabled, my panel shows fine, with the blur working as expected.

Here is the grayscale post-processing effect I'm using by Alan Zucconi. I have this on my Main Camera, and it is enabled when my game is paused.

Here is the blur shader I'm using by vinipc, modified from cician, whose blur shader is commonly used by Unity users.

I'm not sure why these would conflict. My guess is that somehow the blur effect is seeing empty/fully transparent colors and therefore is also transparent?


texts:
I have a custom widget with an image component.  I want to change the image dynamically based on a string from a data table.
How do I do this?


texts: What's the best way to deal with platformer tile collisions?

texts:
I am starting with game development and creating a basic platformer game. I already have searched a lot and found some ways to implement the platformer aspect to the game, like apply a gravity, velocity and so on.

Everything is good, but always when I implement a way to deal with the collisions, a bug appears. If I fix it, it appears at other side, etc. The main problem is when the player intersects a tile and I need push him up back. The most simple way that I found is this:

player.Y = tile.Y - player.height;

The most problems comes when you also need verify the X axis, the player is pushed out from the tile, or it is thrown at other tile position, like this issue I had when trying to implement the XNA Platformer Example. Or even pass through the tiles if you are going too fast.

After some research I found a good way to avoid all this problems: instead of move the player to the next position and deal with the tiles to push him back, calculate a safe distance and move the player following this. The "safe distance" is for example, the player.Y += player.Velocity.Y, but if any tile is at the way, the safe distance is decreased to the player don't enter in the tile.

I read this excelent article and it's what is said about the algoritm:

  The total movement of the player along that direction is then the minimum between the distance to closest obstacle, and the amount that you wanted to move in the first place.
  Move player to the new position. With this new position, step the other coordinate, if still not done.

So, the best way is use the "safe distance" method?


texts:
I'm trying to achieve the effect from https://www.iquilezles.org/www/articles/warp/warp.htm

with no success. Here is the experiment http://jsfiddle.net/fro5y0jm/15/ with canvas. Any ideas?


texts: How to deal with data that needs to be accessed by all objects?

texts:
I have a World class that currently only has one instance. It has data and methods that need to be accessed by all other game objects. Right now I'm hardcoding a reference to the global variable world in all of my methods, and this doesn't seem to be the right approach.
Another idea I tried was a dependency-injection-esque approach, where each object stores its own reference to the world object, but this clutters memory with unnecessary references, so I don't think this is the right approach either.
Another approach I tried was passing world as an argument directly into the method call, but this led to repetitive code as I was constantly passing world into any function that needed it.
A bit of research hasn't worked for me because it's hard to summarise my problem into a few words that can return Google search results. It seems this isn't a problem in the majority of applications, so I'm wondering if this is mainly a gamedev situation.
What is the best way to solve this problem?


texts: Opentk LookAt() and 'eye' argument rotating

texts:
I'm trying to create rotating camera, which looks down by 45 deegre like this:

However my code for rotating eye vector is not working properly and I achieve vertical rotation, when it should be horizontal. What am I doing wrong?

class Camera
{
    private Vector3 target;
    private Vector3 origin;
    private float rotation;
    public Matrix4 ModelViewMatrix;

    public Camera(Vector3 target)
    {
        this.target = target;
        origin = target + new Vector3(5);
        SetMatrix();
    }

    public void Move(float x, float y, float z)
    {
        Move(new Vector3(x, y, z));
    }

    public void Move(Vector3 translation)
    {
        target += translation;
        origin += translation;
        SetMatrix();
    }

    public void Rotate(float deegres)
    {
        rotation += MathHelper.DegreesToRadians(deegres);
        SetMatrix();
    }

    public void Zoom(float zoom)
    {
        origin += new Vector3(zoom);
        SetMatrix();
    }

    private void SetMatrix()
    {
        var rotationMatrix = Matrix4.CreateFromAxisAngle(target, rotation); // rotation around target
        var eye = Vector4.Transform(new Vector4(origin, 1), rotationMatrix);
        ModelViewMatrix = Matrix4.LookAt(eye.Xyz, target, Vector3.UnitY);
    }
}


texts: Half top-down view collision and mechanics

texts:
I'd like to create a game with a half top-down (2d RPG) view (I don't know the exact name of it). It would be 2d, but I'd like to add 3d-like collisions. For example:

If the grenade lands on the roof, it would roll down and fall. Or if it hits a wall, it would bounce back.

I've never worked with this view, that's why I'm asking for advices for how to do proper collisions and physics. I don't want to use any external libraries.

Thanks in advance!


texts: Why is there grey haze that appears when game is simulated in viewport, and how do I fix it?

texts: For some reason when the game runs in the regular viewport (not it's own) a grey haze slowly appears. This never used to happen. The level architecture (code) changed recently and then this started happening. However, none of the assets or visual build configurations were changed. This problem does not occur when the game is running in a separate viewport, but the fact is it wasn't an issue in the default viewport before. Does anyone know what is causing this and how to fix/prevent it?


texts: How can I protect myself and my game from users including copyrighted material in the content they submit?

texts:
For example there is a Warcraft III map with Tom & Jerry in it. The author clearly doesn't have the rights for it.

How can I avoid getting into trouble for user-submitted content like this being hosted on my servers?

Is a statement regarding this in the EULA enough or what?


texts: DX11 swap chain is 1 frame behind when presenting to screen and using multisampling

texts:
After adding multisampling to a DirectX 11 project, I noticed that the screen was no longer updating when calling IDXGISwapChain ::Present. Further testing showed that it was in fact updating the screen, but it was always 1 frame behind. If I added a line to the scene and presented it, I wouldn’t see that line until I do the next present call. This behavior is specific to the use of multisampling. If I turn multisampling off, the behavior goes away. This behavior is also specific to my Intel display adapter. If I use my Nvida display adapter, the behavior goes away.

The multisampling settings are determined by using ID3D11Device::CheckMultisampleQualityLevels, and the creation of the back buffer and depth stencil work, so I don’t think the settings themselves are incorrect in any way. Also the multisampling does work; the end result is properly multisampled. I have played with various multisampling settings within the available range, and all settings produce the same behavior. Just in case I’m doing something wrong, I tried using the debug layer, but got no warnings or errors.

Through hours of testing, I found two work-arounds:

1 - Call Present twice:

HRESULT result = _swapChain->UnmanagedPointer->Present(0, 0);
if (result != S_OK)
    ExceptionThrower::Throw(result, "Failed to present the swap chain buffer.");

result = _swapChain->UnmanagedPointer->Present(0, 0);
if (result != S_OK)
    ExceptionThrower::Throw(result, "Failed to present the swap chain buffer.");

When I do this, the second Present call puts the correct information on screen.

2 - Call ID3D11DeviceContext::Flush after Present

HRESULT result = _swapChain->UnmanagedPointer->Present(0, 0);
if (result != S_OK)
    ExceptionThrower::Throw(result, "Failed to present the swap chain buffer.");

_d3dDeviceContext->Flush();

After the Flush call, the correct information is on screen.

As I understand it, both of these work arounds incur a significant penalty, so I would rather find a better solution (if on exists).  I especially dislike this work around because it penalizes everyone. There is no way for me to know when this behavior is happening. I have a feeling that I may be dealing with a driver bug since this is only an issue with the Intel adapter. I hate to force all scenarios to add this overhead when for most, it won’t be necessary. Oh and in case someone asks, I have updated the Intel drivers to the most recent, but it’s an old adapter, so these drivers date back to 2012.

Has anyone seen this type of behavior before? Is there a better work around, or perhaps a solution I’m not aware of? If forced to use one of the two work arounds, which of the two would be the best? I’m leaning towards the second (Flush call), but not sure.

In case helpful, here is my swap chain creation code

DXGI_SWAP_CHAIN_DESC desc;
ZeroMemory(desc, sizeof(DXGI_SWAP_CHAIN_DESC));

desc.BufferDesc.Width = width;
desc.BufferDesc.Height = height;
desc.BufferDesc.RefreshRate.Numerator = 60;
desc.BufferDesc.RefreshRate.Denominator = 1;
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;

desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.BufferCount = 1;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.OutputWindow = outputWindow;
desc.Windowed = true;
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
desc.Flags = 0;

if (useMultiSampling)
{
    desc.SampleDesc.Count = _multiSampleCount;
    desc.SampleDesc.Quality =  _multiSampleQuality - 1;
}


texts: Creating a newspaper that effects the game's economy?

texts:
I am writing a game in Objective C/cocos2d where a newspaper is a central part of what controls or rather effects the game's world economy as well as what a city might do (such as increase X, reduce Y)

The newspaper is a bit like a "Chance card" in Monopoly, it has an effect on something.

My question is, what is the best way to do write a newspaper that has both a random and specific effect within the game.

Would the best strategy be to write out all the things a newspaper can affect, a PLIST of headlines (with placeholders).

I think Tiny Tower uses a PLIST of events and it randomly picks an event, but I'm not sure how it actually parses it because certain events do different things.

But then how do I parse all the scenarios that a newspaper can deliver?  A big switch statement seems very long and complicated to do.

I am wondering if there is a simpler way to handle this kind of thing.

Related to this is that there might be no news that day and I'm not sure what the newspaper should display, should it just display the last headline?

So, in summary.

1) A newspaper generates a headline, it affects different things, such as the world economy, prices, how city reacts

2) I need the newspaper to generate headlines (although there may be days when there are no headlines at all), but I am not sure how to parse it without using a big-ass switch statement.

Thanks in advance.


texts:
I'm trying to install OpenGL 3.0 for studying examples about GLUS , which require OpenGL 3 or 4.

I read on the official Mesa website that Mesa 9.2 support OpenGL 3.0, but after I installed Mesa 9.0, it only support OpenGL 1.4. This is the information  from the command line "glxinfo | grep "OpenGL" ":

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Mobile Intel® GM45 Express Chipset
OpenGL version string: 1.4 (2.1 Mesa 9.1.4)
OpenGL extensions:

My question is how can I get OpenGL 3.0 in Mesa 9.2. I hope to see your answer!


texts: Is it possible to debug shaders in GLSL level instead of assembly language level?

texts:
I'm writing some Vulkan code and write my shader in GLSL.
I tried to use Renderdoc to debug my shader, but I only got disassembly code.
Is it possible to debug shaders at the level of GLSL if I have the source code of  the shaders in GLSL format?


texts:
One of the maps I've played, nicknamed SotiS (DoTA in SC2) has the ability to maintain stats, which are sent back to their own server.

Does anybody know how this is done?


texts: Why is it when I render a basic cube, my editor's grid changes too?

texts:
I have one HLSL file for DirectX11 that only has input layout for color and position. Then another HLSL file for the simple cube that has position, normal and textures. What I noticed is when I render the simple cube; the grid also changes and doesn't remain pure white color. They have different pixelshaders, vertexshaders, constant buffers and different inputlayout descriptions.

Would anyone like to chip in and help get this resolved? This has been puzzling for a day!


texts: Why does the Unity manual add "Quaternion.identity" to an instantiated object?

texts:
In Unity's documentation you can find an example usage of Instantiate:

https://docs.unity3d.com/ScriptReference/Object.Instantiate.html

using UnityEngine;

public class InstantiateExample : MonoBehaviour
{
    public GameObject prefab;

    void Start()
    {
        for (int i = 0; i < 10; i++)
            Instantiate(prefab, new Vector3(i * 2.0f, 0, 0), Quaternion.identity);
    }
}

Why do they add the "Quaternion.identity" instead of leaving it blank? Wouldn't the engine instantiate the object with the original object's rotation anyway?


texts: 'Resetting' Google Play Games Services so app forgets it previously connected (so it shows confirmation screen again)

texts:
When I first integrated Google Play Games Services into my app, it came up with a 'confirmation screen', something like:

App Name wants to connect to Google Play Game Services

I don't recall the exact wording.

While Alpha testing my app, one of my users has discovered a potential issue where he presses 'cancel' at that point instead of connecting. I would like to try to resolve this issue, but I can't recreate it because I can't work out how I can get that confirmation screen again!

I have implemented a 'log out' button in my app and that works, but when subsequently connecting, it just goes ahead without displaying the confirmation screen again.  Any ideas how I can force that screen to show again for testing?!