texts: How do we adapt our game to work over a network?

texts:
A friend of mine has made a Java version of a popular board game in Java, and has it working for multiplayer on one PC with different turns for each player. He's mentioned he wants it to eventually run from a webserver and people around the world can play the game together, but he's dismissed this as impossible (translated: Too hard to be worthwhile).
I'd like to make this happen for him, and I'm wondering:

Do we need to completely rebuild or can we just adapt the existing code, for the game to work across a network?
What are the advantages of a GWT based browser game, compared to a swing based client side game that updates to a server?

What is the common practice here, for going from one instance on one PC to multiple instances across several networked PCs?
Edit:
The game code is very well broke and down and generalised; game logic and display are completely seperate. The main GUI is a scroll pane with a dungeon, squares are coloured for monsters, players, doors, floors etc, and are just JButtons essentially. Players have turns and then the monsters have a turn. It's very simple in essence.


texts:
Note: This is long but I explaining everything that you need to know. Don't read half way through it and say "What's the question?". It's simple but long and I need help as soon as possible.

So I asked a question not long ago that was similar but it wasn't my best work. What I'm trying to do is make a small jar with no other files but the jar (maybe natives if needed) that handles a window and graphics for games. I'm making this for some people I know who don't want to get into advanced graphics and stuff to make games, plus I figure it would be easier to stick everything they need into one jar that they know how to use. Anyway I found JOGL but after like the past 3 hours or so all I got with JOGL was the memory to never use it because it's a pain to install (at least for me) and everyone says a different way to install it and I need like 100 files along with my jar to get it to work. So since I'm not dealing with JOGL i figured that it's best to try and find something else. So does anyway know any way to get OpenGL into java without libraries that add more files and if so just like 1 file? I'm trying to get it so it's just that jar and nothing else. I just want this done but I'm very confused. I would also like it to be able to run on Windows, Linux and Mac. I only have a Windows machine although I can get Linux to test it on and I know someone who has a Mac but keep in mind I'm building it on a Windows machine. So my question really is how would I be able to stick OpenGL (I would like OpenAL and maybe OpenCL too) in a single jar and nothing else? I have a few exceptions such as I'm kinda ok if I need a few natives but I don't want 10 jars and 50 natives and I need it to work on all kind of machines, and also I would like to be able to use swing to handle the window.


texts: I am currently using Java to develop a multiplayer game engine. However, I am stuck on one thing. Many games (Overwatch, DotA) have automatic game search engines - you click a button and the computer automatically finds you a game. My first thought to replicate this was to have a server that every computer running the game would connect to, then would find groups of, say, in a 3v3 team game, 6, start a new room with those 6, and run the game. However, there is one major problem here: I am only 14 and am nowhere NEAR being able to afford a server farm that would be necessary. Since I cannot afford this, a single server running the game would be out of the question, so I've been looking into the p2p (peer-to-peer) format. The problem is, I cannot think of a way to have an automatic game search engine in a p2p format without a host server. Is there any way that I can replicate this with a p2p format?


texts: XNA 4.0 storage framework not being recognized

texts:
This may be a silly question but, im unable to do any save game data because for some reason, this following namespace is unrecognizable:

 using Microsoft.Xna.Framework.Storage;

All the normal XNA namespaces work but not this one. Im ade sure to uninstall XNA 3.1, and the windows phone 7 SDK. Then i un-installed XNA 4.0 and reinstalled it. Im not sure whats wrong, but i would really enjoy some help so could get to saving some games.


texts:
Im trying to create an Animated Waterfall Tilemap from a tutorial video.

In his video when the author right clicks he can see a Animated Tile > under CREATE option.

But In my case its not there !! Please see picture below.


texts: How to make a door stay open if the player is inside the trigger zone?

texts:
I've been struggling with this for all day long, I want to make a door to stay open when the player is inside the trigger zone, but I cannot make it happen...

Here is what I did:

A basic animations and animator (Open, Close, Idle/Default)
Default transitions between states (with and without "Exit Time")
A basic script to check if the player is inside the trigger:

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

public class DoorScript : MonoBehaviour
{
    Animator _animator;
    bool doorOpen;

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

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

} */

void OnTriggerEnter(Collider other)
{
    if (other.tag == "Player")
    {
        doorOpen = true;
        DoorController("isOpen");
    }
}

void OnTriggerExit(Collider other)
{
    if (other.tag == "Player")
    {
        doorOpen = false;
        DoorController("isClosed");
    }
}

void DoorController(string trigger)
{
    _animator.SetTrigger(trigger);
}
}

And my result is the same, the animation of the door repeats itself even when the player is in the trigger zone, I tumbled upon some other resources (here... here... here... here I tried to copy what this person did, but is the same... here... and here) about doors and triggers, and I still don't know how I am wrong or what am I doing wrong, I tried everything in those links

The door goes through all animations regardless the script, and the parameters, when I move my player inside the trigger zone loops between open and close animations no matter what

Could some one help me with this?

Thanks in advance

EDIT:

Here are some screenshots of my animator and updated code, for this update I followed this tutorial, just a little difference, I'm using a FPS Controller from the Unity standard assets

Updated code:

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

public class DoorScript : MonoBehaviour
{
    Animator _animator;
    bool doorOpen;

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

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

    } */

    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            doorOpen = true;
            DoorController("isOpen");
        }
    }

    void OnTriggerExit(Collider other)
    {
         //These lines were modified
        if (doorOpen)
        {
            doorOpen = false;
            DoorController("isClosed");
        }
    }

    void DoorController(string trigger)
    {
        _animator.SetTrigger(trigger);
    }
}


texts: Does game development have its own types of modeling?

texts: In general computer science there are modeling "languages" (read: standardized diagramming techniques) such as UML 1,2, in databases there are things like ERD3, in business there are other types such as BPMN4,5. Is there anything like these that are Game Design specific?


texts: How to setup my texture cordinates correctly in GLSL 150 and OpenGL 3.3?

texts:
I'm trying to do texture mapping in GLSL 150 and OpenGL 3.3

Here are my shaders I've tried my best to get this correct as possible hopefully this is :)

I'm guessing you want to know what the problem is well my texture shows but not in its fullest form just one section of it not the full texture on the quad.

All I can think of is its the texture cordinates in the main.cpp which is at the bottom of this post.

FRAGMENT SHADER

#version 150

in vec2 Texcoord_VSPS;

out vec4 color;

// Values that stay constant for the whole mesh.
uniform sampler2D myTextureSampler;

//Main Entry Point
void main()
{

    // Output color = color of the texture at the specified UV
    color = texture2D( myTextureSampler, Texcoord_VSPS );

}

VERTEX SHADER

#version 150

//Position Container
in vec3 position;

//Container for TexCoords
attribute vec2 Texcoord0;

out vec2 Texcoord_VSPS;

//out vec2 ex_texcoord;
//TO USE A DIFFERENT COORDINATE SYSTEM JUST MULTIPLY THE MATRIX YOU WANT

//Main Entry Point
void main()
{
    //Translations and w Cordinates stuff
    gl_Position = vec4(position.xyz, 1.0);
      Texcoord_VSPS = Texcoord0;
}

LINK TO MAIN.CPP
http://pastebin.com/t7Vg9L0k


texts:
I've gone through Unity's documentation for Quaternion.LookRotation, but I didn't get the full understanding of how it works.

What is the meaning of Creates a rotation with the specified forward and upwards directions?
And if I have to rotate my object in X axis I have to modify both X and Z axisVector3 lookAt = new Vector3(relativePos.x, 0, relativePos.z);
transform.rotation = Quaternion.LookRotation(lookAt);, why can't I only just modify the X axis directly to rotate?


texts: Ways to "invert Z-axis" in shader-based core-profile OpenGL?

texts:
In my hobbyist shader-based (non-FFP) GL (3.2+ core) "engine", everything in world-space and model-space is by design "left-handed" (and to stay that way), so X-axis goes from -1 ("left") to 1 ("right"), Y from -1 ("bottom") to 1 ("top") and Z from -1 ("near") to 1 ("far").

Now, by default in OpenGL the NDC-space works the same but the clip space doesn't, from what I gather, here z extends from 1 ("near") to -1 ("far").

At the same time I want to ideally keep using the "kinda-sorta inofficial quasi-standard" matrix functions for lookat and perspective, currently defined as:

func (me *Mat4) Lookat(eyePos, lookTarget, upVec *Vec3) {
    l := lookTarget.Sub(eyePos)
    l.Normalize()
    s := l.Cross(upVec)
    s.Normalize()
    u := s.Cross(l)
    me[0], me[4], me[8], me[12] = s.X, u.X, -l.X, -eyePos.X
    me[1], me[5], me[9], me[13] = s.Y, u.Y, -l.Y, -eyePos.Y
    me[2], me[6], me[10], me[14] = s.Z, u.Z, -l.Z, -eyePos.Z
    me[3], me[7], me[11], me[15] = 0, 0, 0, 1
}

//  a: aspect ratio. n: near-plane. f: far-plane.
func (me *Mat4) Perspective(fovY, a, n, f float64) {
    s := 1 / math.Tan(DegToRad(fovY)/2) // scaling
    me[0], me[4], me[8], me[12] = s/a, 0, 0, 0
    me[1], me[5], me[9], me[13] = 0, s, 0, 0
    me[2], me[6], me[10], me[14] = 0, 0, (f+n)/(n-f), (2*f*n)/(n-f)
    me[3], me[7], me[11], me[15] = 0, 0, -1, 0
}

So, for the lookat-part to have my world-space camera (positive-Z) work with lookat (negative-Z) as per this pseudocode:

// world-space position:
camPos := cam.Pos
// normalized direction-vector, up/right/forward are 1 not -1:
camTarget := cam.Dir
// lookat-target:
camTarget.Add(&camPos)
// invert both Z:
camPos.Z, camTarget.Z = -camPos.Z, -camTarget.Z
// compute lookat-matrix:
cam.mat.Lookat(&camPos, &camTarget, &Vec3{0, 1, 0})

That works well. Moving the camera in all 6 degrees of freedom produces correct on-screen movement and correct new camera world-space coords.

But geometry is still inverted on the Z-axis. When I position two boxes, A at (-2, 1, -2), to appear near-left and B (2, 1, 2) to appear far-right,  then A appears far-left and B appears near-right. Z is still inverted here.

Now, these nodes have their own world-space coords and update from those their own model-to-world matrices. I shouldn't invert posZ there as they form a hierarchy of sub-nodes multiplying with their parents transforms and all that. They're still in model or world space, which as per my decree is to remain left-handed.

Their world-to-camera calculation happens on the CPU at my end, not in a vertex shader which just gets a single final (mvp/clip-space) matrix.

When that happens -- multiplication of world-space-object-matrix with clip-space lookat-and-projection matrix -- at that point I need to somehow invert Z.

What's the best way to do this? Or, more generally speaking, what's a common way that works? Do I have to modify the projection to accept left-handed but output-to-GL right-handed? If so, how? And then wouldn't I also have to modify lookat? Is there a smart way to do all this without having to modify the somewhat-standard lookat/projection matrices while also keeping model-transform-matrices in left-handed coords?


texts: Missing Reference exception when accessing a GameObject in Unity

texts:
I have been making a C# script that attacks the player in Unity. However, with the following code I got the following error message:

  "The object of type 'GameObject' has been destroyed but you are still trying to access it.

Here is my code:

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

public class attackPlayer : MonoBehaviour {

    GameObject Enemy;
    GameObject Player;

    void Start ()
    {
        Enemy =  GameObject.FindWithTag ("Enemy");
        Player = GameObject.FindWithTag ("Player");
    }

    void Update ()
    {
        var heading = Enemy.transform.position.x - Player.transform.position.x;
        if (heading > 0.0f && heading < 5.0f)
        {
            Explode ();
        }
    }

    void Explode()
    {
        var exp = GetComponent <ParticleSystem>();
        exp.Play ();

        Destroy (gameObject,exp.main.duration);
        Destroy(Player);
    }

    void OnCollisionEnter2D (Collision2D col)
    {
        if (col.gameObject.tag == "Player")
        {
            Explode ();
        }
    }
}


texts: How to display Render Target live to HUD widget in UE4

texts:
I'm making a security camera system in Unreal Engine 4. It allows the player to 'activate' the monitor, which should display the Render Target texture or the material made from it on the HUD. However, that just doesn't work. There's just no image when I try to play it. Nothing appears on the screen. I'm using blueprints btw, not C++. And yes, I did check and make sure that it's not the part that displays the HUD that's going wrong, it's the displaying of the render target to the UI widget. To display it, i've tried using the image component in the UI widget.

Can anyone help?


texts: Splitting textured model faces into different polygons

texts:
So I have a bunch of hat models that I wanted to incorporate into my game (custom engine, c++/opengl) and my problem with the models right now is that each hat has its own texture with different color spots on it.
That is, I have a lot of these models:

And with textures such as these (e.g the wizard hat)

What I would love to have instead is just a model, and if there are patterns within the model, it would be reflected as polygons with colors on it instead.
I realize this can be quite complex, but besides this hat model, there are a lot of other models I'm seeking to use, but have single colored faces, but instead of having colors on the actual models itself they use texture coordinates and some color palette kind of texture:

My problem with these is that I can't easily modify their colors without changing the texture coordinates.
Now, I'm using my own engine and I guess these assets were originally meant for unity/unreal. How is is handled over there, when you want to change the color palette, to affect a model's color to reflect a team? E.g change a shirt's highlights from red to blue, but not the whole shirt?


texts: How can I detect mouse events on sprites in a canvas?

texts:
I'm making an HTML 5 game. I want mouse clicks on sprites drawn in a canvas element cause events that my code can react to. At the moment, I'm doing it by checking through all of my sprites in a for-loop on each click.

Is there a way to do that by adding an event listener to a sprite so it would respond just like that?

Are Javascript's custom events useful in this situation? I know it's possible with KinectJS, but I don't have any experience with it and really I'd like to learn how to do this myself without the help of a library.


texts:
There is something I can't figure out.

I have two models - grass.blend and tower.blend.

grass.blend:

tower.blend:

Note X, Y and Z axises.

The problem is that when I load these models using Assimp the scene looks like this:

The tower should be placed vertically, but for some reason it is placed horizontally. I didn't rotate it this way. Why is it happening?

Project example is here (tower was rotated in Blender right way for now). Tower model could be downloaded from blendswap.com.


texts: Relational Databases vs XML vs public static finals: Pros and Cons

texts:
I'm working on a game (single player, metroidvania type, Java) and I'm torn as to how data should be stored. For example, monster stats, dialogues, flavor text for weapons, gear stats... there is all kinds of fixed data that needs to be loaded.

I've tried 3 ways of handling this:

Apache derby database
XML (or JSON or CSV) files
Java classes with a long list of "public static final" Strings/floats

Hands down I love #1 the most, but I wonder if it will affect performance. I hate #2 because it requires a lot more work to organize everything, plus I have to do encryption and remove said encryption when debugging. #3 works fine but feels... unprofessional or sloppy.

I want to hear from someone with experience, since I'm new at this, what are the pros/cons of each, and is there a "best way", for simple single player games?


texts: Smoothing Pathfinding on Tile-Based Terrain but Free-Roaming Player

texts:
I'm sorry if this is a long post, but I feel as though the details should help clarify gray areas. I'll try and provide a detailed layout of what I'm trying to achieve, what I have so far, and where my questions stand/I'm stuck at.

(Will likely touch up how this post looks when seeing it live properly)

Game Overview:
I'm designing a top-down, single-layer, obstacle-based game that will consist of tile-based terrain (only squares). Players, enemies, and objects, however, will be capable of free-roaming and do not snap to any grid. Players, in particular, will vary in sizes and models, so as a generalization they could be circles, triangle, squares, X's, etc.

Since pathfinding is going to rely on solidity, this is the layout I am aiming for:

Tiles will always be solid or not solid.
Players and enemies will never be solid.
It would be nice for objects to go either-or, but if not they can be non-solids.

My Progress:
I've got the the grid-based terrain set up in a Tile[][] design. Since there's only 1 tile per (x,y) coordinate, this allows for clean referencing. Tiles, however, could change via triggers very seldom. So a non-solid Grass tile could turn into a solid Stone tile that is impassible.

Player movement via the mouse is in place. Although this will likely get overwritten with the pathfinding, it currently works with moving the player from point A to point B. The player class has its pixel-position, image, scale, and speed. A player will be 1 grid unit in size (currently 40x40px) and scaled from there. So 0.5 scale is always 20x20px.

Minor hit box detection is in place with bounding boxes as a very general design. Later this will likely get changed to a pixel-checking hitbox method.

My questions/concerns:
My main question for reference is which pathfinding method(s) can I use to know that my unit that isn't based on a grid can move through my map properly and not have clipping? Keeping in mind again that the player can vary in size and tiles can change solidity.

I've spent the past few days looking into pathfinding methods. I've looked into A*, HAA*, HPA*, NavMeshes, and lightly into things like D* and Dijkstra's algorithm. However, pathfinding in general is brand new to me when it comes to something that doesn't move directly on a grid.

Reference material:

The 2x2 teal box is the player. The green 2x2 is the goal. The dots are where the player's top left would be if he went on the grid one square at a time. The gold line is what I'd like to path like.

This HPA* method seems like it'd work, but I'm not sure how to get the path smoothing to work. Would I just constantly see if the next point in the list is something I can go directly to without clipping and remove it if I can?

End Comments:
I'm not sure if posting some structural code here would provide any benefit as my issue is with the methodology of how to approach this rather than what I have so far.

I do know there are some topics involving this. I cannot link since I'm limited to two, but I see one here titled 'Tile-wide extent tracing on a grid' that seems to ask a similar thing. The problem with almost all example pictures of pathfinding methods uses a size-less example. (Except this one, but it still clips in one of its turns)

The unit itself will have a turning speed involved, but I don't think that should affect the cornering. For the most part, I don't need smooth, car-like, turning if it's more work.

Please let me know if there's anything I missed, I should clear up, or if I've overlooked a topic that went deep into exactly what I'm asking. It's late and I wanted to get something up on here while I continue my search. I just feel lost in this implementation.


texts:
What would a ball look like when it makes itself bounce. Say, for example that the ball had its own "inner power", was made out of (mostly) rubber, and pulled the top of itself inward and then released, causing itself to 'bounce' up. Is that logic correct? And is this what it would look like?

If this logic is correct, what other materials can have this effect given the scenario described above?


texts: Using same buffer for vertex and index data?

texts:
Is it possible to use the same buffer for both GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER?

I load both vertex data and index data into a big slab of memory, so it would be easier for me to just load it all into a single buffer. So naturally, I do like this

glBindBuffer(GL_ARRAY_BUFFER, vboId);
glBufferData(GL_ARRAY_BUFFER, dataSize, data, usage);
glBindBuffer(GL_ARRAY_BUFFER, 0);

Is it legal to – during rendering – simply use it as both?

glBindBuffer(GL_ARRAY_BUFFER, vboId);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboId);
glVertexAttribPointer(...);
...
glDrawElements(mode, count, dataType, (void*)indexOffset);

I can't find anything in the spec saying it's ok to do so, but I can't find anything that says that I can't either. Googling doesn't turn up much either, but I might be looking in the wrong places.


texts: Shadow mapping. I don't understand what to do after creating the depth texture

texts:
I'm taking an intro to computer graphics course, so this is something we haven't touched on.

I am reading this tutorial http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/ but I cant figure out what to do after creating the depth texture. The depth texture is from the lights point of view (directional light). I sent the depth texture to my post process shader where I want to apply the shadows.
The depth texture:

From what I understand from the article, I also need the position texture from the light's point of view.

The position texture:

And then the article determines if the current pixel is visible from the lights point of view like this:

float visibility = 1.0;
//ShadowCoord is the position of the vertex as seen from the light
if ( texture2D( shadowMap, ShadowCoord.xy ).z  <  ShadowCoord.z){
   visibility = 0.5;
}

Here is what I end up with:

Im not sure, but I believe my position texture is wrong?

Edit:
Here is how I create the position relative to the light texture in my shader:

positionSunPOV = (biasMatrix * sunMVP * vPosition).xyz;
// biasMatrix is the matrix that changes the coords from [-1,1] to [0,1]
// sunMVP is the model view projection matrix for the sun than I passed in
// vPosition is the position of the vertex

Here is how I create sunMVP:

SunDir = vec3(0,30,-30);
sunProjectionMatrix = ortho(left, right, bottom, ytop, nearO, farO);
sunViewMatrix = lookAt(SunDir, vec3(0,0,0), up);
sunModelMatrix = mat4(1.0);
//sunMV = mult(sunViewMatrix,sunModelMatrix);
sunMVP = mult( sunProjectionMatrix, mult(sunViewMatrix,sunModelMatrix) );


texts: Can I use information from a science book and mention it in bibliography without copyright problems?

texts: I'm making an educational game to study some science topics. I want the users to know that the information in my game is real. Can I use a science book and mention it in the bibliography? Of course I will not copy / paste, I will only paraphrase some concepts.


texts:
I'm using Unity C#. How would I create the effect in my pool game, a line showing the direction of the second (not white) ball after collision.
Example:

I need to make the line coming from the ball (second/leftmost)

P.S. I made the other line by using Raycast to find the hit point and set that point last position of line renderer (white ball is a start position for line renderer and it casts the ray)


texts: Unity DirectoryInfo not working in OSX standalone build

texts: So I'm building an application in unity which I hope to use at a market day coming up soon at my school (it's not a game, it's basically like a checkout app, kind of...) Anyway, I'd like to be able to import images from the app and to have the option to change them while the app is running. Currently I have the images in a folder and I'm using DirectoryInfo to get the contents of that folder and load the images. Works like a dream inside the editor but as soon as I build the app (on OSX), everything is blank. Other people seem to have similar issues but I'm a little unsure as to how they fixed it. Could someone please help me, this is kind of urgent!


texts: How to take into consideration the effect of initial rotation of a ball hitting & reflecting off a surface

texts:
Hey all, I am trying to take into consideration the effect of inertia of the initial rotation of a ball, hitting a surface, into the exit velocity vector of the ball.

My current theory is this:

Assume Ball initial rotation is Ri
Calculate an exit Velocity vector
without any consideration for the
ball's initial rotation, call this
Ve
Rotate Ve by an angle proportionate to Ri [while limiting the rotation, so ball new vector does not point into surface]. Call this new vector rVe
Calculate exit rotation of ball, by calculating it as a portion of max ball rotation speed, bas on angle between rVe & Vi using dot product of these two vectors

Does this sound right to you? Am I missing something here? Is there an easier way to do this?


texts: Calculating size and position of Tilemap for camera bounds

texts:
I'm new to Unity and I'm following a series of tutorials covering off building a 2D Zelda-like game. I'm at a stage where I have two Tilemaps side by side and I'm working on a transition between them, triggered when the player collides with a trigger at the edge of Tilemap 1.
I have a basic camera movement script which follows the player and constrains the camera within the bounds of Tilemap 1 - it's constrained by two Vector2 fields (a min and a max). I got the values for these two Vector2 fields manually in the Scene editor by moving my camera to the desired edges, noting its transform position and entering in those values to the camera movement script.
For the transition, I will change these min and max Vector2 values in the camera movement script to then constrain the camera to Tilemap 2. I could just hard code these in again, but it seems like a good learning opportunity to try and calculate these values dynamically.
My room change script stores a reference to the camera movement script so that it can amend the min and max values itself. In an attempt to get it to calculate the next room's bounds dynamically, I added a public Tilemap field to the room change script so it can examine it and determine the bounds of the next room itself. I then set this field in the Inspector to point to Tilemap 2.
I've so far been unable to calculate these new bounds from the Tilemap reference. The cellBounds property looked promising: Position (-44, -7, 0), Size: (19, 20, 1) - the size is right, but the actual origin position I calculate manually by moving my camera in the scene editor is -35.14, -2.02. As a result, setting the bounds off of what cellBounds tells me does not work. I've made sure that I've used the 'Compress Tilemap Bounds' too.
I've tried accessing individual tiles within the Tilemap and using CellToWorld - this only seems to give me the Tile's position relative to the Tilemap (?).
The transforms for all of the Tilemaps in my scene - and their parents (which are Grids) - are set to 0, 0, 0.
Basically, I know I should calculate a value of approximately -35.14, -2.02 for my new min position, but I can't see any way to calculate that. How do I go about achieving this, and the same for max?
Here is what my scene looks like:

Main Camera [Camera, Audio Listener, Camera Movement (script)]
Player [Sprite Renderer, RigidBody 2D, Box Collider 2D, Player Movement (script), Animator]
Room1 [Grid]

Ground [Tilemap, Tilemap Renderer]
Collision [Tilemap, Tilemap Renderer, Tilemap Collider 2D, RigidBody 2D, Composite Collider 2D]

Room2 [Grid]

Tilemap [Tilemap, Tilemap Renderer]

RoomTransfer [Box Collider 2D, Room Move (script)]


texts: How can I randomly spawn circles on a screen but make sure they don't overlap?

texts:
I just need a general idea for how to do this.

I have a list of Circle objects.

Circle {

private int yCoord;
private int xCoord;

Circle(int a, int b) {

xCoord = a;

yCoord = b;

}
}

I randomly spawn circles on a screen:

private void spawnCircles() {

   //Spawns new circle in a rectangular region that starts at top corner
   //of screen and has 100 pixels length and width.
   Circles.add(new Circle(rand.next(100),rand.next(100));
}

The radius of the circles is 20 pixels.

How can I spawn these circles randomly so they don't overlap?

All I need is pseudo code or a rough outline.


texts: How can I execute GLFW fullsceen in a secondary monitor (Xorg)?

texts:
I am currently learning GLFW using C++. I have found many tutorials on initializing windows, but not many on initializing full screen, and next to nothing on initializing full screen on a secondary display (In this case, my television). This way I can use my primary display for logging and debugging.

I have visited the man-pages for GLFW. However, even after going over examples for glfwGetMonitors(), I am still not entirely sure how to use these in conjunction with  glfwCreateWindow().

I have included links to the reference pages.

GLFW Monitor Guide

GLFW Window Guide


texts: For my Heat I want to change the players speed but its not working

texts:
I have a heat bar for my player and I want it so if the player is at 40 heat or under the players speed slows. This is my script. The problem is when the player gets to under 40 heat the speed is not changing. Is this because I have a player speed on my movement script?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerHeat : MonoBehaviour
{
    public float maxHeat = 100;
    public float currentHeat;
    public float heatLossPerSecond;
    public float moveSpeed = 4f;

    public HeatBar heatBar;

    void Start()
    {
        currentHeat = maxHeat;
        heatBar.SetMaxHeat(maxHeat);
    }

    void Update()
    {
        if (currentHeat <= 40)
        {
            moveSpeed = 2;
        }

        currentHeat -= heatLossPerSecond * Time.deltaTime;
        if (currentHeat <= 0)
        {
            currentHeat = 0;
        }
        heatBar.SetHeat(currentHeat);
    }

    public void Heat(float amount)
    {
        currentHeat += amount;
        if (currentHeat > maxHeat)
        {
            currentHeat = maxHeat;
        }
    }
}

This is my movement script
public class PlayerMovement : MonoBehaviour
{
    public float moveSpeed = 5f;

    public Rigidbody2D rb;
    public Camera cam;

    Vector2 movement;
    Vector2 mousePos;

    // Update is called once per frame
    void Update()
    {
        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");

        mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
    }

    void FixedUpdate()
    {
        rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);

        Vector2 lookDir = mousePos - rb.position;
        float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg - 90f;
        rb.rotation = angle;
    }
}


texts: what is the best way to add avoidance behaviour to an AI framework?

texts:
I have a small AI framework for a shooting based game. Although this is rarely needed, as when agents are close to each other they are usually fighting, I would none the less like some way of implementing avoidance behaviour.

For example, if in the future I wanted to take away their weapons and have many of them wonder around in a crowd, how would I make them not hit / pass through each other, but instead avoid each other? while still following their calculated paths that is.

two ideas I had would be to add steering behaviour and allow that to deviate from their path, or to use a dynamic pathfinding technique. Are these valid solutions? If yes how, in theory, would I implement them? Are there better ways? What is the more respected practice?


texts: Have a method accept generic methods for a in-game console

texts:
I'm making a console, like in Half-Life so that the devs can add their commands.

I'm making this in Unity's C#.

I have a problem when dealing with the commands. When you want to add a commands, you create a class Command and add it through a method to the Console List of Commands.

The code of the class Command is the following one:

public class Command
    {
        /// The string by which this command will be called
        public string commandKey;
        /// The information of this command that the help option will show
        public string helpInfo;

        public delegate string stringVoid();
        public delegate string stringString(string consoleInput);
        public delegate void voidCmd();
        public delegate void voidString(string consoleInput);

        public stringVoid _stringVoid;
        public stringString _stringString;
        public voidCmd _voidCmd;
        public voidString _voidString;

        public Command(string commandInput, string helpTooltip)
        {
            commandKey = commandInput;
            helpInfo = helpTooltip;
        }

        #region Add Command Methods
        public Command addVoidCommand(voidCmd voidCommand)
        {
            _voidCmd = voidCommand;
            return this;
        }
        public Command addStringVoid(stringVoid stringVoidCmd)
        {
            _stringVoid = stringVoidCmd;
            return this;
        }

        public Command addStringString(stringString stringStringCmd)
        {
            _stringString = stringStringCmd;
            return this;
        }

        public Command addVoidString(voidString voidStringCmd)
        {
            _voidString = voidStringCmd;
            return this;
        }
        #endregion
    }

As you can see users can add four types of delegates methods:

Void methods with no parameters.
String methods with no parameters.
Void methods with a string parameter.
String method with a string parameter.

This makes the class very heavy, and makes the users have to navigate through a lot of options to add a class.

I want to have some way to add methods without having to go through so many options, and, from my side, taking out the need of searching through so many options when a command is called from console.

You can find the whole script/project here.

In conclusion, I want to have a way that the user simply write

// way I want it to work
new Command("commandName", "this is an example" ExampleCommand);
new Command("commandString", "this is another example" ExampleString);

void ExampleCommand(){ }
string ExamplesString(string ble){ return ble + "bla"; }

// way it currently works
new Command("commandName", "this is an example").addVoidCommand(ExampleCommand);
new Command("commandString", "this is another example").addStringString(ExampleString);

To simplify everything. Is any way I can achieve this with delegates, Unity Actions or something else?

Thank you very much.


texts: Would making a satirical version of someone else's character get me sued?

texts: Licensing the rights to a popular character is definitely a hard process. Rather than licensing the rights to (insert hero here), what if I were to make a satirical version of the IP owner's character(s) like Spaceballs did? What sort of legal trouble could I face for making a satirical rip-off of a character?


texts: How do I make "weaponsclash" = animations adapating to parameters

texts:
Meaning: how do I build my animations/system so that I can have swords blocking each other?
I honestly believe this is the hardest part of a game: I need animations to interact with each other. If a monster uses attack 1 on hero 2, then both NPCs have to play a different animation based on,

A, How big these NPCs are. I need them to be able to be scaled (monsters can grow, but when it jumps on a small player, it still has to look just as fitting as with other sizes)
B, Speed of the monster when it runs up for the attack.
C, Countless other things I suppose.

How do I achieve this? KI, Pathfinding... all that is meaningless unless I can build a believable combat system.


texts: Directx9 - Generate mesh from vertex and index buffer

texts:
I've got a single vertex buffer and an index buffer for a cube in Directx9. I now want to generate a LPD3DXMESH  object from them, so that I can manage mouse picking and other stuff with the cube model. How can I achieve this? Here's the code of my vertex and index buffers:

CUSTOMVERTEX vertices[] =
{
    { -3.0f, 3.0f, -3.0f, D3DCOLOR_XRGB(0, 0, 0), },
    { 3.0f, 3.0f, -3.0f, D3DCOLOR_XRGB(0, 0, 0), },
    { -3.0f, -3.0f, -3.0f, D3DCOLOR_XRGB(0, 0, 0), },
    { 3.0f, -3.0f, -3.0f, D3DCOLOR_XRGB(0, 0, 0), },
    { -3.0f, 3.0f, 3.0f, D3DCOLOR_XRGB(0, 0, 0), },
    { 3.0f, 3.0f, 3.0f, D3DCOLOR_XRGB(0, 0, 0), },
    { -3.0f, -3.0f, 3.0f, D3DCOLOR_XRGB(0, 0, 0), },
    { 3.0f, -3.0f, 3.0f, D3DCOLOR_XRGB(0, 0, 0), },
};

d3ddev->CreateVertexBuffer(8 * sizeof(CUSTOMVERTEX),
                           0,
                           CUSTOMFVF,
                           D3DPOOL_MANAGED,
                           &vertex_buffer,
                           NULL);

VOID* pVoid;
vertex_buffer->Lock(0, 0, (void**)&pVoid, 0);
memcpy(pVoid, vertices, sizeof(vertices));
vertex_buffer->Unlock();

short indices[] =
{
    0, 1, 2,
    2, 1, 3,
    4, 0, 6,
    6, 0, 2,
    7, 5, 6,
    6, 5, 4,
    3, 1, 7,
    7, 1, 5,
    4, 5, 0,
    0, 5, 1,
    3, 7, 2,
    2, 7, 6,
};

d3ddev->CreateIndexBuffer(36 * sizeof(short),
                          0,
                          D3DFMT_INDEX16,
                          D3DPOOL_MANAGED,
                          &index_buffer,
                          NULL);

index_buffer->Lock(0, 0, (void**)&pVoid, 0);
memcpy(pVoid, indices, sizeof(indices));
index_buffer->Unlock();


texts: Are there existing FOSS component-based frameworks?

texts:
The component based game programming paradigm is becoming much more popular. I was wondering, are there any projects out there that offer a reusable component framework? In any language, I guess I don't care about that. It's not for my own project, I'm just curious.

Specifically I mean are there projects that include a base Entity class, a base Component class, and maybe some standard components? It would then be much easier starting a game if you didn't want to reinvent the wheel, or maybe you want a GraphicsComponent that does sprites with Direct3D, but you figure it's already been done a dozen times.

A quick Googling turns up Rusher. Has anyone heard of this / does anyone use it?
If there are no popular ones, then why not? Is it too difficult to make something like this reusable, and they need heavy customization? In my own implementation I found a lot of boilerplate that could be shoved into a framework.


texts: When using deferred rendering technique, what space should my normals be? Why?

texts:
I'm implementing a deferred shading technique and the following question arose:

When storing the normals, should I transform to view space, or may I keep them in world space? Why?

Will any of the alternatives be better than the other for calculating lighting?


texts:
I have made a box where you can type in your name in unity. After typing your name you can click on the button. Clicking on the button it will copy the string that you typed in within a sentence. so like: "The name" + stringToEdit + "is the name that your parents gave you!" . Now I used debug.log so that the text will show up in the debug. Is there a way to make the button add a text in a specific position in the scene that copies the string plus the sentences after being clicked???

I Used JS script by the way.


texts: Creating an Android port of old PC games

texts:
I have seen some decent ports to Android of old PC games.

The graphics and game engines are the same, and all that seems to have been changed was the key mapping, and adding touch-screen events.

I want to play around with learning how to do this, but I have done a lot of searching online, and haven't been able to find a general overview of how to begin.

What would I to do, or at least, where can I learn how, to take an old, existing PC game, and port it to Android, only changing the key-mappings, and add touch-screen support?

From what I have seen, a native app is created to launch the game, and then from that point, you're just playing the original game.

And I'm not referring to playing games through emulators.  This is something that would be able to be downloaded from the Google App store.  And I would first get rights to do so, of course, unless it was, or has been released as, an open-source game.


texts: Is it possible to convert file from Blender 3d to svg?

texts:
I want to build web game in html5 with canvas/svg.

Can I convert/export file from blender to canvas/svg?

Maybe via unity3d?


texts:
What do you guys think of using Windows Azure for deploying a custom built game server. It's being built in C#, and I want to get a few things down before stretching too far into the project.

I like the idea of being scalable, but I also know that I will never get to the scale of anything to the scale of WOW, or something quite as big. It will just be an interesting journey to test something like this.

So, will Windows Azure work for that, or is there any other services that can provide something like that?


texts: How do I apply touches to images, using Swift?

texts:
I need code this game for iOS, using Swift; but I don't know how to apply touches to images, using Swift. My attempts thus far have failed; touch!.view != image.

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
    let touchesSet = touches as NSSet
    let touch = touchesSet.anyObject() as? UITouch
    let location = touch?.location(in: self.view)
    if touch!.view == bee1 {
        bee1?.center = location!
    } else if touch!.view == bee2 {
        bee2?.center = location!
    }
}


texts:
So i have written a program to play a sound file when ever my RightHand.Joint touches the 3D model . . It goes like this . . even though the code works somehow but not very accurate  . . for example it will play the sound when my hand is slightly under my 3D object not exactly on my 3D object . How do i make it more accurate?  here is the code . . (HandX & HandY is the values coming from the Skeleton data RightHand.Joint.X etc) and also this calculation doesnt work with Animated Sprites..which i need to do

foreach (_3DModel s in Solar)
{
    float x = (float)Math.Floor(((handX * 0.5f) + 0.5f) * (resolution.X));
    float y = (float)Math.Floor(((handY * -0.5f) + 0.5f) * (resolution.Y));
    float z = (float)Math.Floor((handZ) / 4 * 20000);

    if (Math.Sqrt(Math.Pow(x - s.modelPosition.X, 2) + Math.Pow(y - s.modelPosition.Y, 2)) < 15)
    {
        //Exit();
        PlaySound("hyperspace_activate");

        Console.WriteLine("1" + "handx:" + x + "," + " " + "modelPos.X:" + s.modelPosition.X + "," + " " + "handY:" + y + "modelPos.Y:" + s.modelPosition.Y);
    }

    else
    {
        Console.WriteLine("2" + "handx:" + x + "," + " " + "modelPos.X:" + s.modelPosition.X + "," + " " + "handY:" + y + "modelPos.Y:" + s.modelPosition.Y);
    }
}


texts: In Unity, does a reference delegate clear out when its parent GameObject is destroyed?

texts:
If I have a GameObject with a component like some:

class SomeComponent : MonoBehaviour
{
    System.Action DoStuff;
}

class SomeOtherComponentInAnotherGameObject
{
    public GameObject ObjectWithThatComponent;
    void Start()
    {
        ObjectWithThatComponent.GetComponent<SomeComponent>().DoStuff += SomeFunc;

        Destroy(ObjectWithThatComponent);

        // is there still a reference to SomeComponent somewhere?
    }
}

I'm getting some odd behaviour/random crashing when deleting this stuff but I'm not sure if it's being caused by these delegates.


texts: Unity swapping textures not working, weird?

texts:
I made two textures for my 3D game character. I can use both of them by dragging them on my player but I want to do the same through code. I searched and found that people are either using:

1) rend.material.mainTexture = texts [0];

or

2) transform.GetComponent<Renderer>().material.mainTexture = texts [0];

but none of them works for me. I have a mesh renderer attached to my player. I set my code to swap the texture on my player when it reaches a certain amount of points. To debug I attached an empty material to my player and during run time so that I could see the texture on it but the swap didn't take place. The first texture is in texts[0] and the second one is in texts[1].

This is my code:

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

public class swaptexture : MonoBehaviour {

    public Texture[] texts;
    public gemlife g;

    // Use this for initialization
    void Start () {

        transform.GetComponent<Renderer> ().material.mainTexture = texts [0];
    }

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

        if (g.ratio >= 0.96f)
            transform.GetComponent<Renderer> ().material.mainTexture = texts [1];
    }
}


texts: How to remove voxel lights with Minecraft-style algorithm?

texts:
I am making a voxel game. I have researched lighting techniques, and the minecraft-style algorithm appears the most efficient. When blocks are placed, they are marked for update. The engine performs a recursive algorithm on them that forms a diamond-shaped pattern like this:

01210
12321
01210
00100

My question is how you would remove lights using such an algorithm. Suppose your light setup looks like this: (The 2s would be the light sources)

01100
12210
01100

And you wanted to remove one of the light sources. From what I have seen, it would produce a result like this:

01000
10000
01000

A diamond-shaped pattern around the light source would be removed. How can I remove a light source without causing this effect?


texts: When is an intro too long for game logos?

texts:
After doing some searching and finding no answers, I decided it would be okay to ask here.

In indie or big company games, when they show their logo or have an animation for that company logo, what is the average display time for it and how often do they have themes or sounds with that splash screen?


texts: Unable to add asset/sprite, not sure why

texts:
I'm using Unity and have a 2D project.  I'm trying to add a background image to my project/scene, but I'm unable to.

Adding smaller .png files to the project work fine, by simply dragging them onto the Hierarchy tab.  My background image, and larger images, do not work though.  Below is the image in question:

It's a 66kb png.  Nothing weird about it.

How should I be adding it as a background if I'm unable to add it as a sprite?

Below is the assets settings under Import Settings:


texts: Packet Loss Affecting Client-Side Prediction

texts:
I have been reading about client-side prediction lately and I have been thinking of ways to implement it into my multiplayer game. I think I have a pretty good understanding of client-side prediction but I am a bit confused of how packet loss will affect it.

For example, say the client moves left. The client moves left on its side and also sends a packet to the server. If the server received this packet, it would see it was a valid move and send a packet back validating the clients decision. But if the packet didn't make it, the server would not move left and if the client moves left again their move will seem invalid to the server, giving the client a choppy experience.

So my question is how is client-side prediction implemented without this problem? Thanks for your help.


texts: Anyone know the frames per second that IOS apps run?

texts: Anyone know the frame rate that iphones, ipads, and even android mobiles run?


texts: Unity editor PropertyDrawer custom button

texts:
I has a PropertyDrawer, everything goes fine, except one feature: I can't figure out how to add button and I use checkbox instead

using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomPropertyDrawer (typeof (InteractiveObject))]
class InteractiveObjectPropertyDrawer : PropertyDrawer {

public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) {

    EditorGUI.BeginProperty (position, label, property);
    position = EditorGUI.PrefixLabel (position, GUIUtility.GetControlID (FocusType.Passive), label);
    var indent = EditorGUI.indentLevel;
    EditorGUI.indentLevel = 0;
    Rect colorRect = new Rect (position.x, position.y, 40, position.height);
    Rect unitRect = new Rect (position.x + 50, position.y, 90, position.height);
    Rect nameRect = new Rect (position.x + 150, position.y, position.width - 150, position.height);

    EditorGUI.BeginChangeCheck();
    EditorGUI.PropertyField (colorRect, property.FindPropertyRelative ("show"), GUIContent.none);
    if (EditorGUI.EndChangeCheck() ) {
        RenderSettings.skybox.SetColor("_highlight", property.FindPropertyRelative ("id").colorValue);
    }

    EditorGUI.PropertyField (unitRect, property.FindPropertyRelative ("name"), GUIContent.none);
    EditorGUI.PropertyField (nameRect, property.FindPropertyRelative ("name"), GUIContent.none);
    EditorGUI.indentLevel = indent;
    EditorGUI.EndProperty ();
}
}

How I can add button there?


texts: Shoot a bullet towards cursor - top down 2d

texts:
I am making a 2D topdown shooter game, in which the player's movement is controlled with WASD and gun with the mouse. I'm having a hard time figuring out how to update the position of the bullet as it moves towards the cursor.

I have the player's X and Y coords, and the cursor's X and Y coords. I need to be able to update the bullet's X and Y coords each frame based on its trajectory.


texts:
I'm using Godot 3.1.1 and just realized that there is no available AA options. According to some post, Godot 2 supports FXAA, but some reason it's took out from 3. So I try to get FXAA for Godot 3.1, but couldn't find any.

I don't want to publish my game without Anti Aliasing. Is there a way to apply FXAA in Godot 3.1.1 which using GLES3?


texts: Trouble using Ray.Intersect method on bounding boxes in a 2D XNA game

texts:
I am trying to use a ray and bounding box to determine if a box is between the player and the mouse pointer in 2D space.  When I try testing the code, the collision will return true when pointed at the box but it also returns true under other circumstances where it shouldn't.

For instance.  If I have a player on the left and a box directly to the right, I can put the mouse pointer a few hundred pixels above the box or a few hundred below and it will still return true.  Also, I can put my mouse pointer to the left of the player and in a certain area it will still return true.  Does anyone have any idea what might cause this?

I have left out definitions for some of my members and properties just to make this code sample easier to read.  The position property is just a Vector2 for where each object is located.

ray = new Ray(new Vector3(player.Position, 0), new Vector3(mouse.Position, 0);
box = new BoundingBox(new Vector3(box.Position, 0), new Vector3(
new Vector2(box.Position + box.Width, box.Position + box.Height), 0);

if (ray.Intersects(box) != null)
    collision = true;
else
    collision = false;


texts:
I'm attempting to write a level viewer for Quake 3 levels (repo here). I've got some of the way towards it, but for every level I try to view with it I get lots of missing faces.

(image from Dustbowl)

In the above image, I have disabled backface culling in order to show where faces are missing a little better.

My question is, has anyone else run into this problem? I know Quake/Quake 3 level rendering is a well-trodden path, so I'm luckier than most in this situation. I so far only render meshes and polygons, not models, but most of the missing faces seem to be where one would expect static faces.

I'm not really asking for a code review, as much of the implementation details I would not expect to be common (I transform the BSP tree into a proper tree structure and discard the index-based structure entirely), but if anyone has seen this before I'd love to know what the issue was.


texts: how to implement A Star path finding on 2D map with large tiles

texts:
The map tiles I have im my game are 64x64 pixels, and the characters are 16x16 pixels. I was reading about A Star path finding and I was wondering if I need my tiles closer to the size of my characters so that the movement given by the path finding seems more natural, or should I set up a different node map of where the characters can move, and use that in the A Star algorithm.

Or if you have a better solution let me know

Thanks!

EDIT: this is the Map class I am using

public class Map extends JComponent{
MapTile[][] map;
Random random;

public Map(char[][] mapKey){
    map = createMap(mapKey);
}

public void update(){

}

@Override
public void paintComponent(Graphics g){
    for(int i = 0; i < map.length; i++){
        for(int j = 0; j < map[0].length; j++){
            drawTile(g, map[i][j].getType(), i * 64, j * 64);
        }
    }
}

private MapTile[][] createMap(char[][] mapKey){
    MapTile[][] temp = new MapTile[mapKey.length][mapKey[0].length];

    for(int i = 0; i < mapKey.length; i++){
        for(int j = 0; j < mapKey[i].length; j++){
            temp[i][j] = new MapTile(mapKey[i][j]);
        }
    }
    return temp;
}
}

really the only thing that the MapTiles hold at this point is a key to the Image they paint on the screen


texts: How to batch coroutines (IEnumerators) in parallel

texts:
We are working in a context where multithreading is not an option, so we're using coroutines to handle our loads. Often there are multiple things that need to be downloaded, leading to a pattern like this:

// set up multiple downloads
dataToDownload = 3;
StartCoroutine(ReadDataCoroutine1(OnDataRead));
StartCoroutine(ReadDataCoroutine2(OnDataRead));
StartCoroutine(ReadDataCoroutine3(OnDataRead));

// handle each of the loads completed
private void OnDataRead()
{
    // nasty and error prone way to check completion of all data
    dataToDownload--;
    if (dataToDownload > 0) return;

    DoStuffNowThatDataIsAllLoaded();
}

So I thought I would build a helper class to batch the downloads:

public BatchDownloader(
    IEnumerable<Func<IEnumerator>> downloadFuncs,
    Action<int, int> onDownloadComplete = null,
    Action<int> onAllDownloadsComplete = null)
{
    this.downloadFuncs = downloadFuncs;
    this.onDownloadComplete = onDownloadComplete;
    this.onAllDownloadsComplete = onAllDownloadsComplete;
    totalDownloads = downloadFuncs.Count();
}
public IEnumerator DownloadBatch()
{
    completedDownloads = 0;
    foreach (var downloadFuncs in downloadFuncs)
        yield return ProcessDownload(downloadFuncs);
    onAllDownloadsComplete?.Invoke(totalDownloads);
}
private IEnumerator ProcessDownload(Func<IEnumerator> downloadFunc)
{
    yield return downloadFunc();
    onDownloadComplete?.Invoke(totalDownloads, ++completedDownloads);
}

Used something like this:

public IEnumerator LoadAllTheThings()
{
    Func<IEnumerator>[] downloadFuncs = new Func<IEnumerator>[]
    {
        ReadDataCoroutine1,
        ReadDataCoroutine2,
        ReadDataCoroutine3
    };

    BatchDownloader batchDownloader = new BatchDownloader(downloadFuncs);

    yield return batchDownloader.DownloadBatch();

    DoStuffNowThatDataIsAllLoaded();
}

Now that is much cleaner, more flexible, and it all works a treat, except that no load starts until the previous finishes. This obviously has a huge effect on load time. So in an attempt to have the coroutines run simultaneously, I'm trying the following:

public IEnumerator DownloadBatch()
{
    completedDownloadsCount = 0;

    var activeDownloads = new List<IEnumerator>();
    foreach (var downloadFunc in downloadFuncs)
    {
        activeDownloads.Add(downloadFunc());
    }

    while (activeDownloads.Count > 0)
    {
        yield return null;
        for (int i = activeDownloads.Count - 1; i >= 0; --i)
        {
            var download = activeDownloads[i];
            if (!download.MoveNext())
            {
                onDownloadComplete?.Invoke(totalDownloadsCount, ++completedDownloadsCount);
                activeDownloads.RemoveAt(i);
            }
        }
    }

    onAllDownloadsComplete?.Invoke(totalDownloadsCount);
}

Now while this correctly kicks off the coroutines, and runs them "in parallel", any code after the last yield in a coroutine is not executed. So in a method like the following:

private IEnumerator ReadDataCoroutine1()
{
   yield return WaitForStuffToDownload();

   DoPostDownloadStuff();
}

DoPostDownloadStuff() is never called.

What am I misunderstanding here about stepping through these IEnumerators? Is there a way to do what I'm trying to, without introducing StartCoroutine into the batch downloader? (that is my solution for now, but idealy I'd like to not have to)


texts: Proper audio formats in low resolution without gaps for a game

texts:
I'm a music composer and I have to give my first job for a game. They are working in Objective C in Xcode, it's a game for iPhone/iPad.

I need to know the proper audio format to give programmers since .mp3 or .aac make gaps at the start and end of the loop and .Wav or .Aiff are too heavy.

I'm working in Windows7 with Sony Sound Forge and Audacity.


texts: margin of error trying to check if a point lays on line

texts:
Working with floating point values it is as easy as breathing to run on approximation errors by comparing quantities which should be the same. I want to know if there is a way built in some MSDN (or even external) library for c# to ignore the problem.

An example could be: more than comparing 2 float values like this

if(myVector3.X == anotherVector3.X)

I would appreciate something like this

if(myVector3.X.isInTheNeighbourhood(anotherVector3.X))

This is not well-written, I know. That is just to simplify the explaination. What I am exactly doing is checking if a point (Vector3) lays on line segment. So basically the calculations I make are nothing more than

(x - x1)/(x2 - x1) = (y - y1)/(y2 - y1) = (z - z1)/(z2 - z1)

But these values won't be always the same, so I need to write down some code which includes a sort of tolerance a sort of Neighbourhood mathematical concept to accept values close enought to the line.

Hope that I made myself clear.
Has anyone a solution for this?


texts: How to play an animation backwards in Unity?

texts:
I know this question has been asked before but it all involves using the Animation(?) component, so that is no longer any good in Unity 5.3.1f1, I explain a bit more later.

I'm trying to simply get an animation to play backwards. On the object that I want to have an animation play backwards on, I have an animator.

private Animator anim;
...
anim = GetComponent<Animator>();

If I do:

animator.speed = -1.0f;

It tells me Animator.speed can only be negative when Animator recorder is enabled. Animator.recorderMode != AnimatorRecorderMode.Offline

So I try putting on an Animation component on the game object, and making the clip the animation.

Every time I do anything with the Animation component in script, it tells me the component must be marked as Legacy. That is no good, because when I tried making it Legacy it caused multiple problems including not being recognized by the Animator. Also GetRef errors. The entire Animation component seems like it's treated as legacy now or is just broken.

So I decided well maybe I could just try to get the animation to play backwards in the animator and having the animator record it, and then using that backwards recorded animation in the actual game. I cannot figure out how to this, even if I click record in the Animation view anim.recorderMode != AnimatorRecorderMode.Record. I don't know what to do. All I want to do is play the same animation backwards without having to copy and paste an animation in the Project and moving all of the keys around so that they are reversed. Please help. Unity's animation system seems so convoluted in script.


texts: Unity TextMeshPro bounds.size is wrong when hovering first time over gameobject

texts:
I have this weird issue, which I am not able to fix. This is my third attempt and I need some help. Basically I have a hover element which spawns when I hover over a gameobject. The height of the element is determined by the amount of text (TextMeshProUGUI).
The issue happens only when I hover first time, also not always (I have no clue how to reliably to reproduce it).
Here is what happens (sec 10~):
https://vimeo.com/449387131
I have tried to add these everywhere and different combinations:
LayoutRebuilder.ForceRebuildLayoutImmediate(hoverElementRect);
hoverElementRect.ForceUpdateRectTransforms();
Canvas.ForceUpdateCanvases();
txtMeshPro.ForceMeshUpdate();

They dont seem to help. I assume the problem is here:
float bgHeight = txtMeshPro.bounds.size.y + 25;

The bounds.size.y is wrong the first time I hover, but I have no clue why.
Here is the whole code for spawning the GUI element:
public static void SpawnGeneralHoverElement(string descText, RectTransform hoverOverRect, float guiWidth) {
    Canvas hoverCanvas = instance.hoverElementGeneral.GetComponent<Canvas>();
    EnableCanvas(hoverCanvas);

    TextMeshProUGUI txtMeshPro = hoverCanvas.GetComponentInChildren<TextMeshProUGUI>();
    RectTransform hoverElementRect = hoverCanvas.GetComponentsInChildren<RectTransform>()[1];

    float scale = hoverCanvas.GetComponent<RectTransform>().localScale.x;

    txtMeshPro.text = descText;

    // Need this to be dynamic, if I change hover element size, it will still work
    float hoverElementWidth = guiWidth;

    // Forces canvas update because of: stackoverflow.com/questions/55417905/why-is-textmeshpro-not-updating-textbounds-after-setting-text
    Canvas.ForceUpdateCanvases();
    LayoutRebuilder.ForceRebuildLayoutImmediate(hoverElementRect);
    hoverElementRect.ForceUpdateRectTransforms();
    txtMeshPro.ForceMeshUpdate();

    // Need this because otherwise the element spawns too far away on smaller resultions
    float spawnOffset = (txtMeshPro.bounds.size.y * hoverCanvas.GetComponent<RectTransform>().localScale.x) + (Screen.height * 0.022f);

    float bgHeight = txtMeshPro.bounds.size.y + 25;

    hoverElementRect.position = new Vector3(hoverOverRect.position.x, hoverOverRect.position.y + spawnOffset,
        hoverOverRect.position.z);

    hoverElementRect.sizeDelta = new Vector2(guiWidth, bgHeight);
    Debug.Log(hoverElementRect.sizeDelta);

    LayoutRebuilder.ForceRebuildLayoutImmediate(hoverElementRect);
    hoverElementRect.ForceUpdateRectTransforms();
    Canvas.ForceUpdateCanvases();
    txtMeshPro.ForceMeshUpdate();

    // Slide in form left to right if off bounds, need for traps for example
    float leftOffset = hoverElementRect.position.x - ((hoverElementRect.sizeDelta.x * scale) / 2);
    if (leftOffset < 0) {
        hoverElementRect.position = new Vector2(hoverElementRect.position.x + (leftOffset * -1) + 15, hoverElementRect.position.y);
    }

    // Slide in form right to left if off bounds, need for traps for example
    float rightOffset = Screen.width - (hoverElementRect.position.x + ((hoverElementRect.sizeDelta.x * scale) / 2));
    //Debug.Log("Screen width: " + Screen.width + "\nrightOffset: " + rightOffset);
    if (rightOffset < 0) {
        hoverElementRect.position = new Vector2(hoverElementRect.position.x - (rightOffset * -1) - 15, hoverElementRect.position.y);
    }

    LayoutRebuilder.ForceRebuildLayoutImmediate(hoverElementRect);
    hoverElementRect.ForceUpdateRectTransforms();
    Canvas.ForceUpdateCanvases();
    txtMeshPro.ForceMeshUpdate();

}


texts:
[UNITY]
As you can see above a solid color is connecting one platform to another. My question is whether this color must be applied through code or through a sprite. In my game there are three lanes and for each platform you land on, it must connect the color to the platform...and so to put that into sprites seems to be a bit numerous...in my opinion with varying vertical and horizontal distances between the platforms it will much too difficult to make each individual sprite (as they also are of varying colors).

Hopefully, the above explains my dilemma well enough. Would anyone be so kind as to guide me through this?


texts: How should I update object movement on Client in a lockstep game?

texts:
I have a game that I am implementing a lockstep system for multiplayer on an RTS game. Now the server sends update packets at a higher frequency than the clients with new data.

What I'm stuck on understanding about lockstep systems is how does this tie in with the movement of the units. Should I only move the objects when a new update packet is received?


texts: Attach a method to every GameObject or use a manager script

texts:
I'm new to Unity but not new to development so I'm wondering what the standard way of doing this in with Unity.

In the scene from the start is an empty GameObject that has a script that contains all of the items in the game. Once the game starts, chest prefabs are going to be spawned in the game and upon interaction they will reveal some random loot from the items script.

Is it better practice to have a script on all of the chests that accesses the items script or should I create another empty GameObject as a sort of a chest manager that accesses the item script and keeps track of all of the chests in the game and what all of their loot is.


texts: What's the easiest way to fill my 3d enviornment with temporary graphics?

texts:
Currently I am starting a 3D game with C# but I don't have a designer yet nor any images or anything or any money to invest on it.

I would like to develop it using some sort of placeholder or whatever to fill the graphics so I can make at least the basics of it and later simply switch for the real thing.

Should the place holders be actual sample images or can I use for example a ball to represent a body (what will be the impact of it later when I switch to the actual body it self)?


texts: How to save Player's progress with variables?

texts:
I'm trying to save and load my Player's progress. I have a serialized class named "gamestate".

This class contains all of the Player's progress, number of lives, total points, etc. That class also contains a public static gamestate current variable that I use to call later.

This class has a save method, which I assigned to a save button. The save method comes from "SaveLoad" class where I have a list of gamestate GameObject. On that method I add a "gamestate.current". When I try to save or load I get a message that my gamestate is actually NULL. I can't tell if my variables are not being passed into my gamestate class or my list is being created with null object.

Can anyone help me fix this? Thanks!

Now the code :

Class gamestate:

[System.Serializable]

public class gamestate: MonoBehaviour {

  public static gamestate current;

  public GameObject thirdpersoncontroller;
  public GameObject gameover;

  public int live=5;
  public Text txtlive;
  public Text txtscore;
  public AudioSource source;
  public AudioClip audiogameover;

  void Awake(){
    current = this;
  }

  void Start () {
  }

  // Update is called once per frame
  void Update () {
    txtscore.text = ThirdPersonCharacter.score.ToString();

    txtlive.text = live.ToString();
  }

  void livegameover(){
    live= live- 1;

    if (live== 0) {
      source.clip = audiogameover;
      source.Play();
      Time.timeScale = 0.0f;
      gameover.SetActive(true);
    }
  }

  public void SaveMethod(){
    Debug.Log ("save...");
    SaveLoad.Save();
  }
}

Class SaveLoad :

public static class SaveLoad  {

public static List <gamestate> savedGames = new List<gamestate>();

public static void Save(){
  SaveLoad.savedGames.Add(gamestate.current);   //here is gamestate current is NULL.
  BinaryFormatter bf = new BinaryFormatter ();
  FileStream file = File.Create(Application.persistentDataPath + "/savedGames.gd");
  bf.Serialize(file,savedGames);
  file.Close ();
}


texts: How can I get the NodePath that points to the property, rotation, of the parent node?

texts:
The 2nd arg in interpolate_property takes a NodePath, but str of a path to a prop seems fine too. So I'd expect this to work:

var rotation_node_path = "/root/Main/Boid1/InitialRegion/Bird:rotation"

but I'm getting the error

ERROR: interpolate_property: Condition ' !prop_valid ' is true. returned: false

func lerp_rotation():
    add_child(tween)

    var rotation_node_path = str(parent.get_path()) + ":rotation"
    var current = Math.smallest_equal_angle(parent.rotation)
    var target = Math.smallest_equal_angle(target_rotation)
    var duration = 1
    print(current, ' ', target, ' ', rotation_node_path)

    tween.interpolate_property(parent, rotation_node_path, current, target, 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
    tween.start()


texts: What is the proper way to create a camera matrix?

texts:
I am having issues when trying to create a camera transform. It seems to have odd distortions and it does not seem to rotate properly, though it will translate alright. While I have seen issues like this where the rotation does not work, I have not found any like my issue.
This is what I currently do to create the matrix:
Mat4 TransformLookAt(Vec3 from, Vec3 to, Vec3 world_up) {
    Mat4 view_matrix = Mat4New(1.0f);
    Mat4 rot_matrix = Mat4New(1.0f);

    Vec3 axis_n = Vec3Normalise(Vec3Subtract(to, from));
    Vec3 axis_v = Vec3Normalise(Vec3Cross(from, Vec3Cross(world_up, from)));
    Vec3 axis_u = Vec3Normalise(Vec3Cross(axis_n, axis_v));

    // Rotate on the X-axis
    rot_matrix.ax = axis_u.x;
    rot_matrix.ay = axis_u.y;
    rot_matrix.az = axis_u.z;

    // Rotate on the Y-axis
    rot_matrix.bx = axis_v.x;
    rot_matrix.by = axis_v.y;
    rot_matrix.bz = axis_v.z;

    // Rotate on the Z-axis
    rot_matrix.cx = axis_n.x;
    rot_matrix.cy = axis_n.y;
    rot_matrix.cz = axis_n.z;

    // Translate the camera
    view_matrix.aw = -from.x;
    view_matrix.bw = -from.y;
    view_matrix.cw = -from.z;

    view_matrix = Mat4ByMat4Multiply(view_matrix, rot_matrix);

    return view_matrix;
}

The camera is at (1.0, 0.0, 3.0) at is set to look at (0.0, 0.0, 0.0), which is where the centre of the cube is located. Here is what it looks like:

I would expect to see the left side and possibly top of the cube (since that is what this is supposed to do), but instead the cube has been distorted so that its left side cannot be seen.
That leads me to this question: If none of the methods like the one I've tried to implement works, then what is the proper way to create a camera matrix? What am I missing so that this does not work?
I understand how it should work, but I just can't get it to work. I feel like it might be something obvious, but I can't seem to figure it out.


texts:
After setting up my joystick axes in Unity and sweeping them around I find that the Y-axis jumps to the opposite direction in certain positions.

So, when I press up on the joystick, the input will often indicate that it's pointing down. It will also sometimes do this in the opposite direction. It's somehow tied to the x-axis position, making it especially weird.


texts:
I am having trouble with a camera class I am trying to use in my program. When I change the camera_target of the gluLookAt call, my whole terrain is rotating instead of just the camera rotating like it should.

Here is some code from my render method:

camera->Place();

    ofSetColor(255, 255, 255, 255);

 //draw axis lines
 //x-axis
 glBegin(GL_LINES);
 glColor3f(1.0f,0.0f,0.0f);
 glVertex3f(0.0f,0.0f,0.0f);
 glVertex3f(100.0f, 0.0f,0.0f);
 glEnd();

 //y-axis
 glBegin(GL_LINES);
 glColor3f(0.0f,1.0f,0.0f);
 glVertex3f(0.0f,0.0f,0.0f);
 glVertex3f(0.0f, 100.0f,0.0f);
 glEnd();

 //z-axis
 glBegin(GL_LINES);
 glColor3f(0.0f,0.0f,1.0f);
 glVertex3f(0.0f,0.0f,0.0f);
 glVertex3f(0.0f, 0.0f,100.0f);
 glEnd();

 glColor3f(1,1,1);

 terrain->Draw();

And the rotate and place methods from my camera class:

void Camera::RotateCamera(float h, float v){
hRadians += h;
vRadians += v;

cam_target.y = cam_position.y+(float)(radius*sin(vRadians));
cam_target.x = cam_position.x+(float)(radius*cos(vRadians)*cos(hRadians));
cam_target.z = cam_position.z+(float)(radius*cos(vRadians)*sin(hRadians));

cam_up.x = cam_position.x-cam_target.x;
cam_up.y = ABS(cam_position.y+(float)(radius*sin(vRadians+PI/2))) ;
cam_up.z = cam_position.z-cam_target.z;
}

void Camera::Place() {
//position, camera target, up vector
gluLookAt(cam_position.x, cam_position.y, cam_position.z, cam_target.x, cam_target.y, cam_target.z, cam_up.x, cam_up.y, cam_up.z);
}

The problem is that the whole terrain is moving around the camera, whereas the camera should just be rotating.

Thanks for any help!


texts:
I have a friend who is developing a game for HTML, and wants me to implement GLFX into the site page.
The problem is GLFX was designed specifically for use with the HTML5 Canvas, which he isn't using, and wants the effect across the whole site page, not just an area; here in lies the problem.

As GLFX was designed for Canvas objects specifically, and there are no obvious alternatives for creating CRT/Arcade-esque effects on websites, I seem to be at an impasse with my current understanding.

I have set up one of my own little side projects on a localhost on my PC in hopes that I can get it to work with a plane website.

Has anyone here had experience with GLFX, or know how I would implement it's effects onto the body of an entire site?

Here is the link he sent me to follow, it contains the "scanlines" image as well.

Sorry in advance if I have posted this in the wrong place, but I couldn't find StackExchange's Web Development community.

http://www.zachstronaut.com/posts/2012/08/17/webgl-fake-crt-html5.html


texts:
I'm trying to play background music for my game when it starts but I can't get it to work right. I'm not sure what's the right logic to do it.
I this my code (written in TypeScript):

backgroundAudio() {
        this.countAudio++;
        if (this.countAudio == 200) {
            let audio = new Audio();
            audio.src = "audio/background.mp3";
            audio.load();
            audio.play();
            this.countAudio = 0;
        }

}

Basically this method it's called over and over again in the loop of the game but when the game starts it has a short delay until the count gets to 200. I'm not sure how I should be doing it if I want to start when the game starts but have a delay until the song is played and than get called again.


texts:
I'm writing my own level editor and recently got the exporter working so now I'm working on the importer. My save file structure looks essentially like this:

[ObjectType]
    Property=Value
    ContentProperty:ContentType=ContentName
[/ObjectType]

The problem is in loading the content. I'm trying to find out how to load some content with the given content type at runtime. Technically, I could do a switch-case of each type

switch(ContentType)
{
    case Texture2D:
        Content.Load<Texture2D>(ContentName);
        break;
    case Model:
        Content.Load<Model>(ContentName);
        break;
    ...
}

but that just seems messy (and I can't find a reliable listing of all of the default content types in XNA).

Is there a way for me to load the content with the proper type without having to list out all possible types?


texts: Why doesn't my wave movement code account for the game object's initial position?

texts:
I want an object to move like wave. Currently, when I start the game the object's position doesn't account for its initial position. How would I fix this?

float amplitudeX = 5.0f;
float amplitudeY = 2.5f;
float omegaX = 0.5f;
float omegaY = 2.5f;
float index;

public void Update() {
    index += Time.deltaTime;
    float x = amplitudeX*Mathf.Cos (omegaX*index);
    float y = Mathf.Abs (amplitudeY*Mathf.Sin (omegaY*index));
    transform.localPosition= new Vector3(x,y,0);
}


texts:
So I've got the animation, it has root motion but activating it in the settings doesn't seem to do much.

What would be a good optimized way to have the character sit on the stool with the animation matching the movement? Would I need to do it through code?And if that's the case, could I specify in which frame do the movement? Or add a second animation that is in charge of Root Motion?

I know either of these two options I give could work but I'm checking to see if there is a better way or if I'm missing something here.

Thanks!

EDIT: Following DMGregory's comment I disabled the collider to see if it improved... it did change, but it isn't much better:

EDIT 2: This is how the animation preview looks like (what I'm expecting)

Then I just hold the last frame while they're sitting and play the animation backwards for when they're getting off - this is just while I get it to work.


texts: How does an iOS developer get his app/game on the AppStores main page?

texts:
I was looking at the front page of the AppStore, and they display a new game and a new app every day. I was just curious, how does an iPhone developer get their game or app onto that front page? Does Apple choose what goes on there? Or do you pay money?

I was just curious, I don't develop games for iOS.


texts: How can I provide a scrollable inventory list?

texts:
Does XNA have a built in method for drawing a scrollable list?

There would be a scroll bar on the right that can be selected and moved up and down to scroll the list inside the inventory screen. The list would not be all visible at once so as you scroll down the top items disappear and the bottom ones appear next in the list.

Visually it's like scrolling a webpage but within a smaller window.

Can this be done without using Windows Forms?


texts: Restricting Camera Movements with OpenGL

texts:
I've been programming a game using the Java library LWJGL. I've got a little problem, though. It is a 2D game, and I'm aiming for a game like the original Civilization (I quick Google of "Civilization 1" will show you what I want). So far I have been able to generate a random 64x64 tile world. Each tile is .5f in size, drawn like this:

float size = .5f;

//...

GL11.glTexCoord2f(uvCoords[0][0], uvCoords[0][1]); GL11.glVertex3f(-size, size, 0.0f);
    GL11.glTexCoord2f(uvCoords[1][0], uvCoords[1][1]); GL11.glVertex3f( size, size, 0.0f);
    GL11.glTexCoord2f(uvCoords[2][0], uvCoords[2][1]); GL11.glVertex3f( size,-size, 0.0f);
    GL11.glTexCoord2f(uvCoords[3][0], uvCoords[3][1]); GL11.glVertex3f(-size,-size, 0.0f);

Now, I don't want my camera to be able to leave this 64x64 space and see black. My camera works like this:

GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glLoadIdentity();
        GL11.glOrtho(position.x, position.x + Display.getDisplayMode().getWidth()/zoom, position.y + Display.getDisplayMode().getHeight()/zoom, position.y, -1, 1);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);

I am restricting its movements like this:

public void moveForward(float distance)
    {
        if(position.y <= 0.5f)
        {
            return;
        }
        position.y -= distance;
    }

    public void moveBackward(float distance)
    {
        if(position.y >= Constants.WORLD_SIZEY - 0.5)
        {
            return;
        }
        position.y += distance;
    }

    public void moveLeft(float distance)
    {
        if(position.x <= 0.5f)
        {
            return;
        }
        position.x -= distance;
    }

    public void moveRight(float distance)
    {
        if(position.x >= Constants.WORLD_SIZEX - 0.5)
        {
            return;
        }
        position.x += distance;
    }

Because the camera's location is the top left corner of the display, it works great for moveForward and moveLeft. However, for moveBackward and moveRight, it moves out of the 64x64 box until the top left corner gets to the edge.
How do I prevent this, because I don't know how to get the screens length in the units I am making the tile sizes.

Sorry if this is hard to understand, because I don't know how to explain it myself. That's why I've had so much trouble finding an answer.


texts:
In my car sim I am doing my calculations in Standard Units, except for the distance which is in pixels. Is this still correct (my guess is no) or should I use Meters ?

If I should use meters what is the best way to go about it?
should I just pick a scale 10px = 1m or is there a better way to do this ?

thanks in advance.

Some additional info: I'm using Unity3D and using its physics engine.


texts: How do I create a scrollableparallax background in AndEngine GLES1

texts: In my game I want my background to move side by side as the player moves on screen in AndEngine. I moved my sprite using analogScreenControl. I am using AndEngine GLES1. i don't want to move my background automatically but i want to move the background as per player moves on the screen with the help of analogScreenControl.


texts:
So I have this large forest of around 2M tris:

Same chunk selected with view on the whole level:

It's been generated within Blender and exported as fbx into Unity. Exporting each tree as an individual object is very performance expensive so the whole forest is split into 2 Objects: Treetrunks and leaves. The Treetrunks all have meshcolliders on them, the leaves obviously don't. (However I do split the forest into chunks as seen above, each chunk roughly 400k tris)

When the Player gets outside visible range of the forest it is disabled, and enabled when the Player gets within a certain range. When it is enabled sometimes it causes a massive lag. When looking into the Profiler it shows this:

Physics? FixedUpdate? The leaves have absolutely no colliders on them, why does it take up Physics.Processing? So I wanted to search further what part of Physics.Processing takes up so much processing time but the top process already shows nothing:

I have an 8 year old GTX760 but it still manages to render the entire forest at 200fps so no, the 2 million Tris are definitely not overkill for my computer.

I've tried this and that and 3 things managed to stop the issue (as seen in the profile screenshots above, the Physics processing time significantly reduced a few frames later)

Pausing & Unpausing the game or simply Alt-Tabbing outside the Unity Player and back (not always effective)
Disabling the Player & Reenabling it (almost always effective)
Starting the Scene with the Player (including Rigidbody, Camera and raycasting scripts) disabled and enabling him a few seconds later via script.  (almost always effective) However this only worked if ALL of the forest was set active (roughly 2M tris). If half the forest was disabled on start, and activated after the Player was enabled: LAG.

The Player is the only thing in the game (at this moment) that has a Rigidbody, Raycasting Scripts and a camera.

Things that didn't work:

Waiting a few minutes
Disabling & Reenabling the Players Character Controller at any time
Disabling & Reenabling the camera on the Player at any time.
Disabling & Reenabling the fucking trees

Anyone got an idea? I'm dumbfounded over here.


texts:
After having used display lists for my programs since I started learning OpenGL, I've finally decided to switch to VBOs after experiencing a considerable amount of lag when I started work on a new game. I've nearly finished with my transition, but I'm still having a bit of trouble with rendering the textures to the screen. The way I'm working it is this: I have several sprites of the same dimensions for each type of "block" in the game (it's a Terraria port) which are loaded into the game via a convenience method, then after they're all loaded, they're compiled into a virtual texture atlas via Graphics2D, converted to a Slick texture, and their relative coordinates are saved to a HashMap. However, when it comes time to grab the textures out of the HashMap and render them, the game simply doesn't. Here's part of my code for adding a block to the VBO (this is executed 4 times per block, once for each corner):

// top left
// vertex
values.add(Float.valueOf((float)b.getLocation().getPixelX()));
values.add(Float.valueOf((float)b.getLocation().getPixelY()));
// light
values.add(Float.valueOf((float)b.getLightLevel() / 15));
values.add(Float.valueOf((float)b.getLightLevel() / 15));
values.add(Float.valueOf((float)b.getLightLevel() / 15));
// texture
values.add(tX);
values.add(tY);

(Note: values is a list which is later converted to an array.)
Then comes my code for rendering the VBO:

public static void render(){
    glPushMatrix();
    glTranslatef(MineFlat.xOffset, MineFlat.yOffset, 0);
    glBindTexture(GL_TEXTURE_2D, BlockUtil.atlas.getTextureID());
    glVertexPointer(2, GL_FLOAT, 28, 0);
    glColorPointer(3, GL_FLOAT, 28, 8);
    glTexCoordPointer(2, GL_FLOAT, 28, 20);
    glDrawArrays(GL_QUADS, 0, vertexArray.length / 7);
    glBindTexture(GL_TEXTURE_2D, 0);
    glPopMatrix();
}

The blocks are properly rendered with the correct lighting, but they lack any sort of texture. Any suggestions as to how to get the code working? I apologize if the answer is obvious, but I still consider myself a bit of an OpenGL noob, especially in the area of VBOs.

One last thing; I should mention that I'm not using any shaders in my current game.

EDIT: I seem to be a bit mistaken. Upon experimenting with the code by manually setting all texture coords, I discovered that the game simply converts the texture to a uniform color by averaging the RGB value of all pixels. I didn't recognize this before because the color of most blocks is grey. I recall having this problem before with display lists, but that was quite a while ago, and so I don't remember how I resolved it.

SECOND EDIT: Screenshots of the expected and actual result, respectively:
http://i.stack.imgur.com/3t4r4.png
http://i.stack.imgur.com/edv8v.png


texts:
So I have created plane in which my buildings are going to be placed on and I was wondering how to add grids to it and make my building snap to it, just like in clash of clans.

Thanks!


texts:
I have written the following code:

public class TargetAnimation : MonoBehaviour {
    Animation anim;
    public AnimationClip Open;
    // Use this for initialization
    void Start () {
        anim = GetComponent<Animation>();
        anim.AddClip (Open, "Open");
        anim.Play ("Open");

    }
}

I have the following script and animation settings:

I have put the animation type in legacy and the generation as store in root (Depricated)
as suggested elsewhere, this did not work.
The animation works in the import/annimations view.
The origenal comes from blender. And all f this is in unity 5.


texts: Dynamic navigation mesh generation algorithm

texts:
I'm working on a 2D game (top down / zelda like view)

I'm struggling with navigation mesh generation, in complex scenarios my homemade algorithm is lost and too slow...

I would really love to see a detailed explanation of Hertel-Melhorn Algorithm (if you have any ressources). I'm open to suggestions for other good algorithms, as long as I can process round and square obstacles.

My map is randomly generated and obstacles can be added anytime.

I don't want to use a grid system, my entities are positionned freely.
My map is big so I can't store precalculated paths / I just need pathfinding to be efficient

I'm working with Javascript, I can't use c++ library like detour/recast

Edit

I am looking for serious documentation of fast triangulation algorithm

If I understand the process of navmesh generation :

Input walkable area(s) as polygons
triangulation of walkable area
(Optionnal) merge triangles to big convex polygons
Output a node graph


texts: Should the game update loop compensate for slowness

texts:
I am building a game engine and considering the design for the core game loop that will drive the game.

In the most basic form, the implementation looks similar to this (in pseudo-code):

while (game.running)
{
    // Calc time delta from last update
    var timeDelta = Time.now - lastUpdate

    engine.components.update(timeDelta)

    engine.drawAll()
}

This loop updates and draws in a 1:1 ratio (for every update there's a draw).

Should there be any compensation for the engine when it runs slower than its target update rate?

I've seen frameworks such as XNA for example, with the IsRunningSlowly property: http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.gametime.isrunningslowly.aspx

Is it preferred to keep a 1:1 update/draw ratio? or should i compensate for slower updates?


texts: How to include fur in the exported obj file in Maya?

texts:
In Maya I use fur to create plants. In my game I want to render these plants with cel shading. I use Wavefront .obj as a file format in my game for the models, but it doesn't seem to include the fur.

Is there a way to export the fur (as vertices) with the model into the obj file? Generating the fur at runtime is a bit CPU expensive for the platform.


texts: How to program friction in an air hockey game in Cocos2d-x 3.11?

texts:
I'm developing a simple air hockey game, and I have a question about friction of puck and puddles with the game scene. How can I do that? I'm using cocos2d-x default physics engine, and the friction setting of physic bodies only applies when they collide.

I've found an old air hockey example project, but it seems that it's ported to cocos2d-x 3.x so it doesn't use built in physics engine.


texts: I am a business developer who is new to game programming. In learning Stencyl, I see that there are things called collision shapes associated with tiles. This seems to be a standard term in game programming. What is a collision shape?


texts: Bounding volume hierarchy - linked nodes (linear model)

texts:
The scenario A chain of points: (Pi)i=0,N where Pi is linked to its direct neighbours (Pi-1 and Pi+1).

The goal: perform efficient collision detection between any two, non-adjacent links: (PiPi+1) vs. (PjPj+1).

The question: it's highly recommended in all works treating this subject of collision detection to use a broad phase and to implement it via a bounding volume hierarchy. For a chain made out of Pi nodes, it can look like this:

I imagine the big blue sphere to contain all links, the green half of them, the reds a quarter and so on (the picture is not accurate, but it's there to help understand the question). What I do not understand is:

 How can such a hierarchy speed up computations between segments collision pairs if one has to update it for a deformable linear object such as a chain/wire/etc. each frame? More clearly, what is the actual principle of collision detection broad phases in this particular case/ how can it work when the actual computation of bounding spheres is in itself a time consuming task and has to be done (since the geometry changes) in each frame update? I think I am missing a key point - if we look at the picture where the chain is in a spiral pose, we see that most spheres are already contained within half of others or do intersect them.. it's odd if this is the way it should work.


texts: Android cocos2d getting a sprite to continuously move to a dynamic position

texts:
I tried using the MoveTo method in cocos2d to get a sprite to continuously follow my player sprite:

CCMoveTo actionMove = CCMoveTo.action(actualDuration, player.getPosition());
CCSequence actions = CCSequence.actions(actionMove);
enemy_sprite.runAction(actions);

However when the sprite spawns it just goes to the position the player sprite was at when it spawned, therefore it doesn't follow it continuously.
So I tried using a recursive function to get the sprite to follow the player sprite continuously:

CCMoveTo actionMove = CCMoveTo.action(actualDuration, player.getPosition());
CCCallFuncN actionMoveDone = CCCallFuncN.action(this, "enemySpriteMoveFinished");
CCSequence actions = CCSequence.actions(actionMove, actionMoveDone);
enemy_sprite.runAction(actions);

Where "enemySpriteMoveFinished" is:

    public void enemySpriteMoveFinished(Object sender) {
    CCSprite sprite = (CCSprite)sender;
    CCMoveTo actionMove = CCMoveTo.action(0.5f, player.getPosition());
    CCCallFuncN actionMoveDone = CCCallFuncN.action(this, "enemySpriteMoveFinished");
    CCSequence actions = CCSequence.actions(actionMove, actionMoveDone);
    sprite.runAction(actions);
    }

But this method turns out to be rather choppy. Anyone have any solution to getting cocos2d to move a sprite to a dynamic position continuously that's smoother?


texts: White dots artifacts when applying borders to hex tiled geometry

texts:
I have a hexagon tiled geometry I created in Blender

Which I then load in WebGL, using THREE.js library. Below is the loading code, I've cut the code of creating scene, lights, etc. I create rendered with antialiasing flag.

grassTexture = new THREE.ImageUtils.loadTexture( 'textures/GrassTileModo.png');
grassTexture.wrapS = grassTexture.wrapT = THREE.RepeatWrapping;

var loader = new THREE.JSONLoader();
loader.load("models/hexmap.json", function(geometry)
    {
        var attr = []
        for(var i = 0; i < geometry.faces.length; i++)
        {
            if(i % 4 == 0)
                att = [new THREE.Vector3(1.0, 0.0, 0.0), new THREE.Vector3(0.0, 1.0, 0.0), new THREE.Vector3(0.0, 0.0, 1.0)];
            if(i % 4 == 1 || i % 4 == 2)
                att = [new THREE.Vector3(1.0, 0.0, 0.0), new THREE.Vector3(0.0, 0.0, 1.0), new THREE.Vector3(0.0, 1.0, 0.0)];
            if(i % 4 == 3)
                att = [new THREE.Vector3(1.0, 1.0, 1.0), new THREE.Vector3(1.0, 1.0, 1.0), new THREE.Vector3(1.0, 1.0, 1.0)];

            attr.push(att);
        }

        var material = new THREE.ShaderMaterial( {
            uniforms:
                {
                    diffuse: {type: 'c', value: new THREE.Color(1, 1, 1)},
                    opacity: {type: 'f', value: 1.0},
                    map: {type: 't', value: grassTexture},
                },
            attributes:
                {
                    aBorderMap: {type: 'v3', value: attr, boundTo: 'faceVertices'}
                },
            vertexShader: document.getElementById('shader-vs').firstChild.textContent,
            fragmentShader: document.getElementById('shader-fs').firstChild.textContent
        } );

        plane = new THREE.Mesh(geometry, material);
        scene.add( plane );

    });

Basically, the idea is I assign each vertex barycentric coords, and use them to know which edge I need to outline. Since my hexagons are getting tesselated by blender to 4 faces each, I assign different attributes to different faces, the way edges I don't need to outline are not outlined. In my case on the edges I don't want to outline, z barycentric coordinate will be zero.

This is how blender tesselates:

Vertex shader code:

precision highp float;
precision highp int;

uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
attribute vec3 position;
attribute vec2 uv;
varying vec2 vUv;
attribute vec3 aBorderMap;
varying vec3 vBorderMap;

void main()
{
    vUv = uv;
    vBorderMap = aBorderMap;
    vec4 mvPosition;
    mvPosition = modelViewMatrix * vec4( position, 1.0 );
    gl_Position = projectionMatrix * mvPosition;
}

Fragment shader code:

precision highp float;
precision highp int;

uniform vec3 diffuse;
uniform float opacity;
varying vec2 vUv;
uniform sampler2D map;
varying vec3 vBorderMap;

void main()
{
    gl_FragColor = vec4( diffuse, opacity );

    vec4 texelColor;
    if(vBorderMap.x <= 0.05 || vBorderMap.y <= 0.05)
        texelColor = texture2D( map, vUv ) * 0.5  + vec4(0.0, 0.0, 0.0, 1.0) * 0.5;
    else
        texelColor = texture2D( map, vUv );
    gl_FragColor = gl_FragColor * texelColor;
}

When I zoom out those artifacts can be clearly seen:

Although zoomed in it looks much better:

At first I thought lack of antialaising was a problem, but when I added it, it didn't help.

EDIT:

js fiddle link ---> https://jsfiddle.net/denisve/ad74pf77/5/

full screen ---> https://jsfiddle.net/denisve/ad74pf77/5/embedded/result/

WARNING: Huge embedded image there, so will take some time to load, sorry about that, didn't find a way to use external images on jsfiddle.


texts: Getting started at 3D modelling and animation

texts:
I'm looking for  book or a guide that will direct me to 3D modelling/animation for gaming.  Most tutorials will go for lengths about things I don't really need for games and I want to get to the chops of making assets for my games -- like many developers have said: the best way to get experience is finish a game!

So what good books/tutorials are there on modelling for games?


texts:
Is it possible to mix 2D and 3D graphics in a single OpenGL ES 2.0 game, please?

I have plenty of 2D graphics in my game. The 2D graphics is represented by two triangular polygons (making up a rectangle) with texture on them. I use orthographic matrix to render the whole scene.

However, I need to add some 3D effects into my game. Threfore, I wish to use perspective camera to render the meshes.

Is it possible to mix orthographic and perspective camera in one scene? If yes, is there going to be a large performance cost for this? Is there any recommended approach to do this effectively? I wil have 90% of 2D graphics and only 10% of 3D.

Target platform is OpenGL ES 2.0 (iOS, Android). I use C++ to develop.

Thank you.