texts: How to calculate spherical harmonic coefficients for indirect diffuse?

texts:
After reading the article "An Efficient Representation for Irradiance Environment Maps", I'm a bit confused as how to calculate the spherical harmonic coefficients.  I'd like to generate these coefficients given a cube map that I've generate dynamically in engine.

I'm currently using DirectX 11, but I have some familiarity with OpenGl. Some tips on calculating these coefficients would be greatly appreciated!


texts: Deactivate VS warning "Macro in skipped region"

texts:
Since the UE4 API relies heavily on macros outside of function bodies, the IntelliSense function (not the compiler!) of Visual Studio 2017 throws a lot of warnings with update 15.7, also visible in the scroll area.

Is there a possibility in the Visual Studio settings to deactivate such kind of warnings?

The option to deactivate IntelliSense

Tools -> Options -> Text Editor -> C/C++ -> Advanced -> Disable IntelliSense

will disable those warnings. However I don't want to renounce IntelliSense completely. Maybe Visual Studio offers more fine grain control over IntelliSense via its GUI or some settings file to disable only those macro warnings?

EDIT: The Visual Studio team recommends using a .hint file to register macros as workaround. However maintaining a separate macro list is not the way to go. You can also vote there that the VS Team works on that.


texts:
I'm a beginner Unity 3d developer. I want to keep quads one aside another touching each other and use that as a road for making an endless runner game. The problem is each of the quads have their own box collider thus the car bounces a little bit sometimes.

Is there any way to get those stuff connected with each other and make the whole thing behave like a single plane?

I know using a big box collider covering all the quads in the repeating unit is gonna work but I don't want to use that.


texts: Apply two animation on one object in unity

texts:
I am looking for a perfect example to apply two animation on same object and to run those animations simultaneously. In my game, a player is jumping as well as flapping. As per my research, I have got something like this. create both animation in different layer in animator control and then blending those animations. But I could't do that as I can't understand it properly. I need an example that can solve my problem. And I am not importing animations from anywhere. I am creating it in unity only.
Hope for good example.
Thanks in Advance.


texts:
I want to implement soft bodies in my game similar to this link.
I tried using this Soft body simulation plugin but it has the following problems:

Only works with box colliders.
Doesn’t work with Unity’s physics engine i.e. the bodies don’t react to the forces applied.

For my game,

The soft bodies should be able to collide and interact with any types of colliders (including mesh collider).
The bodies should work with Unity’s physics engine i.e. the bodies should react to the forces and gravity applied.

I am flexible in implementing soft bodies in 2D or 3D.
I would appreciate any suggestions and thoughts on this topic.


texts: Should beginning/indie game developers target multiple platforms initially?

texts: Partially as a response to How do game developers target multiple platforms (Xbox 360, PS3, PC and Linux)? but mainly because there are people on here with published games, should cross platform be the first requirement/feature for a developer trying to break into the business?  I have always been a believer (in a totally procrastinating sort of way) in picking either a 'niche' or 'mass market' platform and porting later if demand justified it.  Cross platform always felt like an artifical barrier to entry.  Why shouldn't we all write iPhone, Windows, or Browser games?


texts: Perlin noise - copying the algorithm on the CPU?

texts:
I have successfully made a Perlin noise algorithm on the GPU. It works as expected, and generates great results. Now, as part of the physics calculations in my game, I need to replicate the exact same algorithm on the CPU, so that I can (given an X, Y and Z coordinate) determine whether or not that is inside a wall, or a walkable area.

I have debugged the shader through PIX, and I've gotten everything almost right, except for the part below (seen in shader code).

GPU (shader) code (HLSL)

float4 perm2d(float2 p)
{
    return tex2D(permSampler2d, p);
}

permSampler2d samples a texture that I generate out of Color structures and then pump to the GPU. The way I generate the texture on the CPU is the following:

CPU code (XNA C#)

int createPerm2d(int i)
{
    return permutation[i % 256];
}

public Texture2D GeneratePermTexture2d()
{
    permTexture2d = new Texture2D(device, 256, 256, true, SurfaceFormat.Color);
    permutationData = new Color[256 * 256];
    for (int x = 0; x < 256; x++)
    {
        for (int y = 0; y < 256; y++)
        {
            int A = createPerm2d(x) + y;
            int AA = createPerm2d(A);
            int AB = createPerm2d(A + 1);
            int B = createPerm2d(x + 1) + y;
            int BA = createPerm2d(B);
            int BB = createPerm2d(B + 1);
            permutationData[x + (y * 256)] = new Color((byte)(AA), (byte)(AB),
                                            (byte)(BA), (byte)(BB));
        }
    }
    permTexture2d.SetData<Color>(permutationData);
    return permTexture2d;
}

As said before, all this works as expected, until I run the code on the CPU to get the noise data back later.

According to PIX, the part that fails is indeed perm2d on the CPU (as seen below), which produces incorrect results.

CPU code (XNA C#)

static Vector4 perm2d(Vector2 p)
{
    return permutationData[(int)p.X + ((int)(p.Y) * 256)].ToVector4();
}

At the particular area (in the exact same pixel with the exact same seed used to generate the map, where it returns the incorrect results, PIX reports that the GPU returns "{0.035, 0.067, 0.365, 0.408}" from the perm2d function whereas the CPU code returns "{X:0,7450981 Y:0,345098 Z:0,5137255 W:0,09803922}".

Other than that, the rest of the functions produce the right outputs.


texts:
I just started using Gamemaker Studio and so far it seems fairly intuitive.  However, I set a room to "Room is Physics World" and set gravity to 10.  I then enabled physics on my player object and created a block object to match a platform on my background sprite.

I set up a Collision Detection event for the player and the block objects that sets the gravity to 0 (and even sets the vspeed to 0). I also put a notification in the collision event and I don't get that either. I have my key down and key up events working well, moving the player left and right and changing the sprites appropriately, so I think I understand the event system.

I must just be missing something simple with the physics.  I've tried making both and neither of the objects "solid".  Pretty frustrating since it looks so easy.

The player starting point is directly above the block object in the grid and the player does fall through the block.  I even made the block sprite solid red so I could see it (initially it was invisible, obviously).


texts: Does creating a static instance of a class inside itself have any negative performance effects on game frame-rate

texts:
For example, if we have a class that is for handling GooglePlay. And instead of creating an instance of it in every class where you want to use it, you have:

public class GooglePlayHandler {

    public static GooglePlayHandler instance;

    private void Awake(){
        instance = this;
    }
}

If I then access this in say 5 of my scripts in Unity. Would it be the same, better or worse than having a separate GooglePlayHandler inside each class?

And furthermore if I continue using this style in my game with lots more classes and features would that badly affect the games frame rate. (For example if I did this with my inventory code, cash/points, total time taken, etc etc.


texts:
I have been working on my this aspect of my project since last night and have finally got this code to work exactly as I want it to.

However if the first target is removed before the second one, I get an out of range exception. I would like to know if there is a better way to fix my problem.

void LateUpdate()
{
    if (targets.Count == 0)
        return;
    Move();
    Zoom();
}

void Move()
{
    GetBoundsData();
    Vector3 newPosition = new Vector3(centerPoint.x + offset.x, transform.position.y, centerPoint.z + offset.z);
    transform.position = Vector3.SmoothDamp(transform.position, newPosition, ref velocity, smoothTime);
}

[SerializeField] Bounds bounds;
[SerializeField] Vector3 centerPoint;
public Vector3 maxBoundsPoints;

void GetBoundsData()
{
    if (targets[0] == null)
    {
        targets.RemoveAt(0);
    }
    if (targets.Count == 1)
        centerPoint = targets[0].position;
    SetUpBounds();
    centerPoint = bounds.center;
    maxBoundsPoints = bounds.max;

}

void SetUpBounds()
{
    bounds = new Bounds(targets[0].position, Vector3.zero);
    for (int i = 0; i < targets.Count; i++)
    {
        if (targets[i] == null)
        {
            targets.RemoveAt(i);
        }
        bounds.Encapsulate(targets[i].position);
    }
}


texts: How to create polygons from tilemap areas?

texts:
I'm currently working on a project which needs simple AI's to walk around using pathfinding.

I'm trying to find a way to generate a polygon based on the connected tiles (explained below), an i'm wondering how to do this.

I know about the flood fill algorithm, but have never used it before.

This is what a map (could) look like (maps are created by the players)

Basically, i wan't the yellow outline as one polygon (vector2 array)
and the red outline/area as another polygon (vector2 array)


texts: XNA Platformer Sample: Supporting multiple resolutions?

texts:
I have been looking at the XNA Platformer Sample and noticed that, when you change the resolution, the game world still renders at 800x480 and not the new width and height of the display.

Can anyone suggest a simple way to make the Platformer sample support multiple resolutions?


texts: Trying to understand the range of Improved Perlin noise

texts:
I've been implementing Improved Perlin Noise for a small library I'm writing. Everything was hunky dory when it was just in the 3rd dimension, but I recently expanded to the 1st, 2nd, and 4th dimension, which is where things started get weird.

I originally thought that the range of Improved Perlin was +-1.0. When I implemented the 1st dimension version, I noticed that the unmodified range was +-0.5, ie, you had to multiply the result by 2, but figured nothing of it. 2nd dimension worked just like 3rd, with both working within the +-1.0 range. Then when I got to 4th, I ran a large number of samples and saw that I was getting results outside the -1.0 to +1.0 range.

I started Googling, and apparently the +-1.0 range is a common misconception? The solution I've read in a couple places, which is +-1/2(sqrt(N)), where N is the number of dimensions, implies the following ranges for dimensions 1 through 4:

0.5, ~0.71, ~0.87, 1, respectively

However, the only version I have which matches this is the 1st dimension, which as I said, works out to +-0.5 before multiplying by 2. For dimensions 2 and 3, I get +-1.0 without any need to modify the result, and for the 4th dimension, I believe my results are actually in the range of the 6th dimension according to that solution.

The following is my code:
https://pastebin.com/CpAi3PUF
And for those who aren't familiar, it's Cython, so yes, a weird Frankenstein of Python and C.

I use the following code to test the ranges of each dimension: https://pastebin.com/yUpw1Z00
Since my method involves just running tons of random inputs over and over, I did run this test a few times to make sure the results are consistent, which they are, and here is an example of the output:

DIM1 - Minimum: -0.999999999999943 | Maximum: 0.9999999999871175 | Average: 0.0003455999808678627
DIM2 - Minimum: -0.9999515602331069 | Maximum: 0.999900249691747 | Average: -0.00011840974404335401
DIM3 - Minimum: -0.9932063986908607 | Maximum: 0.9931959744642007 | Average: -0.00010701170753012655
DIM4 - Minimum: -1.0576886515898196 | Maximum: 1.123720946368049 | Average: 0.00022555631399532482

You can clearly see that as my code is written, dimensions 1 through 3 have a limit of +1.0, and then with the 4So clearly there is some contradiction between the alleged result ranges, and the code I'm implementing. The 3rd and 4th dimensions were implemented straight from Perlin's own example code.

3rd Dimension: https://mrl.nyu.edu/~perlin/noise/

4th dimension: https://mrl.nyu.edu/~perlin/noise/ImprovedNoise4D.java

The only major changes I've made to the implementation are in the grad functions, where I use what is essentially a switch case, rather than Perlin's fancy pants (but extremely expensive) bitshifting method. But afaik doing so is functionally equivalent.

Can anyone provide some insight as to what is going on? What is causing the difference between the supposed expected ranges, and my actual results? And what can I do to get the 4th dimension "in shape", like how modifying the 1st dimension is required?

Thanks so much for any help.


texts: Procedurally placing buildings on noise-field

texts:
So, I have a procedurally generated planet. In my case it's 3D (hexagon/pentagon globe) but for simplicity let's assume it is a 2D grid.

I have distributed resources over this planet, using Simplex Noise, with a cut-off value, giving me a binary distribution.

One of the things I generate in this way, are fields of wheat, shown in yellow below.

After the wheat-fields are generated, I want to procedurally place farms on the planet.

If I would just randomly pick a "yellow tile" (tile with wheat on it) then I run the danger of having them poorly distributed, as shown on the left.

What I want, is a nice distribution where farms favour large wheat areas that are still unoccupied by other farms, as shown on the right.

Is there a simple algorithm that can do this placement?

NOTE: I want to use this approach for other buildings like mines, quarries, lumberjack operations, etc. So I want to avoid placing first, and then growing resources around it. I want the noise field to drive the placement, not the other way around.

NOTE: Farms will not consume the wheat. I've made wheat fields binary wheat/no-wheat but also have scaled distributions with "potency" for e.g. forests, where the number of trees per tile can vary.


texts: How can I simulate limited AI vocabulary for a word game?

texts:
I've got a small handful of competitive word games in progress, and while the preference is for (mostly asynchronous) play against other human opponents, I'd like to provide players the option of playing against an AI.  I have my dictionary and I can easily give the AI full dictionary knowledge while it's playing, but my concern is that having the AI regularly playing words they're not familiar with will be a frustrating experience for players: 'I would have won that game if it'd just used words I know!' — even if the AI's overall skill level is turned down.

I'd rather create a weaker AI through a combination of (un)tuned play parameters and a weaker vocabulary — but I'm not sure how to limit that vocabulary to 'common' words.  I've looked at several word frequency lists (for instance, the list of all words that appear in the Project Gutenberg books, sorted by number of occurences) but they all have a number of false negatives: words that everyone knows that simply don't show up with any real frequency (for instance, CHEETAH shows up less frequently in the PG texts than VOCATIVE or SUTTEE).  I've tried using search results to get estimates of a word's popularity, but they also tend to be prone to spurious mis-estimates, and of course it's hard to get search results for an entire dictionary without running afoul of the terms of service on the search engines.

Does anyone have suggestions on other good means of determining a rough frequency of word usage, or other ways of limiting word game AI that will feel natural to players?


texts: Should be GameKit used together with GameCenter?

texts: As far as I understand, GameKit provides Bluetooth-maches, while GameCenter allows to play matches through internet. So it looks like the best scenario is to use both of them? Is this reasonable?


texts:
Something really odd happens when I'm trying to load a scene.

It is supposed to look like this (it also has to show the next scene after loading):

What is going on?


texts: Game architecture for someone with a background in LOB Apps

texts:
I've got a background that is almost entirely based around business applications - Web services, schedulers, desktop and web front-ends to CRM systems, etc...

Now with almost all of the above projects, the basic principles are the same:

Some sort of data access layer, business logic layer and a UI.

Obviously some scenario require something a little unique but in general it's N-Tier all the way.

I'd like to do some game development as a hobby. I'm not expecting anything impressive as I don't have the resources to dedicate to it, but something to challenge me a bit would be good.

What lessons (if any) should I be taking from my current experience and what do I need to learn again?

I'm assuming that as with all my experience, different types of games will have different architectures but are they all based around the same core principles? For the sake of argument, let's say I'm  building a simple MUD (maybe a top-down UI like the older Zelda games) - This seemed like something that I could have my 3-Tier logic for - A server with the BLL and DAL and a client UI - But I'm not quite sure if this is right - certainly using the Entity Framework doesn't seem appropriate as there's an awful lot of overhead in accessing lots of stuff in the Db and I'd imagine performance will be an issue - eg I'm assuming I wouldn't want to constantly use the Db to store player locations if they're changing 20+ times/second...

Are there patterns and practices specifically for game scenarios?

Is it feasible to develop the back-end system before creating a UI (eg plugging a console app in instead to allow me to develop the functionality I'd like before adding the UI). Is this good/bad practice?

In short, I don't know where to start and would appreciate some advice - especially from those with experience.

About the only thing that's set in stone is that I'd like a multi-user game with a central server. Game suggestions welcome.

[This was originally asked on SO but it was suggested that this would be a better forum. Apologies if this breaks any rules but I don't know how to link across sites. If someone can advise me of the appropriate action, I'll take it. Many thanks]


texts: Can't move bone on blender. "Location" transform grayed out

texts: I'm trying to move a bone on Blender. I can't do anything with it at all. I've searched through the menus and noticed the Location transform is grayed out.


texts: Multi-disciplined: Strength or Weakness?

texts:
My last two credited titles I was Lead Programmer then moved to Lead Design role. At my current company I kinda switch between design and programming hats quite often.

The bulk of my education is in programming and my experience is pretty broad. I honestly can't pick which I prefer, and if I focused then I think I would do the other in my spare time. My colleagues consider me capable in both roles.

I'm currently looking for opportunities, some at larger companies, and often people seem to be thrown by my dual role. I feel like it may be damaging my chances in some cases, because they can't easily fit me into the company.

Should I just pick one and focus or is it viable to continue wearing my two hats?


texts:
I am writing a little game, in C++, using OpenGL. I have a varying number of enemies that are identical objects; each one uses the same animated mesh and shader, with skinning performed by GLSL-shader. I need to draw all of these objects at once, and I am confused about the fastest and most convenient way to do it.

I see several ways to solve my problem:

Creating a single Vertex Buffer Object (VBO) for the vertices and indices, and binding it to a Vertex Array Object (VAO) to draw it ten times by ten draw calls. In this way, after creating the VBOs we, can free the memory that stores the mesh vertices in the RAM, because we don't need it anymore.
Upload all of the meshes into a single VBO for the vertices and indices, and draw this VAO at once. In this case, there is a need to add a lot of additional info, such as the attributes such as position of the mesh, bone matrices, etc. In this case, we continue to store vertex info in the RAM, in order to add vertex data into that global VBO.
Upload all of the meshes into a single VBO for the vertices and indices, and bind it to a VAO. This time, we draw models one by one, sending uniforms for uniform skinning and animation for each model before the draw call. Like in the previous case, we store mesh vertices in the RAM.
Using instancing - passing a uniform array of bone transform matrices and accessing it within the shader by instance id. In this case, we might get rid of the CPU-side mesh data, as we don't need it anymore; much like with the first option. I'm not sure about this option, because instancing is usually used for drawing a large number of mesh instances, rather than drawing 10 instances.

I'm currently not sure which method is faster, and just overall convenient. What is the fastest and most convenient way to draw a number of identical objects at once in OpenGL?


texts: How do I create a weighted collection and then pick a random element from it?

texts:
I have a loot box that I want to fill with a random item.  But I want each item to have a different chance of being picked.  For example:

5% chance of 10 gold
20% chance of sword
45% chance of shield
20% chance of armor
10% chance of potion

How can I make it so that I select exactly one of the items above, where those percentages are the respective chances of getting the loot?


texts: Instantiate a prefab and call a method from it's script

texts: I am creating a game in unity and I have a prefab that I instantiate on center occasions. What I want to do though is after instantiating the prefab. Get a handle to it and call a specific public method from the script attached to it. One method would be to put that part of code in the start function of that script. But what if I do not want that code to run as soon as the prefab is instantiated? How can I get a handle to it and manually call that specific method?


texts: Unity: An empty idle animation overwrites values set through the FixedUpdate code

texts:
I am relatively new to the Unity environment. I am creating a 2D game. My character's avatar consists of only one single sprite. Due to its specific crawling-like type of movement, I apply some scale changes on the entire object representing my character (lets say it's something like a spring-wiener dog toy if you've ever seen one ;) ).

Now, I wanted to add an animator to the character's object, but unfortunately I've encountered a problem. I would like to apply to the object some animations on specific occasions, but I don't really need an idle animation. In other words, I want that the animator has no effect on the object in its idle state. At first, I created the state "Idle" in the animator controller and assigned no animation to it. It doesn't work. For some reason, the animator overwrites my character's sprite (opacity in this case), along with its scale. That is, the values assigned through the code are being overwritten by the default character's sprite. Eventually, that breaks up the whole crawling-through-scaling idea and for me it really feels crucial for this character.

My second idea was to create an idle state animation, but without adding any parameters to it. The effect is the same as leaving the animation slot unassigned.

I would really love to get some help here, since right now I have completely no idea how to resolve this issue. Thanks in advance :)


texts: Making walls in tile-based games: what am I missing?

texts:
After spending time today to jot down some notes regarding the implementation of walls into my tile-based game, I've suddenly realized it's not going to be as simple as I imagined before. While the current stage of my work is not even close to actually making the wall-related code, I've come up with three different ways to do it. Right now I'm unsure which one of my ideas will work best, and whether I missed something or not.

Important: a character CAN stand on a tile that has walls, regardless of their form.

The common thing for all the three variants: the tilemap will be "kept" in an single-dimension std::vector (or similar) based container. The reasons for that are (awesomely) explained in answers to a different question.

Container classes in tile-based games.

Back to walls.

A) The simple approach.

Nothing fancy here. Each tile-container can hold not only characters, but one or several Wall objects, which are attached to the edge inside the tile.

Pros: easy to implement, nothing to change in the engine.
Cons: Two things. One - it might be just in my head, but some combinations just look ugly. Second - this approach allows to make a double-wall from two adjacent tiles. Building will be an important part of the game, and double-walls allow the builders to possibly forego upgrading the material of the walls through game means, and just achieve increased durability with doubling the existing wall. That's not desirable. Sure, I could include a procedure that forbids double-walling, but it will have a bad feel to it.

B)The smart(?) approach.

Instead of letting the players double-wall the whole map, I'm going to beat them to it. Every wall has two halves that are attached to the edge of the tile from inside. So, to make a single "Wall unit" I'll have to create two Half-Wall objects in two adjacent tiles.

Pros: It's symmetrical!!! Also, no significant change of current engine specs is needed.
Cons: More hassle, more objects, and, of course, the "caps".
As you can see in the picture, a corner will basically cry for a "cap" object. I'm actually cool with it, it's not so hard to add. Hey, I already have a plan for thin columns made out of four connected caps. Sweet. Still, I have some worries regarding possible Field of View and Line of Sight issues.

C) The total overhaul variant.

Or, I could just create borders and corners as separate containers for game objects. Just like that.

Pros: Not even sure. Well, it's straightforward. Definitely.
Cons: It will require an overhaul. Not of code, thankfully, but of the current game mechanic mentality - that's for sure. The benefits are not so obvious. Also, this aprroach requires much more containers than the two previous ones. The indexing math will also be a bit of pain.

So here we have it - three distinct ways of making walls between tiles. If there are any alternatives out there - I'll be happy to check them out. If there are any benefits/downfalls to any of the approaches that I didn't see - please point them out.


texts: Cross & dot product using ASSIMP's aiVector3t vector class

texts:
I'm using ASSIMP's built in aiVector3t class but I can't find any mention of dot product or cross product in the class documentation.

Are these operations defined? If so what is the syntax?


texts: How do you rotate a material 90 degrees in UDK?

texts:
So, I have started checking out UDK since yesterday, and most of it is clear and understandable.

I'm trying to create a curved road. The idea was to use a brush (Curved Staircase) and set the steps to 0 so it would be flat. This all worked well and I made a static mesh of it. Now, the problem arrives when I add a material. It doesn't rotate the material the way I want it.

Here's the way I do the example above:

Create a brush:
Convert to Static Mesh
Add Static Mesh into the game:
Change material to "Asphalt"
Scale it a bit so you can notice the problem:

As you can see, the stripes aren't following 'the mesh' correctly. They have to rotate 90 degrees for them to appear correctly.

How can you do this?


texts:
I am using a plugin DLL that I created in Visual C++ Express 2010 on windows 7 64 bit Ultimate Edition. The DLL functions properly on the machine that it was originally created on.

The problem is that the DLL is not functioning in the Unity3d Editor on another machine and giving an error that basically states that the DLL is missing some of its dependencies. The target machine is running Windows 7 Home 64 bit (if this is relevant)

Results from the error log of Dependency Walker:

Error: The Side-by-Side configuration information for "c:\users\dewayne\desktop\shared\vrpnplugin\unityplugin\build\release\OPTITRACKPLUGIN.DLL" contains errors. The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail (14001). Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module. Error: Modules with different CPU types were found. Warning: At least one delay-load dependency module was not found. Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

The Visual C++ Express 2010 project and solution file can be found here: https://docs.google.com/leaf?id=0B1F4pP7mRSiYMGU2YTJiNTUtOWJiMS00YTYzLThhYWQtMzNiOWJhZDU5M2M0&hl=en&authkey=CJSXhqgH The zip is 79MB and also contains its dependencies.

The DLL in question is OptiTrackPlugin.dll


texts: What should I use instead of pixels in a LibGDX game?

texts:
Recently I have read here: https://xoppa.github.io/blog/pixels/ that I should not use pixels in my game. But Im not sure that I have understood this so I have some questions.

Xoppa writes that pixels may look different on different devices but I thought all the time that viewport solves the problem of different screen size and aspect ratio. Was I wrong?
How can I draw all assets without using pixels?
I have an idea to support all screen ratios and sizes by using ExtendViewport with the biggest screen that I will support. It looks like this:

  viewport = new ExtendViewport(1080, 1920, 1440, 1920, camera);

And everything works well on the smartphone during test. Game is prepared for 16:9 screen and if somebody have for example 4:3 screen he will se more background texture.

But I dont know how game will work on weaker devices. Is one viewport (1920x1440) enough? Or I should make more viewports for several sceen sizes for example 1920x1440, 1280x960 and 800x600?

Just I dont understand why I should not use pixels in game if everything works well. Can somebody explain it to me in simple way?


texts: Best approach to smooth pathfinding for 2d top down game LibGDX

texts:
I'm trying to make a buddy ai that follows the player (being controlled by you) around and at the moment it works but when I add collision detection it doesn't work very well when the buddy hits an obstacle. I was just wondering what would be the best approach (like perhaps an implementation of the a* algorithm) to making the ai movement smooth and so it avoids obstacles?
Here is the update method currently for my buddy class:

public void update() {

    setBounds(getX(), getY(), getWidth(), getHeight());

    float xDiff = Math.abs(player.getX() - getX());
    float yDiff = Math.abs(player.getY() - getY());

    if (player.getX() > getX() && xDiff > buddyDistance) {
        setX(getX()+speed);
    }
    else if (player.getX() < getX() && xDiff > buddyDistance) {
        setX(getX()-speed);
    }

    if (player.getY() > getY() && yDiff > buddyDistance) {
        setY(getY()+speed);
    }
    else if (player.getY() < getY() && yDiff > buddyDistance) {
        setY(getY()-speed);
    }

}


texts: LibGdx TextField - Hide Keyboard when not focused - How to?

texts:
I'm creating a registration screen for my game. I implemented textfields and input is getting correctly. But when I click elsewhere after text is entered, the keyboard stays visible and does not hide automatically, even when a new screen is loaded. Is there any listener methods for hiding the keyboard?

Right now I did a workaround by calling the setOnscreenKeyboardVisible(false) in the sign up and sign in buttons. But I want the keyboard to hide right when it is unfocussed. Is it possible?

UPDATE:

Actually I thought when I click elsewhere the textfield focus changed automatically but that's not the case. The cursor keeps blinking even after the keyboard is hidden explicitly. I edited the correct answer to include this.


texts: Assigning optimal jobs to entities based on travel distance

texts:
I'm hoping there is a standard algorithm for this problem, but I don't even know what to search for.
Let's say you have a collection of entities (people, vehicles, whatever), in random locations. And you have a collection of jobs to be done, also in random locations. How do you assign each one a job where they have the least distance to travel?

For example, several entities may have the same travel distance to job A, but only a few of those are closer to job B, making them less of a candidate for job A.
Or, entity 1 is currently headed to job A, but entity 2 just spawned and they're even closer to job A, so entity 1 should switch to job B since they are closer to it than entity 2 is.

Seems like a lot to untangle, where would I start in structuring this?


texts:
I am working on a hobby project and implemented a skybox, no big deal. Now I bought (licensed) a few really nice sky textures. Unfortunately the textures are projected for a skysphere.

I could implement a skysphere handling/rendering, but I figure rendering a box is way more efficient. (That may actually not matter on modern devcies though.) So I decided to transform the textures into 6 textures for a skybox.

My hodge podge solution to convert the textures is I create a scene in blender and render out the appropriate 6 views. If you ask google that is aproptatly the common sollution.

It there a tool that can do the conversion in a more automated way?


texts: The distance to a line from a point, find the constant values?

texts:
I have 3 points, (x1, y1), (x2, y2), (x3, y3)

I should find the AH height. For this i must use:

How can i find each "a", "b" and "c" values?


texts: Javascript: Eventlistener 'keydown' not registering all keys pressed when holding down other keys

texts:
Sollution provided in the comments. The issue is that my keyboard has what is called ghosting issues, this means it doesn't support some key combinations when pressed together.

When the user holds 's' and 'd' key at the same time (movement keys, so character would move south-east), and during this presses the 'n' or 'm' key, the keydown event of the 'n' and 'm' key is not triggered. This happens with other key combinations as well, but not with all. Per example: holding down the 'w' and 'a' key will trigger the 'n' and 'm' keydown events. Is there a way to allow any keydown event to be triggered, regardless of other keys pressed? You can test this behavior using the following code:

document.addEventListener('keydown', (e) => {
    console.log(e.key);
});


texts: Can't change anchor position and TextureRect size

texts:
I'm making UI, and want to set anchor to middle of the image, but changing anchor from Layout -> Anchors Only or setting Anchor value directly doesn't work. The value was updated, but anchor point not moved at all. Is it bug or is there are something that I missed?

Here's the node tree:

CanvasLayer

Control

TextureRect <- Anchor is not moving at all

Using Godot 3.1.1.

Also I can't find how to resize texture rect. I can set the min-size, but change size doesn't work, the value immediately set back to original size. How to change the texture rect size?


texts:
I'm working on a GLSL raytracer, and I need to be able to edit gl_FragDepth in the FS.  However, doing so disables early-z culling.  The scene is rendered front-to-back and the FS can only push points further away, so the results of the z-test shouldn't affect the final render, even with a long pipeline.

Is there anyway to force early-z culling to run, or otherwise get around the "no fragdepth" restriction?  I suppose I could do a z-test in the FS, but I'd rather let the hardware take care of it if possible.


texts: My unity terrain size is 150*150, and I want to create a plane in blender have the same size. How to figure the correct size ?


texts:
I have got a floating character, which should be a robot like thing, floating over the ground, whereby I am using the »hovercar« effect described here. Zhe Image below outlines the basic setup of the physics

The Green rectangle is the chassis, its not allowed to rotate and held up by the »hover-power«. Attached to this is the robots head with an revolute joint, and attached to the head is the robots body, with another revolute joint. There are some more distance Joints for damping this, but not of interest for now.

In the next image one can see how the body of the robot should be tilted when it is in motion to the right or left.

Right now, the movement of the character is implemented so that forces and impulses are applied to the chassis body. Especially if there is an Impulse to the left or right, the desired tilt of the robots body comes to happen, but it fades away when the velocity becomes more constant, or acceleration comes closer to zero.

What can I do to keep the robots body tilted, when it is in motion?


texts: Script not working (Function not changing value)

texts:
I have this script that I made for an FPS character.
public class Player_Movement : MonoBehaviour

{
public CharacterController controller;
public Transform camera;
public float gravity = -9.81f;

public Transform groundCheck;
public float groundDistance = 0.4f;
public LayerMask groundMask;
bool grounded;

public GameObject joystick;
public bool isMoving;
public float speed = 12f;
public float turnSmoothTime = 0.1f;
float turnSmoothVelocity;

public float jumpHeight;
public Vector3 yPosition;
public bool jumpAble = true;

// Update is called once per frame
void FixedUpdate()
{
    grounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

    if (grounded)
    {
        yPosition.y = -2f;
        jumpAble = true;
    }

    Vector3 direction = new Vector3(joystick.GetComponent<Joystick>().inputDirection.x, 0f, joystick.GetComponent<Joystick>().inputDirection.y);
    isMoving = direction.magnitude != 0 ? true : false;

    if (isMoving)
    {
        controller.Move(direction * speed * Time.deltaTime);
    }

    yPosition.y += gravity * Time.deltaTime;
    UnityEngine.Debug.Log(yPosition);
    controller.Move(yPosition * Time.deltaTime);
}

public Vector3 Jump()
 {
     UnityEngine.Debug.Log(jumpAble);
     UnityEngine.Debug.Log(grounded);
     if (jumpAble && grounded)
     {
         jumpAble = false;
         yPosition.y = Mathf.Sqrt(jumpHeight * -2 * gravity);
         UnityEngine.Debug.Log(yPosition.y);
         UnityEngine.Debug.Log(yPosition);
         return yPosition;
     }

     return yPosition;
 }

}
The game operates on mobile touch controls, and the Jump() is called when the jump button is pressed. However, the character does not jump when I press the button, even though the function is being called, and the yPoisition is being changed in the function. I know that changing the yPosition should make the player jump, as when I add this code to the Update:
if (Input.GetKey(KeyCode.Space) && jumpAble)
         {
             fallDown.y = Mathf.Sqrt(jumpHeight * -2 * gravity);
         }

Everything works fine.
Why is the new yPoisition value not being passed to Update, and why is this happening?


texts: How can I move an object in a direction other than the ordinals?

texts:
I want to move a game object from its current position to the mouse position, but my current code only ever moves in one of the eight ordinal directions. In other words, I want it to move along the red path, but I only know how to move it along the white path.

Here's my code:

while(cont){
    if(x1 > x){
        x++;
    }else if(x1 < x){
        x--;
    }
    if(y1 > y){
        y++;
    }else if(y1 < y){
        y--;
    }
    frame.repaint();
    sleep(); // Thread.sleep(200)
}
// x1 y1 - mouse position
// x, y - sprite position

What am I missing?


texts: How do I make both the Standard Unity Sphere and Pro Builder Sphere behave the same way?

texts:
I recently got into Unity and have been developing a game with a co-worker. Long story short I was thinking about using Blender for the 3d models but found about ProBuilder and gave it a shot. Here's my problem/question...

Take this code for test:

 public Rigidbody rigiBody;

[Range(200,800)]
public float jumpForce;

// Start is called before the first frame update
void Awake()
{
    rigiBody = GetComponent<Rigidbody>();
}

// Update is called once per frame
void Update()
{
    if(Input.GetButtonDown("Jump"))
    {
        rigiBody.AddForce(Vector3.up * jumpForce, ForceMode.Force);
    }
}

When I create a 3D object within Unity (r-click on hierarchy panel -> 3d object -> sphere, Scale[x:1,y:1,z:1]) and add a rigid body component and the script above the sphere jump feel just about right.

When using a ProBuilder object (New Shape Tool -> Cone [Radius: .5, Height: 2, Number of Sides: 32] -> Build Cone) and and add a rigid body component and the script above the cone just drop very fast and the jump force applied almost don't have any impact on it. Rigid Body's settings are default for both objects.

How do I make both the Standard Unity Shape (Sphere) and Pro Builder Shape (Cone) behave the same way?

Note: Both objects have the same scale.

Thanks in advance.


texts: Player Ai for games involving scoring goals like soccer, hockey, basketball?

texts:
I've been working on a soccer game, and was thinking of different ways to program player AI's and was wondering how they actually work. The concept is probably similar to all games where there are balls and goals like Soccer, Hockey, Basketball etc.

Which algorithm do they use ? I imagine if you have the ball, you can use A*, to figure out a path passed other "enemy" players and score. That seems simple to implement.

But if you do not have the ball then then it becomes really complicated - you could either play "zone" in which case, you stay within a particular region on of the playing area, and orient yourself towards the ball. Or switch to playing "man", in which case you stick to some player on the other team.

Was wondering what other algorithms people use, as machine learning for a simple mobile game seems like over kill.


texts:
I'm trying to read this text file and render the corresponding tiles on the screen.

The code for reading the map is as follows:

private void loadMap(InputStream is) throws IOException {
    ArrayList<String> lines = new ArrayList<String>();
    int width = 0;
    int height = 0;

    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    while (true) {
        String line = reader.readLine();
        if (line == null) {
            reader.close();
            break;
        }

        if (!line.startsWith("!")) {
            lines.add(line);
            width = Math.max(width, line.length());
        }
    }
    height = lines.size();

    for (int j=0; j < 18; j++) {
        String line = (String) lines.get(j);
        for (int i=0; i < width; i++) {

            if (i < line.length()) {
                char ch = line.charAt(i);
                Tile t = new Tile(i, j, Character.getNumericValue(ch));
                tiles.add(t);
            }
        }
    }

}

The first problem I have is with Character.getNumericValue(ch) as this does not seem to be doing anything, resulting in a NullPointerException. When I remove it and replace it with either a 1 or a 2 I'm able to render the tiles onto the screen but somehow the spaces in between the digits are interpreted as tiles, resulting in a continuous block of tiles eg in the second line with 1s results in tiles beginning from the left margin up until the last 1. How can I fix this?


texts: How do I support multiple platform patch cycles in a client/server multiplayer game?

texts:
I'm making a game with network multiplayer that will be playable with crossplay from multiple platforms. The game is written in c++ and uses regular TCP sockets for network communication. Currently the game exists on windows but ideally it will exist on ios/android/linux/mac as well. The server is a single process written to run on Ubuntu Linux. Currently, clients find the server by hard coded url which is resolved to the server IP, and a hard coded port.

This is fine as long as the clients/server are developed/shipped in perfect lockstep. If I change the client or network code in some way, I have the power to just release the client update and start running the new server version simultaneously.

The problem is that once I've released on multiple platforms, I'll never be able to ship an update to all clients at once. Additionally, old versions of the client will exist in the wild forever.

If I add a version handshake to the beginning of each connection, I could detect and deactivate multiplayer features in old clients. With this constraint, I could only operate one server for all platforms (big upside).

Delayed updates would cause a version of the game to be broken temporarily (for example the App Store could reject an update unexpectedly). If my App Store build falls behind, it would not be supported by the current server.

What simple methods exist for supporting multiple api versions when your server is a single process communicating over TCP?

What are the typical solutions to this problem? I know games like Hearthstone achieve this but I assume they have some massive server infrastructure/ops team to help with this.


texts: Ultimate beginner's tutorial to 3d game dev using XNA Framework?

texts:
I'm looking for a tutorial that starts at square 1 for game development and moves up through intermediate/expert levels of 3D game development. I really want to get into 3D game dev and I've been trying to for awhile in my free time, but I know so little at times that I'm not even sure what terminology to use in order to phrase a question properly.

Ideally, I'm hoping to find tutorials for the XNA Framework, what little experience I have is XNA.

I've been developing for years and don't really need help with the language. What I know I need help on is stuff like rendering, what exactly a Matrix represents, and other things in the framework's library. I don't even know what all is available in the library.


texts: Collider does not call callback functions

texts:
I have a script that will create new GameObjects and will place it where the mouse is placed on the terrain. Now I need to have a check for collision on other already placed GameObjects on the field.

I check different tutorials and documentation and cannot find a way to do this in code.

My code looks like:

objectToPlace = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Game/3D Models/Buildings/" + objectName + ".fbx", typeof(GameObject));
objectToPlace.SetActive(true);
objectToPlace.transform.localScale = new Vector3(1, 1, 1);
objectToPlace = Instantiate(objectToPlace);

objectToPlace.transform.Rotate(Vector3.right * 90);

BoxCollider collider = (BoxCollider)objectToPlace.AddComponent(typeof(BoxCollider));
collider.isTrigger = true;

In the same class as the above code I have OnTriggerEnter function. But that function is not called. How can I link the Collider to that function in Unity 5.6?

I also tried using the Physics.CheckBox for checking if my new create gameObject does not collide to any other object. But without any succes.


texts: Calculating ln (natural logarithm) in games

texts:
I am developing a game for tablets using the Marmalade SDK and Cocos 2dX.

In my game I have implemented a separation steering behavior in order to keep some of my characters separated from eachother. Currently I am calculating the magnitude of this steering force using a y = -ln(x) function, in which ln is the natural logarithm.

However, I am wondering if this is a wise choice of function, because it may be costly for the processor to calculate this, just like the square root function.

What do you think, should I try to replace my function for something similar to optimize my game's performance, or there will be minimal gain in replacing a logarithm function for a 1 / x function, for example.


texts: Using PhysX, how can I predict where I will need to generate procedural terrain collision shapes?

texts:
In this situation, I have terrain height values I generate procedurally. For rendering, I use the camera's position to generate an appropriate sized height map. For collision, however, I need to have height fields generated in areas where objects may intersect.

My current potential solution, which may be naive, is to iterate over all "awake" physics actors, use their bounds/extents and velocities to generate spheres in which they may reside after a physics update, then generate height values for ranges encompassing clustered groups of actors. Much of that data is likely already calculated by PhysX already, however.

Is there some API, maybe a set of queries, even callbacks from the spatial system, that I could use to predict where terrain height values will be needed?


texts: How to receive shadows on animated object In optimize way?

texts:
I've been trying to add shadow to my flag that animated In my vertex shader but after adding shadow , my shadow is fixed and does not follow the animation of the flag.

for adding shadow I use below link:

  Diffuse has a fallback of vertex lit, which contains within it two passes; Shadow Caster and Shadow Receiver. These are the two passes that allow the shader to cast and receive shadows.
  http://polycount.com/discussion/131260/how-to-get-custom-shaders-to-recieve-shadows

my shader is here:

Shader "Custom/Flag" {
    Properties {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Speed ("Speed", Range(0, 5.0)) = 1
        _Frequency ("Frequency", Range(0, 1.3)) = 1
        _Amplitude ("Amplitude", Range(0, 5.0)) = 1
    }
    SubShader {
        Tags { "RenderType"="Opaque" "LightMode"="ForwardBase"  }
        Cull off

        Pass {

            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile_fwdbase

            #include "UnityCG.cginc"
            #include "AutoLight.cginc"

            sampler2D _MainTex;
            float4 _MainTex_ST;

            struct v2f {
                float4 pos : SV_POSITION;
                float2 uv : TEXCOORD0;
                LIGHTING_COORDS(1, 2)
            };

            float _Speed;
            float _Frequency;
            float _Amplitude;

            v2f vert(appdata_base v)
            {
                v2f o;
                v.vertex.y +=  cos((v.vertex.x + _Time.y * _Speed) * _Frequency) * _Amplitude * (v.vertex.x - 5);
                o.pos = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
                TRANSFER_VERTEX_TO_FRAGMENT(o);
                return o;
            }

            fixed4 frag(v2f i) : SV_Target
            {
                return tex2D(_MainTex, i.uv);
            }

            ENDCG

        }
    }
    FallBack "VertexLit"
}

Finally I use "LightMode"="ShadowCaster" but this Tag prevents rendering my flag like this problem.A solution came to my mind that works correctly "using two pass for implementing shadows: 1.normal pass 2.ShadowCaster pass" but I think It's not optimize.

this is my solution as Pseudo Code:

   SubShader {
        Tags { "RenderType"="Opaque" }
        Cull off
        Pass {
            CGPROGRAM
            Shader "Custom/Flag" // normal Pass for animating flag
            ENDCG
        }

        Pass {
            Tags { "LightMode"="ShadowCaster" }

            CGPROGRAM
            Shader "Custom/Flag" //ShadowCaster Pass for recieving shadow
            ENDCG
        }
    }
    FallBack "VertexLit"
}

Flag shader.unitypackage

In short I finding a way for adding shadows for vertex animated objects In optimized way.


texts: How can I support many point light sources in a dynamically-generated level in Unity?

texts:
I'm currently working with a dungeon game which is similar to Dungeon Keeper by Mythic Entertainment. I'm using Unity and developing this game for Ipad 2 and above. Player can modify his dungeon, and I'd written a dungeon generator which creates it. In this case, I can't use lightmaps, because the dungeon has been created dynamically and player can tweak it. I also devised a way to combine separate game objects in a single mesh, so imagine that the entire dungeon (except special objects such as pillars, statues and mobs) is the single mesh. There's many point light sources (10-15 and above) on the stage, but Unity don't allow to use more than 8 light sources per object.

So, if all dungeon cells are separated objects, I can use the diffuse or even vertex-lit lighting, but if the entire dungeon is a single mesh, there's the hardware limit appears.

Ways to solve this problem I'd divised:

Use separated geometry (tried) - bad, because it harms berformance because there's many-many-many drawcalls (16-17 fps on Ipad 4).
Use deffered shading (tried) - bad, because it harms performance even more than separated geometry.
Use a custom shader (haven't tried) - I don't know how.
Don't unite all cells in the single mesh but unite groups of cells to reduce the number of separated objects (haven't tried)
Use the light manager (haven't tried) - I don't know how.
???

How can I deal with it?


texts: How do I make my camera follow a Box2D object?

texts:
I'm implementing a camera in my game. It worked for regular objects, but I began using Box2D and obviously things changed a bit. I have a Body object that I want to draw at the center of the screen. Basically what I'm doing is subtracting the viewportX and viewportY from the Body's position.

The relevant code:

public void paint(Graphics2D g, int viewportX, int viewportY) {
    Transform xf = new Transform();

    // m_body is the Body object
    xf.set(m_body.getTransform());

    // Here I attempt to take the transform and alter it by the viewportX and
    // Y, which are something like (-240, -150). It's negative because an
    // object at (500, 300) would be displayed at (160, 150) after the
    // subtraction. DrawUtils.toScale(), is just how I convert units from
    // JBox2D units to my units.
    Vec2 v = Transform.mulTrans(xf, new Vec2(DrawUtils.toScale(-viewportX),
        DrawUtils.toScale(-viewportY)));

    // Set the new transform to the new vector. Keep the old angle.
    xf.set(v, xf.q.getAngle());
    g.setColor(Color.white);

    // I know the following method works correctly. It displays my object,
    // just doesn't follow it.
    for (Fixture f = m_body.getFixtureList(); f != null; f = f.getNext())
        DrawUtils.drawShape(f, xf);
}

I don't want to alter the actual physics position of the object, just its graphical position such that it's displayed it in the center.


texts: Particle system not copy object with particle system?

texts: "main karma" is an object with three particles. "Karma particle system" is a particle system copy "main karma" object without particle system inside it ?!! how to copy object with the particle system ?


texts:
When i run the game particles crash the game, im not sure what am i doing wrong because the program doesnt tell me. But i know particles are causing this , if i remove the code in update code at bottom, the runnable jar works fine.

Particle class : http://pastebin.com/ATLN6qzR

Particle manager : http://pastebin.com/vAk1nwmi

Slick 2d docmentation : http://www.slick2d.org/javadoc/

It says error is here where the for starts

public void update(int delta){

    for (Particle o: particleList) {
        if(o.emitter.completed() == true){
            particleList.remove(o);
        }
        else{
            o.system.update(delta);
        }

    }
}


texts:
I have a Enemy class that Seeks a player if he is in his field of view.
Problem is i want the enemy only to move up/down/right/left, not like for example up and left at the same time (diagonal movement).

EDIT: Code updated

    private void SeekPlayer(GameTime gameTime, Player player)
    {
        directionToPlayer = player.Image.Position - Image.Position;
        directionToPlayer.Normalize();

        if(Image.Position != player.Image.Position)
        {
            if (directionToPlayer.X != player.Image.Position.X)
            {
                if(directionToPlayer.X < player.Image.Position.X)
                    Image.Position.X += directionToPlayer.X * MoveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                else
                    Image.Position.X -= directionToPlayer.X * MoveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else if (directionToPlayer.Y != player.Image.Position.Y)
            {
                if (directionToPlayer.Y < player.Image.Position.Y)
                    Image.Position.Y += directionToPlayer.Y * MoveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                else
                    Image.Position.Y -= directionToPlayer.Y * MoveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

        }
        UpdateFOV();
    }

With the current code the enemy sometimes follows the play on the X coordinates, and when it's the same has the player's, doesn't continue to follow on the Y coordinate. And vice-versa for Y.


texts:
I am working on my first game with LibGDX and coming from ActionScript3 I am used with the possibility of scaling things more or less the way I want. I know it works different in LibGDX, but I can't seem to figure out exactly how to achieve what I am trying to do.

I have a camera set up (OrthographicCamera), a SpriteBatch where I render different items(textures) and what I want is to be able to scale and move a group of items, while the rest remain intact. I know that I can zoom the camera itself, but this applies to all the elements int he SpriteBatch.

If you worked with ActionScript before, imagine you have the stage (this is my SpriteBatch) where I render different DisplayObject. Some DisplayObjects have other DisplayObjects inside. I calculate these offsets (item.x is parent.x + offsetInParent). Now what I want is to be able to scale one such DisplayObject with ease.

Thanks.


texts:
I'm experimenting with isometric tile maps in JavaScript and HTML5 Canvas.
I'm storing tile map data in JavaScript 2D array.

// 0 - Grass
// 1 - Dirt
// ...
var mapData = [
    [0, 0, 0, 0, 0],
    [0, 0, 1, 0, 0,
    ...
]

and draw

for(var i = 0; i < mapData.length; i++) {
    for(var j = 0; j < mapData[i].length; j++) {
        var p = iso2screen(i, j, 0); // X, Y, Z
        context.drawImage(tileArray[mapData[i][j]], p.x, p.y);
    }
}

but this function mean's all tile Z axis is equal to zero.

var p = iso2screen(i, j, 0);

Maybe anyone have idea and how to do something like mapData[0][0] Z axis equal to 3 mapData[5][5] Z axis equal to 5?

I have idea: Write function for grass, dirt and store this function to 2D array and draw and later mapData[0][0].setZ(3); But it is good idea to write functions for each tiles?


texts: Unreal engine project not responding to key binding changes

texts:
I'm getting started with learning Unreal development, and I've created a new project based off the FPS C++ template.

I've changed the key mappings inside the DefaultInput.ini, rebuilt the Visual Studio solution, and rebuilt the project in the Unreal editor, but none of my changes are taking effect.

What step am I missing?


texts: Unity Editor stops updating ScriptableObjects if I click away from them in editor

texts:
I'm trying to be better about structuring my code, and I think I'm doing it right. The issue I've got right now is I need to get joystick inputs, scale those values appropriately, and then use that scaled data on any number of MonoBehaviour scripts.

I'm trying to split the input conditioning from the end user, and I'd like to do that by using a ScriptableObject to hold the conditioned data.

I was thinking that a MonoBehaviour script would run, get the joystick data, scale it, and then push that data to variables in the ScaledJoystickData ScriptableObject. Later, a second MonoBehaviour script would access the variables in the ScaledJoystickData and use those to move the things in the game.

I'm understanding the benefits of structuring the code this way, especially in that I can access the ScriptableObject from the editor and manipulate those values; I don't actually need to have a joystick connected, and I'm free to test either end of the input handling independently.

The problem is that, if I am looking at the ScriptableObject instance in the editor, it stops updating as soon as I click away from it (to the consuming GameObject). If I click back to the ScriptableObejct instance, none of the values update. Nothing on the GameObject's script updates unless I start the game with that GO selected in-editor, and again THAT fails to update if I click off and click back.

The GameObject script is currently using the values from the ScriptableObject instance and piping them to public variables, and the public variables aren't updating.

Is there some bug with ScriptableObjects, or am I doing this wrong?

:EDIT:

Here's an example. Make a script called "ExampleSO" and replace the contents with:

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

[CreateAssetMenu]
public class ExampleSO : ScriptableObject
{
    public float stashedVar = 0f;
}

Make a script called "ExampleWriter" and replace the contents with:

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

public class ExampleWriter : MonoBehaviour
{
    public float scaling = 2f;
    public float scaledInput = 0f;
    public ExampleSO exampleSO = null;

    // Update is called once per frame
    void Update()
    {
        if(exampleSO!=null)
        {
            scaledInput = scaling * (Input.GetKey(KeyCode.LeftArrow) ? 1f : 0f);
            exampleSO.stashedVar = scaledInput;
        }
    }
}

Make a script called "ExampleReader" and replace the contents with:

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

public class ExampleReader : MonoBehaviour
{
    public float display = 0f;
    public ExampleSO exampleSO = null;

    void Update()
    {
        if(exampleSO!=null)
        {
            display = exampleSO.stashedVar;
        }
    }
}

Create an instance of the ExampleSO, add the ExampleWriter to a game object, and put the ExampleSO instance into the ExampleWriter slot.

Highlight the game object holding ExampleWriter and run it. Push the left arrow key and see the value toggle 0/2.

Click the ExampleSO instance. Nothing is happening there now. Click back on the game object, and now it doesn't update either.

If you have the ExampleReader on the same game object then it won't work at all. ExampleReader will read fine, if you have it on a separate GameObject, but again if you click off and click back then it stops responding.


texts: Are all conditions in an if statement checked?

texts:
If I have an if statement like this:

bool conditionOne = true;
bool conditionTwo = false;
bool conditionThree = false;

if(conditionOne || conditionTwo || conditionThree)
{
    //do something
}

Will conditionTwo and conditionThree actually be checked even though conditionOne is already true, and thus has met the requirements of the if statement to run the code inside it? It would be pointless to check if conditionTwo and conditionThree are true because either way the code inside the if statement would be run.

I'm thinking this would be useful to know if I have some really long and quite expensive checks to do.


texts:
I have some code that looks like this:

DirectX::XMVECTOR a, b, c;
a = DirectX::XMQuaternionIdentity();
b = DirectX::XMQuaternionRotationAxis(DirectX::XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f), 3.1415f);
c = DirectX::XMQuaternionRotationAxis(DirectX::XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f), (3.1415f * 3.0f) / 2.0f);

DirectX::XMVECTOR slerpAB = DirectX::XMQuaternionSlerp(a, b, 0.4f);
DirectX::XMVECTOR slerpBC = DirectX::XMQuaternionSlerp(b, c, 0.85f);
DirectX::XMVECTOR slerpCA = DirectX::XMQuaternionSlerp(c, a, 1.0f);

The thing is, I'm sure that slerpBC is wrong. Here's what I'm getting:

If I understand it right, slerpBC should be 85% of the way towards a 3-quater turn around the Z axis. But when I plug that value in to Wolfram Alpha, it looks totally wrong.

Furthermore, when I run the code through my own Slerp code I get a totally different answer that looks more correct, to me.

So... What am I doing wrong?


texts: How can i exclude "Y" from drag in unity?

texts:
I'm trying to make a moving object drag when no input is received, but i want the drag to only apply to X and Z variables, and not Y. Meaning i want it to fall at a normal speed, but when i stop giving it force in x and z directions, i want it to gradually and quickly stop going in those directions. How can i achieve this?

I've done this:

Vector3 input = new Vector3(Input.GetAxis("Horizontal") , 0, Input.GetAxis("Vertical");
If (input.x == 0 && input.z ==0) rb.drag = 3;


texts:
I have created a basic game that runs in a view. It consists of a thread which repeatedly calls the update() and draw(Canvas canvas) method. Everything works fine so far.

Next, I want to implement a UI that consists of a textView showing the score, and other stats of the game. This is put above the view of the main game. Should this UI have its own thread that repeatedly checks to see if the score has changed, and then update that change in the UI?
At first I just made a class that allows the main game thread to update elements in the UI via something like scoreView.setText(currentScore).
But this leads to some instability, and that object to talk to the UI has to be passed throughout the methods in the main game UI which isn't the cleanest approach.

What is the standard approach for implementing the UI in a clean way which is easy to maintain.

visual guide: (the line indicates that the two communicate with another)


texts: How to implement buffs / debuffs / temporary stat changes in an RPG?

texts:
Possible Duplicate:
  What’s a way to implement a flexible buff/debuff system?

In the context of creating an engine for a RPG I want to implement a generic way to give effects / buffs / debuffs to the player, for instance:

strength boost : +15 to strength last for 10 mins
sickness : all attributes are divided by 2. Permanent until removed

Now the problem is that effects can stack upon each others but they can be removed independently. For instance you could have both above-mentioned effects and only remove the "sickness" one leaving the other one.

Are there any existing solutions to this problem? My idea is to always recompute the "final" statistics by applying each effect in chronological order to the "initial" stat, but I wonder: is there any downside?


texts:
I'm developing my first game using Löve, the game is a basic Asteroids clone. Everything is going well so far, until I decided to actually add asteroids.

I'm trying to make a basic hit-detection that checks if a bullet is within the boundaries of an asteroid, then deletes both of them.

The issue is that if I do this:

for i, v in ipairs(bullet) do
    for i, ast in ipairs(asteroid) do
        i fv.y < 20 + ast.y and v.y > ast.y - 20 and v.x < 20 + ast.x and v.x > ast.x - 20 then
             table.remove(asteroid, i)
             table.remove(bullet, i)
        end
    end
end

It deletes the asteroid that was hit, but a random bullet rather than the bullet that hit the asteroid. If I split the code, it only deletes either the asteroid or the bullet, whichever is run first. If I reverse the ipairs, the bullet disappears, but a random asteroid is removed instead of the one that got hit.

Tl;Dr, How do I properly use nested ipairs?


texts: Unity Colliders - How do I detect nearby objects without my detection ranges detecting each other

texts:
How can I get both colliders' types in a trigger overlap message like OnTriggerExit2D(Collider2D other)?

Example:

objects A and B both have a BoxCollider2D and CircleCollider2D components.
Then, object A enters one of the trigger colliders of object B.
I can get object B's collider type with the is operator.

How can I get A's collider type?

The reason I want this is that I want only collisions where object A's CircleCollider2D touches object B's BoxCollider2D.

void OnTriggerExit2D(Collider2D other)
{
    if (other is BoxCollider2D)
        //Do Code
}

Here is a table of what I want: I want only to register trigger overlaps from CircleCollider2D to BoxCollider2D. With the is operator, I can safely remove all collisions to CircleCollider2D but collisions between two BoxCollider2D stay, which I do not want.

+------------------+---------------+------------------+
|  Row to Column   | BoxCollider2D | CircleCollider2D |
+------------------+---------------+------------------+
| BoxCollider2D    | No            | No               |
| CircleCollider2D | Yes           | No               |
+------------------+---------------+------------------+

Edit
The real questions was to detect nearby objects without the detection range dectecting each other.


texts: How do I draw an isoline in a shader with a triangle topology?

texts:
I have some problems with my displacment. So I would like to have a simple little isoline starting in every triangles face center of the mash pointing in the direction of the corresponding faces normal direction.
like in the following picture (okay these are no triangles, but still something like that):

Can I draw isoline in my shader when the topology is a trianglelist? if yes, how do I do that?


texts: How do I reference one game object in a script attached to another?

texts:
This is all in Unity, with C#.

I have attached a script to my player that should destroy a TreeGroup (as in a forest) whenever I press 'Q' and instantiate one when I press 'E'.

Here is the code:

using UnityEngine;
using System.Collections;

public class DisableTrees : MonoBehaviour {

    // Use this for initialization
    void Start () {

    }

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

        if (Input.GetKeyDown (KeyCode.A)) {
            //Disable Trees on A Keypress

            Debug.Log("Trees Disabled!");
        }

        if (Input.GetKeyDown (KeyCode.E)) {
            //Enable Trees on E Keypress

            Debug.Log("Trees Enabled!");
        }

    }
}

How do I access and find my 'TreeGroup' object group while script not being attached to 'TreeGroup' but my character instead and then Destroy on Q Keypress?
And how do I Instantiate it?


texts: Unity Rendering (Bug): Objects rendered as multiple instances after repositioning

texts:
Context: I am currently making the menu for my game demo. It involoves "Raindrop"-Gameobjects (Sprites) being repositoned and recolored after a random amount of time. I do this by instantiating a predefined amount of Raindrops and manipulate them after said amount of time.

I am using Unity 2018.1.6f and, if possible, want to avoid switching to another version. If it is of relevance and requested, I can also post my sprite import settings.

Problem: Upon repositioning a sprite, it keeps being rendered at its old position AND the new position, making it appear as if a new instance was created

(this isn't the case as 1. the objects in the hierarchy view remain the same, and 2. the unwanted "multiple renderings" aren't shown in the scene view either, only in game view)

As seen below, there are 5 Raindrop objects in the hierarchy as well as in the scene view. In the game view however, there a lot more than 5 Raindrops are being rendered. The amount of rendered Raindrops increases each time a single one is repositioned.

Further notice:
I had a fairly similar problem once where a bug in my code caused it tho delete all objects at once. The objects were deleted but kept on being rendered and even functioning as if nothing happened, save for the difference that all moving objects would be rendered like the cards in solitaire once the game is over (I do not know of a different way of describing it). None of the code above, except for the Exit() function of MenuEnvironment destroys any object. As you can see, the rainbow objects are only instantiated once, upon Setup(GameObject, GameObject) and being continuously manipulated in Unity's Update Loop.


texts:
I'm studying 2D geometry with eventual goal to study 3D geometry for building games - very much looking forward to 3D!!
Looking up on how to calculate hypotenuse of a right triangle in 3D I read that the the same 2D Pythagorean theorem can also be used in 3D right triangle to calculate the hypotenuse.
So now I'm curious on how much of the 2D geometry I'm learning right now will be reusable when I get to 3D?
By "how much" I mean

Do devs throw away their 2D knowledge in 3D and use a whole new sets of formulas/theorems?
Or almost all or at least 90% of 2D knowledge is reused in 3D?


texts: Can I sell Windows Phone 7 games on the marketplace from India?

texts: I am a developer from India working on a game in WP7. I need to know, can I sell my game in Windows phone apps marketplace or is it like Android market where only free/ad-based is allowed?


texts: Why when using Lerp and StartCoroutine to Lerp between -3 and 3 it's not working?

texts:
private bool alreadyFading = false;

Then
private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Teleporting Object")
        {

            if (!alreadyFading) StartCoroutine(Teleport(-3, 3, 5f));
        }
    }

And
IEnumerator Teleport(float from, float to, float duration)
    {
        alreadyFading = true;

        var timePassed = 0f;
        while (timePassed < duration)
        {
            var factor = timePassed / duration;
            var value = Mathf.Lerp(from, to, factor);

            material.SetFloat("_DissolveAmount", value);

            yield return null;
        }

        material.SetFloat("_DissolveAmount", to);

        alreadyFading = false;
    }

Using a break point it's getting to the Teleport function but it's not changing the values from -3 to 3.
It does nothing to the shader to the property _DissolveAmount.
I want it to change the value from -3 to 3 with duration once not ping pong. but it's not just it's just don't do anything.


texts: Can I use JBox2D on server with Box2D on libGDX on client?

texts:
I want to use Box2D for my turn-based game, made with libGDX. The client is supposed to do some prediction of physics after his input and I want to correct these calculations with server-side calculations afterwards.
As I do not want to run an entire libGDX project on my server (because there will be parallel games and a single game per GameRoom is not necessary), I thought about running JBox2D on the server and send the final calculations for correction purposes to my two clients.

Can I e.g. step 10 seconds ahead at once with my server-side physics and send the results to my client right away? I don't need small steps, because the server won't render them anyways
Will these results mostly match with the client results of the built-in libgdx box2d version? I will here use smaller steps, so the client can render the changes easily.

Thanks in advance!


texts:
I want to make a separate landscape layout for each size of my original layout

I have activity_main.xml. I have adapted it to be able to fit multiple screen sizes:

Now, I want to create a landscape layout for each different screen size. The android docs and many (Many!) stack overflow pages suggest to do something like this to create a new landscape layout:

But after doing this, I create a landscape layout for all of the activity_main.xml's I need a separate landscape for the large activity_main, the small activity_main, the xlarge activity_main, and the normal activity_main. By doing the method described everywhere, I end up with this:

And because this covers all of the activity_main.xml's, I don't get the option to 'Create Landscape Variationon my other versions of myactivity_main`.

So, how do I get separate landscape layouts for each already made variation of activity_main?

Thanks so much,

Ruchir


texts: SimpleOpenNI: Check if user hand is in specific area on image

texts:
Concerning our Microsoft Kinect project, we need some help.

We control a robot with our movements tracked by the Kinect sensor. We display the depth image of the Kinect sensor on our screen, so we see what the sensor is acutally tracking.

Now we want to implement a feature that a user can turn the robot on and off by moving the hand on a specific area drawed on this depth image. You can see this in the image below. The problem now is, that the coordinates of this "on-drawed" ellipse obviously are relative in the 3d-space.  I know that there must be any possibility to translate the X-, Y- and Z-coordinates of the hand in the 2d-space, but honestly, I have no idea how to do this. I imagine a kind of "tunnel" from the point of view of the sensor, like in the picture below, which the user must hit.

I hope that somebody can help us here.


texts: How to get and copy font bitmap from WinGDI to a IDirect3DTexture9?

texts:
I want to get the pixels (or other data) for any character of the available fonts and copy/build them into a D3D texture so I could make some cache of text rendering by mapping only the character coords in the d3d texture and other stuff I need to solve (and using ID3DXFont is not an option).

How is this normally achieved? Should I render the GDI font to a GDI bitmap and then copy the opaque bits from the bitmap?

I thought about GDI because I can use the fonts installed in the system that way, but I would also like to know which formats should I consider for storing my own fonts and how these formats work.


texts:
How would I go about finding the fastest path to connect two points on a grid? I'm making a 2D game and the map is based around a grid.

I need to be able to account for any blocked tiles that the path need be able to go through.

Example: http://imgur.com/BbtnR
The blue line being what I need to figure out, and the red tiles being the blocked tiles.

Where should I start? Any advice be would great!


texts: What is the technology behind screen sharing?

texts:
Came across an app called Draw N Guess(iTunes link) and the app uses screen sharing, i.e what a player draws is visible to others. I'm wondering how they are doing it in real time. I believe it is a cross-platform app. I got curios to know what is the technology behind it! It must be very interesting to learn :)

P.S. If this is not the site to ask plain question (i.e unrelated to programming), can you let me know where I can ask such questions? TIY!


texts: Having trouble with getting an image to fit on a face of a cube

texts:
I have a problem with a Unity project that I'm working on. I'm creating an 3D art gallery which will be developed into a VR application in the future.

In a 3D scene, I have created a paint canvas GameObject (a cube) but I have some trouble getting images fit on the whole canvas. When I try to apply an image as a material, it is treated as a texture and only a small part of the image is visible on the canvas.

I am planning to make a UI where the user can upload pictures and the application will automatically render the gallery with these pictures.


texts: How to cause delay of 1 second of bullets when space pressed

texts:
I was wondering how to cause the bullets to delay since at the moment, they fire pretty much one after another. So I was wondering how to make each bullet be delayed by one second when the space bar is pressed/held down.

public class TheGun extends GunType{

  private Rectangle bullet;
  private final double speed = 3d;

  public TheGun(double xPos, double yPos, int width,int height){
    this.setxPos(xPos);
    this.setyPos(yPos);
    this.setWidth(width);
    this.setHeight(height);

    this.bullet = new Rectangle((int) getxPos(),(int) getyPos(), getWidth(), getHeight());
  }

  @Override
  public void draw(Graphics2D g) {
    if(bullet == null)
      return;

    g.setColor(Color.YELLOW);
    g.fill(bullet);
  }

  @Override
  public void update(double delta, BlockyBlocks blocks) {
    if(bullet == null)
      return;

    this.setyPos(getyPos() - (delta * speed - 1));
    bullet.y = (int) this.getyPos();
    wallCollide(blocks);
    isOutofBounds();
  }

  @Override
  public boolean collisionRect(Rectangle rect) {
    if(this.bullet == null)
      return false;

    if(bullet.intersects(rect)){
      this.bullet = null;
      return true;
    }

    return false;
  }

  @Override
  public boolean collisionPoly(Polygon poly) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public boolean destroy() {
    if(bullet == null)
      return true;

    return false;
  }

  @Override
  protected void wallCollide(BlockyBlocks blocks) {
    for(int i = 0; i < blocks.wall.size(); i++){
      if(bullet.intersects(blocks.wall.get(i))){
        blocks.wall.remove(i);
        bullet = null;
        return;
      }
    }
  }

  @Override
  protected void isOutofBounds() {
    if(this.bullet == null)
      return;

    if(bullet.y < 0 || bullet.y > Sea_InvadersDisplay.HEIGHT || bullet.x < 0 || bullet.x > Sea_InvadersDisplay.WIDTH){
      bullet = null;
    }
  }
}


texts: Interesting/Innovative Open Source tools for indie games

texts:
Just out of curiosity, I want to know opensource tools or projects that can add some interesting features to indie games, preferably those that could only be found on big-budget games.

EDIT: As suggested by The Communist Duck and Joe Wreschnig, I'm putting the examples as answers.

EDIT 2: Please do not post tools like PyGame, Inkscape, Gimp, Audacity, Slick2D, Phys2D, Blender (except for interesting plugins) and the like. I know they are great tools/libraries and some would argue essential to develop good games, but I'm looking for more rare projects. Could be something really specific or niche, like generating realistic trees and plants, or realistic AI for animals.


texts: So I have implemented grenades, and thats working fine. Now I want some explosion sound, but the problem is that the sound is still playing when the grenade is explode and I Destroy the grenade. Does someone have an idea how to circumvent this? I mean I could disable all Components on the nade so that it's invisible etc. and destroy it after the sound is done playing, but I feel like that's a bit weird.


texts:
I want to draw a 2D scene and after the scene i want to draw some light effects.

When i draw some light, i create a FBO, draw in it and when  finished with drawing, i want to create a texture where i draw the content of the FBO.

My current code:

//////////
//Init_

//Create Texture
glActiveTexture(GL_TEXTURE0);
glGenTextures(1, out _texfbo);
glBindTexture(GL_TEXTURE_2D, _texfbo);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _screenWidth, _screenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
glBindTexture(GL_TEXTURE_2D, 0);

//Create Renderbuffer
glGenRenderbuffers(1, out _rb);
glBindRenderbuffer(GL_RENDERBUFFER, _rb);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, _screenWidth, _screenHeight);
glBindRenderbuffer(GL_RENDERBUFFER, 0);

//Create Framebuffer
glGenFramebuffers(1, out _fbo);
glBindFramebuffer(GL_FRAMEBUFFER, _fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texfbo, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _rb);
glBindFramebuffer(GL_FRAMEBUFFER, 0);

//////////
//Loop:

glBindFramebuffer(GL_FRAMEBUFFER, _fbo);

//Draw Scene

glBindFramebuffer(GL_FRAMEBUFFER, 0);

glBindTexture(GL_TEXTURE_2D, _texfbo);

//Draw Rectangle with texture from Framebuffer

The Scene is not drawn on the screen, i think that means it's drawn in the right buffer. But i can't get someting on the screen. What is wrong?


texts: How do I click on specific text in an array of text?

texts:
I am trying to click on a specific word in an array but I can't think of how.
This is what I have:
  for x in range(0, len(names)):
    templine = font.render(names[x], True, WHITE)
    tempRect = templine.get_rect()
    tempRect.midleft = (50, (170+30*x))
    if mouse012[0] == True and tempRect.collidepoint(mouseXY):
      state = AppState.STATS

      detailsName = names[x]
    screen.blit(templine, tempRect)


texts: Problem with Parameters for polymorphism class

texts:
This is going to be a bit tricky but it is really bothering me so I hope you will have the patience to follow along :)
Here is my very basic architecture:

So in the framework, I am creating I have Actions these currently have a list of Conditions or Considerations (same thing different name).
While each Condition share some of the same functionality  such as:

Returning a float score
Using an evaluation formula

They implement these in very different ways depending on the situation.
Take a look at the following code:
[CreateAssetMenu(fileName = "Consider my health vs max health",
    menuName = "AnAppGames/AI/Example/Decisions/Health Consideration")]
public class MyHealth : BaseConsideration
{
    private float health;
    public float maxHealth;

    public override float Consider<T>(BaseAiContext context, BaseAction action, T value)
    {
        health = value as float;
        return EvaluateValues(health / maxHealth);
    }

}

What you are looking at is my first attempt at making some sort of "reusable" Consideration.
Now in the continuation of my development, I had to make the following Consideration:
public class DistanceFromMe : BaseConsideration
{
    public float minRange;
    public float maxRange;

    private float ConsiderWithValues(Transform target, Transform caller)
    {
        return EvaluateValues(new FloatData(Vector3.Distance(target.transform.position, caller.position),
            minRange,
            maxRange).GetNormalizedData());
    }

    public override float Consider<T>(BaseAiContext context, BaseAction action, T value)
    {
        Transform target = value as Transform;
        if (target == null)
        {
            return 0;
        }
        return ConsiderWithValues(target.transform, context.transform);
    }

    public override float Consider(float x)
    {
        return EvaluateValues(new FloatData(x,
            minRange,
            maxRange).GetNormalizedData());
    }

}

And now the trouble begins I thought "This is not a scaleable solution" as soon as I need more than 1 generic parameter I am screwed and have to create additional overrides of this Consider function.
So what I need is somehow to add different types of parameters to the Consideration however these parameters will vary a lot.
Another problem I have with this is that when I loop through the list I won't be able to tell what parameters i needed and how to fulfill the needs of the Consideration.
I thought of different ways of dealing with this inside the editor but I have come up empty :(
Can anyone help me out with this architectural mess? :)
It is worth mentioning that at the current point each of these are ScriptableObjects I am not 100 set in the fact that they should be but i am just not sure how to deal with this problem.


texts: How to stop sprite when overlap on in libgdx?

texts:
How can I stop my player if he overlap or touch the ball? In my top down game my player is cat and I want to stop  his moving or stack in that place of the ball is located if he hit the ball I'm using acceleromter to move the cat left and right.

Here is my code. How can I add collide method just like the image bellow? Thank's and advance!

// Load the sprite sheet as a texture
cat = new Texture(Gdx.files.internal("cat.png"));
catsprite = new Sprite(cat);
player = new Rectangle();
player.width = 20;
player.height = 80;
player.x = 300;
player.y = 0;

basketball = new Texture(Gdx.files.internal("ball.png"));
ball = new Circle();
ball.x = Gdx.graphics.getWidth() / 2;
ball.y = Gdx.graphics.getHeight() / 2;
ball.radius = basketball.getWidth() / 2;

In render method

camera.update();
TextureRegion currentFrame = walkAnimation.getKeyFrame(stateTime, true);
spriteBatch.draw(basketball, ball.x-ball.radius, ball.y-ball.radius);
spriteBatch.draw(currentFrame,player.x, player.y);// Draw current frame at (50, 50)

if(player.y < 0)
    player.y = 0;
if(player.y > 900 - 80)
    player.y = 700 - 80;

// check collision
if(Intersector.overlaps(ball, player)){
    tmp.set(player.x, player.y + player.height/2, player.width, player.height/2);

    if (Intersector.overlaps(ball, tmp)){
        //top half (or both top and bottom) hit
        Gdx.app.log("overlaps", "yes");
    } else {
        //bottom half hit
    }
}

//Mobile acceleration
if (Gdx.input.isPeripheralAvailable(Input.Peripheral.Accelerometer)) {
    player.x -= Gdx.input.getAccelerometerX();
    player.y += Gdx.input.getAccelerometerY();
}

if (player.y > Gdx.graphics.getHeight() - 100)
    player.y = Gdx.graphics.getHeight() - 100;

if (player.x < 0) {
    player.x = 0;
    player.x += Gdx.graphics.getDeltaTime() * catSpeed;
}

if (player.x > Gdx.graphics.getHeight() - 250) {
    player.x = Gdx.graphics.getHeight() - 250;
}


texts:
I have the following code:
public float jumpHeight = 3f;

bool isGrounded;

void Update()
{
    if(Input.GetButtonDown("Jump")) && isGrounded)
    {
        velocity.y = Mathf.Sprt(jumpHeight * -2f * gravity;
    }
}


texts: Is it possible to make an obj with single triangle

texts: I am not good in using blender so i wanted to ask if it is possible to make an object with just one triangle and how would it look like, will the no of triangle increase if you scale it up.


texts:
I'd like to build a multi user dungeon in Java/C# (also open to other suggestions).  Below I have listed two ways of handling connections, and would like to know which would be the recommended way?
I think a good way to build it would be something like this:

Currently, I'm working on the connection handling portion (shown in the picture on the left, heavy black rectangle). It would take care of the connection handling between multiple clients and basically shove commands received from clients (denoted by newline char) into a queue, which the game engine can then pull off of and process. If there is a reply, the game engine would shove it into another queue so the connection handler can send it back to the client.
I see two ways to work this part:
Thread per connection
class Server {
    public void Listen() {
        // configure
        final int portNumber = 81;

        try {
            ServerSocket serverSocket = new ServerSocket(portNumber);

            while (true) {
                Socket socket = serverSocket.accept();
                new ProcessThread(socket).start();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class ProcessThread extends Thread {
    protected Socket socket;

    public ProcessThread(Socket clientSocket) {
        this.socket = clientSocket;
    }

    public void run() {
        try {
            OutputStream os = socket.getOutputStream();
            PrintWriter pw = new PrintWriter(os, true);

            while (true) {
                BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                String str = br.readLine();

                // do processing here
            }
        }
    }
}

Pros:

Easier implementation

Cons:

Thread per connection not scalable
Multithreading = potential yuckiness

Async socket
public class Server {
    // use hashmap to keep track of current input
    private HashMap<SelectionKey, StringBuilder> strings = new HashMap<>();

    public void Listen() {
        // configure
        Selector selector = Selector.open();
        ServerSocketChannel serverSocket = ServerSocketChannel.open();
        serverSocket.bind(new InetSocketAddress("localhost", 5454));
        serverSocket.configureBlocking(false);
        serverSocket.register(selector, SelectionKey.OP_ACCEPT);
        ByteBuffer buffer = ByteBuffer.allocate(256);

        while (true) {
            selector.select();
            Set<SelectionKey> selectedKeys = selector.selectedKeys();
            Iterator<SelectionKey> iter = selectedKeys.iterator();
            while (iter.hasNext()) {

                SelectionKey key = iter.next();

                if (key.isAcceptable()) {
                    // register new connection
                    register(selector, serverSocket);
                }

                if (key.isReadable()) {
                    // process input
                    // add input to hashmap, if not newline terminated
                    process(buffer, key);
                }
                iter.remove();
            }
        }
    }
}

Pros:

Will definitely process in order received
Less resource intensive (?)

Cons:

Handling readline is more difficult

What would be the recommended way?
I'm leaning towards the thread per connection, as it seems to be slightly easier to implement. For a MUD, I would expect less than 200 simultaneous connections (50 might be a more accurate estimate), which would not be too resource intensive.


texts:
Here's the code I use.

public class CameraGyro : MonoBehaviour {

private float initialX;
private float initialY;
private float initialZ;

// Use this for initialization
void Start () {
    Input.gyro.enabled = true;

    initialX = Input.gyro.rotationRateUnbiased.x;
    initialY = Input.gyro.rotationRateUnbiased.y;
}

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

    transform.Rotate (initialX - Input.gyro.rotationRateUnbiased.x, initialY - Input.gyro.rotationRateUnbiased.y, 0f);
}

}

The thing is when I rotate the phone, the Z axis seems to change even if I've set it to 0f in the code above. Is there a way to really lock this position to 0?


texts: Reorder a set of points in order to draw a triangle fan (example)

texts:
I'm doing a light engine (c++, using sfml), and to connect the light vertices, I thought about drawing a triangle fan.
Here is a representation of a triangle fan (sfml documentation):

The points HAVE TO be "ordered" to draw the shape correctly, otherwise it would mess the shape I suppose.

I drew the desired effect in ms paint:

As you can probably see, there is a central point, a light, and other points that I want to connect together. The problem is that the points are not always ... "In a row/Ordered" ? Let's see an example and simplify this problem.

In the example above, I can't connect the points from 0 to 8 because it would mess the shape.

I would like to reorder the points so I can connect them properly, like :

Do you have any ideas ?

I thought about doing something based on the "point in polygon" algorithm, like checking if the point is "on the right/left" but it seems complicated.

I don't necessarily need code (if you have time it would be nice) but I can try to do some, I just need ideas. Thanks


texts:
I'm using Node.js and Redis. I'm trying to come up with a reliable way to automatch players. There is a matching server and then multiple game servers set up.

The following is what I need to have happen:

Player sends join request with game type (small/medium etc)
Matching server adds player to the current game type that is waiting for players
Game server sends player the game ID

Currently I have implemented this as follows:

Matching server listens to game:queue:small using BRPOP
Checks if game:queue:small:id = id exists
Checks if game:id:users length is <= 6 (max players)
Adds player to game:id:users list if it is
If game length is now 6, it removes game:queue:small:id

If the matching server finds game:queue:small:id is missing, it does as follows:

INCR game:nextGameId
Sets game:queue:small:id to the previously generated ID
Adds the game ID to game:queue:waiting

The game servers wait using BRPOP for new games. When they get one, they wait until the game has a minimum of 2 users then start a timer. If they don't fill up in that time, they begin with the users they have and subsequently remove game:queue:small:id (thus forcing the matchmaker to request a new game).

Whilst my method is working, I'm not convinced it will work well in production and it seems very convoluted. I can see the potential for the following issues:

Game server crashes after accepting the game ID from the waiting list resulting in users getting added to the game:id:users but nothing happening with them (the crash itself isn't a problem, but users continuing to get added to that games queue is)
If a user disconnects and the game hasn't started, the game server will remove the user from the game:id:users list. Whilst it is in the process of doing that, the matchmaking server could be adding a user to the list and think the game is full, thus removing it from the queue.

My initial thoughts were to change to a single queue of users waiting for one game type. However, this presents further issues:

If the server that the users connects to crashes, it won't remove the user from the queue thus leaving that user to be entered into a game when they don't exist. I could use sorted sets to store the time of the request and have the client poll until it gets a game ID returned but this would mean that I have no idea of how long that client has waited and therefore do not know whether to start the game with fewer users.
Without putting the users into a game, they have no ability to see what users have joined, nor the ability to chat with the users that are waiting (as that requires a game ID).

None of the way I have set this up feels right so I was hoping someone might be able to offer some better suggestions. I really need to keep the game servers and the matchmaking servers separate though in order to grow them out as required.


texts: Calculate the amout that should be added or subtracted to x and y axis with rotation?

texts:
Say I have this figure:

How would I calculate the amount I must add or subtract to x and y axis to get the cube to move in the direction its facing? The rotation is a float 0 - 360 and 0 is straight up.


texts:
Linked to: GLSL pack floats into an RGBA texture

I found EncodeFloatRGBA/DecodeFloatRGBA shader functions in Unity https://gist.github.com/hecomi/9580605

Now I try to figure out how they work. So I try them on C++
http://coliru.stacked-crooked.com/a/345f8c403d4a78f9

But I got wrong results. Also I tried that with Mathematica, and got the same wrong results.  http://www.sendspace.com/file/qmlu8b

I tried to encode {0.1, 0.2, 0.3, 0.4} - but after encode/decode got {0.0980392,0.698039,0.79649,0.93266}