texts: How can a team work together to assemble a large world map?

texts:
I recently played a open world FPS game with a large and dense game world, in a single map like this.

It contains many objects, roads, rivers, trees, houses, rocks, hidden places, NPCs, etc... all carefully placed relative to each other. The game was made in two years (which is pretty fast regarding the content).

How can a team work at the same time on such a huge map?

3D models and textures can have been done separately and in parallel as I understand. The question is about how to put all this content on the map and model the map itself (lowering or raising some parts since it is a huge heightmap).

Several things solutions I have in mind:

The map could be divided into big chunks, with each person (or small team) working on a small part. Then (at the end) everything is reassembled. I seriously doubt this, because of the map topology. Or maybe the height of the map was fixed first (no more change possible after some point), then map cut in squares, then reassembled (which would work because height was not changed).
Developers created a multi user editor where it is possible to connect to a server (using LAN) then any change in editor would be directly visible and propagated to other editors connected to the same server. Something like Minecraft.

How can this be done? Has anybody worked on a similar game?


texts: Modifying Alpha in Unity Standard Shader

texts:
I'm trying to create a shader in Unity with a slider that can adjust the transparency. (This is the first step toward something more sophisticated.) I try to do this by setting the alpha of the SurfaceOutputStandard struct to the texture alpha times a value between 0 and 1:

Shader "Custom/MakeVisible" {
    Properties {
        _Color ("Color", Color) = (1,1,1,1)
        _TransparencyMult ("Transparency Mulitplier", Range(0,1)) = 1
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
    }
    SubShader {
        Tags { "RenderType"="Transparent" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard fullforwardshadows
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input {
            float2 uv_MainTex;
        };

        half _Glossiness;
        half _Metallic;
        fixed4 _Color;
        half _TransparencyMult;

        UNITY_INSTANCING_CBUFFER_START(Props)
        UNITY_INSTANCING_CBUFFER_END

        void surf (Input IN, inout SurfaceOutputStandard o) {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
            o.Albedo = c.rgb;
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;

            //Multiply alpha by value between 0 and 1
            o.Alpha = c.a * _TransparencyMult;
        }
        ENDCG
    }
}

This seems like it should work, since Alpha is an available property. But it doesn't. Here's a screenshot:

EDIT:

I realized after reading closer that I needed to add the alpha:fade parameter for that to work, however, when I add that it is always transparent no matter what:

EDIT:
I changed the shader code according to Draco's answer:

Shader "Custom/MakeVisible" {
    Properties{
        _Color("Color", Color) = (1,1,1,1)
        _TransparencyMult("Transparency Mulitplier", Range(0,1)) = 1
        _MainTex("Albedo (RGB)", 2D) = "white" {}
        _Glossiness("Smoothness", Range(0,1)) = 0.5
        _Metallic("Metallic", Range(0,1)) = 0.0
    }
    SubShader {
        Tags {
            "IgnoreProjector" = "True"
            "RenderType" = "Transparent"
            "Queue" = "Transparent"
        }
        LOD 200
        Blend SrcAlpha OneMinusSrcAlpha
        CGPROGRAM
        #pragma surface surf Standard fullforwardshadows alpha
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input {
            float2 uv_MainTex;
        };

        half _Glossiness;
        half _Metallic;
        fixed4 _Color;
        half _TransparencyMult;

        UNITY_INSTANCING_CBUFFER_START(Props)
        UNITY_INSTANCING_CBUFFER_END

        void surf(Input IN, inout SurfaceOutputStandard o) {
            fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
            o.Albedo = c.rgb;
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;

            //Multiply alpha by value between 0 and 1
            o.Alpha = c.a * _TransparencyMult;
        }
        ENDCG
    }
}

Now it is always the same transparency with no texture:


texts:
Due to this question I have changed the method of rendering portals. Before I was using FBO and rendering to a texture, but somehow I failed. Now I switched to a stencil buffer method.

My problem is that I don't know how to set properly the stencil buffer parameters. I'm doing it like in this tutorial. I have done rendering virtual scenes to portals, but the problem is that the portals are visible always, even if they are behind the wall.

Here's my code:

glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_STENCIL_TEST);

glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glDepthMask(GL_FALSE);
glStencilFunc(GL_NEVER, 0, 0xFF);
glStencilOp(GL_INCR, GL_KEEP, GL_KEEP);

// here goes rendering the portal geometry //

// here some other properties for rendering the virtual scene
// in a portal, but that does not matter now

// this part is important:
glStencilFunc(GL_NOTEQUAL, 1, 0xFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);  // this shows image 1
glStencilOp(GL_ZERO, GL_KEEP, GL_KEEP);  // this shows image 2 and 3

// here goes rendering main scene //

Here are this images:

Image 1:

When changing the first glStencilOp to the second one I got it working:

But then problem occurs in other place like here:

How to deal with it?


texts: Should the Oj lobe of a Lafortune shader cause the light to be displaced?

texts:
I implemented the Lafortune shader in WebGL, and my biggest concern is about this formula:

Explanation

Kd/Ks is the material diffuse/specular color, ρd/ρs is the light diffuse/specular component, m is the number of lobes (in my shader I always use a single lobe), o is the viewer direction (from the surface point), i is the light direction, Oj is the lobe and ej is the shininess factor.
Full reference is here: A survey of shading models for real-time rendering, at page 28.

Question

The problem comes with the Oj lobe. I realized that as I change the value of Oj, the light gets displaced from it's original position, for example that's what I get with Oj= (-1,-1,1):

And that's what I get with Oj=(0,0,1):

Is that behavior normal? Should the light get displaced according to the value of Oj?


texts: Is there a site where people discuss game concepts and questions in general?

texts: I like making game concepts for fun, as a hobby. I don't think that all my game concepts are amazingly awesome and have to be created and would revolutionize the industry. I just want some people to talk to that have the same hobbies as I do. To be able to discuss ideas and point out the pros and cons.


texts: SDL2 taskbar icon notification (blinking / flashing orange)?

texts:
In steam when you get a message, or in CS:GO when you find a match the taskbar icon flashes orange and your taskbar becomes unhidden if that's how you have it setup.

In SDL2 you can set a window icon fairly easily, but is there a way to notify the user such as bringing "up" the taskbar?


texts: Transform texture coordinates when using shader

texts:
Assuming I define four vertices of a quad with texture coordinates that cover a whole texture or region of a texture, I can animate these coordinates by setting a transform using

SetTransform( D3DTS_TEXTURE0, &texTrans )

...scaling, translating etc.

If I render using a shader, and still want to animate the coordinates, presumably I can pass in the same transformation matrix and multiply the coordinates in the vertex shader?

Instead of in the vertex shader

Output.TextureUV = vTexCoord0;

do

Output.TextureUV = mul( vTexCoord0, texTrans );

Is this a/the correct way to render an animated sprite with shader?


texts:
I want to port a WP7 XNA game to WP8 using MonoGame. The thing is that I have Windows 7. So here's the questions (if some sound dumb, please bare with me).

Do I need to have Windows 8?
Do I need to have the Windows Phone SDK 8?
How do I get the templates for Visual Studio so I can create a project for WP8?

I'm kinda newbie into this monogame thingy. I've been using XNA for quite a while.


texts: What are the newest alternative to all-in-one game engines?

texts:
I have been seaching a while for recent alternative to engines like unity or unreal, however, I haven't found one actively maintained that meet my needs.

For instance, I tried irrlicht with maps editors such as 3D world studio or irrEdit, but those didn't have any big feature update since 2010.

That is why I'm looking for new alternatives, here are my constrains :
- Language : C, C++ or JAVA
- Able to render 2D sprites in 3D world ( like the battles of agarest)
- Native Bumpmap support
- Lightweight
- Run both on linux and windows
- Compatible with free or low-cost map editors
- Able to do Borderless fullscreen


texts:
So I'm using Farseer to create an immovable object:

[...]
private Body body;
public Immovable(World world, ContentManager c, String s, int posx, int posy, int w, int h, String user_data)
{
    texture = c.Load<Texture2D>(s);
    float converted_width = ConvertUnits.ToSimUnits(w);
    float converted_height = ConvertUnits.ToSimUnits(h);
    float converted_posx = ConvertUnits.ToSimUnits(posx);
    float converted_posy = ConvertUnits.ToSimUnits(posy);
    body = BodyFactory.CreateRectangle(world, converted_width, converted_height, 1.0f, new Vector2(converted_posx, converted_posy), user_data);
    body.BodyType = BodyType.Static;
    width = w;
    height = h;
    x = posx;
    y = posy;
}

What I'm trying to do is keep separate my values for screen units (here, width, height, x, and y) and my values for simulated units (here, stored in body). This way, later, when I draw the object to the screen, I can:

public virtual void Draw(SpriteBatch sb)
{
    sb.Draw(texture, new Rectangle(x, y, width, height), Color.White);
}

This way, when I instantiate things, I can visualize them as screen coordinates, which should hopefully keep me sane during all this! Theoretically (especially as these objects don't move), these two coordinate pairs should be in the same spot (or off by a maximum of one pixel if I'm truncating floats to an int somewhere).

However, for some reason, my rectangles are being offset by ~25 pixels up and to the left. Here's a screenshot:

You can see that he has "landed" just above where the rectangle is being drawn. I can float around the box to explore where the physics engine believes it is, and I find that it's up and left about 25 pixels.

Any ideas on what could be causing this?


texts: Converting a GameObject method call from UnityScript to C#

texts:
Here is the UnityScript implementation of the method i use to generate a randomly tiled background, the problem i'm having relates to how to translate the call to the newTile method in c#, so far i've had no luck fiddling... can anyone point me in the correct direction?

Thanks

#pragma strict
import System.Collections.Generic;

var mapSizeX : int;
var mapSizeY : int;
var xOffset : float;
var yOffset : float;

var tilePrefab : GameObject;
var tilePrefab2 : GameObject;

var tiles : List.<Transform> = new List.<Transform>();

function Start () {
    var i : int = 0;
    var xIndex : int = 0;
    var yIndex : int = 0;
    xOffset = 2.69;
    yOffset = -1.97;

    while(yIndex < mapSizeY){
       xIndex = 0;
       while(xIndex < mapSizeX){

                var z = Random.Range(0, 5);

                if (z > 2)
                {

                 var newTile : GameObject = Instantiate (tilePrefab, Vector3(xIndex*0.64 - (xOffset * (mapSizeX/10)), yIndex*-0.64 - (yOffset *  (mapSizeY/10)), 0), Quaternion.identity);
                 tiles.Add(newTile.transform);
                 newTile.transform.parent = transform;
                 newTile.transform.name = "tile_"+i;
                 i++;
                 xIndex++;

                 }

                 if (z < 2)
                {

                 var newTile2 : GameObject = Instantiate (tilePrefab2, Vector3(xIndex*0.64 - (xOffset * (mapSizeX/10)), yIndex*-0.64 - (yOffset *  (mapSizeY/10)), 0), Quaternion.identity);
                 tiles.Add(newTile2.transform);
                 newTile2.transform.parent = transform;
                 newTile2.transform.name = "Ztile_"+i;
                 i++;
                 xIndex++;

                }

       }

       yIndex++;
    }
}

C# Version [Fixed]

using UnityEngine;
using System.Collections;

public class LevelGen : MonoBehaviour {

    public int mapSizeX;
    public int mapSizeY;
    public float xOffset;
    public float yOffset;

    public GameObject tilePrefab;
    public GameObject tilePrefab2;

    int i;

    public System.Collections.Generic.List<Transform> tiles = new System.Collections.Generic.List<Transform>();

    // Use this for initialization
    void Start () {

        int i = 0;
        int xIndex = 0;
        int yIndex = 0;
        xOffset = 1.58f;
        yOffset = -1.156f;

        while (yIndex < mapSizeY)
        {
            xIndex = 0;
            while(xIndex < mapSizeX) {

                int z = Random.Range(0, 5);

                if (z > 5)
                {
                    GameObject newTile = (GameObject)Instantiate(tilePrefab, new Vector3(xIndex*0.64f - (xOffset * (mapSizeX/10.0f)), yIndex*-0.64f - (yOffset *  (mapSizeY/10.0f)), 0), Quaternion.identity);
                    tiles.Add(newTile.transform);
                    newTile.transform.parent = transform;
                    newTile.transform.name = "tile_"+i;
                    i++;
                    xIndex++;

                }

                if (z < 5)
                {
                    GameObject newTile2 = (GameObject)Instantiate(tilePrefab, new Vector3(xIndex*0.64f - (xOffset * (mapSizeX/10.0f)), yIndex*-0.64f - (yOffset *  (mapSizeY/10.0f)), 0), Quaternion.identity);
                    tiles.Add(newTile2.transform);
                    newTile2.transform.parent = transform;
                    newTile2.transform.name = "tile2_"+i;
                    i++;
                    xIndex++;
                }

            }
            yIndex++;
        }

    }

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

    }
}


texts: In my sprite editor, under the weights menu, the option for bone influence appears kinda faded and I am not able to select it. Unity is also not generating automatic weights around my bones for different sprites in the same image. Is this feature only available in the pro version, or is there some other setting that is causing the problem?


texts:
I am developing a 2D shmup (i.e. Aero Fighters) and I was wondering what are the various ways to store a level. Assuming that enemies are defined in their own xml file, how would you define when an enemy spawns in the level?

Would it be based on time? Updates? Distance?

Currently I do this based on "level time" (the amount of time the level is running - pausing doesn't update the time). Here is an example (the serialization was done by XNA):

<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:level="pekalicious.xanor.XanorContentShared.content.level">
  <Asset Type="level:Level">
    <Enemies>
      <Enemy>
        <EnemyType>data/enemies/smallenemy</EnemyType>
        <SpawnTime>PT0S</SpawnTime>
        <NumberOfSpawns>60</NumberOfSpawns>
        <SpawnOffset>PT0.2S</SpawnOffset>
      </Enemy>
      <Enemy>
        <EnemyType>data/enemies/secondenemy</EnemyType>
        <SpawnTime>PT0S</SpawnTime>
        <NumberOfSpawns>10</NumberOfSpawns>
        <SpawnOffset>PT0.5S</SpawnOffset>
      </Enemy>
      <Enemy>
        <EnemyType>data/enemies/secondenemy</EnemyType>
        <SpawnTime>PT20S</SpawnTime>
        <NumberOfSpawns>10</NumberOfSpawns>
        <SpawnOffset>PT0.5S</SpawnOffset>
      </Enemy>
      <Enemy>
        <EnemyType>data/enemies/boss1</EnemyType>
        <SpawnTime>PT30S</SpawnTime>
        <NumberOfSpawns>1</NumberOfSpawns>
        <SpawnOffset>PT0S</SpawnOffset>
      </Enemy>
    </Enemies>
  </Asset>
</XnaContent>

Each Enemy element is basically a wave of specific enemy types. The type is defined in EnemyType while SpawnTime is the "level time" this wave should appear. NumberOfSpawns and SpawnOffset is the number of enemies that will show up and the time it takes between each spawn respectively.

This could be a good idea or there could be better ones out there. I'm not sure. I would like to see some opinions and ideas.

I have two problems with this: spawning an enemy correctly and creating a level editor. The level editor thing is an entirely different problem (which I will probably post in the future :P).

As for spawning correctly, the problem lies in the fact that I have a variable update time and so I need to make sure I don't miss an enemy spawn because the spawn offset is too small, or because the update took a little more time. I kinda fixed it for the most part, but it seems to me that the problem is with how I store the level.

So, any ideas? Comments?

Thank you in advance.


texts: Chess Programming - Principal Variation and Transposition Tables

texts:
Right now I am currently trying to implement a principal variation search algorithm for my chess engine (C++) as well as a transposition table. I have looked at various sources online and have become confused on how to properly store the principal variation. I have seen some sources/implementations use a seperate array of structs that can be indexed at a certain depth to extract the pv move and I have also heard about people storing the principal variation moves within the transposition table. Therefore I have a few questions that I would like to ask to perhapse clear my mistunderstanding.

Should I or should I not have a seperate array to store the principal variation and store it in the transposition table. Which is better?

If I store it in the transposition table the same as other moves, how would I go about preventing that entry from getting overwritten by another move????

Or am I thinking about this wrong? What then is the proper way to do this?


texts: Out of curiosity, does anyone know how feasible it would be to have a voxel engine that allowed for voxels within other voxels? For example, you would have the usual chunks filled with voxels, but instead of stopping there each voxel could become a chunk of it's own to store more, smaller voxels. The first use case that comes to mind would be for showing damage to voxels, but there could be others, such as smoother terrain. Thoughts?


texts: Endless Running Game - Changing Lane Function in JAVA

texts:
I am developing a kind of vertical endless running game, where the character has 4 possible lanes to be in. I am using libGDX and want the character to change lanes by adding a horizontal velocity to a Vector2. The position will be upgraded by velocity increments and not by simply changing the position to the next lane. So far I have a working function, but as I increment the horizontal velocity, along the run, it loses accuracy. Let's assume each lane is 50px width.

I am also using a acceleration vector to slow down as the character gets closer to the next lane.

The 2 functions below are about what happens when the screen is touched right or left.
The position verification is a boundary condition to avoid the character going off the screen.

public void onClickRight(){
    if(!(position.x>=50*2.75)&&isAlive){
        velocity.x=350+extraSlideSpeed;
        acceleration.x=-500;
    }

}

public void onClickLeft(){
    if(!(position.x<=50*0.75)&&isAlive){
        velocity.x=-350-extraSlideSpeed;
        acceleration.x=500;
    }
}

The function below is called about 60 times per second, as delta is a very small number and represents time.

public void updateRunning(float delta){

    velocity.add(acceleration.cpy().scl(delta));
    position.add(velocity.cpy().scl(delta));
    displacement.add(velocity.cpy().scl(delta));

    if(displacement.x>=50||displacement.x<=-50){
        velocity.x = 0;
        acceleration.x = 0;
        displacement.x = 0;
    }
}

I am looking for smarter options as I am not pleased with my own. Help would be appreciated!


texts: How should I track players' real-time positions in an MMO?

texts: How do you keep track of the positions of the players in a MMORPG? I read that you can use either a database or you can store the coordinates in files. I tried using a database but it was slow. How can files be used to keep track of players positions?


texts: How to implement input-texture limited alphablending of 2 textures with HLSL?

texts:
I try to implement a HLSL shader the does the normal Alphablend with premultiplied colors (just as XNA4 does) but depending on some existing colors. One can think of adding a glow to a 2D terrain where the glow should only be applied to the not fully transparent parts of the terrain.

My current code is:

sampler TextureSampler1 : register(s1); // Addition (Terrain-only particles)
sampler TextureSampler2 : register(s2); // Existing (Terrain)

float4 main(float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
    // Look up color from partly transparent existing texture (premultipied colors)
    float4 existing = tex2D(TextureSampler2, texCoord);

    // For transparent pixels -> Color stays the same
    if ((existing.r + existing.g + existing.b + existing.a) == 0) return existing;

    // Look up color from partly transparent addition-texture (e.g. glow) (using premultipied colors) that should be added to existing color
    float4 addition = tex2D(TextureSampler1, texCoord);

    // Rescale light that is added by existing alpha
    addition.rgb *= existing.a;

    // Use this color to blend
    existing.rgb *= (1 - addition.a) + addition.rgb;

    return existing;
}

However, there still seems to be a problem with the alpha channel. Any ideas?


texts: Create sprite and place in pre-defined places using mouse

texts:
So, I have a table. I want to be able to click on a button that allows a mode where I place a sprite on the table, on places that are predefined. How do I do that?
I was thinking I could constantly update the mouseState when the button is pressed, and if the mouse is within a ceratin rectangle of a position where you can put it, it will snap to it and if you click, it will create a sprite in that position.

The thing is, I don't really know how to do this in practice.

Some guidance would be great!


texts: Convert Flash game to work on Android devices

texts: Is there any way to convert a Flash games(file with .swf extention) to work with android devices? I want the game to use Android device native controls like sensor, accelerometer, etc.


texts: How can I convert this 2D pixel array into a 1D pixel array?

texts:
I have this 2D array that works like this, and I made this image to help illustrate what my 'Screen' class's array represents.

Basically, the first part [x][] is how many scan-lines there are. And then, [][x] is how many pixels long that particular line is.

Now, I've researched 'flatting 2D arrays' or '2D to 1D array conversion' - and yes, they 'work', but they seem to just break it... What I mean is, have the screen goes a certain color, then crashes by going out of bounds. Then, other times, it just goes out of bounds, and nothing happens.

I've tried the following, which is what caused it to crash:

final int[] PIXEL_BUFFER = game.getPixelBuffer();

    int pixel = 0;
    for (int j = 0; j < SCANLINE_COUNT; j++)
    {
        for (int i = 0; i < SCANLINE_LENGTH; i++)
        {
            PIXEL_BUFFER[pixel] = this.PIXEL_BUFFER[j][i];
            pixel++;
        }
    }

I've searched high and low, but I can't figure this out. If anyone knows how, it'd be greatly appreciated if I could gain some insight. Until then, I'm going to keep trying.

Many thanks.


texts: How to calculate building cost with production per hour?

texts:
I know that it may not detailed thread title but I will give more detail about my question.

I'm working on a strategy game, and can't find a solution about building cost or training cost. I spent 1 week to calculate it but I can't find the formula. I kindly request help from experienced developers.

Here is the example:

Building Name: Quarry
Building Time: 15 seconds
Production per hour: 25 Stones

I give this building random building cost for Level 1; 20 Stones, 15 Timber, and 10 Iron.

First of all, I thought this: Quarry at Level 1 is producing 25 Stones for p/h, and in 24 hours 600 Stones.

How can I calculate to give building cost for upper levels of Quarry? Is there any formula or we can give random cost for it?

Thanks!


texts: Recommendations to protect music and sound effects

texts:
I can make some very basic music and sound effects, but prefer to have some actual real audio happening. There are some audio that does support game development - Artlist for one. They state that the music and audio is fine to include in a game, as long as you don't offer them as a jukebox style where the player can select tracks. They also stated that the license is not transferrable, so I would need to ensure to prevent anyone from extracting the assets and grabbing the sounds/songs directly.
I am using MonoGame for my project with .NET Standard and .NET Core. Is there really a perfect way to prevent someone from accessing the files? Would encryption be recommended? Should I instead have my game download audio assets on startup from a website?


texts: Kinematic rigidbodies push each other in unet

texts:
https://youtu.be/j3f44E-ExLc
I have a bunch of rigidbodies on each player, ALL set to kinematic. And this stuff happens. All the sword swinging is animation state driven, and basic back and forth and sideways motion is using Rigidbody.MovePosition. There is not supposed to be any rotation on the players' local x axis. This only seems to happen using Unet networking . Any ideas how to fix this?? Thanks!


texts:
I am currently developing small 2D game in Unity, in which player is using swipe to create objects paths. I already did almost everything, but I hit a wall which i cannot pass. The thing is, that when I am using Bezier Curve I have to specify all points to have a base for my curve, but I'd like my object to move further after passing end point. Look at the image.

I've created a curve based on points A, B and C. The curve is green, but it doesn't reach the screen end, so I'd like to extend it with the red line. This my code to get a point on a curve.

public static Vector3 GetPoint(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
{
    t = Mathf.Clamp01(t);
    float oneMinusT = 1f - t;
    return
        oneMinusT * oneMinusT * oneMinusT * p0 +
        3f * oneMinusT * oneMinusT * t * p1 +
        3f * oneMinusT * t * t * p2 +
        t * t * t * p3;
}

I heard that passing parameter T greater than 1 should acutally do the thing, but it does not always work with my curves. Sometimes the object starts to go backwards or goes into some random direction. I would be grateful if someone could help me solve this problem. Thank you.


texts: DirectX 12 Questions about the command queue and command list?

texts:
I have been wondering this question for a while. Would this command

ThrowIfFailed(m_command_list->Reset(m_command_allocator.Get(), nullptr));
m_command_list->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_depth_stencil.Get(), D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_DEPTH_WRITE));
ThrowIfFailed(m_command_list->Close());

get sent to the command queue and not be executed?

Also how would I set the command list back into a recording state?


texts: Bullet impact or force on cube in Blender

texts:
Hoping someone here may be able to help. I'm new to Blender (and game development/3d modelling) and have been following some tutorials online to get me started. I am building a very basic FPS just to get started. I have a gun that shoots a cube object as a bullet, but when I shoot a different cube object that I added as a target, I have a number of issues. EDIT: The target cube is just set as a rigid body object. No other attributes as yet.

The cube only moves when I hit one particular face of the cube with a bullet. Otherwise, it doesn't register a hit. It's like the bullet passes right through it unless I hit the particular face.
When I hit the correct face, the cube flies way off the screen. I know this is controlled by the physics of each object but I can't find any explanations of it. It's like the box has no weight. If I increase the mass of it, walking against the cube is affected. The cube moves around slower/faster depending on the mass, but shooting it shows no change.

Could someone give a newbie some pointers?? Thanks so much guys.

btw I'm using Blender 2.6 but I reckon that's irrelevant really


texts: [Unity2D]Make a bullet move toward player and keep moving when past him

texts:
Basically I'm trying to make enemies attack player and shot bullets towards player and for now is kinda working, but my problem is the bullet stop when it reach the player position instead of keep moving.

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

public class EnemyTwoBulletScript : MonoBehaviour {

    public float bulletDamage;

    private float bulletSpeed = 9.5f;
    private float spriteWithDelta;
    //private Rigidbody2D bulletBody;
    private Transform playerTransform;
    private Transform selfTransform;
    private Vector3 playerPosition;

    // Use this for initialization
    void Start() {
        //bulletBody = GetComponent<Rigidbody2D>();
        spriteWithDelta = GetComponent<SpriteRenderer>().bounds.size.x / 2;
        playerTransform = GameObject.FindWithTag("Player").GetComponent<Transform>();
        bulletSpeed = 9.5f;
        playerPosition = playerTransform.position;
        selfTransform = GetComponent<Transform>();

    }
    // Update is called once per frame
    void Update () {
        selfTransform.position = Vector3.MoveTowards(selfTransform.position,playerPosition,bulletSpeed*Time.deltaTime);
    }
}

I don't want the bullet to follow player either, I just want to shot a rect between origin and player, but keep moving when the bullet past player.


texts: How to a select a single 3D object out of multiple objects using mouse click and move it using mouse drag in OpenGL

texts:
I am rendering multiple 3d objects on the screen but i want to select one particular object  by clicking on it and then move it using mouse drag but i cant figure it how to do it because on clicking on the screen all i get is the 2D coordinates of the mouse pointer
I am new to OpenGl Plsss help


texts:
I want my camera to be smooth on only the Y axis.How do I do that it?

Current code:

public Transform target;
public float smoothSpeed = 0.3f;
public float offsetX = 1f;
public float offsetY = 1f;
public float offsetZ = 1f;

void FixedUpdate ()
{
    Vector3 pos = transform.position;
    pos.x = target.position.x;
    pos.y = target.position.y;
    pos.z = target.position.z;
    Vector3 positionz = pos.z;

    Vector3 smoothedPosition = Vector3.Lerp(transform.position, pos, smoothSpeed);
    transform.position = smoothedPosition;
}


texts:
Which approach should I take for creating a game/app where the player, looking above the ground "canvas", would be able to "move" dirt (i.e. soil, or generally powder) around using fingers? I.e. similar to what you would achieve if you placed some dirt on a A4 white paper, and then move it around using palms/fingers?

I first thought it would be something similar to how painting apps work, but they more or less use a texture brush, and this doesn't seem to give me the desired effects. The ultimate experience would probably be to do it using a full-fledged physics particle system, but I am not sure a midrange device (Android, iOS) is capable of rendering something like that with satisfying detail in realtime? Admittedly, I am not trying to do what's shown in the video, but at least something that wouldn't look like moving "puzzles" around.

All other materials related to these search terms are merely using particles to simulate dirt flying around vehicle tires, so I am slightly stucked and I feel a nudge in the right direction might do wonders. Any algorithm/technology hints?


texts:
I wanted a swift look around functionality to be put in the middle of a room and just look around.
So obviously I imported the standard assets and put the FPS controller in the middle and then dragged in the Dual touch controls and build it to android.
The problem is that it only rotates horizontally and not vertically. I tried playing around with the values a bit but nothing seems to be working.


texts: Making an ice cream or icing effect as shown in GIF below

texts:
How can I make an effect like filling a cone with soft serve ice cream, or putting icing on a cake. I want to have the real icing effect shown in the https://twitter.com/D_M_Gregory/status/1248475917975867392?s=19 link.
In the game play scene there will be three buttons with different ice cream colors at the bottom, one icing machine at the top with three colors same of the buttons and an image displayed that is to be matched on the left corner.If a user press the yellow button the ice cream starts popping out from the yellow part of the machine and and if blue button is pressed blue cream start's popping out and vice versa.The machine will fill up the cone in a circular manner. When the button is pressed the machine starts animating in a circular manner on top of the cone and if the user stops in between and than start again than the icing machine should start from the same position where it left. A bar on the top will show the complete percentage of the filling cone

When the cup or cone is filled and the level processing bar is completed than it will be checked at the end and given points according to the matched percentage.Like if the prepared cone matches 100 percent with the matched image than it will be given full points and if the color of the layers doesn't match properly than points will be deducted according to the matching criteria.

(Animated example via this article)


texts: How can I know in which direction 2 balls will go in billiard game?

texts:
When a ball is struck, how can we know in which direction both balls will go when ball is struck? I know the angle at which the ball strikes the other ball matters, but how can we calculate that angle?

I've seen some of the videos to get started with elastic collision. Here is the link:

http://www.youtube.com/watch?v=BZOkrCQRVWM

But it assumes that we know the angle at which the ball strikes other ball. May be I am asking too basic question but I am not a Physics guy so I need to understand how to calculate the angle.

Thanks in advance :)


texts: How can I measure the velocity of a Farseer body?

texts:
I want to know how fast my body(a circle) is moving. How can I do that? How can I measure the velocity of a body?

In addition, I want to limit the velocity of a body. For example, I want that a body couldn't move with more than 50 km/h. How can I do that?


texts:
I'm working on a game in a 3D world with elements 2D only (Like Don't starve game) for Android and IOS.

Currently, I've managed "Sprite" without alpha blending, I've just put a condition in the pixel shader to test if pixel alpha channel is null:

if ( texture.a < 0.5 ) discard;

Everything working here. (On old devies like an HTC desire mobile, this condition destroy framerate but it's another problem :/)

But recently, I've tried to had another Sprite with AlphaBlending activated:

glCheck( glEnable(GL_BLEND) );
glCheck( glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ) );
glCheck( glDisable(GL_DEPTH_TEST) );

My sprite transparency is ok but it is now in front of everything in the scene. (Probably due to glDisable(GL_DEPTH_TEST)).

How can I handle depth with alpha blending activated?

EDIT:
A video to show the problem: http://www.youtube.com/watch?v=W0gpBekEwW8&feature=youtu.be


texts:
I've been building an SFML engine and I've been very confused on the FPS, frame independent movement and game loop.

My particular problem is that I have a variable set to 60 for the frame limit but changing this value doesn't seem to change the frame limit. I used the built in SFML window function to set a limit and it seems to work.

Am I doing something wrong with this loop?

while (mWindow.isOpen())
{
    time=renderClock.getElapsedTime();
    float fFps=1000000/time.asMicroseconds();
    std::stringstream s;
    s<<fFps<<" fps";
    fps.setString(s.str());
    renderClock.restart();

    const sf::Int64 frameTime = 1000000/FRAMES_PER_SECOND;
    sf::Clock c;
    sf::Time t=c.getElapsedTime();
    sf::Int64 nextFrameTime=t.asMicroseconds()+frameTime;

    int loops = 0;
    while( t.asMicroseconds() < nextFrameTime && loops < MAX_FRAMESKIP)
    {
        processEvents();
        updateTime=updateClock.restart().asMilliseconds();
        update(updateTime);
        t=c.getElapsedTime();
        loops++;
    }

    render();
}

Here's a link to my full code: https://github.com/csharpest94/SFML/blob/master/src/Game.cpp


texts: How to generate mesh at runtime using raycast points?

texts:
I'm trying to make a clone of the trail/line renderer with the difference that everything is perfectly flat, i.e. the faces are not designed to face the camera. I'm using two raycasts to get the position of the edges of where I want those faces but now I'm struggling to generate the mesh...I've gone through the mesh docs but I don't really understand it. Could someone help me do this?

Here is my code so far:

    public Transform[] probes;
    public float probeDistance;

    public Vector3[] newVertices;
    public Vector2[] newUV;
    public int[] newTriangles;

    void Update () {
        //Generating the mesh
        Mesh mesh = new Mesh();
        GetComponent<MeshFilter>().mesh = mesh;
        mesh.vertices = newVertices;
        mesh.uv = newUV;
        mesh.triangles = newTriangles;

        //Defining the rays
        Ray l_ray = new Ray(probes[0].position, -probes[0].forward * probeDistance);
        Ray r_ray = new Ray(probes[1].position, -probes[1].forward * probeDistance);

        RaycastHit l_hit;
        RaycastHit r_hit;

        Debug.DrawRay(probes[0].position, -probes[0].forward * probeDistance, Color.blue);
        Debug.DrawRay(probes[1].position, -probes[1].forward * probeDistance, Color.red);

        //Getting the position of the left ray point
        if(Physics.Raycast(l_ray, out l_hit)){
            print (l_hit.point);
        }

        //Getting the position of the right ray point
        if(Physics.Raycast(r_ray, out r_hit)){
            print (r_hit.point);
        }
    }


texts: Level of Detail algorithm(s) and texture coordinates

texts:
I'm playing with LOD these days and trying a couple of implementations, specifically quadric mesh simplification, there is a link.

I don't have problem simplifying my models but i do have problem finding the correct texture coordinates after simplification. None of the implementations i found (many) cover texturing, they only handle flat colored triangles, and i was wondering if it's possible anyhow to preserve coordinates.

Is there an approach to handle texture coordinates on quadric simplified meshes?
I tried storing the original texture coordinates into their faces before passing them to simplifier, then restore them but the results are clearly wrong.


texts: Fire an event while the mouse is down within my box 2d collider in Unity

texts:
The method OnMouseDown() is called once when the mouse presses my box 2d collider.

Is there a method that keeps firing while the mouse is still holding the button down inside the collider? Something like WhileMouseDown().

I could use Input.GetMouseButton(0) in the Update() method. However, this does not check if the mouse is pressing the collider.


texts: C# modal to represent Nesting JSON in Unity JSONUtility

texts:
I am wanting to build the C# data object to represent the following JSON. I am using unity's JsonUtility. I have used the JSONUtility before but only with a simpler JSON structure. However I am not sure nesting can be done as I have been searching for examples without any luck.

{
"datacharts":[{
    "0000000009":[{
            "dateTime": "2016-09-14 00:14:20",
            "seconds": "60.50"
        },
        {
            "dateTime": "2016-09-14 00:15:20",
            "seconds": "57.23"
        },{
            "dateTime": "2016-09-14 00:18:20",
            "seconds": "61.230"
        },
        {
            "dateTime": "2016-09-14 00:23:20",
            "seconds": "55.875"
        }
    ]
 }]
}

My current C# model.

[System.Serializable]
public struct Drivers
{
        public DateTime[] dataTime; //time stamp unique enough to group each points?
        public float[] seconds;
}

[System.Serializable]
public class DataCharts {
    public List<Drivers> driverIds;
}

[System.Serializable]
public class DataList{

public List<DataCharts> availableData;
}

I'm not sure this answer will help me as I don't understand what it's wrapping. https://forum.unity3d.com/threads/how-to-load-an-array-with-jsonutility.375735/#post-2585129

Should my Json be modal differently? I am wanting to save driver times to display in a bar chart. So every driver would have a timestamp and the lap time.

UPDATE:
after reading this question/answer Communicate Unity application via a series of Json

I've remodelled the json and c#.
Json

{
    "driverId": "0000000009",
    "dataPoints": [{
                "dateTime": "2016-09-14 00:14:20",
                "seconds": "60.50"
            },{
                "dateTime": "2016-09-14 00:15:20",
                "seconds": "57.23"
            },{
                "dateTime": "2016-09-14 00:18:20",
                "seconds": "61.230"
            },
            {
                "dateTime": "2016-09-14 00:23:20",
                "seconds": "55.875"
        }]
}

C#

[Serializable]
public struct Drivers
{
    public string driverId;
    public List<DataPoints> points;
}

[Serializable]
public class DataPoints {
    public string dateTime;
    public string seconds;
}

[Serializable]
public class DataList{
    public List<Drivers> availableData;
}


texts: How do Idle games progress while not active?

texts:
A hallmark of many idle games is the ability to still progress (or at least regain resources) while the game isn't active. The device can even be off.

Initially I figured they just calculated progress off system time next time it was started, but they do not appear fooled by messing with the clock.

How do they manage this specific feat?


texts: Drag and drop card game--NullReference Exception despite object existing?

texts:
I am trying to build a Hearthstone-style online TCG. Right now I am just working on getting the cards to drag around on the screen. Since I'm new to Unity, I'm using this tutorial https://www.youtube.com/watch?v=AM7wBz9azyU&index=3&list=PLbghT7MmckI42Gkp2cILkO2nRxK2M4NLo

I've copied the code in the tutorial pretty much exactly. What I have looks like this:

public class dragable : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler {

   public Transform parentToReturnTo = null;

   GameObject placeholder = null;

   public void OnBeginDrag(PointerEventData eventData)
   {
       Debug.Log("OnBeginDrag");

       placeholder = new GameObject();
       placeholder.transform.SetParent(this.transform.parent);

       LayoutElement le = placeholder.AddComponent<LayoutElement>();
       if (le) {
           Debug.Log("Found it!"); //Found le here...
       }
       else
       {
           Debug.Log("No dice.");
       }
       le.preferredWidth = this.GetComponent<LayoutElement>().preferredWidth; //can't find le--why?
       le.preferredHeight = this.GetComponent<LayoutElement>().preferredHeight;
       le.flexibleHeight = 0;
       le.flexibleWidth = 0;

       parentToReturnTo = this.transform.parent;
       this.transform.SetParent(this.transform.parent.parent);

       GetComponent<CanvasGroup>().blocksRaycasts = false;
   }

The rest of the class doesn't seem to effect the problem I'm having. That problem being: whenever I try to write to the LayoutElement le, the console returns a NullReferenceException error. But when I try to read le--for instance, testing if it exists in the if (le) loop (which exists only for debugging this particular issue), it works fine. Also, if you watch the tutorial video, you'll see that there is a "tabletop" on the upper half of the canvas that you can drop cards on to--this doesn't seem to work unless I comment out all code that tries to write to le's attributes. Anyone know how to fix this?


texts:
I am trying to create the effect of the water surface thickness with a vertex-fragment shader.

I am in a 3D game environment but It's a scroll view so a "2D" view.
Here is a good tutorial of creating such effect in real 2D using fragment shader.
But this can't be used in my case I think.
For the moment I have only a plane were I apply refraction.

And I want to apply the water thickness effect. But I don't know how to do it.
I am not trying to create some water deformation/displacement using vertex for the moment, this is not the point.

I don't know if it's possible with a simple quad maybe should I use an object like this.

Here are some examples.

I don't have any idea on how to create this effect.

Thanks a lot !

[EDIT] Added Rayman water effect to have a better reference of the effect.


texts:
Recently I've been putting together an in-game UI for a passion project I'm working on, but I absolutely hate the UI meta at the moment.
I love Morrowind's UI, in that it is central and easy to access. For this reason, when opening inventory nearly everything is instantly visible. The difference is that I find those kind of UIs break the flow of the game and immersion, so I used a diegetic UI element for this. Other UI elements I've succeeded in making diegetic include a basic map, compass, and journal.
I also love Dead Space's UI, and it's impossible to mention diegetic UI without mentioning it. Other diegetic UI's such as those in some Metroid series entries are similar, though I prefer Dead Space's for its simplicity.
My own game is a third-person action adventure RPG, so immersion in the environment is important to me. It has its own magic system that plays a lot on the way health works. Magic overuse can kill the user, making it very important for me to telegraph HP and magic reserves to the player.
These goals make UI hard though. I don't want a cluttered UI, but I can't use sci-fi or futuristic elements to display information like the examples I listed due to the context of the story and the time period it is based in. I can use animation based things like limping, slouching and so on, but I feel those are too hard to recognise in the heat of a fight and could use some complementary system. Are there any fantasy games that don't use futuristic elements or gamey UIs successfully? Is it possible and has it been done before?


texts: Game 30% done on HTML5. Maybe it was a bad idea. Should I change to Unity3d?

texts:
I'm creating a 3d game on HTML5. It's 30% complete and the hard part is already coded. The server is on node.js.Now I'm realizing that maybe it was not a wise choice. This is because I realized:

Three.js still has many bugs. I don't see the same thing on every machine. Each browser, OS, can give different results. I'm afraid my clients will have a great stress installing my game properly.
I have tons of sprites and models on my game. I wonder if my clients will have to load all them again everytime they want to play?
I wonder if a Node.js server will be fast enough to handle it, and I'm afraid it won't be scalable.

What would you advise me? Should I continue and finish the game on HTML5 or is it better to remake it on something else, like Unity3d for the client and (what?) for the server?


texts: Why is texturing interfering with my ID-based picking implementation?

texts:
Today I came across a tutorial about color picking and I implemented it on my machine. But there is a problem: when I disable the texture and draw the object I want to pick with its picking color, it turns to black (the first colorID) and then switches to the texture which I am placing on pick.

That is the case when I enable the textures after rendering the object. When I enable texturing before rendering my object, as in:

void MenuButton::Render(double windowWidth, double windowHeight)
{
    glEnable(GL_TEXTURE_2D);
    gui_OrthogonalStart(windowWidth, windowHeight);
        TextureManager::Inst()->BindTexture(gui_TextureID);
         glBegin(GL_QUADS);
            glTexCoord2f(0.0f, 1.0f); glVertex2f(gui_Position.GetX(), gui_Position.GetY() - 25.0f);
            glTexCoord2f(1.0f, 1.0f); glVertex2f(gui_Position.GetX() + 100.0f, gui_Position.GetY() - 25.0f);
            glTexCoord2f(1.0f, 0.0f); glVertex2f(gui_Position.GetX() + 100.0f, gui_Position.GetY());
            glTexCoord2f(0.0f, 0.0f); glVertex2f(gui_Position.GetX(), gui_Position.GetY());
         glEnd();
    gui_OrthogonalEnd();
}

Then the texture cannot be disabled and the color picking isn't working. I hope I explained it well. If the code provided in the link isn't enough tell me and I will post more.

Can this problem be solved in some way?


texts: How could I figure out the shortest way to turn, and whats the angle?

texts:
I'm creating some robots for my tank game. I want them to find each other and shoot each other down, so I'm trying to implement a way for them to turn towards each other, and turn the shortest way. For instance, if we where T1 (tank 1), how could I figure out if I where to turn right of left, and at what angle to turn if

Tank1 (us) position is (8906,76), facing is 23 degrees.
Tank2 (enemy) position is (888,61)

0/360 is straight up.

The way I've tried to do is to decide what quadrant the enemy is of myself. But that leaves out a 45 degree angle to fail. I know there is some archtan but I cant simply get a grip on them...


texts:
I am working on a turn based game that utilizes the model, view, controller design pattern to separate logic from input from rendering. I am still a little new to the pattern, but from my understanding I have laid out the following MVC system.

The model(s) comprise a set of pawns with game flow and interaction logic. Pawns/models know how to interact with each other and the model world, but only when signaled to do so via function calls. (i.e. pawn.move(startLocation, endLocation) or pawn.attack(enemyPawn))

The view(s) make up everything that is viewable by the player. This includes menus, visual representations of the pawns/models, and any user interface components like cursors and buttons. The view(s) query the model for data to draw visual representations of pawns. The view(s) also can dispatch user interface events to any observers interested in these events.

The controller(s) handle all transition and input logic. When an interesting user interface or input events occur, the controller decides what the model should do and signals the model to do it. The controller also handles swapping out of views when necessary.

I know there are many ways to implement MVC and I am open to suggestions if something seems off with this design, but the real problem I am having is how to handle animations in the view. Say the user commands a pawn to move 5 spaces North and 1 space West. I want an animation to show this over several seconds. How would I handle something like that?


texts:
I'm trying to build a small networked game using WebGL and NodeJS. I have a basic client and server setup and I'm at the point where I'm trying to implement dead reckoning to simulate what happens on the client.

I have a odd problem which I'm not really sure how to fix, the game loops for my client and server don't seem to match up and the client one always seems to be faster. I'm hosting my server on the same system as my client right now and I'm logging every frame for the two. If I log it for longer than 5seconds the server starts to get behind by 10-20 frames and the gap just gets bigger and bigger over time. There isn't really anymore processing that is happening on the server than on the client at the moment because I'm working with a really basic example right now.

My loop for both right now look something like this:

var loopDelay = 16.666666666666666666666666666667;

function loop()
{
    setTimeout(function() {
        update();
        loop();
    }, loopDelay);
}

On the client I did have something like this:

function loop()
{
    setTimeout(function() {
        update();
        requestAnimationFrame(loop);
        draw();
    }, loopDelay);
}

But I removed it and copied the server one temporarily when I started running into this problem to make sure it wasn't that.

What can I do to make the two sync up perfectly?

Thanks


texts: Calculate winner of battle when auto is chosen

texts:
There are two slightly different scenarios I am interested in and I'l give you examples of each.

The first is like the tournament system in Super Smash Brothers Melee, when there can be dozens of cpu vs cpu battles and it has to choose a winner. This could be done with a random number generator but I feel there is something more there.

The second is in some games, mostly strategy games, you can choose to play a battle or have the computer calculate the battle for you. The game Medieval: Total War comes to mind, where it calculates how many troops you and the computer lose. In these scenarios, it never goes as well as if I had done it myself but I usually win if it is plausible.

What I want to know is, how are these battles are calculated? Does anyone know how it is done, or have an idea of how to implement it?

I had an idea of just doing the battle normally but disabling all graphic display so it would conclude very fast, but I'm not sure this would work too well.


texts:
I have in my hierarchy tab a Canvas. Inside the canvas I have an Input Field that holds a placeholder and a text.

I read the documentations and didn't find how to hide the Input field.

I want that if a if statement is true, then it will show the input field. Else you won't see it.

How can I implement it?

EDIT

I thought about an idea to test: If I press the O key on the keyboard it disappears, and if I press again it appears; and so on.

This is what I tried:

bool shown = true;
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
    GameObject inputField = GameObject.Find("InputField");
    if (Input.GetKeyDown (KeyCode.O)) {
        shown = !shown;
        inputField.SetActive (shown);
    }
}

I play the scene and when I press the O key I get

NullReferenceException: Object reference not set to an instance of an object

If I double-click on the console message it highlights me the if (Input.GetKeyDown (KeyCode.O)) { line.

Something not good does the SetActive(bool) method, I suppose.


texts: How can I set my non-convex object's collision to a more detailed one to allow other objects to go underneath?

texts:
My problem is simple. I imported a 3D object (it's not convex) and I want the character to go under your legs.

But this does not happen:

There seems to be a way to do this, I just do not know which one.

Vision of what would be a complex collision:

I've already changed all these options, but it did not work out:

The closest I got was when I saw something about adding a physical material. But when I try only a circle appears, I still can not add one exactly equal to the Character:

Links where I've already looked for help:

https://docs.unrealengine.com/en-us/Engine/Content/FBX/StaticMeshes#collision
https://docs.unrealengine.com/en-us/Engine/Physics/PhysicalMaterials/PhysMatUserGuide
https://forums.unrealengine.com/development-discussion/content-creation/18509-how-can-i-make-this-have-a-more-precise-collision-box


texts: How can I render a tmx map at a given location?

texts: I am using libgdx & trying to implement a Binding of Issac like dungeon. To do this I'm loading a tmx map when a dungeon room is created and rendering it to the screen. The issue is that the each room renders the map in the same place on top of each other. This all boils down to one question: How can I render a map at a specific x,y position, so that I can display the whole dungeon at once?


texts: Unity2D: Delete spawn objects once it exits camera's view

texts:
does anyone know how to delete/destoy a spawn object when it exit out of the camera view. I tried using:

   void OnBecameVisible() {
      Destroy (gameObject);
     }

But it didn't work. Maybe I'm doing something wrong, I don't know. Oh just a friendly advice my spawned object may enter form any point of the screen. Thank you :).


texts:
I have 3 spots, I would like to move my camera to using slerp. Just As seen in the image below. My question is how I can connect my camera to the first spot? I should be able to move between other spots after I connect my camera to the first spot.

Maybe a better way to ask is how can I make the camera location my first quaternion spot?


texts: Drawing multiple polygons with vertex buffer object

texts:
I tried to create program in which I would draw multiplepoygons
here is fragment of what I have done:

GLuint VertexArrayID;

exampleof drawing triangle(I have more polygons, like circle, and so on..)

if (figure == RECTANGLE)
{
    data[0][0] = px1;   data[0][1] = py1;
    data[1][0] = px2;   data[1][1] = py1;
    data[2][0] = px2;   data[2][1] = py2;
    data[3][0] = px1;   data[3][1] = py2;
    vertex_count = 4;
}
if (vertex_count > 0)
{
    glGenBuffers(3, VertexArrayID);
    glBindBuffer(GL_ARRAY_BUFFER, VertexArrayID[0]);
    glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(float), data, GL_STATIC_DRAW);
//GLfloat* data = (GLfloat*)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);

    glVertexPointer(2, GL_FLOAT, 0, NULL);
    glEnableClientState(GL_VERTEX_ARRAY);
    glDrawArrays(GL_TRIANGLE_FAN, 0, vertex_count);
    glDisableClientState(GL_VERTEX_ARRAY);
}

Now the point is that I want to:
1) create polygon
2) save this polygon ob buffer
3) create other polygon
4) save that polygon
5) and so..

I know that here I create N buffers:

glGenBuffers(N, VertexArrayID);

But I need to know how to save each polygon on each buffer, and then show it all on screen.
I tried do use glBufferSubData, glMapBuffer, I have read many tutorials, but still I don't know how to do that.


texts: Where can I host the compiled version of my game for free?

texts: Can somebody recomend a free site for distributing and advertising my freeware (but not open source) Asteroids game in BINARY format?


texts: a flexible data structure for geometries

texts:
What data structure would you use to represent meshes that are to be altered (e.g. adding or removing new faces, vertices and edges), and that have to be "studied" in different ways (e.g. finding all the triangles intersecting a certain ray, or finding all the triangles "visible" from a given point in the space)? I need to consider multiple aspects of the mesh: their geometry, their topology and spatial information.

The meshes are rather big, say 500k triangles, so I am going to use the GPU when computations are heavy.

I tried using arrays with vertices and arrays with indices, but I do not love adding and removing vertices from them.
Also, using arrays totally ignore spatial and topological information, which I may need studying the mesh. So, I thought about using custom double-linked list data structures, but I believe doing so will require me to copy the data to array buffers before going on the GPU. I also thought about using BST, but not sure it fits.

Any help is appreciated. If I have been too fuzzy and you require other information feel free to ask.


texts: Component-based design: handling objects interaction

texts:
I'm not sure how exactly objects do things to other objects in a component based design.

Say I have an Obj class. I do:

Obj obj;
obj.add(new Position());
obj.add(new Physics());

How could I then have another object not only move the ball but have those physics applied. I'm not looking for implementation details but rather abstractly how objects communicate. In an entity based design, you might just have:

obj1.emitForceOn(obj2,5.0,0.0,0.0);

Any article or explanation to get a better grasp on a component driven design and how to do basic things would be really helpful.


texts: How to debug framerate drops with VBOs, OpenGL

texts:
I'm working on an experimental app to test how VBOs perform when rendering a minecraft-like world. If the performance is better than what I use now I'll update my actual game. Based on what everyone says, VBOs should totally be the right direction, but it's really hard making that become a reality.

I've finally gotten to a point where I've replicated culling block faces, I'm properly using the buffer IDs to render and not building the VBO every frame - there's no a ton of performance tweaking left aside from:

Using an indexed system so I can send fewer vertices
Using a ByteBuffer for my color/texture values instead of floats (I need to find a good way, right now everything is interleaved)
I could take block face culling a little further because in the test app, they don't check across chunks for solid blocks.

My primary issue is that for some reason, when I render 15x16 chunks (16x16x16 blocks per chunk in my test app) the performance and rendering is great. Movement is fluid, 60fps.

At 16x16 chunks, performance drops to like 5fps. I've run profiling like VisualVM and see no unusual differences in the speeds/memory of the code between the two states. It's odd how the addition of one extra row of chunks can take performance down so  much - there must be some specific threshold I cross.

How can I better debug what's happening? Where should I be looking? There are no console errors.

This test app is open source so you can look at the code:

World
Chunk
Rendering

Update I've updated my actual game with the VBO work I've been doing in this test app and the performance of the 10x10 grid of chunks (16x16x128) was so horrid that my system took minutes to allow me to kill the app. I'll certainly spend some time adjusting things and making sure that it's performance-tuned for my app, but wow - still not seeing how VBOs are all they're cracked up to be.


texts:
how can i move static box2d sprites. i have tried this tutorial from .
http://www.raywenderlich.com/475/how-to-create-a-simple-breakout-game-with-box2d-and-cocos2d-tutorial-part-12.

I managed to add another "paddle" object with box2d body, but i can seam to be able to make the code to move the second "paddle" body.
Can anyone direct me how to do it?

Is there a way to move a "b2_staticBody" box 2d object? i have tried, but i can only move it when i use "b2_dynamicBody" if i used "b2_staticBody" i can move it at all.


texts: How can I change the sprites in the NES Double Dragon ROM?

texts:
I have played a few NES ROMs where people have gone into them and changed the sprites. How did they do this?

I'd like to do this for the Double Dragon ROM. How can I accomplish that?


texts: Issue giving object player's hand position

texts:
I'm trying to put an object (for example a sword) in my player's hand.
To do so i set the player's hand transform as the object's parent, in order to have the same movement for the object and the hand. No problem here.

The real issue starts as soon as i set the sword position to the hand position. My player starts to move backward.

One of my doubt was that my sword has a rigid body and my player too, so it could have an impact on it because I know that you can set a rigid body as a rigid body child.

So I was wondering if it's the right way to do it.

Edit

Here is my script to pickup an item:

 public void PickupItem()
    {
        Ray interactionRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit interactionHit;

        if (Physics.Raycast(interactionRay, out interactionHit, InteractionMaxDistance))
        {
            if (interactionHit.collider.tag == "LootableItem")
            {
                Item item = interactionHit.collider.gameObject.GetComponent<Item>();
                GetComponent<CharacterStats>().AddStats(item.Stats);

                _hand = TransformUtil.FindChild("mixamorig:RightHandMiddle1", _player);
                item.GetComponent<Rigidbody>().isKinematic = true;
                item.GetComponent<Rigidbody>().useGravity = false;

                item.transform.parent = _hand;
                item.transform.position = _hand.position;
                item.transform.rotation = _hand.rotation;
            }
        }
    }

My script for player movement :

void Update()
    {
        float translation = (Input.GetAxis("Vertical") * Speed) * Time.deltaTime;
        float rotation = (Input.GetAxis("Horizontal") * RotationSpeed) * Time.deltaTime;
        transform.Translate(0, 0, translation);
        transform.Rotate(0, rotation, 0);

        if (Input.GetButtonDown("Jump"))
        {
            _animator.SetTrigger("triggerJump");
            return;
        }

        if (Math.Abs(translation) < 0.01 && Math.Abs(rotation) < 0.01)
        {
            Speed = 1;
        }
        else
        {
            if (Input.GetKey(KeyCode.LeftShift))
            {
                Speed = 4;
                RotationSpeed = 150;
            }
            else
            {
                Speed = 2;
                RotationSpeed = 200;
            }
        }

        _animator.SetFloat("speed", Speed);
        _animator.SetFloat("rotation", rotation);
        _animator.SetFloat("translation", translation);
    }

I took my character from Mixamo, same for the animaitons.


texts: C & SDL: Unexpected Behaviour with Renderer

texts:
I'm creating a clone of the memory testing game SIMON. My program is simply four differently colored squares that light up one at a time in a random order. I wrote some code that lights up one square, dims it, waits 250ms and then lights up the next in the sequence. Rinse and repeat until the sequence is complete.

My problem is that everytime it lights up a square, it's lighting up all of the previous lit ones as well, instead one at a time. I hope I'm explaining that clearly.

Below is my code. I know it's silly code, but I plan to come back and find a better way to do it.

SDL_SetRenderDrawColor(renderer, 255, 255, 0, 255);
SDL_RenderFillRect(renderer, &squareTwo);
SDL_RenderPresent(renderer);

SDL_Delay(250);

SDL_SetRenderDrawColor(renderer, 50, 50, 0, 255);
SDL_RenderFillRect(renderer, &squareTwo);
SDL_RenderPresent(renderer);

SDL_Delay(250);

SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
SDL_RenderFillRect(renderer, &squareThree);
SDL_RenderPresent(renderer);

SDL_Delay(250);

SDL_SetRenderDrawColor(renderer, 50, 0, 0, 255);
SDL_RenderFillRect(renderer, &squareThree);
SDL_RenderPresent(renderer);

SDL_Delay(250);

SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
SDL_RenderFillRect(renderer, &squareThree);
SDL_RenderPresent(renderer);

SDL_Delay(250);

SDL_SetRenderDrawColor(renderer, 50, 0, 0, 255);
SDL_RenderFillRect(renderer, &squareThree);
SDL_RenderPresent(renderer);

SDL_Delay(250);

SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
SDL_RenderFillRect(renderer, &squareFour);
SDL_RenderPresent(renderer);

SDL_Delay(250);

SDL_SetRenderDrawColor(renderer, 0, 0, 50, 255);
SDL_RenderFillRect(renderer, &squareFour);
SDL_RenderPresent(renderer);

With the above code, I was hoping only one square will be lit up at once. Instead the first one lights up, and dims. And then the first and second square light up at the same time.

And to make this even stranger, I ran it on my work computer and it works like expected (both systems it was tested on are Linux, if that matters)! Maybe I changed something by accident after last testing it, but I really just don't recall that. Very strange.

Would anyone have any ideas or clues for me on this one?


texts: How to setup a public github unity repo with paid assets?

texts:
From what I gathered (like in this thread or here) I am allowed to push my own game code on github and choose a license, as long as I avoid putting assets I do not own. I want to make it public to be able to show it (to potential employers for instance) but I cannot make it open source as I plan to use paid assets (like DoozyUI).

I can avoid pushing  the asset itself on the repo (with .gitignore for instance). Should I prevent gameobjects created with this package to be pushed as well ? That would make the game unusable, even with the rights to use the package...

Once that is settled, Is it ok to push it to github without license ?

Specifically, I do not know if objects generated by a paid asset are still considered that asset or not...

Edit: I asked the question directly to DoozyUI support, which quickly responded :

  You can upload your project, without the Doozy folder. Thus excluding our source code from being shared. Also, unsert a disclaimer letting anyone know that DoozyUI is required to be installed (before getting your files) for the project to work.
  You can share any GameObject (or prefabs) you create, but they will not work if DoozyUI is not installed due to missing references (scripts). Once Doozy is installed, they will work as expected. Thus anyone who has the system will be able to see/use your project.


texts: Splitting game into multiple standalone parts

texts:
I'm digging into Starling's CitrusEngine game engine. I try to understand the idea of structuring the game.

If you take a look at chrome.angrybirds.com or puddingmonsters.com you see that games load states (StarlingState's assets) dynamically which is smart. When the game starts a splash-screen displays, then you get a pre-loader which loads the main state (home, settings and choose-level view) and when you select a level a pre-loader displays again which loads the level state. This looks like they've constructed multiple parts for the game and then connect them together where the pre-loader is displayed when switching from one part to other.

How should we do that in Starling/CitrusEngine? What's the logic here? Flash games usually load all assets at the beginning which is not smart on mobile devices. Is it wise to have multiple StarlingCitrusEngine classes or you should handle the whole game in a single StarlingCitrusEngine class? Please explain in details.

Many thanks for answers.


texts: Slick2D drawString with coordinates from bottom-left corner

texts: For OpenGL text drawing I use Slick2D library. Default Slick2D 0:0 coordinates are at upper-left corner. But in my project I use bottom-left corner for 0:0. Is it real to configure Slick2D with bottom-left corner as starting point?


texts: Can steam features be used in a game bought on an alternate distribution platform?

texts:
We're in the process of game development where we need to integrate with the Steamworks API for multiplayer matchmaking, achievements, player stats, etc. We also have a rudimentary implementation integrating with the Steam Workshop in order to distribute player-authored content.

However, I have a remit that the game should be publishable on other distribution platforms such as GOG.

If we were to distribute on an alternative platform such as GOG, is it acceptable to rely
on steam features? I presume this would mean the player
purchasing on GOG and being forced to install steam and set up a
steam account before playing. (I'm also aware that GOG are very much
anti-DRM which might entail a separate build version too, if even possible).
If not acceptable, what's the alternative? Are developers expected to employ platform-specific or a proprietary network system for multiplayer matchmaking for instance? How is this achieved in other games?


texts: Rich text in Debug message in Unity console

texts:
I'm currently writing a debug script and would like to add colors to certain parts of the debug messages. Reading the unity docs lead me to believe that I can use the Rich text formatting. Like it is explained here. I'm using the Debug.LogForamt().

  Logs a formatted message to the Unity Console.

  For formatting details, see the MSDN documentation on Composite
  Formatting. Rich text markup can be used to add emphasis.

This is from the unity docs. My code looks like this :

Debug.LogFormat("Status of some gameObject is : <color = red>{0}</color>" +
"Status of another gameObjcet is: <color = red>{1}</color>",
gameObject1.activeInHierarchy,gameObject2.activeInHierarchy);

This just outpust the strings as plain text. What am I doing wrong ?


texts: Are there important cases when one needs to know how to program sort algorithms in game programming?

texts:
Well I already read a little about sorting algorithms on wikipedia, the subject seems vast, especially when dealing with some cases where some algos are faster than others.

That might need some quick sum up, but before that, can somebody tell me if there are subjects of game programming where sorting is necessary ? (or optional, for execution time matters).

Maybe in a depth buffer?


texts: 2D Topdown Shooter - Player Movement Relative to Mouse

texts:
I'm trying to make a topdown 2D space game for my school project. I'm almost done but I just want to add a few little things to make the game more fun to play.

if (keystate.IsKeyDown(Keys.W))
        {
            vPlayerPos += Vector2.Normalize(new Vector2(Mouse.GetState().X - vPlayerPos.X, Mouse.GetState().Y - vPlayerPos.Y)) * 3;

            rPlayer.X = (int)vPlayerPos.X;
            rPlayer.Y = (int)vPlayerPos.Y;
        }

        if (keystate.IsKeyDown(Keys.S))
        {
            vPlayerPos += Vector2.Normalize(new Vector2(Mouse.GetState().X - vPlayerPos.X, Mouse.GetState().Y - vPlayerPos.Y)) * -3;
            rPlayer.X = (int)vPlayerPos.X;
            rPlayer.Y = (int)vPlayerPos.Y;
        }

This is what i use to move towards and away from my mouse crossair. I tried to make a somewhat similar function to make it strafe with "A" and "D". But for some reason I just couldn't get it done.

Any thoughts?


texts:
I have been developing for win7 mobile (XNA/silverlight and will continue to do so, love everything about it) but I wanted to branch a few of my more polished games to google app store online, and perhaps android(though not sure, as with all the different versions it makes learning/loading applications a bit tricky)

What is the most versatile language to start learning from chrome apps/android:

Java would be excellent for android, but could I port it to a web app for chrome? (and its close to C#)

Flash would work for a web app as I can just embed it into a html page (have done actionscript before, didn't care much for the IDE though), but would it also work on android?

or I guess there is always C/C++ but haven't heard much about that, though I think it works for both (though C++ does interest me)

Any advice would be excellent, thanks.


texts: How can I maintain a contiguous area when generating a tilemap using Wave Function Collapse?

texts: I'm using Wave Function Collapse to generate a tilemap, and I'm trying to come up with a way to maintain a contiguous area during generation. As an example: ensuring all "walkable" tiles are contiguous such that no "walkable" tile is blocked off from another. An acceptable outcome would also be ensuring there is a contiguous path between two (or more) designated tiles. I'm thinking there may be some way to determine how likely any given tile is to bisect a contiguous area and integrate that into the entropy calculation, but I'm not sure how I would determine that.


texts: Does using a Community Script with Creative Commons - Attribution-NonComercial-ShareAlike prevent me from selling the game?

texts:
So I have been building a game in one of the RPG Makers with the end goal to sell it. while I have been working hard coding up my own scripts one in particular is a complex Active Battle System like that of Zelda which gives me more options for enemy verities and attack patterns.

The script has in the comments a Creative Commons - Attribution-NonComercial-ShareAlike license. I asked about NonComercial and I get 2 kinds of answers

I can not sell the game at all if the script is in there as such I either have to replace the script or give the game away for free
I can not sell the script or remixes of the script for others to use as such in a compiled game which isn't open source (ie. you have to hack/decompile it to get it's scripts) it's fine to sell the game with the script

now I am a long ways away from completing the game and it might be possible that later on my scripting skills get to the level that I can rebuild the Battle System to be similar but of my own code (or even hire someone to do it for me)

however, in the situation that I complete the game and I can not replace the script, does it prevent me from selling it? or does NonComercial prevent me from selling the script for others to use for themselves?


texts: How can I GL_SELECT from a gluPerspective-transformed scene?

texts:
I'm using JOGL to access OpenGL-methods on an old OpenGL version, because of school.

I have written a method which is called before any objects are drawn. This method shows which object is picked.

Before I call my "picking" method, I draw a camera. This is where the problems begin: I can't click precisely on the objects, because they don't know they are transformed by the camera.  I have tried to leave the projection matrix unchanged, but this leads to other problems...

I first draw the camera, then do picking, then draw the objects to screen.

What am I missing?

My camera:

public void draw(GL2 gl) {
    GLU glu = GLU.createGLU(gl);
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();

    glu.gluPerspective(viewingAngle, whRatio, 1, 1000);

    gl.glMatrixMode(GL2.GL_MODELVIEW);
    glu.gluLookAt(xPos, yPos, distance, 0, 0, 0, 0, 1, 0);
}

My picking method:

private void picking(GL2 gl) {
    if (currentClickPoint != null) {
        int buffSize = 512;
        int[] select = new int[buffSize];
        int viewport[] = new int[4];
        IntBuffer selectBuffer = newDirectIntBuffer(buffSize);

        gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport, 0);

        gl.glSelectBuffer(buffSize, selectBuffer);
        //gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glRenderMode(GL2.GL_SELECT);
        gl.glInitNames();
        //gl.glPushName(-1);

        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glPushMatrix();
        gl.glLoadIdentity();

        glut.gluPickMatrix((double) currentClickPoint[0],
                (double) (viewport[3] - currentClickPoint[1]),
                10.0, 10.0, viewport, 0);

        //gl.glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5);

        gl.glMatrixMode(GL2.GL_MODELVIEW);
        drawObjects(gl, GL2.GL_SELECT);

        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glPopMatrix();
        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glFlush();

        selectBuffer.get(select);

        interpretClicks(select, gl.glRenderMode(GL2.GL_RENDER));

        resetClickPoint();
    }
}


texts:
My team is currently developing a 3D Sidescroller game and we encountered some issues regarding the whole in-game perspective of the levels.
The levels are composed of 3D modeled corridors which are specifically modified to simulate the effect of - 'immersive-depth'.

Example(Front View - InGame View):

Example(Side View - Angled Floor):

Example(Flat Floor Comparison - Angle vs No Angle)

The issues I spoken of are appearing at the moment I start adding 3D objects on the corridor, like lamps, crates, cabinets etc. They all seem off, due to the fact that the whole floor of the corridor is angled forward
(even if the objects themselves are angled forward).

I know it seems like a strange question to ask but are there any smarter ways/alternatives of simulating the same depth of the corridor without angling it's floor?

P.S.

1) 2D is not an option. The camera isn't static.

2) Increasing the Angle of the camera on a flat floor doesn't simulate the same effect.
The camera was meant to change dynamically in certain situations, via it's angles and position (up and down). The higher it is the more it resembles the perpendicular version. However, if the camera is lower, at a lower position and angle (on the same level as the floor is) the difference comes in place, due to the back walls being higher.

EDIT:

We've decided to stick with the 'flat'- 90 deg, floor, it's easier to maintain.

Although the Angled version is more entertaining, it is limited by the fact
    that increasing the depth - means increasing the angle, which at a certain
    point will generate an inadequate look.


texts:
This bug/feature has been plaguing me for a while and i want to know the best way to fix it.
I'm testing simple hit detection with a wall, like:

 if (Forward button)
        if(Inv.w.z < -49 || Inv.w.z > 49)
            pos.z = 0.0f;
        else if(Inv.w.x < -49 || Inv.w.x > 49)
            pos.z = 0.0f;
        else
            pos.z = +1.0f;

where Inv.w. is the camera positions.
Now obviously when i now hit that certain point i can no longer move away from the wall or anywhere in fact. How can i change this code to allow for the camera to be turned away from the wall so therefore i should be allowed to move?

for example, the player hits the wall and i cant move until i turn around or to the side?

I know its something to do with velocity but im pretty new to this so please bare with me if this is easy.


texts: Is it possible to clone a game, and make modifiactions to it?

texts: I basically want to know whether or not it is possible to copy a mobile game and make it into a new game by modifying it . I want to be able to access , moderation tools and basically alter, things like characters, events, in ap purchases etc. Alter it to make it different enough from the original and make it available to other users. The game I want to copy is no longer in the play stores and I want to change that.


texts:
I'm calculating spherical UV coordinates in a loop, trying to get GCC to vectorize the code.

Here's a compile-able example of what it looks like.

#include <cmath>
#include <cstddef>

/// Calculates UV coordinates from positions on a sphere.
/// The sphere has a radius of one.
//
/// @param pos_array The 3D sphere positions to get the UV coordinates of.
/// The positions are in the format: x, y, z, w (where w is unused)
//
/// @param uv_array This is where the UV coordinates go.
/// A series of 2D vectors (no padding)
void calc_uv_coordinates(const float* pos_array, float* uv_array) noexcept {

  constexpr std::size_t chunk_size = 256;

  for (std::size_t i = 0; i < chunk_size; i++) {

    const float* pos = pos_array + (i * 4);

    float* uv = uv_array + (i * 2);

    uv[0] = 0.5 + (std::atan2(pos[2], pos[0]) / (2 * M_PI));
    uv[1] = 0.5 - (std::asin(pos[1]) / M_PI);
  }
}

But the inverse trig functions are keeping it from being vectorized, as per GCC's report:

gcc -c -O3 -fopt-info-vec-missed test.cc

Prints:

test.cc:16:29: missed: couldn't vectorize loop
/usr/include/c++/9/cmath:145:28: missed: statement clobbers memory: _25 = __builtin_atan2f (_4, _3);
/usr/include/c++/9/cmath:145:28: missed: statement clobbers memory: _25 = __builtin_atan2f (_4, _3);
/usr/include/c++/9/cmath:107:27: missed: statement clobbers memory: _24 = __builtin_asinf (_9);

Which is understandable, I don't think there's any hardware implementations of those functions.

Edit: There is for Intel.

In game development, how is this kind of issue dealt with? I could think of two approaches:

Write a vectorized atan2 and asin that compute many inverse trig values at once
Write a SIMD-friendly approximation for each function

A quick google search led me here, where I found an atan approximation.

inline constexpr float fast_atan_approx2(float x) noexcept {
  return x / (1 + (0.28 * x * x));
}

inline constexpr float fast_atan_approx2(float x) noexcept {
  return (0.9724 * x) - (0.1919 * x * x * x);
}

And from the comments, another approximation.

But looking at the graphs, I don't think they're going to be suitable for texture mapping. Here's a picture, where:

blue is true arctan
orange is the first approximation
red is the second approximation

The approximations are only decent in the domain [-1, 1]. So just to restate my question, how is this dealt with? Is there a way to vectorize these trig functions? Do people generally just accept the bottleneck?


texts: How to author custom objects in a tile map?

texts:
I've been using Tiled for my game engine but for objects I have to use points on an object layer and give it a name and use that to create map items in-game. This is really inefficient as I don't want to have to copy paste every time I want to place down a ammo pack.

Is there a better workflow I can use to create custom objects and instantiate them?

Ideally I'd like to export to XML, but that's not a deal breaker.


texts: Destroying non-monobehaviour derived classes

texts:
I'm building an inventory system with different items classes deriving from a 'Item' base class.

When an inventory slot runs out of the item it holds I want the item to be destroyed. I cannot null the inventory slots reference to it, and I cannot destroy it. How are non-monobehaviour classes supposed to be handled in Unity? Any tips on how I can get rid of the used up item?


texts:
I want to create my first game with java. I need a top view map of a city and i am stuck. Randomly there will be happening events in that city and the player should click on it.

Now is my first problem how to create the map in java. I designed a small map with tiled but not sure how to use it now:

I want to use this in the java game. I am stuck. I want to let the events happen on the streets. How do i do this? I am looking for some good tutorials but i am not sure what i am looking for so i could use some help in that direction.

Sorry for my english :(


texts: How do I stop the player from rotating when they collide with a tile?

texts:
I use Touch movement and if I jump and hit a corner with the feet of my player, my player rotates but I don't want this. Can anyone help me jumping without rotating if I hit anything ?

here is my Script:

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

    public float speed = 10, jumpVelocity =  10;
    public LayerMask playerMask;
    public bool canMoveInAir = true;
    Transform myTrans, tagGround;
    Rigidbody2D myBody;
    bool isGrounded = false;

    private Animator anim;

    // Use this for initialization
    void Start ()
    {
        myBody = this.GetComponent<Rigidbody2D>();
        myTrans = this.transform;
        tagGround = GameObject.Find (this.name + "/tag_ground").transform;

        anim = GetComponent<Animator> ();
    }

    // Update is called once per frame
    void FixedUpdate ()
    {
        isGrounded = Physics2D.Linecast (myTrans.position, tagGround.position, playerMask);

        #if UNITY_ANDROID && !UNITY_IPHONE && !UNITY_BLACKBERRY && !UNITY_WINRT
        Move(Input.GetAxisRaw("Horizontal"));
        if(Input.GetButtonDown("Jump"))
           Jump();
        #endif
    }

    public void Move(float horizontalInput)

    {
            //Er klebt nicht mehr an den Waenden
        if (!canMoveInAir && !isGrounded)
            return;

        Vector2 moveVel = myBody.velocity;
        moveVel.x = horizontalInput * speed;
        myBody.velocity = moveVel;

        anim.SetFloat ("speed", Mathf.Abs (GetComponent<Rigidbody2D> ().velocity.x));

        if (horizontalInput < 0)
        {
            transform.localScale = new Vector2 (25, 25);
        }
        if (horizontalInput > 0)
        {
            transform.localScale = new Vector2 (-25, 25);
        }
    }

    public void Jump()
    {
        if (isGrounded)
            myBody.velocity += jumpVelocity * Vector2.up;
    }
}


texts:
I've been trying to draw a text to the display using Slick.
However, when ever I draw the TrueTypeFont to the screen, it draws it reversed upside down and also, it makes the whole display turn black.

This is only a piece of the entire game code, I think this is enough to explain the problem though. I'm new to LWJGL and Slick so this is probably a stupid question.

public Game(String name, int width, int height)
{
    this.name = name;
    this.width = width;
    this.height = height;

    try {
        Display.setDisplayMode(new DisplayMode(width, height));
        Display.setTitle(name + " " + version);
        Display.setResizable(true);

        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();

        Display.destroy();
        return;
    }

    TrueTypeFont font;
    Font awtFont = new Font("Arial", Font.PLAIN, 24);
    font = new TrueTypeFont(awtFont, false);

    Player player = new Player(this, 32, 32);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    while(!Display.isCloseRequested())
    {
        glClear(GL_COLOR_BUFFER_BIT);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, width, 0, height, -1, 1);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        drawBackground();

        player.update();
        player.draw();
        font.drawString(50, 50, "Platform");

        Display.update();
        Display.sync(60);
    }

    Display.destroy();
}

Edit:
After doing what @Katu said, I changed glOrtho(0, width, 0, height, -1, 1); to glOrtho(0, width, height, 0, -1, 1);.
The text is not reversed upside down, but the black screen is still there.

The screen should look something like this. (NOTE: It's an edited image)


texts: FindWithTag returning a game object from "Preview Scene". What is that and why is it not detecting from the active scene?

texts: I have a script that fetches a transform using GameObject.FindWithTag("Tag").GetComponent<Transform>();. This has worked fine for a long time, but now it retrieves a transform from a preview scene(whatever that is). How do I prevent it from looking at preview scene?


texts:
I am learning LWJGL so i can start working on my game. In order to learn LWJGL I got the  idea to implement the map builder so I can get comfortable with graphics programming. Now, for the map creation tool I need to draw new elements or draw the old one's with different coordinates.

Let me explain this:

My game will be a 2D scroller. The map will be consisting of multiple rectangles ( 2 strip triangles). When I click my left-mouse button i want to start the rectangle and when I release it I want to stop the rectangle bottom-right at that position.

As I want to use VBOs I want to know how to modify data inside the VBO based on user input.
Should i have a copy of a vertex array and then add the whole array to the VBO at each user input? How is usually implemented the VBO update?


texts:
I came across the following segment of code that is supposed to project an image on a hemisphere:

void main(void)
{
    vColor = aColor;
    vec4 pos = uModelViewMatrix * vertex;
    float lenxy = length(pos.xy);
    if(lenxy != 0.0)
    {
       float phi = atan(lenxy, -pos.z);
       pos.xy = normalize(pos.xy);
       // pos.xy is equal to (cos theta, sin theta)
       float r = phi / (PI/2.);
       // radius is less than or equal to 1.
       pos.xy *= r;
       // same theta, different radius
    }
    gl_Position = uProjectionMatrix * pos;
 }

The followings are what I need clarifications for:

Why would r be less than or equal to 1 by dividing phi by PI/2.?
Why are we multiplying pos.xy with r?
And, how does normalizing pos.xy give us cos theta and sin theta?

The followings are the accompanying images:

Thanks.


texts: SceneKit-Convert a rotation vector into rotation matrix

texts:
I'm very new and I'm studying this ARKit code from RPasecky/CubesInSpace on github where he/she convert the point of view 's rotation vector into a rotation matrix

https://raw.githubusercontent.com/RPasecky/CubesInSpace/master/CubesInSpace/MainViewController.swift

func calculateCameraDirection(cameraNode: SCNVector4) -> SCNVector3 {
    let x = -cameraNode.x
    let y = -cameraNode.y
    let z = -cameraNode.z
    let w = cameraNode.w
    let cameraRotationMatrix = GLKMatrix3Make(cos(w) + pow(x, 2) * (1 - cos(w)),
                                              x * y * (1 - cos(w)) - z * sin(w),
                                              x * z * (1 - cos(w)) + y*sin(w),

                                              y*x*(1-cos(w)) + z*sin(w),
                                              cos(w) + pow(y, 2) * (1 - cos(w)),
                                              y*z*(1-cos(w)) - x*sin(w),

                                              z*x*(1 - cos(w)) - y*sin(w),
                                              z*y*(1 - cos(w)) + x*sin(w),
                                              cos(w) + pow(z, 2) * ( 1 - cos(w)))

It was called from here

    let rotation = self.sceneView.pointOfView!.rotation //else { return (SCNVector3Zero) }
    let direction = calculateCameraDirection(cameraNode: rotation)

I understand the rotation of pointOfView that is passed in has x, y, z as the coordinate of the axis and w is the rotation angle. But how do I arrive at the code in the function? Which concepts should I learn about here?

I read about homogeneous vector, find rotation matrix between 2 vectors, and transformation matrix but this doesn't look like it

Thanks,


texts: Rotate 3D camera relative to what's on screen (in threejs)

texts:
I'm trying to have a camera in Threejs react to respective left/right/up/down/forward/backward keys, always based on the direction the camera is currently facing. It works fine left/right (camera.rotation.y) and up/down (camera.translateZ) but rotating forward-down/ backward-up (camera.rotation.z) won't work correctly once the camera is already facing up/ downways. Any help please?

Thanks!


texts: How to simulate the movement of a ball in 2D due to force, gravity, and friction with surface?

texts:
I have a ball which I kick with some force.
It has a starting x,y position, sat (2,3) and an intended target x,y  say (7,8) position.
That means I have to translate by (7-2, 8-3) i.e. 5 x units and 5 y units to reach destination.

The things acting on this ball are

force of kick(in direction of target), gravitational pull towards floor due to mass, and friction force provided by grass.

I will experiment different values of the 3 and see which one best simulates. But how do I calculate time required to destination and how much to translate in every frame of my game?

Can anybody please give me an equation for displacement due to these 3 factors and how velocity and other factors required in the equation change with time elapsed?


texts:
I would like to design games with very high difficulty levels. I have read these questions:

How is game difficulty tested/balanced?
What is an optimum failure rate that will keep people coming back to my game?

Yet they focus on general game design and balance, and not on the particular topic of increasingly adding to the difficulty of a game.

I understand that difficulty is different for every game, so I would like to know if there are any general guidelines I could follow to avoid falling into common problems that there may be while designing games and levels on the hard side of the difficulty line, regardless of the genre of the game.

Some sub-questions that come to mind are:

How to ensure 'beatability' while designing insanely hard parts of game?
How to know it is possible to actually beat my game?

For instance, when designing a platformer, I could make a really hard sequence of jumping and dodging. Now, as developer, I know precisely how far the player character can jump, how fast projectiles are moving etc, but how can I ensure that the designed level is actually beatable?

I know that the most obvious answer is to try and play it, but then, the game would be only as hard as how good at playing it the developer is.

Does anybody with actual experience making hard games know of any tricks or guidelines I can use to successfully create a difficult game?


texts: A problem with texture atlasing in Unity

texts:
I have the texture below and I need to get rectangular parts from it. I could finally combine meshes of different quads to improve performance, but I with quads of different tilings, this means different materials, then combining meshes will fail.

Can anybody tell me how to have a part of that texture in C#? Such that all quads will be of the same material only then combining meshes passes.

Thanks in advance.


texts: Tags changing automatically on iOS build!

texts:
First let me tell you that game runs fine in the editor. I check for hitting an enemy via a tag comparison and as I said it works correctly in the editor but when I deploy to my iPad and attach remotely with with MonoDevelop, I can see that the same object I'm checking against in Editor and had "Enemy" tag now has another tag, "Door".

Even before character doing anything, their tag is changed to "Door".

It's actually in the main menu and before running much code so I'm fairy certain it's not my code.

I'm sure there is nowhere in the code that I'm changing the tags.

And my specs: Unity is 5.6.1, Xcode is 8.3.3 and my iPad iOS is 10.3.2 and my macOS (OS X) is 10.12.5
(Tried with both Append and Replace builds)

Thanks


texts:
I am currently making a simple game in XNA but am at a point where testing various aspect gets a bit tricky, especially when you have to wait till you have 1000 score to see if your animation is playing correctly etc. Of course i could just edit the starting variable in the code before I launched but I have recently been interested in trying to implement a console style window which can print out values and take input to alter public variables during run-time.

I am aware that VS has the immediate window which achieves a similar thing but i would prefer mine is an actual part of the game with the intention that the user may have limited access to it in the future.

Some of the key things i have yet to find an answer to after looking around for a while are:

how i would support free text entry
how i would access variables during runtime
how i would edit these variable

I have also read about using a property grid from windows form aps (and partially reflection) which looked like it could simplify a lot of things but i am not sure how I would get that running inside my XNA game window or how i would get it to not look out of place (as the visual aspect of is seems to be aimed just for development time viewing).

All in all I'm quite open to any suggestions on how to approach this task as currently I'm not sure where to start. Thanks in advance.