texts:
I have been passing glm::vec3's in an array to a storage buffer to be processed by a compute shader, but once it has been modified I am getting some malformed data back.

Shader

#version 450

#extension GL_ARB_separate_shader_objects : enable

layout(binding = 0) buffer DataObject {
    vec3[] floatArray;
} data;

void main()
{
    data.floatArray[gl_GlobalInvocationID.x].x = 45.0123f;
    data.floatArray[gl_GlobalInvocationID.x].y = 45.0123f;
    data.floatArray[gl_GlobalInvocationID.x].z = 45.0123f;
}

Data being passed

struct DataObject
{
    glm::vec3 payload[2];
};

...

Buffer payload_buffer;
VkDeviceSize buffer_size = sizeof(DataObject);
CreateBuffer(engine, buffer_size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, payload_buffer);

// Create the data that will be saved
DataObject payload;

// Move the data to the GPU
memcpy(payload_buffer.mapped_memory, &payload, (::size_t)buffer_size);

The data that is returned is as follows

v1 x:45.0123f y:45.0123f z:45.0123f
v2 x:0 y:45.0123f z:45.0123f

Has anyone else come across this issue? and if so how would i resolve it?


texts: Need help to make and optimize a dense forest in Unity with bird view camera

texts:
I'm currently developing a RTS game that has a bird view camera operating while playing the game. One of the core aspects of my game are trees.

So in the previous days i was playing with trees in Unity.

First i played with Unity Tree Creator however later i realized it is broken since 2018.3, and devs said it wont be fixed because it will be a community developed package in the future
Then i downloaded assets from the store that are said to be highly optimized trees, however they are mostly for "3rd person camera projects" thus having around 7-14k triangles.

After these experiences, i decided to export a tree prefab to fbx, then manually decrease the triangle count to around 2.5k in 3ds max, then reimport it to Unity. With this technique i was able to produce quite good results, but still not very satisfied with it.

My camera view, and my "dense forest" 180-300fps... and only like 3-4 shadows

For the above picture i used a Tree with 2 LOD and one billboard(BB).

After playing with this i realized i can sure do better especially with playing LOD numbers, material optimization, and with the default tree trinagle optimization.

However the problem is i can't model pine trees that satisfy my needs in 3ds max. So i started looking into SpeedTree documentation, however it seems a bit too professional for my needs(All the tutorials also make trees with like 20k poly/tri).

So regarding this story. I would like to ask the following question + a bonus one about LOD:

Can you model quality trees with SpeedTree for Unity that have like around 1k-2k triangles, or SpeedTree is for high quality/high poly trees, they algorythms won't work with lower polygon count etc? (I heared they have a simplify modifier is it good? like make a 7k triangle tree then cut it to 1k-2k)
I'm thinking about using 4-5 LOD and a BB for smooth transition. In my picture i use 2 LOD and a BB and sometimes when moving the camera fast, transitions are not as smooth as i want it to be. So i would like to rather have more lower detailed meshes before trasitioning to BB. So does having a 4-5 LOD-s a common practice or any better ides for this?


texts:
As I understand texture usage consist of two parts

How to store this discrete data about texture internally. How much dimensions, channels, etc.
How to fetch/sample/filter

The question relative to OpenGL are:

q1: What parameters are stored in texture object (glGenTexture) and what parameters are store in texture unit (glActiveTexture) ?

q2: Does glTexParameter perform setup per texture object or per texture unit?


texts: Why is my quaternion camera rotating  around strange axes?

texts:
I can't get it to work for the life of me. Its rotating the camera in the global coordinate system, or some other random coordinate system, not the camera local coordinate system. WASDEC work perfectly, right until I start rotating. Here's the annotated code:

  //eye.r is the quat camera rotation
  //eye.p is the vec3 camera position

  // Get the local axes we're going to do transformations with
  var axes = {
    x: quat4.multiplyVec3(eye.r, [1, 0, 0]),
    y: quat4.multiplyVec3(eye.r, [0, 1, 0]),
    z: quat4.multiplyVec3(eye.r, [0, 0, 1])
  };

  // If a movement key is down, add the appropriately scaled local axis
  // to our position
  if(keystate[W]) vec3.add(eye.p, vec3.scale(axes.z,  10, []));
  if(keystate[S]) vec3.add(eye.p, vec3.scale(axes.z, -10, []));
  if(keystate[A]) vec3.add(eye.p, vec3.scale(axes.x,  10, []));
  if(keystate[D]) vec3.add(eye.p, vec3.scale(axes.x, -10, []));
  if(keystate[E]) vec3.add(eye.p, vec3.scale(axes.y, -10, []));
  if(keystate[C]) vec3.add(eye.p, vec3.scale(axes.y,  10, []));

  // If a rotation key is down, create a scaled rotation about the appropriate
  // local axis, and multiply it into the current rotation
  if(keystate[UP])    quat4.multiply(quat4.rotation(-0.05, axes.x), eye.r, eye.r);
  if(keystate[DOWN])  quat4.multiply(quat4.rotation( 0.05, axes.x), eye.r, eye.r);
  if(keystate[LEFT])  quat4.multiply(quat4.rotation(-0.05, axes.y), eye.r, eye.r);
  if(keystate[RIGHT]) quat4.multiply(quat4.rotation( 0.05, axes.y), eye.r, eye.r);

Thanks for your help!

Edit: Since it might not be clear what the functions do. This is javascript and the glmatrix linear algebra/quat library.

quat4.multiplyVec3(quat, vec) // vec = quat * vec

vec3.add(vec, vec2) // vec = vec + vec2

vec3.scale(vec, scalar, dest) // dest = vec * scalar

quat4.rotation(angle, axis) // creates a quaternion rotation about the given axis, by the given angle

quat4.multiply(quat, quat2, dest) // dest = quat * quat2


texts: How can I make a sprite slow down to the speed of another sprite while following it?

texts:
I'm making a SpriteKit game where two SpriteNodes are in a maze. That maze is represented as a grid. One sprite (A) travels faster than the other (B). Items randomly pop up, and the sprites have to collect them.

Pathfinding is easy (GKGridGraph is simple to use).

Here's the problem: At any given time, A and B could be on the same stretch of the maze. If A is behind B, I want A to be forced to go the same speed as B (cannot pass through or around). How can I accomplish this?

Thank you for your time!


texts: Referencing individual cells of a tilemap and changing texture

texts:
I have a tilemap and am trying to proceduraly generate islands on it by changing the texture of the tiles and marking it as land ( I want to do this without texture atlas for now). How do you change the texture of an individual tile and how do you mark the tile to distinguish it from other tiles within map as land . I have tried to do this but for some reason even though I reference an individual tile all tiles are changing textures.

private static TiledMapTileLayer baseLayer;
private static TextureRegion landTextureReg;
private static Texture landTexture;
private static TiledMapTile landTile;

public static TiledMap generateMap(){
landTexture = new Texture(Gdx.files.internal("hex_land_trans.png"));
landTextureReg = new TextureRegion(landTexture);
TiledMap map = new TmxMapLoader().load("ocean_hex_map.tmx");
baseLayer = (TiledMapTileLayer)map.getLayers().get(0);
baseLayer.getCell(1, 1).getTile().setTextureRegion(landTextureReg);
return map;
}


texts: Which 3D graphic engine to use to target old pc's and old graphic cards?

texts:
I would like to build 3d applications that are targeted at old PCs for education.  Which 3d engine do you recommend to use?  What technology should I use or approach?  I would like to avoid Unity3d or any other non-free frameworks, as this work I'm doing is voluntarily.

It's main idea is to make learning fun, using 3d simple gaming.  The target PCs are old single cpu Pentium4, or maybe even p3 (:

Thank a lot for helping.


texts: Blender game engine module file location

texts: Where can I find the "bge" module file ? It imports well from a python script but I want to know where from.


texts: Resetting Achievement Progress for testing

texts: I tried to reset the Achievement Progress, but it is NOT resetting the increment count and I want to delete and create a new achievement each time for testing. Is there any workaround to solve this?


texts:
I'm trying to create my own jumper type game where the player moves up through an infinite y value. The problem I am having is getting the screen size to match up with the android screen.

  viewport = new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), camera);
    camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

Currently I just want the sprite to be drawn in the center of the screen. I'm not worried about the game world size as it will differ from each device.

  camera.update();
    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    batch.draw(player.getKeyFrame(animationTime), Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);

This draws the player somewhere in the upper right corner of the screen. It's my understanding that Gdx.graphics.getwhatever is used to get the dimensions of whatever your device screen is. So I'm wondering if I'm using the viewport class correctly or not?


texts:
I'm fairly new to creating a 2D game in java and I'd love some help. I'm trying to create a sort of knock back effect the enemies have on you. So when you are touched by a enemy you will:

lose life
be knocked back a few pixels

I thought about saying something simple such as:

    if ((player.x & player.y) == (enemy.x & enemy.y)){
        player.x += 8;
        player.y += 8;
    }

But seeing as this will only push you back with no hope of moving while being pushed, I didn't want to use it. Is there any simple, yet effective way for going about this?


texts: Should the frame rate be consistent or is it normal for it to jump around?

texts:
As I commented on a post, I started wondering if it was correct or not (the comment, not the answer). And I'd like to straighten that out.

Although not needed as info, here's the link to the question: Scene management for 3D editor

My comment: "Wouldn't mind that much about the framerate, as long as it stays above 60. you can get away with 30 even."

Still I think if the frame rate is over 30, the real time rendering stays as a good animation. But sometimes I read that people restrict the render() to 60fps or 30fps for performance. This could/would remove all unneccecary calculation wich we can't see anyway. Although true, they (sometimes) claim it is an optimization.

When a scene will render more objects, the fps will drop. Think that is normal.

So what's the deal with fps, should it stay more or less the same even when you turn the camera 90 or 180 degrees, or only when keeping (almost) the same view?


texts: Per color collision is really expensive - can my approach be improved?

texts:
I've been working on adding a color based collision component which takes a list of colors and checks to see if an object is colliding with any of them. However, the operation seems to be extremely expensive, even though I am only colliding 2 objects. I think something is wrong with my TestCollision method but, I can't find the error.

    public List<Color> Colors = new List<Color>();
    private Texture2D _texture;
    public Texture2D Texture
    {
        get { return _texture; }
        set
        {
            _texture = value;
            ColorData = _texture.GetData();
        }
    }
    public Color[,] ColorData { get; private set; }

    public PerColorCollision(Entity e, string name) : base(e, name)
    {
        ColorsColliedWith = new List<Color>();
    }

    public PerColorCollision(Entity e, string name, Texture2D texture) : base(e, name)
    {
        Texture = texture;
        ColorsColliedWith = new List<Color>();
    }

    public List<Color> ColorsColliedWith { get; private set; }

      public override bool TestCollision(Entity e)
    {

        if (BoundingBox.Intersects(e.GetComponent<Collision>().BoundingBox))
        {
            PerColorCollision ppc = e.GetComponent<PerColorCollision>();

            //Get the area of intersection
            var intersection = new Rectangle();
            intersection.Y = Math.Max(BoundingBox.Top, ppc.BoundingBox.Top);
            intersection.Height = Math.Min(BoundingBox.Bottom, ppc.BoundingBox.Bottom) -
                                  intersection.Y;
            intersection.X = Math.Max(BoundingBox.Left, ppc.BoundingBox.Left);
            intersection.Width = Math.Min(BoundingBox.Right, ppc.BoundingBox.Right) -
                                 intersection.X;

            foreach (var color in Colors)
            {
                for (int y = intersection.Y; y < intersection.Bottom; y++)
                {
                    for (int x = intersection.X; x < intersection.Right; x++)
                    {
                        //We subtract our bounding boxes to set the position back to relative, since the area of intersection would be the at the absolute positions
                        Color color1 = ColorData[(x - BoundingBox.Left), (y - BoundingBox.Top)];
                        Color color2 =
                            ppc.ColorData[
                                (x - ppc.BoundingBox.Left),
                                (y - ppc.BoundingBox.Top)];
                        if (color1.A != 0 && color2 == color)
                        {
                            ColorsColliedWith.Add(color);
                            break;
                        }
                    }
                    if (ColorsColliedWith.Contains(color))
                        break;
                }
            }
        }

        if (ColorsColliedWith.Count > 0)
            return true;
        return false;
    }

    public override void Update()
    {
        ColorsColliedWith.Clear();
        base.Update();
    }

In the base.Update it runs the TestCollision method against all of the partners in Collision.Partners. Is there any other optimization that I can do?


texts:
Game development is a large process. In your experience, how are the total hours for releasing a game divided over the following major areas. I believe this is useful because few people (none?) are really good at all the areas, so this helps me balance the cost of items I'm not so good at when estimating the complexity of creating a game.

Modeling and raw asset creation (textures, audio)
Level design
Gameplay design
Programming
Testing
Marketing


texts:
I am making a mining styled game and am looking to make variables that effect how fast you are able to mine the block. This is the idea I have currently got but it does not wait for the timer to complete before mining, has anyone got a better way to do this?

        if (MinePlayerCollision() && newState.IsKeyDown(Keys.D))
        {
            MiningElapsed = (float) gameTime.TotalGameTime.Seconds;

            if (MiningEff <= MiningElapsed)
            {
                BlockMined = true;
                MineReset = false;

                MiningElapsed = 0;
            }
        }


texts: I am trying to write a strategy game with PHP, and basically I have a 1d based tile map (grass, dirt, sand, castles, etc.) stored in a database. Now where is 40k records, from x1y1 to x200y200 and I might increase it in future. Where is few column in this map table, it's id,x,y,occupied,terrain,city_type My question is, what should be a working caching strategy for something like this? Should game cache it by request, i.e. when player requests x189y15 with radius 5, it will cache the resulting array of tiles and when display it to anyone who requests map with the same x,y and display radius. But what is not efficient because of radius. I thought of storing the whole map in array, but I run into two problems, firstly, how would game select data from array within needed radius? Second, if it can is there a point then? Wouldn't this array be as slow or slower than db access? What is a (best) perfomant caching strategy for this case? Does this need caching at all?


texts: How can I blend the center color of a 2 side gradient so it isn't as harsh looking in Unity Shader Graph?

texts:
I am using the gradient node in Unity's Shader Graph.  It is 2 sided, with it being black-white-black.  The white is quite harsh, it makes a line that stands out.  I will be using this as a mask, and would like the white to not be so strong where it appears as a line.  I don't know if this would be better to do outside of the gradient node or not.
I don't want to use an image (don't know how to create one), as I want more control in the shader.
Edit:  I can add more points and make them less white to try and get a better blend, but this is very tedious and isn't perfect.
Here is what it currently looks like:

Here is what I want to achieve (even this is a little harsh, but closer to what I want):

I tried adding more points but still can't get it right:


texts: Why do we need a depth buffer to display a single 3D cube?

texts:
According to a Vulkan tutorial I am following, I will need to create a depth buffer in order to display a 3D cube:

However, as far as I understand, depth buffers are used for the Z-buffering technique, which helps one efficiently calculate occlusion effects. If I have a single 3D cube in a scene, there is never going to be any occlusion. So why would I need a depth buffer?


texts: How does Against The Wall create an infinite wall?

texts:
There is a game called Against The Wall, developed by Michael P. Consoli. It's a fantastic game, as I've always been stumped at how the game creates an infinitely spanning wall.

In the game, you can fall forever, and the wall will keep spanning. I can fall as long as I like, and still be able to climb back to where I was before. The game is developed in Unity.

How can a game do this without crashing, or creating some kind of memory overload?


texts: So I have this idea for a videogame. How do I make sure it gets heard?

texts: I was wondering how I could get a developer to hear about my idea. I don't really care if my idea gets "stolen", I only want it to be heard. So do you know how I could do this, or am I just being stupid? Again, I only want to know what the developer thinks of the idea, I'm not asking the developer to make it. Sorry if this is a stupid question.


texts: Moving a platform left to right with continuous movement

texts:
I made a 2D game with Unity, and I am trying to create a platform that will move from left to right continuously, but I don't know how to make the platform move a greater distance then -1 to 1 units because I use the Mathf.Sin function. I can only control the speed of the platform.

Here is my code:

private Vector2 startPosition;
private int speed;

void Start ()
{
    startPosition = transform.position;
    speed = 3;
}

void Update()
{
    transform.position =
        new Vector2(startPosition.x + Mathf.Sin(Time.time * speed), transform.position.y);
}

Here is what the code actually does:

How can I control the distance that the platform can move to each side? For now, it can only move 1 unit to each side.


texts: Hardcode model data into geometry shader

texts: I have this idea for creating a point cloud and passing an integer into geometry shader to determine which model to draw, each model has the same amount of vertices etc and it would be hardcoded into shader, this would function somewhat like instancing but models have to have the same data size and you can draw multiple meshes in one call. What do you think about it?


texts:
The first thing that comes in mind is masking using RGBA values. With this you can obtain this kind of textures and this kind of results.

But with this, you can only store up to 4 masks inside a texture and blend between maximum 4 textures.

I am wondering if there's a way to store more than 4 masks inside a texture and being able to blend more than 4 textures using this mask texture. The aim would be to store as much as possible masking data inside a texture.

Is it possible ? How ?


texts: Is there any opensource game frameworks in browser?


texts: In GLUT, how do I bind an action to a press of "any key"?

texts:
Well, this sound ridiculous but the logic is escaping me. I have drawn my cube in OpenGL and I want to translate it to the right if any of the key on the keyboard is pressed. I know how to do this for specific keys but not for all the keys in one function? Do I have to code this for every key?

I was thinking to use glutSpecialFunc and glutKeyboardFunc? Is there any shorter way of doing this?


texts: How to add space in inspector in nested object to a field(property) with PropertyAttribute

texts:
I use GUILayout.Space(px) to add space after some property. Property is drawn using PropertyDrawer via PropertyAttribute.

You can see that Min Max Prop displays properly inside targetObject(AudioPlayer) but if it's in nested object like Engine, Engine Multi, Filed it adds space to the targetObject not the nested object itself.


texts: How can I ensure field of view symmetry in a Roguelike?

texts:
I'm working on a Roguelike, and for it I've created a ray-tracing/casting field-of-view (FoV) algorithm that consists of plotting Bresenham lines to every point in a solid circle. It's artifact free (and reasonably efficient), but it is missing an important requirement of mine: symmetry (if you can see a monster, it must also be able to see you).

Here's an example of the non-symmetric behavior of my code. In the left image I'm standing in a corner (red 'X' blocks = wall). I'm able to see the top right tiles. However, if I move to one of those tiles (right image), I can no longer see the tile from which I came from.

I think I might be after a form of Permissive Field of View, but only because the Roguebasin article suggested it allowed for symmetry. Are there alternative means to get symmetry?


texts:
I am trying to render mandelbrot set using glsl. I'm not sure why its not rendering the correct shape. Does the mandelbrot calculation require values to be within a  range for the (x,y) [ or (real, imag) ] ?
Here is a screenshot:

I render a quad as follows:

float w2 = 6;
float h2 = 5;
glBegin(GL_QUADS);

glVertex3f(-w2, h2, 0.0);
glVertex3f(-w2, -h2, 0.0);

glVertex3f(w2, -h2, 0.0);
glVertex3f(w2, h2, 0.0);

glEnd();

My vertex shader:

varying vec3 Position;

void main(void)
{
    Position = gl_Vertex.xyz;

    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

My fragment shader (where all the meat is):

uniform float MAXITERATIONS;

varying vec3 Position;

void main (void)
{
   float zoom = 1.0;
   float centerX = 0.0;
   float centerY = 0.0;

   float real = Position.x * zoom + centerX;
   float imag = Position.y * zoom + centerY;

   float r2 = 0.0;
   float iter;

   for(iter = 0.0; iter < MAXITERATIONS && r2 < 4.0; ++iter)
   {
    float tempreal = real;

    real = (tempreal * tempreal) + (imag * imag);
    imag = 2.0 * real * imag;

    r2 = (real * real) + (imag * imag);
   }

   vec3 color;

   if(r2 < 4.0)
    color = vec3(1.0);
   else
    color = vec3( iter / MAXITERATIONS );

gl_FragColor = vec4(color, 1.0);
}


texts: How to make TEXT RENDER stand facing the camera of my character and also for the camera of simulation?

texts:
I have an actor (Minion) with a Text Render just above it mesh:

As you have seen, I defined your rotation as absolute, so the text does not rotate along with the actor.

In the game the rotation setting is good and acceptable at various times:

At other times it is very bad:

An example of what I want is something like the life of the champions in the League of Legends:

I would also like to know how to do this when I am simulating:

I've made some attempts at the camera of my main character. And I got some of what I tried.

Character Blueprint:

I know I could put on the Event Begin Play because the camera does not rotate.

Minion Blueprint:

I did (partially):

Ignoring the fact that the text is inverted. I tried Split Struct and added 180 to each of the 3 axes (ROLL, PITCH, YAW) and I could not solve it anyway.

Simulating nothing works:

EDIT 1 (Attempt made based on a_rrat's answer)

Blueprint:

I think I tried all the combinations and none worked the way I would. The combination defined in the image made the Text Render spin.

EDIT 2 (Correction of the attempt I made wrongly)

Correction that I did:

With the answer I was given I noticed a marked improvement.

Result 1:

Besides the value is no longer inverted.

Result 2:

But I still have not got what I like.

Result I am looking for:

I wish life would be displayed the same way anywhere on the map the character is on.

EDIT 3 (Removing roll)

Blueprint:

In game there was no difference.

EDIT 4 (Trying to explain what I want to happen)

I think that because I can not speak English and have to use programs to translate things for myself, I do not know the best way to explain my doubts, the best words, among other things.

I think the best way then to try to explain what I want is with images.

I want regardless of the location or angle life is seen in the same way.

Image:

Image:

Image:

In the LEAGUE OF LEGENDS anywhere on the screen that the champion is, the life bar appears the same way. I would like to achieve this result.


texts:
I am posting here even though this isn't technically a game development question, but involves quaternions.

I have a 9-axis sensor which gives me a world-frame (gravity, magnetic-north) quaternion representing it's orientation. It's mounted on the laces of a running shoe (meaning there is a 'pitch' offset for the sensor, relative to the shoe). Which means that the axis of rotation of the sensor and of the shoe are different. If I 'roll' the shoe along it's lengthwise axis, then the sensor traces out a cone, with the quaternion returning the x,y,z,w components for that cone.

What I'd like is the 'equivalent' quaternion for the axis of the shoe. Ultimately, deriving Pitch, Roll, Yaw for some of our (non)quaternion metrics, like pronation.

Appreciate any pointers, as what I've tried thus far doesn't seem to be working.

Thanks!
-Tim


texts: Is Unity 2017 random number generator deterministic across platforms given the same initial seed?

texts:
Is unity engines random number generator deterministic across platforms given the same initial seed or should I implement my own?

I know there have been some modifications to the random number generator recently.

Answers are appreciated, I don't have the devices on hand to perform any tests and I haven't yet found a direct statement on the matter.


texts: 2D Collision in Canvas - Balls Overlapping When Velocity is High

texts:
I am doing a simple experiment in canvas using Javascript in which some balls will be thrown on the screen with some initial velocity and then they will bounce on colliding with each other or with the walls.

I managed to do the collision with walls perfectly but now the problem is with the collision with other balls. I am using the following code for it:

//Check collision between two bodies
function collides(b1, b2) {
    //Find the distance between their mid-points
    var dx = b1.x - b2.x,
        dy = b1.y - b2.y,
        dist = Math.round(Math.sqrt(dx*dx + dy*dy));

    //Check if it is a collision
    if(dist <= (b1.r + b2.r)) {
        //Calculate the angles
        var angle = Math.atan2(dy, dx),
            sin = Math.sin(angle),
            cos = Math.cos(angle);

        //Calculate the old velocity components
        var v1x = b1.vx * cos,
            v2x = b2.vx * cos,
            v1y = b1.vy * sin,
            v2y = b2.vy * sin;

        //Calculate the new velocity components
        var vel1x = ((b1.m - b2.m) / (b1.m + b2.m)) * v1x + (2 * b2.m / (b1.m + b2.m)) * v2x,
            vel2x = (2 * b1.m / (b1.m + b2.m)) * v1x + ((b2.m - b1.m) / (b2.m + b1.m)) * v2x,
            vel1y = v1y,
            vel2y = v2y;

        //Set the new velocities
        b1.vx = vel1x;
        b2.vx = vel2x;
        b1.vy = vel1y;
        b2.vy = vel2y;
    }
}

You can see the experiment here. The problem is, some balls overlap each other and stick together while some of them rebound perfectly. I don't know what is causing this issue. Here's my balls object if that matters:

function Ball() {
    //Random Positions
    this.x = 50 + Math.random() * W;
    this.y = 50 + Math.random() * H;

    //Random radii
    this.r = 15 + Math.random() * 30;
    this.m = this.r;

    //Random velocity components
    this.vx = 1 + Math.random() * 4;
    this.vy = 1 + Math.random() * 4;

    //Random shade of grey color
    this.c = Math.round(Math.random() * 200);

    this.draw = function() {
        ctx.beginPath();
        ctx.fillStyle = "rgb(" + this.c + ", " + this.c + ", " + this.c + ")";
        ctx.arc(this.x, this.y, this.r, 0, Math.PI*2, false);
        ctx.fill();
        ctx.closePath();
    }
}


texts: Where to put Entity Death Events in a Component/System Design

texts:
Entities in my game are nothing more than a collection of components, tied together with an entityID. I have (near) data-only components, and systems that work on the data.

One of these components is HitPoints. It is one of the few components that has a little bit more than just data: it houses a Dying event that triggers from the HitPointsSystem when the hitpoints go below 0. One of the event listeners is my user interface, while an entity is selected, it listens to the current selection's Dying event. On-death, the entity is dis-selected. Having entities selected draws little circles around the selection. It works great... Right up until I have an entity without HitPoints that can still die.

I have a Missile in my game which does not have HitPoints, but it can be selected, and it can die. When a Missile is selected, my user interface recognizes that it does not have HitPoints, and therefore also does not have a Dying event, which later causes the draw loop to attempt to draw a "selected" and dead Missile, causing a crash.

You might guess that you could just add HitPoints to the Missile and everything would be fine, but my AI targeting system looks for enemy HitPoints because those are the only things it can damage. I don't want missiles to be targeted, and I don't want to add a special rule either.

So... if all entities can die (or be deleted), where do I place the Dying event? Should I be making a new component? Either a component for all things that can die (almost everything), or a component for AI targets? Or is there a better place to put an event like this?


texts:
Im trying to make a Vortex effect on a Circle Body that is a Sensor.
I've been looking for this and all examples i look for are in C++ or Objective C and i dont seem to translate them well.

when my objects collition, it calls beginContact(..) and it sets a flag so that i can call bodyToUpdate.applyForce(...);

 public void beginContact(Contact contact) {
             setColliding(true);
 }

 //updating collition every frame
 public void act(){
     if (colliding) {
        ball.getBody().applyForce(....);

 }

how to calculate the amount of force to apply every frame to make it a vortex?

so i now have the object going straight to the center of the vortex, but no "spin"

public void act() {
    if (colliding) {
        ball.getBody().setLinearVelocity(0, 0);

        ball.getBody().applyForce((portal.getBody().getPosition().x - ball.getBody().getPosition().x) * i,
                (portal.getBody().getPosition().y - ball.getBody().getPosition().y) * i,
                ball.getBody().getPosition().x, ball.getBody().getPosition().y, true);

        i++;
    } else
        i = 10;
}


texts: Android: Asynctask causes ANR (very) intermittently

texts:
I'm doing some work on an AsyncTask (creating game objects, loading resources etc) while displaying a static splashscreen.

The problem is that every now and then, the AsyncTask doesn't run and the app becomes unresponsive.

I must point out that this is extremely difficult to reproduce.  So far today, I've un-installed my app and re-launched it 73 times so far (no joke) and it's behaved perfectly.  However, yesterday (again, after un-installing and installing many many times), I saw the issue about 4 times.  It's very random.

What I'm asking is, if there is anything that I am doing obviously wrong here (or not doing, that I should be)?.

I am:

Targeting Gingerbread, although so far, have only seen this issue on a tablet running Lollipop 5.0.1 (But this may simply be because this is my main test device)
Not sure if I should be doing any 'clean up' in onDestroy?
Am using only 1 AsyncTask - in most of the similar questions that I have read, it seems people are using more than one AsyncTask??
Am starting it from the UI Thread

Also this problem only seems to happen when installing / running from Eclipse. (ie, hitting the run button).  Once it becomes unresponsive, I can close the app and relaunch it straight from the device and it always works OK.

I have checked in onDestory and can confirm the AsyncTask's status is 'finisihed' (obviously only when the app launches OK, not when it crashes) although I'm not performing any specific clean-up work.

Any ideas?

Some Code:

In my onCreate method:

@Override
protected void onCreate(Bundle savedInstanceState) {

    //Only showing code here pertienent to the question (AsyncTask Stuff)
    myAsync= new LoadResources(newBundle);
    myAsync.execute();

}

protected Void doInBackground(Void... params) {

    //It appears that, when the app becomes unresponsive, this my not be reached
    Log.v("tag","DoInBackground");

    //Here I am just creatin game objects, loading sounds and putting some values into sharedPreferences

    return null;
}


texts:
I am working on puzzle game where tiles are needed to be dragged to their correct place, but at the time of dragging one of the textures goes behind the other texture. How can I bring the texture to the top?

       private void OnDraw(object sender, GameTimerEventArgs e)
       {
                         SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue);

         // TODO: Add your drawing code here
        Color transp = Color.White;
     //   transp.A = 200;
        spriteBatch.Begin();

                   spriteBatch.Draw(Texture.piece[1],Texture.piecerect[1],null, transp,0,Vector2.Zero,SpriteEffects.None,1);

        spriteBatch.End();
    }


texts: How do I calculate a new position from current and target position for intuitive non-instant dragging?

texts:
I have a simple 2D game where I can move an object using the mouse. I've been improving on the 'feel' of the movement gradually, however it still doesn't behave as you'd expect if the object were to be moved by human hands in a real-world scenario. My improvements were as follows:

New position = mouse position
Sharp unrealistic movement. No max speed.

Cap the maximum speed
Nicer. Still stops abruptly. Doesn't accelerate smoothly

Add 'inertia', recording last change in position and applying it to subsequent moves

Vastly improved, however...

Object is dragged as if on elastic, slow to accelerate, very slow to stop.
Once moving, object oscillates or orbits around a stationary mouse position.

I'm looking for suggestions on how to make the movement more intuitive:

Moving an object from A to B a human would rarely overshoot

A user shouldn't need to correct against inertia to stop an object

I'd like to be able to adjust the weight of the object so that heavier things are harder to get moving

My current code is as follows:

float maxInertiaChange = 0.1;
Vector2 lastPosition = Vector2.negativeInfinity;
Vector2 inertia = Vector2.zero;

private Vector2 InterpretPosition(Vector2 mousePosition) {
    Vector2 newPosition;
    if (lastPosition.x != float.NegativeInfinity) {
        newPosition = lastPosition + (inertia * Time.deltaTime);
        newPosition = GetPointTowardsTargetWithMaxDistance(newPosition, mousePosition, maxInertiaChange);
        inertia = (newPosition - lastPosition) / Time.deltaTime;
    } else {
        newPosition = mousePosition;
    }
    lastPosition = newPosition;
    return newPosition;
}

private static Vector2 GetPointTowardsTargetWithMaxDistance(Vector2 startVector, Vector2 targetVector, float maxDistance) {
    float lerpScale = maxDistance / Vector2.Distance(startVector, targetVector);
    return Vector2.Lerp(startVector, targetVector, lerpScale);
}

Thanks in advance!


texts:
I am working on a Unity 3D game for Oculus and I have problems with making my objects to apply physics on a player. So getting rid of a CharacterController and using something like a rag doll is not an option.

I am using OVRPlayerController, that has a Rigidbody with mass 1 and a box collider on it. My gameObject has a Rigidbody of mass 100, and a box collider. But when the object hits the player it just goes through it, whereas I want it to push the player in x direction.

I tried using onColliderHit but it doesn't even recognize the collision between the player and the object, so I checked box collider on the object to be a trigger and I use OnTriggerEnter() to recognize the collision.

I tried to translate the player's position on collision, but player gets positioned to weird places out of my map for some reason. Here is what I use:

 info.transform.Translate(new Vector3( -0.5f, 0.0f, 0.0f));
 info.transform.rotation = Quaternion.identity;

I also tried to manually set the x position of the player but this doesn't work, and I know I am not supposed to do it.

I searched for answers for a long long time, so please don't answer to this with something like "oh, have you tried googling it, there are a lot of similar questions" etc.


texts: Unity prefab script "GameObjects" can't be ones on the scene?

texts:
Currently, I have an object on the scene, and one in prefab. I want the prefab's script to reference to the object on the scene through the

public GameObject obj;

code. However, when I tried to add the object in the editor, I cant seem to be able to select any objects from the scene, only ones in prefabs.

I am quite new at unity, so am I missing something really basic here?

Thanks for any help!


texts: Government or NGO grants for game development

texts:
I live in the United States, and I was curious whether or not any governmental grants or NGOs (Non-Governmental Organizations) support game developers via grants or other funding options for games that are not directly developed for commercial gain.

After a quick googling, the only examples I could find were the NEA media arts grant which is restricted to games that can be claimed to be art (arguably all of them), and the ESA Foundation which focus on games for learning but are restricted to giving funding to non-profit organizations.

Are there any other institutions that accept applications for games from individuals? Perhaps similar to Y-Combinator where you have to present a short video of yourself, and a working prototype of your game along with background of the team you will be using to develop it? I'd also like to know whether or not there are institutions that would like to promote a certain cause or aspect through game development by providing developers with resources to pursue this? (Similar to this DOE project)


texts: How to support importing .uasset files in game for content creators(UE4)?

texts:
I would like to support importing clothes(as SkeletalMeshes) and props(as StaticMeshes) as uasset files into game for content creators, which  obviously have not been packaged with the game.
Basically I am looking for a clean modding pipeline.
EDIT:
TLDR:
Is it possible to load .uasset files with StaticLoadObject() into game and use assets from it after the game has been packaged?
Or does it only work with packaged files?
If not what function do you recommend for that purpose?
not-TLDR
Bringing in stuff does work well in the editor, using Rama's LoadObjectFromAssetPath, just by:

right clicking my asset in Content Browser

copy reference

and copy pasting the result to the path variable of the LoadObjectFromAssetPath blueprint node.

Well, I am not sure if it is going to work at runtime...
So I used my favourite search engine and put in some keywords and bumped into this.
Then I wrote some code(Blueprint Function Library):
void UFileDialogOpener::LoadFile(FString  from) {

    auto result = StaticLoadObject(UStaticMesh::StaticClass(), NULL, *from);

    GEngine->AddOnScreenDebugMessage(-1, 150.0f, FColor::Red, "from: " + from);

    if(result)GEngine->AddOnScreenDebugMessage(-1, 150.0f, FColor::Green, "name: " + result->GetName());
    else GEngine->AddOnScreenDebugMessage(-1, 150.0f, FColor::Green, "no result");

    auto * meSkelMesh = Cast<UStaticMesh>(result);

    if(meSkelMesh)GEngine->AddOnScreenDebugMessage(-1, 150.0f, FColor::Red, meSkelMesh->GetName());
    else GEngine->AddOnScreenDebugMessage(-1, 150.0f, FColor::Red, "no mesh");

}

As per the debug messages StaticLoadObject does not find anything.
I tried feeding it the both of the results of righclicking my asset in Content Browser and choosing either: copy reference and copy path.
Neither of them yielded any result.
Not sure where I am messing up.
Anyways, just wondering if anyone can recommend a better way of doing this(code, plugins etc)?


texts: Storing wins and losses locally in Unity

texts:
I am writing here as I have made a game in Unity where I want to store how many wins/losses a player has. The way I am thinking to do it is by putting 2 counters; One for every time a player wins, and one for every time a player loses. What I do when a player wins or loses is that he can shoot something and restart the game; I load scene 0 here. I know that the counters will reset once the player closes the application, but that doesn't matter.

Anyway, is there a better way to do it?

The other thing I am thinking about is storing how many times a player has played the game in total, and this has to be stores locally too and must not get reset when the player closes the application. How is this done?


texts: Nullpointer exception with Scrollpane in LIBGDX

texts:
I get a strange Nullpointer exception and I don't understand why. Can someone help me ?

Exception:

Exception in thread "LWJGL Application" java.lang.NullPointerException
    at com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.draw(ScrollPane.java:583)
    at com.badlogic.gdx.scenes.scene2d.Group.drawChildren(Group.java:123)
    at com.badlogic.gdx.scenes.scene2d.Group.draw(Group.java:57)
    at com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.draw(WidgetGroup.java:163)
    at com.badlogic.gdx.scenes.scene2d.ui.Table.draw(Table.java:119)
    at com.solvapps.tests.NewStoryBook.draw(NewStoryBook.java:40)

My Code ACTOR:

public class NewStoryBook extends Actor {

    Table table;
    ScrollPane pane;
    Table tableScroller;

    public NewStoryBook(Skin skin) {

        int w = Gdx.graphics.getWidth();
        int h = Gdx.graphics.getHeight();
        table = new Table();
        table.setPosition(400, 400);
        table.setSize(w / 3, h * 0.8f);
        tableScroller = new Table();
        tableScroller.add(new Label("bla bla",skin));
        pane = new ScrollPane(tableScroller);

        table.add(pane);

    }

    @Override
    public void draw(Batch batch, float parentAlpha) {
        super.draw(batch, parentAlpha);
        table.draw(batch, parentAlpha);
    }

My Code App:

public class StoryBoxTest4 extends ApplicationAdapter {

    private Stage stage;
    NewStoryBook newstoryBook;

    public void create() {
        stage = new Stage(new ScreenViewport());
        Skin skin = new Skin(Gdx.files.internal(SkinManager.getSkin()));
        newstoryBook = new NewStoryBook(skin);
        stage.addActor(newstoryBook);
        Gdx.input.setInputProcessor(stage);
    }


texts: How can I increase the resolution of a low-polygon model in ZBrush?

texts:
I have a low-polygon model of a character used in an old game, and I would like to improve it into a high resolution one, with more details, for a more recent game.

What process should I follow to achieve this in ZBrush?

I've seen this video which explains that they have done it for the Shadow of the Colossus remake, but they're shy on details.


texts: Moving Draw functions out of GameObjects

texts:
This is basically the issue as in Tactics for moving the render logic out of the GameObject class with the topic already discussed here and here
However I'm not really satisfied with the given answers.

What I have is an event-driven GameEngine, where each object only reacts on events happening at given GameFrames (GFs) and enqueue Events for future notifications. Example: Change state to WALKING and direction to SOUTH and enqueue event for curGF + 10 GFs. After the Engine ticked of 10 GFs, the object is notified, updates its position and decides what to do next (start walking again, start working, disappear, ...) Note here that new state is influenced by current state and event ID.

Now each object has the simple Draw(x, y) method which need to be implemented differently for each object while some stuff can be inherited (e.g. a pig farm lets the base class draw the building and adds a couple of animated pigs depending on current state, productivity,...)

However these 'simple' methods are quite complex and make a bad design as Drawing is coupled to the logic. Also I found animations are using a global object which I'd like to remove, but that means passing an animation 'thing' into each Draw method.

But I don't see how I could possibly uncouple these things, as the drawing functions need to know quite some stuff about the objects internals (state, position, next event execution time) E.g. walk animation drawing must know that, where and how long the object is walking and the object type/sprite set to draw the object interpolated between start and end position. Also objects may be quite different, have attached decorations or goods that need to be drawn etc.

Solutions I see:

Create an all-knowing renderer that knows how to render each object -> Not an option due to many classes and hence large dependencies
Replacing the Draw calls by Renderer instances that render a specific object -> This would mean creating a mirrored class hierarchy which might be hard to maintain and to implement in the first place (Building->BuildingRenderer, Pigfarm->PigfarmRenderer, Mill->MillRenderer)
Introduce basic renderers (sprite, position, animation?) that can be composited to create the final renderer for each object -> GameObjects need to push their state into those, possibly recreating/recompositing them on each update which sounds like a lot of overhead especially if an object is never rendered at all (offscreen). Also does this look very similar to the actual rendering so I doubt a real gain here but a lot of work

Due to long code I just post links to the Draw functions on GH: Drawing building, Base worker drawing, Derived working drawing, Walking drawing functions

I don't see how I could possibly move all this out of the object classes.


texts: Play games services leaderboard does not work all the time

texts:
I am trying to login into play services. I got it working. But there were duplicate game objects created. So I added do not destroy on load and now the play services work the first time I access it.

But when I go to play game scene, end the game and come back to main menu, I can not seem to load the leaderboards.

public class PlayServices : MonoBehaviour {

public static PlayServices services;

private void Awake()
{
    if(services != null)
    {
        Destroy(gameObject);
    }
    else
    {
        services = this;
        DontDestroyOnLoad(gameObject);
    }
}

// Use this for initialization
private void Start () {
    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();

    PlayGamesPlatform.InitializeInstance(config);
    // recommended for debugging:
    PlayGamesPlatform.DebugLogEnabled = true;
    // Activate the Google Play Games platform
    PlayGamesPlatform.Activate();
    SignIn();
}


texts: How to apply transform matrices retrieved from FBX

texts:
I'm trying to import a skeletal animation using FBX SDK. I followed this article, managing to load all the needed data, but when I try to display the animation the mesh falls apart. My knowledge of skeletal animation is fairly limited which may be the issue.

Here is the animation code

for (int i = 0; i < m_numTriangles; i++)
{
    for (int j = 0; j < 3; j++)
    {
        currVertex = m_verticies[m_triangles[i].vertices[j]];
        posVec1.Set(0, 0, 0);
        normVec1 = currVertex.normal;
        for (int k = 0; k < currVertex.blendingInfo.size(); ++k)
        {
            jointIndex = currVertex.blendingInfo[k].index;
            jointWeight = currVertex.blendingInfo[k].weight;

            if (jointWeight != 0)
            {
                transMat1 = m_skeleton.joints[jointIndex].animation[frameIndex1 - 1].transform;
                temp = transMat1.MultT(currVertex);
                posVec1 += temp*jointWeight;
            }
        }
        glNormal3f(normVec1.mData[0], normVec1.mData[1], normVec1.mData[2]);
        glVertex3f(posVec1.mData[0], posVec1.mData[1], posVec1.mData[2]);
    }
}

I iterate over all the triangles, get the vertices, iterate over all the joints that affect said vertex, get the transformation matrix for the current frame and apply.

I believe the problem is with how I'm applying the matrix, but I don't know what I'm doing wrong. I think either I'm skipping a step or I'm misunderstanding what the transform matrix represents.

The article retrieves the global bind pose inverse as follows

currCluster->GetTransformMatrix(transformMatrix);   // The transformation of the mesh at binding time
currCluster->GetTransformLinkMatrix(transformLinkMatrix);   // The transformation of the cluster(joint) at binding time from joint space to world space
globalBindposeInverseMatrix = transformLinkMatrix.Inverse() * transformMatrix * geometryTransform;

This is done for each joint. Do I need to multiply this with the transform matrix before applying to vertex? Like this

transMat1 = m_skeleton.joints[jointIndex].animation[frameIndex1 - 1].transform * m_skeleton.joints[jointIndex].globalBindposeInverse;

Or do I need to also multiply each joints globalBindposeInverse with its parents first?

This is how the article calculates the transform for each frame of animation

for (FbxLongLong i = m_startFrame; i <= m_endFrame; ++i)
{
    FbxTime currTime;
    currTime.SetFrame(i, FbxTime::eFrames24);
    currAnim.number = i;
    FbxAMatrix currentTransformOffset = inNode->EvaluateGlobalTransform(currTime);
    currentTransformOffset *= geometryTransform;
    currAnim.transform = currCluster->GetLink()->EvaluateGlobalTransform(currTime);
    currAnim.transform *= currentTransformOffset.Inverse();
    m_skeleton.joints[currJointIndex].animation.push_back(currAnim);
}

I'm sorry if this is a trivial question, but I've been stuck on this for 4 days now.


texts: I am trying to figure out the difference between a "Material" and a "Material Pass" (in theory). Is it basically that a Material will have multiple "Material Pass"'es, along with a  name. Then the "Material Pass" will have the references to the texture, shaders and property values that need to be set?


texts:
There isn't a really adequate explanation of these anywhere on the internet, so I thought I'd ask this question here.

What are spline input keys in Unreal?
How are they represented in Unreal?

Also:

FindInputKeyClosestToWorldLocation returns a float.

What is this return value?
Why is it a float?


texts: Physics in a 2D oblique perspective game

texts:
So, just to clarify, because I'm still fuzzy on the terms for perspectives in older games myself, examples of an oblique perspective can be seen in many older RPGs (Earthbound, Final Fantasy, Secret Of Mana, etc.).

I've seen many games created in this perspective that utilize a more action-oriented style of gameplay in which one can see various physical interactions at work, such as projectiles, jumping, friction, and more. (Alundra is one that always stands out in my mind)

My question is: How are the physics often being done from a design/engine perspective in these games? Are there common practices for this sort of game design?


texts: How to find a game server in the LAN network with IPv6 technology?

texts: Back in the IPv4 days, people simply used broadcast packets check if there are any server available in the network as described in this answer. But in the IPv6 protocol they've dropped broadcast support. There is still multicast support available but how can/should I use it?


texts: NxWheelShape Tilt with Vision(Havok) Engine and PhysX 2.8.x

texts:
A vehicle I am working on has front wheels that can tilt(lean) left and right as well as turn left and right. The turning was pretty easy, but there seems to be nothing on how to set a WheelShapes tilt and I'm wondering if anyone here has experience with this and can point me in the right direction?

I see there is a SetRotationMatrix() but it also says that it bypasses physics module and will lead to unpredictable results so I was looking into a Vision Engine function that allows me to set a Rotation Delta by passing in a yaw, pitch and roll but that doesn't affect the WheelShape itself, only the 3D Wheel Model and I don't think thats what i want anyway.

I only mention the Vision Engine in case anyone is familiar with both but the PhysX stuff is mostly untouched by the engine. Any suggestions?


texts: Should I scale gravity for small objects?

texts:
If I am working with objects that are small in real life, but in the Unity world they are scaled larger, should I increase the Gravity with the scale of the objects?

For example, if an object of size one would actually be 10 cm across, would gravity scaled to be 10x make the object behave more like a small object would in real life.

I know objects fall at the same rate, but the rate is the same so small objects fall more in proportion to their size don't they?


texts: Virtual game dimensions - how to implement?

texts:
I'm creating a fighting game in LibGDX with a static board, camera moves only right<>left.

There are 5 screen aspect ratios in Android and Apple so I have created 5 different background graphics:

2560x1440 16:9
2560x1920 4:3
2700x1800 3:2
3000x1800 5:3
3200x2800 8:5

Each background width is multiplied by 1.5, cause I need to zoom-out the game when players are too far away from each other, so for example 16:9 isn't 2560x1440 but 3840x1440. (I just realised that I should expand the height too LOL, gamedev is a fantastic place).

When I load the background I check the screen size and scale the background to fit.

The thing I need to implement is: Virtual Coordinates which are the same for each device.

Let's get the screen below:

I need to set virtual board dimensions to for example 2000x1000 units/meters whatever.

When the server sends a message:
Spawn a bomb on (1000,1000), left device spawns it at x=512, right device at x=960 (both on the half).

I think working on pixels is a bad idea, cause I would need to calculate things with each move, jump etc.

If someone could help me, how should I achieve this, I would be grateful for pointing me a way.

Thanks!


texts:
I have Googled for it but there are no ready scripts - as opposed to the same effect on Flash.  I have checked the algorithm on The Water Effect Explained and also tested an implementation of the Perlin Noise, which provides a good simulation of the end of waves on a flat surface. I am looking for the same implementation found on several Flash Effects, based on mouseover/hover actions. This is targetting an interactive floor library, and I would enjoy moving away from Flash for this matter, particularly to avoid such easy reverse-engineering of the code - and yes, I know it could just use some ready-made flash code, but I would only use that as a last resort.

In time: Flash effect sample: flash-effects.com/tutorial-create-a-water-ripple-mouse-follow and a valid similar Java effect: Water Simulation using Java applet.

Has anyone seen a suitable implementation of this effect for Pygame (using OpenGL or not)?

The culprit here is the (code) interface to pass a list of values that will be sent from an external interpreter (tracker - not TUIO though) via Python. I have tried for some straight days but Pygame is not able to generate anything as fast as sheer C/C++ code (as used for the shaders in OpenGL), and my knowledge of C/C++ is null. So the target is to at least have that coming from Python code.


texts: How do I convert DirectX's .X from binary encoding to text encoding and back

texts:
As far as I know, .X format can be text encoded and binary-encoded.

I basically want to look into the model I'm playing with, get a better understanding of .X, possibly make some changes in it and convert back.


texts: How to procedurally (create) grow an artistic (2D) tree in real-time (L-System?)

texts:
Recently I programmed an L-system module, It got me interested further. I am a Plants vs Zombies junkie as well, really liked the concept of Tree of Wisdom. Would love to create similar procedural art just for fun and learn more.

Question: How should I approach the process of creating an artistic tree (2d perhaps with  fixed camera/perspective) dynamically?

Ideally I would like to start with a plant (only a stem with a leaf) and grow it dynamically using some influence (input/user action) over its structure. These influences may result in different type of branching, curves in branches, its spread, location of fruits, color of flowers, etc. Want it to be really full of life/spirit. :)

Plants vs Zombies: Tree of wisdom
It would be great to dynamically grow a similar tree, but with lot more variation and animations happening.

My Background: Programmer, have used few game engines (Ogre3d, cocos2d, unity). Haven't really programmed directly using openGL, trying to fix that :).

I am ready to spend considerable time, Please let me know about the APIs? and how would an expert like you would take on this problem?

Why 2D? I think it's easier to solve the problem only considering 2 dimensions.

Artistic inspirations:

Only the tree, with fruits and leaves, without the shrubs at the bottom

The large tree (visible branches, green leaves, flowers, fruits, etc) on the left, behind monkey.

PixelJunk's Eden (Art style inspiration).

Procedurally Generated Apple Tree using Fractals

Please let me know if it was easy for you to understand the question, I may elaborate further.

I hope a discussion of various approach would be helpful for everyone. You guys are awesome.


texts:
I'm working on an engine for my game (in C++). I've done the graphics related stuff and I've started working on UI (user interface). When I was working on buttons I've realized that hardcoding every kind of button would not be possible (or would be too many classes) as I have buttons with only labels, with colored backgrounds, with texture backgrounds and so on...

So I think what I need are Components. I just build the button I want:

UIButton* btn = new UIButton();
btn->AddRenderComponent(new DrawRectComponent(...));
btn->AddRenderComponent(new DrawStringComponent(...));
btn->AddLogicComponent(new SendEventOnClickComponent(...));

My problem is that I don't know how to tell the component objects what fields should they use from the UI elements? For example position and size (which could change dinamically). Should I use references for example?

Also it would be good if I could not only use this in the UI, but a similar component system could be used in other parts of the engine (at entities for example).


texts: Convert global rotation into local rotation

texts: I have an object in my game and I have its location, rotation and scaling in separate float[3]. The location rotation and scale are all on the global axis; these do not change based on the objects rotation. How would I convert them to the local axis where the xyz always corresponds to the same face?


texts: Graphics card settings tampering with my Java game

texts:
I'm working on a simple 2D side scrolling platform game in java.

It is a canvas with a bufferstrategy which is placed inside a jframe, and that jframe is set as the fullscreenwindow on the graphics device.

Now my computer has a decent nvidia card. In the nvidia control panel on my computer, just looking at the basic settings, if I set the the mode to "Emphasize performance," the game runs as it should and renders properly. The game is not vertical synced.

If I set the mode to "Emphasize quality" or "Let the 3D application decide," the game renders lines a slight distance away from where I intended them, collision detection is also slightly off, and things are overly anti-aliased. The game is now vertical synced.

Now on my crappy laptop, the game runs fine because the card is much less sophisticated. (I think?) However, on my friends computer, he plays with his ATI control center a bit (turns every enhancement off) and then the game runs perfect, but by default its a mess just like with my nvidia card.

TLDR: Is there any way to override the settings on the graphics card or force the settings to be set a certain way from inside Java?


texts: Handling player logoff and logon in a persistent world without breaking immersion

texts:
One problem I've never seen fixed in any persistent online game is how to handle player logon and logoff without the characters just popping in and out of the world.  My first thought is to simply make a player's offline state as their character being asleep, but that doesn't make sense in the event of a disconnect and not an intentional logoff.

How would you fix this, if you would even bother fixing it at all?


texts:
I am developing a mobile game where I need to control main character in any direction using touch analog joystick (https://pineight.com/mw/images/6/6f/Ipoc_dpad.png). It's ok but I also want my character to fire in any direction. Thus I am looking for best solution of control.

There are some variants, but no one is ok:

Target and fire by pointing finger to exact point of the screen (not comfortable, because player will need to hold device by one hand and use second hand to move over the whole device).
Fire to direction where the character moves. This case will limit characters' freedom on move and target. Not good.
Use second touch joystick (under opposite hand) to select fire direction - this variant looks better than previous two, however I still not sure how comfortable it will be. I've tried by myself and it looks a bit complex for me to follow both controls at the same time.

Did you saw any games achieving the same goal? What you can recommend?


texts: Design problem with specific requirements (logical dependencies needed)

texts:
I started to write some code for a small 3D environment. This week I wanted to start with my entities and when I thought about it again, I stumbled across some unmet requirements. My design works fine concerning the game loop, but I missed the logical relationships between distinct entities.
To show what I mean: my entities could interact through a common interface (my base class) but they lack the ability to react to a specific environment, e.g. imagine you have a simulation with some different animals. Some are carnivores (pretator) and some herbivores (prey). When I thought about my design, I somehow missed to include the ability to catch an entity's surroundings. My prey cannot find out about the predators near them ('am I in danger of being eaten? should I flee or am I safe? ..'), nor can the predators actually hunt their prey.

So I am looking for a design that is able to manage all entities through a single interface (game side) and allows information about the environment (entity side).
Besides these, there are some more conditions:

thread-safety
expandable via dll (I'm using C++)
effectivity

Side notes: my entities don't need to change properties during runtime (like in ECS) and I want injected entities (through dlls) to work properly with the original ones (e.g. if someone adds a lion through a dll, any prey should properly react to nearby lions as they are a kind of predator).


texts:
I want to compose conventional triangle-based models and particles with a ray-traced scene at a reasonable frame-rate.

webGL does not let you write the gl_FragDepth in the fragment shader.  You cannot have multiple render targets, but you can render to an RGBA texture and then use that texture as input to another draw-op.  So I can render my ray-traced scene and store the depth as input to the next stage.  This is obviously far from ideal, but workable.

I'd love to be wrong about this, and this is gathered from trial and error rather than any definitive source; please correct any flawed assumptions

How can you pack/unpack a float and, ideally, some flag bits and such, into an RGBA texture efficiently in a GLSL fragment shader?


texts:
I'm a music composition student also getting a minor-plus-some in computer science. I love writing music and making sound effects and want to write music for games. But, I also realize everyone and their mother wants to do that. With that in mind, and since I'm already equally in love with programming, I'm interested in looking at focusing some aspects of the computer science portion of my education towards audio implementation for games.

What I've done/am doing:

Wrote "MusicManager" classes that are aware of musical timings and a small amount of automated mixing based on game events
Reading Who is Fourier? as I work my way toward understanding Fourier analysis and implementing the FFT
Learning FMOD Designer and using the designer API in a game (of course not taking a class specifically on this, I'm good for learning APIs on my own)

With that background, I've got a two-part question.

So aside from the things I list above, and the good ole fundamentals of computer science (data structures and algorithms, discrete math, OO/structured design), what are studios looking for in audio programmers?

Also, G.A.N.G. and Audio Engineering Society lecturers speak as though audio programmers are the next hot thing in games, but do many studios even have or think to hire dedicated audio programmers?


texts: How to reregister gamecontroller changedvalue handler upon game scene reload

texts:
I'm working on a tvOS game that uses the siri gamepad controller. Everything works fine the first time out. If the user loses the round I reload the same scene using presentScene. After reloading the scene any reference to self.xxxxx don't work in the valuechangehandler closure because the it references the first scene not the new one.

In my didMoveToView there is the usual

NSNotificationCenter.defaultCenter().addObserver(self,
        selector: Selector("gameControllerDidConnect:"),
        name: GCControllerDidConnectNotification,
        object: nil)

In the gameControllerDidConnect function we have:

if let controller = notification.object as? GCController {

        if let mGPad = controller.microGamepad {

            let gamePad = mGPad
            gamePad.allowsRotation = true
            gamePad.reportsAbsoluteDpadValues = true

            gamePad.buttonA.valueChangedHandler = { (buttonA: GCControllerButtonInput, value:Float, pressed:Bool) -> Void in

                    print("buttonA")        // <--- this still works
                self.theBall.alpha = 0.5    // <--- this does not

            }}}

Since the observer is added every time the scene is loaded should this not reflect in the self reference to the scene being updated?

Out of sheer desperation I filed a bug report with apple and this is the answer they gave:

When "reloading" the scene, the scene instance is recreated. The old value changed handler for the controller references the ball object in a SKScene instance where it is garbage collected. You need to re-register value changed handler for the controller whenever the scene is reloaded.

So if the addObserver doesn't do this every time then how do I do this inside the didMoveToView method? My apologies if this is a really dumb question. I'm migrating from a lua based SDK to spritekit/swift.


texts: Ease out elastic function with equivalent start and end values?

texts:
I have an elastic ease out function, formula in code:

float easeOutElastic(float t, float b, float c, float d) {
    float ts = (t/=d) * t;
    float tc = ts*t;
    return b+c*(33*tc*ts + -106*ts*ts + 126*tc + -67*ts + 15*t);
}

Taken from here, the elastic out small variant:
http://www.timotheegroleau.com/Flash/experiments/easing_function_generator.htm

I'm trying to modify the function so that the start and end values are equivalent. Essentially the red line.

I am not sure which of the parameters to modify to achieve this. Is anyone familiar with this particular easing function that could provide some guidance?

My goal is to use this function on the scaleY param of a rectangle I'm animating. I think this would provide a nice stretch/squash animation, where the rectangle returns to its original size at the end of the animation.

Thank you


texts: Unity remote security vulnerablity risk identified. Is there a patch for beta versions?

texts:
https://unity3d.com/security?utm_campaign=other_emea_announcement_2017-08-18-EMEA-Security-Notification&utm_content=2017-08-17-Global-Editor-Security-Notification&utm_medium=email&utm_source=Eloqua

Ok So I got an email with the attached link stating there is vulnerablity been identified and I need to patch Unity. However I had several crashing errors and other errors since I updated to 2017.1 and so I'm currently using the beta b6 version.

On the link, i didnt see a mention of a patch. Am I supposed to use the 2017 patch? Or is there not a patch for this ? (If thats the case, should I uninstall the beta , or just not use it? Or is it safe to use?)

SIDE NOTE: Is this WHY I keep getting the error saying : Failed to connect , you longer own this project, check your network connections ... etc . Im worried I had already been hacked maybe?


texts: Alternative solutions to applying an overly large and detailed texture to a mesh

texts:
I have a very large spherical mesh in my Unity scene (the earth), to which one very large texture is applied (a map of the earth). Now it just so happens that Unity's max texture size (8192 pixels I believe) is not enough to capture the details I need on this huge mesh.

What's the proper way to deal with this situation in Unity? That is, not only overriding the 8192 pixels limitations (although that would be nice as a temporary solution), but also making sure the overhead won't become unbearable...

Is there a way to dynamically stream higher quality sections of textures as the camera gets closer to that specific part of the mesh?

Additionally, I see the Granite add-on (http://graphinesoftware.com/products/granite-for-unity) seems to do just this (if I understood it well), but it's only for Windows, and I'm developing on a Mac. Is there any other adding out there?


texts:
I'm working on a dice mechanic/resolution system based on the Ghost/Echo (hereafter shortened to G/E) tabletop RPG. Specifically, since G/E can be a little harsh dealing with consequences and failure, I was hoping to soften the system and add a little more player control, as well as offer the chance to evolve player characters into something unique, right from creation. So, here's the mechanic: Players roll 2 separate d12 against each of the two statistics for their character (each is a number from 2-11, and may be rolled above or below depending on the nature of the action attempted, rolling your stat exactly always fails). Depending on the success for that roll, they add dice to the pool rolled for a modified G/E style action.

The acting player gets two dice anyhow, and I am debating offering a bonus die for each success, or a single bonus die for succeeding on both of the statistic-compared rolls.

Once the size of the dice pool is set, the entire pool is rolled, and the players are allowed to assign the rolled dice to a goal and a danger, one to each. Assigned results are judged as follows:

1-4 means the attempted goal fails, or the danger comes true.

5-8 is a partial success at the goal, or partially avoiding the danger.

9-12 means the goal is achieved, or the danger avoided.

My concerns are twofold:

Firstly, is the two-stage action too complicated, with two rolls to judge separately before anything can happen?

Secondly, are the statistics involved going too far in softening the game? I've run some basic simulations, and the approximate statistics follow:

                 2 dice     (up to) 3 dice      (up to) 4 dice
failure          ~33%            ~25%               ~20%

partial          ~33%            ~35%               ~35%

success          ~33%            ~40%               ~45%

I'd appreciate any advice that addresses my concerns or offers to refine my simulation (right now the first roll is statistically modeled as sign(1d12-1d12), where >0 is a success).


texts: Change animation speed through the editor in Unity

texts:
How can I change the speed of the animation through the editor if I have the following animation structure?

I would like Adult1@walk to play faster.


texts: Is there an engine-agnostic tool for editing curve animations?

texts:
I am looking for a tool that allows to edit 3D animation curves. What I want is something similar to how the animation system works in Unity or others. Being able to create a timeline of transformations to some object, with properties like scaling, rotation, position etc.

I am looking for an engine agnostic tool that can export this in a format that can be parsed and used in my own engine, like some level editors do.


texts:
I noticed something strange while playing with my menu on keyboard.

I have four items arranged in a square (i.e. the top-left item should be able to navigate to the top-right and the bottom-left). If I hover over top-left, hold the right key, and then tap down, the cursor moves to the top-right and then to the bottom-right.

However, if I hold the down key and then tap right, it moves to the bottom-left and does not move to the bottom-right.

This also happens on the reverse side, so it seems as if vertical navigation is being given preference over horizontal. If a vertical key is being held, horizontal navigation is impossible.

How can I turn this off? My buttons are all set to Automatic navigation, and when I turn Visualize on, they all look like they're connected properly.


texts: What are the advantages and challenges of using Haxe over ActionScript 3?

texts:
I read this, and I also see that using FlashDevelop you can make an Adobe Air project with Haxe and compile to exe.

I begun to wonder from a game making perspective:

Are there any additional advantages in performance when using Haxe instead of AS3 for games development (for the web)?


texts: 10 weapon types, 2 proficiencies, rock-paper-scissors relationship?

texts:
I want to make a game where there's a total of 10 general weapon types. I want any given character to be able to be proficient with 2 of the weapon types. Looking at the fact that 10 is an even number, a perfect rock-paper-scissors relationship wouldn't be possible. "C(10,2)=45" however is an odd number, which should be workable into a rock-paper-scissors system.

Since the final number of total weapon pairings is an odd number, I reckon there should be an intuitive and systemically organized way to get a rock-paper-scissors relationship to exist where each weapon pairing is at an advantage against 22 of the other pairings while being at a disadvantage against the remaining 22 pairings. Assuming the 10 weapon types that a character can be proficient with 2 of are labeled A through to J, how should I organize it?

P.S.: A smaller example that runs into the same situation would be "C(6,2)=15"; weapons labeled A through F; if that's more convenient for explanation purposes. Please let me know if this question belongs under different tags or even over on the Mathematics section of SE instead of here; I wasn't sure where to put this question.


texts:
I'm looking to make a button that is activated by two of the same objects, but the code I'm using doesn't recognize the second object as a different instance. Not the best explanation but here's the code:

if place_meeting(x,y,obj_cube) && place_meeting(x,y,obj_cube)

So the game sees this as just one obj_cube and the button is pressed even if there is only one cube on the button. I've tried using variables but I might be doing it wrong.


texts:
I've got a problem with the settings of lighting in my unity scene.

The objects have got "dark sides" and it doesn't look natural.

You can see the screenshots and my light settings here:

The screenshot that shows the problem


texts: how to check if a gameserver can handle clients before game release?

texts: we are developing an iOS-based game with multiplayer support. so far everything seems real good but now we want to make sure if server could handle 10000 clients or not. any idea how can I make sure server will survive that much traffic?


texts: Find the coordinates between two points based on third

texts:
You can see two points in this picture. Points are surrounded by collider which is set to trigger. Points can either be Vector3 or Vector2, shouldn't make any difference.

I need to get the coords on gray line if mouse enters the trigger, at the exact point where mouse and gray line form 90 degree angle. Gray line is just an straight line between 2 points.

All the data:

left point coords
right point coords
mouse coords

Is it possible with the data I have and how?


texts: When input listener set in resize(), input doubles

texts:
I created a button and assigned an input listener in the resize() method of the screen.

For simplicity's sake, whenever I press the button, 1000 adds to a total amount. The weird part is, it adds 2000 when I press the button. Then I moved the button's input listener addition to the constructor - now it works perfectly adding 1000.

For some odd reason, if I set the input handler in the resize method it somehow does everything it is supposed to twice. The game works when I transfer that piece of code to the constructor, but why on earth did it do the assigned thing twice?

This is the code I use for attaching the input listener:

button.addListener(new InputListener() {
        public boolean touchDown (InputEvent event, float x, float y, int   pointer, int button) {
                return true;
        }

        public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
                count += increment;
                countLabel.setText(String.valueOf(count));
        }
    });


texts: Scaling material texture to be 1pixel = 1 unit

texts:
I have a mesh I use to render a sprite texture I set up in a material. This mesh is planar XY-aligned and stationary. It's vertexes are generated from a PolygonCollider.

The problem is that I'm using 1 PPU in the rest of my sprites, but the sprite rendered in the texture looks extremely small.

How can I make the scale of the texture's material, so the size of a pixel in the material is equal to 1 unit?

I can't just scale it, because I need it to be EXACTLY 1 unit.


texts: Mapping dynamic buffers in Direct3D11 in Windows Store apps

texts:
I'm trying to make instanced geometry in Direct3D11, and the ID3D11DeviceContext1->Map() call is failing with the very helpful error of "Invalid Parameter" when I'm attempting to update the instance buffer.

The buffer is declared as a member variable:

Microsoft::WRL::ComPtr<ID3D11Buffer>                m_instanceBuffer;

Then I create it (which succeeds):

D3D11_BUFFER_DESC instanceDesc;
ZeroMemory(&instanceDesc, sizeof(D3D11_BUFFER_DESC));
instanceDesc.Usage = D3D11_USAGE_DYNAMIC;
instanceDesc.ByteWidth = sizeof(InstanceData) * MAX_INSTANCE_COUNT;
instanceDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
instanceDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
instanceDesc.MiscFlags = 0;
instanceDesc.StructureByteStride = 0;

DX::ThrowIfFailed(d3dDevice->CreateBuffer(&instanceDesc, NULL, &m_instanceBuffer));

However, when I try to map it:

D3D11_MAPPED_SUBRESOURCE inst;
DX::ThrowIfFailed(d3dContext->Map(m_instanceBuffer.Get(), 0, D3D11_MAP_WRITE, 0, &inst));

The map call fails with E_INVALIDARG.  Nothing is NULL incorrectly, and this being one of my first D3D apps I'm currently stumped on what to do next to track it down.  I'm thinking I must be creating the buffer incorrectly, but I can't see how.  Any input would be appreciated.


texts:
I am learning to use godot following this video:
Collisions with Autotiles
The problem is that when I create the collision for the cliffs using tilemap, it appears me a blue quadrant indicating the collision. What should I do for what these "quadrants" do not appear?

As you can see, all the cliffs are blue for indicate me the collision, but I have no idea about what to do for hide them.


texts:
I keep hearing the word "affordance" in terms of game design, most recently in the movie Indie Game: Life After. I also vaguely remember it from a UX class in undergrad. But I have no idea what it means.

What is an affordance in the context of game design?


texts: Unity 2019.3 - Player getting stuck on wall

texts:
Problem
I have a wall made with a Tilemap and a Tilemap Collider 2D. Sometimes, when the player jumps against the walls, it seems to get stuck. You do not need to be pressing the directional button, when pressing jump, for this to happen. Just being pressed against the wall, and then pressing the jump button alone, reproduces the error.
Demo

What I have tried
I applied a Physics collider to the Walls with friction set to 0. It didnt solve the issue.

Info that might be relevant to solve this
This is the player controller for the movement. Notice the FixedUpdate method, to see how I control the velocity of the Rigidbody2D.
using UnityEngine;
using UnityEngine.InputSystem;

namespace Notan
{
    public enum Direction3 { Left, Right, Still }

    [RequireComponent(typeof(Rigidbody2D))]
    public class PlayerMovement : MonoBehaviour
    {
        [SerializeField, Range(0f, 100f)] float speed = 10f;
        [SerializeField, Range(1f, 20f)] float jumpForce = 3f;

        Rigidbody2D body;
        Direction3 direction;
        bool jumpScheduled;

        void Awake()
        {
            body = GetComponent<Rigidbody2D>();
        }

        void Update()
        {
            UpdateDirection();
            UpdateJump();
        }

        void FixedUpdate()
        {
            UpdateVelocity();
        }

        bool LeftPressed() => Keyboard.current.leftArrowKey.isPressed;

        bool RightPressed() => Keyboard.current.rightArrowKey.isPressed;

        bool SpacePressed() => Keyboard.current.spaceKey.wasPressedThisFrame;

        void UpdateDirection()
        {
            direction = LeftPressed() ? Direction3.Left : RightPressed() ? Direction3.Right : Direction3.Still;
        }

        void UpdateJump()
        {
            if (SpacePressed()) jumpScheduled = true;
        }

        // Left is -1
        // Right is 1
        // Still is 0
        int GetHorizontalDirection() => direction == Direction3.Left ? -1 : direction == Direction3.Right ? 1 : 0;

        void UpdateVelocity()
        {
            var velocity = body.velocity;
            velocity.x = GetHorizontalDirection() * speed;
            if (jumpScheduled)
            {
                velocity.y = jumpForce;
                jumpScheduled = false;
            }

            body.velocity = velocity;
        }
    }
}

This is the configuration of the players Rigidbody2D

Unity version
I am using Unity 2019.3.9f1.


texts: What standards should designers/artists follow when giving UI assets to coders?

texts:
How do you or your company require designers to deliver their assets to coders?  Do they deliver a PSD?  A series of 24-bit PNGs?

If you are a coder, what would you include in a best-practice guideline to designers?  If you are a designer, what questions would you like to see answered in such a document?

Here are some ideas:

Generally:

include designs for mouse-over and mouse-down states for all
buttons and other interactive elements, as well as the normal state.
for toggle buttons, this can also include different states for
both selected and unselected modes, for 6 states total: normal,
over, down.
in drop-downs, lists, etc, please design a selected and unselected
state for each item, if appropriate, especially where the content
varies.
Flash is strictly an sRGB colorspace.  If creating assets for
Flash, make sure that your deliverables look how you expect it in
sRGB.

If delivering assets as a PSD, please:

label all layers clearly.
make sure that the dimensions of your document exactly match the
dimensions of the application

What else would you include in a Visual Asset Delivery Best Practices document?


texts:
I'm attempting to rearrange a Unity project that is under source control. Two problems:

In order to maintain the relationships between assets, I need to use Unity's API or interface. But when I move something that way, git loses track of them.
In order to maintain git tracking, I need to use git commands. But when I move them that way, Unity loses track of how they're related.

Is there an easy way for me to tell one what the other is doing?


texts: Why is there such a difference in between my scene and game?

texts:
Here I have 2 screenshots of my problem:

By the way my water shader works with Screen position and Scene Depth.
I can include them here if needed.
Here is my shader(GoogleDrive)
Added
Now it looks like that when I move window "game" to the side:

Added
Here's graph's screenshoots:

P.S. I think it's something in unity's settings but not in shaders(not sure).


texts:
When i'm compiling a shader does it have to be complete? Can i use glCompileShader on a shader without a main() function? The OpenGL reference documentation has a nice writeup on program linking errors, but i can't find one for shader linking, so i have to ask here.

I want to have the ability to have each part of a shader in a different file. So f.e. i'll have a material calculating function and i'll have a "main" shader with the main function that'll only reference the material calculating function. Right now i have my shaderes as arrays of strings that they can read from a file, then i put together an array of string pointeres and compile that into a single shader (vertex, fragment, geometry). But if i could compile each invidividual shaders (parts of vertex shaders, instead of the whole vertex shader put together in an array of strings) and put them together when i'm linking the program, that would make the code much clearer and i could move the shader compilation code from the program managing code to the shader object itself (the one that load the string from file and exposes it).


texts: How to only allow letters to be pressed on in pygame?

texts:
I want the user to press on any letter of the alphabet; it should block the input from the rest of the keys. How can I do this using pygame?

Keys=pygame.key.get_pressed()


texts: Moving autonomous robot form one location to another based on array

texts:
I have a 3D model of a house, and I want an autonomous robot to move from 1 object in this house to the next one. I have it moving to the first, but it won't move to the second one. This is my code:

using UnityEngine;
using System.Collections;

public class MoveTo : MonoBehaviour {

public Transform[] goals;

void Start () {
    NavMeshAgent agent = GetComponent<NavMeshAgent> ();
        agent.destination = goals[0].position;

    if (agent.transform.position == goals[0].position) {
        agent.destination = goals[1].position;
    }

}
}

I'm a complete beginner in code, please keep that in mind :)


texts: Unity3D: How to just center a mesh inside a character controller!

texts:
Hi I have a simple character mesh and it's parented to my character controller-invisible-capsule object and all the moving code is applied to the parent (if that's relevant), but the point Is I'm trying to line up the mesh to be exactly inside the capsule to make it look like the player is walking ABOVE the ground (pretty normal ...?) So by default the character controller is origined in the center so I move it up by half of it's height to try to get it to line up with the character mesh, which has it's origin below it's feet a little, and this is the result:

as you can clearly see, his feet slightly go into the ground, I have no idea why this is happen, then should be just above the ground like any other normal feet! Here's the code for setting the capsule up half of it's width, since it starts by lining up the mesh in it's CENTER for some reason:

Vector3 tempPos = player.transform.position;

        tempPos.y += (capsuleSize.y / 2);// + chassidSize.y / 12;
        chassid.transform.position = player.transform.position;
        player.transform.localPosition = tempPos;
        chassid.transform.parent = player.transform;

and here's a picture of the mesh (which is just a blender file, easier for import):

As you can see, in the blender file, the origin is slightly below the characters feet, IN THE CENTER, so I don't know why it's not working as planned.

Also, you can see in the first picture that he's slightly moved to the center of the controller on the z(?) axis, but I want him to be completely centered in, any idea how to fix this?


texts: What Shading/Rendering techniques are being used in this image?

texts:
My previous question wasn't clear enough. From a rendering point of view what kind of techniques are used in this image as I would like to apply a similar style (I'm using OpenGL if that matters):

http://alexcpeterson.com/

My specific questions are:

How is that sun glare made? How does the planet look "cartoon" like? How does the space around the planet look warped/misted? How does the water look that good?

I'm a beginner so any information/keywords on each question would be helpful so I can go off and learn more. Thanks


texts: How to build repetition into a game that won't ruin the experience

texts:
I am building an Educational technology (Edtech) game that attempts to follow the format of an adventure RPG while teaching foreign languages.

Obviously, EdTech games must actually teach, which requires repetition for mastery. Especially foreign languages which requires a lot of practice to master. But, the game's goal is for the story line and game world to be immersive to the point the player is hooked in. Repetition often destroys the immersive aspect and linearity of a story.

What are some strategies to ensure the necessary repetition is happening such that a student retains the information, but also has fun playing along with the story? Are there any?


texts: If "ResourceManager" classes are considered bad, what are the alternatives?

texts:
I'm hearing conflicting opinions such as:

"Dedicated Manager classes are almost never the right engineering tool"
"Dedicated Manager classes are (currently) the best way to survive a large project with thousands of resources"

Let's take a classic ResourceManager class that has the following functionality:

Loads assets (textures, audio, 3D models, etc)
Ensures assets are only loaded once by keeping a cache
Reference counts assets to determine if they can be deallocated
Hides where the actual assets came from (e.g., could be one file per asset, or all assets in one package file, or assets could even be loaded over the network)
Can reload assets without restarting the program, which is extremely useful for the artists working on the game.

Let's also take the "singletons are bad" argument off the table by pretending these ResourceManager objects are not singletons, and instead are passed around via dependency injection.

Then there is the "use a factory" or "call it a factory" argument. My problem with this is that, yes, it is a factory, but it's also a cache and a reloader (for lack of a better word). Calling it a factory doesn't describe it properly, and if I make it a proper factory then where does the caching and reloading get implemented?

I agree that "Manager" classes are often a symptom of bad architecture, but in this particular case how could it be restructured and still retain all of the functionality? Is this a situation where a "Manager" class is actually appropriate?


texts: Versions of GL and its device that don't display or required powers of 2 for the sprites

texts: From this question aside from identifying possibilities of displaying images that don't needed to require powers of 2, what are the versions of GL that can actually display images even if don't needed the power of 2 size?


texts: How to access specific child indices (directly, not using tags or searches)?

texts:
I have a game object whose prefab is structured a very specific way. It is a conveyor belt. I intend to arrange them end-to-end and animate them all at once using a script. Right now I am trying to get the normalized heading vector between two children, TargetStart and TargetEnd (see images below):

You can see that both of these objects are children of the prefab's first child. Because all of these instances will be structured the same, I want to compute the heading for the conveyor belt by accessing the locations of these children by their indices relative to the parent (which sounds like it should be simple and should be more efficient than searching by name or tag). I am anticipating a structure like this (pseudo-code):

// heading = targetEnd's position - targetStart's position
vector3 heading = gameObject.GetChild[0][1].position - gameObject.GetChild[0][0].position;
vector3 direction = heading / heading.magnitude;

How can this be done? I would like to know this so I can access any child I need to for any object by the child's index.


texts: Unity: Smart approach needed: Enemy AI detection of firearm discharge

texts:
If the player fires his firearm within a certain hearing range of an Enemy Bot, the Enemy AI should be alerted to his position. My initial solution to the problem was the following: Everytime the player fires a shot, find all Enemy AI Game Objects and trigger a function that checks wether the player is within hearing range or not.

The problem is some weapons have a firerate of up to 20 shots per second. And if there are 25 enemies in the scene it means that, while shooting, I will be asking for GameObject.FindGameObjectsWithTag(Enemy); and accessing a function within 500 times every second. This is not very performance friendly.

I cannot think of a better way to do this. Is there?


texts: Lunar lander: How to calc acceleration in each step

texts:
I'm trying to make a lunar lander simulator. I'm going to use a simple Euler integration. AFAIK all I've to calculate is the acceleration in each step, and then I should be able to update velocity and position.

I'm following this page:
http://www.braeunig.us/apollo/LM-descent.htm

There's a paragraph I don't really understand:

  Although most operations are self-explanatory, a brief description of
  acceleration is warranted. Acceleration is broken down into vertical
  and horizontal components, where the vertical component is normal to
  the Moon's surface. The instantaneous vertical and horizontal
  accelerations of a moving body in reference to this surface are
  Av=Vh^2/r and Ah=–VhVv/r. To this we add the accelerations resulting
  from gravity and thrust. Gravity, of course, acts vertically downward.
  The vertical and horizontal components of thrust are a function of the
  pitch angle.

The author is making a much more realistic simulation here and because of that he is not assuming the Moon is flat. He comes up with two initial values for each acceleration component:

    Av=Vh^2/r

    Ah=–VhVv/r

1- Seems that Av is the centripetal acceleration, but where does the Ah come from?

2- Are those initial values really needed? In my game the Moon is going to be flat. I thought taking into account thrust/mass and gravity would suffice.

Thanks in advance.


texts: What is the meaning of the row "opposite" the translation column?

texts:
Usually, I do my matrix multiplication like this:

[1 0 0 dx] | [px]   [px + dx]
[0 1 0 dy] | [py]   [py + dy]
[0 0 1 dz] | [pz] = [pz + dz]
[A B C  1] | [1]    [1]

Where the translation is along the right-hand edge of the matrix.

Once, I forgot about that and put them on the lower line instead, on the places marked as A B C above.

What did that do to the resulting points?  With the upper-left 3x3 being an identity matrix, and the translation being zero, nothing happened to my point

[1 0 0 0] | [1]   [1]
[0 1 0 0] | [1]   [1]
[0 0 1 0] | [1] = [1]
[1 2 3 1] | [1]   [7]

except that 1 we always use in fourth place gets changed. Does this mean further multiplication with the point results in a mess? What am I doing by changing the bottom row?