texts: Whats the general method developers to implement FPS multiple weapon handling animations?

texts:
I'm trying to create a first person shooter and I'm lost on what's a good, efficient methodology to implement the whole weapon handling animation system.

Now, I know that I could have a unique animation for every weapon, but this sounds very expensive. Do people use IK to modify hand positions so that they can reuse the same animations for similar weapons?

Also, How does recoil work? Is it baked into the animation? Or is it applied via script? In counterstrike it looks like it's baked into the animation (since they use hip firing), however, in COD it looks like

Id really appreciate any opinions because I am lost!

Thank you


texts: How to stop an ImageView being dragged before the user stops dragging

texts:
I am making a maze game using Android Studio. I have a GridLayout on the bottom layer of the layout, each cell contains a custom LinearLayout. Some of these LinearLayouts have a special boolean property isWall. If isWall = true I put a different image in the LinearLayout.

The "start" cell of the grid contains a child ImageView of a ball. I want the user to be able to drag the ball through the maze and drop it on any non-wall LinearLayout. I don't want the ImageView to be dragged across any cell containing a LinearLayout where isWall = true. I know how to get the DragListener to return false after the user drags the ImageView across a "wall" and drops it on the other side, and I basically have the ball return to the cell it was in before that drag.

How to I make the ImageView itself stop mid-drag, thus forcing the user to stay inside the maze walls?


texts: How to make a stack stable? Need help for an explicit resting contact scheme (2-dimensional)

texts:
Previously, I struggle with the sequential impulse-based method I developed. Thanks to jedediah referring me to this paper, I managed to rebuild the codes and implement the simultaneous impulse based method with Projected-Gauss-Seidel (PGS) iterative solver as described by Erin Catto (mentioned in the reference of the paper as [Catt05]).

So here's how it currently is:

The simulation handles 2-dimensional rotating convex polygons.
Detection is using separating-axis test, with a SKIN, meaning closest points between two polygons is detected and determined if their distance is less than SKIN.
To resolve collision, simultaneous impulse-based method is used. It is solved using iterative solver (PGS-solver) as in Erin Catto's paper. Error-correction is implemented using Baumgarte's stabilization (you can refer to either paper for this) using
J V = beta/dt*overlap,
J is the Jacobian for the constraints, V the matrix containing the velocities of the bodies, beta an error-correction parameter that is better be < 1, dt the time-step taken by the engine, and overlap, the overlap between the bodies (true overlap, so SKIN is ignored).

However, it is still less stable than I expected :s I tried to stack hexagons (or squares, doesn't really matter), and even with only 4 to 5 of them, they would swing! Also note that I am not looking for a sleeping scheme. But I would settle if you have any explicit scheme to handle resting contacts.

That said, I would be more than happy if you have a way of treating it generally (as continuous collision, instead of explicitly as a special state).

Ideas I have tried:
Using simultaneous position based error correction as described in the paper in section 5.3.2, turned out to be worse than the current scheme.

If you want to know the parameters I used:

Hexagons, side 50 (pixels)
gravity 2400 (pixels/sec^2)
time-step 1/60 (sec)
beta 0.1
restitution 0 to 0.2
coeff. of friction 0.2
PGS iteration 10
initial separation 10 (pixels)
mass 1 (unit is irrelevant for now, i modified velocity directly<-impulse method)
inertia 1/1000

Thanks in advance! I really appreciate any help from you guys!! :)

EDIT

In response to Cholesky's comment about warm starting the solver and Baumgarte:
I forgot to mention! I do save the contact history and the impulse determined in this time step to be used as initial guess in the next time step.

As for the Baumgarte, here's what actually happens in the code. Collision is detected when the bodies' closest distance is less than SKIN, meaning they are actually still separated. If at this moment, I used the PGS solver without Baumgarte, restitution of 0 alone would be able to stop the bodies, separated by a distance of ~SKIN, in mid-air! So this isn't right, I want to have the bodies touching each other. So I turn on the Baumgarte, where its role is actually to pull the bodies together! Weird I know, a scheme intended to push the body apart becomes useful for the reverse.

Also, I found that if I increase the number of iteration to 100, stacks become much more stable, though the program becomes so slow.

UPDATE

Since the stack swings left and right, could it be something is wrong with my friction model?

Current friction constraint: relative_tangential_velocity = 0


texts: Algorithm for creating mesh from 2D image silhouette

texts:
I'm looking for an algorithm that can take a 2D image, approximate it's shape and then generate a low poly mesh. Basically, the same what Unity does with sprites when you select tight mesh instead of a rect mesh.

I'd be very thankful for any links that would put me on track to begin my research. Thanks!


texts: Is this a suitable "pathfinding" algorithm for a tower defense game?

texts:
Note: I put "pathfinding" in quotes because I'm not sure if it's the proper term for this.

My goal is to create a 2D tower defense game with HTML5/JavaScript. It's mostly for learning purposes, so I'm trying to come up with solutions myself before looking how others did it.

One of my first questions was: How do I get enemies to follow a path? After thinking about it for a while, I came up with an idea which I think might be a bit counter-intuitive. It appears to work perfectly in testing, but I'm not sure if I should do it this way because I couldn't find any similar examples. Although that may just be because I'm not sure how to search for it.

The general idea works like this:

The map has a path, which the enemies follow. The path is an array of waypoints (each with X and Y coordinates) which are implicitly connected in sequence by straight lines. So the length of the path can be measured by adding the distances between consecutive waypoints.
Each enemy's position is represented by a single number, which refers to how far they are on the path (i.e. their progress). There's also a field for their two-dimensional position on the map (needed for rendering), which is initially empty.
Every frame, the algorithm recalculates and updates each enemy's 2D-position. This is done by taking its 1D-position, checking which waypoint was the last one the enemy passed, and then calculatig the correct position between that waypoint and the next (even if they're at an angle).

The reason I like this idea is that each number between 0 and the length of the path corresponds exactly to one single point on the path. That way it should be impossible for objects to glitch out of bounds or be rendered at the wrong place. It also makes finding the first or last enemy in a given range a trivial task.

My main concern so far is performance. Running this calculation for each enemy on every frame seems rather time-consuming, especially if the map gets filled with enemies, towers and projectiles later on. Are there any other problems with this approach?

In case my description doesn't tell you enough, here's what my code looks like:

posOnMap(pos) {
    if (typeof pos !== 'number') throw TypeError('pos is NaN');
    if (pos < 0) return new V2(map.path[0].x, map.path[0].y);
    if (pos >= map.pathLength) return new V2(map.path[map.path.length - 1].x, map.path[map.path.length - 1].y);

    var last, next, offset, len = 0;
    for (var i = 0; i < map.path.length - 1; i++) {
        offset = len;
        len += V2.distance(map.path[i], map.path[i + 1]);
        if (len > pos) {
            last = map.path[i];
            next = map.path[i + 1];
            break;
        }
    }
    var posRel = pos - offset;
    var dist = V2.distance(last, next);
    var fraction = posRel / dist;
    return new V2(last.x + (next.x - last.x) * fraction, last.y + (next.y - last.y) * fraction);
}

map.path is the path array, as described above. So map.path.length is the total number of waypoints, while map.pathLength is the length of the path in in-game units.


texts: How do you add turbulence to a particle system using noise?

texts:
I have implemented a basic particle system using transform feedback in openGL, hoping to replicate a dust cloud.

I have looked at methods of adding turbulence, such as vortices found here.

But they do not give the desired effect. The guide discusses the idea of using perlin or simplex noise to add turbulence.

But I don't understand how this is done?

Would you use a pre-generated noise texture and take sample data from it?

Or calculate data at run time in the shader?

What is the basic idea behind implementing noise turbulence?

Edit:
My main question would be, how do you get a turbulent velocity from noise values?


texts: I need an enemy spawning algorithm for a 2D tower defense

texts:
I need an enemies spawning algorithm for a 2D tower defense game. I have 4 maps, each has 4 stages and each stage has 40 rounds. I need to create an algorithm which will instantiate waves, increase health and change their type in new rounds, new stages and in new maps. I need your suggestions and ideas to resolve my problem.

It should be done like in geoDefense and Fieldrunners.

Lets take an example which is somewhat in my mind:

MAP1- Stage-1, on Rounds 1,2,3,4 loop around with '+5' on it so also in Rounds 6,7,8,9 ...so on... instantiate 'Type-1 swarm' after increment(+5) add 'Type-1 swarm + some value' so that if previous 'Type-1 swarm' (on rounds 1,2,3,4) has 3 enemies, after above increment(+5) 'Type-1 swarm' has 3+some value. The rounds multiple of 5 will instantiate 'Type-2 swarm + some value', and as round increases health value should also increase.

On Map-1 Stage2/ and other Maps and stages repeat the above process with some slight difficulty and change type swarm1 and swarn2 with other swarn types.

I hope you people got what I actually need. I don't want to hardcode the rounds because there is also an endless option in my game and hard level would have 100 rounds instead of 40.

Any other spawning ideas/algorithms followed by TD game programmers/designers.


texts: In a 2D multiplayer game should I send the position of user to the server all the time?

texts: In a 2D game where the user moves with the keyboard arrows, should the user send all the time he moves his position (x, y)?. If the user has some speed, the user would send (x, y) like 50 times pixel by pixel in just a second.


texts: Where can I download the Doom Classic source code, the iOS port?

texts:
Doom classic source code for iOS was released by id software, but there is no working link on their web site where I could get it from.

Do you know an alternative source to download the Doom Game for iOS?


texts: How do I raycast for a spherical harmonic shader using the iOS GPU?

texts:
I am beginning an Spherical Harmonics shader project for an iOS app I am writing. I have begun by reading this excellent in-depth paper on the subject.

The paper describes a scene pre-processing step that involves ray-casting (one bounce, shadow feeler). Can someone describe how ray-casting can be performed using GLSL on iOS?


texts:
Possible Duplicate:
  How closely can a game resemble another game without legal problems

Can I use remade sprites in my game?

I am making a game and I used some sprites, but I didn't copy them. I remade them completely the character looks nothing like the original. I only did this to get the movement of the character right (moving, running, jumping, punching). I've been working on the game for a long time, so I really need to know is it safe and legal to do this. I do intend making a small profit.


texts: Is it possible to have a GUI in world space in Unity3D game?

texts: I'm trying to make a tank shooter game for learning purpose and I want to have it viewed in first person, is there a way to make it so that the GUI seems projected onto the interior of the tank chamber so that I can look around without the GUI following the camera along with having the perspective change effects (i.e. the edge of the GUI further away from the camera appears smaller than the edge closer to the center of the camera)?


texts: How to use 3D models in video games? (Copyright related)

texts:
There are many gray areas in using 3D models online that may be free, creative commons with specific terms, or public domain. I notice many 3D models being sold by artists that are exact replicas of known vehicles (eg. BMW,Honda,etc.(with emblem)). I would think in this situation there will be some sort of infringement  especially if someone bought that model and used it in their video game, no matter if it was marked as royalty free. I would appreciate if someone with experience could assist in clarifying some of the following areas. Please note, this is the information I have inferred based of personal research, may not be factual, please correct me if I am wrong.

Commercial Use: Of course never sell someone's 3D model, but what part of that is considered theirs; if they made a model of an RC car, are the wheels legal to use, the chassis, engine especially if the creative textures(or meshes) are removed and all that is the mere form of the object. (Eg. if I 3D model a nail/screw; that is not considered copyright protected because it is a 'common'/'useful' object)

Free Usage: If your product is free, my assumption is that game devs could use a 3D model as long as they change textures, colors, etc. But form of the object is all for grabs.

Commercial Use & Free Use: If the product/game you are using is free, but you have advertisements bringing you revenue that may be on the side of a website or phone app and pop up every now and again; does this make it acceptable?

Thank you ahead of time!


texts:
I have a simple prototype with 2D worms-like destructible terrain.
I use a trivial shader to discard pixels based on a mask.

varying vec2 v_texCoords;
uniform sampler2D u_texture;
uniform sampler2D u_mask;

void main()
{
    vec4 colour = texture2D(u_texture, v_texCoords);
    vec4 mask = texture2D(u_mask, v_texCoords);

    if (mask.a > 0)
        discard;
    else {
        gl_FragColor = colour;
    }
}

What would be a good and simple way to add few pixels thick black outlines to the terrain to make the carved parts look better?

I've researched something about edge detection algorithms, but my hunch says that such a fullblown thing would be kind of an overkill for this task?

I'm not after quality or high performance, but simplicity.

Thanks for any ideas.


texts: Unity - Modify basic dissolve shader graph to dissolve from bottom up

texts: I have this dissolve shader made in shader graph which works fine, however I would like it to dissolve from bottom up, how would this be done?


texts: Particle System in XNA - cannot draw particle

texts:
I'm trying to implement a simple particle system in my XNA project. I'm going by RB Whitaker's tutorial, and it seems simple enough. I'm trying to draw particles within my menu screen. Below I've included the code which I think is applicable.

I'm coming up with one error in my build, and it is stating that I need to create a new instance of the EmitterLocation from the particleEngine. When I hover over  particleEngine.EmitterLocation = new Vector2(Mouse.GetState().X,      Mouse.GetState().Y); it states that particleEngine is returning a null value. What could be causing this?

/// <summary>
/// Base class for screens that contain a menu of options. The user can
/// move up and down to select an entry, or cancel to back out of the screen.
/// </summary>
abstract class MenuScreen : GameScreen

    ParticleEngine particleEngine;

    public void LoadContent(ContentManager content)
    {
        if (content == null)
        {
            content = new ContentManager(ScreenManager.Game.Services, "Content");
        }
        base.LoadContent();
        List<Texture2D> textures = new List<Texture2D>();
        textures.Add(content.Load<Texture2D>(@"gfx/circle"));
        textures.Add(content.Load<Texture2D>(@"gfx/star"));
        textures.Add(content.Load<Texture2D>(@"gfx/diamond"));
        particleEngine = new ParticleEngine(textures, new Vector2(400, 240));

    }

    public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                                   bool coveredByOtherScreen)
    {
        base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

        // Update each nested MenuEntry object.
        for (int i = 0; i < menuEntries.Count; i++)
        {
            bool isSelected = IsActive && (i == selectedEntry);

            menuEntries[i].Update(this, isSelected, gameTime);
        }

        particleEngine.EmitterLocation = new Vector2(Mouse.GetState().X,      Mouse.GetState().Y);

        particleEngine.Update();
    }

    public override void Draw(GameTime gameTime)
    {
        // make sure our entries are in the right place before we draw them
        UpdateMenuEntryLocations();

        GraphicsDevice graphics = ScreenManager.GraphicsDevice;
        SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
        SpriteFont font = ScreenManager.Font;

        spriteBatch.Begin();

       // Draw stuff logic

       spriteBatch.End();
       particleEngine.Draw(spriteBatch);

    }


texts: Showing background transparent image in android

texts:
I have a image with transparent background created from photoshop.

I added this to my android game which I am creating using libgdx. But when I add it to that, it is shown with white background like following.

Whats the reason for this? How can I fix this?


texts: Unable to get Box2dlights to cast shadows

texts:
I'm trying to use box2dlights to add lighting to my game and I have everything working except I am unable to have shadows cast with my box2d bodies.  I also have collision working using category/maskBits with my various objects and I'm trying to apply the same strategy to box2dlight filters.  You can see how the light just passed through the body.

EDIT:  I think I may have discovered why the lights are not colliding with my box2d bodies.  When I define the body shapes using "real world" scale pixel coordinates, the lights cast shadows properly, but I lose collision since the bodies are defined at pixel scale as opposed to the box2d scale I have defined.  Does anyone know why the box2dlights are using real world scale?

Here is my RayHandler Setup

RayHandler.useDiffuseLight(false);
rayHandler = new RayHandler(world);
rayHandler.setAmbientLight(.5f, .5f, .2f, 1f);
rayHandler.setBlurNum(1);
rayHandler.setShadows(true);

I have a PointLight that is positioned in the center of the screen.

PointLight pl = new PointLight(game.rayHandler, 128);
pl.setDistance(1000);
pl.setPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
pl.setColor(Color.WHITE);
pl.setSoftnessLength(0);
Filter filter = new Filter();
filter.categoryBits = B2DVars.CATEGORY_LIGHT; // Value listed below
filter.maskBits = B2DVars.MASK_LIGHT;         // Value listed below
pl.setContactFilter(filter);

Also, my body is defined as

body = world.createBody(squareBodyDef);
PolygonShape squareShape = new PolygonShape();
squareShape.setAsBox(b2dWidth / 2, b2dWidth / 2, new Vector2(squareBodyDef.position.x * WORLD_TO_BOX, squareBodyDef.position.y * WORLD_TO_BOX), 0f);
body.setUserData(this);

FixtureDef fdef = new FixtureDef();
fdef.shape = squareShape;
fdef.density = 10.0f;
fdef.friction =  0.1f;
fdef.restitution = 1.15f;
fdef.filter.categoryBits = CATEGORY_SQUARE_OBJECTIVE; // Value listed below
fdef.filter.maskBits = MASK_SQUARE; // Value listed below

body.createFixture(fdef).setUserData(this);
squareShape.dispose();

Finally, my box2d filtering constants

public static final short CATEGORY_BALL = 1;
public static final short CATEGORY_LINE = 2;
public static final short CATEGORY_WALL = 4;
public static final short CATEGORY_SQUARE_OBJECTIVE = 8;
public static final short CATEGORY_TRIANGLE_OBJECTIVE = 16;
public static final short CATEGORY_LIGHT = 32;

public static final short LIGHT_GROUP = 1;

public static final short MASK_BALL =
                CATEGORY_LINE |
                CATEGORY_WALL |
                CATEGORY_SQUARE_OBJECTIVE |
                CATEGORY_TRIANGLE_OBJECTIVE;

public static final short MASK_LIGHT =
                CATEGORY_LINE |
                CATEGORY_SQUARE_OBJECTIVE |
                CATEGORY_TRIANGLE_OBJECTIVE |
                CATEGORY_WALL;

public static final short MASK_SQUARE =
                CATEGORY_BALL |
                CATEGORY_LIGHT;

public static final short MASK_WALL = -1

I've been going non-stop for about 3 days trying to solve this problem to no avail.  Any help is appreciated!


texts:
I was wondering how my vertex shader is causing my cube to be render weirdly? I am using the Visual Studio graphics tool and see that my input assembler is correctly receiving the cube and I can only guess my issue is within my shader. I did enable device creation flags but nothing related to the issue.

//Constant Buffer Variables
cbuffer constantObjects : register (b0)
{
    matrix World;
    matrix View;
    matrix Projection;
}

// Input Structure
struct VS_INPUT
{
    float3 inputPosition : POSITION0;
    float4 inputColor: COLOR0;
};

// Output Structure
struct VS_OUTPUT
{
    float4 position : SV_POSITION;
    float4 color : COLOR;
};

VS_OUTPUT VS(VS_INPUT input)
{
    // Create Pixel Shader output
    VS_OUTPUT output;

    float4 pos = float4(input.inputPosition, 1.0f);

    // Multiple to get worldViewProject for object position
    output.position = mul(pos, World);
    output.position = mul(output.position, View);
    output.position = mul(output.position, Projection);

    // Simply set color to color;
    output.color = input.inputColor;

    // Return position and color to PS
    return output;
}

// Create World View
worldMatrix = DirectX::XMMatrixIdentity();

// Create view matrix
DirectX::XMVECTOR eyePosition = DirectX::XMVectorSet(0.0f, 1.0f, -5.0f, 0.0f);
DirectX::XMVECTOR targetPosition = DirectX::XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
DirectX::XMVECTOR upDirection = DirectX::XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);

// Store View Matrix
viewMatrix = DirectX::XMMatrixLookAtLH(eyePosition, targetPosition, upDirection);

// Create Projection Matrix
projectionMatrix = DirectX::XMMatrixPerspectiveFovLH(DirectX::XM_PIDIV2, (float)getHeight(), 0.01f, 100.0f);

It might be an issue with my world, view, and projection matrix but I don't really understand why that might be the issue. Here is the debug information. As you can see it goes to the input assembler correctly and has an issue with the vertex shader. Any help will be appreciated.


texts: Determining the price of a trade good depending on supply and demand of a marketplace

texts:
I've been meaning to add a market/trading system in my space-themed game where a player can buy from one station and sell it to another for profit, etc. (Examples would be Starsector, Elite: Dangerous, EVE Online)
The problem I've been having is actually determining the price of an item based on parameters like: Base Value, Supply, Demand, Transaction costs, Markup, and maybe others if I can think of them. I'm not particularly sure where to start with a price formula.
Any ideas on how to best decide on this?


texts: Offscreen arrow indicator appears only when the user go near to the object

texts:
I have placed four gameobject at different place.And I have a player and have applied movement to it through keyboard control.I have added script for arrow indication towords this gameobject.But the problem is that,the arrow appeaar only when the user go near to the gameoobject.I need the arrows to appear on the screen so that the user initially know where the gameobject is placed on the scene.

Here is the code for onscreen arrow.I have attached this script to each gameobject

public Texture2D icon; //The icon. Preferably an arrow pointing upwards.
public float iconSize = 50f;
[HideInInspector]
public GUIStyle arrow; //GUIStyle to make the box around the icon invisible. Public so that everything has the default stats.
Vector2 indRange;
float scaleRes = Screen.width/200; //The width of the screen divided by 500. Will make the GUI automatically
//scale with varying resolutions.
Camera cam;
public bool visible = false; //Whether or not the object is visible in the camera.

void Start () {
    visible = GetComponent<SpriteRenderer> ().isVisible;

    cam = Camera.main; //Don't use Camera.main in a looping method, its very slow, as Camera.main actually
    //does a GameObject.Find for an object tagged with MainCamera.

    indRange.x = Screen.width - (Screen.width / 6);
    indRange.y = Screen.height - (Screen.height / 7);
    indRange /= 2f;

    arrow.normal.textColor = new Vector4 (0, 0, 0, 0); //Makes the box around the icon invisible.

}

void OnGUI () {
    if (visible) {
        Vector3 dir = transform.position - cam.transform.position;
        dir = Vector3.Normalize (dir);
        dir.y *= -1f;

        Vector2 indPos = new Vector2 (indRange.x * dir.x, indRange.y * dir.y);
        indPos = new Vector2 ((Screen.width / 2) + indPos.x,
            (Screen.height / 2) + indPos.y);

        Vector3 pdir = transform.position - cam.ScreenToWorldPoint(new Vector3(indPos.x, indPos.y,
            transform.position.z));
        pdir = Vector3.Normalize(pdir);

        float angle = Mathf.Atan2(pdir.x, pdir.y) * Mathf.Rad2Deg;

        GUIUtility.RotateAroundPivot(angle, indPos); //Rotates the GUI. Only rotates GUI drawn after the rotate is called, not before.
        GUI.Box (new Rect (indPos.x, indPos.y, scaleRes * iconSize, scaleRes * iconSize), icon,arrow);
        GUIUtility.RotateAroundPivot(0, indPos); //Rotates GUI back to the default so that GUI drawn after is not rotated.
    }
}

public void OnBecameInvisible() {
    visible = false;
}
//Turns off the indicator if object is onscreen.
public void OnBecameVisible() {
    visible = true;
}

}

How can I make the arrows to appear on the edges of the screen


texts: What 3D engine should I use for the browser, iPhone, and Android platforms?

texts: I have a C++ game that has a 3D engine that works only in Windows. I'm wondering which engine I should use so that it can be used in a browser or in iPad (iPhone) and Android environments? Does anyone have an idea of the size of the task to migrate from one 3D engine to another?


texts: I'm currently trying out the various free SDKs out there (Cryengine3, UDK, Source) however all of them are mainly designed for FPS games. I was wondering if there are other AAA 3D engine SDKs that are aimed towards RTS games?


texts:
I create Pixmap in Actor and don't know how to dispose it. Is it necessary in my case?

class MyActor(x: Float = 0f, y: Float = 0f): Actor() {

    var pixmap = Pixmap(1, 1, Pixmap.Format.RGBA8888)
    var texture = Texture(pixmap)
    var sprite = Sprite(texture)

    init {
        setPosition(x, y)
        sprite.setSize(32f, 32f)
        sprite.setPosition(this.x - sprite.width/2, this.y - sprite.height/2)
    }

    override fun act(delta: Float) {
        sprite.setPosition(x - sprite.width/2, y - sprite.height/2)
    }

    override fun draw(batch: Batch?, parentAlpha: Float) {
        sprite.draw(batch)
    }
}


texts: What technology would you use to communicate between an iOS game and a Lua-based AI server?

texts:
What technology would you use to communicate between a two-player,turn-based, board game (like checkers or Othello) running native on iOS, and a remote game server

The remote game server is just the artificial intelligence portion of the computer player and it is coded in Lua.


texts: in XNA 4.0, How to get the matrix or Vector3 of a model?

texts:
I'm trying, for many days, to get the Matrix or the Vector3 of my 3D model, I don't want to use the World matrix because I need first to idenfy the axes of my object for animation (= rotation of a second object around my first object).

If you have an idea or a tutorial for this ?

Many thanks,

Jeangil


texts: Unrealistic sphere behavior on inclined plane

texts:
I am trying to model a ball rolling down an inclined surface in Unity based on what I am observing in real life but it is still quite off.

In Unity it takes the ball about 3 seconds to travel from a place to another specified place where in real life it only takes 1 second.
The ball isn't as fast to react to the incline as in real life (even though I have tried giving the ball and surface low or zero friction values).
The ball does not accelerate nearly as fast as it does in real life.

What do I do to give the ball more realistic behavior ? I have tried messing around with mass, physics materials, drag, and angular drag on the ball and surface but it doesn't seem to help.


texts: Efficiently transforming a series of points into curves to be serialized

texts:
I’m working on a video game where I need to display a map (in 2D) of an actual big European city (Paris, London, Madrid… that kind of big) and the player, displayed as a simple dot on the map, can take different routes while following the street lines.
To do so I extract real data from OpenStreetMap.org. Thanks to it I have access to a ton of data and geographic information, and among them I have street visual settings given as series of coordinates (long/lat converted to X/Y points using the right projection). In OpenStreetMap a street is composed of a set of points so drawing a line between these points is enough to display streets.
However it represents a huge number of points to load which means a lot of time spent processing the data which means: not ideal. For example, a big city like Paris is composed of 65.000 street points. That is huge. In order to reduce this number and still being able to draw / follow street curves I’m thinking about using a graph only composed of points implied in street intersections alongside curve equations to describe the street display. This way a street composed of 2000 points would be not much bigger than one composed of 10 points in theory.
Example

In this example my initial set is composed of 13 points (red crosses) to display a street. What I’m aiming to in this case is keeping only 4 points (intersections with other streets) and an actual “equation” (or something similar) between each couple of points in order to reduce the size on disk of the final map.
This is where I’m stuck. I suck at Math (and regret it every day). So I can’t figure what would be the best way to transform a series of points into a simple equation that would allow me to follow the actual street curve at runtime.
I don’t know how to do it… I’ve read things about Bezier curves, about Clothoids, Circular Arcs… but I don’t know where to start, what is the best solution here, how to convert my series of points using one of these techniques, or if it’s really the clever thing to do in order to reduce the size (in bytes) of the map…


texts: Implications of using a single ID3DXSprite object to render multiple images

texts:
I wanted to know if using a single Sprite object to render all 2D textures on screen is better than using one sprite for each 2D texture in performance.

EDIT:
Using single sprite refers to using a single ID3DXSprite Object to render all textures.


texts: Software rendering 3d triangles in the proper order

texts:
I'm implementing a basic 3d rendering engine in software (for education purposes, please don't mention to use an API). When I project a triangle from 3d to 2d coordinates, I draw the triangle. However, it's in a random order and so whatever gets drawn last draws on top of all other triangles (which might be in front of triangles it shouldn't be in front of)...

Intuitively, seems I need to draw the triangles in the correct order. So I can calculate all their distances to the camera and sort by that. The objects furthest away get drawn last. Is this the proper way to render triangles? If I'm sorting all the objects, this is n*log(n) now. Is this the most efficient way to do this?


texts: Reduce render time for a tiled map in ThreeJS

texts:
I'm working on a WebGL game using Three.js, its been a few days and I found my first issue, render time on big maps.

The game runs great, there are even some AI mobs that run around randomly like crazy, the problem comes when the game has to display many tiles at once (being many around 900 (30x30) on my Computer), if I zoom in the game runs at 60 solid FPS, here's the game demo so you can watch it in action.

http://kuxtal.oruga.biz/

You can move around with the classic WASD or arrow keys and zoom in and out with the MouseWheel.

Right now I'm creating a map like this (The project's code name is Kuxtal):

I have a singleton called Kuxtal, from which all the magic happens, I create a Kuxtal.Instance, which holds the renderer, scene, camera, and some functions to work with them.

Then I create a Kuxtal.Map, to which I pass the width & height as parameters and it runs:

for (var i = 0; i < this.width; i++) { // map.width
    for (var j = 0; j < this.height; j++) { // map.height
        var type = Math.ceil(Math.random() * 3); // 1-Grass 2-Dirt 3-Something else
        var tile = new Kuxtal.Tile(type, i, j);

        this.tiles.push(tile);
    }
}

This is my Kuxtal.Tile Class:

Kuxtal.Tile = function(type, x, z) {
    this.type = type;
    this.x = x;
    this.y = Math.random(); // A random elevation between 0 and 1 les me see the grid and looks nice
    this.z = z;

    this.sprite = new THREE.Mesh(new THREE.CubeGeometry(Kuxtal.TILE_SIZE, 1, Kuxtal.TILE_SIZE), new THREE.MeshPhongMaterial({color: 0xFFFFFF, map: Kuxtal.getTexture("grass")}));
    this.sprite.position.set(SELF.x * Kuxtal.TILE_SIZE, SELF.y, SELF.z * Kuxtal.TILE_SIZE);
    this.sprite.receiveShadow = true;= THREE.RepeatWrapping;
}

And the tiles are added to the scene on this Kuxtal.Instance.loadMap(map) function:

map.tiles.forEach(function(tile) {
    SELF.scene.add(tile.sprite);
});

Any suggestions on how to improve the performance?


texts:
Good day sirs, I know this is a newbie question but I really need to ask it. I've been reading a lot of sample codes on libgdx, and I have seen entities(player, enemy, boss,etc.).

my question is what should an entity class contain?as I have seen it contains states which i will use to animate my sprite, should I also put my inputs/controls, and animation in this entity class?


texts: When to use multiple parts for a mesh, and when to build detail in?

texts: I am always running into the decision whether or not to make a mesh one connected mesh or to add small details as just separate parts to the model. Is there a best practices for this? Does it matter for games either way?


texts: How do you prevent inflation in a virtual economy?

texts:
With your typical MMORPG, players can usually farm the world for raw materials essentially forever. Monsters/mineral veins/etc are usually on some sort of respawn timer, so other than time there really isn't a good way to limit the amount of new currency entering the system.

That really only leaves money sinks to try to take money out of the system. What are some strategies to prevent inflation of the in-game currency?


texts: Is this the correct way to detect ray-sphere intersection?

texts:
I have this java function that should return a true or false for any sphere passed to it if they intersect. However it seems to end being true a lot of the time when it shouldn't and false sometimes when it should be true.

It is possible however that i am passing incorrect data to the function. This was done with jPCT so the object SimpleVector is a vector with 3 variables.

public Boolean sphereIntersect(SimpleVector rayOrigin,SimpleVector rayDirection, SimpleVector sphereOrigin, float sphereRadius )
{
        SimpleVector Q = new SimpleVector(sphereOrigin);
        Q.sub(rayOrigin);

          float c = sphereOrigin.length();
          float v = Q.calcDot(rayDirection);
          float d = sphereRadius*sphereRadius - (c*c - v*v);

          if (d < 0.0){
              System.out.println("False");
          return false;
          }
          System.out.println("True");
          return true;

}


texts: How should I make (3D) buildings that can be entered in the game?

texts:
I have no idea about how would I make a building that can be entered in a game.
Should I model separate parts of it and than combine them or should I model the entire thing as one object?

Are these things are built up in a 3D modeller like blender or if not where?


texts: Collision detection - Smooth wall sliding, no bounce effect

texts:
I'm working on a basic collision detection system that provides point - OBB collision detection. I have around 200 cubes in my environment and I check (for now) each of them in turn and see if it collides. If it does I return the colliding face's normal, save the old player position and do some trigonometry to return a new player position for my wall sliding.

edit
I'll define my meaning of wall sliding: If a player walks in a vertical slope and has a slight horizontal rotation to the left or the right and keeps walking forward in the wall the player should slide a little to the right/left while continually walking towards the wall till he left the wall. Thus, sliding along the wall.

Everything works fine and with multiple objects as well but I still have one problem I can't seem to figure out: smooth wall sliding. In my current implementation sliding along the walls make my player bounce like a mad man (especially noticable with gravity on and moving forward).

I have a velocity/direction vector, a normal vector from the collided plane and an old and new player position. First I negate the normal vector and get my new velocity vector by substracting the inverted normal from my direction vector (which is the vector to slide along the wall) and I add this vector to my new Player position and recalculate the direction vector (in case I have multiple collisions).

I know I am missing some step but I can't seem to figure it out.

Here is my code for the collision detection (run every frame):

Vector direction;
Vector newPos(camera.GetOriginX(), camera.GetOriginY(), camera.GetOriginZ());
direction = newPos - oldPos; // Direction vector
// Check for collision with new position
for(int i = 0; i < NUM_OBJECTS; i++)
{
    Vector normal = objects[i].CheckCollision(newPos.x, newPos.y, newPos.z, direction.x, direction.y, direction.z);
    if(normal != Vector::NullVector())
    {
        // Get inverse normal (direction STRAIGHT INTO wall)
        Vector invNormal = normal.Negative();
        Vector wallDir = direction - invNormal; // We know INTO wall, and DIRECTION to wall. Substract these and you got slide WALL direction
        newPos = oldPos + wallDir;
        direction = newPos - oldPos;
    }
}

Any help would be greatly appreciated!

FIX
I eventually got things up and running how they should thanks to Krazy, I'll post the updated code listing in case someone else comes upon this problem!

for(int i = 0; i < NUM_OBJECTS; i++)
{
    Vector normal = objects[i].CheckCollision(newPos.x, newPos.y, newPos.z, direction.x, direction.y, direction.z);
    if(normal != Vector::NullVector())
    {
        Vector invNormal = normal.Negative();
        invNormal = invNormal * (direction * normal).Length(); // Change normal to direction's length and normal's axis
        Vector wallDir = direction - invNormal;
        newPos = oldPos + wallDir;
        direction = newPos - oldPos;
    }
}


texts: How can I run my XNA demo straight from a CD?

texts: I was told by a company that better than putting an installer on a CD would be allowing the user to run the demo directly from the CD. Is this even possible when the demo might require things such as the XNA framework to run? Are they actually wrong and an installer is in fact necessary for the dependencies?


texts: How are walkable regions determined, and movements handled on a 3D map?

texts:
I've created a 3D scene with both indoor and outdoor parts. The outdoor part has bridges and caves also.

How is it possible to handle player movements on it?

My intuition is: To determine the walkable regions, I could create a large grid. If the normal under the segment is not too steep, then it is walkable. If the difference between the heights of two neighboring segments in not large, then the player can move between them.

My solution is far from optimal. It would consume a lot of memory, and it can't handle situations, when there are multiple walkable regions on the same XZ position (for example a bridge over a valley)

How to manage movements effectively? How is it solved in game engines like Unreal or Unity?


texts: Is creating vertex/index buffer optimized this way?

texts:
I have some vertices in an array from which I create a vertex buffer. Let's say I have vertices:

v1, v2, v3, v4

I use indices:

0, 1, 2, 3

Is there any performance impact if I change the indices to

1, 3, 0, 2

(to have another geometry)? I just wonder whether the directx will iterate through vertices jumping to different addresses in a memory to get vertices (not linearly) or maybe the directx is able to recreate the vertex buffer (before it is sent to the graphics card) to suit the indices like this (it could then iterate it linearly):

v2, v4, v1, v3

(beacuse it is obvious that is is better to iterate through data put linearly in a memory)?

Is the question understandable?


texts: I need to create a c++ native plugin for my game. If I want to support macOS and Windows, do I need to write my plugin twice - one in XCode with a bundle project and another in VS for windows or is there a way to support both with one codebase?


texts: If Windows 10 store games aren't crackable, why continue to publish on Steam?

texts:
I never heard that any of those games that are exclusively sold on the Windows 10 store have ever been cracked. But some games on Steam are cracked days after release, even with the protection of something like Denuvo.

Given that, why should a game developer continue to sell games on Steam instead of just selling on the Windows store exclusively?


texts: Creating a model procedurally through coding?

texts:
Possible Duplicate:
  Creating a basic character skeleton from code

I'd like to have a procedural system that uses a string of data to create a 3d creature. The way I've thought to do this is to use the code to generate a simple creature frame, and later add something to add additional detail.The goal is to create creatures of different forms and frame. The creation will be mirrored down the spine so both sides are the same.

I assume it will work best to generate it like bones so the code would have information used to show what type of bone it was(hierarchy), the bone length, and how the bone was positioned and use this to make the model. (At least in planning, I don't know how to implement it)

I'd like it to be highly adaptable but I'd like to specify a max of 4 legs and 4 arms (8 limb max only 4 on ground for walking). Being able to create a basic structure for humanoids, quadrupeds, and mixes (like a centaur or biped with no arms) is the goal.

I've looked into turtle graphics, l-systems, metaballs, and FReps. But I still don't know what to use. How can I use a set of data to generate the simple 3d frame?


texts: How to make texture for text displaying using SDL ttf with good performance?

texts:
In my game, there are many units and for each units there's an information widget attached next to them. I use SDL as the game rendering engine.

I currently want to display their ID for debugging purposes.

However, for each unit, I create a texture with their ID, I render it, then I destroy it.

Needless to say that when there are about 40 units on my screen, the game gets pretty laggy (if its any indication, my game currenly weights 25 MB)

How can I get over this?


texts: How do I move a Unity object with velocity instead of force?

texts:
I have a 2d car in Unity that I want to move, but Unity does this using relative force & I want to use velocity.
As we know if we add force, an object will move and never stop. I want to use velocity to control movement, because then the car will stop when its velocity is zero.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GamePlay : MonoBehaviour
{
    public GameObject player;
    public Rigidbody2D rb;
    public float speed, steering;
    void Start()
    {
    }
    void FixedUpdate()
    {
        rb.AddRelativeForce(Vector2.up * speed);
        // rb.velocity = Vector2.up;
        Touch touch = Input.GetTouch(0);
        if (Input.touchCount > 0)
        {
            if (touch.phase == TouchPhase.Moved)
            {
                // Vector2 v = Camera.main.ScreenToWorldPoint(touch.position);
                float pos = touch.position.y;
                player.transform.Rotate(0, 0, pos - steering);
            }
        }
    }
}


texts: libGDX/HTML5 game sounds doesn't work on iPhone

texts:
I have a libGDX/HTML5 project that works well on desktop browsers, but on mobile browsers it has problems.

I can have some sounds on Android browsers (not perfect) but on iPhone browsers it doesn't work at all.

I don't know exactly which part of the project to put in here. There is an mp3 file to be played at menu screen, "music.mp3". I use:

import com.badlogic.gdx.audio.Music;
...
public class MyGame extends ApplicationAdapter {
...
private Music music;
...
@Override
    public void create () {
    ...
         music = Gdx.audio.newMusic(Gdx.files.internal("music.mp3"));
         music.setLooping(true);
         music.setVolume(0.1f);
         music.play();
    ...
    }
}

I would appreciate any help.


texts:
If I have a buffer with my vertices, normals and texture coordinates, and I use glDrawArrays to draw the VBO to the screen, how can I send attributes per vertex that I placed in an array to the shader program? I'm making a voxel terrain, and every chunk is 1 VBO, this works all great, but I want to send the light value of each block (Just an array filled with int's) to the shader as well, how would I do that?

Edit: After reading some comments, here some clarification:
I'm trying to avoid the deprecated glVertexPointer etc, so I'm using Vertex Arrays. Here is the layout of my vertex array:

X, Y, Z, NX, NY, NZ, X, Y, Z, NX, NY, NZ,X, Y, Z, NX, NY, NZ

I'm using this to draw it: (ofcourse with the array buffer bound)

glVertexAttribPointer(0, 3, GL_FLOAT, false, 12, 0);
glVertexAttribPointer(1, 3, GL_FLOAT, false, 12, 12);

glDrawArrays(GL_TRIANGLES, 0, arraySize / 6);

However I get some weird shapes on my screen. Apart from the light problem, that is essentially the same thing, I don't get why this doesn't just work. When I remove the normals, and use just 1 vertexattribpointer it works fine. Yes, the attributes are bound to in_position and in_normal, and the vertex shader is nothing more than gl_Position = gl_ModelViewProjectionMatrix * vec4(in_position, 1.0);

Thanks!

This is what I get:

(This are 6X6 chunks, so this code is called 6*6 times.)


texts: Help creating combat for collection type game

texts:
sorry for my odd terminology, I am rather new to all this

I'm creating a collection/pokemon type game. as of right now I have created a separate GameObject prefab for every monster/character in the game. Each gameobject contains a script with enumerated values for it's stats. When combat begins It calls a random monster from a pool of gameobjets. The problem is at this point I'm not sure how to have it create a new instance of the enemy in a way where it retains the values in it's public floats from the prefab or have it's level be adjusted as it enters. And I don't know how I can derive it's stats and properties for scripts outside the function that spawned it. as the function that creates the new duplicate won't remember the new creature after the function resolves.

so In short, How can I reference the enumerated integers of a newly duplicated gameobject

I was asked to include some more information on what I've coded:

public List<baseMonsters> allMonsters = new List<baseMonsters> ();

public void EnterBattle(Rarity rarity)
{
    // this code swaps camera view to the battlefield from the overworld map
    playerCamera.SetActive(false);
    battleCamera.SetActive(true);

    // call function to determine which monster appears
    baseMonsters battleMonster = GetRandomMonsterFromList(GetMonsterRarity(rarity));

    // returns which monster was chosen
    Debug.Log (battleMonster.name);

    // prevents the player from moving after combat begins
    player.GetComponent<PLayermove>().isAllowedtoMove = false;

    //Creates the defending monster
    GameObject dMon = Instantiate (emptyMon, defencePodium.transform.position, Quaternion.identity);
    //Ensures scale from original is preserved
    dMon.transform.localScale = battleMonster.transform.localScale;

    Vector3 MonLocalPos = new Vector3 (0, 1, 0);
    dMon.transform.parent = defencePodium;
    dMon.transform.localPosition = MonLocalPos;

    //Adds the stat components of the original prefab
    baseMonsters tempMon = dMon.AddComponent<baseMonsters> () as baseMonsters;

    tempMon = battleMonster;

    dMon.GetComponent<SpriteRenderer> ().sprite = battleMonster.image;
    bm.ChangeMenu (BattleMenu.Selection);

}

the issue that I see with the code is that it's transforming an already existing object into what the prefab monster is, not copying it. what method can I use to copy the prefab in a way I can easily reference in the same function to change it's level?

-Update-

ok so changing everything over to instantiating a GameObject is what I want. now there is the other part from the code before:

public List<baseMonsters> GetMonsterRarity(Rarity rarity)
{
    List<baseMonsters> returnMonster = new List<baseMonsters> ();
    foreach (baseMonsters Monster in allMonsters)
    {
        if (Monster.rarity == rarity)
        returnMonster.Add (Monster);
    }
    return returnMonster;

}
public baseMonsters GetRandomMonsterFromList(List<baseMonsters> monList)
{
    baseMonsters mon = new baseMonsters ();
    int monIndex = Random.Range (0, monList.Count - 1);
    mon = monList [monIndex];
    return mon;
}

I was following a tutorial when I created this code, I am starting to understand more and more how spaghetti it is.
sorry for all the Alike Terms, baseMonsters is a class that houses things like the rarity and stats of the monster. These functions are searching by and for that script. How can I convert these codes over to searching the class from a list, to a Gameobject from a list, and still be able to read baseMonsters of each respective GameObject and it's rarity int?
 as of right now, one workaround I can think of is to create a seperate list for each rarity. that way I can skip needing to read the rarities in the baseMonsters script entirely. But I will still need to know how I can call that class script for other things like determining level of the monster and what it's attacks will be?


texts: Why is there a difference in frame rate between my fps calculation and Unity's calculation

texts:
So I wrote my own script for calculating framerate but it consistently comes out with a different value than Unitys idea of current framerate.

This is my implementation

  void UpdateFPSStats()
{
double frameTime = new double();
frameTime = Time.deltaTime;
m_times[frameIndex] = frameTime;

frameIndex++;

if (frameIndex == m_numberFrames)
{
  frameIndex = 0;
}

int numberSamples = 0;
double averageFrameTime = 0.0f;
foreach(double t in m_times)
{
  numberSamples++;

  averageFrameTime += t;
}

if (numberSamples > 0)
{
  averageFrameTime = averageFrameTime / numberSamples;
  m_frameRate = 1 / averageFrameTime;
}
}

where m_frames is a list of the last 60 frames frame times and UpdateFPSStats is called in Unitys Update(dt) function.

On average in my scene my fps calculation gives a steady 50fps, while Unity calculates a steady 80fps.

Which is right and why?


texts:
I am getting the following error ONLY when running my game in Firefox (3.6)

  Component returned failure code:
  0x80040111 (NS_ERROR_NOT_AVAILABLE)
  [nsIDOMCanvasRenderingContext2D.drawImage]

The issue does not occur in the other major browsers, and my game runs completely fine after I click 'OK.'

Here are a few snippets of code where I have localized the issue to.  Has anybody seen this issue before?  According to Google it has something to do with drawing the image before it is loaded, but from my understanding I am loading it properly before using it!.

player class

var player = new (function(){
  var that = this;
  that.image = new Image();
  that.image.src = "res/enemy1_sprites.png";
  that.width = 16;
  that.height = 16;
  that.frames = 2;
  that.actualFrame = 0;
  that.spriteXoffset = 0;
  that.spriteYoffset = 0;
  that.moved = false;
  that.boundary = false;
  that.num_balls = 5;
  that.rootX = 350;
  that.rootY = 250;
  that.ballX = [that.rootX,0,0,0,0];
  that.ballY = [that.rootY,that.rootY,that.rootY,that.rootY,that.rootY];

  that.directions = {"up":0, "right":1, "down":2, "left":3};
  that.dirs  = [that.directions.right,that.directions.right,that.directions.right,that.directions.right,that.directions.right];

  for (i = 1; i < that.num_balls; i++)
    that.ballX[i] = that.rootX - (i * that.width);

...
...

that.draw = function(){
    try {
      for (var i = that.num_balls-1; i >= 0; i--)
      {
        // update animation
        switch (that.dirs[i])
        {
          case that.directions.left:
            that.moveLeft();
          break;
          case that.directions.right:
            that.moveRight();
          break;
          case that.directions.up:
            that.moveUp();
          break;
          case that.directions.down:
            that.moveDown();
          break;
        }
        ctx.drawImage(that.image, that.spriteXoffset, that.spriteYoffset, that.width, that.height, that.ballX[i], that.ballY[i], that.width, that.height);
      }
    }
    catch (e) {
      alert(e.message);
    };

    if (that.moved)
    {
      if (that.spriteYoffset > 0)
        that.spriteYoffset = 0;
      else
        that.spriteYoffset += 16;
      that.moved = false;
    }
  }
})();

game loop

 var GameLoop = function(){
    ..
    ..
     player.move();
     player.draw();
    ..
    ..
      if (state)
        gLoop = setTimeout(GameLoop, GAME_SPEED);
    }


texts:
I wonder what the best way is to move the player. Is it best to always check for movement like I do in the first example of is it better to only access the movement function via the input function like the 2nd example?

-EXAMPLE 1-
while(running)
{
    while(event)
    {
      player.input();
    }
    logic();
    render();
}
logic()
{
    player.move();
}

-EXAMPLE 2-
while(running)
{
    while(event)
    {
      player.input();
    }
    logic();
    render();
}
player.input()
{
    player.move(direction);
}
player.move(int dir)
{
    if(dir == left)
    {
        xvel += 1;
    }
}

I hope I explained it right. Thanks in advance.


texts: Jagged Edges Even With Anti Aliasing 8x Multi Sampling

texts:
I have an interior scene where I have imported a model for the apartment and many of the interior objects such as lamps, windows, etc. Unfortunately I have a lot of jagged edges on almost all the objects in my scene even on Fantastic Quality settings with Anti Aliasing pushed to its maximum. What else can I do to reduce the jaggies seen here:

Here are my quality settings:

And here are my model import settings:


texts: Find index of GameObject in array of GameObjects

texts:
In my script, i have declared an array of GameObjects like this:

public GameObject[] go;ld object name. `String temp;`

Also, i have a temporary variable to ho
Then, i assigned objects to elements in Inspector.

I'm using Raycasting to find which object was clicked. Block of code for handling Raycast:

Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
        RaycastHit2D hit = Physics2D.Raycast (ray.origin, ray.direction, Mathf.Infinity,layerMask);

        if (hit) {
            temp=hit.collider.gameObject.name;
            index=ArrayList.IndexOf(go,GameObject.Find (temp));

                }

Ray casting works well. It will print object name if i insert a Debug.Log. However, what i want to do is, find the GameObject's index in the array "go".
I need this index because i have another boolean array isSelect[] which, has a property that needs to be set to true when the corresponding GameObject is selected.

With the IndexOf code above, i get the following error:

An object reference is required to access non-static member `System.Collections.ArrayList.IndexOf(object)

What changes do i need to make to this code?


texts: How to create a material that blends textures in Blender to Unity workflow

texts:
I'm new to Blender and Unity and trying to figure out the best way to create a material that will use either vertex colors or a texture map to interpolate between other textures on a single mesh.  This is the sort of effect you might use when you want to have a big grassy terrain mesh with a dirt path running down the middle of it and patches of rock here and there - and instead of modeling each of those as separate pieces, you create a single shader that takes a grass, dirt and rock texture map and uses a fourth blending map to decide which to sample from.

I come from a Maya background which provides an HLSL material shader that makes this straight forward.  It's not as clear to me how to do this in Blender, and in particular the best way to set it up so that it imports into Unity cleanly.  I suspect that setting up the shader using Blender's cycles shading network won't create anything Unity can recognize.  Blender also has the Open Shading language, but again I'm unsure how well this will work with Unity.

I could also bake all my textures, but this strikes me as wasteful of memory and bandwidth.

I have experience with both HLSL and GLSL.  Is trying to do this with custom shaders the best way to do about things?  What's the best way to set things up so that both Blender and Unity are happy?


texts: What causes the difference between these boxes?

texts:
I have recently started using Blender and I notice that the light (from my game) on default box is different from the one I downloaded. The below picture shows that.

They have the same normal direction in Blender.
Thanks in advance.


texts: In very simple 3d racing games, how are collisions handled?

texts:
I was wondering how collisions in some simple 3d car racing games are done (especially in games like Outrun 2/Motoracer).

In classic car racing games with complex environment (open world), I guess this is done with a basic box (for the car) to plane collision (for track, buildings an other stuff). The whole thing would be optimized using some bounding boxes (this is the way collision is done in many games).

In a game like Outrun 2/Motoracer, the gameplay is so simple that developers maybe dont need that and everything could have been simplified a lot. For those who never play it, here is what is so specific :

The car/bike is always glued on the road.
The road is always same size and have a very simple shape.
The only possibilities is to follow that road, its not possible to leave the road, or to get in collision with something else (except other cars/bikes but we don't care).
When you collide with the road, very basic arcade collision is done (the car is simply pushed away from it)

Here is how i think collision (could) have been done :

The whole track could be considered as giant a 3d bezier curve. From that curve, the road polygons could be generated (using front, left and up vectors generated from curve). Other elements (like houses, trees, ...) could be also placed and aligned using this method.

Then, to handle the collisions (and draw car) :

1) Find closest position on 3d curve from current car 3d position. In other words, transform 3d car position to bezier curve position. Every 3d position on the road could be considered as a displacement along 3d curve (t) + lateral displacement (d). Check image below if it is not clear (this is a 2d example but this apply to 3d easily).

  when t = 0 car is at beginning of track section, when t = 1 car is at
  the end. when d = -1 or 1 car is at border of track, when d = 0 car is in
  the middle of the road

2) align the car to the road using t and d (very simple : for any t and d values i can get a 3d position + up/front/left vectors). the car is now glued on the road

3) check lateral displacement d of car. if value is too big (d > 1) or to low (d < -1) car is away of track. just clip it to put car in correct place.

This also make 3d culling very simple, just draw the track from current car t position to t + some_big_enough_value_to_avoid_visible_clipping.

Or maybe i'm completly wrong : it would have been lot faster and simpler to just check collision of the car (a bounding box) and a very simplified set of polygons that represent the track (without the buildings and such). The 3d world (and the resulting colision model) would have simply  been generated before, using some 3rd party tool (no more 3d curve when running the game, just a bunch of polygons).


texts: First Steps. Windows Phone game development

texts:
I'm pretty new in game development. Have a couple ideas wich could be cool. First that comes to mind is to develop a 2D game (kinda puzzles) for Windows Phone Mango. You may ask: "Why Windows Phone?". I answer - I've got solid experience in Silverlight and C#. For me, this is a major advantage compared to other platforms.

Please, give advice and suggestions about:

What should I read?
Best practices.
Third party libraries.
Silverlight(Only) vs XNA.
Whatever I should pay attention to.


texts: Rotate camera keeping player not in the middle

texts:
Here I have a 2D top down game. Currently the camera is set on the player position.
The player constantly points to mouse position.

I want to modify this setup having the camera to be set slightly forward in the player.transform.up direction but when I try it as the mouse gets closer to the character it starts looping because as the mouse approache, the camera turns but also change the mouse position so the camera needs to turn again, and so on.

this is the camera update

transform.position = new Vector3 (player.transform.position.x, player.transform.position.y, -10) + player.transform.up * camDistance;

and this is how the mouse position gets updated

mousePos = Camera.main.ScreenToWorldPoint (new Vector3(Input.mousePosition.x, Input.mousePosition.y, -5)) - transform.position;

any clue?


texts: Detect when an Oculus headset is stationary/idle using transform.hasChanged

texts:
I want to know how can I change in unity the thershold of the method below:

  transform.haschanged

At the moment it is so sensitive and it triggers with 0.00001 change in the camera.

We have created an Interactive VR video in unity and we want that everytime the user doesnt use the oculus for 30 seconds, a trailer video starts to play!

We have created the code below but even when the oculus is on the ground, still moves a bit (too sensitive):

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

public class Trailer : MonoBehaviour
{

public int timeOut;

private int timeOutTimer = 0;

private Quaternion gameObjectrotation;
private VideoPlayer videoPlayer;
public float dynamicRange = 100f;

// Use this for initialization
public void Awake()
{
    Vector3 lastPos;
    videoPlayer = GetComponentInParent<VideoPlayer>();
    gameObjectrotation = Camera.main.gameObject.transform.rotation;

    InvokeRepeating("ScreenSaver", 0, 1.0f);
}

public void ScreenSaver()
{

    timeOutTimer++;

    var wMinus = gameObjectrotation.w - dynamicRange;
    var wPlus = gameObjectrotation.w + dynamicRange;
    var xMinus = gameObjectrotation.x - dynamicRange;
    var xPlus = gameObjectrotation.x + dynamicRange;
    var yMinus = gameObjectrotation.y - dynamicRange;
    var yPlus = gameObjectrotation.y + dynamicRange;
    var zMinus = gameObjectrotation.z - dynamicRange;
    var zPlus = gameObjectrotation.z + dynamicRange;

    var cameraW = Camera.main.gameObject.transform.rotation.w;
    var cameraX = Camera.main.gameObject.transform.rotation.x;
    var cameraY = Camera.main.gameObject.transform.rotation.y;
    var cameraZ = Camera.main.gameObject.transform.rotation.z;

    if (cameraW >= wMinus && cameraW <= wPlus && cameraX >= xMinus && cameraX <= xPlus && cameraY >= yMinus && cameraY <= yPlus && cameraZ >= zMinus && cameraZ <= zPlus && timeOutTimer >= timeOut)
    {
        //Show video
        videoPlayer.gameObject.SetActive(true);
        videoPlayer.Play();
    }
    else
    {
        //Hide Video
        videoPlayer.gameObject.SetActive(false);
        videoPlayer.Stop();
        videoPlayer.frame = 1;
    }

    if (cameraW > wPlus || cameraW < wMinus || cameraX > xPlus || cameraX < xMinus || cameraY > yPlus || cameraY < yMinus || cameraZ > zPlus || cameraZ < zMinus)
    {
        timeOutTimer = 0;
    }

    gameObjectrotation = Camera.main.gameObject.transform.rotation;
}
}

Any help would be appreciated!
Cheers


texts: 3D tilt angle for an arrow in archery game

texts:
How can I calculate the angle of rotation/tilt of an arrow in 3D?

When I say angle I mean the angle the arrow takes when it flies through the projectile path.

I am using logic given in the below link to calculate the location in the 3D space

http://babek.info/libertybasicfiles/lbnews/nl130/proj3d.htm

and also OpenGL for rendering


texts:
1 - Does Blender have a main menu, and if so, how do I make it appear? This is what I'm looking at currently:

http://imgur.com/wbowyco

2 - Also, that text panel at the top, that is as large as I can make it. Is there any way to make it taller? Or change the panel layout...?


texts: A good beginners' game engine to run on linux

texts:
I am involved with a research that deals with 3D graphics. I am very new to 3D graphics. In my research I have to move a 3D object based on some information queried by processing a video. Viewer's only interaction with the 3D environment is, changing the camera viewpoint.

I am not that worried about the speed or efficiency at this level. What I need is easy to learn and easy to program 3D game engine, I suppose.

I'd like to know about any open 3D model file format supported by the game engine, as I will have to use custom made 3D models using 3D modelling techniques of computer vision.

I tried Panda3D, but the most significant drawback was it's inability to use .max files directly (most of the 3D models available were of this format). Panda3D was quite simple when it came to scripting.

Thank you in advance.


texts: Level editing using a 2D map for a 3D game

texts:
We're trying to make a level editor for a 3D game that involves walking around outdoor environments. In many ways a heightmap satisfies the game's needs, but it also falls short in several ways, so we're considering various enhancements to the heightmap concept, but it's proving difficult to find a simple solution to this problem.

For a start, a heightmap has great difficulty with sharp edges. As long as everything is smooth a heightmap looks wonderful, but it becomes jagged around vertical cliffs, along the edges of roads, and anywhere the resolution of the heightmap becomes relevant. The obvious solution to these issues is to add a layer of vector drawing on top of the heightmap, so we can preciously define the curves of vertical cliffs and roads, and use this to insert specialized polygons into the terrain's mesh. A vertical cliff can even be a simple gap in the terrain mesh that can be filled by another mesh which allows us to render the cliff face however we like, bypassing the limitations that heighmaps usually have.

Another issue with heightmaps is the difficulty of drawing smooth slopes by hand. For the purposes of the game, terrain should either by a gentle slope or a vertical cliff, so there is no ambiguity over whether the player can traverse through it. We could scan the heightmap to detect overly steep slopes and show an error message, but what we really want to do is give the user drawing tools that will only draw acceptable slopes. But how can this be done?

Perhaps the traditional raster heightmap is causing more problems than it is solving, so an entirely different kind of heightmap is called for. Perhaps instead of adding a vector drawing layer, the whole heightmap was done as a vector image and represented as a set of polygons with each polygon having a certain elevation. This way we get smooth curves automatically, and creating meshes for vertical cliffs and flat land is trivial, but representing slopes in the editor and rendering them becomes a challenge.

We've considered a blending tool that would draw polygons on a second layer, and wherever these blend-polygons appear the underlying terrain polygons would smoothly merge together. Polygons that have shared edges would from a slope perpendicular to those edges at an angle that makes the slope walkable. Unfortunately working out the geometry of the resulting mesh is difficult, and it means that cliffs are the default for every change in elevation.

Since it seems more natural for the user to draw lines to block the player's passage rather than drawing the places where the player can traverse, another approach is to have the user draw the cliff lines in another layer just as with the raster heightmap, but now those cliff lines would act to stop the terrain from smoothing itself into pure rolling hills. Imagine each polygon of the heightmap as a pillar of sand with vertical sides, and when a mesh is formed from the map the sand flows out of its pillars, forming smooth slopes in every direction except where it encounters a cliff line and is forced to flow around. Everywhere except the cliffs need to be a gentle enough slope to walk up, so when there is a gap in a cliff the sand needs to flow through and spread out on the other side. We have some ideas about how this might be done, but it's still a major challenge to implement.

Finally, we could just use a grid with sloped blocks to represent slopes. Editing would be easy, generating the mesh would be easy, all the problems would be solved, but being confined to a grid would surely sacrifice the freedom we'd hoped to have. We don't want to be constrained to being axis aligned unless no other solution is practical.

Ultimately the question is: are there practical ways to implement any of the approaches we're considering, or are we coming at this from entirely the wrong direction?


texts: How to get `Label::createWithTTF` to support RTL languages such as Arabic

texts:
Firstly, I'm using Cocos2d-x v3.6, Visual Studio 2013 uses(UTF-8 without signature option) and C++.

When using Label::createWithTTF method to write Arabic text, It appear like the following.

The previous arabic text has not been written correctly, It was supposed to look like this السلام عليكم, and it also supposed the Arabic language belong to Unicode encoding.

My code:

auto label = Label::createWithTTF("السلام عليكم", "fonts/arial.ttf", 34);

Is there any way to solve that problem ?

Edit:

I have applied what in this link [ Right-to-left mark  ] and the result was disappearance the Arabic text as in the following picture.

The code:

auto label = Label::createWithTTF("\u200fالسلام عليكم", "fonts/arial.ttf", 34);
label->setAlignment(TextHAlignment::RIGHT);

The problem still exists.


texts: How do I convert screen coordinates to isometric tile map coordinates in libGDX using matrices

texts:
I know this has been asked many times but my question doesn't quite fit the others. I have an IsometricTiledMap and I need to get the tile under a set of screen X and Y coordinates. Here is a picture of my game:

I need to get the tile that the player is standing on. I need to convert screen coordinates to isometric tile coordinates and the way that seemed the easiest was by using a matrix as described here: http://www.alcove-games.com/advanced-tutorials/isometric-tile-picking/#comment-56390

Unfortunately I have no idea how to change that code to fit a 128x64 tile instead of a 1.0x.5 tile. Here is my code

isoTransform = new Matrix4();
isoTransform.idt();
isoTransform.translate(0.0f, 32f, 0.0f);
isoTransform.scale((float) (Math.sqrt(2.0) / 2.0), (float) (Math.sqrt(2.0) / 4.0), 1.0f);
isoTransform.rotate(0.0f, 0.0f, 1.0f, -45.0f);

invIsotransform = new Matrix4(isoTransform.inv());

//touch vector
touch = new Vector3();

@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    touch.set(screenX, screenY, 0);
    touch = gameCamera.unproject(touch);
    touch.mul(invIsotransform);

    pickedTileX = (int)touch.x / 64;
    pickedTileY = (int)touch.y / 32;

    debug(touch.x + " " +  touch.y);
    debug(pickedTileX + " " + pickedTileY);

    return false;
}

I think the problem is in this line isoTransform.scale((float) (Math.sqrt(2.0) / 2.0), (float) (Math.sqrt(2.0) / 4.0), 1.0f); but I'm not sure what to change.


texts: SetColorMod() with mini delay when the texture is rendered for the first time

texts:
I have one image.png that I load using SDL_IMG. I load by creating a surface. Then I create a texture using CreateTextureFromSurface() and I free the original surface. I repeat the same process but now at the end I use SetColorMod(128, 128, 0) to this new texture. This changes the color of the image as I wanted! Cool!

This whole process is done way before the images are rendered to the screen. The original texture (without the color change) is rendered normally. The texture with the color change creates a mini delay when rendered for the first time. After that it keeps rendering without any delay.

I’m using SDL 2.0.2 (I’m using ubuntu 14.04)

A quick preview of the code to give an idea of what is happening

// load function
func load() {
    newSurface, err = img.Load(fname)
    defer newSurface.Free()
    newTexture, err = renderer.CreateTextureFromSurface(newSurface)
    return newTexture
}

// pre load
func init() {
    sprite1 := load()

    sprite2 := load()
    sprite2.SetColorMod(128, 128, 0)
}

// render...
func render() {
    Renderer.Clear()
    //loop for each object
    obj1 := sprite1
    obj2 := sprite2
    Renderer.CopyEx(obj1, &crop, dst, render.Angle, render.Center, render.Flip)
    // LAG HERE
    Renderer.CopyEx(obj2, &crop, dst, render.Angle, render.Center, render.Flip)
    Renderer.Present()
}


texts:
How can one store chunks in such a way that they can be looked up using their XYZ location without wasting memory?

The problem with a HashMap<Vector3i, Chunk> is that you have to keep creating Vector3i objects, just to use them in the lookup.

I am basically looking for a solution that does not involve the creation of an object to perform a lookup.


texts: How do you calculate the rate of rotation using the accelerometer values in Android for a particular axis?

texts:
I am developing a simple game which involves a character moving up and down only along the Y axis.

Currently I am using the accelerometer readings to change the Y velocity of the character. The game works fine but the biggest problem is that you have to keep the device horizontal in order to play the game properly.

What I really want is to change the characters Y velocity only when there is a change in the rate of rotation along the Y axis. I need to be able to translate this rate of change into the Y velocity of the character. In this way it will not matter how much the device is tilted and the user can play the game while holding the device normally.

Since the accelerometer is mandatory in every device, therefore older devices can run my game I want to be able to calculate this rate of change using the data retrieved from the accelerometer.

I found a link which explains how to get pitch and roll from accelerometer data. I used the exact code and came up with this,

final double alpha = 0.5;
double fXg = 0;
double fYg = 0;
double fZg = 0;
fXg = game.getInput().getAccelX() * alpha + (fXg * (1.0 - alpha));
fYg = game.getInput().getAccelY() * alpha + (fYg * (1.0 - alpha));
fZg = game.getInput().getAccelZ() * alpha + (fZg * (1.0 - alpha));
double pitch = (Math.atan2(-fYg, fZg) * 180.0) / Math.PI;
double roll = (Math.atan2(fXg, Math.sqrt(fYg * fYg + fZg * fZg)) * 180.0) / Math.PI;
pitch = (pitch >= 0) ? (180 - pitch) : (-pitch - 180);

With this piece of code I am unable grasp how to calculate the RATE of change.

Am I going in the right direction with this or is this completely different from what I want?

Also is it better if I just use the gyroscope instead of relying on the accelerometer?

Thanx in advance.


texts: Game Maker Language's random function always giving the same result

texts:
I'd like to create a Snake game, and for that, I'd like to position the sweet which makes the snake bigger in a random position.

For that, I use this code in the create event of the object bonbon :

position_x = round(random(10));
position_y = round(random(10));

x = position_x*16;
y = position_y*16;

But the sprite of this object is always in the same position of the room.

I tried changing the argument to the function random(), and then it changed the position of the sweet once, but after a rerun, the position doesn't change from that new location.

I think the position of the sweet is set using the argument to the random() function.

How can the position of the sweet be randomized?
Why does the random function return the same values every time I run the game?

Thanks to DMGregory, I changed the code and this code works :

randomize();
position_x = irandom(10);
position_y = irandom(10);

x = position_x*16;
y = position_y*16;


texts:
I have started working on the AI for a game, but am confused how I should handle animations.  I will be using a Behavior Tree for AI behavior and Cocos2D for my game engine.

Should my "PlayAnimationWalk" just be another node in the tree?

Something similar to this:
[Approach Player]
- Play Walk animation
- Move Towards player
- Stop Walk animation

Or should the node just update an AnimationState in the blackboard and have some type of animation handler/component reference this for which animation should be playing?

This has been driving me nuts :)


texts: x-inverted obj importer in BulletSharp - what's wrong?

texts:
See [dead link removed] at the repository.

Screenshot:

[broken image removed]

Left: bullet imported version, right: correct 3ds max version.

It's somehow inverted. If you think that left part is just 180 degrees rotated you are wrong. Just rotate it yourself in Paint and you'll see - they will be different.

What's wrong with the bullet importer?

Usage:

        var wo = new WavefrontObj();

        int tcount = wo.LoadObj(path);

        Vector3 localScaling = new Vector3(1, 1, 1) * 1f;

        var vertices = wo.Vertices.Select(v => Vector3.Modulate(new Vector3(v.X, v.Y, v.Z), localScaling)).ToArray();
        var indices = wo.Indices;

        if (tcount > 0)
        {
            var trimesh = new TriangleMesh();
            int i;
            for (i = 0; i < tcount; i++)
            {
                int index0 = indices[i * 3];
                int index1 = indices[i * 3 + 1];
                int index2 = indices[i * 3 + 2];

                Vector3 vertex0 = vertices[index0];
                Vector3 vertex1 = vertices[index1];
                Vector3 vertex2 = vertices[index2];

                trimesh.AddTriangle(vertex0, vertex1, vertex2);
            }
            CollisionShape concaveShape = new BvhTriangleMeshShape(trimesh, false);
            CreateRigidbody(transform.Position, transform.Rotation, concaveShape);
        }

I tried to import with Assimp and got the same result. So the importer is correct but something inside the bullet mirrors it.


texts: How can I make sure multiple player scripts all get the same amount of execution time per game tick?

texts:
I'm looking for a way to allow players  to write code in a high level language, but I need to be able to keep all script instances synchronized in terms of script execution time per game tick so that no player gets an advantage.

The purpose for this is a simulation in which there are many bots scripted by several people, and the bots are in competition. The idea is to have a level playing field by advancing the execution in a controlled way so that no bot can gain an advantage.

This also has to be synchronized in a meaningful way with the rest of the simulation/physics. Having control over granular execution steps seems like one way to do this, although I'd be open to other potential solutions. In other words, if i made up my own assembly language and associated interpreter, I could control execution granularly,  but besides being a significant undertaking, assembly languages are far more difficult to work with then high level ones.

Here are some ideas I've come up with :

If there is a way for each bot to run a simple OS/VM, that could work, provided the OSes can be instantiated, controlled/execution time metered, and interfaced with programmatically from .NET code, but I don't know of anything like that.
A scripting engine like Google's V8 seemed like it would be awesome, but there's no way to ensure program A and program B can each be allowed equal execution time; line by line stepping doesn't work here, as a line from program A could read:

q=(((x+y)/z)-(a*b))/c;

while a line from program B could read:

q=3;

meaning running each line's program results in one (probably) executing for a longer time than the other.


texts: How to embed unity webplayer built inside phonegap app?

texts:
After exporting my game made with unity, I got two files web.html and web.unity3d

I want to embed this game in a phonegap app. I used this code:

<object id="UnityObject"
          classid="clsid:444785F1-DE89-4295-863A-D46C3A781394"
          width="1024"
          height="768"
          codebase="http://webplayer.unity3d.com/download_webplayer/UnityWebPlayer.cab#version=2,0,0,0">
     <param name="Web/Web.unity3d"
            value="Web.unity3d" />
         <embed id="UnityEmbed"
                src="Web/Web.unity3d"
                width="1024"
                height="768"
                type="application/vnd.unity"
                pluginspage="http://www.unity3d.com/unity-web-player-2.x" />
 </object>

This code works on the browser but nothing shows when I build with xcode.


texts: Cap Framerate in the asynchronous world of Javascript

texts:
I'm developing a game in JavaScript & HTML5 with CreateJS. (I doubt you'll need CreateJS experience to answer this question, though)

My main game loop function is initialized and run using the CreateJS library like so:

createjs.Ticker.on("tick", loop);

(Similar to an event handler)

Then, it's off to the races - my function loops indefinitely, running my game at around 50FPS.

I want to cap this at 30FPS. But without a "sleep" function, or any real "pause" function, what's the best way to do that? How can I force my loop to slow down?

Thanks!
-W


texts:
Considering there are many games out there that use some sort of a server that contains a list of current games/servers, is there an existing library I can use instead of writing my own master server?

I only wish to store game/server data (server name/ip, num players, game-specific data...).

Thanks!


texts: What is the formula for the collision of two "stretched spheres"?

texts:
In Smash Bros Melee, hitboxes aren't perfect spheres or boxes. They are, instead, a shape that looks like a continuous line of consecutive spheres:

I.e., the geometry can represented as:

Hitbox : (fromPos : V3, fromRad : V3, toPos : V3, toRad : V3)

Of course, one could emulate that by creating several spheres in a row, but it will probably not be the most efficient solution. So, what is a formula to test the collision of two of those hitboxes?


texts: Best way to handle events for a turn base game?

texts:
I'm looking for the best way to handle events for a tactic game in Unity. Every unit may need to react to different events (turn start, end, on damage to self, on damage to other, on kill, etc...).
At the moment I'm just cycling all units for any event from a central manager class, but I'm looking for a more elegant and easy-to-extend solution. I'm not worried about performance since the involved number of units will be low.
Any advice?


texts: How do I create a save file for a C++ game?

texts: I am coding my final for a Video game Programming  course, and I want to know how to create a save file for my game, so that a user can play, and then come back later. Any idea how this is done, every thing I have done before has been single run programs.


texts:
Up to 3 days ago I used a Canvas in a SurfaceView to do all the graphics operations but now I switched to OpenGL because my game went from 60FPS to 30/45 with the increase of the sprites in some levels. However, I find myself disappointed because OpenGL now reaches around 40/50 FPS at all levels. Surely (I hope) I'm doing something wrong. How can I increase the performance at  stable 60FPS? My game is pretty simple and I can not believe that it is impossible to reach them.

I use 2D sprite texture applied to a square for all the objects. I use a transparent GLSurfaceView, the real background is applied in a ImageView behind the GLSurfaceView.

Some code

    public MyGLSurfaceView(Context context, AttributeSet attrs) {
        super(context);
        setZOrderOnTop(true);
        setEGLConfigChooser(8, 8, 8, 8, 0, 0);
        getHolder().setFormat(PixelFormat.RGBA_8888);
        mRenderer = new ClearRenderer(getContext());
        setRenderer(mRenderer);
        setLongClickable(true);
        setFocusable(true);
    }

    public void onSurfaceCreated(final GL10 gl, EGLConfig config) {
        gl.glEnable(GL10.GL_TEXTURE_2D);
        gl.glShadeModel(GL10.GL_SMOOTH);

        gl.glDisable(GL10.GL_DEPTH_TEST);

        gl.glDepthMask(false);

        gl.glEnable(GL10.GL_ALPHA_TEST);
        gl.glAlphaFunc(GL10.GL_GREATER, 0);

        gl.glEnable(GL10.GL_BLEND);
        gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);

        gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
    }

    public void onSurfaceChanged(GL10 gl, int width, int height) {
        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glLoadIdentity();

        gl.glOrthof(0, width, height, 0, -1f, 1f);

        gl.glMatrixMode(GL10.GL_MODELVIEW);
        gl.glLoadIdentity();
    }

    public void onDrawFrame(GL10 gl) {
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

        gl.glMatrixMode(GL10.GL_MODELVIEW);
        gl.glLoadIdentity();

        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

        // Draw all the graphic object.
        for (byte i = 0; i < mGame.numberOfObjects(); i++){
            mGame.getObject(i).draw(gl);
        }

        // Disable the client state before leaving
        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    }

mGame.getObject(i).draw(gl) is for all the objects like this:

    /* HERE there is always a translatef and scalef transformation and sometimes rotatef */

    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTexPointer[0]);

    // Point to our vertex buffer
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTextureBuffer);

    // Draw the vertices as triangle strip
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, mVertices.length / 3);

EDIT:

After some test it seems to be due to the transparent GLSurfaceView. If I delete this line of code:

    setEGLConfigChooser(8, 8, 8, 8, 0, 0);

the background becomes all black but I reach 60 fps. What can I do?


texts: How do I move my character using accelometer (android)?

texts:
I created a class for accelerometer, and there are no errors, my game does not crash when I run it, but my character does not move when I tilt my phone. I have been trying to figure out how to use the accelerometer for some days now, but every tutorial uses it in an activity, and there is no activity in my application.

Here is the code:

package com.saladchef.bananasplit;

import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;

public class MyAccelerometerClass implements SensorEventListener {
private SensorManager sensorManager;

public float x, y, z;

public MyAccelerometerClass(Context context) {
    sensorManager = (SensorManager) context
            .getSystemService(Context.SENSOR_SERVICE);
}

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
    // TODO Auto-generated method stub

}

@Override
public void onSensorChanged(SensorEvent event) {
    x = event.values[0];
    y = event.values[1];
    z = event.values[2];

    if (y == 0.0){
        Banana.stop();
    }
    if(y >= 1.5){
        Banana.moveRight();
    }

    if (y <= -1.5){
        Banana.moveLeft();
    }

}

public SensorManager getSensorManager() {
    return sensorManager;
}

public void setSensorManager(SensorManager sensorManager) {
    this.sensorManager = sensorManager;
}

public float getX() {
    return x;
}

public void setX(float x) {
    this.x = x;
}

public float getY() {
    return y;
}

public void setY(float y) {
    this.y = y;
}

public float getZ() {
    return z;
}

public void setZ(float z) {
    this.z = z;
}

// codes

}


texts: How to return the scene view camera to the default view

texts:
By the "scene view camera" I don't mean a GameObject with a Camera component, I mean the camera used to draw the Scene window in the Unity editor, controlled by this "Scene Gizmo" widget:

The default view shows an almost isometric perspective, where all three X Y Z axes are visible.
But when I clicked the green Y cone, my view changed to look straight down the Y axis, and I can't seem to return to the 3-axis view.
Clicking the other cones on this widget just switchest to look along the X or Z axis instead, and clicking the cube in the middle or the "Top" label just toggles between orthographic and perspective projection.
How can I get back to the default 3-axis view?


texts: Can I use different Tile/Sprite Sizes on the same Tilemap?

texts:
My partner and I are creating a 2D RPG with D&D elements with Unity.

I am very new to Unity and making games in general, apart from 2 games which I created with Java and the rougelike tutorial which I did with Unity. For this university project we have 4 months and my partner has the job creating tiles, sprites, sound and music. I will program the game.

My question is:

Can we create 32x32 tiles and 64x64 sprites in the same tilemap or does everything need to be the same size?

If we can combine them, will a 64x64 sprite on a 32x32 tilemap take 4 tiles, or can we scale it down to one tile?


texts: Multiplayer VR art gallery using different headsets

texts:
I'm creating a VR art gallery using Unity3D (like a VR Museum Views with more freedom) and would like to have an environment where 1 or more users can gather together, communicate and move around (similar concept to SecondLife except in this case would be first-person view (by default) with only one room/location and users would be in VR).

From a user perspctive, the initial screen would be a door and the user would have a mini-map and a menu, turned to him/herself, with specific actions.

Once inside of the gallery, the users would be able to see others, "walk" or "teleport" to different locations

and see the canvas

The overall environment is rather simple so I've decided to get feedback from potencial users. Turns out the majority doesn't want to be alone in such environment. So, I've considered adding multiplayer (one of the users could even be guiding the others, which is interesting).

Now, multiplayer makes more sense when we can more inclusive. That's where the problem starts. In this specific case, inclusive is being defined as the possibility of users to be able to be present in the environment using at least one of the following devices

Android Phone (Cardboard)
Oculus GO
Samsung Gear VR
Google Daydream
Oculus Rift
HTC Vive

I've done some research and couldn't find someone doing it or a way to do it (considering all of the requirements). If that's possible to do, how can i do it?

One thing I found was that if I didn't want the users to move around and just be watching the gallery like watching a webinar / presentation in different devices, I could use VR Sync (they basically synchronize video playback on multiple VR devices).

So, at the moment I can either have the environment with just one user at a time and develop the environment for all the different headsets or use VR Sync.


texts: What is the advantage of OpenGL's direct state access mechanism?

texts:
I've been reading about OpenGL 4.5 Direct State Access (DSA) at opengl.org and not sure if I'm getting it right.

It seems to imply, that the old way is less efficient:

glBind(something)
glSetA(..)
glSetB(..)
glSetC(..)

than the new way:

glSetA(something, ..)
glSetB(something, ..)
glSetC(something, ..)

From the looks of it now each glSet has to include glBind(something) inside of it and if OpenGL still being a state-machine cannot take advantage of streamed changes applied to a single something.

Please explain the reasoning behind and advantages of the new DSA.


texts: Instantiate prefab as a type that inherits from MonoBehaviour

texts:
I have a CeilingTile class. In this class, I have an InstantiateCeilingLamp() method, which instantiates from a CeilingLamp prefab.

Here is the code:

protected void InstantiateCeilingLamp()
{
    Object ceilingLampPrefab = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject));

    CeilingLamp ceilingLamp =
        Instantiate(ceilingLampPrefab, this.transform.position, Quaternion.identity)
            as CeilingLamp;

    if (ceilingLamp == null)
    {
        Debug.Log("Failed to instantiate the ceiling lamp.");
        return;
    }

    ceilingLamp.transform.SetParent(this.transform);
}

prefabPath is a const string defined within the class.

Stepping through my code using the debugger, I can see that ceilingLampPrefab is non-null after executing AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject));.

However, Instantiate(...) as CeilingLamp; returns null, because the instantiated prefab cannot be cast to the type CeilingLamp, which inherits from MonoBehaviour.

How should I modify my code in order to instantiate a prefab as a type that inherits from MonoBehaviour?


texts:
I'm looking for a reusable 3d animated dice component I can reuse in my XNA board game.

I know it might be wishful thinking in hoping such a component exists, but at the same time worthwhile checking.

I'm looking for something that can give a realistic dice animation and return the dice result that matches the animation.

Does such a thing exist?


texts:
I am creating a game using a relatively new platform called "codenameOne", but I'm actually a software engineer, so this question might be rather basic or odd, but I'm unsure what to do.

The game is targeting mobile phones and tablets (codenameOne has the advantage of being close to WORA) and I'm unclear on how to correctly update the "logic" and the "view".

At the moment, both update 60 times per second, but this feels wrong. This means that if I decrease the update speed of the game, the elements will also slow down (such as applying the current acceleration to the velocity, to the position,...)

This comes down to two questions:

1) Should they have separate update frequencies?

2) If so, which ones are conventionel for mobile applications?

EDIT: It might actually be worth noting that the game works (some bugs but it renders fine and it's playable). If you want to take a look at the source it's here: https://github.com/DylanMeeus/CNOGame


texts:
One issue I grapple with across many of my games is trying to decide how many levels to put in my game. This is across genres and platforms.

In general, constraints that may decide -- although they are not applicable in my case -- can include:

Pre-determined schedule or release dates
Fixed budget
The game's story finishes/concludes
(PCG games): difficulty becomes "impossible"

These are all great, but not sufficiently constraining as to tell me how many levels to make.

Another constraint that sounds good in theory but is hard to implement is game time -- for example, Mario or Super Meat Boy, I can guesstimate x minutes per level, and target y minutes of intended total gameplay, yielding y/x levels.

But none of these seem quite right to me. It seems like there should be a better way to decide when to add more levels and when to stop.