texts:
I'd recently asked a question for getting started in game development from where I was suggested for the book "Killer Game Programming-Java".

On the page there is a java 3d program which needs to be installed. I'd downloaded and installed java3d file from here and also from the sun/oracle's site. But the program given there is not working.

I would like to know how to install that java3d package in Ubuntu 10.10, and also is there any need to set environmental variable $PATH or classpath for java, and if so, how to do that?

The downloaded version of java3d is 1.5 and it is a .bin file.


texts: Use different values for Depth Test and Depth Write in OpenGL

texts:
Is there a way to use something similar to PolygonOffset to make a depth test more permissive (move fragment depth towards eye) but still write the original depth value to the depth buffer? The only thing I can come up with is a tricky two pass solution using a stencil buffer, but I'd like to avoid that if possible.

Context of my question: We have an entity with a particle based smoke plume that is often in front of a semi-transparent building. Do to some constraints with batching, the building gets drawn after the smoke plume. Originally the smoke plume particles were rendered with a depth test but no depth write. This caused the building to be drawn on top of the smoke.

Turning the depth write on for the smoke particles fixes the building, but now the smoke particles interfere with each other. Ideally, I'd like to find a way for them to stop interfering while still writing to the depth buffer.


texts: How to prevent showing outside of Game Map ( Cocos2D-x ) ( Scrolling game )

texts:
I'm trying to make a tower defense game and it can zoom in/out and scrolling over my world map. How to scroll over the game and how to restrict it not to show outside of my map(black area).

At below I scroll over the map by using CCCamera but I don't know how I can restrict it.

CCPoint tap = touch->getLocation();
CCPoint prev_tap = touch->getPreviousLocation();
CCPoint sub_point = tap - prev_tap;

float xNewPos, yNewPos;
float xEyePos, yEyePos, zEyePos;
float cameraPosX, cameraPosY, cameraPosZ;

// First we get the current camera position.
GameLayer->getCamera()->getCenterXYZ(&cameraPosX, &cameraPosY, &cameraPosZ);
GameLayer->getCamera()->getEyeXYZ(&xEyePos, &yEyePos, &zEyePos);

// Calculate the new position
xNewPos = cameraPosX - sub_point.x;
yNewPos = cameraPosY - sub_point.y;

GameLayer->getCamera()->setCenterXYZ(xNewPos, yNewPos, cameraPosZ);
GameLayer->getCamera()->setEyeXYZ(xNewPos, yNewPos, zEyePos);

And for zooming I used such code:

GameLayer->setScale(GameLayer->getScale() + 0.002); //zooming in


texts: How to animate fluid filling down a pipe of any shape?

texts:
I am working on a project where I want to model a simple flow of fluids around a circuit of pipe. I thought a simple way to do this would be to create an irregular shaped loading bar, then animating the shape as it filled up.

I have found answers for how to create regular loading bars that are rectangle shaped, as well as some for circular loading bars.

But what if want some arbitrary "circuit" of pipes, kind of like one long windey loading bar.


texts:
I'm trying to learn OpenGL and i'm using SOIL to load images.

I have the following piece of code:

GLuint texID = 0;

bool loadCubeMap(const char * baseFileName) {

    glActiveTexture(GL_TEXTURE0);

    glGenTextures(1, &texID);
    glBindTexture(GL_TEXTURE_CUBE_MAP, texID);

    const char * suffixes[] = { "posx", "negx", "posy", "negy", "posz", "negz" };
    GLuint targets[] = {
        GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
        GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
        GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
    };

    for (int i = 0; i < 6; i++) {
        int width, height;
        std::string fileName = std::string(baseFileName) + "_" + suffixes[i] + ".png";
        std::cout << "Loading: " << fileName << std::endl;
        unsigned char * image = SOIL_load_image(fileName.c_str(), &width, &height, 0, SOIL_LOAD_RGB);
        if (!image) {
            std::cerr << __FUNCTION__ << " cannot load image " << fileName << " (" << SOIL_last_result() << ")" << std::endl;
            return false;
        }
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
        SOIL_free_image_data(image);
    }

    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
    glGenerateMipmap(GL_TEXTURE_CUBE_MAP);

    glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
    return true;

}

When i call this, the images load successfully, but then i get an error in console:

---- OGL DEBUG ----
message <1>: 'API' reported 'Error' with 'High' severity:
GL_INVALID_OPERATION in glGenerateMipmap(incomplete cube map)
---- BACKTRACE ----

and no cubemap is displaying at all.
Do you see any mistake in this code?


texts: Beginner C# image loading woes - NullReferenceException

texts:
I keep getting a "NullReferenceExeption was unhandled" with "Object reference not set to an instance of an object." written under it. I have all of the images (png) correct with names and added to references.

protected override void LoadContent()
{
    spriteBatch = new SpriteBatch(GraphicsDevice);
    backGround = Content.Load<Texture2D>("Cracked");
    player1.playerBlock = Content.Load<Texture2D>("square");
    player2.playerBlock = Content.Load<Texture2D>("square2");
}


texts: How can I determine that a user actually followed me to give them an in-game reward?

texts:
I have seen many apps where they will reward you if you follow them on social media. However, all you need to do is click on the link and then close the browser opened up and you will still be rewarded.

I would like to be able to spread my app through social media. I want people to get a reward only if they follow me so that the game can be spread through social media.

This does nothing if all they have to do is click on a link and then they can close the browser. Is there a way that I can only reward the user if they have actually followed me on social media.

Thanks


texts: Simple LibGDX Pong game drag player instead of getting x position

texts:
I got a working pong game in LibGDX but when I touch the screen the player x automaticly jumps to the coordinates I touched. I wan't my game to detect I touched and then move the player to the left/right if I swipe my finger to the left or the right.

This is what I tried so far:

if(Gdx.input.isTouched() && Gdx.input.getY()>240*screenheight){
  if(tapped)TouchX = Gdx.input.getX();
    tapped = false;
    DragX = Gdx.input.getX();

    distance = player.getX() - TouchX;

    PlayerX = Gdx.input.getX() + distance;

    Gdx.app.log("PlayerX "+player.getX(), "Distance "+distance);
    Gdx.app.log("DragX ", ""+DragX);
}else{
    tapped = true;
}

Here I update the player X coordinates

player.setX(PlayerX);

Does anyone know how to make this work?


texts: Load Unity game launch options from file

texts: I have a need to disable the resolution dialogue when the game launches, but have a config file that will have all of the dialogue options (resolution, quality, monitor (monitor is most important, because none of the solutions to change the active monitor after launch have worked out with a decent result)). Is there a way for a unity game to load options from a file instead of the resolution dialogue?


texts: Stuck on walls or sliding on top dilemma

texts:
I'm making a 2.5D platformer game. I earlier had problem with my character getting stuck on walls when holding the forward button. I solved this problem by adding a physics material with zero friction to my colliders on the wall. So now when hitting a wall the character slides down, which is correct.

My walls consits of 1 unit cubes tiled together, and box colliders are generated and merged at runtime.

Now I've created a ladder and by pressing a button the player will rotate 180 degrees, and I also add some force along the y- and z-axis:

var force = -transform.forward + Vector3.up;
force.y *= JumpOffForceY;
force.z *= JumpOffForceZ;
_rigidBody.AddForce(force, ForceMode.Impulse);

Now when the player lands on the top of the wall, which has the same box collider, and physics material, the player slides very jerky for a long time before coming to a halt.

I understand why this happens, I've been trying to find a solution. One solution I'm thinking of is to change my algorithm that creates the box colliders and divide them so there is one box collider on the top with higher friction, and one for the walls with zero friction. Before I delve into that, is that a good solution? Or is there any other way?

Have a nice day!


texts: Assigning IDs to entities and obects for use in scripts and by other objects

texts:
I'm currently planning a small, simple scripting system for my game engine that will allow me to easily define scenes (similar to the "cutscenes" found in 2D RPGs). It consists mainly of simple commands such as "Change scene", "Move to" and so on.

Some of these scripting commands require operands. For example, the "Move to" command should expect an entity ID and a target node ID (where the node is just another placeable object). The aim is that whenever you create an entity, map or other object in the editor, it is assigned an ID that other objects and scripts can use to refer to it easily. These IDs will be stored when the game loads its data and used during runtime to make sure I'm targeting the correct object when an interaction occurs.

The problem I'm having is in how best to assign IDs to these objects of interest. I thought about just automatically assigning an incremented integer ID to new objects, but was unsure of how I should deal with the possibility of stale references. As I work in the editor, I may add and then later remove an item that was assigned an ID when it was created. If I delete an item that previously had an ID, should that ID be released for use by something new, or should I just leave a gap? Also, how should I keep track of assigned IDs between uses of the editor so that I can easily avoid collisions and also check easily for stale references?

For example, if I was to (either accidentally or intentionally) delete door A that is linked to door B, what would be the simplest way to check for any stale references, so that door B can be known to refer to something that no longer exists? Is it literally just a case of iterating through every object and seeing if any IDs it refers to are there or not?

I have the same problem when trying to decide how best to refer to the game's central list of items, spells, etc. These are the things that can be considered a core part of the game, but may be modified or removed over time. How can the game deal with a situation like the deleting of an item that has already been put in numerous places (i.e containers) in the game world?

Thanks in advance for any enlightenment you can offer with the above.


texts: What graphics library should I use for line rendering for a raycasting renderer?

texts:
I want to develop simple RPG with ray casting rendering. I chose SDL for graphics and input. The problem is there is no native line drawing in it, which I need to start prototyping a ray casting engine.

I know about SDL_gfx, which can do this, but I am asking if there is any alternative to SDL with primitives drawing functions for C++, which is easy to learn, and is also used by indie game developers?


texts: Need some help with math steering behavior stopping on destination point

texts:
I have implemented a movement system based on steering behaviors: http://gamedevelopment.tutsplus.com/series/understanding-steering-behaviors--gamedev-12732 where each object has vec2 position, velocity, desiredPosition with 2 constants: maxspeed and acceleration. In each game step, the object's position is updated as follows:

vec2 desiredVel = this.desiredPos - this.position;
desiredVel.truncate(this.maxSpeed);

vec2 steeringForce = desiredVel - this.velocity;
steeringForce.truncate(this.acceleration);

this.velocity += this.steeringForce * dt;
this.velocity.truncate(this.maxSpeed);

this.position += this.velocity * dt;

The problem is stopping. I have been stopping by using a scaling factor that reduces the desiredVel when the object is within a certain distance of the target position:

var dist = desiredVel.length;
if (dist < this.maxSpeed * this.maxSpeed / this.acceleration){
    this.desiredVel *= dist/this.maxSpeed;
}

This goes between the desiredVel calculation and steering force calculation.

Unfortunately, this method is not very exact. Sometimes the object will overshoot its destination and sometimes it will slow down way before the destination is reached. Is there a way to make the object stop on the destination point? That is, it should not overshoot nor slow down prematurely.

Edit: and yes I have seen the arrival section in the link I posted above and it shares this same inexactness. What I want I guess is for the path to look more realistic. That is the object accelerates at the start of path to its max speed then it decelerate at the right timing so that it stops at the destination exactly. (or close enough)

And 2ndly, I also want to know the time it takes for an object to reach from pointA to pointB before the object takes its path. The maxspeed and acceleration is constant and there are no other forces acting on the object within the path. How can i calculate the time?


texts:
I get the DXGI_ERROR_DEVICE_REMOVED error on some machines. According to this (https://msdn.microsoft.com/en-us/windows/uwp/gaming/handling-device-lost-scenarios) MSDN article this can happen and it should be handled by your application.

I've managed to recreate the device but I'm unsure how to handle all content. It seems I have to create all vertex buffers and textures again, which essentially means I have to reload almost the entire scene. Is this really the correct way?


texts: ConcurrentDictionary as a main container for game objects?

texts:
I wonder if it is wise to use ConcurrentDictionary as a main container in a game? That is it will be used to:

update every object inside it in a parallel.Foreach loop;
add (but not remove) objects inside it in a parallel.Foreach loop (sometimes while updating);
retreive data from the dictionary with a Linq query/ simply by index in sometimes a parallel loop, but mostly in the main thread;
remove data from it in a parallel loop (but NOT when updating objects) <- this step can be done in the main thread.

What could be the disadvantages of this list compared to HashSet (we are using the latter now, but we are only reading from it in parallel - when updating models). What lists are used in big engines?


texts: Change Text - Inside A button, inside a Canvas, inside a GameObject: Access all the texts inside of hierchy?

texts:
//....
Gameobject tile;
int count = 1f;
float posX = 0;
float posY = 0;
....//

GameObject blueTile = (GameObject)Instantiate(Resources.Load("block_blue"));
tile = (GameObject)Instantiate(blueTile, transform);

for loop {
   ...
   ...
   tile.GetComponent().GetComponentInChildren().text = count.ToString();
   tile.transform.position = new Vector2((float)posX, (float)posY);
   count++;
}

As you can see by the image.
My line of thinking goes like this; I used to create Flash/AS3 Applications and Games. I have used a number of API's and they usually have a lot in common. Unity, however, is very different and I may have not grasped the key concepts.

I want to access my PreFab, named in Assets/Resources (the root path)

"block_blue"

All I wan to do is set up a row and columns of a box with a number inside of it.

Before you go and ask, why the complicated mix of Objects? Well, Adobe had MovieClip and use of layers and also use of a timeline. Unity doesn't seem to have this in setting up a Scene (the Stage in Flash).

So, I set up a block that looks like this (right of main image 66):
It's a Canvas, to hold a Button, the button has a text. To move the Canvas, I put the Canvas inside a GameObject. This, to me, is like a MovieClip in Flash API.

**GameObject > ButtonLight, Button > TextBlack, Text**

I need to access TextBlack and also Text. Pretty easy right? I've been at this for 4 days, many many hours.

EDIT: It seems that it is working, somewhat.

Looking at the reference photo and the Hierarchy reference, it looks like the blackText behind the blueText is changing as expected. But I cannot access the top BlueText. The Blue Text is also a child of type Text, but it's a second (layer?) copy of the text inside of the Button. So, it's getting the first Child Text, but how to access the second Text?


texts: Procedurally generate with different sized cubes

texts: I am trying to procedurally generate my world like in Minecraft with tons of blocks. I have watched lots of videos about this but they all use a single fixed size cube. I would like to achieve the same as in Minecraft but with different sized cubed for example. How could this be done? I am using Perlin Noise for generation.


texts: Draw a line trailing behind a moving object

texts:
I'm working with monogame, moving a sprite object up and down. I want to draw a trail from the sprite's position and scrolling off to the left of the screen - like the sprite was a pencil leaving marks on a long sheet of paper sliding underneath it.

Here is an animated example:

I know how to move the sprite up and down but I'm a bit lost on how to do the trailing part. If someone could point me in the right direction I would really appreciate it


texts: How can a resource manager have dynamic loading/unloading without creating dangling pointers?

texts:
I have a resource manager that manages the lifetime of resources in memory. A "resource" is something like a texture, mesh, et cetera. I also have an entity class that, the base class for things in my game world, which has pointers to individual resources.

I'm thinking about giving my resource manager a memory quota so it can free and reload resources as it needs to in order to satisfy this quota, and I'm wondering how I could go about this without ending up with dangling pointers in my entity objects.

I'll need the ability to free up a mesh or texture at any time in the resource manager.

I could use shared_ptr in the resource manager and weak_ptr in the entities (as long as I don't expose a shared_ptr out side of the resource manager, I'd still get the ability to free them on demand), but I am more interested in how you would do it without those classes, for example before C++11 existed or before Boost's smart pointer library existed.


texts: Google Play Services and COPPA Compliance

texts:
I hesitated to ask this question here, since i'm not sure there is a definitive answer (but there can be, maybe i missed it).

I'm implementing Google Play Services for a game on Android target at all audiances, including children under 13.

So, I was wondering, does the use of achievements comply with COPPA rules?
On one hand the app is not using personal informations (only reporting progress of achievements, which can be score, or number of games... nothing personal), BUT on the other hand, the authentication itself to google play games seems to be personal information sent to the internet (the auth process itself).
I'm already using admob with the tagForChildDirectedTreatment.

So i was wondering, if achievements (and maybe leaderboards) need specific steps to comply with COPPA, is there something like this tagForChildDirectedTreatment but for achievements, ... or do I have to show a panel to get parental authorization? Or maybe set the google play connection as optional, not default as written somehow here?

The reason why i'm so concerned by this is this little $16000 fine i read several times, in case you don't respect whatever has to be respected.


texts: Maya: after bake into control rig, IK will auto reset when I change another IK

texts:
Arter setting one IK on my control rig, when I start to set the next IK, the previous one resets to its prior state.

Here's an example of my problem:

How can I keep the previous IK from resetting?


texts: How do I make a shaped fluidSurfaceActor in UDK?

texts:
I'm trying to make a fountain for my level in UDK. I've made the base of a fountain by using a Cylinder build and now I'm trying to put water in it. I want to use the fluidSurfaceActor but I notice that it's square, while my fountain is a cylinder!

Is there a way I can change the shape of the fluidSurfaceActor to fit the builder brush shape or is there another way to do this?

Here is a picture of what I'm talking about:


texts: Unity tiles with wierd border flickering when moving horizontal 2D

texts:
I recently made some Tiles using a program called Pyxel Edit to create some placeholder graphics. The problem I'm having is that when I move the camera horizontal the edge of the tiles starts to flicker, however if I move the camera vertical it wont.

This is my settings for the Tilemap, I have sliced them up inside the sprite editor.

This is a gif of what I'm talking about:

The image maybe isn't that clear but if you watch closely you can see some borders appear when I'm moving.

Do anyone know what could have caused this and what could be done to fix it?

EDIT: Second image for clarity:


texts: Combining and drawing 2D lights in OpenGL

texts:
I have progressed to the lighting portion of my little framework and I managed to solve a few initial problems so now I'm left with the subtle weirdnesses.

At this stage I just have 2 lights - the ambient daylight and a hard-coded example light in my fragment shader (ultimately, I want to have multiple lights that I loop through adding together, and shadows would be nice too, but 1 step at a time!):

        uniform sampler2D u_image;

        varying vec2 v_texCoords;
        varying vec4 v_position;

        uniform vec3 ambient_light; // set as (0.3, 0.3, 0.3), night!

        vec2 point_light_pos = vec2(-0.4, 0.3);
        vec3 point_light_col = vec3(0.999, 0.999, 0.999);
        float point_light_intensity = 0.4;

        void main()
        {
            vec4 frag_color = texture2D(u_image, v_texCoords);
            if(frag_color.a < 1.0)
              discard;

            float distance = distance(point_light_pos, v_position.xy);
            float diffuse = 0.0;

            if (distance <= point_light_intensity)
                diffuse =  1.0 - abs(distance / point_light_intensity);

            gl_FragColor = vec4(min(frag_color.rgb * ((point_light_col * diffuse) + ambient_light), frag_color.rgb), 1.0);
        }

Which almost does what I want, but there are 2 problems:

The light has a bright ring in it and the light is squashed on the y-axis. I actually like how it looks squashed at this ratio, but I'd much rather do it deliberately.

I the y-axis squashing is down to the window aspect ratio - if the window is square, the light is circular, but I don't know how to fix this in the fragment shader.

I don't know where the bright ring is coming from.


texts: Unet, client is unable to control spawned units

texts:
I am trying to create a simple table top game with Unet. Right now I am just trying to get simple spawn mechanics working. The issue I am having is that the host computer can spawn and control objects correctly. The object gets instantiated, it gets added as a child to the armylist gameObject correctly. The client is able to see the object move around. Etc. Everything is working correctly it appears from the host side.

The client however, can only instantiate a game object then they lose all reference to it. Also when it gets instantiated it does not become a child of the correct object, it is just its own object in the scene without a parent. The host computer can see the object be spawned.

I am not sure what I am doing wrong, I have tried reading the documentation but to no avail. Any help would be greatly appreciated.

public class PlayerManager : NetworkBehaviour {

[SerializeField]
GameObject tank;
[SerializeField]
Camera PlayerCamera;

[SerializeField]
GameObject[] ArmyList = new GameObject[50];

private Vector3 placePos;
GameObject currentUnit;

void Start () {

}

void Update () {
    if (Input.GetKeyDown (KeyCode.A)) {
        Cmd_place_initial_units ();
    }
    Rpc_PlaceUnit ();
}

[Command]
void Cmd_place_initial_units(){
    currentUnit = Instantiate(tank, placePos, Quaternion.identity) as GameObject;
    currentUnit.transform.parent = transform.GetChild(0);
    ArmyList [0] = transform.GetChild (0).GetChild (0).gameObject;
    NetworkServer.SpawnWithClientAuthority (currentUnit, connectionToClient);
}

void Rpc_PlaceUnit(){
    if (ArmyList[0] != null) {
        RaycastHit hit;
        if (Physics.Raycast (PlayerCamera.ScreenPointToRay (Input.mousePosition), out hit)) {
            if (ArmyList[0].tag == "ground") {
                placePos = new Vector3 (hit.point.x, 1f, hit.point.z);
            } else {
                placePos = new Vector3 (hit.point.x, 1.2f, hit.point.z);
            }
            ArmyList[0] .transform.position = placePos;
        }
    }
}
}


texts: How to decompose a rectangular shape in a Voronoi diagram, only generating convex shapes?

texts:
I think this is a very straighforward question, lets say i have a building in 2D, a rectangle shape. Now i want to decompose that area in a lot of convex shapes, as seen in a voronoi diagram, or closely like it, just so I can add those shapes to the physics engine, and have a realistic destruction.

Bonus: Possible suggestions on how to make the effect more dynamic and interesting.

Please keep in mind we re talking about realtime calculations..


texts: Memory-Efficient, Optimized Terraria-Like 2D Lighting

texts:
I am working on a terraria-clone and I am aiming for it to be able to be run on most Android devices. I am able to generate a world, jump around, etc but I am not looking to add in some efficient lighting. In the past I have tried doing a tile-based lighting system but the project quickly came to an end after that because it dropped performance hugely. In that demo I was drawing a transparent black square over each tile and setting the alpha value dependent on surrounding lights. I envision that this will not be efficient on mobile so I don't even know if I want to go down that road. I don't need the shadows or anything like that (as of right now), I just need the lighting portion implemented. I have also looked at the other suggestions on the page here but am not sure which is the best option.

If tile-based lighting is the way to go I'd have to think of the best way to go about it. I don't think that it would be a problem to just have it work with a torch giving off light and only updating light values when a light source is added/removed, but when entities are incorporated I also have to think about how will I efficiently update an entities light value based off of surround light values. I have optimized the game a lot so far, with a world of 1,620,000 tiles being contained within it and getting a stable, smooth 30 fps even on mobile. I haven't attempted creating larger worlds than that but I don't see why, at this rate, it wouldn't be able to become any larger. I am trying to keep it as optimized as possible throughout development of the entire game so coming up with an efficient, optimized lighting system is essential.

Any suggestions are greatly appreciated.


texts: (Why) Should I choose Unity 3 or Cocos2d (or something third) for my app?

texts:
My colleague and me made an HTML 5 iPad game ( http://braille.gandzo.com/ ) and we would like to upgrade it, and our framweork is not enoguh, for what we want. Some of the things we would change are: graphics update, animations/"effects", multi-player, achievements and so on. The game would stay 2d. Now, as far as I understand, both Unity and Cocos would be good for this task, with Unity having the advantage of being multi-platform.

What I want to know is are there unknown qualites/"flaws" to these two programs which would influence my decision (maybe even by choosing something else). Examples that come to mind are "Unity is too complicated/has too much unneeded options/hoops because it's made with 3d in mind" or "Cocos is significantly more suited for 2d games".


texts: How can i apply texture to cylinders created using Ogre Procedural Geometry Library?

texts: I am using Procedural::CatmullRomSpline3 to create cylinders between 3 control points, now instead of solid cylinders i need to create dashed/ dotted cylinders so is there a direct way to do so or alternatively i have to make desired textures and add them to cylinders, how can i achieve this?


texts: Using seeds for rng. A reliable way of saving bandwidth?

texts:
Imagine a server-client game application.

While running, the server is constantly generating numbers for various random events and sending them over the network to inform the clients of the result.

I realized it would save alot of bandwidth if I made my rng deterministic and would only transmit a seed value at the start of the game and the number of random calls that have been made on that random instance in the past so that my clients can reproduce a similar random instance and the next generated value will be the same for all clients. Is that a reliable option in terms of security and synchronization and apart from predictability?


texts: Shaking objects near correct position (with video)

texts:
All right, so I'm testing two box objects. One is standing fixed in a position and another at the beginning of the program goes to the first one. And at the end the latter should stand completely over the first (so the center of both is equal).

Here's my method in the Object class:

Old code

void Object::moveTo(Point _p) { // _p is always the center of the other object we want to go to

    // adjust speed, don't worry it's not important here, I guess
    if (current_speed == 0)
        current_speed = speed/16;
    else if (current_speed >= speed)
        current_speed = speed;
    else
        current_speed *= 2;

    // we want to calculate the new center of the
    // our object (the one that run this method)
    Point center;
    // distance(x) calculate the distance between the center point of the object and
    // the x point passed
    if (distance(_p) <= current_speed) {
        // we don't want shaking things!
        center = Point(_p.x, _p.y);
    } else {
        // move diagonally
        center.x = getCenter().x + current_speed*std::cos(angle(_p)); // angle calculates the angle between the center of the object and the _p point
        center.y = getCenter().y + current_speed*std::sin(angle(_p));
    }
    // since we draw sprites by the top left corner we need to convert
    // the center point to the correct top left point
    center = toPosition(center);
    sprite.setPosition(center);
}

New code

Notice that the origin of the sprite is set to be in the center so setPosition will correctly set the center and that getCenter() returns sprite.getPosition() which is the center point.

void Object::moveTo(Point _p) {
    Point center;
    //std::cout << distance(_p) << std::endl;
    if (distance(_p) <= speed) {
        center = Point(_p.x, _p.y);
    } else {
        center.x = getCenter().x + speed*std::cos(angle(_p));
        center.y = getCenter().y + speed*std::sin(angle(_p));
    }
    sprite.setPosition(center);
}

This is what happens: http://youtu.be/Ngra3FXFe0A.

The distance keeps going from 15.xxx to 16.xxx and I don't know why.

Testing surprise

Doing distance(_p) <= 10 instead doesn't make it shake. With 9, 8... or minor it shakes.
Defining a minor speed the object gets nearer the correct position before start shaking.
Setting the white cube to follow the player (yellow sprite) it moves like a jagger: http://youtu.be/9FjRfHHprEQ
Here's a recent video: the 3 little squares points (its the specific top left corner) to: blue = box center, red = player center, green = top left corner of the box. As you can see they are correctly calculated (this test was made with speed of 1, while the others were made with a greater speed): http://youtu.be/iFAWGssk7NI

Distance function:

float Object::distance(Point _p) {
    return sqrt((pow((getCenter().x - _p.x), 2) + pow((getCenter().y - _p.y), 2)));
}

Angle function

float Object::angle(Point _p) {
    //  (180 / PI = 57.3065)
    return 57.3065f * atan2(getCenter().y - _p.y, getCenter().x - _p.x);
}

Why is that?


texts: Why the Vector3.Dot value is -12 when running the game?

texts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System;

public class InteractableItem : MonoBehaviour
{
    public string currentMode;

    private Transform player;
    private InteractableMode currentInteractableMode;
    private string currentDesription;
    private float originDistance;

    private void Awake()
    {
        player = GameObject.Find("Player").transform;

        originDistance = transform.GetComponent<InteractableItem>().distance;
    }

    public enum InteractableMode
    {
        Description,
        Action,
        ActionWithoutThrow
    };

    public enum ViewMode
    {
        FrontView,
        AllView
    };

    public ViewMode viewMode = ViewMode.AllView;

    public InteractableMode interactableMode = InteractableMode.Description;
    public float distance;

    [TextArea(1, 10)]
    public string description = "";

    public bool IsAnyAction()
    {
        return interactableMode == InteractableMode.ActionWithoutThrow || interactableMode == InteractableMode.Action;
    }

    public bool IsActionWithoutThrow()
    {
        return interactableMode == InteractableMode.ActionWithoutThrow;
    }

    private void Start()
    {
        currentMode = GetComponent<InteractableItem>().interactableMode.ToString();
        currentInteractableMode = GetComponent<InteractableItem>().interactableMode;
        currentDesription = GetComponent<InteractableItem>().description;

    }

    private void Update()
    {
        var heading = transform.position - player.transform.position;
        var dot = Vector3.Dot(heading, -transform.forward);

        if(viewMode == ViewMode.FrontView
            && dot < 1)
        {
            transform.GetComponent<InteractableItem>().distance = 0;
        }

        if (viewMode == ViewMode.FrontView
            && dot > 1)
        {
            transform.GetComponent<InteractableItem>().distance = originDistance;
        }
    }
}

The script is attached to some objects and one of them the ViewMode is set to FrontView and then when running the game first time the dot value is -12 and then it's getting inside and going the line :
if(viewMode == ViewMode.FrontView
    && dot < 1)
{
    transform.GetComponent<InteractableItem>().distance = 0;
}

but it should not set the distance to 0.  only if I'm getting close enough to the item then it should see the item from the front and then only if I'm moving the player behind the item the dot should be minus and set the distance to 0 but for some reason the dot is minus 12 when running the game so it's setting the distance to 0 right away.


texts: How should we determine which portions of the game to develop first?

texts:
We are developing an action RPG and have listed out the following modules/subsystems that we're going to need to make:

HUD(Heads-up Display) System
EXP/Leveling System
Combat and Navigation System
Character Controller System
Skill System
Monsters and NPC (AI)
Levels (Missions) System

The combat system is real time and we planned to include a puzzle type game in some (60%) of levels. We also have a game plot.  Which modules should we develop first?


texts:
I am trying to implement jump in a game I have written for android using canvas.
I have referred this tutorial for implementing jump.
My code is like
if(jumpKeyPressed){
    jumpVel = -initialMomentum;
    state = "jumping";
}
if(state == "jumping"){
    jumpVel += gravity * deltaTime / 2;
    loc.y += jumpVel * deltaTime;
    jumpVel += gravity * deltaTime / 2;
}

Even after tweaking gravity and initialMomentum, character is jumping too slow (seems like stuck at ground). I have read many posts but I am not able to figure out what am I doing wrong here?
Edit: Video


texts:
I'm trying to debug a Unity project using the Unity Editor and Visual Studio. A runtime exception keeps popping up, but the debugger doesn't halt when an exception occurs, making it impossible to debug my code efficiently.

In Visual Studio, I've gone into Tools -> Options -> Tools For Unity and set "Exception Support" to "True". I've also enabled all types of exceptions in the Exception Settings panel. I am connecting the debugger to Unity using the "Attach to Unity" button. Breakpoints are working, but the debugger isn't halting on Exceptions.

What do I need to do to get Unity/VS to actually halt on Exceptions?

Note: I've tried closing and re-opening both Unity and VS many times but that doesn't make any difference.


texts: What range of values can HLSL's tex2D function return?

texts:
When using the tex2d function in a HLSL shader, as so:

float height = tex2D(heightMap, IN.texCoord).r;

What range of values can be returned to the height variable? Is it always a number between 0.0f - 1.0f? Or does it depend on the texture or sampler?


texts: Presentation / input layer that communicates with server

texts:
I want to learn more abot how to use some kind of presentation/input layer that communicates with server for HTML5 games.

Instead of sending all the code to the clients browser, I would like to just send a simple interface and code to handle the keyboard input. The algoritms for the game would be kept on the server and the data for the game would be sent with AJAX. I guess this is possible, but I cant find any tutorial that show some simple examples how this should be done.

Is there someone here how knows about tutorials about this or have knowledge about this and would like to share some info about this? I'm just looking for an overview of the design so that I know what to focus and seek for.

Could the algoritm be done in PHP functions that return back the data to the game? I guess there could be some bottlenecks in time delays, but I'm not going to create any fast action game.

I read some about Websockets and Node.js. But to use Node.js, I guess you have to pay to get a special server that run Node.js.

Looking forward to get some info or tips! :)


texts: how to change default third player controls in unity, to work with touch?

texts:
I am developing a game for my project using Unity 3d and have currently used the third player controller available in standard asserts.

I have to export it in android phone so need to modify the player controls to work with touch inputs... But I am a beginner and finding it very complex to modify the ThirdPersonController script...


texts: I have a problem concerning a board game I'm creating. I plan on making an artificial player for the game using MiniMax with AlphaBeta prunning, but I'm not sure how to evaluate ir the player is good at the game. Since it's a new game I can't get a player who is good to give feedback. So I'd like to know if there is any technique to determine objectively if the artificial player is actually good. Thank you in advance.


texts: Using forces to reach a specific velocity

texts:
In my game, I currently move the player by directly setting its velocity on key press events. This makes the game feel very responsive and allows the user to quickly change direction.

However, I would like to implement knockback and elements like conveyor belts that should push the player around. My first idea was to add a bool underControl; variable that was set to false when the player was under the effect of an external force, but it didn't work well in practice.

Then I thought of another way: how about adding the exact required force to move/stop the player at a desired velocity instead of acting on the velocity itself? It would allow the user to move and stop like if velocity itself was being set, but also allow external forces to act on the player.

Basically I want this:

if(someKeyPressed()) player.setVelocityX(100); else player.setVelocityX(0);

to be expressed like this:

if(someKeyPressed())
    player.applyForce(getForceRequiredToReach(100, player.getVelocityX());
else
    player.applyForce(getForceRequiredToReach(0, player.getVelocityX());

Vec2f getForceRequiredToReach(float mDesiredVelocity, float mCurrentVelocity)
{
    // What goes in here?
}

How can I implement the getForceRequiredToReach function?


texts:
How would I make a start screen for a game using HTML5 canvas?

I'm not looking for something advanced, just the new game button and highscore link etc. The question might be stupid, but I've never done anything similar, and the tutorials out there don't cover the subject.

Is it enough to just make a fillText with an onclick function? Is there a way to find out the size of the text?

Help appreciated.


texts: Testing my game in the engine works fine, I export to HTML5 and try but all the tiles in tilemap have disappeared

texts:
Here is a link to the live game:
https://44351-w21.github.io/one-screen-platformer-francescainfranca/
As the title says all the platforms in the tilemap do not appear when you run the game on the HTML5 export. I have no missing assets, and I made sure the filenames match where they are referenced. I have no idea why this is. Any help is much appreciated.
Error in the console:
**ERROR**: No loader found for resource: res://Assets/Platform/grassLeft.png.
put_char @ tmp_js_export.js:8
tmp_js_export.js:8    At: core/io/resource_loader.cpp:286:_load() - Method failed. Returning: RES()
put_char @ tmp_js_export.js:8
tmp_js_export.js:8 **WARNING**: Couldn't load external resource: res://Assets/Platform/grassLeft.png
put_char @ tmp_js_export.js:8
tmp_js_export.js:8    At: scene/resources/resource_format_text.cpp:175:_parse_ext_resource() - Couldn't load external resource: res://Assets/Platform/grassLeft.png


texts:
I made a game and I made a Magnet upgrade and I have 8 game objects to set active 1 by 1 every time when I upgrade the magnet and I have (int upgrade = 0;).

But when I upgrade these game objects it's set active, but if I quit the game and start again all these game objects are FALSE.

How can I make e.g if I upgrade to (int upgrade = 6) and to make my game objects active only from element 0 to element 6. I do upgradeMagnet(); to void Update but its make active only 1 game object depends from (int upgrade) if (int upgrade) is 5 and only game object element 5 is active.

    public GameObject[] upgranded;
    public int upgrade = 0;

    public void upgrandeMagnetButton()
    {
        upgrade += 1;
        upgradeMagnet();
    }

        void upgradeMagnet()
    {
        if (upgranded[upgrade])
        {
            upgranded[upgrade].SetActive(true);
        }
    }


texts:
We are trying to build a Unity game in Xcode but keep getting this error:

  ld:
  '/Users/Pero/Documents/GitHub/MyGame/XCodeProject/Pods/GooglePlayGames/gpg-cpp-sdk/ios/gpg.framework/gpg(libgpg.a-armv7-master.o)'
  does not contain bitcode. You must rebuild it with bitcode enabled
  (Xcode setting ENABLE_BITCODE), obtain an updated library from the
  vendor, or disable bitcode for this target. for architecture armv7
  clang: error: linker command failed with exit code 1 (use -v to see
  invocation)

We are using:

Unity 5.1.1f1
Xcode Version 7.1 (7B91b)

We have these frameworks included in the Xcode project:

gpg.framework
GooglePlus.framework
GoogleOpenSource.framework
GoogleMobileAds.framework
CoreText.framework
AdSupport.framework
AudioToolBox.framework
AVFoundation.framework
CFNetwork.framework
CoreGraphics.framework
CoreLocation.framework
CoreMedia.framework
CoreMotion.framework
CoreVideo.framework
Foundation.framework
iAd.framework
MediaPlayer.framework
OpenAL.framework
OpenGLES.framework
QuartzCore.framework
SystemConfiguration.framework
UIKit.framework
StoreKit.framework
CoreTelephony.framework

We also have Cocoapods installed and this is in our Podfile:

platform :ios, '7.0'
pod 'GooglePlayGames'
pod 'Google/SignIn'

We have tried searching the issue and none of the solutions we found did work. We have tried enabling and disabling the bitcode, Build Active Architecture Only, setting or deleting Search Paths… Here are some links:

xcode-5-1-missing-required-architecture-arm64

new-warnings-in-ios9

impact-of-xcode-build-options-enable-bitcode-yes-no

error-after-updating-to-xcode-7

xcode-7-and-enable-bitcode-yes-setting-does-not-work

apple-llvm-6-0-error-clang-failed-with-exit-code-1

It is our first time using Xcode. We have built the Android version from Unity with no problems.

There was also a problem with creating the Xcode project from Unity on a Mac (Unity kept crashing), so the Xcode project was created on a PC.

Thank you in advance


texts:
I know this is an old question and it has been answered for a lot of people. Unfortunately none of the solutions apply to the problem I seem to have with rigidbodies.

I have a moving AI character and the playermodel. When the AI gets to close the player just bumps on top of it. If I unattach the rigidbody from the moving AI this does not seem to be a problem. My player is controlled by a charactercontroller and the rigidbody is set to "Is Kinematic".

Of course, when none of the agents has a rigidbody my entire combat mechanic falls apart. Does anyone have any idea on how to solve this?

For clarity, here is a short demonstration of the bug:
Bump

And the code in question:

void FixedUpdate ()
{
    if (!controller.isGrounded)
    {
        movement.y -= gravity * Time.deltaTime;
    }
    controller.Move (movement * Time.deltaTime);
}

void CalcMovement (float h, float v)
{
    movement = new Vector3 ();

    if (v != 0 || h != 0) {
        movement = v * forward + h * right;
        movementDirection = movement.normalized;
    }
}


texts: Android how to get opengl 3D coordinates in ontouch event

texts:
I created a cube in opengl and it rotates in ontouch event. To to this I created a CustomSurfaceView as follows

public class CustomSurfaceView extends GLSurfaceView {
    @Override
    public boolean onTouchEvent(MotionEvent e) {
        float x = e.getX()
        float y = e.getY();
    }
}

Here x and y are screen coordinates. How can I get 3D coordinated from this? I have already looked gluProject and NeHe. But I dont know how to implement this in my project, it shows that there is no GLdouble,GLfloat class.


texts: How to build Arena-ish level using grid tiles?

texts: I had an idea of procedurally generating arena-type levels in which the player would either fight hordes of enemies, or another skilled opponent. The level would be built at the very start of the layout, and will have a layout similar to those in Quake Live; Pickups, enemy spawners, etc. What would be the best way to achieve this?


texts: I want to know how Admob pays for banners? Is it based on time or impressions or count of times that been showed to users?


texts: Where do you put the game window in fullscreen mode?

texts:
My game, like most games, supports running in fullscreen exclusive mode. And I'd like to give my players the choice of which monitor the game will display on.

In order to prevent the player from clicking through to the desktop, I need to position my game window to exactly cover the entire monitor's area.

My game works fine when displaying on adapter 0. I simply set the window's location to 0,0 and its size to the fullscreen resolution.

However, this doesn't work if the player chooses a different monitor. The game will render on the correct monitor, but the window will still be located on the primary monitor.

How do I determine the location for my window when the player chooses a monitor other than 0?


texts: Bad pixels on shader when loading cached binary programs

texts:
I have been trying to cache binary shader programs in my game and load them accordingly using "glGetProgramBinaryOES" and "glProgramBinaryOES" respectively.

I was successfully able to cache and load the programs but there is one problem that can be seen in some of the shaders. The problem is that SOME pixels of the object that uses that shader appear black / white and keep flickering.

These are heavy shaders and I cannot skip their caching. Any help ?

Edit:

I compile and store the shaders on the device itself. So device/GPU dependency is taken care of.
I recompile the shaders on any new OS DLC, so software update is taken care of.

The white spots in the image below show the glitch that i am encountering.


texts: Adding 2d hud/gui to a 3d game engine which has no 2d features

texts:
I have been following the 3d game engine tutorial series made by theBennyBox for a few months now, and have finally decided to create a game with it. My problem is that it is a 3d only engine which does not have an easy way to draw in 2d.

The code for it is here (github)

I've figured that I need to change the camera class to take in a generic matrix, so The old camera class was this:

    public class Camera extends GameComponent
    {
    private Matrix4f projection;

    public Camera(float fov, float aspect, float zNear, float zFar)
{
    this.projection = new Matrix4f().initPerspective(fov, aspect, zNear, zFar);
}

public Matrix4f getViewProjection()
{
    Matrix4f cameraRotation = getTransform().getTransformedRot().conjugate().toRotationMatrix();
    Vector3f cameraPos = getTransform().getTransformedPos().mul(-1);

    Matrix4f cameraTranslation = new Matrix4f().initTranslation(cameraPos.getX(), cameraPos.getY(), cameraPos.getZ());

    return projection.mul(cameraRotation.mul(cameraTranslation));
}

@Override
public void addToEngine(CoreEngine engine)
{
    engine.getRenderingEngine().addCamera(this);
}

}

To this:

public class Camera extends GameComponent
{
    private Matrix4f projection;

public Camera(Matrix4f projection)
{
    this.projection = projection;
}

public Matrix4f getViewProjection()
{
    Matrix4f cameraRotation = getTransform().getTransformedRot().conjugate().toRotationMatrix();
    Vector3f cameraPos = getTransform().getTransformedPos().mul(-1);

    Matrix4f cameraTranslation = new Matrix4f().initTranslation(cameraPos.getX(), cameraPos.getY(), cameraPos.getZ());

    System.out.println("Location: " + cameraPos.getX() + " " + cameraPos.getY() + " " + cameraPos.getZ());
    return projection.mul(cameraRotation.mul(cameraTranslation));
}

@Override
public void addToEngine(CoreEngine engine)
{
    engine.getRenderingEngine().setMainCamera(this);
}

}

But now I don't know what to do. I can't work out how to switch between 2 cameras and draw in 2d.

How would I achieve this?
Thanks!!


texts: How to replicate Unity's Rigidbody.AddForceAtPosition in C++?

texts:
I am trying to replicate the function Rigidbody.AddForceAtPosition of Unity in C++, it means, to apply force to a body offset from its center.

How could I achieve that in C++?


texts: Designing a weather system for biomes in a roguelike

texts:
I'm making a roguelike game similar to dwarf fortress. So far, I have an average temperature map and average yearly precipitation map generated with simplex noise. Now, I'm trying to implement a weather system that seems realistic, as in it rains more often in biomes with higher precipitation rates, but still seems coherent.

Some of my thoughts on designing this system would be to have a weather object for each individual biome, and every time it rains (and the startup) it picks the next time it will rain based on the biomes precipitation rate.

One problem with this approach is that it would always rain within the exact edges of a biome, and I don't think it would look very realistic.

Another option could be to have cloud objects move around the map, and have them pick up water while in biomes with high precipitation rates, and when reaching the max, they rain.

This seems like a good approach to me that could be very realistic, I would just have no idea how to program the movement for the clouds.

Any thoughts on a better approach or how to implement either of these to make them work?


texts:
I'm heading out from the prototype stage and towards my early/alpha stage.

In this transition period I've been interested in getting an estimate of what the revenue will be so I've come up with this in Excel.

I've considered taxes in general, VAT and fee transactions from Stripe and PayPal.

I'm from Europe.

This is my first game and I know no-one in the field so I don't really have an answer.

Is the following a reasonable assumption?

Itch.io Cut           10 %
VAT Transactions      25 %

With this as an example result:

Money Earned       +1,000 €
VAT Transactions   -  250 €
                   --------
SubTotal           +  750 €

Itch.io Cut        -   75 €
                   --------
My Final Revenue   +  675 €

Here is my question on itch.io, and here it is to my reddit question.


texts: shader coding: calculate screen coordinates of fragment

texts:
Good morning,
I'm new to shader coding and trying to implement some visual effects code in shaders using billboards. (Yes, I couldn't have picked anything harder to start with, but I'm lucky that way)

Setup:
I have rendered the full screen z depth to an array of floats in a previous pass.
In the fragment shader I need the scene depth where the rendered fragment is displayed (to see if it's occluded). I can use tex2d() to get the depth value if I have the screen coordinates of the point being rendered in the fragment shader.

Question:
In the fragment shader how do you calculate the screen coordinates of the pixel (in the range 0-1.0)?

Is the position passed to the fragment shader a pixel offset? If so, I guess it would be:
    float2( position.x / screen-width, position.y / screen-height )

Thanks for any help/


texts: How to propagate component updates? (Changing components at runtime)

texts:
Whenever an entity is being added to an entity controller (which is essentially just a bag of entities), I scan through it's components to figure out if I need to register additional entity processors (game systems). For instance, if I add an entity which has a SpriteComponent attached to it for the first time, the EntityController resolves the e.g. SpriteRenderSystem using a factory and a simple specification, which is then being registered within the controller.

Now I'd like to make it possible to figure out whether the component of an entity has changed. I was suggested in off-topic discussion elsewhere that I should use an eventing system to raise component change events in order to have the entity rescanned.

However this has two problems, I think:

The entity, which was a simple component bag beforehand, now holds a dependency to a event bus.
An event bus traditionally raises global fire-and-forget events. My entitiy controllers are the base of scenes (individual game states to activate/deactivate entities together) - and there can be many scenes active at once. When a component changed event fires, then I ask myself: In which entity controller is the affected entity? Scanning all controllers for whether they contain the entity sounds expensive.

Another option would simply make the entity aware of the entity controllers in order to signal "Hey, I have changed!". However should an entity know where it's currently attached to?


texts: Why should I separate objects from rendering?

texts:
Disclamer: I know what an entity system pattern is and I'm not using it.

I've read a lot about separating object and rendering. About the fact that the game logic should be independent from the underlying rendering engine. That's all fine and dandy and it makes perfect sense, but it causes a lot of other pains too:

need for synchronization between the logic object and the rendering object (the one that keeps the state of the animation, the sprites etc)
need to open the logic object to the public in order for the rendering object to read the actual state of the logic object (often leading the logic object to easily transform in a dumb getter and setter object)

This doesn't sound like a good solution to me. On the other hand it's very intuitive to imagine an object as its 3d (or 2d) representation and also very easy to maintain (and possibly much more encapsulated as well).

Is there a way to maintain graphic representation and game logic coupled together (avoiding synchronization issues) but abstract away the rendering engine? Or is there a way to separate game logic and rendering that doesn't cause the above drawbacks?

(possibly with examples, I'm not very good at understanding abstract talks)


texts: Should a wall be created as a plane or as a box?

texts: What are the benefits of a wall being as a plane or as a box? Should I use a plane with a box collider instead of mesh collider?


texts: Any good web frameworks for asynchronous multiplayer games?

texts:
I'm trying to craft a site for web-based (original) board games, and my client (currently written in Actionscript, but that's highly fungible) works fine - I can play solitaire games in the client - but it has nothing to connect to.

What I'm looking for is a server framework for handling accounts/authentication and game tracking: something that would let players log in, show them a list of their current games, let them invite friends to new games, let them make moves in the games they have open, etc.  I'm flexible on language; obviously I'm going to have to write a lot of server code to handle the actual game logic, but that should be straightforward enough.  I'm more concerned with how to handle the user (and game) DBs, though suggestions for a good server framework for communicating with the DBs (and serving up, most likely, JSON for client communications) are also welcome.  Right now my leaning is towards Ruby (probably with Rails) but as far as I can determine it would be a pretty good chunk of effort to set up the necessary databases, so having something automagically handle that - or even just having a good example project that I can check out for a how-to - would be really useful to me.


texts:
I've implemented an OpenGL based terrain unsing a tesselation-shader for dividing each 'terrain-cell' into the desired tiles.
The heightmap is uploaded to the GPU and applied on the shader.

When it comes to picking, I don't really know what to do.
Testing triangles on intersection with the pick ray is not possible because only the GPU 'knows' the mesh.

Is render to texture with an unique color the way to go?
Or holding an additional mesh in RAM, only for picking/collision?


texts:
the problem is with shadow mapping as you can see,

actually it works fine but in a certain condition that the Depth Map size must be equal to the size of rendering buffer, I use an infinite directional light

so if the window is 800x600 the depth map must be 800x600, and when i change the size of the shadow map to be 900x600 it starts to be shifted and when it's size be 1024x1024 it also shifts till it disappears

the GLSL shadow function

float calcShadow(sampler2D Dmap, vec4 coor){

vec4 sh = vec4((coor.xyz/coor.w),1);
sh.z *= 0.9;
return step(sh.z,texture2D(Dmap,sh.xy).r);
}

here's the result when it's the same size as the window

Colored result & Depth Map

and here's the shifted result, as you can notice the depth map is exactly as the previous one with the addition of white space to the right.

Colored result
http://goo.gl/5lYIFV

Depth Map
http://goo.gl/7320Dd


texts: How to weld nearby mesh collider vertices together to erase seams in Unity?

texts:
I'm using Unity 2020.3.2f1 and I have a very commonly seen problem. I have a Spherecollider which I am using for a physics game, and geometry that uses BoxColliders or MeshColliders. Everything is nice until I get to the seams of one of these objects, and then my ball loves to do inane things like come to a complete stop across a seam or bounce high into the air when striking one. These seams are very tiny as you can see in the image below.

So, I've tried basically every workaround in the physics engine and rigidbody options for my ball (continuous, changing timestep, etc), and none of them completely erase the issue. I suspect that unless I marry all the colliders together, decimating points within some tolerance of each other into one, I will always have this problem at least in some cases, which isn't acceptable for my project.
So I'm wondering how I would work with this data. How do I access the MeshCollider data of each object in the scene? If I join them into a "master mesh" how does it expect to be constructed (quads from vertices or something)? Is there a performance aspect to worry about, having one giant collider versus many tiny ones? I imagine it screws with pruning colliders in the collision detection portion.


texts: LookRotation() make X axis face the target instead of Z

texts:
I use LookRotation() in order for an object to look at another, but since I'm using 2D I would like to make the axis looking/facing the target to be X instead of Z. I have the code below currently:

Vector3 dif = targetPos - obj.position;
Quaternion angle= Quaternion.LookRotation(dif, obj.up);
obj.rotation = Quaternion.Lerp(obj.localRotation, angle, Time.deltaTime);

Now->

What I'm trying to achieve->

Thanks!


texts: taking a static animation and making it move unity3d

texts:
Say you have an animation of a bird flapping its wing.

Some animations actually moves the Avatar either forward, backwards or to the side.

My question is, is it possible to take that flapping animation and change the animation to make it move forward within the unity editor?

Please note that i am not an animator which means that i do not have the skills to edit the animation in a 3rd party program. So this question revolves around what you can do in Unity3d


texts: How do I stop my timer when I close my game?

texts:
Background:

I have a background service with a timer. It opens up a new activity when 20 seconds are over.

Currently, my app is using componentCallbacks2 to detect when the user has pressed the home screen, or has left the app, and on detection, I stop the timer, so that the activity doesn't get called.

But, for some reason, componentCallBacks2 does not get called when the user just closes out of the app:

Here you can see the user closing an app. For some reason, my app doesn't stop its processes when the app is closed. And, the timer continues to run. This results in the activity popping up on the users screen after 20 seconds, even though the user isn't in the app.

How can I detect if the app has been closed so that I can stop the timer? I have read on this topic in many other sources, and those sources just say to use the onStop method. I can't do that, because the onStop gets called whenever there is a change in activities

So, where should I stop the timer?

Image source.


texts: How can I make a sprite move in the direction it's facing using radians?

texts:
I am using PGELua for the PlaystationPortable. I would just like to know how to make a 2D sprite move in the direction that the sprite is facing.

When the sprite is blitted to the screen it should be heading down the y axis (like it's moving up the screen) but it doesn't appear to be working that way. As far as I am aware, the angles of the images use radians for the rotations.

I have this in a function

function FUNC_MOVE_SHIP(speed,angles)
    VAR_SHIPX = VAR_SHIPX + pge.math.sin(angles) * speed
    VAR_SHIPY = VAR_SHIPY + pge.math.cos(angles) * speed
end

and I call it in my main program like

    FUNC_ST_DR()
    if pge.controls.held(PGE_CTRL_LEFT) then
        VAR_SHIP_ANGLE=VAR_SHIP_ANGLE-0.01
    elseif pge.controls.held(PGE_CTRL_RIGHT) then
        VAR_SHIP_ANGLE=VAR_SHIP_ANGLE+0.01
    end
    FUNC_MOVE_SHIP(VAR_SHIP_SPEED,pge.math.rad(VAR_SHIP_ANGLE))
    SHIP_11:activate()
    SHIP_11:draweasy(VAR_SHIPX,VAR_SHIPY,pge.math.rad(VAR_SHIP_ANGLE))
    FUNC_EN_DR()


texts: In UE4, how do I turn my character's body together with the camera?

texts:
I made a simple punch animation in Blender and exported it into Unreal Engine 4. In-game, the character appeared from a 3rd-person perspective, but I made it look like first-person by adjusting the camera.

Now, whenever I turn the camera in-game, I can look around at different parts of the character's body. (For example, if I turn right I can see shoulder of my character, and if I am facing the front I can see just the wrists.) Whenever I turn the camera and run the punch animation, it looks weird because the character model isn't aligned with the camera.

How can I make the body turn together with the camera, so my animation looks right?


texts: How do you get audio clips to play on all clients?

texts:
I am new to networking with so this is probably a noob question.
For context I am trying to get a gunshot sound effect to play and be heard by all players.


texts: Unity3D: Mathf Lerp too fast when timescale increases

texts:
I have an image with a fill amount component controlled by a Mathf Lerp. The problem is, the time for completion of the Mathf Lerp function decreases more than expected when the timescale increases.

When the timescale is equal to 2 the function should take half the time to complete but it takes less than that. Any idea why?

public static float demolishTime = 6.0f

public void OnClickDemolish()
{
    InvokeRepeating("demolishProgress", 0f, 0.1f);
}

void demolishProgress()
{
    progress += (Time.deltaTime / demolishTime);
    demolishProgressBar[DemolishManager.demolishState].fillAmount = (float)Mathf.Lerp(0, 1, progress);
    if (progress >= 1) demolishCompleted();
}


texts:
I have a game that was written in pixels and now I want to change it to meters like(box2D do). How I need to do that. I have wached a lot of tutorials and all they have some SCALING FACTOR but when I implement it my game don't work as I aspected. How I need to do that? For example I have a Coin and I want to make position of that coin random. I also want that coin sprite have a CircleShape (Box2D). Here are my code where I update my coin coordinates at specific time

if(time > 1.5f && !goToWallet && setUpCoin){
                coin.setCoinPosition(-100, -100); // do not show coin on the screen
                coin.update(coin.getCoinX(), coin.getCoinY());
                cam.update();
                if(showTime > MathUtils.random(5, 20) && !goToWallet){
                    coin.setCoinPosition(MathUtils.random(50, Gdx.graphics.getWidth() - 50)/100f, MathUtils.random(50, Gdx.graphics.getHeight() - 50)/100f); // random position of the screen IN PIXELS!!!
                    coin.update(coin.getCoinX(), coin.getCoinY());
                    cam.update();
                    time = showTime = 0.0f;
                }
            }

The problem is that is very easy to do in pixels, but How I need to do that in meters?

Here's my Coin class

public class Coin {
    /*
    A lot of variables
    */

    private final float radius;
    private BodyDef body;
    private FixtureDef bodyPhysics;
    private static Box2DDebugRenderer rend;
    private static World world;
    private static CircleShape coin;

    public Coin(World world, Box2DDebugRenderer rend){
        this.rend = rend;
        this.world = world;

        body = new BodyDef();
        bodyPhysics = new FixtureDef();
        coin = new CircleShape();
        coin.setRadius(.05f);
        body.type = BodyType.StaticBody;
        bodyPhysics.shape = coin;
        world.createBody(body).createFixture(bodyPhysics);
}
public void setCoinPosition(float x, float y){
    this.x = x;
    this.y = y;
    coin.setPosition(new Vector2(x, y));
}

}


texts: How can I test whether points are within a polygon?

texts:
I have 2D-points, which boundaries depict a polygon. The points are at integer positions (no fractions possible).

Now I want to build an enumerator in C# that returns all points that are inside the polygon. Implementing the enumerator is not the issue, but how do I efficiently get all the points? The polygon can be quite big.


texts:
Assume you had to find the shortest path through a dungeon, where certain passages are only opened to you after certain items were collected, like locked doors and keys, for instance.

The normal gut reaction to the words "shortest path" would obviously be A*. But A* would fail in such an environment, since I see many problems defining a reliable heuristic and, additionally, it is very likely, that a node has to be visited multiple times, which is also not possible in conventional A* and would also make the heuristic harder.

What I thought about is simply looking for a path from the start of the dungeon to the end, ignoring any blocked doors. After this path is found, for each of the doors blocking our way, an additional path looking for the appropriate key and back to the door would be sought and traversed before the door is even reached. The very same system would be used to handle a situation, where the path to a key needed to open a door is again blocked by another door, which needs to be opened first.

A big problem I see with my solution is that after all the paths including the ones for item acquisition are found, the total distance travelled by the agent might not be the smallest possible, since there might be other blocked doors that are farther from the goal but have their appropriate key much more easily available. A* would have neglected these doors on the first pass where blocked doors are simply ignored.

I'm sure I'm not the first one to try to solve this and I would appreciate some input on the problem.


texts: Signed Distance Fields: How are different colour channels used to improve output of sharp corners?

texts:
The naive approach to implementing signed distance field font rendering suffers quality issues where sharp corners get softened (either outward- or inward-facing corners, i.e. convex or concave corners).

Step-by-step, just how are a second and third channel used to improve the final output? How are these channels produced, as compared with a single channel (for which the process is straightforward)?


texts: How can I fix "the referenced script on this Behaviour is missing" warnings?

texts:
One of my game objects used to have a script that I have now deleted on purpose. Now it keeps saying this message as a warning:

  The referenced script on this Behaviour is missing!

How can I rid of that?


texts: How to increase the difficulty setting as close as possible to maximum difficulty automatically?

texts:
I have a simple 2D version of Mini-golf. The goal is to manage to clear each level in the least amount of shots, the ball is bouncing at most 3 times (stops on the 4th hit) from a wall but not reducing in speed, there is no out of bounds and no obstacles that would remove the ball. Now I would like to add some water/ instant death obstacle at the most annoying places.

How do I find those places?

The player can aim in a 360 radius, if I set the goal of managing a given level in 2 shots, there are 129,600 ways of how the player could shoot the ball. While it should be possible to simulate all of those shots fairly easy, I don't want to add randomly water and check if the level is still possible to clear, rather simulate the level, record all places the ball went over and place on the spots with the most hits water.

What is the best strategy/ a good algorithm to blockade the most ways but to guaranty that at least one way stays clear?

Does the strategy change significantly if moving obstacles (on a fixed path, same rule for bouncing as normal wall) are included?


texts:
I'm a new game developer and I have already finished Pong, Breakout and Snake. I want to start with strategy games, where do I read up on that? What ideas should I wrap my head around?
I like games like civilization, master of Orion, etc.

Edit: I use objective-c and cocos2d. My question is more general and broad, for example how would one start with such games, e.g. I want to make a very simplified civ game.
I have a tile map, one town and one attack unit. Town gives me x money every turn, i can build more units in town.
How do I store said town, units?
Do i use classes for them?
Where does my combat function go? In units, or in separate entity? Do I use inheritance for digferent units, how do I handle makinf more units in towns? How so I implement turn-based turn? Some sort of state machines?
General read about those topics would be nice.


texts: What happens with associated animation clips when I copy a gameobject in Unity?

texts:
I have a gameObjectOne that has two animation clips: move into the screen and move out of the screen. This gameObjectOne has an animator that checks when each clip has to be played.

Now I duplicated this gameObjectOne via the edit menu and named the copy gameObjectTwo, and to my surprise the animator and the animations still work. I expected that the animation clips were associated with gameObjectOne but this is not the case....

The animation clips are not duplicated. There are still only two clips and one animator in the project window. But when I click on gameObjectTwo in the animation window, you can see that there are two animation clips associated with gameObjectTwo as well.

So my question is: how is this possible? And is there a way to see what is "inside" an animation clip file? If I click in the project window on an .anim file, it doesn't say which gameObject it belongs to.


texts: Why is my partially transparent image blitted fully opaque?

texts:
I have a part in my program that should display the currently playing song's name for the first 4 seconds, then fade out. Even though Surface.get_alpha() returns expected results, the image still does not fade out.

Why is this? How can I make it work?

My code looks like this:

for event in settings.events:
    if pygame.mixer.music.get_pos() < 4000 and sounds.music.volume != 0:
        #This part creates the surface and determines the position
        show = 40 * 4
        font = pygame.font.SysFont(typeface, 15)
        songname = font.render(sounds.music.playlist[0], True, settings.color)
        font_pos = songname.get_rect()
        font_pos.right = screenx - 10
        font_pos.top = 10
        alpha = 255
    if event.type == USEREVENT + 1 and sounds.music.volume != 0:
        #The userevent is there to ensure it will fade out with the same speed
        #and not being related to fps
        #this decreases alpha
        show -= 1 if show > 0 else False
        if show < 40 * 4 and alpha > 0:
            alpha -= 1.6
        songname.set_alpha(int(alpha))

if pygame.mixer.music.get_volume() != 0.0 and show != 0:
    #This does actually return the correct results
    print songname.get_alpha(), alpha
    screen.blit(songname, font_pos)


texts: tvOS game launch image shows on simulator but not on device

texts:
I’ve set up a launch image in XCode and it does show up in the simulator, but on the Apple TV it just displays a blurry gray background. The image is the correct size and doesn’t have any transparency.

I have tried full clean and delete the app from the device – neither has worked.


texts: How to get neigbor pixel coordinates in Unity HLSL shader

texts:
I am writing Mandelbrot set shader for Unity.
I wrote an Image Effect shader and it works.
Unfortunately, each point "shimmers" on translate scale. This is because, for each shader call I compute value for only one mathematical point, which is infinitesimal. On even small translation, the value can change drastically.
So, I would like to compute math value not for one point, but for several. But for this I need to know, which aother points belong to my pixel, and for this I need to know the distance to neighbor pixel. Unfortunately, my incoming values are float and I don't know, how to step to next pixel.
How to accomplish?


texts: What pitfalls should one look out for when starting a studio

texts:
What are the common mistakes or oversights made when starting a new game studio?

Please only one mistake or oversight per answer and if you can explain why it is an issue and what one should do to avoid falling into the mistake or recover if they've already made it.


texts: Why do some games show lights shine through walls?

texts:
In some games, I see lights shining through walls, even if I set video quality on high levels.

A couple of examples of games I recently played are Borderlands 2 (missile explosions) and Call of Cthulhu (lanterns; the game even uses Unreal Engine 4).

Is this a bug or there are performance reasons?

Example Borderlands 2: https://youtu.be/9bV83qA6_mU?t=419 (few times, but quickly)

Bonus question: in the latter case, is there any way ray tracing could be cheaply used to solve the problem? I guess that expensive RT definitely solved the problem, but I wonder if it can also be used in a "cheap" form to solve this specific problem.


texts: What technique should I use in a shader to give this reflective effect?

texts:
I'm working on a top-down 2D strategy game written in Java with LibGDX (though really for the purposes of this question I'll be using GLSL).

I want to give metallic materials in the game a shiny effect - but not a lightsource-based specular highlight or anything similar, I'm after a kind of global shine or shimmer, much like the effect on the word "King" in this logo from King under the Mountain:

While I'm not looking for someone to implement this for me, as a bit of a newbie to shader programming, what kind of techniques or algorithms should I be looking at to give this kind of effect?


texts:
Possible Duplicate:
  What are some good game development programs for kids?

I want very easy game builder for a kid - somebody who knows nothing about programming games (how they work inside) and just wants to build some (I could teach him but I am not available all the time). She tried Adventure Maker and got confused. It has to be something very straightforward. Do You know about any? Thanks. :)


texts:
I have been trying to figure out why my collision tiles act so strange; I put I collision tile above a normal chunk based tile but it seems to not work - the collision tiles seem to appear in the wrong places.

Here is my code for tile collision:

protected boolean collisionWithTile(int Px, int Py){
    for(CollisionTile e: handler.getWorld().getCollisionMap().getCollisionTiles()){
        if(getCollisionBounds(0,0).intersects(e.getBounds())){
            return e.isSolid();
        }
    }
    return false;
}

Here's the code for getting collision bounds for entities (player):

public Rectangle getCollisionBounds(float xOffset, float yOffset){
    return new Rectangle((int) (position.x+ bounds.x+xOffset), (int) (position.y+bounds.y+yOffset), bounds.width,bounds.height);
}

collision bounds for tile and render:

 public void render(Graphics g){
    if(solid){
        g.setColor(Color.RED);
    }else{
       g.setColor(Color.CYAN);
   }
    g.drawRect( (int) ((tilePosition.x * Tile.TILE_WIDTH - handler.getGameCamera().getxOffset())+regionPosition.x*Tile.TILE_WIDTH), (int) (tilePosition.y * Tile.TILE_HEIGHT - handler.getGameCamera().getyOffset()+regionPosition.y*Tile.TILE_HEIGHT),Tile.TILE_WIDTH,Tile.TILE_HEIGHT);
    g.setColor(Color.black);
}

public Rectangle getBounds(){
    return new Rectangle( (int) ((tilePosition.x * Tile.TILE_WIDTH - handler.getGameCamera().getxOffset())+regionPosition.x*Tile.TILE_WIDTH), (int) (tilePosition.y * Tile.TILE_HEIGHT - handler.getGameCamera().getyOffset()+regionPosition.y*Tile.TILE_HEIGHT),Tile.TILE_WIDTH,Tile.TILE_HEIGHT);
}

The render works just fine but the collision is totally different.


texts: How does time-dependent camera rotation with a mouse work?

texts:
The commonly used equation for camera rotation with a mouse does not involve time. This make sense since higher frame rates have smaller changes in mouse position and vise-versa so it all evens out. If time slows down or speeds up, however, camera rotation from the mouse does not adjust accordingly. Just as you move slower when time is slowed, logically I also want rotating to be slower.
One option is to multiply the change-in-position of the mouse with the same multiplier I'm using on time, but shouldn't it be possible to have change-in-rotation and change-in-time in the same equation, independent from framerate?


texts: Help needed, following Unity multiplayer Health-Bar tutorial. Only working on Server Host instance of the game

texts:
was really hoping someone can be good enough to look over my code, I've been trying to fix it for several days. I followed the Unity tutorial which is fairly basic but the bit that confuses me (and potentially where the problem lies) is the:

 if (!server){return;}

part at the top of my TakeDamage() function.

The problem im seeing is that once I get to that part of the tutorial, the bullet fired by the Host is registered against the other player and I can see his health has gone down (great so far!) , but when I load the instance in the editor (i did running another standalone on my laptop and connect to internet matchmaking but the same thing occurs) his bullets are not registered (even though my debug log tells me the Ray did hit the player.

The tutorial tells me to make it return if not server, it then uses [SyncVar] and a hook that is supposed to call the method "OnChangeHealth" whenever currentHealth is changed.
This DOES NOT appear to be happening, and the TakeDamage code is only happening on the Server-Client-Host instance.

I was trying to adapt the tutorial to my own game, so there are some slight differences in the function and class names, but to me it looks to be exactly the same functionality-wise. I will have to just post my full code here as I don't know which part is causing the issue:

(MANY THANKS FOR READING  AND/OR HELPING):

the Player class:

public class Player : NetworkBehaviour {
private GameObject startScreen;
public const int maxHealth = 100;

[SyncVar(hook = "OnChangeHealth")]
public int currentHealth = maxHealth;

private float playerHeight;
private AudioSource audioSource;
public AudioClip painBodySound;
public AudioClip painHeadSound;
public AudioClip painHeadSound2;
public RectTransform healthBar;

void Start () {
    startScreen = GameObject.FindGameObjectWithTag("StartScreen");
    if (startScreen != null)
    {
        startScreen.SetActive(false);
    }
    playerHeight = GetComponent<Collider>().bounds.size.y;
    currentHealth = maxHealth;
    audioSource = GetComponent<AudioSource>();
}

void Update () {

    if (!isLocalPlayer)
    {
        return;
    }
    if (Input.GetKey(KeyCode.LeftControl))
    {
        transform.localScale = new Vector3(1, 0.5f, 1);
    }
    else
    {
        transform.localScale = new Vector3(1, 1f, 1);
    }
}

public void TakeDamage(Vector3 hitPoint, int bulletDamage)
{
    // check that its Server so that damage only gets applied on the server
    if (!isServer)
    {
        return;
    }
    currentHealth -= bulletDamage;
    audioSource.PlayOneShot(painBodySound);
    if (currentHealth <= 0)
    {
        currentHealth = 0;
        Debug.Log("Dead!");
    }
}
private void OnChangeHealth(int health)
{
    healthBar.sizeDelta = new Vector2(health, healthBar.sizeDelta.y);
}

}

Inside the bullet class is this function:

private void CastBulletRay()
{
    ray = new Ray(bulletSpawnPos, bulletSpawnDirection);
    if (Physics.Raycast(ray, out hit, bulletRayDistance))
    {
        if (hit.collider.tag == "Baddie")
        {
            Debug.Log("ray has hit a baddie");
            Destroy(gameObject);
        }
        if (hit.collider.tag == "Player")
        {
            Debug.Log("ray has hit a player");
            hit.collider.gameObject.GetComponent<Player>().TakeDamage(hit.point, bulletDamage);
            Destroy(gameObject);
        }

    }
}

and inside The Unity RigidBodyController class I'm using, I added:

    [Command]
    void CmdFireBullets()
    {
        muzzleFlashObject.SetActive(true);
        audioSource.PlayOneShot(gunFireSound, 0.2f);
        //Create a new bullet
        GameObject newBullet = Instantiate(bulletPrefab, bulletSpawnPoint.transform.position, bulletSpawnPoint.transform.rotation) as GameObject;

        //Spawn the bullet on the clients:
        NetworkServer.Spawn(newBullet);
    }
}


texts: Transform values stay zero while catching mouse movement

texts:
I am working on a game using GoogleVR, but I don't think that has anything to do with my problem.

Basically, I am testing to see if I can move a stick by using the mouse at the moment.

I am getting mouse movement, as seen from the value of md:

(-0.5,-1.25)
UnityEngine.Debug:Log(Object)
PlayerMovement:Update() (at Assets/Character Pack/PlayerMovement.cs:30)

But the transform is wrong, as seen from the localRotation:

(0,0,0)
UnityEngine.Debug:Log(Object)
PlayerMovement:Update() (at Assets/Character Pack/PlayerMovement.cs:29)

I just want to see my stick move in some predictable way based on the movement of the mouse, and I am not certain why my equation is wrong.

public class PlayerMovement : MonoBehaviour {
    Vector2 mouseLook;
    Vector2 smoothV;
    public float sensitivity = 5.0f;
    public float smoothing = 2.0f;

    public GameObject stick;

    // Use this for initialization
    void Start () {
        smoothV.x = 0.5f;
        smoothV.y = 0.5f;
    }

    // Update is called once per frame
    void Update () {
        var md = new Vector2 (Input.GetAxisRaw ("Mouse X"), Input.GetAxisRaw ("Mouse Y"));

        md = Vector2.Scale(md, new Vector2(sensitivity * smoothing, sensitivity * smoothing));
        smoothV.x = Mathf.Lerp (smoothV.x, md.x, 1f / smoothing);
        smoothV.y = Mathf.Lerp (smoothV.y, md.y, 1f / smoothing);

        stick.transform.localRotation = Quaternion.AngleAxis (-mouseLook.y, Vector3.right);
        stick.transform.localRotation = Quaternion.AngleAxis (mouseLook.x, stick.transform.up);
        Debug.Log ("(" + stick.transform.localRotation.x + "," + stick.transform.localRotation.y + "," + stick.transform.localRotation.z + ")");
        Debug.Log ("(" + md.x + "," + md.y + ")");
    }
}


texts:
I'm building a game called DVP(Digimon Virtual Pet), and in this game other than taking care of your digimon, You can also battle and breed them. I'm working on the battle system (making it first cause the actual pet system will be easy compared to the netplay, or 39DLL)but here is the problem I don't want it to be "too" simple or "too" complicated, but I do want to go by a certain formula. There are str, def, spd, and int.

Strength: How hard the attacking digimon is hitting
Defense: How much damage your digimon can defend when being attacked
Speed: The chance of you missing the enemy
Intelligence (battle knowledge): The chance of you hitting a critical hit or defending a critical hit.

I can make a super simple turn based example, but I don't know how exactly to make the formulas for what I've explained above, any help?


texts: checking if an array rank is not equal to an int C#

texts:
I'm creating an inventory system for a dungeon crawler, I've got world gen, and player controls down, and this is the only snag.`

public Transform[] items;

public bool[] usingitem;

public int usingitemnumber;

public void Update()
{
    if (Input.GetKeyDown("1"))
    {
        usingitemnumber = 1;
    }

    if (Input.GetKeyDown("2"))
    {
        usingitemnumber = 2;
    }

    if (Input.GetKeyDown("3"))
    {
        usingitemnumber = 3;
    }

    if (Input.GetKeyDown("4"))
    {
        usingitemnumber = 4;
    }

    usingitem[usingitemnumber] = true;
    if (usingitem.Rank != usingitemnumber)
    {
        usingitem[!= usingitemnumber] = false;
    }

}

`

i need to check if a rank on the transform[] usingitem array is not equal to the int usingitemnumber , and if it's not equal to it set it to false, and keep the on that is equal to it true


texts: Geometry shader wireframe not rendering correctly GLSL/OpenGL/C++

texts:
Im trying to make a tool for skinning 3D models, and as part of that, I need to show faces wireframed, making use of the geometry shader stage.

Im following the approach suggested here and here. My problem however, is that it ends up looking like this:

Where some of the lines get thicker when the faces are oriented in a specific way. This is my geometry shader: (The vertex shader just passes vertices, so theres no need to show it)

#version 400

layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;

noperspective out vec3 gDist;

void main()
{
//800,600=window size(make uniform later)
vec2 p0 = vec2(800,600) * gl_in[0].gl_Position.xy/gl_in[0].gl_Position.w;
vec2 p1 = vec2(800,600) * gl_in[1].gl_Position.xy/gl_in[0].gl_Position.w;
vec2 p2 = vec2(800,600) * gl_in[2].gl_Position.xy/gl_in[0].gl_Position.w;

vec2 v0=p2-p1;
vec2 v1=p2-p0;
vec2 v2=p1-p2;
float area = abs(v1.x*v2.y - v1.y * v2.x);

gDist = vec3(area/length(v0),0,0);
gl_Position = gl_in[0].gl_Position;
EmitVertex();

gDist = vec3(0,area/length(v1),0);
gl_Position = gl_in[1].gl_Position;
EmitVertex();

gDist = vec3(0,0,area/length(v2));
gl_Position = gl_in[2].gl_Position;
EmitVertex();

EndPrimitive();
}

and frag shader:

#version 400

noperspective in vec3 gDist;

const vec4 wire_color = vec4(0.0,0.5,0.0,1);
const vec4 fill_color = vec4(1,1,1,0);

void main()
{
float d = min(gDist[0],min(gDist[1],gDist[2]));
float i = exp2(-2*d*d);

gl_FragColor = i * wire_color + (1.0 - i) * fill_color;
}

So what am I doing wrong here? I feel like im missing something. Is anyone familiar with this?


texts: How many Pipelines in a Typical Rendered Scene DirectX12

texts: I'm learning DirectX12 right now and I'm missing a few pieces of the puzzle in my own head on the overall structure of how you would setup a game. Specifically, I'm trying to get an idea of how shaders are processed through the pipeline. So in DirectX12, there seems to be a lot of work to setup a pipeline state object (PSO) and then you can assign one each of the following vertex, pixel, domain, hull, and geometry shaders. Well, it seems like there are probably many different shaders being rendered at one given time, so you would have your water shaders, glass shaders, ground, etc.. and you would need a separate pixel shader for each of these correct? So if you had about 50 pixel shaders running on a particular frame, you would need to create and configure another 50 pipeline objects? This seemed like overkill to me, so I'm just trying to figure out how this would work in a real world game engine. Thanks!


texts: Convert Global Space 3D Location to Local object space?

texts:
I'm trying to find a formula that could convert my 3D global coordinates into local object space.
Here are the inputs I have
A Location

B Location
B Rotation
B Scale

I need a Location output, corresponding to my A Location in B Space, according to B Location, Rotation, and Scale. I'm working in a 3D Space
So far I didn't found any formulas online, anyone can point me in the right direction?
Bests
If possible, i'd need a formula that doesn't use any matrix calculation, it's not supported by the nodal system of my engine (I'm using blender geometry node, but my problem is more generic as you can see)


texts:
I don't know if this is a valid question, but: What kind of window manager do games use which have internal frames (Frames inside frames)? Does this differ between the programming languages (Are e.g. in Java the AWT/Swing libraries used to manage these and other graphical elements, such as buttons,or is this to restrictive (speed, graphical possibilities?))

A special example would be EVE Online, where the client can use the ingame windows like on a normal desktop.


texts:
I've got a projectile working perfectly using the code below:

//initialised in loading screen
    60 is the FPS - projectilEposition and velocity are Vector3 types

gravity = new Vector3(0, -(float)9.81 / 60, 0);
//called every frame
projectilePosition += projectileVelocity;

This seems to work fine but I've noticed in various projectile examples I've seen that the elapsedtime per update is taken into account. What's the difference between the two and how can I convert the above to take into account the elapsedtime? (I'm using XNA - do I use ElapsedTime.TotalSeconds or TotalMilliseconds)?

Edit: Forgot to add my attempt at using elapsedtime, which seemed to break the physics:

projectileVelocity.Y += -(float)((9.81 * gameTime.ElapsedGameTime.TotalSeconds * gameTime.ElapsedGameTime.TotalSeconds) * 0.5f);

Thanks for the help


texts:
Google has failed me, I could not find anything informative. So perhaps GameDev can :).

What are 3D textures?
When are they
used?
Performance costs?
How are they stored?

I have many vague ideas, but no 'definitive' definition.

Any references to examples or tutorials is appreciated, especially in rendering particle systems via 3D textures.


texts: I'm trying to understand the mathematical theory behind UVW mapping. Can anyone explain me how UVW mapping works? Or at least provide me a pointer?


texts: How to apply Collider to Particle and what components are needed for particles?

texts: i want to apply collider to particle system because if i applied the collider to particle ,if any other game object touched to that particle its gives some action or do some operation.so only i need.


texts: Issue with TurnBased Multiplayer Game in Game-kit

texts:
I am working with cocos2d game in which i am implementing Game-kit. My game supports multiplayer option. Actually as given example Raywenderlich link. I am GKTurnBasedMultiplayer class from Game-kit. But now the issue when first player connected to game center and will select option of "Play Now" it automatches for another player. but issue is it directly connects and starts the match, and doesn't wait for another player. I am using

[[GCTurnBasedMatchHelper sharedInstance] findMatchWithMinPlayers:2 maxPlayers:4 viewController:viewConroller];

for connecting and playing with other players but directly connects the match.

I want to wait for another player.  That is the issue. I am also using GCTurnBasedMatchHelper Class.


texts: Texture visualization problem on camera movement (xna)

texts:
I'm trying to move a camera over a model that is used as the floor of the game. When I move the camera, the texture of the model is not showing correctly (video of the problem: http://www.youtube.com/watch?v=bpycA7epMns&feature=youtu.be). I know that the model is fine because i use xnamodelviewer (http://modelviewer.codeplex.com/) to preview all the models, and  i can see it all right, even if i move the camera. So, the problem is in my model class maybe? what is wrong with this? any help is appreciated.

this is the model class im using:

public class CModel
{
    public Vector3 Position { get; set; }
    public Vector3 Rotation { get; set; }
    public Vector3 Scale { get; set; }

    public Model Model { get; private set; }

    private Matrix[] modelTransforms;
    private GraphicsDevice graphicsDevice;
    private BoundingSphere boundingSphere;

    public BoundingSphere BoundingSphere
    {
        get
        {
            // No need for rotation, as this is a sphere
            Matrix worldTransform = Matrix.CreateScale(Scale)
                * Matrix.CreateTranslation(Position);

            BoundingSphere transformed = boundingSphere;
            transformed = transformed.Transform(worldTransform);

            return transformed;
        }
    }

    public CModel(Model Model, Vector3 Position, Vector3 Rotation,
        Vector3 Scale, GraphicsDevice graphicsDevice)
    {
        this.Model = Model;

        modelTransforms = new Matrix[Model.Bones.Count];
        Model.CopyAbsoluteBoneTransformsTo(modelTransforms);

        buildBoundingSphere();

        this.Position = Position;
        this.Rotation = Rotation;
        this.Scale = Scale;

        this.graphicsDevice = graphicsDevice;
    }

    private void buildBoundingSphere()
    {
        BoundingSphere sphere = new BoundingSphere(Vector3.Zero, 0);

        // Merge all the model's built in bounding spheres
        foreach (ModelMesh mesh in Model.Meshes)
        {
            BoundingSphere transformed = mesh.BoundingSphere.Transform(
                modelTransforms[mesh.ParentBone.Index]);

            sphere = BoundingSphere.CreateMerged(sphere, transformed);
        }

        this.boundingSphere = sphere;
    }

    public virtual void Draw(Matrix View, Matrix Projection,bool luces)
    {
        // Calculate the base transformation by combining
        // translation, rotation, and scaling
        Matrix baseWorld = Matrix.CreateScale(Scale) * Matrix.CreateFromYawPitchRoll(Rotation.Y, Rotation.X, Rotation.Z) * Matrix.CreateTranslation(Position);

        foreach (ModelMesh mesh in Model.Meshes)
        {
            Matrix localWorld = modelTransforms[mesh.ParentBone.Index]
                * baseWorld;

            foreach (ModelMeshPart meshPart in mesh.MeshParts)
            {
                BasicEffect effect = (BasicEffect)meshPart.Effect;

                effect.World = localWorld;
                effect.View = View;
                effect.Projection = Projection;
                if (luces == true)
                {
                    effect.LightingEnabled = true;
                }
                else
                {
                    effect.EnableDefaultLighting();
                }
            }
            graphicsDevice.DepthStencilState = DepthStencilState.Default;
            mesh.Draw();
        }
    }
}

If I disable the line:
    graphicsDevice.DepthStencilState = DepthStencilState.Default;
The problem with the texture is solved, but i now have problems with the model showing things that must be hidden behind others, like in this picture:


texts: How do I efficiently fill the background with a tiling image?

texts:
I'm learning Unity by developing a 2D game. It's similar to RimWorld and Prison Architect. I have a 32×32-pixel grass tile image that I want to fill the background with.

Here's a screenshot from Prison Architect to demonstrate what I want:

I created a 2D sprite and set the grass image as sprite and created a prefab with this gameobject. I used this to fill background with prefab:

 // This script attached to main camera
for (int q = -1*(Camera.main.pixelHeight/2); q<Camera.main.pixelHeight; q++) {
    for (int i = -1*(Camera.main.pixelWidth/2); i<Camera.main.pixelWidth; i++) {
        Instantiate (grass, new Vector3 ((float)i, (float)q, 0f), Quaternion.identity);
    }
}

It's really slow because it's creating 619200 instances of the prefab for 860×720 screen resolution.

How can I better do this?

UPDATE 1

After Joe's answer.

Imported grass image to Unity

Created new material

Created a quad and set grass material

Result (ignore the purple thing):