texts: Target tracking with a small delay (actionscript 3.0)

texts:
I'm having trouble thinking of a good method to track my character with an enemy attack. Of course, I don't want the attack to track my character's current position; I want it to track where the character was about 1 second before (so you can move around and make the attack miss and loop around you sort of a thing).

The general structure of my game uses a timer to update all of my events. I have a timer going off every 25 milliseconds that updates everything, including my player's position and the enemies position. Right now I just have the enemy attack directly targeting my character....which works fine except that it's impossible to escape =p.

Let me know if I didn't supply enough details. My approach was going to basically be get my character's position from about 1 second ago, then have the enemy target that position, the only problem is I can't think of a good way to get my character's position from previous times. Thanks for the help!


texts: What percentage of development time should I spend in balancing?

texts: As an indie developer, I am inclined to release the game as soon as it is 'finished'. In hindsight, most of my games could have used more balancing. I know that there is no fixed answer to this question, but as a thumb rule, what percentage of total development time should be dedicated to game balancing?


texts:
I am very new to game development but I do have some programming experience of a few years, but that isn't helping me. I am trying to create a simple ragdoll character( a stickman) by joining the limbs and the head to the torso using Hinge Joints 2D. I also added a code enabling the Ragdoll to move around by applying a force to his body. When I hit the play button, while falling to the ground( a rectangular sprite), the stickman keeps twisting inwards. All the body parts seem to be twisting clockwise even though the motor is disabled on all of them.
So the Stickman goes from this -

To this-

I have configured the joints as below -
The leg joint -

The Hand joint -

The Head joint -

Can someone please tell me what I am doing wrong?


texts: Why does my collision detection code cause my framerate to drop?

texts:
I have this code:

foreach (CollisionTiles tile in map.CollisionTiles)
{
  player.CollisionBox(tile);
  foreach (Enemy enemy in enemys)
    enemy.CollisionBox(tile);
}

This is the CollisionBox() function:

public void CollisionBox(CollisionTiles tile)
{
  int x = rectangle.X / Map.Size;
  int y = rectangle.Y / Map.Size;
  int tileX = (int)tile.Position.X;
  int tileY = (int)tile.Position.Y;

  if (tileX >= x - 1 && tileX <= x + 2 && tileY >= y - 1 && tileY <= y + 3)
  {
    Collision(tile.Rectangle, Map.Width, Map.Height);
    tile.Collide = true;
  }
}

These two lines appear to be the problem:

 int x = rectangle.X / Map.Size;
 int y = rectangle.Y / Map.Size;

I guess because it loops through them on every tile...

The Collision() function just check the face's of the two triangles (both player/enemy and the tiles) with these functions:

 public static bool TouchTopOf(this Rectangle r1, Rectangle r2)
 {
   return (r1.Bottom >= r2.Top && r1.Bottom <= r2.Top + (r2.Height / 2));
 }

public static bool TouchBottomOf(this Rectangle r1, Rectangle r2)
{
  return (r1.Top >= r2.Bottom - (r2.Height / 2));
}

  public static bool TouchLeftOf(this Rectangle r1, Rectangle r2)
  {
  return (r1.Top <= r2.Bottom - (r2.Height / 2) &&
          r1.Bottom >= r2.Top + (r2.Height / 2) &&
          r1.Right >= r2.Left &&
          r1.Right <= r2.Left + (r2.Width / 4));
  }

  public static bool TouchRightOf(this Rectangle r1, Rectangle r2)
  {
    return (r1.Top <= r2.Bottom - (r2.Height / 2) &&
            r1.Bottom >= r2.Top + (r2.Height / 2) &&
            r1.Left >= r2.Right - (r2.Width / 4) &&
            r1.Left <= r2.Right);
  }

When there is more then one monster with the player I get a massive FPSdrop, and it's getting worse when more monsters get added. What should I do to fix that problem?


texts: Best way to create a Chromadepth shader for unity?

texts:
I'm trying to create a chromadepth environment in unity3D. So the camera sees close objects colored as red, and then farthest objects as blue. And everything in between falls down the color spectrum (Red orange yellow green blue)

I've looked into a few things such as z depth or even using fog for this kind of thing. But I'm not sure what the best way to approach this is; or maybe it's already been done before but I couldn't find it in the asset store.
I
Thanks in advance for your thoughts and time, it is much appreciated.


texts: (2D) Take player speed into account while shooting bullets

texts:
In my top down 2D game, there is a plane as shown below:

The plane shoots bullets forward. For firing bullets, I use:

obj.GetComponent<Rigidbody2D>().AddForce(transform.up*500);

However, when player presses up arrow or A key, plane speed increases. At this point, bullets are slower than the plane and appear to move backwards when plane moves at maximum speed.

How do I take into account player speed so that force applied takes into account player speed?


texts: Fast Serialization for Multiplayer Gaming

texts:
I wish to make a Java based multiplayer game. I am learning all about sockets and so forth. I have built a very basic UDP system that serializes an object with all the information about the game state and then sends that to the client. The client sends input which changes the game state.

My question is, is serializing an entire object an acceptable way to send game info over the internet.

It's super simple but my placeholder images are lagging quite a bit across the screen on a localhost. This could be for several reasons but I was wondering if serializing and then sending and then de-serializing was just too slow a method? This game will be fast paced and reflex oriented.


texts: Working together on a game as a project over the internet

texts:
I'm looking for someone who would be willing to work on a project that would potentially become something similar to the game evony/tribal wars, but the project won't be primarily for actually making the game, rather than learning from starting to make the game work.

What website would I go about finding someone willing to help me with this and work together on a little project, no money involved unless things started really progressing, in that case if we actually do complete something worth money, then there will definitely be an even split of the income. I'm not what you would call great at programming, I have learned everything from teaching myself and have never taken a college level (or highschool) programming class, but I'm not bad at it or anything. And if anyone reading this is interesting, leave a comment.


texts: How to make a static Material reference?

texts:
I have a class Edge which may change to multiple colors - materials in this case. I need to switch a Material on MeshRenderer.

In order to do this, I'd need to make multiple prefabs public variables like

class Edge : Mono{

    public Material red, blue, green;

    public void SwitchColor(SomeColorEnum param){
        switch(param)
           // change
           // this.renderer.mat = something;
    }

}

This is a bad solution for this, cause I'd need at least 3 material references in each Edge object. Is there any way to make a material static, assign it from a prefab and then access it statically?


texts: Modern OpenGL Sprite Drawing - Not Rendering

texts:
I'm trying to render sprites based of this tutorial, in LWJGL.

Here's what I have so far, with descriptions of what class I use:

Transformable2D is a class that holds transform matrices meant for 2D rendering, and Drawable is just an interface that has a draw() function.

Texture is a container for loading and creating Textures, and its bind function just sets the active  texture to it's ID and binds itself to the passed unit parameter.

SpriteTechnique is a container for a shader program, and I will paste the shaders here too, although they are the same as from the tutorial.

I make the shader and vao static, because every Sprite uses the same vao and shader.

Finally, I pass a View to the draw() function, which holds the necessary info to make an orthogonal matrix based off the transforms of the object. This matrix is correct, as I also use it for text rendering, where it works as expected.

All of  the classes described above work completely; I am 100% sure the problem is not within the backing classes. Here are the GL settings I set in my backend, too:

glFrontFace(GL_CW);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);

So, onto the actual class:

public class Sprite extends Transformable2D implements Drawable {

    private Texture texture;

    private Vector3f color;

    private static SpriteTechnique tech = new SpriteTechnique();

    private static boolean isRendererInitialized;

    private static int vao;

    public Sprite(Texture texture) {
        this.texture = texture;
        color = new Vector3f();
    }

    public static boolean initRenderer() {
        if (isRendererInitialized) {
            return true;
        }

        if (!tech.init()) {
            return false;
        }

        float[] vertices = {
            // Pos      // Tex
            0.0f, 1.0f, 0.0f, 1.0f,
            1.0f, 0.0f, 1.0f, 0.0f,
            0.0f, 0.0f, 0.0f, 0.0f,
            0.0f, 1.0f, 0.0f, 1.0f,
            1.0f, 1.0f, 1.0f, 1.0f,
            1.0f, 0.0f, 1.0f, 0.0f
        };
        FloatBuffer vertexBuf = BufferUtils.createFloatBuffer(vertices.length);
        vertexBuf.put(vertices);
        vertexBuf.flip();

        vao = glGenVertexArrays();

        glBindVertexArray(vao);

        int vbo = glGenBuffers();

        glBindBuffer(GL_ARRAY_BUFFER, vbo);
        glBufferData(GL_ARRAY_BUFFER, vertexBuf, GL_STATIC_DRAW);

        glEnableVertexAttribArray(0);
        glVertexAttribPointer(0, 4, GL_FLOAT, false, 16, 0);

        //glBindBuffer(GL_ARRAY_BUFFER, 0);
        //glBindVertexArray(0);

        isRendererInitialized = true;

        return true;
    }

    @Override
    public void draw(View v, RenderStates states) {
        if (!isRendererInitialized) {
            System.err.println("Sprite renderer must be initialized before drawing sprites!");
            return;
        }

        tech.enable();

        tech.setTextureUnit(COLOR_TEXTURE_UNIT_INDEX);
        tech.setColor(color);
        tech.setProjection(getOrthoTrans(v).getMatrix());

        texture.bind(COLOR_TEXTURE_UNIT);

        glBindVertexArray(vao);

        glDrawArrays(GL_TRIANGLES, 0, 6);
        //glBindVertexArray(0);
    }
}

Here are my shaders:

Sprite.vs:

#version 330 core
layout (location = 0) in vec4 vertex; // <vec2 position, vec2 texCoords>

out vec2 TexCoords;

uniform mat4 gProjection;

void main()
{
    TexCoords = vertex.zw;
    gl_Position = gProjection * vec4(vertex.xy, 0.0, 1.0);
}

Sprite.fs:

#version 330 core
in vec2 TexCoords;
out vec4 color;

uniform sampler2D gSpriteTexture;
uniform vec3 gSpriteColor;

void main()
{
    color = vec4(gSpriteColor, 1.0) * texture(gSpriteTexture, TexCoords);
}

When I try to render a Sprite, however, nothing appears on the screen. Not even a black quad. I've tried to scale the quad, but to no avail. What am I doing wrong here?


texts: How can I access LWJGL's Keyboard from a thread other than the graphics thread?

texts:
I'm loving LWJGL, but have been running into a number of odd problems with it. Most of it seems to deal with the fact that OpenGL is a state-machine and was only ever meant to be accessed from a singular thread.

However, I'm dealing with OpenAL and input as well, and they are both bound pretty tightly into LWJGL. In spite of the fact that they are entirely independent of graphics, I have been getting an IllegalStateException every time I try to access Keyboard.isKeyDown outside of the graphics thread. It's hard to emphasize how important it is to me that I have a new thread for each feature of this project; the classic game loop will not do the job.

How do I accomplish this? There must be a way.


texts: Could you create a game for an older system (say, SNES) and sell it with an emulator as well as the game?

texts: I was looking into development for the SNES in assembly, as programming in assembly is my hobby. I then had the thought: what if I could sell my native SNES games for modern use (on steam, bundled with an emulator for example)?


texts:
I have several animations that I am using on a GameObject.  I switched the folder they were stored in, and they got detached from the gameObject.  How can I add the existing animations to my gameObject without having to recreate them?

I am not looking to do this programmatically.  I just want to undo the damage I have done without having to start over.  Ideally, I want a "Load Animation" option from the Animator window in the editor, but that does not appear to exist :-/.


texts:
Is it possible to rotate my sprite in LibGDX?

public class Flame {
    private static final int FRAME_COLS = 6;
    private static final int FRAME_ROWS = 1;

    private Animation flameAnimation;
    private Texture flameSheet;
    private TextureRegion[] flameFrames;
    private SpriteBatch spriteBatch;
    private TextureRegion currentFrame;

    private float stateTime;

    private int xFlame;
    private int yFlame;
    private float rotation;

    /*
        Some code here
    */

    public void draw(){
        stateTime += Gdx.graphics.getDeltaTime();
        currentFrame = flameAnimation.getKeyFrame(stateTime, true);
        /*
          I also try currentFrame.flip(true, false); // but this doesn't work
        */
        spriteBatch.begin();
        spriteBatch.draw(currentFrame, xFlame, yFlame);
        spriteBatch.end();
   }


texts: Is there a way to make the reflection probes to work smooth without making the game lag?

texts:
In the Hierarchy I have 6 Reflection Probes and the only different between each one is the position and the box size.

The problem is when i'm running the game after few seconds it's loading the reflection probes and that make the game to freeze for 1-2 seconds then the lights are changing and then the game continue regular.

Is there a way to avoid this 1-2 seconds freeze ?


texts: Tips on how to notify a user of new features in your game

texts:
I have noticed a problem when releasing new features for a game that I wrote for Android and published on Google Play Store. Because my game is "stage-based"  - and not a game like Hay Day, for example, where users will just go into the game every day since it can't really be finished - my users are not aware of new features that I release for the game.

For example, if I publish a new version of my game and it contains a couple new stages, most of their devices will just auto-update the game and they don't even notice this and think to check out what's new. So this is why an approach like popping open a dialog that showcases the new feature(s) when they open the game for the first time after the update was done is not really sufficient.

I am looking for some tips on an approach that will draw my users back into the game and then they could read more detail about new features on such a dialog. I was thinking of something like a notification that tells them to check out the new features after an update is done but I am not sure if this is a good idea. Any suggestions to help me solve this problem would be awesome.


texts:
Is it possible to use swapChildren() with a child and a child's child? Every time I try, I get this error:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.

Why can I not compare a child with a child's child? How can I?


texts:
I am using Unity and I have some difficulties about understanding the way Set Render Target works and how it can behave with the shaders.

Is it possible to render a shader pass in multiple render targets ? How ?
As this behaviour seems to be linked with all rendering platforms and not only Unity, any help is welcome.

Thanks !


texts: When when pressing on the G key one of parts is scaling slower then the other?

texts:
Each Prefab is built with canvas and two panels childs of the canvas.
I'm scaling the two panels. The automatic mode part is working fine.

The problem is with the G key. When I press once on G it's scaling both panels up to maxSize then when pressing on G once again it's scaling the panels back down to minSize.

But when I press on G quick in the middle while it's scaling them it should turn the scaling side in the middle. For example if I press G and both panels start scaling to maxSize if in the middle I press on G again it should scale them both to minSize without getting first to the maxSize. But in this case one of panels is keep scaling to maxSize a bit and then move back to minSize.

But they both should turn side in the middle at once. It seems like one of them have a lag he turn sides a bit after the first one.

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

public class Scaling : MonoBehaviour
{
    public GameObject Prefab;
    public int numberOf = 1;
    public float duration = 1f;
    public Vector3 minSize;
    public Vector3 maxSize;
    public bool scaleUp = false;
    public Coroutine scaleCoroutine;
    public bool automatic = false;
    public bool coroutineIsRunning = false;

    private List<GameObject> parts = new List<GameObject>();

    private void Start()
    {
        for (int i = 0; i < numberOf; i++)
        {
            GameObject objecttest = Instantiate(Prefab);
            foreach (Transform child in objecttest.transform)
            {
                parts.Add(child.gameObject);
            }
        }
    }

    private void Update()
    {
        if (automatic)
        {
            if (!coroutineIsRunning)
            {
                Scale();
            }
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.G))
            {
                Scale();
            }
        }
    }

    private void Scale()
    {
        scaleUp = !scaleUp;

        if (scaleCoroutine != null)
            StopCoroutine(scaleCoroutine);

        for (int i = 0; i < parts.Count; i++)
        {
            if (scaleUp)
            {
                scaleCoroutine = StartCoroutine(ScaleOverTime(parts[i], maxSize, duration));
            }
            else
            {
                scaleCoroutine = StartCoroutine(ScaleOverTime(parts[i], minSize, duration));
            }
        }
    }

    private IEnumerator ScaleOverTime(GameObject targetObj, Vector3 toScale, float duration)
    {
        float counter = 0;
        Vector3 startScaleSize = targetObj.transform.localScale;

        coroutineIsRunning = true;

        while (counter < duration)
        {
            counter += Time.deltaTime;
            targetObj.transform.localScale = Vector3.Lerp(startScaleSize, toScale, counter / duration);

            if (counter > duration)
                coroutineIsRunning = false;

            yield return null;
        }
    }
}


texts: Using texture() in combination with JBox2D

texts:
I'm getting some trouble using the texture() method inside beginShape()/endShape() clause.

In the display()-method of my class TowerElement (a bar which is DYNAMIC), I draw the object like following:

void display(){
    Vec2 pos = level.getLevel().getBodyPixelCoord(body);
    float a = body.getAngle(); // needed for rotation

    pushMatrix();

    translate(pos.x, pos.y);
    rotate(-a);

    fill(temp);    // temp is a color defined in the constructor
    stroke(0);

    beginShape();
    vertex(-w/2,-h/2);
    vertex(w/2,-h/2);
    vertex(w/2,h-h/2);
    vertex(-w/2,h-h/2);
    endShape(CLOSE);

    popMatrix();

}

Now, according to the API, I can use the texture() method inside the shape definition. Now when I remove the fill(temp) and put texture(img) (img is a PImage defined in the constructor), the stroke gets drawn, but the bar isn't filled and I get the warning

  texture() is not available with this renderer

What can I do in order to use textures anyway? I don't even understand the error message, since I do not know much about different renderers.


texts: Which three points to use to calculate a frustum plane?

texts:
So I have a view frustum I'm going to be using for frustum culling. I have a method that finds the cross-product of three points but since each side of the frustum has four corners I don't know which three to use and in which order.

Point numbers:

My question is, does anyone know what order and which points to use?


texts: Which consoles may I target with OpenGL?

texts:
I'm thinking on technical design for a game/game engine using OpenGL, and I wonder if there is any recent consoles (Xbox360, PS3, Wii U, Xbox one and PS4) that I could work with if I do so.

I found plenty of conflicting answers through forums. The only straight answer seems that it is impossible for Xboxes because Microsoft forbid to use something else than DirectX, its own product.

So, finally, does anyone know for sure which consoles can support an OpenGL-based game?


texts: How to aim with a spaceship in 3D considering its angular momentum?

texts:
So I have a spaceship and I have 6 degrees of freedom.

At a given moment the following vectors are known of the spaceship:

Local forward.
Local up.
Local sideways (may be implied from the previous two).
Angular momentum.

The spaceship has 3 torquers to add/subtract to the angular momentum the in main directions relative to it.

Each of them can add 0 to 1 units of angular momentum per second (so it's possible to run them less than full power when needed).

So from the given vectors, how can I compute which torquers to run to lock on the target vector as quickly as possible?

I think this is a basic problem in the field of attitude control. But I couldn't find good pointers yet (maybe I didn't use the right keywords in my search).

The tricky part is that I want to consider the instantaneous angular momentum. Otherwise I would just cross multiply the forward vector and the desired direction vector to have the desired axis of rotation, but that's not what I'm looking for...

My current idea is the following: use the roll torquers to eliminate the roll component the spaceship rotation if any, while using the pitch/yaw torquers to rotate it into the direction based on pitch/yaw angular differences of the forward and the desired direction and the pitch/yaw component of the spin. But I'm not sure it's the quickest, might not even be correct.


texts: How can I get a reference to a object in the world in UE4?

texts:
I'm coding a simple maze game in UE4 and I have everything I wanted to implement done except having an obstacle in the scene. What I have is a simple Obstacle class which is a child of an Actor class.

Now in the scene I have a Blueprint which is a child of the Obstacle class and this Blueprint is placed in the maze. What I'm trying to achieve is when the player collects so many objects (let's say 10) then the Obstacle will be destroyed but I don't know how to get a reference to that Obstacle object in my code.

AObstacle* Obstacle /////// This is where I don't know how to initialize the object
if (MyCharacter->collectedPickUps >= requiredAmountOfPickups)
{
    Obstacle->Destroy();
    Obstacle->isActive = false;
}


texts: Determining the first future intersection possible between ships and a planet

texts:
Somewhat of an extension of this.

The Problem

I have a ship being launched from a planet, and I would like it to travel at a constant speed and direction such that it intersects another planet the soonest that it can.

(Beautiful diagram courtesy of Ausa)

I am ignoring initial velocity, end velocity, and gravity. The angular velocity of the planets and the velocity of the ship is constant. The physics that I am trying to achieve need not be realistic.

Using some quick maths I created a function! The function determines the smallest fly-by distance from the ship to the planet over time if the ship were to take the optimal route (a linear route since there's no gravity). So by determining when the fly-by distance is 0 (when the paths of the ship and planet intersect) I can work backwards to easily determine the angle of which I must launch the ship at to achieve this.

I created an implementation of the Bisection Method to find the first root of the function but depending on the variables of the function, the bisection method isn't the best solution to this problem. So now I'm trying to solve it mathematically! This is essentially what I need to solve:

Any solutions or ideas are greatly appreciated, thank you!

TL;DR:

This means I want to find the x-intersection of the function nearest to the origin.

Desmos

If you're interested in playing around with this function, I graphed it in Desmos https://www.desmos.com/calculator/tdtzt1gqkl

r_0 radius from the planet to the sun ("magic" units)

a_0 current angle of the planet in relation to the run (clockwise radians)

s_0 angular speed of the planet (clockwise radians per second

x_1 current x-position of the ship ("magic" units)

y_1 current y-position of the ship ("magic" units)

s_1 speed of the ship ("magic" units per second)

x_p planet x-position at x time ("magic" units)

y_p planet y-position at x time ("magic" units)

d_x delta x-position from ship to planet at x time ("magic" units)

d_y delta y-position from ship to planet at x time ("magic" units)

d_net net delta position from ship to planet at x time ("magic" units)

v_x optimal x-component of ship velocity ("magic" units per second)

v_y optimal y-component of ship velocity ("magic" units per second)

x_s ship x-position at x time ("magic" units)

y_s ship y-position at x time ("magic" units)

f(x) net distance from planet to ship at x time


texts:
I'm following a tutorial about the time management and, the tutorial shows this function:

double GetFrameTime()
{
    LARGE_INTEGER currentTime;
    __int64 tickCount;
    QueryPerformanceCounter(&currentTime);

    tickCount = currentTime.QuadPart-frameTimeOld;
    frameTimeOld = currentTime.QuadPart;

    if(tickCount < 0.0f)
        tickCount = 0.0f;

    return float(tickCount)/countsPerSecond;
}

The tutorial explains that, this function basically gets the time that one frame takes, but, I don't understand how the variable tickCount can be negative, if the currentTime is
increasing all the time (calling this function every frame, obviously), so, is that if really necessary?


texts: How to find collision detection side between two objects?

texts:
I am using box2D and I have two objects, one is bouncy ball and the other one is block. I'd like to find which side of the block is collided with, so I can only make the ball bounce when it hits the top.

I tried to implement many things like fixture data and by detecting position, using manifold but not get the accurate result. I also tried to calculate distance between two object but all went wrong.


texts: What does Unity's "Speed of Sound"-option do?

texts: I've been reading Unity's manual on the AudioManager's properties.  Speed of Sound is the only undocumented option. What is it for?


texts: Why do the order of struct members between vertex and pixel shader must be reversed?

texts:
This has been driving me crazy for the last two days but it is finally working, however I really don't see why the order of struct members should be reversed.

Why do members of PS_INPUT must be reversed compared to VS_INPUT for this shader to work ?

Texture2D<float4> Texture;

SamplerState linearSampler
{
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Wrap;
    AddressV = Wrap;
};

// A constant buffer that stores the three basic column-major matrices for composing geometry.
cbuffer ModelViewProjectionConstantBuffer : register(b0)
{
    matrix model;
    matrix view;
    matrix projection;
};

struct VS_INPUT
{
    float4 Position : SV_Position;
    float4 Color    : COLOR0;
    float2 TexCoord : TEXCOORD0;
};

struct PS_INPUT
{
    float2 TexCoord : TEXCOORD0;
    float4 Color    : COLOR0;
    float4 Position : Position;
};

PS_INPUT mainVS(VS_INPUT vs_input)
{
    float4 pos = float4(vs_input.Position);
    pos.w = 1.0f;
    pos = mul(pos, model);
    pos = mul(pos, view);
    pos = mul(pos, projection);

    PS_INPUT output;
    output.Position = pos;
    output.Color = vs_input.Color;
    output.TexCoord = vs_input.TexCoord;
    return output;
}

float4 mainPS(PS_INPUT ps_input) : SV_TARGET
{
    float4 value = Texture.Sample(linearSampler, ps_input.TexCoord);
    value.rgb = 1 - value.rgb;
    return value;
}

float4 main(float2 uv : TEXCOORD0) : SV_TARGET
{
    float4 value = Texture.Sample(linearSampler, uv);
    value.rgb = 1 - value.rgb;
    return value;
}

technique Technique1
{
    pass Pass1
    {
        EffectName = "TextureEffect";
        VertexShader = compile vs_4_0 mainVS();
        PixelShader = compile ps_4_0 mainPS();
    }
}

Note that I am still getting the following even though things are being drawn:

D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Rasterization Unit is enabled (PixelShader is not NULL or Depth/Stencil test is enabled and RasterizedStream is not D3D11_SO_NO_RASTERIZED_STREAM) but position is not provided by the last shader before the Rasterization Unit. [ EXECUTION ERROR #362: DEVICE_DRAW_POSITION_NOT_PRESENT]
D3D11 ERROR: ID3D11DeviceContext::Draw: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (COLOR,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::Draw: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (Position,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]

Can you explain why it does that and how can I fix it ?


texts: How to avoid overwriting a value in Unity?

texts:
I'm working on a Tower Defence style game, and wondering how best to handle the "resources" part. I have multiple enemies on screen at a time, and when an enemy dies, it updates a resource that allows the player to build more towers
var tower = Instantiate(buildables[0], center, Quaternion.identity);
var controller = tower.GetComponent<TowerController>();
controller.OnKilledEnemy += (sender, args) =>
{
    int.TryParse(goldAmount.text.Replace(",", ""), out var curr);
    curr += args.gold;
    goldAmount.text = $"{curr:n0}";
};

But if 2 enemies die in the same frame, wouldn't the value there miss an update?
What ways are there in Unity/C# to mitigate this problem?


texts: How to drag my dragging object in 'game'-unity?

texts: I have made a dragging sphere which drags, problem is how can I drag it using keyboard keys , I dont want to build it again on iphone simulator after experimenting with my code. for dragging it is not accepting mouse or any keyboard keys. Is it possible ?


texts: Creating Unity games for older versions of Android?

texts: In the Unity editor, the lowest available Android version for debugging is Android 2.3.1 In my case, I have a phone running an older version of Android and I intend to publish my game to a wide audience. With the lowest version being 2.3.1, I see a problem publishing my games to older smartphones which still occupy a considerable size of the market share. My question is: Is there a way to publish my game to older versions of Android? Or is it impossible?


texts: Why when using editor script with handles with DrawSolidArc it's not drawing any arc over the object?

texts:
This is the editor script is in the Assets/Editor
using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(DrawSolidArc))]
public class DrawSolidArcEditor : Editor
{
    public float arrowSize = 1;

    void OnSceneGUI()
    {
        DrawSolidArc t = target as DrawSolidArc;

        Handles.color = Color.blue;
        Handles.Label(t.transform.position + Vector3.up * 2,
                             t.transform.position.ToString() + "\nShieldArea: " +
                             t.shieldArea.ToString());

        Handles.BeginGUI();
        GUILayout.BeginArea(new Rect(Screen.width - 100, Screen.height - 80, 90, 50));

        if (GUILayout.Button("Reset Area"))
            t.shieldArea = 5;

        GUILayout.EndArea();
        Handles.EndGUI();

        Handles.color = new Color(1, 1, 1, 0.2f);
        Handles.DrawSolidArc(t.transform.position, t.transform.up, -t.transform.right,
                                180, t.shieldArea);

        Handles.color = Color.white;
        t.shieldArea = Handles.ScaleValueHandle(t.shieldArea,
                        t.transform.position + t.transform.forward * t.shieldArea,
                        t.transform.rotation, 1, Handles.ConeHandleCap, 1);
    }
}

And the mono script for example this script is attached to a simple 3d cube :
using UnityEngine;

[ExecuteInEditMode]
public class DrawSolidArc : MonoBehaviour
{
    public float shieldArea = 5;
}

but there is nothing around the cube. not also near it nothing.
it should draw arch in the editor.
Later I want to be able to use the mouse with a click down and drag to be able to change the arc size but for not it's not drawing any arc.
I took the example from the unity official docs :
https://docs.unity3d.com/540/Documentation/ScriptReference/Handles.DrawSolidArc.html
I noticed now also for example that I don't see the gui button in the inspector of the object that the mono script is attached to :
if (GUILayout.Button("Reset Area"))

not sure what's wrong with the editor script.
This is working. I still wonder why the unity docs example didn't work but this is working and I don't need the editor script. The problem with this script is that I must to turn on the Gizmos in the editor and I don't want to make it turned on all the time. So it's working but not as I wanted.
I want to draw the arc without the gizmos.
using UnityEngine;

[ExecuteInEditMode]
public class DrawSolidArc : MonoBehaviour
{
    public Vector3 offset = Vector3.one;
    public float fieldOfViewAngle = 20;
    public float viewDistance = 4;
    public bool usePhysics2D = false;

    public void OnDrawGizmos()
    {
        DrawLineOfSight(this.transform, offset, fieldOfViewAngle, viewDistance, usePhysics2D);
    }
    public static void DrawLineOfSight(Transform transform, Vector3 positionOffset, float fieldOfViewAngle, float viewDistance, bool usePhysics2D)
    {
#if UNITY_EDITOR
        var oldColor = UnityEditor.Handles.color;
        var color = Color.yellow;
        color.a = 0.1f;
        UnityEditor.Handles.color = color;
        var halfFOV = fieldOfViewAngle * 0.5f;
        var beginDirection = Quaternion.AngleAxis(-halfFOV, (usePhysics2D ? Vector3.forward : Vector3.up)) * (usePhysics2D ? transform.up : transform.forward);
        UnityEditor.Handles.DrawSolidArc(transform.TransformPoint(positionOffset), (usePhysics2D ? transform.forward : transform.up), beginDirection, fieldOfViewAngle, viewDistance);
        UnityEditor.Handles.color = oldColor;
#endif
    }
}


texts:
OpenGL VBOs (vertex buffer objects) have been developed to improve performance of OpenGL (OpenGL ES 2.0 in my case). The logic is that with the help of VBOs, the data does not need to be copied from client memory to graphics card on per frame basis.

However, as I see it, the game scene changes continuously: position of objects change, their scaling and rotating change, they get animated, they explode, they get spawn or disappear.

In such highly dynamic environment, such as computer game scene is, what is the point of using VBOs, if the VBOs would need to be constructed on per-frame basis anyway?

Can you please help me to understand how to practically take beneif of VBOs in computer games? Can there be more vertex based VBOs (say one per one object) or there must be always exactly only one VBO present for each draw cycle?


texts:
I'm trying to make a Pawn that I can raycast against. Starting from the DefaultPawn object, I can't find a way to have a StaticMesh cube that simulates physics. My raycasting code works with Actors, but I'd like to apply the same feature to moving objects now.

Any advice on how to achieve this?


texts:
I have been trying to understand how projective texture works; and, even I have been able to achieve the result by following the steps in tutorial, I fail to understand how it works in my mind.

To my understanding, we need to construct a model, a view and a projection matrix for the texture along with a bias matrix which maps to [0, 1].

The usual steps consist of:

Calculating the UV within vertex shader by the projection texture's matrix (MVP + Bias matrix).
Then, sampling the texture (the smiley face) using the aforementioned UV passed in from vertex.

But what is actually happening within vertex shader and fragment shader?

Take the following image, for instance:

Please correct me if I am wrong:

Here, we have a teapot, a background texture and a texture for the projection (the smiley face).

What is happening when the background and the teapot is going through vertex and fragment shader as far as projective texture is concerned?

Some says rather than projecting the texture onto the objects in the scene, we are actually projecting the scene onto the the texture (the smiley face), which I also fail to see.

Again, by using the code found on most tutorial sites I have been able to achieve the result; but my goal is to be able to understand how things work, which I hope someone could offer me a hand here by taking me through the vertex and fragment shader and perhaps post some pictures which could help me to see what is happening in my mind. I have been trying to read several books and online tutorials on this but I have not been successful in understanding it.

Thanks.


texts:
I know most games store dialogue text in files, but I've also seen a few text-based games actually program the content (map, choices, possible player commands, story text) into the game code.

I can think of a few reasons, but what is the major reason why even text games keep everything in files outside the program?

The implementation details differ little between holding content in something like the popular XML format, parsing it, then rendering maps/displaying text based on the variables created from XML file, and simply forgoing the XML file entirely. They both end up with strings which output to the screen. Isn't the difference just notation?

Some games even hold the graphics (ASCII art?) inside the code. I know this isn't right, and I can guess a few reasons why it is bad, but don't know the major reason why either.

It is very popular to have most of the content outside the program. Even Dwarf Fortress doesn't use actual ASCII characters, but images of ASCII characters loaded into memory.

I primarily ask because it is a bit of a PITA to create, parse, and work with XML files. You know... compared to the lazy alternative of just making every unique dungeon (content) its own class.


texts:
I've seen that octrees are often used for things like frustum culling and collision detection in 3D. But I'm just not sure how the algorithm works at all. Surely the whole principle of the octree breaks when you try to use bounding boxes, because any given box could be stored in one node but actually overlap the space represented by another node. In addition, I'm not sure how this can possibly work for looking up bounding boxes rather than points, because again, you could be stuck looking up into virtually all the nodes, defeating the purpose.

So how on earth do octrees cope with bounding boxes?


texts: Unity - How to move a user controlled animated gameobject programmatically?

texts:
I have a player controlled gameObject with an attached script and animator with it's related animations. It all works great.

However the gameObject is on screen immediately on level startup.

I want to have the gameObject start off-screen so that story dialog can be displayed first and once completed the player gameObject will move onto the screen and then come under the players control.

I have been able to create a separate animator state for the "off-screen to on-screen" animation and it can be triggered separately in code. But I can't work out the logic needed to get the gameObject to do what I want.

In the enclosed image the PaddleIdle state keeps the paddle off screen.
The PaddleStartup state moves the gameObjects position onto the screen.
Once on-screen, the PaddleNormal state is supposed to start the gameObjects normal animations and allow player control.

I have tried a default transition from PaddleStartup to PaddleNormal but it performs one "PaddleStartup" sequence and then there is nothing.

I know I am missing something either I am not configuring a transition correctly or I am not scripting this correctly, can someone advise me on things I might try?

Thank you so much for your help


texts: Keeping score server side to prevent cheating

texts:
For my Unity WebGL game, I'm looking into storing the score of users in a database to make a highscore table (it's not a multiplayer game). Because client side code can always be "hacked", the advice most people give is: "keep the score server side so you can validate it".
But I don't quite understand how that would work. I could of course publish the score to the server using an Ajax call, and even hash it, but even then the cheater could just simply look at the hash method and use the same Ajax to upload a different score.

I'm assuming I should get a game server or something then? But again: no idea on how to start... I'm really just scratching the surface here.

So I'm basically looking for any sort of information on how to change my "regular", client side, WebGL Unity game to a game where I keep the score securely at server side so that the highscore table is valid.

I don't mind spending some money on both a server/assets that simplify the task. As I said, I'm just interested in implementing this feature, I don't need to become a game server wizard.

Note: even with server side scores, there's probably a way to cheat. There most likely always is, but at least it would be more secure than just inserting the final score into the database...


texts: How do I load Collada models into a WebGL app?

texts: I have written some simple apps following the tutorials on http://learningwebgl.com. What is the simplest way to load and display Collada model files, particularly the files available from Google 3D Warehouse?


texts: What language to use to create a browser-MMO?

texts:
I have a game ready to be implemented (Class Diagrams and other UML stuff are good).

Here are some characteristics:

MMO.
Browser game and download-game.
Multiplatform.
With 2D graphics.
Real time.
Point-and-click.
With an online database (duh!).

What language should I use?


texts: libgdx: 2nd var of myClass()'s values saving to/overriding 1st var of myClass()

texts:
I'm using libgdx with Eclipse.

PROBLEM:

In the class inputHandler I have a list of buttons, menuButtons, composed of 2 buttons: playButton and retryButton.
They both belong to the class simpleButton:

public static simpleButton playButton, retryButton;

I declared them as:

retryButton = new simpleButton(100, 100, 40, 10, retryRegion, retryRegion);
playButton = new simpleButton(80, 80, 20, 20, assetLoader.playButtonUp, assetLoader.playButtonDown);

(see note at end of question)

But when I run the game only the 2nd button runs (in the above case, playButton).

So I went to the class
gameRenderer
and used shapeRenderer to clearly see what was going on.

shapeRenderer.rect(inputHandler.retryButton.bounds.x, inputHandler.retryButton.bounds.y,
    inputHandler.retryButton.bounds.width, inputHandler.retryButton.bounds.height);

shapeRenderer.rect(inputHandler.playButton.bounds.x, inputHandler.playButton.bounds.y,
        inputHandler.playButton.bounds.width, inputHandler.playButton.bounds.height);

Although only the 2nd button was displaying, the 2nd button now adopted the code for both the buttons.
i.e. the 2nd button was now both the play and retry (replay) buttons and worked perfectly.

note from before:
These aren't their actual sizes (the actual sizes are equal to the sizes of the texture regions of their art graphics) but for the sake of simplicity and legibility I changed them to simpler values.

Pictures:

playButton on bottom (playButton working):

retryButton on bottom (retryButton working):

The simpleButton class:

public class simpleButton {

    private float x, y, width, height;

    private TextureRegion buttonUp;
    private TextureRegion buttonDown;

    public static Rectangle bounds;

    public static boolean isPressed;

    public simpleButton(float x, float y, float width, float height,
            TextureRegion buttonUp, TextureRegion buttonDown) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.buttonUp = buttonUp;
        this.buttonDown = buttonDown;

        bounds = new Rectangle(x, y, width, height);
    }


texts: Unity 3D - Have a Vector3 attribute on inspector that behaves as GameObject's Transform position Vector3

texts:
As the title suggests, I am looking to serialize on the Inspector a Vector3 that behaves just as the Transform's position Vector3:

If you modify the position Vector3, the GameObject positions itself according to the World Position.
If you move the GameObject on the scene by picking the handles, the GameObject moves, and the position Vector3 gets modified equal to the GameObject's position.

So, is there a way I can constrain a serialized Vector3, so if I modify it on the inspector I can change the GameObject's position, like this:

[ExecuteInEditMode]
public class LameExample : MonoBehaviour
{
    public Vector3 transformPosition;

    private void Update()
    {
        if(modifyingVectorOnInspector)
        transform.position = transformPosition;
        else if(gameObjectIsBeingMovedOnScene)
        transformPosition = transform.position;
    }
}

I've tried an approach using Selection.contains(gameObject), but that does not take into account if it is dragged by the handles.

Thanks in advance for your help.


texts:
I'm beginning to implement a simple scripting system into my networked server, and I've hit a snag. Before, I've been wrapping my calls into functions on objects that manipulate objects, but lately I've been finding this to be a pain for simple things. For example, if I set 'player.HP = 1'.. this works server-side. But the player side never sees this change unless I explicitly send a packet to inform the client.

For many things like map swapping that require more complicated changes, like change X, Y, Map and do this.. I have a function. That's fine. But what about these small properties I want to sync?


texts: How complex should enemy AI be in a dnd-alike?

texts:
I'm writing a text-mode (python + ncurses), turn-based rpg based loosely on 3rd edition D&D and Neverwinter Nights (the PC game) rules. It's not going to be a full implementation, but 'in the spirit' of them. I already have quite a bit of the basics in place; movement, a few base classes and races, rule-based encounters (shop/npc/monster X shows up when condition Y is true), dynamic generation of monsters, player and enemy stats and random, levelled equipment etc. It's enough to start moving around a basic world, talking to people, examining objects and location and now I'm moving on to (melee) combat.

I'm interested in what people would expect of an algorithm that co-ordinates the computer-controlled attacks of an enemy party against the player. How smart should the computer controlled enemy be (in my implementation the player will take control of each of his own characters in turn, and they wont be AI controlled, but the enemy party will - attacking, spell casting etc at-will).

For example; if an enemy character initially chooses a random pc from the players party on round 1, should that enemy continue to attack the same target in subsequent rounds. How about if another pc then attacks that enemy? What if the enemy is unable to cause damage to that pc (ie say the pc has something crazy like damage reduction 100/+5 - should the programme know in advance?), should they switch to another in the players party?

Has anyone implemented anything similar and would be able to provide any pointers?


texts:
I'm using Bullet Physics for Collision Detection in a first person game. The collision basically work fine, I cannot walk through objects. But if I walk against the wall and release the key I get bounced back and automatically move backwards. This is something I do not want. The player should not be bouncing off when walking into a wall, it just shouldn't be possible to pass through it.

Here are some code snippets.

Creating the Player-RigidBody (class Camera):

btCollisionShape* _collisionShape = new btCapsuleShapeZ(0.2f, 1.0f);
btDefaultMotionState* _motionState = new btDefaultMotionState(btTransform(
    btQuaternion(1, 0, 0, 1),
    btVector3(_position.x, _position.y, _position.z)
    ));
btRigidBody::btRigidBodyConstructionInfo cameraRigidBodyCI(
    10,
    _motionState,
    _collisionShape,
    btVector3(0, 0, 0)
    );
_rigidBody = new btRigidBody(cameraRigidBodyCI);
_rigidBody->setActivationState(DISABLE_DEACTIVATION);

Creating the RigidBody of the Walls and other box-objects:

btVector3 rigidBodyPos;
btCollisionShape* collisionShape;
glm::vec3* minMax = getMinMaxVertexCoords();
glm::vec3 minCoords = minMax[0];
glm::vec3 maxCoords = minMax[1];
glm::vec3 middleSize = glm::vec3((maxCoords.x - minCoords.x) / 2, (maxCoords.y - minCoords.y) / 2, (maxCoords.z - minCoords.z) / 2);
glm::vec3 middlePos = glm::vec3((maxCoords.x + minCoords.x) / 2, (maxCoords.y + minCoords.y) / 2, (maxCoords.z + minCoords.z) / 2);

collisionShape = new btBoxShape(btVector3(middleSize.x, middleSize.y, middleSize.z));
rigidBodyPos = btVector3(middlePos.x, middlePos.y, middlePos.z);

btMotionState* motionState = new btDefaultMotionState(btTransform(
    btQuaternion(0, 0, 0, 1),
    rigidBodyPos
    ));
btRigidBody::btRigidBodyConstructionInfo* rigidBodyCI = new btRigidBody::btRigidBodyConstructionInfo(
    0,
    motionState,
    collisionShape,
    btVector3(0, 0, 0)
    );
if (_rigidBody != nullptr){
    delete _rigidBody;
    _rigidBody = nullptr;
}
_rigidBody = new btRigidBody(*rigidBodyCI);
_rigidBody->setActivationState(DISABLE_DEACTIVATION);
_rigidBody->setRestitution(0.0f);

The Collision-Detection itself:

dynamicsWorld->updateAabbs();
dynamicsWorld->stepSimulation(1 / 60.f, 10);
//...
btTransform cameraTrans = camera->getRigidBody()->getWorldTransform();
camera->setPosition(glm::vec3(cameraTrans.getOrigin().getX(), cameraTrans.getOrigin().getY(), cameraTrans.getOrigin().getZ()));

How can I change this behaviour?


texts: Returning a List of coords for a sphere in order of inside to outside

texts:
I'm looking for any algorithm that can return a list of Vector3 coordinates that form a sphere. If you read the list from the beginning it would appear the sphere was expanding.

The only algorithms I've found are for circles, the algorithm doesn't have to make a sphere of a particular radius, just a number of coordinates would be fine.

If anyone could point me in the right direction for such an algorithm that would be great. Any language or even just sudo code for a basic algorithm would be appreciated.


texts: What is a good budget ratio for computation time?

texts:
What sort of budgets do they put on computation time?

For example, lets say a football game needs to run at 50 frames per second.  That means that each frame can only be 20 milliseconds long.  How is that 20 milliseconds divvied up?  For example, it could be:

Pathfinding - 3ms limit
Ball Physics - 8ms limit
Particle Effects - 2ms limit
Animations - 7ms - limit
Total - 20ms

However, I just made those numbers up without any idea what I was doing.

Is there a rule of thumb or a standard practice used?  I know every game is different depending on art-style, game genre, etc.  I am looking for as generic as an answer that can be had; however, if specifics are needed, then Madden Football 2017 can be used as the example game.

What percentage of milliseconds should be allowed for each aspect of game development?


texts: Textures on grass not showing on android

texts:
I'm using assets from InfinityBladeGrassLands, and used SM_Plains_Grass01 for some foliage on my landscape.
In editor, the foliage looks like this:

But when building for andoroid, this is what shows up:

What's the problem here?
Edit: I manually added an instance of the grass to the viewport, and that one is showing fine in android, but still the rest added using Foliage tool are not.


texts:
Is there any way to increase the width of the line that makes up the shaperenderers circle?

shape.begin(ShapeRenderer.ShapeType.Line);
shape.setProjectionMatrix(batch.getProjectionMatrix());
shape.setColor(1, 0.53f, 0.53f, 1);

shape.circle(nest.getCenter().x, nest.getCenter().y, radius, 500);

If not, is there any other approach that can give a similar effect?


texts: XNA: Auto-populate content within the content project based on current folder/file structure and content management for large games

texts:
1) Is it possible to implement a system where I can simply drop a new image into my content project's folder and VS will automatically see that and bring it into the project for compiling?

2) Similarly, if I wanted a specific texture I could state something like var texture = Game.Assets.Image["backgrounds/sky_02"]; (where Game is the standard XNA Game class and Assets is some kind of content manager statically defined within Game). I know this is fairly simple to implement manually and have done such things in the past (static Dictionary defined within Game) except this only works for relatively small games where you can have all assets loaded at the start without much issue. How would you go about making this work for games where content is loaded and unloaded based on level / area?

I'm not asking for the solution, just how you would go about this and what things you would have to be aware of. Thanks.


texts:
Since many users are facing the NullReferenceException: Object reference not set to an instance of an object error in Unity, I thought that it would be a good idea to gather from multiple source some explanation and ways to fix this error.

Symptoms
I am getting the error below appearing in my console, what does it mean and how do I fix it?

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


texts: Why Some objects or prefabs don't respond to mesh collider?

texts: I imported some assets and, I used some prefabs from that assets. Some of them responds when I add the component of mesh collider to it and disable the ability of going through with it. But some of the is not is not. I can still go through them. Is it a good practice to add 3d cube and disable that or, is there any other way to disable of going through it?


texts: Where can I find the Roblox Material/Terrain textures?

texts: The textures shown in this image: Where can I find them? I am making a Roblox game, it's a terrain based mining game, and I want to add an inventory. Where can I find the textures for the terrain to use as icons? I am not allowed to use screenshots. I am looking for the terrain textures that get rendered, not the icons in the terrain editor. Where in Roblox studio are they located?


texts: Unity Moving and rotating part of a model

texts:
I have downloaded a high quality head model which includes the shoulder, and I have want to move and rotate the head model, but its shoulder fixed, as if it is looking at the certain points that I have as list. I am not sure what is the best way to implement this -- should I split the model into two parts with blender, and just move the head model? Or should write a script that only moves the part of the model. If I write a script, how do I locate specific vertices in the model(in my case, the tip of the nose would be best) to follow the coordinates in the list, and how do I specify other vertices in meshes that needs to be follow the change so that the movement would look natural?

Thank you!


texts:
How to implement Unit Test at Unity3D.

I wonder if it would be possible to extend the Unity editor to have some sort of testing framework in it.

Is there any guideline to implement it?
Any reference like book, blog?
Any working example or project?


texts: How is Signed Distance Field Ray Marching implemented for a dynamic world?

texts:
I think I understand the basics of Signed Distance Field Ray Marching. You model your scene with a bunch of distance fields (such as these: http://iquilezles.org/www/articles/distfunctions/distfunctions.htm), then for each pixel you cast a ray, start from the start of the ray, find the distance to the nearest object at that point, and increment the point by the nearest distance, until you hit something. I managed to do a simple renderer, and that is where most descriptions of the technique stop.

This leaves me with some questions on how SDF Ray Marching can be used in a real world scenario:

Question 1:
In a real game, the scene is usually complex and loaded on the CPU, with many dynamic objects. I understand basic occlusion culling (such as octrees), and with polygonal rendering, I would create a list (on the CPU) of items in the view frustrum to render.

So, imagine I have a very complex scene with many characters and dynamic objects moving on the screen, controlled by the CPU. How would I stream the objects I want to render to the GPU each frame? Every example has the scene hardcoded in GLSL. Can someone share an example of the level being streamed to the shader dynamically?

Question 2:
How can objects have multiple colours? The distance functions only return a distance, but how do implementations commonly pass the colour back? (e.g. you hit a red sphere and not a blue cube.) If this were a CPU implementation, I could call a global function inside of the distance function when it's a hit to terminate the ray marcher, and that could also pass the hit object's texture/colour. But, how would you return the item's colour or texture in GLSL?

Thank you.


texts:
I new to game development with Unity and my first project is a slot car racer. For a realistic slot car-like-driving experience, I first build a track with a channel in the track and a pin on the car. This kind of works, but it does not look like a slot car, its more like a car with a pin and sometimes the physics just go crazy and kick me out of the channel.

I next tried making a spline with a simple game object following the track. I attached my car to my "follower" with a fixed joint. This didn't work so well: My car was tumbling and pulled sideway but I never archived that my car gets pulled down the track.

How should I be approaching this? I'd like the car to accelerate and decelerate quickly, with that acceleration and deceleration controllable by the user.


texts:
Before this question is criticized for lack of research effort, please read the whole description, as I know there are other similar questions out there.

I am making a 3D game, and would like to put text on the screen (FPS counter, different stats for me while I am designing that won't go into the final product). I have followed this tutorial on how to use TrueTypeFont fonts.

This is in my main game loop:

TrueTypeFont font = Text.prepareFont("WasterMaster10");
Color.white.bind();    //this is Line 163 in MainGameLoop.java
font.drawString(100, 50, Integer.toString(fps), Color.red);

And this is my preparation method in my Text class:

public static TrueTypeFont prepareFont(String fontname) {

    TrueTypeFont font = null;

    // load font from a .ttf file
    try {
        InputStream inputStream = ResourceLoader.getResourceAsStream("res/" + fontname + ".ttf");

        Font awtFont = Font.createFont(Font.TRUETYPE_FONT, inputStream);
        awtFont = awtFont.deriveFont(24f); // set font size
        font = new TrueTypeFont(awtFont, false);

    } catch (Exception e) {
        e.printStackTrace();
    }

    return font;

}

However, I keep getting this error:

Exception in thread "main" java.lang.IllegalStateException: Function is not supported
    at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:58)
    at org.lwjgl.opengl.GL11.glColor4f(GL11.java:893)
    at org.newdawn.slick.opengl.renderer.ImmediateModeOGLRenderer.glColor4f(ImmediateModeOGLRenderer.java:124)
    at org.newdawn.slick.Color.bind(Color.java:182)
    at engineTester.MainGameLoop.main(MainGameLoop.java:163)

I have been referring to this question and this question, as well as a lot of research on the web, but I still can't find why it won't work. The game works fine when the Color.white.bind() and font.drawString(...) lines are commented out. There are no syntax errors and the project compiles successfully. When I comment out just the Color.white.bind() line, then the program compiles but throws an error at the font.drawString(...) line during execution.

Does anyone know a better way to print text to the screen? Or is there a problem in my implementation?


texts: How to keep track of previous scenes and return to them in libgdx

texts:
I have three scenes: SceneTitle, SceneMenu, SceneLoad.

(The difference between the title scene and the menu scene is that the title scene is what you see when you first turn on the game, and the menu scene is what you can access during the game. During the game, meaning, after you've hit "play!" in the title scene.)

I provide the ability to save progress and consequently load a particular game. An issue that I've run into is being able to easily keep track of the previous scene. For example, if you enter the load scene and then decide to change your mind, the game needs to go back to where you were before; this isn't something that can be hardcoded.

Now, an easy solution off the top of my head is to simply maintain a scene stack, which basically keeps track of history for me. A simple transaction would be as follows

I'm currently in the menu scene, so the top of the stack is SceneMenu
I go to the load scene, so the game pushes SceneLoad onto the stack.
When I return from the load scene, the game pops SceneLoad off the stack and initializes the scene that's currently at the top, which is SceneMenu

I'm coding in Java, so I can't simply pass around Classes as if they were objects, so I've decided implemented as enum for eac scene and put that on the stack and then have my scene managing class go through a list of if conditions to return the appropriate instance of the class.

How can I implement my scene stack without having to do too much work maintaining it?


texts: Why do some .obj files have no newlines?

texts:
I'm working on a game engine and just started with mesh loading. I started with the format .obj. I ran into this problem:

The guide I'm following gave me a couple of .obj files to try and they all worked fine. I then asked a friend who is working with 3D animation to give me a couple of .obj files to try in addition, but his files, when opened up in a txt format, contain no newlines to separate the information at all. (Everything was on one line). The loading function I use depends on this to extract the information.

Are the files he gave me bad in some way? Is my function bad because it depends on newlines being there? (I can't see .obj files having any other delimiter character...)

My friend made and exported the 3D models in Blender. This is the guide I'm following.


texts: Show the GUI button when mouse hover to the object

texts:
i already have this player on my screen. And i want, whenever the mouse hover at the object, the GUI button show itself (like tooltip). I tried below code, but the button is not showed up when i hover at the object. Here is my code:
void OnMouseEnter()

    {

        Rect buttonRect = new Rect(250, Screen.height - buttonHeight, textInfoPlayerButtonWidth, textInfoPlayerButtonHeight);

        if (GameManager.instance.currentPlayerIndex == 0) (the object)

        {

            if (GUI.Button(buttonRect, "This is player 1"))

            {

            }

        }

    }

I want to be like this:

But i want it to be show that GUI hovering button on that character, not when the character selected.
Thank you


texts: Performance of Tristrip vs Indexed Triangles in OpenGL

texts: Let's say that I want to take advantage of GPU transform cache and use tristrips for that purpose. In the first case we have three triangles: 012, 213, 234. In the second case we used tristrip topology and passed indices to GPU: 0 1 2 3 4. In both cases all vertices will be cached on GPU. The only difference is the size of index buffer. In the first case (triangle topology) the size is 9. In the second case the size is 5. Even if we get 2x-3x size reduction, the index buffer is usually not the bottleneck. So, the question is why we get performance boost when using triangle strip vs indexed triangles in OpenGL?


texts:
I'm making an isometric game in Unity. So far I have managed to render a diamond shaped board, with tiles that are aligned on the x and y axis (and the camera looks down the Z axis).

I am spawning game objects for each tile with their own polygon collider and sprite renderer. I hope this is the correct way. They appear in front of each other naturally as you would expect them to in an isometric view.

I want to make a raycast from the player and forward on the z axis, to hit the sprite right under him. As you can imagine, I run in to problems when I do that, I imagine it's because they are all on the same 0.0f on the Z axis.

So my question is, does the raycast care about when a sprite is rendered in front of another, when it calculates what to hit, or is it just the physics engine handling this? And if so, how can I get around this? I guess I can translate the player coordinates to the board, but I just want to know how this works anyway.


texts:
what I'm trying to do is make the paddle follow the mouse position(red dot).
I know how to rotate the paddle relatively to the center of the screen, but I'm not sure how to determinate the coordinates.

thanks.


texts:
I have a ready-to-launch application, cleaning everything right now. I have these strange spikes on Mesh Memory.

The best part of it is that this view below is from a static menu screen, where there are no meshes. I don't even interact with it.

Can this be caused by meshes import options or something like that?


texts: Intersection of ray and non-axis-aligned box

texts:
I need to compute the intersection of a ray with a non-axis aligned box. Currently, I transform the ray into the local space of the box, do classic ray-AABB intersection and transform the intersection back to world space. This requires 4 matrix multiplications (2 for the ray, 2 for the entry and exit points of the intersection).

I was wondering what could be a better approach to this problem. Most resource I could find focus on the AABB case.


texts:
I'm currently developing a game where players will be able to battle each other, not in real time, but offline, in a way where both players doesn't have to be online. This might seem like a bad idea, but it makes sense in the context of the game.

Right now I'm trying to create some kind of ranking system, where the outcome of the match only affects the player who initiated the match, since I don't want players loosing rank when they're not playing.

A simple idea would be to award the player 2 points for winning and take away 1 for loosing.

I honestly have no idea if this design would work, so I come here to get some suggestions on how to design system like this. Thank you.


texts: Unity NavMesh pathfinding using Job System

texts:
I'm trying to write a system where I can run each enemy's NavMesh pathfinding in parallel, using Job System.

The problem I'm having is that I can't pass the NavMesh agent argument as it's a reference type.

  InvalidOperationException: PathfindJob.agent is not a value type. Job structs may not contain any reference types.

I'm probably approaching this problem in a completely wrong way, but this is all I've come up with.

Here's the current Enemy code

using System.ComponentModel;
using Managers;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Jobs;

namespace Characters
{
    [RequireComponent(typeof(Rigidbody))]
    public class Enemy : MonoBehaviour
    {
        [Header("Stats"), SerializeField] private int _health = 100;
        [SerializeField] private int _damage = 20;
        [SerializeField] private float _aggroRadius = 10f;

        private Rigidbody _body;
        private NavMeshAgent _agent;
        private Transform _target;

        private void Awake()
        {
            _body = GetComponent<Rigidbody>();
            _agent = GetComponent<NavMeshAgent>();
            _target = PlayerManager.GetInstance().GetPlayer();
        }

        private void OnDrawGizmosSelected()
        {
            Gizmos.color = Color.blue;
            Gizmos.DrawWireSphere(transform.position, _aggroRadius);
        }
    }

    public struct PathfindJob : IJobParallelForTransform
    {
        public Vector3 TargetPosition;
        public NavMeshAgent Agent;
        public float AggroRadius;

        public void Execute(int index, TransformAccess transform)
        {
            var distance = Vector3.Distance(TargetPosition, transform.position);

            if (distance < AggroRadius)
                Agent.SetDestination(TargetPosition);
        }
    }
}

I'm scheduling the job from the GameManager class.


texts: XNA 3D Unable to Position Bounding Sphere

texts:
I have a collision method that seems like it would work, and it does, but the bounding sphere is always at 0, 0, 0. How do I fix this? Any more code and or details are available upon request.
BoundingSphere CreateBoundingSphereForModel(Model model, Matrix worldMatrix)
{
    Matrix[] boneTransforms = new Matrix[this.model.Bones.Count];
    this.model.CopyAbsoluteBoneTransformsTo(boneTransforms);

    BoundingSphere boundingSphere = new BoundingSphere();
    BoundingSphere meshSphere;

    for (int i = 0; i < model.Meshes.Count; i++)
    {
        meshSphere = model.Meshes[i].BoundingSphere.Transform(boneTransforms[i]);
        boundingSphere = BoundingSphere.CreateMerged(boundingSphere, meshSphere);
}
return boundingSphere.Transform(worldMatrix);
}

bool IsCollision2(Model model1, Matrix world1, Model model2, Matrix world2)
{
    BoundingSphere bs1 = CreateBoundingSphereForModel(model1, world1);
    BoundingSphere bs2 = CreateBoundingSphereForModel(model2, world2);

if (bs1.Intersects(bs2))
    return true;

return false;
}

private bool checkPlayerCollision(Model model1, Matrix world1)
{
    //Make player location matrix
    Vector3 playloc = new Vector3(X, Y, Z);
    //Make ship1 matrix
    Matrix ship1WorldMatrix = Matrix.CreateTranslation(ship1loc) * Matrix.CreateScale(0.1f);
//Make ship2 matrix
Matrix ship2WorldMatrix = Matrix.CreateTranslation(ship2loc) * Matrix.CreateScale(0.1f);
//Check for collision with ship1
if (IsCollision2(model1, world1, model, ship1WorldMatrix)) return true;
//Check for collision with ship2
if (IsCollision2(model1, world1, model, ship2WorldMatrix)) return true;
return false;
}


texts: What weight should each frame have in motion blur?

texts: I am working on a game and would like to add motion blur to videos that I export from the engine. Right now, I play back gameplay at 1/16th the original speed, giving me 16x more frames (e.g. instead of 60 frames per second, it's 960 frames per second) and averaging the frames. I am curious though, is this the proper weight or should I give frame samples closer to the middle more alpha? Also, should the frames sampled be sampled uniformly?


texts: 3D Game Engine comparable to UDK that's not GPL'd

texts: Are there any good, free 3D game engines similar to UDK that are under open-source licenses without copyleft provisions?


texts:
I'm trying to implement a collision on ImpactJS entities that both will be stopped when collided and being pushed.

This will be exactly similar to player to player collision on top down games such as Battle City where you can't push the other player and vice versa.

All collision type combination does not seem to work on this case. It still pushes the other and FIXED vs FIXED is being ignored.


texts: Can't get simple OpenGL texture working using SDL2 and FreeImage3

texts:
I created a simple OpenGL program that display a quad with texture, but it doesn't seem to be working as it only displays a white quad. What could possibly be wrong? I checked everything I could think of that could cause the issue. The bitmap is also 256x256. Any clues?

Here's the source code: http://pastebin.com/5nVbMPVp

I'm also on Linux if that helps. Thanks!


texts: Zooming in on procedural generated 2D terrain? (LOD)

texts:
My question is what methods are there to "zoom in" on a procedurally generated map using Perlin Noise (or Simplex).

If I have for example this generated

and I wanted to "zoom" into that little red square I drew, how could I achieve something to the likes of this (ugly drawn) example:

While staying true to the terrain above? I have heard of 3D methods but couldn't find any meant for 2D maps.

Any advice or help would be appreciated.


texts: I was following AnimFollow tutorial to learn how to rag without using any script from it. I found issue with gravity. When I hit play button and animator is enabled character stay on air and play idle animation. If I disabled animator character fall down and all human parts moving. If I enabled again animator character get back to air position with idle animation playing. My issue is when character stay on air for 2 seconds, he fall down stronger than one second !! And if he stay for long time on air, the fall becomes more stronger !! Rigidbody settings for all parties [Mass = 1 , Drug = 0 , Angular Drag = 1] How to solve this ? why gravity is increase ?


texts: What basic windows form games should I build as a newbie in game development?

texts: I am a complete newbie in game development. I want to know about some basic games that I can start building with simple algorithms and basic knowledge. I have already made few basic games like minesweeper, TicTacToe, basic card games, and a snake game. I just want to have an idea to start a new fun project.


texts:
I am trying to fit a grid of gameobject into the orthographic view but I have a problem whenever I change the amount of grids to display it would overlap the view.

What cαn I do to fit a series of gameobjects, having always the same margin as the amount of grid changes?

private void Start() {
    for(int i = 0; i < wordSearch.Gridsize; i++) {
        for(int j = 0; j < wordSearch.Gridsize; j++) {
            cell = Instantiate(gridCell, new Vector3(j * 1 * gridCell.transform.position.x * cellSpacing, i * 1 * gridCell.transform.position.y * cellSpacing, 0), Quaternion.identity);
            cell.name = "cell-Y: " + i.ToString() + " cell-X: " + j.ToString();
            GameObject textObject = cell.transform.GetChild(0).gameObject;
            textObject.GetComponent<TextMeshPro>().text = wordSearch.matrix[i, j].ToString();
            textObject.name = textObject.GetComponent<TextMeshPro>().text;
        }
    }
    CenterPoint();
   // FitToScreen();
}

private void CenterPoint() {
    Vector3 offset = new Vector3(0, -1, -10);
    cellGameobject = GameObject.FindGameObjectsWithTag("cell");
    transformCell = new Transform[cellGameobject.Length];
    for(int i = 0; i < cellGameobject.Length; i++) {
        transformCell[i] = cellGameobject[i].transform;
    }
    for(int a = 0; a < transformCell.Length; a++) {
        cellVectors += transformCell[a].position;
    }
    centercell = cellVectors / transformCell.Length;
    GetComponent<Camera>().transform.position = centercell + offset;
}

private void FitToScreen() {
    Camera.main.orthographicSize = /* Insert Comment */
}


texts: Texture2D.GetData fails to return pixel colour data

texts:
Because I'm using sprite sheets instead of an individual texture per sprite, I need to pass in a Rectangle when calling Texture2D.GetData() in my collision detection for per-pixel tests. Unfortunately, without fail I get an ArgumentException percolated down from an internal method inside the Texture (not Texture2D) class.

My code for getting the texture data looks like this:

    public override Color[] GetPixelData()
    {
        Color[] data = new Color[(int)size.Product()];
        Rectangle rect = new Rectangle(hframe * (int)size.X, vframe * (int)size.Y, (int)size.X, (int)size.Y);

#if DEBUG
        if (sprite.Bounds.Contains(rect) && sprite.Format == SurfaceFormat.Color)
#endif
            sprite.GetData(0, rect, data, 0, 1);

        return data;
    }

Even with the check to ensure I'm grabbing a valid rectangle and that the texture format matches what I'm trying to get, I still get that exception, claiming "The size of the data passed in is too large or too small for this resource." Unfortunately, the debugger won't let me check the locals within the Texture.ValidateTotalSize() method where the exception originates.

Has anyone else had this problem and knows how to fix it? I'm relying on AABB testing only for now, but that doesn't really work for some of my game's entities due to odd shapes, rotation and scaling.


texts:
As many others I want to code a game with a voxel based terrain. The data is represented by voxels which are rendered using triangles. I head of two different approaches and want to combine them.

First, I could once divide the space in chunks of a fixed size like many games do. What I could do now is to generate a polygon shape for each chunk and store that in a vertex buffer object (vbo). Each time a voxel changes, the polygon and vbo of its chunk is recreated. Additionally it is easy to dynamically load and reload parts of the terrain.

Another approach would be to use octrees and divide the space in eight cubes which are divided again and again. So I could efficiently render the terrain because I don't have to go deeper in a solid cube and can draw that as a single one (with a repeated texture).

What I like to use for my game is an octree datastructure. But I can't imagine how to use vbos with that. How is that done, or is this impossible?


texts:
In my array there are 6 elements "guns" and I want to activate one element after deactivate all of them. Here is my script

public saveInfo _file; // get gun ID number from save file.
public GameObject Player1_pistol;
public GameObject[] pl1_p; // 6 guns

void Start()
{
    pl1_p = new GameObject[Player1_pistol.transform.childCount];
    for (int p = 0; p < Player1_pistol.transform.childCount; p++)
    {
        pl1_p[p] = Player1_pistol.transform.GetChild(p).gameObject;
        pl1_p[p].SetActive(false);
      // Now I need to activate the third element in my array.
    }
}


texts: Can i use art from another videogame as base for my art?

texts: For example: if I take the 3d models and textures from GTA: San Andreas and I modify them making better models and textures, can i use this new art to make a game with a different gameplay and sell it without infringing the game's copyright?


texts: Unity - Quaternion - Rotate / Unrotate Error

texts:
I'm trying to un-rotate a quaternion, aligning it with the axis, and then rotate it back to where it was originally.
But with every iteration it seems to lose precision and just after 20 iterations the rotation disappears.
Here is an example, which is a simplification of my code:

Quaternion rotation = Quaternion.Euler (0f, 90f, 0f);
Debug.Log ("Before: " + rotation.ToString ("F7") + " / Euler: " +
  rotation.eulerAngles.ToString());

int iterations = 1;
for (int i = 0; i < iterations; i++) {
    var currentRotation = rotation;
    rotation = Quaternion.Inverse (currentRotation) * rotation;
    rotation = currentRotation * rotation;
}

Debug.Log ("After:  " + rotation.ToString ("F7") + " / Euler: " +
  rotation.eulerAngles.ToString());

With 1 iteration the output is:

Before: (0.0000000, 0.7071068, 0.0000000, 0.7071068) / Euler: (0.0, 90.0, 0.0)
After:  (0.0000000, 0.7071067, 0.0000000, 0.7071067) / Euler: (0.0, 90.0, 0.0)

With 5 iterations:

Before: (0.0000000, 0.7071068, 0.0000000, 0.7071068) / Euler: (0.0, 90.0, 0.0)
After:  (0.0000000, 0.7071019, 0.0000000, 0.7071019) / Euler: (0.0, 90.0, 0.0)

With 10 iterations:

Before: (0.0000000, 0.7071068, 0.0000000, 0.7071068) / Euler: (0.0, 90.0, 0.0)
After:  (0.0000000, 0.7059279, 0.0000000, 0.7059279) / Euler: (0.0, 90.0, 0.0)

With 15 iterations:

Before: (0.0000000, 0.7071068, 0.0000000, 0.7071068) / Euler: (0.0, 90.0, 0.0)
After:  (0.0000000, 0.4714038, 0.0000000, 0.4714038) / Euler: (0.0, 90.0, 0.0)

And finally with 19 iterations

Before: (0.0000000, 0.7071068, 0.0000000, 0.7071068) / Euler: (0.0, 90.0, 0.0)
After:  (0.0000000, 0.0000000, 0.0000000, 0.0000000) / Euler: (0.0, 0.0, 0.0)

At the 19th iteration the euler angles becomes zero, and at previous iterations altough the euler angles are still correct, if I rotate a vector with the quaternion its magnitude is changed.

I hope you can help me and sorry for my bad english!


texts: lwjgl request display close when undecorated

texts: I want to create a custom titlebar/border for my display/window so I set the corresponding system property to "true" but how do I send a close request to the window manually to react to the Display.isCloseRequested()?


texts: In SDL, what is the difference between using a Surfaces and a Renderer?

texts:
I am new to SDL and I've been following some tutorials; in one tutorial he used Surfaces (a window surface and image surface) and a BlitSurface function to draw images without using any renderer (used SDL Image library for JPG, PNG etc.).
And in another tutorial, he used a Renderer.
What's the difference between those two? It seemed to me they do the same thing but I'm assuming if they were the same, one wouldn't exist.


texts: Action-oriented AI: evasion-algorithm takes much time

texts:
Evasion, the process of evading, is the opposite of chasing. Instead of trying to decrease the distance to the target we try to maximize it.

It takes much time while evading multiple objects simultaneously. I use BFS here. To make it faster what algorithms should I use?


texts: What are the basic systems used to implement a combat system like in Devil May Cry 5?

texts:
My basic observations from playing DMC5 and other Character-Action games a lot are the following...

There are a lot of different Animations that blend into each other.
These Animations are triggered by input sequences of varying complexity.
Input to Animation time feels very responsive.

My question is what systems does one use to organize all these animations with their input sequences and make it responsive.


texts:
In the PolygonShape object, there is the method setAsBox() which allows for creating rectangles easily, but there is no getAsBox() for cases where you know the polygon is a box. I know Box2D comes with it's own renderer, but I need to make custom renders.

Also, PolygonShape objects have a getVertex() method, but it has no return, and it takes a second argument of a vector2, for some reason. I don't know how I'm supposed to get a vertex from that. Why isn't there just a method that returns an array of Vector2 objects?

How can I easily render Box2D polygons with ShapeRenderer in LibGDX?


texts: Should I get an official content rating, like from the ESRB, or just rate my game myself?

texts:
I'm developing a game out of my garage basically with the intention of selling it on my own website and hopefully on Steam, and I've been wondering if I should try to get it rated by an official ratings agency, like the ESRB, or just display my own content rating? As I see it, rating the contents of your game has three purposes.

Let the player know the type of any potentially objectionable content they are about to experience.
Access certain marketplaces that require a content rating.
Fulfill legal requirements in certain countries that do not allow minors to be exposed to certain content.

Purpose #1 is the most important, and you certainly don't need any official ratings body to do that. Purpose #2 doesn't seem to be necessary for Steam. As for #3, I'm in the United States but I don't know how exactly any such laws would apply.

I looked into getting an official ESRB rating for a digital-download-only game, and it seems to be a hassle. It used to be that you could send them a letter in the mail with your company information, then they would create an account for you to log in to their website where you could fill out a questionnaire to have your game rated for free. They discontinued that in 2018 I think. Now they say you still can get a free rating through the IARC through participating storefronts, like the Windows Store, but it seems all of them require you to pay for a developers account before you can access the rating form.

So if I just make my own content rating, I don't want to create a new system that nobody is familiar with. Would I still be able to use "M for Mature" without the ESRB's blessing? Do they have a copyright on that phrase? I was thinking of using a similar color scheme (black with white text) to make it look similar to an official ESRB rating and using the content descriptors they use, but without mentioning the ESRB. Does that seem like a good idea?


texts: How do I select my platform and move them in a specific place in gameplay?

texts:
I saw this game called TaniNani and I was amazed by the concept of the game and I would like to try to replicate it!

My goal is to let the player hover on the available grid (somehow like hovering on an inventory) and when the player finds its desire the player will select the platform and when it is selected it could move in a specific location inside the box only! How do I code this using C# in Unity2D?

The example I want to achieve!

MEANING OF THE COLORS

Red -- The platform

Light Blue -- Where the platform can be moved either from left/up/right

Purple -- The platform can be switched by another platform


texts: How to generate a log file from a Unity WebGL build?

texts:
I want to create a log file for every time my WebGL game is played and have the errors and warnings with detail in there. I know how to make the log file I just don't know how to get the errors and warnings and their details, and I want to have the line number too.

The only way I know of getting an error is by Try Catch but that is not working in Unity or at least in WebGL build. The manual states that the log is output to the browser's JavaScript console, but I don't have access to all of my play testers and sometimes I can't reproduce the bugs they report.


texts: What is this type of sound effect called?

texts:
There is a sound typically associated with a bright flash of light, which starts with a lower whirring noise, then breaks into a higher pitched sound. What is that type of sound called? I'm not sure how to begin searching for that, so a typical name for it would be very helpful.

It's something similar to what occurs at 0:41 in this youtube video (here's a link to a few seconds beforehand), where Naruto 6 tails transforms into Kyuubei in Naruto Generations.


texts: Correct way to integrate scaled axis angular velocity into a quaternion

texts:
Across my travels on the internet I have came across two different ways of integrating a scaled axis angular velocity into a quaternion.

The first way converts the angular velocity into an axis angle quaternion like so

Quaternion q = new Quaternion(vector.normalised(), vector.getLength());

Where the constructor looks like:

float sinHalfAngle = (float) Math.sin(angle / 2);
float cosHalfAngle = (float) Math.cos(angle / 2);

this.x = axis.x * sinHalfAngle;
this.y = axis.y * sinHalfAngle;
this.z = axis.z * sinHalfAngle;
this.w = cosHalfAngle;

And then multiplies the existing quaternion by that new quaternion

this.rotateSelf(q);

The second approach also converts the velocity into a quaternion, but uses a different method:

Quaternion change = Quaternion.mul(
    new Quaternion(x * 0.5f, y * 0.5f, z * 0.5f, 0),
    this
);

It then adds the quaternions together, scaled by delta T:

this.w += change.w * scale;
this.x += change.x * scale;
this.y += change.y * scale;
this.z += change.z * scale;

Both approaches produce a rotation, however the first approach rotates the object much faster than the second. I was wondering which is the 'more' correct way, or if they are just different methods used for different units perhaps? (ie: degrees vs radians?)

Thanks very much if you can help.


texts: How to move one Game unit with every key press?

texts:
I have a tile board set up with 500 x 500 pixels = 1 unit. I have code that will move the object over time.
    void Update()
{
    Vector2 pos = transform.position;

    if (Input.GetKey("w"))
    {
        pos.y += speed * Time.deltaTime;
    }
    if (Input.GetKey("s"))
    {
        pos.y -= speed * Time.deltaTime;
    }
    if (Input.GetKey("d"))
    {
        pos.x += speed * Time.deltaTime;
    }
    if (Input.GetKey("a"))
    {
        pos.x -= speed * Time.deltaTime;
    }
    transform.position = pos;
}

I want to move 1 unit after each button press and only by integer values. Speed is a public variable that sets how fast the object moves.
Thanks for the help.


texts:
I'm looking to implement screen shake in a 2D top down game.
From an earlier Q on this exchange, I learned that noise values could be a good candidate, so I intent to try that.

But I wonder: is a screen shake more about rotating the 2D topdown camera, or about jittering the position of that camera?

Or does it really require both?

Additionally, I would like to know if a good screenshake would require motion blur? Something like rendering your world in 4 small micro-steps for each 60fps frame, maybe? Or can you shake the camera at 60fps with normal rendering and it still looks good?

The quality I am after is something like shown in this video. It's kinda hard to judge, but it seems that video does translational jitter only?


texts: Error using Physics Body Editor for LibGDX

texts:
In my game, I've been trying to use the physics body editor for libgdx, but I kept on getting an error. So I thought there was probably something wrong with my code so I took the example off of the website (http://www.aurelienribon.com/blog/projects/physics-body-editor/), and tried running that. But I got the same exact error on the same line of code.

The line of code from the website's example that's creating the error is

BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal("data/test.json"));

and the error is

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoSuchMethodError: com.badlogic.gdx.utils.JsonReader.parse(Ljava/lang/String;)Ljava/lang/Object;
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:118)
Caused by: java.lang.NoSuchMethodError: com.badlogic.gdx.utils.JsonReader.parse(Ljava/lang/String;)Ljava/lang/Object;
    at aurelienribon.bodyeditor.BodyEditorLoader.readJson(BodyEditorLoader.java:179)
    at aurelienribon.bodyeditor.BodyEditorLoader.(BodyEditorLoader.java:41)
    at com.Jon.App.App.createBottle(App.java:129)
    at com.Jon.App.App.create(App.java:76)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:132)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:112)

Any ideas on how to fix this?


texts: Can I publish a game on Steam while obscuring my personal identity from the public?

texts:
I'm looking to publish a game on Steam that contains explicit adult content.

I am seeking to make this a hobby that earns passive income as opposed to pursuing it as a full time job. I would prefer that a prospective employer could not easily track my name back to this game and thus not consider me for the job.

I have read the Steamworks Partner Program here:
https://partner.steamgames.com/steamdirect

And thus understand that for Steam's sake, I will need to identify myself. But can I publish under some sort of pseudonym to prevent a simple Google Search of my name from returning this game? Or will this pretty much be on my so-called "permanent record" for life?


texts: How can i reproduce the bird to catapult animation in angry birds?

texts: I've seen tutorials on producing an angry birds like game but non of them explain how to get the next bird on the catapult after the current bird is shot. Also how would i go about doing this if the catapult could change position and i want to get the next bird on the catapult taking into account that the birds are not all in the same position.


texts: Lazy way to figure out the two sides of a border?

texts:
We have a 3d model. There is a simple path on that model's surface graph G of the form:
<v_0, v_1 ... v_n-1, v_n> where if v_i == v_j then i == j

Great! now the simple question appears:
How do you programmatically tell in the human sense if v_orange and v_green are on the same side of the trail and if v_green and v_blue are on the same side or not?
My intuition is that you Dijkstra the shortest path between them and if it goes through the trail an even number of times their on the same side. However that is not defined if you don't know what goes through the trail computes to. If thinking if it was 2d and we could project these trail edges on some flat surface this would be made trivial.
My current solution is a lie. Each edge is normally shared by two faces unless it's an orbifold which is currently not interesting to this question's input population set. Also, in our world, each face has percisely three vertices.

Use Dijkstra to find the shortest path between them. If the path does not touch the trail, their relation to the trail isn't well defined or their on the same side (for now it outputs they are on the same side).
Assuming the path does go through the path, we pick one of the edges it went through.
Each edge belongs to two faces, each of these faces has precisely one vertex that is not on the edge trail. we now have two vertices that are supposed to be on different sides of the trail.
Dijkstra from each of the trail side vertices to the vertices in question.
If the shorter path to both vertices in question is from the same side then maybe they are on the same side. If it each vertex prefers a different side then maybe they are not.

Here is one fault in this solution:

Sometimes the two are on the same side and the other route is shorter.

Clarification
This is a clarification inspired by wondra that felt nothing can be on the right side or the left side of a trail, something that in my opinion people would disagree with as we have a good sense of left & right.
Lets "split" the model where the trail is and add more faces between the two new trails (lips) and get something like this:
Trail 1 is Blue, trail 2 Red and some epsilon wide faces between them. Now we use Dijkstra to find the shortest distance from both trails (Blue and Red). Some vertices are closer to the Red, some to Blue. Very few are (the same), closest simply to the last or first vertex in the original trail that are conjoined between the trails.


texts:
I have made great strides in creating a custom built server browser for UDK. It registers servers with a master, and the client can download the list and populate the server browser.

However I'd like to tell users the ping of a server in the server browser. I know PlayerReplicationInfo has a server check native function, but that only works when the player is actually connected to a server.

I want to ping check a server without joining it, and then collect the data to show to the player?

Is this easy to implement? Hard to implement? Maybe it's a waste of time because of the time required to ping all the possible servers? If it's easy to implement how can I do it? Do I need to make a custom TCPLink class that counts the time it takes for a message to go back and forth?


texts: How can the lategame in a 4X game be made more exciting?

texts:
I played a lot of different 4X games lately (eXplore, eXpand, eXploit, eXterminate, like the Civilization series, for example), and noticed that most of them suffer from the same problem: As soon as one player got significantly more powerful than the others, that player gets almost unbeatable. The dominant player has access to vastly more resources than the others. Also, that player has a significant advantage in research, which means that the other factions will soon fall back in technology, giving the powerful player even more tools which the weaker factions can not counter, so it makes the game even easier for them.

During this phase it is pretty clear that this player will inevitably win. However, the game usually does not stop here. It continues for hours while the dominant player steamrolls all the weaker players one after another. This poses no challenge to them, because they are so vastly more powerful. So this phase of the game becomes a dull and boring chore for everyone. The dominant player moves their units from one enemy base/city/planet to another knowing that nothing they could encounter there could stop them as long as they avoid some easily avoidable mistakes, while the other players watch helplessly in frustration without any way to prevent their demise.

How could a 4X game be designed to avoid this boring and tedious endgame?


texts: Panning a 3d viewport in 2d direction with rotated camera

texts:
I am using below code to pan the viewport (action script 3 code using flare3d framework)

_mainCamera.x-= Input3D.mouseXSpeed;
_mainCamera.z+= Input3D.mouseYSpeed;

Where as Input3D.mouse[X|Y]Speed gives the displacement of the mouse on the X/Y axis starting from the position of the last frame.

This works perfect if my camera is not rotated. However, if I rotate the camera (x by 30, y by 60) and pan the camera then it goes wrong. Which is actually correctly panning according to the code. But this is not desired and I know I need to do some math to get the correct x/y which I am not aware of it.

Can some one help me achieving it?

Update:

I am getting an Idea but I am not sure how to do it :(

Get the mouseX/Y deltas (xd,yd)
Get the current camera coords (pos3d)
Convert to screen coords (pos2d)
Add deltas to screen coords (pos2d+ (xd,yd))
Convert above coords to 3d coords