texts:
I'm working on my combo system and I keep getting this weird problem. It's a pretty basic setup: when the player hits the attack button it changes the character's current action to "attack", if the player hits an enemy then an int (f) is set to the next combo number, after the attack finishes the character's current action turns to "standing" and an if statement makes the combo int equal to f.

So basically it reads like this:

switch (action)
{
    case "attack":
        if (combo == 0)
        {
            if (enemy.Hit(playerSquare))
            {
                f = 1;
            }
            else
            {
                f = 0;
            }
            if (animationDone)
            {
                action = "stand";
            }
        }
        else if (combo == 1)
        {
            same
        }
        else if (combo == 2)
        {
            same
        }
        break;
}

if (action != "attack")
{
    combo = f;
}

My setup works, however, if I press the attack button too quickly it either doesn't add to the combo int (keeping it at the same number as before) or adds to it twice (depending on whether or not I slow it's update rate.) I'm sure there's probably an easy way to fix this and I'm not seeing it or maybe there's a better way to do this that I haven't considered yet, so I'm hoping you guys can help out. Any suggestions?


texts:
I have a simple particle game, where all the particles are arranged in a grid.  This game is for touch devices so to take advantage of it I am trying to have a multitouch gravity field thing going on.

Basically I am trying to get it so that each finger is basically a well in an otherwise non existent gravity field. That way the particles are pulled towards a finger.

My problem is I don't even know where to begin with these calculations, I have tried averaging a particles distance to each finger, its direction to each finger and nothing seems to work nicely!

I have seen other games do this.  What does the math for it look like?


texts:
I am new to cocos2d. I am using CCAnimation. It's working fine, except I want to pause the animation occasionally. How do I do this?

Here's what I'm doing so far:

[mySprite runAction:[CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim]]];


texts:
I'm on the planning stages for an internal game engine I am about to start creating, which will be used for all my games going forward. But I'm struggling a bit with how it should be built.

The choices come down to: framework or library.

My basic objective is to hide engine details as much as possible to keep high level game development on scripts and config files as much as possible. But also to reuse the core engine for any tools we might develop in the future.

Frameworks can make things nice and easy for development, but then you're locked in. Libraries are good if you're only interested in a specific subsystem. But we need to glue everything together in a game by game basis.

Well there is also another, building the engine as a standalone exe that handles all game resources, and all the subsystems. Game logic (and other per game dynamic stuff) is done exclusively on scripts with config files to configure each internal engine subsystem.

Which one will give me more flexibility in the future.

Thanks.

Edit:
Thanks everybody, guess I was looking at this in the wrong perspective. We can't really plan something like this without a priori knowledge of what the games need, guess this is why there is no such thing as a general engine for all genres.

I'll focus first on the game proper then iteratively analyze at the end of each game how to make decent abstractions for libraries or frameworks depending on my work-flow (or possibly that of a future team).


texts: Is there a way that I can use Krita assets that I draw in Spine for animation?

texts: I am using Krita to create my assets for a game. I am also using Spine so that I can animate those assets to add into my game. Is there a way that I can use Krita and Spine together? I would really like to not have to buy Photoshop or have to learn another software to create my assets.


texts:
I'm currently making a stock game where the user can buy fictional stocks. Upon registering the user will receive 1.000.000 DKK (danish krone) to spend on stocks.

I'm trying to create a ranking system, but I found this to be more difficult than I had imagined.

By giving the user 1.000.000 at the start of the game it's hard to evaluate how good a player is doing when compared to an inactive player.

Thing is, a player could sign up and receive the money and then do nothing else and (probably) do better than a lot of the people who get negative. In this way, inactive players are rewarded for doing nothing and will look better on the scoreboard.

Is there a good way to avoid this?


texts: openGL Vertex Projection does not work as expected

texts:
I try to render a simple grid using glBegin(GL_LINES).
I have a class Camera, which provides values like this:

float farPlane = 100.0f;
float nearPlane= 0.1f;

float screenRatio = 1,42857; //width/height = 1000/700
float frustum = 70.0f;

glm::vec3 position = glm::vec3(3.0f, 3.0f, 3.0f);

glm::vec3 UP = glm::vec3(0.0f, 1.0f, 0.0f);
glm::mat4 view = glm::lookAt(position, position - glm::normalize(position), UP); // makes the lookAt vector always point towards (0, 0, 0)
glm::mat4 projection = glm::perspective(frustum, screenRatio, nearPlane, farPlane);

using the view and projection matrices, i transform every vertex from my Grid model and render it.

glm::mat4 viewProjectionMatrix = Graphic::camera->getViewProjectionMatrix(); // returns Camera::projection * Camera::view
glBegin(GL_LINES);
for (unsigned int i = 0; i < vertexNum; ++i) {
    glColor3f(vertexArray[i].normal.x, vertexArray[i].normal.y, vertexArray[i].normal.z); // normal vector is used for color in this case
    glm::vec4 translatedPosition(viewProjectionMatrix*gridTransformationMatrix*(glm::vec4(vertexArray[i].position, 1.0f)));
    glVertex3f(translatedPosition.x, translatedPosition.y, translatedPosition.z);
}
glEnd();

but this is what i see when i move the camera along the line: (0,0,0) + u*(1,1,1)
http://i.imgur.com/PrcDcLs.gifv
(you can see the camera cooridnates in the console)


texts: Throttling or adding delays between OnTriggerEnter2D calls

texts:
I have 2 game objects: Explosion and Enemy. At any given point, an enemy can collide with multiple Explosion game objects at the same exact time. This causes a few issues when I'm trying to destroy the Enemy game object.

This is the function that destroys the game object:

bool isDead = false;

public void KillCharacter () {
  if (!isDead) {
    isDead = true;
    Debug.Log ("kill enemy...");
  }
}

If I use OnTriggerEnter2D inside the Enemy script, like so:

void OnTriggerEnter2D (Collider2D other) {
  if (other.gameObject.tag == "Explosion") {
    KillCharacter();
  }
}

In case two explosions spawn on the position of the enemy, Debug.Log inside the KillCharacter function will fire twice, even though I set the isDead bool to true on the first run.

The only solution I found was to call KillCharacter from the Explosion script, like so:

void OnTriggerEnter2D (Collider2D other) {
  if (other.gameObject.tag == "Enemy") {
    other.gameObject.GetComponent<Enemy> ().KillCharacter ();
  }
}

Is there a way to run the OnTriggerEnter2D from the Enemy script, as I originally intended? Or is having the KillCharacter handle all the death logic and calling it from outside good enough?


texts: Checking if Body is surrounded by other Bodies

texts:
I'm trying to make a game like Rampart as practice. I have gotten to the point where I want to check if the castle is surrounded by walls and decide whether to fill in the area and continue the game, but I have no idea how to do this. I have thought about ray-casting from the castle but it wouldn't work if there was a bend in the walls.

So any help or suggestions would be great!


texts: My SVG graphics don't look as good in Unity as they do in my web brower

texts:
I thought had an easy solution to getting nice smooth edges on all of my images: export them to .svg and then use Unity's new SVG importer package. However, my svg images don't really look better once they get into Unity. They don't look worse than my .png images but they don't look as nice as they do when I'm looking at them in a web browser or photo viewer.

Why is that?
And is there a simple way to fix that?

I did try out as a 'Textured Sprite' instead of a 'Vector Sprite' and noticed some quality differences messing around with Sample size and Filter mode but I wasn't able to get the .svg images to look as good as they do in a regular image viewer.

ETA images:

SVG image in a viewer or web browser (This is ideal):

SVG image in Unity when object is close. It's okay but not as good. A little fuzzy plus it adds some random notches:

SVG image in Unity when object is far. More fuzzy:

PNG image in Unity when object is close. Very good:

But PNG image in Unity when object is far. Very fuzzy:


texts: Circle inside ellipse collision/intersection (preventing circle from leaving the ellipse)

texts:
I am working on a 2D RPG with a turned based battle system.

Characters move inside the confines of an ellipse movement area and when they leave the boundaries will be pushed back inside. (i.e they should be able to walk around the inner part of the ellipse). Previously we were using circles for the movement area and I wrote the code to do circle inside circle collision (not too difficult because the radius is always the same) but since we will change to using an ellipse, I am trying to update the code.

I have looked at a few solutions for actual ellipse collision/intersection and the math looks..daunting. My questions are:

Are there any clean solutions to doing circle inside ellipse collision/intersection?
Should I be approximating the ellipse collision in another way? Like using an n-sided polygon?

I am a bit lost on how to approach this and could really use some advice.


texts: Resize Label automatically with the text content in LibGDX?

texts:
In LibGDX, I want to add some long text content to several Labels. I'm creating those labels in a loop, and the text content is different in each iteration. I want the Label to have a size that fits the text exactly. Is there a way to do this? I did setWrap(true) to the Label.

For reference, consider a Label:

+------------------+
|                  |
+------------------+

One copy of that may be:

+------------------------------------+
| Lorem ipsum dolor sit amet,        |
| consectetur adipiscing elit.       |
| Nec vero alia sunt quaerenda       |
| contra Carneadeam illam sententiam.|
+------------------------------------+

Another one should resize to the content:

+------------------------------------+
| Uterque enim summo bono fruitur,   |
| id est voluptate. Illud non        |
| continuo, ut aeque incontentae.    |
| Occultum facinus esse potuerit,    |
| gaudebit; Multoque hoc melius nos  |
| veriusque quam Stoici. Id Sextilius|
| factum negabat. Ita nemo beato     |
| beatior.                           |
+------------------------------------+

EDIT:

Please note that the horizontal wrapping is working perfectly. I need the Label size to adjust with the text content vertically. Width is fixed. Height is not.


texts: How do you build a matchmaking service for an iOS turn-based board game?

texts:
I want to build a board game that matches players with similar skill levels against each other.

Take for example a chess iOS app. Log in, and the game pairs you up against someone with a similar elo rating.

But there's a network infrastructure they're using. I haven't been able to find a suggestion for what kind of network architecture I should use.

I've tried Google and searching on YouTube for how to build a multiplayer solution, and I haven't been able to find anything specific.

The closest thing I have is to just use the built-in GameKit features Apple offers.

Otherwise I have to use some things called REST, SOAP, Amazon AWS, or Unity's UNET multiplayer matchmaking service. And that's all fine, but I haven't been able to find any specific directions on how to use those services.

What I'm trying to say: There doesn't seem to be a stock, default solution for multiplayer matchmaking in 2018.

What should I use? What can I use? Should I just stick to the basic Game Center functionality?

Should I explore other services or take a few months to build a custom-solution?

What's the most efficient route towards building a multiplayer server for a simple board game between two players?


texts:
I'm currently working on a 3D RPG game and I'm adding Interactions with objects. I have a lot of objects to interact with and I've placed them in an folder/empty object "Interactables".

Now, I want all my objects to have a SpriteRenderer Component. I'm currently adding this Component on each Interactable Object, one by one.

Is there a cleaner way of doing that, for example adding the Component to the Interactables parent empty object and cloning it to all the children ?

Thank you!


texts: Is it sound to use javascript for cross platform game scripting instead of lua? I might need web clients for my game

texts:
I have been looking around for clues on the subject but I'm not convinced to commit to javascript as my primary scripting language.

Currently I have started with lua. But I fear it will be a limiting choice for my future projects which include web clients for my games.

So basically I would like to know if you think it would be a viable solution for handheld devices and consoles.

Also, I would be glad to hear about:

anyone who had much success with javascript in cross platform games
failures with javascript scripting engines
restrictions within console SDKs that would prevent this type of solution
successes using lua in web games


texts: Lets say I have a model with multiple meshes. Mesh A is at position PositionA = new Vector3(5,0,10). And mesh B is at position PositionB = new Vector3(7,0,9). How can I rotate mesh B around meshes A pivot point, or its centre?


texts: Is there an ideal width to height ratio?

texts:
I would like to know if there is any "ideal" width to height ratio when creating games for the web.

My canvas is fluid, and resizes according to the browser width and height. But with all the devices out there it's difficult to know what ratio to choose.

Right now i have 4:3 (Width:Height), but is there any ratio that would fit well in most devices?

Thank you.


texts: Why am I seeing this assertion error during Collada DOM loading?

texts:
D3DXMATRIX ColladaFileLoader::processMatrix(daeElement* node)
{
D3DXMATRIX matWorld;

daeTArray<daeElementRef> nodeChildren = node->getChildren();

for (int i = 0; i < nodeChildren.getCount(); i++)
{
    string type = nodeChildren[i]->getAttribute("sid");

    if (type == "rotationX")
    {
        string data = nodeChildren[i]->getCharData();
        stringstream stm(data);

        stm >> matWorld.m[0][0];
        stm >> matWorld.m[0][1];
        stm >> matWorld.m[0][2];
        stm >> matWorld.m[0][3];
    }

    if (type == "rotationY")
    {
        string data = nodeChildren[i]->getCharData();
        stringstream stm(data);

        stm >> matWorld.m[1][0];
        stm >> matWorld.m[1][1];
        stm >> matWorld.m[1][2];
        stm >> matWorld.m[1][3];
    }

    if (type == "rotationZ")
    {
        string data = nodeChildren[i]->getCharData();
        stringstream stm(data);

        stm >> matWorld.m[2][0];
        stm >> matWorld.m[2][1];
        stm >> matWorld.m[2][2];
        stm >> matWorld.m[2][3];
    }

    if (type == "location")
    {
        string data = nodeChildren[i]->getCharData();
        stringstream stm(data);

        stm >> matWorld.m[3][0];
        stm >> matWorld.m[3][1];
        stm >> matWorld.m[3][2];
        matWorld.m[3][3] = 1;
    }

}

return matWorld;
}

This function will run run debug assertion failed after it ends the first pass through the loop.  The loop will run correctly, it will enter the last if statement and set all values correctly.  However when the pass is done and before it starts the next pass it will debug assertion failed on me.  I think it is trying to destroy the string type variable but something is breaking when it does tries to delete it.  I don't know what the problem is.  It seems to do this on other parts of my program that get strings from the file and place in std::string.  I fixed those by just removing those entirely but this one cannot be removed it needs to exist.

Don't know if this has anything to do with it, but I'm using visual studio 11 dev preview, and using compiler vs100 (vs10's compiler) settings.

dbgheap.c
Line:1322

Expression: _CrtISValidHeapPointer(pUserData)

also when i use debugger none of my vars from this function show up after the error.


texts: Steering forces - Avoidance does not affect trajectory when flying directly at a target

texts:
I'm trying to implement a simple seek & avoid system for a 3d game wherein planes fly around. Using https://gamedevelopment.tutsplus.com/series/understanding-steering-behaviors--gamedev-12732 as a reference.
During testing I found that if a plane was flying directly at a target it should avoid, the avoidance force (a Vector3 that points in direction from the plane's target to the plane) is in the complete opposite direction of its velocity (also a Vector3), thus it doesn't steer at all. I could detect this and rotate the avoidance force a bit, but that seems like a poor solution.
func _avoid() -> Vector3:
    var avoidance_force := Vector3.ZERO

    var ray_start = host.get_position()
    var ray_length = host.get_view_distance()
    var collision = host.get_world().direct_space_state.intersect_ray(
        ray_start,
        ray_start + -host.global_transform.basis.z * ray_length,
        [host], 31, true, true)

    if collision.empty():
        return avoidance_force

    if collision.collider.name == 'Avoidance':

        var collision_dist = (host.get_position() + host.get_velocity() - collision.position).length()

        avoidance_force = (collision.position - collision.collider.global_transform.origin).normalized()

        # if direction_change == -1, then the plane is flying directly at its target
        # var direction_change = avoidance_force.dot(host.get_velocity().normalized())
        return avoidance_force


texts: What is "terrain mesh generation" exactly?

texts: I'm new to computer graphics and need to know and understand what the "terrain mesh generation" is? I read about "terrain", "mesh", "terrain generation" but can't find an article named "terrain mesh generation". So is there anyone can explain "terrain mesh generation" ?


texts: Which Terrain LOD algorithm should I use for super large terrain?

texts:
My game needs a terrain, the requirements are:

Freely Zoom in & zoom out, like GoogleEarth. Max resolution when zooming in ~100 meter, Max range when zooming out ~2000km (a whole country scale).
Freely fly over to any direction with any height; Freely rotate camera; Framerate should not a bottleneck for all those basic camera movement.
Support large heightmap data. I got mine real world elevation data from NASA with 7.5arc resolution, around 30k * 15k for a whole country.
Also I need to consider the spherical earth surface curvature other than using a planar map. But this should be easy if I just map each vertex into spherical coordinates. I am not build the whole planetary LOD so it's not even a problem.

I noticed there are many different LOD algorithm out there. For example:

ROAM: very classic algorithm, most done on CPU;
Geomipmapping: store the whole heightmap with best resolution as vertex buffer, with different LOD in vertex index. Then determine LOD and draw range in vertex index at runtime.
CDLOD:
Geo Clipmapping: I am feeling excited about this one since it claims to load all 200k * 100k US heightmap into video card memory and compressed ~300M, it seems to meet all my requirements. see source paper. And this is paper in 2004 and think about the video card at that time!

That's pretty much all I know about terrain LOD.
I am not familiar recently study/research in this area.
Is Geo clipmapping my best option? What else algorithms are also useful to consider?


texts: Add single color background to texture using shader

texts:
I want to add a single color background to my texture.
In my case, in Unity UI, I can simply create two Image components, one on top of another, and use the one on the bottom as a single color background.
However, I would like to do it in a single draw call, using a shader. This is the shader that I use:

   Shader "UI/Background Tinted"
   {
    Properties
    {
        [PerRendererData]_MainTex ("Sprite Texture", 2D) = "white" {}
        _BgClip ("Offset Mask", Range(0,0.1)) = 0.025

        _StencilComp ("Stencil Comparison", Float) = 8
        _Stencil ("Stencil ID", Float) = 0
        _StencilOp ("Stencil Operation", Float) = 0
        _StencilWriteMask ("Stencil Write Mask", Float) = 255
        _StencilReadMask ("Stencil Read Mask", Float) = 255

        _ColorMask ("Color Mask", Float) = 15

        [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
    }

    SubShader
    {
        Tags
        {
            "Queue"="Transparent"
            "IgnoreProjector"="True"
            "RenderType"="Transparent"
            "PreviewType"="Plane"
            "CanUseSpriteAtlas"="True"
        }

        Stencil
        {
            Ref [_Stencil]
            Comp [_StencilComp]
            Pass [_StencilOp]
            ReadMask [_StencilReadMask]
            WriteMask [_StencilWriteMask]
        }

        Cull Off
        Lighting Off
        ZWrite Off
        ZTest [unity_GUIZTestMode]
        Blend SrcAlpha OneMinusSrcAlpha
        ColorMask [_ColorMask]

        Pass
        {
            Name "Default"
        CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma target 2.0

            #include "UnityCG.cginc"
            #include "UnityUI.cginc"

            #pragma multi_compile __ UNITY_UI_CLIP_RECT
            #pragma multi_compile __ UNITY_UI_ALPHACLIP

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

            struct v2f
            {
                float4 vertex   : SV_POSITION;
                fixed4 color    : COLOR;
                float2 texcoord  : TEXCOORD0;
                float4 worldPosition : TEXCOORD1;
                UNITY_VERTEX_OUTPUT_STEREO
            };

            fixed4 _TextureSampleAdd;
            float4 _ClipRect;
            float _BgClip;

            v2f vert(appdata_t v)
            {
                v2f OUT;
                UNITY_SETUP_INSTANCE_ID(v);
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
                OUT.worldPosition = v.vertex;
                OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);

                OUT.texcoord = v.texcoord;

                OUT.color = v.color;
                return OUT;
            }

            sampler2D _MainTex;

            fixed4 frag(v2f IN) : SV_Target
            {
                half4 main = tex2D(_MainTex, IN.texcoord);

                float mask = 1.0 - main.a;

                half4 bg = IN.color;
                bg.a = mask;

                half4 color = main + (bg * mask);

                return color;
            }
        ENDCG
        }
    }
}

With two Images component everything is fine. However, with single shader approach I encounter sharp edges near image alpha boundaries.

Using 2 images, looking fine:

Using single shader, jagged edges:

How do i fix that, using a single shader approach?


texts:
I'm currently using a GJK implementation (supported by EPA for penetration) and I'm trying to optimise the calculation times of distance calculations.
One of the biggest hits is trying to solve for distance between a simple 3D shape (ie a cylinder) and a curved line in the shape of a helix (https://en.wikipedia.org/wiki/Helix).

I'm just brute forcing them by chopping the helix into a lot of smaller straight lines and solving each one against the 3D shape.

Is there a better way to do this?

The image below shows the relative shape of the objects and how they can come into contact (the red disk is the moving object). In this screenshot its contacting an end point of the curve, but it will commonly contact anywhere between the end points of the helix.


texts:
Actually two questions:

Can I use TCP sockets in UDK to implement my own networking protocol? (I guess TCPLink is an answer)
Is there any way I can user Protocol Buffers inside UDK? Or anything like that? (i.e. thrift, bson)


texts: How can I create a world map like Mario 3's?

texts:
I want to create a world map similar to the type that Mario 3 on NES uses

where Mario can walk between levels (nodes?) by pressing up, down, left and right on the controller, and Mario can only pass through a level when it has been cleared.

What I have so far is a list of level nodes:

std::vector<SLevelNode*> NodeList;

struct SLevelNode
{
    CVector2D Position;
    CVector2D Size;
    CVector2D Origin;

    int ID;
    int Type;

    SLevelNode* pNeighbourNode[4];
};

The level node contains stuff like position, the type of level node (ground level, water level, castle level and so on). It also contain a neighbor node array, which in my case is 4, since I want the player to, eventually, be able to walk from a level node in all four directions. A level node might only have two ways of travel though, left and right for example.

Besides the level node, I also have a path piece, which is a piece of road between the level nodes:

struct SPathPiece
{
    CVector2D Position;
    CVector2D Size;
    CVector2D Origin;

    int Type;

    float Rotation;
};

The type variable is either a horizontal piece, a curve piece, a bridge piece and so on.

So far my character can walk between the level nodes by dragging a 2D vector between them, that the player traverse with. I want, however, the player to start walking from a level node, walk through the road pieces (between the nodes) and end up at the goal level node.
I'm not sure how to make the level nodes "know about" the road pieces that is placed between the start node and the goal node. Have a list of path pieces in each level node?

I have though about using A* and make a path finding map but it feels like it's over-complicates things.

I would like some help on how to achieve this.


texts: Send empty vertex buffer data but keep Vertex Shader Input Structure?

texts:
lets say i have the following structure defined in a header (for reusage):

struct VertexShaderInput
{
    float3 Position: POSITION;
    float3 Normal: NORMAL;
    float2 UV: TEXCOORD;
    float4 Color: COLOR;
};

however, some meshes dont have normals or colors and some passes (such as Depth PrePass) doesn't need Normal or Color.

Is there a way to keep the struct definition above in my shaders and simply sending "zero" bytes for Normals and Colors?


texts: Overriden Event does not execute on Unreal

texts:
I've been learning Unreal Engine through this tutorial and I am having an issue with overriding an event I created on C++ using blueprints.
So here is what I've done:

I created a class called ABasePlayer that inherits from APawn. And I am trying to make this jump.

On the unreal project settings > Engine > Input, I created an Action Mapping called "Jump" and set it to the space bar.

On the ABasePlayer, I created a function called Jump, like this:
UFUNCTION(BlueprintImplementableEvent)
void Jump();

I also created a jump impulse property, looks like this:
UPROPERTY(EditAnywhere, BlueprintReadWRITE)
float JumpImpulse;

In the SetupPlayerInputComponent function, I added the next line :
InputComponent->BindAction("Jump", IE_Pressed, this, &ABasePlayer::Jump);

Then I went to the blueprint editor of my main player, and override the function:

I then created the next blueprint to add Jump to my player:

I then added the jump impulse :

-After building and compiling, I ran the scene but nothing happened. When I press space nothing happens.
So what I did next was to try to implement jump by code instead, just to see if I can see what is going wrong with my blueprint. I went to C++, and implemented the Jump function in this way:
void ABasePlayer::Jump() {

    FVector ForceToAdd = FVector(0, 0, 1) * JumpImpulse ;
    Mesh->AddForce(ForceToAdd);

    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Jump!"));

}

Curiously enough, whenever I press space I see the "Jump" message, but there is no jumping.
My question would be, did I did something wrong? Did I oversee something in these steps that does not allow my character to jump?
Thanks in advance!


texts:
This question relates to this link:
https://www.freetronics.com.au/blogs/news/6537043-experimenting-with-unity-processing-and-arduino#.W2-SFs4zbIU
Does anyone have any idea how I would begin doing this? I cannot find the tutorial or code that relates to this. I have a cube on unity that changes colour and texture according to the input from a force sensing resistor. How would I get the cube to react in this way (as in the video)? Any assistance will be appreciated

In this video, a flexiforce sensor is housed in a cube. When the user presses the sensor, a cube on Unity reacts in the same manner that the real cube is squeezed; its basically a virtual version of what is happening to the cube in real life


texts:
What is the basic procedure to create the signed apk for my libGDX project? I am new to libGDX so provide some guidance.

I am talking about deploying apk to the Android market. I have to ask this question because my Galaxy SX2 display only blank screen.


texts:
I'm creating a game with a lot of elements. Should I store all components that I'll eventually access on class variables (memory) or should I access them when running the script(processor)?

Example:

private SpriteRenderer sprite;

void Start () {
   sprite = GetComponent<SpriteRenderer>();
}

public void StartMovement()
{
    sprite.doSomething();
}

VS

void Start () {

}

public void StartMovement()
{
    GetComponent<SpriteRenderer>().doSomething();
}


texts:
How can I identify the correct vertecis and move them in XNA using VertexBuffer? Let's say I have a simple cuboid in my project and want to move one face of it. How would I loop thru vertices, get their information and reposition those vertices to a new Vector3 location?

This is a must for my project, since bones aren't flexible enough.

EDIT:

Since everyone is saying this would be bad and slow. Is there a way, again to loop thru vertecis, create a BONE and assign correct vertecis to it? Can this be done outside of content pipeline, during run-time (if not, content pipeline is ok)? How can I also then parent these bones to bones of THIS or OTHER model?

Also, if all of this works great and all. How would I then draw this model, I mean which transform or bone would I use for the world matrix? Especially if I had more than just one new bone.


texts: Best way to store NPCs, Monsters, Shops, etc for JavaScript game?

texts:
OK, let's say I have a JavaScript game (preferably on jQuery framework) and its using HTML5 Canvas.

What would be your way of storing data to map out shops, monsters, and NPCs? I was thinking maybe JSON txt files on the website? Or maybe simple text files and simple delimiters? I am not sure. How would you store that kind of data?


texts: How can I handle merging and splitting lots in a city block?

texts:
I am currently working on a SimCity-style game in C# using SharpDX. I'm having trouble handling the growing and shrinking the game entities that represent zones within a region. For example:

     +-------+-------+-------+-------+
     |       |       |       |       |
     |       |       |       |       |
     |   R   |   R   |   R   |   R   |
     |       |       |       |       |
     +-------+-------+-------+-------+   Residential Zones as initially placed
     |       |       |       |       |   with low populations.
     |       |       |       |       |
     |   R   |   R   |   R   |   R   |
     |       |       |       |       |
     +-------+-------+-------+-------+

     +---------------+-------+-------+
     |               |       |       |
     |               |       |       |
     |       R       |   R   |       |
     |               |       |       |   After time, residential zones merge
     +-------+-------+-------+   R   |   to form larger dwellings.
     |       |       |       |       |
     |       |       |       |       |
     |   R   |   R   |   R   |       |
     |       |       |       |       |
     +-------+-------+-------+-------+

I'm not sure how to represent the simulation and display of this kind of behavior. At the moment, I have the following:

Each zone is represented by an individual object of type ResidentialZone.
Each ResidentialZone has a GridSpace[] property which can changed when the zone shrinks or expands.
OnGrow(): a new ResidentialZone is created combining the properties (population, education, etc.) of the 2+ that it combined.
OnShrink(): new ResidentialZones are created and divide the properties of the one they replaced.
All Zones (Residential, Commercial, Industrial, Parks, etc.) are stored in a collection of IZone within class ZoneManager which handles simulation, rendering, placement by the user.

In the eyes of more experiences game developers, does this model represent a good practice and what performance impacts may arise? Any improvements or suggestions?


texts: How to lead a moving target from a moving shooter

texts:
I saw this question: Predicting enemy position in order to have an object lead its target.  My situation is a little different though.

My target moves, and the shooter moves.  Also, the shooter's velocity is added to the bullets' velocities, i.e. bullets fired while sliding to the right will have a greater velocity toward the right.

What I'm trying to do is to get the enemy to be able to determine where they need to shoot in order to hit the player.  Using the linked SO solution, unless the player and enemy are stationary, the velocity difference will cause a miss.  How can I prevent that?

Here is the solution presented from the stack overflow answer.  It boils down to solving a quadratic equation of the form:

a * sqr(x) + b * x + c == 0

Note that by sqr I mean square, as opposed to square root. Use the following values:

a := sqr(target.velocityX) + sqr(target.velocityY) - sqr(projectile_speed)
b := 2 * (target.velocityX * (target.startX - cannon.X)
      + target.velocityY * (target.startY - cannon.Y))
c := sqr(target.startX - cannon.X) + sqr(target.startY - cannon.Y)

Now we can look at the discriminant to determine if we have a possible solution.

disc := sqr(b) - 4 * a * c

If the discriminant is less than 0, forget about hitting your target -- your projectile can never get there in time. Otherwise, look at two candidate solutions:

t1 := (-b + sqrt(disc)) / (2 * a)
t2 := (-b - sqrt(disc)) / (2 * a)

Note that if disc == 0 then t1 and t2 are equal.


texts: SDL_SetColorKey in SDL c++ removes most of the white pixels but there is a border around my character

texts:
I have drawn all of the images of my sprite in paint. Is there a way to remove all white pixels?

bool Game::loadFromFile(std::string path)
{
    free();

    SDL_Texture* newTexture = NULL;
    SDL_Surface* loadedSurface = IMG_Load(path.c_str());

    if(loadedSurface == NULL)
    {
        printf("Unable to load image %s! SDL_image Error: %s\n", path.c_str(), IMG_GetError());
    }

    else
    {
        //Color key image
        Uint32 colorKey = SDL_MapRGB(loadedSurface->format, 255, 255, 255);
        SDL_SetColorKey(loadedSurface, SDL_TRUE, colorKey);

        //Create texture from surface pixels
        newTexture = SDL_CreateTextureFromSurface(gRenderer, loadedSurface);

        if(newTexture == NULL)
        {
            printf("Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError());
        }

        else
        {
            //Get image dimensions
            mWidth = loadedSurface->w;
            mHeight = loadedSurface->h;
        }

        //Get rid of old loaded surface
        SDL_FreeSurface(loadedSurface);
    }

    //Return success
    mTexture = newTexture;
    return mTexture != NULL;
}

void Game::free()
{
    //Free texture if it exists
    if(mTexture != NULL)
    {
        SDL_DestroyTexture(mTexture);
        mTexture = NULL;
        mWidth = 0;
        mHeight = 0;
    }
}

void Game::render(int x, int y, SDL_Rect* clip)
{
    //Set rendering space and render to screen
    SDL_Rect renderQuad = {x, y, mWidth, mHeight};

    //Set clip rendering dimensions
    if(clip != NULL)
    {
        renderQuad.w = clip->w;
        renderQuad.h = clip->h;
    }

    //Render to screen
    SDL_RenderCopy(gRenderer, mTexture, clip, &renderQuad);
}

int Game::getWidth()
{
    return mWidth;
}

int Game::getHeight()
{
    return mHeight;
}

bool Game::Initialize()
{
    bool success = true;

    if(SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        printf("SDL could not initialize! SDL Error: %s\n", SDL_GetError());
        success = false;
    }

    else
    {
        if(!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"))
        {
            printf("Warning: Linear texture filtering not enabled!");
        }

        gWindow = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);

        if(gWindow == NULL)
        {
            printf("Window could not be created! SDL Error: %s\n", SDL_GetError());
            success = false;
        }

        else
        {
            gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
            sBackground = SDL_LoadBMP("BackgroundLeft.bmp");
            tBackground = SDL_CreateTextureFromSurface(gRenderer, sBackground);

            if(gRenderer == NULL)
            {
                printf("Renderer could not be created! SDL Error: %s\n", SDL_GetError());
                success = false;
            }

            else
            {
                SDL_SetRenderDrawColor(gRenderer, 255, 0, 255, 0xFF);

                int imgFlags = IMG_INIT_PNG;

                if(!(IMG_Init(imgFlags) & imgFlags))
                {
                    printf("SDL_image could not initialize! SDL_mage Error: %s\n", IMG_GetError());
                    success = false;
                }
            }
        }
    }

    return success;
}


texts: Should I do interactions between a new class and the main engine via a redirector class, or directly refer to only the classes the new class needs?

texts:
I'm making an open-source voxel engine, and there's an architectural problem that I would like an answer to. I have come up with 2 different solutions, and would like your opinions on:
When I'm creating a new class for a feature that uses the voxel engine, should the new class only refer to a big re-director class called VoxelWorld that redirects the calls to whatever component is responsible for it (solution 1), OR should the new class directly refer to only the classes it actually needs. Simply put, should the new class refer to the entire voxel engine, or just the parts it needs to?
This may be similar to a monolithic vs microservice problem?
Solution 1: All interactions go through a single entry point (I shall call it the VoxelWorld class). It's a single class, which would redirect all calls to whichever component is responsible for it. Examples of those calls would be for example VoxelWorld.GetVoxelData(position) or VoxelWorld.UnloadChunk(position). These calls would be coming from wherever, maybe a custom class made by the user such as a TerrainDeformer.
The TerrainDeformer would only have a reference to VoxelWorld, and nothing else (except for all the parameters it needs to deform the terrain, such as the deformation range). The TerrainDeformer would simply call VoxelWorld.EditTerrain(listOfModifications), and that's it. The VoxelWorld would be responsible for redirecting the EditTerrain call to whichever class is responsible for editing the terrain, for example, a VoxelWorldEditor.
The VoxelWorld.UnloadChunk call would be redirected to ChunkManager, which is responsible for managing chunks. Here's a picture to better explain it:

The public VoxelWorld would be the only public class in assembly A. Everything else is internal, meaning they are only visible for other classes inside assembly A. The assembly A is also like a black box, it is mostly (except for the VoxelWorld) hidden from the outside project. It just works, that's not a good ideology, but sometimes a necessary one. Everything in assembly B is easily extensible and public to the user. It contains the code the user would be messing with.
VoxelWorld would essentially by only a redirector of calls. It would have absolutely no logic, only redirections. A function in VoxelWorld.cs could look like this:
public void LoadChunk(int x, int y, int z){
    ChunkManager.LoadChunk(x, y, z);
}

Solution 2: Everything that the user wants to add refers to only the classes it really needs. Now, forget all that public/internal/redirecting stuff from solution 1, but keep in mind the different classes. This is kind of like the interface segregation principle, but just without the interface part.

The interface-segregation principle (ISP) states that no client [e.g.
TerrainDeformer] should be forced to depend on methods it does not use
[e.g. LoadChunk]

In solution 1, everything depends on everything. That's the blessing and the curse of solution 1. In solution 2, that's not a problem because a class only depends on what it actually needs.

Solution 2 is more traditional and maybe cleaner -> easier to maintain. I feel like I like solution 2 more than solution 1, but both seem good. Here's the main benefits and disadvantages:
Solution 1:
+Easy to use API (VoxelWorld.DoWhatever())
-It contains a black box, so it's harder for the user to extend the very core features. (Of course, it wouldn't be an actual black box, this is open source, it's just something that the user shouldn't mess with)
Solution 2:
+Easier to maintain and extend
-More difficult API, everything is scattered so the user has to explicitly know if some feature already exists (in solution 2, the user can just scroll through the suggested functions for VoxelWorld.___())
So, which solution do you recommend, and why? Or is there some third solution that I haven't thought about?
This was quite a long question, but I hope it can help others who might have the same problem. I tried googling but didn't find anything related to this kind of problem, but I didn't really even know what to search for.


texts: How to rotate something around a fixed point WebGL

texts: I have created a simple robot in webgl with cubes and now i want to rotate one "leg" around a point. But the leg is rotating around its origin. I want to rotate it around the point that connects with the body. I dont understand how to do it. How i am supposed to use translations and rotations outside of a push/pop when these translations will change the center of the world for the cubes i want to draw later on?? A little help would be appreciated. Thanks.


texts: SFML 2.4's RectangleShape is running slow when rendered multiple times

texts:
I am creating a level for my game and currently, there is a Tile class where I have a black RectangleShape rendering without any weirdness, except when I look at the FPS, its 200. Now, I have a pretty bad computer, but Normally when it just has my player texture on the screen, it was at 1200 FPS. Is this normal? I know that SFML 2.4.1 does not support batching. For that you would have to use a VertexArray. So, I replaced the RectangleShape with a VertexArray and used vertices[0].position = ... for the 4 vertices. Yet even if I set the color of the vertices to black, there are no black boxes on the screen. (This is now running at 500fps). I am sure that all the render methods are being called each frame. (window.draw(vertices);). TL;DR I need a way to optimise RectangleShape rendering within C++.

I am sincerely sorry if this is a nooby question or if the construction of this question is bad.

Thanks in advance!


texts:
I want to color polygon of box2d in LibGDX. Found below useful class for that.

http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html

But, it is not coloring the body instead making colored shapes. I want colored bodies having all the property like gravity, restitution etc. In brief, I want to make colored ball and surface.And i don't want to attach sprite on bodies. Want just fill color in bodies.

Need some guidance????


texts: stop previous audio from playing when starting a new one

texts:
I created a dialogue system with audio it works perfectly fine unless you start skipping the voice lines so then it all becomes a mess with all of the voice lines overlapping is there a way to make it so when you go to the next audio line the previous one stops playing?
Example of what is happening
as you can see in the video you can switch the text just fine and it doesn't show the previous one but for the audio, it just transforms into a jumbled mess, is there a way to fix this or to at least make it so people cant go to the next line until they finish hearing the current one?
DialogueManager Script:
public class DialogueManager : MonoBehaviour
{
public Door1Animation doorAnimation;

public Text nameText;
public Text dialogueText;
public Text changeText;

public AudioManager Sound;

public Animator textBoxAnimation;

public Queue<string> sentences;

public Queue<string> voiceLines;

void Start()
{
    sentences = new Queue<string>();
    voiceLines = new Queue<string>();
}

public void StartDialogue (Dialogue dialogue)
{
    textBoxAnimation.SetBool("Open", true);

    changeText.text = ("Aperte R para continuar");

    nameText.text = dialogue.name;

    sentences.Clear();

    voiceLines.Clear();

    foreach (string sentence in dialogue.sentences)
    {
        sentences.Enqueue(sentence);
    }

    DisplayNextSentence();

    foreach (string voiceLine in dialogue.voiceLines)
    {
        voiceLines.Enqueue(voiceLine);
    }

    PlayNextLine();
}

public void DisplayNextSentence()
{
    if (sentences.Count == 1)
    {
        changeText.text = ("Aperte R para fechar");
    }

    if (sentences.Count == 0)
    {
        EndDialogue();
        return;
    }

    string sentence = sentences.Dequeue();
    dialogueText.text = sentence;
}

public void PlayNextLine()
{
    if (voiceLines.Count == 0)
    {
        return;
    }

    string voiceLine = voiceLines.Dequeue();
    Sound.Play(voiceLine);
}

public void EndDialogue()
{
    Debug.Log("End of conversation");
    doorAnimation.openDoor = true;
    textBoxAnimation.SetBool("Open", false);
}
}

AudioManager Script:
using UnityEngine.Audio;
using System;
using UnityEngine;

public class AudioManager : MonoBehaviour
{
public Sound[] sounds;

void Awake()
{
    foreach (Sound s in sounds)
    {
        s.source = gameObject.AddComponent<AudioSource>();
        s.source.clip = s.clip;

        s.source.volume = s.volume;

        s.source.pitch = s.pitch;

        s.source.loop = s.loop;

    }

}

private void Start()
{
    Play("BackgroundMusic");
}

public void Play (string name)
{
    Sound s = Array.Find(sounds, sound => sound.name == name);
    s.source.Play();
}
}

Just the part of the interaction code so you can go to the next line/audio:
    public void Update()
{
    if (Input.GetKeyDown(KeyCode.E))
    {

        PersonInteract();
        buttonInteract();

    }

    if (Input.GetKeyDown(KeyCode.R))
    {
        FindObjectOfType<DialogueManager>().DisplayNextSentence();
        FindObjectOfType<DialogueManager>().PlayNextLine();
    }
}

Inspector view of the dialogue manager:


texts:
In dwarf fortress, there are  3 levels of maps in the screen you pick your starting position, and they all coincide with each other perfectly. I am assuming that the top level tile accounts for lets say 36 smaller map blocks, and when the player spawns on the map, that is just a noise value at a different level or frequency of even more tiles.

The selection screen looks like this:

How is such a level of coherence achieved? It doesn't seem like simply adjusting noise frequency/octave values would work perfectly, or maybe it does, I am just not grasping the workflow properly?


texts: Unity Direct Compute: Setting a struct of arrays

texts:
The NVIDIA Direct Compute programming guide lists some best practices for memory management on the GPU. One tip they give on page 8 ("Structured Buffers") is to use a 'structure of arrays' (SOA) layout rather than the typical 'array of structures' (AOS) one:

struct Particle {
    float4 position;
    float4 velocity;
};
RWStructuredBuffer<Particle> particles;

vs

struct Particles {
    RWStructuredBuffer<float4> position;
    RWStructuredBuffer<float4> velocity;
};
Particles particles;

(At least, as far as I understand)

AOS layout seems to be the most popular (maybe even only) way to manage lists of stuff in the compute shader.

I haven't found a way to implement SOA from the CPU side, Unity's ComputeShader.cs doesn't have a set struct function or similar. Does Unity expose a way to set SOA structs from the CPU side at all?


texts: Unity IOS game restart when you press the home button

texts: Why does my unity IOS game restart when i press the home button on the device? The same game worked fine on Android device and did not restart on pressing the home button. Thanks


texts: Offset during zooming to keep object within boundries

texts:
I have a simple zoom feature which lets the user zoom in and out. I'm having an issue how ever when i zoom out the object gets smaller to the point that the boundaries become broken.

The idea is the red dot stays inside the circle but the red dot never moves, its stationary in position and size.

This for example is correct because the red dot is inside the circle:

Now if i zoom out and make the circle smaller the red dot ends up outside the circle like so:

The problem i have, is i don't know how to offset the circle to keep the red dot inside of the circle regardless of zooming scale. I have a working example here: http://jsfiddle.net/3wr885so/ if you zoom out you'll find the circle doesn't fix its offset to keep everything in the right place.

The two relevant functions I used for zooming and drawing are below:

Zoom function

function zoomObj(e){
var delta       = e.wheelDelta,
    mousePos    = {};
    mousePos.x  = e.pagex;
    mousePos.y  = e.pageY;
var range = zoom.percentVal * zoom.modifier;
if(delta == 120){         //scroll in
    var endVal = zoom.position + range;
} else {                  //scroll out
    var endVal = zoom.position - range;
}

zoom.position = endVal;
zoom.percent = (zoom.position/zoom.range) * 100;

//need to set offsets to correct for new zoom here
}

Game Loop

function start(){
    var radius = obj.radius/100*zoom.percent;
    if(radius < 0){ radius = 0; }
    ctx.clearRect(0,0,canvas.width,canvas.height);
    ctx.beginPath();
    ctx.arc(camera.offsetX, camera.offsetY, radius ,0,2*Math.PI, false);
    ctx.restore();
    ctx.lineWidth = 1;
    ctx.strokeStyle = 'black';
    ctx.stroke();

    ctx.setTransform(1, 0, 0, 1, 0, 0);
    ctx.beginPath();
    ctx.fillStyle = 'red';
    ctx.fillRect(canvas.width/2-5,canvas.height/2-5,10,10);
    ctx.stroke();

}

Any suggestions how i fix this problem :) ?


texts: How do I debug Azure Spatial Anchors with Unity on an Android device?

texts:
I've been building an AR app that's already been a pain to debug, because instant preview refuses to work over wifi and usb debugging causes the phone camera to not display on the phone itself. Now I'm at the point where I can integrate Azure Spatial Anchors and I cannot seem to be able to be able to play in the editor. I receive the message:

DllNotFoundException: azurespatialanchorsndk
Microsoft.Azure.SpatialAnchors.CloudSpatialAnchorSession..ctor () (at Assets/AzureSpatialAnchorsPlugin/Plugins/Common/AzureSpatialAnchorsBridge.cs:6864)
SpatialAnchors.GetCloudManager () (at Assets/Scripts/SpatialAnchors.cs:60)
tester.Start () (at Assets/tester.cs:18)


texts: Do the sprites inside a PoT spritesheed need to be PoT aswell?

texts: I use TexturePackerGUI to create PoT spritesheets. But do the sprites inside the spritesheet need to be PoT aswell? If they need to, do I need to disable trimming? The framework I use is libGDX.


texts: Physics2D raycasting with a perspective camera and tilted sprites

texts:
So i ran into this problem today. I want to have a perspective camera and sprites that are rotated by lets say 1.5 on the X axis. The problem is that the 2D raycast does not work correctly, it returns the wrong colliders. Here is the implementation:

Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            RaycastHit2D hit = Physics2D.Raycast(mousePos, Vector2.up);
            if(hit.collider)
            {
                Debug.Log(hit.collider.gameObject.name);
            }

Now if my  camera is orthographic everything works great. How can I make it work with a perspective camera? Should I use 3d colliders and raycasts ?


texts:
I am trying to do a Minecraft-like game (like every one have already tried I guess) and i went across the problem i expected: lag with world Generation. I did lot of searching but i can

I tried to combine them into a bigger mesh, which work, but not i can destroy a single block. So how can I place/destroy chunked (mesh combined) block? If i cant, can someone clearly explain me a solution (i am not fluent in english nor with programming expressions, i can code tho) and how to do it (with a script example if possible :) ) ? Thanks in advance !

I generated my world using 2D perlin noise. Once i have the blocks, i split them into 16x16x100 chunk meshes.

Before Making chunks, i first tried to combine all of them into one block (using the unity manual), but the result is only one cube placed at 0,0,0. Where are all the other cubes ?

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class ThisWorldGen : MonoBehaviour {

public GameObject blockPrefab;
public GameObject grass;
public GameObject dirt;
public GameObject rock;
private string[] blockTag;
private GameObject stockin;

public int amp;
public int freq;
private Vector3 mypos;
[SerializeField]
private Material material;
private Vector3 blockLocations;

public List<MeshFilter> meshes = new List<MeshFilter>();

void Start()
{
    Generate();
}

void Generate()
{
    amp = Random.Range(0,100);
    freq = Random.Range(30,100);
    mypos = this.transform.position;
    int cols = 100;
    int rows = 100;
    float startTime = Time.realtimeSinceStartup;
    #region Create Mesh Data
    MeshFilter blockMeshes = Instantiate(blockPrefab, Vector3.zero, Quaternion.identity).GetComponent<MeshFilter>();

    for(int x = 0; x < cols;x++)
    {
        for(int z = 0; z < rows;z++)
        {
            float y = Mathf.PerlinNoise ((mypos.x + x) / freq,(mypos.z + z)/freq) * amp;
            y = Mathf.Floor(y);
            for(float hy = y; y > 0.0F; y -= 1.0F)
            {
                blockMeshes.transform.position = new Vector3(mypos.x + x,y,mypos.z +z);//move the unit cube to the intended position
                meshes.Add(blockMeshes);
            }
        }
    }
    int i = 0;
    MeshFilter[] listMeshes = new MeshFilter[meshes.Count];
    foreach(MeshFilter cubesToAdd in meshes)
    {
        listMeshes[i] = cubesToAdd;
        i++;
    }
    CombineInstance[] combine = new CombineInstance[listMeshes.Length];
    int w = 0;
    while(w < listMeshes.Length)
    {
        combine[w].mesh = listMeshes[w].sharedMesh;
        combine[w].transform = listMeshes[w].transform.localToWorldMatrix;
        listMeshes[w].gameObject.SetActive(false);
        w++;
    }
    Debug.Log (combine.Length);
    transform.GetComponent<MeshFilter>().mesh = new Mesh();
    transform.GetComponent<MeshFilter>().mesh.CombineMeshes(combine);
    transform.gameObject.SetActive(true);
    #endregion
    Debug.Log("Loaded in " + (Time.realtimeSinceStartup - startTime) + " Seconds.");
}
}

(the world was generating randomly and perfectly before trying to merge the meshes)


texts: How to share battle execution code between client and server?

texts:
We're making an online turn-based game. There's some logic that is executed in both client and server side. Here's the pseudocode that shows how we share the code:
// Shared Code
class BattleExecutor {
  constructor(eventHandler)

  void ExecuteTurn(userInputs) {
    ......
    trigger events such as Move, Fire, TakeDamage
    ......
  }
}

// Server
new BattleExecutor(noOperationHandler)

// Client
class ClientEventHandler {
  // play Move, Fire, TakeDamage anime
}

new BattleExecutor(new ClientEventHandler())

In this design, the shared BattleExecutor has the logic of how game is played. Client code is just to play the anime for the events that triggered in BattleExecutor. Server needs the BattleExecutor to determine if user inputs are valid and to determine battle result (who won).
Now our problem is, think of this scenario, in one turn BattleExecutor triggers a Fire and a TakeDamage event within 1 millisecond. But in client side TakeDamage can only be played when Fire anime is done (bullet flying takes time). How to control the playing of events in client side?
The solution we're considering is to add "Id" and "DependOnIds" property to Event class, meaning that BattleExecutor provides the information of "event A should happen after events B, C, D". Client knows when anime of B, C, D is done playing, after which client starts playing anime of A. This solution looks a little messy to us, because BattleExecutor now needs to figure out the dependency of events which server doesn't care about at all.
Is there any more elegant solution that can share battle execution code between client/server and allow client to control the playing of events correctly?


texts: Need to join 2 bodies via weld joint but not on center of mass

texts:
I have successfully join 2 bodies via weld joint , but my problem is I want to join corners of bodies not on centre of mass. Is there any way to achieve this?

Above image consist 3 polygon body that I want to join via weld joint. feel free to ask more information.
Any help will be appreciable.


texts: Displaying (3D) objects' name above them

texts:
The Elder Scrolls: Morrowind has a rather interesting way to display each focused objects' name. It's all a bit fuzzy in my memory right now, but the most important part I remember perfectly: the object's name is always displayed in the proximity of the object (most of the time on top of it).

My question is: given a 3D mesh, how should I proceed to calculate the name's position on the screen? I'd like to always position it on top of the given mesh for now. Like in this screenshot of Morrowind:

I'm working under Unity, if it helps. The first thing that comes to my mind is to somehow use the distance between the player and each object, then take the object's actual height in consideration, and determine a line in 2D space (the screen) that just "touches" (intersects) the top of the 2D representation of the mesh (what we're actually able to view on the screen). Something like this:

But this feels a bit complicated and clunky, and might not work for characters that are not standing tall for example.

The 2nd thing that comes to my mind: would there be a way to achieve this using matrix multiplication, in the same way 2D representations of 3D objects are obtained?

Thanks!


texts:
The following is taken from my current understanding of spherical harmonics. There may be errors involved which solve my question if they're resolved, so please notify me if I misunderstood something.

Evaluating reflected diffuse indirect illumination at a surface point is done by computing the integral (simplified rendering equation) in the last line of

(stolen from here).

An important property of functions in SH representation is that the integral in the last line boils down to a dot product between the vectors containing the SH coefficients for projected functions L(x,omega_i) and max(N_x dot omega_i,0).

For example, for each surface point in our target image that we wish to compute indirect illumination on, L(x,omega_i) is available in a precomputed vector of a 4 elements (for 2 bands SH approximation) containing spherical harmonics coefficients. It's not really important where it came from, just that it's available at this point.

From my understanding, to actually evaluate the lighting at a surface point [x] is to project the function max(N_x dot omega_i,0) into spherical harmonics, and dot it with the coefficient vector of the incoming radiance (and then, multiply it by the stuff in front of the integral, surface albedo / pi).
The first 4 coefficients (2 bands) for max(N_x dot omega_i,0) projected into SH basis are known, they are:

c_0 = 0.88622692545...

c_1 = -1.02332670795 * n_y

c_2 = 1.02332670795 * n_z

c_3 = -1.02332670795 * n_x

So the irradiance at that surface point with normal n would just be

E = dot(L_sh,n_sh)

where L_sh is the coefficient vector for the incoming radiance, and n_sh the coefficient vector for the cosine lobe that we just calculated. Specifically, L_sh is the same max(...) function projected into SH basis [with the normal from which the light originated], just scaled a little by the color its transporting.

The above actually looks fine and seems to produce somewhat correct lighting (hard to judge without ground truth reference). What's confusing me now, is that I've come across several sources (for example here, page 17), which, in the final step, when evaluating the lighting, don't actually use the coefficients from above to project max(N_x dot omega_i,0) into SH basis, but instead calculate n_sh as

n_sh0 =  0.282094792f

n_sh1 = -0.488602512f * -n_y

n_sh2 = 0.488602512f * -n_z

n_sh3 = -0.488602512f * -n_x

These four coefficients are actually just the spherical harmonics basis function coefficients parametrized in cartesian coordinates (here they are for spherical coordinates).

What's up with that? Why aren't they projecting the max(...) function into SH basis instead? Am I misunderstanding something? Unfortunately, the usual sources (gritty details and stupid SH tricks) don't seem to go into details of this either.


texts: Application design for specific points on image

texts:
Hi guys I am starting a simple hobby app in Unity, its a 2D app, which have some alphabets like A,B,C..Z (images) . There ll be specific paths where user touch one by one to complete drawing the alphabet, like image below. Now I have some solutions for it in my mind:

Make a grid of small boxes/planes with colliders on complete alphabet character, and enable some of its planes, like in image the "red" line ll have small planes behind it with colliders enabled (planes with colliders on "yellow" and "blue" line ll be disabled) "red" plane colliders are triggered with some texture when user clicks/touches on that plane wo show some color on touch point. Thats how complete alphabets can be done with one grid.
Create mesh colliders for every alphabet in 3dsMax or any other modeling tool and enable them one by one. For e.g first enable "red" line collider then "yellow", then "blue". But this ll require to make collider for every curve and changing design ll require re work.
Picking specific pixel set on the image, e.g to first pick red area pixels, if user touching on these pixels then true else false.

I would like if some can have a better solution of it ? may be any optimized way, may be some variation of custom colliders, bounds, line renderes, curves etc.


texts:
There are some effects for which I must do multi-pass rendering. I've got the basics set up (FBO rendering etc.), but I'm trying to get my head around the most suitable setup. Here's what I'm thinking...

The framebuffer objects:

FBO 1 has a color attachment and a depth attachment.
FBO 2 has a color attachment.

The render passes:

Render g-buffer: normals and depth (used by outline & DoF blur shaders); output to FBO no. 1.
Render solid geometry, bold outlines (as in toon shader), and fog; output to FBO no. 2. (can all render via a single fragment shader -- I think.)
(optional) DoF blur the scene; output to the default frame buffer OR ELSE render FBO2 directly to default frame buffer.
(optional) Mesh wireframes; composite over what's already in the default framebuffer.

Does this order seem viable? Any obvious mistakes?


texts:
I'm currently working on a Java MMO with a pretty solid start, but I've come across an issue I need a little help with.

I'm working on player positions. Meaning their X/Y on the screen, if the PlayerA has a higher FPS (Frames Per Second) than other players, the resulting action will be that PlayerA will move faster than everyone else. I know the reasoning for this, it's because when the game draws I just use x++.

What would a better method be?


texts: How to Replace two object by rotating in center

texts:
I created Find Rock game but I have problem In replacing two object by rotating in center and when rotating finish stop rotating how can I do this?

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
    public GameObject[] obj;
    public int[] Randomize = new int[2];

    void Start(){
        StartCoroutine (Delay ());

    }

    IEnumerator Delay(){
        Randomize [0] = Random.Range (0, obj.Length);
        Randomize [1] = Random.Range (0, obj.Length);
        while (Randomize [0] == Randomize [1]) {
        Randomize [0] = Random.Range (0, obj.Length);
        }
        yield return new WaitForSeconds (2);
        obj [Randomize [0]].transform.rotation = Quaternion.Euler (new Vector3 (0, 0, 0));
        obj [Randomize [1]].transform.rotation = Quaternion.Euler (new Vector3 (0, 0, 0));

        StartCoroutine (Delay ());
        }
    void Update(){
        if (obj [Randomize [0]].transform.rotation.eulerAngles.y < 90 || obj [Randomize [1]].transform.rotation.eulerAngles.y < 90) {
            obj [Randomize [0]].transform.RotateAround (obj [Randomize [1]].transform.position, Vector3.up, Time.deltaTime * 100);
            obj [Randomize [1]].transform.RotateAround (obj [Randomize [0]].transform.position, Vector3.up, Time.deltaTime * 100);
        }
    }
}

I can make this game but when rotating finish they aren't Directed.
this video link describe my problem and this is unity package of my game.
how can I use mathf clamp RotateAround for stopping rotation?!


texts: Unity 3D - Rotate (smoothly) towards a target

texts:
I wanted to know if there is a method on which I can rotate an object with an angle given (a float to be precise), I use trigonometry to calculate the angle between the two objects in a (x, z) plane perspective (using y as the height coordinates).

This is the code I use to calculate the angle, but I want to know if a float would be anough data (then pass a Vector3 with that angle calculation as the Y parameter, since I want to rotate the Y axis).

//Makes the player heads to the direction the ball is...
public float headOnBall()
{
    Vector3 playerPos = this.transform.position;
    Vector3 ballPos = ball.transform.position;

    float angle;
    float x = (playerPos.x - ballPos.x);
    float z = (playerPos.z - ballPos.z);

    if(playerPos.z < ballPos.z || playerPos.x < ballPos.x && playerPos.z < ballPos.z)
    {
        angle = (Mathf.Atan2(z, x) + (Mathf.PI * 2)) * Mathf.Rad2Deg;
    }
    else
    {
        angle = Mathf.Atan2(z, x) * Mathf.Rad2Deg;
    }

    return angle;
}

Thanks in advance.


texts: Should I use float, double, or decimal for stats, position, etc?

texts:
The problem with float and double is that they are not exact. If you are to do something like store replays, the values would have to be exact.

The problems with decimal is that they are approximately 16x slower (confirmed by searching and personal testing) than floats and doubles.

Couldn't Vector2s be another problem because they use floats internally for all the components?

How do other games solve this problem? I'm sure they must use floats and doubles but aren't they not deterministic across platforms and different architecture?

The replay files for games like SC2 run in a linear fashion so you cannot skip ahead so how do they solve the determinism issue with floating point numbers?


texts: LibGDX search for file types in local file system

texts: I'm building a system that allows users to upload files to LibGDX's local directory to play them in the game. How can I search recursively through the local file system for a specific file type and return all returned files?


texts: How to Render and Blend Multiple Frames to a Buffer in Unity?

texts: I was wondering if anyone knew how to render multiple frames from a camera or texture to a buffer in Unity and to then blend them together? Is this possible? If so how would I go about doing so in Unity?


texts:
I have an enum in my game that denotes the game state ie MainMenu, InGame, GameOver, Exit
and I was wondering if it would be advisable to add a new one in for PrepGame - in which the game creates viewports for however many players there are, creates the battlefield etc.

I feel like this is a good idea except for one thing: should I make a call back to LoadContent() in this state? I could just put a switch statement in the LoadContent for my currentGameState. If it equals PrepGame load things like the skybox, ship models, texures, HUD graphics etc. Or is it a good idea to create an Asset Manager class in the first call to LoadContent() and load everything then.

I feel like both approaches have different benefits: faster, but more load times vs slower initial load time, but then all my objects are referencing the same variables so I only have to load each on once.

Any help is greatly appreciated.

Thanks,
Peter


texts: Moving a sprite towards an x and y coordinate

texts:
Given a sprite with an x and y coordinate, how would I move it toward another sprite with an x and y coordinate?

I've already made it face towards the other sprite, and I've made it move towards the other sprite, however because I'm using sin and cos it's circling the player and slowly moving in on them. Here's the method:

Enemy.prototype.update = function(playerX, playerY) {
    // Rotate us to face the player
    this.rotation = Math.atan2(this.y - playerY, this.x - playerX) - 2.35;

    // Move towards the player
    this.x += Math.sin(this.rotation) * this.speed;
    this.y -= Math.cos(this.rotation) * this.speed;
}

How can I get the sprite to just move towards the player in a straight line rather than a circle? I found a good example but it uses XNA Vector2's so it's not working with x and y positions directly.


texts: How do I know if memory isn't being handled right?

texts:
My (2D) game's memory footprint seems to increase any time I load a texture, e.g. when I start my game it uses 30 mb private RAM, after transversing a ~367mb background file, so it's all in RAM at some point, it increases to 54 mb private RAM.

The same thing happens after going the same distance but going back and forth between two points repeatedly.

However, my readouts are showing that the program is correctly calling glDeleteTextures about a second after textures go off screen; and valgrind isn't finding any leaks.

How do I know if I should be worried about this, or if it's just a quirk of how the OS pages memory?


texts: Farseer physics engine: The name 'ConvertUnits' does not exist in the current context

texts:
http://digitalerr0r.wordpress.com/2012/03/11/farseer-physics-in-xna-4-0-for-windows-phone-1/

I tried this Farseer tutorial but I always get that error message in the following lines:

spriteBatch.Draw(rectangleSprite, ConvertUnits.ToDisplayUnits(rectangle.Position),
                                        null,
                                        Color.White, rectangle.Rotation, new Vector2(rectangleSprite.Width / 2.0f, rectangleSprite.Height / 2.0f), 1f,
                                        SpriteEffects.None, 0f);

        spriteBatch.Draw(rectangleSprite, ConvertUnits.ToDisplayUnits(rectangle2.Position),
                                        null,
                                        Color.White, rectangle2.Rotation, new Vector2(rectangleSprite.Width / 2.0f, rectangleSprite.Height / 2.0f), 1f,
                                        SpriteEffects.None, 0f);

        spriteBatch.Draw(rectangleSprite, ConvertUnits.ToDisplayUnits(rectangle3.Position),
                                        null,
                                        Color.White, rectangle3.Rotation, new Vector2(rectangleSprite.Width / 2.0f, rectangleSprite.Height / 2.0f), 1f,
                                        SpriteEffects.None, 0f);

What is wrong? I added the two usings to my code but I always get this error message:
The name 'ConvertUnits' does not exist in the current context


texts: How can I effectively manage a hobby game project?

texts:
How can I successfully finish a hobby game project in my free time?

How do I motivate myself to keep it up and drive right through to the finish without losing interest or motivation along the way?


texts: C++ -- How could I create a list that contains functions, and would either run the top or iterate through and run all?

texts:
I'm not sure how to phrase this to be perfectly accurate to my goal implementation

I need a dynamic scene/menu system. I'm going to create a base class and inherit in two other classes specific to either rendering a scene or controlling a menu chain. From here I'll be creating functions with specific draw characteristics (such as a specific menu) and run them into my draw function.

What type of container system would work? I need it to be able to both run only the top and run all of the ones loaded in it (I specify because you cant iterate through a stack, from what I'm told)


texts:
By profiling my game, I see that the vast majority of the execution time of my hobby game is between the blit and the flip calls. Currently, it's only running at around 13fps. My video card is fairly decent, so my guess is that pygame is not using it.

Does anyone know of any graphics/display options I need to set in pygame to make this faster? Or is this just something that I have to live with since I've chosen pygame?


texts: Rigidbody2D hanging when moving across set of colliders (tiles)

texts: I've got a player object that has a Rigidbody2D and CircleCollider2d attached to it, and I'm trying to make it move across a large field of tiles, each exactly next to one another and each identical in size. For some reason, the player object occasionally gets stuck on what looks to be points between tiles. Any ideas on why this is happening, or what I can do to fix it? Thanks!


texts: How can I use spectrum data to calculate energy values of certain frequency bands?

texts:
I'm working on a rhythm game, and need to detect beats in a piece of music.

After all the research and reading through old posts in unity forum/reddit etc., as far as I understood, I need to calculate the average energy, and if there is a sudden energy change/spike, I want to register them as beats.

So here's the thing as far as I understood ;

 public class something : MonoBehaviour {

     public AudioSource audioSource;

     public float[] freqData = new float[1024];

     void Start ()
     {
         audioSource = GetComponent<AudioSource> ();
     }

     void Update ()
     {
         audioSource.GetSpectrumData (freqData, 0, FFTWindow.BlackmanHarris);
     }
 }

Let's say I have this code in place. My sampling rate is at 48000 Hz. The array size determines the frequency range of each element. So with a size of 1024, my frequency resolution is 23.4 Hz. So freqData[0] represents the freq between 0-23.4 Hz. freqData[1] represents 23.4-46.8 Hz. so on and so forth. And I want to detect, let's say bass beats between 60Hz and 250 Hz.

How can I translate this data into the average energy value for this frequency band?


texts: How important do you find exception safety to be in your C++ code?

texts:
Every time I consider making my code strongly exception safe, I justify not doing it because it would be so time consuming. Consider this relatively simple snippet:

Level::Entity* entity = new Level::Entity();
entity->id = GetNextId();
entity->AddComponent(new Component::Position(x, y));
entity->AddComponent(new Component::Movement());
entity->AddComponent(new Component::Render());
allEntities.push_back(entity); // std::vector
entityById[entity->id] = entity; // std::map
return entity;

To implement a basic exception guarantee, I could use a scoped pointer on the new calls. This would prevent memory leaks if any of the calls were to throw an exception.

However, let's say I want to implement a strong exception guarantee. At the least, I would need to implement a shared pointer for my containers (I'm not using Boost), a nothrow Entity::Swap for adding the components atomically, and some sort of idiom for atomically adding to both the Vector and Map. Not only would these be time consuming to implement, but they would be expensive since it involves a lot more copying than the exception unsafe solution.

Ultimately, it feels to me like that time spent doing all of that wouldn't be justified just so that the a simple CreateEntity function is strongly exception safe. I probably just want the game to display an error and close at that point anyway.

How far do you take this in your own game projects? Is it generally acceptable to write exception unsafe code for a program that can just crash when there is an exception?


texts:
Is there a commonly-accepted general approach to the order of processing logic updates?

My current 2D platformer has objects that implement different concerns, including the following:

Notifiable - can be event-driven and scripted
Collidable - can interact with solid tiles (eg NPCs)
Intersectable - exists in 2D space and can intersect with the player (eg doors)

In general the order of events in a game loop is:

Get input
Act on input and update stuff
Render

I'm not sure what order to do things in point #2. I've concluded moving things like moving platforms that the player can stand on first is a good idea, but I don't know when to consider scripting. The scripting in my game can give NPCs behaviours (walk between here and there), suspend player input for 'cutscenes', show dialog screens, and move the player to a new level.


texts: How to simulate destruction/damage of household objects?

texts:
I'm looking for a method to simulate various objects' damage and destruction.
As far as I can see, Unreal Engine 4's Chaos can only simulate buildings, but I'm more interested in other type of objects. I found DestroyIt for Unity, but the author must manually create all destructions which is not really a simulation.
For example, if I had a TV sitting on a table, how could I simulate both the TV's and table's realistic destruction if something heavy falls on top of them?


texts: I've been trying to install PyGame for Python, and can't seem to get Python to recognize that it's there.  I use Python 3.3, and have a 64-bit Windows computer, but that's really all I know.  The PyGame website has piles of different versions of the installer, but I can't seem to find the right one.  Either they let me install it but then starts spitting errors (basically saying the module doesn't exist, when it does), or I get this sort of set-up program that keeps saying it's not in my "registry".


texts: How to produce assets effectively on large Flash game projects?

texts:
I have been working on Flash games professionally for two years now and somehow, having our artists producing assets the right way is one of our biggest challenge.

More precisely, it is very hard to have them following any kind of structure and/or standards, nor taking into consideration performance. I would say also the most of our issues concerns UI and related animations.

Our current workflow is (on a Facebook hidden object game) :

Artists produce PSD and animate prototypes in Flash
Artists re-organize their FLA files to be a bit more "programmer friendly"
Programmers retouches assets until they have the right structure and export classes inside a SWC, from Flash
Programmers try to improve performances, sometimes degrading the quality of game graphics

Our main idea is to hire somebody dedicated to prepare assets for programmers but I am really looking forward to improving the pipeline.

I was wondering if you guys have tips of any kind to improve this workflow, whether it be team organization, training, tools or tips with Flash. Any explanation on your asset pipeline is well appreciated too.

EDIT :

Thanks for your replies. I do agree with you that tools and processes will never replace collaborative people. However, I feel like we got stuck into this "I am doing my own thing" mentality as the integration process caused a lot of friction. As part of our Scrum process, the team clearly acknowledge its own quirks and was looking at immediate solutions for the next project : better rules, better attitude, better understanding of each other.

My team have specialized artists (UI, character drawing, character animation), but no leading art director (we use existing licenses/brands), and programmers (both front and back end). That's why having a very versatile person in between (designer, integrator, technical artist or however you want to call it) is invaluable in my opinion - so, I am looking for innovative solutions.

Usually, the main specs/requirements for assets are :

Naming (of classes, textfields or various visual objects that will be used by the code, taking in account that visual needs can cause deep nesting of objects)
States (that we implemented with frame labels)
Alignement (always build from 0,0 - use round values)

So, while adopting "good practices" can sure help, there always is this little part of feature-specific requirements that has to be decided. Basically I was looking for a an efficient way to communicate these specs (even to non-technical people) and avoid the back and forth to verify assets are as expected (this is where my idea of intermediate validation format comes from).

I understand there is no clear answer and I created this post to get people feedback and good ideas (it's working so far :)


texts:
It's like this: I've got this very simple game in mind, and I happen to be lucky enough to know this guy at my college who is the best musician I've ever met in person who wasn't already on a stage. He writes these beautiful songs on piano, just meandering and mysterious. They'd add so much as background music.

But here's my dilemma: say I record a 5 minute long song from him. How do I use it? Do I set it playing, and then make it start over as soon as it ends? Do I leave a 5 minute period of silence and then start it over again? Or do I find other music and just have continuous music playing? What do other people usually do for this sort of thing?


texts: Why large builder classes rather than separate clases in component-based entity systems?

texts:
I was reading about component-based entity systems and I was wondering why there is usually a large EntityBuilder class with methods like CreatePlayer(), CreateEnemySpaceship(), and CreatePowerup(), all creating an entity, attaching some components, and returning the entity.

The class has the potential to get quite large given enough different entities and having to search this large code-file can eventually become quite cumbersome. Also, with this system, since all entities are of type Entity, to determine what something actually is, you would have to add some sort of TypeComponent to the entity which may contain a string like "Player", "Enemy", and "Powerup". Now you lose some benefits of strong typing and have to rely on personal memory more (bad in my opinion).

Another problem with this setup is the inability to use function overloads based on what type the entity is. Instead one would have to use hashtables based on some identifying component which is a bit ugly.

I was wondering, instead of having these large builder classes and cumbersome ways of determining what an entity really is, why not just have separate classes for each entity? Well, that is what we were doing but they resulted in large and complex hierarchies, right? Well, I'm not advocating large hierarchies. Rather, move every method from this monolithic builder class to a separate class deriving from Entity and place that code in the constructor. No multiple-inheritance. No large trees. Example: Both Ship, Spaceship, and EnemySpaceship would all derive from Entity and only Entity.

This could be useful for determining the types of entities when a collision occurs and how to proceed with handling the event. The classes themselves would basically be empty except for the constructor logic in how to construct the entity (attaching components and whatnot). This solution seems to be a lot more extendable as well, considering if one would ever need to modify the creation process of an EnemyEliteFighterSpaceship, rather than searching through some large builder class, just go to that class file.

Am I missing something here? I suppose, if all else, my real question would be of an elegant way to determine what an entity is when it collides with another entity so some action could be taken (increase score, play sound, etc.). I initially tried setting up some sort of TypeComponent but it just seems a bit hackish as opposed to simply deriving from the base Entity class. Also, deriving from a base entity class gives strong-typing and type-safety support, gets rid of the public static builder class, and allows for polymorphic behavior and ease of determining an entity's type.

So I'm wondering, with all these positives and no perceivable negatives (other than .. more files? organization trumps file count in my opinion), why do most component systems favor these large builder/factory classes rather than my proposed approach?


texts:
I've recently created a shuffle-type puzzle game for mobile (with Unreal Engine 4), where you, obviously, solve these puzzles.
Since I didn't know how to do this puzzle mechanic in UE4, I went to UE4 - Slide Puzzle Pt.1 by Nicholas Thompson.

The problem:
Somewhat halfway through the tutorial, I stumbled on a very important issue: the block / tile of the puzzle wasn't moving when clicked on.

What I did:
I then rewatched the whole tutorial again, and didn't find anything wrong. I tried placing Print Strings on Bind Event to OnClicked, it worked, then I placed it on Mesh Clicked, and it didn't.

Cause of problem:
After I debugged, I found out that Move To was not called because for some reason, Is Valid...didn't work? (This is found at the end of the chain in the Mesh Clicked custom event.)

The code for the Event Graph is pasted here.
I have been trying to fix this problem for days, help would be very much appreciated! Thank you!


texts: How to implement the rag doll physics in OpenGL?

texts:
I'm wondering, having a human model made in blender, how can you make it so that at some point (when the human "dies") the body follows the rag doll physics in OpenGL? I tried looking for some tutorials but I can't found one that fits my requests.
Specifically how do you make rag doll physics in OpenGl (and if needed using Blender)?


texts:
I came up with some cube rotating, but I could not make it smooth and easy to use because as the cube turned - the keys that handle the turning changed their purpose. Link to demo. The demo rotation is done by increasing euler angles and using Quaternion.Euler() to get a quaternion for Quaternion.Slerp().

The ideal rotating would be like below: the keys stay the same, no matter how the cube is rotated. A/D turn the cube from "left/right". W/S turn the cube "up/down". Q/E turns the cube's current face.

But I have no idea where to start when making the above. How could the above be achieved?

EDIT
Rioki's answer solved this question. I was previously using local rotation but changing it to world rotation fixed this. Link to demo.


texts:
I opened a blank project that came with two types of flooring, a table with two chairs and a statue.

The only things I modified was the size of one of the floors and the texture of the two floors.

When I did this, the following message appeared: LIGHTING NEEDS TO BE REBUILT (2 unbuilt objects)

I clicked on the option below (Compile Only Lighting):

Compilation failed (view image below), the following error appeared (0xc000007b):

Note that the Swarm Agent is working.

I restarted the program several times. I cleared the cache. I fixed the program. I started a new project. All this did not result in anything.

Below are some links that I researched and tried to solve the problem, doing almost everything I was told:

https://answers.unrealengine.com/questions/201327/lightning-build-failed-swarm-failed-to-kick-off.html

https://answers.unrealengine.com/questions/12975/unreal-engine-wont-launch-error-code-0xc000007b.html


texts: Poor performance in android when running APK, runs fine in browser

texts:
I have created a small game project in HTML5 using Phaser engine (tried both 1.1.5 and 1.1.6). Then to port it to mobile platform, used Phonegap/Cordova for Windows Phone 8, Android and iOS.

In my game, there are around 10 elements, which get animated (moving from point a to point b and some rotation at same time). On iOS and Windows Phone 8, I didn't face any issue.

But with Android, performance is unacceptable. On the other hand, if I run my game via device browser, it run smooth without any lag. But compiled APK runs very jerky and elements move very slow & in flickering manner.

I have checked android hardware acceleration flag is set to "true" in manifest file. Tried changing it false too, but that didn't reflected any change in performance.

I have checked same on Android 4.2 on Samsung S2 device and on that performance is better. But on Asus Nexus Tab 7 (running Android 4.4) its very jerky, while the OS and Device both are latest. Also checked on another device running Android 4.3 (Samsung Galaxy Grand Duos) and on that too performance is not good at all.

In my game tried both WebGL / Canvas rendering (Phaser engine uses Pixi.js, which fallback to 2d canvas if WebGL isn't supported), but no change. Similarly with easeljs.

If anyone else faced similar issue and can suggest any way to get native like performance. I checked cocoonjs examples and while they seems smooth and acceptable, I can't go for that route.


texts:
I have tried to make game with libgdx

I want to create 3x3 grid in the middle of screen
I ran the desktop project, it seems that not much problem at all,
but if I resize the windows the 3x3 grid move towards the lower left of the screen
(I want to make it always in the center of screen regardless of the screen size change)

What are the problem in my code, I am a new to game developing.

public class GameScreen implements Screen {

    MyGdxGame game;
    SpriteBatch batch;
    Texture img, item;

    public GameScreen(MyGdxGame game) {
        this.game = game;

        batch = new SpriteBatch();
        // a 640x480 image for testing background position
        img = new Texture(Gdx.files.internal("640Wx480H.png"));
        // a 64x64 image for grid item
        item = new Texture(Gdx.files.internal("badlogic.jpg"));
    }

    @Override
    public void render(float delta) {
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        Gdx.gl.glClearColor(1, 1, 1, 1);
        batch.begin();
        batch.draw(img, 0, 0);
        float itemSize = item.getWidth();
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                batch.draw(item, itemSize * i + (Gdx.graphics.getWidth() - (itemSize * 3)) / 2, itemSize * j + (Gdx.graphics.getHeight() - (itemSize * 3)) / 2);
            }
        }

        batch.end();
    }

    @Override
    public void resize(int width, int height) {
    }

    @Override
    public void show() {
    }

    @Override
    public void hide() {
    }

    @Override
    public void pause() {
    }

    @Override
    public void resume() {
    }

    @Override
    public void dispose() {
        img.dispose();
        item.dispose();
    }

}

public class MyGdxGame extends Game {

    GameScreen mainGameScreen;
    private Viewport viewport;
    private OrthographicCamera camera;

    @Override
    public void create() {
        camera = new OrthographicCamera();
        camera.setToOrtho(false, 640, 480);
        viewport = new FitViewport(640, 480, camera);
        mainGameScreen = new GameScreen(this);
        setScreen(mainGameScreen);
    }

    public void resize(int width, int height) {
        viewport.update(width, height);

    }

    public void render(float delta) {
    }

    public void dispose() {

    }
}


texts: AABB 2D Collision response teleports player when hit on wrong edge

texts:
I'm currently breaking my head with collision detection and resolving in C++ for my 3D game engine. But currently I'm trying to get resolving to work in 2D.
The problem is that when I hit the solid object with my moving object on a specific side, it teleports the player to the edge. It's a bit hard to explain, so I gave my artistic skills a run:

Here you see, if my moving object travels from the bottom up and hits on the right side, everything works. But even if there is a little bit of an overhang on the left side, it teleports the player completely to the edge.
And it does that on every side of the AABB.

I also made a short video visualizing the problem.

This is my function to return the overlapping values:

glm::vec3 Collider::getOverlapping(AABB &other, AABB &aabb) {
    glm::vec3 overlappingAxis;

    if( (std::abs(aabb.first()->x - other.first()->x) * 2 > (aabb.size()->x + other.size()->x)) ||
        (std::abs(aabb.first()->y - other.first()->y) * 2 > (aabb.size()->y + other.size()->y)) ||
        (std::abs(aabb.first()->z - other.first()->z) * 2 > (aabb.size()->z + other.size()->z))){
        return overlappingAxis; //No collision occured
    }

    overlappingAxis.x = sign(aabb.center()->x - other.center()->x) * ((other.size()->x/2 + aabb.size()->x/2) - std::abs(aabb.center()->x - other.center()->x));
    overlappingAxis.y = sign(aabb.center()->y - other.center()->y) * ((other.size()->y/2 + aabb.size()->y/2) - std::abs(aabb.center()->y - other.center()->y));
    overlappingAxis.z = sign(aabb.center()->z - other.center()->z) * ((other.size()->z/2 + aabb.size()->z/2) - std::abs(aabb.center()->z - other.center()->z));

    for(int i = 0; i < 3; i++){ //Add a bit of an offset so that it actually moves out of the collision
        overlappingAxis[i] += sign(overlappingAxis[i]) * 0.0005;
    }

    return overlappingAxis;
}

My method(s) to figure return if there is actually an collision:

bool Collider::isColliding(AABB& other, glm::vec3& axis, AABB& aabb) {
    axis = getOverlapping(other, aabb);
    return !(axis == glm::vec3(0, 0, 0));
}

bool Collider::isColliding(AABB &other, glm::vec3 &axis) {
    return isColliding(other, axis, *m_aabb);
}

My collision resolving method:

void Collider::resolveCollisions(AABB& other, glm::vec3 *position) {
    glm::vec3 overlapping;

    if(isColliding(other, overlapping)) {
        Logger::info(glm::to_string(overlapping), 2);

        if(overlapping.x < overlapping.z){
            position->x += overlapping.x;
        }else{
            position->z += overlapping.z;
        }
    }
}

And my move method of the Physics Object:

void PhysicsObject::updatePosition() {
    AABB testAABB(glm::vec3(0.0f, 0.0f, 0.0f) + glm::vec3(3.0f, 0.0f, 1.0f), glm::vec3(1.0f, 1.0f, 1.0f) + glm::vec3(3.0f, 0.0f, 1.0f));

    m_transformation.getPosition().setPosition(*m_transformation.getPosition().getPosition() + velocity * glm::vec3(DeltaTime::getBigDeltaTime()));
    updateAABB();
    collider->resolveCollisions(testAABB, m_transformation.getPosition().getPosition());

    updateAABB();
    collider->resolveCollisions(testAABB, m_transformation.getPosition().getPosition());
}

Just to be clear: Because it's actually a 3D Engine, the Z-Axis represents the Y-Axis, if that makes sense! I just want to get 2D to work and then I extend to 3D!

I'm pretty sure I'm wrong in my resolveCollisions() method. I tried many things, but I just cannot figure out whats wrong.


texts:
So, I have a goal to make and publish one (small, stupid, simple) game every ~Saturday.  (I've made two, so far, thanks for asking.)  I've started in Unity, because it's convenient.  My plan for each game was to have a free version with ads, a paid version without, but also have it open sourced (and if they're willing to go to the trouble of removing the ads themselves, so be it).

Now, concurrently, I keep wandering into e.g. Humble Bundle, or Unity Asset Store sales, and picking up things I probably don't need but maybe might use.

It has just occurred to me, though, that if I'm open sourcing these games - I kinda suspect the owners of these assets aren't going to be happy with me just posting all their files on the internet.  Pretty sure I can't open source assets I've purchased.

Now, I could probably just use free assets and make note of where they came from, and everyone would PROBABLY be ok with that.  But that significantly restricts the things I can use.  (And it would be kindof a waste - you don't want to know how many ancient untouched game-dev Humble Bundles I'm sitting on, haha.)

Is there some kind of workaround?  Like, if I posted the whole project, but included a license stating that only my code was open sourced, and the rest could not be used in anything else, for instance?  Anybody know any nice solutions?


texts: Perlin noise terrain issue when scrolling

texts:
I am generating a terrain in Javascript canvas using this js project for the Perlin noise. I have an array of points, and when one point leaves the left-hand-side of the window, it is removed, and a new point is added to the right.

For the first few points (before any point moves out of the LHS of the window), it works fine, but once I start removing points from the start of the array and adding them to the end the Perlin stops working.

JSFiddle

Does anyone know why this would happen?