texts:
I tried to draw Mario Sprites in my HTML Canvas, but it always went blank.
Anybody knows why?

var canvas = document.getElementById("screen");
var ctx = canvas.getContext("2d");
var mario;
var marioSprite;
var tiles;
var speedX = 1;

//marioSprite Specification
mario = {
    //target picture specification X & Y, Width & Height
    px:276,
    py: 44,
    pwidth: 16,
    pheight: 16,
    //drawing on Canvas specification X & Y, Width & Height
    cx: 16,
    cy: 116,
    cwidth:16,
    cheight:16,
}

//draw Mario in Canvas
function drawMarioSprite(){
    marioSprite = new Image();
    marioSprite.src = 'file:///C:/Users/MASTONO ALI/Desktop/img/characters.gif';
    marioSprite.addEventListener('load', e => {
    ctx.drawImage(marioSprite,
        mario.px, mario.py, mario.pwidth, mario.pheight,
        mario.cx, mario.cy, mario.cwidth, mario.cheight);
    });
    this.position = function() {
        this.mario.cx += speedX;
    }
    position();
}//drawMarioSprite() end

//drawTiles and tilesLoop
function drawTiles() {
    tiles = new Image();
    tiles.src = 'file:///C:/Users/MASTONO ALI/Desktop/img/tiles.png';
    tiles.addEventListener('load', e => {
        tilesLoop();
    });
}
function tilesLoop(){
    for (let x = 0; x < 25; x++){
        for (let y = 11; y < 13; y++){
            ctx.drawImage(tiles,
                0, 0, 26, 26,
                x*12, y*12, 20, 20);
        }
    }
}//drawTiles() end

function draw(){
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    drawMarioSprite();
    drawTiles();
    window.requestAnimationFrame(draw);
}

window.requestAnimationFrame(draw);


texts:
Version: Unity 2020.2.0f1
I started my project with Universal render pipeline template but I don't know why all materials are pink. i even tried to upgrading but nothing happened.
This error was coming after upgrading:

And when I am creating new materials then I still getting pink materials and I am also not able to upgrade them:


texts: No more OpenGLES 2 UWP template in Visual Studio 2017?

texts:
In Visual Studio 2015, a convenient cross-platform C++ project template was available named "OpenGLES 2 Application (Android, iOS, Windows Universal)."  I cannot find this template in Visual Studio 2017; only the Android + iOS template is present.

A response to this post on the VS dev community site suggests the template was removed by design.  If so, are there any alternatives I might consider to give a similarly streamlined workflow?


texts: When to get input state: multiple times or one time in a static class?

texts:
Let's say I have these classes:

Player

Here I want to make the player jump:

  current_state_ = Keyboard.GetState();
  if ((current_state_.IsKeyDown(Keys.Space) || current_state_.IsKeyDown(Keys.Up))
       Jump();

Intro scene
GameOver scene

Here I just want to give the possibility to skip those scenes:

  current_state_ = Keyboard.GetState();
  if ((current_state_.IsKeyDown(Keys.Space) || current_state_.IsKeyDown(Keys.Up))
       SkipScene();

My question is what is usual done:

"Asking" for input in every class, or make a static class that asks for input every update, and then you get that value?

public static class InputHandler
{
    private static KeyboardState current_state_;

    public static bool IsSpacePressed()
    {
        return current_key_.IsKeyDown(Keys.Space);
    }

    // Others

    // To be called in game's main loop
    public static void Update(GameTime gametime)
    {
        current_key_ = Keyboard.GetState();
    }
}

I'm worried about that because I thought (don't know if it is correct!) that maybe it is wrong to ask multiple times per update for input.


texts:
I'm new and trying to draw a very simple quad with VAO and GLSL.

My definitions:

typedef struct SPos
{
    float x;
    float y;
} SPos;
SPos mVertices[6];
SPos mIndicies[6];
GLuint mVao;
GLuint mVertexVbo;
GLuint mIbo;

These are my steps:

Load Vertex, Fragment code (I'm sure that no mistake in this step) and get programID
Create VBO

glGenBuffers(1, &mVertexVbo);
glBindBuffer(GL_ARRAY_BUFFER, mVertexVbo);
glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(SPos), mVertices, GL_STATIC_DRAW);

Create IBO.

mIndices[0] = 0;
mIndices[1] = 1;
mIndices[2] = 2;
mIndices[3] = 3;
glGenBuffers(1, &mIbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIbo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 4 * sizeof(GLuint), (GLuint*) mIndices,\
    GL_STATIC_DRAW);

Create VAO

glGenVertexArrays(1, &mVao);
glBindVertexArray(mVao);
glUseProgram(mProgram);

GLint posLoc = glGetAttribLocation(mShader.program, "a_posL");
glEnableVertexAttribArray(posLoc);
glBindBuffer( GL_ARRAY_BUFFER, mVertexVbo );
glVertexAttribPointer( posLoc, 2, GL_FLOAT, GL_FALSE, 0, 0 );

glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, mIbo );
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

Render loop.

mVertices[0].x = -50.0f;
mVertices[0].y = -50.0f;

mVertices[1].x = 50.0f;
mVertices[1].y = -50.0f;

mVertices[2].x = 50.0f;
mVertices[2].y = 50.0f;

mVertices[3].x = -50.0f;
mVertices[3].y = 50.0f;

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindVertexArray(mVao);
glDrawElements( GL_TRIANGLE_FAN, 4, GL_UNSIGNED_INT, 0 );
// GLES2 swap function.
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );

These are my shaders

fragment:

#version 300 es
precision mediump float;

out vec4 oColor;
uniform vec4 unifColor;

void main()
{
    oColor = vec4(1);
}

vertex:

#version 300 es

in vec2 a_posL;

void main()
{
    gl_Position = vec4(a_posL, 1.0, 1.0);
}

Nothing is draw in the screen. What's wrong?

All above is follows a VAO tutorial on the internet.

I spend 1 day to debug and scan it very carefully but not work.

EDIT:

Thanks GOD. The problem is that I setted the data of mVertices in render step, have to set it before create VBO.

I'm still confuse that glBufferData need a pointer for data but Why I cannot pass the address of data then assign its value in later? Why I have to assign its value before bind it to VBO?


texts: If a user marks a seam on a mesh, how do 3D modelling programs (like Blender or Maya) unfold the mesh on to a 2D surface? I can only find papers trying to automate the seaming for you. Given user-defined seams, does the unfolding happen?


texts:
Summarizing my problem well, I need a single button (right mouse button) to do two things.

In my project (TopDown) I defined that instead of the left mouse button, the character moves with the right mouse button.

I happen to like that when I click the right mouse button on a particular actor, a simple event is called (print hello).

I tried doing this with the Event On Clicked, but it only works with the left mouse button:

With the help of these links:

https://www.unrealengine.com/en-US/blog/input-action-and-axis-mappings-in-ue4

https://answers.unrealengine.com/questions/134349/right-click-on-an-actor.html

https://answers.unrealengine.com/questions/17729/how-to-create-a-right-mouse-click-event-with-bluep.html

I figured out how to do an action/event call with the right mouse button, but even then I did not succeed.

Soon I discovered that the reason was that there was already an action that was executed with the right mouse button (walk/set destination):

I would like my character to continue to move with the right click of the mouse, but how do I also call an event when I click the right mouse button?

EDIT 1

If the mapping is done with two different keys, it works perfectly:

In this case the character jumps and walks (instead of jumping it could be anything else):

I want this to happen by right-clicking (walking and jumping):

This action I want to perform is when clicking on the mesh of any actor, but I can only do this with the left button.


texts: Multiplayer card game using PHP/Ajax and mysql

texts:
I am designing a map game, using PHP and MYSQL. I don't know how to make the players who sign-in to the website to see other players who are also connected to the site and be able to chat with one another.

I want to design the game in such a way that 2 players can play with each other and be able to send messages during the game while others groups are playing at the same time.

I have designed the map game successfully, but the problem is making the player 1 who log-in to site to see the player 2 who will also log-in and both can get connected to play each other.
http://i.stack.imgur.com/YyCPG.png

I will appreciate your responses.


texts: How can I access the members of XMVECTOR?

texts:
So I have been reading these articles, and I find implementing them a trouble. Currently, all I am trying to do is add two vectors together, leaving my question more specifically this: How can I add specific members of two given vectors together? An example would be this:

XMVECTOR v1 = XMVectorSet(1.0, 2.0, 3.0, 4.0);
XMVECTOR v2 = XMVectorSet(1.0, 1.0, 1.0, 1.0);

Then I would need to be able to lets say add v1's third member (3.0) and v2's second member (1.0). How can I pull this off? I tried using:

v1.z += v2.x;

To no avail. Any help is very much appreciated.


texts: How to perform simple collision detection?

texts:
Imagine two squares sitting side by side, both level with the ground like so:

A simple way to detect if one is hitting the other is to compare the location of each side. They are touching if all of the following are false:

The right square's left side is to the right of the left square's
right side.
The right square's right side is to the left of the
left square's left side.
The right square's bottom side is above
the left square's top side.
The right square's top side is below
the left square's bottom side.

If any of those are true, the squares are not touching.
But consider a case like this, where one square is at a 45 degree angle:

Is there an equally simple way to determine if those squares are touching?


texts:
So assume you have an input system that is based on polling

void update()
{
    if( Keyboard[ 'A' ] )
        // A is down
}

Say you want to be able to recognize 3 to 8 length key combinations (like down, down-forward, forward, A for hado-ken)

How would you best create a generic (easily modifiable/programmable) key combination input system on polled input?


texts: Fbx SDK Importer issue (texture / uv related)

texts:
I am using the latest autodesk FBX Importer SDK, but whatever I do, I am unable to get the uvs right. Some parts are textured properly while others are not.

I am using Direct3D9 and Direct3D11 (same result in both).

Image:

360 image: https://i.gyazo.com/5a2e5f6e127521915508c9c300eb03e5.mp4

The model uses a single texture and a single material shared among 4 meshes.

Is there someone who sees immediately what the problem could be? Or is there someone who can replicate the issue for me and figure out what I am missing?

FBX Test File: http://www.4shared.com/rar/o_WG0Crpce/Peach64FBX.html

My UV reading method:

int vertexCounter = 0;
for (int j = 0; j < nbPolygons; j++) {

    for (int k = 0; k < 3; k++) {

        int vertexIndex = pFbxMesh->GetPolygonVertex(j, k);

        Vector2 uv;
        _readUV(pFbxMesh, vertexIndex, pFbxMesh->GetTextureUVIndex(j, k), uv);

        pVertices[vertexIndex].uv.x = uv.x;
        pVertices[vertexIndex].uv.y = 1.0 - uv.y;
        vertexCounter++;
    }
}

void _readUV(fbxsdk::FbxMesh* pFbxMesh, int vertexIndex, int uvIndex, Vector2& uv) {

    fbxsdk::FbxLayerElementUV *pFbxLayerElementUV = pFbxMesh->GetLayer(0)->GetUVs();

    if (pFbxLayerElementUV == nullptr) {
        return;
    }

    switch (pFbxLayerElementUV->GetMappingMode()) {

        case FbxLayerElementUV::eByControlPoint:
        {
            switch (pFbxLayerElementUV->GetReferenceMode()) {

                case FbxLayerElementUV::eDirect:
                {
                    fbxsdk::FbxVector2 fbxUv = pFbxLayerElementUV->GetDirectArray().GetAt(vertexIndex);

                    uv.x = fbxUv.mData[0];
                    uv.y = fbxUv.mData[1];

                    break;
                }

                case FbxLayerElementUV::eIndexToDirect:
                {
                    int id = pFbxLayerElementUV->GetIndexArray().GetAt(vertexIndex);
                    fbxsdk::FbxVector2 fbxUv = pFbxLayerElementUV->GetDirectArray().GetAt(id);

                    uv.x = fbxUv.mData[0];
                    uv.y = fbxUv.mData[1];

                    break;
                }
            }

            break;
        }

        case FbxLayerElementUV::eByPolygonVertex:
        {

            switch (pFbxLayerElementUV->GetReferenceMode()) {

                // Always enters this part for the example model
                case FbxLayerElementUV::eDirect:
                case FbxLayerElementUV::eIndexToDirect:
                {

                    uv.x = pFbxLayerElementUV->GetDirectArray().GetAt(uvIndex).mData[0];
                    uv.y = pFbxLayerElementUV->GetDirectArray().GetAt(uvIndex).mData[1];

                    break;
                }
            }

            break;
        }
    }
}

I am doing V = 1.0 - uv.y because I am using Direct3D11.

NOTE: the MappingMode is always eByPolygonVertex and ReferenceMode is always eIndexToDirect

Rendering Info:

Rendered as a Triangle List
Uv wrapping mode: Wrap (Repeat)
Culling: None


texts: I'm not sure whether this is the correct site to ask this question, but why does it sometimes (game-specific, usually) take really long to enter / exit a fullscreen game (black screen for ~1-5s)? And why don't we have these problems for example when entering a Windows 8 fullscreen app?


texts: Marmalade SDK 6.1: missing Studio UI Builder

texts:
Marmalade SDK 6.1 they removed the UI Studio builder tool used in previous versions to construct the UI for apps.
http://www.madewithmarmalade.com/devnet/documentation#/tools/uibuilder.html

now is there any alternative to the tool or we have to construct the UI programmatically ?

Thanks


texts: Compiling a Monogame Game into a single .exe

texts: Is it possible to compile a monogame game into a single .exe? I know if you go in the debug or release bin, there is in fact a .exe your game, except you move this .exe's file location or try to run in on another computer it crashes. I am also aware of the one-click application except this seems like a really messy way of redistributing a monogame game. How come when you build your game, the exe for it wont work anywhere but that file location and that computer. I am also aware that the computer probably needs the XNA framework downloaded to play the monogame game, so in short is it possible to redistribute a monogame game by creating a single .exe and assume that person who is using it doesnt have XNA or monogame installed?


texts:
I'm simply trying to make my character turn in his place, whether he's standing still or moving, currently, he isn't turning what-so-ever. Here is the code that I currently have for turning:

I AM NO LONGER USING THIS TURNING FUNTION vvv

void Turning()
{
    Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
    RaycastHit floorHit;

    if (Physics.Raycast (camRay, out floorHit, camRayLength, floorMask))
    {
        Vector3 playerToMouse = floorHit.point - transform.position;
        playerToMouse.y = 0f;

        Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
        playerRigidbody.MoveRotation(newRotation);
    }
}

So what should be happening is my character should turn and face toward wherever my mouse is pointing, but that isn't happening and I'm not sure why.

Thank you in advance for any assistance.

WHAT I AM USING NOW

I have alternatively tried another bit of code which I will post below, I completely got rid of what is above in place of this:

Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.LookAt(mousePos);

This will actually make the camera follow the mouse, but it goes crazy, the camera seems to spin in circles rapidly : here is actually a gif of what is happening. https://gyazo.com/952da6c28e644b7b0e6500a597b6804e/preview Could anyone help me figure how how to fix it?


texts:
I'm drawing some kind of bullet trace effect with LineRenderer in my 2D Game Project with Unity. At some position, setting position of LineRender result weird:

In the above screenshot, you can see two types of lines are exists. Pure red lines are result of Debug.DrawRay which is only renders in Scene view, not actual game play, and another lines which has yellow to red gradient are actual line renders I want to draw.

I used exactly same code for rendering both two, Debug.DrawRay() and LineRenderer.SetPosition(), but as you can see only DrawRay works as I expected and LineRenderers are cutted and pointing wrong direction.

Here's the code I'm trying:

void Fire() {
    Vector3 shootDirection = m_ShootPoint.right;

    RaycastHit2D hit = Physics2D.Raycast(m_ShootPoint.position, shootDirection, m_Range);
    Debug.DrawRay(m_ShootPoint.position, shootDirection.normalized * m_Range, Color.red, 20);

    // On Hit, set end position where it hits
    if (hit) {
        CreateBulletTrace(m_ShootPoint.position, hit.point);
    }
    // Otherwise, render straight until it's range
    else {
        CreateBulletTrace(m_ShootPoint.position, shootDirection.normalized * m_Range);
    }
}

void CreateBulletTrace(Vector3 startPos, Vector3 endPos) {
    GameObject bulletTraceObj = Instantiate(m_BulletTraceLineRendererPrefab);
    LineRenderer bulletTraceLineRenderer = bulletTraceObj.GetComponent<LineRenderer>();
    bulletTraceLineRenderer.useWorldSpace = true;

    bulletTraceLineRenderer.SetPosition(0, startPos);
    bulletTraceLineRenderer.SetPosition(1, endPos);

    // Destroy(bulletTraceObj, 0.1f);
}

Note that LineRenderer checked use world space to true. What am I missing?

Using Unity 2019.1.0f2.


texts: How to version control game balance data stored in spreadsheets

texts:
Is there any good workflow/tooling for having good version control on spreadsheets for game data? Ideally something that supports branching or merging.

Google spreadsheets allow people to edit data live so it makes "merging" easy, but it gets really hard to link the data that's live in a spreadsheet with the current version of the game in source control (ie. your git repo or other)

Conversely, with a local tool like Excel you at least have actual files that can be stored in the repo, but there doesn't seem to be good tooling for merging different versions of them.

With all that in mind, how can we ensure that a specific branch in a game repo can be linked to a specific version of the game data, and how can we allow people to work on different "branches" of game data in parallel while still keeping the ability to source control?


texts: Should the world transformation matrix be stored in a constant buffer when rendering?

texts:
Generally when rendering objects you would:

Apply world transformation to go from object space to world space
Apply view transformation to go from world space to camera space
Apply perspective projection transform to go from camera space to canonical view volume

In a normal situation, you only have a single camera and screen to work with so you only have one each of view transform matrix and projection transform matrix to render a frame. So, before the rendering begins, you need to put all this info in a constant buffer. So that the vertex shader can transform the vertices per objects into a world matrix.

Considering you need a (probably unique) world transform matrix for each object, how is this process actually done in practical situations?

The easiest and obvious solution I can think of is to put world matrices in a constant buffer but if I am not mistaken from the architecture of video card memory, you are not able to dynamically allocate constant buffers. I can think of this being a big problem because in real situations, the number of objects to be rendered would vary each frame.

A tutorial I came across handles this situation in a rather concerning way. If object A, B, C exists, instead of passing all objects to the vertex shader, it would go through the following process:

Add world matrix of object A into a constant buffer then draw the object A
Add world matrix of object B into a constant buffer then draw the object B.
Add world matrix of object C into a constant buffer then draw the object C.

This works, but this seems really counter-intuitive from a performance perspective as you have to do a lot of synchronization for a simple rendering process. Not to mention drawing operation becomes O(n) for the number of objects. It also doesn't fit too well with the philosophy of shader process where parallel processing is heavily favored.

So I had a random thought for a potential solution: you would first dynamically allocate memory size of (XMMatrix) * (Object Count) on the GPU, and when transforming from vertex from vertex shader, you would select which matrix to use from list of world matrices. This seems very doable in CUDA but not too sure about HLSL . Is this idea even legit to begin with?

I guess you could also somehow send the vertices of the object located in world space directly to the vertex shader.


texts: Syntax error in multi-pass Surface Shader

texts:
I'm trying to make a Surface Shader that uses multiple passes, with two different blending functions for each one, but I get the following error I don't understand:

  Parse error: syntax error, unexpected TOK_PASS, expecting TOK_SETTEXTURE or '}' at line 28

SubShader
{
    ZWrite Off
    Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" "PreviewType"="Plane" }
    Pass
    {
        //transparency
        Blend SrcAlpha One
        CGPROGRAM
            #pragma surface surf Lambert
            #pragma target 3.0
            struct Input
            {
                //
            };
            sampler2D //;
            void surf (Input IN, inout SurfaceOutput o)
            {
                //
            }
        }
     ENDCG
    }
    Pass
    {
         //alphabend
        Blend SrcAlpha OneMinusSrcAlpha
        CGPROGRAM
        #pragma surface surf Lambert
        #pragma target 3.0

         sampler2D//;
         fixed4 //;

         struct Input
         {
          //;
         };
         void surf(Input IN, inout SurfaceOutput o)
         {
         //
         }
        ENDCG
    }
}


texts:
I'm trying to learn procedural generation technique's. Specifically for dungeons. I started off with a 2D array and I generate my rooms fine. Each room contains wall tiles as seen in the screenshot below.

Right now I use A* to link the rooms together. But this has some paths go straight through other rooms or around rooms. Having done some googling I found this demo which game me the idea of using Delaunay Triangulation to properly connect the rooms without going through already existing connections/rooms.

But how to apply it to my 2D array setup? My initial thinking is that I should think out side of the box (2d array haha) and grab my rooms and create a complete graph from this and then apply the Delaunay Triangulation.

I've never done anything with graphs before. So what I would to know is a) is my thinking correct in creating the graph with all the rooms linked and then to apply the triangulation and b) where should i start?

[small edit]after some more looking around stackoverflow i found this post explaining Graphs more in depth. https://stackoverflow.com/questions/15306040/generate-an-adjacency-matrix-for-a-weighted-graph


texts:
Imagine you have a multiplayer RTS game (e.g. Dune, Age of Empires, Settlers, Warcraft). There are certain commands available from keyboard to command the troops (Stop, Attack, Move) and some more general commands like Pause or Exit. The game is localized into many languages (18+).

I can see two possible ways of using keyboard shortcuts:

A. Use first English letter of said commands ("S", "A", "M", "P", etc.) for every locale.

B. Use first letter of the word on that locale (e.g. Russian shortcuts will be "С", "А", "Д", "П". German will be "H", "A", "S", etc..)

Which of these (or suggest your own) approaches is better when choosing the shortcuts for multiple locales?

P.S. Of course the shortcuts might be customizable by player, but some sane defaults are still needed.


texts: Do any 3d engines natively import Google Sketchup models

texts: Google Sketchup is about the only 3d cad program I can use, because I suck.  Do any 3d engines natively import Sketchup models?  Are there any major caveats when doing so?


texts: Is it possible to draw inner shadow for some polygon to make it look like this?


texts: How to rotate the transform only on the Y?

texts:
private Update()
{
    // Here the transform player should rotate facing the opposite direction.
    // Determine which direction to rotate towards
    Vector3 targetDirection = targetToRotateTo.position - transform.position;

    // The step size is equal to speed times frame time.
    float singleStep = rotationSpeed * Time.deltaTime;

    // Rotate the forward vector towards the target direction by one step
    Vector3 newDirection = Vector3.RotateTowards(transform.forward, targetDirection, singleStep, 0.0f);

    // Draw a ray pointing at our target in
    Debug.DrawRay(transform.position, newDirection, Color.red);

    // Calculate a rotation a step closer to the target and applies rotation to this object
    transform.rotation = Quaternion.LookRotation(newDirection);
}


texts: How can players randomly - and secretly - choose 5 cards out of 25 that match a specific condition

texts:
So this is a less a coding question and more a 'there's gotta be a way'...
I have a Clue-like logic/deduction board game that has 25 cards - 5 of each color and 5 of each taste. Each card is unique, and has a unique combination of color and taste.
Just like in Clue, I want to have players randomly choose some cards that make up the answer they're trying to discover through logic and deduction. In previous versions, one side of the cards (the back side) had the taste of the card, and the correct answer would have exactly one of each taste. After some playtesting, a suggestion was made to have the correct answer have 5 cards, including exactly one card of each color and taste...
So that's what I'm trying to do. Players need to secretly determine this for themselves by using just some playing cards. One side needs to have the actual combination of color and taste on it, but anything can be on the back to make it work. I've tinkered with numbers and bar-code-like graphics, but anything's possible here (numbers shouldn't be easily memorized, naturally, and the backs of the cards should be able to remain visible without this system giving away what's on the other side...


texts: How to draw lines with fountain pen effect in Unity?

texts:
I'm working on drawing lines in Unity, I've already implemented smooth line drawing with LineRenderer. But I need lines have effect of fountain pen or gel ink pen, just as the picture showed below, I have no idea about this,  may shaders  make the effect ?can anyone help?

Now I can draw common lines with Unity:

Effect needed:


texts: How to make a 2D sprite slowly vanish as it crosses a line — as if disappearing behind a wall?

texts:
...Except there is no wall. Only one of its edges.

Here is what I mean. Notice how the lines "sink" into the center square.

I've been trying to do something very similar, in Unity. My approach is to detect when the lines come into contact with the center square (hexagon, in my case), and first initiate an animation that decreases the width of the lines, precisely timed via math to last exactly as long as needed.

But there's a problem. The animation doesn't play. I've spent the last few hours debugging it, to no avail, and now have finally given up, because the problem is too complex to post here. Too many variables.

Are there any better methods of achieving this?

My own, even if it had worked, wouldn't have been perfect, because the width would've decreased on both sides (of the line running in the middle of the thick squares or hexagons that are to disappear), giving it a strange, swallowing effect, but I'd be satisfied, since it's just a practice project.

So, I'm giving up on this approach. What are easier ways to do this? (Preferably in Unity, but I'll take anything.)

Hasty edit: Keep in mind that my "lines" are not sprites but line renderers, but I'm looking for ways to work on either.


texts: How does raytracing triangle meshes with RTX work internally?

texts:
Raytracing a huge bunch of triangles the naive way (ie. testing each ray against every single triangle) would be humongously slow, which is why raytracers use optimizations to greatly reduce the number of ray-triangle tests that needs to be done. The most common optimization is to organize the triangles into a tree-like data structure, such as a kd-tree.

How does Nvidia's RTX technology do this internally? It's my understanding (please correct me if I'm wrong) that it, indeed, also uses a tree data structure for the triangles to be raytraced. My question is which part of the rendering pipeline performs this construction of the tree data structure. Is it done on the application side?

But, more importantly, and this is the crux of my question: How are mesh deformations handled? (In other words, triangles that change shape and/or their relative position to each other within the same mesh object.)

It is my understanding that a tree data structure works wonders when raytracing a triangle mesh... as long as the mesh is completely rigid and doesn't deform. If the mesh deforms (triangles change shape and/or their position in relation to each other) the entire tree needs to be rebuilt (because the changed triangles can well end up in completely different locations in the tree).

RTX demos, and especially BF5, show animated human characters (with eg. their clothes being deformed by wind) being shown in raytraced reflections just fine. How is this achieved? Are the tree data structures recalculated on every single frame, or is this done some other way?


texts: Tiled perlin/value noise texture with (2^n)+1 size

texts:
Actually what I have in mind is value noise I think, but what I am going to ask applies to both of them.

It is known that if you want to produce tiled texture by using the perlin/value noise, the size of the texture should be specified as the power of 2 (2^n). Without any modifications to the algorithm when you use the size of (2^n)+1 the texture cannot be tiled anymore, so I am wondering whether it is possible (by modifying the algorithm somehow) to generate such tiling texture with the size of (2^n)+1. The article (from which I have my implementation) is here: http://devmag.org.za/2009/04/25/perlin-noise/

I am aware that I can produce texture with 2^n size and just copy twice the last column/row from the ends to make it (2^n)+1, but I don't want to, because such repetitions are visible too much.


texts: Could I get in to trouble for "rickrolling" users in my commercial game?

texts:
Not sure if this question is too stupid but, theoretically speaking...

Could you get into trouble for using something like Application.OpenURL in a commercial game to rickroll a player or would that be legally okay? (sorry this question is really stupid)


texts: How do I protect sending scores from HTML5 games to my server

texts: On backend I am using java. I have a game in HTML5; when user completes it I sends an Ajax call to save the score to database. Now, someone can easily use tools like Fiddler and firebug to modify this ajax request and send a much better score to the server. How do I make sure that user cannot manipulate scores !


texts:
I will change a scene on button click. But not change the main scene with button.

Node structure:

main
- scene (with childs)
- button

button.gd:

func pressed():
    get_node("scene").change_scene("res://second_scene.tscn")

It doesn't works.


texts:
I am looking at implementing the Theta* algorithm in a 2D NavMesh.
I have A* working, and I need to add a line of sight check to turn it into Theta*, this seems relatively easy in a uniform grid but a bit trickier in a NavMesh. There is excellent documentation on the funnel algorithm here, however this seems better suited to A* post smoothing.

Is there an method that would be better suited to Theta* line of sight checks in a Navmesh, or would I just need to use a modified version of the funnel algorithm?


texts: Find the Contact Normal of Rectangle Collision

texts:
It seems a lot of people have asked similar questions on this site, and every time it seems like a whole bunch of answers that don't work are given.
Basically, I have two rectangles (AABBs) that collide, and I want to find out on what side they collided with each other.

I know the velocities of each object before they collide, and of course their positions before and when they've actually collided (if I use discrete collision checking that is, currently I'm using speculative). Many people say find the lowest penetration distance or take the largest speed (either horizontal or vertical) and that will give you the answer. But the collision is dependent on both of those values, I just don't know how they fit together to tell me where the collision is coming from. I don't think I need an exception for corner collisions.

I do not want to do my horizontal and vertical collisions separately as that just opens up even more problems.

So, any suggestions?


texts: Multiplayer oriented game engine object (C++)

texts:
for a personal project i started making a 2d game engine in C++ that uses sfml. The idea is having base "game object" classes from which a game will inherit.

Right now i have:

Game_engine class which has a run method that takes care of the game loop (fixed timestep loop). The loop consists in:

dequeuing SFML window events
step

dequeue networking events
call step function for each Object instance

draw

call draw update function for each Object instance
call draw function for each Object instance

Resource_manager class which takes care about loading and holding resources and holding animations.

Animation and Animated_sprite, where animation exists only once per animation, has a pointer to the texture and a list of the frames, while animated sprite is a child of sf::Sprite and there's one instance per each instance of a game object. Animated sprite points to its animation and frames are updated when Object's draw_update is called.

Logger class, which queues up strings from the engine thread and uses a second thread to write the strings to file without the main thread suffering from write-to-disk delay

Networking_client class, which queues up networking packets in a secondary thread, and returns the queue to the Game_engine when it requires it for the networking part of the step.

Object class which is the basis on which an actual game's objects will be built. It has by default vertical and horizontal speed variables, and function to set them both as vertical and horizontal components or as speed and direction. It has both a sprite with its coordinates and its own coordinates. Sprite's coordinates are used by sfml to draw and will be updated with interpolation when draw_update is called. The own coordinates are updated when the step function is called, which in an actual game will take care of checking collisions and stuff like that.

Up until that point i really did everything kinda by instinct, but now i don't know how to design networking managed objects.
Ideally i would have a server which runs the game without the drawing part, only the fixed steps, and holds information about all connected clients. My issues are not about lag compensation right now, but about how to deal with these classes.

When i shoot on my client, i would tell the server i shot, the server creates a projectile and its creation is sent to all clients together with an id that identifies the networking object for future updates (changes in direction, destruction). However this adds a delay in the client when it's shooting its own projectile. If i create the projectile in the client first and tell the server about its creation, the client can cheat about its coordinates. If i create the projectile individually in both, once the client receives the information "create projectile" from the server it can't tell it's its own already existing projectile and not someones else's.
Same issue when a client is changing it's controlled object's direction...

Can i get help designing that? I did something like that in javascript (without lag compensation it was a teleporting fest) but idk i'm finding it harder to design now, because i'm making it more generic, while my javascript project was directly with the actual game objects.

Before anyone tells something like "use an existing engine", part of my interest is actual making my own, after all it's an hobby and i'll likely never publish any game with that, i just enjoy writing such things and overcomplicating my life in a way that ends in never having any concrete result whatsoever.


texts:
I am currently developing a Puzzle/RPG game which works a little bit like Minesweeper.
You have a Field of Tiles and 2, 3 or 4 different colors from which you can choose. Now you have to uncover tiles in order to attack the enemy.
Therefore you need to choose the correct color for the tile you want to open. If you try the wrong color, the enemy may try. As long as you open tiles, the enemy may not try (same if it's the enemy's turn).

Now I wrote a really simple AI which works like this:
It iterates over the complete field and looks for all unopened tiles. For each of this unopened tiles, it calculates a score, depending on the tile's neighbours. So an unopened neighbour gives +0, an opened neighbour with a 0 gives +4, an opened neighbour with a 4 gives +4, with 3 gives +3 and so on.
At the end the score is weighted, depending on the fact how many different colours the neighbours have and how many beighbours it actually has (because tiles at the edge have less neighbours).

When it comes to choosing a tile, it works pretty well. Then for the chosen tile it tries every colour, starting with some colour of the neighbouring open tiles. But the ai has no understanding for what the neighbours can tell it. So there is no actual strategy except of: Look for a tile, try colours until it is opened.

I am really new in AI development and find it pretty hard to wrap my head around that topic. The only AI I wrote before was some simple chasing in 2D space shooter.

So my question is: How would a good AI in such a case look?
I thought it would be best to give the AI the same information as the player. So it only knows Tile count and which tiles are opened/closed and the colours of the opened and their neighbour counts. Is this correct or should the AI know everything?
Addtionally, the AI should be beatable.
Can you give me some hints on how this can be/should be/usually is done?  Or is there some literature you can recommend for this topic?
(I already looked in an AI for games book I have here and thought I could use minimax but I could not find out how. Also I thought maybe seeing this problem as pathfinding problem would be a solution, but I am not quite sure.)

For better understanding, this is a game which works like what I am building, except this game has no AI and no rela enemy turns (The player just gets hit if he clicks a wrong tile): GameLink


texts: How to architect systems is Enity Component System, in C++

texts:
When creating an ECS in C++, what are good, simple approaches to architecting the systems.

Should each system be a static function of a dedicated class (is this semantically different than just being a global function?) Or maybe the systems should be static methods of a related component or "systems manager"?

Or is there some more elegant way? (neither of these approaches seem elegant to me...)


texts: Selection of a mesh with arbitrary region

texts:
Considering example:

I have a mesh(es) on the OpenGL screen and would like to select a part of it (say for delete purpose). There is a clear way to do the selction via Ray Tracing, or via Selection provided by OpenGL itself.

But, for my users, considering that meshes can get wired surfaces, I need to implement a selection via a Arbitrary closed region, so all triangles that appears present inside that region has to be selected.

To be more clear, here is screen shot:

I want all triangles inside black polygon to be selected, identified, whatever in some way.

How can I achieve that ?


texts: How can I render some graphics using XNA to a widget/control in a WPF app? Specifically, I don't need any WPF controls inside the XNA graphics window, I just want to put some controls around it for a level editor.


texts: Do Google Play and the Apple App Store allow symbols such as square brackets app names?

texts:
For instance, if I wanted to call my game [GAME].

I tried searching for apps on both marketplaces using both symbols and didn't get any errors, although no apps were found with square brackets.

[Removed portion of the question on ( ) and !'s per Gnemlock's answer.  Part of the reason I'm asking is this is my very first app launch and I'm about to spend some money on Trademarks, so I really wanted validation from experienced developers since I'm a noob.]


texts:
I am using a physics library based on the Bullet physics engine. How do I create an egg shaped object or a cylinder where the width differs from the depth (i.e. with an oval shape)?

I'm not looking for code, but for a conceptual answer to help me understand this, or a useful approximation.


texts: What maths should I learn for game programming, and what aspect of programming does it relate to?

texts:
Possible Duplicate:
  What math should all game programmers know?

Obviously a good knowledge of maths is essential for good programming, my maths isn’t the best ( I didn’t pay attention in school all those years ago) so, in order to get one step closer to being the best I need some advice. What maths should I learn for specific areas of game programming?
If someone could outline some subjects and say one or two words about what areas of game programming they would be used in I’d greatly appreciate it. I’m working through the Khan academy programme at the moment, and I’m just getting into algebra now.


texts: Is it possible to apply a texture to a 2D-sprite in unity 2-d?

texts:
I want to take an (animated) 2-d sprite and apply a texture to it. Basically, I want every non-transparent pixel to be covered by the texture (color is disregarded). I understand I can probably accomplish this using masks but I am worried that may not be the most performant solution. I know you can put textures onto 3-d models, so I was wondering if there was a similar process for 2d sprites. Below I have a graphic demonstrating what I want.

What I have tried so far

I see there is an option to add a material to a sprite, so I tried creating various materials.

1. Default material

When I tried applying this material to my sprite, the sprite disappeared entirely. I suspect because this default material type only works on 3D objects

2. Sprite Material

I figured sprites probably expect sprite materials, so I tried creating one. However, there does not appear to be anywhere to upload an image to use as a texture. This appears to only be useful for adding tints to sprites.


texts: Game() parametters Content and Window are not pre initialized

texts:
I've been experiencing a really Strange problem since recently, Every variables of XNA Framework Game class seems not to be initialized before my extending Game1 class. Variables does not seem to be initialized before the point where they should be.
I do not plan to change the game engine, but I'll appreciate any help of any kind.
Thanks for your time
here is my Game1 class (a small part of it)
public class Game1 : Game
{
  public static GraphicsDeviceManager graphics;
  public static SpriteBatch spriteBatch;
  public static ContentManager ContentManager;
  public static SceneManager SceneManager { get; private set; }

  public Game1()
  {
    ContentManager = Content;

    graphics = new GraphicsDeviceManager(this);
    ContentManager.RootDirectory = "Content";

    // TODO: Add your initialization logic here
    /*
    GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height
    GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width
    */
    Window.IsBorderless = true;
    graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
    graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
    IsMouseVisible = true;

  }

    (...) //The code continues
}

and here is the errors:

the Null pointer error on the Window variable occures when i declare a new Content manager

Edit:
It seem that there is a conflict between System.RunTime.Serialization v4 and v2 in my project
1>  Impossible de résoudre le conflit entre "System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" et "System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes". Choix arbitraire de "System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".


texts: Extract a rotation matrix given a camera direction (vector) and a up vector for the camera?

texts:
I am having some issues constructing a rotation matrix from a camera direction vector.

The Up vector is computed from the camera direction as such:

up = cross(cross(direc,(0,1,0)),direc)

How do i given the up vector and a camera direction vector compute the rotation vector, that tells the camera how it should be rotated such that it points toward my object?


texts: I've been looking at creating some 2D rendering systems in D3D9, basically because I don't like ID3DXSprite. For the output of the vertex shader, what co-ordinate system does the run-time expect vertex co-ordinates in, like homogenous device co-ordinates? And secondly, does the depth of the resulting vertices have any effect except on the culling/depth buffering? I wanted to "reserve" a section of depth for use in 2D drawing, and then have a section for 3D geometry, to ensure that 3D geometry is always behind 2D.


texts:
I made the game space shooter and i want the space fire continuously (auto fire) without click the button. [ This are the code i always click on space bar and its fire but i want its fire continuously (auto fire). if (Input.GetKeyDown (KeyCode.Space) && isEnemyWeapon == false) { Fire (); } ] and i want only player fire continuously not enemy. In my case enemy also fire continuously like laser after taking some times..

Weapon.cs

using UnityEngine;
using System.Collections;

public class Weapon : MonoBehaviour {

    public Transform laserPrefab ;
    public bool isEnemyWeapon = false;
    public float shootDelay = 0.0f;
    private float waitToShoot;

    void Start () {
        waitToShoot = 0f;
    }

    void Update () {

        if (waitToShoot > 0) {
         waitToShoot = Time.deltaTime;

        }

    if (Input.GetKeyDown (KeyCode.Space) && isEnemyWeapon == false) {
          Fire ();
    }

        if (isEnemyWeapon == true && EnemyAttack == false) {
            waitToShoot = shootDelay;
            var shootLaser = Instantiate (laserPrefab) as Transform;
            Vector2 pos = shootLaser.transform.position;
            pos.x = transform.position.x ;
            pos.y = transform.position.y - 0.3f;
            shootLaser.transform.position = pos;
            SoundHelper.instanceSound.EnemyLaserSound();

        }
    }

    public void Fire()
    {
        var shootLaser = Instantiate(laserPrefab) as Transform;
        Vector2 pos = shootLaser.transform.position;
        pos.x = transform.position.x;
        pos.y = transform.position.y + 0.5f;
        shootLaser.transform.position = pos;
        SoundHelper.instanceSound.PlayerLaserSound();

    }

public bool EnemyAttack
    {
         get
        {
         return waitToShoot <= 0f;
        }
    }
}


texts: Basic 2D Lighting Optimization Issue in Fragment Shader with OpenGL (GLSL)

texts:
I'm using a fragment shader to implement 2D lighting (code further below). Even though I am satisfied with the visuals of the light i noticed that it has a quite big GPU usage, and when trying to add about 40+ light sources the usage is close to 100% (GTX 1050).
I have a uniform array of structs that contain data about each light source and for loop that goes through all of them.
At first I thought I was pushing too much data to the GPU so I combined the RGB values of the light color in a single 32 bit integer and the two strengths of the light in a single 32 bit integer as well. Then I tried simplifying the formulas I used (using a composed, by composed I'm not referring to the operation, function from multiple linear functions) but it seemed that just made the matters worse.
I think it's worth noting the difference between LightStrength and VisualStrength values that I used in the code, the LightStrength is the strength of the light that lights up the medium around it and the VisualStrength is the strength of the colored hue around the light. And there is also a dark hue variable that is used to make the scene darker as of in the different times of the day.
The code of the fragment shader:
#version 450 core

in vec2 texCoord0;
uniform vec3 CameraPosition;
uniform mat4 Projection;
uniform float DarkHue;

uniform sampler2D u_Texture;
uniform vec2 u_resolution;

struct LightSource {
    vec2 Position;
    int LightColor;
    int ArgumentValue;
};

uniform LightSource LightSources[300];
uniform int LightSourceCount;

float GetLightfactor(float x,float Streght) {
    return min(1/(x*(Streght/100.0)+1),1);
}

void main() {
    gl_FragColor = texture2D(u_Texture,texCoord0);

    vec3 LightSum = vec3(0);
    vec4 PCameraPosition = vec4(CameraPosition,0) * Projection;

    vec2 NormalizedPosition = gl_FragCoord.xy*2/u_resolution-1;

    float LightFactor,VisualFactor,LightStreght,VisualStreght;

    for (int i = 0;i < LightSourceCount;++i) {

        vec4 Pos = vec4(LightSources[i].Position,0,0) * Projection + PCameraPosition;

        vec2 coord = (NormalizedPosition-Pos.xy) * u_resolution;
        LightFactor = 0.0;
        VisualFactor = 0.0;

        LightStreght = LightSources[i].ArgumentValue & 0xffff;
        VisualStreght = (LightSources[i].ArgumentValue >> 16) & 0xffff;

        float lng = length(coord);

        LightFactor = GetLightfactor(lng,LightStreght);
        VisualFactor = GetLightfactor(lng,VisualStreght);

        LightSum = mix(LightSum,vec3(1),gl_FragColor.rgb * LightFactor * (1-DarkHue)) + vec3(((LightSources[i].LightColor >> 16)&0xff)/255.0,((LightSources[i].LightColor >> 8)&0xff)/255.0,(LightSources[i].LightColor&0xff)/255.0) * VisualFactor;

    }

    gl_FragColor.rgb *= DarkHue;
    gl_FragColor.rgb += LightSum;

}

The code of the c++ function that adds a light source. (Yes when setting uniforms caching is used)
static void AddLightSource(Vec2 Position, uint8_t R, uint8_t B, uint8_t G, uint16_t LightStrenght,uint16_t VisualStrenght) {
        std::string access = "LightSources[" + std::to_string(ActiveLightSources) + "]";
        int Value = (VisualStrenght << 16) | LightStrenght;
        int Color = (R << 16) | (G << 8) | B;
        Vec3 Translated = VertexArrayManager::TranslateValue;
        shader->setUniform2f(access + ".Position", glm::vec2(Position.x+Translated.x,Position.y + Translated.y));
        shader->setUniform1i(access + ".LightColor", Color);
        shader->setUniform1i(access + ".ArgumentValue", Value);
        ActiveLightSources++;
        shader->setUniform1i("LightSourceCount", ActiveLightSources);
}
```


texts: Parented hitboxes with attributes in .FBX

texts:
Here's a visual description.

In Maya, I want to:

have boxes parented to my model
have these boxs scale/translate/rotate with respect to each limb.
have them to carry attribute data that describes if they enabled, what state they are in, and a flag that states they are geometry that should not be drawn.
have all of the hitbox data defined in the FBX.

I want to store attribute data that changes while the animation plays, e.g. frames 1-8 have an attribute that states that the hitbox is "HITTABLE", and frames 9-19 have the attribute state "INVULNERABLE".

I want to keep all of the hitbox data: their position, scale, rotations, and their states within the FBX file so that no adjustments need to be made in code for them, and that they can be tweaked when the animation is tweaked.


texts: Implementing a multishot powerup for a top down shooter

texts:
I have a top down shooter wherein I generate a projectile on each mouse click at the player's position and translate it in a straight line until it reaches the edge of the screen.

I also have powerups that enhance the player's current weapon by giving a multishot for a certain time span. Here's my problem. I'm not sure of how to place the projectiles relative to the player so that they are offset to the "left" and the "right" instead of directly on the player's position.

In order words, I will need to:

Vector2 playerPosition = playerOne.Position;
Vector2 projectileOnePosition = playerPosition + offsetVector;
Vector2 projectileTwoPosition = playerPosition - offsetVector;

I'm having trouble calculating the offset vector because I need to take the current rotation of the player in to account as well.

TL;DR: How do I find a point relative to the player's current position taking rotation of the current player in to account? My theory is that it involves calculating a circle around the player with a specific radius that determines the distance away from the player and placing the points somewhere on that circle.

I can draw a picture if necessary. Right now I'm on my laptop so it isn't draw-friendly.


texts: How do I create a 2D tile map, and implement movement within it?

texts:
How do I create a 2D tile map that I can use? How do I get the world coordinates of it so I can move something to that tile?

I'm learning OpenGL, at the moment, but I'm having a lot of issues understanding how to create a 2D tile map. I have rendered tiles to the world, but I have no way of using them. For example, I'm trying to implement movement, where when clicking on a tile, I would move the player to that tile.

To elaborate, I want a tiles coordinates when I click near/on it, so I can use that position when implementing movement. Right now, I have no idea how to do that; I am able to get the windows 2D coordinates on click, but I don't know how to turn that into a useful way of finding the coordinates I want based on where my tile is in the world.


texts: How can i load a level in my gameengine wich is larger than 2GB? C#

texts:
i were asking myself how could i load a large Level? My gameengine is written in C# and is rendering with Direct3D11. I just have my class called "Scenery" and the class is able to store all objects in a level (sceneryObject) with their components and features. My engine loads the serialized scenery, but i know that the maximal size of a .net object is 2gb. So how could my Scenery class load bigger levels? The .Scenery class contains a List with all the objects, and the Assets are included within the sceneryClass.
Do you thinkthe Scenery class should not include the Assets, and they should be stored extern?

Maybe somebody have a suggestion :)

Best Regards and thanks in advance!


texts:
I'm making a 2d rpg with libgdx and java. I have an Inventory class with an Array of Items, and now I want to be able to equip items onto the player. Would it be more managable to do

have every item have an "equipped" boolean flag
have an "equipped" array in the player class
have individual equipped fields in player class, e.g.

  private Item equippedWeapon;
  private Item equippedArmor;
  public void equipWeapon(Item weapon){
   equippedWeapon = weapon; }

Or just another way completely? Thanks.


texts: How to update vertex buffer in DirectX 12

texts:
I would like to create cloth simulation. Which type of buffer should i use for vertices. I will need to update them on every frame. And how updates need to be done. I'm new to graphics programming, but still i'm mostly interesting in high level overview. If there is open-source project implementing it, reference to it would be of help.

For now i have only rigid body geometries. For this i create a resource with

    THROW_IF_FAILED(g_device->CreateCommittedResource(
        &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
        D3D12_HEAP_FLAG_NONE,
        &CD3DX12_RESOURCE_DESC::Buffer(byteSize),
        D3D12_RESOURCE_STATE_COPY_DEST,
        nullptr,
        IID_PPV_ARGS(buffer_.GetAddressOf())));

Then i update it with initial data using another upload buffer to initialize first buffer. Lastly i transition first buffer into D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER state.

Well, i got some comments directing me toward DirectX11, but for my purposes i will better use DirectX12, and again, i'm pretty matured programmer and just need a highlevel overview of what need to be done.

For example,

  create default buffer with geometry, then create upload heap, and when
  needed create placed resource buffer to upload data into your default
  buffer.

But here a lot of questions arise. For now i use frame resources e.g. for transforms to update them on each frame and do not stall CPU. But if i will copy once a frame to the same default buffer will my it cause stalling? And should i use different queue for copying, and how then do resource state transitioning?

From what i understood for now, i need to implement this, but how to implement CopyResource functionality?


texts: Find out what word you are hovering mouse over

texts:
I want to be able to pop up something when the user hovers over particular words that are on a label in pygame.

Can anyone give me a good (or even bad) idea on how to implement this (doesn't have to be pygame specific)? Do I have to put each word in a different label and place them one after the other?

(what I'm calling a label is the result of font.render)


texts: Incorrect frustum culling with center/half-size AABB

texts:
I'm trying to implement an axis-aligned bounding box with center/half-size instead of min/max. And I have some problems when it comes to create a method to detect if the aabb is visible or not.

I try to do the same as on this website at "Method 5": http://fgiesen.wordpress.com/2010/10/17/view-frustum-culling/. I'm trying to implement this formula:

  return dot3(center + extent * signFlip, plane) > -plane.w;

But it doesn't work at all and I don't find what's going wrong. Objects in my scene seems to appear and disappear in a strange way, sometimes appears when I'm not watching them or disappears when frustum faces them (I look at draw calls to determine if the isVisible test returns true or false).

Here is my code:

The Axis-aligned bounding box

public sealed class AxisAlignedBox
{
    public Vector3 Center;
    public Vector3 HalfSize;
}

The method in the frustum that tests if the aabb is visible or not:

public bool Intersects(AxisAlignedBox aabb)
    {
        Vector3 v;
        float d;

        Vector3.Multiply(ref aabb.HalfSize, ref _signPlane[0], out v);
        Vector3.Add(ref aabb.Center, ref v, out v);
        Vector3.Dot(ref v, ref _planes[0].Normal, out d);
        if (d > -_planes[0].D) return true;

        Vector3.Multiply(ref aabb.HalfSize, ref _signPlane[1], out v);
        Vector3.Add(ref aabb.Center, ref v, out v);
        Vector3.Dot(ref v, ref _planes[1].Normal, out d);
        if (d > -_planes[1].D) return true;

        Vector3.Multiply(ref aabb.HalfSize, ref _signPlane[2], out v);
        Vector3.Add(ref aabb.Center, ref v, out v);
        Vector3.Dot(ref v, ref _planes[2].Normal, out d);
        if (d > -_planes[2].D) return true;

        Vector3.Multiply(ref aabb.HalfSize, ref _signPlane[3], out v);
        Vector3.Add(ref aabb.Center, ref v, out v);
        Vector3.Dot(ref v, ref _planes[3].Normal, out d);
        if (d > -_planes[3].D) return true;

        Vector3.Multiply(ref aabb.HalfSize, ref _signPlane[4], out v);
        Vector3.Add(ref aabb.Center, ref v, out v);
        Vector3.Dot(ref v, ref _planes[4].Normal, out d);
        if (d > -_planes[4].D) return true;

        Vector3.Multiply(ref aabb.HalfSize, ref _signPlane[5], out v);
        Vector3.Add(ref aabb.Center, ref v, out v);
        Vector3.Dot(ref v, ref _planes[5].Normal, out d);
        if (d > -_planes[5].D) return true;

        return false;
    }

_signPlane is an array of Vector3 using the following formula and applied for each plane once per frame when the frustum is updated:

        public static void Sign(ref Vector3 v, out Vector3 result)
    {
        result.X = Math.Sign(v.X);
        result.Y = Math.Sign(v.Y);
        result.Z = Math.Sign(v.Z);
    }


texts:
I've just recently started working with LibGDX and Ashley, and I find it to be really useful and I like working with the whole entity/component/system workflow. But I've been starting to layout the GUI and other aspects of the interface that dont exactly, to me, seem like they should be entities.

When using an ECS should EVERYTHING in your game be an entity with components/a system to control them?


texts: Vertex buffers - interleaved or separate?

texts:
Interleaved - all vertex data (position, normal, texcoord...) kept in 1 vertex buffer, separate - each vertex attribute is kept in a separate vertex buffer (1 for positions, 1 for normals...).

I know this question came up many times and I also know there's no 1 right answer (sadly). But I'd like to try to list the main advantages/disadvantages of both. Or maybe you have some general rules of thumb for when to use each.

Advantages of interleaved:

faster? (all data for 1 vertex is fetched at once? sth about cache working better)?
less API calls (for creating and setting buffers but that's probably a very small difference)

Advantages of separate:

when different shaders need different vertex attributes (e.g. one shader needs only position and another needs position, normal and texcoord) it's possible to provide each shader only the data it needs and there's no data duplication
when updating only e.g. position of vertices it's not necessary to resend the other attribute data (e.g. normals and texcoords)

If you see any other differences please write. From the above it generally looks like a struggle between memory and performance optimisation. But maybe I'm wrong? Maybe one is better/worse in most cases?

Edit:
One more concern, actually - with interleaved buffers I could end up sending unnecessary data to GPU and the data bandwidth is a big bottleneck in today's cards. Should I worry about that?


texts: Procedurally generating non tile based top down 2d game worlds

texts:
I’ve been fascinated by procedural generation for over two years now. I have played around with many types of noise generation and even wrote some myself. I’ve been looking into water erosion and procedurally generated biomes and during this time I’ve managed to build some nifty little map generators. Something that has always escaped me, however was generating a procedural map that is not “tile based”. So far, all the procedural map generators I have built relied on one axiom - the map is represented as a 2d matrix containing some sort of information about the terrain that is to be found there. This means that I, by definition, can’t build anything that is not tile based.

And this is why I come here asking for your help. I am curious about how one could render a procedurally generated map in a non tile-based fashion. My end result is the image I posted.

The solution that immediately jumped to my mind is drawing each end every pixel individually, thus making the map look essentially non tile based. This, however would require enormous memory and is unfeasible.

So I am turning to the masters - how can I procedurally generate (and more importantly render) such a map? How would I go about representing the sprites to be drawn? Where do I even get started? This feat is so much out of my grasp that I do not even understand where I should be looking

Note - I know about marching squares and wang tiles. These approaches are however not something I’m fond of because of the huge workload that would go into drawing the resources. I am looking for something more in the realm of algorithms

Thank you!


texts:
I am developing a strategy-game AI (think: Final Fantasy Tactics), and I am having trouble coming up for the design of the AI. My main problem is determining which is the optimal thing for it to do.

First let me describe the priority of what action I would like the AI to take:

Kill nearest player unit
Fulfill primary directive (kill all player units, kill target unit, survive for x turns)
Heal ally unit / cast buffer

Now the AI can do the following in its turn:

Move -> {Attack / Ability / Item}  (either attack or ability or item)
{Attack / Ability / Item} -> Move
Move closer (if targets not in range)
{Attack / Ability / Item} (if move not available)

Notes

Abilities have various ranges / effects / costs / effects.
Each ai unit has maybe 5-10 abilities to choose from.
The AI will prioritize killing over safety unless its directive is to survive for x turns. It also doesn't care about ability cost much. While a player may want to save a big spell for later, the AI will most likely use it asap.

Movement is on a (hex) grid

num of player units: 3-6

num of ai units: 3-7 or more. Probably max 10.

AI and player take turns controlling ONE unit, instead of all at the same time.

Platform is Android (if program doesnt respond after some time, there will be a popup saying to Force Quit or Wait - which looks really bad!).

Now comes the questions:

The best ability to use would obviously be the one that hits the most targets for the most damage. But since each ability has different ranges, I won't know if they are in range without exploring each possible place I can move to.
One solution would be to go through each possible places to move to, determine the optimal attack at that location - which gives me a list of optimal moves for each location. Then choose the optimal out of the list and execute it. But this will take a lot of CPU time. Is there a better solution?
My current idea is to move as close as possible towards the closest, largest group of people, and determine the optimal attack/ability from there. I think this would be a lot less work for the CPU and still allow for wide-range attacks. Its sub-optimal but the AI will still seem 'smart'.

Other notes/questions:

Am I over-thinking/over-complicating it? Better solution? I am open to all sorts of suggestions
I have taken a look at the spell-casting question, but it doesn't take into account the movement - so perhaps use that algo for each possible move location? The top answer mentioned it wasn't great for area-of-effect and group fights - so maybe requires more tweaking?
Please, if you mention a graph/tree, let me know basically how to use it. E.g. Node means ability, level corresponds to damage, then search for the deepest node.


texts: Why models that are far from camera not rendered correct in unity?

texts: I am making a roguelike in unity and i came across a problem where models are far from the center of camera rendered weird like upper right enemy. I have added screnshot there are also camera settings. I tried changing field of view but it did not work. Does anyone know which option causes that distortion?


texts:
In the last couple of days I'm experimenting a lot with Unity 3D to get a feeling about the environment and the behavior of game development. I come from a programming perspective and try to develop as much as possible in Unity 3D.

I created a base controller which creates a 10x10 surfaces area on start. Each part is based on a prefab plane (scale: 0.1, 0.1, 0.1) with an appended box collider. On this surface area I'm moving an object with the AddForce method. So far everything works fine.

However, if my moving object reach the edge of a surface area part (prefab plane) it breaks and I am not able to move the object directly over the edges. Sometimes it stops completely. If I use a bigger prefab plane I'm able to move my object smooth on that part, but it also stops at the edges.

Do you have an idea, why the cube stops at the edges?

  Edit

I think this behavior occur because the cube hit a new collider surface. My currently fix calculate an overlaying BoxCollider over all surface elements. With this implementation there are no collider edges.

Is this an acceptable implementation?

public class Surface : MonoBehaviour {

    private static readonly GameObject GameObject1 = new GameObject("Surface");

    private static readonly GameObject GameObject2 = (GameObject) Resources.Load("Ground");

    private static readonly BoxCollider BoxCollider = GameObject1.AddComponent<BoxCollider> ();

    private GameObject obj;

    public void Draw() {
        this.obj = Instantiate (Surface.GameObject2, new Vector3 (this.X, this.Y, this.Z), Quaternion.identity) as GameObject;
        this.Add ();
    }

    private void Add() {
        this.obj.transform.parent = Surface.GameObject1.transform;

        Surface.BoxCollider.size = new Vector3 (this.X, this.Y, this.Z);
    }

    public static Surface Create(int x, int z) {
        var surface = Surface.GameObject1.AddComponent<Surface>();
        surface.x = x;
        surface.y = 0;
        surface.z = z;

        return surface;
    }
}

The single surfaces are created with a simple loop.

private static readonly Surface[] Surfaces = new Surface[Width * Height];

for (var z = 0; z < Width; z++) {
    for (var x = 0; x < Height; x++) {
        Surfaces[x + z] = Surface.Create(x, z);
        Surfaces[x + z].Draw();
    }
}


texts: Calculating the intersection of a fast moving circle and a line

texts:
Inside of my game, I am in need of a way to test the collision between a line segment and a fast-moving circle. I would say I need a line v capsule collision however the problem is I need the collision point. None of the existing formulas I can find can do quite what I need. I have tried line x line intersection and just moving the lines by the radius of the capsule sort of work however then the collision point found around the edges is off. Additionally, I can't find a way to work back from the collision point to the point that the circle first collided at.

Above is sort of a picture of what I am hoping to achieve. The green capsule represents the circle's path.

So really the problem here is finding that collision point because a yes or no answer is trivial here. There are formulas for ray capsule or box capsule however none of them will get me this collision point.

Does anyone have any ideas on how I can figure this out?


texts: Where does the Framework (XNA) end and the API (DX) begin?

texts:
I have read a lot of interesting questions asking about XNA vs. OpenTK vs. SlimDX vs. OpenGL vs. DX, and while it is really useful to get others general impressions from 100s of hours using these various APIs/Frameworks, I haven't seen any answer which clearly defines what the scope of each is.

It's understood what the difference between an API, Engine and Framework is in theory, but for someone who has limited experience with graphics systems, its harder to see what on the practical side falls into each category. (Not made easier by all the overlap! e.g. XNA implementing a content pipeline as an integral part)

Take for example face culling - XNA 'does' this in the background without the programmer needing to think about it, but where does it happen? Is there a 'cull face' function in DX that must be called, or perhaps above in XNA? Or does the GPU or its driver do it?

I read in the documentation for one of the managed projects (annoyingly I can't remember which) about how difficult it was to implement efficient rendering code, and how that project abstracted it. This unnerved me a bit, and made me wonder just what XNA is doing beneath DrawIndexedPrimitives that would have to be done manually should the framework be left for something more flexible.

What does XNA do in the background, when rendering that cube, that a managed API would not?


texts: Use a different target framework version in a unity c# project, other than 4.6

texts:
I'm using a dll in my project which is built against a higher target framework (4.6.1 actually)

I can't build or attach to Unity because of this. Visual Studio shows this error:

The primary reference "MQTTnet" could not be resolved because it was built against the ".NETFramework,Version=v4.6.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".

The only option in player settings in Unity for API compatibility level is .NET 4.6

how can I change that to 4.6.1 in order to be able to build or attach to Unity?


texts: Unity Gyroscope orientation (attitude) "wrong"

texts:
I am using the Unity reference and example implementation here https://docs.unity3d.com/ScriptReference/Gyroscope.html

I struggle to fix an orientation problem. When my phone lies flat on the ground, screen facing upwards, unity thinks I am looking as if I'd take a photo of a landscape. When I actually hold the phone as if I'd take a landscape photo, the screen shows me the sky. Rotating then shows me an arc from sky to my left or right side.

What I want is: Holding the phone as if I'd take a landscape picture should do the same in Unity.

Here is a short video where the phone lies flat and then I pick it up and look left and right on a chair.

and this is the codesnipped responsible:

protected void Update()
{
    GyroModifyCamera();
}

void GyroModifyCamera()
{
    transform.rotation = GyroToUnity(Input.gyro.attitude);
}

// The Gyroscope is right-handed.  Unity is left handed.
// Make the necessary change to the camera.
private static Quaternion GyroToUnity(Quaternion q)
{
    return new Quaternion(q.x, q.y, -q.z, -q.w);
}


texts:
I have a camera that works with Pitch and Yaw (no roll) and compute the look at matrix as following :

glm::vec3 direction;
direction.x = cos(glm::radians(pitch)) * cos(glm::radians(yaw));
direction.y = sin(glm::radians(pitch));
direction.z = cos(glm::radians(pitch)) * sin(glm::radians(yaw));
direction   = glm::normalize(direction);
this->view =
  glm::lookAt(position, position + direction, glm::vec3(0, 1, 0));

Now I want to initialize these Pitch and Yaw from another View Matrix and used this method but without success:

  /* previousCamera->view as a glm::mat4 */
  position = glm::vec3(previousCamera->view[3]);
  const glm::vec3 direction = glm::vec3(previousCamera->view[2]);
  yaw   = glm::degrees(glm::atan(direction.x, direction.z));
  pitch = glm::degrees(glm::asin(direction.y));

Do you spot any mistake in my code?

Edit:

In addition to the answer from @DMGregory, my position and direction were not correctly extracted from the ViewMatrix:

  const glm::mat4 inverted = glm::inverse(previousCamera->view);
  position = glm::vec3(inverted[3]);
  const glm::vec3 direction = - glm::vec3(inverted[2]);
  yaw   = glm::degrees(glm::atan(direction.z, direction.x));
  pitch = glm::degrees(glm::asin(direction.y));


texts: How can I implement a more realistic momentum system in Unity 4.5?

texts:
I'm just starting out with Unity and am making a simple environment where there is a sphere and a ramp.  When the sphere approaches the ramp everything is fine.  As soon as the sphere hits the ramp is where I'm having trouble; the velocity is instantly reduced and when it goes off the end of the ramp, instantly returns to the velocity as though it were on the ground.

I'm not sure if this can be changed by some settings in Unity or I would have to write some code.

Here's the physics code I have so far (in C#):

public class PlayerController : MonoBehaviour {
    public float speed;

    void FixedUpdate(){
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");

        Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

        rigidbody.AddForce(movement * speed * Time.deltaTime);
    }
}


texts:
On a tile based strategy game I'm working on the player may select an area in which a room is placed. To do so the player selects the tiles. Either by clicking on each individual tile or dragging from one point to another. An algorithm kicks in and decides how and where the pre-made tiles should be placed. My concern is getting this algorithm working for more complex shapes than a single rectangle.

My first approach was to check whether or not the tiles around each selected tile is selected. Using this "signature" the algorithm chooses what tile matches that description and places it accordingly. With this setup I would need 7 models:

floor tile
tile with single wall & floor
tile with two walls (placed opposite of eachother) & floor
tile with three walls & floor
tile with four walls & floor
corner tile & floor
"cap" for inverted corners (as shown in blue below)

This seems like a viable option without too much work for the modellers. I have however had some problems recognising the tiles where an cap should be placed. And for situations as shown on the right-hand room would require a near endless combination of caps and walls.

A solution to discard the caps would be to make walls with a 45 degree cut on the end. This way there would be a lot more flexibility in placing the tiles and it would allow for special cases found in T-junctions. I believe the current pattern recognition algorithm would not suffice here. In order for it to work I think each tile had to check what kind of tile is around it, not only whether or not it's selected. I fear that this option would require too much computing power as the surrounding tiles may change recursively.

Now, the question is what option should I go for? One of the two proposed, or an third option?

Any help, tip or solution is greatly appreciated.


texts: Matrix represents same rotation with different euler angles

texts:
I have Transform component storing it's rotation as Quaternion.
Transform has set/getEulerAngles (rotation order oy, ox, oz).
I want to rotate object in any direction but while testing I get jumping(glitch) objects stop rotating at specific angles.

Euler angles in problem frames:

1) oy  0  ox  -90 oz  0  - previous frame.

2) oy 180 ox  -90 oz 180 - next frame after incrementing angle of the object.

my increment looks like:

tr->setEulerAngles(tr->eulerAngles()+Vector3(5,0,0));//rotate around ox by 5 degrees

visually this rotations are equal, but when I get angles 2) from quaternion and increment them it starts rotating in oposite direction, next frame rotation is again as 1), so there is infinite loop at this rotation (some kind of black hole;-)).
What can it be? Something wrong with math?


texts:
I was wondering if it was possible to create a light source in Unity, one that "sucks" light from the environment.

Negative value does not seem to work in Unity, as pointed out by many.

It is quite surprising that there is nothing that I could find that has information on this topic. All year old posts that mentioned this contained only dead links.


texts: Mobile Multiplayer games and coping with high latency

texts:
I'm currently researching regarding a design for an online (realtime) mobile multiplayer game.

As such, i'm taking into consideration that latencies (lag) is going to be high (perhaps higher than PC/consoles).

I'd like to know if there are ways to overcome this or minimize the issues of high latency?

The model i'll be using is peer-to-peer (using Photon cloud to broadcast messages to all other players).

How do i deal with a scenario where a message about a local object's state at time t will only get to other players at *t + HUGE_LAG* ?


texts: How to get which gameobject the mouse is over in Unity?

texts:
So I'm working on a simple drag-n-drop based trading card game for my own amusement.

There is a card inspector included.

What I want to achieve is to change values in the inspector (which has its own Inspector.cs, so I would change the variables in it) based on which card I hover over with my mouse.

Each card has its own Card.cs attached from which I want to read the values of the current card.

If I try to do this from within the Inspector.cs by something like this: Name.text = gameobject.GetComponent<Card>().Name;, then obviously it won't work, because using gameobject in the current context is not valid.

So solution No1 would be to properly reference the gameobject over which the mouse is, which I don't know how to do.

When I try to do the same from within Card.cs, I cannot use an event trigger OnPointerEnter and run the code through that, because I have to have a reference to the gameobject that contains that function. ( And I cannot do that in a prefab, only in gameobject already existing in the level.)

So could anyone tell me how I could achieve what I want, please?


texts: Unity error "must have a body because it is not marked abstract, extern, or partial"

texts:
I'm trying to setup a system where I pickup an object drop it into a zone, and then the object is destroyed.

So far I have:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class TriggerZone2 : MonoBehaviour {
    public Text MyText;
    private int score;
    public bool CompareTag(string Player);

    // Use this for initialization
    void Start () {
        MyText.text = "";
    }

    // Update is called once per frame
    void Update () {
        MyText.text = "$" + score;
    }

    void OnTriggerEnter(Collider coll) {
        score = score + 1;

        if (other.CompareTag ("Player")) {
            Destroy (other.gameObject);
        }
    }
}

Everything works up until I try to destroy the game object. The console keeps saying

  Assets/Scripts/TriggerZone2.cs(11,21): error CS0501: `TriggerZone2.CompareTag(string)' must have a body because it is not marked abstract, extern, or partial.

I've looked up quite a few threads, but I'm still not sure what it wants me to do with it. How do I fix this?


texts: toString() - method doesnt' choose right Array Index

texts:
My topic is a adventure game. The heroes have Superpowers, but if I want to print the superpowers from a superhero, it prints just the last index of my array, which I set it before.

My code: `

public void createdTeam() {
    Superhero krieger = new Superhero("Thylraz");
    Superpower[] kriegerPowers = { new Superpower("Schwertwirbel\n", " Thylraz wirbelt mit seinem Schwert."),
            new Superpower("Schildschlag\n", " Thylraz schlägt den Zombie mit dem Schwert."),
            new Superpower("Durchschlag\n", " Thylraz macht einen Durchschlag!") };
    krieger.setSuperpowers(kriegerPowers);
    krieger.setHeroRole("Krieger");
    team.add(0, krieger);
    Superhero archer = new Superhero("Artemis");
    Superpower[] archerPowers = {
            new Superpower("gezielter Schuss", " Artemis versucht einen gezielten Schuss zu treffen."),
            new Superpower("Pfeilregen", " Artemis lässt Pfeile über den Zombie regnen!"),
            new Superpower("Falkenschlag", " Artemis ruft nach ihrer Falke!") };
    archer.setSuperpowers(archerPowers);
    archer.setHeroRole("Bogenschützin");
    team.add(1, archer);
    Superhero berserk = new Superhero("Adukan");
    Superpower[] berserkPowers = {
            new Superpower(" Elektroschlag", " Adukan lädt seine Äxte mit Elektrizität auf und schlägt zu!"),
            new Superpower(" Blutrausch",
                    " Adukan geriet in Blutrausch! Er haut auf sein Gegner mit voller Aggro!"),
            new Superpower(" Blutiger Schlag", " Adukan versucht einen tödlichen Schlag zu treffen!") };
    berserk.setSuperpowers(berserkPowers);
    berserk.setHeroRole("Berserker");
    team.add(2, berserk);
}

and my print method:

public void printOneSuperhero() {
    System.out.println("\nVon welchem Superhelden möchtest du die Daten sehen?\n");
    int index = selectSuperhero();
    System.out.println("=====================================================================================");
    System.out.println("Heldenname\tHeldenrolle\tHP-Max\tHP\tEXP\tKampfbereit\tlebendig\tFähigkeiten");
    System.out.println("=====================================================================================");
    System.out.println(team.get(index).toString());
    startMenu();
}

public class Superpower {
private String id = UUID.randomUUID().toString();
private static String superpowerName;
private static String actionDescription;

public Superpower(String superpowerName, String actionDescription) {
    this.superpowerName = superpowerName;
    this.actionDescription = actionDescription;
}
public String toString() {
         return "Skill: " + superpowerName + "\n" + "Beschreibung: " + actionDescription + "\n";

}

}

Edit:

public int selectSuperhero() {
int index = 0;
for (int i = 0; i < team.size();) {
    System.out.println("Position: " + (i++) + "" + team.get(index).print());
    index++;
}
index = scan.nextInt();
return index;

}


texts: How to make a sprite above my character appear on the minimap attached to the floor?

texts:
I have a project where I made 2 minimaps.

One of minimaps is linked to the character of my project and the other to the floor:

As I already said in the title of the question, my character has a sprite above the head (red arrow) that appears on the minimap attached to it, but does not appear on the minimap attached to the floor.

Image:

I looked at the rendering options and many others, but I could not get the sprite to show up. How do I get the sprite to appear on the floor minimap?

EDIT 1 (Showing how I made the minimap)

I used a SpringArm:

And a SceneCaptureComponent2D:

The PaperSprite is not the children of the SpringArm and stands a little below the SceneCaptureComponent2D:

The minimap is made from a RenderTarget. From this RenderTarget a material is created:

Widget Blueprint:


texts: Drawing two orthogonal strings in 3d space in Android Canvas?

texts:
I want to draw two strings in canvas. The first string must be rotated around the Y axis, for example 45 degrees. The second string must start at the end of the first string and also it must be orthogonal to it.

This is my code:

String text = "In the";
float textWidth = redPaint.measureText(text);

Matrix m0 = new Matrix();
Matrix m1 = new Matrix();
Matrix m2 = new Matrix();
mCamera = new Camera();
canvas.setMatrix(null);
canvas.save();

mCamera.rotateY(45);
mCamera.getMatrix(m0);
m0.preTranslate(-100, -100);
m0.postTranslate(100, 100);
canvas.setMatrix(m0);
canvas.drawText(text, 100, 100, redPaint);

mCamera = new Camera();
mCamera.rotateY(90);
mCamera.getMatrix(m1);
m1.preTranslate(-textWidth - 100, -100);
m1.postTranslate(textWidth + 100, 100);

m2.setConcat(m1, m0);
canvas.setMatrix(m2);
canvas.drawText(text, 100 + textWidth, 100, greenPaint);

But in result, only the first string (drawn red) is visible.

How can I draw two orthogonal strings in 3D space?


texts:
We are trying to determine the distance (a scalar, double) between two objects' surfaces in Bullet. We are new to the Bullet engine, and we've been looking into the demo projects, but couldn't find any good examples.

The closest we have come to implementing this is using the following:

btManifoldPoint& pt = contactManifold->getContactPoint(j);
double dist = pt.getDistance();

But where do we get the contactManifold object? (We're not even sure this is the right approach.)

We want to calculate distance when a key is pressed, so this is done in the specialKeyboard() function, a function in the Bullet demo framework.

Can anyone provide us with a clear, simple example?


texts: Isometric tile picking algorithm not working

texts:
Starting to gamedev again and Trying an isometric game. However, all I try, I can't seem to figure out tile picking properly.. Using SFML

Here's how I'm detecting the clicks and moving around a sf::View. Sprites are 64*32

#include "GameWorld.h"
#include <math.h>
GameWorld::GameWorld()
{
    this->camX = 0;
    this->camY = 0;
    this->factories.push_back(new Factory("Factory 1"));
}

void GameWorld::draw(sf::RenderWindow * win, ContentManager* contentManager) {
this->factories.at(this->activeFactory)->render(win,contentManager, this->camX, this->camY);
}

void GameWorld::update(float delta, sf::RenderWindow* win) {
    float speed= 128;
    sf::View view = win->getView();

if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
{
    this->camY -= speed*delta;

}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::A))
{
    this->camX -= speed*delta;

}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::S))
{
    this->camY += speed*delta;

}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::D))
{
    this->camX += speed*delta;
}
view.setCenter(this->camX,this->camY);

win->setView(view);

if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {

sf::Vector2i selectedTile;
int x = sf::Mouse::getPosition(*win).x - this->camX;
int y = sf::Mouse::getPosition(*win).y - this->camY;
selectedTile.x = (y + x/2)/32;
selectedTile.y = (y - x/2)/32;

        printf("%d %d %d %d\n",sf::Mouse::getPosition(*win).x,sf::Mouse::getPosition(*win).y, selectedTile.x,selectedTile.y);
   }

}

The map is a 2d vector, which gets drawn like so

float screenX = (indexX - indexY) * this->sprite->getGlobalBounds().width/2;
float screenY = (indexX + indexY) * this->sprite->getGlobalBounds().height/2;

this->sprite->setPosition(sf::Vector2f(screenX,screenY));

win->draw(*this->sprite);

Here's what this currently prints out: When the game is loaded initially - clicking the first tile rendered (0,0) outputs 21 0 as the computed coords. As you can see, the X value is completely off, and the Y value goes off aswell as soon as I move the view in any direction. How could I get this picker to work properly?


texts:
I'm making a game in Game Maker that involves the player leaving a trail of debris behind them. This trail is permanent and has gameplay implications (for which I'm using a fairly coarse grid to store the player's movements), so I need to draw it on the screen. I'm comfortable with GML.

I have a sprite (with subimages) that represents the debris left behind. I'm not sure of the best way to go about it. Surfaces perform well and are straightforward to my mind - I draw the trail to the surface, then the room draws the surface between my objects and the background - but my rooms are more than a screen, and surfaces seem intended more as an image buffer than as a large background. A background resource I edit as I go would probably be better, but this doesn't appear to be an appropriate use of backgrounds.

Is there another approach that would work better? One consideration is that I need to be able to store the trail at checkpoints so that it's not destroyed if the player dies.


texts: How to implement the seek steering behavior in Unity3d?

texts:
Following this tutorial: Understanding Steering Behaviors: Seek, I tried to add seek and steering behavior to my Unity prototype but it's not working this is my script. The cube does not steer it just follows the target.

public GameObject target;

    float maxForce = 15;
    float maxSpeed = 30;
    float maxVelocity = 200;
    float mass = 15;

    Vector3 velocity;

    void Start() {
        velocity = Vector3.zero;
    }

    void Update() {
        transform.LookAt(target.transform);

        var desiredVelocity = target.transform.position - transform.position;
        desiredVelocity = desiredVelocity.normalized * maxVelocity * Time.deltaTime;

        var steering = desiredVelocity - velocity;
        steering = Vector3.ClampMagnitude(steering, maxForce);
        steering = steering / mass;

        velocity = Vector3.ClampMagnitude(velocity + steering, maxSpeed);
        transform.position += velocity * Time.deltaTime;

    }

What could be the problem??


texts: Synchronize running code over the network Unity

texts:
I want my code to run/perform the same on different Unity clients. I don't know if this is hard to achieve.
Here hare my problems:

The enemies movement:
I have a pathfinding that should always give the same results on server and on clients. Because I use the same pathfinding algorithm on server and client, and the position the algorithm chooses is synchronized with a network transform. But it does not give the same results on client and on server.

Bullets make enemies die over all clients:
I have a script with OnTriggerEnter2D(Collider2D collision) that never gets called at the same moment on clients and server. The clients might miss touching a bullet on an enemy on server but not on a client. So in server enemies died and on client they have not. How to synchronize OnTriggerEnter2D() ?

I will update the question to improve it with more examples when I find them.


texts: How to rotate an object around its own roll axis

texts:
I have a 2-dimensional image of smiley face in a 3-dimensional space.
I want it to rotate like a fan, so the smiley would look as if it's rolling like a wheel in place. Since the smiley is placed in a 3D space it can face any direction, but I always want it to rotate around like a wheel.

I use Minecraft so the Z and Y have the opposite jobs. (Y is the height).

I use these 3 functions for rotating around the x, y and z axis.

public static final Vector rotateAroundAxisX(Vector v, double angle) {
    double y, z, cos, sin;
    cos = Math.cos(angle);
    sin = Math.sin(angle);
    y = v.getY() * cos - v.getZ() * sin;
    z = v.getY() * sin + v.getZ() * cos;
    return v.setY(y).setZ(z);
}

public static final Vector rotateAroundAxisY(Vector v, double angle) {
    double x, z, cos, sin;
    cos = Math.cos(angle);
    sin = Math.sin(angle);
    x = v.getX() * cos + v.getZ() * sin;
    z = v.getX() * -sin + v.getZ() * cos;
    return v.setX(x).setZ(z);
}

public static final Vector rotateAroundAxisZ(Vector v, double angle) {
    double x, y, cos, sin;
    cos = Math.cos(angle);
    sin = Math.sin(angle);
    x = v.getX() * cos - v.getY() * sin;
    y = v.getX() * sin + v.getY() * cos;
    return v.setX(x).setY(y);
}

Sometimes I spawn the smiley facing the negative/positive X direction so to make it look like a wheel I have to rotate it around the X axis. But sometimes I spawn the smiley facing the negative/positive Z direction so I have to rotate it around the Z axis.

I searched online and found a term for an object's axes, and the one I was looking for is called "Roll".

Is there any way to rotate this smiley like a wheel regardless of where it's facing? a.k.a rotate it around its own "roll axis"?


texts: How to hide a MMORPG backend server from the internet?

texts:
I want to create a network where the main servers IP is never exposed to the client. By going throught tunnels.

Here is a sample:
http://dl.dropbox.com/u/12304631/eliteots/mc/network.jpg

Problem

By making tunnels through dedicated servers I hope to solve latency issues from some clients that are far away from the main server.
But even if this does not succeed, I wish to hide my main server to avoid network attacks directly against it. So the main server only communicates with the tunnel hosts, which then communicates with the clients.

So by creating several tunnels I will be able to let customers easily access the main server by switching tunnel if their preferred tunnel is currently under attack. This is not my problem, should be easy to program, however the network configurations between tunnel and main server is the issue because of my lack of experience in this area.

Requirements

I am not talking about a simple http proxy, I want this to solution to operate on all ports. Or at least the configured ports. Only transmitting TCP.
I do not wish any encryption on the traffic between the vpn and main server, I think it should be as fast as possible.
I am working on an MMORPG, which is why I put so much effort into learning this. The worst thing that can happen to a customer is to be kicked from game server unable to login to finish their needs.
I only operate in an linux environment server-based. (Debian/Ubuntu).

Solution idea

I heard having an openVPN server might be what I need.

But I have problems operating it, I find it quite complex. First off, I want to know, is this even possible in OpenVPN? If so, how should I configure the network logics?

I am open to try out any free solutions you may find/recommend me!


texts: Using ShaderGraph for UI elements with transparency

texts:
I am trying to design some UI elements using shader graph. In this case specifically a lifebar that is transparent where empty.

For a normal lifebar with a filled and empty color I got it working without much issue. I created my shader using an unlit model, and set it to a material. I set the material on a raw image, and then added it to a canvas.

Now I want to create a lifebar with transparency. It i make the shader transparent, I just get a black box. If i make it opaque i can see the shader, but the transparent (alpha blended) sections of the image are just black. I cannot find any settings to fix this. She shader looks fine outside of UI with the transparency working.

Is there a way to make raw images on a shadergraph shader support transparency even if it is just yes/no per pixel transparency?
Is a raw image the correct way to use a shader on UI?


texts: What is the name for the kind of game of jumping dinosaur from Chrome's 404 page?

texts: Basically, I want to know the name so I can find if anyone already built a clone game with PhaserJS like the one of jumping dinosaur from Chrome's 404 page.


texts:
I saw this game Clay Jam, that the user can create a path in the sand. The path is a continuous one, and it can varies from a single point to curves.

How one can develop smooth and continuous paths?


texts:
I use Unity and Photon for the multiplayer. I Instantiate my gameObjects using this method :

void LoadGameObject(PhotonPlayer player,bool isMaster)
 {
  if (isMaster)
  {
    GameObject baby = PhotonNetwork.InstantiateSceneObject(babies[0].name,
    babies[0].transform.position, Quaternion.identity, 0,null);
    baby.SetActive(true);
    Debug.Log("playerpref created on " + player.ID);
  }
  else
  {
   //Nothing for the moment
  }
}

I call the method in "OnJoinedRoom()" and "OnPhotonPlayerConnected(PhotonPlayer other)", but when the second player join the room, he can't see the gameObjects because they aren't activated on his scene.

Any Idea of the mistake ?


texts: Control the Transform component of an object while the animation is playing

texts: It seems the the animation controls the Transform component of the gameobject, hence making it not possible to control the transform properties while the animation is playing. Is there any way to control the Transform component of an object while the animation is playing, like rotating it for example?


texts: Remove Sprite Shape Controller Icons from 2D sprite shapes

texts: How do I get rid of those "purple icons in my scene"? They are so annoying ... they literally covers the entire 2d shape! GIF showcasing it