texts: Creating palette from irregular sprites in Unity

texts:
I want to create a palette based on a number of PNGs in Unity 2D. I am struggling to understand the slicing logic. Let's say I have a sprite 588x547, and I set PPU to 128. So obviously the sprite cannot be divided into 128-parts:

So the right and the bottom part are not going to appear on my palette.
Now I would like the grid to start in the center. The tiles on the sides are not "full" tiles, but I still want them on my palette in the end, so I kind of want Unity to fill up the border tiles for me with void till they reach the 128x128 size:

Is there a way to achieve this? Or am I conceptually misunderstanding something? Given a bunch of PNGs, all of them different pixel sizes, none dividable by 128, how do you create a palette from them to paint on a 128 PPU grid?
I had a look at external tools like TexturePacker and Showbox, but did't manage to achieve a nice 128-dividable grid from my sprites.


texts: How to add Facebook Data Storage to Mobile Game?

texts:
I was wondering how I would add the option for players to sign into their Facebook profiles on my mobile game and then have Facebook store their game save data, so they can recover it on any device when they sign into Facebook. Other Facebook features would include seeing their friends on the Facebook leaderboards, inviting their friends to the game and challenging their friends to beat their scores. I would hate for the Player's data to be lost, so the Facebook data save part is very important. A good reference to this feature is the Hungry Shark mobile game.

I wasn't sure how this works. My programming friend and I are creating the game together, but he doesn't know how to do this and I don't know how to program. Once I figure out exactly what has to be done, I would like to hire a programmer who knows how to add this feature.

Thank you!


texts:
I wrote a pretty basic game for colleagues to play : the player shoots on an enemy which has 50 lives while other smaller enemies pop randomly on the screen. The goal is to kill the main enemy as fast as possible.

One important point : the game is written in javascript (using HTML5 canvas).

At the end of the game, I send the score and username to my php function in Ajax, and that's where I have trouble : I find it really hard to restrain my colleagues from cheating.

Here are the different ways of cheating I've noted so far :

Changing the score sent during the ajax call
At the beginning of the game, reducing the number of lives of the enemy
At the beginning of the game, reducing the probability for enemies to appear

Here are the solutions I implemented to counter that cheating :

Create an array that I fill each time I enter the game loop with "delta", the time between that frame and the previous. I send that list to my php save function and then check that the total time of the deltas is equal to the score sent.
Create an array where I store the times when the Enemy loses 1 life. Then in the php save function I check that the list trully has 50 elements, and that the time between 2 elements is not less than a certain value
Create an array where I store the time when an enemy appears. Then in the php save function I check the number of enemies is not less than a certain number.

The 2 first points seem good enough for me : it becomes too much trouble for anyone to try and cheat that.
The last point is causing me much trouble. I cannot stop the user from changing apparition rate to 0, then in the ajax call just fill the array with 30 values, that seems pretty easy.

This is my first try with this kind of issue, so I have several questions :

Am I on the good way?
Are there any "patterns" I am missing for this kind of issue?
What would be your approach? What would you do? How to make it even more difficult for the players to cheat?


texts: Detect if a sprite has left the camera in libgdx?

texts: Is there a method to know if a sprite has left the camera of the stage? or I have to do my operations? :P


texts: Problem with HLSL :TextureCoordinate0 is missing

texts:
I'm trying to create a very simple game, and am working with HLSL. I got this error in my draw method:

  The current vertex declaration does not include all the elements
  required by the current vertex shader. TextureCoordinate0 is missing.

Here is my draw method:

public void Draw(Matrix View, Matrix Projection,Vector3 CameraPosition)
{
        // Calculate the base transformation by combining
        // translation, rotation, and scaling

        Matrix baseWorld = Matrix.CreateScale(Scale) *
            Matrix.CreateFromYawPitchRoll(Rotation.X, Rotation.Y, Rotation.Z) *
            Matrix.CreateTranslation(Position);
        foreach (ModelMesh mesh in Model.Meshes)
        {
            Matrix localWorld = modelTransforms[mesh.ParentBone.Index] * baseWorld;

            foreach (ModelMeshPart part in mesh.MeshParts)
            {
                Effect effect = part.Effect;
                if (part.Effect is BasicEffect)
                {
                    ((BasicEffect)effect).World = localWorld;
                    ((BasicEffect)effect).View = View;
                    ((BasicEffect)effect).Projection = Projection;
                    ((BasicEffect)effect).EnableDefaultLighting();
                }
                else
                {
                    setEffectParameter(effect, "World", localWorld);
                    setEffectParameter(effect, "View", View);
                    setEffectParameter(effect, "Projection", Projection);
                    setEffectParameter(effect, "CameraPosition", CameraPosition);

                    Material.SetEffectParameters(effect);
                }
            }
            mesh.Draw();
        }

But in VertexShaderFunction (in LightingEffect), instead of output.UV = input.UV I put output.UV=float2(somefloat,somefloat) I get no error.

There is a another thing, I got this error when I try to load my "Cathedral" model and others, but for "teapot" model I get no error.

Here is my complete code and models.


texts: Technique to have screen independent grid based puzzle with sprite animation

texts:
let's say I have a fixed size grid puzzle game (8 x 10). I will be using sprites animation, when the "pieces" in the puzzle is moving from one grid to another grid.

I was wondering, what is the technique to have this game being implemented as screen resolution independent. Here is what I plan to do.

1) The data structure coordinate will be represented using double, with 1.0 as max value.

// Puzzle grid of 8 x 10
Environment {
    double width = 0.8;
    double height = 1.0;
}

// Location of Sprite at coordinate (1, 1)
Sprite {
    double posX = 0.1;
    double posY = 0.1;
    double width = 0.1;
    double height = 0.1;
}

// scale = PYSICAL_SCREEN_SIZE
drawBitmap (
    sprite_image,
    sprite_image_rect,
    new Rect(sprite.posX * Scale, sprite.posY * Scale, (sprite.posX + sprite.width) * Scale, (sprite.posY + sprite.Height) * Scale),
    paint
);

2) A large size sprite image will be used (128x128). As sprite image shall look fine if we scale from large size down to small size, but not vice versa.

Besides the above mentioned technique, is there any other consideration I had missed out?


texts: How to go about implementing pathfinding in Unity with Tiled2Unity map prefabs?

texts:
I have created a map using Tiled application and have added collision boxes and used Tiled2Unity to import the map to Unity. The collisions are working with key inputs.

I want to implement pathfinding in my 2D tile game.

I have studied and written a A * pathfinding code with 2D array in C#, which is working. But with the map import I have no way to iterate through the tiles.

How to go about implementing pathfinding?


texts: How to find path in graph without crossing the walls?

texts:
I would like to know how to find path in a graph while having the edges "double-sided". Consider this scenario:

I have list of the line segments. These represents "walls" or rather impassable edges (in a game). I then plan in a next step to build a connected graphs (where possible). I'm trying to determine the feasibility at this point. If there's even a solution to this (it should in my opinion).

I don't need to know about A* or other algorithms per se, but rather how to not walk through the walls as seen in figure B. Any ideas?

I was wondering if I could turn segments to polygons (by adding width). Then make an union of these polygons and then treat them rather as polygons. But I would like to know whether there is a way to do it without this hassle. Also I'm not sure I want to add any width to the lines necessarily.


texts:
Using Unity (2109.1.3f1) is there a way to switch the scene view's Shading Mode/Draw Mode from Wireframe to Shaded?
(eg. press 4 for Wireframe, 5 for Shaded)

I've looked in the Shortcuts Editor, but "Wireframe" doesn't appear in any list of commands, and I don't see anything under the Scene Visibilty or Scene View Categories that look appropriate either.

The docs only describe how to toggle this through the Scene view control bar, but it seems silly that it wouldn't be possible to map that operation to a key combination.


texts: Setting up local players in Unreal Engine

texts:
I'm trying to make a 4 player 2D local multiplayer game.

I have tried a lot of stuff to get to this stage, but as far as I have been told, a method called CreateLocalPlayer creates a local player, creates a controller and spawns an actor into the game... It sounded good so I gave it a try:

Inside my game mode StartPlay()

void AGeneralGameMode::LoadPlayers()
{
    if (GetMaxPlayerCount())
    {
        UWorld* currentWorld = GetWorld();

        UGameInstance* gameInstance = currentWorld->GetGameInstance();
        UGameViewportClient* gameViewport = currentWorld->GetGameViewport();

        // Remove split screen because I want a 2D game
        gameViewport->SetDisableSplitscreenOverride(true);

        for (int32 a = 1; a <= GetMaxPlayerCount(); a++)
        {

            FString error;
            ULocalPlayer* localPlayer = gameInstance->CreateLocalPlayer(a, error, true);
        }
    }
}

Before i get to the problem of the above, I could forsee two issues anyway... How could I convert the controller and the actor(pawn) created for me by CreateLocalPlayer to the types i have made myself...

I was told to place the following code inside the game mode construct:

AGeneralGameMode::AGeneralGameMode(const FObjectInitializer& ObjectInitializer)
    : Super(ObjectInitializer)
{
    // set default pawn class to our character
    DefaultPawnClass = ABasePlayer::StaticClass();
}

This does get called, but the ABasePlayer class I have never has a Possess statement trigger it... and thus my virtual override never gets called for Input stuff:

// ABasePlayer
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;

My question is, what is the procedure to create 4 local players...

Feel free to gather more context from this conversation:   https://forums.unrealengine.com/showthread.php?56494-How-do-you-place-APlayerCharacter-onto-APlayerStart-and-take-control

Thanks in advance!

Edit:

This is my current understanding of what is happening... is this atleast right?


texts:
I am trying to install PhysicsFS (icculus.org/physfs/) on my Win 7 with MinGW. But I am having hard time doing it. I googled it as well but still nothing - I have used linux environment and make toolchain before (not CMake though) - but I guess I am a bit rusty.

I tried following all the directions in INSTALL.txt and google - but here is what I managed till now.

I have MinGW installed and manually installed CMake as well. Now I download the src from the site and do cmake -G "MinGW MakeFiles

The next this is what bemused me - Well I haven't encountered it before - I do make and expect it to make the files but instead it goes into Windows Command Prompt. And then I am lost.

PART 2 -

I am fairly new MinGW - I was wondering if I want to develop do I compile from source or just install the developing package - as I understand compiling from source would give me both ( dev packages as well as binaries/static libs), right? Please correct me if I am wrong.


texts: Determine if 2D-projected point is visible

texts:
I render a model and do have various 3D points around the surface of it. Because it's easier and I'm already using D2D for UI rendering, I implemented it so that these points are rendered as 2D points onto the screen.

The thing is that of course not all points are always visible. I'd like to test that and only show these which are actually seen by the camera.

Is there any way besides rendering them in Direct3D or reading the depth-buffer CPU-side to test it?


texts:
I am currently working on a fighting game (with 3d graphics, gameplay like a 2d fighter) and encountered a pretty big hurdle I currently don't know how to deal with. For fighting games, input consistency is an absolute must, for example reading and processing the user input 60 times per second with fixed intervals between the input processing steps.

I started my game with Unity and right now, Unity's input is tied to the Update() function which means that during one Update() the input is consistent. the problem is that this would mean that input is framerate dependent and it would be pretty bad if the game has lag spikes or some machines cannot run the game at full 60 fps. I read that Unity is working on a new input system that allows for framerate independent input, but it is uncertain when the input system is finished or when it will be implemented in a public build:

https://forum.unity.com/threads/welcome-new-input-system-resources-and-info-please-read.397153/

I searched a little in the Unreal Engine 4 forums but couldn't find an answer to my specific question whether the engine does process the input really frame rate independent.

The goal is the following: Have the game logic separate from the main thread which handles rendering in another thread. Read the user input at fixed time steps, for example 16,6 milliseconds, provide this input information to the game logic thread, calculate the game logic for the input (which of course must take less long than 16,6 milliseconds) and only use the main thread for rendering the world state. For example by taking the world state data from the logic thread from the previous frame and the current frame and interpolate the data, then render the visuals with the provided interpolation.

My question is:

Is my approach the correct one when the goal is to have framerate independent input for games?


texts: Universal Tween Engine - simulating time T instantaneously

texts:
I have a circuit in Universal Tween Engine in libgdx and I want to make several entities follow this path

, each behind the other, like body pieces of a snake. The problem is that I need to find the initial position for each piece. I could obtain this effect by setting every piece to one point and setting incremental delay times for each one, and when the largest delay ends, I have something like this, with the last entity at the origin point

The problem with this is that the full formed "snake" must be like this when the level starts, that means, time = 0. How can I achieve this instantaneously?


texts: Identifying mesh format from initial bytes

texts:
I have a file containing mesh data whose blocks seem to start with DWORDS like:

0x1 0x1 0x3100026f 0x1 0x30000112

or

0x1 0x1 0x310007b2 0x1 0x30000112

or

0x10000006 0x3 0x310001f6 0x310001f6 0x310001f6

They don't look like .x binaries. Any other ideas?

UPDATE:

Here's more: 00000001 00000001 3100026F 00000001 30000112 000000C7 BD869270 3F0372D4 00000000 BD41F15F 3F11A611 3F522E05 3E40EF5A 3E17CDF8 3E40993C BF504FBD 3F0CCC2A BF78001B BE654B6A 3DDA7965 BD80EB99 3F003679 3C0BDAE1 BD3DD880 3F112A76 3F528732 3E8EFD04 3E185DD8 3E3984B8 BF48A923 3F180DA9 BF7854DC BE6599AE 3DBF7319 BCD7235C 3F041CCC 00000000 BF52314E 3F12223D 00000000 3F727B04 3C22FD80 3E29BCD1 3F7C0367 3D6FCD12 3E70A826 BCE91707 BF78B921 BCD7235C 3F008C87 3C28E0F6 BF6B36D8 3BD28E32 3ECA109F 3F4AEA89 3D894EC0 BE18A98D 3F7CC7A8 3D57AE4B 3E48D2F6 B46C577B 3F7B0753 BE3DBAC2 3EF41E67

It looks like some of these are almost certainly floats and others are almost certainly not. And it appears (not shown here) that after a long list of valid floats, there is a long list of DWORDS that aren't valid floats. A list of vertices followed by some table of indices?


texts:
I am in a 3d environnement, when I jump, i'm calculating the hitPoint of the end jump. I want to know when I jump, if there is a GAP between my initial point, and the end point.

But I don't want to set any trigger in the Level Design...

My Initial Idea is to do Raycast each 5-6 steps, but I wonder if this is too much cost effective. MayBe it isn't ?


texts: what is the simplest 3d software for unity?

texts:
Ive heard a lot about Daz studio, Poser, Maya, K-3d, Anim8or, Blender, and all the rest.

My question is which one is the best choice in terms of simplicity and quality. price is not an issue really. I'm programming games in java for android mobile devices at the moment but i will eventually move onto larger platforms. I would like to utilize unity3d for the game programming itself and utilize a 3d modeling software just to create the game objects.

I just need to know the best one to get started with from scratch or should i use a combination of multiple ones? Any insight for this would be great, thanks!


texts: How to generate tile patterns in one dimension, then in a second dimension?

texts:
I'm trying to do a 2D Game that tries to emulate the Crossy Road game logic with the Java's GUI programming environment as a college project.

I'm having issues designing the way the 'roads' are procedurally generated.

An example of game-play of Crossy Road can be found here, but to give a glimpse, here is a screenshot (taken from the Crossy Road Web site):

The game is based on an infinite, randomly generated level. I need to generate different kinds of patterns, for example:

one street then 2-way street
some small river with logs around them
etc.

I don't know how I could generate at first the types of roads/roads groups that one should cross, then how I could generate the tiles for that road, and then eventually how to link these roads with the different mobile items on them (floating logs, vehicles, trains, etc.).

How could I do that?


texts: How can I easily create textured physics objects of different shapes and sizes?

texts:
I want to make a 2D game with this art system:

Whats the best way to achieve this in Unity?
Can I use sprite renderers or do I need quads or something different?
Rectangles seem possible and easy with Sprite Renderer, but Circles, Triangles and other shapes... how would those be done?


texts: I am trying to put 3Dish audio in a game I'm developing, and I'm unsure how to do positional sound. I want to be able to adjust the volume of the audio's channels depending on how far it is and the orientation.


texts: How to move a player along Waypoints with Rigidbody.MovePosition in Unity?

texts:
I have a player with a Rigidbody, I want it to follow along the Waypoints.
I have used MoveTowards but it seems also not to work however. I want to use MovePosition to add force while grinding. I commented a code that could maybe work but I got an error on that, check //ADDFORCE lines.

Here is my code:

public GameObject[] waypoints;

public float grindSpeed;
public float turnSpeed;

public int currentWaypoint;

private Animator anim;
private Rigidbody rb;

public bool isGrinding = false;

void Start()
{
    anim = GetComponent<Animator>();
    rb = GetComponent<Rigidbody>();
}

void FixedUpdate()
{
    MoveAlongWaypoints();

    if(isGrinding)
        anim.SetBool ("isOnGrinding", true);
    else if(!isGrinding)
        anim.SetBool("isOnGrinding", false);
}

void MoveAlongWaypoints()
{
    if(isGrinding)
    {
        //TRANSLATE
        transform.position = Vector3.MoveTowards(transform.position, waypoints[currentWaypoint].transform.position, grindSpeed * Time.deltaTime);
        //ADDFORCE
        /*
        Vector3 movePosition = transform.position;
        movePosition = Mathf.MoveTowards(transform.position, waypoints[currentWaypoint].transform.position * grindSpeed * Time.deltaTime);
        rb.MovePosition(movePosition);
        */
        //ROTATE
        var rotation = Quaternion.LookRotation(waypoints[currentWaypoint].transform.position - transform.position);
        transform.rotation = Quaternion.Slerp(transform.rotation, rotation, turnSpeed * Time.deltaTime);

        if(Mathf.Abs(transform.position.x - waypoints[currentWaypoint].transform.position.x) < 1
            && (Mathf.Abs (transform.position.y - waypoints[currentWaypoint].transform.position.y) < 1)
            && (Mathf.Abs (transform.position.z - waypoints[currentWaypoint].transform.position.z) < 1))
        {
            //rb.useGravity = false;
            currentWaypoint++;
        }
    }
}

void OnTriggerEnter(Collider other)
{
    if(other.gameObject.tag == "GrindWayPoint")
    {
        Debug.Log ("Waypoint!!");
        isGrinding = true;
    }
}


texts: How can I handle a transition into building interiors?

texts:
I am trying some stuff on Unreal Engine to make something approching games like Commandos series.
But for now, I'm stuck with something I can't figure how it is done :
How are building interior handled ?

Here's a screenshot to illustrate what I say :

When you enter a building, everything become black, except the building's interior. The interior is isolated, there is no "communication" between the interior and the exterior, and between linked interiors. For exemple if you shoot with a weapon and there is an enemy outside just behind the door, he can't hear you.

Sometimes biggest buildings are divided in many parts, and each floor are a different "section" that are isolated from each other (you have a transition and can't communicate between). Here is an image that explain it well : Commandos 2 interior

Teleport : I first thinked that you were teleported to a different portion of the map, or a different small map, but it is unlikely. If you look at a window, you are at the same time outside (you can see your character outside at the window) and inside (you character is leaning out the window). Teleport would cause many sync issue.

Section toggle : Then, I thinked that the interior is already handled in the exterior map, but completely hidden, and when you enter it, it "deactivate" the exterior by hidding everything outside and displaying interior. Again, this is unlikely since map are full 3D (you can rotate 360°) and exterior are 2D.

How can I create this kind of transition?

I've specified that I am on Unreal, but I'm more searching the theorical way rather than Unreal specifics.


texts: Can I use the 2d physics engine in a 3d game (or viceversa) in Unity?

texts: This is entirely for performance. The 2D physics are less expensive, but I require 3D for some scenes. I never need both at the same time. I know you can have 2D with an orthographic perspective in a 3D engine, but what I want is really the physics engine. Also, is there a way of turning off these engines? I´ve made most collisions from scratch and am only using  them for some raycasts at the beginning and for some collider/rigidbody.casts in not every, but a lot of frames (If I understand correctly, they are calculated from the physics engine in each FixedUpdate()).


texts: XNA move from start position to target position exactly in 3D

texts:
If I have a list of positions that map out a path a character should follow. What would be the best way to move at a constant speed to each position making sure the character lands exactly at each position before moving onto the next?

For example the character is at position A, we then queue up position B and position C. The character cannot move towards position C until it reaches position B exactly.

It would be great if the solution worked at slower frame rates/update speeds as well.


texts: (Unity) what happens if i get a transform.position of a nested object

texts:
Okay so here is the example

You have a plane at position 0,0,0 with a scale 15,1,15 (for demonstration)

Now you have a parent object for the sake of simplicity lets call it parentObject this parent object has the following position: 7,25,26 The parent DOES NOT have a mesh and is thereby an empty gameobject

The parent has a child gameobject Here the issue starts the child has a transform position at 5,-25,30 however this objects transform.position is relative to the parent

last take our agent i know set him to go to childObject.transform.position will he then move correctly to the object or will he, in fact, move to the position that is relative to the parent object?

I know this might seem a bit messy but the general question is if i tell an agent to go to a gameobject that is a child of another object using transform.position will he go to the place we would expect?


texts:
So, I want to use textures for weapons in my FPS game instead of actual models.  However, if I just draw the texture onto a square in the game, it has the rotation and stuff, but it looks "2D".  How can I make it look like it has width?

The best example I can think of is probably Minecraft.  If you hold a tool in Minecraft (such as a pickaxe), the texture is drawn and it has an "edge" that shares a color with the color of the actual pixel next to it.

That was probably really confusing, so here's a picture of what I mean:
Original:

Edge highlighted:

How can I do this with XNA?

My code basically makes a square right now (four vertexpositiontexture vertices), and I use BasicEffect to attach an image to it.


texts: How to write a custom map canvas and project coordinates on it?

texts:
I am writing a game with Objective C ( xcode ) and I need to use the users location service to mark their position on a map but since I need to create my own map component, I am not able to use the Map framework.

Doing this I think I need to project latitude and longitude which I receive from location framework on my custom planar canvas, this is a small part of my game but the other parts are pretty easy or could be done if I could manage to implement this part, however I dont know where to start.

did anybody does it before? is it easy to create a map canvas?

Any kind of hint and help or sympathy are welcome.

Thanks


texts: How do I maintain game balance while promoting interaction between dead and alive players?

texts:
How do you motivate players to be content with randomly selected roles that are often complex to play and differ drastically in playstyle (AND to stick around till the end of game)?

Some background: Town of Salem is a more diversified and polished version of the popular "party games" such as Mafia and Werewolf. There are about 30 roles with offensive/defensive/supportive/investigative specializations, assigned to players at random. Most of all, many roles have unconventional abilities that provide incentives for any player to stay engaged during each stage of a game session (i.e. early-game/initiative, mid-game, and end-game)

For example: Medium can chat with dead players. The catch is that the names of such dead players ("out of play") are anonymous to Medium. In this sense, it provides a greater flexibility in player contribution overall with a strong emphasis on mid and late-game . Players are motivated to keep deducing and cooperating until the game is declared over (as opposed to sitting back once they are out of play) knowing that their intel can affect the outcome via Medium regardless of how early they were killed off.

I am also interested to see examples from multiplayer games in the same genre.


texts: How to find all the possible places to go on a grid?

texts:
Given the amount of steps you can take in a grid, how could I implement a way to get all the possible places a unit can go to, in a game like Advanced Wars?

I have currently got A* path finding working, but it would be nice to have an indicator of the possible places to go to. I have linked to an image to make things more clear.

I was thinking of computing the path of every single tile on the grid to the unit tile, then working it out from there, but I can imagine that will take crazy amounts of resources.

Notice how the other units 'block' the path of the selected unit. So unfortunately its not a trivial 'draw a circle with radius X'


texts: Design pattern for animation sequence in LibGDX

texts:
What design pattern to use for sequence of animation that involve different actor in libGDX. For example I am making a game to choose a wolf from a group of sheeps. The first animation played when the game begin is the wolf enter the field that is filled with two sheeps.Then the wolf disguise as a sheep and goes to the center of the screen. Then the game will shuffle the sheeps. After it finished it will ask the player where is the wolf. The game wait for player input. After that the game will show animation to show the player whether their answer is right or wrong.

I am currently using State design pattern. There are four states wolfEnterState,DisguiseState,ShuffleState,UserInputState, and answerAnimationState. I feel that my code is messy. I use addAction with action sequence and action completion(new Runnable()) a lot. I feel that the action sequence is getting long. Is there a better solution for this kind of problem


texts: Is there a method to add partial scorch marks or decals on top of existing sprites?

texts:
Let's say what I have is a planet like so:

What I want to do is to add a scorch mark like this:

Now, if this was a one time thing, it wouldn't be a problem. I'd make a sprite for this specific occasion and move on. The problem is however, I want the scorch marks to look different and to not use all that much memory (because there might be too many of them on screen and this is for mobile).

The scorch marks will almost always be the same size but the planets will be different sizes, so one sprite that is scaled is not what I want (it would look too big on bigger planets and too small on smaller ones). Also, I want to be able to rotate the sprite to make it look different.

I've thought about adding another sprite on top of the planet (a border-like hack) to hide this but there can be other planets that are really close by to this one and they would be hidden too.

I've looked at a lot of stuff but nothing like this exists.

I've managed to create some stuff with a stencil shader and the use of a sphere with zero Z scale. This does create the problem of showing the sprite on other planets and I haven't been able to push forward on this.

This is what I can currently make:

This is what I need to make:


texts: Rendering skybox in first person shooter

texts:
I am trying to get a skybox rendered correctly in my first person shooter game. I have the skybox cube rendering using GL_TEXTURE_CUBE_MAP. I author the cube with extents of -1 and 1 along X,Y and Z.

However, I can't wrap my head around the camera transformations that I need to apply to get it right. My render loop looks something like this:

mp_Camera->ApplyTransform() :: Takes the current player transformation and inverts it and pushes that on the modelview stack.
Draw GameObjects
Draw Skybox

DrawSkybox does the following:

glEnable(GL_TEXTURE_CUBE_MAP);
glDepthMask(GL_FALSE);

// draw the cube here with extents

glDisable(GL_TEXTURE_CUBE_MAP);
glDepthMask(GL_TRUE);

Do I need to translate the skybox by the translation of the camera ? (btw, that didn't help either)

EDIT: I forgot to mention: It looks like a small cube with unit extents. Also, I can strafe in/out of the cube.
Screenshot:


texts: Getting wrong value for middle of screen

texts:
My mouse is able to move the camera and rotate it around my model. If the mouse is in the middle of the screen, the camera should not move.

The red circle is where my mouse has to be at in order for the camera to stay still. If I put the cursor in the middle of the screen, it rotates the camera which shouldn't happen.

    Point screenCenter;
    float scrollRate = 1.0f;
    MouseState previousMouse;
    bool moveMode = false;

    #region MOUSE
        screenCenter.X = this.Window.ClientBounds.Width / 2;
        screenCenter.Y = this.Window.ClientBounds.Height / 2;

        this.IsMouseVisible = true;

        previousMouse = Mouse.GetState();
        Mouse.SetPosition(screenCenter.X, screenCenter.Y);
        #endregion MOUSE

    if (this.IsActive)
        {
            MouseState mouse = Mouse.GetState();

            if (moveMode)
            {
                Vector3 temp = player.playerWorld.Translation;
                player.playerWorld.Translation = Vector3.Zero;
                player.playerWorld *= Matrix.CreateRotationY(MathHelper.ToRadians(mouse.X - screenCenter.X) / 75);
                player.playerWorld.Translation = temp;

                cam.up -= MathHelper.ToRadians(mouse.Y - screenCenter.Y) / 25;
            }

            if (mouse.RightButton == ButtonState.Pressed)
            {
                if (graphics.GraphicsDevice.Viewport.Bounds.Contains(new Point(mouse.X, mouse.Y)))
                {
                    moveMode = true;
                }
            }
            else
            {
                if (moveMode)
                {
                    moveMode = false;
                }
            }

            if (mouse.ScrollWheelValue - previousMouse.ScrollWheelValue != 0)
            {
                float wheelChange = mouse.ScrollWheelValue - previousMouse.ScrollWheelValue;

                cam.up += 0.7f;
                cam.backward += 0.7f;
            }
            previousMouse = mouse;
        }

Why could this be happening? the screen is 650X1000. ScreenCenter x and y are the correct values.

Now that I play with it more, it seems each time the game starts, the mouse is set to a different position. The mouse should automatically be set to the middle of the screen each time the game starts, but it ends up anywhere but the middle.

Any idea of what could be happening here?


texts: Do all included assets become part of built outcome or only the ones in use?

texts:
When building a unity game, does it include all assets inside the project folders etc or only the ones used?
Can Unity really tell if a prefab is used anywhere or a sprite or any downloaded package for that matter?


texts: What is the purpose of the stencil buffer ? More precisely, what is a stencil in computer graphics?

texts:
I read the stencil word a lot, and I don't have a clue what is its real purpose in computer graphics.

Seeing the picture in black and white on wikipedia, I'm still having problem with it.

Why do we use a stencil or a stencil buffer, and what is the difference with a Z-buffer ? Why using this word which seems to have some meaning in graphic design ?


texts: How to interrupt an animation and transition to another?

texts:
I am trying to make a 2D platform game which is Megaman-style. I have some problems when I make shooting animation. In Megaman game, the animation can interrupt by press keys. Just like this:

For instance, when move button was pressed, the animation frame will loop in D0~D9, if fire button was pressed, it interrupts the current animation and transition to shooting animation(A,B,C). If stop shooting, it goes back to move(D).

I have no idea how to design "interrupt/transition animation system" in my game.
Here is my pseudo code(JavaScript):

animation.play('move',[0,1,2,3,4,5,6,7,8,9],loop);

if(isMoving && key['fire']) {
    //I don't know how to make this work
    animation.play('fire',[A1,A2,B3,B4,B5,C6,D7]);
}

and each frame has a metaData like this:

{x:37,y:0,w:36,h:41,offsetX:0,offsetY:0,duration:100,collisionBox:[0.4,0,0.84,1.875],
    interrupt:{
        nextMotion:'A',
        nextFrame:7
    }
}

What is common solution in this scene? Please, Any help would be appreciated.


texts:
For 2 days now i am trying to calculate the correct delta time for my game , I am starting to getting crazy since i tried all the solutions that i found on the 5 first google pages...
What is wrong? I cant get the correct delta time ,whatever i tried is just not working , the delta goes from 1 to 4 and then back 1 and then to 3 even if i take the averange delta between many frames.Plus  the game runs way much faster(i mean the movement) on slow devices than in fast.
The game runs on android so the spikes between frames are expected.

My code is this:

    void Game::render()
    {

        timesincestart=getTimeMil();

        _director->Render();
        _director->Update();

        float dif=(getTimeMil()-timesincestart);//usally its about 5 milliseconds

        lastcheck++;
        sumdelta+=dif;
        if(lastcheck>20)
        {
            sumdelta=sumdelta/20;
            delta=sumdelta;
            sumdelta=0;
            lastcheck=0;
        }

        LOGI("delta:%f",delta);
    }

SOLVED:

void Game::render()
{
    oldtime=newtime;
    newtime=getTimeMil();

    delta=(newtime-oldtime)/16;//divide by 16 is just making the dt closer to 1

    _director->Render();
    _director->Update();

}


texts: How difficult is it to add vibration feedback to a open-source driving game?

texts:
I'm looking to use SuperTuxKart as a basis for a PhD research project. A key requirement for the game is to provide vibration feedback through the controller (obviously dependant on the controller itself).  I don't believe that the game currently includes this feature and I'm trying to get a feel for how big a challenge it would be to add.

My background is as a J2EE and PHP developer/architect, so I don't know C++ as such, but am prepared to give it a crack if there are resources and guides to assist, and it's not a herculean task.

Alternatively, if you know of any open source games that do include vibration feedback, please feel free to let me know!  Preferably the game would be of the style that the player had to navigate a character (or character's vehicle) over a repeatable course/map.


texts: How much does game development mathematics change over time?

texts:
This question is mainly aimed at this book, Essential Mathematics for Games and Interactive Applications, Second Edition which I have seen highly recommended all around the internet, so I'm sure there are people on here who own a copy.

What I want to know specifically is if any of the information would be out dated since the book was released on June 2, 2008?

Also interested to see how the mathematics behind game development has changed over time.


texts: Art Guide Theory: Lighting an Game Environment (Objectives, approach/workflow and mood) in PBR

texts:
What's the theory behind the Lighting an Game Environment in a Physically Based Renderer?

As far my research, lighting an scene is done with different Rules and Different Ways of Lighting an Scene depending upon the scene.

For an Interior scene - Omni Lights, Area Lights, point Lights and Spot Lights with baking is used to give proper amount of illumination.

whereas for an Outdoor Scene - Directional Lights, Area Lights, Point Lights are used to illuminate the scene with baking Lightmaps.

Usually to Light Individual Objects, 3 point Lighting is used and colors signify the Mood of the Scene.

But, the 3 point lighting is unfavorable for Game Environment, So, what's the Good way to start and what are the main objectives in Lighting an Scene?

How Lighting an Scene Contributes to the mood of the scene? like here -


texts: How many normals are needed to have a smooth surface?

texts:
I'm trying to draw a smooth cloth surface and I have a per-pixel shader. I expect to have a smooth surface but it's not the case. I think the problem comes from my normals.

The image show the surface drawn with multiple triangles. The surface is lit; the white zone are specular reflection.

Here is the way I calculate normals

ofVec3f v0(ps[i].pos.x, ps[i].pos.y, ps[i].pos.z);
ofVec3f v3(ps[i+cols+1].pos.x, ps[i+cols+1].pos.y, ps[i+cols+1].pos.z);
ofVec3f v1(ps[i+1].pos.x, ps[i+1].pos.y, ps[i+1].pos.z);
ofVec3f v2(ps[i+cols].pos.x, ps[i+cols].pos.y, ps[i+cols].pos.z);

    ofVec3f n0 = (v1-v0).cross(v3-v0);
    n0.normalize();
    ofVec3f n2 = (v0-v2).cross(v3-v2);
    n2.normalize();
    ofVec3f n3 = (v0-v3).cross(v1-v3);
    n3.normalize();
    ofVec3f n1 = -(v0-v1).cross(v3-v1);
    n1.normalize();

Here is the code to draw my surface. It's a 64x64 array of double triangles

glBegin(GL_TRIANGLES);

for (int i=0; i<ps.size()-(cols+1); i++) {
//  v0 - v1
//  | \  |
//  v2 - v3

// v0
glNormal3f(n0.x, n0.y, n0.z);
glVertex3f(ps[i].pos.x, ps[i].pos.y, ps[i].pos.z);

//v3
glNormal3f(n3.x, n3.y, n3.z);
glVertex3f(ps[i+cols+1].pos.x, ps[i+cols+1].pos.y, ps[i+cols+1].pos.z);

//v1
glNormal3f(n1.x, n1.y, n1.z);
glVertex3f(ps[i+1].pos.x, ps[i+1].pos.y, ps[i+1].pos.z);

//v0
glNormal3f(n0.x, n0.y, n0.z);
glVertex3f(ps[i].pos.x, ps[i].pos.y, ps[i].pos.z);

//v2
glNormal3f(n2.x, n2.y, n2.z);
glVertex3f(ps[i+cols].pos.x, ps[i+cols].pos.y, ps[i+cols].pos.z);

//v3
glNormal3f(n3.x, n3.y, n3.z);
glVertex3f(ps[i+cols+1].pos.x, ps[i+cols+1].pos.y, ps[i+cols+1].pos.z);

I don't know how many normals I need and where to put them: at each vertex, one by face ? four by vertex ?
I still have a flat triangulated surface although I have a per pixel glsl shader

Thanks for help.


texts: How can I evenly fan out a hand of cards?

texts:
Given a set of playing cards (rectangle images with a width and height) how can I rotate and position each one so that they appear in a 'fan' pattern, much like you would hold a hand of cards in real life. What math is needed to do this?

UPDATE

Here is the final, in browser implementation in JavaScript: https://cosmicrealms.com/blog/2013/03/16/hand-of-cards/
and
http://jsfiddle.net/tyyvk/108/


texts: Creating a new GLFW window and re-using the old context causes crash

texts:
I am using GLFW 3.0.2 and when I want to switch the application to fullscreen, I create a new window and intend to use the OpenGL context of the old window so I don't have to reload all the meshes, materials, etc and can just draw it again...

This is what I do when I want to create a new window, such as when first creating the window or switching fullscreen mode:

bool GLFWWindowManager::SetupWindow(const uint32_t width, const uint32_t height)
    {
        glfwWindowHint(GLFW_SAMPLES, mMSAA);
        auto newWindow = glfwCreateWindow(width, height, mWindowTitle.c_str(), mFullscreen ? glfwGetPrimaryMonitor() : NULL, mWindow);   // mWindow is NULL first time

        if (!newWindow)
            return false;

        if (mWindow)  // if old window present, destroy the old window
            glfwDestroyWindow(mWindow);

        mWindow = newWindow;
        glViewport(0, 0, (GLsizei) width, (GLsizei)height);

        return true;
    }

// the flow:
void GLFWWindowManager::Test()
{
    SetupWindow(800, 600);
    glfwMakeContextCurrent(mWindow);

    // draw meshes

    mFullscreen = true;
    SetupWindow(800, 600);

    // try to draw some meshes, crashes on GLDrawElements
}

What am I doing wrong?


texts: How a "view" is handled in an Entity-Component based model?

texts: Coming from an MVC background, I am trying to understand Entity-Component based model. However, i can see description about the use components( data objects ) and entities ( group of different data-objects ie components), but cannot see how view is created. I can see something called "render" components though. But how would i use it ? It seems, i don't need to bother about separation of view from data in this architecture. But i doubt, if this is the case, then things would mess up.


texts: Implementing a SceneManager using OpenFL

texts:
I'm trying to implement a basic SceneManager using OpenFL and Haxe. I don't have a lot of experience using OpenFL and Haxe so I have a few problems.

Here is how I designed the SceneManager class:

package;

import openfl.display.Sprite;
import openfl.Lib;

class SceneManager extends Sprite
{
    private var currentScene: ...;

    public function new(rootScene: ...)
    {
        super();

        currentScene = rootScene;
        Lib.current.addChild(currentScene);
    }

    public function changeScene(newScene: ...): Void
    {
        Lib.current.removeChild(currentScene);

        currentScene = newScene;
        Lib.current.addChild(SceneTwo);
    }
}

The "..." should be replaced with a general "class" type that can hold any of my scenes.

If anyone can help me solve this I would be really grateful.


texts:
I'm attempting to program an offline puzzle game in C++. I'm trying to figure out the best way (particularly during the alpha) to report back to me

Whether people finish the level
Where people died
How long they took on the level
The current version that they are playing

I don't currently have a public database server which I could dump it in to.

Is there any already written libraries that (for instance) drop analytics into a Google App Engine Database or Google Docs Spreadsheet?

What approach (if any) have you used for storing analytics?


texts: Looking for a library to create a grid based first person game online

texts:
Before I go and build it myself, I have been looking for a library that may help making a grid based first person view similar to:

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

I plan to make a web based version of this in a hackathon I am organizing.
Would there be something for this in python?


texts:
So, I have some variables in my game :

This is all the tiles in my game / the map.

std::vector<Sprite*> tiles;

This is the sprite variable which I have in a custom Sprite class.

sf::Sprite* sprite;

And here are my functions :

in main :

gameScreen.GetSpriteByPosition(window.mapPixelToCoords(sf::Mouse::getPosition(window), view), &window)->setColor(sf::Color::Black);

(That gives me a exception thrown error, Access violation reading 0x000000B4)

And this is the getSpriteByPosition function :

sf::Sprite* GameScreen::GetSpriteByPosition(sf::Vector2f mousePos, sf::RenderWindow* window)
{
    sf::FloatRect mouseBound(mousePos, sf::Vector2f(1, 1));

    for (int i = 0; i < tiles.size(); i++)
    {
        if (lastSprite == i)
        {
            tiles[i]->setColor(sf::Color::Black);
        }

        else if (tiles[i]->getGlobalBounds().intersects(mouseBound) && lastSprite != i)
        {
            tiles[lastSprite]->setColor(sf::Color::White);
            tiles[i]->setColor(sf::Color::White);

            std::cout << "Found tile, index : " << i << std::endl;
            lastSprite = i;
            return tiles[i]->getDrawable();
        }

    }

    return nullptr;
}

And here's my getDrawable() function :

sf::Sprite* Sprite::getDrawable()
{
    return sprite;
}


texts:
I'm new in game development and I'm struggling to implement Entity Component System (ECS) properly, I have no idea whether I'm doing it right or completely wrong.

Basically, I try to implement ECS pattern with SceneGraph system, so here my current understanding:

  Entity is nothing but a components bag, it has no logic but it may (or may not?) contain essential information to differentiate from the other Entity or grouping them as well, such as ID, Name, Tags, etc.
  Component is a data container but contains no logic how to process the data but may contains function to manipulate the data, for example a Transform component may contains Inverse() function.
  System is the implementation holder, it process Entity based on its Component. The System may define a "requirement". The Entity is processed if it match the requirement, for example SpriteRendererSystem only process Entity that contains SpriteRenderer and Transform component.

Currently, I have no idea if it's correct or completely mess. Therefore, I try to implement ECS along with SceneGraph as stated before, here my SceneGraph implementation:

  Node is an object in the Scene, basically, everything that need to added into the Scene must implement this. The Node can add another Node instances as its child as well as parent. Currently, my Entity implement Node, meaning that all Entity can be added into Scene
  Scene is the top most level of Node, it represent a root of Node and there can be only one active Scene at a time. The Scene basically implements Node and it has Update() and Render() functions, this functions is called by SceneDirector
  SceneDirector is basically inherit game window, it manage the active Scene, passing Render() and Update() method to the active scene as well as updating the Input states to the Scene.

Now, I combine both pattern as follows:

  The Scene has a list of System as well as list of Node. Depending the System, the System may called on Render() function if the System is Renderable, otherwise it will called on Update() function
  Upon Render() / Update() function, the Scene will loop the entire Entity, it also loop the entire registered System. The System will check the Entity whether the requirement is match, if the requirement is fulfilled, the Entity will be processed by the System

Now my questions:

Can Component hold the logic? or it should not and stay as a bag of data?
Is it correct implement Node on Entity?
Is it correct to let every instances of Scene has their own System? or should I make it globally by storing the list of System in SceneDirector?
Is there any more efficient way to process the Entity rather than loop the Entities and the Systems completely?
Is my understanding correct about the ECS? Am I on the right track? or completely wrong?

Thanks in advance


texts: Simulate race winner based on character attributes

texts:
I'm new to game development and I was thinking of starting off with something easy like a top down simulated race game. It will be similar to a horse race, such that there will be betting, and character should win based on their attributes and simulated conditions.

One problem I'm currently facing is how to simulate who wins. Characters will probably have the attributes top speed, acceleration, endurance etc. I don't want the top ranked character winning all the races.

I was looking into probability distributions but I couldn't quite understand how that would help calculate who will win.

I know the winner will be who crosses the finish line first. However how do I calculate characters slowing down, speeding up?


texts:
There are several questions and articles which deal with timestep - for example:

Should game logic update per second or per frame?
https://gafferongames.com/post/fix_your_timestep/
Accounting for drift between ticks (this was my previous question)

Although that last one started to get into it in the comments - I still have an unanswered question about how to architect for a multithreaded system.

Given two threads:

State Worker : simply does pure transformations on data.
IO Renderer : Deals with input, and renders the latest available State object

Let's say the state-worker thread simply updates the game state in a continuous loop, while the renderer updates the screen on a fixed timestep (e.g. 60fps).

Let's ignore input for now.

The renderer does its job by taking the freshest data it has, which was passed in from the state-worker whenever it was finished (which may have happened dozens of times between renders.)

It seems to me like this would be the smoothest solution and it's extremely simple (no interpolation other than reading the delta time between state updates - irrespective of render updates).

Although very minor - and I said we can ignore input, it also gives a tiny bit more snappyness since it polls the input and syncs it with the game state updates which would happen far more frequently in this case vs. basing it on render ticks (at least for simple games).

What are the flaws with this idea? Or is it solid?


texts: Using angle_difference to calculate shortest turn to target [Gamemaker]

texts:
I've tried, but I cannot understand angle_difference.

I have an object, oTurretDetTurret, which turns to face its Target, which lies at the angle DirectionOfTarget from it.

It does this by updating its direction thus:

direction = direction + SpinDirection

SpinDirection can be either +3 or -3, meaning it can turn in either direction at a rate of 3 degrees per step.

What determines the direction it turns in is the angle between its current direction and the `DirectionToTarget. I want the turret to turn in the direction with the shortest number of degrees to travel.

I've been using this:

if angle_difference(direction, DirectionToTarget) > 0 {
direction = direction + 3
} else if angle_difference(direction, DirectionToTarget <= 0 {
direction = direction - 3
}

However, in game this just means that the turret faces the opposite direction to its target at all times, oscillating back and forth slightly.

In my understanding, angle_difference returns the smaller of the two angles between two directions.

For example, if the turret's direction is 300 degrees and the DirectionToTarget is 90 degrees, angle_difference should return +150, the smaller of the two angles, and thus my above code should move the turret counter-clockwise towards 90 degrees.

Can anybody help me?


texts: Unity and C# - Cube with random directions

texts:
I want to create a similar line RigidObject in Unity c# just like in the iOS game Circle:

So far I placed a cube object that is extended by length.

So, how would you approach to create such an object?

I tried with a for loop where I was trying to add a cube at the end of the other, but the rotation messed everything up.

I don't want to create a prefab, since I want the lines to be random and different every time the player starts the game.


texts: How do you stop OgreBullet Capsule from falling over?

texts:
I've just started implementing bullet into my Ogre project. I followed the install instructions here: http://www.ogre3d.org/tikiwiki/OgreBullet+Tutorial+1

And the rest if the tutorial here:
http://www.ogre3d.org/tikiwiki/OgreBullet+Tutorial+2

I got that to work fine however now I wanted to extend it to a handle a first person camera. I created a CapsuleShape and a Rigid Body (like the tutorial did for the boxes) however when I run the game the capsule falls over and rolls around on the floor, causing the camera swing wildly around.

I need a way to fix the capsule to always stay upright, but I have no idea how

Below is the code I'm using.

(part of) Header File

OgreBulletDynamics::DynamicsWorld *mWorld;   // OgreBullet World
OgreBulletCollisions::DebugDrawer *debugDrawer;
std::deque<OgreBulletDynamics::RigidBody *>         mBodies;
std::deque<OgreBulletCollisions::CollisionShape *>  mShapes;

OgreBulletCollisions::CollisionShape *character;
OgreBulletDynamics::RigidBody *characterBody;
Ogre::SceneNode *charNode;

Ogre::Camera* mCamera;
Ogre::SceneManager* mSceneMgr;
Ogre::RenderWindow* mWindow;

main file

bool MinimalOgre::go(void)
{
    ...

     mCamera = mSceneMgr->createCamera("PlayerCam");
     mCamera->setPosition(Vector3(0,0,0));
     mCamera->lookAt(Vector3(0,0,300));
     mCamera->setNearClipDistance(5);
     mCameraMan = new OgreBites::SdkCameraMan(mCamera);

    OgreBulletCollisions::CollisionShape *Shape;
    Shape = new OgreBulletCollisions::StaticPlaneCollisionShape(Vector3(0,1,0), 0); // (normal vector, distance)
    OgreBulletDynamics::RigidBody *defaultPlaneBody = new OgreBulletDynamics::RigidBody(
            "BasePlane",
            mWorld);
    defaultPlaneBody->setStaticShape(Shape, 0.1, 0.8); // (shape, restitution, friction)
    // push the created objects to the deques
    mShapes.push_back(Shape);
    mBodies.push_back(defaultPlaneBody);

    character = new OgreBulletCollisions::CapsuleCollisionShape(1.0f, 1.0f, Vector3(0, 1, 0));

    charNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    charNode->attachObject(mCamera);
    charNode->setPosition(mCamera->getPosition());

    characterBody = new OgreBulletDynamics::RigidBody("character", mWorld);
    characterBody->setShape(   charNode,
                    character,
                    0.0f,         // dynamic body restitution
                    10.0f,         // dynamic body friction
                    10.0f,          // dynamic bodymass
                    Vector3(0,0,0),
                    Quaternion(0, 0, 1, 0));

    mShapes.push_back(character);
    mBodies.push_back(characterBody);

    ...
}


texts: Can I use sin or cos for the non uniform rotation in unity 5?

texts:
I have few objects which I have to rotate on an ellipsoidal track and speed is changeable at the run time because its a betting game in which racing will be done so speed values will come from the server and I have to handle run time speed as well as the rotation angle at the curved path within the track.

And I would like to clarify one thing that we don't have to give any output to the objects make run just as we play the game the objects start running till the end point without giving an input.

So how do I rotate the objects within the curved area according to change in speed at the run time?


texts: How to use Actors/Groups with ShapeRenderer instead of Batch?

texts:
I am intersted in using Actors and Groups on a Stage so that I can make components and subcomponents which draw relative to their parents, but I intend to do my drawing with a ShapeRenderer instead of a Batch.  From what I understand of an Actor, the batch which is passed in to the draw() method has all of its matrices set up properly so that I can just use a coordinate system WITHIN THE PARENT to lay out the subcomponents.  But it seems that this coordinate system is focused on Batches, and I want to draw using a ShapeRenderer.

What do I have to do to get the child Actors to draw themselves RELATIVE TO THEIR PARENT (rather than in global coordinates) when drawing them with ShapeRenderers?

Also, one other question:  How should I be managing begining/ending the ShapeRenderer?  I am currently passing in a reference to a global ShapeRenderer when I construct my parent object, and this parent object passes in references to each of its children.  Should I be calling begin() end() separately in the draw method of each parent/child actor?  Or should I call it in my main app's draw() method, so I'm only calling it once each frame?


texts:
I'm looking to implement tooltips on VR controllers (e.g. controller highlights, text overlays) in Unity (e.g., Oculus Quest, XR interaction toolkit). I have seen an old solution based on VRTK.
How can I do this?


texts:
Right. So I was making this simple game. The player is two tiles wide, and four tiles high. My current code is really buggy (it was better before my rewrite)

Here it is:

    float newx = position.x + velocity.x;
    float newy = position.y + velocity.y;

    int tx = (int) newx;
    int ty = (int) newy;

    Tile tile = WorldHandler.currentWorld.getTile(tx, ty);
    Tile ground = WorldHandler.currentWorld.getTile((int) position.x, (int) position.y-1);

    if (tile.type == 0) {
        position.x = newx;
        position.y = newy;
    }
    if (ground.type != 0) {
        grounded = true;
        //position.y = Math.round(position.y);
    }

    if (grounded) {
        velocity.x = 0.0f;
        velocity.y = 0.0f;
        //position.y = Math.round(position.y);
    } else {
        velocity.x = velocity.x * (1.0f - Math.min(0.1f, 1.0f));
        velocity.y += 0.0f;
    }

it basically uses the indices for performance.

But I need a decent collision detection system that wouldn't be painful to implement, would AARBs be of use here? Also, the game loop is a tick based one, it runs at 30 ticks/s.


texts: Understanding buffer swapping in more detail

texts:
This is more a theoretical question. This is what I understand regarding buffer swapping and vsync:

I - When vsync is off, whenever the developer swap the front/back buffers, the buffer that the GPU is reading from and sending to the monitor will be changed to the new one, regardless if the old buffer was being read (i.e. no vblank is needed).

II - When vsync is on, the buffers are not immediately swapped, they will only be changed when the old buffer was completely read (i.e. vblank is needed).

III - Turning vsync off can boost the frame rate to be greater than the monitor refresh rate, but screen tearing can appear when buffers are swapped when they are being read

IV - Turning vsync on prevents tearing, but the monitor refresh rate limits the FPS.

Based on this I tried to do the following experiment: I disabled vsync and rendered a simple glClear + glClearColor every frame, with a new random color per frame. I got ~2400FPS in a 60Hz monitor. Since every frame I swapped the buffers, and since the monitor takes 1/60 second for each full screen drawing, I was expecting that each time the monitor was being refreshed, the buffers would have been swapped roughly ~40 times. This is because in 1/60s, there are around 40 buffer swapping calls. Since everytime the buffers are swapped the clear color is different, I was expecting to see a really messy image, with lots of different colors, because of the tearing. Instead, by taking some screenshots I didn't see any tearing... every pixel had the same solid color.

Could someone point the wrong assumptions that I had and why I see such behavior?

Thanks in advance!


texts: MissingReferenceException being thrown in async method

texts:
I'm trying to create a UI pop up box to show messages. It is a simple component: it's only a background image, a text and a script to manage it.
The script is very simple and just have a Display method that should show the message and after a while close the element.
public class NoticeBox : MonoBehaviour
{
    [SerializeField]
    private TextMeshProUGUI messageText;

    private int lastUse;

    public async void Display(string text, int lifeTime = 2000)
    {
        lastUse = Environment.TickCount;
        var thisUse = lastUse;

        messageText.text = text;

        gameObject.SetActive(true);

        await Task.Delay(lifeTime);

        if(thisUse == lastUse)
            gameObject.SetActive(false);
    }
}

The problem is: when the scene is transitioned to another one or the game closes (at least in play mode), the code after await Task.Delay(lifeTime); is executed anyway, throwing a MissingReferenceException when executing.
I tried the exact same behavior using WaitForSeconds and coroutines and the problem still rises up.
I tried testing both this and gameObject for null but despite of that the exception still rises.
What should I do in this case?


texts: How do I create smoke-like beam or aura effects?

texts:
I mean things like the Team Fortress 2 medic gun:

...or the Killzone: Shadow Fall anti-gravity effect:

How do these work?


texts:
the issue I'm having will be best described with pictures more so than with code, so lets have a look if you will.

So all the mobs followed the player and started attacking him, but as soon as 4 spots to the E, S, W, N were taken, mobs 1 and 2 are no longer able to find the path.

When mob from E/S/W/N spot dies they can of course find a way to the player.

My question therefore is what is the way to implement this so that mobs can get to the player when only corners are free?

Diagonal movement is not allowed and  i'm using Euclidean distance.
I've read this How do I avoid pathfinding characters getting stuck in corners? and other questions, but they dont quite cover what I need here. I'm sorry if this isnt specific enough, happy to clarify.


texts: Why is the Tilemap not fitting the screen?

texts:
I have a background image which I made it in tiled map editor of width 40tiles and height of 8tiles.When I run the game the tilemap bounces with the player and I can see the black portion of the screen.The game screen width and height is 320 by 256.Here is the problem
Play class


texts:
I just want to ask if can I check for "KEY"(keyboard) that is HOLD/PRESSED for a long time, because I am to create a clone of breakout with air hockey for 2 different human players.
    Here's the list of my concern:

Do I need other/ 3rd party library for KEY HOLDS?
Is multi-threading needed? I don't know anything about this multi-threading stuff and
I don't think about using one(I'm just a NEWBIE).
One more thing, what if the two players pressed their respective key at the same time,
how can I program to avoid error or worse one player's key is prioritized first before
the the key of the other.
example:

Player 1 = W for UP & S for DOWN
Player 2 = O for UP & L for DOWN

(example: W & L is pressed at the same time)

PS: I use GLUT for the visuals of the game.


texts: What is "u" and "v" in this Navier Stokes implementation?

texts:
reference: https://pdfs.semanticscholar.org/847f/819a4ea14bd789aca8bc88e85e906cfc657c.pdf

while ( simulating )
{
    get_from_UI ( dens_prev, u_prev, v_prev );
    vel_step ( N, u, v, u_prev, v_prev, visc, dt );
    dens_step ( N, dens, dens_prev, u, v, diff, dt );
    draw_dens ( N, dens );
}

Is u,v the same as x,y?


texts: How do I choose the scaling factor of a 3D game world?

texts:
I am making a 3D tank game prototype with some physics simulation, am using C++. One of the decisions I need to make is the scale of the game world in relation to reality. For example, I could consider 1 in-game unit of measurement to correspond to 1 meter in reality. This feels intuitive, but I feel like I might be missing something.

I can think of the following as potential problems:

3D modelling program compatibility. (?)
Numerical accuracy. (Does this matter?) Especially at large scales, how games like Battlefield have huge maps: How don't they lose numerical accuracy if they use 1:1 mapping with real world scale, since floating point representation tend to lose more precision with larger numbers (e.g. with ray casting, physics simulation)?
Gameplay. I don't want the movement of units to feel slow or fast while using almost real world values like -9.8 m/s^2 for gravity. (This might be subjective.)
Is it ok to scale up/down imported assets or it's best fit with a world with its original scale?
Rendering performance. Are large meshes with the same vertex count slower to render?

I'm wondering if I should split this into multiple questions...


texts:
I'm figuring out how to create games with teams. The problem is that there will be games 1v1, 2v2, and so on as well as free for all. What would be the most efficient way to do this in Unity C#?

I'm thinking of making a Dictionary with players' instances and every player has an index for a team. For example, we have 2v2 game, two players have teamIndex 1 and the other two have teamIndex 2. Is this the right way to do it, or there is a better way?

Thank you!


texts:
I'm currently working in virtual dressing project using kinect. I'm using a dress model with bone created in blender and added that to xna, placed on the customer and controlled the product movements like hand, leg using the kinect skeleton data.

I would like to add some cloth physics effect to the model like flying and shaking. What would be a best way to accomplish this. I have surfed a lot and found that can be done using physics engine but no idea about which engine and how?

Can I create the cloth effect in blender and add that to xna? or else whether I need to add some engine like bullet and Physx inside xna and create that cloth effect manually.


texts:
I use script below to take a screenshot from camera. It's working fine. However, when I take a screenshot again (pressing k multiple times), its old image is not clear from the memory and it keep drawing over same image over and over again. If object is moving while taking screenshot multiple times, image I will get all frame combine into one image with every frame in the same image. What should I do to fix this problem?

using UnityEngine;
using System.Collections;

public class HiResScreenShots : MonoBehaviour {
    public int resWidth = 2550;
    public int resHeight = 3300;

    private bool takeHiResShot = true;

    public static string ScreenShotName(int width, int height) {
        return string.Format("{0}/screenshots/screen_{1}x{2}_{3}.png",
                             Application.dataPath,
                             width, height,
                             System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));
    }

    public void TakeHiResShot() {
        takeHiResShot = true;
    }

    void LateUpdate() {
        takeHiResShot |= Input.GetKeyDown("k");
        if (takeHiResShot) {
            RenderTexture rt = new RenderTexture(resWidth, resHeight, 24);
            camera.targetTexture = rt;
            Texture2D screenShot = new Texture2D(resWidth, resHeight, TextureFormat.ARGB32, false);
            camera.Render();
            RenderTexture.active = rt;
            screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);
            camera.targetTexture = null;
            RenderTexture.active = null; // JC: added to avoid errors
            Destroy(rt);
            byte[] bytes = screenShot.EncodeToPNG();
            string filename = ScreenShotName(resWidth, resHeight);
            System.IO.File.WriteAllBytes(filename, bytes);
            Debug.Log(string.Format("Took screenshot to: {0}", filename));
            takeHiResShot = false;
            Debug.Log("Capture!!");
        }
    }
}


texts: Firing a simple sphere from below the camera at crosshair in the centre of the screen, with or without raycast

texts:
I have a game that spawns "enemies" within a sphere around the camera, the player moves the camera to target and simply presses the screen to fire. For now my "ammo" is simply a sphere and for visual purposes the object I'm firing from is a sphere located below the camera. the "ammo" should fire from the "cannon" below the camera directly towards the crosshair and hit whatever target is in the crosshair.

With some online help this is how my crosshair is generated:

if(Time.timeScale != 0)
    {
        if(crosshairTexture!=null)
            GUI.DrawTexture(new Rect((Screen.width-crosshairTexture.width*crosshairScale)/2 ,(Screen.height-crosshairTexture.height*crosshairScale)/2, crosshairTexture.width*crosshairScale, crosshairTexture.height*crosshairScale),crosshairTexture);
        else
            Debug.Log("No crosshair texture set in the Inspector");
    }

And currently this is how my "Cannon" works

if ( Input.GetButton("Fire1") && Time.time > mNextFire){

        mNextFire = Time.time + mFireRate;

        Rigidbody projectile= (Instantiate (ammo, gameObject.transform.position, Quaternion.identity)).GetComponent<Rigidbody>();
        projectile.AddForce (projectile.transform.forward * mHitForce);
    }

Then on the ammo, I have this:

  int x = Screen.width / 2;
  int y = Screen.height / 2;
  transform.LookAt(new Vector3(x, y));

but it is horribly inaccurate, I had to move the canon around so it appears to be firing from below the camera, the speed/velocity is off and it barely hits what's being aimed at. It also often appears to go through the cross hair but doesn't collide with the target. I know it's not the target cause if I move the canon around a bit and keep the target still, it hits, the target takes damage, life bar decreases and the "ammo"that hit it "disappears".

I know questions like this are all over the internet however none of them describe my problem, and the ones I found somewhat similar have no solutions. After days of frustration I decided to ask the question here, I just started unity last week so I apologise in advance if my problem seems silly.

Also, I've been seeing a lot of things with raycast, I found this script that projected a yellow laser towards the centre of the screen;

void Update()
{
    int x = Screen.width / 2;
    int y = Screen.height / 2;

    Ray ray = camera.ScreenPointToRay(new Vector3(x, y));

    Debug.DrawRay(ray.origin, ray.direction * 1000, new Color(1f,0.922f,0.016f,1f));

}

it worked perfectly and projected the laser right to the centre but what am I supposed to do with it afterwards? how do I make the projectile follow it? I'd really appreciate the help. Thank you!


texts:
I am fairly new to the programming world. I am currently at college and one of the tasks I need to do is create a "stun gun" or "freeze gun."

Basically, when you shoot a target (another player) I want it to stop them for five or so seconds. The gun will do no damage to the player, just simply freezes them. The player can be refrozen and/or continuously shot to remain frozen until the shooter's ammo runs out.

If anyone can give me some help on what to call in certain classes, or even provide me with the basic code the will freeze the player for several seconds, I'll be very thankful.

I know how to make a new weapon, and change fire-rates, etc... I am just stuck with what it is I have to do to freeze a player using the projectile class, or pawn class?


texts:
I was working on implementing a renderer for SYOYO's tiny obj loader and when it came to testing time, it failed to render. Here is an image of the result:

I believe that i have made the error with my renderer, in which i have no idea of what is wrong.

Here is the code for the renderer:

void flushTerrain() {
            while (!pr_Models.empty()) {
                const Model3D* model = pr_Models.front();

                model->getVAO()->bind();

                glm::mat4 a;
                glm::translate(a, glm::vec3(model->getPosition()));

                model->getShader().setUniformMat4("ml_matrix", a);
                glDrawArrays(GL_TRIANGLES, 0, model->getShapeVerticies().size());

                model->getVAO()->unbind();

                pr_Models.pop_front();
            }
        }

and the code for the Model3D Constructor:

Model3D(std::vector<tinyobj::shape_t> shapes, std::vector<tinyobj::material_t> materials ,glm::vec3 position, Shader& shader) :
            pr_shapes(shapes), pr_materials(materials), pr_position(position), pr_shader(shader)
        {
            pr_VAO = new VertexArray();
            for (tinyobj::shape_t shape : pr_shapes) {
                pr_VAO->addBuffer(new Buffer(shape.mesh.positions, shape.mesh.positions.size(), 3), 1);

                pr_VAO->addBuffer(new Buffer(shape.mesh.texcoords, shape.mesh.texcoords.size(), 2), 2);
                pr_VAO->addBuffer(new Buffer(shape.mesh.normals, shape.mesh.normals.size(), 3), 3);
            }
        }

and finally, for the Buffer and VertexArray class:

Buffer::Buffer(tinyobj::shape_t data, GLsizei count, GLuint componentCount) {
        glGenBuffers(1, &pr_BufferID);
        glBindBuffer(GL_ARRAY_BUFFER, pr_BufferID);
        glBufferData(GL_ARRAY_BUFFER, count * sizeof(tinyobj::shape_t), &data, GL_STATIC_DRAW);
        glBindBuffer(GL_ARRAY_BUFFER, 0);
    }

void VertexArray::addBuffer(Buffer* buffer, GLuint index) {
        bind();
        buffer->bind();

        glEnableVertexAttribArray(index);
        glVertexAttribPointer(index, buffer->getCount(), GL_FLOAT, GL_FALSE, 0, 0);

        buffer->unbind();
        unbind();
    }


texts: Get the tile that my mouse pointer is currently over?

texts:
I want to get the tile that my cursor is over in my game.

I did some googling though most of the examples we're in other languages/libraries and if they weren't, they didn't work for me because I use a sf::view.

So, what I currently have is a tile generator which works like this :

GameScreen.h :

std::vector<sf::Sprite*> tiles;
std::map<std::string, sf::Texture*> textures;

GameScreen.cpp :

void GameScreen::Init()
{
    std::cout << "Loading map" << std::endl;
    textures.insert(std::make_pair("Grass", new sf::Texture()));
    if (!textures["Grass"]->loadFromFile("Res/Textures/Grass.png"))
        std::cout << "Could not load texture : Grass.png" << std::endl;

    for (int y = 0; y < MapSize; y++)
    {
        for (int x = 0; x < MapSize; x++)
        {
            sf::Sprite* tile = new sf::Sprite();
            tile->setTexture(*textures["Grass"]);
            tile->setPosition(x * 32, y * 32);
            tiles.push_back(tile);
            std::cout << "Loading : " << tiles.size() << " / " << MapSize * MapSize << std::endl;
        }
    }

    std::cout << "Map loaded!" << std::endl;

    initialized = true;
}

How would I get the tile my cursor is currently over, even if my sf::view is moving?

This is how the newest code is looking :

Calling the get tiles function :

gameScreen.GetSpriteByPosition(window.mapPixelToCoords(sf::Mouse::getPosition(window), view));

Inside the get tile function :

sf::Sprite* GameScreen::GetSpriteByPosition(sf::Vector2f mousePos)
{
    sf::FloatRect mouseBound(mousePos, sf::Vector2f(1, 1));

    for (int i = 0; i < tiles.size(); i++)
    {
        if (tiles[i]->getGlobalBounds().intersects(mouseBound))
        {
            std::cout << "Found tile, index : " << i << std::endl;
            return tiles[i];
        }
        std::cout << "not found" << std::endl;
    }

    return nullptr;
}


texts:
I'm working on a simple Sinistar-style shooter in XNA, and I'm constantly running into trouble with transformations.  I feel like I'll get it eventually, but this problem is really bending my mind.

My little ship has two states: idle and engines-firing.  Idle is a single frame, and engines is a few frames that animate. Got all that.  Part 1 of the issue: Instead of using rotated images, I just use XNA's rotation to orient the ship.  Seems to work ok, but I think my origin point is off because it seems to rotate at a point just below the vertical axis of the ship (default orientation is ship's nose pointing up), instead of in the dead center of the ship.  Likewise, when I switch to engines, the sprites are different heights (due to the flames) so the origin of rotation doesn't seem like it would be constant.  Do I need to specify all my frames the same size so as to preserve the origin point?

Second bit: The gun turret sits on top of the ship, as a separate sprite.  With a bit of trial-and-error and calculation, I can get the gun to align on top where I want it.  But then when the ship rotates, it rotates out from under the gun!  Would fixing the first problem adequately cover this one, or is there some trick to getting the gun's position to translate properly?

So:

Do I need to have all my sprite's frame-rectangles be the same dimensions?
Is there a standard technique in XNA for stacking multiple sprites so they act as one unit, including for rotations?


texts:
So I've been wondering lately... on games like pokemon (on ds and gba), How did they handle the collision of all those tiles in the map? Should all those collision checks running in the background slow down the game? Do they have it where the collision activates from a certain distance? Do they have a player event where the player is next to a tile that is not able to be walked on? If it is not possible to know the answer, could you give me a solution to that problem?

I guess what I am really asking is how to handle collision of almost every tile in a big map.


texts: Android: Layouts and views or a single full screen custom view?

texts:
I'm developing an Android game, and I'm making it so that it can run on low end devices without GPU, so I'm using the 2D API. I have so far tried to use Android's mechanisms such as layouts and activities where possible, but I'm beginning to wonder if it's not easier to just create a single custom view (or one per activity) and do all the work there.

Here's an example of how I currently do things: I'm using a layout to display the game's background as an image view and the square game area, which is a custom view, centered in the middle.

What would you say? Should I continue to use layouts where possible or is it more common/reasonable to just use a large custom view? I'm thinking that this would probably also make it easier to port my code to other platforms.


texts: How can I ensure I still get correct touch inputs when my scene is offset?

texts:
How can I accept touch input beyond the scene's bounds, so that no matter what I set self.position to, touches can still be detected?

I'm creating a tile based game from Ray Winderlich on Cocos2d version 3.0. I am at the point of setting the view of the screen to a zoomed in state on my tile map. I have successfully been able to do that although now my touches are not responding since I'm out of the coordinate space the touches used to work on.

This method is called to set the zoomed view to the player's position:

-(void)setViewPointCenter:(CGPoint)position{
    CGSize winSize = [CCDirector sharedDirector].viewSizeInPixels;
    int x = MAX(position.x, winSize.width/2);
    int y = MAX(position.y, winSize.height/2);
    x = MIN(x, (_tileMap.mapSize.width * _tileMap.tileSize.width) - winSize.width / 2);
    y = MIN(y, (_tileMap.mapSize.height * _tileMap.tileSize.height) - winSize.height / 2);
    CGPoint actualPosition = ccp(x, y);

    CGPoint centerOfView = ccp(winSize.width/2, winSize.height/2);
    NSLog(@"centerOfView%@", NSStringFromCGPoint(centerOfView));
    CGPoint viewPoint = ccpSub(centerOfView, actualPosition);
    NSLog(@"viewPoint%@", NSStringFromCGPoint(viewPoint));

    //This changes the position of the helloworld layer/scene so that
    //we can see the portion of the tilemap we're interested in.
    //That however makes my touchbegan method stop firing
    self.position = viewPoint;
}

This is what the NSLog prints from the method:

2014-01-30 07:05:08.725 TestingTouch[593:60b] centerOfView{512, 384}
2014-01-30 07:05:08.727 TestingTouch[593:60b] viewPoint{0, -832}

As you can see the y coordinate is -800. If i comment out the line self.position = viewPoint then the self.position reads {0, 0} and touches are detectable again but then we don't have a zoomed view on the character. Instead it shows the view on the bottom left of the map.

Here's a video demonstration.

How can I fix this?

Update 1

Here is the github page to my repository.

Update 2
Mark has been able to come up with a temporary solution so far by setting the hitAreaExpansion to a large number like so:

self.hitAreaExpansion = 10000000.0f;

This will cause touches to respond again all over! However, if there is a solution that would not require me to set the property with an absolute number then that would be great!


texts: Canvas Rotation collision detection on a sprite

texts:
I am using this code to detect collisions between two rectangular sprites.

intersect: function(other) {
    return this.x < other.x + other.width && other.x < this.x + this.width &&
        this.y < other.y + other.height && other.y < this.y + this.height;
},

My question is how can I account for rotation of the sprite.  This will only work with the

initial rotational position of the sprite.

Can someone point me in the right direction?

Thanks.


texts: Cost of Using Virtual Methods to Query Properties?

texts:
Let's say you're making a tile-based roll-playing game, and you're obsessed with OOP.

You have an abstract base class Tile which will be inherited from by many derived classes, like Grass Sand and Water

The base class declares virtual methods for querying properties of derived classes, such as isCollidable() and isFlammable()

class Tile{
public:
 virtual constexpr bool isCollidable() = 0;
 virtual constexpr bool isFlammable() = 0;
};

class Grass:
public Tile{
public:
 constexpr bool isCollidable(){
  return false;
 }
 constexpr bool isFlammable(){
  return true;
 }
};

class Sand:
public Tile{
public:
 constexpr bool isCollidable(){
  return false;
 }
 constexpr bool isFlammable(){
  return false;
 }
};

class Water:
public Tile{
public:
 constexpr bool isCollidable(){
  return true;
 }
 constexpr bool isFlammable(){
  return false;
 }
};

When you want a new type of Tile you just create a new class, inherit from it, and implement it's virtual methods. Adversely, when you want a new property, you've to add is methods to all the classes.

My question is, what is the cost of using polymorphism in this way? Is this an inappropriate use of polymorphism? If so, What are some alternatives to this while maintaining nice, pretty OOP?


texts: Problem rendering a Wavefront mesh, nothing displays(VBO)

texts:
I'm having a problem with displaying my wavefront obj file using VBO's My fps counter slows down like there is something being drawn but I cannot see anything. Is it a problem with my loader? Or maybe just a simple bug in my VBO rendering code?

I have checked that I am actually loading the data but maybe it's in the wrong order. I used OpenGL profiler and found nothing specious the texture and the VBO and IBO are in the GPU. I did try two different obj files, one of mine and a random one I found on NASA's site both rendered at the same speed(about 60 fps) with nothing on the screen. If you want any output from OpenGL profiler ask me.

BlockRender.cpp
http://pastebin.com/3KuuWX9H

Renderer.cpp
http://pastebin.com/gDCvi3t7

Relevant snippets of code
http://pastebin.com/rTqRzYXL

Sample wavefront obj file
http://pastebin.com/qVJ55gwn


texts: When creating an FPS style game, how should the iron sights be setup?

texts:
I am working on creating an FPS style game for learning purposes. I previously was using self created animations for aiming down the iron sights of a gun. The animation would play when you zoom to iron sights and it would hold it there as long as you have the mouse held down. However, talking to a high rated designer, he told me usually it is done with a second camera that sits perfectly aligned with the guns iron sights. I would imagine you would still have to have an animation that then transitions you into that iron sight camera though. Now my animation works fine but I feel I may run into a problem later down the road if I am approaching it the wrong way from the start.

Can someone verify the right way to do this and explain why it is?


texts: What is the role of tessellation in terrain?

texts:
I'm relatively new to graphically programming and I've been looking into ways to render larger heightened terrain. I keep seeing comments directing me to disregard things such as geometry clipmaps, in favor of tessellation.

From what I've read however, tessellation adds inner and outer triangles between a set of vertices. So from what I understand, you would lose the 1 to 1 relationship between height points and vertices. Additionally, the new vertices would be interpolated and therefore somewhat similar looking between points of similar height.

Is this the case or is there something I'm missing.  Is tessellation exclusively the way to go or can it (/should it) be combined with other techniques?


texts: Method Animator.SetBool sometimes is not working (or not triggering) in Unity2D

texts:
I have trouble with Animator in Unity2d. I have a main character for my game. The character has his own animation clip for fighting. When the player touches the screen, i am starting animation. When the player touches the screen slowly (every second) - everything is working fine, but when the player touches the screen fast, the animation clip is playing about 10 times, and then nothing happens (the clip isn't playing). I've checked - the touch event is triggered normaly, may the problem is with animator. Does anyone have ideas how to fix this issue?

public bool UseAxisInput = false;
private Animator Anim;

// Use this for initialization
void Start () {
    Anim = GetComponent<Animator>();
}

// Update is called once per frame
void Update () {
        for (var i = 0; i < Input.touchCount; ++i)
        {
            if (Input.GetTouch(i).phase == TouchPhase.Began)
            {
                Anim.SetBool("IsFighting", true);
            }
        }
}

May be this is because of that at the end of my animation i have an animation event which calls the method, that stops animation.

This is my method, that is called, after the animation ends

public void stopFighting()
{
    Anim.SetBool("IsFighting", false);
}


texts: When is a good point to revise a project?

texts:
I am currently working on a project. Some time ago I realized that I do achive my goals but the more code and prototypes I add the more I feel like there is no going back. For example some of the data-structures, methods and parts of architecture I implemented could be made more productive and reusable. But this would need a refactoring nearly from scratch.

So I wonder, is it a good decision to reedit a project as soon as I realized it's flaws or should I finish all the prototypes and then create a final and clean version?

I think it does matter that I am a solo developer.

Thanks in advance.


texts: How can I pool objects with differing properties?

texts:
My game requires a 2D GameObject to be spawned every second until they fill the whole screen and the game ends (around 60 objects total). On Android I see some performance spikes whenever a GameObject is spawned, so I'd like to use object pooling to help alleviate this. However, some of my objects have random properties like a second sprite, different tag, particle effect, and so on, so I don't think it's possible to save them for object pooling.

Is there any way for me to pool objects that have variable properties?


texts: How do you stack things in between a Table?

texts:
So I understand that a Stack is used to overlay things on top of each other, but is it possible to sandwich something in between a Table? For example, let's say I build my main menu using a Table, but after the UI is built, I want to place a full-screen overlay right underneath my play button. How can I achieve this? Here's a simple sketch of what I'm looking for:

The problem I'm facing is that, even if I use a Stack, the button that I want to place on top of the overlay has to be a separate entity apart from the Table I want it to be a participant of, so I can't place it within the underlying Table's structure.


texts:
I see that OpenGL versions 3 and up eliminate the use of client-side rendering. Immediate mode has been eliminated, and vertex arrays seem to be deprecated. Instead, if I understand correctly, VBOs are the main way of rendering vertices.

While I see the logic behind having a uniform way of rendering everything, is it the case that VBOs have no major downsides over vertex arrays? I thought VBOs were supposed to be large buffers containing > 1MB of data, generally. What if I have a scene that has a lot of smaller geometry? I have a scene graph with a large number of nodes, each of which needs its own transform, etc. Each node should also be able to be deleted separately, added to separately, etc. I was using vertex arrays before. So my first question is whether, if I switch to VBOs, there will be a greater overhead to my scene graph objects now because a VBO needs to be allocated for each object.

Another concern is that the geometry I'm rendering can be highly dynamic. In the worst case, there may be times when all geometry needs to be resent every frame for some period of time. Will VBOs have worse performance than vertex arrays in this use case, or do VBOs at worst do just as much work as vertex arrays but no more?

So, in more concise format, my questions are:

1) Is there a substantial overhead to allocating / deallocating VBOs (I mean the mere act of setting up a buffer)?

2) If I'm updating the data from the CPU every frame, can this be substantially worse than if I had used vertex arrays?

And finally, I'd like to know:

3) If the answer to either of the above questions is "yes", why deprecate other modes of rendering that could have advantages over VBOs? Is there something I'm missing here, like techniques I'm supposed to use to mitigate some of these potential allocation costs, etc.?

4) Do the answers to any of these questions change substantially depending on what OpenGL version I'm using? If I refactor my code to be OpenGL 3 or 4 forward-compatible by using VBOs in a way that is performant, will the same techniques be likely to perform well with OpenGL 2, or is it likely that certain techniques are much faster with OpenGL 3+ and others with OpenGL 2?

I asked this question on stack overflow, but I am re-posting here because I realized this site may be more appropriate for my question.


texts: How can I rotate the two endpoints of a line around the line's center in 3d?

texts:
The object is a capsule. I have the position of the object vector3, and the orientation of the object, a quaternion. I want to construct a line which goes through the middle of the capsule with the two endpoints of the line being the top and bottom.
The capsule can be rotated in all 3 dimensions.


texts: Is it a good idea and a logic to create adventure game with one scene?

texts:
I mean instead messing with loading scenes and passing variables between the scenes to make one scene and using in the hierarchy empty game objects for each part in the game for example empty game object name main menu and all the childs of it will be main menu objects.

Or instead making a new scene to make one empty gameobject and all it's childs will be like scenes.


texts: What is wrong with my collision detection code?

texts:
I want to check collision detection between two bitmaps but I am not getting how to do it. I read several queries and tutorials but didnt get properly. I want to check by their width and height. I have implemented some logic also but not getting where I am doing wrong

public boolean collision(){
        for(int i=0; i<9; i++){
            for(int j=0; j<14; j++){
                if(frog.getX() < x + getX() || frog.getY() < y + getY() || frog.getX() > x || frog.getY() > y){
                //if(other.getWidth() > x && other.getWidth() < x + width && >other.getHeight() > y && other.getHeight() < y + height);
                    frog.frogShiftDown();
                }
            }
        }
        return true;
    }

public void draw(Canvas canvas){
        canvas.drawBitmap(bmp, x, y,null);
        carmove();
        collision();
    }


texts: What does 'AlwaysResetOnEntry' do, and where would it be used?

texts:
In Unreal Animation Blueprints, each state has an option for AlwaysResetOnEntry.

The tooltip text for this is:

Whether or not this state will ALWAYS reset its state on reentry, regardless of remaining weight

Question

What does this do, exactly?

Additionally, what is a good example of where this would be used?


texts: What's the best way to organize small textures in OpenGL?

texts:
What's the best way to organize small textures in OpenGL—having them all in a big texture and selecting them with texture coordinates, or using individual OpenGL textures?

Until recently, I used to have all textures in a big pixmap and load that into a single texture.  This worked well, but in some situations, I had bright pixels from a neighboring texture leak into the edges of a dark texture, so I decided to split the textures up and load them separately.  However, since I now had to switch textures quite often, this significantly increased the frame render time.

So I have basically two options:

Go with one big texture and find a way to avoid pixel leakage.
Go with many small textures and try to avoid texture switches as much as possible (which will put some more load onto the CPU) or to speed them up significantly.

Do you have any suggestions how to achieve this?

Edit: I'm currently using the following texture parameters:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

As far as I can tell, these are already the optimal parameters for what I'm trying to do.  However, if there is there anything which I can still improve, I'd be glad for a hint.


texts: How do I create an installer for my XNA demo?

texts:
I have a demo coded in XNA3.1 using VS2008. I'd really love to be able to send this to anyone with a PC and let them install and run it without requiring them to have VS installed or the .Net framework etc.

I thought it would be the publish option but I'm a little confused by it. Can anyone shed some light on the matter?

Thank you in advance.


texts: Flipping a 3D text around its Y axis SharpGL

texts:
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
    private readonly MainViewModel _mainViewModel;
    private float _rotation;
    public MainWindow()
    {
        InitializeComponent();
        _mainViewModel = new MainViewModel();
        DataContext = _mainViewModel;
    }
    private void OpenGLControl_OpenGLInitialized(object sender, OpenGLEventArgs args)
    {
        OpenGL gl = args.OpenGL;
        gl.Enable(OpenGL.GL_DEPTH_TEST);
        gl.ShadeModel(OpenGL.GL_SMOOTH);
    }

    private void OpenGLControl_OpenGLDraw(object sender, OpenGLEventArgs args)
    {
        OpenGL gl = args.OpenGL;

        // Clear The Screen And The Depth Buffer
        gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);

        // Move Left And Into The Screen
        gl.LoadIdentity();
        gl.Translate(0.0f, 0.0f, _mainViewModel.Zoom);

        if (_mainViewModel.Rotate)
        {
            gl.Rotate(_rotation, 0.0f, -1.0f, 0.0f);
        }

        gl.Color(_mainViewModel.RgbColors[0], _mainViewModel.RgbColors[1], _mainViewModel.RgbColors[2]);

        gl.DrawText3D("Mazor", (float) 30.0, (float) 1.0, (float) 0.5, "Mazor");

        _rotation += 3.0f;
        gl.Flush();
    }
}

I would like to flip the 3D text I have around y axis, I am able to do so,
However I want the word "Mazor" to flip around the middle of the word, and not around the left side of the word.

if you run the code you can see the rotation occurs around the M letter, where as I would like to change the y axis to be where the Z letter is.
Can you please help ?
Thanks


texts: MMO techniques, algorithms and resources for keeping bandwidth low?

texts:
Are there any resources and documentation on how current MMOs handle the action and movement data from the compression to the handling on the client?
Any resources for movement prediction algorithms?

I'm especially interested in those that have wsad movement and focus on keeping latency low
Also what is the packet rate and size for different types of MMOs(network wise)?

Is there a way to scale the packet rate or outright disable some packets if the player can't reach or in the later case see them?


texts:
I am self-learning programming for video games. I have learned:

Basics (variables, loops, branching, etc.)
Object Oriented (classes, objects)
Functions
Dynamic Memory Allocation
Operator Overloading
Aggregation
Inheritance and Polymorphism
Swallow Copy And Deep Copy
STL Libraries

and I am learning I/O Files. What is next? Thanks for the help.