texts: Path finding to collect enough items before the fight with the enemy

texts:
So I have the following problem : a X by Y grid. On the grid there is a character and a monster and some items that give bonus points to the character's damage if picked and holes that must be avoided. The goal is to collect enough items to be able to defeat the monster, then navigate to the monster and fight it.

What kind of algorithm can be used to solve this problem?


texts: Determining whether to trigger random events

texts:
Say I want to trigger some event with a certain likelihood throughout gameplay. For example, say I want there to be a 5% chance of engine failure in a spaceship simulator that runs for an indeterminate length of time.

When and how do I determine if that event will occur? If I determine it will occur, how do I determine when it will occur?

The problem I see is that if you calculate the chance of a failure every tick, then there's a 5% chance of failure per tick, which means over two ticks there's more than a 5% chance - something like 8% I believe. Once the game ticks 1,000 or 1,000,000 times, it's almost certain the engine will have failed (~100% chance) when there's only supposed to be "a 5% chance."

Say we somehow knew the game would last for ten minutes - then we could get a random number 1-100 and if it's 5 or less, say the engine will fail within those ten minutes. But then at minute 5, say the player upgrades his or her engine to a 2% failure rate. We could again roll the die and if we get 2 or less, the engine will fail within the next five minutes. But again, we've calculated the chances of failure twice, which means it's more likely to fail than if we calculated those chances only once.

When we look at in-game items, they never say "5% chance of failure per frame, per minute, per game, etc." What does "x% chance" really mean and how do we get a computer to tell us if and when the event will occur?


texts: HLSL equivilant to "Object" data from "Texture Coordinate" node in Blender

texts:
I mocked up a shader how I wanted it with the node editor in Blender. Now I'm trying to write it in HLSL. In Blender there is a node group called "Texture Coordinate". If I use the "uv" node from the group it behaves like a normal unlit frag shader but if I use the "object" node to give coordinates to the texture, it ignores the uv data and just maps the texture like an image overlayed onto the object.

This is actually the effect I want. However, I can't find a way to replicate this in HLSL. As far as I can see I can use TEXCOORD0 and POSITION as texture coordinates to produce uv mapping and world mapping respectively for a texture onto an object. Maybe what I want is object mapping?

And if it matters I'm using a generated texture


texts: How to have coins burst out in random directions after destroying an object in unity?

texts:
I want coins to burst out of an obstacle in random directions after I destroy it, kind of like the rings in sonic. I have everything else done: the physics, bouncing, instantiating to coins. I just don't know how to get them to fly out in random directions.

Here's my script:

while (counter < 5) {
    counter++;
    Instantiate(token, transform.position, transform.rotation);
}
Destroy (gameObject, 0.4f);


texts:
How does the engine sound for a car (or whatever has an engine) work?

When you increase the throttle the engine sound changes but it's never quite the same. When programming such a system what is the high level view of how it works. I know that there is some looping involved in the sound files but how do you transition when for example you change gear or you increase/decrease the throttle? How would one go about getting and preparing the sound files?


texts: How do I draw a high-performanced scatter plot

texts:
I am new to DirectX and currently I'm trying to use it for data visualization, to be specific, a 3D scatter plot. There are very limited resources on the internet, and I have read part of Frank D Luna's book as suggested by many. I studied some samples provided by Microsoft and finally have a grasp on how the loops work inside programs.

However, since I need to manipulate a huge amount of data and require performance as much as possible, I run into something that I hardly find reference with current material.

Buffer Usage
I expect the points I plot to be constant after they are created, but the creation of points happens all the time, should I set the D3D11_USAGE to Default or Dynamic, and which method to call when I need to update the buffer?
I have noticed How to use UpdateSubresource and Map/Unmap?, and the presentation https://developer.nvidia.com/sites/default/files/akamai/gamedev/files/gdc12/Efficient_Buffer_Management_McDonald.pdf by NVIDIA. But what should I do if I do need frequent updates of buffer, while no update for each data in the buffer needed?
I noticed in the example "Simple Direct3D game" by Microsoft, it seem to rewrite the entire buffer each time it is updated.

        auto objects = m_game->RenderObjects();
    for (auto object = objects.begin(); object != objects.end(); object++)
    {
        (*object)->Render(d3dContext, m_constantBufferChangesEveryPrim.Get());
    }

Is it really so? And How should I only add new vertices into the buffer every time updating it?
Since the program is expected to run very fast, the buffer is expected to be updated much faster than once per frame. Can I write a method to update the buffer and add a new point into the buffer every time I call it? If I could, can I put it in another thread or is there any better method to realize it?
In the example the main loop of the game seems to be in GameMain::StartRenderLoop(), is this loop running once per frame? And what determines the frequency of the loop?

I might have many misconception on frame and rendering, so thank you very much for the patience and answers.


texts: How do I run my XBOX XNA game without a network connection?

texts:
I need to demo my XBOX XNA game in college. The college doesn't allow this type of device to connect to the network. I deployed my game to the Xbox and it is sitting in the games list along with my other games. It runs fine with a network connection but when its offline it comes up with an error message saying its needs a connection to run the game.

This makes no sense, the game is deployed on the Xbox memory, it must be some security policy or something!

Is there any way around this? The demo is on monday!


texts: Recursive backtracking sometimes missing a tile?

texts:
I have a basic recursive backtracking algorithm for a maze. It pretty much works but occasionally leaves some tiles in the corners untouched. This is the recursive function:

void GenerateMaze(Coordinate tilePos)
    {
        Debug.Log("MazeGen");
        tileMap[tilePos.x, tilePos.y].visited = true;
        Shuffle<Coordinate>(directions);
        foreach(Coordinate d in directions)
        {
            if (tilePos.x + d.x >= 0 &&
            tilePos.x + d.x < mapWidth &&
            tilePos.y + d.y >= 0 &&
            tilePos.y + d.y < mapHeight)
            {
                if (!tileMap[tilePos.x + d.x, tilePos.y + d.y].visited)
                {
                    Carve(tilePos, d);
                    GenerateMaze(new Coordinate(tilePos.x + d.x, tilePos.y + d.y));
                }
            }
        }
    }

This is how the Carve method looks like:

private void Carve(Coordinate position, Coordinate direction)
    {
        if (direction.Equals(new Coordinate(-1, 0)))
        {
            tileMap[position.x, position.y].west = true;
            tileMap[position.x + direction.x, position.y + direction.y].east = true;
        }
        else if (direction.Equals(new Coordinate(1, 0)))
        {
            tileMap[position.x, position.y].east = true;
            tileMap[position.x + direction.x, position.y + direction.y].west = true;
        }
        else if (direction.Equals(new Coordinate(0, -1)))
        {
            tileMap[position.x, position.y].south = true;
            tileMap[position.x + direction.x, position.y + direction.y].north = true;
        }
        else if (direction.Equals(new Coordinate(0, 1)))
        {
            tileMap[position.x, position.y].north = true;
            tileMap[position.x + direction.x, position.y + direction.y].south = true;
        }
    }

I'm betting on a typo or stupid mistake somewhere but I cannot find it. In my last result tileMap[4,4] stayed untouched without any walls. But the algorithm does backtrack as I often end up with dead ends. It does not happen often and up till now only on the sides.

Below is an example where two tiles on the bottom right have not been carved in too.

Here is another one without walls, this time 3 unconnected tiles in another corner of the maze.

Anyone can find whats wrong?


texts: Why my game is running slowly if it was launched from a wpf application?

texts:
i have some issues why my GameEditor. I would start my XNA project from it, like a debug-client. It opens and all works fine, but it runs on 45 frames until I hide the wpf form. then the framerate goes up and remains there, even if I return the wpf form.

    private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
    {
        var gameAppDomain = AppDomain.CreateDomain("Game");
        gameAppDomain.ExecuteAssembly(@"..\..\..\WindowsGame1\WindowsGame1\bin\x86\Debug\WindowsGame1.exe");
    }

the game is a just a new xna game without any rendering, except my framerate counter.

/// <summary>
///     This is the main type for your game
/// </summary>
public class Game1 : Game
{
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;
    private FrameRateCounter frameRateCounter;

    public Game1()
    {
        this.graphics = new GraphicsDeviceManager(this);
        this.Content.RootDirectory = "Content";
    }

    /// <summary>
    ///     Allows the game to perform any initialization it needs to before starting to run.
    ///     This is where it can query for any required services and load any non-graphic
    ///     related content.  Calling base.Initialize will enumerate through any components
    ///     and initialize them as well.
    /// </summary>
    protected override void Initialize()
    {
        // TODO: Add your initialization logic here
        this.frameRateCounter = new FrameRateCounter(this);
        base.Initialize();
    }

    /// <summary>
    ///     LoadContent will be called once per game and is the place to load
    ///     all of your content.
    /// </summary>
    protected override void LoadContent()
    {
        // Create a new SpriteBatch, which can be used to draw textures.
        this.spriteBatch = new SpriteBatch(this.GraphicsDevice);
        this.frameRateCounter.LoadContent();
        // TODO: use this.Content to load your game content here
    }

    /// <summary>
    ///     UnloadContent will be called once per game and is the place to unload
    ///     all content.
    /// </summary>
    protected override void UnloadContent()
    {
        // TODO: Unload any non ContentManager content here
    }

    /// <summary>
    ///     Allows the game to run logic such as updating the world,
    ///     checking for collisions, gathering input, and playing audio.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Update(GameTime gameTime)
    {
        this.frameRateCounter.StartUpdateTimer();

        // Allows the game to exit
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            this.Exit();

        // TODO: Add your update logic here

        base.Update(gameTime);
        this.frameRateCounter.EndUpdateTimer(gameTime);
    }

    /// <summary>
    ///     This is called when the game should draw itself.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Draw(GameTime gameTime)
    {
        this.frameRateCounter.StartDrawTimer();
        this.GraphicsDevice.Clear(Color.CornflowerBlue);

        // TODO: Add your drawing code here

        this.frameRateCounter.EndDrawTimer(gameTime);
        base.Draw(gameTime);
    }
}

If I do the same for a WinForms application, I dont have that issue.
My first try was to launch it in an TASK/Thread but then it crashes after 15-20 min if I have loaded my soundeffects. The event log says it was "XAudio2_6.dll_unloaded" with a access violation exception.

hre is my test game: https://www.dropbox.com/s/gtt49lwquyoo86e/WindowsGame1.zip?dl=0


texts:
I'm going to write a server for an online multiplayer with these requirements:

Pretty simple turn based game (think a card game) that is played entirely on the server (security reasons)
Must be able to run multiple games (tables) with 4 players per table, but no lobby system required (another server takes care of that)
Can support as many players at once as possible; Might need multiple servers
Chat between players
Socket connection to a Flash/AIR client
Must be able to communicate with other servers (for player accounts and such)

Now, I'm considering two options:

Smartfox (or equivalent)
A custom Java solution in something like Tomcat

Why Smartfox?

It handles multiple rooms and chat natively
It presumably has solutions for well-known multiplayer gaming issues

Why custom?

Smartfox has many unneeded functions, bad for performance
Smartfox communicates with an XML-based format, I could use a more efficient binary one.
Don't know if running the entire game model on the server is convenient with Smartfox' extension mechanism
Multiple rooms and chat are easy to reimplement
Tomcat or a lightweight container is easier to deploy than Smartfox
Better IDE support for developing on Tomcat (automatic deploy, etc)

What do you think? Are my assumptions correct? Do you have anything to add? What option should I choose (or maybe a different one entirely)?


texts: How on earth do you get decent color out of 2BPP?

texts: I've been looking into PowerVR textures, and have run into several textures that are apparently 2 bits per-pixel. This, frankly, boggles my mind. How does one get even half way decent color preservation when you only have 4 possible states per pi per pixel? I would love any resources out there that talk about the compression behind such a feat. Thanks!


texts:
I am trying to implement Normal-Oriented SSAO and i'm having an issue with the results.  Portions of the screen are inverted/wrong, typically half way through the screen but not always, it seems tied to the camera, but can also be anything lol.  Here is the resulting render:

And here is the SSAO Shader:

void main()
{

  vec3 WorldPosition = texture(GPositionsTexture, In_TexCoords).xyz;
  vec3 WorldNormal = normalize(UnScaleNormal( texture( GNormalsTexture, In_TexCoords ).xyz ));

  vec3 Random = texture(KernalNoiseTexture, In_TexCoords * KernelNoiseScale).xyz;
  vec3 Tangent = normalize(Random - WorldNormal * dot(Random, WorldNormal));
  vec3 BiTangent = cross(WorldNormal, Tangent);
  mat3 TBN = mat3(Tangent, BiTangent, WorldNormal);

  float Occlusion = 0.0;
  for (int i = 0; i < KERNEL_SIZE; ++i)
  {
    // get sample position:
    vec3 Sample = inverse(TBN) * Kernel[i];
    Sample = Sample * Radius + WorldPosition;

    // project sample position:
    vec4 Offset = vec4(Sample, 1.0);
    Offset = CamData.Projection * CamData.View * Offset;
    Offset.xy /= Offset.w;
    Offset.xy = Offset.xy * 0.5 + 0.5;

    // get sample depth:
    float SampleDepth = texture(GPositionsTexture, Offset.xy).z;

    // range check & accumulate:
    float RangeCheck= abs(WorldPosition.z - SampleDepth) < Radius ? 1.0 : 0.0;
    Occlusion += (SampleDepth <= Sample.z ? 1.0 : 0.0) * RangeCheck;
  }

Occlusion = 1 - (Occlusion / KERNEL_SIZE);

Out_Diffuse = pow(Occlusion, Power);
}


texts: How to get the mouse events in an unreal engine editor plugin?

texts: I would like to react to user inputs in an editor plugin, how can I do that? In a game I can use a custom Pawn or a custom PlayerController but how can I do it in the editor?


texts: Frame Buffer Objects vs calling TexCoord2f?

texts:
I'm learning the basics of OpenGL with lwjgl currently, and following a guide I've got textured quads that can move around a scene.

I've been reading about Frame Buffer Objects, and I'm not really clear on their purpose and their benefit.

My understanding is that I'll create a FBO with the texture I'd like, load the FBO, draw a quad, then unload the FBO. What would the technique I'm currently doing for texture management be called, and how does it differ from using FBOs?

What are the benefits to using FBOs? How does it fit into the grand rendering scheme of things?


texts: Render-to-texture doesn't work on nvidia cards. OpenGL 3.3

texts:
I've implemented some postprocessing effects (DOF, HDR, Bloom) into my engine. I've tested it on AMD card which supports OpenGL 4.2. Yesterday I've made a test on NVidia card which supports only OpenGL 3.3. I tried to write my code to works also in OpenGL 3.3 but I was suprised when I saw something like on the screen:

It seems that textures are filled with random values and never change during app life (only when I'm changing dimensions of textures so basically recreate them). It happens mostly when I want downscale texture to some size (I use 2 textures to do that and a shader). Here is some examples of my code which implements Bloom effect:

Creating framebuffer:

if (!_p_buffer)glGenFramebuffers(1, &_p_buffer); // generate postprocess buffer
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _p_buffer);

    for (int i = 0; i < 2; i++){
        _lens[i].create(x / D.lensDownsample(), y / D.lensDownsample(), 0, IMAGE_16F_3, IMAGE_2D, true, FILTER_LINEAR); // create Lens Flare texture (with half resolution)
        glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT2 + i, GL_TEXTURE_2D, _lens[i].get(), 0);
    }

Render-to-texture:

glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _p_buffer);

// first downsample image
glDrawBuffer(GL_COLOR_ATTACHMENT2);
glClear(GL_COLOR_BUFFER_BIT);

glActiveTexture(GL_TEXTURE0);
_aux[_aux_number].lock();

Shaders["ScaleBias"].set(true);
Shaders["ScaleBias"].set("scale", Vector4(1.2f));
Shaders["ScaleBias"].set("bias", Vector4(-0.4));
Shaders["ScaleBias"].set("texelSize", Vector2(1 / (float)D.x() * D.lensDownsample(), 1 / (float)D.y() * (float)D.lensDownsample()));

glViewport(0, 0, D.x() / D.lensDownsample(), D.y() / D.lensDownsample());
Quad();

ScaleBias shader:

void main() {
    FragColor = max(vec4(0.0), texture(col, gl_FragCoord.xy*texelSize) + bias) * scale;
}

What "create" method actually does here:

if(!_image)glGenTextures(1, &_image);

glBindTexture(GL_TEXTURE_2D, _image);

glTexParameteri(_gl_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(_gl_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(_gl_target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri(_gl_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(_gl_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, x, y, 0, GL_RGB,GL_FLOAT, NULL);

I used debug extension to check if there is any invalid parameters but debuging shows nothing interesting. I tried make G-Buffer textures as GL_FLOAT but they works ok. I tried make shader as simple as possible (return color texture) but error still was valid. I've observed similar problem on newer NVidia cards but the only difference was that textures are clear (black). But they still didn't update. Framebuffer doesn't output any errors.

Could you point me out the cause of this bug or give some clue?


texts: (DX11.1) CreateSwapChainForHwnd fails with E_NOINTERFACE when using Graphics Diagnostics

texts:
The CreateSwapChainForHwnd fails with E_NOINTERFACE "No such interface supported" when I use the Graphics Diagnostics on Visual Studio 2013 Update 4 on Windows 7 sp1 under DirectX 11.1. The program runs fine in debug mode. Has anyone come across this problem before or know of a solution?

Here is the initialisation code:

#include <d3d11_1.h>

// Set feature levels supported by our application
D3D_FEATURE_LEVEL eFeatureLevel1[] =
{
    D3D_FEATURE_LEVEL_11_1,
    D3D_FEATURE_LEVEL_11_0,
    D3D_FEATURE_LEVEL_10_1,
    D3D_FEATURE_LEVEL_10_0,
    D3D_FEATURE_LEVEL_9_3,
    D3D_FEATURE_LEVEL_9_2,
    D3D_FEATURE_LEVEL_9_1
};

D3D_FEATURE_LEVEL           eReturnedFeatureLevel;

D3D11CreateDevice(nullptr,                  // default adapter
    D3D_DRIVER_TYPE_HARDWARE,
    0,                          // no software device
    uiCreateDeviceFlags,
    eFeatureLevel1,
    ARRAYSIZE(eFeatureLevel1),
    D3D11_SDK_VERSION,
    &m_spDeviceOld,
    &eReturnedFeatureLevel,
    &m_spContextOld);

if (eReturnedFeatureLevel < D3D_FEATURE_LEVEL_11_0)
{
    //MessageBox fails silently here!!!
    return false;
}

// Fetch the underlying interfaces and store them:
m_spDeviceOld.As(&m_spD3DDevice);
m_spContextOld.As(&m_spD3DImmediateContext);

SETPRIVATEDATA(m_spDeviceOld, "CD3DObject::m_spDeviceOld");
SETPRIVATEDATA(m_spContextOld, "CD3DObject::m_spDeviceOldspContextOld");

// This is the earliest the Debug Layer can be created
MyDebugLayer.CreateD3DDebugLayer();

SETPRIVATEDATA(m_spD3DDevice, "CD3DObject::m_spD3DDevice");
SETPRIVATEDATA(m_spD3DImmediateContext, "CD3DObject::m_spD3DImmediateContext");

m_spD3DDevice->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM,
                                            4,
                                            &m_ui4xMsaaQuality);

assert(m_ui4xMsaaQuality > 0);

DXGI_SWAP_CHAIN_DESC1 stSwpChainDesc = { 0 };
stSwpChainDesc.Width = 0;
stSwpChainDesc.Height = 0;
stSwpChainDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
stSwpChainDesc.Stereo = false;
stSwpChainDesc.SampleDesc.Count = 1;
stSwpChainDesc.SampleDesc.Quality = 0;
stSwpChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
stSwpChainDesc.BufferCount = 1;                                 // Used to be 1
stSwpChainDesc.Scaling = DXGI_SCALING_STRETCH;
stSwpChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
stSwpChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

// Use 4X MSAA?
if (m_bEnable4xMsaa)
{
    stSwpChainDesc.SampleDesc.Count = 4;
    stSwpChainDesc.SampleDesc.Quality = m_ui4xMsaaQuality - 1;
}
// No MSAA
else
{
    stSwpChainDesc.SampleDesc.Count = 1;
    stSwpChainDesc.SampleDesc.Quality = 0;
}

Microsoft::WRL::ComPtr<IDXGIDevice1> spDXGIDevice;
m_spD3DDevice.As(&spDXGIDevice);

IDXGIAdapter1* pDxgiAdapter = 0;
spDXGIDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&pDxgiAdapter);

IDXGIFactory2* pDxgiFactory = 0;
pDxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&pDxgiFactory);

// Create DXGI swap chain targeting a window handle (the only Windows 7-compatible option)
HRESULT MyHr = pDxgiFactory->CreateSwapChainForHwnd((ID3D11Device*)m_spD3DDevice.Get(), m_hMainWnd, &stSwpChainDesc, nullptr, nullptr, &m_spSwapChain);

//MessageBox fails silently here!!!
//MessageBox(m_hMainWnd, _com_error(MyHr).ErrorMessage(), "Error Caputed", MB_OK);

ReleaseCOM(pDxgiAdapter);
ReleaseCOM(pDxgiFactory);
spDXGIDevice->Release();

Why does the code fail when I use the graphics diagnostics tool and not normally? Basically the main window appears then the application shuts down. Also any calls to MessageBox([NULL/or not]) fails silently too.

Supplemental: m_spDeviceOld and m_spContextOld are ID3D11Device and ID3D11DeviceContext used for getting the 11.1 interface they then are detached at exit and the 11.1 interfaces are released instead.

Thanks in advance for your indelible advice.


texts: How to improve the charactercontroller for jumping?

texts:
I have an issue with my character controller, when I jump, it sometimes lands on surfaces it shouldn't be able to land on, like very steep slopes etc (even though my max slope is 45 deg). In this case, Controller.isGrounded() still is true. The controller doesn't fall off the steep slopes either, it just stays there and the controller can jump again.

I also notice that the controller sometimes can climb heights very awkardly (after jumping), like it is barely touching the elevated ground surface yet it can "push move" to climb it's way up

These problems both occur in the standard implementation given by unity https://docs.unity3d.com/ScriptReference/CharacterController.Move.html

See also: https://i.imgur.com/AD6dVy2.png (here it can jump on the steep slope and stay there, UCC is the example script from unity copy pasted)

How can I fix these things? Are there any existing solutions or guides for better character controllers?


texts: OpenGL: How to map point inside frustrum to normal device coordinates (NDC)?

texts:
I read this article http://www.songho.ca/opengl/gl_projectionmatrix.html.
It's explain how calculate projection matrix coefficients.
But I completely can't understand how author perform mapping from frustrum to NDC.

Why x_n perpendicular to x_p? I can't imagine it. Maybe someone can explain it? Or share useful source.


texts: How does the double-buffered canvas know when to swap the buffer?

texts: How does the HTML5 canvas know that all the drawing operations are complete and it's time to swap the buffer ? Program can have multiple draw calls at different places so how will it know when is the right time to swap the front and back buffers ?


texts: Why when I change some values of propertie in the inspector of my script it's highlightnig the text?

texts:
A simple script that attached to a GameObject in the Hierarchy:

First the variable in the editor in the inspector of the script Speed Change Wait was highlighted I mean it's much black painted then the rest.

Then when I changed or changing other variables values in the editor in the inspector they are also become more black painted.
In the screenshot the Headers like Door Init or Door Moves should be in black and painted more then the rest. But now also the other variables like this. I can't figure out why.

For example Random Speed Range is not yet in highlighted black but once I will change it's value it will too.

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

public class GateControl : MonoBehaviour
{
    [Header("Door Init")]
    [Space(5)]

    public Transform door;

    [Header("Door Moves")]
    [Space(5)]

    public float doorMovingLength = 64f;

    [Header("Door Speed")]
    [Space(5)]

    public float constantDoorSpeed = 1f;
    public float currentDoorSpeed;

    [Header("Door Random")]
    [Space(5)]

    public bool randomDoorSpeed = false;
    public int speedChangeWait = 7;
    [Range(0.3f, 10)]
    public float randomSpeedRange;

    private Vector3 originalDoorPosition;
    private bool isRising = true;
    private float fraq = 0;
    private float timer = 0;

    // Use this for initialization
    void Start()
    {
        originalDoorPosition = door.position;
        StartCoroutine(DoorSpeedWaitForSeconds());
    }

    // Update is called once per frame
    void Update()
    {
        if (isRising)
            fraq += Time.deltaTime * currentDoorSpeed;
        else
            fraq -= Time.deltaTime * currentDoorSpeed;

        if (fraq >= 1)
            isRising = false;
        if (fraq <= 0)
            isRising = true;

        fraq = Mathf.Clamp(fraq, 0, 1);

        door.position = Vector3.Lerp(originalDoorPosition,
            new Vector3(originalDoorPosition.x, originalDoorPosition.y, doorMovingLength),
            fraq);
    }

    IEnumerator DoorSpeedWaitForSeconds()
    {
        timer = 0;

        while (true)
        {
            if (randomDoorSpeed == true && randomSpeedRange > 0.3f)
                currentDoorSpeed = Random.Range(0.3f, randomSpeedRange);

            if (!randomDoorSpeed)
                currentDoorSpeed = constantDoorSpeed;//reset back to original value

            while (timer < speedChangeWait) { timer += Time.deltaTime; yield return null; }
            timer = 0;
        }
    }

    #if UNITY_EDITOR // make OnValidate() only exist in Editor mode
    private void OnValidate()
    {
        timer = 0;
    }
    #endif
}


texts: Translate velocity to mouse curos position

texts:
I have particles, with a velocity (x and y) per tick. I would like to to make my cursor a gravity force, so particles fly to the cursor's position.

How can I apply gravity (that is towards my cursor position) on my velocity (x and y)?


texts: How would you code an AI engine to allow communication in any programming language?

texts:
I developed a two-player iPhone board game. Computer players (AI) can either be local (in the game code) or remote running on a server. In the 2nd case, both client and server code are coded in Lua. On the server the actual AI code is separate from the TCP socket code and coroutine code (which spawns a separate instance of AI for each connecting client).

I want to be able to further isolate the AI code so that that part can be a module coded by anyone in their language of choice. How can I do this? What tecniques/technology would enable communication between the Lua TCP socket/coroutine code and the AI module?


texts: Where to install game from my game launcher

texts:
I've created a game launcher that I'm pretty proud of :). I use nw.js and so the interface uses html/javascript/css. It makes ajax api calls to my web service that I've written in C# to do things like register/login/news. I'm now looking at having my game launcher do the initial install of the actual game and updates.

My question is, where should the game be installed by default. I will allow them to change the location but what should the default game location be? This will be on Windows only at this time. My concern is that I've heard (and I don't know because I'm always admin on my PC) that you can run into issues if your game is in program files because of permissions.

Does anyone who has made a game launcher have experience around the downloading/copying/unzipping of game files in a game launcher?


texts: How do I implement wander behavior in GDX AI?

texts:
So I follow the original gdx-ai documentation and created 2 circles to test Steering behavior.

The image shows arrival behaviour but I am still quite lost about how they work.

Screen class:

public void show() {
        pCircle = new ShapeRenderer();
        pCircle.setProjectionMatrix(mCamera.combined);
        sCircle = new SteeringCircle(pCircle, 15, 128*5, 128, Color.BLUE);

        target = new SteeringCircle(pCircle, 15, 128,128*3 , Color.CYAN);
        /*
        Wander<Vector2> wanderSB = new Wander<Vector2>(sCircle);
        wanderSB.setEnabled(true);
        wanderSB.setTarget(target);*/
        Arrive<Vector2> arriveSB = new Arrive<Vector2>(sCircle, target).setTimeToTarget(0.1f).setArrivalTolerance(10f).setDecelerationRadius(25f);

        sCircle.setBehavior(arriveSB);
}

   @Override
    public void render(float delta) {

        Gdx.gl.glClearColor(63 / 255f, 128 / 255f, 70 / 255f, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        mCamera.update();
        mTiledMapRenderer.setView(mCamera);

        mTiledMapRenderer.render();

        sCircle.update(delta);
        sCircle.render();

        target.render();

        mBatch.setProjectionMatrix(mCamera.combined);

        mBatch.begin();
        mBatch.draw(img, 128, 0);

        mBatch.end();

    }

SteeringCircle class:

   public SteeringCircle(ShapeRenderer circle ,float boundingRadius, float x, float y, Color color) {
        pCircle = circle;
        mColor = color;
        this.position = newVector();
        this.position.x = x;
        this.position.y = y;
        this.boundingRadius = boundingRadius;
        this.maxLinearSpeed = 50;
        this.maxLinearAcceleration = 5000;
        this.linearVelocity = new Vector2(15,15);
        this.maxAngularSpeed = 30;
        this.maxLinearAcceleration = 5;

        this.tagged = false;

        this.steeringOutput = new SteeringAcceleration<Vector2>(new Vector2());

    }

@Override
    public Location<Vector2> newLocation() {

        return null;
    }

public void update (float delta) {
        if (steeringBehavior != null) {
            // Calculate steering acceleration
            steeringBehavior.calculateSteering(steeringOutput);

            // Apply steering acceleration to move this agent
            applySteering(steeringOutput, delta);
        }
    }

    private void applySteering (SteeringAcceleration<Vector2> steering, float time) {
        // Update position and linear velocity. Velocity is trimmed to maximum speed
        this.position.mulAdd(linearVelocity, time);
        this.linearVelocity.mulAdd(steering.linear, time).limit(this.getMaxLinearSpeed());

        // Update orientation and angular velocity
        if (independentFacing) {
            this.orientation += angularVelocity * time;
            this.angularVelocity += steering.angular * time;
        } else {
            // For non-independent facing we have to align orientation to linear velocity
            float newOrientation = calculateOrientationFromLinearVelocity(this);
            if (newOrientation != this.orientation) {
                this.angularVelocity = (newOrientation - this.orientation) * time;
                this.orientation = newOrientation;
            }
        }
    }

For the arrival behaviour, the blue circle will move from the original position towards the Cyan circle and comes back to the circle back and forth. I thought the blue circle is supposed to stop when arriving the cyan circle which it didn't.  How can I make it stop at arrival? what's wrong with the codes?
For the wander behaviour, the blue circle just moves north-east direction and never goes back to the cyan circle. I thought it will wander around but it didn't. Any advice on what is needed to change to make the wander behaviour happens?

Also, does anyone know what should Location returns? Isn't Vector2 position already has the location?


texts:
Given the academic definition of a Stack as "A data structure where items are added in a FILO manner and accessed in such a way that only the top item may be examined or removed to be modified."

Game view implementations that call them "stacks" where each view is pushed onto the top or popped off the top and each view below it is visible seems to violate the above definition. The first part is valid, views are only added/removed from the top but the fact that each other view in the stack is still visible from top-down seems to violate the principle that only the top is accessible for examination or modification.

That said, are these implementations actually Stacks in the data structure sense of the word or just wrapped fully accessible arrays with fancy methods called pop and push added to them?


texts: How can I find the location of OpenGL object after rotation?

texts:
I have a rotating object, a cube, which I rotate in OpenGL as follows:

gl.glPushMatrix();
gl.glTranslatef(400.0f, 300.0f, 1300.0f);
gl.glRotatef(m_x, 4.0f, 0.0f, 0.0f);
gl.glRotatef(m_y, 0.0f, 4.0f, 0.0f);
gl.glRotatef(m_z, 0.0f, 0.0f, 42.0f);
gl.glCallList(++shapeNumber); // cube 2
gl.glPopMatrix();

(m_x, m_y, and m_z are the change in the rotation each frame.)

I want to detect a collision between the camera and that rotating object, and to do that I need to get the coordinates of the rotated object in real time. How can I accomplish that?


texts: Problem with draw distance in Unity editor 3D view

texts:
The Unity editor scene renderer is not letting me get a close-up view of anything.  As the camera moves closer, the geometry closest to the camera just disappears.  It's as if the draw distance has become far-sighted.

In the example above, the geometry of the green object (a car mesh) is being cut off as I pull the camera in.  The floor is also disappearing, as shown by the grey cut-off at the bottom.

This is making is extremely difficult to line up colliders with render meshes, position smaller objects, and do other detailed tasks.  I don't remember my Unity doing this before about a month ago, but I have no idea what changed.  Is there a setting somewhere?  Has anyone else seen this?


texts:
I am developing an Android game using LibGDX and I have big world map made of polygons.

I use PolygonSprite and PolygonSpriteBatch, when I render map, I get 30-35fps and it feels laggy. I wonder if there is a way to cache polygons like sprites in SpriteCache and is it a good idea to cache part of the map which is currently on camera?


texts: Can't remove JPanel from JFrame while adding new class into it

texts:
Basically, I have my Frame class, which instantiates all the properties for the JFrame, and draws a JLabel with an image (my title screen). Then I made a separate JPanel with a start button on it, and made a mouse listener that will allow me to remove these objects while adding in a new Board() class (Which paints the main game).

*Note: The JLabel is SEPARATE from the JPanel, but it still gets moved to the side by it.

Problem: Whenever I click the button though, it only shows a little square of what I presume is my board class trying to run.  Code below for the Frame Class:

package OurPackage;
//Made By A.K. 5/24/12
//Contains Frame.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.*;
import javax.swing.plaf.basic.BasicOptionPaneUI.ButtonActionListener;

public class Frame implements MouseListener
{
    public static boolean StartGame = false;
    ImageIcon img = new       ImageIcon(getClass().getResource("/Images/ActionJackTitle.png"));
    ImageIcon StartImg = new ImageIcon(getClass().getResource("/Images/JackStart.png"));
    public Image Title;
    JLabel TitleL = new JLabel(img);
    public JPanel panel = new JPanel();
    JButton StartB = new JButton(StartImg);
    JFrame frm = new JFrame("Action-Packed Jack");

    public Frame()
    {
        TitleL.setPreferredSize(new Dimension(1200, 420));
        frm.add(TitleL);

        frm.setLayout(new GridBagLayout());
        frm.add(panel);

        panel.setSize(new Dimension(220, 45));
        panel.setLayout(new GridBagLayout ());

        panel.add(StartB);
        StartB.addMouseListener(this);
        StartB.setPreferredSize(new Dimension(220, 45));

        frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frm.setSize(1200, 420);
        frm.setVisible(true);
        frm.setResizable(false);
        frm.setLocationRelativeTo(null);
    }

    public static void main(String[] args)
    {
        new Frame();
    }

    public void mouseClicked(MouseEvent e)
    {
            StartB.setContentAreaFilled(false);
            panel.remove(StartB);
            frm.remove(panel);
            frm.remove(TitleL);
            //frm.setLayout(null);
            frm.add(new Board()); //Add Game "Tiles" Or Content. x = 1200
            frm.validate();
            System.out.println("Hit!");
    }

    @Override
    public void mouseEntered(MouseEvent arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseExited(MouseEvent arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mousePressed(MouseEvent arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseReleased(MouseEvent arg0) {
        // TODO Auto-generated method stub

    }

}

EDIT: I also created a new Board Object(?) in my Frame class. Will I be able to resize it and such?


texts: SFML function does all the job with setting up timestep?

texts:
Usually i set up timestep something like this:

timestep=1.0f/60.0f;
if(time>=timestep)
{
update;
time-=timestep;
}

But SFML has the next function: window.setFramerateLimit(). Does it do the same thing i described above?


texts:
for 3D:
Q1 : I want to make zone range for each enemy in the game , so that when the player in the view range he will be chased .

Q2 :if I want to make enemy walk a little bit around his position ( from -10  to 10 ) for example , i.e as he is searching for some one , can you give me just steps ! thanks

Q3 : How to make enemy moves toward Player if he is being detected ?
Sorry for question , but I am new to this world :)


texts: Does an inventory limit in an MMORPG make sense?

texts:
I am currently developing a simple 2d MMORPG. My current focus is the inventory system.

I am currently wondering if I should implement a limit on what a player character can carry. Either in form of a maximum weight, a limited number of inventory slots, or a combination of both. Almost every MMORPG I ever played limits inventory space. But plausibility aside, is this really necessary from a gameplay point of view? Maybe it would in fact improve the game experience when I just let the players carry as much stuff as they want.

tl;dr: What is the game development rationale behind limiting carrying capacity of player characters?

Edit:
Thanks for all the answers so far. They all were very insightful. After your input I decided to go for a limited inventory to prevent people from carrying too many healing items and too much specialized equipment into dungeons. To avoid the problem of loot overload and having to return to the town all the time, I plan to give players the ability to send items from their inventory directly to their storage (but not the ability to retrieve them in the field). I accepted the answer by Kylotan for now, but do not let this discourage you from posting additional answers, when you feel that some interesting aspect wasn't covered yet.


texts: As a client, trying to get a coder/programmer to develop my ideas into a functioning program, what should I be providing to my developer(s)?

texts:
I am the director of a start-up game development group (I say "group" because it is not yet an official company). I have recently gained the willingness of a few coders who are willing to help me with the project, but they are asking for documentation.

I understand the need for documentation, and I have a lot of our ideas in a few different documents, but I imagine that I will want to organize it in some way that the developers can understand individually as well as collectively.

Is there anything I should leave out of such a document; if so, what kind of things? Is there an appropriate template for this kind of document; if yes, where can I find it? Is there anything else that I should know to offer the coders before they begin their work?

I know that I have many questions being asked here. I hope that isn't a problem. Thank you in advance for any guidance!


texts: Making a player move to my mouse when clicked?

texts:
How can I get my player to move to the mouse when it is clicked (like in Warcraft)?

So far I have tried:

if (Mouse.isButtonDown(0)) {

    if (X < Mouse.getX()) {
        X += Speed;
    }
    if (X > Mouse.getX()) {
        X -= Speed;
    }
    if (Y < Mouse.getY()) {
        Y += Speed;
    }
    if (Y > Mouse.getY()) {
        Y -= Speed;
    }
}

But that only does what I want if I hold the mouse down.


texts: Is it Possible to create one equipment piece, and handle the manipulation programatically

texts:
I have a 2D game made in XNA-4.0.  I am brainstorming on how to implement a system of equipment where I can draw one Texture, and rotate/scale it to my character's current animation without haveing to create a seperate Atlas for each Weapon/Gear Piece.

Right Now I have a Default Character Sprite Sheet that I use, and For each Item I wish to incorporate into the game, I draw it onto the Sprite Sheet, remove the character from the sprite sheet, then draw the new Sprite Sheet with just the visible parts of the given piece of equipment.  It works very well, and looks great... The only problem is that It requires a lot of work for each piece of gear I implement into the game.

Originally my hope was to Create one image, and have a system in place that can alter the texture as required to rotate and move with my hero's animations.  Since I am in 2D, I am restricted to Scaling and rotation images.

Is this goal of creating one image even a possibility?  If so I would love any direction to as how this might be achieved.


texts: How to fight against memory editing cheat software?

texts:
What is the best way to protect run-time memory from such software?

We just published an online game (written on AS3, Flash, published on a social network), and pretty much all of the players got max_int money just using a simple memory editor ("ArtMoney").


texts: Looking for JMonkeyEngine tutorials and documentation

texts: I'm looking for tutorials and documentation for JMonkeyEngine, beside the material on the official website. Any clue?


texts:
For my game, there's two types of items - stackable, and nonstackable.

Nonstackable items get assigned a unique ID that stays with it forever. A character ID is assosicated with the item, as is a state (CHANGED, UNCHANGED, NEW, REMOVED). The character ID and state is used for item saving purposes.

Stackable items have one unique ID, as in the entire stack has one unique ID. For example: 5 Potions (stacked ontop of each other) has one unique ID.

When dropping a nonstackable item, the state gets set to REMOVED, and the unique ID and state don't change. If picked up by another player, the state gets set to NEW, and the character ID gets changed to the new character's ID.

When dropping all items in a stack of stackable items (for example, 5 potions out of 5) - it behaves just like a nonstackable item.

When dropping some of a stack of stackable items (for example, 3 potions out of 5)... I really have no clue what to do. The 3 dropped potions have the state of REMOVED, but the same unique ID and character ID. If another player picks it up, it has no choice but to obtain a new unique ID, and its state gets changed to NEW and its character ID to the new one. If the dropping player picks it back up, they'd just be readded to the stack.

There's two issues with that though. 1. If the player who dropped the 3 potions picks it back up, there's no way to tell if they legitimately dropped the items, or if they're duped items. 2. If another player picks up the 3 potions (assuming they're duped), there's no way to know if they're duped or not.

My question is: How can I create a system that detects duplicated items for both nonstackable and stackable items?


texts:
I'm viewing tutorial of Unity. In this tutorial, I see this piece of code:

public class GameControl : MonoBehaviour {
    public static GameControl control;

    public void Awake() {
        if (control == null) {
            DontDestroyOnLoad(gameObject);
            control = this;
        } else if (control != this) {
            Destroy(gameObject);
        }
    }
}

I don't understand above code very much. I just understand the first if. it means: when we first use this class, we will initialize control object and set attribute dontdestroyonload for this. But I don't understand second if, when will it meet condition control != this ?

Thanks :)


texts: libGDX - Drawing polygon with texture gives weird lines

texts:
I have a hexagon-shaped polygon. I want to put a part of a rectangular image onto it (a part because it's a hexagon, not a rectangle). I tried to do this using PolygonRegion, but it gives a weird and flipped result. Also when I have multiple hexagons, the texture is only on the first hexagon, and on the others, only the weird lines are visible. I use libGDX with the Game and Screen classes. I'd also like to know what this error/effect is called.

My questions:

How do I make the texture scale to the size of the hexagon?
How do I not flip the texture?

My (altered) code "GameScreen":

class GameScreen implements Screen {

private OrthographicCamera cam;
private PolygonSpriteBatch pSB;
private Hexagon hexagon1, hexagon2;
public final int HEXAGON_WIDTH = 100;
public final int HEXAGON_HEIGHT = (int) (HEXAGON_WIDTH / (Math.sqrt(3) / 2));
//Ratio of width and height of a regular hexagon.

GameScreen() {
    this.cam = new OrthographicCamera(800, 800);
    cam.setToOrtho(true);
    cam.position.set(cam.viewportWidth / 2f, cam.viewportHeight / 2f, 0);
    cam.update();

    hexagon1 = new Hexagon(new Vector2(0, 0));
    hexagon2 = new Hexagon(new Vector2(HEXAGON_WIDTH + 2, 0));

    pSB = new PolygonSpriteBatch();
}

@Override
public void render(float delta) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Gdx.gl.glClearColor(1, 1, 1, 1);

    cam.update();
    pSB.setProjectionMatrix(cam.combined);

    pSB.begin();
    hexagon1.draw(pSB);
    hexagon2.draw(pSB);
    pSB.end();
}
}

Class Hexagon

class Hexagon {

    private PolygonSprite sprite;
    private Vector2 pos;

    Hexagon(Vector2 pos) {
        this.pos = pos;
        this.sprite = createPolygonSprite();
    }

    private PolygonSprite createPolygonSprite() {

        int hexWidth = GameScreen.HEXAGON_WIDTH;
        int hexHeight = GameScreen.HEXAGON_HEIGHT;

        float[] vertices = {
            pos.x + hexWidth / 2, pos.y,
            pos.x + hexWidth, pos.y + hexHeight * .25f,
            pos.x + hexWidth, pos.y + hexHeight * .75f,
            pos.x + hexWidth / 2, pos.y + hexHeight,
            pos.x, pos.y + hexHeight * .75f,
            pos.x, pos.y + hexHeight * .25f
        };

        PolygonRegion polygonRegion = new PolygonRegion(
            new TextureRegion(new Texture(Gdx.files.internal("badlogic.jpg")),
            vertices,
            new EarClippingTriangulator().computeTriangles(vertices).toArray());
        PolygonSprite polygonSprite = new PolygonSprite(polygonRegion);
        polygonSprite.setOrigin(pos.x + width / 2, pos.y + height / 2);
        return polygonSprite;
    }

    void draw(PolygonSpriteBatch pSB) {
        this.sprite.draw(pSB);
    }
}

The result (using similar code as written above but with more hexagons and other things):

What I expected to see (instead of the above picture): I expected to see the image not flipped and on every hexagon. The image should have been of such a size that all the hexagon space is filled (that of course means you can't see the corners of the image, but that's what I want). The image should be displayed on each hexagon, so it should start drawing on each hexagon. The image should scale to the size of the hexagon.


texts: UDK/ UnrealScript class interaction? HUD advice?

texts:
Beginner basics requested here, While i'm familiar with the basics of OOP programming i've just started looking as UnrealScript for a game i had made in the UDK editor up to now.

I have a class that extends UTHUD and another that extends UDKPAWN. I have the pawn destroyed when its been shot 3 times and some basic helloworld text displaying in my HUD but i'm completely lost as to how one would get some sort of feedback between the two classes going on?

What i would like to do to start off, is have some text that says something like "Amount of baddies killed: 0" Displayed on the HUD which would then increment each time the player destroyed one of my pawns.

I'm sorry if this is an inappropriate question but i've never really worked within a framework like this before and wasn't sure where to go for help to get my footing. All advice appreciated!


texts: How do I set up an SFML .NET dll reference in Visual Studio Code

texts: How do I set up SFML .NET library dll files as references in Visual studio code using dotnet core SDK? I want to ditch visual studio as it's large and clunky and am wondering how to add "third party" .dll's as references like I can in visual studio by right clicking the references tab in the project explorer and selecting the dll.


texts: How should you save sprites for talking and blinking characters?

texts:
Lets say you have a game like Phoenix Wright: Ace Attorney, where characters appear on screen and do things like:

change their stance/pose depending on the situation and mood (looking happy, looking sad, looking at the camera, looking to the side, etc.)
move their mouths while their text is printing out
randomly blink
do other stuff (getting pecked by a bird for example)

I'm not sure how I should go about saving all those different "sub animations" in my spritesheets. Should everything related to one character be saved in one huge spritesheet? Or should all those sub animations have their own separate spritesheet? Should I save ALL blinking related sprites in one spritesheet or should I keep them separate from each other (one spritesheet for the blinking sprites of the happy pose, one file for the sad pose, etc)?

I would like to know what the preferred approach would be from a technical and "artistic" standpoint:

What's the best way to save up on space and make sure the game handles the sprites well?
What "format" would be preferred for the guy actually creating those sprites? I don't mean format as in file format or even a tool specific for the creation of spritesheets, but more HOW the sprites are arranged on the spritesheet(s).


texts: Why use 3d matrix and camera in 2D world for 2d geometric figures?

texts:
I'm working in XNA on a 2d isometric world/game and I'm using DrawUserPrimitives to draw some geometric figures...

I saw some tutorials about creating dynamic shadows but I didn't understood why they use a "3d" matrix to control the transformations since the figure I'm drawing is in 2d perspective.

I know I'm drawing a 2d figure in 3d but I still can't understand if I really need to work with the matrix.

Is there any advantage in using a 3d Matrix to control camera and view?

Any reason why I can't just update my vertex's positions by using a regular method since the view is always the same... And since I want to work only with single figures, won't this cause all the geometric figures have the same transformations simultaneously?

To understand better what I mean here's a video
http://www.youtube.com/watch?v=LjvsGHXaGEA&feature=player_embedded


texts: How do I access a variable from my code in Godot's editor?

texts:
In Godot, I have a node with a variable that I often need to tweak for balancing purposes. It would be a lot easier to manage if I could modify it inside the editor instead of the code.

How would I go about doing this?


texts: Is there a way to procedurally generate the history of a world?

texts:
I am somewhat intrigued by the diagram found here representing 1800 years of cultural history in an imaginary world some guy created.

This sort of thing would seem to have strong applications for game development, insofar as world design.

It looks like he did this diagram by hand. What I'm interested in is seeing if there is a way to create this sort of diagram programatically.

If you were tasked with generating diagrams in the style of the above from random values, how would you go about it? Are there any particular data structures or algorithms that you would consider?


texts: How to count rotations or spins when using addtorque?

texts:
I have a rigidbody and use 4 keys to addtorque in 4 different directions:

W adds torque positively along the X axis (pitch forward)
S adds torque negatively along the X axis (pitch backward)
A adds torque negatively along the Y axis (yaw left)
D adds torque postively along the Y axis (yaw right)

The rigidbody is able to rotate around/spin in any combination of these directions, but my issue is how can I count the number of rotations it has done in any given axis? Eg. if the player has completed 2 360 rotations to their left I would like to display "2 Left Spins" etc.

I have tried storing the eulerangles of each axis but this is no good as it resets after certain degrees.

I think the way it could work is on keydown reset a degrees counter, while the key is being held I could continue to store the change in rotation for that axis, and then on keyup I could divide this total number of degrees by 360. I'm not sure how to do this in C# though, or if this is the best way to do this.

How could I do this?


texts:
I'm trying to make a space shooter game in Unity3D with realistic spaceship physics. I have a problem with correct rotations. When I apply torque in global coords system it will always apply them in the same global planes, even when the ship is eg. rolled to a side - if I now yaw, it will rotate it in the global system instead of yawing the ship in its local coords.

Now, when I use relative torque, I can apply yaw, then roll and it's screwed again because now the torque applied for yaw works in rotated (rolled) plane instead of the old plane.

Is there any way to keep the applied torques in the old planes, even if the ship's local plane has rotated?

Screenshots to explain the relative torque problem:

I start off with the ship aligned with the world axes. I apply relative torque to yaw.

The ship rotates in yaw plane (same as world horizontal plane).

I apply roll. The yaw is supposed to continue rotating the ship in the old plane same as world horizontal plane.

But it does not. Instead, the old yaw torque now continues in the new plane which is the local X-Z plane!

Here is the code I'm using to control the spaceship currently, using the relative torque strategy:

public class PlayerControl : MonoBehaviour
{
    private Rigidbody rb;
    public ManeuverEngineScript FrontRightManeuverEngine;

    void Start ()
    {
        rb = GetComponent<Rigidbody>();
    }

    void Update ()
    {
        if (Input.GetKeyDown(KeyCode.Q))
        {
            //rb.AddTorque(0f, 0f, 10f);
            rb.AddRelativeTorque(0f, 0f, 10f);
        }

        if (Input.GetKeyDown(KeyCode.W))
        {
            Debug.Log("W pressed");
            rb.AddRelativeTorque(0f, 0f, -10f);
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            Debug.Log("LeftArrow pressed");
            //rb.AddTorque(0f, -10f, 0f);
            rb.AddRelativeTorque(0f, -10f, 0f);
        }

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            Debug.Log("RightArrow pressed");
            rb.AddRelativeTorque(0f, 10f, 0f);
        }

        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            Debug.Log("DownArrow pressed");
            rb.AddRelativeTorque(-10f, 0f, 0f);
        }

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            Debug.Log("UpArrow pressed");
            rb.AddRelativeTorque(10f, 0f, 0f);
        }
    }
}

Here's a "stop-motion" explanation. The first set of frames shows how I expect the rotations to happen and the second one shows how it actually takes place in Unity.

The actual:


texts:
I'm trying to design a wiring system that allows players to connect power sources to switches via wires. Think redstone in Minecraft. When a wire is placed, if it is not initially connected to the power source, it has no power (behaving as expected). The PROBLEM occurs when the wire is connected to power, detecting that it is powered, and then disconnects from power. After it has touched the power source, it then becomes it's own source if disconnected, which is not what it should be doing.

This is what SHOULD be happening

Here's what is ACTUALLY happening

And here is my code:

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

 public class Wire_Moveable : MonoBehaviour {

 public static Wire_Moveable control;

 public bool IsBlue;
 public bool IsRed;
 public bool powered;

 void Start () {
     IsBlue = false;
     IsRed = false;
 }

 void Update () {
 if (Input.GetMouseButtonUp (0)) {
         following = false;
         this.gameObject.GetComponent<Wire_Moveable>().SnapWire ();
     }
 }

 void OnTriggerStay2D (Collider2D trigger) {
     if (trigger.tag == "wire") {
         if (trigger.gameObject.GetComponent<Wire_Moveable>().powered) {
             powered = true;
         }

         if (trigger.gameObject.GetComponent<Wire_Moveable> ().IsBlue) {
             IsBlue = true;
             IsRed = false;
         } else if (trigger.gameObject.GetComponent<Wire_Moveable> ().IsRed){
             IsBlue = false;
             IsRed = true;
         }
     }
 }

 void OnTriggerExit2D (Collider2D trigger) {
     if (trigger.tag == "startnode_blue") {
         IsBlue = false;
         powered = false;
     }

     if (trigger.tag == "wire") {
         if (trigger.gameObject.GetComponent<wire_Moveable>().powered) {
             powered = false;
         }
     }
 }

 void SnapWire () {
     if (this.gameObject.name == "Wire_Basic" || this.gameObject.name == "Wire_Basic(Clone)") {
         StartCoroutine ("ActivatePower", 0);
     }
 }

 IEnumerator ActivatePower () {
     yield return new WaitForSeconds (0.1f);
     if (powered) {
         PowerBeam.SetActive (true);
     } else if (!powered) {
         PowerBeam.SetActive (false);
     }
 }


texts: How to change an int value in the Unity editor

texts:
The player of my game can collect logs and can use them for hold on the fires. Each fire has its own status. So one is off and the other one is for 50% on.

I created a public int inside my script that is linked to my gameObject. Because it is public, I can change the value also in the Unity editor. See image:

The int is linked to a int parameter of "Intensity". And use this as follow:

public Animator anim;
public int campfireStatus;
public float timer;
public float beforeDecrease; // timer for campfires
bool inTrigger = false;

// Use this for initialization
void Start () {

    anim = GetComponent<Animator>();

}

void OnTriggerEnter2D(Collider2D other) {
    if (other.gameObject.tag=="Player"){
        inTrigger = true;
    }
}

void OnTriggerExit2D(Collider2D other) {
    if (other.gameObject.tag=="Player"){
        inTrigger = false;
    }
}

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

    anim.SetInteger("Intensity", campfireStatus);
    //Debug.Log (campfireStatus);

    if(inTrigger && Input.GetKeyDown(KeyCode.E)) {
        if (WoodBehaviour.count > 0) {
            campfireStatus++;
        }
    }

    timer+= Time.deltaTime;

    if (timer > beforeDecrease) {

        timer = 0;

        if (campfireStatus !=0){
            campfireStatus--;
            Debug.Log ("Decrease");
        }

    }

}

But the added value inside the Unity editor will not be use by the script. It will start from the default state, as you can see here:

Each transition, like the one is selected, will have the condition: intensity is equals to 1 till 4.

So I look for a solution, so that I am be able to change which start animation should fired for that object, by changing the Campfire Status inside the Unity editor with the values of 1 till 4.

Look out for some advice!


texts:
I have this code,

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

    playerRigidbody.MoveRotation(newRotation);
}

What happens when I use  playerToMouse = floorHit.point,instead of  playerToMouse = floorHit.point-transform.position.


texts:
I am making an android game. Mobile phones are usually very limited in graphics capability and so I do not want to use standard post-process bloom due to performance drawbacks.

However I do want to have some objects in the game to appear glowing e.g. explosions, jewels etc, nothing very fancy just like it used to be on older hardware such as N64 and PS1.

What method and practices are common to get the desired look?


texts: Making multiple VertexPositionColor variables in the same class? - XNA

texts:
I have studying XNA on my spare time for about a year now and I could use some professional help on this issue. Any time given to my problem is appreciated.

I have two VertexPositionColor variables both of which are placed into two separate vertex buffers to draw up three triangles

basicEffect = new BasicEffect(GraphicsDevice);
        VertexPositionColor[] vertices = new VertexPositionColor[6];
        vertices[0] = new VertexPositionColor(new Vector3(0, 1, 0), Color.Red);
        vertices[1] = new VertexPositionColor(new Vector3(-1, -1, 0), Color.Green);
        vertices[2] = new VertexPositionColor(new Vector3(1, -1, 0), Color.Blue);
        vertices[3] = new VertexPositionColor(new Vector3(0.05f, 1, 0), Color.Yellow);
        vertices[4] = new VertexPositionColor(new Vector3(-1, -1, 0), Color.Blue);
        vertices[5] = new VertexPositionColor(new Vector3(-1, 1, 0), Color.Pink);
        vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), 6, BufferUsage.WriteOnly);
        vertexBuffer.SetData<VertexPositionColor>(vertices);

        VertexPositionColor[] vertices2 = new VertexPositionColor[3];
        vertices2[0] = new VertexPositionColor(new Vector3(0, 1, 0), Color.Blue);
        vertices2[1] = new VertexPositionColor(new Vector3(-1, -1, 0), Color.Red);
        vertices2[2] = new VertexPositionColor(new Vector3(0.9f, -0.9f, 0), Color.Orange);
        vertexBuffer2 = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), 6, BufferUsage.WriteOnly);
        vertexBuffer2.SetData<VertexPositionColor>(vertices2);

I then use the draw function to draw all three triangles ..

public override void Draw(GameTime gameTime)
    {
        basicEffect.World = world;
        basicEffect.View = view;
        basicEffect.Projection = projection;
        basicEffect.VertexColorEnabled = true;
        GraphicsDevice.SetVertexBuffer(vertexBuffer);
        GraphicsDevice.SetVertexBuffer(vertexBuffer2);
        RasterizerState rasterizerState = new RasterizerState();
        rasterizerState.CullMode = CullMode.None;
        GraphicsDevice.RasterizerState = rasterizerState;
        foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
        {
            pass.Apply();
            GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 3);

        }
        base.Draw(gameTime);
    }

But it does not draw all three triangles. I have tried various variations and all that gets drawn is either the last vertex buffer or the first one. I know it would be more efficient to place them all in the same buffer or have them used with indices, but in the future I will run into issues where I am going to need more than one buffer to draw something and I want to be prepared. What is the problem here and how do I draw more than one vertex buffer at a time?


texts: Procedural dungeon algorithms for a more open dungeon

texts:
I'm working on a game that I want dungeon generating in, but I plan on having ranged weapons in it, so I want it a bit more open. I'd like to avoid corridors and I don't want to use a grid of custom rooms.

I don't want to use perlin noise and make it like random blotches, so that's not an option.

All I need is a summary of how the ideal algorithm for this works.

EDIT: Something that gives a result like this:

It doesn't need to be so rounded. The point is that there aren't really corridors.

I'm also fine with a modular approach where the areas are hand made as long as it's still not on a grid. The issue is that if it's not on a grid, the areas are normally connected by corridors.

EDIT2:
I made this a while ago, which works when it comes to shape, but it works with a modular system and it looks like this because I intentionally put rooms on top of other rooms. This causes problems if I start decorating the rooms and filling them with interesting stuff.


texts: Making Procedurally Generated Top-Down Landscapes Interesting

texts:
I'm working on a game with a procedurally generated world. Ideally, I'd like to generate landscapes as beautiful as Minecraft's worlds are. Minecraft has chasms, and waterfalls, and mountains, and rolling hills, and oceans, etc. But as this is going to be a top-down (actually 3/4 perspective) game, I don't believe most of that is possible. The main reason being how hard it is to try and represent height in this perspective. Zelda: A Link to the Past created the illusion of height well, but this would be very hard to recreate procedurally, and also introduces some problems such as the fact that the tallest structures have to be at the top of the map.

So, I'd like to know some techniques to make landscapes interesting in a top-down format without having to fake a 3rd dimension. (You cannot create or destroy terrain in this game, so that gives us a little more flexibility.)

EDIT: To make things a little more clear, I'm trying to avoid worlds with features that require a 3rd dimension. For example, I can't really have rolling hills or mountains. What landscape features could be added that don't require faking a 3rd dimension? One answer could be to add rivers, but that's an obvious one.


texts:
I'm creating a ResourceManager.
At the beginning i'm creating a groups of resources which contain a map of resources. The role of groups is to quick load/unload resources, to find some constant, never unloading resources which placing to group, for example named Static and newer trying to unload, or find resources common for 2 scenes, or batches etc, this is work of pipeline. Also resource names are hashes of string, they are all unique and its checked off-line.

After i'm adding archives, where assets is stored and load table of contents and put it into group. After i'm calling InitializeGroup where i'm creating a raw resources with out creating or loading some data, only passing to them the Location, where their data is stored.

struct Location
{
    Archive* pArchive;

    size_t m_Offset;
    size_t m_Size;
};

class ResourceManager
{
public:
    struct RacingEngineExport ResourceGroup
    {
        LocationMap m_Locations;
        ResorceMap m_ResorceMap;
        String m_Name;
    };

    void CreateGroup(const String& name);
    void AddLocation(const String& path, const Archive::Type lType, const ResourceGroupName& group, bool recursive = true);

    void InitialiseGroup(const String& name);

    void RegisterResourceHandler(ResourceHandler* pResourceHandler);;

protected:

    ResourceGroupMap            m_ResourceGroups;
};

For each Resource type like Mesh, Texture etc. i'm creating specific ResourceHandler. ResourceHandler responsible to retrieve data from archive(not load, just ask some background queue to load it) and prepare resource for future using, also it's creating and unloading them.

class ResourceHandler
{
public:
    inline ResourcePtr Get(const ResourceID& id);
    ResourcePtr Create(const ResourceName& name, const PropertyMap& properties = PropertyMap(), const bool isManual = false);
    inline void Load(ResourcePtr pResource);
    inline void Unload(ResourcePtr pResource);
    inline void Destroy(ResourcePtr pResource);
}

In Load it's retrieving Archive from Resource::Location::pArchive, loading data from disk and creating some other stuff specific for Resource type.

So when the resource needed by some one, it's calling ResourceManager, retrieving ResourcePtr and asking ResourceHandler to load it if it's not loaded, ResourceHandler somehow (async or sync) loading it and returning ready to use resource.
So now the resources ready to load.

This model not friendly to real-time adding new resources, but it's possible, but i don't need it, just it's can't be loaded again after unload automatically.

So, the question is where i have to store resources, in the main ResourceManager, in all ResourceHandler, in Groups or everywhere? Also i want to hear some recommendations how to improve my impl. or defects in it, or some better way to manage resources. May be my question is stupid but i can't get rid of thoughts that that it's not OK at all.


texts: How to add only 1 value in a list in the Update function when a GameObject is active for many frames

texts:
In my C# script, I get the active gameobjects during play mode. Those gameObjects that are active are:

1- First, I get the ones that the application has selected randomly 2- and then after the first ones get disabled (setActive(false)), I get the selected gameObjects which are those that the user has pressed using their button.

So basically the application is: The user hears a sound being played (here I set active the gameObject that has that sound) and then after some frames, the sound gets disabled and then the user needs to press a button in screen to make a choice depending on the sound (here I set active the gameObject that has the button) and then I disable that game object after some frames.

Now every time one of those gameObjects gets selected, I try to add to my list some sort of value (lets say 1 in this case). But what happens is that I only manage to add the value in the Update() function but in this function I do not get only 1 value added in the list every time I get the first gameObject selected but because it updates every frame, this value gets added for like 125 times in the list until this gameObject gets diselected and the next gameObject (the one that holds the button) get active.

  if (DogSelected.activeSelf && NoCarSelected.activeSelf)
    {
        enable = true;

        if (enable)
        {
            DogLionSelected.Add(0);
            NoCarCarSelected.Add(0);

            enable = false;
        }

        if (DogPressed.activeSelf && NoCarPressed.activeSelf )
        {
            enable = true;

            if (enable)
            {
                string[] data = new string[] { scene.name.ToString(), "0", "0", "0", "0", "1" }; orientationStringWriter.Write(string.Join(delimiter, data) + "\n");
                DogLionPressed.Add(0);
                NoCarCarPressed.Add(0);
                PrimaryCorrectIncorrect.Add(1);

                enable = false;
            }

        }

Ideally, I would want to:

1- Hear the sound (gameObject is active) => add only 1 value in list until the gameObject is deselected. 2- Then do the same thing for the gameObjects that hold the button. So when that gets selected = > add only one value in the other list until this gameObject is deselected. Then do the same process 72 times (because the number of trials in this application is 72).

Can anyone give me any advice how to achieve this?

Thanks


texts: Unity is losing track of changes to Resources

texts:
I have a Unity project, where I recently changed the names of a few files in my Resources folder.  This is relevant because I have code that looks like this:

        internal void LoadItems(string[] names)
        {
            var items = Resources.LoadAll<TileBase>("Tiles\\Items");
            var itemMap = items.ToDictionary(m => m.name.ToUpperInvariant());
            _items.Clear();
            _items.AddRange(names.Select(n => itemMap[n.ToUpperInvariant()]));
        }

The AddRange call is currently throwing an exception, because the incoming data is expecting the new names to be present, but itemMap for some reason still contains the old names.  I've verified this in the debugger, and I've verified in Unity's file search that no file matching the old version of the name that's causing trouble here exists anywhere in the project anymore.  And yet, when I run the project, (using the Attach To Unity And Run option from Visual Studio,) the old names still show up.

If I go into Build Settings and tell it to rebuild the project, this code works correctly... once.  Subsequent runs cause it to fail, going back to the old names again, so it kind of feels like Unity is actively trolling me at this point.

The old data has to be cached somewhere, but I'm not sure where or how to fix it.  Anyone know how I can resolve this?


texts: Integrating an AI state machine with actions that take more than 1 tick

texts:
Background: I'm having a problem conceptualising something which seems to be pretty fundamental. We have, what I believe to be, a traditional 'game loop', which runs at 60 fps and iterates through each entity calling it's update method (and later on its draw method). Although probably irrelevant, we're developing the game in Objective-C (for iOS / OSX). Currently an 'Entity' can be assigned a 'Controller', and the controller's 'update' method is called every frame. We would like to introduce a state machine for our AI system.

I understand the concept of having events trigger changes in the current state and we have  a base state object with the following methods (heavily inspired by Mat Buckland's AI Book);

@interface KTBaseState : NSObject {
    -(void)enter;
    -(void)update;
    -(void)exit;
}

The chapter suggests that the 'enter' method might involve entering a mine, and the execute method involves mining. However, we're developing a real time game, and 'entering a mine' is not an immediate action - it might take a few animation frames showing the guy disappear. Equally, it suggests that, on a state transition you call;

[oldState exit];
[newState enter];

But I would also envision exiting the mine to take a few frames, after which I guess the 'enter action' of the new state would then be allowed to enter / start (say, putting the bag of gold on his shoulder). When the guy's started walking - it's easy to push him around in the state's update method.

Any advice on how best to implement these 'actions' that take longer than the state transition would be greatly received. I thought about implementing some kind of action queue, but I'm not sure exactly how that would work...

Some actions would be 'immediately interruptable' (walking -> being hit) but others wouldn't (mining -> walking around).
You could end up with a massive queue of actions - when all the guy needs to do is run away!
In the walking state 'update' method, I would really just want to call "moveTo(destination);" every frame - would you implement this as another 'action', or just push the sprite around the screen?

Sorry for the long text with no specific list of questions. I'm seeking advice on how to approach this problem and I wanted to make sure I was clear in describing what's not clear in my head!


texts: Replicating no. of sprites without letting the app to slow down and crash

texts:
Is it possible that if I'm making a a simple drag-n-drop game, does making a new sprite via constructor with texture as a parameter makes the game slower and depletes more memory until it crashes or does making a new texture via constructor cause the memory to go slow? I'm on a revision for the new drag-n-drop puzzle game where the only goal is to stack the most no. of objects as you can before it falls off the platform. Is it a good idea to create another sprite with texture as a parameter every time a player drag-n-drop another object?

Here's the start of the dry run looked like and I set it to debug mode so that the platform is completely block the pit to test the replication test.

Afterwards, when it reaches from hundreds to thousands, this will be like this and the game gets slower.

When the game crashes, here's the result via Logcat:

12-11 16:38:53.953: E/AudioTrack(25701): AudioFlinger could not create track, status: -22
12-11 16:38:53.953: E/SoundPool(25701): Error creating AudioTrack
12-11 16:38:53.993: D/dalvikvm(25701): GC_EXPLICIT freed 947K, 14% free 14414K/16672K, paused 2ms+4ms, total 96ms
12-11 16:39:16.363: E/AudioTrack(25701): AudioFlinger could not create track, status: -22
12-11 16:39:16.363: E/SoundPool(25701): Error creating AudioTrack
12-11 16:39:16.433: D/dalvikvm(25701): GC_FOR_ALLOC freed 2120K, 15% free 14418K/16848K, paused 47ms, total 47ms

By the way, I'm using BodyEditor library for Box2D program and rendering, a physics engine.


texts: How to store data and behaviour for what happens within a level?

texts:
I made a game a year ago featuring a custom scripting language, but I realised that it took far too long to actually make the language and there were many commands that were very rarely used.
I'm trying now to do something similar with a game I'm working on, and I'm wondering what the simplest way to store level data would be. There are programs like Tiled that let you store some JSON data and tiles and .png's and whatnot, but I want to be able to store commands for what happens within a level gameplay wise. I'll give some examples.
I could have a file for the starting room that has commands that run when you enter the room, e.g. to have some text pop up, have a character walk up to the player, etc. I could also have individual commands for what happens when you interact with an object or with a character. What's a good way to store this data without having to write my own scripting language? It's not too difficult to make a very basic one with minimal functionality, but I feel like there are much better ways out there.


texts: How to store and organize my data in a JRPG style game?

texts:
I am trying to make a JRPG style game using Unity. See this image below to get a sense of the "feel" of the type of game I am making:

http://www.juicygamereviews.com/uploads/3/0/5/0/30501048/9185639_orig.jpg

Currently I'm struggling to find a good way to organize the data in my game.

Referring to the image above, see how each party member has stats, as shown in the UI? I'm sure the monster also has the same kinds of stats, just hidden away. Hence, I want to make a struct called Stats, that both PartyMembers and Monsters contain a reference to.

To summarize what I'm saying so far:

Right now I'm pretty sure I want two classes - one called PartyMember and one called Monster, both of them deriving from a common class - I'll call it TurnTaker - that takes turns during battle. In the TurnTaker class I want a reference to a struct called Stats, which contains HP, MP, Attack, Defense, etc.

The problem is, for player data I want the Stat class to be [Serializable] because I want to save player progress in a binary format, yet for Monsters I wish to make the Stat class inherit from Scriptable Object (SO) for easy development and editing.

Is it possible to make Stats both serializable and derive from SO in Unity? (Note: a struct cannot derive from SO; only a class can. Should I change my stats from a struct to a class? Seems a bit of a waste, just for the inheritance functionality.)

Further, I'm thinking party members have data specific to themselves (equipment, total EXP, character class, etc), as do monsters(drop items, movement type, etc.)

Should I make these two "things," I'll call them PartyMemberSpecificData and MonsterSpecificData

separate classes altogether
separate interfaces that attach themselves to PartyMember, Monster, or Stat
classes that derive from Stats

(I think I want PartyMember to contain a reference to PartyMemberSpecificData and Monster to contain a reference to MonsterSpecificData.)

Any help appreciated!


texts: How to get object or its index from mouse coordinates?

texts:
Basically, I have a NumPy array of rectangles that store their colour and position.
I want to be able to compare my mouse position and clicked on the rectangle's position and get the index or the object itself from the array.
Do I have to iterate through every square in the array and compare item's coordinates?
The structure looks like:
Cube[Face][Horizontal-Line][Square] = np.array([colour, coordinates])
What's the most efficient way to do it? I'm thinking of using colliderect() method, but I don't know how to implement it.


texts: Strategies for dealing with crowds at choke-points

texts:
I've recently switched my game engine over from steering behaviours to impulse based movement with proper time based collision resolution. This has solved so many problems (no more tunnelling, yay) and made the simulation a great deal more stable. However, with the stability has come a new problem.

The three balls started their journey near the bottom of the image, their target was where the pink ball has stopped. On the way the red and green balls have become stuck at the choke-point in the wall.

Before, I could rely on floating point errors and the general instability of steering behaviours to make the green and red balls jostle each other until they managed to get through the choke point. Now with proper collision resolution, the forces acting upon the balls cancel each other out which results in the balls remaining perfectly still.

What methods are commonly used to resolve such situations? Perhaps some sort of priority queueing system would work, though I can see it becoming complex once I need to decide priority between more than 2 objects.


texts: What's the best way of drawing a glowing 3d line using LWJGL?

texts:
Sort of like a strip-light effect; not actually a light source, but just a polygon with glowing edges.

Can this be done easily? Right now I'm contemplating drawing a line more than once with varying alpha/width values to achieve this, but I think that'll cause weird glowing points at the vertices, which is far from ideal.


texts: How can I simulate relatively realistic weather?

texts:
I'm trying to create relatively realistic weather patterns for my game. The simulation should handle temperature, wind, cloud formation and evolution, fog/mist, rain, snow, etc., and account for terrain (including seas/oceans).

My question: how can I achieve this? I've tried looking up how weather systems work but it hasn't been that helpful.

I've given it a shot anyway. I started with a 2D pressure grid that diffused and advected in the regular fluid-dynamical way (which generates a pressure-velocity grid, i.e. wind). Then I added a humidity grid that is pushed according to the wind. I made clouds form / un-form (rain?) based on the humidity (I gave the air a humidity 'carrying capacity' based on its pressure. Any extra humidity is converted into cloud).

Anyway, I've sort of lost faith in my work so far. Am I going in the right direction? One idea would be to simulate warm / cloud fronts themselves. Would that work out?

Any direction would be nice, I really don't know what I'm doing here. Thanks.


texts: Automapping of the noise texture onto 3D model

texts:
I want to apply kind of noise/dust texture to objects so it would look good, and make it without having UV mapping in models. This is because I want to have a possibility to apply this to any objects, despite them having some other textures already. Just to have a way to make anything look little dirty.

It doesn't have to seam well between faces as this is noise type texture. The priority is that the texture scale is preserved.

In the vertex shader I have vertex coordinates as well as normal, binormal and tangent. I thought about projecting 3d vertex coordinates onto a plane defined by the normal and getting 2d coordinates from there, then use them as UV. But either I can't get the equations right, or it's not going to work. I check results on a sphere and I always get places where texture is stretching.

Is there any way to achieve good results?

I'm using XNA/Monogame, C#, HLSL if this matters.

UPDATE: I have found this:

Calculate Rotation Matrix to align Vector A to Vector B in 3d?
https://math.stackexchange.com/questions/180418/calculate-rotation-matrix-to-align-vector-a-to-vector-b-in-3d/897677#897677

And I thought this could work:

Find rotation matrix which would rotate plane normal to (0, 1, 0)
Use this matrix to rotate current vertex position.
Take (x, z) from the rotated position as (u, v).

However my math skills are not enough to make algorithms out if these equations. Would this work at all?


texts: Randomize and display sprites in a 4x6 grid - Cocos2d-x

texts:
I am creating a card matching game. I have a vector that stores 16 unique cards. I am trying to randomize the order and select only the first 12 cards, then setup in a 4x6 grid for a total of 24 matching pairs. I'm having trouble randomizing it and displaying it in the grid. Also, I am using Cocos2d-x 3.2. Thanks for any advice.

std::vector<Sprite*> cards;
std::vector<std::string> cardNames = { "0.png", "1.png", "2.png", "3.png", "4.png", "5.png", "6.png", "7.png", "8.png", "9.png", "10.png", "11.png", "12.png", "13.png", "14.png", "15.png" };

for (int n = 0; n < cardNames.size(); n++)
{
    auto sprite = Sprite::create(cardNames.at(n));

    sprite->setPosition(cocos2d::Point((50 * (n + 1)), 20));
    sprite->setTag(n);

    cards.push_back(sprite);

    addChild(sprite);
}

std::random_shuffle(cards.begin(), cards.end());

for (int n = 0; n <= 11; n++) // select forst 12 cards to display in the grid
{
    // logic to create grid
    // set position of each card

    addChild(cards); // error here
}


texts: how are semantics used when declaring a struct?

texts:
I don't understand how semantics are used in shaders. While reading Unity's shader tutorials, I come across this

struct v2f {
    float worldPos: TEXCOORD0;
    half3 worldNormal: TEXCOORD1;
    float4 pos : SV_POSITION;
};

and also this

       struct v2f {
            float3 worldPos : TEXCOORD0;
            half3 tspace0 : TEXCOORD1;
            half3 tspace1 : TEXCOORD2;
            half3 tspace2 : TEXCOORD3;
            float2 uv : TEXCOORD4;
            float4 pos : SV_POSITION;
        };

Microsoft's documentation says

  A semantic is a string attached to a shader input or output that conveys information about the intended use of a parameter.

I know there is some kind of interpolation of data because vertices and pixels aren't one to one, thus I think semantics are used for telling the graphics library what to do about the data. But here it uses TEXCOORDX for things like world position and tangent space vectors. They don't seem to have anything to do with UV coordinates. So how are these semantics actully used?


texts:
I'm working on a top-down 2D boat game with Unity3D. I couldn't able to understand how to implement physics of rudder controlling. My physics knowledge is not enough to think how rudder dynamics work. How rudder dynamics works in water? Can you help me for finding a starting point for this?

Since I'm not able to think any solution for this, I can't provide an example code.

EDIT:

I'm trying to apply a force to rigidbody2D of the ship at the point of rudder with angle of the rudder. But I couldn't able to make something working

Sample Code

I draw a sketch. Red point is location of rudder. I'm trying to apply a force at that point with angle of rudder relative to ship heading on each Update. How can I do this?


texts: SNES Limitations: Number of stored Graphics?

texts:
There are plenty of resources that tell you how many sprites can appear on a screen for a SNES game and how many per scanline. There is even answers for the number of tilemaps.

But when I ask the question "How many texture pages could a SNES store on a cartridge? And what size approx.?", that is when there is silence. I appreciate there were no such thing as texture pages back then (it was just a way to explain the question) but surely someone must how many tiles and sprites a SNES cartridge could store on a game?

Any documents/articles that can help me is highly appreciated. Perhaps I missed something while looking on google.


texts: What modern AAA games on the top of the market used OpenGL? If applicable, what engine did they use?


texts: Round position to center of current grid position

texts:
The title may not make sense, nor may the question - I'll try nevertheless.
I'm attempting to make a game similar to The Powder Toy.
Essentially, this is a physics simulation game, where the users create various structures using the provided materials.
As of now, I've created the grid, and given the user the ability to draw with grey cells (or, Stone).
Of course, this may seem like what I would want - however, all the cells are stored in a two dimensional array. When the user clicks on the screen, the program round the x and y of the cursor to the grid, and adds to the array like that.
What I want to happen is for the cell to change in the place of the cursor, instead of rounding it to the nearest cell.
I've attempted to explain it in this image:

In this image, the green large dots are the mouse position, and the place at which the arrows are pointing are examples of where the cell could be.
Green represents what I want to happen but in most cases doesn't, and red is what does happen, but what I don't want.

Here's part of my function to set the cells:

public void handleInput () {
    if (Gdx.input.isButtonPressed(Buttons.LEFT)) {
        mouse_x = Gdx.input.getX();
        mouse_y = Gdx.input.getY();

        rou_mouse = new Vector2(round2px(mouse_x), round2px(mouse_y));

        set_px (rou_mouse, new Element_stone());
}

Where set_px sets a certain item, this is used to draw to the screen.
I hope this is enough information, but if you would need anymore to solve it, I'd be happy to update the post to include more code.

Oh, and I should probable mention I'm using LibGDX.


texts: How to create a transparent mask in Love2D

texts: Since Love2D doesn't support SVG, I'm looking for other ways to create solid, compound shapes.  Anything that has straight edges can be drawn using a polygon, but I haven't yet found a way to mask an circle or ellipse, or in other words, subtract a circle or ellipse from the object being drawn.  Is this possible with Love2D?


texts: What techniques enable web based games to update player's resources frequently?

texts:
Long ago there was this web-based game called Utopia (and I'm sure it is still around), turns are by per hour. You only get new gold/lumber or what-not every hour.

Some newer web based games have resources incrementing in finer resolution, like per minute. So say a player has a food production rate of 5 per minute - the player will have his food amount incrementing every minute. I am not sure if it is wise to constantly set a CRON job to update the SQL database, which I am assume what they are using, as it is web-based. Perhaps I am wrong, every minute.

What techniques do those web-based games use? Added on Edit: And can database can really handle the load?


texts: Unity 5 - Input Field - How to confirm password entry with ENTER only and not a click/loss of focus

texts:
I have an input field password box, currently the password is 'submitted' either by clicking Enter or by clicking elsewhere on the screen.
This seems to be the designed way, as it states this in the documentation (https://docs.unity3d.com/Manual/script-InputField.html) -

"A UnityEvent that is invoked when the user finishes editing the text content either by submitting or by clicking somewhere that removes the focus from the Input Field."

As I have other buttons on the same screen that users can click on, I would like it so mouse clicks are not counted as an invoke.

Is this possible?

Many thanks in advance


texts: How to program an enemy to attack when someone gets near it?

texts:
Like in free-roam RPGs, like Skyrim, I want to make a super-rudimentary screen with just two objects: player and enemy. The enemy will walk around randomly through AI algorithms, and will only fight back gracefully when the player gets near them, and when the player runs away past a certain distance it will continue its AI walking cycle. How do I do this?

Any guidance would be nice.


texts: How do I procedurally generate level like in Dino Run, or Tiny Wings?

texts:
I'm looking to create a game like Dino Run, where I will need to create large slopes for a level, procedurally generated.
How do I go about this?

Do I have to make certain predefined pieces of level that I can connect to each other?
How do I make this fully procedural?

I'm using Sprite Kit if it makes any difference.


texts:
I am just starting game-dev with slick2D and marte engine. When I move my sprite left and right, I am doing walk animation but when the key is released how can I decide in which side the sprite face to set?

Here's the relevant code:

    Input ip = gc.getInput();

    if (ip.isKeyDown(Input.KEY_RIGHT))
    {
        this.currentAnim = "Anim2";
        System.out.println("down");
        x += 0.1f * delta;
    }

    if (ip.isKeyDown(Input.KEY_LEFT))
    {
        this.currentAnim = "Anim4";
        System.out.println("down");
        x -= 0.1f * delta;
    }


texts: What are the tessellation factors Direct3D11?

texts:
I don't quite understand the documentation but if I was to tessellate a mesh using 3 control points in Direct3D11 with the "tri" domain am I right in thinking that

SV_TessFactor is how many times to split up each edge

and

SV_InsideTessFactor is how many points inside the triangle to create?


texts: Is there a good way to represent variable terrain using heightfields (or heightmaps) in an ASCII game such as a Roguelike?


texts: How can I improve the rendering speed of procedurally-generated curved shapes (while keeping them smooth)?

texts:
I'm trying to render a large, procedural-generated shape with OpenGL, but I'm having some issues. I'm rendering the shape by composing it from many cubes, as follows:

int TRACK_MIDDLE2 = 107;
for (GLdouble i=0.00; i<2*M_PI;i+=0.001) {
    x = TRACK_MIDDLE2 * sin(i) + 0.5;
    y = TRACK_MIDDLE2 * cos(i);
    glPushMatrix();
    glTranslatef(x, y, -size - 0.4);
    Cube c2(size);
    c2.render(grey, dgrey);
    glPopMatrix();
}

The Cube render code looks like this:

glBegin(GL_POLYGON);
glColor3fv(c1);
glVertex3f(-size, -size, size);
glVertex3f(size, -size, size);
glVertex3f(size, size, size);
glVertex3f(-size, size, size);
glEnd();

glBegin(GL_POLYGON);
glColor3fv(c2);
glVertex3f(-size, size, size);
glVertex3f(size, size, size);
glVertex3f(size, size, -size);
glVertex3f(-size, -size, -size);
glEnd();

glBegin(GL_POLYGON);
glColor3fv(c2);
glVertex3f(-size, -size, -size);
glVertex3f(size, -size, -size);
glVertex3f(size, -size, size);
glVertex3f(-size, -size, size);
glEnd();

glBegin(GL_POLYGON);
glColor3fv(c2);
glVertex3f(-size, -size,-size);
glVertex3f(-size, -size, size);
glVertex3f(-size, size, size);
glVertex3f(-size, size, -size);
glEnd();

This is the result image:

It looks visually correct, but it renders very slowly. If I decrease increment of i in the for loop, I loose out on the "smoothness" of the shape, which is undesirable.

How can I improve the rendering speed of this mesh?