texts: How to send data from Unity to Mailchimp

texts:
I have followed the WWWForm script reference to try to connect Unity with Mailchimp. According with the log, the form is sent without errors. Unfortunately Mailchimp did not stored any data.

This is my code:

public class EmailSendButton : MonoBehaviour {

    public GameObject emailInputText;
    private WWWForm form;

    ///
    /// In the Inspector we tell Unity to call this function when the button is clicked.
    ///
    public void onClick() {
        StartCoroutine(SendToMailChimp());
    }

    // TODO It seems to be working but Mailchimp did not store anything
    private IEnumerator SendToMailChimp() {
        form = new WWWForm();
        string email = emailInputText.GetComponent<UnityEngine.UI.Text>().text;
        form.AddField("mce-EMAIL", email); // I have also tried with: form.AddField("email", email);
        WWW w = new WWW("http://bustogames.us11.list-manage.com/subscribe/post?u=8855252b454d05c2f913c1d2b&amp;id=2ac022b22a", form);
        yield return w;

        if (!string.IsNullOrEmpty(w.error)) { print("Error sending the form: " + w.error); }
        else { print("Form sent without errors"); }
    }
}

This is the cut and paste code provided by Mailchimp:

<link href="//cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">

<form action="//bustogames.us11.list-manage.com/subscribe/post?u=8855252b454d05c2f913c1d2b&amp;id=2ac022b22a" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>

    Subscribe to our mailing list
    <input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>

<input type="text" name="b_8855252b454d05c2f913c1d2b_2ac022b22a" tabindex="-1" value="">

<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">

</form>


texts: Idle game: calculating resource generation/consumption

texts:
I'm making an idle game in the vein of Melvor Idle and I've run into a problem calculating the yield and consumption of resources while the user is away. For those who don't know, many idle games have a feature where they'll still "run" while the user is away. I say "run," because they most likely just save the user's log off and login time and then determine any offline yield based on that time delta, e.g. if I quit when I'm cutting wood @ 1 log per minute, when I get back an hour later, the game will calculate that I gained 60 logs in the interim by multiplying the time I was gone by task completion rate.

However, tasks can be more complex than simply getting a resource every minute. Tasks can consume some resources to generate another, e.g. turning ore into ingots, if there is no resource to consume, the task is cancelled. Tasks can also be exhausted and need to recharge, e.g. after doing a task 10 times, it needs to cool down for 2 minutes (look at mining in Melvor for example). I would also like players to be able to perform multiple tasks at once.

So, each task has the following features:

time: integer; how long it takes to complete one task in milliseconds
cost: a list of tuples of the form (resource, count), e.g. (ore, 5)
yield: a list of tuples of the form (resource, count), e.g. (ingot, 1)
charges: integer; the number of times this task can be completed before needing to cooldown
cooldown: integer; cooldown time in milliseconds

And I maintain a list of active tasks in the game's overall state.

You can see how this complicates the delta calculation. I can very easily deal with this if I ignore cost. The total yield can be modeled by this function multiplied by the task's yield:

function tasksCompleted(time: number, taskTime: number, taskCharges: number, taskCooldown: number) {
  if (!taskCooldown)
    return time / taskTime
  if (taskCharges <= 1)
    return Math.floor(time / taskCooldown)
  let upTime = taskTime * taskCharges;
  let totalTime = upTime + taskCooldown
  let tasksCompleted = Math.floor(time / totalTime)
  let tasksRemainder = time % totalTime
  return Math.min(charges, Math.floor(taskRemainder / taskTime)) + charges * tasksCompleted
}

I just don't know how I'd easily find the x intercept of this function so I can figure out when the cost of the task outpaces the player's resource pool. Further, imagine the player is running 2 tasks that both exhaust the same resource but have different completion times, charges, and cooldowns, how do I combine these functions to find the intercept?

My question is: is there an optimal way to represent this problem, and if not, how might I simplify it to achieve as close to the desired results as possible?

Potential solutions I have come up with so far, but don't particularly like:

Calculate yields iteratively rather than with a function and a delta. This avoids the complex math because if I ever run out of a resource, I'll know mid-loop. I don't like this because it means that the game has to essentially run X hours of game the instant the user logs back in.
Do what Melvor does and only let users perform one task and don't let tasks with cooldowns have costs. This simplifies things, but performing multiple tasks is a core mechanic to the game design, and I'd rather not lose that.
Give each task an "offline function" which would be a simple linear function that I could more easily compute. I'd still have to figure out how to combine linear functions in the code and I don't like losing the fidelity, but it could work.

I'd appreciate any advice you could give me!


texts:
I'm working on a little game that uses Irrlicht. I'm pretty new to Irrlicht and I was wondering how I could enable multisampling. The device driver is EDT_OPENGL initiated as such:

IrrlichtDevice *device = createDevice(video::EDT_OPENGL,
                                        core::dimension2d<u32>(800, 700),
                                        16,
                                        NO);

How do I enable multisampling?


texts:
I'm doing a small direct3d11 project for "fun". I know d3d11 quite well but not really any opengl. My program is designed for d3d11 but I would like it to be easy to port to opengl at some point so I'm trying to keep to abstractions that are somewhat portable. The concepts of vertex buffer, index buffers, vertex shaders, pixel shaders, and some form of input layout structures all seem to map pretty well.

But what about constant buffers? all of the examples I see of opengl shaders have code getting "pointers" to named variables in the shader and setting them whereas my code for d3d11 just creates a big c++ struct and copies it into a constant buffer. This then maps directly to a cbuffer in the shader.

Does the same concept exist in opengl? I've been unable to find it with any quick searches. Or do I have to set named variables only?


texts:
Now, the classic Torrance derivation for roughened surfaces which Cook took into vectorized form yields the familiar parametrization of a specular BRDF where we have the NDF which decides how much perturbation is around the average normal direction of the macrosurface. For example, in the isotropic GGX version, an alpha value is used to modulate just how rough the surface is or just how much specular reflection a partical halfdirection yields from the microsurface normal.

Then there's the geometry term which is, numerically, a protective term from the classic denominator of dot(n,v) * dot(n,l) which can tend to zero and the whole term to infinity. It also has a more physically intuitive side rendered irrelevant by the sheer horror of division by zero.

And there's the Fresnel term, the least threatening of all of them.

Basically, it's DGF / (4(n.v)(n.l)). And if any of these terms fail, it goes to hell. Hence, all of these terms have normalizing terms which force them in the [0,1] range. Unfortunately, the one I was studying from Epic does not converge give in to the normalization and some values at grazing angles get frustratingly high.

The BRDF is the ratio between the outgoing radiance and the incoming irradiance. Anything beyond 1 is weird to me. But 477.43 is... Well... I've double-checked everything, the math is a direct match. And yet...

Any ideas?


texts: Bullet: btCollisionWorld::contactTest doesn't work

texts:
I added some boxes in a collision world, then use btCollisionWorld::contactTest to test if any box contact with a given sphere. Below is the code:

    int SpacePhysics::SphereContactTest(const btVector3 &center, btScalar radius) {
        btSphereShape *sphere_shape = new btSphereShape(radius);
        btCollisionObject *sphere = new btCollisionObject();
        sphere->setCollisionShape(sphere_shape);
        sphere->setWorldTransform(btTransform(btQuaternion(), center));
        collision_world_->contactTest(sphere, result_callback);
        delete sphere;
        delete sphere_shape;
        return result_callback.hit_count;
    }

However no contact can be detected(when it should), if I use btCollisionWorld::contactPairTest to test the sphere with all the collision objects in the world, the contacts can be detected. But using btCollisionWorld::contactTest nothing can be detected. What's the proper way to use btCollisionWorld::contactTest?


texts: LibGDX - Drawing animation before specific tiled layer is drawn

texts:
I'm using TildedMap to separate map layer, drawSprites layer and objects layer.I'm trying to draw the map, then the player animations and then the objects on the map. This way I'll be able to have the player walk behind an object. This works for single sprites but not for animations. When I run the game, it doesn't draw the animation and if I render the animation continuously, the object layer is never reached. What can I do to get around this?

public class PlayerRenderManager {
.....

//Animation for when the player is moving up
public Animation<TextureRegion> playerUp() {
    TextureRegion[][] tmp = TextureRegion.split(textureUp, 32,32);
    TextureRegion[] walkUpFrames = new TextureRegion[4];
    sprite = new Sprite(textureUp);
    int index = 0;
        for (int j = 0; j < 4; j++) {
            walkUpFrames[index++] = tmp[0][j];
        }
        animation = new Animation<TextureRegion>(1f/30f,walkUpFrames);
        return animation;
}

Rendering class

public class MapRenderManager extends OrthogonalTiledMapRenderer {
......

private float stateTime;
public void render(Player player, ArrayList<Actor> actors, ArrayList<Projectiles> projectiles, PlayerRenderManager playerrender) {

    stateTime += Gdx.graphics.getDeltaTime();
    beginRender();
    int currentLayer = 0;
    for (MapLayer layer : map.getLayers()) {
        if (layer.isVisible()) {
            if (layer instanceof TiledMapTileLayer) {
                renderTileLayer((TiledMapTileLayer) layer);
                currentLayer++;

                // draw sprites if ground layer has been rendered and object layer is yet to be rendered
                if (currentLayer == drawSpritesAfterLayer) {

                    batch.draw(playerrender.playerDown().getKeyFrame(stateTime, true),0,0);

                } else {
                    for (MapObject object : layer.getObjects()) {
                        renderObject(object);
                    }
                    for (int i = 0; i < projectiles.size(); i++) {
                        projectiles.get(i).getProjSprite().draw(this.getBatch());
                    }
                }
            }
        }
    }
    endRender();
}


texts: Unity-How can I enlarge the sprite to avoid the movement of the character when the pivot change?

texts:
Changing the pivot to custom on all of the sprites is not a viable option for me
Video showing the problem:
https://youtu.be/YpAdamkbhFA


texts: Rotation versus transform.forward in Unity

texts:
I want my player to "face" the direction they're moving, or if not moving, face the last movement direction. There are two solutions I see most often, using rotation (usually Transform.LookAt) or a "forward" vector, transform.forward.

Is there a reason to use one or the other? What do I gain/lose by using one over the other?

For the time being I'm updating transform.forward with a normalized vector of my character movement, unless it's 0,0. That doesn't work 100% so I have some logic left, but I want to understand why this isn't done using rotation.


texts: I have several line renderers that are using as gas pipelines. A user can select one end of the pipe and attach it to one connector. Now the problem is some pipes (line renderer) are overlapping and penetrating with each other. Is there any way to avoid penetration using colliders so they look realistic?


texts: In Unity, what's a better solution than having a bunch of singleton static managers? (SceneManager, UIManager, SfxManager, PfxManager)

texts:
I always hand a bunch of public static manager classes in my game:

GameManager (singleton) for reading and writing persistent data and gamestate across scenes
SceneManager for holding scene data (coins picked up, score, are we in a cutscene)
UIManager for dealing with HUD stuff
SfxManager for sound effects
PfxManager for particle effects

On the gameobject that holds these manager classes, there are also subordinate classes (e.g. HUDManager, a smaller class that managers tasks specific to HUD, and then delegate those tasks into other smaller scripts) in order to avoid monolithic manager classes.
Is this method frowned upon in Unity game development and if so, what are some better solutions than this approach?


texts: Get collision time between two moving, non uniform Axis Aligned bounding boxes

texts: I have a problem finding the exact time of collision of two possibly moving or static objects. Both objects have AABB data (HalfExtents, Min, Max, Center vector and stuff) and a velocity vector. The objects, as I wrote, can move, but must not to. How can I get the exact collision time from now? Could you give me please a pseudo code, or at least some directions how can be this solved?


texts: Import multiple models in runtime into Unity3d scene and make an animation sequence out of it

texts: So, I have multiple models of ply file formats on my phone. When my scene is running, I want to let users import multiple models into Resource folder and create an animation sequence in runtime. Is there any way to do it? Thanks.


texts:
I'm using GameMaker Studio and I want to put my game on my website.

I need help with saving a game in a exe file or anything that will make my game to open normally. How do I do that?


texts: How to make a background fill the screen on different-resolution phones?

texts:
I am developing my first Android OpenGL game. It's a 2D game and I would like the background to always fill the screen. I've managed to achieve this by stretching the texture to fit the size of the screen based on the aspect ratio, but the texture becomes quite pixelated when stretched.

What is the correct way to achieve this?


texts: Make a sprite jump to a certain direction in libGDX

texts:
I was wondering how you can make a sprite jump to a certain direction in libGDX just like the brick does in the famous mobile game "Amazing Brick'

I want to make my sprite jump up a bit to the right when I tap the right part of the phone and make it jump up but to the left direction when I tap on the left part of my phone.

I am using libGDX on android studio and I am on a beginner level, trying to develop a unique game for android. Plz help. Thanks in advance. ^o^


texts: What AI for a resource management + combat?

texts:
I have a very simple game: 2 players (one human and a computer) and both have 1000 tokens. They must build an army. Depending on the type of soldier, it cost from 10 to 100 token to train one. Eventually I want them to attack the each other.

What would be the AI to use in that case? Is there any example around that I could learn from?

Thanks!


texts: How to play sound in WebGL build in Unity?

texts:
I have a project that works fine when I build for windows, but doesn't work when I switch platform to WebGL. The [SerializeField] AudioClip variables in the inspector are all 'missing', even after I check 'override for WebGL' convert to AAC. And when I try to link any audio file to an AudioClip within a WebGL build in the inspector, it doesn't seem to work.
How do I get sound to play within WebGL?
To recreate the problem:

Switch platform to WebGL.
Create a new Script in any recent unity version, then add a [SerializeField] AudioClip x.
Put that script on a new gameobject and try to link an audio asset to it (default import settings, however don't forget to check 'override for WebGL' to AAC, otherwise you will get compiler errors when you switch platform).


texts:
I'm developing my first game for mobile devices in Unity3D. My game uses a 720p-resolution. Currently the UI uses the same one. So far so good.

I heard that professional game-developers create their games in a way where the UI uses a much higher resolution than the game itself in order to deliver high-definition graphics for the UI-system.

So in my case does that mean I have to create a much higher resolution for the UI so it looks crisp and sharp even on large mobile-displays (e.g. tablets like the iPad Pro, etc.)? Is 1080p a good resolution for the UI I'm creating? Or shall I stick with 720p? If I use e.g. 1080p for the UI do I need to scale down the UI in Unity3D?


texts: unable to send or update data into my mysql database using unity

texts:
I am trying to save user scores into my data base so i have deveoped backend on php and mysql datbase. All the things are complete but having issues to send or receive data through my unity WWW class.

Here is my C# code to get and send data to php and then DB:

using UnityEngine;
using System.Collections;

public class Scripts : MonoBehaviour {
    string dataSubmitURL = "http://localhost/HighScore/AddScore.php?";
    string dataGetURL = "http://localhost/HighScore/GetScore.php";
    // Use this for initialization
    void Start () {
        StartCoroutine(GetScores());
        //StartCoroutine(PostScores("faizan",100));
    }

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

    }

    IEnumerator PostScores(string playerName, int score) {
        string submitURL = dataSubmitURL + "name="+ playerName + "&score=" + score;
        print(submitURL);
        WWW submitData = new WWW(submitURL);
        yield return submitData;
        if (submitData.error != null)
        {
            Debug.LogError("Error occur when Submitting data : " + submitData.error);
            Debug.LogError("Error occur when Submitting data : " + submitData.text);
            Debug.LogError("Error occur when Submitting data : " + submitData.responseHeaders);
            //submitData.text
        }
        else {
            print(" Submitted");
        }
    }

    IEnumerator GetScores() {
        WWW getData = new WWW(dataGetURL);
        yield return getData;
        if (getData.error != null)
        {
            Debug.LogError("There was an error getting the high score: " + getData.error);
        }
        else {
            print(getData.text);
        }
    }
}

If i directly run my urls into browser

string dataGetURL = "http://localhost/HighScore/GetScore.php";

then it is working perfectly and giving me data but same thing when i trying through my c# www(above code) then it reply.

There was an error getting the high score: Empty reply from server


texts: Which iPhone/iPod Hardware to Support for iPhone Game

texts:
I'm coming from a background of Android. I would like to figure out what kind of iBlah device hardware I need to support for iPhone game development; something like Android's OS distribution stats, but for iBlah hardware.

From my research, it seems that I need to support both iPod and iPhone. But which versions of hardware? is 3G still used? What about 3GS?

For example, the -S phones seem to have dual core instead of single-core CPUs.

I also worry about performance. In Android, I had a severely low-end phone, which meant pretty much anything that ran okay there ran okay on other phones. For iPhone, how do I figure out what to support in terms of performance?


texts: How can I reference the frontmost part of a mesh in my Unity code? (and help making FPS projectiles seem more real)

texts:
I have started making a PC game using Unity. It's just a test project, where I'm making as basic as possible FPS shooter.

I'm using the FPS Controller prefab, and I have also a rifle model attached to it. The result is pretty much what I wanted.

Now I'm considering how I want to create projectiles for the gunfire. I think it will be best for me to create each bullet as just being a ray from the gun barrel heading forwards, OR I might create rigidbodies from the gun barrel I'm not sure yet.

My question is: What is the proper way to reference the point in space in which the gun barrel current ends? At the moment, I am thinking just attach ANOTHER gameObject to the gun model, and just manually position it where the barrel finishes. But this seems 'cheaty' and I think perhaps there is a better way (something like mesh.position.z + mesh.length, but I can't seem to find anything like mesh.length).

I haven't posted code at all, because I haven't really written any on this project yet.

I would also be very interested to hear the pro-tip version of how best to simulate this gunfire (ie. is it best to use rigidbodies? or somehow use raycast or something? or some better way that I haven't even dreamt of)


texts: How do I resolve a collision of a circle with two rectangle corners?

texts:
I'm writing a simple non-physical one-circle-to-many-rectangles collision detector/resolver.

For collision detection, I'm using a very common algorithm, and it's working pretty well.

For collision resolving, once a collision is detected, I calculate the penetration vector, and reactively move the circle in the opposite direction. Once again, it is working pretty well.

However, when there are two adjacent colliders, and the circle is moving right in the place where the two colliders meet, the situation is more complex. This is a screenshot of the situation:

The white rectangles are the rectangle colliders (walls), the yellow circle is the circle collider (player), and the magenta lines are the vectors from the center of the circle to the closest point in each collider.

The problem happens when I get a collision on more than one rectangle. As you can see in the picture above, the top rectangle will have a penetration vector which is not in the direction of the normal of the entire surface, and as such will create artifacts as the circle slides through the wall, depending on how I handle it.

There are many solutions I have tried, but they all create artifacts. In particular, using any algorithm to pick only one collision and solving only for that one, may yield different solutions depending on the order in which they are evaluated, especially on cases where both collisions must clearly be chosen, like the following one:

Just for reference, these diagrams are meant to show a top-down, not a side view of the playing field.

Is there a known way to resolve such a collision correctly?


texts: How do I convert my XNA game to Android without using MonoGame?

texts: I want to convert my XNA Game to Android, but I don't want to use MonoGame or ExEn. How can I do this?


texts: Best collision algorithm for Axis Aligned Bouding Boxes

texts: I have a number of quads (suppose like 20-40) and i want to quickly check the collisions between any of them. I would like to know if there's a quick algorithm to do that 60 times per second without performance decrease


texts: MMORPG - Representing Money in a DB table

texts:
Where to begin... I'm currently busy with a few Udemy courses on game development using Unreal Engine 4. My end goal is to develop an MMORPG that I've always wanted to play, but never found online.

Q: How would I represent in-game money in a database table?

I've thought of adding it as a field in the "character" table, but then I struggle to see how I can implement it as a field in the "bank" table... Bank already has a quantity field, so I though about adding the money values as "items", but I just can't get myself to approve that...

Some information on the table fields:

Each players bank will have a size limit (upgrade-able) on how many items they can place in it. I was thinking of moving it out to the "character" table as it doesn't really have anything to do with the bank table...

As for the rest of the tables, I'm still working on them. For now I just wanted to get the communities opinion on how to represent money in an mmorpg database.


texts: Text is unreadable at fov's edges with HTC Vive

texts:
Not sure if this is the good place to ask or if should asked it in photography, sorry if it's not.

I was trying stuff in Unity for a vr game based on text but as I tested it I saw that the center of the field of vision is pretty sharp but the edges are blurry/"spread toward the center".
Tests were made with the first HTC Vive and it was the first time I used it (https://www.vive.com/eu/product/)

The problem is, high text quality is really important, it has to be the cleanest it can be in the entire fov.

Does Unity can be tweaked to solve this problem ?
Is this a problem with the physical headset's lenses ?
Can it be fixed by changing headset configuration or something ?

Also, as this is linked to the subject, is there some way to get a wider fov without increasing the "blurry edges" effect ?


texts:
i'm asking for a more clever encoding algorithm to retrieving game stats
which generates a shorter and more clear password

for example i have this information's to be saved via a short CODE

Health                    0 - 99
Armor                    0 - 99
Ammo                    0 - 999
Shells                     0 - 99
Rockets                  0 - 9
Weapon1                0 - 1 // picked or not (boolean)
Weapon2                0 - 1
Weapon3                0 - 1
Weapon4                0 - 1
Level                       1 - 3

what i did :

an inline example of above information's :
99    99  999 99  9   1111    3

the encoded result with base64 as String : OTkgOTkgOTk5IDk5IDkgMTExMSAz

the encoded result with base64 as Decimal : Y2PPp2MJ0ZcD (good but long yet)

what i know is to handly encoding some part of the code
for example for boolean part, there is only 16 states, 0000 0001 0010 0011 ...etc

so it can be reduced to only 16, information could be reduced to: 99 99 999 99 9 16 3

then result will be still same : Y2PPp2MJEAM= (ogly and long)

i used this website for decoding and encoding


texts: Offsetting ground texture doesn't work in WebGL

texts:
so I've created a 2D sidescroller game, the technique I used is to keep the player on the same place, and move the obstacles towards him. I also offset the ground and backdrop constantly to create the illusion of player moving.

The ground texture is on a quad, and the texture wrap mode is set to repeat.
In the editor everything is running fine as I wanted, however when I build it (WebGL), in the browser the ground doesn't seem as if it is set to Repeat but rather Clamp.
Here's how it looks:

You can see from the left part of the image the ground doesn't repeat, the strange thing is that, after the game runs for a few more seconds it fixes, and then in a few seconds becomes like that again.

heres the code attached to the ground to keep it offsetting constantly:

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

public class Offset : MonoBehaviour {

public float scrollSpeed;
public Material mat;

private float offset;

// Use this for initialization
void Start () {
    mat = GetComponent<Renderer>().material;
}

// Update is called once per frame
void Update () {
    offset = Mathf.Repeat(Time.time * scrollSpeed, 1);
    mat.mainTextureOffset = new Vector2(offset, mat.mainTextureOffset.y);
}
}

What may I be doing wrong, and how can I fix it?

Thanks in advance!


texts: Resizing a Framebuffer Object (ie: its attachments) on Screen Resize

texts:
I have been experimenting with some post-processing effects and I have been using FBOs to store stuff.

The problem is, I attempt to resize them when I change resolution. I get no errors, however the image has been stretched so that I only see about the bottom-left quarter of it on my screen.

I have looked over the internet and and found issues such as not using glTexStorage because it is immutable, and being sure to call glViewport after binding a framebuffer. As far as I can see I'm not missing anything simple like that.

Here are some (very dark) screen shots showing the issue:

Please excuse the horrible graphics. I am working on a bloom filter and these images only contain the bright bits so it looks dark and weird.

My FBOs are initialised with a blank texture attached to GL_COLOR_ATTACHMENT0. Here is the rough pseudo code (in java). (my actual code is abstracted behind a game engine I'm writing)

Generating texture:

    // Creates the texture

    this.id = glGenTextures();

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    glBindTexture(GL_TEXTURE_2D, this.id);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    // Set up texture scaling
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magnification);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minification);

Filling it with data: (data is a ByteBuffer filled with 0s)

    glTexImage2D(GL_TEXTURE_2D, 0, colorMode, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
    glGenerateMipmap(GL_TEXTURE_2D);

Binding the framebuffer:

   glBindFramebuffer(GL_FRAMEBUFFER, this.id);
   glViewport(0, 0, width, height); // width and height taken from width and height of framebuffer texture

Resizing the framebuffer:

    // stores new width and height to be used with glViewport
    this.width = width;
    this.height = height;
    // resize renderbuffer
    if(renderbuffer != 0) {
        glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
        glBindRenderbuffer(GL_RENDERBUFFER, 0);
    }

    glBindTexture(GL_TEXTURE_2D, texture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
    glGenerateMipmap(GL_TEXTURE_2D); // do i need this?

Thanks very much in advance if you can spot an issue with my code. Let me know if you need the full source as well.

I have a couple of ideas for issues:

is it possible to resize the renderbuffer like that?
do I have to re-attach the textures after resizing them
should i just re-create the entire framebuffer/renderbuffer/textures instead of resizing them.


texts:
How do I close the GUI after the user enters a value? Is there any way to stop execution of the entire app (from inside this script) until a value is entered?

using UnityEngine;
using System.Collections;
using UnityEngine;
using UnityEditor;

public class Popup : MonoBehaviour {

    // Use this for initialization
    void Start () {

    }

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

    }

    string record="";

    void OnGUI() {
        //Participant Number/Record:
        GUILayout.Label ("enter participant id:");
        record = GUILayout.TextField(record);
        //GUILayout.TextField()

        if (GUILayout.Button("Submit")) {
            OnClickSavePrefab();
            GUIUtility.ExitGUI();
        }
    }

    void OnClickSavePrefab() {
        record = record.Trim();

        if (string.IsNullOrEmpty(record)) {
            EditorUtility.DisplayDialog("Unable to save record", "Please specify a valid participant record.", "Close");
            return;
        }
        // Save your prefab
        Debug.Log ("record:" + record);
    }
}


texts: Where could I look online to learn about being a game designer?

texts: I'm interested in being a video game designer but I know next to nothing about how to do what ever it is I will be doing as a game designer. Could you offer any advice of a good online area where I could learn about the basics of game designing and later on the more complicated information.


texts: Changing the Camera at Some Spots Unreal 4 Blueprint

texts:
I'm making a 2D game, and during the level the camera will move together with the player. But in the end, during the final boss, I want the camera to stop and don't move during the fight.
How I can make it with blueprints on Unreal 4?


texts: UI Sprite in Unity3D is badly drawn? (Possibly anti-aliasing problem)

texts:
I move a

28x42 Image,
in a 11x17 RectTransform
in Update,
with anti-aliasing on,
without compression,
with point filtering.

But sadly its visuals aren't smooth, it's flickery, even in a standalone build with 1440p resolution.

I move it like this:

Arrow.anchoredPosition = new Vector2(newX, Arrow.anchoredPosition.y);

I've already tried:

Changing the RectTransform's size to 28x42.
Turning off anti-aliasing.
Changing filtering modes.
Moving it in FixedUpdate.

I tried it with a 110x170 and 280x420 RectTransform, but it's still wrong: (110x170 shown below)

Why?


texts:
i am having a problem with animations in my game using flashpunk

this is one of the animations that are causing problems in the game. The animation looks like that. The actual entity however with the animation  on it looks like this

but without the tiled background

the code i am using is this

package
{

import net.flashpunk.Entity;
import net.flashpunk.graphics.Image;
import net.flashpunk.FP;
import net.flashpunk.graphics.Spritemap;

public class Fireball extends Entity
{
    public var angle:int = FP.angle(Player.playerX,Player.playerY,FP.world.mouseX, FP.world.mouseY);
    [Embed(source = 'Images/fire ball.png')] private const FIREBALLANIME:Class;
    protected var animatedSprite:Spritemap = new Spritemap(FIREBALLANIME,128,128);

    public function Fireball()
    {

    animatedSprite = new Spritemap(FIREBALLANIME, 16, 16);
    graphic = animatedSprite;
    animatedSprite.add("defaultfire", [0, 1, 2, 3], 24);
    x = Player.playerX;
    y = Player.playerY;
    animatedSprite.play("defaultfire");
    }
    override public function update():void
    {

    }

}

}

i turned the png's into an animation using texture packer. The ide i am using is FlashDevelop. I used pyxel edit to make the actual art.


texts: Alternatives to map of strings in regard to performance

texts:
I would like to start my first question here with a subjective question. I think it qualifies as constructive.

To introduce the situation: I have a 2D tiled map. I also had different arrays of graphics (one array for tile graphics, one array for GUI graphics, multiple arrays for different kinds of entities that can be placed onto the map).

Because I have not liked these many arrays I wanted to refactor so that I have one data structure to hold all my graphics.
The thing is now that a number of graphics belong together

A map tile has several graphics for different views, i.e. angles you can watch from.
An animation has multiple frames and is also view-dependant.
There are entities with have multiple states and therefore different graphics.

These states I can also use for GUI elements (button normal, hovered, pressed).

To consolidate all these requirements I thought of

std::unordered_map<std::string, const GraphicSet*>

as the holder of all the graphics

// with ...
class GraphicSet : private std::unordered_map<GraphicSetKey, Animation*, ...>

class Animation : private std::vector<const IGraphic*>

typedef const std::string GraphicSetKeyState;
typedef const std::string GraphicSetKeyView;
typedef std::pair<GraphicSetKeyState, GraphicSetKeyView> GraphicSetKey;

// ...and IGraphic as the very graphic

.
I knew that using standard library container is slower than arrays in memory but tried it anyway. And indeed it is too slow. According to callgrind rendering a single frame is nearly 85% slower than before. This is unacceptable.

I do not want to badmouth the standard library because if I would implement my own container it would be as bad. The problem - callgrind reveals this as well - are the strings I am using.
For every tile I want to draw the program creates a string uses the whole mechanism hashing and so on just to get me the graphic I desire.

Now we are getting to the question:
What data structure / technique would you suggest? (please read on)

My next idea is to partially fall back to my graphics arrays. But instead of several arrays I want to do one big array and map these views and state at compile time to indexes.

One issue I yet have in mind: My goal eventually is to be open for extensions. I want everything to be configurable so for example modifying the entities and the graphics of the game is possible by editing a config file.

With strings this is pretty easy by simply adding a new key to the map. If however I use fixed indexes at compile time this will be a very big problem in the future.

How can I keep it performant but also flexible for the future?


texts: How do I make a health bar that drains when the player takes damage? C#/XNA

texts:
I've drawn a Health Bar before and had it drain/refill on a button press using if statements and rectangles.

First I loaded the image, then I set a new rectangle to be equal to the image's height and width.

        greenHealth = Content.Load<Texture2D>("GreenHealth");
        redHealth = Content.Load<Texture2D>("RedHealth");
        blackHealth = Content.Load<Texture2D>("BlackHealth");
        jumpGuy = Content.Load<Texture2D>("JumpGuy");
        enemyBlock = Content.Load<Texture2D>("Block");

        greenRectangle = new Rectangle(0, 0, greenHealth.Width, greenHealth.Height);
        redRectangle = new Rectangle(0, 0, redHealth.Width, redHealth.Height);
        blackRectangle = new Rectangle(0, 0, blackHealth.Width + 5, blackHealth.Height + 5);

Then I set it to drain/refill based on key presses -

  public void healthDrain()
    {

        if (Keyboard.GetState().IsKeyDown(Keys.Space))
        {
            greenRectangle.Width -= 2;
        }

        if (Keyboard.GetState().IsKeyDown(Keys.Space))
        {
            redRectangle.Width -= 1;
        }

        if (Keyboard.GetState().IsKeyDown(Keys.L))
        {
            redRectangle.Width = greenRectangle.Width;
        }

        if (Keyboard.GetState().IsKeyDown(Keys.R))
        {
            greenRectangle.Width += 1;
        }

        if (greenRectangle.Width > blackRectangle.Width - 4)
        {
            greenRectangle.Width = blackRectangle.Width - 4;
        }

    }

The Result is a Health Bar that can be drained/refilled -

The problem arises when I want the health to drain/refill based on the Player Health, which I set to 100.  I do not know how to properly implement this and attempts at it have resulted in it functioning incorrectly, like the health draining on its own, or not moving at all.

I intend to have the player take damage when in contact with the yellowish-green block in the image. I did this using rectangles and an if statement with rectangle.Intersect.

        if (jumpRect.Intersects(enemyRectangle))
        {

            playerHealth--;

        }

I tried having the health bar's width be equal to the playerHealth value but it didn't work and I'm unsure of how to make it work correctly.

I do hope I was able to make this easy for someone to help me solve.


texts: Rendering output to arbitary quadrilateral

texts:
I want to render output on a device to an arbitary quadirlateral, i.e. project texture on to a quad. What are the possible ways I could implement it?

Till now, I have investigated:

Drawing textured quadrilateral - Quads look odd as they are composed of triangles, and the distortion looks odd. The issue I'm facing has been discussed here and here as well.
Setting transformation on device - Need help in getting this implemented.
Pixel shaders - Not able to implement the desired effect.

Any help would be much appreciated.


texts: Is it possible to load shader files from a DLL?

texts: I have a few HLSL files that I'd like to add into a DLL project so that I don't have to keep adding these same shader files into a new Content project every time I want to use them. Is this possible, or does the XNA framework have to compile the shader files beforehand?


texts: How to achieve this particular screen filter with GLSL?

texts:
I know this may be a "short" question, but still here it goes.

I would like to know how to achieve a post rendering effect, that looks like the following image from walking dead series:

I will make the art already fitting the style, but what if I want to make the colors more coherent by adding a color filter such as the one in the picture?

Thanks


texts: Unity 2D Player Shoots at my joystick position

texts:
Hi I am new to unity and have only a little coding knowledge.
Right now I have made my character shoot at my touch position on mobile but when ever I touch the joystick, whick I use to move my character, he shoots there, what should I do to make him not shoot at the joystick when i hold the joystick, any suggestion... heres my code.
Shooting code
public class Shooting : MonoBehaviour
{
    public GameObject shot;
    private Transform playerPos;

    void Start()
    {
        playerPos = GetComponent<Transform>();
    }
    void Update()
    {

            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
             Instantiate(shot, playerPos.position, Quaternion.identity);
            }
            else if (Input.GetTouch(1).phase == TouchPhase.Began)
            {
                Instantiate(shot, playerPos.position, Quaternion.identity);
            }
        else if (Input.GetTouch(2).phase == TouchPhase.Began)
        {
            Instantiate(shot, playerPos.position, Quaternion.identity);
        }

    }
}

Projectile Code
public class Projectile : MonoBehaviour
{
    private Vector2 target;
    public float speed;
    private Shake shake;
    void Start()
    {
        shake = GameObject.FindGameObjectWithTag("ScreenShake").GetComponent<Shake>();
        target = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
        target = Camera.main.ScreenToWorldPoint(Input.GetTouch(1).position);
        target = Camera.main.ScreenToWorldPoint(Input.GetTouch(2).position);
    }

    // Update is called once per frame
    void Update()
    {
        transform.position = Vector2.MoveTowards(transform.position, target, speed * Time.deltaTime);

        if(Vector2.Distance(transform.position, target) < 0.2f)
        {
            Destroy(gameObject);
        }

    }
    void OnTriggerEnter2D(Collider2D other)
    {
        shake.CamShake();
    }
}

Thanks in advance


texts: Number of Impressions on Admob for Revenue

texts: Just curious for a rough estimate; how many impressions would it take to make 300 dollars, a day, in ad revenue?


texts: Why do i get this error in VS2017 but game compiles and works as expected?

texts:
I have this error, yet the game works and that variable ActorThatOpens get assigned correctly.

In my header the includes are:

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Engine/TriggerVolume.h"
#include "OpenDoor.generated.h"

As far as I can tell from the docs Components/ActorComponent.h contains the function  GetWorld().

I have to go work now, but been scratching my head over this for an hour or so, and will continue to when i get home later. If anyone can see what I am doing wrong and can help I will be so grateful.

(As you can probably tell I am completely new to C++) THANKS!


texts:
I'm currently involved in a college assignment where we must create a game with our own game engine. In my game, we have an enemy moving around with paths constructed with a A* algorithm. Every frame I update his position but this is too dependent on the computer. Can you guys help to figure out how to solve this?

I tried to make him move only in even frames but, again, it's too time dependent and it's not smooth.


texts: My ball which has a circle collider 2D component occasionally passes through my box collider2D object. Both objects have rigidbodies attached. I have set a high mass for my box collider and a small mass for my ball. Strangely enough, it doesnt pass through every time (maybe due to varying velocity). Basically i am making pong.


texts: Affecting all instances of a GameObject at once

texts: I want all instances of a prefab to change their velocity when one of them is clicked, and I think having each object constantly check a variable with a coroutine might not be the best solution. How can I reference all instances of the prefab in a script efficiently?


texts:
I'm converting old shader code to be a bit more modern. So far this works out great, but I'm having a though time figuring out how to convert shader code that works with cubic textures.
In the old code I would declare a generic texture in HLSL and create a samplerCube to do the sampling. Then  I would use the intrinsic texCube function to actual sample in the direction of the normal N.
texture Irradiance;
samplerCUBE irradianceSampler = sampler_state
{
    Texture = (Irradiance);
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    MipFilter = LINEAR;
    AddressU = Clamp;
    AddressV = Clamp;
    AddressW = Clamp;
};

float3 N;
float4 irradiance = texCUBE(irradianceSampler, N);

In the updated shader I would like to use the texture objects. In case of a cubic texture I would assume I'd have to use the TextureCube type. This type has a regular Sample method but that method does not accept a samplerCube only a sampler. Using a regular sampler I have no idea how to pass the normal argument N to look up the pixels.
To summarize in code, this is the code that I expected to have to write
TextureCube Irradiance;
samplerCube irrandianceSampler = sampler_state {...};

float3 N;
float irradiance = Irradiance.Sample(irradianceSampler, N);

But that doesn't compile because samplerCube does not conform to the first argument of Irradiance.Sample.
TLDR
Who can show me the right syntax to sample from a TextureCube in HLSL Shader Model 5+.


texts:
I'm trying to implement a 3D camera of the "Orbit around the origin" variety in a game engine I'm developing in order to learn about 3D graphics and game programming. I have a basic handle on the required math, and have implemented my own crude 3D math library and matrix stack (functionally similar to the one in OpenGL's compatibility profile). My first attempts at a camera failed miserably, until I decided that I should use quaternions to represent rotation. Once I'd done that, I had a camera that moved in the direction I expected it to at about the right speed and fairly smoothly, but there is an odd spatial distortion effect that I can't seem to get rid of. I have posted a brief video on YouTube showing exactly what is happening.

I honestly don't know what could be causing this issue, the magnitude of the distortion appears to reach a maximum at certain angles, but beyond that I'm not sure what I should be looking at. Right now my chief suspect is my quaternion math code, because the matrix stack appears to be behaving itself and if something was wrong with my matrix math code I would be having more serious issues than this.

I'm not sure what information or code I can provide that would be of any use, so I'll start with the code that handles quaternion math.

public class Quaternion {
private float w;
private float x;
private float y;
private float z;

public Quaternion(){
    this(1.0f,0.0f,0.0f,0.0f);
}

public Quaternion(float W, float X, float Y, float Z){
    w = W;
    x = X;
    y = Y;
    z = Z;
}

public void loadIdentity(){
    w = 1.0f;
    x = 0.0f;
    y = 0.0f;
    z = 0.0f;
}

public float magnitude(){
    //AKA the "norm"
    return (float) Math.sqrt(w*w + x*x + y*y + z*z);
}

public void qNormalize(){
    float mag = this.magnitude();
    w /= mag;
    x /= mag;
    y /= mag;
    z /= mag;
}

public void qMultiply(Quaternion q){
    this.qMultiply(q.w, q.x, q.y, q.z);
}

private void qMultiply(float w2, float x2, float y2, float z2){
    //Performs A*B, where this Quaternion is A
    this.w = w*w2 - x*x2 - y*y2 - z*z2;
    this.x = w*x2 + x*w2 + y*z2 - z*y2;
    this.y = w*y2 + y*w2 + z*x2 - x*z2;
    this.z = w*z2 + z*w2 + x*y2 - y*x2;
}

public float[] qMatrix(){
    //Return a 4x4 matrix representation of this Quaternion, column-major like OpenGL prefers
    float w2 = w*w;
    float x2 = x*x;
    float y2 = y*y;
    float z2 = z*z;

    if(Math.abs(w2+x2+y2+z2 - 1.0) >= 0.000001){
        this.qNormalize();
        return this.qMatrix();
    }

    return new float[]{
        1.0f - 2.0f*y2 -2.0f*z2, 2.0f*x*y + 2.0f*w*z, 2.0f*x*z - 2.0f*w*y, 0.0f,
        2.0f*x*y - 2.0f*w*z, 1.0f - 2.0f*x2 - 2.0f*z2, 2.0f*y*z + 2.0f*w*x,0.0f,
        2.0f*x*z - 2.0f*w*y, 2.0f*y*z + 2.0f*w*x, 1.0f - 2.0f*x2 - 2.0f*y2,0.0f,
        0.0f,0.0f,0.0f,1.0f
    };
}

public void qFromAA(float angle, float[] axis){
    //create a Quaternion from an axis-angle representation

    if(Vector.magnitude(axis) == 0.0f){
        this.loadIdentity();
        return;
    }

    float theta = angle/2.0f;
    axis = Vector.scale((float)Math.sin(theta), Vector.normalize(axis));

    w = (float)Math.cos(theta);
    x = axis[0];
    y = axis[1];
    z = axis[2];
}

public String toString(){
    return "w: "+w+"\tx: "+x+"\ty: "+y+"\tz: "+z+"\tmag: "+(x*x+y*y+z*z+w*w);
}

}

Any ideas about where I should start?


texts:
I am making a COLLADA parser in Java, and I have made a loader that reads a .dae file, and saves it's content in a string. But, when I load a specific file, it doesn't get read correctly. Specifically a line of 3s between two  nodes is getting read wrong. Instead of reading in 3s the program reads in spaces. How do I know it is a line of 3s? Well, when I open the file with Notepad++ or Sublime Text 2 it opens fine, but when I open it from Eclpise's Text Editor or load it from my program it reads it wrong. Any reasons why that happens and how to can fix it?

This is my code for loading the file:

BufferedReader reader = new  BufferedReader(new FileReader("src/MAIN/ScondTest.dae"));
StringBuilder builder = new StringBuilder();
String line = reader.readLine();//Ignore the first line: <?xml...
while((line = reader.readLine()) != null) builder.append(line).append(" ");
line = builder.toString().trim().replaceAll("   ", "").replaceAll("  ", "");

This is a link to my file (the line of 3s is at line 228):

https://drive.google.com/open?id=0B_QCd3U4JeWLbmYwSnlzY2ttdEE

This is a small part of the line of 3s(to big to put it all): 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3


texts: I have a SDL_Renderer in SDL2 that I use both to render textures on screen and to render textures on textures, my problem is that when I render to texture the renderer may have some content in it which needs to be drawn, but if it's empty and I call SDL_RenderPresent() on it the screen flickers. So how can I check if there's something drawn inside the renderer?


texts: 2D game background art and assets, sketch / drawing size and resolution for a 1080P PC Console game?

texts:
I am a new game developer, working on a 2D platformer game.

I am working with my friends who can make sketches on paper and import them to Photoshop to paint, as none of us have worked on an actual game before we have no idea as to what scale /dimension to use while sketching (the background image for eg.).

I have always been a programmer and have only worked with blocks as placeholders while learning. So I have no idea how to communicate with the artists on what resolution or scale they should use or what type of assets I want.

My Required result is:

I want a game which should look good on a 1080p screen.
I want a 16:9 ratio for the game, with black bars at the bottom and top like
movies.
It should be scalable to fit all resolution screens(I am targeting
PC and console (future)release for the game).
You can imagine Guacameele as a reference for the art style.

My Specific questions are:

How should I communicate the technical aspects of the art to the artists for
character sprites / background images and items?
Is sketching out an image and taking a photograph and importing to photoshop
a good way to work on the assets? If not what should be done?
Should all the assets be of the same size, as I want a 1080p game and
suppose if the background is 1xsize should the character be 1/6xsize or the
same size as the background asset and scaled down in Unity(I am using unity
for development)?
What is the correct way of working with sprites in such a case, which image
format should I use, some other tools I should be using or some guide or
guidelines that everyone follows will be helpful.

Thanks !


texts: Android emulator with acceleration and gyroscope simulation

texts: Is there an Android emulator that is compatible with eclipse that can simulate acceleration and tilting of a mobile device?


texts: how can i make an object in a canvas always look at the mouse cursor

texts:
this is my code

var myGamePiece;

function startGame() {
    myGamePiece = new component(30, 30, "red", 10, 120);
    myGameArea.start();
}

var myGameArea = {
    canvas : document.createElement("canvas");
    start : function() {
        this.canvas.width = 480;
        this.canvas.height = 270;
        this.context = this.canvas.getContext("2d");
        document.body.insertBefore(this.canvas, document.body.childNodes[0]);
        this.interval = setInterval(updateGameArea, 20);
         window.addEventListener('keydown', function (e) {
            myGameArea.keys = (myGameArea.keys || []);
            myGameArea.keys[e.keyCode] = (e.type == "keydown");
        })
        window.addEventListener('keyup', function (e) {
            myGameArea.keys[e.keyCode] = (e.type == "keydown");
        })
    },
    clear : function() {
        this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
    }
    }

function component(width, height, color, x, y) {
    this.gamearea = myGameArea;
    this.width = width;
    this.height = height;
    this.speedX = 0;
    this.speedY = 0;
    this.x = x;
    this.y = y;
    this.update = function(){
        ctx = myGameArea.context;
        ctx.fillStyle = color;
        ctx.fillRect(this.x, this.y, this.width, this.height);
    }
    this.newPos = function() {
        this.x += this.speedX;
        this.y += this.speedY;
    }
}

function updateGameArea() {
    myGameArea.clear();
    myGamePiece.speedX = 0;
    myGamePiece.speedY = 0;
    if (myGameArea.keys && myGameArea.keys[37]) {myGamePiece.speedX = -5; }
    if (myGameArea.keys && myGameArea.keys[39]) {myGamePiece.speedX = 5; }
    if (myGameArea.keys && myGameArea.keys[38]) {myGamePiece.speedY = -5; }
    if (myGameArea.keys && myGameArea.keys[40]) {myGamePiece.speedY = 5; }
    if (myGamePiece < 299) {myGamePiece.speedX = -5}
    myGamePiece.newPos();
    myGamePiece.update();
}

I want myGamePiece to look exactly were the mouse cursor is looking. How can I do this?


texts:
Preface:

I purchased Programming an RTS in DirectX recently, and I know the code uses DirectX 9, but it has fantastic reviews and is apparently one of the best books you can get on beginning DirectX.

Question:

To my understanding, DirectX is just a means of displaying graphics to the scene. I will still have to code any games in C++ using game logic code, input, etc. Was I naive in thinking I could read the book with the MSDN tutorial site open for DirectX 10, and convert all of the samples to DirectX 10, or is that gonna be extremely difficult for me to do?
Also, is DirectX 9 still relevant, or would it really behoove me to go about converting to DX 10?

Thanks!


texts: How can I make billiard without using Rigidbody?

texts:
Unity's physics engine isn't deterministic (ie. the results aren't always the same on all computers) so I haven't Idea that how billiard games Implemented.Is there a way to Implementing fake and deterministic
physic in unity?
I mean I want to make billiard without using Rigidbody

http://www.bezzmedia.com/swfspot/tutorials/flash8/8_Ball_Pool

I found this open source project that didn't use physic! this is what I need but unfortunately it's full c++ and I haven't enough time to convert it to c#

http://downloads.sourceforge.net/foobillard/foobillard-3.0-win32-2-bin.zip


texts: Why when coloring a Light from green to red it's coloring only part of it in red?

texts:
I have in the Hierarchy a door with a script attached to it.

The script:

using UnityEngine;
using System.Collections;

public class DoorVert : MonoBehaviour {

    public float translateValue;
    public float easeTime;
    public OTween.EaseType ease;
    public float waitTime;
    public Light[] lt;
    public bool doorLocked = false;

    private Vector3 StartlocalPos;
    private Vector3 endlocalPos;

    private void Start(){
        StartlocalPos = transform.localPosition;
        gameObject.isStatic = false;

        if (doorLocked == true)
        {
            for (int i = 0; i < lt.Length; i++)
            {
                lt[i].color = Color.red;
            }
        }
    }

    public void OpenDoor(){
        if (doorLocked == false)
        {
            OTween.ValueTo(gameObject, ease, 0.0f, -translateValue, easeTime, 0.0f, "StartOpen", "UpdateOpenDoor", "EndOpen");
            GetComponent<AudioSource>().Play();
        }
    }

    private void UpdateOpenDoor(float f){
        if (doorLocked == false)
        {
            Vector3 pos = transform.TransformDirection(new Vector3(0, 1, 0));
            transform.localPosition = StartlocalPos + pos * f;
        }

    }

    private void UpdateCloseDoor(float f){
        if (doorLocked == false)
        {
            Vector3 pos = transform.TransformDirection(new Vector3(0, -f, 0));
            transform.localPosition = endlocalPos - pos;
        }

    }

    private void EndOpen(){
        if (doorLocked == false)
        {
            endlocalPos = transform.localPosition;
            StartCoroutine(WaitToClose());
        }
    }

    private IEnumerator WaitToClose(){

        yield return new WaitForSeconds(waitTime);
        OTween.ValueTo( gameObject,ease,0.0f,translateValue,easeTime,0.0f,"StartClose","UpdateCloseDoor","EndClose");
        GetComponent<AudioSource>().Play();
    }
}

I added the doorLocked bool variable.
And i want that when it's true and the door is on locked state to change the color of the two Point light 1 from green to red.

In the Start i did:

if (doorLocked == true)
            {
                for (int i = 0; i < lt.Length; i++)
                {
                    lt[i].color = Color.red;
                }
            }

When i'm running the game and doorLocked is false this is how it looks like:
Both lights are green and i selected one of the Point light 1 and you can see in the inspector the Color is green:

Now this is a screenshot when the game is running and when lockedDoor is true.
Now it should be red but it's only red around the Point light 1 the color seems to be still green:

Now i saw that in the Hierarchy one object above Point light 1 is called Light_Small_02 it's a child also of Light_Small_02:

I marked it here with a black circle.

And i think that i need also to change this Light_Small_02 color from green to red. Not sure since i can't find any green color with it in the inspector but when i disable the Light_Small_02 the green color is gone.

Anyway the main goal is to change the color of the two lights according to the door state: doorLocked true/false

This is a screenshot of Light_Small_02 inspector showing the mesh renderer part:


texts: When two moving objects collide, which one sends the message, and which one recieves it?

texts:
I am writing a platform game using an entity-component system. Entity-World collisions are robust and work very well, and I'm now working on collisions between entities.

Just to be clear, in my code an Entity is a collection of Attributes (data) and a collection of pointers to Components (logic).

My Entity class has a sendMessage(messageType type, char* messageData) member function, which adds the messageType and messageData to a queue which is then used by the component interested in that message type. So in this example CollisionMessage is used by CollisionComponent and processed at the end of the tick with other messages (after normal collision checks).

My problem is that with every collision, I have two messages sent per collision, from each Entity to the other. This means that either I need to halve the forces I apply since it applies to each entity twice or I need to set up some Entities to only send collision messages and some to only receive collision messages.

So far things work fine when a player collides with an item, as it just gets picked up and removed from the world, but collisions between players and enemies are proving troublesome.

Is there a better way, or is there anything fundamental I've missed?

Thanks.


texts: Total Texture memory size iOS / OpenGL ES

texts:
My team is running into an issue where the amount of texture memory allocated via the glTexImage2D is high enough that it crashes the app ( at about 400 MB for iPhone 5). We're taking steps to minimize the texture allocation ( via compression, using fewer bits/channel and doing procedural shaders for VFX etc).

Since the app crashed on glTexImage2D, I felt like, it's running out of texture memory (as against virtual memory). Is there any documentation/guideline on the recommended texture memory usage by an app (not just optimize your texture memory) .

AFAIK on iOS devices ( and many Android devices) there's no dedicated VRAM and our app process is still well within the virtual memory limit. Is this some how related to the size of physical RAM ? My searches so far has resulted only in info on max texture size and tricks for optimizing texture usage and such. Any information is appreciated.


texts: Will my huge sprites for a 2d game create performance issues?

texts:
I'm new to Unity, and have been confused about this issue for a while. Some people say that for 2D games you don't need to worry about performance (I'm making the game for PC, not mobile) while others report bad performance with larger sized sprites

I have a long scene with some large background sprites, measuring about 14552x3308 (weird resolution I know, would that also cause issues?) All methods of scaling it down and resizing in Unity lead to jagged edges (these are basically hills so I need them to be significantly bigger than the player character) I always keep the image size in the inspector similar to the resolution of the actual file, and set the filter mode to Point, so the jagged edges are not due to that, but only because of me scaling up a smaller file size to fit the scene.

If I use the original sprites of 14552x3308, it's perfectly smooth (image size set to 8192 in inspector) but each file takes about 120mb in the profiler. All combined, my assets are showing a usage of 1.25 GB for this scene. How bad is this? Should I be trying to keep it under 1GB?

I don't really know what the best practices are in this situation, so I don't know what to aim for. I'd ideally like to keep the sprites at this large size so that I don't have to redraw anything.


texts:
Preconcepts
Ok, so what I've gathered so far is this:

don't use fixed pipeline (deprecated or going to be deprecated)
vbos store "object models" (n vertex data, mostly)
vaos describe how data is laid down so that draw calls know what part of each vbo is for what kind of vertex information (one vao can refer to multiple vbos, the opposite is kinda difficult)
each draw call also sends vertex data to shaders

How I see 3D (optional)
Given these informations, I can see how drawing 3D complicated objects is very nice with modern OpenGL. You basically load a bunch of object models (probably from Blender or other similar software) into VBOs with local coordinates, and then you simply provide for each instance of an object a different shader parameter (offset) to draw to world space.
Problem/question
In 2D problems and priorities are completely different, though. You don't draw much complex objects, you don't need complicated projection matrixes and whatnot and shaders are much simpler.
What would be the best way to draw frequently (really frequently, basically every frame) changing geometry with modern OpenGL?
In the following paragraph you can see some ideas of problems (the circle and rectangle problem), that better identify the kind of changes I'm interested in.
My attempts (optional)
So, I began to think how I would deal with drawing basic 2D geometry on the screen:

a square: load a [(1, 0), (1, 1), (0, 1), (0, 0)] VBO for the geometry of a square in local space, then provide the shader with the actual width of the square and world coordinates and color informations

cools, looks easy. Let's move to a circle:

a circle: triangle fan with... eh. how much precision (number of vertexes)? for small circles precision must be small and for bug circles precision must be high. Clearly loading 1 VBO cannot possibly fit all cases. What if I need to add precision because a circle is resized to be bigger?

Less cool. Let's move to something slightly easier, a rectangle:

a rectangle: eh. there's no "general rectangle geometry". You just have a width/height proportion and that's it, but each rectangle is probably different if the size changes.

As you can see, things go downhill from there. Especially with complex polygons and whatnot.
No code policy :P
I just need an overview of the idea, no code is necessary, especially C or C++ code. Just say stuff like: "make a VBO with this vertex data, and then bind it, ...".


texts: How to pass an argument with ref keyword to a local funtion/ how to work around it?

texts:
Unity 2019.3

I am writing a few extension methods to make my life a little bit easier, but this one is bogging me down.

I am loading stuff with Unity's Addressable system, and I would like use it by extension methods.

I am passing in my variables (reference type & value type, doesn't matter) to my extension methods, hoping to set them and and hide some complexity and source of bugs, and errors. It seems to me they are passed by value, because when I am trying to use them outside the extension methods, they are not set, null, etc. Not working.

There is a callback called Completed, and I am subscribing with a lambda expression...

I tried with the ref keyword, but obviously the compiler is yelling, that she doesn't want to pass my ref, out whatever parameters to local functions... :(

I tried it out with no local functions, and it did not work without the ref keywork, but it did with it!

You get the idea! Please see my code below!

This is the one that I can't get to work...

///Trying to set the generic variable data from the Addressable assetref
public static void TryLoadData<T>(this AssetReference assetref, T data)
    {
        var handle = assetref.LoadAssetAsync<T>();

        handle.Completed += loadedresult =>
            {
                T result = loadedresult.Result;
                if (result == null) return;
                data = result;
            };
    }

This one does, but only with ref...

///Setting the generic data parameter to the parameter g.
public static void SwapTest<T>(this T g,ref T data) where T : class=> data = g;

I am not sure if there is a workaround, I thought of pointers, or global variables, but not sure which one is the right way to go.

Thanks


texts:
So I am designing a game like scrabble in which a user has to make words using the letters on the screen. When the there is no possible combination of word that can be made with the letter the game is automatically supposed to tell the user to shuffle. Which changes the present set of alphabets with a new set (odds are very very very low that the new set cannot form a word either.)

So I now its a simple word game, but I am making this on HTML5 Canvas. It hugely resource consuming. And I need to run this even heavier computation on the client machine of whether a new word is possible from the selection on the screen. Ideally I would run a thread were this an app for the native code, and check after every new word created whether new words are possible with the remaining alphabets. Alas on the web browser I am afraid, it will toast the computer, crash the browser and a lot of other horrible things. So I would like to know is there a way that I could make such a computation feasible with all the other actions I am already running!?

Thanks


texts: Why is my Admob reward interstitial ad connected to Unity stuck on pending?

texts:
I am trying to better monetize my game by using rewarded interstitials. I have set these up on my admob console. I have also linked the ad source on the admob console to my game through the Unity ads service using my game's id.

It seems to be stuck on "pending". I can't find any further options on admob or on the unity ads console to remedy this. In the game itself, my rewarded ads are not loading.

Is there some step I am missing either through Admob or Unity ads? How long does pending take because it has been like this for a few days.

Edit with more info
Unity version 5.5.1f1
I am using the example code from the admob site (I removed my apps id's here for privacy reasons):

    public RewardBasedVideoAd nonskipInterstich;
    public void NonSkipGoogleAd(){

    #if UNITY_ANDROID
    string adUnitId = "--------------------------------------";
    #elif UNITY_IPHONE
    string adUnitId = "------------------------------------------";
    #else
    string adUnitId = "unexpected_platform";
    #endif

    nonskipInterstich = RewardBasedVideoAd.Instance;

    // Create an empty ad request.
    AdRequest request = new AdRequest.Builder().Build();
    // Load the interstitial with the request.
    nonskipInterstich.LoadAd(request, adUnitId );

    nonskipInterstich.OnAdFailedToLoad += LogFailedToLoadError;

}

if I display the failed to load event I get "No fill".
I haven't ever gotten it to fill a request, but I am only using remediation linked to the UnityAds source.

I read a post online that recommended importing the Unity Ads plugin from the asset store into the project. I did this and the google request is still not filling. I do not use the unity ads plugin directly to make the request. I also have the unity ads adapter jar found here


texts: How to update the monsters in my MMO server using Node.js and Socket.IO

texts:
Currently I am creating an MMO using Node.js and Socket.IO.

The node server needs to handle connections for players, and also use a loop to update all monsters positions in my game and let them attack players in range.

For the loop I read that you can use process.nextTick or use a child process, which option would be the best choice? What are the advantages/disadvantages of using each?

Also, how many times per second should I run this loop for the monsters?


texts:
I have my isometric world represented by isometric tiles. If I were to allow the player to place buildings on any of the tiles how would I get this funcitonality to work?

I was thinking if I could add a MouseListener to the images?


texts: I'm following the Frank Luna directX12 book, I have installed the windows 10 SDK etc but now, when I compile any project from his demo they wont build. Error I am getting is Cannot open source file  which I have never had a problem including before I installed windows 10 SDK, any suggestions? If any more info is needed let me know


texts: How should I animate sprites with separate body parts?

texts:
I am not an artist. I have a 2D Sprite broken up into different body parts that I want to animate. I know how to do it in Unity, but every artist I know would prefer to use Flash. I am trying to figure out if I should do it in Unity, or learn how to do it in Flash.

My understanding is that in Unity, I'd have to animate directly, or Flash would output sprite sheets.

Is there anything Flash offers for animating sprites that Unity does not? Is there a benefit to using sprite sheets over animating directly? Is there an option I should consider over Flash and Unity?


texts: Max texture size Android : which settings for 2048x2048?

texts:
I want to use a texture atlas of 2048 x 2048 in my game, and I would like to warn the users with a "too low" device to not download the game.

With a texture atlas of this size, what requirements should I say, on ANDROID ?

This image (source : https://stackoverflow.com/questions/10392027/recommended-limit-for-memory-management-in-cocos2d ) shows the requirements for IPHONE, what about for ANDROID : 512Mo minimum, with a 1GHz, is a correct requirement ?

Thanks for your answer


texts: How to create a 2D Polygon Sprite from prefab at runtime?

texts:
At start of my 2D unity game I want to create a new "building" (at random).
So I created a prefab named "Building" from a polygon sprite. Then I created a "Empty Game Object" named "GameManager" with a script named "GameManager" attached to it. The script looks like this:
public class GameManager : MonoBehaviour
{
    public GameObject Building;
    // Start is called before the first frame update
    void Start()
    {
        var createdBuilding = Instantiate(Building, new Vector3(0, 0, 0), Quaternion.identity);
        var sprite = createdBuilding.GetComponent<SpriteRenderer>().sprite;
        Vector2[] geometry = new Vector2[6];
        geometry[0] = new Vector2(0,0);
        geometry[1] = new Vector2(0,20);
        geometry[2] = new Vector2(20,20);
        geometry[3] = new Vector2(27,20);
        geometry[4] = new Vector2(29,29);
        geometry[5] = new Vector2(16,0);
        sprite.OverrideGeometry(geometry, sprite.triangles);
    }
}

The hardcoded position values are just for testing purporses. The plan is to create multible buildings but first I have to get unity to show at least one of them.
Afterwards I attached the prefab "Building" to the variable "Building" via the inspector.
But when I ran the game the sprite is shown as a Pentagon, regardless what I write into the "geometry"-Array.
So why I cant change the geometry? And is this even the right way to create buildings at startup?


texts: I am working on a voxel engine. Currently my cubes are rendered as vbos. I thought, it may be better to load only the cooridinates of voxels to the shader and make it draw a cube itself. Can someone tell me, if thats possible, and if so, how?


texts:
I've got a question about toggling keys. How do You check if the key is toggled?

Here's my quick and easy code:

    public class KeyToggle
    {
        private bool isEnabled = false;
        private Keys key = Keys.None;

        public KeyToggle(Keys key)
        {
            this.key = key;
        }

        public bool IsEnabled()
        {
            if (keyboardState.IsKeyUp(key) && previousKeyboardState.IsKeyDown(key))
                isEnabled = !isEnabled;

            return isEnabled;
        }
    }

    private KeyToggle keyToggleF12 = new KeyToggle(Keys.F12);

    protected override void Update(GameTime gameTime)
    {
        if (keyToggleF12.IsEnabled())
            Method();
    }

Do You have any better idea for checking if the key is toggled?

EDIT: I didin't mean if the key is clicked (aka current up, previous down). Toggled key is like CapsLock, You press it once and it's enabled, press it once more and it's disabled. I've updated my code a little bit:

    private List<KeyToggle> keyToggleList = new List<KeyToggle>();

    protected override void Update(GameTime gameTime)
    {
        if (IsKeyToggled(Keys.F12))
            Method();
    }

    public static bool IsKeyToggled(Keys key)
    {
        if (ReferenceEquals(keyToggleList.Find(x => x.Key == key), null))
            keyToggleList.Add(new KeyToggle(key));

        return keyToggleList.Find(x => x.Key == key).IsEnabled();
    }


texts: Why do loot drops contain (mostly) useless items?

texts:
I was thinking about this and couldn't figure this out.  In Diablo you kill enemies and they drop random things.  But usually the drops are worthless to you relative to what you already have equipped.  Why bother building a drop system that gives you crappy drops?  Maybe I'm not communicating my question well so I'll provide an alternative implementation:

Instead of frequently dropping crappy items and rarely dropping good items, why not only rarely drop good items?

I guess that crappy items adds to the addictive-ness somehow, but I don't understand why.  Why is dropping crappy items part of the design?  What does that add?

Edit: FWIW, I have been referring to Diablo 2 as my reference, not D3.  But it's still interesting to see answers explaining why D2 was more addictive.


texts: Storing non-binary, but non-mergable files in Git LFS

texts:
Is it acceptable to store files that aren’t binary and diffs between versions are not important in Git LFS? Examples of these files include:

.obj
.stl
.mtl
large .csv data dumps
etc

I know that I can, but would there be any advantages to storing them in LFS instead of the regular repo? I've done a bit of googling but couldn't find any information on the subject.


texts:
So I am currently making a game that aims to help people with anxiety management. I , however, would like to ask them how they feel before playing the game and then again after playing the game. Would it be possible to do this directly on Unity? I would like for them to be able to log their entries much like an online journal. I have attached pictures from the daylio app. I would like to do something similar. At this point, I really do not know how to begin doing this on Unity. Any advice, or tutorial suggestions would be appreciated.

This far I have managed to do the following (in the picture below):
This is how the survey looks (its pretty rudimentary at this point):

And this is where the information is getting displayed (in the inspector):

So now, what I would like to know, is how would I go about sending this data to somewhere else i.e. as it is in the daylio app?


texts: How can I change my RangeAttribute during in my script?

texts:
I have an int which I want to be between 0 and an unknown number.  This unknown number is max in the example below.  I want this max number to change when another number changes in the editor.  How can I accomplish this?  This is my best attempt, but it won't let me use an unknown value for my range.

[Range(1, 10)]
public int multiplier;

[Range(0, max)]
public int x;

void OnValidate(){
    max = 10 * multiplier;
}


texts: Embed a real city in a game and use data to find and display paths

texts:
First of all this question is gigantic but it's mainly about Unity, maps, pathfinding, and real data.

The problem.

In my game the player sees the map of a real city (in 2D), it’s exactly the same kind of view you have on Google Maps. The map is “almost” real, as I will probably have to modify some street names, point of interest, or exclude some streets. But the fact is that it’s based on a real “big” city (think of Paris, France or London, UK), with too many streets or roundabouts. The player knows where she is and can travel throught ways / streets in a car (no pedestrian ways, parks, forests... are useful here).

I need to display itineraries to the player. At some point she will be able to say “I’m on Foobar street and I want to go on Blah street.” and I must show her several possible itineraries (at least 3 when possible).

The restrictions.

The game is made with Unity 5.X
Game must be playable on Windows/Mac/Linux
Game will probably, at some point, be playable on smartphones / tablets
Being connected must not be mandatory
More than 5 frames per seconds would be appreciated :)

The tricky questions.

How to embed an entire “real” city in a game?
How to compute itineraries?
How to display the map?
How to display the itineraries?

What I have in mind so far.

How to embed an entire city in a game?

Using SQLite.

SQLite is a database made to be embedded with software. After some researches it happens that SQLite can be used with Unity, however I haven’t tested for portability on smartphones / tablets.
SQLite database can be used with a scheme called SpatiaLite. This scheme is made to help users working with GIS to save all the information they need. Also as OpenStreetMap.org offers some city dumps I have access to the city I want and can import it all in SQLite. After that it’s all about making the right request to know where a specific street or a specific point of interest is.

How to compute itineraries?

To be honest I still don’t know. I don’t know what SQLite can offer on this topic, but I’m sure someone, on the dark side of the Interwebz has already answered this.

Also, maybe a texture showing the "walkable ways" could be used alongside the database for pathfinding purpose. A simple A* or Djikstra on it could do the trick...

How to display the map?

2 options here. Either I generate meshes to draw EVERY streets of the map using SQLite data at runtime (meh… the CPU will burn), or I can use a tile system (it’s how map systems usually work). The trick with a tile system would be to be sure that the coordinate of the tiles match the coordinates of the information in the database. Tools like TileMill can export a set of tiles for different zoom levels.

How to display itineraries?

So, let’s say that I find how to display the map correctly. Let’s admit that I find how to compute itineraries based on the database. And let’s say that everything works like a charm. I can’t figure the best solution to display itineraries… Generate meshes based on DB data points and display them directly on the map? Won’t it be overkill? I don’t know.

Well now you know has much as I do.

My question is simple: how would YOU do it?
Forget the method I have in mind right now, if tomorrow someone would ask you to answer this problem, what solution would you go for?

THANKS A LOT in advance for your time and your help.


texts: unity4.3 rigidbody2d unexpected force behaviour

texts:
So guys ive edited the question and here is what my problem is i have a player which has a rigidbody2d attached to it.my player is able to doublejump in the air nicely and stick to walls when colliding with them and slowly slides to the ground.All movement is handle through physics and no transform manipulations.here i did something similar to this in the FixedUpdate of my player.

    void FixedUpdate()
    {
     if(wall && Input.GetButtonDown("Jump"))
      {
       if(facingright)//player is facing the left side of the wall
        {
         rigidbody2D.Addforce(new vector2(-1f,2f)*jumpforce);
         /*Now the player should jump backwards following this directional vector and
   should follow a smooth curve which in this part works well*/
        }
       else
       {
        rigidbody2D.Addforce(new vector2(1f,2f)*jumpforce);
        /*Now this is where everything gets complicated as you should have noticed
          this is the same directional vector only the opposite x axis value
        and the same amount of force is used but it behaves like the red curve
        in the  picture below*/
       }
      }
    }

bad behaviour  and vector in red

.I tested the same thing(both addforce methods) for a simple jump and they exactly behave like mentionned above in the picture.so here is my problem.Jumping diagonally forward with rigidbody2d.addforce() do not have the same impact,do not follow the same curve as jumping the opposite direction with the same exact amount of force.if i could fix this or get past this i could implement a walljump system like a ninja jumping in zigzag between two opposite wall to climb them.Any ideas or alternatives?


texts:
I have a sphere in my 3D world located at the origin. I have models orbiting it and I need to keep track of each models' position (x, y, x coordinates) as well as update their bounding boxes for collision detection. I have calls to glRotate() and glTranslate() but I'm not sure how to keep track of this. Should I create a position matrix and apply rotations and translations to it? Any help on that would be great!

Also if there is a better way to do this I am open to anything.


texts: how to prevent stretched vertical shadow in blob shadow which projected by Projector of Unity

texts:
I feel it's a ridiculous because projector's rotation of X is 90.

the projector is a orthographic.

how can i prevent that long stretch shadow in vertical side of a platform?


texts: Design question: How to handle input more efficiently?

texts:
I'm designing a system to handle the keyboard input for my game. To get it more simple, I have a class that has two methods, KeyUp and KeyDown which tell me which key has been pressed, this is already implemented by the library I'm using, now I want to have a way to send that information to the classes that are handling input (I'm using an MCV pattern, those would be the controllers). I've thought of two ways of doing that, both seem valid to me, and I don't know which is better, so I'm asking which would be the best way, in terms of object-oriented design, and if it has any significant impact, also efficiency.

The first way I thought of is having the class which receives the input hold references to all the controllers, and then call some methods of those controller classes in an event-like fashion when a key event is triggered in this class.

The other method is the other way round, the controllers hold a refference to the input handler class, which in this design has some kind of data structure (I was thinking of an EnumMap) that holds the status of all the relevant game keys, and then the controller classes might query the input handler for a key with some getters (just to encapsulate the data structure).

So, that's it, I'd like some help on how to do this. Any comments on which of both is better, or a new design that might be better than this are more than welcome.

Thanks in advance.


texts: How do I avoid an infinite loop when testing D3D9 occlusion queries in SlimDX?

texts:
I'm creating a Managed DirectX 9 application using SlimDX. I'm trying to utilize occlusion queries in order to cull non-visible geometry found in the scene. The problem I'm having relates to SlimDX's implementation of IDirect3DQuery9::GetData().

SlimDX, in managed code, has a function to check the status of a query. This function(SlimDX.Direct3D9.Query.CheckStatus(bool flush)) returns true if the query results are available, and false if the data is not yet available. The problem is, the unmanaged counterpart of CheckStatus(), IDirect3DQuery9::GetData(), will not only return true or false but also an HRESULT that indicates that the device was lost while waiting for the query result to become available. Because the call to CheckStatus() lies within a 'while' loop, the application hangs in an infinite loop. Also, another problem occurs that causes the graphics device driver to crash. The computer must be restarted altogether in order to restore the system. Here is my implementation of an occlusion query:

using Device = SlimDX.Direct3D9.Device;
using Query = SlimDX.Direct3D9.Query;
using QueryType = SlimDX.Direct3D9.QueryType;
using Issue = SlimDX.Direct3D9.Issue;

// device and query
Device pd3dDevice = GetDevice();
Query occlusionQuery = new Query(pd3dDevice, QueryType.Occlusion);

...
// issue begin
occlusionQuery.Issue(Issue.Begin);

// draw scene item
...

// issue end
occlusionQuery.Issue(Issue.End);

// wait for query results to be ready
while (!occlusionQuery.CheckStatus(true)) { }

// get query data
uint ucPixelsRendered = occlusionQuery.GetData<uint>(false);

The implementation eventually hangs or the device will be lost during the CheckStatus loop and the graphics device driver will crash requiring a restart of the computer...

I have successfully implemented timing queries(disjoint, frequency, and timestamps) without any problems.

How do I correctly implement an occlusion query in SlimDX?


texts: What are the disadvantages of client-side prediction?

texts:
There's lots of talk of server-side prediction, but I haven't seen a client-side alternative implemented anywhere.

My game uses mouse-based movement, so it's easy to predict the player's location 150ms from when the event is sent. Wouldn't this be more accurate than using old data on a receiving client's side?

Is there something fundamentally wrong with this approach that I'm missing? I'm thinking of implementing it, but the lack of existing info gives me cold feet.


texts:
I am using OpenGL ES 1.x/2.x

I have 2 attributes to be passed to the GPU(one is colors, one is vertices, one color per vertex).

I use indices. Both attributes will use the same indices array

This is not a big issue but I was wondering if there is a way to tell the GPU that both attributes use the same indices array so that it is not transfered to the gpu twice, or maybe it does not matter because the GPU uses the RAM?


texts:
I am beginner in Unity and I have created tilemap using new tilemap system in unity which looks like this:

I created a script that lets me swap tiles. First I click on some tile and than I choose second tile, after I click second time, tiles swap their positions. Which will than look like this:

How can I apply some animation to this process? Seems like I have no control over tile object as it is. I can only access TileBase which as I understand is not all information about tile. I can't create any animator controller or access its transform object. I want to add some custom animation when tiles swap their places. Thank you!


texts: Will I have copyright issues making a mobile game based on an anime?

texts:
I have been wanting to create a mobile game based on some of my favorite anime.

I want to know if using character images and names from those anime (even after giving full copyright credits and disclaimer) infringes any copyrights?

Would this come under "fair use" in the DMCA (I mean there are already so many not-so-legal sites using this "fair use" to continue running).

What are the possible things I can do for making this game? I have seen many online browser games based on anime which use images and elements from that anime, while I have also seen many games advertise themselves based on a anime but just use diffrent names for characters of that anime (sometimes modifying the character images, too).


texts: How can I minimize the chances of my game getting pirated?

texts: I am planning to make a small game in the near future. How can I minimize the chances of it being pirated?


texts: Prevent instances from overlapping gamemaker studio

texts:
I have a game where multiple instances of an enemy move towards a player in their step process.  There can be as many as 50 instances on screen.

The issue is that the instances all end up in 1 big group as they follow the player.
I would like to prevent them from getting more than 2 pixels of each other.

the code is as follows:

if distance_to_object(player) < 160 {
  direction = ppoint_direction(x,y, player.x, player.x, player.y)
  p_potential_step(x,y, player.x, true);
}

If I put a distance check of 2px in this code, the instance starts making jerky movements and spins. I would like the instance to continue following the player, but just not allow themselves to overlap.


texts: Interactive ways to answer a yes or no question in a VR game?

texts: Currently, I am creating a VR game with a simple AI that at certain points ask for yes or no answers. Considering the player is free to walk around, I need a sort of spawn in and out kind of solution. I would really like this to be interactive and engaging. So far, I'm thinking to animate a "terminal" from the floor with a green and a red button on it and the user simple pushes down on one with their hand. I don't really want to use a 2D UI or a controller button press for this. Are there any other potential ways to handle this situation while keeping the interactivity there?


texts: Why does my player walk animation take so long to begin?

texts:
I'm new to Unity and after doing some tutorials and reading documentation from Unity, I've started a test project. The game is a 2.5D platformer and I wrote the PlayerController; it looks like this:

using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour {

    public float turnSmoothing = 15f;
    public float speedDampTime = 0.1f;

    private Animator anim;
    private Rigidbody rb;
    // Use this for initialization
    void Start () {
        anim = GetComponent<Animator>();
        anim.SetLayerWeight(1, 1f);

        rb = GetComponent<Rigidbody>();
    }

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

    }

    void FixedUpdate()
    {
        float h = Input.GetAxis("Horizontal");
        MovementManagement(h);
    }

    void MovementManagement (float horizontal)
    {
        if (horizontal != 0.0f)
        {
            anim.SetBool("Move", true);
            anim.SetFloat("Speed", 5.5f, speedDampTime, Time.deltaTime);
            Rotating(horizontal);

        }
        else
        {
            anim.SetFloat("Speed", 0.0f);
            anim.SetBool("Move", false);
        }
    }

    void Rotating (float horizontal)
    {
        Vector3 targetDirection = new Vector3(horizontal, 0.0f, 0.0f);
        Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);
        Quaternion newRotation = Quaternion.Lerp(rb.rotation, targetRotation, turnSmoothing * Time.deltaTime);
        rb.MoveRotation(newRotation);
    }
}

My AnimatorController has a BlendTree called Locomotion and looks like this:

When I run the game and use the keyboard or the controller the player starts walking, but it takes a long time (I can see the Speed parameter from the blend Tree that has to reach "5" to start walking)

I think I'm not understanding something but I don't know what it is.


texts: How can I communicate user information from a website to a hosted Unity game?

texts:
I have a Ruby on Rails website running which provides a log-in system and dashboard for users. I am building a small game in Unity which is much like an inventory management system. But, the inventory is specific to a user and the user can make changes to it. The user sees the game as a part of his dashboard.

What I'd like is for the moment the user lands on his dashboard, the Unity game should load with the inventory of the signed-in user. How can I get this user information from the Ruby dashboard over to Unity?


texts: Place an UI Image between two 2D sprites in Unity

texts:
I am developing a 2D game with Unity.

I have two sprite objects rendered using SpriteRenderer.

With the new UI system, I want to use it to display an image between my two sprites. That is, my first sprite has a sorting order of 100, then my UI Image has a sorting order of 200 and then my second sprite has a sorting order of 300.

Is that possible?

I tried using sorting layers, but no matter what, the UI image seems to always overlay my two sprites.


texts: Maximum tile and texture size for tiled maps

texts:
I'm currently making a game using libGDX and Tiled.

Everything was running fine until I changed the tile size from 96x96 to 300x300. Most layers are still displayed correctly but the tiles of a single layer are just black. I guess that there may be a problem with the large tiles (as there are some tiles together in one tileset bitmap the texure is 2100x2100 large). Are there any upper limits for tiles and/or tilesets regarding the bitmap and texture size?

GL_MAX_TEXTURE_SIZE returns 3379 on this machine.


texts: Learning OpenGL 3.3 on OpenGL 2.1 machine?

texts:
I am going to learn OpenGL 3.3 instead of OpenGL 2.1 because many model of OpenGL 2.1 is deprecated (base on this information). It's pity that my "old friend" only support OpenGL 2.1.

Base on this article at learnopengl.com I found that from OpenGL 2.1 to OpenGL 3.3 is a huge jump of Khronos Group and I will receive error if I run OpenGL 3.3 function on OpenGL 2.1 machine.

1) Is it possible to learn OpenGL 3.3 on OpenGL 2.1 machine?

2) Relate to this question 7 years ago, is learning OpenGL 2.1 useless today?

Thank you!


texts: Rendering an Assimp Scene object in XNA without DirectX or OpenGL

texts: Is there any site that explains how to render an imported Assimp Scene object in XNA/MonoGame using only the Frameworks available in those libraries? I realize that would be at the Vertex/Matrix level but that is what I am trying to learn. The site would preferably start with the basics of rendering a mesh from the Scene object and then move on to Materials or Textures. A bonus would be if it could include information about Animating from the Scene object.


texts: Unable to rollout release to alpha in Google Play Console

texts:
I have uploaded my APK, and filled in data in every field which was required... but using Googles new MAnage releases tab, I am unable to press the final button to roll it out to alpha. Its not telling me I need to do anything else, but the button is inactive.

See image:


texts: there is a text box on GUI in my application created using Unity3D. in the textbox user can input only the keys of "A-Z", "0-9" , "enter key" , "." and "," other key press should be ignored (not should print in textbox when typing). how to do this in Unity3D C#


texts: Is it allowed by social platforms to promote a game in exchange for in-game currency?

texts:
I have a mobile game that uses a a hint system.
If the user needs help to solve a puzzle they can get a hint by watching an ad. I'm interested in offering some hints, let's say 5, if the user presses a Facebook/Twitter button and posts some predefined text on those platforms - something like "I've been playing X game, check it out".
I haven't seen many games that have something like this. For those more familiar with App Store and Play Store publishing guidelines, is there anything against such behaviour?


texts: where have the shape drawing functions gone in DirectX10?

texts:
such as the CreateTeapot function - http://msdn.microsoft.com/en-us/library/windows/desktop/bb172798(v=vs.85).aspx

Is there an equivalent in DX10? If so, how do I use it?

In DX9 you..

Declared:

LPD3DXMESH meshTeapot;

Initialised:

D3DXCreateTeapot(device, &meshTeapot, NULL);

Drew:

meshTeapot->DrawSubset(0);

Released:

meshTeapot->Release();

Is there an equivalent set of methods for drawing primitives? (to be honest the sphere is of more interest to me than the teapot!)