texts:
Can anyone explain the general architecture typically used for 3D character animation?

Are movements like walking and falling scripted against the skelton, and simply executed on input?  If so, is the scripting typically actual script or hard code?

What are common pitfalls or flaws in character animation engines?


texts: How can I hand out free copies of my otherwise-paid Play Store game?

texts: With Google Play Services, is it possible to give people redeemable codes for an Android game I made, or give them special access or something like that? How do I do it?


texts: My transparent objects overwrite opaque objects depth and always draw on top?

texts:
I have set up an 'Order Independent Transparency' method for drawing my transparent objects.

The algorithm can be simplified as follows:

DrawOpaqueObjects()
DrawTransparentObjects()

Drawing the transparent objects uses the following render target setup:

        colourAccumulation = new RenderTarget2D(
            game.GraphicsDevice,
            game.GraphicsDevice.PresentationParameters.BackBufferWidth,
            game.GraphicsDevice.PresentationParameters.BackBufferHeight,
            false,
            SurfaceFormat.Rgba64,           // 16 bit floating point texture (required for alpha blending caculations)
            DepthFormat.None
            );

        depthComplexity = new RenderTarget2D(
            game.GraphicsDevice,
            game.GraphicsDevice.PresentationParameters.BackBufferWidth,
            game.GraphicsDevice.PresentationParameters.BackBufferHeight,
            false,
            SurfaceFormat.Rgba64,           // 16 bit floating point texture (required for alpha blending caculations)
            DepthFormat.None
            );

The transparent objects are combined with another render target texture that all the opaque objects are drawn to before hand:

        scene = new RenderTarget2D(
            graphicsDevice,
            graphicsDevice.PresentationParameters.BackBufferWidth,
            graphicsDevice.PresentationParameters.BackBufferHeight,
            false,
            SurfaceFormat.Color,
            DepthFormat.Depth16,        // Requires a depth format for objects to be drawn correctly (e.g. wireframe model surrounding model)
            0,
            RenderTargetUsage.PreserveContents
            );

They are combined as follows:

PixelShaderOutput PixelShaderFunction(VertexShaderOutput input)
{
PixelShaderOutput output;

// Background colour 'Cbg'
float4 BackgroundColour = tex2D(BackgroundSampler, input.TextureCoordinates.xy);

float4 SumColour = tex2D(Texture0Sampler, input.TextureCoordinates.xy);

// [Depth complexity]
// • Each time a pixel is written by the transparent object it adds 1 to the value [float4(1, 1, 1, 1)]
// • This is why a render target with 16-bits per channel is required (SurfaceFormat.Rgba64)
float n = tex2D(Texture1Sampler, input.TextureCoordinates.xy).r;

// If no transparent pixel has been drawn at this location, return the background colour
if (n == 0.0)
{
    output.Colour = BackgroundColour;

    return output;
}

SumColour = Upscale(SumColour);
n = Upscale(n);

// Average colour 'C'
float3 AvgColour = SumColour.rgb / SumColour.a;

// Average alpha based on depth complexity 'A'
float AvgAlpha = SumColour.a / n;

// T = (1 - A) ^ n
float T = pow(abs(1.0 - AvgAlpha), n);

// [Weighted Average Formula]
// • Cdst = (C * A * (1 - (1 - A)^n) / A) + Cbg * (1 - A)^n
// • Cdst = (C * A * (1 - T) / A) + Cbg * T
// • Cdst = C * (1 - T) + Cbg * T;
output.Colour.rgb = AvgColour * (1 - T);
output.Colour.rgb += BackgroundColour.rgb * T;
output.Colour.a = 1;

return output;
}

The problem is that all transparent objects are never obscured by the opaque objects drawn before hand as denoted by the yellow circle in the following picture:

The depth test has to be disabled for the transparent objects but it is enabled for the opaque.

Why is this incorrect effect occurring?


texts:
I have a scene with a massive terrain.  It took a long time to load (approximately 60 seconds) when I pressed play. I am in the editor.

I prefabbed it.

Now it only took about 5 seconds to load when I pressed play.  Why?

My best guess is that there is some preloading done when it is prefabbed, but it only takes a few seconds to prefab it.  So that couldn't be the reason.  Any ideas?  I am at a loss.


texts: How do you manage versioning across platforms in Unity?

texts:
I'm just beginning to look into versioning games in Unity and noticed that Unity seems to offer different things depending on the platform you are building for. For instance, Android and iOS seem to have their own individual properties for versioning while Desktop has no versioning functionality at all out of the box.

Since I'm working on a game that has builds for PC, Mac, Android, and iOS, I need to determine how we want to manage version numbers within our game without having to manually manage individual version for each platform. How do you solve this?


texts:
I have a simple orthographic projection that is rotated at an arbitrary angle on any combination of the three axes.  I am trying to use these matrices to calculate the viewable area of the screen for clipping purposes.

All of the examples I can find are old, use one game engine or another, mostly deal with perspective projection (and seem more complex than they need to be for orthographic projection), just plain don't work, or I am not understanding the calculations enough to plug in my own values and get the answer I am looking for.

I aim not only to get a functional (and relatively fast) way to achieve my goal, but hopefully understand the why and how in the process.

Does anyone here know how to calculate these values given the projection/view/model matrices?

I work with OpenGL, in C++, using glm for matrix calculations.

Update #1

I realize my original post might not be clear enough so I will try and clarify a bit.

Imagine I had an ortho projection like: glm::ortho(0.0f, 2.0f, 0.0f , 1.0f, -10.0f, 10.0f);

Given no rotation or other translation of any kind, then the information I am looking for would coincide exactly with the values I put into the ortho.  Taking the X axis as an example, I want to know that the first visible X coordinate is 0.0 and the last visible X coordinate is 2.0.  If I were to translate this by 0.5 on the X axis, then the values would be 0.5 and 2.5 respectively.

Now if I rotated the view by 90 degrees, then the first visible X would be 0.0 and the last visible X would be 1.0 (obviously depending on the rotation origin), because it can now only display what it can fit on the vertical screen area.

Given any arbitrary rotation, scaling or translation (on any axis) how would I get that information (and the same for Y and Z)?


texts: Include deprecated OpenGl "immediate mode" context in OpenGl 4?

texts:
I'm working on an app that uses immediate mode in all of it's draw routines and I'd like to keep those functions intact when updating our graphics drivers to OpenGl 4.

My intention is to get the app functioning on 4.x and then convert the code to use VBOs.

I've read there's a way to load a more "full" context that includes deprecated libraries but I have not found an actual implementation to base mine off of.


texts: How do you do very simple texturing in OpenGL 3+?

texts: I managed to create a sphere (calculating all the vertices etc etc). Now I want to apply a texture on it. I have no idea how. I googled some "OpenGL 3 texture tutorials" but I can't seem to find anything simple. I am using shaders btw. Is there anywhere a very basic step by step tutorial on how to implement a texture? A texture is just an image that wraps around a shape right? Sounds simple, but from what I have seen on the web it's kinda complicated.


texts: How do I create a laser pointer dot in Unity URP?

texts:
I want to replicate the laser pointer dot as in RE4:

Here is a video that shows the laser in action.
I have tried to replicate it using a spotlight. The problem with the spotlight is that its size can only be controlled by its distance to the object. I'm struggeling really hard with keeping it at just the right distance.
Since this is such a big problem, I would first of all like to ask if a spotlight is the preferred way to create such a laser dot.
Thank you.


texts: Does projection take place before clipping in the rendering pipeline?

texts:
At first I thought clipping happens before projection since new vertices may be added and the output of projection is in NDC which is 2D.
However after a lot of googling, I found that some articles/presentations/images indicate that projection takes place before clipping which contradicting with other articles I've read and my initial thoughts.

Could anyone tell me which one is correct and why?


texts: Why can't I rotate anything to be "more than 360 degrees or less than 0 degrees"?

texts:
I've been trying to make an animation in Unity, but most assets already come bundled with everything facing at 0 degrees, not to say it's a bad thing.
However, the problem I'm facing is that the animation keyframes aren't playing out correctly.
When this is done with raw measurements (simply dragging the XYZ rotations), negative and greater than 360 degree angles are taken account. But then again - Unity could be simply remapping them, whcih is not the case.
For example, the prop_robotArm prefab, found within Unity's Robot Factory asset pack has a rotator script that simply rotates the whole thing along the Y axis.

void OnFixedUpdate()
{
    transform.Rotate (new Vector3(0, rotateSpeed*Time.deltaTime,0));
}

Meaning that after slightly more than a full revolution, the Y rotation value should be more than 360 degrees, which it does end up becoming... Eventually.

Thinking that was possible, I tried to mimic this behavior by making the arm rotate 720 degrees (twice) in an animation file (this is not using the rotator.cs script attached to the body in the example above).
Instead, all I ended up was the arm's body staying still as 720 is the same as... 0 degrees in rotation changes.
So, I tried a second experiment; trying to rotate from 359 degrees to 1 degree (or -1 to 1 degree).
Just like above, it didn't go to plan. When the animation is run, it simply runs from 359, through every angle in-between before reaching 1, instead of 359, 360 (0) and 361 (1).
If you don't get what I mean, see the diagram below.

So, I was wondering, is there a way to allow for such rotation to be defined in an animation curve?
Every time I try doing it, any value greater than 360 (or lesser than 0) is replaced by its co-terminal counterpart that's between 0 and 359.999999...999.


texts: How do I create a maze without drawing each individual line or using sprites?

texts:
I am currently trying to create a maze game by following some online tutorials, and putting my own spin on them. I found a pretty good tutorial at pythonspot.com, but I am not sure what some of the code means, and if I have to use images and sprites to create this maze.

The piece that is confusing me is this:

class Maze:
    def __init__(self):
       self.M = 10
       self.N = 8
       self.maze = [ 1,1,1,1,1,1,1,1,1,1,
                     1,0,0,0,0,0,0,0,0,1,
                     1,0,0,0,0,0,0,0,0,1,
                     1,0,1,1,1,1,1,1,0,1,
                     1,0,1,0,0,0,0,0,0,1,
                     1,0,1,0,1,1,1,1,0,1,
                     1,0,0,0,0,0,0,0,0,1,
                     1,1,1,1,1,1,1,1,1,1,]

    def draw(self,display_surf,image_surf):
       bx = 0
       by = 0
       for i in range(0,self.M*self.N):
            if self.maze[ bx + (by*self.M) ] == 1:
               display_surf.blit(image_surf,( bx * 44 , by * 44))

           bx = bx + 1
           if bx &gt; self.M-1:
               bx = 0
               by = by + 1

I know that you can make a maze with 1s and 0s to print to the screen, and this is easier for me to make levels with, because I can visualize them in the 1s and 0s.

Do I have to use images like the tutorial is (display_surf.blit(image_surf)), or can I use pygame.draw to create a square for use multiple times as a wall?

I was also wondering what the self.M,  self.N, bx and by variables do

I have tried looking at other mazes, on the Internet, but they tend to either draw all of the walls as lines in individual draw statements without using 1s and 0s, or they use sprites to create the player and walls. This leads me to believe that I have to use sprites for this drawing method, but I thought I would check here to make sure. I would ask the creator of the tutorial, but I can not create an account for the website, and can not ask questions or leave comments without an account.


texts: Why ImGui not rendering image correctly in my game ui

texts:
[Scene:]

I am working on a game project.In a part of my project,I have to do following things.

1.Read a image

2.Detect face(I am using opencv)

3.view in my imgui window using ImGUi::image()

I already have abstracted my texture object working fail~safe(without any runtime error).I also abstracted a class integerating use of opencv.That part is also fail~safe.

Opencv reads imagefile and detects face and return its unsigned char*(format demanded by opengl)which later fed to my texture object..creating Opengl texture

ImGui requires opengl texture id to render an image using ImGui::image()function..After all my texture is ready,so no problem in calling the function

[Problem:]

I tried drawing two different image

1.Whole image(512x512)

2.The facial part of Whole image(173x173)

Whole image is rendered quite well.but when i render facial part image seems to shear or say disort..why?i mean it is not rendered correctly...

This the first part i did...I read lena.jpg and rendered whole image in imgui window...this was the result

And then in second part i detected face using opencv and fed to gl texture the face ROI and rendered the image.But result was this

both imageg are square matrix..one is rendered well while other is not..How shall i fix this


texts: Drawing sprites to the screen in 65816 Assembly

texts:
I am trying to create a SNES game in assembly on the WLA-65816 assembler. However, I can't quite figure out how to draw sprites to the screen or figure out what software to use. At the minute, whenever I have scoured the internet for answers, I have only got results for a different compiler which uses different syntax to the one I am using. It would be really useful to have some code like a subroutine or something for drawing sprites.

Thankyou in advance.


texts:
Anybody wrote games for Android TV using LibGDX?

What is the mapping of the remote control?

Can we use the game controller with LibGDX?

Thanks!


texts: How to develop VR PC games without a Head-Mounted Display of my own?

texts:
I am an intermediate student of Unity 3D, and I am not able to purchase heavy and expensive equipment like Oculus Rift, HTC Vive, or other models that are not available in Pakistan.

So I'm wondering how I can develop VR games without these peripherals.


texts: Hi,how can I flip x a collider when the Sprite renderer rotates?

texts: I have been making a 2d platform game in unity.My main character has a box collider but when he rotates, the box dont rotates with him. Thanks!


texts: How do I move/select menu options through UI joystick and buttons?

texts:
I have a working Menu system in my game. I am able to move across the menu using Up/Down arrow keys and select those options using the enter key. The problem is how do i get that arrow key functionality to a UI joystick and enter key functionality to a UI button that I have.

Any help would be greatly appreciated. Thank you in advance. Let me know if you need any more details, happy to provide videos of the problem, code, or the entire project if need be.


texts:
I am modifying an old water shader for the game "MTA San Andreas" (the multiplayer modification). MTA uses HLSL and comes with some builtin predefined variables and functions. The water shader itself is already modified by me, but now I want to add shore fading to it. Objects slightly below water surface should be visible, but objects deeper in the water should be completely invisible and that effect should be configurable. I found a water shader that has shore fading included, but it was covered within very complex other things in a very large file. I managed to extract most of the necessary information (i think) but I get an error message in the game:
Invalid PS 3_0 input semantic "POSITION" in water.fx 139,23
I know that this line 138 has no errors and the only reason why the game throws this error is actually line 268... Debugging HLSL is a pain, horrible language. And there may be much more wrong stuff. This is the water shader:

https://pastebin.com/VDFxS7RX

I started my modifications in line 268, where objdepth seems to be "wrong" and causes the compile error:

float objdepth = input.position.z/input.position.w;
float nonlinearobjdepth = objdepth;
objdepth = 1.0/max(1.0-objdepth, 0.000000001);
float planardepth = tex2D(SamplerDepth, input.textureCoords.xy).r;
float depth = tex2D(SamplerDepth, input.textureCoords.xy).r;
if (nonlinearobjdepth>depth)
{
    depth = planardepth;
}

float scenedepth = depth;
      planardepth = 1.0/max(1.0-planardepth,0.000000001);
      depth = 1.0/max(1.0-depth,0.000000001);
float depthfact = (depth-objdepth)*WaterParameters1.z;
      depthfact = depthfact*WaterParameters1.x;
      depthfact = depthfact/(depthfact*0.50+1.0);
if (scenedepth>0.99999) depthfact = 1.0;
float backside = saturate(WaterParameters1.w*10.0);
      depthfact*= 1.0-backside;
float shorefade = (planardepth-objdepth);
      shorefade = shorefade*WaterParameters1.x;
      shorefade = saturate(13.40*shorefade*1000.0 - 0.05);
      depthfact*= shorefade;
finalColor.a *= shorefade;

return finalColor;


texts: What is the difference between an impulse and a force related to a physics engine?

texts: What is the difference between an application of an impulse and an application of a force in relation to a physics engine?


texts: Any reason not to combine an AO Map and Cavity Map into one texture?

texts:
If an Ambient Occlusion Map is for mapping shadows based on closeness of neighboring geometry, and a Cavity Map is for mapping smaller shadows based on angle or distance, then is there any reason not to mix these into one unified shadow map? It seems desirable to do so for saving a game from having to load extra textures, but I ask in case I'm overlooking something.

This article gives an overview of the differences between the two types of maps, but it never mentions combining them. This made me wonder if there was some reason to keep them as separate images.

Thanks in advance for any insight.


texts: 2D mouse coordinates from 3d object projection

texts:
Not entirely certain of the nomenclature here -- basically, after placing a model in world coordinates and setting up a 3D camera to look at it the model has been projected onto the screen in a 2D fashion.

What I'd like to do is determine if the mouse is inside the projected view of the model.

Is there a way to "unproject" in the XNA framework?  Or what is this process called as, so that I can better search for it?


texts:
I am currently working on creating a board-game together with some friends of mine. The game is focussed on gathering resources around the map and buying stronger items with the money you can get by selling said resources.

To make the game a bit more interesting for multiple players, so that they don't just play their own game by themselves, we want to implement a combat system that can help players to get resources from other players by fighting them. This fight should be able to have 3 possible outcomes:

The player that challenged the other player wins:
In this case the winning player is able to select one resource from the losing player.
The player that challenged the other player loses:
Same as above.
Draw, both players 'lose':
Nothing happens.

As you can see this is not too complicated so far, but we are stuck at finding a way to make this combat system more than just "I have the better weapon, I can win against all of you".

Every player has 2 combat item slots, for weapon and armor, each posessing an ATK and a DEF value, representing the items attack and defence.

The way we are currently determining which player wins is by following this procedure:

We compare the total ATK value of the attacking player with the total DEF value of the player being attacked. If it is higher, the attacking player wins.
If that is not the case, the total ATK value of the player that was attacked beforehand is compared to the total DEF value of the player that attacked before. If it is higher, the player that was challenged to the fight wins.
If none of the upper cases are met, the battle results in a draw.

Our problem is that when we tested the game with a few people, fights were almost not used, because the players were still primarily focusing on gathering their resources.

In a game of 30 turns and 4 players we had a total of 5 battles, 3 of them by the player that got a strong weapon at the start of the game by luck and won every fight easily.

After the game, we asked the players why they were not using the fighting mechanic, since it is supposed to put you ahead and the other players behind. They answered that they couldn't keep track of whether the player they would have challenged would be stronger than them or not, which was too great of a risk for them.

Is this combat system basically designed badly, or is there a way to improve it slightly to make it more appealing for the players?


texts: Changing game object type: reinstantiating the object, or switching an object state

texts:
I work on a strategy game, where the player occasionally has to transform ordinary citizens into the so called "leaders". Leaders are temporary units, which the player can control directly, in order to interact with the other citizens. After some time, the leader gets transformed back to a normal citizen.

My question is if I should stick to the classical OOP approach of keeping citizens and leaders in two separate classes, whereas the leader class extends the citizen class, and every time when I need a leader, I simply re-instantiate the current citizen instance.

I personally dislike this approach, however. I already have a state machine implemented, and am more likely to keep only the citizen class (or rather, human class). Rather, I'd like to keep the citizen/leader separation into two different states. When I need one or the other type, I simply switch the current state.


texts: Algorithm to detect impossible scenarios

texts:
I'm making a simple game where a surface is split up into 4 parts, rows, obstacles spawn in them, and a player tries to dodge them.

Up to 3 obstacles are generated in each row, and this can lead to some impossible scenarios such as:

And

What would be the best way to implement an algorithm to check if it is possible to get through or not?


texts: Unity raycast misses convex mesh collider

texts:
I have a bunch of fighter AIs that are doing attack runs on a target (Currently just a cylinder).

It is designed to veer off course the moment it gets too close and loop around for another attack run. Using a raycast, I raycast ahead 5 units and do obstacle avoidance.

Using a sphere/capsule collider for the cylinder, I get good results. The fighters veer off course and doesnt collide with the cylinder.

However, the moment I switch over to a mesh collider, they start veering off course late. Moreover, there is also a delay before the ships realise that they are within weapons range. (Also a raycast)

Each of the white gizmos are a collision point detected by a trigger collider


texts: Everything after the yield return new wait for seconds is not runnung Unity

texts:
I am trying to add a delay to the respawn of my player. But when I add the yield return new line nothing runs after it. I have tried addiing debug.log after everyline and they stop out putting once they get to the yield return new line. This respawn is on the player on its own script and there is no other script that would effect the player respawn. The game is also 2D. Here is the code

public GameObject spawnPoint;
public float respawnDelay = 2;

public IEnumerator RespawnPlayer()
{
    gameObject.SetActive(false);
    gameObject.transform.position = spawnPoint.transform.position;
    yield return new WaitForSeconds(respawnDelay);
    gameObject.SetActive(true);

}

void OnCollisionEnter2D(Collision2D other)
{
    if (other.gameObject.tag == "Enemy")
    {
        StartCoroutine(RespawnPlayer());
    }
}

Thanks!


texts: Scaling of a bone is working while rotation is not Unity3d

texts:
I'm using Unity3d and I'm trying to rotate the left leg bone of an avatar but it is not working although scaling is working well.

This is the code used for scaling and is working perfect:

 r.localScale += new Vector3( 0.1f , 0.1f , 0.1f);

and these are my attempts to is the code of rotation but not working:

 r.eulerAngles = new Vector3(10, 10, 10);
 r.rotation = transform.rotation * r.rotation;

where r is the transform of the left leg.

EDIT:

This is my file.

So this doesn't work when I'm using the Update function, like nothing happens to the avatar.
If I used LateUpdate function, I can see the rotation made but then flickers back to the old position, I wonder how to apply the rotation to all the remaining frames as well.

If anyone could please advise


texts:
Suppose I design a game such as Battle of Wesnoth, where there are many races, each of which with many types of units.
Is there any rule-of-thumb for determining how much each unit should cost?

One obvious rule is that weaker units should be cheaper, otherwise no-one would like to buy them. But how much cheaper should they be?

As an example from the above link, is there any formula by which I could decide that "vampire bat" (based on its HP and damage properties) should cost 13 while "blood bat" should cost 21?
Or is it just a guess that is validated by extensive playtesting?

EDIT: To make the question more focused, let's assume for simplicity that the units in Wesnoth differ by only two stats: health points ($h$) and damage points ($d$), and all their other stats are equal. Is there a way to calculate a formula to determine the cost as a function of $h$ and $d$?


texts: How to give depth to a top-down shooter?

texts:
I'm working on a top-down shooter kind of game, but it lacks the feeling of depth.

When you have a sun, it's a bit easier, because the sun can cast shadows. But it's even harder, when there is no sun, like underground.

How do you simulate an ambient occlusion kind of thing? I think that's what it lacks, but maybe I'm wrong.

(And this could be also applied to levels with sun as well, further enhancing the feel)

Example: I have floors and walls, but even if the walls would be a bit thicker, it would lack depth. How could I fix this? I.e. rendering small shadows at floors' edges which are neighbouring walls?


texts: How can I merge multiple sprite into one sprite or texture using Unity3d?

texts:
I have an avatar generator where someone can create a custom avatar with layers superimposed.
And in order to reuse this image multiple times, i want to merge all layers in one image.
Is there any way on unity3D to create this image.

I've already coded that :

atlas = new Texture2D (width, height, TextureFormat.RGBA32, false);
foreach (Sprite s in allSprite) {
        atlas.SetPixels (0, 0, atlas.width, atlas.height, s.texture.GetPixels (0, 0, atlas.width, atlas.height));
        atlas.Apply ();
}

My problem is to keep the transparency and not erase old layers where pixels are transparent.
The setPixels method replace old pixels in atlas by new one.
I can't loop over pixels because of the size of the image (1024*1024) and more than 6 layers.


texts: Directory.CreateDirectory() created a folder with name that was supposed to be a file

texts:
i am experiencing some problem here , i have a path :

"/folder/folderagain/file.xml"

i tried to use Directory.CreateDirectory() to create all folder (in case one of them is missing) and then reuse the path to create a file in another place inside the script. But instead a folder named "file.xml" was created by Directory.CreateDirectory() and my script got blocked from creating the file .

I managed to solve this problem by creating 2 different path , one of them end with file.xml and the other does not. But is there any better way to do it ? can i tell Directory.CreateDirectory() to create only folder ??

look at screenshot below , there's System.UnautorizedAccessException error because my script trying to create file named "keymap.xml" but a folder with the exact name already exist so it thrown that error .


texts:
I am making a Tetris clone. Is there any way that I can avoid using a 2D array for storing a Tetris block?

EDIT: Suppose I have an array to store an L-shaped piece:

1 0
1 0
1 1

But for the sake of rotation, I do that shape as this:

0 1 0 0
0 1 0 0
0 1 1 0
0 0 0 0

I can do this in either objects or arrays. If I use objects then create four objects for each "square", and I can store the position of each square, and rotate it about the piece's center. But I am finding a better way to optimally perform a rotation on the piece. I believe rotating this array 90 degrees would take O(n^2) time. I try to avoid making rotated copies, and instead rotated on the fly. What algorithm or approach should I use?


texts:
I am currently working on a little OpenGL project.
At the moment I am trying to find a good solution for rendering multiple objects.
I have set up a terrain with its own buffers, which works just fine.
Now I am at a stages where I want to fill this terrain with game-objects (tree, rock, ...)
I already programmed the .obj loader for 3D models.
But now the question:
Is it good to have for each game-object its own buffers(vertices-buffer, indices-buffer, ...) and enable these each draw-call ?
For me it seems a bit weird having like 100+ buffers in the v-ram and enable these after each other.
Is this the way buffer should be used? Or should I combine these (small) buffer to a few (big) ones ?


texts:
So I have a very simple scene set up with just a camera, a game object called TestGrid with a grid script, and then a canvas. I have a TextMeshPro prefab that I instantiate to fill the 10 x 20 grid with cells.
If I build and run the game, I see all the cells on my screen. However, in the editor play view, I can only see as many grid cell as would fit on startup. Making the game view smaller or larger will scale the ones already there, but everything that didn't fit initially is "clipped" out. The "canvas" is in the bottom left corner of the "grid"

I'll share my code as well:
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Diagnostics;

public class TestGrid : MonoBehaviour {
  private float _cellSize = 50.0f;

  [SerializeField]
  private float _width = 0.0f;

  [SerializeField]
  private float _height = 0.0f;

  [SerializeField] private TextMeshProUGUI labelPrefab;

  // Start is called before the first frame update
  private void Start() {
    if (labelPrefab == null) {
      Debug.LogError("You must set a label prefab.");
      return;
    }

    GameObject canvas = GameObject.Find("labelCanvas");
    if (canvas == null) {
      Debug.Log("Unable to find canvas");
      return;
    }

    // This is just a 2D array of ints.
    Grid grid = new Grid((int)_width, (int)_height);
    var canvasRect = canvas.GetComponent<RectTransform>().rect;
    _cellSize = Math.Min((canvasRect.width / _width), (canvasRect.height / _height));

    for (int x = 0; x < grid.Data.GetLength(0); ++x) {
      for (int y = 0; y < grid.Data.GetLength(1); ++y) {
        SpawnLabel(new Vector3(x, y, 0), canvas, grid.Data[x, y].ToString());

        // TODO: Replace this with LineRenderer
        Debug.DrawLine(GetWorldPosition(new Vector3(x, y)), GetWorldPosition(new Vector3(x, y + 1)), Color.white, 100f);
        Debug.DrawLine(GetWorldPosition(new Vector3(x, y)), GetWorldPosition(new Vector3(x + 1, y)), Color.white, 100f);
      }
      Debug.DrawLine(GetWorldPosition(new Vector3(0f, _height)), GetWorldPosition(new Vector3(_width, _height)), Color.white, 100f);
      Debug.DrawLine(GetWorldPosition(new Vector3(_width, 0f)), GetWorldPosition(new Vector3(_width, _height)), Color.white, 100f);
    }
  }

  void Update() {
    // NYI
  }

  private void SpawnLabel(Vector3 localPos, GameObject canvas, string text) {
    float x = localPos.x;
    float y = localPos.y;
    var world = GetWorldPosition(new Vector3(x, y, 0)) + new Vector3(_cellSize, _cellSize) * .5f;
    var label = Instantiate(labelPrefab,
      world,
      Quaternion.identity, canvas.transform);
    label.text = text;
    label.fontSize = 100;
    label.autoSizeTextContainer = true;
  }

  private Vector3 GetWorldPosition(Vector3 local) {
    return local * _cellSize;
  }

}

Additional images of environment:

I'm actually not too sure what is going on here, so here is everything I know:

I'm parenting my TextMeshPro prefab transform to the canvas transform, so that it scales properly
My Canvas Scalar is set to reference resolution of 2560 x 1440, with a RPPU of 108
Canvas Scalar is also set to Scale With Screen Size
Canvas Screen Space is set to Overlay

I've also read the following links with no luck:
https://stackoverflow.com/questions/32347009/unity-canvas-does-not-fill-screen
https://answers.unity.com/questions/943190/ui-panel-not-covering-whole-screen.html
https://answers.unity.com/questions/1331722/ui-scaling-issues.html
Expected Results:
No matter what the screen size is, I should see my full 10 x 20 grid of "cells" (in play view they're just 0's).
Question:
If my canvas is supposed to scale with screen size, why is it that when I choose a cell size calculated from the canvas size, that it thinks the canvas is 2560 x 1440 when the screen size is clearly much smaller than that?
Do I need to calculate with a different value? Must I dynamically resize everything I draw within the canvas? What's going on here?


texts: why my shader is black in the game mode?

texts:
I used this useful blending modes It's good but it just work in Editor mode.
what is the problem?!

Shader "CodeCorsair/BlendModesFX"
{
    Properties
    {
        _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}

        // This here gives hints to the shader to do pixel-time tricks
        _BlendMode("BlendMode", Range(0, 16)) = 0 // 0 is standard blend

        [HideInInspector] _BlendOp1("__op1", Float) = 0.0
        [HideInInspector] _BlendSrc1("__src1", Float) = 1.0
        [HideInInspector] _BlendDst1("__dst1", Float) = 0.0
        [HideInInspector] _BlendSrcAlpha1("__src_alpha1", Float) = 1.0
        [HideInInspector] _BlendDstAlpha1("__dst_alpha1", Float) = 0.0
    }

    SubShader
    {

    //  Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
    //ZWrite Off Lighting Off Cull Off Fog{ Mode Off }
    //LOD 110
        Pass
        {
            BlendOp[_BlendOp1]
            Blend[_BlendSrc1][_BlendDst1],[_BlendSrcAlpha1][_BlendDstAlpha1]

            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma fragmentoption ARB_precision_hint_fastest
            #include "UnityCG.cginc"

            sampler2D _MainTex;
            float _BlendMode;

            struct vin
            {
                float4 vertex : POSITION;
                float2 texcoord : TEXCOORD0;
                float4 color : COLOR;
            };

            struct v2f
            {
                float4 vertex : POSITION;
                float2 texcoord : TEXCOORD0;
                float4 color : COLOR;
            };

            v2f vert(vin v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.texcoord = v.texcoord;
                o.color = v.color;
                return o;
            }

            fixed4 frag(v2f i) : COLOR
            {
                float4 color = tex2D(_MainTex, i.texcoord);
                color.rgb = 1.0 - (1.0 / max(0.001, color.rgb * color.a + 1.0 - color.a)); // max to avoid infinity

                return color;
            }

            ENDCG
        }
    }
}

when I used Transparent Queue I had this result:


texts: Is there a design flaw when an entity's state doesn't fully utilize enter(), execute() and exit()?

texts: I'm following Mat Buckland's Programming Game AI by Example, and I find that I don't always have use for enter(), execute() and exit() on an entity's state. For example, in an RPG, a weapon may have an equipped state, and I may use enter() and exit() for that state to add or subtract to a player's ability modifier, but there isn't really a need for execute(). Is this a design flaw in my engine, or a shortcoming of this approach?


texts: Choosing a data structure for a group of static (almost) thousands of objects on HTML5 canvas

texts:
I have this requirement to implement a data structure for a group of thousands of displayable objects, on HTML5 canvas. Something like a particle system. The objects are randomly spread on the map. They have different colors and sizes. Each of them can be removed and I can also add more objects onto the map. These objects may move around a little bit but just one or two pixels. But on any specific (x,y) position there can be only one object.

So we can say that these are static objects. To render this group of objects and make changes to them I have used a particle system and put all the objects in an array. It works but the performance isn't good especially if I perform some operations on the objects. I find that each time I need to find or remove a particular object at a specific location I have to loop through the entire array, which is not very efficient.

Now my question is, can I put the objects into an object and use their position on the map as the key, and the object itself as the value? This way it works more like a hashmap or dictionary. So each time I want to get an object based on its location I can complete that operation in O(1) time. Removing any of the objects is also very easy too. When adding new object I just need to check if the location is occupied otherwise I put the new object in a new position. This way looks so good I want to implement it right away. In ES6 javascript maybe I will put them into Map or WeakMap. But before I do that I want to know if there is any drawback for this method or is it even a good option for this situation? I am also gonna implement this on the game server and transmit the data through network. I wonder if this method has any negative effect on networking?


texts:
I am trying to draw point sprites in OpenGL with a shader but gl_PointCoord is always zero.

Here is my code

Setup:

//Shader creation..(includes glBindAttribLocation(program, ATTRIB_P, "p");)
glEnableVertexAttribArray(ATTRIB_P);

In the rendering loop:

glUseProgram(shader_particles);
float vertices[]={0.0f,0.0f,0.0f};
glEnable(GL_TEXTURE_2D);
glEnable(GL_POINT_SPRITE);
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
//glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);(tried with this on/off, doesn't work)
glVertexAttribPointer(ATTRIB_P, 3, GL_FLOAT, GL_FALSE, 0, vertices);
glDrawArrays(GL_POINTS, 0, 1);

Vertex Shader:

attribute highp vec4 p;
void main() {
  gl_PointSize = 40.0f;
  gl_Position = p;
}

Fragment Shader:

void main() {
 gl_FragColor = vec4(gl_PointCoord.st, 0, 1);//if the coords range from 0-1, this should draw a square with black,red,green,yellow corners
}

But this only draws a black square with a size of 40.
What am I doing wrong?

Edit: Point sprites work when i use the fixed function, but I need to use shaders because in the end the code will be for opengl es 2.0

glUseProgram(0);
glEnable(GL_TEXTURE_2D);
glEnable(GL_POINT_SPRITE);
glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
glPointSize(40);
glBegin(GL_POINTS);
glVertex3f(0.0f,0.0f,0.0f);
glEnd();

Is anyone able to get point sprites working with shader? If so, please share some code.


texts: Unity Google VR SDK Main Camera showing Game Objects Behind Left and Right Cameras

texts: I'm trying to get a basic VR app up and running on iOS with the Unity Google VR SDK and I've run into a strange issue where my game objects are appearing behind the left and right camera views in cardboard view. In the HeadsetDemo app that is provided along with the SDK, there's just a black background but in my app that background is the default grey-blue skybox color and renders any game objects that I have in my scene. Does anyone know how to hide game objects from that main camera?


texts: I understand that Opengl directly cannot load BSP files. How would I go about loading them into my Android game?


texts:
I can easily add listeners to the actors within a table, and they will fire events, but if I want an entire to table to have 1 listener and do not care to have differentiated effects depending on where it is touched, I want to be able to add the listener directly to the table. However, it is not firing, at all. I have turned on debug and tried pressing within the labels in the table or outside of them (still in the table, like on padding), but to no avail.

This is how I add the create the table:

il = new InfoListener();// extends ClickListener
info = new Table(skin);
info.setBackground("default-rect");
info.setVisible(false);
info.addListener(il);
info.setDebug(true);

// later on I have a method that adds things to the table
info.clear();
info.add(item.getDescription()).padRight(5);

info.setVisible(true);
info.setSize(info.getPrefWidth(), info.getPrefHeight());

It is a dynamic table (i.e. I change it's children when necessary), but that shouldn't make a difference. How do I have the table fire touch events?


texts: What is the purpose for drawing vertices and shapes in OpenGL (or DX), if a game is using sprites?

texts:
Something I do not understand.  All the tutorials on OpenGL, DirectX, or other, always show you how to draw a shape and then change its vertices, move it around and so on.  But all the games I know of, tutorials on creating, etc., always have sprites and sprites alone.

What is the reason for drawing triangles and squares for games?  I never see it used, only pre-made graphics.

edit:  based upon answers so far, is the purpose of drawing shapes to "bound" a sprite?  So if I have a character, on a platformer like Mario, Mario has a shape around him and that shape's location is used to detect collisions, etc.?

edit:  Maybe a small example?


texts:
I'm working on a 2d java game on Slick engine and I always wondered how to make swing effects when striking with a sword? How to code something like this what's in the game Hollow Fear? Example from YouTube here.

(Image source)


texts: Space invader barrier implementation algorithm

texts:
I've been struggling with implementing the space invader bullet to barriers. I wanted right now to blast a circle around, when the bullet hits the barrier and modifies the circle. As shown in the video, the algorithm looks wrong, http://youtu.be/VMBczCsP3J4
I have tried my best to debug it, but I've failed.

here is the algorithm:

// if there is intersection
    if (IntersectsWith((*it)->BoundingRect, barrierRect))
    {
        // subtract (*it) bullet position from barrrier's rect
        int normX = (*it)->Position.x - barrierRect.x;
        int normY = (*it)->Position.y - barrierRect.y;

        // barrier image pixels
        uint32* ptr = (uint32*)pixels;
        // height of the barrier
        int y = 31;

        for (int i = 0; i < 31; i++)
        {
            int pixelOffset = y + normX * 51;
            int color = ptr[pixelOffset];
            // look up the color if its not black, it should be green
            if (color != 0xFF000000)
            {
                // delete the bullet
                Bullet *bullet = *it;
                it = ship->Bullets->erase(it);
                delete bullet;
                ship->Canfire = true;
                isCollision = true;

                // blast a circle around that bullet hit position
                int radius = 9;
                for (int y = -radius; y <= radius; y++)
                {
                    for (int x = -radius; x <= radius; x++)
                    {
                        if (x*x + y*y <= radius*radius)
                        {
                            int j = x + normX;
                            int i = y + normY;
                            int pixelOffset = j + i * 51;
                            ptr[pixelOffset] = 0xff000000;
                        }
                    }
                }
                break;
            }
            // go up
            y--;
        }


texts: Where should I put code if I want it to run automatically?

texts: I'm new to programming and I found an animation script that has code that is called in the OnMouseDown event, when the user clicks the object. I'd like the code to run automatically, instead of responding to an event. Where can I put code to be called automatically


texts:
I came across an asset with 3 different licenses. The GPL 3.0 license appears to just be a newer version of the GPL 2.0. Can the GPL 2.0 be disregarded if the GPL 3.0 is complied with?

Must all conditions from all 3 licenses be met? For example, the GPL 2.0 mentions printing or displaying an appropriate copyright notice, but this seems to be absent from the CC BY-SA 3.0 license.


texts: How to use AttachComponentToComponent in C++?

texts:
Anyone can explain why using the blueprint is more efficient in this case, I mean when I attach the hairs using blueprint, the hairs is welded with headsocket in editor and in play mode, but with C++ I don't know why only welded when playing the game... but in editor not welded. I can only think about the one thing that from where the BOOL condition comes in the AttachComponentToComponent node, I think this is responsible for this welding.
What I am trying to fix it: CODE:
//this must be in the constructor
     auto Material = ConstructorHelpers::FObjectFinder<UMaterial>(TEXT("parrent material path"));

     void initSkeletalMesh()
     {

         if (Material.Object == nullptr) return;

         //create skin material
         SkinRef = GetMesh()->CreateDynamicMaterialInstance(0, Material.Object, NAME_None);

         GetMesh()->SetMaterialByName("Skin", SkinRef);

         //set master pose
         SKMShoes->SetMasterPoseComponent(GetMesh());

         //attach hair
         SKMHair->AttachTo(GetMesh(),TEXT("Head"), EAttachLocation::KeepWorldPosition, true);
     }


texts:
I'm trying to scale a lot of dynamically created game objects in Unity3D to the bounds of a sphere collider, based on the size of their current mesh. Each object has a different scale and mesh size. Some are bigger than the AABB of the collider, and some are smaller. Here's the script I've written so far:

private void ScaleToCollider(GameObject objectToScale, SphereCollider sphere) {
    var currentScale = objectToScale.transform.localScale;
    var currentSize = objectToScale.GetMeshHierarchyBounds().size;

    var targetSize = (sphere.radius * 2);

    var newScale = new Vector3 {
        x = targetSize * currentScale.x / currentSize.x,
        y = targetSize * currentScale.y / currentSize.y,
        z = targetSize * currentScale.z / currentSize.z
    };

    Debug.Log("{0} Current scale: {1}, targetSize: {2}, currentSize: {3}, newScale: {4}, currentScale.x: {5}, currentSize.x: {6}",
        objectToScale.name, currentScale, targetSize, currentSize, newScale, currentScale.x, currentSize.x);

    //DoorDevice_meshBase                   Current scale: (0.1, 4.0, 3.0), targetSize: 5, currentSize: (2.9, 4.0, 1.1), newScale: (0.2, 5.0, 13.4), currentScale.x: 0.125, currentSize.x: 2.869114
    //RedControlPanelForAirlock_meshBase    Current scale: (1.0, 1.0, 1.0), targetSize: 5, currentSize: (0.0, 0.3, 0.2), newScale: (147.1, 16.7, 25.0), currentScale.x: 1, currentSize.x: 0.03400017

    objectToScale.transform.localScale = newScale;
}

And the supporting extension method:

public static Bounds GetMeshHierarchyBounds(this GameObject go) {
    var bounds = new Bounds(); // Not used, but a struct needs to be instantiated

    if (go.renderer != null) {
        bounds = go.renderer.bounds;
        // Make sure the parent is included
        Debug.Log("Found parent bounds: " + bounds);
        //bounds.Encapsulate(go.renderer.bounds);
    }
    foreach (var c in go.GetComponentsInChildren<MeshRenderer>()) {
        Debug.Log("Found {0} bounds are {1}", c.name, c.bounds);
        if (bounds.size == Vector3.zero) {
            bounds = c.bounds;
        } else {
            bounds.Encapsulate(c.bounds);
        }
    }
    return bounds;
}

After the re-scale, there doesn't seem to be any consistency to the results - some objects with completely uniform scales (x,y,z) seem to resize correctly, but others don't :|

Its one of those things I've been trying to fix for so long I've lost all grasp on any of the logic :| Any help would be appreciated!


texts: Get Particular Object's collision status via C# script

texts:
My current scripts creates and modifys the location of various prefab objects as they go along the screen. One of the things I want to find out about the active object is whether it has collided with another object, and if so, to destroy itself. The problem is that every example I've found to date has no way to access the object itself to get this information.

        if (Random.value > 0.9)
    {
        var bomberInstance = GameObject.Find("bomber");

        var newBombObject = Instantiate(Resources.Load("_prefabs/bomb"), new Vector3(bomberInstance.transform.position.x, bomberInstance.transform.position.y, bomberInstance.transform.position.z), Quaternion.identity) as GameObject;

        bombArray.Add(newBombObject);
    }

    foreach (GameObject bomb in bombArray)
    {

        //get bomb objects collision status here.

        var newBombYAxisPosition = bomb.transform.position.y - .1f;

        bomb.transform.position = new Vector3(bomb.transform.position.x, newBombYAxisPosition, bomb.transform.position.z);

    }

As you can see, the examples you find online don't exactly fit very well for what I need. Do objects in unity store this information, and if so how can it be accessed? And if not, is there another way to access this information?


texts: Calculating aim point to pass through other point

texts:
We know for an object:

Initial point O(x,y)
Initial speed (s_x,s_y)
Constant vector module aceleration (A)
A point P(i,j) where we have to pass through in the future.

We need:

A point W(x, y) so the angle alpha (or only the angle alpha), formed between O and W, can be used to calculate acceleration in both axis:

Ax = A * cos(alpha)

Ay = A * sin(alpha)

so that the object passes through W.

How do I define an elliptic motion system knowing two points of the orbit (and Vo)?

I'll appreciate alternatives to design a guided rocket too.

My attempt for solving this:

Calculate module of initial point O, initial speed So, destination point D. (Aceleration module A is given)
Use these terms to calculate the time we need to arrive to D with the equation:

D = O + So*t + 1/2 A * t^2
Find out the value of alpha from this equation, knowing time:

Dx = Ox + Sox * t + 1/2 A * cos(alpha) * t^2

I tried to implement this, but for some reason it doesn't work. Should this theorically work?


texts:
In a general purpose C++ rendering engine, one way of organizing data is to divide mesh data into two classes: the geometry and the material. The geometry class includes indices, vertices, normals, and texture coordinates. The material class, as established by this answer, is often used to store the shader and uniforms.

Uniforms can be many types, such as an int or a float. So you can't just have one member variable in your material class defined std::vector<GLint> uniforms, as in that case you would only be able to add uniforms of integer type. There are two solutions that I know of:

Adding a vector for each type of data you want to use
In this case the material class would look like the following:

class Material {
  ....
  std::vector<GLint> intUniforms;
  std::vector<GLfloat> floatUniforms;
}

The problem with this is that it is very verbose and would probably require a lot of different functions (for each type) to add and delete uniforms.

Creating a class called Uniform, having a member variable of type any.

class Uniform {
  UniformType type;
  GLuint size;
  any value; // This will be a float/vec2/vec3 ...
}

class Material {
  std::vector<Uniform> uniforms;
}

However, using the 'any' class feels cheaty and seems to break the static typing design pattern used in C++.

My question was, is there another method of storing variable uniform data that supports a set of types without being verbose or using the any class? Or is there a design flaw with this approach and I should organize the Geometry/Shader/Uniform data differently?


texts: What is a fair latency, to cut off game connection at?

texts:
I'm currently coding a realtime game. I'm doing alot of technical operations with the physics world (resimulations of old world states etc.) to prevent game lag. I save the world state every physics update, so I can re simulate it later if needed.

Of course this consumes alot of memory, so I'm trying to decide after what period will I remove old world states. For example, if a world state is 250 milliseconds old, remove it from memory. Then, if any player movements are received from players, that occurred more than 250 milliseconds old, discard them.

This would theoretically discontinue any physics movements of players with a latency of 250+. This is to improve the performance/experience for other players, and to maintain low memory usage.

My question is, what is a fair latency to cut off players at (for the good of other players)?


texts:
I found this link:
Where do I store (or how do I refer to) textures for custom blocks?

Unfortunately, the answer did not explain where that assets folder actually is. As such, I can't figure out where the textures themselves go.

I'm trying to replicate the tutorial on minecraftforge.net, so the mod's ID is "generic". For some reason, though, the assets folders all contain folders called "genericmod".

Basically: Can someone give me the exact path I should go to, starting from forge_1710_src, to put my graphics in?


texts: Loading class instance from XML with Texture2D

texts:
I'm having trouble with XML and XNA. I want to be able to load weapon settings through XML to make my weapons easier to make and to have less code in the actual project file. So I started out making a basic XML document, something to just assign variables with. But no matter what I changed it gave me a new error every time. The code below gives me a "XML element 'Tag' not found", I added  and it started to say the variables weren't found.

What I wanted to do in the XML file as well, was load a texture for the file too. So I created a static class to hold my texture values, then in the Texture tag of my XML document I would set it to that instance too. I think that's were the problems are occuring because that's where the "XML element 'Tag' not found" error is pointing me too.

My XML document:

 <XnaContent>
   <Asset Type="ConversationEngine.Weapon">
    <weaponStrength>0</weaponStrength>
    <damageModifiers>0</damageModifiers>
    <speed>0</speed>
    <magicDefense>0</magicDefense>
    <description>0</description>
    <identifier>0</identifier>
    <weaponTexture>LoadWeaponTextures.ironSword</weaponTexture>
   </Asset>
 </XnaContent>

My Class to load the weapon XML:

public class Weapon
{
    public int weaponStrength;
    public int damageModifiers;
    public int speed;
    public int magicDefense;
    public string description;
    public string identifier;
    public Texture2D weaponTexture;
}

public static class LoadWeaponXML
{
    static Weapon Weapons;

    public static Weapon WeaponLoad(ContentManager content, int id)
    {
        Weapons = content.Load<Weapon>(@"Weapons/" + id);

        return Weapons;
    }
}

public static class LoadWeaponTextures
{
    public static Texture2D ironSword;
    public static void TextureLoad(ContentManager content)
    {
        ironSword = content.Load<Texture2D>("Sword");
    }
}

I'm not entirely sure if you can load textures through XML, but any help would be greatly appreciated.


texts: How to handle enemies outside camera view in 2d platform

texts:
i am making a 2d platformer in unity like mario or adventure island, and i am placing enemies manually(not doing any spawning) in the world, and those enemies have animations and movement scripts with update function.
And now my question is, how can i handle the enemies outside camera view.
I just want that the enemies should update/animate/move only when they come inside the camera view, otherwise they should be fixed where they were manually placed in the world.
Maybe not only enemies but other things like coins, stars, etc(having different animations and scripts)
Should i need to use some collision trigger, like attaching trigger to camera and detecting each enemies entered inside it and enabling animations and scripts on them.
Please tell me if that is an efficient way or if not please tell me if there is any simple and efficient way to do this.
Please correct me if there's anything wrong. Thank you.


texts: How to expose a child node’s texture from the parent in Godot

texts:
I built a simple scene that I instanciate at will.  Simply a KinematicBody2D as root, containing a Sprite and a CollisionShape2D.  There is a script linked to the root node that basically expose a few properties to describe an orbit and make it move in orbit around its parent.  The point being to make a very basic solar system simulation or anything that requires a node to move around another in a circular fashion.

The movement work fine and I’ve been playing around my scene tree, instancing a bunch and watching them move around as moons of planets, etc.  But the texture is all the same.  If I make children editable, I can go change the texture of the sprite, but I’d like to expose that property from the root node so I can access it directly from the editor.

I tried adding an exposed property with a setter and a getter to assign and retrieve the texture, but it seems to crash Godot completely with this code:

export(Texture) onready var texture setget texture_set, texture_get

func texture_set(newtexture):
    $"Sprite".texture = newtexture

func texture_get():
    return $"Sprite".texture

Is there a solution for that?  Or simply another way?


texts: What's the best server architecture for real-time games?

texts:
I'm developing a Real-Time game which should hold thousands of players in real-time (FPS like. max 1s lag). What would be the best infrastructure for this?

My idea was using 2 server clusters - one for the Server End (all the computing side) and one for the Database end, where a load balancer is "responsible" for each of the clusters. One main server will receive the requests from the users and send back the IP address of the relevant server that the user can work this.

The database cluster will use database replication for consistency between the databases.

There should be a geographical load balancer as well - so it will assign the regional load balancer to each user for best response.

I'm using .NET + MSSQL for the game.

Thanks!


texts: Rotating 2D-Projectile towards mouse, hides the projectile (Maybe changes the layer)

texts:
I want to shoot towards my mouse, which is working fine now. After this was solved, I wanted to rotate the projectile, so that it's looking to the mouse. This is my code:

projectile.transform.LookAt (target);

I think this should work, but suddenly my projectile is gone, I can still see the particles behind it but the projectile for itself isn't visible. So I think, that it switched to another layer. Target looks like this:

Vector2 target = Camera.main.ScreenToWorldPoint (new Vector2 (Input.mousePosition.x, Input.mousePosition.y));

So it shouldn't be possible that the z value is wrong am I right?


texts: More than 8 lights without deferred shading / lighting

texts:
I want to know if there is any technique (efficient) to use more than 8 lights in a scene made with OpenGL and GLSL. Without making use of deferred shading / lighting.

I have not implementadon these techniques for their limitations and not being able to use transparency or antialiasing.

If there is a good alternative, describe it with an example.

I use OpenGL 2.0.

Thank you.


texts: Implementing a multilanguage AI contest platform

texts:
This is a followup to this question. To sum: I'm implementing an AI contest site, where each user may submit several AI implementations for different games. Think about Google AI Challenge
but instead of just having a big event once a year, I would like it more on a league fashion, with all virtual players playing with each other every some close period of time.

I want to support as many programming languages as possible. I've seen that contest sites (like codeforces) ask you to submit a source code and interact through stdin and stdout. The first question is: what is the best way of supporting multiple languages?

As I see it, I can either ask people to upload some binary/script, and interact either through stdin/stdout, or sockets, or the file system; or ask people to submit source code, and wrap it with whatever is necessary for the interaction. I would like to skip the need to compile the code by myself (in the server, I mean), but I am willing to do it if its the "best" choice. I need to comunicate virtual players with each other, or even better, with some intermediary arbiter.

The second question is regarding security. If I'm going to be running user code in my server, I want to ensure strict security conditions, like no file system access, no networking, etc. Otherwise it would be a safe heaven for hackers.

I will be implementing the engine/arbiter in .NET. I would like to support at least C#, C++, Java and Python for the user's implementations. I'm willing to write interfaces for each of these languages to simplify the user interaction with the system.

Thanks in advance.


texts: Difference between CC BY-SA 3.0 and CC BY 3.0

texts:
Comparing CC BY-SA 3.0 and CC BY 3.0, both permits that you share ou even modify the material, under the term that you give credit, link the license and inform in case of any changes.

But in CC BY-SA, if you transform the material, those modifications should be distributed under the same license (or a compatible one, if I got it right). CC BY does not have such a term.

So, what's that mean? If someone got my game under CC BY, can they change it and distribute it under a different license, even a closed-source license?

In the case of CC BY-SA, in the same scenario, this version should be distributed as CC BY-SA as well?


texts:
I am planning a project using Kinect's depth sensoring but I do not have a Kinect yet.

Newest information from Microsoft's website says it can take over 4m, and Wikipedia page says over 6m. What I want is about 20m, is that OK for Kinect? If not what is the bottleneck, SDK or hardware?


texts: Do I still owe Epic royalties if I am not enrolled in the Unreal Engine subscription?

texts:
I have just started using Unreal Engine 4 and I have had a very good experience, though I have left the subscription now.

I've made an Android game with it and I am planning to release it, but I have some doubts about the license. Suppose I post my game on my own website for, say, $%, will I still have to give 5% of my income to Epic? How will they come to know that the game is made in Unreal Engine?

I am very confused in taking this step and I'm not really understanding what they mean by "5% gross revenue."


texts: Clone gameobject on drag without having to click a second time

texts:
I have a standard Cube gameObject (with a BoxCollider and my CubeController.cs script) in my scene and I want to be able to click and drag on it to instantiate a new cube prefab (with a BoxCollider and my DragController.cs script) which then follows the mouse.

I have it nearly working but when the new cube prefab is instantiated at the same position as the clicked cube (but 10% bigger) you have to then click the new instantiated object again to begin dragging it. I have a debug line printing 'Prefab created' in DragController.cs so the prefab must be sensing that the mouse button is still down.

How can I do it so you click the original cube then the new prefab is created and draggable without having to click again?

CubeController.cs - placed on original Cube gameobject

using UnityEngine;

public class CubeController : MonoBehaviour
{
    RaycastHit hitInfo;
    Ray ray;

    public GameObject CubePrefab;
    private bool canCreate = true;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        }

        if (Physics.Raycast(ray, out hitInfo))
        {
            GameObject objectHit = hitInfo.transform.gameObject;

            if (objectHit.tag == "Cube")
            {
                createCubePrefab();
            }
        }
    }

    void createCubePrefab()
    {
        if (canCreate)
        {
            canCreate = false;
            GameObject newCube = Instantiate(CubePrefab, hitInfo.transform.position, Quaternion.identity);
            newCube.transform.localScale = new Vector3(1.1f, 1.1f, 1.1f);
        }
    }
}

DragController.cs - placed on Cube prefab that is going to be instantiated

using UnityEngine;

public class DragController : MonoBehaviour
{
    private Vector3 screenPoint;
    private Vector3 offset;

    // Start is called before the first frame update
    void Start()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Debug.Log("Prefab created");
        }
    }

    void OnMouseDown()
    {
        screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position);
        offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
    }

    void OnMouseDrag()
    {
        Vector3 cursorPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
        Vector3 cursorPosition = Camera.main.ScreenToWorldPoint(cursorPoint) + offset;
        transform.position = cursorPosition;
    }
}


texts: How to disable present function when window is invisible to user. Win32 & DXGI

texts:
When my game window is hidden say by minimising it or hitting Ctrl, Alt, Del. I get the DXGI error:
0x087A0001 : The Present operation was invisible to the user.
I've tried wrapping the present function inside an if statement to check whether the window is visible, this comes from: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-iswindowvisible
And looks like this in my code:
bool Graphics::WindowVisible() const
{
    if (IsWindowVisible(hWnd) == TRUE)
    {
        return true;
    }
    return false;
}

I've created the function in my window object too, and applied it to my EndFrame() call but this doesn't work either.
The function never seems to return false. Any ideas on the best way forward would be gratefully received. If using a check for visibility isn't on the cards, Is there a way to simply disregard the DXGI error and simply throw the frame away and would that be a good idea.


texts: I'm creating a top-down RPG and I have the movement system set up for the player character - it is alike to Pokemon in the movement sense in that it looks smooth but it is aligned to a grid. Since I have the player sorted I was trying to figure out how to use this movement principle for the Enemy AI's Pathfinding but I haven't figured out how to do it; I was wondering if anyone has a possible solution to this.


texts: Detecting collision between a sprite and many tiles

texts:
I have been looking at the following question:- Tile coordinates and am thinking of using this for collision detection in my tile game.

The set up in my game is similar to this, in that there is a grid of tiles, and the sprite will move to (x,y) coordinates. However, if I were to have an object such as a box in my world that is made from multiple tiles, how would I get the collision detection to work?

Any ideas welcome.


texts:
I need help with following pathfinding Task:

I have a grid (7x7 squares) and the starting square is always on the far left side (column 0) and its target is to reach the far right side (column 6).
Between col 1-5 are some walls where the path should "walk" around.

The special thing about the task is, the path can only walk straight,diagonal up, diagonal down, so its column increases += 1 for each movement.

For Example: (row/col)
Start:(1/0)
Path:(1/1) straight
    :(2/2) daigonal down
    :(3/3) diagonal down
    :(3/4) straight
    :(4/5) diagonal down
    :(4/6) straight (reached col 6 , finish)

I'm not sure about A*, maybe its also working for my task?
can anyone help me to find a good algorithm for this task?
I would prefer C++ as code.


texts: Unity Controller to Make Reticle Orbit based on the right stick input

texts:
d platformer arena like game. Right now I have it so a reticle moves around the player based on a controller's right stick's horizontal movement using the rotate around function and while it works great on keyboard on it is funky on controllers since you have to hold it left to rotate counter clockwise and right to make it rotate clockwise. I've been working on changing this for well over a month and a half. I've tried coding it myself and then googling it like crazy but I came up with nothing. the input they give you based on vertical and horizontal is what perplexes me the most. in the debugger comes up like this from a debug.log when tilting it up- "H: 0.02528, V: -.9874454". Which makes sense but when going to the top right it looks like "H: 0.7592, V: -.842965". That's the part that confuses me. I can't find a way to use this data in any of the functions I have experience with and experimenting with new ones has gone nowhere. Any suggestions or ideas would help me greatly and would be even more appreciated!

Based on the above image I want my reticle to be placed in a spot on it's orbit around a player's center based on the right stick's position on the controller. So if I completely titled up my stick the reticle goes up but if I release it stays there. Then if I tilt it to the left bottom corner it will "teleport" there without moving along the orbit. So think of old school twin stick shooters where you can aim instantly in the direction of your choice.

This is my old code that used rotate around that slowly makes the reticle orbit as you hold the stick constantly left or right. I added a new axis called AV which is for vertical instead of just horizontal so now I just need a way to use these together somehow.

void AimControllers()
{
    if (currentControllerAimAxisH != null)
    {
        AH = Input.GetAxis (currentControllerAimAxisH);
        if (Mathf.Abs (AH) > stickTol)
        {
              reticle.transform.RotateAround(this.transform.position,new Vector3(0,0,-AH),orbitAngle);
        }
    }
}


texts: How can I display a loading state until a song loaded with www.GetAudioClip() is ready to play?

texts:
I use www.GetAudioClip() to get a song and play it when my Android mobile game starts.

My issue is that it takes a 3-second delay to play the song.

My idea is to add some loading screen before starting the game, and the game starts after www.GetAudioClip() finishes getting the song and I begin to play it. But I don't know how to control the loading screen so it disappears after the right delay.


texts: Quickly Converting RenderTexture to Texture2D in Unity3D

texts:
I have a screenshot preview at the end of the game's level.
When I am loading the screenshot, it makes the game freeze for a moment.
What may I do so there would be no freeze when I am loading that screenshot?
Here is myc ode:

private IEnumerator ShowScreeshotPreview()
        {
    screenshotTexture = new Texture2D(Screen.height, Screen.height, TextureFormat.RGB24, false);
            for (int i = 0; i < 9; i++)
            {
                yield return null;
            }
            RenderTexture.active = Singletons.Get<SpecialEffectsHelper>().MainCharacterScript.GetComponent<GeneratorScript>().screenshotTexture;
            screenshotTexture.ReadPixels(new Rect(0, 0, Screen.height, Screen.height), 0, 0);
    screenshotTexture.Apply();
            RenderTexture.active = null; //Added to avoid errors

            screenshotPrview.mainTexture = screenshotTexture;
    ScreenshotPreviewAnimator.SetBool("visible", true);
            screenshotLoaded = true;

            yield return null;
        }


texts: Why are assets (images) in Unity build reported as 28 times larger

texts:
I'm trying to reduce a Unity WebGL build size which, for the data asset, is currently at 30 Mb.  I installed the Build report inspector.  On clicking the "Source assets" tab and choosing "Size" it showed the top entries were images.  Fine.  But all the sizes reported were between 4 and almost 30 times the size of the file on disk.  Is this just a bug / artifact of the build reporter or a genuine problem which I need to address to reduce the build sizes?

** Edit **

Two of the files are text files.  Their size in unity build report is the same as that on disk.  Why?

** Edit 2 - after Ed Marty's answer **

Using low quality with crunch compression at 70 results in slightly lower image quality but it went from 10 Mb to 300 kb, i.e. 30 times smaller size (and about 10x smaller than actual file size on disk).


texts: Fix Pixel Shader "Stage did not run. No output"

texts:
I'm trying to set up a minimal D3D11 renderer but fail to get the pixel shader stage to run. The available answers here or the ones I found through Google couldn't help me, unfortunately.

Using Visual Studio's Graphics Debugger I could verify that my vertices are set correctly and the vertex shader also runs as expected. The debug layer doesn't report any issues either. As a test I disabled depth testing, stencil testing and backface culling as shown below with no changes.

I made sure that the viewport is set correctly as well as this seems to be a common source of this problem.

At this moment I can't think of any other cause for this issue and would be happy about any advice of what else to look out for.

Disable depth/stencil test:

D3D11_DEPTH_STENCIL_DESC dsstate_desc = {};
dsstate_desc.DepthEnable             = false;
dsstate_desc.StencilEnable           = false;
dsstate_desc.DepthFunc               = D3D11_COMPARISON_ALWAYS;
dsstate_desc.DepthWriteMask          = D3D11_DEPTH_WRITE_MASK_ALL;
dsstate_desc.BackFace.StencilFailOp  = D3D11_STENCIL_OP_KEEP;
dsstate_desc.BackFace.StencilPassOp  = D3D11_STENCIL_OP_KEEP;
dsstate_desc.BackFace.StencilFunc    = D3D11_COMPARISON_ALWAYS;
dsstate_desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
dsstate_desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
dsstate_desc.FrontFace.StencilFunc   = D3D11_COMPARISON_ALWAYS;
d3d11device->CreateDepthStencilState(&ds_state, &this->ds_state);
d3d11context->OMSetDepthStencilState(this->ds_state, 0);

Disable backface culling:

D3D11_RASTERIZER_DESC rasterizer_desc = {};
rasterizer_desc.AntialiasedLineEnable = false;
rasterizer_desc.CullMode              = D3D11_CULL_NONE;
rasterizer_desc.DepthBias             = 0;
rasterizer_desc.DepthBiasClamp        = 0.0f;
rasterizer_desc.DepthClipEnable       = false;
rasterizer_desc.FillMode              = D3D11_FILL_SOLID;
rasterizer_desc.FrontCounterClockwise = true;
rasterizer_desc.MultisampleEnable     = false;
rasterizer_desc.ScissorEnable         = false;
rasterizer_desc.SlopeScaledDepthBias  = 0.0f;
d3d11device->CreateRasterizerState(&rasterizer_desc, &this->rasterizer_state);
d3d11context->RSSetState(this->rasterizer_state);

Pipeline view in debugger:

Vertex shader transformation:

Vertex shader:

struct VertexIn
{
    float3 position : POSITION;
    float3 normal   : NORMAL;
    float4 color    : COLOR;
};

struct VertexOut
{
    float4 color    : COLOR;
    float4 position : SV_POSITION;
};

VertexOut main(VertexIn i)
{
    VertexOut o;
    o.position = float4(i.position, 1.0f);
    o.color = i.color;
    return o;
}

Pixel shader:

struct FragmentIn
{
    float4 color    : COLOR;
    float4 pos      : SV_POSITION;
};

float4 main(FragmentIn i) : SV_TARGET
{
    return float4(1.0f, 0.0f, 0.0f, 1.0f);
}


texts: How can I exclude my enemies from spawning in certain zones generated at random?

texts:
I have a code where I randomly generate enemy spawn position, but I want to exclude some areas since it's colliding with some sprites it shouldn't collide with.

This is the code where I generate the random points from where the enemy is coming from (from top,down, left and right):

int z = ran.nextInt(4);
int r1 = ran.nextInt(GameControl.CAMARA_WIDTH+1);
int r2 = ran.nextInt(GameControl.CAMARA_WIDTH+ 1);
int r3 = ran.nextInt(GameControl.CAMARA_HEIGHT+ 1);
int r4 = ran.nextInt(ControlJuego.CAMARA_HEIGHT+ 1);

I set the position of the enemy with the random variable:

if (var == 1) {
   newEnemy.getSpriteEnemy().setPosition(0, r1);
} else if (var == 2) {
   newEnemy.getSpriteEnemy().setPosition(GameControl.CAMARA_WIDTH, r2);
} else if (var == 3) {
   newEnemy.getSpriteEnemy().setPosition(r3, 0);
} else if (var == 4) {
   newEnemy.getSpriteEnemy().setPosition(r4, GameControl.CAMARA_HEIGHT);
 }

Later I move the enemies to the center of the screen.

An image for better vistualizatio of the problem:

I don't want my enemies to ever spawn behind any of the corner sprites or to collide with any of the corner sprites before entering the screen. How can I solve this problem? How can I exclude this areas?

Thanks in advance for the help.


texts: How should I handle shared classes between the Game project and the Content Extension Library?

texts:
I've been using XNA for a while but recently I've needed to write a content extension library which I haven't done before. I need to import a TextureAtlas class from a file that is exported by a tool I wrote. The output of my editor is a serialized XML file that contains a list of all StaticImages and Animations in the TextureAtlasFile class that its serialized from. In my solution I have the TextureAtlasContentLoader project which holds all of the classes that I will need for the texture atlas both in game and for loading the actual content. The importer deserializes the xml back to a TextureAtlasFile and the processor converts it to a TextureAtlas to return after it is loaded.

The problem is that I have no idea how to share the classes between the content extension project and the game project that will be using the TextureAtlas class. I've tried referencing the content extension project in the game project and that works fine to get me pass compiling but it throws a ContentLoadException exception when I call

textures = Game1.content.Load<TextureAtlas>("MainMenu");

saying

  Error loading "MainMenu". Cannot find type Client.Render.TextureAtlas,
  TextureAtlasContentLoader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.

The only other clue to whats wrong I have is a warning while compiling that says/

  Warning   2   The referenced assembly
  "Microsoft.Xna.Framework.Content.Pipeline, Version=4.0.0.0, Culture=neutral,
  PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" could not be resolved
  because it has a dependency on "Microsoft.Build.Framework, Version=4.0.0.0,
  Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently
  targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove
  references to assemblies not in the targeted framework or consider retargeting your
  project.   Client

which leads me to believe I'm not supposed to reference it in the game project. So to summarize my question, how do I handle my TextureAtlas and TextureHandle class that both the content loader and the game project need without causing errors?


texts: what is the sequence in using the "send" and "read" commands on the game client and server? boost asio

texts:
I have a voxel game in which you can run on blocks (chunks), jump and set/delete blocks. I want to write an asynchronous TCP server for it and choose boost asio as the network library. I have two commands, async_write_some and async_read_some, through them I can transfer the data structure to the JSON format.

How to organize the exchange of messages (packets?) between the server and the client, so that several people can play on the server at the same time?

For example, if you start from the server: should the client send a message and then wait for a response or should it continuously send messages and will a queue of them be made on the server? The same question about the client->server. If the client needs some kind of information from the server, then in what form should this command be sent? In the form of the word "give information about the players on the server" or what?

p.s. Do I need to compress the data being sent?


texts: Dynamically creating astar node map by triangular polygonal map

texts:
My game's map format uses a bunch of triangles to make up the platforms and terrain in 2d. Right now I can set up a 2d array of nodes for the A* (A star) algorithm that basically is a bunch of rectangles across the maps x and y that can be set to "wall" if the A* algorithm should try to go around it.

However I want a function in the map loader to create the node overlay if the nodes are not specified. I was thinking if more than n percent of the A* rectangle overlaid on map was filled by polygons I could mark that entry in the array as "wall". However I'm stuck on how to do this (or even start) where/when the triangles can be overlapping and also of variable size.


texts:
I'm interested in HTML5 game development and I found about this 2 game engines, I already know ImpactJS requires more programming experience and that Construct 2 has its own event and action system that can be extended with plugins made with JavaScript.

I want to know what are each engine's primary focus, when would someone choose one over the other assuming programming knowledge is not a concern.

Is it a matter of taste, features available, type of game or is it that each tool serves better for some kind of games or development process?.

I'm not looking to know which is better, just in which situations works better each tool, so people can have an idea of what's better for building the game they have in mind.


texts: How to avoid units with different destinations blocking each other in corridors?

texts:
I'm making a roguelike in which enemies wander around the map until they're detected by the player. They each have random destinations, so sometimes their destinations conflict and they block each other in corridors.

Enemies can't go through each other

Is there any approach that can avoid this issue? Only idea I have right now would be to detect which ones are at the end of the "trafic block" and made them change destination until their path is free... But maybe there's a better design solution for this problem?


texts: I am making a game, where if you go through the right wall, you pop up on the left. I want to have a function that calculates the distance between two objects, where we can have a line that goes through the wall. For example, if the screen width is 100 and one object was at (0, 90) and another at (0, 10), the distance between them would be 20.


texts:
What is the fastest way to get all adjacent tiles in a two-dimensional array of tiles, converted into a single-dimensional array?

If you don't know the answer, then the fastest way to do it in a two-dimensional array would be fine as well.

I tried the following, but it does 9 calculations, which is 1 too much when it comes to optimization.

for(int x = -1; x <= 1; x++) {
  for(int y = -1; y <= 1; y++) {
    if(x != 0 || y != 0) {
      Tile adjacent = Tiles[current.x + x, current.y + y];
    }
  }
}


texts:
Texturing for small objects (pickups and enimies) can easily be done UV-unwrapping the model, and use a texture of reasonable size to make the model look good. But how can texturing be done for the world? Covering a large building with one texture would require a huge texture (otherwise it will look blurry), and a lot of it will be repeated (brickwall textures, wallpapers ...), so that approach seems inefficient. Assigning different textures to different faces may be slow, since there cannot be a texture switch within the draw call.

I am targeting OpenGL 4 or later. I prefer good looking stuff rather than extremely high framerate: I aim for 30 fps, but perhaps with motion blur (which I guess requires four times that).

About tiling:

Tiling would work, but then there are some parts of the mesh which requires some other texture. And then I need to switch texture.


texts: Change center point and size with the help of the Matrix in Unity

texts:
Let us suppose I have an array of Vector3, it contains vertices.
Now I want to scale the vertices and/or change the center point of the texture (move texture relatively).

I have a Vector3 which is a new center point and I have a Vector3 which is vector for scaling along x, y and z.

How can I construct a needed matrix in Unity?

I am very new to all this, so, please, in case of any misunderstanding ask me about it.

Here is what I was able to find on my own. The problem with it, though, is that I can not infer what I need from it. I need a little bit more peculiar thing.


texts: Elo-like ratings for games with variable number of players

texts: I read this article about using Elo for more than 2 players in a game: http://sradack.blogspot.ru/2008/06/elo-rating-system-multiple-players.html. But in my case I have a variable number of players in each match (2-10 usually) and if I just apply this logic winner of a 2-players match will have a larger rating increase than a winner of 3-players match (if we start with the same rating we will have expected {0.5, 0.5} actual {1, 0} for 2 and expected {0.33, 0.33, 0.33} actual {0.66, 0.33, 0} for 3). Are there any variations of Elo or some other systems that could handle it?


texts:
I want to apply SNORM texture by using GL_TEXTURE_3D as a target, what will be the fragment shader for the same?
Also, what should be the data type of texture data?


texts: Dealing with floating point imprecisions in a 2D Tiled based game

texts:
I'm using unity3d to create a little horizontal tile based platformer game. My entities have a rectangle defining their collision volume.

On the other hand I'm using a camera configured to  1 unit = 1 pixel because I like to work in pixels instead of units.

The problem is that my sprites are created in a higher resolution and I have to scale them down to allow correct size. So, they do not have integer size in any dimension. For example I'm testing with a sprite that after scaling becomes something like 60.12px in height.

My problem is that when I try to check for collision against tiles some times, there are float precision errors and I come into problems like detecting if a tile is in front of the player wrongly because of the bottom part of the sprite getting into the floor tiles.

How do you deal with this? I have tried to add a little amount to somehow fix that but it does not work quite well.

Cheers.


texts: Is it possible for Minecraft to use time-dependent in-game progression rather than current tick-dependent?

texts:
I see the problem of the current tick-dependent approach to propel the in-game progression. The drawback of this tick-dependent approach is that if a computer running the game is not powerful enough, or there is so many entity to be ticked, the TPS will drop and overall in-game progress will be slowed down, which will negatively impact the in-game experience and immersion.
If the game used time-dependent approach instead, behavior and progression of any entity in a world will be based only on time, which increments regardless of how fast the computer is.
Imagine of projectile motion. The position of a projectile can be readily calculated by the simple formula which is a function of time, without the need of "repeatedly ticking" the object to the new position.
Also this can apply to any redstone circuits, which has exact operation time for each component. Given a serial connection of redstone repeaters, which, for some given time, can be finded out that which repeater is activated.
I wonder that this approach can be apply to Minecraft (or other video games)?


texts:
currently I re-write my codes and change them to make they are better.

I have vertex struct like this:

struct SVertex
{
    float X, Y, Z;
};

struct STexCoord
{
    float U, V;
};

And I re-wrote it like this

struct SVertex
{
    int Flag, BoneID;
    float Pos[3];
    float UV[2];
};

When it comes to the render function, I just need to change it from:

glVertexPointer(3, GL_FLOAT, 0, &(Mesh[i].Vertex[0]));
glTexCoordPointer(2, GL_FLOAT, 0, &(Mesh[i].TexCoord[0]));

to:

glVertexPointer(3, GL_FLOAT, sizeof (SVertex), &(Mesh[i].Vertex[0].Pos));
glTexCoordPointer(2, GL_FLOAT, sizeof (SVertex), &(Mesh[i].Vertex[0].UV));

The problem comes from the triangle struct. I re-wrote the Triangle from

struct STriangle
{
    int X, Y, Z;
};

to

struct STriangle
{
    int Flag, Group;
    int V[3], N[3];
};

and I changed the glDrawElements from:

glDrawElements(GL_TRIANGLES, Mesh[i].TriangleTotal*3, GL_UNSIGNED_INT, &(Mesh[i].Triangle[0]));

to

glDrawElements(GL_TRIANGLES, Mesh[i].TriangleTotal*3, GL_UNSIGNED_INT, &(Mesh[i].Triangle[0].V));

And I got messed vertex with the new triangle struct. If I use the old ones, it is correct. How to pass the new triangle struct to the glDrawElements?


texts: I am attempting to make a 3d game using SDL2 just to learn and have a bit of fun. I was wondering if there is any way to get SDL2 do calculations on GPU. I have read that SDL2 Textures uses GPU for calculation, but is there any way to get it to do calculations from my functions using GPU? For example, if I have a function multiplyVectorWithMatrix, and there is a bunch of additions going on in that function, how would I get SDL2 to do those additions using GPU rather than CPU?


texts: How to solve problem with Terrain Flashing and then disappears when flying away?

texts: I am making flight simulator( my first Unity project) , the biggest challenge so far is terrain, so whenever I fly away from it (not that far) the terrain starts flashing and disappears which is just green mountains, so when i come back to it, i have no idea where its position is, but it suddenly appears (again flashing) when I am close , the terrain size is normal but it's on top of a huge other terrain (about 100,000 * 100,000 which is the max),I tried changing pixel error and base map distance, no change, I looked at big terrain solutions online, but non of them really helped me, Any advice? Thanks


texts: What kind of performance issues does multiple instances of the exact same object have on a game?

texts:
I'm fairly new to programming, and I've pretty much learned all the things I know on the go, while working on projects. The problem is that there some things that I just don't know where to begin searching.

My question is about performance, and how can multiple instances of the same object affect it -- Specifically, I'm talking about XNA's "GraphicsDevice" class. I have it instanced on four different parts of my game, and in three of those, the object has the exact same values for all the attributes. So, in that case, should I be using the same instance of GraphicsDevice, passing it as a parameter, even if I use it in different classes?

I apologize if the question seems redundant, but like I said, I've taught myself most of what I know, so there are quite a few "holes" in my learning process.


texts: Scrolling background in PyGame with Entity Component System

texts:
I know this type of question has been asked to death for 'normal' games, however I am struggling with relating a scrolling background to an entity component system (ECS) approach.
Generic samples here and here and here.
What I struggle with is how to take a fairly procedural view of this problem and abstract it out to an ECS.  I'm trying to get a roguelike game up and running in PyGame using Esper.  I do have a proof of concept up and running where I generate a large map, however I'm having issues relating how to add a camera here as an entity that other objects would relate to.  I'm guessing that I need to refactor my movement code to be based around a camera, and have each separate entity update their relative position as a result.
At present, the background is being directly drawn and needs to be abstracted to an Entity in this system, but I was somewhat holding off on that until I figured out the camera.  Here is a snippet of the Renderable class that each drawn entity has:
class Renderable:
    def __init__(self, image, posx, posy, depth=0):
        self.image = image
        self.depth = depth
        self.x = posx
        self.y = posy

        self.curr_row, self.curr_col = convert_to_cells(posx, posy)

        self.w = image.get_width()
        self.h = image.get_height()
        self.rect = pygame.Rect(self.x,self.y,self.w,self.h)

And here are the Movement processor and Render processors:
class MovementProcessor(esper.Processor):
    def __init__(self, minx, maxx, miny, maxy, game_map):
        super().__init__()
        self.minx = minx
        self.maxx = maxx
        self.miny = miny
        self.maxy = maxy
        self.game_map = game_map

    def process(self):
        # This will iterate over every Entity that has BOTH of these components:
        for ent, (vel, rend) in self.world.get_components(Velocity, Renderable):
            # Check if movement is valid:
            newx = rend.x + int(vel.x * TILE_SIZE)
            newy = rend.y + int(vel.y * TILE_SIZE)
            new_row, new_col = convert_to_cells(newx, newy)

            if self.game_map.data[new_row][new_col] > 1:
              # Update the Renderable Component's position by it's Velocity:
              rend.x = newx
              rend.y = newy
              rend.curr_row = new_row
              rend.curr_col = new_col

class RenderProcessor(esper.Processor):
    def __init__(self, window, clear_color=(0, 0, 0)):
        super().__init__()
        self.window = window
        self.clear_color = clear_color

    def process(self):
        # Clear the window:
        self.window.fill(self.clear_color)

        # This will iterate over every Entity that has this Component, and blit it:
        for ent, rend in self.world.get_component(Renderable):
            self.window.blit(rend.image, (rend.x, rend.y))

        # Flip the framebuffers
        pygame.display.flip()

Later on in my main loop I iterate over my tilemap (Map class) and simply draw it to a surface, add some debugging overlays, and then assign that surface to the entity associated with the background (bg_entity):
        # Blit background directly -- this needs to be abstracted out
        for row in range(len(game_map.data)):
          for col in range(len(game_map.data[0])):
            rect = pygame.Rect(col*TILE_SIZE,row*TILE_SIZE,TILE_SIZE,TILE_SIZE)

            # Blit a wall sprite
            if game_map.data[row][col] in [0,1]:
              bg_surface.blit(walls[game_map.data[row][col]],rect)

            # Blit a floor/grass sprite
            elif game_map.data[row][col] in [2,3,4,5]:
              bg_surface.blit(floors[game_map.data[row][col]-2],rect)

Here is the full listing:
https://pastebin.com/N7c4TXXB


texts: How does Vector3.Angle compute the resulting angle?

texts:
I don't understand the concept of Vector3.Angle in Unity.

Can someone please explain in detail how it computes the angle? From which two points is the angle measured? It would also be really awesome if you could provide some diagrams for me understand it more, visually.


texts:
I'm trying to implement picking in my framework but I don't understand how I can do this.

I'm working with:

OpenGL ES 2.
GLM mathematic library.

What I have understand, picking can be made with two methods:

Draw scene with one color per polygon, and read pixel under mouse.
Ray projection in 3D and finally calculate geometry <-> ray intersection.

My architecture:

A Geometry class with indices/vertices/texture coords/colors data.
A Scene class with a Mesh array (using a geometry).
A Transformable class with Matrix computed with rotation/position/scale.
A Camera class with methods like getViewport/….

What I have:

My ray calculation:

void Ray::createFromEvent( const Camera& camera )
{
    glm::mat4 model         = camera.getMatrix();
    glm::mat4 projection    = camera.getProjectionMatrix();
    glm::vec4 viewPort      = camera.getViewport();

    this->origin = glm::unProject(  glm::vec3( x, y, camera.getMinDistance() ),
                                    model,
                                    projection,
                                    viewPort );

    this->direction = glm::unProject(   glm::vec3( x, y, camera.getMaxDistance() ),
                                        model,
                                        projection,
                                        viewPort );
}

So, my questions are:

How can I calculate intersection with my scene geometries?
It's better to calculate if point is inside a bounding box or ray traversing a bounding box?
How can I compute bounding box with Transformable matrix (rotation, scale, …)?

(I am on mobile so I am limited by hardware performance.)

Thanks!