texts:
I'm trying to make a game using C++ (in Visual Studio 2015).
I want to make the game run for X minutes and then end.
I have a function play() that calls all other functions required and I need to make play() run for 2min.
I've tried putting play() in loops that run for some time, but none of them work. I am not able to find any other question that addresses the problem I'm facing and so any help would be appreciated.


texts: How to compare recorded skeleton with live skeleton by using kinect sensor?

texts:
I am developing project where user will perform movement in front of the kinect. Up to now I can calculate the angles between joints and can detect body parts. My second approach is recording these movements and store in database and then patient will try to follow this motion. Now I need to compare live skeleton with recorded skeleton. I am working with c#. This screenshot gives what i done up to now.

My Question is how to save motion by using kinect and how to compare save motion with live skeleton. If there any reference please let me know.


texts: How do you pass arguments with UnityEvents?

texts:
I was inspired by a great talk at Unite by Ryan Hipple.

https://youtu.be/raQ3iHhE_Kk?t=28m

His examples didn’t cover passing arguments with UnityEvents

Do I need to extend UnityEvent, GameEvent and GameEventListener from a generic base class for this to work properly?

If so do I need to make a new set of classes for each Type and combination of Types that I want to pass?

Game Event Scriptable Object

[CreateAssetMenu]
    public class GameEvent : ScriptableObject
    {
        /// <summary>
        /// The list of listeners that this event will notify if it is raised.
        /// </summary>
        private readonly List<GameEventListener> eventListeners =
            new List<GameEventListener>();

        public void Raise()
        {
            for(int i = eventListeners.Count -1; i >= 0; i--)
                eventListeners[i].OnEventRaised();
        }

        public void RegisterListener(GameEventListener listener)
        {
            if (!eventListeners.Contains(listener))
                eventListeners.Add(listener);
        }

        public void UnregisterListener(GameEventListener listener)
        {
            if (eventListeners.Contains(listener))
                eventListeners.Remove(listener);
        }
    }

Listener Class

public class GameEventListener : MonoBehaviour
    {
        [Tooltip("Event to register with.")]
        public GameEvent Event;

        [Tooltip("Response to invoke when Event is raised.")]
        public UnityEvent Response;

        private void OnEnable()
        {
            Event.RegisterListener(this);
        }

        private void OnDisable()
        {
            Event.UnregisterListener(this);
        }

        public void OnEventRaised()
        {
            Response.Invoke();
        }
    }


texts: How can I set a system's emission rate using Particle Designer 2.0?

texts:
In cocos2d-iphone (2.1), CCParticleSystem has a property called emissionRate.

Is there any way to set it using Particle Designer 2.0? I've tried all the various settings but there doesn't seem to be anything achieving that effect. Perhaps I'm overlooking something?


texts: Are there viable alternatives to polygons for creating 3D worlds?

texts:
Of course, I see the benefit in using polygons to create 3D worlds. But I sometimes wonder if other methods exist and have been used in published computer games; perhaps even hybrid methods of 3D animation that combine polygons with some other style of rendering, so that the limitations of polygonal rendering might be overcome or just mitigated.
For example, a way of rendering human bodies without jagged limbs.


texts:
Suppose I have a character and an array of 3D coordinates, separated at most a certain distance apart. I would like to have a character run across the points in the array, placing its feet exactly on those coordinates, while the animation still seems natural (given the path does not have many unnaturally sharp angles). How can I accomplish this?

I doubt it would work to just take a normal running animation based on Bézier curves, and then vary the points of the animation so that the foot bones will end up on the right place.

My next best guess would be to create a physical/mathematical model of a basic running animation. Then I would be deriving equations for the character position from projectile equations for mid flight and a simple model with two springs with variable spring coefficients for the legs during touchdown. I could then position the feet using an inverse kinematics setup for the legs and interpolate the IK anchor between the nodes in flight. This seems a bit overkill, however.


texts: I want to play .mp3 sound files in a game I built with Crafty.js. Is this possible without converting the sound file?


texts: Unity method to get a vector, which is x seconds behind another moving vector (A bit like TrailRenderer)

texts:
I want a function, which lets me follow a vector with a bit offset or delay, like it's done in the TrailRenderer. I tried to achieve this with the Lerp function, but that didn't work for me like I want, since I had to wait for a specific time until the lerp was done and then updated my targetVector of the Lerp again, which led to a bad result.

Now a possible solution to my problem would be a List, which holds all Positions of my Vector from the past 50 frames or so and I assign the same values to my other Vector with a specific offset. But I was wondering if there is some built in method in Unity, which could achieve this for me.

Edit: This is about moving a Canvas


texts:
I am having some problems drawing my entities in an isometric map.

Tiles are drawn using Painter's algorithm to do the z-sorting which works great for the tiles alone. Entities are parented to a particular tile and have an offset within it. They are drawn immediately after their parent tile. The problem is that when the entity is too far right or too far down; the next tile(horizontally to the right, or vertically below) is drawn over parts of it like so:

(Note, currently my player has his registration point (red circle) a little higher than right at the bottom, just to better approximate the centre of his feet.)

A couple of ideas I had to try and remedy this:

1) To simply offset the position of entities to move them so that they will always draw in a place that won't be drawn over later. I really don't like to add in strange offsets that must be compensated for all over the place but this seems like a viable option.

2) To draw everything tiles and entities, using painter's algorithm. Entities would not need to be parented to a tile anymore but every renderable graphic would need it's drawing position offset. (Tiles would have their point at the very top, entities at the very bottom so that painter's orders things correctly)

3) Implement some kind of layering system so that all floors are drawn first, then things behind entities etc etc. This seems complex and would change from scenario to scenario. As my game will have randomly generated levels, I feel this isn't the right solution.

So, do any of the above have merit? Do I have it all completely wrong and there's another solution I've missed?


texts: Looking for the best way to store game data that is meant to be user editable at runtime

texts:
I have a broad question, hopefully I'll synthesize it well. I've been looking for the best way to store the standard data of my project. So far, I've found 4 possible answers to my problem: Binary files, Json files, XML files and local DB(using SQLite). While the first 2 seems to be common sense for store data, I would still need some opinions about it, instead of create a bunch of content and code in vain. The chosen option must generate files that can be editable at runtime. Already used some XML files for basic saving and watched tutorials on Json and Binary files but I'm still uncertain about what road to take. I believe DB's are a different animal, but maybe it would worth for my case.
To contextualize, my project is a sports game, so I must start to generate and store virtual players and teams. After that I need to link those virtual players at their respective teams. It happens that I would like to enable human players to edit those generated virtual players and teams attributes at runtime through some kind of editor. Furthermore, I want to enable human players to create their own virtual players and teams, so the chosen method must have scalability, so it's expected to have hundreds of teams and thousands of virtual players at some point. My target platform is PC, so file sizes and general performance isn't so critical as it could be on mobile for example.
Anyway, hopefully my doubts are clear enough. It would be cool if someone have something to say, I would like to know the best choice for my case.
PS: Already take a look at these 2 questions:
How to choose how to store data?
Would it be better to use XML/JSON/Text or a database to store game content?
But most of it's answers have some years now and I still have doubts on this matter.


texts: 2D and 3D Perlin Noise Terrain Generation

texts:
I'm using 2d perlin noise to generate a heightmap and then adding 3d perlin noise to the heightmap to create overhangs and ridges. But it's not turning out like I would like it to. There are too many hills that don't look good and lots of different places where it's flat. This is the perlin noise function I'm using for both the 2d and 3d (in LUA):

function noise(x, y, z)
  local X = math.floor(x % 255)
  local Y = math.floor(y % 255)
  local Z = math.floor(z % 255)
  x = x - math.floor(x)
  y = y - math.floor(y)
  z = z - math.floor(z)
  local u = fade(x)
  local v = fade(y)
  local w = fade(z)

  A   = p[X  ]+Y
  AA  = p[A]+Z
  AB  = p[A+1]+Z
  B   = p[X+1]+Y
  BA  = p[B]+Z
  BB  = p[B+1]+Z

  return lerp(w, lerp(v, lerp(u, grad(p[AA  ], x  , y  , z   ),
                                 grad(p[BA  ], x-1, y  , z   )),
                         lerp(u, grad(p[AB  ], x  , y-1, z   ),
                                 grad(p[BB  ], x-1, y-1, z   ))),
                 lerp(v, lerp(u, grad(p[AA+1], x  , y  , z-1 ),
                                 grad(p[BA+1], x-1, y  , z-1 )),
                         lerp(u, grad(p[AB+1], x  , y-1, z-1 ),
                                 grad(p[BB+1], x-1, y-1, z-1 )))
  )
end

function fade(t)
  return t * t * t * (t * (t * 6 - 15) + 10)
end

function lerp(t,a,b)
  return a + t * (b - a)
end

function grad(hash,x,y,z)
  local h = hash % 16
  local u
  local v

  if (h<8) then u = x else u = y end
  if (h<4) then v = y elseif (h==12 or h==14) then v=x else v=z end
  local r

  if ((h%2) == 0) then r=u else r=-u end
  if ((h%4) == 0) then r=r+v else r=r-v end
  return r
end

p = {}
local permutation = {151,160,137,91,90,15,
  131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
  190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
  88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
  77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
  102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
  135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
  5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
  223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
  129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
  251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
  49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
  138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180
}

for i=0,255 do
  p[i] = permutation[i+1]
  p[256+i] = permutation[i+1]
end

You can also find the implementation, written by Perlin himself, here: http://mrl.nyu.edu/~perlin/noise/

And this is how my loop looks like:

local smoothness = math.random(20, 30)
    for x = 1, mapScale do
        wait()
        for z = 1, mapScale do
            local height = noise(x/smoothness, z/smoothness, 0) --Find out the height
            for y = 1, (height*mapHeight)+10 do
                local density = noise(x/smoothness, y/smoothness, z/smoothness) --Find out the density
                if y > waterLvl then
                    if density*10 > 0 then
                        t:setCell(x, y, z, 1, 0, 0) --Sets cell at position x, y, z
                    end
                else
                    t:setCell(x, y, z, 1, 0, 0)
            end
        end
    end
end

This is how it turns out to be:

How would I change the frequency, number of octaves, and persistence with this function since it doesn't take any parameters for them?


texts: Java how to rotate an image towards a certain point?

texts:
Hello I have a game where a spaceship flies towards a different point every time I press a button. I am able to rotate the image but I don't know how to rotate the image to face the direction it is going. How can I make the image face towards the target area.
Heres my code:

public class ship {

    public boolean arrived,sel1,sel2;
    public int amountOfPop = 0;

    public int fc = -1,sc = -1,rot =5;
    private Image img;

    private Vector2 position;
    private Vector2 start;
    private Vector2 target;
    private Vector2 direction;

    private float speed ;

    private float distance;
    public boolean remove;

    public ship(Vector2 position, Vector2 target, float speed,int aop) {
        this.position = position;

        this.start = new Vector2(position.x, position.y);
        this.target = target;

        distance = Vector2.distance(start, target);
        direction = Vector2.direction(target.x - start.x, target.y - start.y);

        this.speed =speed;
        this.amountOfPop = aop;

    }

    public void tick(){

        start.x = position.x;
        start.y = position.y;

        if(play.ds.s1.p.get(play.ds.s1.secondclicked).moon == false){
        target = new Vector2((int)  play.ds.s1.p.get( play.ds.s1.secondclicked).x + 25, (int)  play.ds.s1.p.get( play.ds.s1.secondclicked).y + 25);
        }else{
            target = new Vector2((int)  play.ds.s1.p.get( play.ds.s1.secondclicked).x + 10, (int)  play.ds.s1.p.get( play.ds.s1.secondclicked).y + 10);

        }
        distance = Vector2.distance(start, target);
        direction = Vector2.direction(target.x - start.x, target.y - start.y);

        position.x += direction.x * speed;
        position.y += direction.y * speed;

        if (Vector2.distance(start, position) >= distance) {
                remove = true;
        }

        if(rot >= 360){
            rot = 0;
        }else{
            rot+=5;
        }

    }

    public void render(Graphics g){

        Graphics2D g2 = (Graphics2D) g;

        g.setColor(new Color(255,127,42));
        g.drawLine((int)start.x+7, (int)start.y+7, (int)target.x, (int)target.y);

        AffineTransform at = AffineTransform.getTranslateInstance((int)position.x,(int)position.y );
        at.rotate(Math.toRadians(),7,7);

        ImageIcon i121 = new ImageIcon("res/misc/circle4739.png");
        img = i121.getImage();
        g2.drawImage(img,at, null);

    }
}


texts: OpenGL calculate circle rotation around a given point

texts:
I'm trying to rotate an object around a certain point. If this point is the center of my world space I use the following algorithm:

glm::vec3 center is the center of the current object. Each frame it will get updated.

glm::mat4 transformationMatrix is the 4x4 matrix I am "uploading" to my shader later on. It will get multiplied by the vertex position.

t_point is the point I'd like to rotate around

t_deflection is the impact for each axis (in order to draw ellipses instead of circles)

t_speed is in my case the current time since the game started (e.g. glfwGetTime())

void rotateByPointY( const glm::vec3& t_point, const glm::vec3& t_deflection, const float& t_speed )
{
    float radius = glm::length( t_point - center );

    glm::vec3 newPosition( glm::sin( t_speed ) * radius * t_deflection.x, center.y, glm::cos( t_speed ) * radius * t_deflection.z );

    translationMatrix = glm::translate( glm::mat4( 1.0f ), newPosition );
    center = newPosition;
}

How can I take into account a point other than the center of my world in the calculation?

EDIT:

So my rotateByPointY calculates the translation around the world center. Therefore I am adding the new center vector to my new position:

translationMatrix = glm::translate( glm::mat4( 1.0f ), newPosition + t_point );
center = newPosition + t_point;

That is working now!


texts: Use both AddForceAtPoint and change velocity property?

texts:
I'm using Rigidbody2D for some game objects. It seems that when I AddForce() or AddForceAtPoint(), the game objects are mostly affected on the Y axis and hardly at all on the x axis. I don't understand why. To really get any effect on the x axis, I need to have a very strong force like *10 000. But the effect on the y axis is then extremely strong and shoots the object out of screen, yet only nudges the game object on the x scale.

I believe that the problem with the y axis is because I use .velocity to move the character. But I don't know how to change the velocity directly without doing that.  What should I do to use both forces and set velocity on the same object?


texts: Export UnityProject inside Android Studio's existing project

texts:
I am new to the Unity3D, but I have made a small Unity project with a humanoid gameobject. I can move this humanoid with the demo data but I want to move it with the quaternion data which I am already getting inside the android app.

I have searched on the internet, but everyone just tells about the android plugin that we have to make for the unity, and that way we can use the JNI to send or receive the data (I need to access the c# scripts from the android).

But, I wanted to import the unity project inside the android project so that I can(access the c# scripts from android and send the quaternion data to the Quaternion variable of the gameObject and make it move) make changes to the android app and test it instantly!! (Also I don't need to make further changes inside the unity project but I need to make further improvements to the data inside the android project).

Please help and provide a guide for the android studio.
Thanks.


texts:
I have executed the following command in order to store a texture (PNG) file in a C++ header file: xxd -i Texture.png Texture.h.

How would I go about loading this texture into OpenGL?

glEnable(GL_TEXTURE_2D);
GLuint textureId;
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

I realise that the function glTexImage2D should be used but am very unsure about which parameters to choose.

The specification describes the parameters as shown below.

void glTexImage2D(GLenum target, // GL_TEXTURE_2D
    GLint level, // 0
    GLint internalFormat, // GL_RGBA
    GLsizei width, // 2048
    GLsizei height, // 2048
    GLint border, // 0
    GLenum format, // What's this?
    GLenum type, // What's this?
    const GLvoid * data);

What are the format and type parameters for and what should they be set to in this case?


texts: How to design a separated tutorial mode?

texts:
I'm working on a "social" game that's about 90% completion. One of the remaining features is the tutorial mode.

Basically, the tutorial mode will restrict the user to access some parts of UI and limit the features (like store items). The tutorial will only progress if a certain event is triggered, specifically following the tutorial.

The code is ready and we already have an "almost" working game. The problem is I haven't foreseen the tutorial mode while I was doing those 90%. My requirement is there shouldn't be any loading/transition from tutorial mode to normal mode. This means I have to pick up the progress from the tutorial (no re-rendering of assets and stuff).

How should I design this in a way where I won't touch anything from my old code? I want it to be as easy as just plugging it in. I don't want to jam the tutorial in my old code since this will lead to many bugs.


texts:
I'm trying to create a list of bounding boxes for each cube drawn, so I can use the boxes to intersect with a ray that my mouse position is casting, but I have no idea how. I've created a list that stores the boxes, but how am I getting the values from each box?

    for (int x = 0; x < mapHeight; x++)
        {
            for (int z = 0; z < mapWidth; z++)
            {
                cubes.Add(new Vector3(x, map[x, z], z), Matrix.Identity, grass);
                boxList.Add(something here);
            }
        }

    public Cube(GraphicsDevice graphicsDevice)
  {
    device = graphicsDevice;

    var vertices = new List<VertexPositionTexture>();

    BuildFace(vertices, new Vector3(0, 0, 0), new Vector3(0, 1, 1));
    BuildFace(vertices, new Vector3(0, 0, 1), new Vector3(1, 1, 1));
    BuildFace(vertices, new Vector3(1, 0, 1), new Vector3(1, 1, 0));
    BuildFace(vertices, new Vector3(1, 0, 0), new Vector3(0, 1, 0));

    BuildFaceHorizontal(vertices, new Vector3(0, 1, 0), new Vector3(1, 1, 1));
    BuildFaceHorizontal(vertices, new Vector3(0, 0, 1), new Vector3(1, 0, 0));

    cubeVertexBuffer = new VertexBuffer(device, VertexPositionTexture.VertexDeclaration, vertices.Count, BufferUsage.WriteOnly);

    cubeVertexBuffer.SetData<VertexPositionTexture>(vertices.ToArray());

}

There aren't any clearly defined variables for the bounds of each cube created, so where do I create the bounding box from?


texts: How does this work? Data catching without displaying client

texts:
Alright so this is about a game, but more generally this can probably be done for all games, I just want to figure out how the application accomplishes it.

So it's for a game called League of Legends, huge game, has an executable file and a massive LoLClient where you can view all data specific to your account, you can queue for games etc.

Now what this app does (that I've came across) is it logs into the league client, grabs all info related to the character and logs out) but it does this without even displaying the client on the users screen, how is this possible? bare in mind it isnt using a server.

A broad question perhaps, but im sure there's a straight forward question (app developed in C#)


texts: Unity3d - How to use controller joystick to look around?

texts:
I try to use my xbox controller as input device for a game targeted to run on windows. However the documentation fails to explain how to set it up.
E.g. how can I use the right stick from my xbox controller to look around, like in any 3D game? Even such a common task is not documented.

I found a very old wiki entry where the xbox controller is briefly described, I was able to find out that the Y-Axis of the right analog is called 5th axis (Joysticks) and the X-Axis is called 4th axis (Joysticks). I post the images below, in case the link get's dead.

Linux

Note: wired controllers only support axises for the d-pad, while the wireless controller only supports buttons for the d-pad, refer to the table above for the wireless controller configuration.

I figured out that the name of a control is responsible for the action which the button, stick, key, pedal etc. does. But it is not documented how the control has to be named for looking around vertically or horizontaly like you can do in an 3D game to look around with the camera by using the right joystick (e.g. witcher 3)

How can I control the camera by using the right joystick?


texts: Creating a Full Stadium of People, Ready as a Game Asset (ie. not too CPU intensive)

texts:
I am trying to make a boxing scene in my game. I decided to attempt to make the large stadium first (It's a boxing management game, so the scene can be 'pre-rendered' perhaps, the fight events (eg. Big hits, blocks, dodges) are going to be calculated based upon the boxers skill values and some luck etc.
I have this scene in Maya:

My first idea was to 'scatter' assorted people into the crowd. But on further advice it seems this might be too resource-heavy.
I am very keen to learn such things as LOD, or effects to make it look like the crowd is full of people. Also smoke etc effect to cover empty areas (or allow for much reduced detail) would be amazing.
A little bit broad question I realise, but I'm looking for some starting points of what to learn to achieve this stuff.
Many thanks


texts: Can we create same name class for different objects in unity?

texts:
I have four similar objects in my game. As they are all similar therefore I have created a single script that defines mash for all of them. The script that defines mash for these objects uses a variable called radius which I have imported from other file (by classname.radius). The radius updates on every frame and it is the only property that is different for all objects.

To allow different radius for different objects, What I thought would work was, making four different classes of same name classname. Creating variable radius in all of them and giving them different values. Dragging first file to the first object, second file to second object and so on.. When executed, every time the script that generated mash considers classname.radius from the file which is dragged to that object. But that isn't working. What is wrong and how can I implement it?

Seems I'm messing with OOPS concepts!


texts:
I have two sets of assets (lo res and hi res) that are exact replicas of each other except one set is twice the size of the other and used for larger screens. At runtime, I find the users screen size, and determine which set of assets to use.

I'm trying to find a way to handle this with my Tiled Maps. The maps are 40 x 23. Lo Res the tiles are 32x32. For the hi res, they are 64x64. The maps also have a few objects on them.

Is there a way I can create a 64x64 tile size map and then scale it down to 32x32 tile size? That way, I don't have to support both sizes and can instead just create the hi res map and scale it down for the lo res. Currently, I have to replicate changes to both manually.


texts: Unity2D: How to destroy spawned object once it exit out of camera's view?

texts:
I'm trying to destroy spawned objects once it exit out of camera view automatically/straight away. You see I'm trying to make a flappy brids type of game but things also comes in from the bottom and if they get a really high score then things will be spawned in from above and from the left side. So, so far this is what my game looks like (I'm still working on it). However I'm having problems with deleting spawned objects once it exit out of camera's view, I tried all sorts of things like:

private var hasAppeared : boolean;

function Start ()
 {
hasAppeared = false;
}

function Update()
{

if (GetComponent.<Renderer>().isVisible)
{
    hasAppeared = true;
}

if (hasAppeared)
{
    if (!GetComponent.<Renderer>().isVisible)
        {
            Destroy(gameObject);
        }
    }

}

But with this script, it doesn't destroy the game object quickly enough that and only some of them is being deleted. I also tried this method:

     public void OnBecameInvisible() {
        Destroy(gameObject);
      }

But not all of them is being deleted as well and it also takes a long time for any of my game objects to be destroyed. My last result was this script, it destroys the game object straight away once it exit out of the camera's view (which is what I want) but only these sides works where as the other's don't, I think it destroys my enemies (spawned objects)  before it has even entered the camera's view. How do I get the script to work on this side? This is my script:

void Update ()
{
    DestroyAllEnemy ();
}

public void DestroyAllEnemy()
{
    GameObject[] enemies = GameObject.FindGameObjectsWithTag ("enemy");
    if ((enemies.Length > 0) && (camera != null)) {
        for (int i = (enemies.Length - 1); i >= 0; i--) {
            // just a precaution
            if ((enemies [i] != null) && ((camera.WorldToViewportPoint (enemies [i].transform.position).x > 1.03f) ||
                (enemies [i].transform.position.y < -6f)))
            {
                Destroy (enemies [i]);
            }
        }
    }
}

Thank you :).


texts: How to identify whether the boundingvolume intersects with walls or floor when it doesnt return normals?

texts:
My game in jMonkey is the kind that use will have to place objects in a scene (which consist of walls and slabs and floor). All my models are centered at origin. When the user click a point I use ray casting to find the point on the floor where the object will be placed (setLocalTranslation() and shootables.attachChild()).

CollisionResults results = new CollisionResults();
allAttached.collideWith (ray, results);

Now the problem is that when I click too close to an object or wall, the objects run into each other. I will use physics bounding volume to prevent objects running into each other but how to distinguish between horizontal(floor and slabs) and vertical planes (walls) which are part of same scene model.

I'm using code like this to identify collision in objects

private void checkCollision(Spatial model) {
      CollisionResults results = new CollisionResults();
      //BoundingBox box = new BoundingBox();
      //model.setModelBound(new BoundingBox());
      //model.updateModelBound();

      BoundingBox box = (BoundingBox) model.getWorldBound();
      allAttached.collideWith(box, results);

      CollisionResult closest = results.getClosestCollision();
      System.out.println("\n SIMAR \n Geometry = ");
      System.out.println(closest.getGeometry().getName());
      System.out.println("\nContactPoint = " + closest.getContactPoint());
      System.out.println("\nContactNormal = " + closest.getContactNormal());

        }

  }

However the problem is that its not giving me any normals/ etc.
Secondly its give me my geom-mall model scene when I shoot floor/ walls and slabs. Using ray casting I can identify horzontal and vertical surface as it gives getContactNormal but in case of BoundingVolume instead of ray, getContactNormal is just null.

How should I identify whether there is a collision with the wall or not.


texts: Given an angle for an arrow, how do I find its X and Y velocities?

texts:
I want to fire an arrow toward the mouse location.

X0 = the players X location
X1 = the mouse X location
Y0 = the players Y location
Y1 = the mouse Y location

I want to make a method which takes degrees as a parameter, and sets the Yspeed and Xspeed accordingly, so the arrow can reach the mouse position, starting at the player position.

I am using float coordinates (i.e. float x, y, z).

How can I do this?


texts:
I was trying to make a script to make my enemy follow my player intelligently (but not too much) and I want to know if there was a better way to do it (of course there is but I wanted to find a way myself)
Here is what I did:
I wanted my enemy to detect the player when he approach a certain distance from him. I have a varibale to determine what distance the nemy have to back up (when player is too close) and when it has to follow the player (player too far). Now, I didn't wanted the enemy to just forgot there is an intruder when the player goes around a corner and they can't see him. When the enemy sees the player directly (raycast), they rotate toward him and start following him directly by normalizing the difference of their 2 position. Now is the tricky part i'm not sure about. My player has a list that keeps the 1000 last positions of my player and that update every 0.01 second to add the lastest position and remove the oldest. If the enemy can't see the player directly (!raycast) he goes through all the positions in the list by checking for every Vector3:

1-is there something between the enemy and this position ?

2-is there something between this position and the player ?

Then it add up the distance between the enemy and the point and the distance between the point and the player and checks

3-is the lenght of the path by going at this point shorter than the last shortest path ?
if it's smaller, it's assigne to the best point.

If it detected a point that matches these conditions, it goes at it and if it doesn't see the player, it continues checking for new points.
If no point matches the condition, he just stop following the player (the enemy lost him).
All this works with raycasting to check positions, presence of objects between enemy, player and points and path to go.


texts:
I'm trying to make a WPF-3D game. WPF uses XAML.

I'm trying to find free 3D assets from the internet. :-)

What format of 3D models I should be looking for, direct XAML or 3D Studio format or what?
I know that there are some 3D Studio format to XAML -converters, but I don't know if they really work...


texts:
I'm looking to set up two threads in my puzzle game, one for logic/graphics, and one for audio.
Am I correct in thinking that the thread that handles the audio should be set as a daemon thread, because the game can end without that thread finishing?


texts:
I have a boat race game. I have a curved mesh, that is the track.
How can I measure the map(mesh) length, so I can place checkpoints on every 1/5 of the length?


texts: How can I detect collision between two objects

texts:
I have some code that when I click on an object with my mouse it will change it to another object. I'm using this code to change an object into a shattered version I made of it for destruction purposes. How could I change the mouse down function into a function that would activate when the object is touched by another object ?

using UnityEngine;
using System.Collections;

public class Destruction : MonoBehaviour
{
    public GameObject destructionPiece;

    void OnMouseDown()
    {
        Instantiate (destructionPiece, transform.position, transform.rotation);
        Destroy(gameObject);
    }
}


texts: LibGDX - how to detect touchUp with GestureListener?

texts:
I'm making a game and I have implemented GestureListener as my inputprocessor. It came with a bunch of methods such as fling, pan, tap etc etc including touchDown. However, there is no touchUp method!

What I want to do is have something happen when the user does a 'fling', but I want something to happen when the user then takes their finger off the screen after flinging, probably setting a flinging boolean and testing if true when taking finger off the screen.

However, I don't see how I can get a touchUp method into my inputprocessor! Is there any work around to this or an alternative solution?

Thanks!


texts: What values to construct "Projection Matrix" from?

texts:
I am curious to what standard values I should use to create a camera's projection matrix, as well as if certain measurements need to be taken if I want to represent a very small world or a very big world and make it feel natural.

What values (field-of-view, nearplane, farplane) to construct a projection matrix should be used if:

1 unit to represent 1 meter?
1 unit to represent 1 cm?
1 unit to represent 100 meter?


texts: Is it safe to make a null reference check like if(component) on Unity GameObjects/Components?

texts:
I was reading that Unity does not store GameObjects being null literally, but instead overloads the == operator.
For this reason the null coalescence operators ?? ??= don't work on GameObjects or Components
But if GameObjects and Components are never set to the literal value null, and instead == is overloaded, is it unsafe to do a null check
if(component != null) as if(component)?
The latter option compiles and seems to work fine, but I don't understand why if it's not ever the value 0, and if this will actually cause problems down the line


texts: Find ID from Spiral x, y positions. Hard programming formula

texts:
I have a formula, which gets coordinates from user_id (see below).
I give User_id, and I get back coordinates.
But now I need to get User_id from coordinates.
For example:

function get_user_id_from_coordinates(x, y) {
  // if x = 1, y = 0, returns 4 (as in this image)
}

Please help me with that formula :) The first one i got also form this forum.

// if user_id = 64
function get_coordinates_from_user_id(user_id) {

  // Math.sqrt(user_id) = 8
  // 8-1 = 7
  // 7 / 2 = 3.5
  // Math.ceil(3.5) = 4
  var k = Math.ceil( (Math.sqrt(user_id) - 1) / 2 );

  // t = 2 * 4 + 1 = 9
  var t = 2 * k + 1;

  // m = 81
  var m = t * t;

  // t = 9 - 1 = 8
  t = t - 1;

  // if 64 >= 81 - 8.   If 64 >= 73
  if (user_id >= m - t) {
    // return [ -4, 4 - (81 - 64)].   return [ -4, -13 ]
    return [ -k,  k - (m - user_id)  ]
  }
  // else m = 81 - 8 = 73
  else m = m - t;

  // if 64 >= 73 - 8.   If 64 >= 65
  if (user_id >= m - t) {
    // return [ -4 + (73 - 64), -4].   return [ 5, -4 ]
    return [ -k + (m - user_id), -k]
  }
  // else m = 73 - 8 = 65
  else  m = m - t;

  // if 64 >= 65 - 8.   If 64 >= 57
  if (user_id >= m - t) {
    // return [ 4, -4 + (65 - 64) ].   return [ 4, -3 ]  <== passes
    return [ k, -k + (m - user_id) ]
  };

  // return [ 4 - (65 - 64 - 8), 4 ].   return [ 11, 4 ]
  else return [ k - (m - user_id - t), k ];
}


texts:
I am new to Game Development, All I have developed is some 2d Games, using Game Maker by YoYo Games. There game development is much more easy, just as simple as Drag and Drop.
But, Now I wish to evolve in Game Development, and wanna try some hands with the common programming languages like, Java, C++ or C. In order to achieve this, I came around the first topic, Game Engine.
So, What is Game Engine.?
That is a broad question, with various answers. I came out with some conclusion after reading various links,

Wikipedia:
A game engine is a system designed for the creation and development of video games. The core functionality typically provided by a game engine includes a rendering engine for 2D or 3D graphics, a physics engine or collision detection (and collision response), sound, scripting, animation, artificial intelligence, networking, streaming, memory management, threading, localization support, and a scene graph.
GameCareerGuide.com
It exists to abstract the (sometime platform-dependent) details of doing common game-related tasks, like rendering, physics, and input, so that developers (artists, designers, scripters and, yes, even other programmers) can focus on the details that make their games unique.
Engines offer reusable components that can be manipulated to bring a game to life. Loading, displaying, and animating models, collision detection between objects, physics, input, graphical user interfaces, and even portions of a game's artificial intelligence can all be components that make up the engine.

Now what I understand is, Game Engine takes care of all the common work, like physics, loading etc...
As far my question is concerned, what is a Game Engine (Programmatically)?
Is it a Library? With pre-defined functions and classes, which can be inherited? Or what so ever, what is it?


texts: I am going to use Ogre3D as the rendering engine for our 3D software. I am not sure if I need to use the engine as it is, or if I need to write a wrapper for the parts I want to use. What are the advantages and disadvantages of both writing a wrapper, and not writing a wrapper?


texts: How can you have the Input Manager Axis values snap to 1 (or -1)?

texts:
When a selected key is pressed in Unity, the Input Manager's Input.GetAxis("Horizontal") function returns a gradually increasing number up to 1 (or negatively -1) for the length it is held down. The rate at which it increases is based on the value Sensitivity in the Input Manager. Similarly, the sticks on a controller return a value depending on how far they are tilted.

Is there a proper way to make the value immediately snap to -1 or 1 through the manager, or would I have to write a couple of if statements in my script to handle that?\

Edit: A very short and readable scripting option would be if (Mathf.Abs(isRunning) > 0) isRunning = Mathf.Sign(isRunning);


texts: How do I use an external FBX object in Unity?

texts:
Is it possible to use an external .fbx object in Unity 3D the same way we can insert a picture?

Something like myPath = "http://www.myserver.com/object/myobject.fbx";?


texts: Suitability of ground fog using layered alpha quads?

texts:
A layered approach would use a series of massive alpha-textured quads arranged parallel to the ground, intersecting all intervening terrain geometry, to provide the illusion of ground fog quite effectively from high up, looking down, and somewhat less effectively when inside the fog and looking toward the horizon (see image below).

Alternatively, a primarily shader-based approach would instead calculate density as function of view distance into the ground fog substrate, and output the fragment value based on that.

Without having to performance-test each approach myself, I would like first to hear others' experiences (not speculation!) on what sort of performance impact the layered alpha texture approach is likely to have. I ask specifically due to the oft-cited impacts of overdraw (not sure how fill-rate bound your average desktop system is). A list of games using this approach, particularly older games, would be immensely useful: if this was viable on pre DX9/OpenGL2 hardware, it is likely to work fine for me.

One big question is in regards to this sort of effect:

(Image credit goes to Lume of lume.com)

Notice how the vertical fog gradation is continuous / smooth. OTOH, using textured quad layers, I can only assume that layers would be mighty obvious when walking through them  -- the more sparse they were, the more obvious this would be. This is in contrast to where fog planes are aligned to face the player every frame, where this coarseness would be much less obvious.


texts: Unreal engine 4 - Actor not updating (when instancing on c++)?

texts:
My custom actor (containing a few custom UMeshComponent) does not update when I change its location or the visibility of its components.

I instantiate it this way in StartPlay() of my GameMode class:

  MyCustomActor = GetWorld()->SpawnActor<AMyCustomActor>(AMyCustomActor::StaticClass());

Then I set its new location like this:

  MyCustomActor->SetActorLocation(FVector(100,0,0));

Is it because I did not set the Owner? Or what is wrong?

Note

I don't understand why, but my code works now... It might be linked to those warnings:

LogActor:Warning: GameSession /Game/PersistentLevel.GameSession_19 has natively added scene component(s), but none of them were set as the actor's RootComponent - picking one arbitrarily

and

LogActor:Warning: Natively added component (MyCustomActor_143.RootComponent) was left unattached from the actor's root.


texts:
I am still in the conceptualisation and early prototyping phase of a game that revolves around RPG/Bullet-time hybrid game where players compete in vs. style executing attack/defence moves per turn.

I am in search for art material/guidance to have symbols representing moves.
For example a stick figure or a silhouette resembling a kick to represent a kick move. I am not really set on one specific style but would rather have something that covers a broad range of moves and be on the easy side to draw in not many strokes (yes player would draw the symbol).

Any guidance to get me started?


texts:
I'm currently developing a game in Python + Pygame and i came up with a problem with the player and the platforms. The game is a 'runner' where the player it's fixed (The 'x' position isn't variable, only the jump).

This is how i'm currently doing the collisions managment:

def collide(self, yvel, platforms):
    for p in platforms:
        if pygame.sprite.collide_rect(self, p):
            if yvel > 0:
                self.rect.bottom = p.rect.top
                self.onGround = True
                self.yvel = 0
            if yvel < 0: self.rect.top = p.rect.bottom

'platforms' its a RenderUpdate group with the platforms (a simple sprite).

When the player is falling from a platform and collides with the next platform, not exactly on top of it but a little below, that's when the character jumps to the position shown in the code above, rather than collide and fall.
I don't know how to check the left bound without a 'xvel' parameter.

(The screen shows an example, but the player only changes the y-axis coordinates, the platforms are updating their position)

I've tried supply a number to a 'xvel' parameter, and check if the character wasn't on the ground (Jumping) and the 'xvel' was greater than 0, but it isn't working at all.

Thanks in advance.


texts: Unity - Convert Camera Gyroscope Attitude to World Space Canvas rotation

texts:
Suppose you have a worldspace canvas parallel to a camera that is rotated by the gyroscope.
How do you convert from the camera's gyroscope attitude to get the world space canvas rotation?


texts: Can I pass RaycastHit2D with a UnityEvent?

texts:
How do I target only the gameObject hit by my Raycast? Do I need to pass in the RaycastHit2D to a custom Unity Event?

I'm shooting a raycast, if it hits a valid target it fires off a UnityEvent to deduct health. My code is currently removing health from all "Enemy" prefabs within the scene even if they aren't being hit by the raycast.

public GameEvent OnDamaged;

public void ConfirmHit()
    {
        var target = Physics2D.Raycast(transform.position, Vector3.right * damageRange, damageRange, layermask);

if (!target) return;

        OnDamaged.Raise();
    }

if a target is hit by the raycast it will trigger the OnDamaged Event. The Event Triggers a simple function to decrease health.

public void DecreaseHealth(float amount)
{
    currentHealth -= amount;
}


texts:
I'm using LWJGL to develop a 3D game.

I'm having trouble with my keyboard handler. My aim is to implement the function which is holding Space then release it to trigger an increasing of the velocity and height of the main character within an interval of time (the longer you hold, the more powerful the bounce).

The point is, I want to increase the acceleration in Keyboard.isRepeatEvent() but, in this condition, the interval between 2 frames is nearly 0, so I can't increase the acceleration. It seems like this event is calculated in 1 frame so now I couldn't think out a new method. This my code:

Keyboard.enableRepeatEvents(true);

    while(Keyboard.next())
    {
        if(Keyboard.getEventKey() == Keyboard.KEY_SPACE)
            if(Keyboard.getEventKeyState())
            {
                if(Keyboard.isRepeatEvent())
                {
                    while(test <= 200)
                    {
                         test += getDelta() / 1000;
                         System.out.println("test Value ---- " + test);
                    }
                }
                // Key held down
                else {

                }
                // Key pressed
            }
            else
                System.out.println("test ------------------- " + test);
        // Key released
    }

getDelta() gets the interval between 2 frames.


texts:
I have two related questions:

What are the tools you use to make icons? (valid for all platforms)

What are the standard sizes and file formats you use? (valid for all platforms too)


texts: Finding the on-screen height of straight walls in raycasting rendering

texts:
I have an issue to find the correct height of walls to make them straight in raycasting rendering.

This is how I calculate the height of the wall which is h_seen:

dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2));
distortion = dist_w * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W));
if (distortion)
    h_seen = dist_c * wall_h / distortion;
//printf("h_seen = %f\n", h_seen);
y = cam_h - (h_seen / 2) - 1;

This is a screenshot of the problem  I have fisheye effect, if i use depth directly

    if (l == 0)
    {
        raytravel.y = w->cam->rays[i].endPoint.y - w->cam->position.y;
        raytravel.x = w->cam->rays[i].endPoint.x - w->cam->position.x;
        depth = raytravel.x * dir.x + raytravel.y * dir.y;
        h_seen = dist_c * wall_h / depth;
        y = cam_h - (h_seen / 2) - 1;
        if (hit == 1)
            while (++y < (cam_h + (h_seen / 2)))
                put_pixel_img(w, WIN_W - i + WIDTH_MM, y + 150, 0xff0000);
    }

// Direction of each ray inside the while loop

if ((hit = intersection(w, l, &dir)))
        w->cam->rays[i].endpoint = w->cam->intersection;
else
    {
        w->cam->rays[i].endpoint.x = w->cam->position.x + w->cam->raylength * tcos((w->cam->angle + w->cam->fov / 2) - (i * (w->cam->fov / limit)));
        w->cam->rays[i].endpoint.y = w->cam->position.y + w->cam->raylength * tsin((w->cam->angle + w->cam->fov / 2) - (i * (w->cam->fov / limit))); // limit is just the screen width
    }


texts:
Here's what I don't understand about Events:

the documentation says that Events correspond to user input (key presses, mouse actions), or are UnityGUI layout or rendering events. For each event OnGUI is called in the scripts; so OnGUI is potentially called multiple times per frame. Event.current corresponds to "current" event inside OnGUI call.

the documentation pertaining to onGUI states that it hasone call per event

That doesn't make sense to me, because I know I can call Events within OnGUI.

I have an OnGUI function that draws a grid using x and y nested for loops, then checks using Event.current.mousePosition if your mouse is hovering over a grid block. What I don't get is how OnGUI is ever called, if OnGUI is only called when an event occurs, but I have the event inside OnGUI so how can you ever check if the event is being called inside a script that is only called after the event is called?

I know that probably sounds confusing -- I'm just puzzled by the seemingly cyclical nature of ongui.


texts: What tools do professionals use to create pixel art with animations?

texts:
I've been looking for the right tool for creating my own pixel art, but I've been having a few difficulties finding the right one.

What I've tried so far:

ProMotion NG - seems to have lots of features, but not sure how many of them are useful, or at least it's difficult for me to see how to use some of them (I only tried the Free version)
Aseprite - nice and simple, but doesn't do things like tile maps and more complicated brush modes
PyxelEdit - doesn't seem to do anything the other two wouldn't do as well, and lacks a shading tool

Then there's also Photoshop, but a lot of people seem to be using these editors made specifically for pixel art.

Is there some other program that I've missed? What do professionals at game studios use to create pixel art and its animations? When someone is creating an animation such as the one below, do they first draw the final version of the character? From what I've tried so far, changing the character after creating a bunch of frames is basically like starting over from scratch, and none of the tools seem to help with that.


texts:
I have a simple map with a Big-sphere and a pawn inside it. I use media texture and media player to play 360 video on it. But when I try to package it for windows-64 it fails while it tries to cook the map.

Yes all the videos are copied to Content/Movies first and then imported to UEProject as asset later.

This is very crucial to our project. One of our developer have already started to build the solution in Unity just in case if packaging issue does not resolve with media player in unreal.

Please help!


texts: Make a game object move inside circle and bounce from walls without gravity

texts:
I have a circle with a RigidBody2D and CircleCollider2D components on it.

I'm trying to make it move constantly inside a bigger circle without gravity involved, make it bounce off the circle walls like it has constant velocity but without any delays, same speed all the time.

Here is an example of the same behaviour but inside a rectangle:

I would like to do the same but inside a circle and detect the collision with the circle walls

Thanks in advance :)


texts: How to do placeable electricity cables that work like the ones in "Prison Architect"

texts:
I would like to know one (of the probably many) ways to code a (sort of) Prison-Architect-ish electricity cable building system.

Here's a picture of what I mean:

How can I detect that cables are connected?
How can I detect if the block it's connected to is a power source?

And these 2 (above) will all be placed inside a dictionary when they are placed.

That dictionary does not yet have a key type, but the second type is a sprite.

How should I do this?


texts: C++ SDL Vector of Textures Storing NULL Objects

texts:
I'm attempting to (re)learn C++ by making a top-down shooter game using SDL. In my game, I have created a Graphics class that handles all of the drawing, textures, etc.

The game is in its very early stages, and at the moment the Graphics class has a textureList, which is simply a vector of pointers to SDL textures:

vector<SDL_Texture*> textureList;

The Graphics class has an int addTexture(const char* filename) method, which is used by a GameObject to add textures to the textureList vector, and return the vector ID back to the GameObject, so that it can access its texture when needed:

int Graphics::addTexture(const char* filename) {
    SDL_Texture* tx = IMG_LoadTexture(this->renderer, filename);
    this->textureList.push_back(tx);
    return (textureList.size() - 1);
}

The addTexture method is called by a GameObject like this:

GameObject player(10, 10, g.addTexture("player.png"));

Later on, a GameObject will call an updateGraphics() method on the Graphics class, which uses the stored ID to draw a texture:

void Graphics::drawTexture(int id, int x, int y, int w, int h, int angle) {
    SDL_Texture* tx = this->textureList.at(id);
    SDL_Point* centre = NULL;
    SDL_RendererFlip flip = SDL_FLIP_NONE;
    SDL_Rect rect;
    rect.x = x;
    rect.y = y;
    rect.w = w;
    rect.h = h;
    SDL_RenderCopyEx(this->renderer, tx, NULL, &rect, angle, centre, flip);
}

From what I can tell, the SDL_Texture* taken from textureList and stored in tx is NULL, and I've read that this is because textureList is storing pointers to objects that become NULL once the objects are destroyed (after the call to addTexture()?).

I've also read about storing deep copies of the textures in the vector, but I'm unsure how to do that, as I only seem to have access to pointers to textures.

Any help or advice greatly appreciated - especially if I'm just going about this the wrong way!

Thanks,
Rich.


texts:
I have developed a game on android using native coding. However I am being asked to port it to ios.

So I thought that I should bite the bullet and recode it in unity so I can go cross platform.

I am just upset that I have to recode everything in unity. Is there any other way or tool that at least will make me use half of my code or so thing?
Basically what would you do.

Ps:I don't even know unity but I heard learning it is easy


texts: What is the best way to limit player movement?

texts:
I'm currently programming a 2d game where the player moves around on a rectangular playing field. The player has a direction and a velocity. What is the best way to limit the player's movement so he/she cannot move past the boundaries of the playing field?

Thanks,

DLiKS


texts: How do I make Unity use UTF-8 and LF characters for new script files?

texts: By default, when you make a new script in Unity on Windows, it will use UTF-8 with BOM and CRLF. How do I change this to be regular UTF-8 without BOM, and LF (Unix-style)?


texts: Web games are being played less by the year, is this only on PC, or also on Mobile?

texts:
I just came from reading the NewZoo 2016 global game market report. The last time I read it, I noticed that the web game's segment was less than the years before (it was 5% in 2016, 6% in 2015, 9% in 2014, and 10% in 2013)

But these are all for users who accessed games using their PCs not mobile phones. And if you've been following the current trends of game portal websites, you'll notice that they are moving to mobile. Both Kongregate and Miniclip, two very big gaming portals, have started publishing games on the two major app stores. They (and the larger part of web game publishers) will usually reject any HTML game doesn't support mobile. So they are definitely aware of this trend.

So now my questions is: what are the stats when it comes to web games on mobile?
 Does anyone know any resource that has stats on this?


texts: Components accessing Game state and other global data

texts:
I have the following example component:

public class DoStuff : MonoBehaviour
{

    public GameManager Data; // data to be shared among components and scenes,

    public bool Predicate()
    {
        return Data.State == Idle;
    }

    public void Execute()
    {
        if (!Predicate()) return;
        //Do stuff
    }
}

It needs to access data that I have in a data class (not a component) called GameInfo, which the GameManager creates on start. What is the 'best practice' for accessing data like that in a unity component.

Make GameInfo static (or Unity equivalent)
Drag the GameManager GameObject from my Scene on this component from the Editor
Use FindObjectOfType(typeof(GameManager)) to find the data on Awake/Start
Turn GameInfo into a component and attach to empty GameObject in my scene, then follow #2.
Some other method?

Thoughts:

Having come from working on Internal tools and webservices, making things Static is rarely a good idea, but maybe for Game development making my global game state data static is the exact thing to do.
I don't have any problems with this other than it just feels strange, but that's probably just due to being new to this mindset.
I believe this uses reflection to search, which if only done once at start would be no big deal, but I feel this option is less nice than #2.


texts: How can I load a scene and move the character to a certain location?

texts:
I am making a dungeon crawler RPG game in Unity 2D and I want to allow the player to go back and forth between rooms of the dungeon. This is the code for a Master script that sends the player to a re-entry point when the scene is loaded. This script becomes functional in scene 2.

public GameObject player;
public GameObject sceneEntry;

// Use this for initialization
void Start()
{
    DontDestroyOnLoad(this.gameObject);
    SceneManager.sceneLoaded += OnSceneLoaded;
}

void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
    Scene CurrentScene = SceneManager.GetActiveScene();
    string SceneName = CurrentScene.name;
    player = GameObject.Find("Player");
    sceneEntry = GameObject.Find("Re-entryPoint");

    if (SceneName == "Dungeon1")
    {
        ReEnter();
    }

    if (SceneName == "Dungeon2")
    {
        ReEnter();
    }
}

void ReEnter()
{
    player.transform.position = new Vector2(sceneEntry.transform.position.x, sceneEntry.transform.position.y);
}

The problem is that when I want to enter scene 2 after going back to scene 1, I end up at the re-entry point in scene 2. I am not sure how to fix this.


texts: What is the name of the AI/algorithm used by most MMOs for monsters or mobs?

texts: Is there a standard name for the (fairly dumb) AI that most MMOs use where you 'aggro' a monster/mob when you are within a certain radius of it, and the monster chases your character for a set amount of time or distance when you attempt to run away?


texts: How do I go from a simple html5 tic tac toe game to an online 2 player game?

texts:
I've been working on an online 2 player Tic Tac Toe solution for blackberries. both old and new. And so far I have html5 code that has a 3 x 3 layout that switches between x and o for the game mechanics. I believe I'm still missing a check for win function but my question is about the server side of this game. I'm not sure how to go about learning what exactly I want. how do you take what I have now, and make this into a functioning online game?

I've been told WAMP is a good solution, as well as IIS. and its all really over my head, so i'm hoping to get a little more clarity as far as what I should focus on to bring this game to life.


texts: Rotating game object without using localEulerAngles

texts:
I'm building a player controller.

While aiming, the player can rotate the chest bone. This looks as if the character aims in different directions.

The chest bone should only be allowed to rotate within a certain range.
If this range is exceeded (either to the left or to the right), the chest bone should stay at its current rotation, and the player should be rotated instead.

I'm having problems applying the desired rotation to the parent game object instead.

I'm trying to work with the localEulerAngles in order to applying an additional Y rotation to the gameobject, but the Y rotation value tells me for example "359.9" while I expected to work with a value of ~0.

private void pHandle_LateUpdate_Aim()
{
    Quaternion oldNeckRotation = Neck.transform.rotation;

    // Fade old input before capturing new, so we don't dull the freshest data.
    float yawBlend = Mathf.Pow(1.0f - Aim_yawInputFalloff, referenceFramerate * Time.deltaTime);
    // A Lerp toward zero is just the same as a multiplication by the blend factor.
    Chest_yawRate *= yawBlend;
    // Accelerate by mouse movement over the past frame.
    // (May need adjustment for display resolution).
    Chest_yawRate += Input.GetAxis("Mouse X");

    float yawDelta = Chest_yawSpeed * Chest_yawRate * Time.deltaTime;
    float offCenterYaw = Chest_currentYaw - Chest_yawCenter;

    float fDesiredChestYaw = Chest_currentYaw + yawDelta;
    float fHeroRotation = 0f;

    if (fDesiredChestYaw > Chest_rotateRange) // the allowed chest rotate range would be exceeded. Instead, move the gameobject / the parent.
    {
        fHeroRotation = (fDesiredChestYaw - Chest_rotateRange);
        fHeroRotation += this.transform.localEulerAngles.y;
        this.transform.Rotate(0, fHeroRotation, 0);
        return;
    }
    else if (fDesiredChestYaw < -Chest_rotateRange)
    {
        fHeroRotation = (Chest_rotateRange + fDesiredChestYaw);
        fHeroRotation += this.transform.localEulerAngles.y;
        this.transform.Rotate(0, fHeroRotation, 0);
        return;
    }
    else
    {
        // If we're moving away from the center, slow down as we approach the edge.
        if (yawDelta * offCenterYaw > 0)
        {
            float extremityYaw = offCenterYaw / Aim_yawMaxRange;
            yawDelta *= 1.0f - extremityYaw * extremityYaw;
            fHeroRotation = yawDelta;
        }
    }

    // Ensure we never overshoot the allowed range.
    Chest_currentYaw = Mathf.Clamp(Chest_currentYaw + yawDelta,
                              Chest_yawCenter - Aim_yawMaxRange,
                              Chest_yawCenter + Aim_yawMaxRange);

    Vector3 nNewChestRotation = new Vector3(Chest.localEulerAngles.x, Chest_currentYaw, Chest.localEulerAngles.z);
    Chest.localRotation = Quaternion.Euler(nNewChestRotation);

    Quaternion newNeckRotation = Neck.transform.rotation;

    //the neck should not rotate with the chest. So I first counter-rotate it against the new chest rotation, then rotate it a little towards the chest rotation
    Neck.transform.rotation = Quaternion.Lerp(oldNeckRotation, newNeckRotation, neckFollowChest);
}


texts: Linux Mint Godot window when ran very small

texts: I am running my game on Linux Mint 20 Cinnamon. When I run my game I get a very small window that is about 1 pixel tall. This happens across all projects. I have tried uninstalling Godot and reinstalling it from the package manager. I have also tried the official launcher from their website. Updating through update manager does not help as well. I get the same issue using Godot 3.2.2 and 3.2.3


texts:
I want to have another go at 3D within XNA. What I have seen from some other games that they just have a separate very low poly model "cage" around the environment model. However I can not find any reference to this. I have not that much experience with XNA 3D either.

Is it possible to have this cage within each of my environmental models already? Lets just say I call the mesh within the .FBX wall and col_wall. How would I call to these different meshes within XNA?

The player would just have a tight collision cube around. To make it a bit more efficient I will be making divide the map up by cubes and only calculate collision if the player is in it.

Question two: I can't find anywhere to do cube vs mesh collision. Is there a method for this? Or perhaps it is possible to build my collision cage out of cubes in the 3D app and on loading of the models in XNA replace them directly by cubes? So I could just do box to box collision which should be very cheap and still give the player the ability to move over ledges on the static models.


texts: Should I be using Blender game engine as my first engine?

texts:
I am new to game development. I was learning how to create 3d models in Blender to use in an Android game, but I was reading that you can use Blender game engine for creating android games.

Is it a good idea to use it since I couldn't find any reviews about it. Is it actually being used by developers to create Android games?


texts:
Is it possible to achieve effect equivalent to looking on the cube textured from cube map from its center, but without creation of its faces (6 quads or 12 triangles)?

Say, one needed a skybox, but without the "box". There is no anything except skybox and there is no need to calculate depth of something - all the points of that skybox are always visible.


texts: How can I get the instantaneous volume level of a sound at a particular playback point?

texts:
How can I go about getting the current volume output of an audio file in libGDX? By that I mean of the actual file at its current play position.

Essentially I want to write my own version of a plugin I was using in Unity for basic lip syncing. Depending how loud the audio is, a different mouth shape sprite will be shown.

So for example if there was a sound with a sentance "what is that?" you would expect the "that" to be a different shape than the "what is," as it's louder. Is there a way to do this, to get the volume at a certain point?


texts: How to disable play automatically on animation in Unity3d 4.5.1

texts:
Where is the option to disable the 'Play Automatically' function for animations in Unity3d 4.5.1. In previous versions, there was a button under the Animation tab to disable the play automatically:

But now in Unity3d 4.5.1, there is no 'Play Automatically' checkbox, instead this is here:

If anyone knows how to disable the play automatically in this version of Unity, I would really appreciate if you could explain how to do it and where to go to do it because I am pretty new to Unity and am not too sure where things are. Thanks!


texts: How can I make an actor fire a bullet on touch?

texts:
I created a Jet and a Bullet, and when Jet is touched, the Bullet is fired.

Now I want to know how can I make the Jet fire again when touched after it has fired the first shot?

public class MyGdxGame implements ApplicationListener{

    private Texture bulletTexture;
    private Texture jetTexture;
    private Stage stage;
    private JetActor jetActor;
    private BulletActor bulletActor;

    int counter=0;
    float jetX = 700,jetY = 150;
    float bulletX = jetX-10, bulletY = jetY +43;
    boolean started;

    public class JetActor extends Actor{

        public JetActor() {
            setBounds(jetX, jetY, jetTexture.getWidth(), jetTexture.getHeight());
            this.addListener(new InputListener(){
                public boolean touchDown(InputEvent event, float x, float y, int pointer, int buttons){
                    stage.addActor(bulletActor);
                    System.out.println(counter);
                    counter++;
                    started = true;
                    return true;
                }
            });

        }

        @Override
        public void draw(Batch batch, float parentAlpha) {
            batch.draw(jetTexture, jetX, jetY, jetTexture.getWidth(), jetTexture.getHeight());
        }
    }

    public class BulletActor extends Actor{
        @Override
        public void act(float delta) {
        }

        @Override
        public void draw(Batch batch, float parentAlpha) {
            batch.draw(bulletTexture,bulletX,bulletY,bulletTexture.getWidth(), bulletTexture.getHeight());
        }
    }

    @Override
    public void create() {
        bulletTexture = new Texture("C:\\Users\\User\\Documents\\LibGdxMainProjects\\SampleGame1\\android\\assets\\bullet.png");
        jetTexture = new Texture("C:\\Users\\User\\Documents\\LibGdxMainProjects\\SampleGame1\\android\\assets\\jet.png");
        stage = new Stage();
        jetActor = new JetActor();
        bulletActor = new BulletActor();
        stage.addActor(jetActor);
        Gdx.input.setInputProcessor(stage);
    }

    @Override
    public void dispose() {
    }

    @Override
    public void render() {
        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        if(started){
            bulletX -=5;
        }
        stage.act(Gdx.graphics.getDeltaTime());
        stage.draw();
    }

    @Override
    public void resize ( int width, int height){
    }

    @Override
    public void pause () {
    }

    @Override
    public void resume () {

    }
}


texts: How to make a follower script without diagonal movement

texts: I’m working on a 2d game in unity. Right now I’m trying to make a follow ai. Where a character will follow the position of the player. I currently have it set it and working using the MoveTowards function. But my problem is that my game does not use diagonal movement. Wondering if there’s a way to constrain the move towards function to not use diagonals or if there is a better function to use in this instance? Thanks


texts:
I want to remove bodies after they touched the character(playerrect). But the bodies get not removed. I set a breakpoint in the following line but it doesn't get yellow:

world.RemoveBody(world.BodyList[i]);

What is wrong? Why is the breakpoint not getting released?

How can I remove a body?

bool Player_OnCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
  if (fixtureB.CollisionCategories == Category.Cat1)
  {
    fixtureB.UserData = "RemoveMe";
  }
  return true;
}

playerrect = BodyFactory.CreateRectangle(world, 0.64f, 0.64f, 1.0f);
playerrect.BodyType = BodyType.Dynamic;
playerrect.Position = new Vector2(0.22f, 0f);
playerrect.FixedRotation = true;

playerrect.OnCollision += Player_OnCollision;

reccoin = BodyFactory.CreateRectangle(world, 0.64f, 0.64f, 1.0f);
reccoin.BodyType = BodyType.Static;
reccoin.Position = new Vector2(0.96f, 4.16f);
reccoin.IsSensor = true;
reccoin.CollisionCategories = Category.Cat1;

 protected override void Update(GameTime gameTime)
 {
   float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
   world.Step(Math.Min(elapsed, (1f / 60f)));
   for (int i = world.BodyList.Count - 1; i >= 0; i--)
   {
     if (world.BodyList[i].UserData == "RemoveMe")
     world.RemoveBody(world.BodyList[i]);
   }

 base.Update(gameTime);
 }

//Drawing:
spriteBatch.Draw(coinSprite, ConvertUnits.ToDisplayUnits(reccoin.Position),
                                   null,
                                   Color.White, reccoin.Rotation, new Vector2(coinSprite.Width / 2.0f, coinSprite.Height / 2.0f), 1f,
                                   SpriteEffects.None, 0f);


texts: How to check if user has integrated graphics card?

texts:
I'm almost done with my Direct3D game. When user starts game first time it will adjust settings (and maximum settings) based on DirectX feature level starting from 9_1 up to 11_1. I have different shaders/multisampling/anisotropy/LOD/shadows. I used my personal PC for development and I had so much backup power I thought performance wont be a problem. Then I bought laptop with integrated graphic card which supports 11_1 but is extremly slow (AMD A6-4400M, Radeon 7520G). First I thought it's my game but after few days of intense testing in other games it feels like integrated card has not enough power. In my game on full settings game drops to 30fps. When I disable few settings I can easly get up to 60 (which is required by Windows store apps).

I don't want to ruin user experience first time he runs app so I would prefer to adjust his settings to 60 fps and here is my question. Is there any way to check if it's integrated card and does it make any sense? I don't want to force user to run some simulator. I could also check ram but I won't solve my problem since game is not using much ram.

Thanks in advance.

Edit: Fixed hardware description.


texts: What can I do to ensure that everyone can run my OpenGL game?

texts:
I am currently learning OpenGL from here. That website teaches OpenGl 3.3 with GLSL 3.3 and says that it is best to learn those because they are well supported and that older versions work in a less efficient way.

So far, this has been going well, but, when I tried to get my OpenGl programs to run on my laptop with Intel HD Graphics 3000, I ran into issues with the lack of GLSL 3.3 support (glGetShaderiv() and such claim that GLSL 3.3 is unavailable. When I ignore these errors, anything beyond the background color isn't rendered).

I am learning OpenGl in order to create a video game for which my target market will contain many older non-gaming computers (in addition to users with brand-new GTX 1080s). It wouldn't surprise me if a few users were still on Windows XP. It is essential that I make sure that everyone can run my game without buying extra hardware. It is equally essential that it looks good on hardware that can support it. What single, non-deprecated graphics API is available on all hardware (using software emulation if needed) along with Windows, Mac, and Linux?

If no single such API is available, what can I do to ensure that my game will work properly everywhere while also taking advantage of new features when available without learning multiple APIs? I would strongly prefer to stay close to the hardware by avoiding higher level APIs such as Ogre3D. If to do this I need to learn multiple APIs, then, what are those and why hasn't the industry standardized this by creating an API then releasing drivers for old hardware?

Some possible solutions are:

A well-enough-performing software implementation of OpenGL 3.3 along with GLSL 3.3
A OpenGL 3.3 implementation that uses OpenGL 1.0 in the background that can be easily swapped out automatically at runtime if newer versions aren't directly available.
A simple to use older version of GLSL that allows me to load separate shaders as needed.


texts:
So I'm trying to get a script of mine to pass information to another static class being used for saving files as I've been told I wouldn't want that script to be instantiated. So I used a separate script to get input field text. However, I seem to be encountering a problem whenever I want to save the file.

I keep getting the error "Object reference not set to an instance of the object", I have made done this though. (See code below)

The class to get the name of the file

public class SaveInputField : MonoBehaviour
{
    public static string saveName;
    public GameObject inputField;

    public void getFileName(string saveName)
    {

        saveName = inputField.GetComponent<Text>().text;
        Debug.Log("Save file name: " + saveName);
        SaveFile.saveName = saveName;
    }
}

^called whenever its been edited

The static class

public static class SaveFile
{

    public static string saveName;

    public static void SaveData(Deck deck)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string path = Application.persistentDataPath + "/" + saveName + ".dd";

        FileStream stream = new FileStream(path, FileMode.Create);
        Debug.Log("Stream Opened");
        DeckData data = new DeckData(deck);

        formatter.Serialize(stream, data);
        stream.Close();
        Debug.Log("Stream Closed");

    }
```


texts: How can I make custom progress bar in unreal engine?

texts: I am trying to make a health bar. I want a masked progress bar so I tried making another progress bar and moving according to the percent of the health in blueprint. But I couldn't find any documentation about it. How can I do it? Or is it possible? It should be like this:


texts: Using idle time in turn-based (RPG) games for updating

texts:
If you take any turn based RPG game there will be large periods of time when nothing is happening because the game is looping over 'wait_for_player_input'. Naturally it seems sensible to use this time to update things.

However, this immediately seems to suggest that it would need to be threaded. Is this sort of design possible in a single thread?

loop:
if not check_something_pressed:
    update_a_very_small_amount
else
  keep going

But if we says 'a_very_small_amount' is only updating a single object each loop, it's going to be very slow at updating.

How would you go about this, preferably in a single thread?

EDIT: I've tagged this language-agnostic as that seems the sensible thing, though anything more specific to Python would be great. ;-)

Second edit: This game is not planning on having any animated components; that is, I'm currently running it as a wait-for-player-input then update everything and draw. So rather than X FPS it depends on the user's speed.


texts:
I have seen several software packages that offer auto UV unwrapping as an option.

My question is why would you ever manually UV unwrap if there is an automated tool to do so? Are there any significant downsides to using an automatically generated UV map?


texts: Simulating long distance migrating monsters in a large minecraft-like world

texts:
I want to create an effectively infinite world, like Minecraft, where chunks are generated as users come close to the edge of their current chunk.

As I understand it, monsters in Minecraft are put to sleep when the chunk they are currently in is unloaded (as far as I understand, if a player moves away from a chunk and that chunk is not close to any player, it is unloaded). That is, they don't move or do anything, and are just stored statically on disk.

This means that all the monsters are effectively territorial and have the behavior of being awake only if a player is nearby - otherwise they sleep forever.

EDIT: Actually in Minecraft mobs despawn when a certain distance away from the player, resulting in a more random experience.

What if I want to simulate the behavior of large scale migrating herds? In an infinitely large world, there should be infinitely many monsters randomly wandering around. There might be herds of monsters wandering around. Obviously they cannot be all loaded in memory at once.

Now, if a player discovers such a herd, he might want to walk away some distance, and then come back later to follow the herd's tracks, which might be quite some distance, but he will eventually catch up to it. This seems impossible with Minecraft's way of dealing with loading/unloading chunks.

Is there some way of simulating long distance monster migrations whilst maintaining Minecraft's advantage of having memory usage be linear with respect to the number of players (rather than the size of the world)?


texts: With a rolling pawn, how can I have a component that follows its rotation, but stays upright and only rolls?

texts:
I'm using the UE4 rolling pawn to create a Metroid Prime morph ball style pawn. I've got it set up with a ribbon particle component on a spring arm, inheriting yaw, but if I set it to inherit roll, the axes invert and cause the particle emitter to flip and break the ribbon trail.

I'm sure there's some kind of rotation math that it needs, but it's beyond me. I've tried doing various math things to the axes, but I haven't been able to get it to click at all.


texts: How to calculate verticle normals of triangular mesh

texts:
I'm playing with some terrain generation. I have a triangular mesh that looks OK - that is if I hardcode verticles normals (on this image every single verticle has normal of (0,-1,0)

The situation is different when I try to calculate normals normally. I.E.

// for every vertex in triangle normal is
private Vector3D GetNormal(Vector3D a, Vector3D b, Vector3D c)
{
    //return new Vector3D(0, -1, 0);
    return (c - b).CrossProduct(a - b).Normalize();
}

In this case I end up with

Is something fundamentally wrong with my approach ? I've read that vertex normals should take into account adjected triangles (sum of adjected triangles normals normalized by area those triangles have), but I don't think my "simplistic" approach should create those weird holes.
Sources (if anyone is interested: https://github.com/svejdo1/Delaunay)


texts: What are projection independent ways of determining whether a normal is facing the viewer?

texts:
A position v and normal n are given in world coordinates. Also there is a view matrix V for world-eye coordinate transition and a projection matrix P for eye-ndc transition. I would like to determine, whether the normal is facing the viewer.

If we assume that P is a perspective matrix, we can compare the normal direction with the direction to the viewer, both in eye-space. Note that the approach won't work for an orthographic projection, because there is no well defined eye position. But if P is orthographic, we only need to check the Z coordinate of n in eye space. Nevertheless, I'm seeking a solution that does not make assumption about what projection type we're using.

One way of achieving this is to compute the inverse P' of P and retrieve the viewing direction as a vector spanned between P' [u.x, u.y, -1] and P' [u.x, u.y, 1], where u is v transformed to ndc. The drawback here is that it requires inverting a matrix and in my case also passing it to the shader.

Another solution would be to construct a small triangle around v within the normal plane of n, and check what's its winding direction in the ndc. The problem with this approach is that it's computationally heavy and it's still seems to me more like a hack than a proper solution.

I am not very satisfied with these two solutions. Do you have any other ideas? Am I missing something very simple?

EDIT:
Since it seems unclear why the dot(v - eye, n) < 0 is not satisfactory in my case, I post an exaple showing the difference between perspective and ortho projection for this particular problem.

As you can see, the vector is facing slightly away in the perspective projection, but clearly towards in the orthographic projection. More specifically, a face having that particular normal would be culled in perspective, but not in ortho.


texts: Managing player/AI state in Entity Component System

texts:
I am working on a 2d platformer game. Right now, I'm also using ECS. My question is how can I manage player's and AI current states in the context of ECS when some states are exclusive and some may be combined.
At this moment, for the player entity I have several components: HorizontalSpeedComponent, VerticalSpeedComponent, CollisionComponent... and also a PlayerComponent that holds a player state flag.
I also have several systems:

PlayerInputSystem that maps player input to state
PlayerWalkSystem that manages player horizontal speed while moving
PlayerGravitySystem that manages player vertical speed while jumping/falling and also checks if player is on the ground.
CollisionSystem that calculates collisions
AnimationSystem that maps entity state to animation frame
DrawingSystem that renders every entity

Player state flag represents following states:

Idle
Walking
Jumping
Falling
Attacking

Now some of the states are exclusive: if player is Idle, then he is not doing anything else.
But if player is walking (moving horizontally), then he may also be jumping(moving vertically up) and attacking. On the other hand, if player is jumping then he is not falling.
I thought about using a single Finite State Machine system to avoid having state checks and transitions mixed in other systems, but I do not know how it could be implemented it while keeping some states exclusive and some not.


texts: How to detect if object is moving in clockwise- or counterclockwise direction?

texts:
I've read this one, but I need more info: rotating an object from sourceAngle to destAngle, both 0-359, clockwise or counter clockwise?

I have a ball. The user is able to drag the ball in any direction clockwise/anticlockwise around a circle. I need to know whether or not the ball was dragged clockwise or anticlockwise.

I'd like to get both vector/non-vector methods.


texts:
I was trying to google and understand my problem in two weeks but i am defeated, so i am asking for help.

The main problem is that my custom unlit frag shader after certain amount of time on devices with mali gpu starts to drop fps - i see it via fps counter in the cpu section. I dont know why in that section and not in render section, but with out this fps counter i can still feel the drop of fps.

So on Samsung S4, Samsung sm-t 380, xiaomi redmi note 5, samsung tab s2 is all ok, the drop was only on samsung s6 - to solve the problem i just half the resolution by Screen.SetResolution function.

I was thinking that drawing the full screen sprite on such a high res device is the point. Then i can test app on samsung sm-t580 - and the drop was there - this device has low resolution than S6.

I assume that the problem in arm mali gpu - or i am sure in my hands.

So again, i am rendering full-screen with draw-mode = tile(countinuous) sprite with 3 textures, just changing theirs uvs in vert func and apply in fragment. This makes distorting effect. The shader show that i have 10 maths and 4 textures, yes 3 textures but i am making 4 sampling.

The textures are 256x256 with repeat mode. I was trying diferrent textures compressions, dxt5, etc1-2, alpha8, R5 - no effect.

I was trying to different precisions half and float in different parts in shader - no effect.

I was thinking in alpha, so i took textures without alpha and not getting it from tex2D. Even the size of textures is doesnt matter, even if they 64x64.

The dance with ZTest, ZWrite, Blend, Queue RenderType, other params - no effect.

My guess was that maybe on mali uv : TEXCOORD0 must be only float2, not float3 or float4 - no effect.

I am applying _Time.y and replace it with float from script - no effect.

Only reducing amount of tex2d in shader - is working. Why?

What i`m doing wrong?


texts: Unity: Finding out where OnSelect comes from

texts:
The new UI EventSystem method OnSelect is called from a number of different sources. One is when the Selectable is selected by using the arrow keys to navigate. Another is when clicking on the Selectable.

Both these methods trigger an OnSelect on the object, but how can I find out where the selection came from, if I want to treat it differently? Any ideas?


texts: Selecting a color that will be readable overlapped upon another?

texts: I've got random circles from random colors of RBG (assume they can be any combination of values). I have some text I want to write on top of them but I want the color to be readable on it no matter the color of the bubble. How can I pick a complimentary color?


texts: Why the lockState of the doors is all the time false even if in the editor I set one of them to true?

texts:
In the DoorsLockManager in the class DoorClass I changed in the editor one of the lockState to true but when running the game they are all change to false including the one I tried to set to true. Not sure why if I set it to true it's changing back to false.

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

[ExecuteInEditMode]
public class DoorsLockManager : MonoBehaviour
{
    [System.Serializable]
    public class DoorClass
    {
        public bool lockState;
    }

    public DoorClass[] doorclass;

    private List<HoriDoorManager> Doors = new List<HoriDoorManager>();

    private void Start()
    {
        var doors = GameObject.FindGameObjectsWithTag("Door");
        doorclass = new DoorClass[doors.Length];

        for (int i = 0; i < doors.Length; i++)
        {
            Doors.Add(doors[i].GetComponent<HoriDoorManager>());
            doorclass[i] = new DoorClass();
            Doors[i].doorLockState = doorclass[i].lockState;        }
    }
}

And the HoriDoorManager script:

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

public class HoriDoorManager : MonoBehaviour
{
    public List<DoorHori> doors = new List<DoorHori>();
    public bool doorLockState;

    private void Awake()
    {
        if (transform.parent != null)
        {
            Transform parent = transform.parent;
            var children = parent.GetComponentsInChildren<Transform>();

            if (children != null)
            {
                foreach (Transform door in children)
                {
                    if (door.name == "Door_Left" || door.name == "Door_Right")
                        doors.Add(door.GetComponent<DoorHori>());
                }
            }
            ColorDoors(Color.red, Color.green, doorLockState);
        }
    }

    void OnTriggerEnter()
    {
        if (doorLockState == false)
        {
            if (doors != null)
            {
               for(int i =0; i < doors.Count; i++)
                {
                    doors[i].OpenDoor();
                }
            }
        }
    }

    private void ColorDoors(Color red, Color green, bool state)
    {
        List<Transform> children = new List<Transform>();

        for (int i = 0; i < doors.Count; i++)
        {
            foreach (Transform child in doors[i].GetComponentsInChildren<Transform>())
            {
                if (child == doors[i].transform)
                    continue;

                var renderer = child.GetComponent<Renderer>();
                renderer.material.shader = Shader.Find("Unlit/ShieldFX");

                if(state == true)
                {
                    renderer.material.SetColor("_MainColor", red);
                }
                else
                {
                    renderer.material.SetColor("_MainColor", green);
                }
            }
        }
    }

    public bool GetLockState
    {
        get { return doorLockState; }
        set { doorLockState = value; }
    }
}


texts: What is the difference between engine approach and language approach in terms of saving game data?

texts:
I was asked to find a way to somehow save gamedata for a game we (my friends and I) are making and i found that there is something called engine and language approach. I have found something i would call language approach because it relies mostly on System libs but cannot find anything on the engine approach. Are scriptable objects the way of saving data by engine approach ? if so how do i combine them in one savefile ?
Game engine we are using is Unity and we're writing code in C#.


texts: How can I disable mipmapping on textures loaded from .X files?

texts:
I'm trying to render a plane mesh textured with a simple grid pattern. The problem is that XNA keeps mip-mapping the texture in horrible, horrible ways.

What I'm trying to achieve is to get this grid to look as close to vector graphics as possible (so anisotropic filtering is out of the question, I must use point filtering):

SamplerState ss = new SamplerState();
ss.Filter = TextureFilter.Point;
ss.MaxMipLevel = 0;
ss.AddressU = TextureAddressMode.Wrap;
ss.AddressV = TextureAddressMode.Wrap;
GraphicsDevice.SamplerStates[0] = ss;

I'm loading the mesh, and it's textures, from an .x file so I don't have control over the specifics of the texture loads. Can I disable mip-mapping for the whole rendering process?


texts: How can I tune material values with the slider in the Unity inspector more finely?

texts: I'm adjusting a material's texture tiling and offset values in the editor but its increments are too large and it's jumping over the value I need. Is there a way to slow it down or adjust the amount it increments by (without using a custom script)?


texts: How do I load chunks of data from an assest manager during a loading screen?

texts:
I'm developing an Android game.  Basically I want to pre-load all graphics/sounds when the app is first loaded.  But I also would like to show a progress bar as this is happening.  Here is a snippet of Java/Android code to display a progress bar while doing some work:

public class LoadingScreen extends Activity {

private static int progress = 0;
private ProgressBar progressBar;
private int progressStatus = 0;
private Handler handler = new Handler();

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.loadingscreen);

    progressBar = (ProgressBar) findViewById(R.id.progress);

    //---do some work in background thread---
    new Thread(new Runnable()
    {
        public void run()
        {
            while (progressStatus < 100)
            {
                progressStatus = doSomeWork();

                //---Update the progress bar---
                handler.post(new Runnable()
                {
                    public void run() {
                        progressBar.setProgress(progressStatus);
                    }
                });

            }
            //---hides the progress bar---
            handler.post(new Runnable()
            {
                public void run() {
                    progressBar.setVisibility(8);
                }
            });
        }

        private int doSomeWork()
        {
            try
            {
                //---simulate doing some work---
                Thread.sleep(50);
            } catch (InterruptedException e)
            {

            }
            return ++progress;
        }

    }).start();

}

My question is: how do I design my Asset Manager to load "chunks" of data (bitmaps and sounds/music) in the doSomeWork() function?  Would it be some sort of stack that I keep popping off the next asset to load?  How do I determine how much of the progress bar I should increment after loading a "chunk" of data?

Is there a better way to approach this or is this the correct way?


texts: Texture with Transparent background has black background in Unity

texts:
please see the below image. I made a model in Blender that has eye meshes with UV mapped Pupils. But trying to import all this into Unity is causing tons of weird visual errors...

The pupil png has a Transparent background but that background shows up as Black in Unity. Googling says to fix it by choosing 'Transparent' shader but all the ones I try end up cutting out the Eye mesh beneath it.

Any help appreciated.


texts:
I have 4 3D points which represent a even quad in space. (So 3 points are sufficient)
I need to get all the individual transformations (translation, rotation, dimensions) so that I can build that quad in my CSS 3D engine. So the default normal vector for a quad is [0, 0, 1].

What I have so far:

// 4 points
p0, p1, p2, p3

// normal
normal = cross(p1 - p0, p2 - p0)

// axis and angle
axis = cross([0, 0, 1], normal)
angle = arccos(dot([0, 0, 1], normal))

// rotation matrix
rotationMatrix = matrix4.fromAxisAngle(axis, angle)

// width and height
width = sqrt((p2.x - p1.x)^2, (p2.y - p1.y)^2, (p2.z - p1.z)^2)
height = sqrt((p1.x - p0.x)^2, (p1.y - p0.y)^2, (p1.z - p0.z)^2)

// translation
x = (p0.x + p1.x + p2.x + p3.x) / 4
y = (p0.y + p1.y + p2.y + p3.y) / 4
z = (p0.z + p1.z + p2.z + p3.z) / 4

It almost works, but some rotations are wrong or more specifically one rotation axis is missing. This is logical because the rotation is only build from the normal. So how can I get the full rotation?

Here you see that the top and bottom quads are just rotated around the x axis but the y axis rotation is missing:


texts: Concerns about APK version compatibility

texts:
I'm making a game in Unity, and i want to know if I generate the apk in version 4.1 Jelly Bean he will run in newest versions of android?
Can anyone explain me better how the version works?


texts: Architecture for mixing synchronous and asynchronous program flow to maximize faux real-time yet logical gameplay?

texts:
What I am attempting to make is a faux real-time game engine in node.js (taking advantage of the non-blocking I/O). When I say 'faux real-time' what I mean is I want players to interact with the world as much as possible without players blocking each other or having to 'wait in line to use the world'.

That is, unless the gameplay requires it. For example, in real life you have to wait in line to do certain things, some as simple as taking up space on a certain section of the highway. However if each person is in their own space, they can do jumping jacks or spin donuts in their car at a unique pace completely unrelated and 'in parallel' to every other person who is also taking these unrelated actions.

Related/synchronized actions would be things like trading, or even moving. If two players move into the same space and attempt to pick up the same object then suddenly it matters if they get there at the same time...

I hope this is making sense, but I'll add some code to try and give an example:

setInterval(function() {
     for(var i = 0; i < someArray.length; i++){
         someArray[i].QueuedAction();
     }
     someArray = new Array();
}, 1000);

If every 1 second we went through this array and then emptied it, we would effectively have a synchronized list. There may be many events coming in to add to this array while this loop is running, but this loop is blocking those events from modifying the array until it is done and has cleared the array. This would be list of things happening in order.

However if this takes too long, then it will also block players from requesting their current location or the client from requesting objects around the player, etc. So this needs to happen quickly to keep the illusion of real-time but in order to keep the illusion of a logical world.

Is there any patterns I should evaluate that could improve this balance of in-order yet non-blocking world game engine?


texts: How to find the total bounds rectangle around a list of rectangles

texts:
How can I find the total bounds rectangle around a list of rectangles?

Rectangle object: a simple data structure of 4 floats (w,h,x,y).
I have an array of 2 or more rectangles and want to create a rectangle that surrounds all of them:

The result rectangle, calculated from rectangles A and B:
 Rectangle T : ( Ht, Wt, Xt , Yt)