texts:
I'm writing a simple C# Script to change Materials color of a object.

public class Highlight : MonoBehaviour {

    public bool Mouse_Over = false;
    public Color Highlight_Color = Color.white;
    private Renderer rend;
    private Material[] mats;

    // Use this for initialization
    void Start () {
        rend = this.GetComponentInChildren< Renderer >();
        mats = rend.materials;
    }

    public void ToggleHighlight(bool t){
        if (mats.Length == 0) {
            return;
        }
        for(int i=0; i < mats.Length; i++){
            if (t) {
                rend.materials[i].color = Highlight_Color;
            } else {
                rend.materials[i].color = mats[i].color;
            }
            Debug.Log ("Material_" + i + ".Color = " + mats[i].color.ToHexStringRGBA());
        }
    }

    void OnMouseEnter(){
        if (Mouse_Over) {
            ToggleHighlight (true);
            Debug.Log ("MouseEnter");
        }
    }

    void OnMouseExit(){
        if (Mouse_Over) {
            ToggleHighlight (false);
            Debug.Log ("MouseExit");
        }
    }
}

As you can see, I store my original Materials inside the mats array, in the Start function.
This is to revert the renderer Materials to the original Materials, but it isn't working. The color doesn't change to the original value.

I tried to check where the problem was, and in the Debug statement inside the for loop, the color is getting updated also inside mats Array.
Why is this happening?

Seems like that mats is only a pointer to rend.materials, am I wrong?


texts:
Here is the code where I initialize the VAO, vertex attributes(also the main VBO) and EBO(im using my own wrapper class for these "databuffers" to hide some of the API features and make life easier so i dont think the problem will be in the generic class as it was working without problems)

void initVAOManager(const bool& ebo) {

    if (_vaoID == 0)
        glGenVertexArrays(1, &_vaoID);

    glBindVertexArray(_vaoID);

    /**
    Here is the main data buffer (positions,colors,UVs)
    If it doesn´t exist a new one is created
    **/
    if (!_mainBuffer)
        _mainBuffer = new DataBuffer<T>(GL_ARRAY_BUFFER);

    _mainBuffer->bindBuffer();

    if (!_eboBuffer && ebo) {

        _eboBuffer = new DataBuffer<eboData>(GL_ELEMENT_ARRAY_BUFFER);

        _eboBuffer->bindBuffer();
    }

    //This is the position
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, position));

    //Color attrib pointer
    glEnableVertexAttribArray(1);
    glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), (void*)offsetof(Vertex, color));

    //UV
    glEnableVertexAttribArray(2);
    glVertexAttribPointer(2, 2, GL_FLOAT, GL_TRUE, sizeof(Vertex), (void*)offsetof(Vertex, uv));

    _mainBuffer->unbindBuffer();

    if (ebo)
        _eboBuffer->unbindBuffer();

    glBindVertexArray(0);
}

Then the render function (dont mind the for loop, as i want to render multiple objects from the batch in one function):

void renderBatchNormal()
{
    uploadData();

    glBindVertexArray(_VAOManager->getVAO());

    std::vector<eboData>

    for (std::size_t i = 0; i < _DATA.size(); i++) {
            glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
    }

    glBindVertexArray(0);

    clearData();
}

The upload data function send a data from the vectors to their buffers, I can send it too but as Im using my generic wrapper and it worked before with normal drawings I assume there is no problem.
And finally a class eboData(if anyone wondered) (basically just a blank class with an array of 6 indices)

class eboData {
public:
    GLuint indices[6];
};

However, this is causing crashes on the line where I try to execute the glDrawElements command, I read that it can be caused with no binded VAO while binding the ELEMENT BUFFER but as you can see from the code I´m doing it right(at least I think that). However, if I change the following line with:

std::vector<eboData> _eboVector;

glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, _eboVector.data());

The code is working (problem is also that I don´t know how to render second item in the buffer as it is showing only the first one). Do you have any ideas what can cause this crash?

PS:
glGetError() returns 0.


texts: How to synchronize the speed of spawned object and spawning time interval?

texts:
I want a stream of enemies coming from the top of the screen one behind other in a line, with their speed (speed of the whole stream i.e. every enemy) increased over time.

When I simply increased their speed, a continuous stream of balls (which will be my enemies) is lost since objects are spawned at a fixed time interval irrespective of the varying speeds of the spawned balls.

To maintain the continuous flow of balls what I wanted is to generate balls rapidly as the speed increases. So there should be a direct relationship between spawning interval and speed of the stream.

How can I do that?


texts: UDK or Unity Dynamic Runtime Mesh Boolean subtraction (or alternative)

texts:
I'm new to 3D game dev and was wondering if anyone could help me out.

I'm planning to use UDK and would like to have deformable items in the world.

So a projectile strikes a target, and a dent or hole is inflicted.

At first I thought there might be a way to load a mesh at the impact point and then "subtract" that mesh from the target mesh. Is this possible? This would allow me to have different "impact effect" - like thin and deep, or wide and shallow. (Similar to this, but without requiring DX11)

I've searched for this but not sure what to call it (deformable meshes, boolean mesh operations, etc), but if it already has an answer then that would be great.

If my approach is wrong, could you point me to any alternatives? Don't really want to go down the chunks route.

Or, if Unity etc. supported it, then it's not too late for me to change engine.

Thanks very much,
Martin


texts:
I am letting the user to swipe around in some movement and to see the scene on mobile device.
Facing too fast swipe.
Need to make swipe slower, smother.Using the code:

foreach(Touch touch in Input.touches)
{
    transform.localEulerAngles = new Vector3(
        transform.localEulerAngles.x + touch.deltaPosition.y, transform.localEulerAngles.y + touch.deltaPosition.x, transform.localEulerAngles.z);
}


texts:
How to change duration of vibration on Android(Unity3D)?

For example:

public void Jump()
{
    if (grounded)
    {
        rb2d.velocity = new Vector2(rb2d.velocity.x, jumpPower);
        Handheld.Vibrate();
    }
}

This code makes a vibration in one second long.


texts: How can I make outline shader like "Life is Strange"?

texts:
I want to make sketch shader like life strange.

shader has two part:

1.animated dashed line

2.noisy outline

I like to know how can I make noisy outline?

see outline of objects

First I tried to make outline by copying of incoming vertex data and scaled according to normal direction then Cull Back.but I think it's something like Image effect because outline sometimes move inside of object.
anyway I will appreciate if someone help me to Implement this shader :)

What I tried

I used edge detection and animate it by vertex shader but this isn't good like above gifs.


texts: Rendering three-dimentional array of tiles (as a tilemap)

texts:
I'm trying to create 2d game engine in C++ using SDL2 (actually some code was migrated from SFML). I want to have a flexible multilayer tilemap that can store different types of tiles. My current version of this kind of map uses three-dimensional array of pointers to base class of tiles ("tilemap").

First of all - is it even a good approach?

I'm using pointers to make tiles polymorphic (eg. ground tile (tile_basic) has it's act number and texture id, but chest tile (tile_chest) has also a list of items in it). However scanning trough this array every time when I'm rendering my map would take a lot of time. So I'm scanning trough three-dimensional array of sprites (drawable objects) which is generated from the tilemap every time when new sprites are meant to be shown on the screen.

std::vector<std::vector<std::vector<mg::CompactSprite> > > sprites;

The first two dimensions are quite constant, they depend on the size of the application window. When moving the camera sprites move up to their size (width, heght) and when they are about to exceed this limit, their coordinates reset (x, or y, depending on which direction the camera is moving), getting it into simple words - I'm using modulo.

The problem is that this is terribly slow (~43ms with 23x18 map with only few layered tiles; using SDL2, similar results with SFML). I know I could render the whole visible area to the one image and just move that image and then render only new areas, but then I won't be able to make animated tiles without listing their coordinates, checking if they are in the visible area and then rerendering them which sounds bit overcomplicated, and I'm not quite sure if it'll really boost the rendering process.

So is there any better way to do this? Or I should change my approach?


texts:
Apologies if this question has been answered before, but after relentless searching I couldn't find anything.

As many, I've recently jumped on the ECS-bandwagon, and I am currently killing some time by making a modest ECS-game. The game is a somewhat simple 2D-platform game. It is programmed in plain JS.

The layout of the game is essentially as following:

The core of the game is the Engine, the Engine runs the game-loop and holds an EventManager, responsible for raising events, and an EntityManager, responsible for containing all components of all entities.

All logic is done by systems. The systems registers event-handlers (i.e. member-functions) with the EventHandler for specific EventTypes, which gets called when an event of that type is raised.

For example:

this.eventManager.registerHandler(EventType.EVENT_RENDER, this.render, null, this);

I recently switched from calling all systems relevant functions explicitly in the Engine to this pattern.

But over to my problem and question.

For rendering I have a RenderSystem. This system contains references to several type of drawable/animatable-components which it, you guessed it, renders.

Until recently, this system also contained a reference to another system, MapSystem, which spatially indexes all entities. The reason for this reference was to be able to call a function along the lines of

mapSystem.search(frame_bound);

effectively pruning away all entities not needing to be rendered.

So I have a couple of questions regarding this:

Is it very bad practice for systems to communicate directly? Something about it just doesn't smell right to me.

I see how it might severely complicate your code if you have say 100 systems, and each system holds references to many of the other systems. Hello O(n^2).
If I am not to hold inter-system references, how do I perform communication like described above?

My initial thoughts was to create an entity whose primary purpose were to hold the necessary information (i.e. all entities currently in the frame). Then let MapSystem write to and RenderSystem read from this entity.

But this also seems to be rather unclean to me. Especially as MapSystems search function might be useful to call in many different contexts. Creating an entity per calling-context doesn't really seem like a good way to go about it either.

TL;DR: Is it bad for systems in a ECS-game to communicate directly and hold references to each other?


texts: How can I resize SDL2 windows efficiently?

texts:
I guess resizable windows are not being optimized for in game development but still... The following piece of code demonstrates a problem I'm having: resizing the window is very slow. Basically the window trails after my mouse as I'm moving it:

#include <SDL2/SDL.h>
#include <iostream>

int main() {
    SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);

    SDL_Window* window = SDL_CreateWindow("test", 10, 10, 800, 600, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);

    int count = 0;
    bool repaint = false;
    auto paint = [&](){
        if(!repaint) {
            return;
        }
        repaint = false;
        std::cout<<"Repaint "<<count++<<std::endl;
        SDL_Surface* surf = SDL_GetWindowSurface(window);
        int w, h;
        SDL_GetWindowSize(window, &w, &h);
        SDL_Rect rect = {0, 0, w, h};
        SDL_FillRect(surf, &rect, 0xff0000ff);
        SDL_UpdateWindowSurface(window);
    };
    SDL_Event event;
    bool run = true;
    while(run && SDL_WaitEvent(&event)){
        switch(event.type) {
        case  SDL_QUIT:
            run = false;
            break;
        case SDL_WINDOWEVENT:
            if(event.window.event == SDL_WINDOWEVENT_RESIZED) {
                repaint = true;
            }
            break;
        };
        paint();
    }
    SDL_Quit();
}

...is there some way for me to interfere with SDL's handling of window events that I am missing?

Platform is Linux (X11), have yet to test on windows.


texts: Would it be better to use XML/JSON/Text or a database to store game content?

texts:
I'm considering how to implement a component-based game, as that seems to be the hot thing and I like the idea of such a flexible design.  One of the features of such a design is that adding new things to the game can be done through data, often presented as loading content through text files such as XML.  This has the advantage of being human readable and easily editable in any text editor.  On the downside, text can be slower to deal with, and you have to manage a large collection of data files.  Similar text-based formats like JSON or config files would have similar benefits.

On the other side, there are small, portable databases like SQLite or Tokyo Cabinet.  While not directly human readable, these files are easy to interface with, and I'd imagine some kind of editing tool would be preferable for game content design anyway.  Using a DB allows for a consistent storage of config information and easy retrieval.  You could serialize data into a DB for save games as well.

Performance wise, I think generally XML is faster for small files but a database scales better to large amounts of data.  I'd imagine any real game is going to have a whole lot of game objects.

So the question:
Which is the preferable approach?  I'm leaning towards the DB, but I want to know if there are hidden pitfalls or real strong advantages to text files.  Or if there are other alternatives besides these (serialize to binary format I guess?)


texts: How do I use guilayout toggle event to check if true or false?

texts:
OnGUI()
{
            for (int i = 0; i < scenes; i++)
            {
                GUILayout.Toggle(false, SceneManager.GetSceneAt(i).name);
            }

            if (GUILayout.Toggle(true, "New Scene"))
            {
                Debug.Log("True now !");
            }
}

First in the loop I'm adding some toggles.
Then I want to do that if specific toggle is checked(true) do something and if unchecked(false) do something else.

But the way I did it it's just changing the toggle to true automatic.


texts:
I'm interested in how the market of casual games is split up between different platforms, both in terms of revenue as well as "amount of games published".

For example, I think that Facebook and iPhone games should make a quite large percentage of the market, Facebook alone due to the *Ville games.

Does anyone of you know of one or several articles on market research in that area? Or some simple web page which lists statistics?


texts: How can I change existing hierarchy in Unity regarding animations?

texts:
I made a bunch of animations in Unity.  Now I need to adjust the hierarchy.  For example:

My animator used to change things in this tree, where the head, legs, and arms were animated:

Player
-->Torso
----->Head
----->Arms
----->Legs

Now I added another layer in my hierarchy so that it is:

Player
-->Body
----->Torso
-------->Head
-------->Arms
-------->Legs

And it cannot find the existing animation, since the hierarchy path is different.  How can I insert the body in my animation hierarchy so that I can keep my new hierarchy without having to redo all of the animation?


texts:
I've been writing this code quite late so please bear with me.
I'm trying to pause the game and show a menu when I'm inside a collider and then when i press a key it should unpause the game and continue but it wont and i cant figure out why.

Here's the very simple (in my eyes) code:

var savedTimeScale : float;
var playerStatus : Player_Status;
var inTheZone : boolean = false;
private var startTime: float = 0.1;
var start:GameObject;

enum Upgrade { None,Main }
private var currentPage:Upgrade;

function Start()
{
    currentPage = Upgrade.None;
}

//function for ontriggerenter and pressing button to show menu
function OnTriggerEnter(collider:Collider)
{
    playerStatus = collider.GetComponent(Player_Status);
    if(playerStatus == null) return;

    inTheZone = true;
}

function OnTriggerExit(collider: Collider)
{
    playerStatus = collider.GetComponent(Player_Status);
    if(playerStatus == null) return;

    inTheZone = false;
}

function Pause()
{
    savedTimeScale = Time.timeScale;
    Time.timeScale = 0;
    AudioListener.pause = true;
    currentPage = Upgrade.Main;
}

function UnPause()
{
    Time.timeScale = savedTimeScale;
    AudioListener.pause = false;
    currentPage = Upgrade.None;
    if(IsBeginning() && start != null)
    {
        start.SetActive(true);
    }
}

function IsGamePaused()
{
    return Time.timeScale == 0;
}

function OnGUI()
{
    if(inTheZone == true && Input.GetKeyDown(KeyCode.E))
    {
        Pause();
    }

    if(Input.GetKeyDown(KeyCode.N))
    {
        UnPause();
    }

    if(IsGamePaused() && !IsBeginning())
    {
        UpgradeMenu();
    }
}

function UpgradeMenu()
{
    BeginPage(200,200);
    GUILayout.Button("Hello");
    EndPage();
}

function BeginPage(width, height)
{
    //GUI.DrawTexture
    GUILayout.BeginArea(Rect((Screen.width-width)/2,(Screen.height-height)/2,width,height));
}
function EndPage()
{
    GUILayout.EndArea();
    ShowBackButton();
}
function ShowBackButton()
{
    if(GUI.Button(Rect(20, Screen.height-50,50,20), "Resume"))
    {
        UnPause();
    }
}

function IsBeginning()
{
    return Time.time < startTime;
}

I think it's just a case of a new set of eyes. But by my logic this should work.


texts: What alternatives to large arrays do I have for level data?

texts:
So I'm going to store my levels in int[] arrays.

Most levels are going to be 300*300*300. However, there will be about 24 levels and so that is 24 int arrays of size 300*300*300. However, that would mean I need about 2.5GB just to hold the information. Was wondering is there ways around this.

It just the nature of the game I need this many things. I can possible go down to 100*100*100 levels, but then I would still need about 17 at minimum.

I just can't get around using large arrays.


texts: What AI technique should I use to control a car in a bumpy environment?

texts:
What kind of AI can you recommend controlling a car in a level where there are hills, sharp turns, straight parts, et cetera?

There is AI in the game already. It uses points on the road to which the car accelerates and when it gets closer, the next points is taken. These points are predefined.
The problem is AI-controlled car are not fast enough compared to a human controlled car.
The difference is about 14 seconds, so what methods can you recommend to speed up cars?

Increasing just maximum speed of the cars does not help, because then, they do not take turns fast enough. Do you know a solution for this?
Do you know a resource where this problem is looked at and solved?


texts: How should I go about protecting my script files?

texts:
I am working on a small multiplayer game with a whole bunch of scripting components.

I know I can't store my files in plaintext otherwise anyone would be able to change the functionality of core parts of the game.

What is the best way to go about preventing this sort of "hacking?"

Would it just be best to develop the program using the script files then just copy the files into strings that are hardcoded in the program?


texts:
If I missed the answer to this question being already posted I apologize but I was unable to find it.

I'm new to C# and XNA and converting a VB game I created into them. Im finding a problem I'm not sure how to get around.

I'm using a generic list that contains information about nonplayer characters including the Graphic, Vector2, Rectangle. I'm reading this information from a file. So I have a class to receive all the information then I add it to the generic List. It then passes that information back to the main Game1.cs.

My problem is when it gets to the Draw method after loading all the information into the generic List<> the other methods in the main see the list EXCEPT the Draw and Update methods. I thought this would be because of the protected status of those methods but it will not let me change them to public.

So to sum up NPCClass.cs creates a class to accept the information. LoadLevel.cs reads from a text file and loads a instance of the NPCClass and adds it to a generic list of the NPCClass that is contained in the Game1.cs. The Draw Method in Game1.cs will not see the generic List even tho I have it publicly declared in Game1.cs main.

Thank you for any help and if i'm going at this completely incorrectly please don't hesitate to tell me.


texts: I have some existing C++ 2D game code that draws using immediate mode (i.e., each frame is drawn bottom-up one sprite at a time by my game code -- not using a scene graph or other retained mode concepts). I'm wondering if I can port this code to Unity without having to rework the game code to operate in terms of retained mode (adding objects to a scene, removing objects, etc.). I have read that Unity has an immediate mode GUI option. But in my case I want to use this for the game sprites themselves, not just the UI elements. I realize that for a 2D game there isn't a big difference between UI elements and game sprites. But I need to be able to do things like rotation and render-to-texture, so I wasn't sure if I'd run into trouble "misusing" the immediate mode GUI mechanism to handle the whole game. Alternatively, does Unity have a more general immediate mode option? (I did search for it and didn't see anything aside from the immediate mode GUI stuff.)


texts:
I am getting the error The name 'txt' does not exist in the current context and I am unsure why this is happening. I am very new to programming in C# so sorry if the answer is obvious. I am trying to make my ammo count change on screen and have been told to use txt.GetComponent<UnityEngine.UI.Text>().text = ammo.ToString(); but that gives me the error and I am unsure why. This code is supposed to spawn in bullets for my gun but that part of the script is not important. The problem is that error. If you could tell me what the problem is that would be greatly appreciated.
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;

public class PL : MonoBehaviour
{
    public GameObject bulletPrefab;

    public Camera playerCamera;

    private Coroutine hasCourutineRunYet = null;

    public int ammo = 165; // 65 enemies in total, needs tons of ammo
    public GameObject axe;

    public Text Ammmo;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (hasCourutineRunYet == null)
            {
                hasCourutineRunYet = StartCoroutine(BulletShot());
            }
        }

        if (ammo == 0)
        {
            GameObject.Find("wp_shotgun").SetActive(false);
            axe.SetActive(true);
        }

        txt.GetComponent<UnityEngine.UI.Text>().text = ammo.ToString();
    }

    IEnumerator BulletShot()
    {
        GameObject bulletObject = Instantiate(bulletPrefab);
        bulletObject.transform.position = playerCamera.transform.position + playerCamera.transform.forward;
        bulletObject.transform.forward = playerCamera.transform.forward;
        yield return new WaitForSeconds(1.0f);
        hasCourutineRunYet = null;
        ammo--;
    }
}


texts:
So I want to make a smooth transition with the camera from point A to point B while keeping direction and rotation.
My current approach is using Vector3.Lerp :
using UnityEngine;

public class CameraMoveVertical : MonoBehaviour
{
    public float cameraSpeed = 0.125f;

    public void moveCamera()
    {
        Vector3 lerpPosition = Vector3.Lerp(transform.position, new Vector3(transform.position.x, transform.position.y+50, transform.position.z), cameraSpeed);
        transform.position = lerpPosition;
    }
}

The camera does move but the movement is instant. Any way to make it a smooth transition?


texts: How do i protect my game assets as an individual?

texts:
For my first games, they will be well made, complete, but extremely simple, while i father enough funds to actually fund a game company.

But because I plan on releasing quality content under {insert my name here} Studio (trademark)(c)

and of course all of my games will be superseded by a (c), despite the fact I haven't even registered anything.

But the real question is, what steps do I need to take to make sure my content does not get stolen while im financially stable enough to file all the paperwork needed to maintain proper copyrights?

I'd also like to release a major title, but I'm scared to, because I know someone is going to try and steal it.


texts: In XNA 4, how can I access SpriteBatch's transformMatrix in my shader?

texts:
I would like to use a custom effect with a regular XNA SpriteBatch. I have a 2D camera which computes a transform matrix, so I need my shader to take this into account.

I have put a world matrix property into my shader:

float4x4 World;

However, it does not get set by SpriteBatch:

spriteBatch.Begin(spriteSortMode, blendState, samplerState,
    depthStencilState, rasterizerState, effect, camera.WorldToScreen);

Everything is rendered properly if I set it manually in the draw loop:

effect.Parameters["World"].SetValue(camera.WorldToScreen);

How can I set up my shader parameters to make SpriteBatch set them up correctly?


texts: Streaming to VAO VertexBuffer using OpenGL Direct State Access for Instancing

texts:
How do i stream to a vertex buffer using Direct State Access? I want to update my vertex buffer of matrices every frame so i can use it in my Shader.
This is how i specify my buffer. I do this once in my application when i initialize my VAO.

    glNamedBufferStorage(StaticModelData::instanceDataID, sizeof(InstanceData)*10, nullptr, 0);
    glMapNamedBufferRange(StaticModelData::instanceDataID, 0, sizeof(InstanceData) * 10, GL_MAP_UNSYNCHRONIZED_BIT);
    glVertexArrayVertexBuffer(StaticModelData::vaoID, 1, StaticModelData::instanceDataID, 0, 0);

    glVertexArrayAttribBinding(StaticModelData::vaoID, 3, 1);
    glVertexArrayAttribFormat(StaticModelData::vaoID, 3, 4, GL_FLOAT, GL_FALSE, 0);

    glVertexArrayAttribBinding(StaticModelData::vaoID, 4, 1);
    glVertexArrayAttribFormat(StaticModelData::vaoID, 4, 4, GL_FLOAT, GL_FALSE, sizeof(float) * 4);

    glVertexArrayAttribBinding(StaticModelData::vaoID, 5, 1);
    glVertexArrayAttribFormat(StaticModelData::vaoID, 5, 4, GL_FLOAT, GL_FALSE, sizeof(float) * 8);

    glVertexArrayAttribBinding(StaticModelData::vaoID, 6, 1);
    glVertexArrayAttribFormat(StaticModelData::vaoID, 6, 4, GL_FLOAT, GL_FALSE, sizeof(float) * 12);

    glVertexArrayBindingDivisor(StaticModelData::vaoID, 1, 1);

Every frame i do this to render

    instanceDatas = updateMatrices();
    updateShader();
    glBindVertexArray(StaticModelData::vaoID);
    glNamedBufferData(StaticModelData::instanceDataID, sizeof(InstanceData)*(instanceDatas.size()), &instanceDatas[0], 0);

    glBindTexture(GL_TEXTURE_2D, 1);//hardcoded

    glDrawElementsInstanced(GL_TRIANGLES, it->second.modelIndexNum, GL_UNSIGNED_INT, (void*)(sizeof(int)*(it->second.indexOffset)), it->second.instances.size());


texts: How can I create tiles that scale to multiple resolutions?

texts:
I am trying to create a multiplayer version of the popular Flash game N in Java. However, I'm not sure how to create a tileset that will scale up. Are the tiles for N pre-drawn or are they defined with mathamatical formulas in code?

I do see how they would scale up in Flash if they were pre-rendered. So if anyone has any ideas how I should go about creating the tileset, or how they are created in the game please let me know.

You can check out the game here.


texts:
I'm working on a shadow-mapping implementation for an OpenGLES 2.0 environment (Stage3D in Flash to be exact). This is how my current implementation works:

Render the scene to backbuffer.
Render depth map from the light's point of view.
Render shadows on a texture from the camera's point of view.
(Do blur and other effects to improve the shadow texture, not implemented yet)
Render the shadow texture to the backbuffer with multiply.

Some pictures to help explaining. Note that the bunny is floating in the air on purpose.

Shadows rendered on a texture from the camera's view.

The final scene with shadow texture rendered on top with multiply.

The problem is the unshadowed pixels at the bottom of the bunny. Because the shadow texture is rendered with linear filter, the edge of the shadow loses its sharpness. This is mostly a good thing but not everywhere. I would like to do more filtering effects on the shadows but they would cause even bigger issues.

I haven't encountered this kind of problem in any tutorials or forums so either there is an obvious solution for this or there is something wrong with my approach. The question is, can I solve this somehow using my current approach? Or is there a bigger gap in my method?


texts: Self occluding object and alpha blending

texts:
Look at the object I've rendered with my app:

It's the same screen twice, above the original and below I've drawn (by hand :P) the shape of the mesh of one of plant's leaves. You can clearly see where the problem is.

From what I understand, this leave is drawn before the other leaves, writing a higher value to the depth buffer but not changing the pixel color (as it's transparent in that particular place). When the other leaves are drawn then their pixels in that place in the buffer are discarded since they're failing the depth test (they're farther away from the camera).

Now while I understand what the problem is I don't know how to solve it. This whole plant is one object so I can't sort by depth. What should I do?


texts: How can I control the volume of the music and the sound effects seperately with two sliders?

texts:
In the Hierarchy i have one Main Camera with Audio Listener.
In the Hierarchy I have AudioPanel and two child Sliders.

And the AudioManager script that attached to the AudioPanel:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

[System.Serializable]

public class AudioManager : MonoBehaviour
{

    public Slider musicVolume;
    public Slider effectsVolume;

    private void SetMusicListenerVolume()
    {
        AudioListener.volume = musicVolume.value;
    }

    public void ApplyMusicSettings()
    {
        SetMusicListenerVolume();
    }

    private void SetEffectsListenerVolume()
    {
        AudioListener.volume = effectsVolume.value;
    }

    public void ApplyEffectsSettings()
    {
        SetEffectsListenerVolume();
    }
}

Now in the Hierarchy I have some Audio Sources components for the sound effects and I want to control them with the Slider (1).

And to control the music sound with the Slider.
The music sound have his own Audio Source.

The problem is that the AudioListener in the script control all the Audio Sources. Music and Effects. Or maybe only the Music ? U'm not sure.
But when i change both sliders when the game is running it's changing the music volume.

My question/s is how to control with Slider only the volume of the music and with Slider (1) the effects volume ?

And how can i get all the effects audio sources in the script and control the volume of them using the Slider (1) ?

The audio source component of the music is attached to GameObject name Sound.
All the other audio sources components are effects and are in some places in the Hierarchy.


texts: What is the most effective way of managing scene objects states in Unity?

texts:
I often see this kind of problem in projects: the scene contains many hierarchical objects that must be in a certain state to work correctly. If a disabled object has to be edited it has to be activated first, and if editing takes a long time it is difficult to remember its original state at the end, especially when there are several objects which states were changed. It leads to hidden bugs. I often take a screenshot of the expanded hierarchy before I start editing but I don't think this is a solution, it's more a method of minimizing the consequences.

So how to manage this problem correctly or what approaches you could recommend?


texts: How can I blend grass LOD's smoothly in unity, similar to the method in BOTW?

texts: This is basically what I mean. I tried to imitate the LOD effect in unity using crossfade LOD but it's not nearly as seamless. I've done some research into the subject but can't seem to find anything about blending foliage in this way so I'm looking for advice. Thanks so much!


texts: Terrain Generation for Tile-Based 2D Platformer

texts:
I'm currently working on a tile-based 2D platformer similar to Terraria in some ways, although I'm having difficulty with the terrain generation. I have some basics done, although they do not come out as anything useful.

I have tried a few different techniques like Perlin Noise and read about some others such as Midpoint Displacement, although I'm not sure what one would be best, or a combination of different techniques to generate different areas. (Such as Midpoint Displacement for the general shape of the terrain and Perlin Noise for the caves.)

I have found an excellent explanation of how I could layer it up with the Accidental Noise Library, although it is in C++, and I do not know enough C++ to compile it into a DLL that I can use from C#. I have tried to copy this in C#, although, I do not know how I can merge two effects together (the gradient for the general base, and then the fractal for detail).

Currently I am using a Plasma Fractal and the results are extremely varied. For example it can generate terrain where there is hardly any surface, or it can generate terrain where there is no surface at all.

An example of an okay map, would be better with some more improvements, though. (Black is solid, white is air):

And an example of a terrible map. (Black is solid, white is air):

Basically, what I'm asking is, what would be a better way of generating the terrain, or forcing it to make sure that there is a reasonable amount of surface area, with the generation time as quick as possible. Or, alternatively, how I would be able to achieve the same result as the Accidental Noise Library, but in C#.

Any examples would be very much appreciated.


texts:
I wanted to try the JMonkey engine, so I downloaded the JMonkey sdk, but I don't want to work in the JME IDE, I would rather like to work with Eclipse, since I already started a game project there, and I only want to replace the game engine(the code is modular, so i can do that) form pure LWJGL to JME. I found this tutorial:
http://hub.jmonkeyengine.org/wiki/doku.php/jme3:setting_up_jme3_in_eclipse
But that won't work, when I add the jar-s then there is no com.jme3.app.SimpleApplication anywhere there, as the tutorial suggests. Also where are the correct native files? I googled, but I can't find any example projects of Eclipse, or any decent explanations how to set up JME in Eclipse properly.


texts: What to look for when searching an artist for doing graphics?

texts:
I was wondering which skills I should ask for when I need someone to make the graphical part for a 2D game intended for iOS or Android.

Not really looking for someone right now, but working on a project and don't really know what to ask for, equally I want to avoid thinking only in experienced artists working for iOS or Android developments, but I would want to ask for necessary similar skills.

Thank u all by the answers, very useful.

As I said before I would be interested in 2D graphics, but speaking about what to ask to a friend of mine, who's very skilled, he's traditional painter, but i don't know what should i ask him to learn related with the computer artwork, for doing the 2D artwork on the computer.


texts: How can I reduce the data sent to the GPU for a voxel?

texts:
I'm making a minecraft style game where each chunk each chunk has buffers holding the position of all visible blocks and texture atlas coordinates of the 36 vertices that are needed to draw the triangles.

I have 8 vertices and an EBO that I use for the triangles so it takes up sizeof(GLfloat)*3*8 + sizeof(GLuint)*36 + sizeof(Glfloat)*2*36 so 528 bytes. that seems like a lot per block meaning that if I am rendering around 16*16 chunks(I use an stl::map not an array) 16*16*256 chunks that have around 300 visible blocks that means I am sending about 40 mb of data to the GPU each frame.

It runs smoothly now but could this end up being a problem? or is there a way to reduce this?

one other thing, I tried to change my program from using gldraw arrays and having 720 bytes for each block to using an EBO for just the position. how can you control what vbo the ebo operates on?

for example the EBO would have indices to the points of the cube and texture coordinates but still have an instance array for the position


texts: Oculus Rift Touch controller input not working for some users in Unity 3D

texts:
I am working on a music based game that supports both Oculus Rift (touch controllers), HTC Vive and also no VR. Everything is working fine, but the past few days I have been stuck with 1 bug and I don't know what the cause is.

In my game I have a pause setting. This works properly for all 3 play modes. My colleague/friend that I work together with also has Oculus Rift with the touch controllers and somehow for him the buttons A, B, X and Y aren't working. The game doesn't get an input signal. In the Oculus app the input is working so it is only bugged in the game and not the hardware itself. From my side the game does get an input signal from the said buttons. Same code, same scenario. The only difference between our setups is that he has windows 7 and I have windows 10. He did a full reinstall with hotfixes, but the bug still persists.

I am using the touch mapping specified in the unity documents: https://docs.unity3d.com/Manual/OculusControllers.html
Once again I have no issues and everything works correctly on my end. On his end however only the buttons X, Y, A and B aren't working. I tested this with simple objects being highlighted when the buttons are pressed as the simplest most basic visual testing method. He gets no error or whatsoever. Log file is clean as well. I have absolutely no idea about what I am doing wrong.

If both our controllers input didn't get recognized by the game then I'd understand that the buttons might not have been mapped properly. But for one person it works and for the other it doesn't. Now the other strange thing is that the other buttons are working on his end such as the triggers and thumb-sticks. And yes I have validated that both our game clients are the exact same version.

I have tried to do some research on my own, but I couldn't find working fixes, since on my end everything is working properly (including the fixes), but not on his end when it comes to those specific 4 buttons.

Update:
He upgraded to windows 10 and it didn't seem to solve the problem.


texts: How do I make a Minecraft recipe that costs XP?

texts:
I want to program a Minecraft client-mod or server-plugin that adds a recipe for making a Bottle o' Enchanting with the following ingredients:

1 glass bottle + 1 lvl of experience → 1 Bottle o' Enchanting

One possible implementation that I have thought of is to execute the command /xp -1L player, but I am unsure how to invoke that command from my Java code. Is there a better way?

How would you go about adding an experience-requiring recipe to Minecraft?


texts: Quaternion not giving correct value back. What am I doing wrong here?

texts:
Right so I made a quaternion and assigned it a value but it reports back the wrong value.

Here is the relevant code...

Quaternion LeftTurnLimit = Quaternion.identity;
float test = 0.1f;

LeftTurnLimit = Quaternion.Euler(test, 0, 0);
Debug.Log(LeftTurnLimit);

Expected result: (0.1, 0, 0) / (x, y, z)
Result: (0.0, 0.0, 0.0, 1.0) / (x, y, z, w)

So what am I doing wrong here?


texts: Spritefonts gets very messed up when scaling up

texts:
I'm recoding a retro video game, but because the original resolution is very low, I scale everything up. I render to a renderTarget and render the renderTarget to the target resolution.

I'm using my spriteBatch like this:

_spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);

This allows upscaling with keeping the pixels as they are.
It works fine, but the spritefont gets really messed up:

Any idea how to fix that? When I create the spriteFont with an extremly large size and give it a low scale to the drawString method, it looks about the same.


texts: A lot of games will suggest you take breaks from them every 30 minutes or so, I think this is especially common in Nintendo games, but they aren't the only ones to do it. What is the advantage to this? Does this somehow help get you to play it more or does it help sell more copies?


texts: Game Design Lexicon: terminology for gems etc

texts: When a Hero picks up gems or coins or other "collectibles" that add to his wealth in a game, what are those things (gems and coins etc) commonly called and how are they generally referred to in game design terminology?


texts: How do rendering pipelines improve the performance of updating all the vertices every frame?

texts:
Let's say I am implementing a simple game engine, particularly the rendering part. From the high-level view we have some vertices which are copied to the graphics card alongside shader information etc.

I do not really understand how this is done in a performant manner: Consider a basic OpenGL program (and all the tutorials or whatever I could find out there) which copies all the vertices to the graphics card at each draw call. This seems to be a lot of work.

And as far as I understand if I am doing some kind of third person game, for example, I have to copy every vertex of the character at each draw call (and possibly more). Even though the world is static and the character is representing only a small amount, this still seems to be a lot.

Do game engines apply some kind of "caching" here, to make sure they only copy what has actually changed, or is this a rather mindless copy of everything, and the performance is not such a big deal?

Essentially I want to learn about some kind of architectural choices concerning this vertex copy operation, however I cannot seem to find the right resources. Thank you for any input you could provide.


texts: Are Differing Store Identifiers Necessary with the Unity IAP Plugin?

texts:
I am looking at implementing the new Unity In App Purchasing API for the first time.

Through the guide and the tutorial, I see that there is the ability to add different store identifiers for product ids that vary across stores... and all the examples reference that way of doing it.

Eg.:

public class MyIAPManager {
    public MyIAPManager () {
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
        builder.AddProduct("100_gold_coins", ProductType.Consumable, new IDs
        {
            {"100_gold_coins_google", GooglePlay.Name},
            {"100_gold_coins_mac", MacAppStore.Name}
        });
    }
}

In my case, my product id's DONT differ, so this seems like unnecessary code bloat to implement it this way... but I don't see any other option?

EDIT

Argh, I'm using VS Code on OS X, which is getting better, but still has
issues, such as having problematic code-completion / API referencing issues, so didn't see the overloaded method option... It's simply enough to do this:

var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
builder.AddProduct("100_gold_coins", ProductType.Consumable);


texts: I see by Process Explorer that many of Unreal Engine games load multiple DirectX runtimes. For example game Gears 5 in requirements has DirectX 12 only support, but uses DirectX 9 and 11 runtimes also. Is it correct - this because unreal engine developers don't remove\rewrite some code which uses old DirectX versions features to new and now we have many legacy code inside and games need this runtimes because of legacy?


texts: Destroying the instance that instantiated the prefab

texts:
What I have so far:

A fuel that has Fuel script attached to it.
The fuel prefab is first instantiated from another script in its Start() method.

problem:
The Fuel script is such that it results in instantiation of prefab fuel repeatedly at some intervals of time and keeps destroying the earlier ones.
But

the prefab that was instantiated from the other script stays there always. I want this prefab to be destroyed as well(or atleast made invisible) while the process of instantiation and destruction of of fuel prefabs continues to go on.

How do I achieve this?


texts: How can I know how big my game "world" should be?

texts:
here is the world map (randomly generated) for a game I'm making:
The green rectangle corresponds to the size of one screen. Each pixel represents 3x3 tiles in my game, this makes the whole map be roughly 7,9 km² (2,3 x 2,3).
How can I assess if the game is too big or too small?


texts: How to predict where the soccer ball should be intercepted by an AI player after being kicked?

texts:
This question has been asked many times before, but most of the answers give solution to the problem where ball (target) is assumed to be moving at a constant velocity.
In my scenario, I'm making a football game. When I kick the ball into a direction by applying some force to the ball's rigidbody, I want a second AI player to find the point in the ball's path where he can intercept the ball. Now this ball can keep slowing down per frame, it does not keep moving with a constant speed.
I have attached an image for visualisation.

I know the ball's position, ball's current velocity, AI player's position, AI player's constant speed. How do I find such a point, where AI player can intercept the ball?
I am able to calculate such a point with the current velocity of the ball, but that point is not accurate, and changes as ball's current velocity changes per frame, as the ball can keep slowing down after every frame. This makes the AI player act kind of like a homing missile. Instead, I want the AI player to predict a point and just run to it.
Here's the C# (Unity) Code I have till now:
public Vector3 CalculateIntercept()
{
     Vector3 pos = Ball.GetInstance().transform.position;
     Vector3 dir = Ball.GetInstance().GetVelocity();
     dir.y = transform.position.y;

     float dist = (pos - transform.position).magnitude;
     return pos + (dist / 6.17f) * dir; //6.17 is the AI player's constant speed.
}

There's no drag on the ball, but there is a physics material with friction. I suppose to solve this, I might need to account for acceleration maybe.
Please help me figure this out. Thanks!


texts: How to avoid wagon wheel illusion of a rotating gun barrel reversing direction?

texts:
I didn't know which forum to post this in, but I'm going to try here first. I am making a shotgun with 3 barrels which spin. However, I also want it to have kickback in the animation, but every time I add that recoil it breaks the animation, making a strange wagon-wheel style illusion. No matter what I try, it always reappears once I add the recoil. Here is the animation:

Here is how the animation is supposed to be perceived, with the barrels spinning in one direction:

But this is what I often see when I look at it, where it seems to snap backwards one step:

It may be a bit hard to see, but if you look at it long enough it will flip between the two, similar to that animation of a ballerina which can be spinning in either direction.
I have tried having it only spin when it is down, only spin when it is up, changing the interpolation of the spinning and of the recoil, everything I can think of, but none of it works.
How do I solve this problem? Can I stop the optical illusion while keeping the recoil?


texts: WWW request does not connect using webgl platform

texts:
I use request like code below:

string url = "http://localhost:51820/Home/login/" + end+"/";
        WWW www2 = new WWW(url);
        StartCoroutine(waitForLogin(www2));

It works fine in the editor but the html build shows a connection problem. message of www error is only "unknown error"


texts: In Hammer 3.4 where do I find the 'null' texure?

texts: I'm using Valve's Hammer Editor v3.4 to make maps for Counter-Strike 1.6.  I want to learn to use the 'null' texture to optimize my map by not drawing surfaces the player won't see, but when I search for it in the list of textures, I don't see it.  I'm guessing I'm not loading some WAD that I need, but I'm not sure which one it is.


texts: Implementing a Turn Radius for a Character

texts:
I'm working on a 3rd person platformer in Unity where I'm attempting to capture a Mario 64 style feel. Part of the game involves attaining really fast speeds. Currently, my turning code is pretty simple, and is essentially a mapping of the left-stick onto the character.
Omitting some more complex logic (accounting for smooth acceleration & the like), the base of my movement code is:
rigidbody.AddForce(direction * speed);
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(direction, normal), delta);

This is really responsive and feels good, but at the high speeds the player will attain, it starts to break down. As such, I wanted to add a "turn radius" so that it feels more realistic to attempt to turn at high speeds and face some resistance.
Really, I don't want to go full on "Arthur Morgan" super belabored semicircle turns, but just provide some sense of "weight" and momentum influence to directional changes. Given how simple my current movement is, I'm not sure where to start when it comes to adding in this type of behavior.
I checked out questions like this mario one and lots of other turning related questions, but most I could find were related to the direciton the character was facing, and less about it's movement or velocity. Any input here is appreciated!


texts: How many players can UDK support without Networking

texts:
I've been looking for the answer to this for some time now, but cannot find anything online that is helpful.

What I want to know is the amount of players that the UDK can support on one single machine. An example of this would be golden eye on the N64. On that, you could get 4 players all playing the same game at the same time using split screen. Like in this image:

Does anyone know is the UDK is capable of doing similar?


texts:
Now my 3D model has complete AI behaviours, but my model has no collision avoidance while he is moving towards the player! Because of this, he gets stuck in front of 3D blocks sometimes.

I think the solution includes the usage of rays.  I've included a picture of what I want to do.

NOTE: The world is a 3D world, not a 2D one.  (Even though they are almost the same)

I want my model to not collide with the boxes while he is moving towards me, i.e make some collision avoidance. :)


texts:
I started developing a little multiplayer game with LibGDX and Kryonet. I'm also using the headless backend for the server. So far everything went well, but now I'd like to create a command-line parser for the server. I found out that I should make that in a separate thread, so I made a class for that. But the BufferedReader's readLine() method always returns with null (but it doesn't raise any exceptions).
Here is the code I'm using:

public class ServerScreen implements Screen {
    boolean headless;
    Server server;
    CLIParser cliParser = null;

    public ServerScreen(boolean headless) {
        this.headless = headless;
        server = new Server();
        server.start();
        if(headless){
            cliParser = new CLIParser();
            cliParser.start();
        }
        System.out.println("SERVER STARTED");
    }

    //Screen overrides omitted...

    public static class CLIParser implements Runnable{

        public boolean started = false;

        public synchronized void start(){
            if(!started) {
                started = true;
                new Thread(this).start();
            }
        }

        public synchronized void stop(){
            started = false;
        }

        @Override
        public void run() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("cliParser run started");
            while(started){
                String line = null;
                try {
                    line = br.readLine();
                } catch (Exception e){
                    System.out.println(e);
                }
                if(line != null){
                    System.out.println("READ LINE: " + line);
                }
            }
        }
    }
}

The cliParser starts up successfully, but the readLine() always returns null, and doesn't even blocks the code from running. I don't get any exceptions. I tried the CLIParser in a dummy project, and it works fine, so I assume this could be an issue with the headless backend.

Here is the sample code I used:

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class CliParserTester {

    public CliParserTester(){
        CLIParser cp = new CLIParser();
        cp.start();
    }

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

    public class CLIParser implements Runnable{

        public boolean started = false;

        public synchronized void start(){
            if(!started) {
                started = true;
                new Thread(this).start();
            }
        }

        public synchronized void stop(){
            started = false;
        }

        @Override
        public void run() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            System.out.println(System.in);
            System.out.println("cliParser run started");
            while(started){
                String line = null;
                try {
                    line = br.readLine();
                    System.out.println(line);
                } catch (Exception e){
                    System.out.println(e);
                }
                if(line != null){
                    System.out.println("READ LINE: " + line);
                }
            }
        }
    }

}


texts: Unity - How to calculate max distance (range) of a Projectile taking drag into account?

texts:
I am able to calculate the projectile max distance, but it only works when there is no drag applied on the spherical projectile. I used the formula for range of a projectile as follows:-

void OnCollisionExit(Collision other)
{
    if(other.gameObject.name == "bat")
    {
        initVel = ballRigidbody.velocity.magnitude;
        lineObject.transform.LookAt(transform);
        angle = Mathf.Abs(lineObject.transform.eulerAngles.x - 360);
        radianAngle = Mathf.Abs(Mathf.Deg2Rad * angle);
        maxDistance = (initVel * initVel * Mathf.Sin (2 * radianAngle))/ g;
    }
}

This works well if there is no drag. But as I add drag, the range ends up being far away from where the projectile actually lands.

I looked up https://en.wikipedia.org/wiki/Projectile_motion#Trajectory_of_a_projectile_with_air_resistance

but can't quite understand how to use it.

Here's a solution I tried

if(ballHeight > maxHeight)
{
    maxHeight = ballHeight;
}
else
{
    if(!flag)
    {
        maxHalfDistance = Vector3.Distance(ballFollow.transform.position, centerPoint.position);
        maxDistance = maxHalfDistance * Mathf.Clamp(maxHalfDistance, 1f, 1.75f);
        flag = true;
    }
}

Basically calculating horizontal distance at max height and multiplying it a value between 1 and 1.75. ballFollow is horizontal position of ball and centerPoint is the launch position.
This works perfectly but there is a problem that actual range isn't calculated until the ball reaches its maxHeight.

So, how can range of a projectile be calculated taking air resistance in account?


texts: Painting a Wall and Calculating the Paint Percentage in Unity

texts:
I'm trying to paint a wall in Unity by following this tutorial however I don't know how can I calculate the paint percentage and not paint the lines that have been already painted, and also not go beyond plane boundaries. Painting needs to be using swerve mechanics.
What would be the approach to accomplish this?


texts: In Maya how do I convert trans, rot, scale data to a 4 x 4 transformation matrix?

texts:
I have been given the following Maya camera data:

trans X: 1.542
trans y: 3.319
trans z: -1.821

rot X: 117.882
rot Y: 2.189
rot Z: 154.074

scale X: 1
scale Y: 1
scale Z: 1

What is the formula for converting this to a 4 x 4 transformation matrix?


texts: What is the relationship between Frames-Per-Second and a game loop?

texts:
What is the relationship between FPS - Frames Per Second and a game loop?
I'm confused how my book is using theses terms.


texts: Is it true that to test a game on the iPhone or iPad, we either need to pay $99 to join Apple Developer program, or jailbreak the iPad?

texts: To test a program for iPhone or iPad, seems like the only way is to join the Apple Developer program and pay $99 per year?  Can you also jailbreak the iPhone or iPad and be able to test it?


texts: When and how should I apply forces in a Cocos2D + Box2D game?

texts:
I have some small circles just rolling across the bottom of the screen in my Cocos2D/Box2D iOS app.  The bodies are dynamic... so I make them roll by applying a horizontal force to the center of mass (when the linear velocity is below the max velocity).

Currently I apply this force in -(void) tick: (ccTime) dt.  Is this the best place to apply it?  Or should I subclass something and implement an update function somewhere?  Please keep in mind I'm very new to Cocos2D/Box2D.


texts:
I am making a melee attack with my game, but I'm stuck in a problem related to using triggers. The enemy NPCs have a sphere collider set on trigger so I will know who is inside their range (radius of 15).

Then, I wrote a simple OnTriggerEnter script to make that when my sword (its collider is set to trigger as well, so it will pass through the enemy) hits an enemy NPC, it will destroy that enemy. The problem is that when I test it, the enemies are destroyed once I enter their sphere collider.

So, is there a way to ignore the trigger from their shpere collider? Or what is the best way to do a melee attack?

NOTE: the destroy function is public in the enemy script and it was called in weapon script attached to the weapon.


texts: Timer.schedule(task, 0, 100) never fires

texts:
I added some code using java.util.Timer to execute my spawnMonster function every 100ms. It worked, until I tried instantiating images in it -- since it doesn't run on the libGDX core thread, there's no OpenGL context, so it can't do stuff with images.

I figured using the libGDX Timer class, which the javadocs say runs on the core thread, would solve this problem; but unfortunately, the timer code just doesn't execute.

I tried:

- new Timer().scheduleTask(task, 0, 100)
- new Timer().scheduleTask(task, 0, 100, 99999)
- Timer.schedule(task, 0, 100)
- Timer.schedule(task, 0, 999999)
- Timer.start()
- t = new Timer(); t.scheduleTask(...); t.start();

task appears to execute once, and only once; it never executes again. (It prints a date-time diff from a target time, so I can tell it's not running.)


texts: How do i define array in shader's constant buffer with C#?

texts:
I am using SharpDX to render 3D graphics and i cannot get to work constant buffer in my shader since it contains an array. Currently it looks like this:

cbuffer cb0 : register(b0)
{
    matrix mWorld;
    matrix mView;
    matrix mProj;
    float4 vLightDir[2];
    float4 vLightColor[2];
    float4 vOutputColor;
}

But how to define a struct in C#, which will be correctly marshalled to such constant buffer in shader? In C# we don't have "excplicit" array initialization, e.g. this line of code i used in C++ will not work in C#:

struct cb0
{
  // ...
  Vector4 twos[2];// C#: Vector4[] twos;
// ...
}

I always set StructLayout option Pack=16 for my structs for alignment, but HOW to define such struct with C#? i have tried to define struct like this:

struct cb0_t//pack=16
        {
            public Matrix mWorld;
            public Matrix mView;
            public Matrix mProj;
            public Vector4 vLightDir0;
            public Vector4 vLightDir1;
            public Vector4 vLightColor0;
            public Vector4 vLightColor1;
            public Vector4 vOutputColor;
        }

Yes, it works with this, but this IS NOT COOL. Thank you, sorry for my english...


texts: naming conventions in game code / vocabulary

texts:
I'm just starting out as a game developer, and I'm finding some difficulty when naming classes.

I usually call the class that handles everything World, Map, or Grid. Then there's the names, inside.

For example, I'm making a Frogger clone, and I have a class for everything that moves on screen (I try to use MVC and I'm talking about the model here - I have Sprite classes in the view), and I named it Object for lack of a better name. Then there's a subclass from Object which I named Frog (though I could name it Player)  and another one for the things controlled by the computer, which I don't know what to call (it could be Enemy or Obstacle or something appropriate for cars and trucks). This class also includes the turtles, which are more like helpful objects, yet are not powerups.

How should I manage my naming conventions?


texts: Algorithmically fracture a mesh in Unity3D?

texts:
I want to create a plugin which shatters/fractures meshes, so I can make every object destructible if I want to. Like in Unreal's built-in feature.

My quick approach to this problem is randomly generating cuts (planes):

every cut divides the mesh into 2 groups: left side of the cut and right side of the cut,
at the points where it intersects the mesh, I add vertices to both groups.
and add 1-1 face to each group with these new vertices.
create the new mesh.

Is there a better way? What do you recommend? Is my way even possible? If yes, what API methods should I use?


texts: Pre- or post-multiplication for rotation between coordinate frames

texts:
I have three 3D coordinate frames: O, A and B, as shown below.

I want to know the rotation matrix RAB between A and B, that is the rotation that is required, with respect to the frame A, to move from A to B.

Let us imagine that all I know, is the rotation matrix RAO between A and O, and the rotation matrix ROB between O and B.

So, what is the correct way to determine RAB? There are two suggestions that come to mind:

(1) RAB = RAO ROB

(2) RAB = ROB RAO

Now, my intuition is that (1) is correct, i.e. post-multiplication. This is because I am multiplying everything with respect to the local coordinate frame (as discussed in http://web.cse.ohio-state.edu/~whmin/courses/cse5542-2013-spring/6-Transformation_II.pdf).

However, when I compute this, I get a different answer to that which I get by inspection of the diagram. The correct answer, I have noticed, is equal to the pre-multiplication solution of (2).

Please can somebody explain to me why (2) seems to be correct, rather than (1)? I was under the impression that if all your transformations are with respect to the current local frame, then post-multiplication should be done, i.e. multiply the matrices from left to right as you move between each frame. However, when doing the maths, pre-multiplication gives the expected answer.


texts: To move an object forward an exact distance and then stop

texts:
I am using this script below to move an animated object in unity with no root-motion. it simply walks across the terrain and has a timer so it waits 60 seconds until starting.

void Update ()
{
    if (Time.timeSinceLevelLoad > 60)
    {
        transform.Translate(0, 0, Time.deltaTime);
    }
}

I want the object to travel a certain distance or certain amount of steps and then stop at an exact point and stay there, is there a simple way to add to the above code to do this? does it entail xyz position reached maybe?


texts: Unity: How to keep animation keyframe position in the transform

texts:
I want to make a paired animation-
I have 2 characters. One is doing a Grabbing-Move on a character who is grabbed.

But for that its necessary to animate all those animations on a character on a certain pose.

And for now I can only do the "grabber" animations on a T-Pose (first character has T-Pose always when I try to animate the second).

But I dont want to do animations on a "T-Pose"
I want to animate the Second Character(Grabber-) on a "Grabbed" - Pose.

I already have a "Grabbed-" Animation.
Now I want the "Grabbed-"Animation to stay.

For that I need to "safe" the current keyframe position of the first character - while animating the second character

How is that possible?


texts: SFML position problem when drawing a CircleShape

texts:
I am not sure but I think it's a problem with Windows 10 borderless windows
The problem is when I draw the circle its always drawn with a little offset from where it should be.

In the top of the window the shape is drawn above the mouse, in the bottom the shape is drawn under the mouse and so for each side of the window

This is my code:

#include "SFML/Graphics.hpp"
#include <stdio.h>
int main(int argc, char **argv){
        sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Application");
        window.setFramerateLimit(60);

        sf::RenderTexture renderTexture;
        renderTexture.create(800,600);
        renderTexture.setSmooth(true);
        renderTexture.clear(sf::Color(255,255,255,255));
        renderTexture.display();

        int wpoint=10;
        sf::CircleShape point(wpoint,50);
        point.setFillColor(sf::Color(255, 0, 0, 128));

        while(1){
                sf::Event event;
                while (window.pollEvent(event)){
                        if (event.type==sf::Event::MouseMoved && sf::Mouse::isButtonPressed(sf::Mouse::Left)){
                                //printf("%d\n",sf::Mouse::isButtonPressed(sf::Mouse::Left));
                                //point.setPosition(event.mouseMove.x-(wpoint/2),event.mouseMove.y-(wpoint/2));
                                //point.setPosition(event.mouseMove.x,event.mouseMove.y);
                                //auto pos=sf::Mouse::getPosition();
                                auto poswindow=window.getPosition();
                                printf("%d,%d\n",poswindow.x,poswindow.y); //This prints -8,0 when I position the window on the left-top corner (0,0)!!
                                //auto pos=sf::Mouse::getPosition(window);
                                auto pos=window.mapPixelToCoords(sf::Mouse::getPosition(window));
                                point.setPosition(pos.x,pos.y);
                                renderTexture.draw(point, sf::BlendAlpha);
                        }
                        if (event.type==sf::Event::Closed
                         || event.type==sf::Event::KeyPressed && event.key.code==sf::Keyboard::Escape)
                                return 0;
                }

                sf::Sprite canvas(renderTexture.getTexture());
                // draw
                window.clear();
                window.draw(canvas);
                window.display();
        }
        return 0;
}

One thing I noticed is when I tried to draw the circle on (10,10) it was painted under the title bar.

I read somewhere that it's probably a thing that only happens with some Intel drivers, I just hope that the users don't have it or I will be in troubles. It's weird because I have been working with the Winapi for a long time and the mouse coordinates have always been correct.


texts: When creating a game engine, how should I define the position of objects?

texts:
I'm building a custom game engine, in C++ using SDL, and I'm not sure how I should define the position of my game objects. I tried googling a bit, but I wasn't sure how to refine my search terms to get what I'm looking for.

Should I define the position (x, y) of my object to be the top left of the object, for ease of rendering? Since my game is tile based, it also makes sense to have the position of the tiles as the top left position.

Perhaps I should define it to be the center of the object, which seems to make more sense, logically? If we use width/2 and height/2 to calculate it, does the slightly-truncated integer for even-sized objects matter?

How do other games do this? Right now, my objects are defined by the top left corner, and it's annoying to do operations that find the center of the object.


texts:
I am trying to draw a triangle using shaders in LWJGL, but nothing is being drawn on the screen, and no error is being produces. I can't figure out what I'm doing wrong.
To create a vao, I use:
int buffer = glGenBuffers();
int vertexArray = glGenVertexArrays();

ByteBuffer data = ByteBuffer.allocateDirect(6 * 8).order(ByteOrder.nativeOrder());
data.putFloat(-0.5f);
data.putFloat(0.5f);

data.putFloat(-0.5f);
data.putFloat(-0.5f);

data.putFloat(0.5f);
data.putFloat(-0.5f);

glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, data, GL_STATIC_DRAW);

glBindVertexArray(vertexArray);
int positionAttributeLocation = glGetAttribLocation(program, "position");
glEnableVertexAttribArray(positionAttributeLocation);
glVertexAttribPointer(positionAttributeLocation, 2, GL_FLOAT, false, 8, 0);

and then I draw using:
glUseProgram(program);
glDrawArrays(GL_TRIANGLES, 0, 3);

Here's my vertex shader:
#version 110

in vec2 position;

void main(void) {
  gl_Position = vec4(position.xy, 1, 1.0);
}

and fragment shader:
#version 110

void main(void) {
  gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
}


texts: How to generate Spritefonts for monogame

texts:
I just want to render some text to the screen using:

monogame 3.0
MS Visual Studio 2010 C# Express

In XNA, you were able to add fonts to the content pipeline quite easily. But this doesn't seem to be the case in monogame. Loading TTF Files using Content<SpriteFont>.Load() doesn't work. Is there any way to generate or download *.spritefont files or *.xnb files containing the font data (without resorting to install XNA)?


texts: Import animated mesh without a rigged skeleton / armature

texts: How can I import an animation of a mesh that was not animated using rigging, skeletons, or armatures from blender? There's got to be a way.


texts: Prevent Animation Tab from changing the position of an object

texts: I am quite new to Unity. I am using the latest version. When I try to make a door open animation, it goes well with rotation. But when I add the position property it takes it to the Vector3(40,12.5,7.5) instead of (10,2.5,15) at the first frame. I try to change the value but it reverts after I write.


texts:
I can define several RPCs in unity and I can call them via the networkView component. But it seems that it gets the RPC called regardless where it is defined.

So I was wondering to know how do the scope of RPC works in Unity. Am I able to call whatever RPC in whatever script which share the same networkView? Or is there any other logic behind?

As a corollary: can I define a unique structured file gathering every RPC in my project?


texts: What kind of ESRB rating do you get for IMPLIED sex?

texts:
My game is a story-driven horror game with lots of gore. Obviously, being a horror game places it on the higher end of the age rating already, but because of how backwards the rating system is (female nipples = BAAAAAD!!! Some guy getting his head split in two = eh... who cares) I'm kinda worried that I would get an even higher rating for the sexual themes.

No nudity is ever shown. Some of the characters mostly flirt and say dirty things, not dancing around the f-word (like I just did), and they don't really hold back on the cursing either, but the "worst" you can see is a couple naked in bed after they've done their deed. The actual deed is never shown and you don't see them naked.

Just to be clear, the sexual themes are not the focus of the game, in fact it only happens sparsely. It's mostly about the survival of the main characters.

What kind of rating would my game get?


texts:
I'm making a chess game with wpf and I have never used wpf before. I've used windows forms, so besides the xaml, it's pretty familiar. Usually when I want to create a mousedown event I look at what I have on window design screen->click the object->go to properties->events->MouseDown event->double click the event->it creates a method that executes when the mouse is pressed on that element. Looks like this...

private void Pawn_1__MouseDown(object sender, MouseButtonEventArgs e)
{

}

But for my chess game in my C# code in the mainwindow constructor I put some initialization code to place a bunch of rectangles all over the screen representing the grid I'd be using for my chess game. How can I create a MouseDown event for these rectangles since they aren't in the designer?


texts: How do you make a ShapeRenderer always full screen on resize?

texts:
I have:

shapeRenderer.setProjectionMatrix(stage.getViewport().getCamera().combined);

And I tried to do the following in render():

shapeRenderer.rect(0, 0, stage.getViewport().getScreenWidth(), stage.getViewport.getScreenHeight());

Which full-screens the ShapeRenderer when I first run my project, but as soon as I resize the window, the rectangle starts to change size and go off-screen. I'm using a FitViewport on my Stage, is there any way to make the ShapeRenderer always be full screen?


texts: Is GPU locality of reference worth worrying about?

texts:
Does locality of reference make as much of a difference to GPU performance as it does CPU performance?

For example, if I send 200 draw commands to the GPU, will I see a (potentially) noticeable difference if the data for each command is contiguous in memory instead of jumping around the buffers/texture maps?

Side question: I'm assuming the GPU ensures against false sharing issues by having most resources immutable. But in the case where they're not, is that why threads always do four fragments' worth of work?


texts: Any way to interface methods in objects?

texts:
Say I have object A, which has children B, C and D.

In OOP I would have A be an interface containing method action(), then I would have B, C and D implement A and, in their class definition, I would define the method in each of them in extremely different ways (as intended).

Is there a way to do something similar in GML? So far I can only think of making a script with an chain of if statements for every kind of action based on object_is_ancestor() which feels messy and unorganized to say the least.

Thank you for the help.


texts:
I have two triangles in 3d space which share 1 edge and I would like to determine if the angle between their normal vectors is "uphill" or "downhill". In other words, if you set one flat, would the angle between them be acute (uphill) or obtuse (downhill). Hopefully that makes sense.

So far I have the normal vectors of each triangle and have calculated the angle between the two triangles, however this angle is always >= 90 degrees.

Vector3 v1 = triangle1.Normal;
Vector3 v2 = triangle2.Normal;
float cosAngle = Vector3.Dot(v1, v2) / (v1.magnitude * v2.magnitude);
float degAngle = Mathf.Acos(cosAngle) * Mathf.Rad2Deg;

Is there a trick I am missing that lets me determine which direction this angle is in?


texts: What operations should be multithreaded?

texts:
I wonder what game operations should be multithreaded, and which should always run on the main thread.

The most expensive operations I could come up with are:

loading a level
loading resources (for each level or at game initialization)
updating game world (weather, liquids, chain reactions, lots of small entities, etc.)
downloading from game server (level files, custom resources, player saves, object states, etc.)
occasional heavy methods (large screenshots, per-pixel calculations, full world update)

Which of those operations should be threaded, and which should not? Which of them can be threaded most effectively by using as many threads as the host supports?

Or is it better to split some of these operations into blocks and execute each frame, bit by bit, without threading, and without causing frame drops?


texts: XNA - Where should I start playing a song?

texts:
I am just wondering where is the best place to start playing the background song for a game. In the loadContent() method, Draw(), or Update() methods or when I initialize it?

I am trying to make it so that the song starts playing at the same time the screen appears.


texts: Unity prefab functionality without files?

texts:
Task

Display a UI list

Assumptions

Most UI parts only get their data during runtime
UI parts need to be styled in the editor (= before runtime)
UI editing should be done with real time preview in the editor
The items in UI list should look the same

Current solution

Save a list item prototype as a prefab (drag&drop in the editor)
Set that prefab as the reference in the script managing the list
During runtime, instantiate the referenced prefab as needed

However, this needs a prefab file, which seems like an unnecessary additional point of failure. Just one annoying example: More often than not I forget to click "Apply" after editing such a prototype - which only becomes apparent at runtime.

Suggested solution

In the script managing the list, set the list item prototype as a reference
On Awake(), create a prefab and store it in a class field
During runtime, instantiate the prefab from the class field

Question

I got the suggested solution working withPrefabUtility.CreatePrefab(). The only issue with that is that it still saves a prefab file. I currently just save those to a temp directory, but that is a workaround.
Is it possible to have a prefab which does not exist as a file, but still allows copying with Instantiate()?


texts: I add a straight big plane over terrain(3d). Vibrations are happening when i move camera

texts:
I have this problem in my OpenGL project but i will show you the same thing over blender3d with video. So I believe that I will better explain the problem. it is just 30 seconds. Take a look.  Youtube LINK
How can i fix these problem ?


texts: How to efficiently implement a 7-segment display?

texts:
I want to construct a 7 segment display (as shown below). When you input a number, the script will read the input number and light up the respective segment
(change the spriterenderer color to red) to display the number.
But I think the code has become too long, since there is 0-9 digit to display, I need 10 if statements, 8 scripts and the function of each statement is to light up the respective segment so it displays the number correctly.
Is there any better way to make the code shorter?
using UnityEngine;

public class ClockController :  MonoBehaviour
{
    Rect1 rect1;
    Rect2 rect2;
    Rect3 rect3;
    public GameObject othergameobjectrect2;
    public GameObject othergameobjectrect3;

    void Start()
    {
        int x = 1;
        if (x == 1)
        {
            rect1 = GetComponent<Rect1>();
            rect1.Rectangle1();

            rect2 = othergameobjectrect2.GetComponent<Rect2>();
            rect2.Rectangle2();

            rect3 = othergameobjectrect3.GetComponent<Rect3>();
            rect3.Rectangle3();

        }
    }
}

using UnityEngine;

public class Rect3 : MonoBehaviour
{
    public void Rectangle3()
    {
        GetComponent<SpriteRenderer>().color = Color.red;

    }
}

using UnityEngine;

public class Rect2 : MonoBehaviour
{
    public void Rectangle2()
    {
         GetComponent<SpriteRenderer>().color = Color.red;
    }
}

using UnityEngine;

public class Rect1 : MonoBehaviour
{
    public void Rectangle1()
    {
        GetComponent<SpriteRenderer>().color = Color.red;
    }
}


texts:
I have a glassy object and when light passes through it I want it to cast colored light behind it, instead of the shadow.

I could just use another light object to cast that colored light, but is it possible to do this using shaders?


texts: Accessing a UI Image that is a child of a GameObject?

texts:
I'm sure there is a very simple solution to this issue. I am creating a UI for a 2D RPG in Unity.

I have a Canvas with a two GameObjects:

DialogManager & MenuManager

The Dialog Manager has a child "DialogBox" which is a UI Image.

And the Menu Manager has three children for each part of the menu, so: three UI Images.

How the heck do I access these UI Images in a script attached to a different gameObject? Since they're technically not gameObjects, I can't just use the old gameObject.Find(). I've seen some things about Transforms and Children, but I just can't wrap my head around it.


texts: Unity's Profiler doesn't specify which of my methods take how much time?

texts:
I'm working on a map generator, which is used in Awake(), so I couldn't see it in the profiler.

So I created a new scene, where right clicking generates the map.

Now I can see the generation process (Update method), but not the specific parts of it.

Only GC.Alloc-s, GC.Collect-s and Mono.JIT-s.

Why?


texts:
So I got this weird problem with regeneration - I decided to create a mana bar which is going down every time when character attack. When the bar is less than integer 100, it should regenerate 1 points per 9 seconds and then stop. The problem is that instead of it, mana regenerate rapidly after chosen time and then, with every attack it regenerate so fast, that is basically staying in same place.

        ////MANA REGENERATION
        currentTime += gameTime.ElapsedGameTime.Milliseconds;
        if (max_mana>=0 && max_mana <= 100 &&currentTime >= 9000)
        {
            max_mana += 1;
        }

that's the parameters for the mana:

in Initialize:

   //PLAYER MANA RECTANGLE

    Texture2D manabar;
    Vector2 posManaBar;
    Rectangle recManaBar;
    //REGENERATION TIME FOR MANA

    int max_mana;
    float currentTime = 0;

In drawGameplay:

        //PLAYER MANA
        spriteBatch.Draw(backBar, posManaBar, recBackBar, Color.Gray);
        spriteBatch.Draw(manabar, posManaBar, recManaBar, Color.Blue);
        recManaBar.Width = max_mana;


texts: Is there any difference between the reading of sensors in Unity5 and Android/Java?

texts:
I'm an Android/Java developer, and I'm new to unity5. I have a program written in Android/Java that uses the readings of three sensors( Accelerometer, Magnetometer and LinearAccelertion ).

I'm now developing my first game in unity5, and I want to use the algorithm that uses the three sensors readings in my game.

In Android/Java, sensors readings are normally row data, which means that I must make some calculations on these data to be able to use them in my program.

Do I also have to make these calculations in unity5? Are the reading of sensors in Android/Java and unity5 the same or different?

If they are different, how can I use them?


texts: How to align edge vertices of modular props snapped on a 2D grid?

texts:
For a project I am working on I create some 3D props in Blender that can be put together in a modular way on a 2D grid in Unity. In Unity I generate the grid contents using these props. Now given these two simple shapes (imagine a pipe or railing in top view):

If they are put next to eachother on the grid like so (left):

I want to make a smooth transition between the two so that their edge vertices align nicely (snap together, see right image above). Note that the angle between the shapes is always the same. However there are variations like straight, left, right for each intersection and also numerous shapes.

How can I achieve this?

I have thought of the following possibilities:

Just model each possible variation in blender and use the matching prop when generating the grid (I hope I can avoid this since its a lot of effort, also it's not reusable)
Rig the shapes in Blender. In Unity move the bone transforms accordingly so that they align (I like this idea, but is it practical?)
(Somehow) mark the vertices on the edge of the shapes and move them to where they belong i.e. modify the mesh in Unity.

Are there other/better ways to achieve this? I appreciate any hints and tips.
I also know I am not the first one to try this so any guidance on where to look for resources and what terms to search for is also appreciated.


texts:
I've been looking to implement a deferred rendering system in SFML.

I've read the tutorials on OGLdev for it, and I was wondering how to draw a scene built in SFML (sprites, text, etc) to the multiple render targets needed for the deferred shading process.

Basically, I need to be able to get SFML to draw every object to the GBuffer's MRTs, so I can have the parameters needed to do what I want.

Is this possible, or will I have to build my own rendering backend from scratch?


texts:
I found this response but the thread is closed:

https://gamedev.stackexchange.com/a/13639

level = constant * sqrt(XP)

I seem unable to properly get current level, this is how I tried to do it, and everything seems to work except the actual current level for some reason:

xpConstant = 0.05;
currentXp = 80;
-- with those two values, level 1 should require 20 xp:
-- xp = 1^2 / xpConstant;
-- with 80 xp, the player should be level 2, 2^2 / 0.05 = 80

-- this is 0.47 but it should be 2?
currentLevel = xpConstant * math.sqrt( currentXp );

-- and to retrieve xp until next level, this does seem to work:
nextLevel = currentLevel + 1;
XPUntilNextLevel = nextLevel ^2 / xpConstant;
XPUntilNextLevel = XPUntilNextLevel - currentXp;

so for some reason the currentLevel variable doesn't give 2 as expected,


texts: Can Unreal Engine Blueprints do everything C ++ code can?

texts:
Can Unreal Engine Blueprints do everything that C++ code can?

Or are there limitations and some stuff you can't do in Blueprint and only using C++?


texts:
I'd like to improve my skills/try something new and I'd like to start with 3D. I have read Starting programming in 3D with C++ but I have question about engines:

What should engine do? I know it is abstraction layer above 3D API (i.e. OpenGL or DirectX) but what should it exactly do?


texts: How can I create a 3D rotating cylinder effect in a 2D game?

texts:
I want to replicate the background effect seen in this video:

https://youtu.be/5mdICmKX94A?t=14m18s

I'm using libGDX and have only done 2D game dev using this framework. Is there some sort of cheat I can do in 2D to simulate this effect, or do I need to create a 3D cylinder, tile the inside of the cylinder with repeating textures, then rotate it with the camera in the middle?


texts: How can I determine the number of pixels drawn within a predefined shape on the screen?

texts:
In the image above, I want to know how can I calculate the number of pixels of the rendered players' shadows that are inside the elephant outline.

An occlusion query is used to count the number of pixels occluded in the entire screen, but I want to restrict my count to just the number of pixels that end up inside the outline.


texts: How to restrict the players movement win relation to screen bounds in Unity? (Without colliders)

texts:
I am really enjoying making the switch to Unity. But here I have found one of those rare moments where it appears to make things more difficult (at least it is for me as I am crap at understanding the actual manual)

Basically my 'player' is a space ship. It starts life at 0,0,0 world coordinates and I have been doing all the movement based off of that. (ie. Add force X to move left or right, and there is a constant Z speed which is done via rb.transform.Translate().)

I want to restrict the movement on the X Axis, so in Libgdx id use something like:

if (player.position.x <= 0){ player.position.x = 0;}
if (player.position.x >= viewport.getX()){ player.position.x = viewport.getX();}

The thing is that wont work for me in Unity for several reasons (1. I dont know much about the viewport as I didnt create it. 2. the player.position is being affected by the rigidbody forces. AND i am working in world coordinates with the players position).

As I said, the player is constantly moving forward on Z axis, so making colliders doesnt seem like the right choice for me.

I'm pretty sure Unity devs would of put this in Unity v0.001 but I just cannot for the life of me find how to actually do it. (Any info I can find seems from like 2011 and also is pretty badly written code making this simple matter takes dozens of lines of code and some methods - I'm hoping there is  a Unity method already made, like player.transform.ScreenPosition or something but yeah I cannot find it!?

Any help would be massively appreciated as always.


texts:
I was reading chapter 4 of the Arcsyntesis OpenGL tutorial when I came across this line in the GLSL shader.

vec4 cameraPos = position + vec4(offset.x, offset.y, 0.0, 0.0);

About it, the tutorial says

  The first statement simply applies the offset to get the camera space positions of the vertices.

I understand what cameraPos is but I don't get what the offset is. It's defined as a uniform and it's passed to the shader by the main program like this:

glUniform2f(offsetUniform, 1.5f, 0.5f);

So offset.x = 1.5f and offset.y = 0.5f. But I see no mention of that offset in the rest of the tutorial and its values seem quite random to me. I know that the offset from the projection plane to the eye is always -1 but that refers to a value of Z. Where do X and Y come from? Are they arbitrary values? What they mean, what they do? I understood everything up to the point but I can find no reference to said offset in the tutorial and I'd like to know if someone can explain it to me, please.

Edit: the last line I posted was probably forgotten by the author of the tutorial and can be find in the book's source distribution here.


texts: QuadTree-based pathfinding for a volume body

texts:
I want to make a game where a player follows a mouse pointer. The game is not tile-based. I use quadtree for a collision detection and everything works fine. But now I want to develop a player pathfinding algorithm. I.e. when a user clicks somewhere the player should find the most expected way to go there and follows it. And I stuck with situations like on the picture:

Player is not just a dot. He has got specified size (2D volume). If I use centres of the quadtree regions as a path trajectory, then this tunnel looks impassable. But when I control the player directly from the keyboard, he of course, is able to pass through this place.

How can I make quadtree-based pathfinding works for such situations? Or should I use another technique to solve this problem maybe?


texts: Iterate over a loop to calculate a sum, or update a sum variable as items are added and deleted from a list?

texts:
I thought I ran into this concept at one point but can't figure out how to find an answer for it.
Is it better to iterate over a list of ints to calculate a running sum each frame, or is it better to create a variable to hold the sum and to increase or decrease it as numbers are added to the list?
The only downside I see for keeping a sum variable around is that you have to make sure you really update it correctly in all niche cases that might appear. Or ensure that items are removed from the list correctly, say, on death.


texts:
I am writing some alpha-blending code, and I realized that premultiplied alpha is enough for most cases.

So I thought about using only premultiplied alpha on my engine code to simplify the structure. Anyway premultiplication itself drops color information on low-alpha pixels, so it can be problematic if I need some kind of serious composition.

But in games, I can't figure out when I need that composition which needs straight alpha. Do you have have case we need straight alpha in trivial(?) game graphics?


texts:
I'm nearing competition of my first title and I'd like to seek out publishers but I'm also eager to show it off on social media.

Should I hold off until I've spoken to publishers or is it mostly harmless?


texts: How can I make a power-up spawn system semi-random?

texts: Basically I'm working on a similar game to achtung die kurve (http://curvefever.com). I'm almost done with the game, however I'm not completely fine with the way power up spawning works. As for now, I have setup a timer loop runs the spawn code block every 1 second. I have setup so each spawning period for each power up (total of 11 powers) is between 19.25 - 1.925 seconds. However this is fine, but it's to random I would say. For example it can be times were no power-ups spawn at all and there can be times were 5 power-ups spawn at the same time. I have made alot of games and this problem comes up every time.


texts:
I'm trying to explore a little as to how I could make a simple 'dots and boxes' game.

The problem I'm facing is in what way to store which lines are allocated by who. The problem lies in the fact that all inner lines are shared by neighbour boxes. So I can't just have four variables on each box because the right line of upper left-hand box is actually the same as the left line of box next to it. So I'd need them to be stored in one variable.

What technique of saving this data would be practical in this case?


texts: How to calculate faces involved in collision (Separating Axis Theorem)

texts:
I have a game engine created in javascript (https://jsfiddle.net/4gqsq8wf/) which uses collision detection via the Separating Axis Theorem. Currently, it does not have any means of resolving velocity upon the impact of multiple objects. Many posts have stated on this site that the post-collision velocity of an object is simply the angle of reflection. (For example: https://stackoverflow.com/questions/573084/how-to-calculate-bounce-angle) However, this requires knowing the angles of the surfaces contacting each other. I don't know how to figure out these, as the function I wrote only calculates the Minimum Translation Vector; how would I find the polygon faces involved in a collision?

Layman's terms would be appreciated.

Edit: Would this be the collision normal?


texts: Should I go with OpenGL to see my future in Game Development industry?

texts:
Possible Duplicate:
  Should I continue studying OpenGL or just switch to DirectX to  give me a better chance of landing a job in the game industry?

I tried Google but found quite old articles, so I am in search of an answer in context to year 2012.

Hi all, I don't know if you will consider this question appropriate for this community but I am constantly searching for a perfect answer.
What I have seen is that most of the games that are released these days are DirectX 1x based. Except for few games like Starcraft or Diablo which don't have high end graphics are using OpenGL.
So I have few questions to ask.

The platforms i would like to target are PC (windows), Xbox 360 and PS3 (must).

Should I go with learning OpenGL to see my future in game development industry? Or should I shift to Directx?
If I learn OpenGL first, will it be difficult to learn direcx then?
Which API is most suitable for indie development?
Which one of the two API's are better from coder's (programmer's) point of view? Like OOP and style of coding.

Is openGL being cross platform should be the only reason to choose it over Directx? Even when vendors are not providing enough stable drivers for it.

Thanks in advance.

I have read this post, but I have few questions.
Should I continue studying OpenGL or just switch to DirectX to  give me a better chance of landing a job in the game industry?


texts:
I'm creating a single player Web rpg that will store a decent amount of information about the player, items,  map,  npcs,  etc.

I have been developing html5, javascript, php, and the mysql database approach and saving/retrieving with json.

Someone mentioned for my purposes,  using 'localStorage' persistent user storage would remove much complexity and help with performance.

Is localStorage the better way to go here?  If I wanted to find out information about my players, or ensure that esch player profile is saved... can I rely on localStorage?

What are the pros and cons of each?


texts: How do you call game mode where the time is running out and player can increase time by collecting coins

texts:
I am working on an arcade game and I want to make a game mode, where the player has some time to collect coins. When a coin is collected player gets extra time, so the game can continue infinitely. But when the time is run out the game ends.
I don't know how to name this game mode. Do you have any suggestions? Something like: Time attack?


texts:
Inspired by the recently released Spelunky 2, I've been making Spelunky clone from scratch using Monogame for gamedev coding practice.
I've successfully coded the basic platforming mechanics: terrain collision solving, gravity, running and jumping, even having the camera pan up or down after pressing those buttons for a half-second.
The next thing I am trying to implement is edge-hanging. Getting the basic case of hanging after falling onto an edge in the right way was easy enough. I basically just checked for the right conditions and added a boolean in my player class for whether the player is hanging, which prevents left/right motion and keeps the player from falling when it's true.
My question is: how can I implement the edge-rolling mechanism, where you can roll over edges into an edge-hang by pressing down as you walk off? I don't understand what extra information I need to store or how to smoothly transition the player from being halfway on the edge to hanging off of the edge one block lower.
Right now the player just kind of falls away from the edge after walking off, as you would expect with the basic mechanics so far.
Any advice is appreciated! Thanks for your time.