texts: Moving a div with hotkeys using easing in and out

texts:
I'm working on replicating Tagpro using AngularJS and Firebase as a learning project.

I want this ball to move using ease in and out like in the youtube video below.

My code: http://codepen.io/clouddueling/pen/vCpuf

http://tagpro.koalabeast.com/

https://www.youtube.com/watch?v=cyAeDTmG8GI

At least my method goes in the right direction but is super glitchy.
Does anyone have an example of the algorithm that makes this happen? Code sample?

Here is a weird graph of the movement I'm trying to achieve:

Sorry if this is a duplicate I came from stackoverflow.


texts: What happens when I implement IUpdateable or IDrawable in XNA?

texts:
I've been fooling around with XNA today, attempting to develop a pure-component model game engine.

I've been working on a GraphicsSubsystem class, and realized that it will need both an Update method (to update the individual graphics components, e.g. animated sprites), and a Draw method (it'll be the only Subsystem with a draw method).

My original plan had been to simply add a "GraphicsSub.Draw()" line in the main game's Draw method, and a "GraphicsSub.Update()" line in the main game's Update method. Totally valid, works fine.

However, I've discovered that XNA has two interfaces, "IUpdateable" and "IDrawable" that seem like they might be designed for exactly that, and that they'd provide a better framework for achieving this functionality compared to my simple method calls.

When I implement IUpdateable or IDrawable, what am I telling the XNA.Game to actually do?

Is it as simple as being included in the base.update() and base.draw() during the main game's Draw() and Update() calls?


texts: Right-To-Left Text Direction in Cocos2dx

texts:
I want to use Persian/Arabic text beside English in whether Label or ui::Text.

Persian is a Right-to-Left and English is a Left-to-Right language and so I have problem to combine them in one string.

Scnario:

I want to show this text: 1."من1" then 2."emadpres2" and finally 3."3هستم".

If I write this text in a Left-to-Right editor it show as : ( Wrong Direction:  =====>  )

  1من emadpres2 هستم3

But actually it should be shown as : (  Correct Direction:  <=====  )

  هستم3 emadpres2 من1

This is my code :

auto rtl = Label::createWithSystemFont("سلام emadpres چطوری", B_NAZANIN, 25, Size(480, 100));
// The string here is also in wrong direction because the Visual Studio editor is Left-to-Right.
rtl->setColor(Color3B(0, 0, 0));
rtl->setPosition(...);
rtl->setHorizontalAlignment(TextHAlignment::RIGHT);
this->addChild(rtl, Z_NORMAL);

and this is the screenshot of this code:

As you see, I tried to use TextHAlignment but It doesn't help. I need something to change Direction not Alignment .

How should I make it Right-to-Left ?

PS: Cocos2dx v3.3


texts: Corona SDK, display.contentWidth and height does not get the expected values

texts:
I'm drawing a simple rectangle to fill the entire screen.
local bg=display.newRect(0,0,display.contentWidth,display.contentHeight)

Instead of drawing a full screen rectangle, all i get is this:

How do i rectify this?


texts:
What is the standard (if there is one) method which professional games developers use to unit test (or closest equivalent) graphics output?

I am developing with Corona SDK and I would like to test the visual output of my game code. I don't believe it is reasonable to pre-generate screenshots, scene definitions or some such for comparison at the end of a test, I would like to know if there is a good testing mechanism for graphics in general.


texts: Replace a div (with a ball picture in it) with a 3D canvas ball

texts:
I am trying to make a game where you have to keep the ball on a green platform. At this point the ball is a div with a ball image. You can move the ball over the field, all works great.

See it in action here (click the 1 first).

When you use your arrow keys you can move the ball (actually you move a div). This looks kinda fake, so I want to use a real 3D canvas ball for this. I saw a nice example here. (scroll down half way to the page. You will see a smiley with a ball in it just above the title: Smoothing it out)

So how can I use this ball into my game? I have the following code for the ball:

  // build the ball and draw its texture with a 2d canvas -------------------------------------------
  var buildBall = function() {
    // create a canvas to draw the ball's texture
    var ballCanvas = document.createElement('canvas');
    ballCanvas.width = 64;
    ballCanvas.height = 64;
    var ballContext = ballCanvas.getContext('2d');

    // draw 2 colored halves of the 2d canvas
    ballContext.fillStyle = "#f8ae44";
    ballContext.fillRect(0, 0, ballCanvas.width, ballCanvas.height/2);
    ballContext.fillStyle = "#ffda4e";
    ballContext.fillRect(0, ballCanvas.height/2, ballCanvas.width, ballCanvas.height/2);

    // create the THREE texture object with our canvas
    var ballTexture = new THREE.Texture( ballCanvas );
    ballTexture.needsUpdate = true;

    // create the physijs-enabled material with some decent friction & bounce properties
    var ballMaterial = Physijs.createMaterial(
      new THREE.MeshLambertMaterial({
        map: ballTexture,
        shininess: 10,
        color: 0xdddddd,
        emissive: 0x111111,
        side: THREE.FrontSide
      }),
      .6, // mid friction
      .5 // mid restitution
    );
    ballMaterial.map.wrapS = ballMaterial.map.wrapT = THREE.RepeatWrapping;
    ballMaterial.map.repeat.set( 1, 1 );

    //THIS PART IS FOR QUESTION 2
    // create the physics-enabled sphere mesh, and start it up in the air
    ball = new Physijs.SphereMesh(
      new THREE.SphereGeometry( 30, 32, 32 ),
      ballMaterial,
      100
    );
    ball.position.y = 500;
    ball.receiveShadow = true;
    ball.castShadow = true;
    scene.add( ball );
  };

I know I have to implement three.js to make this work, but how can I get the div replaced with this 3D canvas ball keeping everything else working as is (using arrows to move, move speed of the ball, reset when fallen of the platform etc)?


texts: How can I make my units follow predetermined paths?

texts:
I'm planning my first game and am planning on using the engine set out in Beginning Android Games, as it deals with a load of stuff that is just noise at the moment to me (because I've no real world experience yet).  There's no real time restraint - this is a learning experience more than a real world project, although I would love to be able to release something at the end of this project.

The way the book tells me how to do movement has been very much acceleration and velocity based with other forces thrown in (wind, gravity etc) but it's not covered how I can set a predetermined path for an enemy to follow.  I was thinking that I could use a lookup table to map points for the enemy to head for, and then I'd just need a way of smoothing out the turning so that the motion is fluid.  Is this the correct approach?

I know this is a bit of a vague question, and I would give you some code, but I'm very much in the planning phase at the moment, so I'm just looking for some pointers or things to think about whilst I'm trying to work out how it's all going to hang together.


texts: When drawing transparent object in OpenGL it cuts some sides of other object?

texts:
I am making some OpenGL program, and I have a lost of cubes next to each other like this:

When I am making this hole, I am just skipping those cubes, just don't draw them.

for (int i=0;i<NUM_OF_CUBES;i++) {
        for (int j = 0; j < NUM_OF_CUBES; j++) {
                if ((i==3 && j==3) || (i==4 && j==3) ||
                    (i==3 && j==4) || (i==4 && j==4))
                        continue;
                cubes[i][j].draw(true);
        }
}

The result is:

But when I make those cubes invisible, by setting alpha to 0, the result is:

The code is:

for (int i=0;i<NUM_OF_CUBES;i++) {
        for (int j = 0; j < NUM_OF_CUBES; j++) {
                if ((i==3 && j==3) || (i==4 && j==3) ||
                    (i==3 && j==4) || (i==4 && j==4))
                        cubes[i][j].draw(true);
                else
                        cubes[i][j].draw(false);
        }
}

true/false fleg which I send to draw function just sets alpha to 0 or 1, if true alpha coordinate of glColor4f is set to 0, and if false is sent alpha coordinate is set to 1.

Does anyone have idea why it looks like some sides of the other cubes are cut? Like they don't exist.


texts: Unity Raycast shoots right through some objects

texts:
I made a melee combat system for my game. The code looks like this:

var hit:RaycastHit;
    if(Physics.Raycast(transform.position,transform.forward,hit)) {
        if(hit.distance<=2.0) {
            Debug.LogError("Hit!");
            Debug.LogError(hit.collider.tag);
            if(hit.collider.tag=="Enemy") {
                Instantiate(bloodFX,hit.transform.position,transform.rotation);
                hit.transform.SendMessage("ApplyDamage",25,SendMessageOptions.DontRequireReceiver);
            }
        }
    }

However, when an object with the tag "Enemy" stands in front of a "Tree" object, the log tells me that it's hitting the tree tag and not the enemy. What am I doing wrong here? The collision boxes are all correct.

Thanks!

P.S. This is for the ludum dare that ends in 4 1/2 hours so I have to fix this quickly.


texts: I just downloaded and installed CryEngine 5.0.1. I am trying to follow the Island tutorial but I don't have the assets the tutor has. I have installing CryEngine Game SDK but I still don't see any assets or materials except the default ones. So my question is how do I install the assets I need to follow the tutorials?


texts: LibGDX background image not fitting the whole screen

texts:
I'm trying to add a background image to the game's main menu, and when I execute the game as a Desktop Application it fits OK,

but if I execute it on a movile device (or using a virtual device) it doesn't completely fit.

I tried changing the image's size, position, etc... but those two blue empty spaces keep being there above and below.

The code:

Texture backgroundImg=game.getManager().get("...");

...

@Override
public void render(float delta) {
    ...
    game.batch.begin();
    game.batch.draw(backgroundImg,0,0, Gdx.graphics.getWidth() * 1.75f, Gdx.graphics.getHeight() * 1.75f);
    game.batch.end();

    ...

}


texts: Is there a way to run an Android Unity game in Windows?

texts:
I was wondering, given a generic Unity game built for Android (with no desktop version), if I could somehow run it on windows (not in an android emulator) by using the windows version of mono.

The theory is that the script assembly (if the scripting was done in c#) is separate from the game engine.

I tried replacing the Data folder of a windows game with the Managed folder from the Android apk but got this error:

  Failed to load PlayerSettings (internal index #0). Most likely data
  file is corrupted, or built with mismatching editor and platform
  support versions.

Is there some tool I can use to change the platform of a third party unity game in order to play it ?

I'm not an unity developer myself but my concern is that games could use features not supported on desktop...


texts:
To display an image from Content in a .NET Forms Dialog, I'm trying to make a function that loads an image through .NET's Image.FromFile(string fileName) function, but instead of taking a whole path, it takes the path you'd usually put in Content.Load<T>(string assetName).

For this, I need to be able to get the complete root directory of the Content folder, but how do I get that?

I've already tried Content.RootDirectory, but that seems to give only a relative file path (in my case, it just says "Content" because I left it at default)

Thanks in advance!


texts: How can I trigger an event each time the rotation of my rigidbody2D is at a given value?

texts:
I would like to trigger an event each time my rigidbody2D is at a particular value.

The event should only be triggered once for each given value per complete object revolution.

Initial attempts at achieving this have resulted in the following method which checks against an array of values, logging an event and incrementing an index when the value has been passed.

static readonly float[] angles = new float[] { 90f, 180f };
int angleIndex = 0;

void CheckForTrigger()
{
    if (rigidbody2D.IsSleeping())
        return;

    var rotation = Mathf.Abs(rigidbody2D.rotation);

    if (rotation % 360f >= angles[angleIndex])
    {
        Debug.Log("Fire");

        angleIndex++;

        if (angleIndex== angles.Length)
            angleIndex= 0;
    }
}

This suffers from a couple of issues:

Floating point inaccuracy means that values close to 360f will often be missed (e.g. 359f)
Fire will be logged each frame between the last and first value (i.e. between 180f and 90f)

Does anyone have any advice for approaching this problem and improving the above method?


texts: Locate the shortest path through obstacles when all normal paths are blocked

texts:
I'm making a Tower Defense and I have basic pathfinding working, but I got a problem.

I want to make the path blockable, and when a block occurs the runners will attack the blocking towers.

So what I need is a way to find the shortest path that, more importantly, has the lowest number of towers in the way.

How do I do that?


texts:
For my game, I need to teleport player (GameObject) to a position (Vector3) whenever it touches a cube with this script. I tried using this:

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

public class Teleporter : MonoBehaviour
{

    public GameObject player;
    public Vector3 target;

    void OnCollisionEnter(Collision collision)
    {
        player.transform.Translate(target);
    }
}

and passing player and position in the inspector:

but it does nothing, when player touches a cube with this script. Please tell me how to fix this, or a completely new idea to teleport the player, that works. Thanks


texts: How to test a network game on a mobile device

texts:
I am looking to test a network game with say, 10 or more users, on a mobile device. Think of it like an MMO with a lot less users. (Assuming I can get 10 running, I'd test for more users later)

The test is for two reasons :

To see if and how the server will handle that many users
To see the performance on the client side (seeing how it has to update/render all these objects on a mobile device)

How would I go about testing 10 or more users? Unfortunately I do not have 10 devices to test on, only one. I've seen a few MMOs available on Android/iPhone. How do these developers go about test their game on devices?


texts: Why isn't my lighting working properly? Are my normals messed up?

texts:
I'm relatively new to OpenGL and I am trying to draw a 3D model (loaded from a 3ds file using lib3ds) using OpenGL with lighting, but about half of it is drawn in black.

I set up the light as such:

glEnable(GL_LIGHTING);
glShadeModel(GL_SMOOTH);

GLfloat ambientColor[] = {0.2f, 0.2f, 0.2f, 1.0f};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor);

glEnable(GL_LIGHT0);
GLfloat lightColor0[] = {1.0f, 1.0f, 1.0f, 1.0f};
GLfloat lightPos0[] = {4.0f, 0.0f, 8.0f, 0.0f};
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);

The model is in a VBO and drawn using glDrawArrays. The normals are in a separate VBO, and the normals are calculated using lib3ds_mesh_calculate_vertex_normals:

std::vector<std::array<float, 3>> normals;
for (std::size_t i = 0; i < model->nmeshes; ++i) {
  auto& mesh = *model->meshes[i];
  std::vector<float[3]> vertex_normals(mesh.nfaces * 3);
  lib3ds_mesh_calculate_vertex_normals(&mesh, vertex_normals.data());
  for (std::size_t j = 0; j < mesh.nfaces; ++j) {
    auto& face = mesh.faces[j];
    normals.push_back(make_array(vertex_normals[j]));
  }
}
glBindBuffer(GL_ARRAY_BUFFER, normal_vbo_);
glBufferData(GL_ARRAY_BUFFER,
             normals.size() * sizeof(decltype(normals)::value_type),
             normals.data(),
             GL_STATIC_DRAW);

The problem isn't the vertices; the model is drawn correctly when drawing it as a wireframe. I also fixed the normals in Blender using controlN. What could be the problem? Should I store the normals in a different order?


texts: When applying Bloom postprocess, error: "XNA...requires TextureFilter to be Point when using texture format Single."

texts:
I have an almost unmodified copy of the bloom sample in my project. I pass it a texture to apply the bloom post process on.

The only modification is that, instead of calling BeginDraw() (to set a render target) in the bloom sample and then doing all of my drawing, I simply do all of my drawing to a rendertarget outside of the bloom sample, and then pass that rendertarget to the bloom sample's Draw() method, which the bloom sample can then use to perform the bloom postprocess.

The texture that I pass to the bloom sample Draw() has format Color, according to the debugger (and by code inspection).

However, on the first draw call in the bloom sample, I get the following error:

The framework produces the error "XNA Framework HiDef profile requires TextureFilter to be Point when using texture format Single."

The code that produces this is as follows:

1   public void Draw(RenderTarget2D sceneRenderTarget)
2   {
3       GraphicsDevice gd = Game3.GDM.GraphicsDevice;
4
5       gd.SamplerStates[1] = SamplerState.LinearClamp;
6
7       //gd.SamplerStates[1] = SamplerState.PointClamp;
8
9       // Pass 1: draw the scene into rendertarget 1, using a
10      // shader that extracts only the brightest parts of the image.
11      _bloomExtractEffect.Parameters["BloomThreshold"].SetValue(
12      Settings.BloomThreshold);
13
14      DrawFullscreenQuad(sceneRenderTarget, _renderTarget1,
15                 _bloomExtractEffect,
16                 IntermediateBuffer.PreBloom);

If I uncomment line 7 above, then the code runs without error (as point sampling will be enabled), but this should be unnecessary (and is not desired) as all rendertargets involved here are SurfaceFormat.Color -- which is not a floating point format!

Does anyone have any idea what might be going on? Perhaps someone has seen this before, and can give me a clue where to look next.

I have some experience with PIX, but I don't know how to use PIX to debug when the program crashes (basically I only know how to take single frame captures in PIX).


texts:
Disclaimer: I'm relatively new to developing games so bear with me.

In my scene I have enemies and when they die, they drop items. No matter which item is dropped, the same prefab (the physical representation of the dropped item) is instantiated. That physical orb on the ground may represent different items. It could be a pile of coins, a sword, etc. Depending on which item is dropped, I want its name to appear in a UI label attached to the top of the item. Basic ARPG stuff really. The problem I'm running into is that I can't seem to get the references right.

DisplayItemNameLabel is a script which is attached to each item when it is dropped. I did it this way so each item can be in charge of its own UI label.

ItemDrops is attached to each enemy. SpawnItem(Item item) is a function which is called when the enemy dies.

The last relevant Monobehaviour script is the ItemData script which is attached to an Item Manager game object which is there from the beginning and persists forever. This class just defines the different items that are possible in the game.

So basically the structure is that when an enemy dies, if the random number generated is within some range, then some item will drop.

If (randomNumber < 0.5)
{
    SpawnItem(itemData.coin);
}

where SpawnItem(Item item) is something like...

private void SpawnItem(Item item)
    {
        itemDropped = true;
        nameOfDroppedItem = item.itemName;

        Instantiate(itemPrefab, transform.position - offset, Quaternion.identity);
    }

Again, this is attached to each enemy.

In the DisplayItemLabel script then, I would like to set itemNameText.text to that nameOfDroppedItem. But the DisplayItemLabel script is attached to each item. I don't think I can make each item a child of each enemy because enemies are destroyed when they are killed so the scripts would be destroyed. I also can't use GameObject.FindGameObjectWithTag("Enemy").GetComponent<ItemDrops>(); because it wouldn't always grab the enemy I want. I thought maybe I could set the text in SpawnItem but it would have to reference the correct item, so I couldn't use GameObject.FindGameObjectWithTag...

What should I do?


texts: Placing nodes in a graph in a random but readable way

texts:
I'd like to create a simple map from vertices and lines - you know, like a usual graph. A tree, to be precise.

To select the location of the next point that comes from one, I use a simple circle-equation function:

function Point_on_Circle(circle_x, circle_y)

degree = math.random(rad_min, rad_max)

point = { x = 0, y = 0, t = math.rad(degree) }

point.x = circle_x + radius*math.cos(point.t)
point.y = circle_y + radius*math.sin(point.t)

return point

end

The result is something like this:

That's a complete mess! What to do to make it readable? As you can see, I checked, how many ways are going from each single points, but don't have much idea, what to do with them.

The problem is that it's impossible to see individual points because their lines cross each other. I want to avoid line crossing at all, like in a usual tree.


texts:
I am trying to make a platformer. For the player character I am using a kinematic rigidbody because I want to calculate the jump curve myself (including physics & gravity). The platforms are also kinematic because I want them to move. I am having issues with the collision detection being imprecise causing the sprite to not stand exactly on the platform after jumping (as seen in the three images taken after three different jumps). This issue also causes the sprite to get stuck in the ground sometimes. The left image is the character inspector and the right is the platform inspector. The jump movements are done with movePosition, and I tried many things to fix this. I tried the following: decreasing the timestep from 0.02 to 0.01, using onCollisionStay to keep it exactly on the platform, adding a physics material with zero friction, using edge colliders & capsule colliders, using interpolate and extrapolate.
https://imgur.com/a/Kech2Qy


texts: What causes still objects have lines in them when lighting is being changed?

texts:
First, here is what I'm talking about (I changed the contrast to make it more visable, since it's not really visible in still images):

Ingore the chat box, I was spamming buttons to see which one took a screenshot :P

Hopefully you can see clearly what I'm talking about. Basically, those lines in the sky (they're only visible in the top part of the image). This seems to occur for me any time I use a still object and move lighting across it (the faster the light, the more the lines are visible to the player). What causes this? It seems to happen in lots of games though (especially in the sky, since it's pretty much still). Is there any way to remove them (I'm not looking for API specific because it seems to occur in all APIs)?


texts: Back to front drawing in an Unorginized array of tiles

texts: I have an Array of tiles in no particular order. How would I do a isometric back to front rendering on it? Do I HAVE to order it?


texts: Child GameObject doesn't follow parent's transform

texts:
Look at this picture first:

I have model that has sword in his hand. I added a cube named "Attack Collision" and located to blade position. And then set the hand to parent.

But when the game starts, sword moves but it's children "Attack Collision" doesn't move at all.

The funny thing is in the scene, I tried to move the "sword", but only it's children "Attack Collision" was moved.

Seems like the sword is somekind of locked, because it's transform can be change but not applied at all, it's just stand still there and only it's children that made from Unity was moved like this:

I made this model and animation by Blender and imported to Unity as .FBX file.

What am I missing?


texts: What things should an indie game developer never do?

texts: What are some of the biggest - and better yet: insidious and unexpected - mistakes that indie game developers make? Especially when making the transition from hobbyist to full-time indie?


texts: Mixing old and new state of game objects?

texts:
If I have a group of game objects that are being updated each frame, and some of them query each others data like position and such, is it common practice to not care that a game object might get another game object's old state or new state depending on what got updated first? I could see that working out alright as long as the time delta between frames is small. Or is it typical to handle this either via saving one frame of old state or perhaps sorting the updates in some way?

What do well known game engines do?

Also if sorting / saving state is done, are NPCs given the new or the old state of other NPCs and the player's character?


texts: Exporting an animated FBX to XNA? (in 3DS Max)

texts:
I'm now working on an XNA 3D game, and I want to add animated models in it. I came across this example.  I see there is one FBX file and a few texture files in the content project, and that in the code you can choose which "take" to play. In this code it is "Take_001". Please tell me: When I create and animate my own 3D model in 3DS Max (2012, since I was told it's only possible in this version), how can I define those takes? plus, are any configurations need to be made when exporting FBX from 3DS Max to XNA?

Thank you.


texts:
I created a blueprint. I added several components to the blueprint. I made it follow a target point and it does it correctly. I'd like to make the NPC make this way to the target point faster, but I do not know how to set the speed.

How I Created:

Components of the NPC:

I've clicked on all components looking for a way to set their speed. I also clicked Class Settings and Class Defaults, but nothing resulted.

Then I tried to find some function or command related to the speed, taking a reference from the NPC itself:

I added values to tranform, but did not change the result in the game at all:

Links that I clicked at the time I typed the title of the question:

How do I change the speed of an object without changing path travelled?

Changing speed of an object


texts: Unity: How to cut a line (or curve) at a specific point and animate it?

texts:
What would be a good approach to cut a line (or curve) at a specific point (let's say we use the mouse pointer to detect the position of the cut).

The curves you see in the image above, are Bezier curve generated using the LineRenderer and have a PolygonCollider2D attached that covers the entire curve (taking the width set to the LineRenderer into consideration).

Imagine a game like Cut the Rope or Fruit Ninja, where you use the mouse pointer to cut the wires. I already implemented the cut detection algorithm, so I know the point where my wire needs to be cut. I would like to know how can I snap the wire in two and add some sort of animation.


texts: Which files should I be looking at to do a total conversion mod using the Source Engine?

texts:
I just installed Source SDK. Made a multiplayer mod from a template using Source Engine 2007. I'm currently using VS2008.

I was wondering which folder I should work in. For example weapons, which files I should change?

Is it "\src\game\server\hl2\weapon_crowbar.cpp"
or "\src\game\shared\hl2mp\weapon_crowbar.cpp"
or "\src\game\shared\sdk\weapon_crowbar.cpp"

Also, I've seen the various help on the wiki, if I want to change bullets for example, saying I should change the scripts in the mod folder in Steam. Is that necessary? Shouldn't I make changes from the source mod folder to things like that and recompile?

I'm aiming for a total conversion mod rather than just a mini-mod in case that matters.


texts: How to texture a floor so that edges have slightly different texture than the rest of the floor

texts:
When trying to create somewhat realistic environments, I often find that the edges where floor/wall/ceiling meet will have slightly different texture compared to the rest of the floor/wall/ceiling.

An example of this can be seen on this concrete walkway:

The parts of the concrete away from any walls is worn smooth by people walking across it, but it becomes lighter and rougher closer to the wall or the metal pole.

What are some techniques (general or UE4 specific) to emulate this when texturing a level?


texts: Should a transform class store a matrix or seperate position/rotation/scale values?

texts:
I'm creating a transform class to make storing the transform of individual objects in a scene easier, but I'm unsure on how to do it.

I could create one like this:

class Transform
{
public:
    //...

private:
    Matrix4f matrix;
};

Easy to concatenate
Easy to perform operations on (since the matrix functions already exist)
Can store certain information such as the camera projection
Difficult to get the individual values such as the position of the object
Performing operations in the wrong order can lead to unexpected results (rotate/translate/rotate results in a very different transform than rotate/rotate/translate)
Lots of memory usage (64 bytes of data for a single-precision transform)

Or like this:

class Transform
{
public:
    //...

private:
    Vector3f position;
    Quaternionf rotation;
    Vector3f scale;
};

Very easy to extract individual values
Very easy to change individual values
Because the position, rotation, and scale are independent from one-another, there is no "correct" order for rotate/translate/scale
Smaller, being only 40 bytes for single-precision
Cannot store anything beyond position/rotation/scale
Performing operations which require information stores in more than one value (such as strafing, which changes the position but depends on the rotation) are much more difficult to implement

I'm not entirely sure how most game engines deal with this. Which implementation should I go with?


texts: OpenGL - Quad is being separated like a two triangles after blending

texts:
I wanted to add transparency for my UI elements, so I enabled blending by adding:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

before renderer and

glDisable(GL_BLEND);

after renderer.

So I tried to render simple rectangle (with glDrawArrays() because I'm using GLSL shaders).

Before I enabled blending my rectangle (1 quad) looked like this:

And now, after blending it looks like this (Like a two triangles):

Do I need some extra settings for my blending or what?

Edit:

I noticed that if I remove anti-aliasing code:

glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

glEnable(GL_LINE_SMOOTH);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);

Problem will disappear, but I want to keep anti-aliasing in my game. Any ideas?


texts: UE4: Subclass problem: cannot access private member declared in parent class?

texts:
I get the following error:

  [...]\ClassB.cpp:7: erreur : C2248: 'UClassA::UClassA' : cannot access private member declared in class 'UClassA'
  [...]\ClassA.h:12: see declaration of 'AClassA::AClassA'
  [...]\ClassA.h:9: see declaration of 'AClassA'

when I create a subsubclass.

The problem occurs with the following code:

ClassA.h

#pragma once

#include "GameFramework/Actor.h"
#include "ClassA.generated.h"

UCLASS()
class PROBUILDER_API AClassA : public AActor
{
    GENERATED_BODY()
    AClassA( const FObjectInitializer& ObjectInitializer );

};

ClassA.cpp

#include "ProBuilder.h"
#include "ClassA.h"

AClassA::AClassA(const FObjectInitializer &ObjectInitializer):Super(ObjectInitializer)
{

}

ClassB.h

#pragma once

#include "ClassA.h"
#include "ClassB.generated.h"

UCLASS()
class PROBUILDER_API AClassB : public AClassA
{
    GENERATED_BODY()
    AClassB( const FObjectInitializer& ObjectInitializer );

};

ClassB.cpp

#include "ProBuilder.h"
#include "ClassB.h"

AClassB::AClassB(const FObjectInitializer &ObjectInitializer):Super(ObjectInitializer)
{

}

(I tried with a subclass of AActor and UMeshComponent and got the same errors)


texts: How can I notify my AI systems that a target has died?

texts:
I am currently building a game focusing on AI for my university and this is my first time writing such a complex AI system.

Naturally, I ran into a little logic problem: In the game, the AI uses a hierarchical finite state machine and certain states have a pointer to a character as target for their logic (e.g. attack state has a target character to attack). Additionally, multiple characters might target this one character at the same time.

Now if that character dies, how should I go about telling the AI that the target is no longer valid? I can't just delete the character object, since that would result in invalid pointers and access violations, of course.

I thought about using an event system, where the characters are notified about the death, but how would I know, when all characters removed their reference, changed their state etc. and I could finally delete the object?

Would I have to resort to using smart pointers here? Or is there another good solution?


texts:
What's a good architecture for Flash games? I've read that MVC is great, with symbols just used purely for views (set states, use the class to manage which state/frame to show).

I would presumably then stick all my code in one or more .AS files, use object-oriented programming, try to unit test whatever I can, and make my art and symbols purely view-state stuff with no code.

Has anyone tried this? On anything other than a small game? How do these big flash RPGs and MMORPGs architect their games?


texts: Is it possible to export a simulation (animation) from Blender to Unity?

texts:
I created an explosion animation within Blender, something as shown in this video. To achieve this I used a particle-system, together with the "Explode" modifier.

This kind of animation (simulation) doesn't get exported to other file-formats though and I'd like to export the animation as FBX, so that I can use it in Unity. So I basically need some way to "bake" the animation to keyframes. I wonder if there's a way to achieve this?

After some testing I found out, that the only way the simulation gets exported is by writing a sequence of obj files. So an answer on how to integrate/animate such a sequence of obj files in Unity would also be welcome.

Side note: I also tried to get an answer to this over at the blender community.


texts: Slick2D Isometric TiledMap Rendering Problem

texts:
I created a Tiled Map using the Tiled Map Editor. In the Editor it looks like this:

Desired State

In my java program it looks like this:

Actual State

My java code is:

public class Game extends BasicGame {

    private TiledMap map;

    public static void main(String[] args) throws SlickException {
        AppGameContainer app = new AppGameContainer(new Game());

        app.setDisplayMode(800, 600, false);
        app.setShowFPS(true);
        app.start();
    }

    public Game() {
        super("Test");
    }

    @Override
    public void render(GameContainer arg0, Graphics arg1) throws SlickException {
        map.render(300, 200);
    }

    @Override
    public void init(GameContainer arg0) throws SlickException {
        map = new TiledMap("res/unbenannt.tmx"); //path is valid!
    }

    @Override
    public void update(GameContainer gc, int arg1) throws SlickException {

    }
}

The orientation of the map is isometric. I'm working under Linux Mint, Java 6, eclipse with the latest Slick2D and LWJGL Library.

Did I forget anything? Why am I getting such a weird looking map rendering?


texts: Progression in a Sandbox Game (to xp or not to xp)

texts:
I'd like to know the strengths and weaknesses of different progression methods through a game (or a part of a game), where they're suited best, and where they should never appear. I have several subsystems a player can progress through in a project I'm working on and I'd like to be able to work out if any of them would benefit from tallying xp. [Not sure why this is on hold, I'm asking about the concrete merits of things not simply asking everyone for their favourite??]

At the moment the player's character becomes more powerful by equipping better and better gear as they progress through randgen levels however they like, but are given clear indication that going in a particular direction will increase difficulty and the quality of items. I'm not sure in what circumstances I would add in xp for fighting monsters, or which I'd have the monsters drop good gear, or parts to make good gear out of. On top of that I have a magic system and a crafting system that I'm considering progressing though with xp but I wouldn't want to implement it if the side effects don't suit the rest of the game.

As far as I know games usually progress in the following ways, often in combination:

Level by Level: Like in old school Mario, you go through a sequence of levels which become more difficult and require you to master the basic techniques of game play.
Power by Power: You gain new abilities which makes it possible to access more and more difficult content. Metroid comes to mind for this.
Xp Growth: Your stats increase every level so you can fight the harder mobs in further content. You may or may not be able to choose where your stats go.
Xp Talent Tree: You get points to put into learning new skills, often from increasingly better pools of skills.
Item by Item: Equipment determines what content can be accessed next, either because the item unlocks something (including methods of transportation), or it increases player abilities such that they can survive certain areas. The distinct thing about items is that they can be removed from a player at pretty much any time. A grappling hook that can't be removed is a Power, not an Item.
Quest by Quest: Like Level by Level, only what triggers the newer content isn't getting to the end of a stage, it's the completing the requirements of a quest (explicitly stated or not). Zelda would be an example of a game that does both LbyL and QbyQ. Each dungeon is a level and between levels you have to do a bunch of little quests to unlock the next level.
Score: You just rack up points like in pinball, it doesn't really have an effect on the game.

If you have a clear idea of the underlying purpose of these or others, I'd like to hear it! At the moment I only know that these systems exist, but only vaguely what they're for.

As an aside, I'm also interested in your thoughts on how to display progression to a player. When is it best to give them numbers, if ever? Are visual/demonstrable displays preferred for certain things? What is the function of doing it one way or another?


texts: Specific bone not present in the skeleton XNA

texts:
I have created a human mesh, bone structure, and animation rig in 3ds max for an XNA game I am developing for school. I am currently having a problem with one specific bone upon build in Visual Studio. It's the 3rd bone of the right pinky and I have promptly named it "The Problem Bone".

The build is giving me this error:

Vertex is bound to bone "The Problem Bone", but this bone is not present in the skeleton.

I've checked the skeleton many times to confirm that the bone does exist. The skeleton hierarchy root is the pelvis bone and I verified that no bone was being ignored due to the mesh having more than one skeleton which is usually the cause of this problem.

After reading the .fbx file, I found that the XNA was building the bones starting with the pelvis, then going down the right leg, then the left leg, then the spine up to the head, and then the right arm which where my problem area is.

As we can see in the schematic view, the problem bone is linked to a previous successfully built bone.

The bones are controlled by splines, point helpers, and IK chains through linking and constraining. I don't think that these are the problem since other bones driven by the controllers were successfully built before the problem bone.

So the other bones up until the 3rd bone of the right pinky are being built correctly which gives me the feeling that I'm close to a solution and it's something small impeding my progress.

Does anyone know why I am getting this error?

Exporting from 3ds Max Process:

Select only the bones and the mesh
File > Export > Export Selected
Save as .fbx
Current .fbx export dialog window


texts: What is better? Lots of small TCP packets, or one long one?

texts:
I am sending quite a bit of data to and from a server, for a game I'm making.

I currently send location data like this:

sendToClient((("UID:" + cl.uid +";x:" + cl.x)));
sendToClient((("UID:" + cl.uid +";y:" + cl.y)));
sendToClient((("UID:" + cl.uid +";z:" + cl.z)));

Obviously it is sending the respective X, Y, and Z values.

Would it be more efficient to send data like this?

sendToClient((("UID:" + cl.uid +"|" + cl.x + "|" + cl.y + "|" + cl.z)));


texts: How can I scale the number and challenge of enemies in an attack wave as the game progresses?

texts:
I'm currently making a defense game where enemies will spawn and attack the player's army. It's similar to a Tower Defense game, except there is only one level. The enemies will keep spawning until eventually the user dies or he amasses a large enough army that they wipe out any enemy that spawns instantly (hopefully it'll be challenging enough that this won't happen).

What I'm struggling with at the moment is how to make this game get progressively harder and the probability of an enemy spawning basically eventually reach 100%.

So far I've got something similar to the following

if(Math.random() < 1 - (1/elapsed_time) && spawnTimer <= 0 ){
    spawnEnemy()
    spawnTimer = rand(); // random number between 1 and 3
}

But it seems too uniform to begin with. At the moment I'm only spawning one type of enemy, the idea being that tougher enemies are spawned as time progresses as well.

I also think I need to randomise my spawnTimer at bit more and make that get quicker as time progresses, but I just can't seen to get my head around what my logic should really look like for this whole section. Is anyone able to help with a rough idea of this kind of formula?

I'm currently using javascript to write the game, but obviously it's more about the concept.


texts: Why is concept art not signed by the author?

texts:
I am a starting concept artist who would like to enter the gaming industry. I noticed that some AAA titles show their concept art with no artists signature (only a reference to game the game, such as for Star Wars The Old Republic: 2013 ALL RIGHTS RESERVED BioWare, LucasArts).

I  asked myself a question, what possible harm could my autograph cause on the public concept art if I am not a well known concept artist such as Adam Adamowicz (who did concepts for Skyrim). Why would a prospective boss tells me not to leave my "finger print" on the picture despite, the fact that I am a very talented artist?


texts: Is it possible to emulate a MovieTexture with dynamically loaded images?

texts: Say I have a short video and want to play the video in a game scene, but I can't use the MovieTexture for whatever reason. Is it technically possible and feasible to dynamically load images (in a flip book fashion) in order to emulate a video being played in a scene?


texts: How to rotate an object towards the walking direction?

texts:
I'm working on a game where you move a object on a game surface of cells, every time you move this object it steps to a cell, up, down, left or to the right. I have been trying to find out a way to rotate the object soo it is facing the moving direction. The rotation should be 90 degrees. It's one thing if the object is going from Up to Left and then rotate it 90 degrees, but what if object is going from Up to Down, then it need to rotate 180 degrees. I need some help with this issue to solve this in a simple and good way? Thanks!

This is the code for moving upwards and the other moving directions are similar. I'm using a short delay, so that the player can't move to fast on the game surface.

    // Upp
    public void Up()
    {
        if (milliSeconds1 >= walkingTimer)
        {
            Position = new Vector2(Position.X, Position.Y - walkingSpeed);
            milliSeconds1 = 0;
        }
    }

And in the Update:

Position = Position + Direction * 1;

EDIT: I solved this by myself! I just used radian values for each directions! :)


texts: Exact collision time of two axis-aligned bounding boxes

texts:
I am trying to calculate the exact collision time of two axis-aligned bounding boxes (aabb) as fast as possible (in the sense of CPU time).

I have all the required information (aabb min, max, center, etc., velocity vector, and so on)
My aabbs are not rotating, so they have linear velocity
The aabbs can be both moving, only one of them might be moving, or they both might be steady

My current approach creates lines from one of the boxes' corners and checks the collision among the planes of the other box (you can see the algorithm below); however it takes 6 times longer than I can afford. So, I am trying to find a faster algorithm; however, I couldn't have managed, yet.
My current "slow" algorithm:

Add velocity of Aaabb to Baabb and assume Aaabb is steady and Baabb is moving
Calculate the corner positions of Baabb
For each corner of Baabb, perform the line-plane intersection with Aaabb's each 6 planes (I use the line-intersection formulate (algebraic form) on Wikipedia) to check if there is an intersection.
If a corner of Baabb intersects with a plane of Aaabb, verify the intersection point is behind the other 5 planes of Aaabb
Keep the smallest value of d and return


texts: Aiming with a crosshair with a lot of polygons/triangles

texts:
I'm working on a 3d kindof game where I'll eventually be able to modify the shapes present in the environment by pulling their faces with a crosshair. The thing is that I don't know how to achieve ray-quads or ray-triangle collision. I did it once with a teacher at school, but he didn't have much time and it was not well constructed (+I lost this code). I was also wondering how I could check for theses collisions with thousands of shapes? Because I know this is quite resource-demanding and doing this for 1000 spheres/cube/freeform shapes is not easy. If anyone could help me push my knowledge a bit further, it'd be very much appreciated!

I also work in Java using LWJGL, so OpenGl.


texts: Pseudo random number generation in compute shader

texts:
Using a C# script in Unity3D to control a HLSL compute shader, I'm trying to generate pseudo random numbers on the gpu. Following along with
GPU Gems 3 Hybrid Tausworthe method
and another thread Pseudo Random Number Generation on the GPU, I've come across an issue.
The problem:
the resulting texture appears to be one solid color. If I run the shader multiple times, I get a different solid color texture result every time, but the entire texture is the one color.
Compute shader code
#pragma kernel CSMain

RWTexture2D<float4> result; // 256 resolution texture to write to
uint4 randSeed;  //four uniform random numbers generated in C# script

struct RandomResult
{
    uint4 state;
    float value;
};

uint TausStep(uint z, int S1, int S2, int S3, uint M)
{
    uint b = (((z << S1) ^ z) >> S2);
    return ((z & M) << S3) ^ b;
}
uint LCGStep(uint z, uint A, uint C)
{
    return A * z + C;
}
RandomResult HybridTaus(uint4 state)
{
    state.x = TausStep(state.x, 13, 19, 12, 4294967294);
    state.y = TausStep(state.y, 2, 25, 4, 4294967288);
    state.z = TausStep(state.z, 3, 11, 17, 4294967280);
    state.w = LCGStep(state.w, 1664525, 1013904223);

    RandomResult rand;
    rand.state = state;
    rand.value = 2.3283064365387e-10 * (state.x ^ state.y ^ state.z ^ state.w);

    return rand;
}

[numthreads(8, 8, 1)]
void CSMain(uint3 id)
{
    result[id.xy] = HybridTaus(randSeed).value;
}

Do I need to save the state on the gpu? If so, how would I do that? Do I need to deallocate the memory afterwards?
I did try to assign the result of the HybridTaus() function to randSeed in hopes that it would use the new value in the following HybridTaus(randSeed) call, like this:
[numthreads(8, 8, 1)]
void CSMain(uint3 id)
{
    RandomResult rand = HybridTaus(randSeed);
    randSeed = rand.state;  // re-assign randSeed with the new state

    result[id.xy] = rand.value;
}

but to no avail.


texts: How should I go about creating a generic Scene object for managing VBO data?

texts:
To simplify managing multiple types of data with different shaders and textures, I thought about creating a generic Scene object (is there a name for this?) which would allow me to pre-configure how I want to render something, and how the data changes. Let me give an example:

Everything  below is in the context of a 2D top-down game

Some parts are completely static, e.g. the background, and their geometry never changes.
Then there'd be a "NPC" layer, which can change on almost every single frame, uses different shaders.
Last but not least, there's a UI layer, which sits on top of everything else.

Some of these parts would probably be split into multiple subparts, such as parts rendered as GL_TRIANGLE_FAN, and other parts rendered as GL_LINE_STRIP, etc. To avoid duplicating lots of setup/generate geometry/render phases, it would seem logical to wrap this in something that can be configured, such as:

Scene s;
Batch b1 = s.create_batch(somehow_specify_shaders_etc);
generate_background_geometry(b1);

Batch b2 = s.create_batch(somehow_specify_other_shaders_and_VAO);

// game loop
while (true) {
  // this would generate/update the NPC geometry on the fly
  b2.process_input(gather_user_input());

  for (Batch b: s) b.render();
}

Now what if I wanted to specify different texture bindings for each batch? Or different shaders?

Is there a general pattern for managing geometry data like this?


texts: How can I load 24-bit audio as SoundEffect?

texts:
When I try to load .wav file I get an error:

  Audio file *.wav contains 24-bit audio. Only 8-bit and 16-bit audio
  data is supported.

Here is my code:

SoundEffect menuSelectionChange = content.Load<SoundEffect>("Sound/Menu Selection Click");
SoundEffectInstance menuSelectionChangeInstance = menuSelectionChange.CreateInstance();

Even if I delete this code I'm still getting this error.


texts:
I currently use Unity 2018 LTS, because of my 2019 Unity colours are not really good.
For example, the white is not really white but more like grey and the Shadows are really strong too even if I change the Shadow type.
Why is this happening?

This is Unity 2019

and Unity 2018-LTS

If I change the Directional Light Color from light yellow to Full White then it is whiter, but it doesn't solve the Shadow problem.


texts: How to script sequential events in GameMaker?

texts:
I am wondering if there is an elegant way to script sequential events in GameMaker 2.

In Godot 3.1, it is very easy to chain events together using yield() and signals. You just start doing something, yield until it emits a signal that it's done, and then continue your code. I am wondering if there is anything similar in GameMaker 2.

In Godot, for example, if i wanted to spawn an explosion cluster which consisted of 10 explosions, each starting 50 milliseconds after each other, I could do something like this.

func create_explosion_cluster(x, y):
    for x in range(10):
        create_explosion(x, y)
        timer = Timer.new()
        add_child(timer)
        timer.wait_time = 0.05
        timer.start()
        yield(timer, "timeout")
        timer.queue_free()

I used this method for complex boss behaviors as well. For example,

func boss_attack():
    animation_player.play("intro_to_attack")
    yield(animation_player, "animation_finished")
    animation_player.play("attack")
    for x in range(10):
        create_projectile(x, y, vector_to_player)
        timer = Timer.new()
        add_child(timer)
        timer.wait_time = 0.05
        timer.start()
        yield(timer, "timeout")
        timer.queue_free()
    animation_player.play("outro_to_attack")
    yield(animation_player, "animation_finished")`

In fact, I use this technique all over the place when I want certain events to follow other events (in transitions, cutscenes, enemy behaviors, etc.)

Is there a way to script sequential events in GameMaker with similar flexibility as you have in Godot?

If there is a general design pattern to solve this kind of problem without yield(), co-routines, and so on, I'd love to know it.


texts: Moving texture according to position in shader

texts:
Divinity Original Sin have beautiful particle effect , When I move around game I see galaxy through particle that move according to my position.how can I make like it?

you can see this effect here:
https://youtu.be/4fIpQZ2sIAY


texts:
I am in the process of making a giant shooter game and I have got to the point where I needed to use rectangles to detect bullets and giants hitting the player. I did that however, if you look at this image:

It shows the giant and the players rectangle, as you can see they are not rotating with the player, any idea how to fix this? Also yes I know they are no the same size as the sprites, that is because I set the size as they were to big before.

Thanks for any help :)


texts: Create bullet physics rigid body along the vertices of a blender model

texts:
I am working on my first 3D game, for iphone, and I am using Blender to create models, Cocos3D game engine and Bullet for physics simulation. I am trying to learn the use of physics engine.

What I have done

I have created a small model in blender which contains a Cube (default blender cube) at the origin and a UVSphere hovering exactly on top of this cube (without touching the cube)

I saved the file to get MyModel.blend. Then I used

File -> Export -> PVRGeoPOD (.pod/.h/.cpp)

in Blender to export the model to .pod format to use along with Cocos3D.

In the coding side, I added necessary bullet files to my Cocos3D template project in XCode.

I am also using a bullet objective C wrapper.

-(void) initializeScene {
    _physicsWorld = [[CC3PhysicsWorld alloc] init];
    [_physicsWorld setGravity:0 y:-9.8 z:0];

    /*Setup camera, lamp etc.*/
    ..........
    ...........

    /*Add models created in blender to scene*/
    [self addContentFromPODFile: @"MyModel.pod"];

    /*Create OpenGL ES buffers*/
    [self createGLBuffers];

    /*get models*/
    CC3MeshNode* cubeNode    = (CC3MeshNode*)[self getNodeNamed:@"Cube"];
    CC3MeshNode* sphereNode  = (CC3MeshNode*)[self getNodeNamed:@"Sphere"];

    /*Those boring grey colors..*/
    [cubeNode setColor:ccc3(255, 255, 0)];
    [sphereNode setColor:ccc3(255, 0, 0)];

    float *cVertexData  = (float*)((CC3VertexArrayMesh*)cubeNode.mesh).vertexLocations.vertices;
    int cVertexCount    = (CC3VertexArrayMesh*)cubeNode.mesh).vertexLocations.vertexCount;

    btTriangleMesh* cTriangleMesh  = new btTriangleMesh();

//    for (int i = 0; i < cVertexCount * 3; i+=3) {
//        printf("\n%f", cVertexData[i]);
//        printf("\n%f", cVertexData[i+1]);
//        printf("\n%f", cVertexData[i+2]);
//    }

    /*Trying to create a triangle mesh that curresponds the cube in 3D space.*/
    int offset = 0;
    for (int i = 0; i < (cVertexCount / 3); i++){
        unsigned int index1 = offset;
    unsigned int index2 = offset+6;
    unsigned int index3 = offset+12;
    cTriangleMesh->addTriangle(
           btVector3(cVertexData[index1], cVertexData[index1+1], cVertexData[index1+2] ),
           btVector3(cVertexData[index2], cVertexData[index2+1], cVertexData[index2+2] ),
           btVector3(cVertexData[index3], cVertexData[index3+1], cVertexData[index3+2]
        ));
        offset += 18;
    }

    [self releaseRedundantData];

    /*Create a collision shape from triangle mesh*/
    btBvhTriangleMeshShape* cTriMeshShape   =   new btBvhTriangleMeshShape(cTriangleMesh,true);
    btCollisionShape *sphereShape =   new btSphereShape(1);

    /*Create physics objects*/
    gTriMeshObject  = [_physicsWorld createPhysicsObjectTrimesh:cubeNode shape:cTriMeshShape mass:0 restitution:1.0 position:cubeNode.location];
    sphereObject    = [_physicsWorld createPhysicsObject:sphereNode shape:sphereShape mass:1 restitution:0.1 position:sphereNode.location];
    sphereObject.rigidBody->setDamping(0.1,0.8);
}

When I run the sphere and cube shows up fine. I expect the sphere object to fall directly on top of the cube, since I have given it a mass of 1 and the physics world gravity is given as -9.8 in y direction. But What is happening the spere rotates around cube three or times and then just jumps out of the scene. Then I know I have some basic misunderstanding about the whole process.

So my question is, how can I create a physics collision shape which corresponds to the shape of a particular mesh model. I may need complex shapes than cube and sphere, but before going into them I want to understand the concepts.


texts: Is it possible to create an irregular-shaped collider?  If so, how?  Would I need to create a couple objects and group them up into one Game Object?


texts:
I have a mesh like this (it's all a single mesh):

How I can figure out that the one floating piece is completely disconnected from the rest of the mesh?


texts:
I've been reading a lot about HDR techniques and came across Alpha Blending compatibility. Searched even more and found this snippet from the Ogre Forums:

  With source alpha blending, it sometimes looks ok provided the range differences aren't too high, but most other blend modes fail completely, particularly add. You really have to do your own separate composition in another fragment shader targetting a second texture and pulling the 'background' values in so you can do accurate blending, rather than render the transparent effects into the same original surface.

Why is alpha blending an issue when it comes to rendering HDR (values above 1.0) in 16FP FrameBuffers?


texts: Gravity and collision detection interfering with player movement

texts:
I am attempting to implement collision detection for a 2d sidescroller game and I'm having trouble keeping gravity from interfering with player movement.

Every frame I get and handle input, creating values for a point that represents the players movement vector. I then add gravity to the vector and check for collisions. This is the way AI will be handled as well.

The problem I'm having is when the player is on a floor tile, even if the input says to walk horizontally, after I add gravity to the move vector, collision detection returns a collision so the movement is completely negated.

I know i can test which a is is the problem, negate that and move the player but then if I change the players movement vector inside collision testing, wouldn't I have to cull for collisions again based off the new move vector?

I don't know if this has to do with input handling or collision testing. So how should I go about adding gravity to the players movement?


texts: How to implement the swipe up and down number select Unity3d

texts:
I want to implement the UI like in the image.
I want the users to select the number by swiping up and down.
I found the tutorial on the YouTube which is similar to the what i wanted (https://www.youtube.com/watch?v=mL-FLsV3WRs)
But it shows only the numbers from 0 to 9. I want to show from 1 to N (n can be any number).
Any idea to help me to get this would be great.


texts:
I'm trying to set up a D3DXQUATERNION to operate a rotation of 90 degrees around the Y axis.

I tried in the following way:

D3DXQUATERNION tempRot1(0.0f, 1.0f, 0.0f, cos(XM_PIDIV2/2));

because in the documentation they write that the fourth component, w, is defined as:

q.w = cos(theta/2)

But I'm afraid I didn't understand correctly, since the rotation is not what I expected.


texts: Server-side and client-side code management alongside API

texts:
Working on a new multiplayer game with an API, I'm struggling with code management and separating the client-side and server-side code. For context, I'm writing everything in C# (Monogame or OpenTK). No Unity here.

Project structure:

Server -> Common <- Client

The main problem I have is trying to separate the rendering code from the server logic.

I want to provide anyone the ability to define new types of entities. I would have a base class Entity and a plugin developer would inherit from this class to define a new entity type. When the server loads the plugin, if the latter tries to load textures for instance, it'll crash because there's no graphics context. Perfectly understandable. I simply don't know how to create a class structure that would allow the plugin to define the rendering logic and the server side logic while being completely separated. The Entity subclasses also have different logic on client than on the server (e.g. client-side prediction or position interpolation).

Is there a design pattern or a known pattern that could be used to do this?

I tried using components attached to the instances, which worked to some extent, but the plugin developer still has to check if they are on a server or on a client and add the related components. What if the plugin developer tries to add a client side component? I'm trying to do all of this in a statically typed manner (as much as possible).


texts:
Suppose I have a world defined in typical OpenGL coords.. then the up vector defined for this space is (0,1,0).

Now, if I load a model that is defined with (0,0,1) as its up vector, what are the matrix operation(s) that I need to carry out here to arrive at the 4x4 transformation matrix for the model?

Many thanks.


texts:
I've been learning OpenGL graphics programming and I've decided I'd quite like to make a simple game using OpenGL.

Drawing something in OpenGL, needless to say, is quite the endeavour. However it usually follows the following steps:

1) Use an array to outline where the vertices are of what I want to draw, as well as

2) Create a vertex array object VAO to store the vertex buffer objects and store how the data is formatted, etc.

3) Generating vertex buffer objects VBOs and element buffer objects EBOs (if applicable). Binding the relevant buffer data to them (ie, passing in the vertex data to the VBO and vertex drawing order to the EBO).

4) Instructing OpenGL on how the data is actually formatted within the array I defined at the start (the vertex coordinates, texture coordinates, etc) using glVertexAttribPointer.

5) Binding the textures if necessary, enabling the vertex and fragment shaders, binding the vertex array, and then finally drawing.

6) Unbinding the vertex array

Since I'm almost always following these 6 steps when I want to draw things I thought I'd be able to abstract it. I thought I could do this by passing in a batch of vertices to a 'render' class every render call which would do these steps every time for me so I can render things more easily without the great big spiel that takes a good 20 lines of code every time I want to draw a box.

This would be immensely helpful. For example, suppose I wanted to draw a heightmap. All I'd have to do would be to pass in the vertex locations/textures to bind/shaders to use, etc, and it'd draw it for me! Possibly even alongside some trees/rocks that I could pass in to that one render call.

However I've realised that there're a lot of technical limitations with this and I'm beginning to question whether this is even a fundamentally correct approach to OpenGL rendering.The reason why I think this is fundamentally wrong is because it still doesn't really avoid the big spiel of code that I have to go through every time I want to draw some vertices - I just create a 'middleman' class inbetween, which is a bit useless and unnecessary.

What are the best practises when it comes to creating a simplified and easy-to-use rendering 'pipeline' like what I'm trying to describe?


texts: GLFW / OpenGL location and size in pixels

texts:
I'm using GLFW to create a little game. (and by little, I mean: small, nonprofit)

After a while of puzzling, I found out that this draws a texture (from an image, for instance) to the screen:

(the syntax is in Go, but the library is the same as the C/C++ version)

gl.BindTexture(gl.TEXTURE_2D, tex)
gl.Color4f(1, 1, 1, 1)

gl.Begin(gl.QUADS)

gl.Normal3f(0, 0, 0)

gl.TexCoord2f(1, 1)                     // top right
gl.Vertex3f(1, -1, 0)

gl.TexCoord2f(0, 1)                     // bottom right
gl.Vertex3f(-1, -1, 0) // = location

gl.TexCoord2f(0, 0)                     // bottom left
gl.Vertex3f(-1, 1, 0)

gl.TexCoord2f(1, 0)                     // top left
gl.Vertex3f(1, 1, 0)

gl.End()

This draws the texture perfectly. There is just one downside: as my screen is 16:9, the texture also gets rendered/displayed as 16:9. But as this is a square image (32 by 32 pixels), how do I get it to draw just those pixels, instead of defining it relative to the screen ratio? (values between -1 and 1)

My first assumption was that I can compute what the values should be, by comparing it with the actual screen size, but this feels like it's not the way to go.


texts:
I've been putting some (a lot) of thought about how to read keyboard input and especially, when.

Looping through all the keycodes on the keyboard and updating the statuses seems like a lot of waste when there are only few keys pressed at one time.

I started to think that if the game gives a player key rebinding ability,
why not read only those keys/actions that are currently bound in the game and ignore the rest?

If the "Move forward" action has a key "W" bound to it, then only look for status of key W.

And you can ignore the rest (Of course not ESC and other various game-wide actions).

To me this would make sense, because most of the time games are simple and they only use a few keys on the keyboard.

Does this approach make any sense?


texts:
I have been working on a game in Ogre for the last 6 months or so. It started as a learning project, and after a few rewrites it actually turned into a real game project. Physics scared me, and using Bullet with its lack of documentation was a nightmare, but I was able to atleast get some basics added and learned a lot. So as of now I am using Ogre with its default animation system (fairly basic) and Bullet Physics.

I had always wanted to use Havok when I started out, but due to lack of integration information on the Ogre forums, and lack of tutorials on the net, I decided against it. Now that I am actually at the point where Bullet is just too much of a headache to proceed with (staring at forum threads praying someone answers) and the Ogre animation system is so basic, I am considering switching to Havok for Physics and Animation.

The Physics system looks extremely polished and easy to use. The animation system looks incredible with the retargeting/blending/etc. The documentation is incredibly detailed as well (I guess when you come from Bullet, any documentation looks amazing)

So my question is, as I am still somewhat of a 'newbie' to game development, should I just stick with what I am using now or should I make the switch over to Havok? The physics looks like I could get my project back to where it is now with minimal effort, and be able to expand much faster. The animation aspect looks extremely daunting as far as integrating it with Ogre.


texts:
Currently, I'm simulating physics impact forces for local avoidance of units but this method sometimes pushes units out of formation and has very undesirable effects when units clump up.

For RTS games like Starcraft 2, how is local avoidance done? Are physics simulated or an omnicient controller decides where everything should be? I know this question might be a little broad so I'm asking specifically for how to achieve the local avoidance behaviors of Starcraft 2; though anything that works will be very appreciated.

I'm not looking for any code - just useful resources or explanations of how Starcraft 2 (or similar games) handles local avoidance.

Currently, I have collision detection (with penetration vector), collision forces, and movement by velocity implemented. Every unit is checked against another for a collision - if they collide, the objects are immediately offset by the penetration vector then the collision force is applied. Then another loop moves the objects by their velocities and applies drag to the velocities. The offset mitigates the problem of excessive collision forces applied on clumped units, but units still sometimes shoot out.

The solution I'm looking for needs to satisfy the following requirements (as in Starcraft 2):

Objects musn't overlap; or at least overlaps must be eventually
resolved.
Objects don't push each other away more than necessary so 2 units can stand and move next to each other in a formation.
There should not be any weird behaviors when objects clump towards the same destination.
Can support units of different sizes, and even different convex shapes.

What I've been thinking of so far is instead of detecting for collisions, detect for future collisions so the overlap never happens. Then apply the constraint, making sure the 2 units' velocities don't cause them to overlap. I'm still tinkering with the algorithm for restricting movement beyond the overlap.


texts: How to set LinearVelocity exactly in onSceneTouchEvent?

texts:
I'm beginner in Android programming.
And i use AndEngine GLS2 with Body and AnimatedSprite.

I have a object ball and i want to move it to follow my hand. This is description for my idea:

And my code:

@Override
public boolean onSceneTouchEvent(final Scene pScene,
            final TouchEvent pSceneTouchEvent) {
     ballObject.getBodyball().setLinearVelocity(
                    new Vector2(pX, pY));
}

How to get exactly variables:pX, pY ?


texts: Matrix Rotation Only Works On one Axis At A Time

texts:
I have this function in my vertex shader. It makes a transformation matix out of a transformation matrix, a rotation and an intensity. It works just fine when setting the rotation of one of the axis (Vector3f rotation = new Vector3f(90, 0, 0);), but when rotating it on multible axis it gives a strange result, that is basicly rotated, but the higher the rotation, the flatter it gets and the model inverts inverts itself if it's too high. this is the function:

void createTransform(in mat4 bone,in vec3 bone_rotation,in float intensity, out mat4 transform)
{
//norm is the identity matrix.
transform = norm;

//rotation
vec3 rot = vec3(bone_rotation.x * intensity, bone_rotation.y * intensity, bone_rotation.z * intensity);
mat4 rotation = norm;

transform[1][1] = 1+cos(rot.x);
transform[2][1] = -sin(rot.x);
transform[1][2] = sin(rot.x);
transform[2][2] = 1+cos(rot.x);

transform[0][0] = cos(rot.y);
transform[2][0] = sin(rot.y);
transform[0][2] = -sin(rot.y);
transform[2][2] = cos(rot.y);

transform[0][0] = cos(rot.z);
transform[1][0] = -sin(rot.z);
transform[0][1] = sin(rot.z);
transform[1][1] = cos(rot.z);

//translation
transform[3][0] += bone[3][0] * intensity;
transform[3][1] += bone[3][1] * intensity;
transform[3][2] += bone[3][2] * intensity;

//scale
transform[0][0] = 1 + (bone[0][0] - 1) * intensity;
transform[1][1] = 1 + (bone[1][1] - 1) * intensity;
transform[2][2] = 1 + (bone[2][2] - 1) * intensity;

}


texts:
I'm making my first game with LibGDX and Box2D, and I've realized that the memory used increases when I change screens. It starts from 150MB and progressively reaches 850. How should I deal with this? It does not seem to be a memory leak, memory is constant throughout the level, and I'm using an AssetManager to dispose everything needed.

The problem is when switching screens, since objects remain in memory. What is the best practice in this case?
Should I have a method in each class that sets every object to null before the screen is disposed?
Another problem might be that I have a static class for all my constants (this was the method proposed in the Udacity course), could this be an issue?

Another idea described here is initializing all screens in the beginning and using them throughout the game. Though I'm not sure this could be done in my game now. Is this good practice?

I tried profiling a bit although it's the first time, here are some results. The sudden 'hops' are when switching screens.


texts: Sending Client Input to Server (which way?)

texts:
I am trying to get networking working for my game, I've read several sources of information about this subject but one thing is still unclear for me.

The way I process client input is by executing a command bound to that input, for example:

Player presses D -> MoveLeftCommand gets executed which applies a linear impulse to the body of the player.

Since the server codebase and client codebase are almost the same I just reference the commands by bytes, MoveLeftCommand is for example byte 1.

What I have now is when the player presses D it sends the byte of the MoveLeftCommand to the server and the server executes this on the specified entity.
I don't believe this is right though since the client will have to send 60 packets per second to the server just to move. It is no problem just send a JumpCommand, this command will get executed once. But I think there is another way to send position.

My question is: what is the common way to send input from a client to a server? I have read about 'sanity checks' on servers but I don't now what is meant by that. Should I do something with client time?

Thanks in advance!


texts:
I know this has been asked before but I would like some things cleared up.

I understand that game logic and rendering should be separated but my problem is more or less how? For instance, should the renderer get ALL info from the sprite/object and use that to draw? Also should the renderer be a seperate class or member function. If it's a separate class should it be able to get the necessary info via public functions or should it be a friend of the class to draw it?

Also some clarification as to what the main object should contain, e.g, is it okay for the main class to have other sprites, shapes, fonts, and effect data? Or, should the renderer somehow contain or produce that data?

I'm asking this because I'm making a menu list class in SFML. And, although it technically works, I'm confused because it's implemented in a way that is considered by many to be bad. Thus, I would like to know as to how to implement it and fix it correctly because I have currently blended both the logic and rendering together.

class MenuList {
    private:
        bool m_visibility{ true };
        std::vector<std::pair<MenuItem, sf::Text>> m_items;
        sf::RenderWindow& m_window;
        SEL::EventManager& m_manager;
        sf::Font m_font;

        sf::RectangleShape m_highlighter;
        sf::Color m_highlightColor;

        sf::RectangleShape m_box;

        size_t m_size{ 0 };
        size_t m_rowSpacing;

        static const uint16_t indent;
    public:
        MenuList(sf::RenderWindow& window, SEL::EventManager& manager);
        ~MenuList();
        // get a certain option, no range checking
        MenuItem& operator[](size_t index);

        // get a certain option, with range checking
        // will report an error to the console if range is out of bounds
        MenuItem& getOption(size_t index);

        // update the menu
        void Update();

        // set the visibility of the menu
        void setVisibility(bool value);

        // get the visibility of the menu
        bool getVisibility() const;

        // add another option
        void addOption(const MenuItem& item);

        // add multiple options via a list { }
        void addOption(std::initializer_list<MenuItem> items);

        // remove an options index
        void removeOption(size_t index);

        // remove an option by name
        void removeOption(const sf::String& name);

        // resize the amount of submenus
        void resize(size_t size);

        // get the local position of the menubox
        sf::FloatRect getLocalBounds();

        // set the amount of spacing between each menu in pixels
        void setRowSpacing(size_t rowSpacing);

        // get the amount of spacing is in between each menu in pixels
        size_t getRowSpacing() const;

        //void addSeperator(size_t index, sf::PrimitiveType Type = sf::PrimitiveType::LinesStrip);

        // get the amount of sub menus
        size_t getMenuCount() const noexcept;

        // get the position of the menu, the top left
        const sf::Vector2f& getPosition() const noexcept;

        // move the menu to a completely new position, overides the previous position
        void setPosition(float x, float y);

        // move the menu to a completely new position, overides the previous position
        void setPosition(const sf::Vector2f& pos);

        void setOutlineThickness(size_t thickness);

        size_t getOutlineThickness() const;

        // reset the menu such as the size, menus, and box
        void reset();
    };


texts:
I want to make a flat world, but i want to split it into pieces which will load in segments (for better optimization), and when you are at the end of map it will start loading segments from the beginning again. And I want to make an illusion of roundness (only optical effect if possible). For example, when you watch ships on the horizon, you see their masts first.

I'm asking only for theoretical ideas, so you don't need to send any scripts.


texts: Java how to color text without using JNI?

texts:
I am working on a small text-based game in Java.  I am trying to understand the concept of how to color the output without needing to use JNI. C++ has the ability to modify the console directly and also make system calls but as far as I can tell JAVA doesn't because of its ability to be system independent.

Is this possible or should I look at using a JFrame and the paint object?


texts: Creating a vertexbuffer to define vertices arranged in a grid with the view for easy editing later

texts:
I'm using the marching square algorithm (2D version of marching cubes) to generate vertices.

I end up with vertices arranged in a grid.

I want to enable destructible terrain, and the way i was planning on doing this was to start simple - have one vertex buffer with the whole map, and edit the bits that change. In cases where I need to remove vertices I was thinking about just making them transparent so I can still render the whole map in one go.

Firstly, is this approach reasonable?

Secondly, I want to design my VB so that if I need to change vertices in 3x3, 5x5 or 7x7 etc. grids the locations of the vertices in the VB are close together.

Now, from university I vaguely remember an image compression algorithm that walked the image in an unusual way, which i think could apply. Basically it walked in a U / horseshoe direction. It would place a U over the image, large enough to cover the whole thing, then it would break the U up into 4 quadrants, and use a smaller U to walk those, and so on until it got down to the pixel level, or in my case it got down to a single grid unit.

Does this sound feasible? What is that algorithm called? (I can't remember the name and haven't found via general searching).


texts: How can I get the Text component from TextMeshPro ? I'm getting null exception

texts:
At the top of the screen :
public GameObject uiSceneText;
private TextMeshPro textMeshPro;

Then in the script at some point :
uiSceneText.SetActive(true);

if (textMeshPro.text != "")
    textMeshPro.text = "";

The exception error null is on the textMeshPro on the line :
if (textMeshPro.text != "")

textMeshPro is null.
This screenshot shows the TextMeshPro in the Hierarchy :

and I see that the Scene Image object and its child Scene Text both are enabled true.
I want to get the text and add replace a new text with the text already in the Text but the textMeshPro is null.
The complete script :
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

public class PlayerSpaceshipAreaColliding : MonoBehaviour
{
    public float rotationSpeed;
    public float movingSpeed;
    public float secondsToRotate;
    public GameObject uiSceneText;

    private float timeElapsed = 0;
    private float lerpDuration = 3;
    private float startValue = 1;
    private float endValue = 0;
    private float valueToLerp = 0;
    private Animator playerAnimator;
    private bool exitSpaceShipSurroundingArea = false;
    private bool slowd = true;
    private TextMeshPro textMeshPro;

    // Start is called before the first frame update
    void Start()
    {
        textMeshPro = uiSceneText.GetComponent<TextMeshPro>();

        playerAnimator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        if (exitSpaceShipSurroundingArea)
        {
            if (slowd)
                SlowDown();

            if (playerAnimator.GetFloat("Forward") == 0)
            {
                slowd = false;

                LockController.PlayerLockState(false);

                uiSceneText.SetActive(true);

                if (textMeshPro.text != "")
                    textMeshPro.text = "";

                textMeshPro.text = "Here I will add the new text.";

            }

            if (slowd == false)
            {

            }
        }
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.name == "CrashLandedShipUpDown")
        {
            exitSpaceShipSurroundingArea = false;
            Debug.Log("Entered Spaceship Area !");
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.name == "CrashLandedShipUpDown")
        {
            exitSpaceShipSurroundingArea = true;
            Debug.Log("Exited Spaceship Area !");
        }
    }

    private void SlowDown()
    {
        if (timeElapsed < lerpDuration)
        {
            valueToLerp = Mathf.Lerp(startValue, endValue, timeElapsed / lerpDuration);
            playerAnimator.SetFloat("Forward", valueToLerp);
            timeElapsed += Time.deltaTime;
        }

        playerAnimator.SetFloat("Forward", valueToLerp);
        valueToLerp = 0;
    }
}


texts: Are there any way to stop Unity from upgrading a shader?

texts:
A projector shader using the _Projector attribute will be changed to use unity_Projector, instead, in Unity 5.5. I'm writing an editor plugin that works on multiple versions of Unity. Such upgrading will make the shader not work in earlier version of Unity.

Is there any way to stop such upgrading?


texts:
I'm having trouble wrapping my head around something that should be relatively simple. I'm making a breakout clone using LibGDX and Box2D. I'm also using the Ashley ECS. For movement with bodies, I have two components - a BodyComponent (BC) which contains a reference to the Body that was created for the owning entity, and a PhysicsComponent (PC) which contains a velocity vector.

What I'm currently doing is manipulating the PC's velocity vector when providing input, then setting the BC's body's linear velocity to the velocity vector in the PC. This allows my bodies to move how I want them to move but there are two issues:

Bodies have no maximum velocity
If the pad bumps into a static body, it should bounce. However it quickly snaps back to its original position because the PC's velocity is unaffected when bodies collides.

How can I manipulate bodies and make them move and interact with other bodies without the need to use another component for velocity?


texts: Why does the box rotate, spin instead of gliding?

texts:
I've just learned that if I want to move an object so it acts depending of physics, I need to use rigidbody.velocity instead of transform.Translate. When I was using transform.Translate the box glided without problem. The only problem was that when it collided with a wall it began to jump and spin like crazy. But that problem is fixed now!

But when I added a rigidbody and used rigidbody.velocity, another problem stemmed: It doesn't glide. I tried using rigidbody.velocity and also, instead, I tried to create a Vector 3 movement, and at the end of the code I would write rb.AddForce (movement);. However, it still rotates, instead of gliding.

What's is generating this weird problem?

This is my updated code:

using UnityEngine;
using System.Collections;

public class MoveCharacter : MonoBehaviour {

    public float deltaMovement = 1f;
    public Rigidbody rb;
    // Use this for initialization
    void Start ()
    {
        rb = GetComponent<Rigidbody> ();
    }

    // Update is called once per frame
    void Update ()
    {
        Debug.Log (Time.deltaTime);
        Moving();
    }

    void Moving()
    {
        Vector3 movement = new Vector3(0, 0, 0);
        //Moves the character to where it needs.
        if (Input.GetKey (KeyCode.A)) {
            movement = new Vector3(deltaMovement, 0, 0);
        } else if (Input.GetKey (KeyCode.D)){
            movement = new Vector3 (-deltaMovement, 0, 0);
        }
        float yRotation = Camera.main.transform.eulerAngles.y;
        float movementX = Mathf.Sin ((yRotation * Mathf.PI) / 180) * deltaMovement;
        float movementZ = Mathf.Cos ((yRotation * Mathf.PI) / 180) * deltaMovement;

        if (Input.GetKey (KeyCode.W)) {
            movement = new Vector3 (movementX, 0, movementZ);
        } else if (Input.GetKey (KeyCode.S)){
            movement = new Vector3 (-movementX, 0, -movementZ);
        }
        rb.AddForce (movement);
    }
}

By the way, changing between Update() and FixedUpdate() didn't help...


texts: Rotation with respect to world instead of the object itself using Quaternion.Euler in unity

texts:
[Other answers on similar questions on stackexchange didnt help]

This script is giving some weird outputs

On running this script If I press rightarrow once followed by 's' the object rotates on 'z' axis and 'x' axis correctly but there after if I press arrowkeys or 'a/s' in both the cases the object rotates on y axis forever. I dont understand why this is happening.

I want it to rotate w.r.t. the world axis always.

code:

public float speed = 1;
private int xtimesHit = 0;
private int ytimesHit = 0;
private int ztimesHit = 0;

void Update () {
    if( Input.GetKeyDown( KeyCode.RightArrow ) ){
        ztimesHit--;
    }
    if( Input.GetKeyDown( KeyCode.LeftArrow ) ){
        ztimesHit++;
    }

    if( Input.GetKeyDown( "a" ) ){
        ytimesHit++;
    }
    if( Input.GetKeyDown( "d" ) ){
        ytimesHit--;
    }

    if( Input.GetKeyDown( "w" ) ){
        xtimesHit++;
    }
    if( Input.GetKeyDown( "s") ){
        xtimesHit--;
    }

    this.transform.rotation = Quaternion.Lerp(this.transform.rotation, Quaternion.Euler(xtimesHit*90,ytimesHit*90,ztimesHit*90), Time.deltaTime*speed);

How can I do that?
I have created this code with help from other, so I'd wish to edit it rather than using totally new functions.

[Optional]
Code explanation:
My code is fulfilling partial requirements, I want to rotate my object on x,y,z axis by 90 deg on  respective keyboard inputs. (Example: keys a and s should rotate the object by 90 deg on z axis, w and s should rotate the object by 90 deg on y axis and arrow keys should rotate the object by 90 deg on y axis). Also pressing 'a' n times should rotate the object by 90 deg n times.


texts:
Heavily related to this question, as of now, Unity's TOS has changed dramatically. And searching in the TOS, it looks like I'm allowed to remove the Unity logo in my exported game. Looking at Section 4.1, it still retains:

  You will not remove, alter or obscure any copyright, trademark,
  service mark or other proprietary rights notices incorporated in or
  accompanying the Services.

However looking at how "Services" is defined in the first paragraph of the TOS:

  Unity Technologies ApS (“Unity”, “our” or “we”) provides
  game-development and related software (the “Software”),
  development-related services (like Unity Analytics (“Developer
  Services”)), and various Unity communities (like Unity Answers and and
  the Made with Unity Platform (“Communities”)), provided through or in
  connection with our website, accessible at unity3d.com or unity.com
  (collectively, the “Site”). Except to the extent you and Unity have
  executed a separate agreement, these terms and conditions exclusively
  govern your access to and use of the Software, Developer Services,
  Communities and Site (collectively, the “Services”)

It does not seem to include the exported game itself. And even if Section 4.1 says "accompanying the services", I assume it still wouldn't include the game as the game does not need to accompany them. Otherwise it would be illegal to remove the logo from the splash screen from a game made in Unity Pro since the TOS applies to all tiers of Unity. Furthermore, I haven't found anywhere that says you can't modify or hack into the produced executables (I even looked in here which contains another part of the TOS). Does this mean I can remove the logo from the splash screen no matter what Unity tier (personal, plus or pro) I'm using?

(My aim is to actually move it to a dedicated credits section accessible from the title screen of the game rather than having it appear in the splash screen. Players of the game will still know that it's made in Unity.)


texts: Fast selection of visible child components

texts:
I'm working on gui and I have next realization of base UI component:

So when I want to get absolute component position I need to sum all parent positions with component position.
Also if I want to skip rendering of component, in case if it out of bounds in one of parent components, I need to go through all parents and check this.
This approach is not very fast in case if there are too much components (about 10.000) so my ups decreased from 2600 to 400 updates per second.

Also till rendering I need to calculate scissoring rectangle by intersecting all parent rectangles with current rectangle.
IMO it is also little bit heavy operation in case a big tree of components.

Is there any way to increase it?
Or some fast way to select only visible components without checking every component in list?
Maybe there should be some another component structure?


texts: Sebastian Lague 2D Platformer Controller 'Continue' Problem

texts:
In episode 10 of Sebastian Lague's "[Unity] Creating a 2D Platformer" series, he creates a jump through platform by using "Continue;" in his vertical collisions script.

This worked great for a jump through platform, but when used by an object that I want to interact with, but not colliding with like a regular platform, problems come up.

When the player is complete covered, collision acts up. Because "Continue" makes the player fall through the platform a bit before correcting itself.

Ignore the weird lines caused by the compressed gif.

What I want to do is be able to interact with objects without colliding with them.
I use raycast2d collision to do this, it's from his video.

Here's the part of the video where he programs it.
https://youtu.be/rVfR14UNNDo?t=268

If there's any other info you'd like, just let me know.
Thanks


texts: Why don't games load assets while showing main menu?

texts:
Most single player computer games have rather frustrating pattern of loading:

start game
Game shows you some logo videos
Game indicates it is loading (general assets are loading, that are always used)
Main menu shows
Select and load game
More loading
You can play now

Loading of general assets could be in theory done while already showing main menu, unless the main menu contains some elaborate graphics itself.

There must be some obstruction, since I am not aware of many modern games that show the menu immediately. What prevents creators to load assets asynchronously while player is selecting things in main menu?

Or other way to phrase the question: If I wanted to have my game show menuy while still loading assets, what problems do I need to solve?


texts: Libgdx stop animation at last animated frame

texts:
How i can stop animation at last frame.

@Override
public void create(){

textureAtlas = new TextureAtlas("pack.atlas");
stage = new Stage(new ScreenViewport());
sb = new SpriteBatch();

 final TextButton button = new TextButton("Start",skin , "default");
        button.setWidth(220);
        button.setHeight(50);

  button.addListener(new ClickListener(){
            @Override
            public void clicked(InputEvent event, float x, float y) {
                spinAnimation.setFrameDuration(0.5f);
                int i = 0;
     Timer.schedule(new Timer.Task() {
                @Override
                public void run() {
                    spinAnimation.setFrameDuration(0f);

                }

            },1);

            }
        });

    stage.addActor(button);

           Gdx.input.setInputProcessor(stage);
    }

@Override
   public void render() {

   elepsedTime += Gdx.graphics.getDeltaTime();
   Gdx.gl.glClearColor(0,0,0,1);
   Gdx.gl.glClear(com.badlogic.gdx.graphics.GL20.GL_COLOR_BUFFER_BIT);

   sb.begin();
   stage.act(Gdx.graphics.getDeltaTime());
   sb.draw(spinAnimation.getKeyFrame(elepsedTime,true), 50,  60

   sb.end();
   stage.draw();
    }


texts: After collision of two objects change the sprite and move in its direction

texts:
I've searched a lot for this question but there was no answer that could solve the problem I'm having. I'm new to unity and a very naive developer.I'm making a game in unity using c# and it's like a bird that throws eggs in down projectile and when the egg hit the container it should destroy egg and the container sprite should change to a sprite which shows that the egg is inside the container.It would be really helpful if someone could answer with a example code and I can implement this. Rest of the game is working fine projectile and hit. There are check points on egg.cs in OnTriggerEnter2D that if target.gameObject.tag == "Container" now here I need to change the container to another sprite I've and this should move in the direction of container.
UPDATE:Here is the code which changes the sprite, but it changes the egg sprite not the container sprite.First the declaration:

public Sprite changedContainer; //here I've set the sprite of Changed Container
private SpriteRenderer spriteRend;

 Then in the start method:

spriteRend = GetComponent<SpriteRenderer>();

and finally my onCollision Trigger method: (Read the comment in my code)

void OnTriggerEnter2D(Collider2D target)
    {
        if (target.gameObject.tag == "Container") //if the egg collide with container
        {
            transform.GetComponent<SpriteRenderer> ().sprite = changedContainer; <br //which it did successfully
            Instantiate(changedContainer, target.gameObject.transform.position, Quaternion.identity); //as it is mentioned that target.gameobject.transform.position but it still takes the egg projectile
        }
}

So how to change the spite of container? I think I'm in the wrong class I should be doing this in the container class. But it is the projectile of egg that collides not the container that collides with egg.


texts:
While developing a small game using tile-mapping method a question came to my mind:

I would develop the game on Windows but wouldn't exclude adapting it to another platform.

What size(in pixels) would you recommend using for creating the tiles of a tile-mapped game(ie: RPG) with the following requirements?

Have an acceptable level of detail without having too many tiles.
Having a decent map size.
Allow adaptation of the game on a handheld(ie: PSP), smartphone or a computer without too much loss of detail or slowdowns.
Allow more or less important zoom-in / zoom-out.
Have a resolution of tile that permits either pixel-perfect collision or block-collision.

Anything from a good explanation to a game example is useful as long as it can fit the requirements.

This question may seem a bit simplistic, but I noticed that many Indies game developer were using inappropriate scales scenery.

Also sorry for the poor syntax and the lack of vocabulary of my question, being a non-native English speaker doesn't help when talking about computers programming.


texts:
I have read the whole unity manual and watched the videos on sprites but I have a question. Is there any way of creating primitive 2D shapes in unity? (I will be assigning trigger colliders to these as well). Or does one need to have a 3rd-party program even for basic primitive 2D shapes? My game really is very minimalist.

I did think about using particle system in a clever way but that won't have triggers and may not be as memory efficient for the several basic shapes that I am after.


texts:
Is there such a thing as screen-space shadows? I know that most shadow projection comes from rendering the world from the viewpoint of the light source, projecting the shadows onto a large square texture laying on the ground, and then rendering the scene again using data from that texture to shade things.

But what if that texture wasn't square? Ultimately, the scene is going to be projected into the screen, and using the viewport you can calculate the trapezoid-shaped block of the world that you know is going to be visible.

What if you then did all of your light projection onto that shape instead? Is there a way to make the math work? Seems to me that the end result would allow everything on the screen to always be shadowed (rather than shadows disappearing when too far from the camera), and would automatically give more shadow detail closer to the camera.

Seems like someone would have already tried this, so what am I missing?


texts: SerializeField vs GetComponent Efficiency

texts:
As far as I know, there are two built in ways to get an instance of a component in Unity.

1 - Serialize the field and drag in the component manually in the editor

[SerializeField] private MyScript script;

2 - Using MonoBehaviour's GetComponent method

script = GetComponent<MyScript>();

I would think that it is more efficient to drag the component in the editor lest making the engine illiterate through every component in the GameObject to find the component.

Is it more or less efficient to drag the component in the editor compared to using GetComponent? Or does Unity find components in a different way or dragging components in the editor is handled in a different way such that it would be more efficient to use GetComponent? Would using one over the other have any impact on performance in the real world?

A similar question would also be raised regarding GameObject.FindGameObjectWithTag() vs dragging in the editor.

As far as optimization go, should you use one method over another?