texts: Numerical differentiation to calculate size of circular buffer

texts:
I'm using Allegro 5 to create a software-generated "motion blur" effect for my 2D sprites. I basically just have a boost::circular_buffer of some length which holds "snapshots" of the sprite going back in time. Each render cycle a new "snapshot" of the main sprite is pushed onto the front of the buffer, and the last is popped off the back. The "snapshots" are then rendered with alpha values scaled by how old/far back in the buffer they are.

To save on CPU power I'd like to have the circular buffer dynamically resized so that the length of the trail is proportional to the object's velocity, i.e. don't store and push back lots of snapshots for trail sprites that won't be needed anyway because the object is moving too slowly.

The inputs I have to the data structure that holds the main sprite and its associated effect buffer are just the dx and dy values of how much its position vector changed since the last update cycle of the game logic. So I'm looking for a suggestion for an algorithm that can use that to increment/decrement some kind of unsigned counter that can be used to resize the buffer proportional to velocity.


texts: Unity: How can I find the center position of a particular triangle?

texts: I need to face an object from a central point directly through any one of many triangles which are faces on an icosphere whose position is centered on that point. Is there a way to get the center position of the triangle itself, even though its position is the position of the larger object of which it is a part?


texts: Box2d: High screen resolution / frequency causes high friction?

texts:
I'm using Cocos Creator with (built-in) box2d for physics.
Recently our game behaves weirdly on our new device Galaxy S20 Ultra 5G - which has screen size = 1440 x 3200 - frequency = 120Hz.
After stop pushing, all our physical bodies almost stop immediately like they has very high friction. No other device react that way.
Anyone experienced this issue can give me an advice?


texts:
This was originally posted as a follow-up comment to https://stackoverflow.com/questions/30714357/guitext-in-unity-5-need-an-alternative , but I'm asking it here as a dedicated question as per the community's recommendation.

What I'm trying to do: display GUI Text on screen as a countdown timer that counts down in real time

What I've done so far:

watched YouTube tutorial:  "Unity Scripting Tutorial 7 - A Countdown Timer" by VR Enthusiast.1
GameObject --> UI --> Text --> renamed: TimerText
Wrote the Timer script in C#

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

 public class Timer : MonoBehaviour

public float seconds = 59;
public float minutes = 0;

void Update() {

    if (seconds <= 0) {

        seconds = 59;
        if (minutes > 1) {

            minutes--;

        } else {

            minutes = 0;
            seconds = 0;
            GameObject.GetComponent<GUIText>().text = minutes.ToString("f0") + ":0" + seconds.ToString("f0");

        }

    } else {

        seconds -= Time.deltaTime;

    }

    if(Mathf.Round(seconds) <= 9) {

        GameObject.GetComponent<GUIText>().text = minutes.ToString("f0") + ":0" + seconds.ToString("f0");

    } else {

        GameObject.GetComponent<GUIText>().text = minutes.ToString("f0") + ":" + seconds.ToString("f0");

    }

}

}
placed the TimerText object in the GUI Text object reference

Then I got this error:

"MissingComponentException: There is no 'GUIText' attached to the "TimerText" game object, but a script is trying to access it. You probably need to add a GUIText to the game object "TimerText". Or your script needs to check if the component is attached before using it. Timer.Update () (at Assets/Timer.cs:40)"

I essentially placed The object GUI Text object itself (TimerText) as its own scripting reference in Unity's Inspector. Not sure where to go from here. Any advice on what I can do next? Any help would be appreciated.


texts:
I've done some research into different collision detection methods but I don't know when I should be using one over the others. Some I've seen are:

Continuous Collision Detection (CCD) or Raycasting
Quadtrees
Discrete stepping

So for example if I want to shoot a bullet which method would I use? Well I've herd CCD is the way to go for that. But what if I have an unrealistic machine gun that has a huge rate of fire making 100 bullets shot at any given time. I don't know if I should be using a quadtree or be consistent and use CCD or even use something else.

Could I get some clarification on what each method is best suited for? That way I'm confident I'm using the right method for the situation. Also if you know of any other good collision detection methods let me know. Oh and if the dimensions matter I'm talking 2D here.

Thanks.


texts: OpenGL ES, object intersection artifacts

texts:
I was developing a C++ implementation of OpenGL for Android and I noticed those weird artifacts that formed between 2 intersecting objects (or triangles) :

[Here are the artifacts on Android]

The weird thing is that exactly the same library, running on my windows machine, with exactly the same shaders is not giving the same results (sorry for the bad image resolution) :

[No artifacts on windows]

I know about the existence of Z-fighting, but wouldn't that issue persist on Windows as well? I am using a 16 bit depth buffer resolution on Android (which seems to be the maximum here).

Is there something I could be missing or doing wrong?

Thank you!


texts:
Point clouds can be obtained from a physical camera using phase shift algorithm. These may be 3-4 separate point clouds. My job is to combine those point clouds (register, filter) using signal processing algorithms to create a CAD model.

How can I do this? Are there existing tools or libraries I can use?

There are C/C++ point cloud libraries, but I'm using C#. Is there a way to use those libraries in C#?


texts:
I have seen a mechanic which I call "armor points" in many games: Quake, Counter Strike, etc. Generally, while the player has these armor points, he takes less damage.

However, they act in a similar fashion that health points do: you lose them by taking said damage.

Why would you design such a feature? Is this just health 2.0, or am I missing something?

To me, armor only makes sense in, for example, RPG games, where it is a constant that determines your resistance. But I don't see why would it need to be reduceable during combat.


texts: How to Create a Blast of Liquid in Unity

texts:
I am making a small cartoon-ish fighting game, and one of the weapons is a Hot Coffee Sprayer, which is a shotgun style weapon.  How do I create a thick blast of dark liquid to come from it, with a solid appearance like the repulsion gel in Portal 2?

If its too complex, just tell me how make the gun launch a handful individual drops at once rather than a horizontal wall of coffee.

I am not amazing in Unity or C# but I learn easily and I understand the fundamentals of programming very well.  I'm skilled in Python.


texts: How to calculate a normalized direction of two rotations?

texts:
In Vector math and translations we can do:

dir = (v1 - v2).norm

and then v1.translate(dir * 50) so v1 moves to the v2's direction.

What about rotation and eulerAngles?

Here's my attempt, but it doesn't work, probably from some obvious reasons.

Vector3 initial = ob1.transform.rotation.eulerAngles; // get it's initial rotation
ob1.Rotate(new Vector3(0,0,90)); // rotate
Vector3 after = ob1.transform.rotation.eulerAngles; // store new rotation
ob1.Rotate(new Vector3(0,0,-90)); // rotate back to initial

// here I need to calculate the direction so I can do rotate(dir * 50); or something similar

I need to get the rotation direction, so I can rotate the object continously with direction, not with a fixed desired angle value.

To be super clear, I need to get this blue line direction:

The object is initially rotated by (0,0,57).
I need to rotate it around it's center (green axis).

I know I can do logo1.transform.RotateAround(logo1.transform.position, logo1.transform.up, 80); and it works, but I need the direction from this, so I can use it in Tweening.


texts: How to get the file location of missing sprite in unity?

texts: I accidentally moved some of my sprites and now I can't remember where they were originally. Now in Unity, it says missign - sprite. So can't I get the location saved in scene file??? i.e. if it is referring to Desktop\file.extension and I move it to Desktop\files\file.extension, can I get Desktop\file.extension in Editor???


texts:
I have some white blocks, and within the white blocks, I have some cyan-bordered boxes. Whenever the white boxes are extended outside of the cyan bordered boxes, I want to resize them so they are back inside the cyan bordered boxes.

As per my image, they need to remain in their borders, like the fifth one from the top.

How do I resize a game object, when it has extended past a boundary?

Here is my current code:

void Update()
{
    if(numOfGeneratedGuideline < numOfGuidelineToGenerate)
    {
        Generate_Guideline_Positons(numOfGeneratedGuideline);
        Generate_Platform_Positions_And_Scale(numOfGeneratedGuideline);
        Generate_Platforms(numOfGeneratedGuideline);
        numOfGeneratedGuideline++;
    }
}

void Generate_Guideline_Positons(int i)
{
    float tempGuidelineOffset = groundHeight + (guidelineOffset * (i + 1));

    guidelinePosX[i] = worldWidth / 2;
    guidelinePosY[i] = tempGuidelineOffset;
    guidelinePosZ[i] = 0;
}

void Generate_Platform_Positions_And_Scale(int i)
{
    randomGuidelineNumber = Random.Range(1, numOfGuidelineToGenerate + 1);

    float tempPlatformPosXMin = (worldWidth - guidelineWidth) / 2;
    Debug.Log(tempPlatformPosXMin);
    float tempPlatformPosXMax = worldWidth - tempPlatformPosXMin;
    Debug.Log(tempPlatformPosXMax);
    float tempPlatformPosY = groundHeight + (guidelineOffset * (i + 1));

    platformPosX[i] = Random.Range(tempPlatformPosXMin, tempPlatformPosXMax);
    platformPosY[i] = tempPlatformPosY;
    platformPosZ[i] = 0;

    platformScaleX[i] = Random.Range(minPlatformScaleRange, maxPlatformScaleRange);
    platformScaleY[i] = 1;
    platformScaleZ[i] = 1;

    //22 29 36 43 50
}

void Generate_Platforms(int i)
{
    GameObject newplatform = Instantiate(platformPrefab,
        new Vector3(platformPosX[i], platformPosY[i], platformPosZ[i]),
        Quaternion.identity) as GameObject;

    newplatform.transform.localScale = new Vector3(platformScaleX[i], platformScaleY[i],
        platformScaleZ[i]);
}


texts: TextField Add in Editor does not display when put under if statement

texts:
I've been trying to make a custom editor window in Unity and I needed to make an "add TextField" button. When I add a TextField directly (without requiring a button), it works. When I put it under if(GUI.Button()) it does not show up.
Here's my code:
private static List<string> s = new List<string>();
private void OnGUI()
{

    if (GUI.Button("+");)
    {
        s.Add(GUI.TextField(new Rect(0,50,Screen.width,20),"field"));
    }
}


texts: Making a new instantiated prefab as a child for existing GameObject

texts:
I've been searched about how to make these fruit to move as the basket movement if it collided with it, and I've been found that if I want to perform this I've to let these fruit to be a child to the basket game object .. for example :

banana.transform.parent = basket.transform;

banana and basket each of them of type "GameObject" ...

BUT unfortunately this way didn't work !! and I don't know why ??

So now I need to know if it is possible to destroy the banana if a collision with the basket happened and instantiate a new banana in the basket as a child at run time ?!!

I need to try this stupid way because I've tried all the other ways and nothing worked :(


texts: Keeping track of moving sprites in 2D grid

texts:
I'm working on a 2D tower defence game in C++.

The game world consists of a grid of Cells, that are managed by a Map:

Essentially the map is:

[cell][cell][cell][cell][cell]
[cell][cell][cell][cell][cell]
[cell][cell][cell][cell][cell]
[cell][cell][cell][cell][cell]

And mobs are moving across the map.

Map class:

class Map{
     //...
     std::vector<std::vector<Cell>> cells;
     std::unordered_set<Cell*> cellsContainingMobs;
     void addCellContainingMob(Cell* c);
     Cell* getCellFromPos(const glm::vec2& pos);

}

Cell class:

class Cell{
     //...
     std::deque<Mob*> mobsInCell;
     void addMob(Mob* m);
     void clearMobs();
}

Mobs are a moving sprites that "walk" around the map and are managed by another class.

My goal is to at every game loop/frame, I know which cells contains mobs (Map::cellsContainingMobs), and for each of those cells, I know which mobs are in the cell (Cell::mobsInCell).

My current method for keeping track of this, is on each game loop iteration (frame) I do the following:

Clear my containers:

for (Cell* c : cellsContainingMobs){
    c->clearMobs(); //calls clear on the std::deque
 }
 cellsContainingMobs.clear();

Iterate over active mobs in the scene

Find out which cell the mob is in (this is inexpensive, as the truncated coordinates of the Mob's position is the indices of the Cell in Map::cells.
Add the Cell to the Map::cellsContainingMobs. Since this is an std::unordered_set if the same Cell is added multiple times, it will only keep one.
Add the Mob to the Cell it is currently at.

part of code:

for (Mob* m : activeMobs) {
    Cell* c = map->getCellFromPos(m->getPos());
    map->addCellContainingMobs(c);
    c->addMob(m);
}

I use std::unordered_set for Map::cellsContainingMobs to prevent keeping the same items multiple times. For Cell::mobsInCell I could probably use std::vector instead of std::deque, but I think the reason was that I don't need random access.

The reason I want to keep track of which Cells contains Mobs, and which Mobs are in which Cells, is to later make it more efficient to check for collision with Tower that shoots bullets. (I only check for collisions on the Cells that have mobs and are in the range of the tower).

My question is; should I use different type of containers for what I'm doing? Is there a completely different approach for keeping track of where my Mobs are located, that could be more efficient?


texts: Making a 2d puzzle game like Unblock Me for iOS and need advice.

texts:
I have a simple game on the Apple App Store written entirely in Objective-C and Cocoa Touch.

I would like my next game to be like the Unblock Me game or Auqeduct where you have to drag pieces around the game board arranging them to create something or free something to exit the board.

My question is how are games like this started. Do they work on a grid? How does collision work? When one piece hits the other piece they stop. Is this all done using Core Animation for moving the pieces and using functions like "CARectIntersectsRect()" to test for collision?

I love puzzle games that involve falling blocks and color matching and puzzles like mentioned above. Is there a resource I could read more about on the principles of these games that is language independent or explains how to make them?


texts:
Summary:
I get FPS slowdown as soon as I try to tint the sprites (i.e: multiply texture with color in the fragment shader)

Details:

Hardware: iPod touch 4

I am drawing 700 sprites on the screen using glDrawArrays. And yes I am batching all of these in a single draw call. Following shows Vertex data structure:

struct Vertex {
    float Position[2];
    float Color[4];
    float Texture[2];
};

Yes I am sending colour with each vertex because I selectively need to tint some sprites but not others. Following is the fragment shader I am using:

varying lowp vec2 TexCoord;
uniform sampler2D TextureSampler;

void main(void)
{
    gl_FragColor = texture2D( TextureSampler, TexCoord );
}

Till now it is working GREAT, giving me full 60 FPS !!!

BUT

As soon as I change the fragment shader to the following (to allowing tinting):

varying lowp vec4 DestinationColor;
varying lowp vec2 TexCoord;
uniform sampler2D TextureSampler;

void main(void)
{
    gl_FragColor = texture2D( TextureSampler, TexCoord ) * DestinationColor;
}

Using following 64x64 png texture containing alpha channel, rendering with glEnable(GL_BLEND):

The performance drops to 47 FPS only due to this single change {just by multiplication with ONE vector} (FPS measured using xcode instruments and OpenGL detective). Any ideas what is going on ?

Thanks.

Edit:

I've also tried stripping off per vertex color attribute:

struct Vertex {
    float Position[2];
    float Texture[2];
};

And modifying the fragment shader as follows:

precision lowp float;
varying lowp vec2 TexCoord;
uniform sampler2D TextureSampler;

void main(void)
{
    gl_FragColor = texture2D( TextureSampler, TexCoord ) * vec4(1.0,0.0,0.0,1.0);
}

It is running at 52 FPS for 700 sprites (a gain of only 5 FPS). So this is not interpolation, seems like the multiplication is extremely expensive. Just this ONE multiplication?


texts: Is it possible to append a blur shader to a standard (diffuse) shader ? I am looking for a way to do this as Unity indie doesn't allow render textures.


texts:
Note: I have to poll, rather than do callbacks because of API limitations (SFML). I also apologize for the lack of a 'decent' title.

I think I have two questions here; how to register the input I'm receiving, and what to do with it.

Handling Input

I'm talking about after the fact you've registered that the 'A' key has been pressed, for example, and how to do it from there.

I've seen an array of the whole keyboard, something like:

 bool keyboard[256];  //And each input loop check the state of every key on the keyboard

But this seems inefficient. Not only are you coupling the key 'A' to 'player moving left', for example, but it checks every key, 30-60 times a second.

I then tried another system which just looked for keys it wanted.

std::map< unsigned char, Key> keyMap; //Key stores the keycode, and whether it's been pressed. Then, I declare a load of const unsigned char called 'Quit' or 'PlayerLeft'.
input->BindKey(Keys::PlayerLeft, KeyCode::A);  //so now you can check if PlayerLeft, rather than if A.

However, the problem with this is I cannot now type a name, for example, without having to bind every single key.

Then, I have the second problem, which I cannot really think of a good solution for:

Sending Input

I now know that the A key has been pressed or that playerLeft is true. But how do I go from here?

I thought about just checking
 if(input->IsKeyDown(Key::PlayerLeft) { player.MoveLeft(); }
This couples the input greatly to the entities, and I find it rather messy. I'd prefer the player to handle its own movement when it gets updated. I thought some kind of event system could work, but I do not know how to go with it. (I heard signals and slots was good for this kind of work, but it's apparently very slow and I cannot see how it'd fit).

Thanks.


texts: I've been looking for a way to implement wall-jump in my xna game, but I can't find any information about it, can someone could someone please help me out ?


texts: Hexagon grid gets cut off when generated outside of the JFrame

texts:
I'm programming a hex-grid based game where you click on adjacent tiles to the player and when the player moves the map/grid moves in the opposite direction (using setLocation() on the jpanel inside the main jframe) so that, relative to the screen, the player is still centered.

When I pass in a big enough number of hexagons some of the grid generates outside of the jframe. When this happens, I can still make the player move around and open the menu and change player skins, but when moving north on the grid (when the top of the grid is what got generated outside the jframe) the grid just gets cut off and ends before the whole hexagon gets repainted.

I was wondering if there was a way to fix this that maybe I've simply just overlooked. My first thought was to delete and then regenerate the grid with new x,y coordinates each time the player moves and not use setLocation() at all, but I feel like that would be very inefficient and more of a brute force solution (last resort). I just feel like there has to be a more elegant or efficient way. I've tried using setSize(), setMinimumSize(), and setPreferredSize() methods to try and make the jpanel or the jframe's content pane bigger.

Picture to help:


texts:
Some weird "ball" is showing when I select an element in Unity, preventing me to see the object itself:

I've tried to hide some layers, but even with all layers hidden it's still here:

Do you know how to hide this thing?
Any idea is greatly welcomed :)


texts: How can I use shaders in Unity to write a scientific computing program?

texts:
I want to write a GPU shallow water code on Unity3D. For sure, performance matters a lot. I've done this before using DirectX and C++. But for a couple of reasons I want to redo it in Unity3D.

I have some hands on experiences with Unity3D, but I have no idea how I can write GPGPU codes, like what I did in DirectX.

In DirectX I am using textures as my data structure for the properties of water cells (height, x-velocity, y-velocity, etc.) and HLSL shaders as my parallel computational functions (kernels).

Furthermore, I prefer my code to be [near] cross-platform. Is it possible to do something similar in Unity3D using OpenGL?

I am an engineer, and not a game developer, so please keep it simple ...


texts: Convert quaternion to a different coordinate system

texts:
OSVR has a right-handed system: x is right, y is up, z is near.

I need to convert orientation data from a sensor in OSVR to a different right-handed system in which x is forward, y is left, and z is up.

I need to calculate the transformation that will convert a quaternion from one system to the other.

I naively tried:

void osvrPoseCallback(const geometry_msgs::PoseStampedConstPtr &msg) { // osvr to ros
    geometry_msgs::PoseStamped outputMsg;

    outputMsg.header = msg->header;
    outputMsg.pose.orientation.x = msg->pose.orientation.y;
    outputMsg.pose.orientation.y = msg->pose.orientation.z;
    outputMsg.pose.orientation.z = msg->pose.orientation.x;
    outputMsg.pose.orientation.w = msg->pose.orientation.w;

    osvrPosePub.publish(outputMsg);
    ros::spinOnce();
}

But that made things really weird. Facing north pitch is pitch, facing west, pitch is yaw, facing south, pitch is negative pitch...

How can I convert my OSVR quaternion to the a corresponding quaternion in the new coordinate system?


texts: Moving an object to random points Unity3d c#

texts:
So here is the problem
I want to change the position of gameObject to specific points that I declared with empty objects randomly but the problem is the moment the object reaches one of the points it starts shaking around and not doing the same thing again
here is my code

public class EnemyController : MonoBehaviour {

public Transform[] movePoints;
public float speed;
private int amount;
private Transform currentTarget;

void Start () {
    randoming ();

}

void Update () {
    Movement ();
}

void randoming(){
    amount = Random.Range (0, movePoints.Length);
    currentTarget = movePoints[amount];
}

void Movement(){
    transform.position = Vector3.MoveTowards (transform.position, currentTarget.position, speed * Time.deltaTime);
    StartCoroutine (startMoving());
}

IEnumerator startMoving(){
    yield return new WaitForSeconds (5.05f);
    randoming ();
}

}


texts: The GameObject transform automatically sets to (0, 0, 0) when i apply Perlin Noise

texts:
I am learning how to use the Perlin Noise with some Documentation. So far i mostly understood quite a lot.

Here i post the codes in order:

The Noise Code

public static class Noise {

public static float[,] GenerateNoiseMap(int mapWidth, int mapHeight, float scale)
    {
        float[,] noiseMap = new float[mapWidth, mapHeight]; //We create new 2D array

        if (scale <= 0)//If input scale is 0 we will have a 0 div!!
        {
            scale = 1f;

        }

        //We loop through the noise map
        for (int y = 0; y < mapHeight; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                //Now at which point we are sampling our height values
                float SampleX = (float)x/scale; //For non integer values we divide by scale
                float SampleY = (float)y/scale;

                float perlinValue = Mathf.PerlinNoise(SampleX, SampleY);
                noiseMap[x, y] = perlinValue; //We assign the Perlin noise value to the 2D thing
            }
        }
        return noiseMap; //We return the noiseMap we generated
    }
}

The Map Generator

public class MapGenerator : MonoBehaviour {

    public int mapWidth;
    public int mapHeight;
    public float noiseScale;

    public bool autoUpdate;

    public void GenerateMap()
    {
        //We will fetch the noiseMap from the Noise class
        float[,] noiseMap = Noise.GenerateNoiseMap(mapWidth, mapHeight, noiseScale);

        MapDisplay display = FindObjectOfType<MapDisplay>();
        display.DrawNoiseMap(noiseMap);

    }

}

Map Display

public class MapDisplay : MonoBehaviour {

    public Renderer textureRender;

    public void DrawNoiseMap(float[,] noiseMap)
    {
        int width = noiseMap.GetLength(0);
        int height = noiseMap.GetLength(1);

        Texture2D texture = new Texture2D(width, height);

        Color[] colourMap = new Color[width * height];
        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                colourMap[y * width + x] = Color.Lerp(Color.black, Color.white, noiseMap[x, y]);
            }
        }
        texture.SetPixels(colourMap);
        texture.Apply();

        textureRender.sharedMaterial.mainTexture = texture;
        textureRender.transform.localScale = new Vector3();
    }
}

EditorControls Code

//This class controls the editor so instead of MB we use Editor
[CustomEditor (typeof(MapGenerator))]
//We have to say it is custom and the "typeof" of the class
//the custom editor is, in that case. MapGenerator

public class MapGeneratorEditor : Editor {

    public override void OnInspectorGUI()
    {
        MapGenerator mapGen = (MapGenerator)target;//The object being inspected.

        //If we changed anything in the Editor, it will autoupdate.

        if (DrawDefaultInspector())
        {
            if (mapGen.autoUpdate)
            {
                mapGen.GenerateMap();
            }
        }

        if (GUILayout.Button("Generate"))
        {
            mapGen.GenerateMap();
        }

    }

}

This last piece of code makes a button inside the Inspector so when i press it. The whole thing runs and gives me the Perlin Noise Map displayed on a plane.

Plane Configuration (Inspector)

QUESTION

The problem i have right now is that when i press the Generate Button (see below):

The Planes Scale goes from (1, 1, 1) to (0, 0, 0) and i do not know why it does that. The only way to get back my Perlin Noise displayed on that Plane is if i manually setup the plane a Scale.

What i am missing here?

Thanks for answer.


texts:
I am currently developing a game in unity and I want to add some sort of saving system that saves the following:

Locked / unlocked level.
The amount of money the player has.
Items / perks that the player has.

As you can see, the data I want to save is global, and has nothing to do with any specific scene.
How would you reccomend save this kind of data? I have heard about the EasySave asset but I don't know if it is the right choice: it is pretty expensive and I belive that there has to be some easier, cheaper (even free) way to save the data.
I'll appreciate any answer or consideration.


texts: Custom Keyboard run by Arduino not working in XNA

texts:
I'm trying to make a stenotype-teaching game using the stenoboard as input.  The Stenoboard emulates an NKRO keyboard, using this code: https://github.com/caru/StenoFW/blob/master/StenoFW.ino, with an Arduino Leonardo as the controller.

My XNA code is unremarkable, and works fine with other keyboards.  The Stenoboard works fine with other programs.  However, when plugged into XNA, it registers nothing unless all keys are mashed repeatedly, in which case it will register one or two random keys for a single frame.

This issue also exists in Monogame and across multiple machines running both Windows 7 and 8.  The Stenoboard presents itself as a PS/2 keyboard on my W8 laptop, but as a USB keyboard on my W7 desktop.  I'm fairly certain XNA's keyboard library just doesn't like the signals the 'board is sending.

My question is: A) does anyone know a way to fix this, and if not, B) is there another way to harvest keyboard events from Windows and feed them into XNA?  I'm currently thinking of adding a Windows Form to the project and using it to catch Keydown and Keyup events and mail them to the game, but since the form would have to be in focus at all times, that seems like a recipe for user error.


texts: How do I store multiple bullets' coordinates?

texts:
My game is a 2D game(or tries to be) in pure C using SDL(no OpenGL at all). No specific goal in it, it's pretty much boilerplate code.

I decided I want to make my character/player shoot "something", whether you'd call it a bullet or not is up to you.
But even before writing any code, I already saw my first hurdle. You see, in reality when you shoot a bullet it's pretty fast, you'd normally hit a target by the time you shoot again, in my game I want the bullets to be slow so that two or three or more can be displayed on the screen. This is where the problem starts. I have written some pseudo-code to illustrate my problem.

Basically, when I shoot a bullet, I increment a total bullet counter, then the sprite would appear and every few MS I would update the animation and check for collision. When I have multiple bullets which I store in a structure array, I would loop through all of them to check their collision, or if they went out of the screen's view. When one fits either condition, I will remove it from the screen and (free it) from the structure array and that index will point to invalid memory. Basically, my pseudo-code tries to illustrate the problem.

http://pastebin.com/9Y40GgT4

This is my interpretation of how it should be done. I am assuming there are other ways. Hopefully we can avoid the "Why C and not C++ discussion at this time".


texts: What's the 'proper' way to get unit vectors?

texts:
My apologies if I've misunderstood the term 'unit vector' or misapplied it in concept, but I think that is the term for an object's heading when expressed as [x, y] when x and y are a value between -1 and 1; so if an object were moving 'south' on a computer screen, it would have a unit vector of

[0, 1]

...right?

Anyway, I've been using this concept to move my objects and rotate their images (when needed), but I think the math I'm using to determine the unit vector is... suboptimal.

def set_heading(self, goal):
    """Uses a 'goal' (x, y) to set the object's heading.
    Returns list of 0s and 1s for 'straight' headings.
    Diagonal headings are + and/or - math.sqrt(2)/2.
    """
    vals = [a - b for a, b in zip(goal, self.pos)]
    self.heading = [i / abs(i) if i != 0 else 0 for i in vals]
    if 0 not in self.heading:
        self.heading = [i * (sqrt(2)/2) for i in self.heading]

(If you're not familiar with Python ternary syntax, the second line contains i / abs(i) if i != 0 else 0 which is Python's way of saying x if Condition else y as opposed to the usual Condition? x : else y syntax in other languages. Basically I'm just trying to avoid dividing by zero!)

So as you can see, this method of doing this sort of 'locks' the object into eight directions; if a 0 is not present in the heading, the method assumes that we're traveling diagonally and so multiplies the values by sqrt(2) / 2 to ensure that the object doesn't travel faster than it should when moving diagonally.  In this way I can move the object by simply adding the result of the unit vector times its speed to its current x and y coordinates.

def move(self):
    """Moves the object by changing self.pos."""
    self.pos = [a + (b * self.speed) for a, b in zip(self.pos, self.heading)]

I can't help but feel like the method for getting the unit vector (if that's what it's correctly called) is sophomoric. Especially since it is locked into eight directions - it's fine for the little project I'm working with currently, but I'm not sure of the right method for getting a more precise unit vector. What is the correct method for doing so - and is it more or less performant than the weirdness I have come up with independently?


texts: How to handle hitboxes/hurtboxes in animations?

texts:
I'm curious how I should go about structuring hitboxes and hurtboxes for my actors. For context, I'm developing a game engine in OpenGL, using C# and OpenTK. I have developed a working skeletal animation system, which loads animations using Assimp, and then passes BoneIDs, BoneWeights, and Transform matrices to the Vertex shader, which calculates all vertex deforms appropriately for the current animation keyframe (or current interpolation between keyframes).

Is there a set standard for calculating collision in animations? I'd prefer to continue using Assimp, which means using standard, recognizable animation formats that my engine can load in, so I'd rather not store any collision data in the animation files, unless there is a precedent for this or room for metadata or something.

My current thoughts: One option would be to calculate the hitboxes and hurtboxes upon loading an animation, and have a mapping that determines which meshes are hitboxes and which are hurtboxes. The second option would be to create a new file format where I store my hitboxes and hurtboxes in a way that is similar to animation files (minus bone weights, since I'll just be transforming the scale/position of axis-aligned rectangles), where I can determine keyframes for hitboxes and hurtboxes, then interpolate based off of these to get the current collision box for each frame. I could combine the two options by automatically generating these files from the animations, then editing them manually until they are reasonable.

Am I on the right track, or are there smarter ways of going about this? I don't want to reinvent the wheel if there are better options available.


texts:
I've made a hole. I have animals tagged as animals. When an animal walks into the hole, they disappear. I tried OnTriggerEnter2D() as well, and set the collider to isTrigger, but it still didn't work. I can get it to work without the tag part, but anything that bumps into each other sets each other to inactive.

public class BlackHole : MonoBehaviour
{
    void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag == "animal")
        {
            other.gameObject.SetActive(false);
        }
    }
}


texts: How can I make a random function generate a specific integer more often without using arrays and vector?

texts:
I was making a ludo game and there's a rule that your pieces will only open when the 6 will shows up on a dice.

How can I make my dice generate the number 6 more often, without using arrays or vectors? I'm using c++.


texts: Reversing translational dependency of Sprite on Mouse instantaneously at runtime without causing the sprite to jump

texts:
Help me think through a logical way to implement the desired effect.

Goal: (I'm using Adobe Animate CC 2017 targeting AIR for Desktop)

Move a sprite using a controller (mouse on a PC for instance) with a 1:2 ratio.
Have an event trigger a function that causes this relationship to become a -1:2 ratio (and another one to switch it back to 1:2)

My First Thought Experiment (represented in pseudo code)

sprite.x = mouse.x * 2 - stageWidth / 2 - sprite.width / 2 (works fine, 1:2 ratio)
function reverseRatio():void{ sprite.x = stageWidth - (mouse.x * 2 - stageWidth / 2 - sprite.width / 2) - sprite.width (also works fine, but with a catch*)

The "catch" is that the sprite, when triggered to reverse ratios, jumps to the reverse side of the display window.  What I'd like to accomplish is somehow have the motion of the sprite tied to the motion of the mouse, but what I have accomplished is the position of the sprite is dependent on the position of the mouse.  And since when this event is triggered, the mouse does not move, the sprite suddenly does (which I'm guessing would get bad reviews during play testing, although the very saddistic gamer may actual enjoy trying to master this effect!)

So it seems I need to do just that, link the motion of the mouse and sprite, instead of the position.  This also seems to have a "catch" though.

Here's another thought experiment using this motion dependency method.

You move the controller toward the right of the display window with a motion dependency to the Sprite of 1:2 (mouse:sprite). *By motion I mean use the delta or change in x position by recording the position in one frame and using the difference in the next frame to determine how much the Sprite translates.*
The Sprite goes to the far right of the window as well (actually getting there before the mouse does because of the imbalanced ratio).
The event is triggered that negates the relationship to -1:2 (mouse:sprite).
The sprite does not jump to the far left side of the window because its motion is dependent on the motion of the controller, which isn't being moved.
Now the controller moves further to the right
This should have the effect of moving the sprite to the left, which it does, but by the time the sprite moves back to the left half way across the screen, the controller has left the window and thus can no longer influence the sprite (my application pauses when the mouse leaves, because my target framework doesn't support mouse input from outside the display window).

So because these two methods have these "catches" I have to choose between the sprite jumping across the screen or only being able to move the sprite halfway back when this event is triggered.  I think this means I need to really rethink my whole methodology.  Any thoughts on a slick way to achieve this effect?  It seems impossible to me without having my PC physically move the location of the mouse cursor (which, if I could do that, would totally work!).

Thoughts? Questions?

in the bottom picture, the event has been triggered, but the sprite can't respond to the movement of the cursor, becasue it is already to the far right.  I could manually move the cursor to the far left, at which point things would work fine, but the goal is for this to be instantaneous reversal of the relationship.

edit

If I were to port this to iOS, I think I could use the accelerometer to control the Sprite which effect could be instantaneously reversed without a cursor running out of real-estate. Right? What about using a finger drag to control the Sprite? Would I run into the same problems as the mouse on a desktop? Just musing here.

update

I have an idea (just to give you an idea of the kind of ideas i am open to for suggestions). My idea is give a visual cue as to where the Sprite would "jump" to when the correlation gets reversed. I am imagining a ghost image, or an outline, or a Sprite with raster lines through it to indicate that it is an inactive version. Then when the correlation switches, the feint one becomes solid and vice versa.


texts: What common interface would be appropriate for these game object classes?

texts:
Question

A component based system's goal is to solve the problems that derives from inheritance: for example the fact that some parts of the code (that are called components) are reused by very different classes that, hypothetically, would lie in a very different branch of the inheritance tree.

That's a very nice concept, but I've found out that CBS is often hard to accomplish without using ugly hacks. Implementations of this system are often far from clean. But I don't want to discuss this any further.

My question is: how can I solve the same problems a CBS try to solve with a very clean interface? (possibly with examples, there are a lot of abstract talks about the "perfect" design already).

Context

Here's an example I was going for before realizing I was just reinventing inheritance again:

class Human {
public:
    Position position;
    Movement movement;
    Sprite   sprite;
    // other human specific components
};

class Zombie {
    Position position;
    Movement movement;
    Sprite   sprite;
    // other zombie specific components
};

After writing that I realized I needed an interface, otherwise I would have needed N containers for N different types of objects (or to use boost::variant to gather them all together). So I've thought of polymorphism (move what systems do in a CBS design into class specific functions):

class Entity {
public:
    virtual void on_event(Event) {} // not pure virtual on purpose
    virtual void on_update(World) {}
    virtual void on_draw(Window) {}
};

class Human : public Entity {
private:
    Position position;
    Movement movement;
    Sprite   sprite;
public:
    virtual void on_event(Event) { ... }
    virtual void on_update(World) { ... }
    virtual void on_draw(Window) { ... }
};

class Zombie : public Entity {
private:
    Position position;
    Movement movement;
    Sprite   sprite;
public:
    virtual void on_event(Event) { ... }
    virtual void on_update(World) { ... }
    virtual void on_draw(Window) { ... }
};

Which was nice, except for the fact that now the outside world would not even be able to know where a Human is positioned (it does not have access to its position member). That would be useful to track the player position for collision detection or if on_update the Zombie would want to track down its nearest human to move towards him.

So I added const Position& get_position() const; to both the Zombie and Human classes. And then I realized that both functionality were shared, so it should have gone to the common base class: Entity. Do you notice anything? Yes, with that methodology I would have a god Entity class full of common functionality (which is the thing I was trying to avoid in the first place).

Meaning of "hacks" in the implementation I'm referring to

I'm talking about the implementations that defines Entities as simple IDs to which components are dynamically attached. Their implementation can vary from C-stylish:

int last_id;
Position* positions[MAX_ENTITIES];
Movement* movements[MAX_ENTITIES];

Where positions[i], movements[i], component[i], ... make up the entity. Or to more C++-style:

int last_id;
std::map<int, Position> positions;
std::map<int, Movement> movements;

From which systems can detect if an entity/id can have attached components.


texts:
Possible Duplicate:
  How are voxel terrain engines made?

I'm making a game like minecraft (although a different idea) but I need a random world generator for a 1024 block wide and 256 block tall map. Basically so far I have a multidimensional array for each layer of blocks (a total of 262,114 blocks).

This is the code I have now:

Block[,] BlocksInMap = new Block[1024, 256];

public bool IsWorldGenerated = false;

Random r = new Random();

private void RunThread()
{
    for (int BH = 0; BH <= 256; BH++)
    {
        for (int BW = 0; BW <= 1024; BW++)
        {
            Block b = new Block();
            if (BH >= 192)
            {

            }
            BlocksInMap[BW, BH] = b;
        }
    }

    IsWorldGenerated = true;
}

public void GenWorld()
{
    new Thread(new ThreadStart(RunThread)).Start();
}

I want to make tunnels and water but the way blocks are set is like this:

Block MyBlock = new Block();
MyBlock.BlockType = Block.BlockTypes.Air;

How would I manage to connect blocks so the land is not a bunch of floating dirt and stone?


texts: Creating looping canvas animation (slot machine with reels)

texts:
I have a small assignment to create something like slot machine with spinning pictures. I have to use HTML5 Canvas. I would like to hear some opinions how this can be made simply and performantly.

There are  symbols that would be spinning vertically while only 2 would be fully visible, next 2 are partially hidden and remaining 2 are not visible at all.

I have chosen CreateJS suite, but I have no experience with that, so I am just trying to figure it out. I made this for the start...

var reels = [160, 405, 648, 892, 1137]; // X offset of reels
var reelLines = [0, 317, 634]; // Y offset of symbols in the reel

var stage = new createjs.Stage('game');

for (x = 0; x < reels.length; x++) {
  for (y = 0, y < reelLines.length; y++) {
    bmp = new createjs.Bitmap('symbol').set({
      x: reels[x],
      y: reelLines[y]
    });
    stage.addChild(bmp);
  }
}

This displays 3 symbols in each reel and it looks good. Now I need to add some animation to it. I am thinking about it like having stack of symbol bitmaps at the top position where it's not visible yet. I tried to use Tween class like this.

createjs.Tween.get(bmp, {loop: true}).to({
  y: 808
}, 500);

It's basically correct, symbol rolls in and out and then it pops at top again. However this works for single symbol only. If I position three symbols as stated above and run same tween on them, each of them will go in different speed, because to call second argument is duration, not the speed.

I would really appreciate some ideas on this approach and if it's even correct one.


texts:
Our game works great with touch or mouse, but the Surface pen doesn't seem to register as a pointing device at all. How can we support the pen in Unity in a native build?

This question on the Unity Answers site suggests we could build it as a UWP app, but that means restricting ourselves to a very limited subset of the .NET framework (specifically, we lose a lot of the Serialization libraries).


texts: Importing skeletal animation from vertex coordinates in maya

texts:
I have files of different frames of an animation which have the vertex co-ordinates of a human skeleton in 3D space. I want to import the animation from these keyframes into maya to perform motion retargeting. Please help me get some direction in this.

Also is there any other way to retarget motion from one skeleton to other(different size) other than in maya?


texts: Finding enemy object in player's forward direction within a range

texts: I would like to know the way by which I can find enemy objects tagged with "player" in a forward direction within a range say 3 units from the player.


texts: Does SDL2 completely encapsulates Direct3D and OpenGL?

texts:
I'm starting to study game development but the concepts of how the SDL2 lib works are still a bit blurry to me.
I get that both Direct3D and OpenGL are two sides of the same coin. They both are used to draw vectors in the screen and are used as a graphics hardware abstraction layer.
From what I read about the SDL2 lib it seems to be a multi-purpose library that encapsulates some functionalities as user input, threading, networking, window creation, and so on [and also "graphics hardware via OpenGL and Direct3D"].
Now the questions:

The SDL2 webpage states that it provides access to "graphics hardware via OpenGL and Direct3D". What exactly that means?
If I'm making a 3D game do I need to decide beforehand which graphics API I want to use (Direct3D or OpenGL) and use it alongside with the SDL2? If not, does SDL2 completely encapsulates the graphics API so I could easily deploy my game targeting Direct3D or OpenGL without adapting too much code for each one?
In the case SDL2 does not completely abstract the graphics API, what texts and terms should I search to learn how to implement such an abstraction layer using SDL2? I want to be able to easily build for Direct3D and OpenGL.

Thanks very much!


texts: I've heard about deferred rendering and how using it can allow for "lots" of lights in a scene without a huge performance hit, but what is it and (from a high level) how is it implemented?


texts: Camera rotation in maze game depending of accelerometer

texts:
I'm still newbie in Unity 3D... I'm trying to develop simple maze game. I want to roll my ball through maze, but I have to rotate camera left or right, otherwise the player can't see what's behind while rolling the ball on the left or on the right.

void Start ()
{
    offset = transform.position - player.transform.position;
}

void LateUpdate()
{
    transform.position = player.transform.position + offset;
}

I'm using low pass filter for accelerometer values:

Vector3 lowpass()
{
    float LowPassFilterFactor = AccelerometerUpdateInterval / LowPassKernelWidthInSeconds;
    lowPassValue = Vector3.Lerp(lowPassValue, Input.acceleration, LowPassFilterFactor);
    return lowPassValue;
}

Accelerometer values are from -1 to 1 for each coordinate. Because of that I check my lowPassValue.x value and limit it. If it's positive ( >0.3 ), then the camera should turn right and if it's negative ( <-0.3 ) then camera should turn left.

Quaternion rotation = Quaternion.AngleAxis(45, Vector3.up* Time.deltaTime) ; // right
transform.rotation = rotation;

Quaternion rotation = Quaternion.AngleAxis(-45, Vector3.up * Time.deltaTime) ; // left
transform.rotation = rotation;

But then my offset doesn't work anymore, I can't see ball anymore. And camera rotation doesn't work as it should.
Is there any better solution for this or I'm using the wrong function?

Any help will be very appreciated!


texts: How can I drag a polygon based on a mouse-moved event?

texts:
I have drawn a polygon in Java using java.awt.Polygon. I want to move that polygon with the mouse (by dragging it). I know that I have to use mouseDragged  method in addMouseMotionListener. That way I can know coordinates of the path in along which the mouse is dragging the polygon.

But the problem is that I do not know what to do with the coordinates I get from the mouse to move the polygon. This is a part of the code:

public void mouseListeners(DrawEverything det) {
    det.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
        public void mouseDragged(java.awt.event.MouseEvent evt) {

            if( isMouseInMe(evt.getX(), evt.getY())){//this "if" checks if the cursor is in the shape when we drag it

                int xTmep , yTemp ;
                xTmep = (int) (evt.getX() - xMousePressed) ;//xMousePressed--> the x position of the mouse when pressed on the shape
                yTemp = (int) (evt.getY() - yMousePressed) ;

                for(int i = 0 ; i < nPoints ; ++i){
                    xPoints[i]  +=    xTmep;//array of x-positions of the points of polygon
                    yPoints[i]  +=   yTemp;
                }
            }
        }
    });

This part is the main part that I am having trouble with:

for(int i = 0 ; i < nPoints ; ++i){
    xPoints[i] += xTmep;
    yPoints[i] += yTemp;
}


texts: Player jitter when positioned at large coordinate values

texts:
I am trying to make a simple top down scrolling shooter using Unity3D comprising of the following elements:

1) Top down orthographic camera: points at 65 degrees towards the ground. At a height of 1000 units. Size 100.

2) Spaceship: Moves around based on the up/down/left/right keyboard commands. Each press moves the ship 1/100 of the screenwidth in distance. I keep its position in screen coordinates and use a ray cast to project it to a height of 500 units off the ground in the camera space using the following code:

Ray ray = mainCamera.camera.ScreenPointToRay(screenLocation);
Plane plane = new Plane(new Vector3(10, 500, 0),
    new Vector3(0, 500, 10),
    new Vector3(-10, 500, 0));
float enter;
plane.Raycast(ray, out enter);
transform.position = ray.origin + ray.direction * enter;

3) A camera scroll component that moves the camera forward by 0.75 units every frame.

When I play the game the spaceship is controlled in screen space and its world coordinates are calculated relative to the scrolling camera. The camera starts at y: 1000, z:0 and z is incremented by 0.75 (scroll per frame).

The problem I am running into is that after a while, the player ship begins jittering. The jittering gets worse the longer the game goes on. The jittering is noticeable around the time z becomes 4200 which gives me about 1m30s game time at 60fps before the jittering starts. The levels I want to create would only be less than 20 mins which would mean that I need a max Z value of 2700 assuming my Z started at -2700 and finished at +2700.

I realised this must be caused by the limitations of floating point precision so I started playing around with the numbers to see what I could do to solve this.

I found that modifying the height of the camera to 50 and the ship to height 25 whilst keeping the orthographic camera size at 100 allowed me to set the distance to around 32,000 with no jittering. I didn't fully understand why this worked as the values of the ship transform and camera transform were still truncated to 2 decimal places at the extreme distance of 32,000. Scaling the camera size to 5 brought back the original problem. This 'fix' seemed mighty hacky to me though as it pretty much screws up the scale of objects in the game and only looks 'normal' because of the orthographic perspective. I don't know how well this would play with other things I plan to add to the game.

I have 3 options at this point:

1) Continue to find a way to get it to work with the limit of 20 minutes and using a virtual camera that tracks around the world coordinate frame. This would be great if it works as I could easily use the editor to add enemies at correct positions e.t.c.

2) Make it so that when it reaches a z limit, the camera resets to z = 0 and all objects in the scene revert back relative to the camera shift. The downside to this I guess is that I would need to figure out how to get the objects to shift back correctly when the limit is reached and also it would be trickier to use unity's editor to do enemy placement e.t.c.

3) Keep the camera at position z=0 and scroll the world backwards towards the camera. This seems like the ideal thing to do as I could place objects and scripts in unity world space and when the game runs, these elements could shift back every frame. I don't know how to achieve this at the moment however. I thought of using a parent object that moves back by 0.75 every frame. Enemies would be children of this object and the player camera would not be a child but be at the same place all the time. However I think this would still cause problems as maybe enemies placed far out in the z direction might jitter as they moved around. Is this concern legitimate?

I am wondering if anyone has any better ideas to solve my problem or understands why changing the height scale seems to temporarily fix the problem?


texts: How much memory can i safely use on android?

texts:
To make my game more fluid, I try to prevent memory allocations during the game I am writing.  To that end, I allocate a whopping 16MB of buffers on startup and then use those as I go along.  When I check in Eclipse my game now uses 24MB in total, which does not change noticeably during the game.

This all works fine on the phone I have now (android 2.3, motorola defy) but I wonder if I'm going to run into problems with this on other phones or tablets that run android 2.2 or higher (which is what I'm aiming for)?


texts: Vertex shader with extrusion, what am I doing wrong?

texts:
So for a simple surface shader, you can use vertex modifier:

    void vert (inout appdata_full v) {
        v.vertex.xyz += v.normal * _Amount;
    }

I was thinking the same would work as vertex shader:

    // vertex shader
    VectexOutput vert (VectexInput i) {
        // init output
        VectexOutput o;
        UNITY_INITIALIZE_OUTPUT(VectexOutput, o);

        // vertex extrusion
        i.vertex.xyz += i.normal * _Multiplier;

        // world space normal
        half3 normal = UnityObjectToWorldNormal(i.normal);

        // standard diffuse lighting
        half nl = max(0, dot(normal, _WorldSpaceLightPos0.xyz));

        // input to output
        o.vertex = UnityObjectToClipPos(i.vertex);
        o.color = i.color;
        o.diff = nl * _LightColor0;
        o.diff.rgb += ShadeSH9(half4(normal, 1));
        o.uv = TRANSFORM_TEX(i.uv, _MainTex);

        return o;
    }

But it doesn't, and since surface shader is compiled to vertex/fragment shader, I am wondering what am I missing?


texts:
What I am developing is not a game, but is done in Unity3d, so I believe here is a good place to ask.

Context:

The unity application runs in the WebPlayer inside a web application

Case:

User uploads a file on the website
Webserver processes the file, does conversion and business stuff. Ends up with a DAE(Collada) file
The DAE file that has been generated on the server needs to be loaded and shown in the Web player inside the browser of the one who uploaded it

Now, I am not very well versed in Unity, so I just want to lay out what I expect to do, and then hope to get feedback on whether that is smart, or whether there is a better approach.

So starting from top down, here's my thinking

In order for the Web Player to find the file and use it as an asset, it should be an AssetBundle, which I can load with UnityWebRequestAssetBundle.GetAssetBundle

that shouldn't be much trouble. If the AssetBundle is stored somewhere that the web app can serve it, I expect that to just work? I see in docs that  Unity can load "AssetBundles from the project folder", but I don't expect that "project folder" is part of the game when loading from a URL. How would it?

In order to generate the AssetBundle, I would need to have a Unity application running on the server (a headless build of unity), which would pick up the generated DAE file and use BuildPipeline.BuildAssetBundle to create the AssetBundle and store it where the web app can serve it
The communication between browser, unity web player, web app server, and unity server instance is something I can manage on my own. I can work with sockets and jslibs to sort out my needs, so that doesn't need to be described here
Instantiating the GameObject after loading the AssetBundle into the Web Player, I expect to be simple, just following the docs for the AssetBundle

Extra credit:

Sources for how to do the headless unity instance would be great. Sort of like a game server, but not really caring about clients connecting, but rather working with the filesystem on the server


texts: How to manage virtual currency transactions

texts:
I am developing a game that needs a transaction management system.

Once player finish a task, he or she would gain some amount of credits (virtual money).

When Player_A buys some virtual things from Player_B, some amount of credits would be reduced from Player_A's account. Simultaneously, the same amount of credits would be added to Player_B.

Is there a standard method I can use, or open system to manage this kind of thing?.


texts:
I'm going through HLSL tutorials and I have lighting and texturing setup. Right now in my shader I take a texture, but if I leave that variable blank it gives me an error. Half of my models have textures and the other half don't, is there a way to "skip" the texturing part for the models that don't have them and set it for the models that do without having to make a completely seperate shader that only deals with lighting?

Also, whilst I'm asking this, is saturate and normalize the same thing?

Thanks


texts: Export session variables easily and permanently in php

texts: I feel like I must be missing something simple, or misunderstanding sessions or cookies. I want to save all session variables and allow players to copy/paste a long string to load the game up from a different computer or give to someone else, much like in Cookie Clicker or Adventure Capitalist etc. There is no need for sql, or for any kind of security; people can "cheat" if they want to.


texts: How do I publish to Google Play if I'm under 18?

texts: I've finished my first Unity and want to release it on the Google Play store but can't because I am under 18.  The main issue is that Google Wallet requires you to be over 18.  How could I work around this?


texts: Help with Chase AI? (Similar to Blue Demon)

texts:
all! I'm working on a chase ai / follow player script, for a 2D project of mine, I'm going for something similar to Blue Demon where an integer value controls what enemy is on screen, and can be changed for individual instances, and it follows the players animations and directions closely, and when you make contact with the enemy, you are defeated- game over. Anyways, I've got some code 'somewhat' working, i have an enumeration that controls the state machine of the animator, however, The Update loop is the real problem here, as of right now-
// Update is called once per frame
void Update () {
    //bool isMoving = anim.GetBool("isMoving");
    if (EnemyID == 0)
    {
        //transform.position = Vector3.MoveTowards(self.position, player.position, speed * Time.deltaTime);

        if(Vector3.Distance(target.position, transform.position) <= maxRange && Vector3.Distance(target.position, transform.position)>= minRange)
        {
            anim.SetBool("isMoving", true);
            transform.position = Vector3.MoveTowards(transform.position, target.transform.position, speed * Time.deltaTime);
        }

        // Enter State
        MovingState();
    }
    else {
        IdleState();
    }

}
Instead of the object following the player, it starts to run away when the player gets near? or when the player goes to a corner, it moves diagonally? It never seems to actually follow the player consistently. Suggestions and constructive criticism are greatly appreciated, thanks in advance!
Edit:
    Animator anim;
    bool caught;
    public Animator player;
    public Transform target;
    [SerializeField]
    float speed = 5f;
    [SerializeField]
    float maxRange;
    [SerializeField]
    float minRange;

    public int EnemyID;
    State state;

The EnemyID as of now isn't necessarily set to a specific value (i.e, it is set to 0) When it is equal to that number, the Update loop is supposed to have the object follow the player at a specific speed and range, during this time, the anim reference is setting the animator boolean parameter 'isMoving' to true starting the walking animation.  If the enemy object stops moving, it should enter its idle state.
    IEnumerator IdleState()
    {
        yield return new WaitForEndOfFrame();

        anim.Play("Idle");
    }

    IEnumerator MovingState()
    {
        yield return new WaitForEndOfFrame();

        anim.Play("Move");
    }

Currently the idle state is not working, but this is alright.


texts: How to transmit data structures larger than the allowed packet size?

texts:
The player avatars in my current project are rather complex and can be configured in a variety of ways. Configurations can be saved and switched between during the game, similar to e.g. an RPG where you can design and play multiple characters.

An avatar is assembled at runtime from a configuration object (that holds only the necessary information, in the form of primitives and arrays) and several prefabs. In single player mode, configuration objects are usually serialized and saved to a file.

In multiplayer, I would like players to be able to select a handful of configurations saved earlier and transmit those across the network so that each client can assemble the other players' avatars locally. This would happen at the start of a match. Configurations do not change during a match, so synchronizing changes is not an issue.

However, I can't seem to find an elegant way to do this with Unity's new networking API. While not by much, the data's too big for a single packet. The size can also vary a bit based on user choices.

Adding transaction and chunk IDs to each packet would be doing protocol level work in the game logic and comes with a number of caveats.

Opening a separate TCP connection seems easier, but would circumvent the UNet API that handles the rest of my network code and probably require users to forward an additional port for internet games.

Splitting up the logic and letting Unity sync every detail on a GameObject/NetworkBehaviour scale (after assembling the avatar) would be incredibly wasteful.

Since configurations are user created data, Asset Bundles don't seem to be an appropriate solution either.

Is there a way to utilize existing Unity functionality to transfer this data or am I better off just rolling my own solution?

Ideally, I would like to avoid creating temporary files or opening unnecessary connections in the process.


texts: How can I have realistically bending/flexing paper?

texts:
I am a new hobbyist to Unity and I working on a game where the player goes around picking up clues in the form of paper notes to solve a mystery.

So far, thanks to the help I got here, I was able to animate a note made from a UI canvas and an image in game world to fly and rotate to align itself in front of the first person camera.

Although, it looks nice, it still looks like a rigid plank of wood rather than a piece of paper. Is there a way I could bend/flew/distort the canvas to give the illusion of a piece of paper rather than piece of wood?

Is it possible to bend a canvas or should I go towards another solution, like using an actual plane or quad during the animation effect?


texts:
In a 3D environment I have an object with a displacement x that I know I need to traverse in a given time interval. I have the object's heading and elevation and I want to figure out the distance the object needs to travel on the x/y/z axis to move x units in the given direction. How can I calculate this? Are there two distinct ways to calculate it (using trigonometry or linear algebra)? Which way is the best in what scenarios?

EDIT: To clarify, I will make an analogy to a simple 2D scenario that is similar to the 3D scenario I'm working with. Let's say the object has an angle of 35 degrees from the x-axis. Making a right triangle, let's say we know that the hypotenuse (or displacement of the object) is 10 units. Now to figure out the x and y deltas to get from the object's current position to the object's new position 10 units away at a 35 degree angle, you simply do:

x = 10 * cos(35)
y = 10 * sin(35)

I simply need to solve the same problem except in 3 dimensions.


texts:
I am considering using the following game engine design pattern, but I am unsure if it's a good idea or not:

Each major task (drawing, physics, logic, networking, disk I/O) will have its own isolated thread or subprocess
Each of these threads can be put to sleep if it is running too quickly, so as to not consume an excess of CPU resources
Threads can only talk to each other through some well-defined interface to avoid messy, buggy, thread-unsafe conditions from occurring
This approach enables parallelism and scalability, but causes a thread safety problem: what if one thread is accessing data that another thread is currently processing?
We could introduce fine-grained locking, but it still can't be guaranteed that the collective states of all of a thread's data objects are coherent.
To solve this, collections of objects are maintained inside state objects, and state objects are double-buffered. The intent of this is to ensure that other threads only see a valid, coherent set of data. If one thread happens to be processing data that another thread wants to read, then the other thread reads from a buffered state, which is guaranteed not to be written to.
However, buffering these states introduces a delay where one thread sees old data from the last cycle of the other thread.
Another problem might occur when a reading thread has a slower "tick rate" than a writing thread: the writing thread may have flipped the state buffer multiple times, while the reading thread is still processing one "tick" using the same state. However this can be solved using OO references.
Pipelining should be achievable using this approach, because the draw thread could be drawing information that entered the pipeline 30 milliseconds ago, while more information is being processed
Ultimately, what I'd like to see is completely decoupled processing for all of the tasks in a game, implemented in a way that helps leverage multi-core environments, and maybe leaves some future expansion room for scaling the server side of things amongst multiple machines. I am aware that this is probably overkill for most purposes :-)

What are the criticisms or pitfalls of this approach? Is this the "right" way to do things? Am I thinking about this backwards?


texts: How can I find the right UV coordinates for interpolating a bezier curve?

texts:
I'll let this picture do the talking. I'm trying to create a mesh from a bezier curve and then add a texture to it. The problem here is that the interpolation points along the curve do not increase linearly, so points farther from the control point (near the endpoints) stretch and those in the bend contract, causing the texture to be uneven across the curve, which can be problematic when using a pattern like stripes on a road. How can I determine how far along the curve the vertices actually are so I can give a proper UV coordinate?

EDIT: Allow me to clarify that I'm not talking about the trapezoidal distortion of the roads. That I know is normal and I'm not concerned about. I've updated the image to show more clearly where my concerns are.

Interpolating over the curve I get 10 segments, but each of these 10 segments is not spaced at an equal point along the curve, so I have to account for this in assigning UV data to vertices or else the road texture will stretch/shrink depending on how far apart vertices are at that particular part of the curve.


texts: UE4 crashes on launch when using custom components in C++?

texts:
I created SM_Door in my Editor with a custom Actor class named "Door" to fire some events like open and close.

The problem is, when I open the UE4 Editor, it loads nearly to 75% loading and then crashes, and I really don't know why!

The code of the Door Header file is:

#pragma once
 #include "CoreMinimal.h"
 #include "Components/ActorComponent.h"
 #include "GameFramework/Actor.h"
 #include "Door.generated.h"

 UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
 class MAZE_API UDoor : public UActorComponent
 {
     GENERATED_BODY()

 public:
     // Sets default values for this component's properties
     UDoor();

     void Open();
     void Close();
     bool IsOverlapping(AActor*);

 protected:
     // Called when the game starts
     virtual void BeginPlay() override;

 public:
     // Called every frame
     virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

 };

Then I created Runner class representing the default player:

The full code of the Runner class is:

#pragma once

 #include "CoreMinimal.h"
 #include "Components/ActorComponent.h"
 #include "Engine/World.h"
 #include "Door.h"
 #include "GameFramework/Actor.h"
 #include "Runner.generated.h"

 UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
 class MAZE_API URunner : public UActorComponent
 {
     GENERATED_BODY()

 public:
     // Sets default values for this component's properties
     URunner();

 protected:
     // Called when the game starts
     virtual void BeginPlay() override;

 public:
     // Called every frame
     virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

     void IsNearToDoor();
     void IsNearToLampKey();

 private:
     void SetupComponents();

     UDoor Door;
     AActor* Runner = nullptr;
 };


texts: How to bounce the ball off a collider and destroying it using trigger?

texts:
I am making a Breakout game.
I have bricks with box colliders and the ball is a rigidbody2d with circular collider.
I have applied the PhysicsMaterial2D on the ball with bounciness set to 1 so the ball is bouncing off the bricks as intended.
Now I want to detect this collision in C# so I could destroy the brick but I cannot enable the isTrigger property as it will disable the collisions in that brick.
So, I am looking for a way to do that.


texts: Rotate on one axis, but visibly keep the other axes stable and editable

texts:
It's been a long two weeks. Quaternions are freaking complicated. I've managed to make a few baby steps towards finishing my project, but I've hit a brick wall and could use a few of your beautiful minds to help me past it.

I'm making an asset for Unity that will automatically rotate/shift objects to make them appear 2.5D. What I'm having trouble with is the rotation part. I go through a trigonometric process to get a calculation of how much, between 0 and 180 degrees (typically), that the object should rotate on its x-axis.

The rotation of this object should be locked between 0 and 180 degrees. Think of it this way: my trigonometric calculation is telling me whether the object should be flipped right-side-up or upside-down

So, we've got the angle it should rotate. Just plop it in a
Quaternion.Euler(MyNewXValue, prevEulerY, prevEulerZ) and we should be good, right? WRONG.

There are a number of things wrong with this.

The previous eulers can come back a bit wonky since they can correspond to multiple values in the -360 to +360 degree range, so we have to "normalize" them a bit.
Due to the rotation order, it ends up "swirling" in 3D space and altering the other two rotations instead of maintaining a stable x-axis rotation change.

With that said, here is my code:

// C#

if (current_euler.z < 180f)
{
   rot = Quaternion.Euler(rotation_angle.x, current_euler.y, current_euler.z);
} else
{
   rot = Quaternion.Euler(rotation_angle.x, current_euler.y-180, current_euler.z-180);
}

Ignore the (if < 180). That's just so I can get this test running and working. I'll find a proper way to normalize it later.

Anyway, this snippet works, but has one problem: It twirls in 3D space and doesn't remain locked on its x-axis. I've tried numerous other solutions, but they either spin out of control or... they all spun out of control.

My question: Is there a way to set the rotation by rotating on one axis, while allowing the other rotations to change at the user's command without it "swirling" in 3D space?

EDIT: SOLUTION

For my use case I was able to use transform.localScale and modify it's Y-scale as a solution to my issue. It has the exact effect as I was looking for, and is definitely more stable. I accepted @Lunin's answer, however, as it seems to be another possible solution, and is written on this forum :).

To clarify, my wish was to rotate a 2D object on its x-axis, which would cause it to rotate vertically. At the same time, I wanted to allow the other axes to be editable at any given time. I can mimic a vertical rotation by changing the y-scale of the 2D object. +1 y-scale is normal, -1 y-scale is flipped upside down. Since I only needed that one axis to change, this workaround worked perfectly.


texts: How to resolve concurrent ramp collisions in 2d platformer?

texts:
A bit about the physics engine: Bodies are all rectangles. Bodies are sorted at the beginning of every update loop based on the body-in-motion's horizontal and vertical velocity (to avoid sticky walls/floors). Solid bodies are resolved by testing the body-in-motion's new X with the old Y and adjusting if necessary before testing the new X with the new Y, again adjusting if necessary. Works great.

Ramps (rectangles with a flag set indicating bottom-left, bottom-right, etc) are resolved by calculating the ratio of penetration along the x-axis and setting a new Y accordingly (with some checks to make sure the body-in-motion isn't attacking from the tall or flat side, in which case the ramp is treated as a normal rectangle). This also works great.

Side-by-side ramps, eg. \/ and /\, work fine but things get jittery and unpredictable when a top-down ramp is directly above a bottom-up ramp, eg. < or > or when a bottom-up ramp runs right up to the ceiling/top-down ramp runs right down to the floor.

I've been able to lock it down somewhat by detecting whether the body-in-motion hadFloor when also colliding with a top-down ramp or hadCeiling when also colliding with a bottom-up ramp then resolving by calculating the ratio of penetration along the y-axis and setting the new X accordingly (the opposite of the normal behavior). But as soon as the body-in-motion jumps the hasFloor flag becomes false, the first ramp resolution pushes the body into collision with the second ramp and collision resolution becomes jittery again for a few frames.

I'm sure I'm making this more complicated than it needs to be. Can anyone recommend a good resource that outlines the best way to address this problem? (Please don't recommend I use something like Box2d or Chipmunk. Also, "redesign your levels" isn't an answer; the body-in-motion may at times be riding another body-in-motion, eg. a platform, that pushes it into a ramp so I'd like to be able to resolve this properly.)

Thanks!


texts: Finetuning movement based on gradual rotation towards a target

texts:
I have an object which moves towards a target destination by gradually adjusting its facing while moving forwards. If the target destination is in a "blind spot", then the object is incapable of reaching it.

This problem is ilustrated in the picture below. When the arrow is ordered to move to point A, it will only end up circling around it (following the red circle) because it is not able to adjust its rotation quickly enough.

I'm interested in a solution where the movement speed is multiplied by a number from 0.1 to 1 in proportion to necessity. The problem is, how do I calculate whether it is necessary in the first place? How do I calculate an appropriate multiplier that is neither too small nor too large?

    void moveToPoint(sf::Vector2f destination) {
        if (destination == position) return;

        auto movement_distance = distanceBetweenPoints(position, destination);
        desired_rotation = angleBetweenPoints(position, destination);

        /// Check whether rotation should be adjusted
        if (rotation != desired_rotation) {
            /// Check whether the object can achieve the desired rotation within the next adjustment of its rotation
            if (Radian::isWithinDistance(rotation, desired_rotation, rotation_speed)) {
                rotation = desired_rotation;
            } else {
                /// Determine whether to increment or decrement rotation in order to achieve desired rotation
                if (Radian::convert(desired_rotation - rotation) > 0) {
                    /// Increment rotation
                    rotation += rotation_speed;
                } else {
                    /// Decrement rotation
                    rotation -= rotation_speed;
                }
            }
        }

        if (movement_distance < movement_speed) {
            position = destination;
        } else {
            position.x = position.x + movement_speed*cos(rotation);
            position.y = position.y + movement_speed*sin(rotation);
        }
        updateGraphics();
    }


texts: XNA ModelMesh.Draw vs GraphicsDevice.DrawIndexedPrimitives

texts:
I am using XNA 4.0 and I wonder if drawing models with multiple meshes is better by filling the vertex and index buffers first and calling GraphicsDevice.DrawIndexedPrimitives() or by simply using good ol' foreach(...) {ModelMesh.Draw()}.

Is it possible to add data to vertex/index buffers at all in order to pack all the models on the scene in them and then call Draw only once per frame?

I would appreciate a link to an in-depth explanation.
Thanks.


texts:
I am writing my term paper about Path finding algorithms in games, and i've got a couple of questions, hopefully you people could help me out with those ;)

So, i've done a little bit of searching around here and stumbled on this question. Now, the things are explained nicely there, but i wonder if anyone got examples of games using those? (obviously A* won't be hard to find, it seems to be quite popular now). I figured that BFS or DFS would probably be found in some older games but I'm not that familiar with those, perhaps someone knows a couple that might be using those algorithms so i could investigate deeper?

Also, i'm having trouble figuring out the strong/weak sides of those algorithms compared to each other, as in when should i use BFS instead of Dijkstra's Method for example, from both efficiency and mechanics point of view? (If amount of available memory isn't the issue). Or is A* an answer to all the prayers and there is no reason not to use it?

Any help would be appreciated!


texts: How do I access my existing script from a different script attached to a different gameobject?

texts:
I have my health (script) component on my player GameObject that gets boosted whenever we tap on that GameObject. However, I want to add a separate GUI texture button GameObject and tap on that to boost my health.

How do I access the health script with this new button button to get it working? I actually want to test this method for tapping on my health packs to increase the health.

This is the existing script I want to access:

//this is my health bar script which increases by tapping
var health = 300;

function OnGUI(){
    if(GUI.Button(Rect(10,10,health,10), "")){
        health += 25;
    }
}


texts: How to implement a slight skid in a car game

texts:
I have a top down car game, where I'm trying to allow a slight skid; I've tried the following code to calculate the X and Y, but there is no skid whatsoever:

radians = rotation * Math.PI / 180;

aX = (momentum * Math.cos(radians));
aY = (momentum * Math.sin(radians));

newX = playerX + aX,
newY = playerY + aY

I can get skid by introducing a velocity variable; for example:

radians = rotation * Math.PI / 180;

aX = (momentum * Math.cos(radians));
aY = (momentum * Math.sin(radians));

velocityX = velocityX + aX;
velocityY = velocityY + aY;

newX = playerX + velocityX;
newY = playerY + velocityY;

This introduces far too much skid, like the car is on ice.  I've tried reducing the amount I increase the velocity by:

velocityX = velocityX + (aX / 3);

Which sort of works initially, but still ends up ice skating and uncontrollable after playing around for a few minutes.

Are there any techniques for introducing a slight skid without this extreme side effect?


texts: Aligning pathfinding to the center of tiles?

texts:
I'm looking to achieve tile by tile movement in a project I'm working on. I employed the use of the asset Simply A* Path-finding to allow a unit to navigate the terrain.

Since the tiles are simply made out of 32x32 sprites, I set the tilesize of the pathfinder to 0.32 to produce the above grid.

However when tested out with a unit, the unit often does not align itself to the center of the sprite as shown in the image below.

I am pretty new to unity and would appreciate if someone could input on how I can fix this or advise on an alternate method to allow this "tile to tile" path finding to work.


texts: Combine rotation XZ (horizontal) with YZ (vertical). Math formula

texts:
I'm trying to make a rotation vertically and horizontally around a point at the same time but I'm not able to combine both.

I have this formula for the horizontal rotation:

camera.position.x = x * Math.cos(inc) + z * Math.sin(inc)
camera.position.z = z * Math.cos(inc) - x * Math.sin(inc)

And this one for the vertical:

camera.position.y = y * Math.cos(inc) + z * Math.sin(inc)
camera.position.z = z * Math.cos(inc) - y * Math.sin(inc)

I guess I need to use a Matrix, but not sure how. Here an example with Three.js:
https://codepen.io/josema/pen/xyQoga


texts:
I was wondering how could I make in Android something like the popup messages seen in Candy Crush Saga, those messages like "Delicious!", "Tasty!" or similar:

As well as the score of each movement, they will pop up at first and then vanish:

How could I implement something like that in Android?


texts: How to make my simple round sprite look right in XNA

texts:
Ok, I'm very new to graphics programming (but not new to coding). I'm trying to load a simple image in XNA which I can do fine. It is a simple round circle which I made in photoshop. The problem is the edges show up rough when I draw it on the screen even with the exact size. The anti-aliasing is missing. I'm sure I'm missing something very simple:

        GraphicsDevice.Clear(Color.Black);

        // TODO: Add your drawing code here
        spriteBatch.Begin();
        spriteBatch.Draw(circle, new Rectangle(10, 10, 10, 10), Color.White);
        spriteBatch.End();

Couldn't post picture because I'm a first time poster. But my smooth png circle has rough edges. So I found that if I added:

spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied);

I can get a smooth image when the image is the same size as the original png. But if I want to scale that image up or down then the rough edges return. How do I get XNA to smoothly resize my simple round image to a smaller size without getting the rough edges?


texts: How to create a grid based on random shapes?

texts:
How to create a "grid" using actionscript like the image below?

Basically you have an area of 1100x615 which should be filled with shapes that could be rotated and scaled...

Collision detection perhaps or something less cpu intensive for flash (as3) to manage?


texts:
Is anyone aware of a nice 3D map tutorial (how to import and use the map) using XNA without any engine but not limited to an external application (like Tiled for 2D maps) ?

I did a search arund here but have'nt found anything towards xna 3d maps only 2d.

PS: I am looking for material that can be read online with no cost if possible.

I would be very interested in knowing any other contents related to this subject other then what  Ricket contributed.

Best regards.


texts: C# XNA How to work out minimum distance to decelerate and stop at a point

texts:
I am building a game in C# using XNA.

I am currently trying to get a character to always travel to the middle of the map which is located a point (0,0,0). I want the character to accelerate to the middle and then decelerate before it hits the middle so it will come to a stop at (or very close to) the middle.

Rate of acceleration does not change. Velocity is a Vector3 and for the purpose of this i will only worry about the X axis.

What I am trying to work out is at what point should I start decelerating to come to a stop in the middle depending on velocity and position.

I have tried to simplify the following code as much as possible

In My Update Method I basically call two methods

    Move(gameTime);
    HandleAcceleration();

Handle Acceleration is very simple

 this.Transform.TranslateIncrement = this.Velocity;

Move method

protected void Move(GameTime gameTime)
{
    //GetDirection just returns 1 or -1 to accelerate the appropriate direction
    int direction = GetDirection((int)this.Transform.Translation.X);

    //This Is where I have trouble With GetMinDecelerationDistance()
    if (GetDistanceToMiddle() <= GetMinDecelerationDistance())
    {
        //Pass in -direction to decelerate(Accelerate opposite direction)
        Accelerate(gameTime, AxisDirectionType.X, -direction);
    }
    else
    {
        Accelerate(gameTime, AxisDirectionType.X, direction);
    }
}

My Accelerate Method

    VelocityX += (this.acceleration * gameTime.ElapsedGameTime.Milliseconds) * direction;

    this.Velocity = (new Vector3(VelocityX, 0, 0));

The problem I am having is how to implement the GetMinDecelerationDistance() Method. I know I need to do something with the Velocity and the position but I have no Idea what. Keep in mind the acceleration rate is always the same and the middle is at point 0.

Basically my question is how do I implement GetMinDecelerationDistance() given that I know the Velocity and position, Acceleration is constant and I want to stop at point 0.


texts: what is the name for the category of game that use a real time clock as the game time like die2nite.com

texts:
I was looking for more game like http://www.die2nite.com and http://mush.twinoid.com/
They use real time as the fictional time.
Player are given a number of action point they can use freely during a 24 hour cycle.

It was quite common to see these kind of games  10 years ago and would really like to explore some more. Any idea what the category is called and where could I find more game like this. Any more example of such games would be great,

Thanks


texts: Multiplayer FPS Gameplay: How to encourage players to dispense ammo?

texts:
In the Battlefield: Hardline beta, players can now obtain health and ammo directly from other players, without having to ask for it via the command rose.

Here's two examples of how asking for health and/or ammo differed between most Battlefield games and Battlefield: Hardline. We'll have two players in these scenarios: A and B. Player A, who is not a Support-class player, is running low on ammunition. Player B, being a Support-class player, has ammo that he can give to Player A.

Example 1 - up to Battlefield 4: Player A tells Player B, "I need some ammo!" Player B will either…

respond by dispensing ammo for Player A; or
not respond, for whatever reasons. Player A has to either keep telling Player B that he needs ammo, or get his attention first.

Example 2 - Battlefield: Hardline: instead of bothering to tell Player B that he needs ammo, Player A walks up to Player B and presses a button. Player A's ammo is replenished.

From looking at each scenario's differences, Example 2 is the most efficient choice. Compared to Example 1, there's no uncertainty about getting the ammo at all. On the other hand, Example 2 costs both players the benefit of team communication (at least with getting health and ammo).

Should there be some sort of penalty for Example 2-esque scenarios, that will encourage players to dispense ammo for their teammates? One possible route can be to take away from a player's EXP for letting other players take ammo from them, directly (and too often).


texts: How to fill a rectangle with tilable texture in XNA?

texts: So, question in the title. I don't know how to create infinite seamless background.


texts: Issue with rotating particle effects with DrawUserPrimitves

texts:
I am creating a voxel-like game in XNA/Monogame. I am trying to create particle effect of which I create by making a list that is populated every frame. My issue is here: I am using a WorldMatrix to help rotate the particles, but I don't see how I can rotate them with a translating because each particle is different. Here is an example:

partEffect.CurrentTechnique = partEffect.Techniques[0];
        partEffect.Parameters["View"].SetValue(camera.viewMatrix);
        partEffect.Parameters["Projection"].SetValue(camera.projectionMatrix);
        Vector3 rotAxis = new Vector3(1,0,0);
        Vector3 rotAxis1 = new Vector3(0, 1, 0);

        rotAxis.Normalize();
        Matrix worldMatrix = Matrix.CreateTranslation(-20.0f / 3.0f, -10.0f / 3.0f, 0);// *Matrix.CreateFromAxisAngle(rotAxis1, camera.HORIZONTAL) * Matrix.CreateFromAxisAngle(rotAxis, camera.VERTICAL);// *Matrix.CreateFromAxisAngle(rotAxis1, camera.HORIZONTAL);//RotateToFace(vertices[0].Position, camera.Position, new Vector3(0, 1, 0));//Matrix.CreateBillboard(vertices[0].Position, camera.Position, new Vector3(0, 1, 0), new Vector3(0,0,0));//Matrix.CreateFromAxisAngle(rotAxis, angle);//Matrix.CreateTranslation(-20.0f / 3.0f, -10.0f / 3.0f, 0) * Matrix.CreateFromAxisAngle(rotAxis, angle);
        partEffect.Parameters["World"].SetValue(worldMatrix);

The next code that I call after that is the actual draw code, but my problem is here: How do I modify that translation when it seems to be static while each particle is different? Here is my draw effect:

foreach (EffectPass pass in partEffect.CurrentTechnique.Passes)
{
pass.Apply();
     GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 1, VertexPositionColor.VertexDeclaration);
}

So as you can see, the Matrix.CreateTranslation is called before I run my actual draw code. I just don't see how I can modify that translation so it works for every particle instead of just the translation for the single particle. Any insight would be greatly appreciated.


texts: NullReferenceException shown every single time a change is applied to my prefab

texts:
I created a prefab out of a game object in my scene. Every single time I hit Apply after making changes to my game object, I see the following stack trace:

However, as far as I can surmise, the changes are applied nonetheless, because the bolded field (indicating that its value is yet to be applied to the prefab) immediately becomes un-bolded once I hit Apply.

If, contrary to my belief, my changes are not applied to my prefab, what should I do to ensure that they are?
If the error message appears even when I successfully apply my changes to my prefab, what can I do to make it go away?

UPDATE 1:

I noticed that after the first time I hit Apply, the game object went from being highlighted in blue (indicating that it mirrors a prefab) to being highlighted in black (indicating that it no longer mirrors a prefab).

Game objects that mirror other prefabs work fine. This is the only exception.

UPDATE 2:

I deleted the prefab, and created another prefab from the same game object. This time, after hitting Apply, I still see the same exception, but the game object remains highlighted in blue (indicating that it is still mirroring a prefab).


texts: The meaning of colours in other cultures

texts:
According to http://www.color-wheel-pro.com/color-meaning.html and many other western websites certain colours have meanings.

To summarise the meaning of colours in the context of a typical RTS game:

red = danger or enemy
gold = wealth or high quality
yellow = energy
green = healing
aqua = protection
blue = power
pink = romance
white/grey = neutral territory
black = mystery

(There are many more meanings that I deliberately left out as it is not applicable to games)

However this information was collected from western websites.

If I have to design a game that needs to be played internationally, would it make sense to go with the above "colour rules" or could I expect that other cultures like the Eastern or African cultures could have a significant different association with colours than the Western cultures?

If so, would it make sense to not only translate the text of a game for a foreign culture, but also translate the colours too?


texts: Unity - SerializedObject.ApplyModifiedProperties() using relavant property setting method

texts:
The problem I have is this.
I have an editor script, at the end of OnInspectorGUI() I want to apply all the changes with the serialized object.
The simplest way to show my problem is thus:

[SerializeField]
private bool _property;
public bool property
{
    get { return _property; }
    set
    {
        _property = value;
        //do some amazing stuff
    }
}

public override void OnInspectorGUI()
{
    serializedObject.Update();
    prop = serializedObject.FindProperty("_property");
    //blah blah blah
    serializedObject.ApplyModifiedProperties();
}

But in order to do my special amazing code represented by the comment 'do some amazing stuff', I have to copy and paste the code or do away with the gets & sets entirely, opting instead for some kind of post-update, all-in-one refresh function.
Ideally, I want to tell SerializedObject, 'Hey, don't do _property = value, do property = value instead!'
Pretty sure that's not possible though, so what should I do instead?


texts: How do I resolve a collision involving more than two objects?

texts:
I have working functions that compute the overlapping polyhedron, contact points, depth of penetration (DOP), etc. of the overlap between two objects with convex polyhedra shapes.

I know how to resolve the collision between two colliding movable objects, for example by moving one of them DOP units along the penetration normal.

Problem: What is a simple method to resolve collisions between more than two objects? For example, let's say objects A, B and C are in collision such that A overlaps with B, and B overlaps with C. If I move A to resolve its collision with B, then A might overlap with C (or any other object in the scene), and now if I resolve the collision between A and C, one of them might overlap with another object. To me, it seems an endless chaining effect. Is there any standard algorithm to resolve collisions between more than two objects simultaneously (batch collision resolving) such that at the end of the day, there are no pairs of objects overlapping?

Note: In my problem statement it is assumed that a scene initially filled with possibly overlapping objects with convex polyhedron shapes is given to my collision resolver engine.


texts: How do I create a server for an existing game I don't have the source for?

texts:
I was wondering if it is possible to create a dedicated game server for a game that already exists and you don't have access to. For example, a game on Steam that only allows multiplayer through hosting a game with your running client. A client can host a server but only while the hoster is also playing the game.

The question being, is it possible to write a server from scratch that can replace the game client host with a dedicated server that does not require a player hosting it? If so, how?


texts: Making The Player Stop Bouncing And Stop Sinking In The Ground In A Platformer XNA

texts:
Heres a problem i've been having. I have a platformer, and whenever my player hits the ground he keeps bounding. Here's the falling code

iceBoy.moveY++;
iceBoy.position.Y += moveY;

Now heres the collision code

if (HitGround())
{

    iceBoy.moveY = -4;

    if (gamepadState.IsButtonDown(Buttons.A))
    {
        iceBoy.moveY = -25;
    }

    touchGround = false;
}

i tried lowering the iceBoy.moveY = -4, or iceBoy.moveY -= 1, but then ice boy just falls through the ground never to be seen again. How to i make it so he stops bouncing and without him falling staright through a block?

UPDATE 1:
At just -4, he bounces little enough too make it look kind of good, but he sinks through the ground first then floats back up and it looks really bad. How can i fix this easily, with just a few lines of code