texts: Are there legality issues using a company's name in a game?

texts:
I'm working on an RPG of sorts where the character has a "day job" that determines how much money they make each time the day cycles and other things like that.

Are there any legality issues with using the names of companies like "Barnes & Noble" or even "Apple"?


texts: Using Quaternions: What can I do with them? (without the maths)

texts:
I am a Game Developer and did not study Mathematics. So I only want to use Quaternions as a tool. And to be able to work with 3D rotation, it's necessary to use Quaternions (Or Matrixes, but let's stay at Quaternions here in this Question). I think it's important for many developers to use them. That's why I want to share my knowledge and hopefully fill the holes I have. Now....

So as far as I understood:

A Quaternion can describe 2 things:

The current orientation of a 3d Object.
The rotation transformation a Object could do. (rotationChange)

You can do with a Quaternion:

Multiplications:

Quaternion endOrientation = Quaternion rotationChange * Quaternion currentOrientation;

So for example: My 3D Object is turned 90° to left - and my rotation I multiply is a rotation 180° to right, in the end my 3D Object 90° is turned to right.
Quaternion rotationChange = Quaternion endRotation * Quaternion.Inverse(startRotation);

With this you get a rotationChange, which can be applied to another Orientation.
Vector3 endPostion =  Quaternion rotationChange * Vector3 currentPosition;

So for example: My 3D Object is on Position (0,0,0) and my rotation I multiply is a rotation 180° to right, my endposition is something like (0,-50,0) . Inside that Quaternion there is a Axis - and a rotation around that axis. You turn your point around that axis Y Degrees.
Vector3 rotatedOffsetVector = Quaternion rotationChange * Vector3 currentOffsetVector  ;

For example: My start direction is showing UP - (0,1,0), and my rotation I multiply is a rotation 180° to right, my end direction is showing down. (0,-1,0)

Blending (Lerp and Slerp):

Quaternion currentOrientation = Quaternion.Slerp(startOrientation, endOrientation , interpolator)

if the interpolator is 1 : currentOrientation = endOrientation

if the interpolator is 0 : currentOrientation = startOrientation

Slerp interpolates more precise, Lerp interpolates more performant.

My Question(s):

Is everything I explained until now correct?

Is that "all"  you can do with Quaternions?
(obv. not)

What else can you do with them?

What are the Dot product and the Cross product between 2 Quaternions good for?

Edit:

Updated Question with some answers


texts: How can I get my physically based sky to be blue all the way down?

texts:
I'm rendering with a physically based sky. I want to get a very simple light blue background but below the horizon the sky becomes grey/brown. How can I get it so that the sky is blue all the way down? As if the edge of the city was the edge of the world.
I also want to make the blue sky brighter, especially at the bottom.


texts: Good way of handling class instances in game development?

texts:
I'm a new indie game developer, and I've made a few games, but often times when coding I wonder "Is this the way most people do it? Am I doing it wrong?" because I'd like to become a game developer some day, and I really want to get rid of bad practices in time.

The way I'm doing it right now is like this:

#include <some libraries>
#include "Some classes"

    int main()
    {
      Class1 a;
      Class2 b;
      Class3 c;

      a.init();
      b.init();
      c.init();

      // game logic;
    }

Now as I see the game grow, I have more and more classes to initialize and create instances of. This is clean but I'm not sure if this is standard practice. Is this a regular way of creating instances of your game classes or is there a cleaner and more efficient way to do it?


texts: Unity Terrain Tools plants trees sideways

texts:
My tree is clearly straight, but painting trees result in sideways ones.
What can cause this?
Tree is straight when placed manually as a prefab.


texts:
Ive just started with andEngine the past week and i only started learning java/android 3 weeks.

I can use a for loop to add multiple sprites to the screen but when i try to check collisions on them it only does it to one and not the rest.

I want to be able to add a specific number for sprites made from the same texture to the scene, add collision detection to them and also make them slide across the screen (im making a game where you avoid the obstacles).

My simple code:

private void createobstacle(float pX, float pY) {

    obstacle = new AnimatedSprite(pX, pY, this.mObjTextureRegion.deepCopy(),     getVertexBufferObjectManager());
    obstacle.setScale(MathUtils.random(0.5f, 3f));
    scene.attachChild(obstacle);
}

private void createobstacle(int num) {
    for(int i=0; i<=num; i++ ) {
        final float xPos = MathUtils.random(30.0f, (CAMERA_WIDTH - 30.0f));
        final float yPos = MathUtils.random(30.0f, (CAMERA_HEIGHT - 30.0f));
        createobstacle(xPos, yPos);
    }
}

Ive read about arrays but i cannot find any tutorials about anything im stuck with.

Any help would be great!


texts: Can you have shader variables that vary per primitive?

texts:
A shader normally has values that vary per-vertex and values that vary per-fragment.

Can you have values that vary only per primitive, such as per-triangle or per-quad?


texts: Validating multiplayer actions when using Javascript Game Engines client-side

texts:
I am using one of the many javascript game engine (impactjs, craftyjs, melonjs, easeljs etc) out there to handle the animation client-side. And I have a way of calling server-side functions and syncing variables between client-server (can be done using node.js/socket.io or libraries like nowjs). Everything is written in javascript.

I was wondering if I am doing the multiplayer right?

playerPosition = { x : 0; y : 0 }

updatePosition = function (a,b)
{
  playerPosition.x = a;
  playerPosition.y = b;
}

"playerPosition" is a server-side array containing the x and y position of the player. "updatePosition" is a server-side function that updates the position.

What I am doing now is when the player presses a movement key, I let the client-side Javascript engine handle all the movement and collision. Then call "updatePosition" to update his position on the server. The relevant values in the "playerPosition" array is passed to the client to sync.

Obviously, players can cheat by hacking the client and feeding whatever value they like for inputs "a,b". (updatePosition is server-side but it is called from client-side) To stop that, I added a check to see if the next position values "a,b" is too far off. E.g. I call updatePosition every frame, and I know players move only 5 pixels per frame, so I ignore "a,b" inputs that differs from the old position by more than 5. (essentially, the client processes keypresses and moves the sprite but this movement is only updated on the server if the server thinks its valid)

Collision is entirely handled by the client-side Javascript game-engine so I am not sure how to check it server-side. Perhaps I will have an array server-side holding all the coordinates that the player is not allowed to move to (solid, colliable objects etc) and use the check as before.

Question: Am I doing it "right"? Or is this totally naive and prone to catastrophic failure? :D

If I am not wrong, I should be doing movement and collision server side? Javascript game engines are written to draw stuff on the HTML5 canvas client-side. I am not sure how to run those engines server side. Or is it enough to be validating moves and what I am doing above, and let the client handles all the movement and collision?


texts: Rigidbody appears to jitter when placed as a sibling to a First Person camera

texts:
In my game, the Player can pick up an object (which gets parented to the first-person camera), or the player can push an object (which is parented to the player, but not their first-person camera). Both mechanics use very similar implementations in regards to moving the objects, yet I get a pretty severe amount of 'perceived' jitter from Pushing -- the object, as far as I can tell, isn't actually jittering.

(Side note - wasn't sure where to upload footage so I used mega which can be used merely to view the footage)

Footage of the push, with visible jitter

Footage of the lift for comparison

Footage of the push but parented to the first-person camera

Footage of push frame-by-frame from the side at 0.50 timescale

Footage of the lift frame-by-frame from the side at 0.50 timescale

The object is moved in FixedUpdate and the camera is moved in LateUpdate. You can see pretty clearly that in the side view, the camera moves after the object. Since the object is parented to the camera on Lift, it moves with it and no change is perceived. However on Push it doesn't move and thus appears to jitter.

I'm not sure how to fix this. I have tried:

Enabling interpolation on the rigidbody,
Disabling gravity on the rb / lifting off the ground (e.g., not caused by collision with the floor),
Not parenting the object to the player at all (object is still perceived to jitter because the camera moves in LateUpdate out of sync with the object)
Parenting the object to the camera (but this is highly unintended since they're meant to only be pushing; causes all sorts of issues with rotation etc - but the jitter does stop as is visible in the third link),
The following code in LateUpdate to sort of nudge it forwards -

    protected void CheckCameraPosition()
    {
        if (m_LastCameraPosition == Vector3.zero)
            return;

        Vector3 newPosition = m_FPCamera.Transform.position;
        if (newPosition == m_LastCameraPosition)
            return;

        Vector3 newOffset = newPosition - m_LastCameraPosition;
        newOffset.y = 0f;
        Transform.position += newOffset;
    }

But the object still jitters and were I to seriously consider the above code I'd be worried about race conditions since the camera movement is executed in LateUpdate as well.


texts:
How to change or remove Skybox on run time in unity using C#?

Is there any way to remove it while its not even required?

Or load it using http link for material we are using in Skybox.


texts: How can I avoid texture stretching when adding high-resolution support via a mod?

texts:
I am currently working on recreating the game engine for an old game (Sacred) using the original game assets I reversed-engineered the formats of.

The game had a fixed 1024x720 resolution, and I'm planning to support higher resolutions. How can I support them without having to stretch textures? I am hoping for results like D2MultiRes mod (Diablo 2) or G3 widescreen mod (Infinity Engine games) achieved.


texts: store definition of "blueprint" of object (e.g. mesh)? ... in top header = bad compile time

texts:
In my game engine, here is my mesh factory :-

//GraphicFactory.h
class GraphicFactory{
    enum blueprint{
        TURRET_01,CUBE,GRASS    //a lot of things
    }
    void initialize();
    BlueprintDatabase db;
}
//GraphicFactory.cpp
void GraphicFactory::initialize{
    db.add(TURRET_01,  very long definition about mesh e.g. material color ...);
    db.add(CUBE,       very long definition about mesh ....   );
}

To use, it is easy as :-

graphicFactory()->create(TURRET_01 /* happy ctrl+space */, position, rotation, scale);

Here, I have a problem about compile time:-

The GraphicFactory can be seen from most game systems
because they want to create some graphics.
Thus GraphicFactory.h must be included into every system's .cpp either directly or indirectly.

When one of the systems want a new type of mesh e.g. IRON_BOX,
I have to add IRON_BOX to blueprint in the GraphicFactory's header.
As a result, I have to recompile most of systems.

Question: Where should I store the declation / definition of mesh?
I also faces this issue for managing material, physic object, and game object.

My poor solution: Use string instead of enum - register by string and query by string.


texts: Organizing an entity system with external component managers?

texts:
I'm designing a game engine for a top-down multiplayer 2D shooter game, which I want to be reasonably reuseable for other top-down shooter games. At the moment I'm thinking about how something like an entity system in it should be designed. First I thought about this:

I have a class called EntityManager. It should implement a method called Update and another one called Draw. The reason for me separating Logic and Rendering is because then I can omit the Draw method if running a standalone server.

EntityManager owns a list of objects of type BaseEntity. Each entity owns a list of components such as EntityModel (the drawable representation of an entity), EntityNetworkInterface, and EntityPhysicalBody.

EntityManager also owns a list of component managers like EntityRenderManager, EntityNetworkManager and EntityPhysicsManager. Each component manager keeps references to the entity components. There are various reasons for moving this code out of the entity's own class and do it collectively instead. For example, I'm using an external physics library, Box2D, for the game. In Box2D, you first add the bodies and shapes to a world (owned by the EntityPhysicsManager in this case) and add collision callbacks (which would be dispatched to the entity object itself in my system). Then you run a function which simulates everything in the system. I find it hard to find a better solution to do this than doing it in an external component manager like this.

Entity creation is done like this:
EntityManager implements the method RegisterEntity(entityClass, factory) which registers how to create an entity of that class.
It also implements the method CreateEntity(entityClass) which would return an object of type BaseEntity.

Now comes my problem:
How would the reference to a component be registered to the component managers? I have no idea how I would reference the component managers from a factory/closure.


texts: change one object into another, and then back again in Unity

texts:
For example, I would like to change a cube into a sphere, then change that sphere into a capsule, by pressing the up arrow. I would also like to be able to change in the other direction. Change the capsule into a sphere, then change the sphere into a cube, by pressing the down arrow. It would be great if i could add extra objects in, say a pyramid etc.

Ultimately i would want to do this with something like a seed, sapling, and tree. Each with there own properties.


texts: SDL_AddTimer + SDL_GL_MakeCurrent not working on Windows

texts:
I'm messing around with C++, OpenGL and SDL doing a game that should be able to run in Windows and Mac OS X.
I have a problem that only happens on Windows.

Let me describe the scenario.

First I create an OpenGL renderer and get the current context:

this->renderer = SDL_CreateRenderer(this->window, rendererIndex, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
this->context = SDL_GL_GetCurrentContext();

Complete code here

In my scene I add a timer to create some asteroids:

this->timer.Start(INTERVAL_CREATE_ASTEROID, SpaceshipScene::CreateAsteroidTimer, this);

Internally this timer uses SDL_AddTimer and keeps the current window and context for itself:

this->window = SDL_GL_GetCurrentWindow();
this->context = SDL_GL_GetCurrentContext();
this->callback = callback;
this->param = param;
this->timerId = SDL_AddTimer(interval, Timer::ExecuteCallback, this);

When the callback executes I use MakeCurrent to make sure that OpenGL will run in the right context (the window and context from the main thread):

bool hasContext = timer->window != NULL && timer->context != NULL;

if (hasContext) {
    SDL_GL_MakeCurrent(timer->window, timer->context);
}

Uint32 result = timer->callback(interval, timer->param);

if (hasContext) {
    SDL_GL_MakeCurrent(timer->window, NULL);
}

Complete code here

On Mac OS X this code is working perfectly, but on Windows it isn't drawing the asteroids on the window neither throwing any error.

What am I doing wrong?


texts:
I have a gameobject to which a script is attached.

In this script I have the following code:

    foreach (GameObject g in this.GetComponentsInChildren<GameObject>())
    {
        BagItem nBagItemScript = g.GetComponent<BagItem>();
        if (nBagItemScript != null)
        {
            Bounds nBounds = Helpers.BoundsFromGO(g);

            Vector3 nPos = new Vector3((nBounds.size.x / 2) - nBounds.center.x, mapHeight - (nBounds.size.y / 2) - nBounds.center.y, -0.01f);
            g.transform.localPosition = nPos;

        }
    }

I thought this code was fail-safe, but Unity outputs the following error message:

ArgumentException: GetComponent requires that the requested component 'GameObject' derives from MonoBehaviour or Component or is an interface.
UnityEngine.GameObject.GetComponentsInChildren[GameObject] (Boolean includeInactive) (at C:/buildslave/unity/build/Runtime/Export/GameObject.bindings.cs:133)
UnityEngine.Component.GetComponentsInChildren[GameObject] (Boolean includeInactive) (at C:/buildslave/unity/build/Runtime/Export/Component.bindings.cs:88)
UnityEngine.Component.GetComponentsInChildren[GameObject] () (at C:/buildslave/unity/build/Runtime/Export/Component.bindings.cs:98)
Bag.pUpdatePositions () (at Assets/Bag.cs:173)
Bag.Update () (at Assets/Bag.cs:107)

Can somebody tell me which error Unity / C# is choking on here?

Is the error really in this line

foreach (GameObject g in this.GetComponentsInChildren<GameObject>())

... or perhaps somewhere else?

Thank you very much!


texts: Camera placement sphere for an always fully visible object

texts:
Given an object:

With the bounds [x, y, z, width, height, depth]
And an orthographic projection [left, right, bottom, top, near, far]

I want to determine the radius of a sphere which allows me to randomly place my camera on so that:

The object is fully visible from all positions on this sphere
The sphere radius is the smallest possible value while still satisfying 1.

Assume the object is centered around the origin.
How can I find this radius?

I'm currently using sqrt(width^2 + height^2 + depth^2) but I'm not sure that's the correct value, as it doesn't take the camera into account.

Thanks for any advice.

I'm sorry for confusing a few things here. My comments below should clarify what I'm trying to do actually.


texts: Moving rigidbody2d towards mouse click using AddForce

texts:
I cant get my rigidbody2d game object to move to where i click the mouse. The first click works. The object travels to the mouse click and stops. But the second time (or the third time) i click the object travels in som direction but its not quite correct and it never reaches the target! What am i not getting right?

   if (Input.GetMouseButtonDown (0)) {
             var mouseClick = Input.mousePosition;
             mouseClick.z = player.transform.position.z - Camera.main.transform.position.z;
             target = Camera.main.ScreenToWorldPoint (mouseClick);
             rotateToTarget = false;
             travelToTarget = true;
             print ("NEW TARGET: " + target);
             Debug.DrawLine (Camera.main.transform.position, target, Color.red, 10f);
      }

      if (rotateToTarget == false && travelToTarget == true) {

             var distanceToTarget = Vector3.Distance (player.transform.position, target);

             if (distanceToTarget > 2) {

                print ("Distance: " + distanceToTarget);

                target.z = 0;

            player.rigidbody2D.AddForce (target * travelSpeed);

             } else {

                travelToTarget = false;
                print ("travelling COMPLETE");
             }
      }


texts: Is there any JavaScript game library good for mobile gaming?

texts: I do not know how should I ask this question. I am a very new in this field. I want to learn game development. I want to learn it for Android and iPhone game development. That's why i was looking for JavaScript game engine or libraries. But, I got many. I do not know which one will good for me for 2D or 3D JavaScript game development.


texts: Calculating angle a segment forms with a ray

texts:
I am given a point C and a ray r starting there. I know the coordinates (xc, yc) of the point C and the angle theta the ray r forms with the horizontal, theta in (-pi, pi]. I am also given another point P of which I know the coordinates (xp, yp): how do I calculate the angle alpha that the segment CP forms with the ray r, alpha in (-pi, pi]?

Some examples follow:

I can use the the atan2 function.


texts: Getting name fragments for a name generator

texts:
Back again to ask more about name generation -- this time about the dictionary of syllables which I apparently need to reliably generate a name. For reference, my last question.

I've written a little bit of code which, given a file, uses the first line to determine how long the name can be (with multiple options for variability), then builds one from the syllables given in the rest of it. It works decently enough, given example syllables in an example file. For those wanting to try out a set of syllables of their own, I've made a version on Ideone.com. stdin contains the list of lengths and syllables.

That's where I'm having an issue, though. What should I use for the syllables? I've looked around, but I've been unable to find a good list of names to draw from. Maybe it's just that I'm bad at this or something, but I can't really get a good list of syllables that make  names. To add to that, I have to do it by hand, and I'd much rather make a program to split a list of names into syllables, but I can't get that to work. I'll post the source for my attempt once I'm home.

In short, how can I get a good list of syllables for use in a name generator? Is there pre-existing code I can use or modify and pass it a list of names to chop into syllables, then save those to a file? If not, how would I go about writing my own?


texts:
I am new to game development but familiar with programming languages. I have started using Flixel and have a working Breakout game with score and lives.

What I am trying to do is add a Start Screen before actually loading the game.

I have a create function that adds all the game elements to the stage:

override public function create():void
   // all game elements
{

How can I add this pre-load Start Screen? I'm not sure if I have to add in the code to this create function or somewhere else and what code to actually add.

Eventually I would also like to add saving, loading, options and upgrades too. So any advice with that would be great.

Here is my main game.as:

package
{
    import org.flixel.*;

    public class Game extends FlxGame
    {
        private const resolution:FlxPoint = new FlxPoint(640, 480);
        private const zoom:uint = 2;
        private const fps:uint = 60;

        public function Game()
        {
            super(resolution.x / zoom, resolution.y / zoom, PlayState, zoom);
            FlxG.flashFramerate = fps;
        }
    }
}


texts: How to design the scenarios in a platform game?

texts:
I am developing a 3D platform game like Metroid Fusion with XNA. I have many classes for different elements as models, game screens, post-processing and so on. Now I want to start designing the scenarios but I think that the scenarios needed in a platform game are not as conventional.

I am very lost and do not know where to start and how to structure it.


texts: How can I implement a "boost pad" with Farseer/Box2D physics?

texts:
I'm trying to implement a boost pad in my XNA game using the Farseer Physics Engine. (This question applies to Box2D too, I would be happy to port working Box2D code to C#.)

By "boost pad", I mean an object that can apply a force to the player that makes him go faster than he usually can under normal circumstances. These are most often seen in non-realistic racing games (e.g., Mario Kart, F-Zero). (For the record, my particular game is a 2D side-scroller.)

I use a very simple Farseer physics Body for my player: it's just a square shape with basic linear velocity.

Normally, I move my player like this:

body.ApplyForce(ConvertUnits.ToSimUnits(force));

Then, in my Update loop method, I cap the player velocity like this (to make sure the player speed never goes above maxSpeed):

float speed = body.LinearVelocity.Length();
if (speed > maxSpeed)
    body.LinearVelocity = (maxSpeed / speed) * velocity;

I'm struggling to think of a good way to implement a boost pad. The issues:

What would be a good way to enforce two separate max speeds? There's one maximum speed for forces that are applied by normal player input, and another maximum speed for forces applied by boost pads.
If the character is going faster than the normal max speed (e.g., they just hit a boost pad), how can I still allow the player to influence his direction without increasing his overall speed?


texts: How to setup Cocos2D-X (Android) under Mac OS X?

texts:
Hi I've made a small game for iPhone that I also want to run on Android but I'm having problems setting up Cocos2D-X for Android.

I've downloaded and installed Android SDK and NDK (under my "/Users/username/Android").

Installed all necessary packages under SDK and created an Emulator.
Copied Cocos2D-x under "/Users/username/cocos2dx".

Installed Eclipse IDE with ADT Plugin.

Opened "Users/username/cocos2dx/tests/build_native.sh" and changed "NDK_ROOT_LOCAL=/Users/username/Android/android-ndk", "COCOS2DX_ROOT_LOCAL=/Users/username/cocos2dx" to the values shown.

On running the script using Terminal it compiles test project. What's next?


texts: How do I convert a vector into a distance?

texts:
I'm doing a 2D raycast where i have to pass distance. The scenario is this:

I'm using rigidbody2d.Moveposition to move my character instantly. However, before a character is moved, i want to do a raycast in that direction.
My Movement code is:

if (Input.GetKeyDown (KeyCode.D)) {
            rigidbody2D.MovePosition(rigidbody2D.position+speedx);
            return;
        }

where speedx is Vector2 Vector2(1,0) (can be increased as necessary). So when A is down, first i want to do a raycast to see if it hits any collider and then move or not move the character to that position. However, i'm not able to understand how to set the raycast distance so that it corresponds to the exact distance my character intends to move.

So, what i'm looking for is a way to corelate Vector2 and float.


texts: How to implement fisheye effect with a GLSL fragment shader

texts:
I would like to render my scene with a wide FOV and then apply a fisheye distortion via fragment shader. How would this shader best be implemented?

Update

I try to reproduce a fisheye effect similar to what can be seen through a lense like this one. My first try was to port the fragment shader explained in How do I create a wide-angle / fisheye lens with HLSL? because it seemed to be a good starting point:

#version 120

uniform sampler2D src;

float fov = 2.09;

void main(void)
{
    float z = sqrt(1 - gl_TexCoord[0].s * gl_TexCoord[0].s - gl_TexCoord[0].t * gl_TexCoord[0].t);
    float a = 1.0 / (z * tan(fov * 0.5));
    gl_FragColor = texture2D(src, (gl_TexCoord[0].st - 0.5) * 2.0 * a);
}

unfortunately, the result looks like this:


texts: How to test for BoxCollider2D intersection in Unity?

texts:
I have a Player object with a BoxCollider2D component and a Ladder object also with a BoxCollider2D component. Each object has a script, and in each script, I set up references to the box colliders in the normal way.

public BoxCollider2D box_collider;

void Start ()
{
    box_collider = GetComponent<BoxCollider2D>();
}

My player script is called "PlayerController", so that's the class defined in the script.

In my Ladder's script I have the following:

void Update ()
{
    GameObject player = GameObject.Find("Player");
    PlayerController player_controller = player.GetComponent<PlayerController>();
    if (player_controller.box_collider.bounds.Intersects (box_collider.bounds))
        Debug.Log ("collision");
    else
        Debug.Log ("no collision");

}

This script invariably returns "no collision" and I'm not sure why.

Any ideas?


texts: Unity - How to tell which objects in scene are creating the most triangles?

texts: I have been working on a game and every time a player prefab is instantiated, it creates 1M+ triangles. That is a nightmare considering the model itself is not even close to 1M. The only thing on the player prefab is the soldier model and some objects for holding the weapons. Nothing more then the model. How can I see which objects in the scene are utilizing the most triangle count? I need to get to the bottom of this.


texts: Current state of the art for holographic displays?

texts:
In another thread I was asking about independent arcade system development, and partly it was because I'm interested in using available 3D holographic technology for the displays.

I saw one which involved a rotating mirror at very high speeds, so that's probably not going to be too feasible (I'd hate to think of what happens when something goes wrong).

However, I looked around for videos from trade shows, and I found this:

http://www.youtube.com/watch?v=Vl0EIngM-RA

But information is scarce, and I'm led to believe it's just using mirrors and reflections, and does not convey true 3D depth like the one using rotating mirrors at high speed:

http://www.youtube.com/watch?v=YKCUGQ-uo8c

So yeah, does anyone know if there's something better available today?


texts: How to make the winner emerge as late as possible in a quiz game?

texts:
I have a quiz game with my 4 friends. We've had 3 seasons so far. One season consists of 5 games (every player organizes one). Each game must have a total of 20 points that a player can earn. There are no rules regarding how many questions a game must consist of but the ideal range is 15-25. Season's winner is the player with the most wins. If there's a draw the player who has more points wins.

Sometimes it is quite clear who is going to win the season after the 4th game because he/she has at least 2 wins and leads with around 10 points.

Ideally the winner of the season would emerge after the results of the 5th game are in. Is there any ideas we could implement to make the winner emerge as late as possible and this way make the game more interesting?


texts: How can I calculate the bounding box of a 3D model?

texts:
I am making a game in OpenGL and Blender and trying to use JBullet as the collision manager. I am using BoxShapes for collisions, which requires a javax.vecmath.Vector3f representing half of the box to create.

How do I calculate the dimensions (width, depth and height) of a Blender model in-game?


texts: How can I create a custom List-of-GameObject inspector which works like the default one in Unity?

texts:
I need to

drag and drop GameObject to ObjectField.
drag and drop a group of GameObjects to list name.

The main problem is either do 1 or 2 work. I need the function same as unity List Inspector for future devolvement. Code as follow.

static SerializedProperty ThisList;
public override void OnInspectorGUI()
{
    ThisList = serializedObject.FindProperty("G");//List name call G
    serializedObject.Update();
    Show(ThisList);
    serializedObject.ApplyModifiedProperties();
}

public static void Show(SerializedProperty list)
{
    EditorGUILayout.PropertyField(list);
    EditorGUI.indentLevel += 1;
    if (list.isExpanded)
    {         EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
        ShowElements(list);
    }
    EditorGUI.indentLevel -= 1;
}

private static GameObject[] a =new GameObject[50000];
private static void ShowElements(SerializedProperty list)
{
    //This code can drag and drop GameObject to ObjectField.
    for (int i = 0; i < list.arraySize; i++)
    {
        list.GetArrayElementAtIndex(i).objectReferenceValue = EditorGUILayout.ObjectField("OBj", list.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObject));
    }

    //This code can drag and drop a group of GameObjects to list name.
    if (Event.current.type == EventType.DragUpdated)
    {
        DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
        Event.current.Use();
    }
    else if (Event.current.type == EventType.DragPerform)
    {
        for (int j = 0; j < DragAndDrop.objectReferences.Length; j++)
        {
            a[j] = (DragAndDrop.objectReferences[j] as GameObject);
        }
        Event.current.Use();
    }
}

However, it not work when both codes together.

If -> EditorGUILayout.PropertyField(list, true);
I can get the same result as the unity function. but I cant Custom the List. (such as add name, change position, add button...)


texts: How important is a single-player mode in a 2-player game?

texts:
So say you have a 2 player game, taking Chess as an example (except it's an original game with no ready-to-go AI available).

Let's say there's also a social-aspect to the meta-game, so let's say it's a Chess game on Facebook where you can challenge your friends.

How important is it to have a single-player mode, knowing that an AI will need to be created (I've done minimax AI for tic tac toe, but nothing too sophisticated)?

Is it important enough that it should be in the initial launch of the game?

Can it wait for a future iteration (knowing that being hosted on the web means the game can be updated at any time)?


texts: Unity camera has no preview, and is not moving

texts:
I have set up a camera in 2D mode. There is only one camera named "Main Camera", and it is set to "MainCamera" (tag). In console I can see camera's transform position updating, but it isn't moving. And if I adjust field of view for perspective mode, it doesn't take effect.

That is saying, when I hit "Play", the game view is always fixed. In inspector there is no camera preview neither (see image 2).

The only effect I can make to camera is changing the background color.

EDIT:

Main camera is placed right at root. And the camera is supposed to be looking at a small area:

EDIT:

Thanks for DMGreygory pointing out, I'm using default canvas settings and this won't move with camera in play mode. (btw, if not best under canvas, where exactly is suggested to apply those graphics?)


texts: New game shows up as an update instead of a release

texts:
I'm not sure if this is the right place to ask this sort of question but since there is a google-play tag...

I've just released a new game (my first one actually) two days ago. And I've just noticed that it showed up as an update instead of a freshly released game: Under ADDITIONAL INFORMATION section on the listing page it shows Updated instead of Released. I don't know how that happened and I'm worried it may affect the relevance of the game on the store. Is there any way to fix this issue? Am I right about worrying about the relevance of the game?

Link to the listing page of the game: Google Play link.

EDIT:

To clear any confusion, I'm not talking about people seeing the install/update button when they are about to install/update the game. I'm talking about the game release dateitself. The game shows up as an update from the Google Play Console as if it was released before. Me publishing the game for the first time was interpretted as updating an already released game, why?


texts:
I've been working with JOGL and I've ran into a problem. The problem is when I try to import import com.sun.opengl.*; on Eclipse, Eclipse doesn't recognize it. Does anyone know where this library is? Did I miss a step during installation? I'm working with the latest build.

Here are the included libraries:

gluegen-rt-natives-windows-i586.jar - JOGL/lib
gluegen-rt - JOGL/lib
gluegen.jar - JOGL/lib
jogl-all-natives-windows-i586.jar - JOGL/lib
jogl-all.jar - JOGL/lib

This is within my JOGL project folder:

gluegen-rt.dll


texts: Parts of sprite disappear when zoomed out

texts:
I'm playing around with making a roguelike and I want to use ascii characters as tiles in the game. I'm using a 256x256 sprite map where each character ends up being a 32x32 box.

This works fine, however the sprites end up being weirdly drawn, especially when zoomed out. Take a look:

As you can see, only the biggest zoom-in has no weird artifacts in it.

I tried playing around with the settings here and that's the best configuration I can get. PPU at 32 or 256 or even 1 doesn't seem to make any difference. Disabling compression doesn't do anything either.

I've also tried using a sprite map where I resized it so every character is 256x256 but it's still the same problem when zoomed out.


texts: What are the types of 3rd-person camera called?

texts:
I'm struggling with the terminology surrounding different types of 3rd person camera. What are the common 3rd-person camera types called? What are some notable examples of their use?

Here's what I think I've got so far:

3rd Person Fixed: This type seems glued to a position behind the character. The camera and character always rotate together.

Example: Gears of War
3rd Person Free: The camera can be rotated independently of the character, so the character can continue walking in one direction while the camera is freely rotated around them.

Example: Assassin's Creed series
3rd Person Fixed-Free: This is a combination of the two above. The camera can rotate independently while the character is stationary. However, when the character starts moving, they will move in the camera's direction (not the character's direction) and rotate accordingly. Also, if the camera is rotated while the character is moving, the character will also rotate with it, as with the fixed type above.

Example: Max Payne

Am I right?


texts: Detecting pixels in a rotated Texture2D in XNA?

texts: I know things similar to this have been posted, but I'm still trying to find a good solution...  I'm drawing Texture2D objects on the ground in my game, and for Mouse-Over or targeting methods, I'm detecting whether or not the pixel in that Texture at the mouse position is Color.Transparent.  This works perfectly when I do not rotate the texture, but I'd like to be able to rotate textures to add realism/variety.  However, I either need to create a new Texture2D that is rotated at the correct angle so that I can detect its pixels, or I need to find some other method of detection...  Any thoughts?


texts: Second text render does not show when hit action button in Unreal Engine 4

texts:
I am basically making a system to show texts like "E to Open" when player gets close to a chest or door. I use this:

When I hit first chest, everything's fine but second or any other text won't show after that.

What am I doing wrong?


texts: (Unity 5) Force child object to be perpendicular to the ground?

texts: As i mentioned in the header, i want my MainCamera child object to stay perpendicular to the ground, any ideas?)


texts: Palette reduction to pre-defined palette

texts:
I'm writing a bunch of GLSL effects for fun, but I can't wrap my head around this. Basically, I want to reduce a texture's palette into a pre-defined set of colors. For example, a post-processing shader would take the FBO result texture and a 1D / 2D texture that would contain the reduced palette (say, 64 colors), and the output would then be sampled based on these.

Something like this in its core:

sampler2D source;
sampler2D palette;

vec4 source = texture2D(...); // Source texture to sample
vec4 palette = texture2D(...); // Palette

vec3 result = /* color from the source converted to the closest value available in palette */;

Any ideas how to do this? And to be more precise, I don't mean palette swapping - the source texture is full-colored result, and this shader would ultimately be a post-processing shader, reducing the amount of colors to the ones that are predefined in the palette texture.


texts:
I'm creating a game (or app, depending on how you would define it...) where I'm moving objects (with sprites) on the screen.

I've got this to half-work in both scenarios, but I can't seem to get it to work completely using only one...

My problem is, I don't know where the touches should be handled for the objects. I have a separate layer that has all the objects on that layer. I put all the touch logic on that layer and it works fine, but I can only move 1 object at a time (I have to declare a currentObject variable to keep track of what is moving) and I don't know how to see if a touch is handled on the layer without a currentObject variable. Here's my touch began method:

-(BOOL)ccTouchBegan:(UITouch*)touch withEvent:(UIEvent*)event{
       BOOL isTouchHandled = CGRectContainsBorder([current.sprite boundingBox], lastTouchLocation);

       return isTouchHandled;
}

I also tried to have all the touch control in the objects itself, which let me move all the objects separately, but I couldn't have the objects react to any of the layer variables or events (I can't figure out how to get the objects to see what the current states are of the variables on the layer). the code for that touch began is:

-(BOOL)ccTouchBegan:(UITouch*)touch withEvent:(UIEvent*)event{
       BOOL isTouchHandled = CGRectContainsBorder([sprite boundingBox], lastTouchLocation);

       return isTouchHandled;
}

The only difference between them is that the layer is accessing the instance variable of the object, and the object accesses its own variable.

Note: these functions aren't being implemented at the same time, I'm trying one and seeing if it works and then trying the other and seeing if it works...

So, how could I fix this? Is there a way to be able to move all the objects independently? I have events that moving the objects react to once the move over a certain point, but I want the objects to be able to be moved after all the events happen as well and I can either get them to react to the events and move the current to the next object (control of touch is on the layer) or I can move all the objects independently but I can't access the layer's events (control is with the object)...


texts: Downloading 10 images and storing their data with WWW

texts:
I would like to download 10 images, and store their texture data into my list. I don't really know how to do that - I heard that for this you use the WWW class, so I went:

List<byte[]> StartDownload() {
    List<byte[]> result = new List<byte[]> ();
    for (int i = 0; i < 10; ++i) {
        WWW request = new WWW("http://www.example.com/" + i + ".png");
        result.Add(request.texture);
    }
    return result;
}

Which of course doesn't work, but I'm not sure why.


texts: Cocos2dx+Chipmunk: Fully elastic collision between moving bodies

texts:
I'm using Cocos2dx and the built in Chipmunk physics engine, and currently I've got my PhysicsBodys' materials set up with:

Density=0
Restitution=1
Friction=0

in order to get fully elastic collision, and keep moving bodies moving at a constant speed. This works great if they collide against a static element, like a wall, not so much if they collide with other moving objects.

I'm moving these bodies by applying an initial force:

Vec2 velocity = moveDirection.getNormalized()*moveSpeed - myPhysicsBody->getVelocity();
Vec2 newForce = myPhysicsBody->getMass()*velocity / deltaTime;
myPhysicsBody->applyForce(newForce);

So I'm guessing that even though their materials would result in fully elastic collisions, the moving objects both carry an impact force, this modifies the resulting force into one with different magnitude? All these moving bodies have the same mass.

Currently I'm manually catching the impact start and manually generating the resulting force in the right directing, and using the object's speed to apply it with the same previous magnitude, effectively overriding Chipmunk's collision resolution.

Is this the best way to do this, or can I configure my bodies in a way that allows Chipmunk collision resolution to achieve the same effect? I'm a bit rusty on my physics.. heh..


texts: How many update and draw calls can a windows phone suppport

texts:
I'm making a Windows Phone game (XNA 4.0) which requires a lot of activity on the screen. It's working well for now. But what I am concerned about is that it uses a lot of sprites and many of them as 'lists' so that I can make multiple copies of the sprite, and this causes a lot of Update() calls which have 'for' loops and collision testing method calls also. This also increases the number of Draw() calls.
As the game progresses, I am going to need to add more sprites and update calls.

Can that cause problems in Windows Phone? (Currently I have no device to test it on).

My game has 18 sprites for now and most of them requires multiple copies to be drawn on screen.

Is there a more efficient way to achieve this?


texts: Component-based game object systems in practice

texts:
Let's see history of success. Which popular games (and game engines) were built using component-based game object system? Each answer should contain:

Game Title (one per answer)
Author / Company
Year
Development time (optional)
Link to postmortem (optional)
Links to docs/source code (optional)


texts:
I'm trying to implement a pinch zoom on a sprite. I would like to get an effect like the SmoothCamera, but on a single sprite. I've managed to pinch zoom on the sprite by changing its scale, but the zoom is really fast and not smooth... it doesn't feel right.

This code is on my sprite :

public class BoardSprite extends Sprite implements IPinchZoomDetectorListener {
...
private float scale = 1;
    @Override
    public void onPinchZoom(PinchZoomDetector pPinchZoomDetector,
            TouchEvent pTouchEvent, float pZoomFactor) {
        float newScale = scale * pZoomFactor;
        if (newScale > 3) {
            newScale = 3;
        } else if ( newScale < 1) {
            newScale = 1;
        }

        scale = newScale;
        this.setScale(newScale);
    }

I'm looking for a way to improve this solution or for a better approach.


texts: How to load unity scenes asynchronously?

texts: If i am playing scene 1, i want to load the scene2 in parallel, so after the completion of scene 1 i will smoothly transition to scene 2 without loading, is there is any option for this?


texts: How should I structure the implementation of turn-based board game rules?

texts:
I'm trying to create a turn-based strategy game on a tilemap.

I'm using design by component so far, but I can't find a nice way to fit components into the part I want to ask.

I'm struggling with the "game rules" logic. That is, the code that displays the menu, allows the player to select units, and command them, then tells the unit game objects what to do given the player input. The best way I could thing of handling this was using a big state machine, so everything that could be done in a "turn" is handled by this state machine, and the update code of this state machine does different things depending on the state.

However, this approach leads to a large amount of code (anything not model-related) going into a big class. Of course I can subdivide this big class into more classes, but it doesn't feel modular and upgradable enough. I'd like to know of better systems to handle this in order to be able to upgrade the game with new rules without having a monstruous if/else chain (or switch / case, for that matter).

Any ideas? What specific design pattern other than MVC should I be using?


texts: How to apply Time.timeScale only to certain scripts?

texts:
I have a need to pause my game and the simplest and most clean way that I know of (other than completely designing my own time system) is by using Time.timeScale = 0;
However, this also makes my CameraController script stop working, because it relies on LateUpdate() and FixedUpdate() to update the camera position.
How would I change the timescale for other things that rely on it, but leave the part of it that the CameraController works with intact?
My first thought was adding a variable int isPaused; to parts of code that need to be stopped, and then instead of actually setting the timeScale to 0, I'd just change that isPaused variable to zero, and then multiply it with Time.deltaTime as usual, which would result in that object not moving, while still keeping my CameraController working. However, I'm not sure if this is the cleanest and simplest way to achieve something like this. Perhaps designing my own time system would be more beneficial in the long run?
Here's the CameraController code incase it is needed: https://hatebin.com/fqtybcuwht


texts: How to retrieve 3D models from a server in Unreal Engine 4

texts: How can I load 3D models from a server in Unreal Engine?


texts:
Usually, vertex data is assigned to a particular vertex, like this:

[data]    [vertices]
[1.31] -> [1, 13, 5]
[84.3] -> [5, 8, 12]
[.095] -> [8, 3, 10]

Then, you would typically have an array saying which order to draw the vertices in:

[indices]
[   0   ]
[   2   ]
[   1   ]
[   2   ]

Using this, the first vertex would be drawn first, then the third vertex, then the second one, then the third one again. My question is if it is possible to assign vertex data to the index array rather than to the vertex array, like this:

[data]    [indices]
[1.31] -> [   0   ]
[84.3] -> [   2   ]
[.095] -> [   1   ]
[30.1] -> [   2   ]

So that when it draws each vertex from the index array, it uses that particular value.

Please note that I am dealing with a lot more vertices than are shown here. (17^3 to be precise) The examples I shown above wouldn't be useful by themselves, but it would make a significant difference in performance in my program if this was possible.


texts: Optimization of animation for large quantity of objects

texts:
I have run into a problem where I need to animate plenty of circles just scaling up and down.

When I use animator, it needs 16ms per frame for 10000 circles. It drops fps significantly from 1000 to 30.

If I use scripts to scale the object, the result would be probably the same or worse, 10000 coroutines changing localScale.

What is the approach to this kind of problem? In agar io for example, they have done this without decreasing fps significantly, the game runs in a browser.

What are the optimizations that can be made?

Use of shaders? Chunks of objects animating as group at the same frame in animation?


texts: Unreal engine how do I change the visual studio version without having loaded up a project?

texts: I get an error which I mentioned in a previous post. I did a little more research on this error and found out that I need to use an up-to-date visual studio. I think that I might need to change the visual studio version from the config. I have both visual studio 2017 and 2013 on my computer.


texts: How to put different textures on different sides of a Cube in DirectX 11?

texts:
I have recently learned how to texture a cube in DirectX with a single texture but I am now trying to put multiple textures on a cube. If your confused the photo below should clarify.

I am aware of the technique of Cube Mapping, but most tutorials online only use that method in the form of a Skybox which is not what I'm trying to achieve at the moment. If someone can explain how I can have different textures for different cube sides or any shape that would be great.

The MSDN documentation says that I need to use a Texture Cube/Array but it lacks information regarding implementation.


texts: Could frame interpolation like used by SmoothVideo Project be an option to increase the framerate of games without as big a performance hit?

texts:
The SmoothVideo Project uses frame interpolation to increase the fps of video from 24 to 60. The results are pretty impressive. I was wondering if this could be applied to, and whether it would look good in video games?

It uses much less resources than rendering all the frames so would allow lower end rigs to render at the quality of much better rigs at some level of compromise. I know it won't be as accurate, and would slightly increase input latency as it needs to hold on to the newest frame to be able to generate and insert the interpolated one. It's not as bad as a full frame though, by my reasoning only the lag would be the interpolation time plus half the original fps refresh time. So for 30 fps it would be 33ms/2 + interpolation time.

Maybe this lag would make it unsuitable for fast past first person games, but I doubt it would be a hindrance in slower paced games.

The lag becomes lower at higher start rates, so I would think it would be certainly worth it when going from 60fps to 100+fps which improves the experience though increasingly marginally, while being extreme taxing on the system.


texts: I'm using death animation for my enemies but the problem is that when enemy dies he crosses the walls/world. I want enemy/animation to be pushed back into world when he dies (animation is playing). Currently all my enemies (contains skeleton, gun mesh & enemy mesh) are rigid-bodies (kinematic) with character controller and all walls have mesh collider attached to them. I have turned on animatePhysics for enemies but there is no effect. HELP? What am I doing wrong?


texts: Predictive Collision Detection - Find Time Of Impact

texts:
I have a green box at a starting position A. It can move along two paths

A to B is linear motion
A to C is under the influence of gravity (non-linear)

The thin vertical line is a fixed colliding wall. All objects are represented with axis-aligned AABB bounding boxes.

For the path A to B, if my understanding is correct, I (think I) can determine the time of impact (T0) on the wall based on swept-AABB collision techniques. this case simply reduces to motion along x-axis, and time of impact can be calculated easily.

My question is for path A to C. Under the influence of gravity how can I determine the time of impact (T1) relative to the starting time T at location A. (The motion of A to C can be predicted using the standard equations of motion)

Are there any techniques/algorithms available for this?

EDIT To clarify the vertical wall is illustrative - walls can be arbitrarily vertical or horizontal or both (like a corner). They will be stationary, and axis aligned though.


texts: How do I respond to keyboard events which occur between polling?

texts:
In my games update loop, which happens on a fixed timestep of 30 times per second, I am checking the current state of several keys to determine how to move the player.
For example:

if(Keyboard.down(KEY_LEFT) { /* move character left */ }

This works fine in situations where I expect the player to hold the key down for extended periods (such as movement), but for things like shooting, where the player just taps the key quickly, it doesn't always pick up the key being down.

This is due to the key being both pressed and released in the gap between polling.

Now obviously I don't want to trigger my shooting code 30 times a second like I do my moving code, so the solution needs to incorporate some kind of buffering/delay mechanism to make sure each shot is still x milliseconds apart, but I need the first one to register immediately and with certainty.

I am using Javascript, so I can easily use event driven functions linked to keypresses (in fact I am doing this already in order to keep track of which keys are down), but I didn't want to have game logic outside of the fixed timestep update.

Can anyone suggest a solution? I'm not looking for code, more an idea of how to design/structure the code around the problem.


texts: How to make a field visible (attachable) in the inspector but inaccessible through code (private-like)?

texts:
Let's say I have a variable named button of type Button which is of course System.Serializable.

I want that variable to be assignable through the inspector, so I make it public:

public class SomeScript : MonoBehaviour{
    public Button button;
}

Which gives me that:

Now, I want to keep the code clean & secure (organized) and there's a real reason why I need to preserve the encapsulation.

I know that there are multiple ways of retrieving components on runtime like transform.Find("Some/Genius/TypeUnsafe/Path") or GameObject.Find("3 seconds scene iteration").GetComponent(...). I want to avoid that.

How do I mix a variable private access with it's public access in the inspector?


texts: Implementing Separating Axis Theorem (SAT) and Minimum Translation Vector (MTV)

texts:
I was following codezealot's tutorial on SAT and MTV and trying to implement it myself but I've come a cropper when it comes to getting the correct MTV. Here is my example: (Cue pretty pictures...)

I'm well aware how to obtain the length of the MTV and the axis on which it lies. However I can't work out whether the length should be 'positive' or 'negative' to push the object in the correct direction.

In the example we are separating the objects by moving the 'red' of the 'blue', the top example is moving the object negatively and the bottom moving it positively.

Please help I'm really struggling with this.

Here is my actual implementation.


texts: How to draw Alpha Masked fragments' depth to depth buffer?

texts:
I feel like an absolute idiot for asking this. But how exactly do safely draw the depth of a fragment featuring a Masked ( Alpha 1) texture on it's surface?

So far I've literally been doing a depth test on truly opaque geometry.

Here's a logarithic Z-bufer from GTA. And yes... it's strange that I know that and how to do it... but not a alpha mask depth.

EDIT: From this, it looks like it's actually possible to write solid texture data to the depth buffer, and ignore the binary transparency.

Here's an image that's an example of the problem I would like to solve.


texts: Check If a 2D Collider Is Completely Inside / Outside of a Polygon Collider

texts: How can I check if one 2d collider (circle, capsule, polygon etc.) is completely inside / outside of a polygon collider?


texts:
I have spent a long time (4-5 hours) digging around as to why my version of the Breakout Unity Tutorial was not working. There where repeated errors of

  NullReferenceException: Object reference not set to an instance of an object
  xxxxxxx

when running the game and calling Game Manager scripts from other scripts in the game.

After much reading up on vaguely useful questions and answers on here I know well enough what the error text means, but the answers on here that describe the error in detail do not reference how to solve this issue on an instance of a singleton.
Elsewhere I found a solution, and want to show this solution as I figure that can help a lot of other people searching for why this issue occurs:

Qualifier:
There is an inconsistency with the Breakout Tutorial

see the instantiation of the Game Manager class:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class GM : MonoBehaviour {

    public int lives = 3;
    public int bricks = 20;
    public float resetDelay = 1f;
    public Text livesText;
    public GameObject gameOver;
    public GameObject youWon;
    public GameObject bricksPrefab;
    public GameObject paddle;
    public GameObject deathParticles;

    /***
     * The below sets the Game Manager Class (GManager) as an instance so is a
     * static variable. This means its accessed via the class rather than via
     * an instance of the class.
     * This means Game Manager can be reached from other scripts with code
     * `GManager.instance.xxx = whatever`
     * So only one GManager instance will be running. This is a singleton pattern.
     ***/
    public static GM instance = null;

    private GameObject clonePaddle;

    // Use this for initialization
    void Awake ()
    {
        if (instance == null)
            instance = this;
        else if (instance != this)
            Destroy (gameObject);

        Setup();

    }

    public void Setup()
    {
       ...
    }

Please read my solution below:


texts: How to access UI elements in a canvas in UnityUI

texts:
I am looking for elements on a canvas (a textfield and a slider); so I can retrieve values and pass them to a function.

But so far I can't figure out how to access them; I can see the methods of the canvas itself, but I can't see the name of the elements that I did add on the canvas.

I have the canvas saved in a variable which is public; then I did place a slider and textfield, connected to text labels; but I can't seem to access neither the label nor the slider or textfield.

Canvas --
        |___ Text
        |        |_____ InputField
        |
        |___ Text
                 |_____ Slider

I did plan to access to the text value in the input field doing something like canvas.text.inputfield.text, but this does not work, since I can't see the name of the text field when using dot notation. Same goes for the slider.

public Canvas mainmenu;

void Start() {
    mainmenu = mainmenu.Getomponent<Canvas>();
}

public RetrieveData(){
    // dot notation does not find sub elements of mainmenu canvas
    // only the properties and methods of the canvas itself.
}

How do you actually access elements on a UI canvas, if you can't see them directly, even if they are parented to other elements?


texts: How to create old-school format music with small file sizes

texts:
My friend and I have been working on a project recently, and because we are hard coding everything (other than the graphics library, Pygame), the total size for our project is super small. I feel like this is awesome and because the game has a retro feel to it I thought it was fitting. The whole project including art is about half a megabyte, which is pretty good when factoring the art and level design and such.

However one thing that is not accounted for in this size is the music. The music itself (around 6 or so tracks) plus the sound effects (4 or 5 currently) make up about 99% of the file size (not an exaggeration, 60mb / 60.5mb is a little over 99%), which I find a little ridiculous. In the old days when games had ridiculously lower memory and file sizes, how did they pull off music? Our game uses Chiptune music to give it a more retro feel, so using that style of music for small file sizes is perfectly acceptable.

Also I because I'm using Python and PyGame I don't know if this will be possible, but I still would like to know the process used anyways so maybe I can play around with it.


texts: In Scene2D, does Actor.hasActions() no longer exist?

texts:
Eclipse does not allow me to do

while (actor.hasActions()){}

saying it's undefined for type actor, but the libgdx API still has it as one of an Actor object functions.


texts: How to custom file formats work, encryption, packing etc

texts:
So say I take an example from Telltale games, they pack all their file assets into ttarch files, now I guess this is a custom file format that allows many file assets such as dds, jpg, bik, wav, 3ds etc to be packed into one file.

So someone has worked out how to explore these ttarch files and inside as you would imagine there are hundreds of files each with non standard file extensions(apart from the  lua files) such as d3dtx, d3dmesh, vers, spline, style, scene, there are also lua files which we all know.

The d3dtx files will be dds, jpg, bmp etc, so do you actually encrypt a dds file in this way, can someone enlighten me on the process of file encryption/packing files together?


texts: How can I efficiently render a tile-based map with many Z-levels, where the levels act like hollowed out voxels?

texts:
My map setup is a little different to what you normally have with tilemaps. The map itself is a rectangular prism, with a width, height, and depth being variable. In my case, width is the x-axis horizontally across the screen, height is the y-axis vertically across the screen; and depth is the z-level, or how "deep" the map goes into/out of the screen.
In my map; you could consider the rectangular prism as "solid". Many/most of these voxels could be considered as occluders to the voxels below them. Some voxels are hollowed out to make rooms and corridors.
The map is viewed at a specific z-level, from 0, the "bottom" of the rectangular prism, to n, the top.
A "hollowed out" voxel, if viewed from it's level, would result in me rendering a floor texture in that tile. If there were 4 voxels above it hollowed out, then that floor texture would be rendered when the map is viewed from each of these z-levels, but each z-level above the "floor" would have a semi-transparent black rect rendered on top of the tile (so it gets successively darker the further "up" you are).
This occurs until you're on a z-level above the tallest voxel that is hollowed out to make the room; at which point you can't see it any longer, because this non-hollowed out voxel blocks your view to the room below.
The problem I have is that there are many z-levels to render; and most of the hollowed out sections criss-cross around in the different layers to make a very complex network of little rooms and tunnels. This results in me naively rendering a floor texture, followed by several layers of semi-transparent black rects, followed by a fully-opaque black rect; and potentially repeated for any additional overlapping rooms; for every x,y tile on the screen.
I'm trying to wrap my head around a way to render this more efficiently but I'm having trouble. Currently, for every render loop, I'm attempting to step through the z-layers, from the current viewed z-level down to 0, and finding the z-level that is occluded first (or all the way to the 0 level), so that when rendering, I can skip z-layers for that tile that are below this value.
This isn't really giving me much of a performance increase.
I'm looking for ideas on how to better perform these series of draw calls. I'm using OpenGL3.3 directly, so I'm not restricted by any library or engine constraints. Currently, I'm rendering each "tile" on each layer seperately and would prefer to keep it that way for simplicity.


texts:
I am looking at adopting a skeletal animation format (as prompted here) for an RTS game.  The individual representation of each model on-screen will be small but there will be lots of them!

In skeletal animation e.g. MD5 files, each individual vertex can be attached to an arbitrary number of joints.

How can you efficiently support this whilst doing the interpolation in GLSL?  Or do engines do their animation on the CPU?

Or do engines set arbitrary limits on maximum joints per vertex and invoke nop multiplies for those joints that don't use the maximum number?

Are there games that use skeletal animation in an RTS-like setting thus proving that on integrated graphics cards I have nothing to worry about in going the bones route?


texts:
I can't really find anything at all on this topic. There's a bunch of YouTube videos that show people doing it, but there aren't any articles that I can find explaining the mechanics of it. In my game, terrain is loaded from a .RAW heightmap, and saved to a .RAW heightmap. But the player will be able to modify the terrain. I don't really understand his this terrain deformation works, but so far, I've only created things using vertex buffers which as far as I know can't be changed efficiently. Here and there I've read a few things about GPU tessellation and compute shaders. I understand tessellation and I can do that, but there's also very little I can find about compute shaders.

Are there any good books or websites that explain these things in detail? I'm not really looking for tutorials, because they tend to be pretty specific. But I really just want anything to bring me out of the dark on this subject.


texts: Should I use XNA or Unity to build a video game?

texts: My friend and I are planning to make a video game (like Slender) where the character is stuck in a building, when lightning strikes, and the lights go out and your objective is to find the back-up generators and turn the lights back on. The game will be pretty small.We are now wondering whether we should use Unity or XNA to build it. I have no experience in either, and I will mostly be writing in C# (which both have that capability). My friend will be drawing the images, and we want to import the images into the game. Which software should we use? What are the pros and cons of each? Thanks in advance.


texts: How can I balance the traffic load of my agents over multiple paths?

texts:
I am looking for a way to distribute the load of the agents over multiple paths. Ideally, the calculation would be executed multiple times a tick.

One use case would be for traffic balancing for a set of vehicles going from point A to B. When a road gets congested, the AI would know to change path to get to the location more efficiently. Best way to visualize this is the traffic issue in every simcity-like game.

The worst case I can think of for now is to just perform A* with a modifier attached to the cost function. I can think of ways to optimize this but it will eventually stack up.

Are there better alternatives?


texts:
Garry's Mod has a copy-protection trap that shows this error:

  Unable to shade polygon normals

It made me wonder if such a problem could ever actually exist.  Can polygon normals be shaded? Is a failure to do so detectable and reportable?


texts: Orthographic camera produces strange results

texts:
I've created a basic orthographic camera using the following view projection matrix:

2 / (right - left), 0, 0, -((right + left) / (right - left)),
0, 2 / (top - bottom), 0, -((top + bottom) / (top - bottom)),
0, 0, -2 / (zFar - zNear), -((zFar + zNear) / (zFar - zNear)),
0, 0, 0, 1

where right = 1280, left = 0, top = 0, bottom = 720, zFar = 1.0 and zNear = -1.0

The matrix gets used in the glsl shader like below:

layout(location = 0) in vec3 a_Position;
layout(location = 1) in vec2 a_TexCoord;

uniform mat4 u_ViewProjection;
uniform mat4 u_Transform;

out vec2 v_TexCoord;

void main()
{
    v_TexCoord =  a_TexCoord;
    gl_Position = u_ViewProjection * u_Transform * vec4(a_Position, 1.0);
}

where the u_Transform uniform is passed a simple identity matrix.

And I have declared a default rectangle that I am trying to get to the middle of my screen:

    float vertices[] = {
        // positions         // texcoords
         0.5f,  0.5f, 0.0f,  1.0f, 1.0f,   // top right
         0.5f, -0.5f, 0.0f,  1.0f, 0.0f,   // bottom right
        -0.5f, -0.5f, 0.0f,  0.0f, 0.0f,   // bottom left
        -0.5f,  0.5f, 0.0f,  0.0f, 1.0f    // top left
    };

This results in the folowing image showing a single diagonal line:

The strange thing is that if I upscale the rectangle coordinates to the following:

        float vertices[] = {
        // positions         // texcoords
         1.0f,  1.0f, 0.0f,  1.0f, 1.0f,   // top right
         1.0f, -1.0f, 0.0f,  1.0f, 0.0f,   // bottom right
        -1.0f, -1.0f, 0.0f,  0.0f, 0.0f,   // bottom left
        -1.0f,  1.0f, 0.0f,  0.0f, 1.0f    // top left

It shows a full rectangle like below:

Expected result: In both cases it should show a rectangle, with the second rectangle being larger.
Actual result: The first case doesnt even produce a rectangle, while the upscaled coordinates do show a rectangle.

My question: Is the problem in the math, and if so, what causes this behavior or should this be the expected result and am I wrong in my understanding of the model view projection matrix.


texts: How should I structure my Android platform board game?

texts:
I'm new to developing Android games, but not new to developing mobile games (J2ME). I'm currently developing a board game, for a school project, with 2 things - a board and a spinning wheel (both are displayed at the same time). The user is able to zoom in/out and scroll around the board and spin the wheel. The wheel is also animated - resized during game. The board is build using tiles (2-4 different tiles on one image per board ) and the wheel is a image with numbers draw on it, using graphics.

My questions is what is the best practice to achive the best performance of the game (game has to run on every possible Android version)?

Should i use Android canvas or open GL?
Is there a mechanism for drawing tiles, animations or should i just implement it my self using drawImage()?
Should i separate the wheel and the board into two different threads? Should i separate the wheel and the board in to 2 activities or put it in 1 activity and draw each part separatly?
What would be the best way to resize the wheel during gameplay? Scale the wheel image (but the animation has to be smooth - opengl vs canvas)?
What would be the best way to make the board zoomable - should i scale every image on the board when the zoom is detected or does android have some better way to do this?
What would be the best way to make the board scrollable - should i implement a Camera that displays just a piece of the board or does android have some better way to do this?


texts:
In my game, I want to change density of my body object when it collide with other objects. I found something like following to change density but further I could not able to find any hint for this. So someone please help.

Fixture fixture = goldenBoxArrayList.get(i)
                                        .getGoldenBoxBody()
                                        .getFixtureList().get(0);
                                fixture.setDensity(0.5f);

After setting fixture data I could not able to set it to the body.

EDIT : I want to change my object body density when physics world in simulation


texts: Which version of Quake 2 source code do I need to compile to work with version 3.20 map packs?

texts:
I'm a big fan of Quake 2 game. Recently I've decided to spend some of my free time for digging into the Quake 2 src code. There are 2 versions of the full game code 3.19 and 3.21 (including the game exe as well as the game dll).
As regards to the Q2 Mission Packs the src files for both The Reckoning and Ground Zero are rather of verions 3.20 as the filename suggests (xatrixsrc320.exe and roguesrc320.exe)
My question is WHICH version of the game exec do I have to compile to use with the mission pack dlls? Is it better to use the 3.21 exe together with 3.20 of the xatrix & rogue dlls, or maybe the older 3.19 would be more appropriate?


texts: Endless runner player detect player drop

texts:
Starting to learn/write my first game using Corona/Solar2d game engine.
And have a very basic question on how do people handle a such this situation which I assume should be common to any game engine.
I am trying to build an endless runner game, where I have an uneven terrain player have to jump between different height platforms while moving forward.
Here is the closest to what I have in mind.
https://youtu.be/qWz0vOywFdY
How do I find if the player has fallen between the the two platforms while jumping ?


texts: How do I add a 3D sprite over a TMX background using Cocos2d-x?

texts:
We have been working on sample game, in which we want to show a 3D sprite on a background loaded from a .tmx file. But the 3D sprite is never showing up, though we tried setting tileMap->setGlobalZOrder(-1).

This is a sample of our code:

CCTMXTiledMap tileMap = new CCTMXTiledMap();
tileMap->initWithTMXFile("map.tmx");
tileMap->setGlobalZOrder(-1);
//tileMap->setGlobalZOrder(-1000);
this->addChild(tileMap, 0);

//Sprite3D player = Sprite3D::create("player.c3b");
auto player = Sprite3D::create("player.c3b");
player->setScale(10.0f);
player->setPosition3D(Vec3(200, 500, 0));
this->addChild(player, 1);

But the 3D sprite is never showing up.

We have also raised an issue on GitHub here.


texts: How would you handle different aspect ratios in a 2d platformer?

texts:
A long time ago, 4:3 was pretty much the only apect ratio you would find on a PC. Today the most common one is 16:10, but most new monitors (especially laptops) are 16:9

I'm writing a 2D platformer, and I can't decide how I should handle all the different ratios.

Here are some ideas:

4:3 gets more content, widescreens are cut on top and bottom
16:9 gets more content, the others are cut left and right
The game is in 16:9 with black horizontal bars for other ARs
The game is in 4:3 with black vertical bars for other ARs


texts:
I've been moving from Unity to Unreal and I'm finding it difficult to grasp the Raycast (Trace) logic of Unreal.

The use case I'm trying to implement at the moment is to trace a ray and check if I hit a specific set of objects or if there are other objects blocking the line of sight.

In Unity, I would use Raycast, define a new specific Layer, set the object layer to it, create a LayerMask with that Layer and Raycast. I consider this method to be performant as the use of layer masks provide a form of optimization and most importantly I'm guaranteed that if the ray hits an object than it's because its layer is part of the layer mask and if I'm using multiple layers I could simply check which layer the hit object has.

In Unreal it's been harder to understand what are the solutions that offer better performance and are easier to use. The C++ documentation for Line Trace (channel or object type) is very poor when comparing to Unity's.

Can anyone shed some light on how to move from the Unity logic to Unreal using the above use case as an example?


texts: Download and open an zip file ingame on unity for android

texts:
I would like to know if it is possible to have a game that would download a rar or zip file from a website and extract it to the internal storage for use, and if it is a good option since i have to use a directory structure to open fbx models that have the texture on a folder with the same name of the fbx.

The App is made for android and the files should not be bigger than 30mb.


texts:
Here is a mockup of a main menu screen I'm trying to put together in Unity.

I'm clueless as to how I should go about creating the blue glow on the left of my menu options.  Can somebody point me in the right direction?


texts: XNA Kinect Color Stream Performance Issues

texts:
I am developing an XNA game using Kinect. It requires using Depth and Color streams for extracting only the player's image from the color image. So far I can extract the image and set their data into a Texture2D object, but the performance gets very low for the whole game when I do that. I tried setting only black color for player's silhouette and performance gets better but I need to use Color Stream with as little performance issues as possible.

Thanks for any help.


texts:
A few days ago I found something called voxel terrains and I think that they're pretty cool.  But I don't know anything generating them. Do you model it in your modeling software or use something like a heightmap? I read on wikipedia that voxels are like 3d pixels or volumetric pixels.

After I make the voxel terrain, how can I take these voxels and make them  destroyable/diggable?

I will pick the best answer based on:

code and algorithms. preferably based in C#
explanations. I am a beginner with algorithms but I'm very familiar with object oriented programming
step by step demonstrations. Not only concept but direction.
diagrams/illustrations. No, not screenshots of other engines.

I know that this is a complicating subject. But, thanks for any help!

No, I'm not trying to make a minecraft clone.

Edit

Thanks to everyone for your great help (especially Nick Wiggill)! This is what I managed to make (Work in progress).


texts: Why are normal maps in tangent space but not in normal space?

texts: I want to implement normal mapping in my little game engine. When getting into normal mapping, I wonder why normal maps are typically in tangent space but not in normal space? That normal maps in object space would be complicated to handle is clear to me. But when in normal space, they could be easily added to the vertex normal, couldn't they? It seems that tangent space requires to construct a transformations matrix for each pixel.


texts: How can I make my player move in the direction the camera faces?

texts:
I have a 3rd person camera which can rotate around the player.
My problem is that wherever camera is facing, players forward is always the same direction.

For example when camera is facing the right side of the player, when I press button to move forward, I want player to turn to the left and make that the "new forward".

My camera script so far:

using UnityEngine;
using System.Collections;

public class PlayerScript : MonoBehaviour
{
    public float RotateSpeed = 150,
    MoveSpeed = 50;
    float DeltaTime;

    void Update()
    {
        DeltaTime = Time.deltaTime;
        transform.Rotate(0, Input.GetAxis("LeftX") * RotateSpeed * DeltaTime, 0);
        transform.Translate(0, 0, -Input.GetAxis("LeftY") * MoveSpeed * DeltaTime);
    }
}

public class CameraScript : MonoBehaviour
{
    public GameObject Target;
    public float RotateSpeed = 170,
    FollowDistance = 20,
    FollowHeight = 10;
    float RotateSpeedPerTime,
    DesiredRotationAngle,
    DesiredHeight,
    CurrentRotationAngle,
    CurrentHeight,
    Yaw,
    Pitch;
    Quaternion CurrentRotation;

    void LateUpdate()
    {
        RotateSpeedPerTime = RotateSpeed * Time.deltaTime;

        DesiredRotationAngle = Target.transform.eulerAngles.y;
        DesiredHeight = Target.transform.position.y + FollowHeight;
        CurrentRotationAngle = transform.eulerAngles.y;
        CurrentHeight = transform.position.y;

        CurrentRotationAngle = Mathf.LerpAngle(CurrentRotationAngle, DesiredRotationAngle, 0);
        CurrentHeight = Mathf.Lerp(CurrentHeight, DesiredHeight, 0);

        CurrentRotation = Quaternion.Euler(0, CurrentRotationAngle, 0);
        transform.position = Target.transform.position;
        transform.position -= CurrentRotation * Vector3.forward * FollowDistance;
        transform.position = new Vector3(transform.position.x, CurrentHeight, transform.position.z);

        Yaw = Input.GetAxis("Right Horizontal") * RotateSpeedPerTime;
        Pitch = Input.GetAxis("Right Vertical") * RotateSpeedPerTime;
        transform.Translate(new Vector3(Yaw, -Pitch, 0));
        transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z);

        transform.LookAt(Target.transform);
    }
}


texts: 2D character with baseball bat implementation in Unity

texts: I'm making a 2D baseball game in Unity and I'd like to know how the player and the bat should be connected. For instance, if I use single sprite for both the player and the bat, then how should the collision between the bat and the ball be detected?


texts:
I want to use frames from a spritesheet as particles for my emitter.

I load my spritesheet with :

game.load.spritesheet('particles_sheet', 'http://stuff.lck.io/luckyslot/sprite_sheet.png', 50, 50, 6);

var emitter = game.add.emitter(game.world.centerX, canvas_height, 80);

And i need some code to load the right frame at random :

emitter.makeParticles('particles_sheet');

Any idea?


texts:
I'm making a dungeon game, and I'm doing input. When I move left or down until the code stops the player, I can no longer move any way except opposite the way I moved. Let's say I moved all the way left. The canmovethere() method stops the player from moving anymore. The player is now "stuck" in the wall; I can't move it up or down, only right. This also happens for moving down, but not up or right.

Here's the code:

public class PlayerInputProcessor {
   private PlayerCharacter player;
   private Dungeon dungeon;

   private final int NORTH = 0, SOUTH = 1, WEST = 2, EAST = 3;

   public PlayerInputProcessor(PlayerCharacter player, Dungeon dungeon) {
   this.player = player;
      this.dungeon = dungeon;
   }

   public void HandleInput() {
      if(Gdx.input.isKeyPressed(Keys.UP)) {
         if(canmovethere(player.getGridPos(), NORTH)) {
            player.setVectorPosY(player.getVectorPosY() + 3);
         }
      }
      if(Gdx.input.isKeyPressed(Keys.DOWN)) {
         if(canmovethere(player.getGridPos(), SOUTH)) {
            player.setVectorPosY(player.getVectorPosY() - 3);
         }
      }
      if(Gdx.input.isKeyPressed(Keys.RIGHT)) {
         if(canmovethere(player.getGridPos(), EAST)) {
            player.setVectorPosX(player.getVectorPosX() + 3);
         }
      }
      if(Gdx.input.isKeyPressed(Keys.LEFT)) {
         if(canmovethere(player.getGridPos(), WEST)) {
            player.setVectorPosX(player.getVectorPosX() - 3);
         }
      }
      System.out.println("Grid Pos " + player.getGridPos());

      player.setGridPos(new GridPoint2((int) player.getVectorPosX() / player.getWidth(),
         (int) player.getVectorPosY() / player.getHight()));

      if(dungeon.getTile(player.getGridPos()) instanceof FloorTile) {
         System.out.println("On A Floor Tile");
      }
   }

   private Boolean canmovethere(GridPoint2 newpos, int die) {
      GridPoint2 nextpos = new GridPoint2();

      if(die == NORTH) {
         nextpos.x = newpos.x;
         nextpos.y = (newpos.y + 1);
         if(dungeon.getTile(nextpos).isPassable()) {
            return true;
         }
      }
      if(die == SOUTH) {
         nextpos.x = newpos.x;
         nextpos.y = (newpos.y);
         if(dungeon.getTile(nextpos).isPassable()) {
            return true;
         }
      }
      if(die == EAST) {
         nextpos.x = newpos.x + 1;
         nextpos.y = newpos.y;
            if(dungeon.getTile(nextpos).isPassable()) {
               return true;
            }
      }
      if(die == WEST) {
         nextpos.x = (newpos.x + player.getWidth() / player.getWidth()) - 1;
         nextpos.y = newpos.y;
         if(dungeon.getTile(nextpos).isPassable()) {
            return true;
         }
      }
      return false;
   }
}


texts: How does a developer ask for the rights to use a character?

texts: What channels must a developer go through to ask for the rights to a character? I want to make a point and click adventure based on Freddy Krueger, and I know my chances are slim, but how do you even go about asking?


texts:
I've been working on a game with a friend for a while now. I'm in charge of plotting most of the stats on the weapons.

Weapons have several attributes:

Four damage types: Base, Impact, Punct and Slash
Two special damages: Elemental and energy
Stats: Speed, durability, crit. chance and crit multiplier

Can anyone think of a way to calculate the price of an item using the weapon stats?


texts:
I am trying to map UV coordinates to indexed vertices with this code. I am using a vertex buffer, texture buffer, and index buffer (note the vertex and texture buffers are indexed in the same order)

glBindTexture(GL_TEXTURE_2D, staticTexture);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glBindBuffer(GL_ARRAY_BUFFER, textureBuffer);
glTexCoordPointer(2, GL_FLOAT, 0, 0);

glBindBuffer(GL_ARRAY_BUFFER, staticVertexBuffer);
glVertexPointer(3, GL_FLOAT, 0, 0);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);

glDrawElements(GL_QUADS, indices.size(), GL_UNSIGNED_INT, 0);

glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glBindTexture(GL_TEXTURE_2D, 0);

but when I run the code I get this (compared to the actual image that is supposed to appear on each face)

My code for setting the indices and uv coords (one face of the cube)

uv.push_back(Vector2(0, 1));
uv.push_back(Vector2(1, 1));
uv.push_back(Vector2(1, 0));
uv.push_back(Vector2(0, 0));
indices.push_back(vertexIndexFromCoordinates(x, y, z));
indices.push_back(vertexIndexFromCoordinates(x, y, z + 1));
indices.push_back(vertexIndexFromCoordinates(x, y + 1, z + 1));
indices.push_back(vertexIndexFromCoordinates(x, y + 1, z));

The only thing I can think of is that the UV's are being mapped by the vertices not the indices.


texts: What does distance divided by acceleration mean?

texts:
I'm reading a book named "Programming Game AI by Example". Here's a method to help an autonomous character to slow down when it's getting closer and closer to its target:

Vector2D SteeringBehavior::Arrive(Vector2D TargetPos, Deceleration deceleration)
{
    Vector2D ToTarget = TargetPos - m_pVehicle->Pos();

    //calculate the distance to the target
    double dist = ToTarget.Length();

    if (dist > 0)
    {
        //because Deceleration is enumerated as an int, this value is required
        //to provide fine tweaking of the deceleration..
        const double DecelerationTweaker = 0.3;

        //calculate the speed required to reach the target given the desired
        //deceleration
        double speed =  dist / ((double)deceleration * DecelerationTweaker);

        //make sure the velocity does not exceed the max
        speed = min(speed, m_pVehicle->MaxSpeed());

        //from here proceed just like Seek except we don't need to normalize
        //the ToTarget vector because we have already gone to the trouble
        //of calculating its length: dist.
        Vector2D DesiredVelocity =  ToTarget * speed / dist;

        return (DesiredVelocity - m_pVehicle->Velocity());
    }

    return Vector2D(0,0);
}

For this line:

//calculate the speed required to reach the target given the desired
//deceleration
double speed =  dist / ((double)deceleration * DecelerationTweaker);

The Deceleration is an enum like this.

//Arrive makes use of these to determine how quickly a vehicle
//should decelerate to its target
  enum Deceleration{slow = 3, normal = 2, fast = 1};

I just don't understand how can it get a speed by dividing a distance by an acceleration (deceleration)? Did I misunderstand anything?


texts: LibGDX - GameWorld Dimensions vs ViewPort Dimensions vs Camera Dimensions

texts:
Before someone mark it duplicate - I am aware that there are few questions already on this topic but the explanations are all theoretical and no graphical elaboration was provided which I think will help in understanding these concepts better.
Coming to the query in hand, I assume LibGDX follows OpenGl definitions of GameWorld, Camera and ViewPorts - please correct me if I am wrong. Now when I am trying to understand these basic concepts of LibGDX, confusions are arising all around me. I am sure these concepts are not that hard to understand and I must be looking at the things in a wrong way. As per my understanding:
GameWorld Dimensions: This is the dimension of the GameWorld that I have created, perhaps a Tiled map or some background which will be showing to the player. Lets assume the GameWorld dimension is 4096 x 4096 px.
Camera Dimensions: This is the dimension of the Camera that I would like to show to the user at a time. It could be 800x480 px or 320x240 px or whatever I want. When set, user will only be able to see that part of the GameWorld at a time.
ViewPort Dimensions: I have absolutely no clue how this works!
And my queries are: (Please explain with image/graphics for better clarity)
a. How is ViewPort related to Camera?
b. Is Camera a part of ViewPort or is it vice-versa?
c. Can Camera dimensions be different than that of ViewPort?  eg: Can camera be 800x480 px whereas Viewport 320x240 px or vice-versa?
d. When designing games for multiple screen densities/sizes, which is a better approach - Camera with standard dimensions (16/9 - 4/3 - 800x480) or   ViewPort? If ViewPort then which is the best in such cases -   Stretch/Fill/Fit/Expanded ?


texts:
I have two user cases:

How would entity_A send a take-damage message to entity_B?
How would entity_A query entity_B's HP?

Here's what I've encountered so far:

Message queue

entity_A creates a take-damage message and posts it to entity_B's message queue.
entity_A creates a query-hp message and posts it to entity_B.  entity_B in return creates an response-hp message and posts it to entity_A.

Publish/Subscribe

entity_B subscribes to take-damage messages (possibly with some preemptive filtering so only relevant message are delivered).  entity_A produces take-damage message that references entity_B.
entity_A subscribes to update-hp messages (possibly filtered).  Every frame entity_B broadcasts update-hp messages.

Signal/Slots

???
entity_A connects an update-hp slot to entity_B's update-hp signal.

Is there something better? Do I have a correct understanding of how these communication schemes would tie into a game engine's entity system?


texts: Drawing particles with CPU instead of GPU (XNA)

texts:
I'm trying out modifications to the following particle system. http://create.msdn.com/en-US/education/catalog/sample/particle_3d

I have a function such that when I press Space, all the particles have their positions and velocities set to 0.

for (int i = 0; i < particles.GetLength(0); i++)
{
    particles[i].Position = Vector3.Zero;
    particles[i].Velocity = Vector3.Zero;
}

However, when I press space, the particles are still moving. If I go to FireParticleSystem.cs I can turn settings.Gravity to 0 and the particles stop moving, but the particles are still not being shifted to (0,0,0).

As I understand it, the problem lies in the fact that the GPU is processing all the particle positions, and it's calculating where the particles should be based on their initial position, their initial velocity and multiplying by their age. Therefore, all I've been able to do is change the initial position and velocity of particles, but I'm unable to do it on the fly since the GPU is handling everything.

I want the CPU to calculate the positions of the particles individually. This is because I will be later implementing some sort of wind to push the particles around. How do I stop the GPU from taking over? I think it's something to do with VertexBuffers and the draw function, but I don't know how to modify it to make it work.


texts: Implementing directional lighting in voxel based polygon-engine

texts:
I'm having trouble implementing directional lighting.
(I'm not that familiar with 3D.)

The problem is that the lighting does not "follow/flow with" the other blocks next to them.

How should I fix this.

At the moment all vertices have there own normals.

Should I combine or re-position normals if the blocks are next to each other?

(I tried combining the normals but then it just looks like a plain, as if its just one color.)

Should I maybe do that kind of behaviour with shadows and is directional lighting specifically for ambient lighting and not so much for diffused lighting?

This is a little bit of the code that contains the normals (the last 3 values).

        {0, {x * BLOCK_RENDER_SIZE                    , y * BLOCK_RENDER_SIZE                    , z * BLOCK_RENDER_SIZE                    , getBlockColor(), -1.0f, -1.0f, -1.0f}},
        {1, {x * BLOCK_RENDER_SIZE                    , y * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, z * BLOCK_RENDER_SIZE                    , getBlockColor(), -1.0f,  1.0f,  1.0f}},

        {2, {x * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, y * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, z * BLOCK_RENDER_SIZE                    , getBlockColor(),  1.0f,  1.0f, -1.0f}},
        {3, {x * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, y * BLOCK_RENDER_SIZE                    , z * BLOCK_RENDER_SIZE                    , getBlockColor(),  1.0f, -1.0f, -1.0f}},

        {4, {x * BLOCK_RENDER_SIZE                    , y * BLOCK_RENDER_SIZE                    , z * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, getBlockColor(), -1.0f, -1.0f,  1.0f}},
        {5, {x * BLOCK_RENDER_SIZE                    , y * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, z * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, getBlockColor(), -1.0f,  1.0f,  1.0f}},

        {6, {x * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, y * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, z * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, getBlockColor(),  1.0f,  1.0f,  1.0f}},
        {7, {x * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, y * BLOCK_RENDER_SIZE                    , z * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, getBlockColor(),  1.0f, -1.0f,  1.0f}}

(I didn't add more code because I don't think its necessary)


texts: How can I represent prerequisites of different type of game objects?

texts:
In a strategy game, I want to declare prerequisites for various types of game objects to limit when they can be acquired/executed: technologies, buildables, resources, actions, etc. Any of these types could have prerequisites from any other type.

Examples:

Training unit U requires technology X to be known, a building Y present in the city, and a surplus of resource Z available.
Starting research on technology T requires technologies A and B to be known, and a source of resource C available.
Construction wonder W requires 5 instances of building D in that player's cities and no other instance of W in existence.

The difficulty here is that each type of object meets the prerequisite in a somewhat different way. Technologies are known to a player or not, while buildings may exist in a given city, and resources could be present but not exploited or already claimed.

Is there a way I can generically describe such a prerequisite feature that can include any combination of semantically different game objects? This structure would have to determine, given a context, whether all prerequisites are met, and if not what is missing.


texts: Algorithm for units to attack each other in strategy games

texts:
I am creating a strategy game with many objects, in which the objects will be able to attack each other.

If an object is within attack range of another object, it will be attacked. But I only know one way is to loop through all objects to see if it is within the scope of this object's attack. Therefore the complexity of the algorithm is O (n ^ 2). Can someone give me a better algorithm or preferably a book about algorithms like this.

Thanks !