texts: Rename Sketchup Component meshes for Unity

texts:
When i create a component in Sketchup and i export it to Unity, the component structure is always:

Component_Name

MeshX

How can i avoid having the component name as an empty parent and just set it for the mesh itself? (i want a single object)


texts:
I'm trying to convert a .fbx model to a .x for use in my DirectX 9 project. Does anyone know of any software to allow me to do this?

Been googling for a few days and not really found anything that has allowed me to do this.


texts: Appropriate Cache Friendly Associative Container For An Entity Component System

texts:
The intro to this problem is a bit of a long one so my apologies in advance. In short I am asking for suggestion as to what type of collection I should use to store data for a particular part of my system.

I have an entity component system in place where a static EntityManager creates and stores components within vectors of their own type, and creates Entities storing them in either a vector for dynamic entities or a vector for static entities. Something like this:

#define COMPONENTS X(MeshComponent) X(CameraComponent) X(PointLightComponent) X(DirectionLightComponent)
#define X(ARG) std::vector<ARG>,
using ComponentTuple = std::tuple<COMPONENTS Empty>;
#undef X

class EntityManager {
    static ComponentTuple components;

    vector<Entity>& getDynamicEntities() {
        static vector<Entity> entities;
        return entities;
    }

    vector<Entity>& getStaticEntities() {
        static vector<Entity> entities;
        return entities;
    }
}

Without getting into too much detail each Entity has an id (stored as a short which determines its dynamic or static status and its index within the respective vector).

Each Component has its own id (an unsigned short referring to its index in its respective vector) and an Entity id, referring to the entity it is "attached" to.

At this point all the Entity object is, is an ID and useful functions. To make it more useful I decided to let the Entity object store a collection of id's (unsigned shorts) of its own components (to make searching for the entities specific components faster). My initial plan was to use an unordered_map data structure it like so:

class Entity {
    friend class EntityManager;
private:
    short id = SHRT_MAX;
    std::unordered_map<std::type_index, vector<unsigned short>> components;
}

Thinking on it though, this introduces at least two (from what I can see) levels of indirection. One to the hash table produced by the unordered map and another to the vector storing the actual id's. With this in mind I was wondering if anyone else would be able to suggest a more cache friendly data structure. If not a simple reassurance that my choice was a correct one will also suffice (as right now I can't help but feel that there is a better way).

Some of the things that I would like the collection to do:

1) I would like to be able to search the collection by ComponentType (because components may share the same ID but be stored in different vectors)

2) I would like the collection to be expansive (not all entities will have the same components and it just seems wasteful to have an array for all potential Component Types when the entity may only have one)

3) I would like the potential to have multiple Components of the same Component Type in the collection (in the example given above maybe some Components have two PointLightComponents)

Any suggestions or comments would be greatly appreciated as I've been wracking my brain on this one for some time now. Thanks in advance.


texts: Farseer Physics for Xna missing ConvertUnits class

texts: Im using Farseer Physics with Xna 4.0. Im following a starter guide. It said that to draw, I need to convert the meters to pixels with the ConvertUnits namespace. I looked through all of the engine, but I cant find the ConvertUnits class. Im basicly stuck without it. Where is it stored, or do I need another resource?


texts: Can I use the names or logos of real football teams in my game?

texts: I am developing a football game and I want to know if it is legal to name teams after real football teams. What about their logos?


texts: Is there any reason not to make all my components a single class?

texts:
What would be the downside to using a generic all-encompassing Component class versus specific classes (PositionComponent, InputComponent, et cetera) for each component in an entity/component system?

By 'generic' I mean:

class Component {
  String name; // component name, like "position"
  Map<Key, Object> attribs; // Attributes like "x" and "y" stored here.
}

Where a 'specific' component might be:

class PositionComponent {
  int x, y;
}

I feel like creating a separate class for each component means tons of 3-5 line classes in my code-base.


texts: UnityEngine.Vector2 does not contian a definition for "Set".... using futile

texts:
I am a bit lost, I am using futile and I am just trying to run the demo. But I keep getting UnityEngine.Vector2 does not contian a definition for "Set" in just one class, my using statments are:

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

When I look at the documents, I see that Set is a function http://docs.unity3d.com/Documentation/ScriptReference/Vector2.html
I am using version 3.4.2 (in futile its happening in just the FAtlas class)


texts: Is it possible to avoid global data in a Multi User Dungeon (MUD)?

texts:
I am currently designing a Multi User Dungeon (MUD). For those who do not know what it is, they are the ancestors of MMORPGs. There is no graphics, everything is played in a console by typing commands. Players move into rooms, fight monsters, earn xp, and so on.

I am programming in C++ and use Boost. I am inspired by several examples of MUD that I found on the internet whose source code is available.

In each of the examples I found, global variables are often used: the list of players, the list of connected players, the list of rooms, etc. Indeed, these data are used absolutely everywhere in the program. They are at the heart of the game. 80% of the code consists in manipulating these data. I understand that others have been tempted to declare these data as global variables.

But I understand the danger of global variables and the problems that their use raises.

The problem is that I cannot imagine a viable solution that would prevent me from using global data.

I will try to give you a description of my architecture to illustrate my problem:

a class Server (linked to a list of sessions)
a class Session (linked to a connection instance)
a class Connection Instance (linked to a Player, a Session and a Context)
a class Player (linked to a Room)
a class Area (contains Rooms)
a class Room
a class Context (used to differentiate the different contexts: normal play, or when the player types his name and password, etc)
a class Command (for example, “kill a mob”)
many others…

I am not sure to know how I can have an access to every room/player/npc/object in the game in all these classes without passing everywhere a reference or a pointer to an object containing the whole game as parameter.

For example, a player might have a "kill every player in the world" command. "KillEveryoneCommand" that would inherit "Command". But where would this list of players be stored? How could it be accessed from the "Player" class or from the "KillEveryoneCommand" class?

Theoretically, a player could also have a command to ignite all the rooms of an area, or to communicate with another player from a distance... All these things are done without any problem with global data.

Would an online game with such central and shared data be a good exception for using global data?


texts:
I have some problems with batching trees.
I'm using the default unity terrain system and trees.
My problem is that trees won't get batched together (I've set up static, dynamic, and GPU instancing) and as I've inspected the frame debugger I've come to these results:
I used trees with the optimized bark material and optimized leaf material
What causes distinct draw call:
1- Wind
2- color and size variations for trees
draw call reason:
non instanced properties set for instanced shader
if I remove Wind or variations the GPU instancing would work (I don't want to remove wind and variations), Is there any way to batch trees in this case?


texts: Axis-Aligned Bounding Boxes vs Bounding Ellipse

texts:
Why is it that most, if not all collision detection algorithms today require each body to have an AABB for the use in the broad phase only?

It seems to me like simply placing a circle at the body's centroid, and extending the radius to where the circle encompasses the entire body would be optimal. This would not need to be updated after the body rotates and broad overlap-calculation would be faster to. Correct?

Bonus:
Would a bounding ellipse be practical for broad phase calculations also, since it would better represent long, skinny shapes? Or would it require extensive calculations, defeating the purpose of broad-phase?


texts: How to compute point in view space from depth?

texts:
I am trying to implement do some screen space rendering but after looking over the web I still don't find answers to some doubts.

First, I need to compute the point in view space from a value in the depth buffer.

View-space means the camera-space or the clip-space?

I also found that, inverting the projection transformation I can get a point from the depth with a formula like

P(x,y) = [(2x/Vx-1.0)/Fx , (2y/Vy-1.0)/Fy , 1] * z(x,y)

where Vx/Vy are the dimensions of the viewport and Fx/Fy are the focal lengths

I don't understand where does this formula comes from, if I have it correctly the perspective projection formula is different. Can someone explain me this?
A point in view-space is a 3D-point, but why is the third coordinate 1?


texts: How do I get pixel to hex coordinates on an array based hex map?

texts:
I'm trying to make a pixel to coord function for a hex map but I'm not getting the math correctly, everything I try seems to be a little off, and the examples I've found were based on circled centered maps.

By 'array based' I mean the way the hexes are ordered, see pic.

The most accurate result I got was with the following code, but it is still off, and gets worse the more the values raise:

public HexCell<T> coordsToHexCell(float x, float y){
    final float size = this.size; // cell size
    float q = (float) ((1f/3f* Math.sqrt(3) * x - 1f/3f * y) / size);
    float r = 2f/3f * y / size;
    return getHexCell((int) r, (int) q);
}

Screen starts with 0,0 on top left, each cell knows its center.

All I need is a way to translate screen coordinates into hex coordinates. How could I do that?


texts:
I have been developing a game for some time thinking of distributing it on steam.

I had a question about taxes. And is that since I am not a resident of the United States, I made my tax questionnaire and I have a 10% rate for the sale of video games due to the treaty with my country.

And was I reading that every country has a tax? special? (VAT) or something like that, for example United Kingdom 20%

Which means that if I sell a game of 10 (€) I think this should happen

Scenario 1:

1 Unit Sale  ---  10.00 €
- (VAT)            1.66 €
-------------------------
Sale w/o VAT       8.33 €
- Steam 30%        2.50 €
-------------------------
S w/o Steam cut    5.83 €
- ISR USA (10%)    0.58 €
-------------------------
Sale revenue       5.25 €  (Less taxes from my country later calculated, this amount is the one deposited by steam)

Scenario 1 considers that each subtraction is made on a non-total balance

Or

Scenario 2:

The percentage is fixed on the total sale

1 Unit Sale  ---  10.00 €
- (VAT)            1.66 €
- Steam 30%        3.00 €
- ISR USA (10%)    1.00 €
-------------------------
Sale revenue       4.33 € (Less taxes from my country later calculated, this amount is the one deposited by steam)

Does anyone know how this situation is handled ?, or where could I get more information?


texts: How to find the resulting angle of a ball hitting a wall in 2D

texts:
So there's a ball moving on a 2D plane with any vector. When it comes into contact with a collider, it should reflect in a linear fashion. What formula should be used in order to find the angle that this new direction should have? The pieces of information that are known are:

The X and Y velocity of the ball when it was hit
The angle it was travelling at when it was hit
The point of contact

I've found many solutions for if the ball can only hit vertical or horizontal walls, but have yet to find a one for a general case.


texts: What are some ways of making a game engine centered around the idea of drawing vector lines and polygons only?

texts:
I've always loved the look of games that just use simple lines and polygons for graphics. Rez is one of my favorite games, visually. I'm a programmer and designer first and foremost, and I'm horrible at creating Actual Art, and the idea of making a game like Rez, using mostly line and polygon drawing, really appeals to me. Sort of like how a lot of programmers like to make roguelikes with minimal or ASCII art, I really like the idea of making a game just using trigonometry to draw lines in cool ways.

I've been making a game for a school project using my school's proprietary game engine. Instead of using its 3D model drawing capabilities and 2D sprite drawing capabilities, I've instead opted to make it using only the engine's "debug draw" functionality. I went so far as to create a library of functions that allow me to create "VecSprites", or collections of lines that act in the same way as sprites, both in 2D and 3D contexts. (For 3D, I do my own matrix math to calculate perspective and stuff, forgoing the engine's own 3D rendering capabilities entirely). Here is a video of my current project in action.

Going forward though, I want to set out to create my own game engine that will allow me to make these sorts of games on my own, without using someone else's game engine. I have plenty of experience with game engine architecture, but I don't know too much about actually drawing stuff to the screen. (Whenever I made a from-scratch game project for school, someone else was in charge of the DirectX or OpenGL side of things.) I have, however, done research into the different methods of rasterizing lines and curves and such to the screen.

What I'm wondering is, if I want to set out to make my own game engine specifically for drawing only primitive lines and circles (and then extend it with classes and such to allow for functionality such as grouping lines together into shapes), where is my best bet for getting started?

In the past, I've fooled around with Cairo, only to be disappointed by the fact that, currently, it is not really meant for rendering graphics in real-time on the GPU. Two years ago I made a simple game project using it, and it worked great until I ran it at 1080p, and, as it turns out, pushing 1920x1080x4 bytes to the GPU sixty times a second isn't exactly what modern computers were meant to do.

So where do I begin? I want to draw primitive lines and polygons on PCs, specifically Windows and possibly Linux, as fast as possible. I wouldn't mind having to go through the effort of creating my own systems for drawing anti-aliased lines, filled polygons, and so forth; I just want to know what my options are for doing such things.

Do I draw lines and polygons using low-level OpenGL calls, and go from there? Is it possible to pass a bunch of data containing the shapes I want do draw to a shader, and then have the shader do it? (I'm only minimally familiar with how shaders work.)

I know this question is kind of broad, but I really want to set out on this adventure to try and make this thing, and I just don't really know where to begin, at least as far as the drawing side of things is concerned.


texts: Mask not applying to gameobjects in UI layer

texts:
I have a bunch of item slots in my scroll view.

The item slots contain 3d objects, but they are all set to use the UI layer.

My problem is that they are not being masked the same as the 2D elements are.

See this example:

Notice how the 3D items in the scroll view are overflowing, but the 3D item slot panels are not.

Like I said, I put everything in the UI layer. I'm not sure how to fix this. Is there a simple fix for this?


texts: Instantiating prefabs dynamically in script

texts:
I have a canvas object. I right click it and add a Button, which defaults to having a rect transform, image script, button script and text child object. I make it a prefab and delete it from my canvas. I want to have a data driven engine so I have an external list which I want to make into buttons. When I have my  list loaded I  attempt to create dynamic buttons by:

GameObject prefabButton = new GameObject("StandardButton");

This in the hierarchy but it doesn't have the image or button or text components added, only a transform.

Why doesn't it have the things the prefab has??

I read I might need to instantiate it, so I tried:

GameObject stdButton = (GameObject)Instantiate(prefabButton);

Again this creates another object in my hierarchy with nothing but a basic transform.

What is the difference between this object and the one I created before? Why instantiate at all?


texts: Is libgdx fit for 2D game development on Android or are there simpler alternatives?

texts:
I'm looking for a Java framework to develop 2D games on desktop and Android. I've looked at Slick and I really like the API, however the developer himself says if you want a framework for Android and desktop best go with libgdx atm.

Now I'm reading up on libgdx, but I'm wondering if there are simpler alternatives for just doing 2D sprite stuff on Android and desktop. I'm only interested in creating NES like graphics, nothing too fancy. Something like this.

Because on the wiki of libgdx it says you can't use the OrtographicCamera with OpenGL ES 2.0 (http://code.google.com/p/libgdx/wiki/OrthographicCamera), but I read (http://www.badlogicgames.com/wordpress/?p=504) when your device supports OpenGL ES 2.0 it doesn't support 1.0, so you can't effectively use OrtographicCamera on OpenGL ES 2.0 devices?

I'm confused, should I go with libgdx? Are there simpler alternatives?


texts: Performance of separate Animators vs single multilayer Animator

texts:
I am making a 2D game with Unity 5.4 and I want to animate my 2D human character.

He has different sprites for its body parts - leg(s), hand(s), head, eye(s), nose, mouth. Its eyes, hands, legs move independently from each other - meaning their animations and transitions are not related in any way.

My question is, which alternative is the better choice performance-wise when animating?

For legs, hands, eyes, etc. create separate Animator and animate them separately.
For all animations use single Animator (attached on body's "container" GameObject) and create for legs | hands | eyes different Layers in the Animator.


texts: How does someone go about selling a game or making a royalties deal with Nintendo(or Pokemon Company)?

texts: It seems like Niantic did just that. If someone were to create their own game(Pokemon, hypothetically), how would they, if at all possible, sell that game to Nintendo or at least make a royalties deal? Or any other game, for that matter?


texts:
I have the OpenGL VAO object (~40K) to draw the 3D scene

glBindVertexArray(VAO);
glDrawElements(GL_TRIANGLES, 4, GL_UNSIGNED_BYTE, nullptr);
glBindVertexArray(0);

To add some data I can use glMapBuffer:

GLuint buffer;
glGenBuffers(1, &buffer);
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, (2 * steps) * sizeof(float),
     NULL, GL_STATIC_DRAW);
float *data = (float *) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
myFuncAddingData(data,{2.4f, 40.0f, 19.0f});
glUnmapBuffer(GL_ARRAY_BUFFER);

Can I to remove (hide/mask) some verteces (3 from 40K) directly from the located in the grafical memory VAO without full complete replacement all of the 40K?


texts: MultiTexturing by neighbouring points textures

texts:
Visual example:

I've been trying to understand multitexturing for a while now, I've created a terrain generator but have no need for height just yet and I still want one texture to blend over to another texture nicely.

I think Blau said that you only need 4 textures per vertex. My only guess then is that each point in a terrain has 4 neighbours - right? And that point is the main texture to sample from / blend from. Because it can't mean that 4 textures are all you get on a whole map in a game.

My idea is to have an "TextureID" for each point and whenever this point comes up, you load the textures in the effect with that neighbours textures.

Example (for each point):

effect.Parameters["MainTexture"].Setvalue(Content.Load<Texture2D>("MainTexture"))
effect.Parameters["TextureTopOfPoint"].SetValue(Content.Load<Texture2D>(textureID));
effect.Parameters["TextureRightOfPoint"].SetValue(Content.Load<Texture2D>(textureID));
effect.Parameters["TextureBottomOfPoint"].SetValue(Content.Load<Texture2D>(textureID));
effect.Parameters["TextureLeftOfPoint"].SetValue(Content.Load<Texture2D>(textureID));

/*
   Now the Pixel and Vertex Shader can calculate a blend effect
   from Center point to it's neighbouring points
*/

and somehow in the Effect file, blend from "Center point" to all it's neighbours. I also guess this would be a "slow" process.

Problems are:

Is this possible? I can't accept 4 textures for a whole map, so how do I manage to have multiple textures at the same time? And I don't want a solution with colors (like this) or heightmap, because I want it to be possible to have 4 or more textures on a flat surface.
How do I access each point's neighbour and when do I know when to set them?

My map contains Areas, each Area has it's own VertexBuffer and IndexBuffer.

(Example: MapWidth=4096, MapHeight=4096, each square = 128x128 = (32 * 128 x 32 * 128 grid)

public class Area
{
    public VertexPositionTexture[] Vertices { get; set; }
    public int[] Indexs { get; set; }

    public VertexBuffer GetVertexBuffer() { /* create a vertexbuffer */ }
    public IndexBuffer GetIndexBuffer() { /* creates a indexbuffer */ }
}

Edit (still not optimal)

Implemented some kind of method, but this method still relies on colors and I have no blendmap. I just use the color in the Vertex to check for a value (r, g, b, a)

Effect Code:

float4 PixelShaderFunction(VS_OUTPUT input) : COLOR
{
   float4 colour = float4(0,0,0,0);

   colour += tex2D(GroundText0Sampler, input.TexCoord) * input.Color.r;
   colour += tex2D(GroundText1Sampler, input.TexCoord) * input.Color.g;
   colour += tex2D(GroundText2Sampler, input.TexCoord) * input.Color.b;
   colour += tex2D(GroundText3Sampler, input.TexCoord) * input.Color.a;

   return colour;
}


texts: How do I get a popup menu to block clicks from hitting UI elements beneath it?

texts:
You can see in the picture that I have a Canvas with a popup menu in it. I just enable this, and it covers the main menu stuff. Clicks go through it and hit stuff in the main menu.

I've tried adding an EventTrigger to the PopupRoot object, and adding an event to listen for PointerClick events, but it doesn't fire.

EventTrigger trigger = m_popUpRoot.GetComponentInChildren<EventTrigger>();
EventTrigger.Entry entry = new EventTrigger.Entry();
entry.eventID = EventTriggerType.PointerClick;
entry.callback.AddListener((eventData) => { PopupClickBlocker((PointerEventData)eventData); });
trigger.triggers.Add(entry);

I'm open to other suggestions. My current system is horrible; button click events query the Popup to see if it's enabled or not, then return doing nothing if it is. This doesn't work for sliders very well, so I want to do this the right way.


texts: How can I generate isometric sprite sheets from 3D animations?

texts:
I want to generate sprite-sheets for an isometric projection of various 3d assets purchased from the Unity3D asset store. I'd preferably also render the normal maps. I am a programmer, but new to 3D modeling software (Blender, etc.)

I found two tools for this; SpriteForge and SpriteWorks, but neither supports enough formats to be worth their cost.

There must be an efficient way of isometrically rendering various animations of a 3d assets in Blender—but I don't know how. How can I do this?


texts:
These 2 polygons are not colliding, though this method returns true:

Intersector.overlapConvexPolygons(
            new float[]{
                        100.0f, 750.0f,
                        200.0f, 750.0f,
                        100.0f, 150.0f,
                        200.0f, 150.0f
                        },
            new float[]{
                        77.0f, 695.0f,
                        91.0f, 695.0f,
                        84.0f, 681.0f
                        },
            null);

Am I using it correctly?


texts: Reducing draw calls in a y-sorted orthogonal world

texts:
This is a hypothetical question, as I haven't yet come across the problem of making too many draw calls, but for my game I am aware that this could become a potential problem.

The style of my game is similar to an old school top down RPG, except the characters and environment are high resolution and not tile based.
With moving characters and objects, different textures and geometries are flitting between layers constantly. It's all in 2D.

Currently I'm finding it very hard to batch anything.
As I understand, batching requires that multiple geometries appear at the same depth with the same texture. Unfortunately, this doesn't leave me many opportunities to batch.
Also consider the high resolution of the textures does not allow me put everything in a single spritesheet, and the z-order of a scene is constantly changing (characters and objects move around)

I'm now trying to add some kind of deferred lighting system and with my many draw calls this appears somewhat incompatible.

I should probably mention I'm fairly new to the concept of GPU rendering. I come from Flash.

This isn't a question really, but I'd appreciate some advice.


texts: Issues with shooting in a HTML5 platformer game

texts:
I'm coding a 2D sidescroller using only JavaScript and HTML5 canvas, and in my game I have two problems with shooting:

1) Player shoots continous stream of bullets. I want that player can shoot only a single bullet even though the shoot-button is being held down.

2) Also, I get an error "Uncaught TypeError: Cannot call method 'draw' of undefined" when all the bullets are removed. My shooting code goes like this: When player shoots, I do game.bullets.push(new Bullet(this, this.scale)); and after that:

    function Bullet(source, dir)
    {
        this.id = "bullet";
        this.width = 10;
        this.height = 3;
        this.dir = dir;

        if (this.dir == 1)
        {
            this.x = source.x + source.width - 5;
            this.y = source.y + 16;
        }
        if (this.dir == -1)
        {
            this.x = source.x;
            this.y = source.y + 16;
        }
    }
    Bullet.prototype.update = function()
    {
        if (this.dir == 1) this.x += 8;
        if (this.dir == -1) this.x -= 8;

        for (var i in game.enemies)
        {
            checkCollisions(this, game.enemies[i]);
        }
        // Check if bullet leaves the viewport
        if (this.x < game.viewX * 32 || this.x > (game.viewX + game.tilesX) * 32)
        {
            removeFromList(game.bullets, this);
        }
    }
    Bullet.prototype.draw = function()
    {
        // bullet flipping uses orientation of the player
        var posX = game.player.scale == 1 ? this.x : (this.x + this.width) * -1;
        game.ctx.scale(game.player.scale, 1);
        game.ctx.drawImage(gameData.getGfx("bullet"), posX, this.y);
    }

I handle removing with this function:

    function removeFromList(list, object)
    {
        for (i in list)
        {
            if (object == list[i])
            {
                list.splice(i, 1);
                break;
            }
        }
    }

And finally, in the main game loop I have this:

for (var i in game.bullets)
{
    game.bullets[i].update();
    game.bullets[i].draw();
}

I have tried adding if (game.bullets.length > 0) to the main game loop before the above draw&update calls, but I still get the same error.


texts: What is the meaning of component is Dirty?

texts:
I was reading a blog from Unity about UI it has a term like component is dirty,
what does that mean component is dirty ?

Unity UI Fundamentals tutorial


texts:
Let me explain: I´m reading a book I got given that is called "Beginning Java Game Development with LibGDX", and get to the section where the book talks about animating actors, or animating "sprites". The example code they presented is as follows:

    public class AnimatedActor extends BaseActor {
    private float elapsedTime;
    private Animation anim;

    public AnimatedActor(){
        super();
        elapsedTime=0;
    }

 public void setAnimation(Animation a)
 {
 Texture t = a.getKeyFrame(0).getTexture();
 setTexture( t );
 anim = a;
 }

 public void act(float dt)
 {
  super.act( dt );
  elapsedTime += dt;
 if (velocityX != 0 || velocityY != 0)
  setRotation( MathUtils.atan2( velocityY, velocityX ) * MathUtils.radiansToDegrees );
 }

 public void draw(Batch batch, float parentAlpha)
 {
  region.setRegion( anim.getKeyFrame(elapsedTime) );
  super.draw(batch, parentAlpha);
  }
}

I'm running the examples, using android studio, and surprisingly I find the following situation: the code that proposes the book marks an error ... and it is exactly in this line:

 public void setAnimation(Animation a)
 {
 Texture t = a.getKeyFrame(0).getTexture(); <------- getTexture() is the error
 setTexture( t );
 anim = a;
 }

The error I'm getting is

  cannot resolve method getTexture()

I'm a bit surprised, since I'm not supposed to have any errors, since I'm reading from a book ... trying to implement something similar for my project, but ... I found this. Surely, it should be that the function should be removed in recent versions of LibGDX.

The only thing I try to do is that the moment you click on an actor on the stage, the texture set, change to the animated sprite. How can you create an animation in LibGDX?


texts:
I'm here struggling for hours to build my game (android) and 'Execution failed for task : checkReleaseDuplicateClasses'

Duplicate class androidx.annotation.AnimatorRes found in modules androidx.annotation.annotation-1.0.0.jar (androidx.annotation.annotation-1.0.0.jar) and androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar)
Duplicate class com.google.android.gms.auth.api.signin.zaa found in modules classes.jar (:com.google.android.gms.play-services-base-17.0.0:) and classes.jar (:com.google.android.gms.play-services-base-17.1.0:)

... are just two examples of the 486 warnings I'm getting.
Can anyone help a noob out?
Thanks so much for your time!


texts: Most efficient way for nested loop to not repeat a value of parent loop in pair-wise structure (C# or Javascript)

texts:
It's hard to choose the correct title for this question, so let's see if I am able to better convey here what I am in search for. If the title is too far away, suggestions are welcome and I can edit it or put a new question.

So, what I am trying to do is the following. I have the following set of values: A=[a1,a2....a100]. Now, suppose I want to loop trough them to check something for each possible pair of these values but without repetition and avoiding to check a value against itself.

It means that we start with a1 and check it against a2, then a3, then a4, until checking it against a100. Next, we start with a2, but we do not check it against a1 because that was already checked. We go directly to check a2 against a3, then a4, until a100. Next, we start with a3 and check it directly agains a4, then a5, and so on. The idea is that there will be 100+99+98+97...+1 checks, instead of 100^2 checks.

A naïve way of doing that would be to use two loops, one nested in the other, both going trough all the values of A. However, after the main parent loop completes each iteration, it stores the current iterated value in a list. So, when the child nested loop starts it checks if its currently iterated value is already on that list - if it is, the nested loop breaks.

However, it is very likely that this is not a very efficient way of doing that, since one would have to create a list, add to the list every iteration of the first loop and search the list every iteration of the second loop. Considering that I will be dealing with enormous amount of values in A, not only 100, that is real concern.

So, what are the most efficient ways one can do that kind of pair-wise comparison without repetition? I can handle both C# and Javascript. Many thanks.


texts: Collisions between players in multiplayer racing game

texts:
I'm creating a simple racing game (spaceships, no gravity) using p2.js, phaser and node.js.

What I have done:
Client receives world state from server:

extrapolate other players based on latest velocity/position from server
check if client-side prediction was correct - if no apply position from server and process inputs that server was not aware of.
fixed physics step

Server:

receives inputs from clients and apply
fixed physics step
sends world state to each client

Now I'm struggling with collisions between players.
Colliding player is jumping all time during collision. I think it's because client-side prediction is not calculating similar results to the server.

Server doesn't know all inputs from player (lag).

Player doesn't have the same position of colliding player as the server (lag).

Combining this two makes the client to resolve collision different than the server and when world state arrives player has to make a big correction.


texts:
I need to write a program that will solve maze. Maze has graph structure, where each node - some room, and edges - exits to other rooms:

Specification:

We start from a random room.
Maze has dead-ends, 0 or few exits.
We don't know anything about all maze, only the number of current
room and list of doors from it.
When we enter new room we don't know where we came from (what door
from current room leads us back to previous room).
We can recognize when we reach exit.
Each step we move from current room to some available door from it.
If we are at room 6 for example, we can't just jump to begin. It's like robot movement.
We know exactly ID of current room. We know ID of each door in current room (not in all maze).
We control robot.

I looked all known algorithms, but they all require at least additional ability to return to previous room. According to specification we can't use any algorithms that search for shortest path (actually, I don't need the shortest), because we know only about current room. We can't use Left-(Right-)hand following algorithms, because don't know direction of exits. Probably, the only solution that meets specification is choosing random exit in every room in hope that some time exit will be found...

Any suggestion how to solve such maze in more smart way?


texts: Object shrinks at same rate no matter what

texts:
I am using the following code to shrink a sprite:

public bool shrinking = false;
public float targetScale = 0.1f;
public float shrinkSpeed = 0.1f;

void Update () {
    if(shrinking) {
        mySprite.transform.localScale -= Vector3.one * Time.deltaTime * shrinkSpeed;
        if(mySprite.transform.localScale.x <= targetScale) {
            shrinking = false;
        }
    }
}

However, no matter what I change shrinkSpeed to, the object shrinks at the same rate. I know it probably has something to do with putting it in the update function but where should I move it to fix the problem?


texts:
How I can get the time, where I am in a map for osu???

I need an osu!api solution, and I want to get this value:

0:05.12

or something like this.


texts: How would I go about implementing a collision avoidance check, avoiding moving objects from multiple directions?

texts:
So I'm making a testbed for an AI actor(ship). It's a simple asteroids game using an AI controlled actor.
I'm doing this using VS, monogame.

I have implemented a simple steering behaviour using a tutorial as a guideline, found here. https://gamedevelopment.tutsplus.com/tutorials/understanding-steering-behaviors-collision-avoidance--gamedev-7777
It works somewhat.

The problem occurs when the objects(asteroids) are all moving around(at different speeds), using the guidelines from above, it only checks for collisions for whats infront, at specific points. Which would work if all other objects were static.
My initial thought was to add a check for back,left,right. Then loop it to check all these positions in a 50-150 units radius. But the more I think about it, the more realize there must be a better way. As understand it, that wouldn't really solve it either, and would be performance heavy.

How would I go about implementing a collision avoidance check that 1; takes into account the approaching objects may come from any direction.
2; the differnt velocities of those objects.

Or might it be better to apply the existing check to the objects and passing the data to the actor?

Any references, tips, guide, code snippets or good old wisdom or simple pointer in the right direction, would be enormously appreciated!


texts: How to disable Monogame pixel font antialiasing?

texts:
I am using Monogame 3.4 (I have held off upgrading to 3.5) and am on Windows 10. I'm drawing using the PointClamp setting (as suggested in this similar question).

Whenever I render text with DrawString(), the text is extremely antialiased, as shown below. However, any stretched textures I draw are NOT antialiased, and seem to use the PointClamp setting as expected.

Here are some examples of drawn text:

How do I disable text antialiasing so that fonts don't blur?

EDIT:

It seems that changing some import settings in the .mgcb changes the quality of the AA? When "processorParam:TextureFormat=Color" is changed to "processorParam:TextureFormat=Compressed", it makes the AA more pronounced. The issue is still not solved, but I feel like the font import settings may have something to do with it. Here is the .mgcb

#begin DwellFont.spritefont
/importer:FontDescriptionImporter
/processor:FontDescriptionProcessor
/processorParam:TextureFormat=Color
/build:DwellFont.spritefont

EDIT 2

Since this question got flagged as a duplicate, let me explain. The other question I have already referenced above uses PointClamping. I already use PointClamping, and it works fine with the textures I render (they aren't antialiased). It does not, however, work with my fonts. Therefor, that other question isn't applicable. I'm wondering why that is.


texts: How to calculate if a point is contained in rectangular camera viewport with rotation?

texts:
I am working with my camera, and am trying to improve it so that I can calculate if a world point is on screen, taking rotation into account. Currently, my camera rectangle is calculated as so:

    public Rectangle Rectangle
    {
        get
        {
            int width = (int)((ViewportWidth / _zoom));
            int height = (int)((ViewportHeight / _zoom));
            return new Rectangle((int)(_pos.X - width / 2), (int)(_pos.Y - height / 2), width, height);
        }
    }

Then, to check if a point is on screen, I call one of the following functions:

    public bool IsOnScreen(Point location)
    {
        return this.Rectangle.Contains(location);
    }

    public bool IsOnScreen(Rectangle bounds)
    {
        return this.Rectangle.Intersects(bounds);
    }

However, none of these calculations take the rotation factor into account; only position and the zoom factor. I know that I can calculate the corners of the camera, in world space, using the following transformations:

var topLeftCorner      = Vector2.Transform(new Vector2(0, 0), Matrix.Invert(ViewMatrix));
var topRightCorner     = Vector2.Transform(new Vector2(ViewportWidth, 0), Matrix.Invert(ViewMatrix));
var bottomLeftCorner   = Vector2.Transform(new Vector2(0, ViewportHeight), Matrix.Invert(ViewMatrix));
var bottomRightCorner  = Vector2.Transform(new Vector2(ViewportWidth, ViewportHeight), Matrix.Invert(ViewMatrix));

However, the rectangle object that I am using is not able to take this into account, since it cannot store rotation. What is the calculation that I can use to check if a point is inside the virtual rectangle with these points, or if a rectangle intersects with the virtual rectangle?

Here's some graphics to better illustrate some of my code:


texts:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.common.base.internal.Finalizer (file:/C:/computer/AIRSDK_Compiler/lib/guava-r08.jar) to field java.lang.Thread.inheritableThreadLocals
WARNING: Please consider reporting this to the maintainers of com.google.common.base.internal.Finalizer
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Anybody can explain this error in the Flex?


texts: How to make mobile movement using CharacterController

texts:
How can i change my movement for mobile i think left and right gonna work but i don't know what should i do for jump

private void Update()
{

    vector = Vector3.zero;

    if (characterController.isGrounded)
    {
        /*verticalVelocity = -gravity * Time.deltaTime*/;
        verticalVelocity = -0.5f;

        if (Input.GetKeyDown(KeyCode.V))
        {
            verticalVelocity = jump;
        }
    }
    else
    {
        verticalVelocity -= gravity * Time.deltaTime;
    }

    vector.x = Input.GetAxisRaw("Horizontal") * speed;
    if (Input.GetMouseButton(0))
    {
        if (Input.mousePosition.x > Screen.width / 2)
            vector.x = speed;
        else
            vector.x = -speed;
    }
    vector.y = verticalVelocity;
    vector.z = speed;

    characterController.Move(vector * Time.deltaTime);
}

I solved the problem this way

if (characterController.isGrounded)
    {

        verticalVelocity = -0.5f;

        if (Input.GetMouseButton(0))
        {
            if (Input.mousePosition.y > Screen.height / 2)
            {
                verticalVelocity = jump;
            }
            else
            {
                verticalVelocity = -jump;
            }
        }
    }
    else
    {
        verticalVelocity -= gravity * Time.deltaTime;
    }

    vector.x = Input.GetAxisRaw("Horizontal") * speed;
    if (Input.GetMouseButton(0))
    {
        if(Input.mousePosition.y < Screen.height / 2)
        {
            if (Input.mousePosition.x > Screen.width / 2)
                vector.x = speed;
            else
            {
                vector.x = -speed;
            }
        }
    }


texts: Data Driven Design and Game Screen Resolution

texts:
So I have just begun studying Data Driven Design and implementing it into a project. I just encountered an issue and I have not be able to locate any material that suggests an elegant if not practical design to address it.

In my case I am using an XML file to assign game objects' member variables such as x/y coordinates, etc. My issue is that the values are still in a sense 'hard-coded', i.e. x="300" y="blah blah", but what if I want to offer different window resolutions? Beyond making X number of XML files for each individual resolution, I am unsure of how to couple DDD and a feature that effects the data in manner such as this.

Could someone please provide any good ideas on how to satisfy the issue? Documented or personal experience are welcomed.


texts:
I have made a simple code where once the player moves through the collider that acts as a trigger then Unity adds a score. However, it increases by increments of 8 and I am not sure why.

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

public class Game : MonoBehaviour
{
    public int Score = 0;

    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }

    private void OnTriggerEnter2D(Collider2D other)
    {

        AddScore();
    }

    void AddScore()
    {

        Score++;

    }
}


texts: Unity network player synchronization issues with HingeJoint(s)

texts:
I have a vehicle with custom wheels which are connected to it by the HingeJoint components. Everything works perfectly when using this car in single-player mode. Wheels are actually as Cylinders. They have HingeJoints attached through which they are bound to the vehicle's Rigidbody. Then I set JointMotor.force and the wheels are getting rotated and the vehicle is moving. It all works very naturally in terms of physics, I don't need to emulate anything.

Still, there is an issue with network synchronization in multiplayer mode and I have no idea how to solve it.

It's said that the proper way to sync the position of a physical object is to use rigidbody.MovePosition(), but any manipulation with Rigidbody leads to the collapse of the vehicle hinge-joints. The only method that works is setting transform.position directly. But this is not recommended for physics and it doesn't allow to synchronize the vehicle smoothly with no twitching. Is there a way to solve this somehow?

I'm using Photon for networking (if it matters in the question context).


texts: How to check Early Z efficiency on AMD GPU with Windows 7

texts:
I have a game using DirectX 9, and a development station using Win 7 x64. I am still able to get access to another station with Vista x64 / dual booted with WinXP x86.

I wanted to check early Z efficiency in the game and to my sadness all tools I have tried seem to be unable to perform this task:

AMD PerfStudio

AMD GPUPerfStudio 2 does not support DirectX 9 at all
AMD GPUPerfStudio 1.2 does not install correctly on Windows 7. When I have tweaked the MSI package (a simple OS version check adjustment was needed), it complained the drivers I have do not provide needed instrumentation. The drivers old enough to support the GPUPerfStudio would most likely not be able to operate with my Radeon 5750 card (though this is something I am not 100 % sure, I did not attempt to try any older drivers, not knowing which I should look for)

PIX

PIX does not seem to contain any counters like this. It offers some ATI specific counters, but when I try to activate them, the PIX reports "PIX encountered a problem while attaching to the target program."

I do not want to upgrade to DX 10/11 just to be able to profile the game, but it seems without the step I am somewhat locked with a toolset which is no longer supported.

I see only one obvious options which would probably work, and that is using WinXP (or with a little bit of luck even Vista) station, perhaps with some older AMD card, to make sure GPUPerfStudio 1.2 works.

Other than that, can anyone recommend other options how to check GPU HW counters (HiZ / EarlyZ in particular, but if others would be enabled as well, it would be a nice bonus) for a DirectX 9 game on Windows 7, preferably on AMD GPU? (If that is not possible, I would definitely prefer switching GPU to switching the OS, but before I do so I would like to know if I will not hit the same problem with nVidia again)


texts:
I'm trying to implement a game where you have car moving along a line in HTML5 Canvas. Using a little bit of trigonometrie I managed to get the right x and y coordinates to add to the coordinates of my image each frame to get to the end of the "line".
Now the problem is, the image I use for the car starts to stutter in the process of rendering. The problem has to be the values I'm adding. (first I thought the problem would be the render loop but when using the render loop from paul irish the same problem occurs)
My question is, how can I use floats in context.drawImage(img,...) smoothly?

What I tried was rounding the values where the image should move to (e.g. context.drawImage(img, Math.round(car.x), Math.round(car.y))) but this doesn't work also.

simple code example to demonstrate the issue: (using a simpler loop, but like I said, the problem isn't the loop)

How it looks:

Here is the whole thing:

var canvas = document.getElementById("canvasID");
var context = canvas.getContext("2d");

var car = new Car(20,10);
var carImg = new Image();

carImg.src = "https://i.stack.imgur.com/L2XQW.png";
function Car(x,y)
{
  this.x = x;
  this.y = y;
}
Car.prototype.advancePosition = function(x,y)
{
   this.x = lerp(car.x, car.x + x, 1);
   this.y = lerp(car.y, car.y + y, 1);
}
 function update()
 {
   car.advancePosition(0.91,0.4);
 }
function lerp (start, end, amt){
  return (1-amt)*start+amt*end
}
function render()
{
  context.beginPath();
  context.clearRect(0,0, canvas.width, canvas.height);
  context.drawImage(carImg, car.x, car.y);
  context.closePath();
}

window.requestAnimFrame = (function(callback) {
        return window.requestAnimationFrame || window.webkitRequestAnimationFrame ||                    window.mozRequestAnimationFrame|| window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
        function(callback) {
          window.setTimeout(callback, 1000 / 100);
        };
      })();

(function mainLoop(){
  requestAnimFrame(mainLoop);
  render();
  update();
})();
#canvasID
{
    z-index: 1;
    background: #eee;
    display: block;
    vertical-align: middle;
    margin: 0 auto;
    z-index: 1;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    position: absolute;
    -webkit-transform:translateZ(1);
}
<html>
  <head>
    <meta charset = "utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="style.css">
    <title>test</title>
  </head>
  <body>
    <div class = "canvas_wrapper">
      <canvas id="canvasID" width="500" height="450">Canvas not supported, please update your browser</canvas>
   </div>
    <script src="main.js"></script>
  </body>

</html>

I would be happy if someone could help me out

Thanks

edit: Tried the suggestions from the comments but nothing worked.


texts: How to identify performance issues with large numbers of mods?

texts:
My current problem is with RimWorld, but in the past I had the same issue with Minecraft. Basically the game gets more fun with more mods, up until the point where performance becomes unmanageable. Most mods are open source and I am confident that I could fix many of these performance issues if I could only identify where the hotspots are.

So as a modder, how can I figure out where I should try and help out?

200+ mods, though obviously I would add more if I could.
I don't have access to the core game source code.
I don't have access to a debug version of the core game.
I probably have source code access to a given mod.
I'm looking for ways to help the community, not ways to make the game faster for just me (like adding more memory).


texts:
For the last month I was learning about meshes and how procedurally generate them. For what I need it looks very straightforward.
For my little app I planning to have a road tool (very simple), user draws lines and curves and road is generated with specific width (flat).
So I can now create a drawing tool and generate simple mesh along the curve or line.
Next step is to be able to construct intersections...
I looked at lots of example but couldn't find any descriptions how it is done.

Could you please advice what approach to take, how to identify intersection of two or multiple curves and generate mesh junction?

Also could you please advice on bigger picture, should I have sort of underline system for city building app, like graph, to know where to place road intersections, buildings and so on?

Thank you
This is a quick prototype I did (not in code)
https://youtu.be/1TxxB-ofLAo


texts: How much is java used in 2d/3d indie games? (before/after Minecraft)

texts:
I wonder for my own use and curiosity, how popular is Java in indie game development ,
in 2d and 3d? Are there any good open/closed source games done in java?


texts: How to instantiate an object to a randomised Vector2

texts:
So I'm trying to make a little game where squares randomly spawn around a set area and you have to tap them. The game is 2D. I'm having trouble using my randomly generated x and y floats to instantiate a cube in the game. Here is my code:

#pragma strict

public var play = false;
public var xpos : float;
public var ypos : float;
public var cube : GameObject;

function Start () {

}

function Update () {
}

function Game () {
    xpos = Random.Range(-10f,10f);
    ypos = Random.Range(-4.45f,4.45f);
    Instantiate(cube, new Vector2(xpos, ypos));
}

And here's the error!

Assets/gameController.js(18,20): BCE0023: No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(UnityEngine.Rigidbody, UnityEngine.Vector2)' was found.

Any help would be appreciated. Thanks!
-Alex


texts: How can I achieve long-distance rendering of static terrain and props in an open-world context?

texts:
How can I perform seamless rendering of long-distance vistas in a fashion suitable for an open-world game (e.g., where the player is relatively unconstrained in how they traverse the world)?

For the purposes of this question, I'm only concerned with rendering of static objects: terrain and large props, as my game world is relative devoid of dynamic actors outside of the player.

The PS4 remake of Shadow of The Colossus™ illustrates the kind of effect I'm going for:


texts: How to represent rotation quaterion to another coordinate system?

texts:
I am trying to combine rotation information from two system in a VR/AR scenario, one is a computer vision solution/ visual SLAM coordinate, initializing the first frame as the world origin as position[0,0,0] and rotation[0,0,0]. the other one is a IMU coordinate, always gives the roll, yaw and pitch Euler angle with respect to the physical environment coordinate.

I think I can represent the rotation in the visual SLAM coordinate by the difference from the IMU coordinate.

In frame 0: visual SLAM system initialized, visual SLAM coordinate as origin with zero position and zero rotation; IMU gives a Quaternion: q_imu_zero, with respect to IMU coordinate.

In  frame 1: IMU gives current Quaternion: q_current; the transform from frame 0 to current: q_imu_transform: q_imu_zero(-1) * q.

Question: Can I use the q_imu_transform to rotate in the visual SLAM coordinate system?

In my experiment in Unity editor, some of the axis rotation is meshed up and always wrong. when I rotate around y axis of my device, IMU gives the right rotation in the IMU coordinate, but visual SLAM system is rotated around z axis.


texts:
So I'm currently working in MagicaVoxel and I have 2 objects in my world. When I export it as .obj it exports as seperate 2 obj models with 2 seperate textures and materials. Is there any way that I can export whole MagicaVoxel world to single object. If there is a way this would really made my work easier because I will add more objects to world.

Thank you for answers.


texts: How to get the bounding box (meters) of an entire Unity gameobject, including all its child objects

texts:
How do you get the meter-accurate bounding box of an entire Unity GameObject, including all its child objects? It seems encapsulate bounds does not generate the right units at all
    bounds = new Bounds ();
    Renderer[] renderers = GetComponentsInChildren<Renderer> ();
    foreach (Renderer renderer in renderers)
    {
        bounds.Encapsulate (renderer.bounds);
    }

I've tried using encapsulate bounds on a round cushion with only a single child object containing 1 renderer.

Bounds encapsulate above gives
(10.3037,10.17837,10.30449)

Just squooshing a Unity cube to size it gives
(0.6185507,0.1842149,0.6185507)

A round cushion as you know is small on one side, so the bounds result isn't accurate.
How does one script a result closer to the second result above?


texts: Pausing game with State machine and handling jumps

texts:
I am adding pause functionality to my upcoming racing game.The players can jump in it.

Time.timeScale = 0 is obvious solution to pause game.I am avoiding this solution as users can do in app purchases in pause menu and with timeScale to 0 its somehow preventing them.

So to overcome that problem I have added state machine pattern to start,pause,resume,finish game.

The thing is when I pause game with my state machine pause behaviour it pauses the game properly without any hesitation until the player is Jumping and pause occurs.

When player is jumping everything gets pause perfectly,just player falls to ground.

So to overcome that problem what I tried was if user pauses game and player is on air the isKinematic on player gets set to to true and game gets pause with player halt on air.

The problem with this approach was that when user resume the game ,unexpected jump movement happens, i.e., player does not land on expected position .

Example if player on y = 10 and game gets pause, with Time.timeScale player will always land on Z = 17 ,but with my this second approach player sometimes land on Z = 20 ,Z = 21 Z = 19 etc

so my question is how will I do properly pause game with state machine without causing unexpected jump movement.


texts: How can I make my character 'flip' in Game Maker?

texts:
I want my character to 'flip' or 'mirror' when I press 'A' or 'S'.
Thing is, I've placed the origin everywhere on the character and he seems to only face one direction.

Video showing what I see: https://www.youtube.com/watch?v=1zZEDpO0yAM&feature=youtu.be

(This video shows the character not 'mirroring' or 'flipping' properly.)

I have done hours of research into this, and I get the same results: "Make sure the sprite has the center origin."

How would I accomplish this?


texts: How to best utilize depth buffer precision

texts:
Are there strategies to minimize depth buffer precision problems with hyperbolic depth buffers, such as the ones resulting from perspective projection matrices, or depth buffers in general?

For example, graphics APIs usually give an option to change the depth range, which might influence precision. It's possible to linearize non-linear depth buffers, for whatever reason. There's the option of floating point depth buffers, and non-floating point depth buffers. It's possible that changing the information in projection matrices has a result on the resulting range & precision of the depth buffer.

How do all of these things interact with the resulting range & precision, or with each other, and how do I get the maximum out of my depth buffer? Are there general good practices one should adopt, regardless of project specifics?


texts: How to create characters randomly with a given skill and weighted abilites

texts:
I am trying to create random characters in my game.
Each character has 33 abilities and one of 6 jobs. For each job you need to skill/increase other
abilities. I am calculating an overall skill (from 1 to 99) by using only the important abilities for this job. For example one of the jobs is a healer. Here you need to skill ability1 to ability6, which have also different weights.

Example:

 - Healer
 - Ability1 has weight 10 (skill 70)
 - Ability2 has weight 5 (skill 60)
 - Ability3 has weight 4 (skill 50)
 - Ability4 has weight 10 (skill 80)
 - Ability5 has weight 5 (skill 40)
 - Ability6 has weight 8 (skill 50)

 Example calculation:
(70 * 10) + (60 * 5) + (50 * 4) + (80 * 10) + (40 * 5) + (50 * 8) = 2600 /  (10 + 5 +  4+10+ 5+ 8) = 62

Problem:

I want to create random characters with random skills WITH a specific overall skill in HIS job. Example: CreateHealer(skill: 70).
It doesn’t matter which values all the other abilities have. For example if ability7 is 1 or 99 the overall skill of the healer is always 70, but I want them to be random because the user has the opportunity to change the job, if he can see that this char would be a better warrior.

My idea:

Create all 33 abilities randomly and calculate the overall skill in this job.

If skill is on the right level —> stop.
If skill is too low increase one of the weighted abilities and calculate again.
If skill is too high decrease one of the weighted abilities and calculate again.

Is there a better way/algorithm to do this?


texts:
I am trying to make a body flying

is there any way to change gravity or hold the circle levitating?

Here is the code i'm using:

public class Fly extends Enemy {

     .....
   protected void defineEnemy() {
    BodyDef bdef = new BodyDef();
    bdef.position.set(getX(),getY());
    bdef.type = BodyDef.BodyType.DynamicBody;
    b2body=world.createBody(bdef);

    FixtureDef fdef = new FixtureDef();
    CircleShape shape = new CircleShape();
    shape.setRadius(6/Advanture.PPM);
    b2body.createFixture(fdef).setUserData(this);

}

 @Override
public void update(float dt) {
   stateTime +=dt;
   b2body.setLinearVelocity(new Vector2(-1,0));
   setPosition(b2body.getPosition().x - getWidth()/2, 1);

  }

......
 }


texts: Finding the Balance - Income vs Expenditure

texts:
I'm working on a game idea that uses an in-game currency, and basic business (income/outcome).

Basically, a certain type of building will generate 'income' per seconds until it hits a certain capacity (per building).

There are many different types of buildings, each with their own 'rate', 'income' and 'capacity', as well as 'cost to purchase building' in the first place.

I want to know if there is a good tactic, or strategy on how to balance this out? I don't want to make the purchasing of the buildings too easy - so the user has to only wait a few seconds ... thats pointless.

And on top of that - each building can be upgraded, which basically increases the 'rate', 'amount' and 'capacity' - with each upgrade increasingly getting more expensive - however this is relative as the user is now getting more cash flow.

Thanks.


texts: Box2d - Attaching a fired arrow to a moving enemy

texts:
I am firing an arrow from the player to moving enemies. When the arrow hits the enemy, I want it to attach exactly where it hit and cause the enemy (a square) to tumble to the ground. Excluding the logistics of the movement and the spin (it already works), I am stuck on the attaching of the two bodies. I tried to weld them together initially but when they fell, they rotated in opposite directions.

I have figured that a revolute joint is probably what I am after. The problem is that I can't figure out a way to attach them right where they collide.

Using code from iforce2d:

b2RevoluteJointDef revoluteJointDef;
revoluteJointDef.bodyA = m_body;
revoluteJointDef.bodyB = m_e->m_body;
revoluteJointDef.collideConnected = true;
revoluteJointDef.localAnchorA.Set(0,0);//the top right corner of the box
revoluteJointDef.localAnchorB.Set(0,0);//center of the circle
b2RevoluteJoint m_joint = *(b2RevoluteJoint*)m_game->m_world->CreateJoint( &revoluteJointDef );
m_body->SetLinearVelocity(m_e->m_body->GetLinearVelocity());

This attaches them but in the center of both of their points.

Does anyone know how I would go about getting the exact point of collision so I can link these? Is this even the right method of doing this?

Update:

I have the exact point of collision. But I still am not sure this is even the method I want to go about this. Really, I just want to attach body A to B and have body B unaffected in any way.


texts: Legal and IP considerations with publishers and playable prototypes

texts:
I'm almost ready to send a playable prototype of a game to a publisher.  I've never worked with publishers.  What legal or intellectual property issues should I consider at this stage (if any)?

In this specific case the publisher is well known... perhaps this makes a difference.  Also the game is for a mobile platform.


texts: Transform.Rotate() rotation about one axis also rotates about the other axes

texts:
i'm new to learning unity and infact game development.Below i have setup a scene to learn about unity and i have encountered a strange problem that doesn't comply with anything that unity has documented.

I am rotating the camera (which is a child of my capsule game object, The object with Gradients highlighted in the photo, Capsule game object is a child of nothing) according to the user mouse movements.Here is the code i have written(Please ignore the commented lines for now)

      Vector3 a;
            rotateby = Input.GetAxis("Mouse X") * MouseSensitivity;// Rotate by is a float variable
            rotation.Set(0, rotateby, 0); // Rotation is a Vector3 i've declared
            transform.Rotate(rotation, Space.Self);

        /*       a = transform.localRotation.eulerAngles;
                 a.Set(0, transform.eulerAngles.y, transform.eulerAngles.z);
                 transform.eulerAngles = a;
        */

            rotateby = Input.GetAxis("Mouse Y");
            if (!invertY) { rotateby = -rotateby; }
            rotation.Set(0, 0, rotateby);
            transform.Rotate(rotation, Space.Self);

        /*       a = transform.localRotation.eulerAngles;
                 a.Set(0, transform.eulerAngles.y, transform.eulerAngles.z);
                 transform.eulerAngles = a;
        */

As you can see from the code when the user moves the mouse across Horizontal axes , i'm only updating the angle of rotation across the capsule's y-axis( rotation.Set(0, rotateby, 0) ) without updating the other two angles(x and y), which rotates it across its y axis.Similarly when the user does vertical mouse movement i'm updating only the z-angle of the capsule( rotation.Set(0, 0, rotateby) ) without updating the other two angles(x and y) again, so now it rotates across it's z-axis.Now it does what is expected, it is infact rotating across its z and y axes but it is also rotating across the x-axis in some cases.I am monitoring the values of the three angles(x y z) from the inspector.Look at how the capsule is titled towards the right , across its x-axis and also from the inspector below(look at the x-angle = -35)

Now the commented lines of code are a solution to this problem of rotating around the x-axis(as when the x-angle changes i'm again setting it to 0).But what i need to know is what have i done wrong in my code i'm never modifying the x-angle then why is it changing to -35??.I have read about local vs GlobalSpaces again and again but i can't find the answer to this.Also what i think is that it's not a Gimbal Lock because as the parenting order that unity uses is  Z-->X-->Y.So Gimbal lock could only occur if i rotate around the X-axis(Which i am not doing in my code) thereby aligning the Y-axis with the Z-axis.Why is this behaviour occuring, why is it rotating around its x-axis .Please Correct me if i am wrong, this is a barrier to my learning process cause i can't continue without clearing my concepts.

Thankyou, much obliged !

UPDATE:  I have trieed changing the 2nd parameter in transform.Rotate() method to Space.World , the problem of rotation about x-axis still happens but in some different mouse movement order.


texts: Can the Shuriken particle system create particles with random shapes and sizes?

texts:
I want to create differently sized (but small, relative to the characters) dust clouds for player movement that move away from the player and fade away by shrinking.

This animated GIF from Samurai Gunn demonstrates the desired effect (observe the brownish clouds that appear as the player attacks).

Can the Shuriken particle system do this? It should randomly create the dust cloud at various shapes and sizes. I'm assuming I'd need to supply the system with a sprite sheet to select from? Or is this just easier/better achieved by using an animated sprite in the scene?


texts: Are buffers in OpenGL associated with GLSL programs?

texts:
I have two different shader programs in my OpenGL code.

1- renders simple font using freetype
2- simple shader which draw primitive shapes.

I sent both of them some data using buffers, I understood that they are stored on server side, but are they associated with different programs? or any program can use any buffer data by just using         gBindBuffer(); ?


texts: how to center 3d camera vertically and horizontally

texts:
How to center the player/camera in the middle of the window/screen , to mimic a 2.5d camera, so it looks like this game:

where I can move vertically and horizontally , and the camera still be centered on the player?
Edit: I want to center it 18 pixels in the 4 directions


texts:
You may be familiar with ryhtm games as Dancing Line, Geometry Dash, or even Guitar Hero. They have something in common : every single action in the game is synchronized with the music. My purpose is to make a game like Geometry Dash where the player has to do some actions in rythm while the character scrolls automatically in the level. I have a few questions about this type of game :

Do I have to keep my FPS constant as it has to be always synchronized with the music ?
How can I build my levels with a music in mind to make sure that it will be synchronized ?

I am working on Unity using C#.


texts: Make object face another object on a sphere

texts:
I have a game I'm working on in Unity where there are two objects on a sphere at random locations (and random rotations). I want one of the objects to always rotate so that if it were to fire a bullet (the end goal) that it would fire at the other object along the shortest arc around the sphere.

The problem I'm facing is that I don't know how to create a rotation for an object that is on the surface of a sphere, and have it point towards the other object.

I can also see an issue after this where I would need it to point towards the other object in the shortest distance because there will always be two directions it can point towards.

Has anyone done something like this? Definitely stuck on this one.


texts: How to make ranked matches in a head-to-head multiplayer game?

texts:
I am working on a field hockey like game for Android and iOS.
Currently I support being able to play against another player online in a client/server fashion where one device host and the other provide an IP address.

I would like to be able to have ranked matches that are recorded in something like Amazon's GameCircle or something similar.

For recording the win/loses I thought having one leaderboard for wins, one leaderboard for loses and perhaps another leaderboard for amount of games in progress...

That is assuming I can read the leaderboard result for each player which I think I can.

Other than that, there are many issues in how to have ranked matches.
I am guessing the biggest difficulty is actually being able to have a client/server session since most devices are not set up to have a direction communication with another device?

What are your suggestions for having ranked matches given no extra server? And what are your suggestions given my own server?


texts: How do you break apart art into components for animation?

texts:
I am a programmer and brand new to the game world, trying to get a sense of what it would take to draw simple characters like you'd see in Don't Starve or indie games like that.

I have seen in their forums images of the characters all broken up into pieces, and found Spriter for windows, and eventually Spine 2D for mac which looks amazing. They have many tutorials that show taking a set of images, applying them to a skeleton, and animating them.

My question is, what is the workflow for creating the characters so you end up with all of these character parts, which you can then use in a skeletal animation?

Do you open up photoshop or some image editor, and just start drawing a foot or an eye?
Or do you draw the whole character first, and then methodically go through and break it apart into individual images?
If so, what is your workflow for doing that? In some of these broken apart images (like the above), many of the pieces overlap in some way.
So it's like, if you draw a complete arm, and then break it up into a hand, a forearm, and an upper arm, in the process of breaking it apart, you would have a technique for somehow closing off the ends where you made the cut, so it is "ideal" for animating. Is there a technique for this?

This is probably a really basic question.. I have been learning to draw by hand and wonder what things you want to pay attention to if you were preparing them for a game.


texts:
Is there a way to bring 3D objects into a 2D project that is using the 2D Universal pipeline for rendering light? I have some 3D objects I want to bring in to the project I'm working on, but they just get imported as pure white.
Is there a way to import 3D models into a 2D game, and keep the 2D pipeline for lighting? I'l tried a few different shaders, but if they're not pure white they're pink. I would like them to have shading as a 3D object, and still interact with light and rotate on all axis if possible. If it's impossible to use a 3D object, if there was a way to at least have a 2D sprite taken from a 3D object, but still react to light as if it were 3D, that'd work too I suppose. This is what it looks like,
https://i.stack.imgur.com/HJeIN.jpg
I've also tried adding 3D lights as well, but to no avail. I'm guessing the issue is because of my 2D lighting renderer, and for the record, this is what this tree looks like in a 3D project.
https://i.stack.imgur.com/nKCyd.jpg
I have since attached a custom shader graph to it that I made, it looks okay, but it still doesn't receive shading at all...
Thanks in advance.


texts: Slick2D crashes on Image.getGraphics() on some machines

texts:
On some machines, creating a new Image and calling getGraphics() on it causes lwjgl to enter into some kind of faulty state that crashes when swapping buffers. Any idea what causes this and how to make Slick clean up after itself properly?

Reproduction code:

package crashrepro;

import org.newdawn.slick.*;

public class CrashRepro extends BasicGame {
    public static void main(String[] args) throws Exception {
        CrashRepro cr = new CrashRepro("CrashRepro");
        // Crash only happens in fullscreen mode.
        AppGameContainer agc = new AppGameContainer(cr, 800, 600, true);
        agc.start();
    }

    public CrashRepro(String title) { super(title); }

    @Override
    public void init(GameContainer gc) throws SlickException {}

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

    @Override
    public void render(GameContainer gc, Graphics grphcs) throws SlickException {
        Image img = new Image(128, 128);
        img.getGraphics(); // This crashes the game.
    }
}

Stack trace:

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.lwjgl.opengl.WindowsContextImplementation.nSwapBuffers(Ljava/nio/ByteBuffer;)V+0
j  org.lwjgl.opengl.WindowsContextImplementation.swapBuffers()V+35
j  org.lwjgl.opengl.ContextGL.swapBuffers()V+3
j  org.lwjgl.opengl.DrawableGL.swapBuffers()V+0
j  org.lwjgl.opengl.Display.swapBuffers()V+39
j  org.lwjgl.opengl.Display.update(Z)V+44
j  org.lwjgl.opengl.Display.update()V+1
j  org.newdawn.slick.AppGameContainer.gameLoop()V+78
j  org.newdawn.slick.AppGameContainer.start()V+17
j  crashrepro.CrashRepro.main([Ljava/lang/String;)V+27
v  ~StubRoutines::call_stub


texts: Dealing with alpha for 2D per pixel lighting

texts:
Right now I've got a simple light shader. Every bitmap I draw goes through it to make up the scene. I only draw quads.

   texture tex;
   sampler2D s = sampler_state {
      texture = <tex>;
   };

bool use_tex;

float x = 0.1;
float y = 0.3;

   float4 ps_main(VS_OUTPUT Input) : COLOR0
   {
float4 p = Input.vPosition / Input.vPosition.w;
      float4 color = 0;
      float a = color.a;
      if(!use_tex)
        {
           color = Input.Color;
        }
        else
        {
           color = Input.Color * tex2D(s, Input.TexCoord.xy);
        }
      p += 1.0;
      p /= 2;
      p.y = 1.0 - p.y;

      float3 lightAttenuation = float3(0.05,4.0, 0.0);
     // float4 color = Input.Color * tex2D(s, Input.TexCoord.xy);
      float2 aux = float2(x,y) - p.xy;
      float dist = length(aux);
      float attenuation=1.0/(lightAttenuation.x+lightAttenuation.y*dist

+lightAttenuation.z*dist*dist);

      float3 lightAttenuation2 = float3(0.05,3.0, 0.0);
      float2 aux2 = float2(0.5,0.4) - p.xy;
      float dist2 = length(aux2);
      float attenuation2=1.0/(lightAttenuation2.x

+lightAttenuation2.y*dist2+lightAttenuation2.z*dist2*dist2);

      color = (float4(attenuation,attenuation,attenuation,1.0) * color * float4(1.0,0.8,0.8,1.0)

* 0.8)  + (float4(attenuation2,attenuation2,attenuation2,1.0) * color * float4(1.0,0.8,1.0,1.0)

* 0.2);

      return color;
   }

The shader calculates based on the current pixel's screen position.

The problem is when the pixel's alpha is != 1.0

It this case it would need to be multiplied by what is already in the backbuffer at that pixel location  in order to get the correct final pixel.

What can I do to fix the alpha issue and deal with the alpha case?

Thanks

PS2.0 hlsl.

Edit

Here are 2 images, the bright one is when the whole scene is rendered to texture then the shader is applied. The second is when I apply the shader on each fragment as the scene is rendered. This is an area where there is a dark shadow  on the ground. The shadow is a semi transparent bitmap. Thus it makes the lighting effect weaker and it makes it look weird.

What I want is a way for it to look like the first one, but still letting me do per fragment shading.  What I was saying was that I thought of maybe looking at what is already in the backbuffer, then multiplying it by the current pixel, then taking that result, applying the shader to it, then obviously you set the alpha to 1.0.

Im not sure if or how that could work. Im wondering either how to do that, or a better way to get the same result.

Here is my shader source:

   texture tex;
   sampler2D s = sampler_state {
      texture = <tex>;
   };

bool use_tex;

float x = 0.1;
float y = 0.3;

   float4 ps_main(VS_OUTPUT Input) : COLOR0
   {
float4 p = Input.vPosition / Input.vPosition.w;
      float4 color = 0;

      if(!use_tex)
        {
           color = Input.Color;
        }
        else
        {
           color = Input.Color * tex2D(s, Input.TexCoord.xy);
        }
     float a = color.a;
      p += 1.0;
      p /= 2;
      p.y = 1.0 - p.y;

      float3 lightAttenuation = float3(0.05,4.0, 0.0);
     // float4 color = Input.Color * tex2D(s, Input.TexCoord.xy);
      float2 aux = float2(x,y) - p.xy;
      float dist = length(aux);
      float attenuation=1.0/(lightAttenuation.x+lightAttenuation.y*dist+lightAttenuation.z*dist*dist);

      float3 lightAttenuation2 = float3(0.0,2.1, 1.0);
      float2 aux2 = float2(-1.5 + x,0.4 + y) - p.xy;
      float dist2 = length(aux2);
      float attenuation2=1.0/(lightAttenuation2.x+lightAttenuation2.y*dist2+lightAttenuation2.z*dist2*dist2);

      float4 c = (float4(attenuation,attenuation,attenuation,1.0) * color * float4(1.0,0.9,0.9,1.0) * 0.2) + (float4(attenuation2,attenuation2,attenuation2,1.0) * color * float4(1.0,0.8,1.0,1.0) * 0.2);

      color = c;

      color.a = a;

      return color;
   }


texts: How was/is playback of music handled on consoles such as the NES, Master System, Gameboy, etc?

texts:
So, I deliberately left out the SNES because AFAIK the music subsystem is basically entirely self-contained. However, on systems like the NES and Gameboy, while there are sound chips, there isn't any sort of dedicated sound CPU.

My question is how one reliably plays back music without putting too much of a burden on the CPU? Timing is clearly very critical: music won't sound right if the notes aren't played at exact intervals. Naively, one might just continually update the registers of the sound chip. However, this leaves no time for programming game logic! You could plan to update the registers every cycle in the main loop, but then any interrupts triggered would throw everything off.

I haven't been able to find any information on this, despite there seeming to be a clear conceptual gap! So basically, how does a game like say, Super Mario Bros on the NES manage to play back music consistently and reliably, regardless of what is happening on screen?


texts:
I understand how properly connected clients in a lockstep model deal with lag but what about the lagger? How does the lagger know that he or she is lagging? Should I continuously ping the central server?

Also, as the game follows the lockstep model, how does the lagger sync if he needs to? Should the desync be altogether prevented by fast pinging?


texts: Deferred Rendering: Orthographic directional light that has position

texts:
Basically I need to code a light for deferred rendering that is a cross between a spotlight and a directional (positionless) light.  It's to be used for sunlight, but because my terrain has overhangs and multiple layers, I can't use a directional light for the sun, as those affect everything in the scene, and do not cast shadows.

I would also prefer that the light uses a full screen pass like directional lights use, rather than rending the light using a cone geometry like spot lights do.

Does anyone have an example of something like this?  I've found a few resources but nothing that clearly shows how to code it up.  Language is irrelevant, but I would prefer C#.  Anything would be great though.


texts: Can't see which line exceptions occurred on in script source files

texts:
After updating Unity to the new 2017.1.0f3 version, I can't see which line in a source file an exception occurred on.

Example:

I can't see the source of the error by double-clicking in the console either, which would usually redirect me to the source file in Visual Studio. I can still see exceptions from the Unity and Mono API.

I have managed to temporarily fix it by going to the PlayerSettings and switching "Scripting Runtime Version" from "Stable (.NET 3.5 Equivalent)" to "Experimental (.NET 4.6 Equivalent)".

This happens to all MonoBehaviour scripts.


texts: What Game mechanic can I implement to give players incentive to finish a race?

texts:
I am essentially making deathrace the game. How do I give players incentive to finish or participate in the race instead of strictly deathmatching on the race track.

Edit More Detail:

General Race Rules:

Death during the race knocks you out of the race
Weapons  and defensive tools are picked by player at the start of the race where they are limited by the amount of "space" on the weapon and defensive system
Using a weapon increases the heat of the weapon system. certain weapons within a cars weapon system can only be used if the weapon systems temperature is below a certain threshold
Defensive systems are power based, where certain defensive tools can only be used if a cars power if above a certain threshold
Killing other players is fun but not required to win the race
Finishing the race or completing a lap or making progress around the track grants X

Where X is something I can't make appealing enough to dissuade player from just deathmatching on the race track.


texts: How to instantiate a prefab only when something is hit, and for some seconds?

texts:
How do I instantiate a prefab only when something is hit for a few seconds? I mean, I just need to activate the particle system when something is hit. Now it always runs, even before I hit something. I need it to activate the particle system when something is hit and for 2-3 seconds.

This is what I do now:

public void Shot()
{
    Destroy(gameObject);
    Instantiate(effect, transform.position, transform.rotation);
}


texts: Why do some games need to be rated by game rating boards?

texts:
I don't know much about why the games are rated in the first place, aside from the fact that it may help customers to filter out the games that aren't appropriate for them due to age or personal preferences.

Are there any other benefits to completing the rating procedure of a game?

I wonder if it is required at all to have your game rated by a local rating board. And what about countries that don't have their own game rating boards?


texts: Playing Video for Splash screens etc using Monogame

texts:
I've been searching around on internet a way to display a video using XNA/Monogame. But everything tend to go in the direction of the class Microsoft.XNA.Framework.Media.Video. Unfortunatly, my xna Framework does not contain any Video member in the Media namespace as shown below. Also i've found this stackhex question which is the same question but the answer contains a gist with the code that does not exists anymore, so i'm a bit stuck here.

i'll appriciate any help, thank you for your time

After the recommandations of @Steven, i've tried to see what visual studio give me for replacement, What i've ended up with is the Video Class turning into the enum VideoSoundtrackType which is not a video or video player class.

public SplashScreenScene(GraphicsDevice gd, ContentManager contentManager, SpriteBatch spriteBatch)
{

   GraphicsDevice = gd;
   ContentManager = contentManager;
   SpriteBatch = spriteBatch;

   SplashScreenTexture2DAnimation = new NonRepeatingTexture2DAnimation();

   XDocument xmlDoc = XDocument.Parse(System.IO.File.ReadAllText("Content/Animations/SplashScreenAnimationMetadata.xml"));

   SplashScreenTexture2DAnimation.LoadAnimation(xmlDoc, contentManager);
   DisplayOffsetMatrix = new OrthographicCamera(gd).GetViewMatrix();

   var Video = new VideoSoundtrackType();

}

here is the enum from meta data

NB: for the moment i've created a class that holds texture2Ds to make an animation. But if I want to create cinematics it will be a bit difficult (or i can create simple story telling through images and text like undertale and other did).


texts:
I am working on a simple two player networked asteroids game using XNA and the Lidgren networking library. For this set up I have a Lidgren server maintaining what I want to be the true state of the game, and the XNA game is the Lidgren client. The client sends key inputs to the server, and the server process the key inputs against game logic, sending back updates. (This seemed like a better idea then sending local positions to the server.) The client also processes the key inputs on its own, so as to not have any visible lag, and then interpolates between the local position and remote position.  Based on what I have been reading this is the correct way to smooth out a networked game. The only thing I don’t get is what value to use as the time deltas.

Currently every message the server sends it also sends a delta-time update with it, which is time between the last update. The client then saves this delta time to use for its local position updates, so they can be using roughly the same time deltas to calculate position updates.

I know the XNA game update gets called 60 times a second, so I set my server to update the game state at the same speed. This will probably only work as long as the game is working on a fixed time step and will probably cause problems if I want to change that in the future. The server sends updates to clients on another thread, which runs at 10 updates per second to cut down on bandwidth.

I do not see noticeable lag in movement and over time if no user input is received the local and remote positions converge on each other as they should.  I am also not currently calculating for any latency as I am trying to go one step at a time.

So my question is should the XNA client be using its current game time to update the local game state and not being using time deltas sent by the server?  If I should be using the clients time delta between updates how do I keep it in-line with how fast the server is updating its game state?


texts: Prime31 Plugin Error : "Plugin 'P31RestKit.dll' is used from several locations"

texts:
I got the following error, when i tried to install "Prime31: MicrosoftAds_2015-04-22" plugin in Unity 5

Plugins colliding with each other
Plugin 'P31RestKit.dll' is used from several locations: Assets/Plugins/P31RestKit.dll would be copied to /P31RestKit.dll, Assets/Plugins/WSA/P31RestKit.dll would be copied to /P31RestKit.dll .Please fix plugin settings and try again.

Thank you


texts:
I have a edge collision problem with a simple game that i am developing. Its about throwing a coin across the screen. I am using the code below to detect edge collisions so i can make the coin bounce from the edges of the screen.

Everything works as i want except one case. When the coin hits left edge and goes to right edge the system doesnt detect the collision. The rest cases are working perfectly, like hitting the right edge first and then the left edge.

Can someone suggest a solution for it?

public void onMove(float dx, float dy) {
 coinX += dx;
 coinY += dy;

  if (coinX > rightBorder) {
    coinX = ((rightBorder - coinX) / 3) + rightBorder;
  }
  if (coinX < leftBorder) {
    coinX = -(coinX) / 3;
  }
  if (coinY > bottomBorder) {
    coinY = ((bottomBorder - coinY) / 3) + bottomBorder;
  }

  invalidate();
}


texts: How should the physics be on an halfpipe like in a skate game in Unity?

texts: I am making a inline skating game. My player is skating based on the normals of the surface of the ground. But when I skate up a halfpipe it flies in the Air but doesnt comes down like it should be, it changes position in the Air and my player falls horizontally on the ground I cant get up anymore like this when he is lying on the Ground. I want it to be physically jump up and come down again the player should align on the ramp again not just fly in the air and drop down on the ground? What infos should you need to answer this question properly I will edit the question then?


texts: Unexpected behavior of bodies affected by gravity in 2D

texts:
I have a simple code that calculates the acceleration of a body every update of my simulation using the Newton's law of universal gravitation and the second law of motion.

def move_bodies():
    def get_dist(b1, b2):
        return math.hypot(b2['x'] - b1['x'], b2['y'] - b1['y'])

    for body in bodies:
        acceleration = 0
        angle = 0

        for other_body in bodies:
            dist = get_dist(body, other_body)

            if body != other_body:
                angle = math.atan2(other_body['y'] - body['y'], other_body['x'] - body['x'])
                acceleration = (GRAVITY_CONSTANT * body['m'] * other_body['m'] / dist ** 2) / body['m']

            body['x'] += math.cos(angle) * body['vx']
            body['vx'] += acceleration

            body['y'] += math.sin(angle) * body['vy']
            body['vy'] += acceleration

when these bodies interact, something unexpected happens when their x/y values are approaching one another -- the bodies move at extremely high speeds and seemingly disappear off the screen.

For example, if we have a body at (200, 100) and another at (200, 300), they do not gravitate towards one another as they would do in a situation where they have unique (x, y) values such as (200, 100) and (300, 400).

Looking at the code, as the y-values of body and other_body approach one another, values get exceedingly large(?)

I can't quite pin down the issue as I'm a beginner. Any suggestions/criticism?


texts: how do I make an enemy target an ally unit?

texts:
I have 2 different classes, a EnemyFighter class, and a EnemyBomber class. both are planes that I have that can fly around the map.( i also have AllyFighter, and AllyBomber)

So far they can follow me, and eachother, but how would I set up a target variable or something?

like I could set up a target variable for the enemyfighter

AllyFighter target;

and a variable holding the location of the allyfighter as a Vector2.

but then what if I want to target an AllyBomber? do I have to make 2 variables? or is there some other approach I should take?

Thanks

EDIT:
Maybe a better question would be how can I target different enemy types (ones with different classes)? or at least hold there information in a 'target' variable


texts: How can one create "network effects" in a game as it scales?

texts:
Is it possible to create network effects in a game? How?

Usually a product with network effects present gets more valuable to a user as more people have the same product. Examples can be Skype or Facebook. The more people are using them, the more it's important to a single user.

Does it even matter in games?


texts: Im working on a "game" that uses lua for scripting and i plan on making it very mod-able. However, malicious code can be written without much difficulty in lua... So how can i go about stopping that? I could block certain functions, but that wouldn't be nice for the modders and those who really want to will find another way.


texts: Why only few parts of the 2D sprite change their colour when I apply sprite color in Unity?

texts:
I'm making a stickman 2D game where I have different sprites for the player.

But when I try to change the Sprite Renderer Color, it only changes few pixels of the sprite and the rest stays black as in the original sprite.

What am I missing?


texts: game physics: contact constraint and relative velocity

texts: For two rigidbodies (2D boxes), A and B, I have been colliding A with B and finding the collision normal pointing towards A i.e. the direction that would separate A from B. When it comes to calculating the relative velocity for the contact constraint, does it matter which body has the edge that the collision normal is perpendicular in terms of which velocity to subtract from which?


texts: How to use a multi-thread OpenGL application to update VBOs and use them at the same time?

texts:
I have a simple application. It has two threads, each with its own rendering context, but they share one VBO (this is working, I tested it).

Now what I want: One thread is rendering some data from the first half of the VBO and the second thread is updating the second part of the VBO.

When I don't update the VBO, it's working fine.

But I have some weird issues when updating. When I use glMapBuffer to update the VBO (in the second thread), in the first thread, most of the time, it renders nothing—the whole screen is clear (after a glClear call). It looks like it can't touch data from the VBO (this is understandable, because the whole buffer is mapped and so it can be locked somehow).

I tried to use glMapBufferRange, which uses GL_MAP_UNSYNCHRONIZED_BIT. This should mean, "don't wait and use the VBO as you want, I (the program) will synchronize it by myself". Also, when I map a range of VBOs and render data from another part, it shouldn't be waiting, but I'm experiencing the same issues as I am with glMapBuffer.

Can anybody help me fix this or explain why it happens?


texts: Special Texture Stretching without deformation

texts:
I am trying to achieve a special texture stretching effect in my shader.
Here is how I define my uv before sampling my texture, nothing really special.

// uv_ST contains the tiling and offset values
uv.xy = uv.xy * uv_ST.xy + uv_ST.zw

This gives the standard tiling/stretching and offset behaviour when you tile/stretche a clamped texture as you can see in the image below. First is normal, second is offset and last is stretching.

But I want to avoid the deformation behaviour when stretching, I want to keep margins when stretching my texture or simply cut it in the middle and stretching it. Here is an illustration below.

How could I do that inside my shader when defining my uvs before sampling the texture ?


texts: Drawbacks of using reflection for a component based system at loading-time

texts:
I'm coding a little casual game in Java using Slick2D.

This game use a lot of different "objects", managed in a composite way. So, firearms, furniture in the map, NPC and player character will be composites objects using components to define their behaviors.

Since I'm going to need a lot of, for instance, "shotgun" object, I'm using a sort of prototype pattern. When the player starts the game, XML files are read, and from those XML, typical objects are built and stored in a "EntityPool" class' hashtable. Then, when I'll need a shotgun, for instance, I'll ask for it to the EntityPool, which will give me a clone of this object.

My problem is as follow : I'm using JDOM to parse my XML. I don't know how many components I'm going to use, nor their exact methods. So I'd like to use reflection; a Class.forName(nameOfMyClass) in order to get the exact component for this class, and then a Class.getMethod("set" + propertyName) to fill the information I need.

So my XML can be like that :

<Entity name="window">
  <Component class="Breakable">
    <health>12</health>
    <newEntityAfterBeingBroken>brokenWindow<newEntityAfterBeingBroken>
  </Component>
  <Component class="Renderer">
     <tileset>object.png</tileset>
     <imgnum>2</imgnum>
  </Component>
</Entity>
...

There are obvious drawbacks to using reflection, particularly the lack in performance. But this is done only once, when loading the game. Do you see other problems with this method? Would you do it differently, and how? Thanks in advance for your advice!


texts: Unity - Mesh importing as child of armature

texts:
I'm following along with this tutorial by Sebastian Lague: https://www.youtube.com/watch?v=yhPRkihs-Yg&list=PLFt_AvWsXl0f4c56CbvYi038zmCmoZ4CQ&index=14
However, when I import my character from Blender into Unity, the sword and shield mesh are children of the armature instead of siblings like the shirt/pants/shoes/etc. I'm fairly certain this is because the sword and shield are parented directly to bones on the hands, I'm just not sure why they import as children of the mesh unlike in the video.


texts: How do I implement bullet spread in three-dimensional space?

texts:
How can I shoot a bullet in three-dimensional space in such a way that its path diverges a bit, randomly, from the direction in which the gun is pointed?

I know I have to use the Quaternions, but I don't know how exactly.

Should I convert Quaternion to EulerAngles

Quaternion randomRotation = Random.rotation;
Vector3 inEuler = randomRotation.eulerAngles;

or is there a fairer / nicer way to do it?