texts:
can someone tell me where i make a mistake? i want to use AssetLoader to load textures but.... always have the same error. I thought that problem is with my game so I made new project but I still have error.

  Couldn't load dependencies of asset: assets/badlogic.jpg

Here is my code:

public class TestApp extends ApplicationAdapter {
   SpriteBatch batch;
   Texture img;

   @Override
   public void create () {
      Assets.load();
      batch = new SpriteBatch();
      img = Assets.manager.get(Assets.image, Texture.class);
   }

   @Override
   public void render () {
      Gdx.gl.glClearColor(1, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
      batch.begin();
      batch.draw(img, 0, 0);
      batch.end();
   }

   @Override
   public void dispose () {
      batch.dispose();
      img.dispose();
   }
}

public class Assets {

    public static final AssetManager manager = new AssetManager();

    public static final String image = "assets/badlogic.jpg";

    public static void load(){
        manager.load(image, Texture.class);
        manager.finishLoading();
    }

    public static void dispose(){
        manager.dispose();
    }
}


texts: Why is my Direct3D 9 floating point texture clamping values 0–1?

texts:
I'm using Direct3D 9 to draw some primitives into a texture. The format used at texture creation is D3DFMT_A16B16G16R16F, and the primitives are drawn using additive blending. The additive blending works as expected provided the result is <= 1. If it is greater than 1 then it seems to be clamped to 1.

This question includes a comment stating that COLOR0 output semantics for a pixel shader automatically clamp the output values. I can't ask for elaboration there due to low SE rep. Is there anything else that I need to do on top of changing the texture format that I pass in to CreateTexture, in order to use the full range of 16-bit floats? Given that I can otherwise draw primitives with shading (aside from the clamping issue) fine, is there any other setup that needs to be done?

To illustrate my issue, I'm doing two passes of the following shader (ping-ponging between two textures in the aforementioned format):

texture tex;

sampler2D sam = sampler_state {
    texture = <tex>;
    minfilter = none;
    magfilter = none;
    mipfilter = none;
};

float4 main(float2 uv : TEXCOORD) : COLOR0 {
    float4 cin = tex2D(sam, uv);
    float4 cout = cin;

    cout.g = 10;
    if (cin.g > 1)
        cout.b = 1;

    return cout;
}

The output (starting from black) is a green screen. If I change:

cin.g > 1

To:

cin.g >= 1

Then I get a cyan screen.

I'm working from a modified version of SDL2's Direct3D 9 driver if that helps.


texts: Most efficient way to capture OpenGL ES content of iPhone screen

texts:
I'd like to efficiently capture a "screenshot" of my OpenGL ES iPhone game.  I put screenshot in quotes because I really want to move the screen contents into a pixel buffer that I can eventually use to create a mov file using AVFoundation.

Currently I'm taking the screenshot with this method from Apple.  The resulting image is great... however capturing the image causes a small stutter in my game.  Looks like the call to glReadPixels causes the stutter.

How can I capture the screen's contents more efficiently?  Perhaps I can improve the efficiency of the call to glReadPixels?  Or perhaps I can populate a CMSampleBuffer or CVPixelBuffer without calling glReadPixels?

Perhaps the OpenGL ES data could be accessed directly somehow w/o having to copy the data into a buffer via glReadPixels.

Edit #1:  Perhaps a "Frame Buffer Object" could be useful?  Or "rendering directly to a texture"?


texts: Scrolling background stops after awhile?

texts:
Can anyone tell me where my maths is wrong please, it stops scrolling after awhile.

if (background.position.y < background2.position.y)
{
    background.position = ccp(background.contentSize.width / 2, background.position.y - 50 * delta);
    background2.position = ccp(background.contentSize.width / 2, background.position.y + background.contentSize.height);
}
else
{
    background.position = ccp(background2.contentSize.width / 2, background2.position.y - 50 * delta);
    background.position = ccp(background2.contentSize.width / 2, background2.position.y + background.contentSize.height);
}

//reset
if (background.position.y <-background.contentSize.height / 2)
{
    background.position = ccp(background.contentSize.width / 2 ,background2.position.y + background2.contentSize.height);
}
else if (background2.position.y < -background2.contentSize.height / 2)
{
    background2.position = ccp(background2.contentSize.width / 2, background.position.y + background.contentSize.height);
}


texts: unity: read from text file to instantiate objects

texts:
I'm trying to use the following code to read a text file stored in the Resources folder or in a file on my computer, and instantiate objects in a Unity 3D scene accordingly. I'm having trouble getting it to work. I've tried attaching the script to either the main camera or an empty gameobject. Neither work so far...

I either end up with an error saying the path does not exist (when I put the text file into the project folder on my desktop), or a null exception, or that the path contains invalid characters.

Where am I going wrong?

I'm trying to use a jagged array because I'll need users to eventually be able to change the text file on-the-go to create a level.

The text file contains the following data:
 S 0 0 0 1
 0 0 1 0 2
 2 0 0 2 1

My script currently reads:

using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
using System.Linq;
using System.IO;
using UnityEngine.UI;

public class GenerateLevel : MonoBehaviour {

    public Transform player;
    public Transform ground;
   // public Transform floor_valid;
    public Transform floor_obstacle;
    //public Transform floor_checkpoint;

    //public const string sfloor_valid = "0";
    public const string sfloor_obstacle = "0";
   // public const string sfloor_checkpoint = "2";
    public const string sstart = "S";

    public string textFile = "maze";
     string textContents;

    // Use this for initialization
    void Start () {
        Instantiate(ground);

        TextAsset textAssets = (TextAsset)Resources.Load(textFile);
        textContents = textAssets.text;

        //string[] lines = System.IO.File.ReadAllLines("//maze.txt");

        //string textFile;
        //textFile = Resources.Load("assets/resources/maze").ToString();

        string[][] jagged = ReadFile(textContents);

        for (int y = 0; y < jagged.Length; y++)
        {
            for (int x = 0; x < jagged[0].Length; x++)
            {
                switch (jagged[y][x])
                {
                    case sstart:
                        //Instantiate(floor_valid, new Vector3(x, 0, -y), Quaternion.identity);
                        Instantiate(player, new Vector3(0, 0.5f, 0), Quaternion.identity);
                        break;
                    //case sfloor_valid:
                      //  Instantiate(floor_valid, new Vector3(x, 0, -y), Quaternion.identity);
                        //break;
                    case sfloor_obstacle:
                        Instantiate(floor_obstacle, new Vector3(x, 0, -y), Quaternion.identity);
                        break;
                    //case sfloor_checkpoint:
                      //  Instantiate(floor_checkpoint, new Vector3(x, 0, -y), Quaternion.identity);
                        //break;
                }
            }
        }
    }

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

    }

    string[][] ReadFile(string file)
    {
        string text = System.IO.File.ReadAllText(file);
        string[] lines = Regex.Split(text, "\r\n");
        int rows = lines.Length;

        string[][] levelBase = new string[rows][];
        for (int i = 0; i < lines.Length; i++)
        {
            string[] stringsOfLine = Regex.Split(lines[i], " ");
            levelBase[i] = stringsOfLine;
        }
        return levelBase;
    }
}


texts: Puting all vertex attributes of a scene into a single VBO

texts:
I'm rendering various elements in OpenGL ES 2 on Android, and I'd like to pack the vertex attributes of the whole scene into a single vertex buffer object (VBO).

My question is, if these objects have different sets of attributes, strides and offsets, can I still pack this data into a single VBO and draw everything using it?

Most of these elements have 2 floats for position and 2 floats for texture coords (X, Y, S, T) as vertex attributes, and they do get drawn correctly using this:

@Override
public void onDrawFrame(GL10 glUnused) {
    glClear(GL_COLOR_BUFFER_BIT);
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.getBufferId());
    drawObject1();
    drawObject2();
    drawObject3();
    glBindBuffer(GL_ARRAY_BUFFER, 0);
}

public void drawObject1() {
    glUseProgram(object1Program);
    object1Program.setUniforms(finalMatrixObject1, object1Texture);

    glVertexAttribPointer(object1Program.getPositionAttributeLocation(), 2, GL_FLOAT, false, 16, 0);
    glEnableVertexAttribArray(object1Program.getPositionAttributeLocation());
    glVertexAttribPointer(object1Program.getTextureCoordinatesAttributeLocation(), 2, GL_FLOAT, false, 16, 8);
    glEnableVertexAttribArray(object1Program.getTextureCoordinatesAttributeLocation());

    glDrawArrays(GL_TRIANGLES, 0, 6);
}

public void drawObject2() {
    glUseProgram(object2Program);
    object2Program.setUniforms(finalMatrixObject2, object2Texture);

    glVertexAttribPointer(object2Program.getPositionAttributeLocation(), 2, GL_FLOAT, false, 16, 0);
    glEnableVertexAttribArray(object2Program.getPositionAttributeLocation());
    glVertexAttribPointer(object2Program.getTextureCoordinatesAttributeLocation(), 2, GL_FLOAT, false, 16, 8);
    glEnableVertexAttribArray(object2Program.getTextureCoordinatesAttributeLocation());

    glDrawArrays(GL_TRIANGLES, 6, 6);
}

But I have weird artifacts and coords showing (if at all) when I try to render an element with a different pattern of vertex attributes, for example just 2 floats for position (X Y), or 3 floats for position and 2 floats for texture coord (X Y Z S T).

public void drawObject3() {
    glUseProgram(object3Program);
    object3Program.setUniforms(finalMatrixObject3);

    glVertexAttribPointer(object3Program.getPositionAttributeLocation(), 2, GL_FLOAT, false, 8, 0);
    glEnableVertexAttribArray(object3Program.getPositionAttributeLocation());

    glDrawArrays(GL_TRIANGLES, 12, 6);
}

To resume the situation, I have a VBO packed this way (it differs a bit from my previous example):

6 * (X, Y, S, T)
6 * (X, Y, S, T)
6 * (X, Y, S, T)
6 * (X, Y)
36 * (X, Y, Z, S, T)

Is it possible to do what I'm trying to do? Or do I have to use different VBOs for every element with a unique set of vertex attributes?

If it's possible, what am I doing wrong? Before moving to VBO everything was working fine.


texts: Love2D game and editor in two separate programs

texts:
I'm building an engine in Love2D and I need to build an editor who will create scenes with game objects I wrote in lua.

The thing is that there's this guy in my team who said : "Don't include the editor within the game, make it separate from it so you won't load the whole editor with the game itself"

So I'm asking how could I achieve this type of structure, because I want my libraries to be shared between the game and the editor.

- MAIN FOLDER
    | - core
    |   | core features of the engine
    | - editor
    |   | main.lua
    | main.lua

I can't see how I'll be able to require files with this structure, is there a specific way to do this kind of thing in lua ?

What I'm trying to do now is this :

main.lua (game)

require "core/engine"

function love.load()  -- This works
    print("Loaded")
end

main.lua (editor)

require "../core/engine"

function love.load() -- Won't work
    print("Loaded")
end


texts: Unity C# - moving objects and Debug.Log; show multiple messages only once (easy but stuck)

texts:
I have the following scenario:

a sphere is moving towards an object it can see (a cube). The cube is moving randomly through the landscape. The sphere will keep following it. I have a script that will check IF the cube is Within Sight. If it is, it will move towards it and it will keep following it.

What I want

I want a Debug.Log message to show when:

When the sphere is moving towards a (new) target. it must say: "Searching..."
When the sphere has found the cube, I want it to say: "Found the cube."
When the cube is found, I want it to continue searching for new cubes. So it must say once more: "Searching..."

Problem:

It keeps showing these messages nonstop. I found a solution with a false bool in an IF statement. But, I don't know how to combine 2 messages.

Code:

using UnityEngine;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;

public class MoveTowards : Action {

public float speed = 0;
public SharedTransform target;
private bool pietje;

private bool jaap;

void PrintMessage (string message) {
    Debug.Log(message);
}

void Start() {
    pietje = false;
}

public override TaskStatus OnUpdate() {

    if (Vector3.SqrMagnitude (transform.position - target.Value.position) < 0.1f && !pietje) {
        PrintMessage ("Found the cube.");
        pietje = true;
        return TaskStatus.Success;
    }

        transform.position = Vector3.MoveTowards (transform.position, target.Value.position, speed * Time.deltaTime);
        transform.LookAt (target.Value.position);
        return TaskStatus.Running;

}

}

I just don't know how to fix the last part where it says: "Searching..." I don't know how to implement it with an IF statement (doesn't work somehow) or  how to create the IF statement (when I use this, it doesn't work:

if (TaskStatus.Running == 1 && !pietje)

Anyone that can help me? That would be awesome! Have been trying to fix this for some hours now....


texts: Can I use real cars in my racing game?(Yeah,I know)

texts: I know this was asked a million times.I know I can't use real car names or badges,but what about body design? I saw a lot of games with real body designs.My other question is about the engine names:VR6,TFSI,1/2JZ etc.can I use them? And if I can use body designs,does that apply to rims too? My last question is that is it legal to use words like WRC,WTCC,NASCAR,F1,LMP,GT3 etc.?


texts: In an artillery game how do I mask out the part of the terrain that was hit

texts:
Let's say I want to make a really simple artillery game, something like Gorillas. I don't have any experience in games, just some basic understanding of OpenGL. I want to do this for fun and to learn something.

I figured out how to simulate gravity and generate simple terrain and how to do some collision detection. But I have no idea how do they mask out the part of the terrain that is hit with a projectile that leaves a hole in form of a circle.

I tried enabling stencil buffer and put a quad which has a circle texture on it expecting to mask out only the circle part, but it masked out the whole quad -- I mean it was a rectangle shaped hole and not a circle shaped one. Next I thought maybe some blending will do the trick but I didn't figure it out how. Or should I just draw a polygon with many edges to look like a circle and use that instead (with the stencil buffer)? I'm just curious how it is done. Can someone point me in the right direction?


texts:
I find that my procedural simplex noise in my fragment shader hurts performance, so I thought I would just use a stored noise texture instead.

I would like my noise values to have better than 8 bits precision, preferably 16 bits.

What would be a good format to store this texture in?

According to Khronos, GL_LUMINANCE16 is deprecated.

Should I use GL_R16I for this? What worries me is that it is listed as not texture filterable. That makes the format not useful for this purpose, I think? The man-page does not explain what the term means, but I gather it means that you are force to do NEAREST filtering.

I am looking for something that would work on both OpenGLES3 mobile hardware and on OpenGL desktop hardware.


texts: HLSL float4 addition returning all 0.0f vector, unexpected result

texts:
Edit: Added images at the bottom to show the current issue.

I have the following few lines in my hlsl pixel shader where color and specular are both float4.

color = color * textureColor;

// Add specular component and clamp
color = saturate(color + specular);

Running VS2013 graphics debugger and debugging into the pixel shader I see specular coming through as (0.0f, 0.0f, 0.0f, 0.0f) which I expect for the pixel I'm checking since it's not within the specular portion of the viewDirection, but the float4 addition is making the final color as zero after the addition.

Am I completely missing something here? I would assume the following math:

   color (0.65f, 0.0f, 0.0f, 1.0f)
 + specular (0.0f, 0.0f, 0.0f, 0.0f)

   result = (0.65f, 0.0f, 0.0f, 1.0f)

Any thoughts would be greatly appreciated. I have a feeling, I'm missing something really simple here.

EDIT:

 // If I remove the specular and return color after multi by tex Sample,
 // I get the following expected result
 color = color * textureColor;

// As soon as I add the specular component back in
color = saturate(color + specular);


texts: Why are Mac versions of games larger in filesize than Windows versions?

texts: I have browsed many games mainly on itch.io and many developers offer a Mac version of their game along with the Windows version. The Mac version of all those games is significantly larger in file size than the Windows version. Why is that?


texts: How to access the raw memory of d3d model in game maker?

texts: I am using the d3d model creation functionality in Game Maker. I also use dlls and I want to be able to modify a 3D model (change uv values) without recreating a model. Is there a way to locate the address of the model’s memory and use pointers to directly change the values? Is this possible and how would I go about doing it?


texts:
I have a canvas with a panel with set width / height inside. The canvas rendermode is set to ScreenSpace Overlay.

My clicks on the panel are falling through and hitting the game objects below triggering their mouse events.

The little green circle is a Sprite with the following event

  public void OnMouseDown() {
        Debug.Log("click");
        Vector3 newPos = Camera.main.WorldToScreenPoint (this.transform.position);
        newPos.x -= panel.GetComponent<RectTransform>().rect.width / 2.0f;
        newPos.y -= panel.GetComponent<RectTransform>().rect.height / 2.0f;

        panel.transform.position = newPos;
  }

I've been reading through the docs but I'm missing something... How do I stop my clicks hitting the game objects below the panel?


texts: Tutorials for Managed DirectX development?

texts: Are there any good tutorials, for someone new to DirectX development? I'd like to use the SharpDX library in a project, but am completely new to this sort of graphics programming. I'm looking for a good resource for very beginner-level DirectX samples, either on the web or in print? I assume the code there will be C++, but I'm hoping they'll be straightforward enough for me to map to C#.


texts: How to normalize the direction to check if the player is able to move?

texts:
I have a room with 4 walls along the x and z axis respectively. My player, who is in first person (therefore the camera), should have collision detection with these walls. I'm relatively new to this so please bare with me. I believe the way to do this is to calculate the direction and distance to the wall from the camera and then normalize the directions. However, I can only get this far before I don't know what to do. I think you should work out the angle and direction your facing?

Here _dx and _dz is the small buffer in front of the camera.

float CalcDirection(float Cam_x, float Cam_z, float Wall_x, float Wall_z)
{
    //Calculate direction and distance to obstacle.
    float ob_dirx = Cam_x + _dx - Wall_x;
    float ob_dirz = Cam_z + _dz - Wall_z;
    float ob_dist = sqrt(ob_dirx*ob_dirx + ob_dirz*ob_dirz);

    //Normalise directions
    float ob_norm = sqrt(ob_dirx*ob_dirx + ob_dirz*ob_dirz);
    ob_dirx = (ob_dirx)/ob_norm;
    ob_dirz = (ob_dirz)/ob_norm;

Can anyone explain in layman's terms how I work out the angle?


texts: Finding SpriteRenderer of specific Child Gameobject

texts:
So i'm trying to work on my Equipment System to also change the appearance of the sprites on my Character once i change the equipped item. My animations are setup in limbs so all i would have to do (i think?) is change the actual sprite of the specific limb skin i want to change (e.g. The Shoes), since the animation should still work independent of what the sprite is. However the problem i'm having is that my equipment manager is on a seperate gameobject than the character is and i don't seem to be able to find the SpriteRenderer components (Null pointer reference). My current function looks like this:
Obviously the commented parts are irrelevant for my question, and i will eventually make the gameobject search more specific to which item piece i'm equipping. For clarification, the Equipment Manager is on my GameManager object and the sprites are on the Player Screenshot Object and its' children.

public void EquipItem(Equipment newItem)
{
    //int slotIndex = (int)newItem.equipSlot;
    //Equipment oldItem = null;

    SpriteRenderer targetSR;

    //if(currentEquipment[slotIndex] != null)
    //{
    //    oldItem = currentEquipment[slotIndex];
    //    inventory.AddItem(oldItem);
    //}

    //if (onEquipmentChanged != null)
    //{
    //    onEquipmentChanged.Invoke(newItem, oldItem);
    //}
    //currentEquipment[slotIndex] = newItem;

    targetSR = GameObject.Find("Mage5/Hip/Body/Hand_L").GetComponent<SpriteRenderer>();
    targetSR.sprite = newItem.icon;
}


texts:
I am currently working on a Java multiplayer game. The game itself (single player) already works perfectly fine and so does the chat. The only thing that is really missing is the multiplayer part. Sadly I am absolutely clueless on where to start with that. I roughly know that I will have to work with packages, and I also know many things about streaming etc (chat is already working). Oh and it should - according to this article - be a UDP server. My problem is that I can't find any resources on how to do this. A tutorial (book or website) would be perfect, alternatively a good example of an open source client/server (in Java of course) would be fine as well. If you feel like doing something helpful I'd also really appreciate someone "privately" teaching me via email or some chat program :)

Thank you!


texts:
I have an AR scene that has one AR camera, an image target and a 3D object as below.

I want to move the AR object to the position of the mouse click. I have tried taking the Input.mouseposition (screen position), converting it using ScreenToWorldPosition and moving the 3D object to this position. The object is moved, but not to the mouse click position.

How can I move the object to the position of the mouse click? My code is as follows:

Camera cam;
Vector3 target = new Vector3(0.0f, 10f,0.5f);
// Use this for initialization
void Start () {
if (cam == null)
    cam = Camera.main;
}
void Update()
{
    if (Input.GetMouseButtonDown(0)) {
        Debug.Log("MouseDown");

        Vector3 mousePos = Input.mousePosition;
        mousePos = cam.ScreenToWorldPoint(mousePos);
        GameObject.Find("Car1").gameObject.transform.position = mousePos;
    }
}

EDIT 1

To move 3d object with mouse, I tried this code. But it don't move the position of mouse click.
enter link description here

EDIT 2

If I add a plane to scene, I can move to the position of mouse click only on the plane. The code is taken from here. But the plane prevents to show AR camera view. The screenshot is below:

EDIT 3

I add box collider and rigidbody to 3d object. Screenshot is below :

I used below code :

if (Input.GetMouseButtonDown(0)) {
            Debug.Log("mouseDown = " + Input.mousePosition.x + " " + Input.mousePosition.y + " " + Input.mousePosition.z);

        RaycastHit hit;
        var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out hit))
        {
            if (hit.rigidbody != null)
                GameObject.Find("Car1").gameObject.transform.position = hit.point;
            else
                Debug.Log("Rigidbody is null");
        }

When mouse clicked, 3d object isn't moved the position of mouse click.


texts: Should I write my own physics engine, because of networking integration?

texts:
I'm currently developing a top down, realtime, zombie shooter. I'm coding this in Java, using JBox2D as my physics engine. I have been coding the networking this week, and am now up to the physics synchronization.

I'm planning to use the predictive client/authoritative server model, where the client is free to move, as long as the server approves of it later. This involves the client sending packets containing movement data to the server, and the server calculating latency, and re-simulating the world from an older state.

My problem is, my current physics engine, JBox2D (basically a port of Box2D), doesn't support rolling back the world, and apparently isn't that easy to serialise the world data. I have 2 solutions, I could either modify/extend my current physics engine, or write my own.

Reasons for writing my own physics engine -

I can remove unnecessary features. In a top down game, I only really need collision mechanics, and handling forces. No gravity is involved.
I can understand the code better, and it would [most likely] be easier to implement roll back functions

Reasons for extending/modifying JBox2D

Writing my own physics engine, would be a significant amount of work, which could be cumbersome
JBox2D has a widely supportive community, that can help me with my dev
JBox2D, has specific optimizations, for things like collision detection, which make it useful
Some work as already been done on this, but little code has been shared

So what are your opinions. This is my first game, and I am no way a professional game developer. If anyone could provide some links to work already done in the area (preferably using JBox2D/Box2D/Java).


texts: Box2D physics are different on server and client

texts:
I'm using C# Box2D library for my server and client, they have similar world.step(), iterations and update function. At the same time they have different physics' results, difference is not fixed, it may be 1-2% or more than 10%.
My timestep is 0.02f and 10 iterations(for both).
Code of the client and the server is almost the same.
I believe it's because of I have the same timestep on both, server and client, but their code execution speed may be quite different.
How can I get the same results in different applications/on different computers?


texts: How do I not let my explosion go through the walls like bomberman?

texts:
I have this problem that I want to fix. Every time I place a bomb it goes pass through the wall even if I added a Layermask to tell if it's a wall or not.

public LayerMask levelMask;
public GameObject explosion;

void Start()
{
    Invoke("Explode", 1f);
}

void Explode()
{
    Instantiate(explosion, transform.position, Quaternion.identity);

    StartCoroutine(CreateExplosions(Vector2.up));
    StartCoroutine(CreateExplosions(Vector2.down));
    StartCoroutine(CreateExplosions(Vector2.right));
    StartCoroutine(CreateExplosions(Vector2.left));

    GetComponent<SpriteRenderer>().enabled = false;
    Destroy(gameObject, .3f);
}

private IEnumerator CreateExplosions(Vector3 direction)
{

    for (int i = 1; i < 3; i++)
    {

    RaycastHit hit;

    Physics.Raycast(transform.position + new Vector3(0,.5f,0), direction, out
    hit, i, levelMask);

    if (!hit.collider)
    {
    Instantiate(explosionPrefab, transform.position + (i * direction),
    explosionPrefab.transform.rotation);
    }
    else
    {
    break;
    }
    yield return new WaitForSeconds(.05f);

    }
}


texts: In GLSL is it possible to offset vertices based on height map colour?

texts:
I am attempting to generate some terrain based upon a heightmap.
I have generated a 32 x 32 grid and a corresponding height map ->

In my vertex shader I am trying to offset the position of the  Y axis based upon the colour of the heightmap, white vertices being higher than black ones.

//Vertex Shader Code
#version 330

uniform mat4 modelMatrix;
uniform mat4 viewMatrix;
uniform mat4 projectionMatrix;
uniform sampler2D heightmap;

layout (location=0) in vec4 vertexPos;
layout (location=1) in vec4 vertexColour;
layout (location=3) in vec2 vertexTextureCoord;
layout (location=4) in float offset;

out vec4 fragCol;
out vec4 fragPos;
out vec2 fragTex;

void main()
{
    // Retreive the current pixel's colour
    vec4 hmColour = texture(heightmap,vertexTextureCoord);

    // Offset the y position by the value of current texel's colour value ?
    vec4 offset = vec4(vertexPos.x , vertexPos.y + hmColour.r, vertexPos.z , 1.0);

    // Final Position
    gl_Position = projectionMatrix * viewMatrix * modelMatrix * offset;

    // Data sent to Fragment Shader.
    fragCol = vertexColour;
    fragPos = vertexPos;
    fragTex = vertexTextureCoord;
}

However the code I have produced only creates a grid with none of the y vertices higher than any others.

This is the C++ code that generates the grid and texture co-orientates which I believe to be correct as the texture is mapped to the grid, hence the white blob in the middle.

The grid-lines are generated in the fragment shader, sorry for any confusion.

I have tried multiplying the r value of hmColour by 1000 unfortunately that had no effect.

The only other problem it could be is that the texture coordinate data is incorrect ?

for (int z = 0; z < MAP_Z  ; z++)
   {
    for(int x = 0; x < MAP_X  ; x++)
    {
    //Generate Vertex Buffer

    vertexData[iVertex++] = float (x) * MAP_X;
    vertexData[iVertex++] = 0;
    vertexData[iVertex++] =  -(float) (z) * MAP_Z;

    //Colour Buffer  NOT NEEDED
    colourData[iColour++] = 255.0f; // R
    colourData[iColour++] = 1.0f; // G
    colourData[iColour++] = 0.0f; // B

    //Texture Buffer

    textureData[iTexture++] = (float ) x * (1.0f / MAP_X);
    textureData[iTexture++] = (float ) z * (1.0f / MAP_Z);

     }
    }

The heightmap texture I am trying to use appears like so (without grid-lines).

This is the corresponding fragment shader

// Fragment Shader Code
#version 330

uniform sampler2D hmTexture;

layout (location=0) out vec4 fragColour;

in vec2 fragTex;

in vec4 pos;

void main(void) {

    vec2 line = fragTex * 32;
    // Without Gridlines
    fragColour = texture(hmTexture,fragTex);

    // With grid lines
    // + mix(vec4(0.0, 0.0, 1.0, 0.0), vec4(1.0, 1.0, 1.0, 1.0),
  //  smoothstep(0.05,fract(line.y), 0.99) * smoothstep(0.05,fract(line.x),0.99));

}


texts:
I am creating a multiplayer JavaScript game with a PHP central server. Each user will be able to move around in a 3D world, with other users and NPCs. It came to my attention that SQL is not going to handle all the requests being made in a reasonable time. So I cut down on SQL requests being made as often, using RAM when I can, but each user that logs into my world, or switches worlds requires a lot of data to be filtered from the server (So the client does not get any information it should not have, and so I don't have to distribute the entire world for every logon) and then uploaded to the client. So I had an idea: What if I can get the World data from the users near to the player(In the 3D world), like a BitTorrent? How to resolve syncing issues? What are my options to prevent Hacking? My ideas were: check with more than one user, get a hash from a server(will probably have syncing problems), have bots who request worlds from clients: then checks with server to see if they are being honest, how ever they all seem to have their problems, and am not sure which one(s) I should incorporate, or if there is a better way I could get correct world data from peers, with minimal server interaction.

Note: Peer to Peer is only used to get the world, block/world updates are still handled between the server and each client


texts: How can I create a pack file / archive for game data files, and then load them? (zlib?)

texts:
I'm starting to think about how I'm going to go about loading models, images, sounds, etc for my game. I have two competing lines of thought to deal with:

If possible, it would be nice to make use of existing libraries to load things like PNGs, etc.
I would like to pack all of my game data into a single archive, and it would be great to use an existing library here also.

Is it possible to do this? I've heard that I could use something like zlib for (2), but I've never used it before so I'm not sure how it would work. Is it possible to yank a file out of a zlib archive in memory, and then pass it to some compatible library for the actual loading? How would these two systems interface with each other? Would using zlib slow down the loading process?

I've not had much experience with I/O in my career, so I'm not really sure where to start.


texts:
I'm coding a very simple game Rust/Dayz like with Unity, and I'm using Forge Networking as network library.

A few days ago, I started to code the Loot system. The Loots in my game are Items that are instantiated in the game world (in other words, the items that are on the ground) and I was implementing the system that send and receive Loot data from and to the server (the server is fully authoritative).
I also created a LootSpawnManager class that contains, in a list, all the Loot spawned in a certain Loot spawn spot (so there is a LootSpawnManager for every spawn point of the Loots object).

In my game the server checks if a player is in a certain range from the Loot gameObject. If it is, then the server sends the Loot data through the network to the client, and the client with that data creates a Loot object and instantiates it in its world (scene).

For optimization (because checking if there are players in an area is a bit expensive), the LootSpawnManager has a list, with all the players nearby, that is refreshed every 4/5 seconds. So, for example (in the server) if a Loot is added to a LootSpawnManager (or a Loot already in the LootSpawnManager list has changed its properties) the server sends the data to the players that are in the LootSpawnManager's players list.

So far no problems. The issues come when a Loot doesn't belong to a LootSpawnManager. In the game there will probably be hundreds if not thousands of Loots that don't belong to a LootSpawnManager, so every single Loot would have to do its check every 4/5 seconds, and this will certainly kill server performance.

A solution to this problem could be to group near solitary Loots in a class similar to LootSpawnManager that has the player list for that zone.  But I don't think that this will help, because there will be few cases in which a lot of Loots are near, although in the majority of cases there will be maximum 2-3 Loots.
So the question is: are there any good performance solutions for this problem?

EDIT :
I didn't mentioned that the client doesn't have instantiated all the Loots that are in the server, and the players have instantiated only the Loots in a certain range from them. If they are too far from a Loot they delete it (I'm talking about the single client side, so deleting means deinstantiating the object, not removing it in the server) and, like I explained before, if they are nearby a certain range from a Loot, then the client has to wait for the server checks.

P.S.  I hope my English is understandable (it's not my mother language) and that what I just wrote above is clear.


texts: How to use Pivot Point in Transformations

texts:
How to translate object using Center point

I have a rectangle which has a center point away from the position of rectangle.

when i rotate rectangle it rotates around its center axis.

if i multyply position before rotation in the modelView matrix

ModelViewMatrix = Rotation * Scaling * Position

Suppose if i want to do these translations.

1) Translate the rectangle position by x = 10 units.

1) Rotate the rectangle by 35 degree with the center point at the center of the rectangle.

2) Translate the rectangle position by x = 10 units.

3) change the x position of the center point by 10 units( rectangle should not be affected by the change in the center point position)

enter image description here

4) Now rotate the rectangle using the new center point.

If someone could please guide me how do we use Center point in transformations. How do i build by ModelView Matrix if i am using a center Point.


texts: How do I use D3DXVec3Unproject with D3D11?

texts:
I'm having a small issue with D3DXVec3Unproject. I'm currently using Direct3D 11 and not 10, and the signature for this function is:

D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3D10_VIEWPORT *pViewport,
      CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld

As you may have noticed, it requires a D3D10_VIEWPORT, and I'm using a Direct3D 11 viewport, D3D11_VIEWPORT.

Do you have any ideas how I can use D3DXVec3Unproject with Direct3D 11?


texts: maps in a multiplayer diablo clone - unity3d

texts:
I'm messing around with unity3d free, trying to figure out if i can get away with using its readymade graphic engine. I have some problems figuring out how maps should be implemented/handled

(the graphics are 3d, like diablo, but essentialy game is only X/Y movement)

Case 1.
Model a "3d" map within Unity scenes, then model a 2d version of it for serverside calculations (line of sight, positioning, movement and spawning of objects). How to keep them in sync the easiest? Are there any tools for this purpose?

Case 2.
Feed a tile based map to Unity client, making it render it from small pieces (tiles). Essentialy use the 2d server version to render the pretty 3d client version. Is that possible at all within unity?

I would love to be able to generate terrain randomly, so solving case two would be most beneficial...

Probably both my cases are a good deal off the "correct" approach, so please give me some hints on the industry standards ;-)


texts: Procedural Progressive wave system advice

texts:
I am developing a game based on waves. Enemies appear as time passes by and every level the hero must kill all the enemies to move to the next level.

At this time I have 2 types of waves. Progressive waves (enemies are spawned every x secs), All at once waves (enemies are spawned all at once at a moment in time). On the other hand my enemies (5 types) have base features that I want to improve as player moves into more challenging levels

My question is simple: How do you ussually handle this type of wave generation system? For every level I would like to generate a set of wave events (first 5 enemies all at once, then 10 progressively, etc...), after this I must select how many enemies to spawn for every wave and their features (velocity, behaviour, weapon power, etc...).

One solution I have thought about is creating some meanful templates for the wave creation. For example, I colud create 10 spawning process. A process is like:

Spawn 5 enemies
Wait 10 secs or all enemies died from previous wave
Create 10 enemies and spawn all at once. THis would be a spawn process.

Then I could select a random template for each level and scale number of enemies, etc... depending on the level difficulty.

How do you ussually handle this kidn of system?

Cheers.


texts: Delaying the game to restarts with Coroutine

texts:
I want to create some sort of delay for the game to restarts when the ball is stops moving but the game keeps restarting whenever the velocity reaches zero. I want use a timer where the game will restarts when the ball is stopping for too long but I don't know how. Here's the code. The Restart() will be called from another script when the game starts and the ball will starts moving. Any help would be appreciated.

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class BallCondition : MonoBehaviour {

    // Use this for initialization
    public bool isLose = false;
    public Rigidbody2D rb;

    void Awake () {

        rb = GetComponent<Rigidbody2D>();
    }
    public IEnumerator Restart()
     {
        Debug.Log(rb.velocity);
        if((rb.velocity.x)==0 && (rb.velocity.y) == 0)
        {
            //print(Time.time);
            Debug.Log("stopped");
            if((rb.velocity.x)==0 && (rb.velocity.y) == 0 && !isLose)
            {
                yield return new WaitForSeconds(3);
                Debug.Log("lose");
                isLose = true;
                SceneManager.LoadScene(0);
            }
        }
     }
}

This is the script where I call the Restart()

using UnityEngine;
using System.Collections;

public class Force : MonoBehaviour {

    public float moveSpeed = 5;
    public static bool isAlreadyClicked = false;

    void Start()
    {
       Reset();
    }

    void Update()
    {
        if(Input.GetMouseButton(1))
        {

            if(!isAlreadyClicked)
            {
                GetComponent<Rigidbody2D>().AddForce(new Vector2(moveSpeed,0));
                Debug.Log("clicked");
                isAlreadyClicked = true;
                BallCondition player = GetComponent<BallCondition>();
                StartCoroutine(player.Restart());
            }
        }

    }
    public void Reset()
    {
        isAlreadyClicked = false;
    }
}


texts: Getting one rigidbody to follow another, but still react to stuff Unity3D/C#

texts:
Basically what I'm doing is having a ball you can pick up and drop on a ramp. When you pick up the first ball, the second ball follows close behind, and when you drop the first ball on to the ramp the second ball drops on to the ramp as well, rolling down and launching off. The second ball continues to follow the first through the air.

How could I go about getting the second ball to follow the first, while still keeping the rolling-gravity effect?

Thanks.


texts: I enabled and setup glBlendFunc, but my texture has a white outline. What am I doing wrong?

texts:
You can see most of my source code in this question: Instead of the specified Texture, black circles on a green background are getting rendered. Why?

Now I have the problem, that my texture has a white outline on its transparent parts. After googling and setting up glBlendFunc, the outline just got "softer".

This is how it looks like:

This is how I now setup OpenGL:

    public static void SetupGL()
    {
        GL.Enable(EnableCap.Blend);
        GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

        GL.Enable(EnableCap.Texture2D);
        GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);

    }


texts: Why when rotating object 360 degrees on the x, it rotates once then stops?

texts:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

public class MeshGenerator : MonoBehaviour
{
    public GameObject meshPrefab;
    public Vector3[] newVertices;
    public Vector2[] newUV;
    public int[] newTriangles;

    private List<Vector3> verticesList = new List<Vector3>();
    private List<Vector2> uvsList = new List<Vector2>();
    private List<int> trianglesList = new List<int>();
    private GameObject go;

    private void Start()
    {
        Mesh meshprefab = meshPrefab.GetComponent<MeshFilter>().sharedMesh;
        newVertices = meshprefab.vertices;
        newTriangles = meshprefab.triangles;

        for (int i = 0; i < newVertices.Length - 2; i++)
        {
            DrawLine(newVertices[i], newVertices[i + 1], Color.red);
            DrawLine(newVertices[i + 1], newVertices[i + 2], Color.red);
            DrawLine(newVertices[i + 2], newVertices[i], Color.red);
        }
    }

    void DrawLine(Vector3 start, Vector3 end, Color color, float duration = 0.2f)
    {
        go = GameObject.Find("Lines");
        GameObject myLine = new GameObject();
        myLine.transform.parent = go.transform;
        myLine.transform.position = start;
        myLine.AddComponent<LineRenderer>();
        LineRenderer lr = myLine.GetComponent<LineRenderer>();
        lr.material = new Material(Shader.Find("Particles/Alpha Blended Premultiply"));
        lr.startColor = color;
        lr.endColor = color;
        lr.startWidth = 0.05f;
        lr.endWidth = 0.05f;
        lr.useWorldSpace = false;
        lr.SetPosition(0, start);
        lr.SetPosition(1, end);
    }

    private void Update()
    {
        var p = go.transform.eulerAngles;
        p.x += 1;
        go.transform.eulerAngles = p;
    }
}

This is the rotation part:

private void Update()
    {
        var p = go.transform.eulerAngles;
        p.x += 1;
        go.transform.eulerAngles = p;
    }

It's rotating 360 degrees once, then it stops rotating but keeps shaking like it's trying to keep rotating but something keeps it from continue.


texts:
I am having a little issue with my game trying to get the screen to draw a ton larger. I am going for a retro type of feel for my game and I believe that this would help with that.

I am basically trying to take a small area (example 100x177) and draw it 9 times the original size while still keeping the nearest neighbor. The image below shows what I am trying to achieve.

(image taken from: http://forums.tigsource.com/index.php?topic=27928.0).

I have been trying to set the current render area to an FrameBuffer then draw the Frame Buffer larger on the window. I have not been able to find any example code or how I would go about doing that.

Thank you in advance for the help.

EDIT: Added sample code

This code is in the same method where I initialize OpenGL

    fboID = GL30.glGenFramebuffers();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fboID);
    colID = GL11.glGenTextures();
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, colID);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, scaleWidth, scaleHeight, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
    depID = GL30.glGenRenderbuffers();
    GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depID);
    GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, scaleWidth, scaleHeight);
    GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, depID);
    //GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, colID, 0);
    drawBuffs = BufferUtils.createIntBuffer(1);
    drawBuffs.put(0, GL30.GL_COLOR_ATTACHMENT0);
    GL20.glDrawBuffers(drawBuffs);
    if(GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) != GL30.GL_FRAMEBUFFER_COMPLETE){
        System.out.println("Framebuffer not complete!");
    } else {
        System.out.println("Framebuffer is complete!");
    }

And this is my render method that the game loop runs (updates at 60fps)

    // clear screen
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    // Start FBO Rendering Code
    //GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fboID);
    // Resets the current viewport
    GL11.glViewport(0, 0, scaleWidth, scaleHeight);                 // Set viewport to be the size of the FBO
    // Clear the FrameBuffer
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    // Actual render code!
    gameMap.render();

    // draw the texture from the FBO
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
    GL11.glViewport(0, 0, scaleWidth*scale, scaleHeight*scale);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f((float)scaleWidth*scale, 0.0f, 0.0f);
    GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f((float)scaleWidth*scale, (float)scaleHeight*scale, 0.0f);
    GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(0.0f, (float)scaleHeight*scale, 0.0f);
    GL11.glEnd();

    // Resets the current viewport
    GL11.glViewport(0, 0, scaleWidth*scale, scaleHeight*scale);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    // let subsystem paint
    if (callback != null) {
        callback.frameRendering();
    }

    // update window contents
    Display.update();

I had to comment out "GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER,GL30.GL_COLOR_ATTACHMENT0, colID, 0);" because it was throwing a "Function not supported" error.

Thanks


texts: How to generate fixed amount of health points in every interval when the data is in database?

texts:
Most of the common example of that in the game is stamina regeneration to control the activity of the players. For example, genshin impact, they have something called resin system, and it regenerates 1 resin in every 8 minutes until the amount maxed out.
What is the algorithm for that? In my case it's hp.
My situation:
The players' data is saved in the database.
I am creating a text-based rpg game using discord bot, and the programming language I am using is python.
Here is what I had thought:

when freeing the data from the memory, save the date and time of when the hp became less than max
amount to the database.
when the data is in the memory, while hp is not full add fixed amount of hp in
every interval.
when querying the data from database, update the hp, calculate from the saved date and time,
interval, and fixed amount of hp.

Thanks in advance.


texts:
I used Game Maker to construct a 3D terrain using Perlin Noise. Since I wanted to create an island, I set the noise function to return a value between 0 and 128. Then I checked each point and subtracted 128 from points at the edge of the map, and added 128 to the middle of the map, with linear interpolation in between. Then I change every value below 0 to 0 and called it water. It looks good for making an island with a single point in the middle, but they all look pretty much like this:

I was wondering if there was a way to get more variation in the terrain just by changing how I use the perlin noise function, or if it would just be simpler to extend my "forced mountain" strategy, maybe by randomly moving the position of the peak, or adding more peaks.

I would like to be able to create a large island with many areas of varied terrain. I want to pre-generate everything and break it up into chunks. The two issues I'm having so far is that the map looks boring, and it looks like making an island as large as I'd like would take up humongous amounts of disk space, but that's a different issue.


texts: Imported Blender .fbx model appears transparent

texts:
I exported a model that i made in blender to a .fbx file. I imported it to Unity and, as you can see in the image, one arm of my character appears transparent.

I already have the normals pointing in the right direction, so i can't see what's causing this. I even tried to create a new arm from the other one, but the problem persisted.

What is causing this?


texts: What is the point of update independent rendering in a game loop?

texts:
There are dozens of articles, books and discussions out there on game loops. However, I pretty often come across something like this:

while(running)
{
    processInput();
    while(isTimeForUpdate)
    {
        update();
    }
    render();
}

What basically is bothering me about this approach is the "update-independent" rendering e.g. render a frame when there is no change at all. So my question is why this approach is often taught?


texts: Is it possible to make a pseudo isometric game with phaser?

texts:
If I use the isometric plugin for Phaser, I end up with something like the third case of the following picture:

I would like to create a world in pseudo isometric, with only one axis tilted. This would be the second case in the picture.

Is it possible to achieve that with Phaser? With or without the Isometric plugin? If Phaser can't handle it, is there an open-source/free alternative for this kind of setup?


texts:
I have another problem i can't solve by myselve.

My situation:
I have four FrameLayouts in LinearLayouts.

I color them, set Layout hight and width at wrap content and just change the minwidth to use them as a status or progress bar.

To adjust the bars i have a method:

public void update_bars(){

    FrameLayout bar_eat = (FrameLayout)findViewById(R.id.bar_eat);
    FrameLayout bar_drink = (FrameLayout)findViewById(R.id.bar_drink);
    FrameLayout bar_wash = (FrameLayout)findViewById(R.id.bar_wash);
    FrameLayout bar_care = (FrameLayout)findViewById(R.id.bar_care);

    bar_eat.setMinimumWidth((int)(((float)screen_part/1000)*eat));
    bar_drink.setMinimumWidth((int)(((float)screen_part/1000)*drink));
    bar_wash.setMinimumWidth((int)(((float)screen_part/1000)*wash));
    bar_care.setMinimumWidth((int)(((float)screen_part/1000)*care));
}

This method works fine from everywhere in my activity.
But i also want to call this update_bars() method every second so i made a timer for it.

private void update(){

    Timer timer = new Timer();
    timer.schedule(new TimerTask(){

        @Override
        public void run() {
            update_bars()

        }

    },0,(1000* getResources().getInteger(R.integer.remove_speed_inSecond)));

But at this point it crashes....

The debugger says this:

  Thread [<12> Timer-0] (ViewRootImpl$CalledFromWrongThreadException)
      Timer$TimerImpl.run() Zeile: 290

So where it the problem? And what can i do?
I woud be very happy if someone have an idear because i'm going crazy^^


texts: using heightmap to simulate 3d in an isometric 2d game

texts:
I saw a video of an 2.5d engine that used heightmaps to do zbuffering.
Is this hard to do? I have more or less no idea of Opengl(lwjgl) and that stuff.

I could imagine, that you compare each pixel and its depthmap to the depthmap of the already drawn background to determine if it gets drawn or not.

Are there any tutorials on how to do this, is this a common problem? It would already be awesome if somebody knows the names of the Opengl commands so that i can go through some general tutorials on that. greets!

Great 2.5d engine with the needed effect, pls go to the last 30 seconds

Edit, just realised, that my question wasn't quite clear expressed: How can i tell Opengl to compare the existing depthbuffer with an grayscale texure, to determine if a pixel should get drawn or not?


texts:
I want to create a 2D tube in unity which I can cut, suture and drag it,  My idea is to use a small image in form of fragments but how i can do it like the picture bellow

EDIT :
What I did until now:

Firstly I tried to use Linerenderer but it didn't work for me because i couldn't cut it so tried to create a tube of cubes I used an empty object as parent whit childs of cubes as you can see on the picture bellow

with this way it was easy to apply the cut script so I just remove the fixed joint between the cubes where i click
and for the appearance of the tube I started by creating it as a direct line and I turned on the game then by dragging the tube i get the form bellow and i copy the position of each cube and set it on the instantiation of the childs

   GameObject intestines_top = GameObject.Find("intestine_top");

    setPositions();//on this method I instantiate an array of vector3 contains all the position i get
    fragments = new GameObject[fragmentNum];

    Vector3 position = Vector3.zero;

    for (int i = 0; i < fragmentNum; i++)
    {
        fragments[i] = Instantiate(fragmentPrefab, positionArray[i], Quaternion.Euler(new Vector3(0.413f, -259.96f, -536.531f)));
        fragments[i].transform.SetParent(transform);

        var joint = fragments[i].GetComponent<FixedJoint>();

        joint.connectedBody = parent.GetComponent<Rigidbody>();
        parent = fragments[i];

    }

the result of what i did :

NOTE :  other problem of my solution is sometimes all the gameobjects disperss due to collision I think
That's happen after a while of dragging the tube
I didn't find what exactly the problem but when I change the direction of the collider to the X-axis its solve the problem by 85% and for the drag script i use AddForce and velocity

rigid.AddForce((dest - rigid.position) * 200f); rigid.velocity *= 0.8f;


texts: For my first 3D engine, should I go for one that is already made, or minimalistic?

texts:
I've been meaning to transition from 2D games to 3D games for some time, now. I have the most experience with RTS games, so I will be doing that.

On one hand, there's a lightweight renderer; Irrlicht. However, considering it's a renderer and not a game engine (only basic collision, etc..) , I would have to write most of the things, myself.

On the other hand, there's a full blown engine like CryEngine 3, for example. Although it is mostly complete, I would first need to understand the various parts of the engine and it's implementation enough to be able to try and transform it into an RTS engine.

My question is, which would be easier for me to transition to?


texts: Geometry shader vertex position to point at camera

texts:
I have a shader that takes an array of points. At each point, a geometry shader creates a quad oriented towards the camera.
This works fine when the camera and point are at around the same Y value, however, looking up/down upon the billboard results in it shrinking to a point the closer the camera approaches being directly above/below.
Example (Youtube)
[maxvertexcount(4)]
void geom(point v2g IN[1], inout TriangleStream<g2f> triStream) {
    // Calculate some vectors
    float3 up = float3(0, 1, 0);
    float3 look = _WorldSpaceCameraPos - IN[0].position;
    look = normalize(look);
    float3 right = cross(up, look);

    // And how far off-centre our corners are
    float halfS = 0.5f * IN[0].colorScale[1] * _Scale;

    // Calculate verts
    float4 v[4];
    v[0] = UnityObjectToClipPos(IN[0].position + float4(+halfS * right - halfS * up, 1.0f));
    v[1] = UnityObjectToClipPos(IN[0].position + float4(+halfS * right + halfS * up, 1.0f));
    v[2] = UnityObjectToClipPos(IN[0].position + float4(-halfS * right - halfS * up, 1.0f));
    v[3] = UnityObjectToClipPos(IN[0].position + float4(-halfS * right + halfS * up, 1.0f));

    // pass through color texture lookup
    float2 color = float2(IN[0].colorScale[0], .5);

    // Start pushing verts
    g2f o;
    o.position = v[0];
    o.color = color;
    o.uv = float2(1.0f, 0.0f);
    triStream.Append(o);

    ...

I'm guessing my issue is related to the fact that my up and look are approaching coincidence, as the forward derives directly from the camera and the up is in world space, however, I'm uncertain of my diagnosis and unclear on how to generate an appropriately rotated up?


texts: Voxel terrain generation performance problems

texts:
I am trying to create a minecraft clone to practice some stuff in Unity including Raycasting, terrain generation and player controlls.
Terrain is generating without any problem with a perlinNoise.
My problem is the then following performance problems.
The terrain is only 1 block high with no underlying blocks. Each block constist out of 6 quads with a 64x64 texture. I generate terrain at 200 x 200 size.
I can't imagine why 4000 voxels with such simple textures can lag out whilst my pc runs objects with 50k tris and complex textures without any problem.
My code:
[...]

public int xVoxels = 200;
public int zVoxels = 200;

[...]

for (int x = 0; x < xVoxels; x++){
    for (int z = 0; z < zVoxels; z++){

        // voxel = script parameter
        GameObject newVoxel = GameObject.Instantiate(voxel);
        Vector3 position = new Vector3();

        position.x = xVoxels/2 + x;
        position.z = zVoxels/2 + z;
        // PerlinNoise stripped out for testing
        position.y = 0f;

        newVoxel.transform.position = position;
    }
}

Solutions I tried:
Combining meshes
Combining all meshes to a single one per material worked wonderfully... until I wanted to interact with each voxel determined by Raycasting from the Camera, I had a raycast hit to the combined mesh and not to my determined voxel
Generating the planes myself
Instead of using the unity plane object I generated all vertecies myself, same performance problems


texts: How to calculate a perfect Super Mario speedrun?

texts:
I've dedicated my time to Super Mario lately, so eventually I ended up watching some speedruns.

I thought to myself, how could one calculate the perfect set of minimal in-game movement?

I considered comparing the time needed to pass to a certain point, for example if there are two paths to take. If I wanted to write a program to measure and calculate those values for me, how would I proceed?


texts: How can I remove Magic Pink from an image at runtime using GraphicsDevice?

texts:
In XNA 4.0, I want to load all my textures at runtime, which means I will not be able to take advantage of the content processor. (This is fine because it would allow people to change graphics and other elements without having to have XNA installed to compile them into .xnb)

Suppose that I can't (or don't want to) use premultiplied alpha on my images, and instead rely on the classic magic pink (255, 0, 255) method:

How can I turn it into a Texture2D object and convert the pink to be transparent using GraphicsDevice? It is trivial to iterate the data with GetData() and SetData(), but this uses the processor, rather than the graphics card.


texts:
Is Integer Linear Programming a viable solution for a turn based game AI?

My current AI solution uses an ILP solver. If you are unfamiliar with ILP, it uses a collection of Booleans to find most optimal solution to a linear problem.

I'm concerned about fluctuations in performance and I"m also thinking of portability. I am using C++ to prototype. I have access to an ILP solver that works well with it. I don't know if I"ll find one that I can use on portable devices. I'm unsure if can rely on the computation time being reasonable with an N large enough to get the results I"m planning for.

I am wondering if anyone used this technique (ILP based AI) and would advice against it or in favor of it. Also are there any other (portable and effective) optimization tools that could be used for a similar result? I read about NegaScout but I did not find a book or tutorial that could provide me with a deep understanding of it.

I also read this question which did not help: Implement Negascout Algorithm with stack


texts: How to check if a point is on the plane given bottom-right point, top-left point, normal and the quaternion rotation of the plane

texts:
I know the world positions of A and B.
We are also given the vector normal and the quaternion rotation of the plane
How do I check if a point lies on the plane?


texts: Mobile game - different actions based on different tap input?

texts:
I am creating a mobile game in which you can destroy blocks and interact with blocks like in Minecraft.

However, the problem is, in Minecraft you destroy blocks using left mouse button click and interact using right mouse button click, but on mobile I don't have 2 buttons, only 1 - the screen tap.

Of course, I could create a button to toggle between 2 modes, but I am sure there is a more elegant way that would not be so annoying for players.

What are the options?


texts: Pathfinding for a destination that is more than 1 tile

texts:
I have a 2d grid, and there are situations where the player selects the 3d model of an exit (like a gate) so they could leave, but in reality, the exit is comprised of multiple tiles in the grid:

In this example, the exit is 4 tiles.
Right now, I'm just thinking of brute-forcing it and doing pathfinding for each exit tile (that means, in the example, 4 times), and just choose the one with the shortest path, but I'm wondering if there is a more efficient way to do this.
Maybe do it only on the extremities of the tile group (in the example, Exit 1 and Exit 4)?
Maybe edit my A* code such that each tile being searched through has multiple heuristic scores (one for each possible destination tile)? Or maybe the heuristic score I assign is the average of all heuristic scores for each destination tile?
I also want to take into consideration other situations in the future where the exit tiles are not necessarily adjacent to each other, even if collectively they are considered one single exit, like this:

So it should figure out that Exit 5 is the shortest path.


texts:
I'm using Monogame to draw 2D primitives to the screen. To do that, rather than use included structures like VertexPositionColor, I wrote my own vertex class for 2D.

public struct VertexColor : IPositionable, IVertexType
{
    private static readonly VertexDeclaration Declaration = new VertexDeclaration
    (
        new VertexElement(0, VertexElementFormat.Vector2, VertexElementUsage.Position, 0),
        new VertexElement(8, VertexElementFormat.Color, VertexElementUsage.Color, 0)
    );

    public VertexColor(Vector2 position, Color color)
    {
        Position = position;
        Color = color;
    }

    public Vector2 Position { get; set; }
    public Color Color { get; set; }
    public VertexDeclaration VertexDeclaration => Declaration;
}

Here's my associated HLSL shader, meant to simply translate vertices from normalized space to screen space.

#define VShaderModel vs_4_0_level_9_1
#define PShaderModel ps_4_0_level_9_1

matrix Projection;

struct VertexShaderInput
{
    float4 Position : SV_Position0;
    float4 Color : Color0;
};

struct VertexShaderOutput
{
    float4 Position : SV_Position0;
    float4 Color : Color0;
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output = (VertexShaderOutput)0;

    output.Position = mul(input.Position, Projection);
    output.Color = input.Color;

    return output;
}

float4 PixelShaderFunction(VertexShaderOutput input) : Color
{
    return input.Color;
}

technique Technique0
{
    pass Pass0
    {
        VertexShader = compile VShaderModel VertexShaderFunction();
        PixelShader = compile PShaderModel PixelShaderFunction();
    }
};

Where Projection is an orthographic matrix computed in code and passed to the shader based on current window size. However, when I attempt to draw primitives, I receive the following exception:

An error occurred while preparing to draw. This is probably because the current vertex declaration does not include all the elements required by the current vertex shader. The current vertex declaration includes these elements: SV_Position0, COLOR0.

Now, I'm familiar with this exception and I understand what it means. The exception is telling me that my shader does not include all required elements based on the current vertex declaration. However, as you can see, my shader does include those two elements (SV_Position0 and Color0).

What am I missing here?


texts:
I'm designing a game reminiscent of Elite or Escape Velocity, those old space trading games, where you play a traveling merchant in space.

I'd like to have the game's economy at least resemble a real one. What resources are available that I could look at to get an understanding of the algorithms I'll need to perform the simulation?

One big hurdle is that I'm pretty horrible at math; so a simplistic explanation would be ideal.

I figure an interstellar economy wouldn't be all that different from a global one; certain things can only be manufactured in certain places (due to resources and technology levels), shipping things takes time and money, people in different places need different things... just instead of cities, they'd be planets.

A Google search of "economics simulation algorithm" and similar terms turns up little of use, and nothing I've got the background to understand.

Anyone know of any useful resources I could look into?


texts: What does this FVF value in the FVFData block of an .X file equate to?

texts:
I'm trying to read and ultimately write a mesh from/to file. This mesh has 2 sets of texture coordinates. The second set I know are held within the FVFData{} block of the .x file. The second set of coordinates is the only data within this block...the block looks like this:

FVFData {
258;
60;
1050755713,
1060090006,
...
}

This is 30 sets of 2 floating point values...

258 is equal to 0x102...
D3DFVF_TEX1( 1, 2-component vector ) is equal to 0x100...
...where does the extra 0x002 come from? is that just D3DFVF_XYZ..?
...why are they coupled for this data block when there is no position data in the block?


texts: How does an ECS work for a world subdivided into chunks (example)?

texts:
I am trying to use an ECS for my 2d game at the moment. Up until now I had my world subdivided into chunks (as minecraft does) of size 64x64. They are loaded and drawn when they come onto screen. I did this to reduce the drawing calls.

How would something like this work in an ECS?
I would say my Chunks have the following properties at the moment: tile_is_water[64,64], humidity[64,64], sprite_batch (the thing that is drawn)

At some intervals I will need to call some kind of updatefunction which uses tile_is_water and humidity to generate a new sprite_batch (but not very often, these change rarely). On every frame I need to draw the sprite_batch. On every (or maybe every few) frame I need to check which areas are visible and set some kind of flag s.t. I only draw the visible ones.

It would help me a lot of someone could explain to me what the components, the entities and systems would be in this case.

Edit: To clarify. I don't have this modelled as an ECS yet and I have problems modelling this particular issue. What I have until now is just seperated everything into components:
Components: Is_Water_Area, HumidityArea, SpriteBatch
Is_Water_Area and HumidityArea just contain the corresponding 64x64 arrays and sprite_batch contains the drawable spritebatch.
I also have a BatchDrawer system that draws everything that has a SpriteBatch. But where do I do the updating of the SpriteBatch for example? Where do I check which areas are drawn?

For example I could just check this every frame or I could keep a list of drawable Areas and update that. But where would I keep such a list of the drawable areas?


texts: How do I acknowledge collisions with volumes in UDK?

texts:
As part of creating a stealth system, I've decided to place volumes over light sources as a first step. The idea being that when a pawn walks into one of those volumes, it will be logged.

How can I detect and react to collisions between a pawn and these sorts of volumes?


texts: Löve2D: Making a random map/city generator

texts: So I'm making a game using love2d where the player will find himself in an zombie infested city but I don't want the city/map to be just the same all the time, so I want to create a random map/city generator, but I don't know where to start, I maybe can make my own but the result would probably be not what I wanted, as I don't want tiles getting placed all over the place messily(it won't look like a city then), I want random set of tiles getting placed in the world/map like buildings get placed randomly throughout the world/map, I hope someone can help me with this as this is really hard for me...


texts: Why is mesh baking causing huge performance spikes?

texts:
A couple of seconds into the gameplay on my Android device, I see huge performance spikes caused by "Mesh.Bake Scaled Mesh PhysX CollisionData"

In my game, a whole level is a parent object containing multiple ridigbodies with mesh colliders. Every FixedUpdate(), my parent object rotates around the player.

Rotating the world causes mesh scaling. Here is the code that handles world rotation.

 private void Update()
    {
        input.update();

        Vector3 currentInput = input.GetDirection();

        worldParent.rotation = initialRotation;

        worldParent.DetachChildren();
        worldParent.position = transform.position;
        world.parent = worldParent;

        worldParent.Rotate(Vector3.right, currentInput.x * 50f);
        worldParent.Rotate(Vector3.forward, currentInput.z * 50f);
    }

How can I get rid of mesh scaling ?
Mesh.Bake physx seems to take effect after some time, is it possible to disable this function ?

The profiler looks like this:

Bottom-left panel shows data before spikes, the right after


texts: How to disable an object after it goes outside camera's viewport?

texts: I have a gameobject at a certain position in the game. I want the gameobject to be disabled once it is outside the camera's viewport, and it should become visible only when the camera focuses at that position.


texts: How to use the unreal "automation spec" with the "automation driver" and latent actions?

texts:
I would like to be able to create an automated test for Unreal that will load a specific map/level and then use the automation driver, which as I understand it, is a way of faking user input, to do things on that level.
My goal is simply to load my "main menu" level and then exit out of it.
My problem is this:
The documentation shows you how to use the automation driver with the automation spec style of automated test. But none of the automation spec tests in the UE4 source do anything with assets (or anything resembling a latent action, as with the other style of tests). Most of the automation spec tests are more akin to unit tests that have no dependency on data, or AutomationDriver.spec.cpp, which has its own hard coded test UI made using SAutomationDriverSpecSuite
There seem to be no examples at all for using the automation driver with the "simple" or "complex" tests (IMPLEMENT_SIMPLE_AUTOMATION_TEST / IMPLEMENT_COMPLEX_AUTOMATION_TEST), and the automation driver documentation just states that it can be pretty tricky unless you're using it in conjunction with an automation spec


texts: How to find or compute or look for overall/max RPM by simply checking for rotation?

texts:
I find it hard to determine the wheel RPM since I'm only making a simple 2D game of rotating object via Z-axis. I wanna try this solution but I got no change since I'm trying to find the RPM from a game object that has a rigid body 2D and a circle collider. I decided to think of something more simple but alternate solution. I'm a bit good at math but not much. Took around to calculate but no luck yet. I want to know possibilities of checking its rotation from transform properties, figuring out yet about 6 degrees per second equivalent to 1 RPM as said from the link. I used the method transform.Rotate() for rotation speed. Also, when the rotation value reaches beyond 360, clockwise or counter-clockwise, sometimes it goes back either 0 or a negative value and I have to maintain total degree so that I can compute for the overall RPM. Please help me.

Re-direct from my original question: http://answers.unity3d.com/questions/1123755/how-to-find-or-compute-or-look-for-overallmax-rpm.html


texts: Unity3D: Convert all game objects to same size irrespective of it's scale

texts: Suppose I have a reference GameObject, Cube, with scale (1,1,1). There is another GameObject with scale (1,1,1), but the size is 3 times bigger than the Cube. How do I dynamically change the scale of the Game objects to fit the size of the Cube?


texts: Language agnostic game programming books

texts:
Possible Duplicates:
  Game programming books that don't teach programming?
  Must read game development books

Does anyone know any good language independent game programming books?

I don't currently know anything about game programming or practices - any good books on stuff like: scene-graphs, handling sprites, layers, collision detection, effects, events?

I'm a college student without the time to learn a new language so the concepts need to be language-agnostic enough they can fit into the languages I know: Javascript, Python, Scheme/Lisp and some light Vala (I'm considering using HTML5 or PyGame). I would use C# books but my OS is Linux and I don't know about the whole mono thing when most C# books use XNA.

Also I know that game programming is an extension of general programming, but I think I've got that down. Like is there a cookbook of some sort?


texts: XNA texture stretching at extreme coordinates

texts:
I was toying around with infinitely scrolling 2D textures using the XNA framework and came across a rather strange observation.

Using the basic draw code:

spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointWrap, null, null);
spriteBatch.Draw(texture, Vector2.Zero, sourceRect, Color.White, 0.0f, Vector2.Zero, 2.0f, SpriteEffects.None, 1.0f);
spriteBatch.End();

with a small 32x32 texture and a sourceRect defined as:

sourceRect = new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height);

I was able to scroll the texture across the window infinitely by changing the X and Y coordinates of the sourceRect.

Playing with different coordinate locations, I noticed that if I made either of the coordinates too large, the texture no longer drew and was instead replaced by either a flat color or alternating bands of color. Tracing the coordinates back down, I found the following at around (0, -16,777,000):

As you can see, the texture in the top half of the image is stretched vertically.

My question is why is this occurring? Certainly I can do things like bind the x/y position to some low multiple of 32 to give the same effect without this occurring, so fixing it isn't an issue, but I'm curious about why this happens. My initial thought was perhaps it was overflowing the coordinate value or some such thing, but looking at a data type size chart, the next closest below is an unsigned short with a range of about 32,000, and above is an unsigned int with a range of around 2,000,000,000 so that isn't likely the cause.

Update 1:
The image above shows the texture stretching vertically near (0, -16,777,000), and the texture stretches horizontally at around (-16,777,000, 0). If I go beyond this point on both axes, the texture is stretched in both directions. This occurs in both the positive and negative directions.

The above positions were noted with a 32x32 texture. With a 16x16 texture, the distortion occurs at the same location. Interestingly, with a 64x64 texture, the distortion occurs in the same location on the x-axis, but is actually farther on the y-axis, more near (0, -17,301,000). It occurs at the same location with a 64x64 texture too, I mistakenly used a 64x66 texture before.

Update 2:
I have repeated the test with a 1024x1024 texture and have found the same results. I looked farther and noticed that it stretches again at double the distance, somewhere near (-33,554,000, -33,554,00), but then doesn't happen again until around 4 times the initial stretching point, near (-67,109,000, -67,109,000).

It seems to occur only at powers of two times that initial value, 16,777,216 * 2^n. The answer below by mh01 suggested to check the MaxTextureRepeat cap of my graphics card (a GeForce GTX 560). According to KluDX this cap has a value of 8192, and it's description indicates that texture coordinates are stored in 32-bit signed integers.

Correction: The stretch points occur at 2^n intervals because my texture sizes are 2^n. Testing with a texture size of 25x33 resulted in the first stretch point appearing near (-13,107,000, -17,301,000). So while it's related to the texture's aspect ratio, it doesn't seem to be directly related to the texture's size.


texts: SQL Server Question: How to go about using a collection of cards

texts:
So basically I'm new to SQL Servers and for that matter generally to Server Logic and Server behavior. (Used to only work on single player games) OK, so my questions is as followed. Lets take Hearthstone for example every user has a card collection. Now if using an SQL server, I can create tables for the users, I can also create tables for the cards, but how do I combine those? To be more specific my solution would have been to make a new table where the playerid and the cardid is stored with the value of how many of the certain card the player has.

However, my issue with this solution is that, if we assume we have 1000 players and we have like 500 cards then the table will be clustered with entries of same playerid's who have different cards.

Basically my question is: Is there a better solution for this and if not what is the capacity of SQL tables/Servers, like when can i expect a drop off during loading the collection of a player who has all 500 cards for example?

Since I'm new to SQL I might also be having a wrong idea on how to solve this issue, so if there is another solution or I'm missing something I would appreciate if someone pointed me in the right direction.


texts: Overdrawn pixels vs many polygons, which affects performance the most?

texts:
I know that having overdrawn pixels is not desirable as well as having many polygons since they can decrease performance.
Often when I model I have an option to decrease the number of polygons by having disconnected polygons over. For example, considering this:
Let's imagine it has more turns that are not visible in this picture.
I can decrease the number of polygons by having a pathway as a single disconnected face:

As a result I would have less poly-count, but the bottom geometry would be overdrawn in many areas.

Or I can model this as a single continuous mesh. As a result I would have more poly-count, but no overdraw:

I very often have similar situations and I'm wondering which of these would be more performance efficient and cause less performance decrease on mobile devices?


texts: How do I switch between different Update behaviour states in Unity?

texts:
I have a bird entity that needs different update rules when it's moving or dying (among potentially other states).

I want to avoid making my Update method a clutter of if-else branches like this:

void Update() {
   if(state == movingState) {
       // Do moving logic.
   else if(state == dyingState) {
       // Do dying logic.
   else if...

Instead, I thought I could make a base class for all my bird behaviours, then derive classes for each state with their own update functions, and use the appropriate derived version based on the current state.

public class BirdBaseModel : MonoBehaviour
{
    void Update()
    {
        // ...
    }
}

public class BirdMoving : BirdBaseModel
{
    void Update()
    {
        // ...
    }
}

public class BirdDying : BirdBaseModel
{
    void Update()
    {
        // ...
    }
}

My BirdBaseModel is attached to the bird game object. Based on game states, I want to dynamically reference it in the GameController class.

BirdBaseModel b;

if(State == 1)
{
    b = new BirdMoving();
}
else if(State == 2)
{
    b = new BirdDying();
}

Based on the above logic, I want to call the Update function of that particular class. How do I invoke the Update of the subclass?


texts:
Following a tutorial on Youtube, https://www.youtube.com/watch?v=P66SSOzCqFU, I'm  trying to make a card game that uses dragged cards. When I drag a card it's supposed to stay centered with the mouse, but it's showing up on the edge of the screen when I start to drag it. How do I make it so the card drags with my mouse instead? Currently I'm using two scripts, one for a drop zone and one for "draggable". When I tried to debug the draggable section it kept referring me back to a line in my drop zone script that just had a '{'. I'm working in Unity 5.6.0f3 and Visual Studio 2017.
My drop zone code looks like this:

public class DropZone : MonoBehaviour, IDropHandler, IPointerEnterHandler, IPointerExitHandler {

public void OnPointerEnter(PointerEventData eventData)
{
    //Debug.Log("OnPointerEnter");
    if (eventData.pointerDrag == null)
        return;
        Draggable d = eventData.pointerDrag.GetComponent<Draggable>();
    if (d != null)
    {
        d.placeholderParent = this.transform;
    }
}

public void OnPointerExit(PointerEventData eventData)
{
    //Debug.Log("OnPointerExit");
    if (eventData.pointerDrag == null)
        return;
    Draggable d = eventData.pointerDrag.GetComponent<Draggable>();
    if (d != null && d.placeholderParent==this.transform)
    {
        d.placeholderParent = d.parentToReturnTo;
    }
}

public void OnDrop(PointerEventData eventData)
{
    Debug.Log(eventData.pointerDrag.name + "was dropped on" + gameObject.name);

    Draggable d = eventData.pointerDrag.GetComponent<Draggable>();
    if(d != null)
    {
        d.parentToReturnTo = this.transform;
    }
}
}

And my Draggable code looks like this:

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

public Transform parentToReturnTo = null;
public Transform placeholderParent = null;

GameObject placeholder = null;

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

    placeholder = new GameObject();
    placeholder.transform.SetParent(this.transform.parent);
    LayoutElement le = placeholder.AddComponent<LayoutElement>();
    le.preferredWidth = this.GetComponent<LayoutElement>().preferredWidth;
    le.preferredHeight = this.GetComponent<LayoutElement>().preferredHeight;
    le.flexibleWidth = 0;
    le.flexibleHeight = 0;

    placeholder.transform.SetSiblingIndex(this.transform.GetSiblingIndex());

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

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

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

    this.transform.position = eventData.position;

    //if(placeholder.transform.parent != placeholderParent)
    //    placeholder.transform.SetParent()

    int newSiblingIndex = placeholderParent.childCount;

    for(int i=0; i<placeholderParent.childCount; i++)
    {
        if(this.transform.position.x < placeholderParent.GetChild(i).position.x)
        {
            newSiblingIndex = i;

            if(placeholderParent.transform.GetSiblingIndex() < newSiblingIndex);
            newSiblingIndex--;
            break;
        }
    }

    placeholder.transform.SetSiblingIndex(newSiblingIndex);

}

public void OnEndDrag(PointerEventData eventData)
{
    Debug.Log("OnEndDrag");
    this.transform.SetParent(parentToReturnTo);
    this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex());
    GetComponent<CanvasGroup>().blocksRaycasts = true;

    Destroy(placeholder);
}

In the draggable code,
if(placeholder.transform.parent != placeholderParent)
    placeholder.transform.SetParent()
is commented out because that's where I stopped in the tutorial in order to go back and fix my displacement issue.


texts:
I've been working with the XNA-Framework(only in 2D) for over a year now. Now I want to try and start a bigger 3D-project. But somehow I have difficulties to decide which engine/Framework I should use. So far I gathered three possible Frameworks, I want to list here:

XNA with the OX-engine: I already have some experience with XNA and the Ox-engine seems to be the best possible open source engine I could use here.
OGRE-engine: Always wanted to get a little deeper into C++ and the engine seems to be well documented.
Cryengine/Sandbox 2 or higher: Well this one also needs C++ knowledge, seems to be user friendly and lets face it one of the most powerful engines out there.

My goals are to start learning 3D-programming and to realize first 3D projects by taking baby steps.

So the question is what engine would you guys recommend? Is there any other stuff I have overseen? as mentioned before getting a little more into C++ would be great to but it is not a "must have" as I alredy worked with C/C#. Most important to me would be that I could lear stuff that I can use later on for example in other Frameworks. This is important to me because I want to get deep into one thing I will be doing for a long time.

Thanks in advance!


texts: XNA 4.0 keeping fonts/sprites without the use of a content project

texts:
Note: The actual title of my question does not really reflect my problem but is actually one of the possible solutions to my problem. I couldn't find a proper way to express my question so feel free to propose a different title.

So I've recently moved to XNA 4.0 and I'm new to this whole content project idea.
I made a simple component based "engine" as a game library that I reuse over all my projects.

I implemented some basic debugging tools like a frame rate counter which used a SpriteFont, which was stored within the actual engine library.

Now that all the content was moved out of the library with XNA 4.0, I don't know where to put the SpriteFont and all other content used by the engine.

I'd rather avoid having to include both the content project and the engine library every time I start a new program, but is this my only option?

Or is there a way to include content within a library without resorting to content projects?


texts: Changing node's translation affects to sibling node

texts:
I have a node which looks like this tree:

FPSController (Root node, and it's KinematicBody)

CollisionShape
Camera
GroundCheckRayCast

When I moved CollisionShape's location down, camera also going down together. There's no code that change Camera's translation, but why this kind of thing happens?

Another weird thing is that y position of Camera won't changed even it's clearly moved down.

Is this some kind of bug or something? Why Camera's y position was changed, also not updated it's own y position value?

Using Godot 3.1.1 and reproduced repo: https://github.com/rico345100/godot-glitch-reproduction


texts: 2D Ragdoll - should it collide with itself?

texts:
I'm working on a ragdoll fighting game as a hobby project, but I have one dilemma. I am not sure if my ragdoll should collide with itself or not, i.e. if ragdoll's body parts should collide.

2D world is somewhat different than 3D, because there are several layers of stuff implied (for example in Super Mario you jump through a platform above you while going up).

The setup I'm currently most satisfied with is when only the parts which are joined by a joint don't collide, so head doesn't collide with neck, neck with chest, chest with upper arm etc, but the head can collide with chest, arms, legs.

I've tried every different way, but I'm not content with either. Which way would recommend me to go?


texts: Is reinforcement learning overkill for a vehicle steering bot?

texts:
I'm slightly familiar with the reinforcement learning (through this edx.org MOOC). Also I'm aware of reactive planning technique. I want to write a vehicle bot for a racing game, where cars have to complete laps and avoid collisions.

Is it sensible to use reinforcement learning for steering? Or should I stick with reactive planning?


texts:
Consider the following situation. In a game you can perform crafting: i.e. create new items from existing ones (like in Minecraft). I have following game entities (simplified):

item: Atomic part.
recipe: A list of items resulting in other list of items.

What would be best structure to store all the recipes in the game? I consider using SQLite database for storing it. However game is not a general type application, so, would it be better to use XML + in-memory structures for storing it?

A database has some major advantages to me, it's much more "DRYer" in my opinion. You also can query it. But I doubt if direct database performance is sufficient for smooth gameplay. On the other hand you can use say, XML to store all of the recipes and use in-memory storage and query it with LINQ. If finally it all results in in-memory structures then database seems to have much overhead, since it's used just as a storage. Or is it still better to use DB?

Solution:

For now I've decided to stick with XML as storage for recipes. The major advantage of XML for me is that the final solution is more portable to other platforms since XML is more widely available.


texts: libgdx universal tween engine how to control the tweening speed?

texts:
How can i control the speed of a tweening sprite? Here is the code:

in create ()

/*try tween*/
            w = Gdx.graphics.getWidth();
            h = Gdx.graphics.getHeight();

            texture = new Texture("nube_png_by_diieguiitoh-d4vhyzb.png");
            texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

            sprite1 = new Sprite(texture);
            sprite1.setPosition(50,0.25f*h);

            Tween.registerAccessor(Sprite.class, new SpriteAccessor());
            manager1 = new TweenManager();
            Tween.to(sprite1,SpriteAccessor.POSITION_X,1000f) //** tween POSITION_X for a duration **//
                    .target(w-100) // ** final POSITION_X **//
                    .ease(TweenEquations.easeInOutQuad) //** easing equation **//
                    .repeat(10,1000f) //** ten more times **//
                    .start(manager1); //** start it
            startTime = TimeUtils.millis();
/*try tween*/

In render()

        batch.begin();

        delta = (TimeUtils.millis()-startTime)/1000; // **get time delta **//
        manager1.update(delta); //** update sprite1 **//
        sprite1.draw(batch);

        batch.end();


texts: Make Unity game using files directly from game directory

texts:
For stats of enemies, and several other kinds of info, I've decided to use not inspector fields or hardcoded values, but to store values to some XML and other types of files, and read them from scripts, obtaining required values. And I want this files to stay in game folder, not packed to *.assets file, because I'd like to have possibility to quickly modify this values without need to rebuild whole game.

So, how can I mark asset in editor, that it should not be included to *.assets, but stay in unchanged form in game folder?

UPDATE: I will slightly rephrase what I want to achieve. I need possibility to have file in game directory, so I can read it from game, and I'd like to have this possibility in both editor and built game. So, as for answer, I will also receive information about what folder is considered as game folder in editor.


texts: Why are games locked at a certain frame per second?

texts: A lot of PC games are locked at 60 frames per second. I know that this is because a high frame rate can cause glitches/bug in a game and mess up the physics but is there another reason? Should anyone who makes games lock their games at 30-120fps? Thanks in advance!


texts: How would I tell the player what options they have without explicitly telling them?

texts:
I'm writing a script for a game story which starts with a bombing of a school. You spawn in a room at the second floor. You play as a child and his 2 best friends and you have 2 options:

Hide in the bombing shelter with everyone else
Risk your lives in an attempt to get out of the schools

I need a way to non-explicitly tell the player to choose one of these options. Rather than tell the user straight out with a message box, I would like the story to tell this to the player.

How I think I might do this:
1. Have an opening scene where the ncps talk with the main character (the main character and his best friends) and initially discus the 2 options.
2. Leave the user to figure this out by giving him/her some clues. This might be an open door to get out of the school [2] , all the other npcs moving to the bombing shelter, etc [1].
3. Give a hint in the loading menu / pause menu. Not the smartest idea, however...

Does anyone have any ideas how to reveal the 2 options without explicitly stating so? I'm free to any ideas.


texts: DirectXTK C++ : How do you use the Spritebatch.Draw() function with overloaded for RECT?

texts:
I am trying to make use of the DirectXTK's SpriteBatch for the C++ version on github. Which is heavily based on the one for XNA. However I can't seem to get the darned thing to work properly.

I have no idea how to fill in the data for RECT. And the closes thing I have found was in SimpleMath::Rectangle.

SimpleMath::Rectangle appears to have a number of overloads to accommodate RECT, however using it as an argument apparently results in visual studios giving a really vague error. Something about their being no overloads to support it.


texts: In a 2D tile-based game, how should NPCs and tiles reference each other?

texts:
I'm making a tile engine for top-down 2D games. Basically the world is composed of a grid of tiles.

Now I want to put for instance NPCs that can move on the map.

What do you think is best:

each tile has a pointer to the NPC that is on its tile, or a NULL pointer
having a list of NPCs, and they have the coordinates of the tile they are on.
something else?

I think

is faster for collision detection but it would use much more memory space and it is slower to find all NPCs in a map.
is the opposite.


texts: How can I roll N dice in constant time and preserve a binomial distribution?

texts:
If I want to throw a 100d6, I have to:

int sum=0;
for(int i=0; i<100; i++)
    sum += Random.BetweenInclusive( 1, 6);

But for high dice count it may be expensive.

Does there exist any algorithm that is able to throw many dice with an algorithm that always require the same time (it is CONSTANT in the number of dice) and that will still produce a binomial distribution?

The goal is to write a function that:

int RollADice( int rolls, int faces)
{
    if( rolls <1245) // constant determined by profiling
    {
        int sum=0;
            for(int i=0; i<rolls; i++)
                sum += Random.BetweenInclusive( 1, faces);
        return sum;
    }
    else
    {
        return RollArbitraryDice( rolls, faces); // how would be that function?
    }
}

The only progress so far is throwing 2 dice at the same time (by noting that the distribution of 2 dice is a linear ramp, so we could cut the ramp in the middle and get a rectangle).

I also found an algorithm that does roll many dice preserving entropy, but it actually have a cost that is binomial on number of dice, not really a good trade (unless you need entropy).


texts: How to use HD and SD sprites in Unity addressables

texts:
I am able to load sprites using Unity addressables. But how can I use SD or HD variants of a sprite based on my device resolution?
Previously I was using LIBGDX, and it has ResolutionFileResolver to handle this scenario.