texts: BoxCollider not blocking other object(s)

texts:
I'm really newbie , watched about 20 videos about and tried to do something. But I still have problems with collisions.

I'm working on 2D. I have a Sprite and a Cube (GameObject>3D Object>Cube). sprite is moving to a random position on screen and when it arrived to that position it's moving to another random position. It's going on like this forever. But when sprite hit to cube, it should change direction (when collision occured) , but instead it's passing through it.

Sprite has these components:

Cube has these components:

BallControl Script

public class Move : MonoBehaviour {

    public float moveSpeed = 3f;
    private Transform tf;
    Vector3 mousePosition;
    bool isMoving=false;
    void Start()
    {
        tf = GetComponent<Transform> ();
    }

    void Update ()
    {
        if(!isMoving) // Find a new position to move
            walkToRandomPosition();
        if(isMoving) // If we already found a position to move
            transform.position = Vector3.MoveTowards(transform.position, mousePosition, moveSpeed * Time.deltaTime);
        if (transform.position == mousePosition)
        { // Stop
            isMoving = false;
        }
    }

    void walkToRandomPosition()
    {
        mousePosition = Camera.main.ScreenToWorldPoint(new Vector3(Random.Range(0,Screen.width), Random.Range(0,Screen.height), Camera.main.farClipPlane/2));
        mousePosition.z = 0f; // Because we are working on 2D
        isMoving=true;
    }
}

Can you tell me why cube's Box Collider not blocking sprite? Should i add something like this to my BallControl script?

 void OnCollisionEnter2D(...)
 {
      // Change direction (find new position)
 }

UPDATE 1

Just add a new sprite and gave BoxCollider2D , now collision working as expected. But it's still not working with 3D cubes.


texts: looking for simple 3d games made with Qt

texts:
Hi
i need to make simple education games in 3d for that i need GUI and editor like function
this is no problem . but the openGL stuff i need to learn by example.
do you know places where i see example of simple 3d games made with Qt ?
Thanks


texts: 2D Per Pixel Collision Detection using Animated Sprite

texts:
I am using MonoGame 3.6 and Visual Studio 2017.

I have been trying to find a solution online to do per pixel collision detection using an animated sprite that I am drawing from a sprite sheet.

Using the following code which is not working:

The BoundingRectangle and Position on the AnimatedSprite.cs

public Vector2 Position
    {
        get { return position; }
        set
        {
            position = value;
        }
    }

public virtual Rectangle BoundingRectangle
    {
        get
        {
            return new Rectangle(
                (int)Position.X,
                (int)Position.Y,
                Width,
                Height);
        }

    }

public static bool CheckForPixelCollision(AnimatedSprite a, AnimatedSprite b)
    {
        // Get Color data of each Texture
        Color[] dataA = new Color[a.Width * a.Height];
        Color[] dataB = new Color[b.Width * b.Height];

        a.Texture.GetData(0, a.Animations[a.CurrentAnimation].CurrentFrameRect, dataA, 0, a.Width * a.Height);
        b.Texture.GetData(0, b.Animations[b.CurrentAnimation].CurrentFrameRect, dataB, 0, b.Width * b.Height);

        int top = Math.Max(a.BoundingRectangle.Top, b.BoundingRectangle.Top);
        int bottom = Math.Min(a.BoundingRectangle.Bottom, b.BoundingRectangle.Bottom);
        int right = Math.Max(a.BoundingRectangle.Right, b.BoundingRectangle.Right);
        int left = Math.Min(a.BoundingRectangle.Left, b.BoundingRectangle.Left);

        for (var y = top; y < bottom; y++)
        {
            for (var x = left; x < right; x++)
            {
                Color color1 = dataA[(x - a.BoundingRectangle.Left) + (y - a.BoundingRectangle.Top) * a.Width];
                Color color2 = dataB[(x - b.BoundingRectangle.Left) + (y - b.BoundingRectangle.Top) * b.Width];

                if (color1.A != 0 && color2.A != 0)
                    return true;
            }
        }

        return false;
    }

When I run this code, I get OutOfRangeException when it tries to get the color out of the array. I am trying to achieve the following steps:

1) Extract the colors from both AnimatedSprites from their SpriteSheet only for the current frame that is drawing from the Animation

2) Check if any of the pixels in the intersecting rectangle are not transparent and return a collision.

An example of how the code will be called when checking Player movement capabilities:

                var nextPosition = (Sprite.Position + (motion * PlayerSpeedAmplifier));
                var playerTempRectangle = new Rectangle((int)nextPosition.X, (int)nextPosition.Y, PlayerCurrentRectangle.Width, PlayerCurrentRectangle.Height);
foreach (var enemy in listOfEnemies)
                {
                    if (playerTempRectangle.Intersects(enemy.EnemyCurrentRectangle))
                    {
                        if (Helper.CheckForPixelCollision(Sprite, enemy.Sprite))
                        {
                            canMove = false;
                            break;
                        }
                    }
                }

I hope someone can please help. Let me know if you need any additional information.


texts:
I'm new to using Unity (2019.30a2) and am currently learning by watching Brackey's (youtube) "How to make a 2D Game in Unity"

At 6:58 he is able to rearrange his layers easily.  On my hand, I can create but am unable to change the order of the layers.

Looking at other questions on similar subjects hasn't provided me with a solution yet.  I'm currently working around it but feel this will hinder me in the future.

The screenshot of the unmovable layers is included below:


texts: How to display procedurally created rooms as a schematic map?

texts:
In most games, a map can be generated by essentially doing a "top-down" view of the specific area. This will accurately show the size and positioning of any rooms, as well as how they connect.There might be special icons for stairs, doors, etc.

In a game I am working on I am intentionally keeping some concepts rather loose. The map is not there so much to display distance between rooms or the relative size of rooms between each other, but just to most clearly show the connections between the rooms.

The easiest real-life example I can show is an electronic schematic.

Now, I only know some of the symbols on there, but in this case you might just substitute them for various rooms. You can easily imagine then that this layout could have many actual physical representations. A connection could be a door, but it could also be stairs or even an abstract "border" between two regions.

I currently generate "rooms", without size or even position. I then assign them connections. Not exactly "random" connections but I am still playing with the generation so I don't have any hard rules at this time.

The task I am having a difficult time with is: How do I take these rooms with connections and arrange them in such a way to maximize clarity of which rooms connect to which?


texts: What happens when a texture is too large for a device

texts:
The question is two fold:

What happens on a device when a texture is too large for it to handle? Will it crash or simply downsize it?
In Unity if I use texture atlases of size 4k and then set Texture Quality in the Quality settings as half res will it run normally on devices with maximum texture size of 2k?


texts: Can art syle proportions have copyright?

texts:
I like the art of a mobile game called Battleheart.

Is it copyright infringement if I copy only the proportions of his characters?
Obviously the clothes, style of the brush, and all the rest of the art will be my own style. The gameplay of the game will be different, too.


texts:
I don't really know how to explain this but I have always wondered how simple player movement collision work. Take Half-Life or Counter-Strike for example.

Their player collision against the world are very simple - AABB collision box vs. simple brushes. For example, you walk towards a wall and when you collide with it, you are perfectly still.

While in Unity, there we have PhysX which is not even the slightest suitable to achieve perfect, almost pixelated(in 3D) player collisions.


texts: How to implement a simple chat option for server-client based game (blender/BGE)

texts:
I want 2 players to be able to chat with eachother. I have a running server-client game, but I'm kind of stuck on this one.

Since there are only outdated videos this is an example I need:

https://www.youtube.com/watch?v=pTPsNYLg2oY

It's just a very simple chat method, but I don't know how to integrate my Python code into Blender.


texts: 2D Parallax scrolling through GLSL shader

texts:
I currently switched from LWJGL to LibGDX. In LWJGL I had a shader to do parallax scrolling by simply adding an offset to the texture coordinates and it worked fine, the texture repeated itself when the coordinates where greater than 1 or smaller than 0. But in LibGDX the same shader won't work. Once the texture coordinates are greater than 1 or smaller than 0, the texture just "smears" all over the screen, it doesn't repeat itself.

Vertex shader:

#version 330 core

layout (location = 0) in vec4 a_position;
layout (location = 1) in vec4 a_color;
layout (location = 2) in vec2 a_texCoord0;

out vec4 v_color;
out vec2 v_texCoords;

uniform float x_offset;
uniform mat4 u_projTrans;

void main() {
    v_color = a_color;
    v_texCoords = vec2(a_texCoord0.x + x_offset, a_texCoord0.y);
    gl_Position = u_projTrans * a_position;
}

Fragment shader:

#version 330 core

in vec4 v_color;
in vec2 v_texCoords;

out vec4 frag_color;

uniform sampler2D u_texture;

void main() {
    frag_color = v_color * texture2D(u_texture, v_texCoords);;
}


texts: Let's say that you want to do bezier curve or surface evaluation on the GPU (fragment shader, geometry shader, compute shader, OpenCL, etc).  Does anyone know of any interesting tricks of techniques to do so?  Im looking for GPU specific techniques, but I already know the equations for n degree bezier curves, triangles and tetrahedrons.  Thanks!


texts:
I've been making a tree in with the Tree Editor in Unity, and for a realistic effect, I need to make all the leaves face a general direction, the problem is that most of them don't face that direction and are upside down or sideways.

So you further understand, i'll add some images.

I'd like all the leaves to face in this direction.

(Image 1) In here you can see that some leaves are upside down or sideways and i'd like to make all the leaves face the same way.

(Image 2) In here you can see the leaf is facing up and this is the way I would like all the leafs to face.

Any help is appreciated, thank you.


texts: How do I duplicate the functionality of ugui's onClick (button component) in inspector (Unity)?

texts:
I'm trying to create the same functionality that occurs when you are working with a button in uGui in Unity. I know that I have to create a custom inspector, but i'm not sure where to go from there.

Essentially the functionality allows you to drag and drop a script to it's on click portion in the inspector, and then it gives you a list of functions for that script to select. This may sound a little confusing, so here are a few pictures demonstrating the functionality i'm trying to replicate.

As you can see above the functionality allows you to drag in a script, select a function to link, and do this for as many or as little scripts as you want by pressing the + or - buttons on the bottom right.

Thanks for any help in advance!


texts: Artemis Framework - delete all entities with a given type of component

texts: In artemis framework how can I list all entities wtih a given type of component and delete them from the world? I couldn't find any examples in the documentation and it seems there's no straightforward way of doing this


texts:
I am using a library to load an obj but it doest compute the tangets for each vertex, which I need for normal mapping and pom. I computed my tangets, and bitangents, everything appears to be fine, but I read that I need to average tangents if the vertices are the same (same position, uv, normal).

So for example if there is a vertex v that has the same pos,uv & norms as vertex v1 and v2, then the tangent for vertex v, v1, and v2 is normalize(v.t + v1.t + v2.t)?

I want to make sure I have the correct understanding before implementing.


texts: Depth Compositing - Background Not Being Rendered

texts:
I have a pre-rendered 3D scene which I am rendering as a background image. Over this, I am rendering an invisible version of this scene only into the depth buffer, so that any other 3D object will be not be rendered if they pass behind an object in the 3D scene. As long as the camera remains static, the player will not notice that the scene is pre-rendered. I believe this method is called 'Depth Compositing', or something similar. It has been used in older games.

The problem I am having is that the pre-rendered background image is not showing through the invisible 3D scene being rendered to the depth buffer, like so:

It should look similar to this:

Here is a screenshot of the scene view to help visualize how this is setup:

The cube is rendered with this shader:

Shader "Custom/Depth"
{
    SubShader {
        Tags { "Queue" = "Geometry-10" }

        ColorMask 0
        ZWrite On

        Pass {}
    }
}

The background image is rendered in panel in a UI canvas, set to Screen Space - Camera. It is rendered in its own camera with a lower depth than the 3D object camera.

My assumption is this is to do with render ordering somehow, as perhaps the UI is being rendered after the 3D objects?


texts: Mouse click coordinates not mapping to Box2d world

texts:
I'm using Box2d in Java with OpenGL, trying to detect if a mouse has clicked on a Body. But having trouble mapping mouse coordinates to Box2d world.

I have a Body positioned at 20.0f, 30.0f in the Box2d World, but find that those coordinates are not available in my viewport?

When the app is running the following locations are clicked on canvas and output:

[00:40:01] INFO (0.05,0.05) // top left corner
[00:40:02] INFO (28.716667,0.05) // top right corner
[00:40:06] INFO (28.666666,16.5) // bottom right corner
[00:40:08] INFO (0.06666667,16.616667) // bottom left corner

OpenGL has this view ..

gl.glViewport(0, 0, getWindowWidth(), getWindowHeight());
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrthof(
    -45.0f * 60.0f,
    45.0f * 60.0f,
    -45.0f * 60.0f,
    45.0f * 60.0f,
    0.0f,
    10.0f);

The MouseListener is attached to a GLCanvas and implements mousePressed()

public void mousePressed(MouseEvent e) {
    log.info(new Vec2 (e.getPoint().x / 60.0f, e.getPoint().y / 60.0f));

    for (Body b = world.getBodyList(); b!=null; b = b.getNext()){

        for (Fixture f = b.getFixtureList(); f != null; f = f.getNext()){

            if(f.testPoint(new Vec2 (e.getPoint().x / 60.0f, e.getPoint().y / 60.0f))){

                log.info("Clicked body");

            }else{
                log.debug("Did not hit body");
            }
        }
    }
}


texts:
I found this question with a really amazing answer How do I implement branching dialogue in javascript?

Unfortunately I can't seem to understand how to get this to work since the code posted isn't complete.

I've gotten my script to print out everything up to the decisions the player has to make, but I just can't understand how to feed the answer back into the script and give the player back the appropriate response.

Here's what I have so far

var current_step;

var story = [
  { m: "Hi!" },
  { m: "This is my new game." },
  { question: "Do you like it?", answers: [
    { m: "yes", next: "like_yes" },
    { m: "no", next: "like_no" },
  ] },
  { label: "like_yes", m: "I am happy you like my game!", next: "like_end" },
  { label: "like_no", m: "You made me sad!", next: "like_end" },
  { label: "like_end" },
  { m: "OK, let's change the topic" }
];

function execute_game() {
  var current_line = 0;
  while (current_line < story.length) {

    current_step = story[current_line];

    if (undefined !== current_step.m) {

      display_message(current_step.m);

      if (undefined !== current_step.next) {

        current_line = find_label(current_step.next);

      } else {

        current_line = current_line + 1;

      }

    } else if (undefined !== current_step.question) {

      display_message(current_step.question);
      display_answers(current_step.answers);
      return;

      // display the question: current_step.question
      // display the answers: current_step.answers
      // choose an answer
      // and change current_line accordingly

    }
  }
}

function display_message(varStore) {
    document.getElementById("container").innerHTML += varStore + "
";
}

function display_answers(varStore) {
    for (i = 0; i < varStore.length; i++) {
        document.getElementById("container").innerHTML += "" + varStore[i].m + "
";
    }
}

What do I need to do from here?


texts: Are prefabs the only way to dynamically build a world in Unity?

texts:
I'm trying to understand how to setup my Unity prefabs and scripts to dynamically spawn a series of "encounters", with each encounter containing several GameObjects.

For example, imagine spawning the next several portions of an infinite-runner level. One encounter is a ramp, the other encounter is a pit with some coins.

This is what I am currently doing:

A global SceneManager script has a handle to an EncounterFactory prefab. When needed, the SceneManager will begin constructing the game world.
The EncounterFactory prefab contains a script that has a method SpawnRandomEncounter. The EncounterFactory also contains handles to several other prefabs for the objects that can be found in an encounter.
The SpawnRandomEncounter method uses the prefabs linked to EncounterFactory and builds the expected GameObjects.

So when building out a new "encounter", the SceneManager clones the EncounterFactory (which serves as the parent object for the full encounter), and then calls SpawnRandomEncounter to build out the child objects.

This seems suboptimal. First, I need to have myriad prefabs for each thing that could be spawned. It also requires a meta-prefab to EncounterFactory. That is, a prefab who just allows me to spawn other prefabs.

Is there a better way to dynamically build out a game world or level in Unity? Or is it prefabs upon prefabs upon prefabs?

For example, I'm aware that I can find an existing object by name. (e.g. find EncounterTemplate5 and clone that.) However, that requires that EncounterTemplate5 exist in the game world. (So it can be cloned.)


texts: Runescape Private Server - How does it work?

texts:
I've seen a lot of Runescape private servers lately. How do they work? Most of them are based on the old Runescape, but a few look exactly like the real Runescape.

How do they make the servers? Has the source code of the game been leaked on several occasions, and is that used to make Runescape servers? Or have some people just replicated Runescape, and tried to make the same game themselves (and "stolen" the 3D objects and texture from Jagex to make it look the same, and written the code to be able to replicate most functions of Runescape)?


texts:
I'm creating a real time multiplayer game. Each piece of data needs to be received, but it still needs to be as fast as possible which is why I don't want to use TLS for every request.

Here's what I was thinking:

The player logs in using TLS, and receives a session ID and symmetric key that the server generates

The server stores the player's ip address and symmetric key in the database for future reference

When they start a match, they receive a match ID, and send data to the server including the match ID, their session ID, and any necessary data using a symmetric encryption algorithm

The server takes their IP, finds the symmetric key from the database, and decrypts the message and authenticates the user based on the session ID

If everything checks out, the server accepts the data.

Is this approach plausible/efficient? would it be better for me to store the each player's symmetric key using their IP, or for me to get rid of the IP/symmetric key link table and send the data with the session id not encrypted, and store the key using the session id?

Any answers/comments would be greatly appreciated.


texts: Why unity crashes when using shell32 in unity3d?

texts:
I'm using shell 32 to get some file descriptions. It works perfect in Visual Studio 2010, but when it comes inside unity3d it crashes.

The code is:

using Shell32;

ShellClass shell = new ShellClass();
Folder objFolder = shell.NameSpace(path);

string fileTitle = objFolder.GetDetailsOf(objFolder.Items().item(0),21); //Crash on this line

I appreciate your help.


texts: Implementing a glowing effect on 3D objects with Direct3D 11

texts:
I'm interested in implementing a glowing effect on some 3D objects. More specifically, I want to make a star that has a sort of halo around it, as it can be seen in the photo:

I've seen on Rastertek the 2D implementation, but I have no idea how it could be done in 3D. I've also read about HDR and bloom effects, but I'm not sure if those would apply here. What Direct3D 11 techniques should I use?


texts: Unity C# - Raycasts, How to Ignore Triggers?

texts:
Let's say I have a Raycast, but I don't want it to collide with any triggers. I don't want to change the Project settings since that's a little inflexible.

How can I have a Raycast ignore any triggers?


texts: Opengl in 500 lines point in triangle question

texts:
https://github.com/ssloy/tinyrenderer/wiki/Lesson-2-Triangle-rasterization-and-back-face-culling
I am on lesson 2 of the "Opengl in 500 lines" tutorial. I follow the part of the lesson in "The method I adopt for my code", but I don't understand this leap from
P = A + uAB-vector + vAC-vector

to
0-vector = uAB-vector + vAC-vector + PA-vector.


texts:
I am currently at the last stage of the Tetris Clone using SDL library, the only thing left is rotation. For each piece I have a separate class, and in order to move the pieces down I use a method:

void PieceZ::movePieceDown()
{
  drawBlock(x1,y1++);
  drawBlock(x2,y3++);
  drawBlock(x3,y3++);
  drawBlock(x4,y4++);
}

This method is called like that: current->movePieceDown(); where current represents a pointer to the current piece. Now to rotate the piece I have another method:

void PieceZ::rotatePiece()
{
  drawBlock(newX1,newY2++);
  drawBlock(x2,y2);
  drawBlock(newX3,newY3++);
  drawBlock(newX4,newY4++);
}

New X and Y coordinates are calculated elsewhere, with x2 and y2 taken as the origin.
My question is how do I swap current->movePieceDown() with current->rotatePiece() while the piece is moving? Taking into acount that I am handling keyboard events in another method.


texts: 'Zoning' up areas on a large tile map, as well as dungeons

texts:
My game is having a map like that of Minecraft, in the way it's pseudoinfinite and randomly generated. And big. Say the user has explored a 1000x1000 zone (2D here), so that's 1,000,000 tiles.

Obviously I'm not going to be able to store it all in memory. Nor do I just want to ignore everything out of a 10 tile or whatever radius - both will nothing update (all the NPCs, perhaps reactive tiles) and I would have to work with awkward positions like 1382,12918.

So if I was to split it down into chunks or zones or whatever of say 64x64 tiles, I would have to store each tile and object's position like:

  Chunk a,b. Position x, y.

But what if I wanted dungeons and the like in my map? So a single tile that leads to maybe a 40 floor dungeon, each with an area of 40x40. I can't exactly store those in the same map.

And there's the memory side; how much could I potentially store in memory at the same time reasonably? I could do tiles by ID quite easily, and have the normal 2D array there. Or again, is there a more effective solution than having a data file of tile types? So for a 64x64..that's only going to be 20K or whatever. I'd like as much as possible surrounding to be loaded for the most realistic update. But I don't know what sort of limits I can hit without becoming memory hogging.


texts: Main camera transform.forward becomes up and down when looking from above

texts:
The camera script is a 3rd person orbit camera, when I look straight it does what it supposed to do which is walk in the direction the camera is pointing, but when the camera is looking down from above the player, the camera's forward is now up. This means when I press W to go forwards I go into the ground and when I press S it goes upwards.

Here is my movement script:

    private void FixedUpdate()
    {
    float x = Input.GetAxisRaw("Horizontal");
    float z = Input.GetAxisRaw("Vertical");

    Vector3 moveDirection = Vector3.zero;
    moveDirection += Camera.main.transform.right;
    moveDirection += Camera.main.transform.forward;
    moveDirection.y = 0;
    // Rotation
    if (x != 0 || z != 0)
    {
        anim.SetBool("Walking", true);
        if (x != 0)
        {
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(moveDirection), 0.4f);
        }
        else
        {
            transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, Camera.main.transform.localEulerAngles.y, transform.localEulerAngles.z);
        }

    }
    else
    {
        anim.SetBool("Walking", false);
    }
    // Moving
    if (Input.GetKey(KeyCode.LeftShift) && !idle)
    {
        anim.SetBool("Running", true);
        rb.position += z * Camera.main.transform.forward * Time.deltaTime * runSpeed;
        rb.position += x * Camera.main.transform.right * Time.deltaTime * runSpeed;
    }
    else
    {
        anim.SetBool("Running", false);

        rb.position += z * Camera.main.transform.forward * Time.deltaTime * moveSpeed;
        rb.position += x * Camera.main.transform.right * Time.deltaTime * moveSpeed;
    }
}

while I'm asking, the movement script gets doubled when two keys are pressed, how do I fix it while keeping the same functionality of my current movement script?


texts:
I have an arraylist of entites that I want to move randomly. No matter what I do, they won't move. Here is my female class:

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.util.Random;

import javax.swing.ImageIcon;

public class Female extends Entity {
static int femaleX = 0;
static int femaleY = 0;
double walkSpeed = .1f;
Random rand = new Random();
int random;
int dir;

Player player;

public Female(int posX, int posY) {
    super(posX, posY);

}

public void update() {
    posX += femaleX;
    posY += femaleY;

}

public void draw(Graphics2D g2d) {
    g2d.drawImage(getFemaleImg(), posX, posY, null);
    if (Player.showBounds == true) {
        g2d.draw(getBounds());
    }
}

public Image getFemaleImg() {
    ImageIcon ic = new ImageIcon("res/female.png");
    return ic.getImage();
}

public Rectangle getBounds() {
    return new Rectangle(posX, posY, getFemaleImg().getHeight(null),
            getFemaleImg().getWidth(null));
}

public void moveFemale() {
    random = rand.nextInt(3);
    System.out.println(random);

    if (random == 0) {
        dir = 0;
        posX -= (int) walkSpeed;
    }
}

}

And here is how I update the female class in the main class:

public void actionPerformed(ActionEvent ae) {
    player.update();

    for(int i = 0; i < females.size(); i++){
        Female tempFemale = females.get(i);
        tempFemale.update();
    }
    repaint();
}

If I do something like this(in the female update method):

public void update() {
    posX += femaleX;
    posY += femaleY;

    posX -= walkSpeed;

}

The characters move with no problem. Why is this?


texts: How to predict future location of a Car in a Navigation Mesh based pathfinding system?

texts:
I am developing a car based shooting game in which the Cars have to shoot each other 3/4 times and eliminate it from the game.

I am trying to develop the AI for my cars now. The problem is how can I predict the future location of one of the user cars in a Navigation Mesh based path finding system ?
I know its current velocity and direction but since we don't have a grid structure how can I predict its location in the next 2 or 3 seconds ?

One of the solutions I could think of was find the X,Y position of the user's car using his current velocity and direction and then approximate to which node does the point belong.
Is there any better system than this which could be employed ?

Any help would be appreciated. Thanks :)


texts: Creating custom types that extend certain objects

texts:
Really new to C# scripting. I'm trying to extend a TileBase type object to be able to hold custom methods and variables.

I want to create a pathfinding script and I need to store certain information for each tile. Something like this:

TileBase startPoint = tilemap.GetTile (tilemap.WorldToCell (transform.position));

startPoint.customVariable = 5;

Is there a way to extend TileBase into a new type and create custom methods inside it? How can I achieve this in Unity?


texts:
According to a post I found, the setPriority of a Sound in LibGDX is not only a hint, but does nothing on desktop, and I can confirm this.

I really need priorities for sounds in my desktop game.

The first thing that comes to mind is to roll some kind of simple "sound system" with, say, a PriorityQueue, but I'm not quite sure of how I would implement it exactly, and I'd like to re-use code as much as possible... has anyone here perhaps rolled one that I could use?


texts: Calculate values in a game, which depends from stats and balance them

texts:
So, I am basically lost at this point, trying to balance things.

In design phase; I did assign certain values to stats (imagine a standard set of any RPG you ever playe, to make things streamlined).

Now, I would like to start to introduce variants that does not depend directly on a stat; a good example could be "fatigue".

In my system, I have the value for strenght, and energy. Strength is constant (it may grow, but for the calculation purpose it is the constant part), so if I want to calculate fatigue:

strenght (0-99) constant
energy (0-99)
fatigue = [(strenght / energy)*10]

Easy...but when I plug in numbers, hell break loose.

Imagine that the character has a strenght of 100, start at 100 with energy, and each x steps, energy diminish, increasing his fatigue.

Strenght = 100
energy = 100; fatigue = (100/100)*10 = 10
energy = 90; fatigue = (100/90)*10 = 11,1
energy = 80; fatigue = (100/80)*10 = 12,5
energy = 40; fatigue = (100/40)*10 = 25
energy = 20; fatigue = (100/20)*10 = 50

This would work like a charm, maxing at 100 when energy is at 10%; but if the character has lower strenght, say 15, I end up with values as above, that are as following

Strenght = 15

1.1
1.6
1.8
3.7
7.5
15

This means that I don't get even close to 100 for fatigue, when energy is at 10% (I am at 15). So I am actually not sure how do you create formulas for parameters interaction in a game? The more complex I make it, the greater is the variance among the results; while Ideally I am aiming at having the character to take longer to reach 100 fatigue, if his strenght is higher, while it should reach fastr the limit, if the strenght is slower.

But in any case; when the energy reach 10%, the fatigue should be equivalent to 100.

Any suggestion wouold be appreciated; spending too much time on this, which should be pretty straight forward.


texts: Non-integer speed values - is there a cleaner way to do this?

texts:
Often I will want to use a speed value such as 2.5 for moving my character in a pixel-based game. Collision detection will generally be more difficult if I do that, though. So I end up doing something like this:

moveX(2);
if (ticks % 2 == 0) { // or if (moveTime % 2 == 0)
    moveX(1);
}

I cringe on the inside every time I have to write that, is there a cleaner way to move a character with non-integer speed values or will I remain stuck doing this forever?


texts: Top-Down Tilemap Rendering and Collisions in Libgdx

texts:
I'm sorry if this question has been previously answered, but I was unable to find an answer here or through google. I'm trying to make a simple roguelike-like that would feature a top-down tile map, a player, AI controlled enemies, and various items. I'm having trouble understanding how I can properly have the tilemap interact with the player and enemies through both collision detection and rendering.

It seems that the two main options for collision detection are 1)to specify if a tile is collidable in Tiled Map Editor, and then check tile by tile in the game code to see if the player's position overlaps that of a nearby collidable tile, or 2)integrate the tilemap with box2d physics. Admittedly, I do not understand any part of using tilemaps with box2d.

Additionally, I am unsure of how to properly draw the tilemap in reference to the player and enemies. Say I had a tree tile that I would like to always draw on top of/in front of the player. What is the best practice for accomplishing this in libgdx? I was thinking assign such tiles a certain ID and then render them after the player is rendered.


texts: OpenGL can an Element Array Buffer points to only one VBO

texts:
I'm making a Minecraft style game and currently storing 36 vertices and texture coordinates per cube. Could I make an EBO for only the position and leave the texture coordinates as they are?

OK i think thsi is how i will do it.

I would have an array of 24 vertices(3*GLfloat) and 24 texture coordinates(2*GLfloat) for the corners

then i would have an EBO pointing to the corners with 36 indices

So memory total = 24*3*4 + 24*2*4 + 36*4 = 624 bytes

instead of

36*3*4 + 36*2*4 = 720 bytes


texts: Determing winning on the server side or client side?

texts:
I am using JavaScript + Node.js+Websockets to develop a multiplayer card game. In my single game version the Win determining calculation is done on the client side (of course) with a function.

It looks something like this:

function(CheckWin){
if (something) {
player1 win
document.getElementById("winning").innerHTML="reason"
}
else if (something) {
player2 win
document.getElementById("winning").innerHTML="reason"
}
else if (something) {
player1 win
document.getElementById("winning").innerHTML="reason"
}

}

It is a bit chunky but that is how it is. So in my multiplayer game I can either:

When all card values are collected, the server emits all the cards value
to the client side and then it will execute the function there like
it was in my single game (but I heard this is not SAFE)
Execute the function in the server side and then emit the result
to the client (but I don't know how to emit all this
information, comments, winning to client with socket.io, I think
socket.io can only emit limited number of value types, I am planning
to emit just the Boolean value win or lose).

I am new with programming/gaming so hopefully this question is not too silly.


texts: How can a system similar to Dwarf Fortress' legends mode be implemented?

texts:
In Dwarf Fortress, nearly everything that happens during world generation is logged and viewable in legends mode. An XML file containing that information can be exported and loaded into a utility such as Legends Viewer which can show specific events, relationships between two recorded people, what kingdoms people belonged to, etc.

My naive approach would be to add each event associated with a person to a database with a unique ID then filtering using the ID in order to view the correct events. However, this approach seems to be inflexible and adds more dependencies and complexity to my project.

My second approach would be to store these events in a JSON file in order to be able to treat each individual as an object, although this approach will probably be either be too memory intensive and not scale well since I would have to load a large file into memory or be too slow since I would have to open and modify many files at a time.

Assume the game has a simple system where each individual is tracked by a name and a UUID, belongs to a kingdom, and has some type of relationship to other individuals. Events are tracked by recording the location, date, and individuals involved. What type of file, data structure, library, etc. is generally used for something like this that is efficient enough to store up to a million or so of these simple entries?


texts: Monogame/XNA - How do you resize a Texture2D and then scale it?

texts:
Problem:
It seems like the Draw() call allows us to use either Destination Rectangle for resizing (5of8) or Scale (6of8/7of8) but not both.

Purpose:
I would like to resize a button from 567x634 to 400x480 and then using scale to further reduce it by 0.8 to 320x400.


texts: How do I keep a PHP server running forever?

texts:
I'm making a web game RTS, it's mostly create units, manage resources, attack with army, and level up factories. I have created the basics of the game using Javascript, PHP, and MySQL databases. I use the database to store player credentials and stats, and PHP as a server-side logic (like retrieve the right player and attack with X units). On the client side I use HTML/CSS and javascript.

My problem is that I need to keep adding resources based on the factories level (ex. 10 gold every min, when mine-factory = lvl.1). The only answers that I have found, is to modify the PHP file to run an infinite loop and keep connecting to the database to add those resources 24/7. I think the server also needs to handle attack travel (when units arrive at the enemy castle and the fight is over) and some other logic, but I don't have physical access to the server, and keep connecting to the database to add resources doesn't seem a good idea. I'm willing to make a server using other languages, or use other way to store data that keeps changing, so I can avoid multiple connections to the database. If you know a better way to do it, or something that can put me on tracks I will appreciate it.


texts: I'm coding a mod for Skyrim with Papyrus and the Creation Kit. I can't seem to get an Actor to move from point A to point B. I know there's a function to teleport an actor, but how can I make them walk or run using Papyrus?


texts: Adversarial Search AI having problems with too many choices

texts:
I'm a game designer working with a set of coders trying to create a card game. Currently we're trying to implement a drawing mechanic in which you choose which card you draw, but the Adversarial Search AI can't keep up with that many choices and can only look two turns ahead without this new mechanic. I'm pretty set on finding a way to make this work, does anyone have and alternatives to fixing this problem?

I've tried reducing the space down to having only a few choices out of the deck, but the problems comes from the AI having to see what the player is going to draw. I'm pulling my hair over this problem, any thoughts?


texts: Question about taking mouse input in unity 2D

texts:
I'm learning a course on unity and when we started learning about taking mouse input the following code is used.

Vector3 pos = Input.mousePosition;
pos.z = -Camera.main.transform.position.z;
pos = Camera.main.ScreenToWorldPoint(pos);
gameObject.transform.position = pos;

My problem is in the second line. Shouldn't our Z be 0 instead of minus wherever our camera is? Because the plane where we our designing our game is in z = 0, right?

Please go slow on me I'm still new to unity. Thank you!


texts:
I was thinking about platforms and enemies moving in circles in old 2D games, and I was wondering how that was done. I understand parametric equations, and it's trivial to use sin and cos to do it, but could an NES or SNES make real time trig calls? I admit heavy ignorance, but I thought those were expensive operations. Is there some clever way to calculate that motion more cheaply?

I've been working on deriving an algorithm from trig sum identities that would only use precalculated trig, but that seems convoluted.


texts: Why do 3d model drawn to a RenderTarget appear distorted compared to those drawn directly?

texts:
I've got a problem drawing a 3D model to a RenderTarget2D in XNA 4. When the model is drawn to a render target, and then the render target is later drawn to the screen it appears distorted. (See right image below)

However, if I draw directly to the backbuffer, then everything appears correctly (See left image)

I'm resetting all the states before doing the 3D drawing. (BlendState, DepthStencilState, SamplerStates and RasterizerState)

This is my draw method. I first draw to the render target. Then I use a spritebatch to draw this to the screen (offset to the right for this example). Finally yfor direct comparison I reset the states again and draw the 3d model a second time directly to the back buffer (using the exact same DrawModel() method) and it works fine.

    protected override void Draw(GameTime gameTime)
    {
        // First set to use a render target.
        GraphicsDevice.SetRenderTarget(_playerBufferRenderTarget);
        GraphicsDevice.Clear(Color.Black);

        // Reset all the states as appropriate for 3d drawing.
        GraphicsDevice.BlendState = BlendState.Opaque;
        GraphicsDevice.DepthStencilState = DepthStencilState.Default;
        GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;
        GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;

        // Draw the model (to the rendertarget)
        DrawModel();

        // Go back to the backbuffer.
        GraphicsDevice.SetRenderTarget(null);
        GraphicsDevice.Clear(Color.Black);

        // Now draw the rendertarget to the screen as a sprite (Offset to the right).
// (This looks wrong)
        spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, null, null, null);
        spriteBatch.Draw(_playerBufferRenderTarget, new Vector2(300, 0), null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
        spriteBatch.End();

        // Again, reset the states.
        GraphicsDevice.BlendState = BlendState.Opaque;
        GraphicsDevice.DepthStencilState = DepthStencilState.Default;
        GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;
        GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;

        // Now draw the model again, but this time directly to the back buffer.
// (This works).
        DrawModel();

        base.Draw(gameTime);
    }

I create the RenderTarger2D within the LoadContent() method.

_playerBufferRenderTarget = new RenderTarget2D(this.GraphicsDevice, 800, 500);

This is the DrawModel method for reference although this is basically copied directly from an MSDN sample:

    private void DrawModel()
    {
        Matrix[] transforms = new Matrix[_playerModel.Bones.Count];
        _playerModel.CopyAbsoluteBoneTransformsTo(transforms);

        foreach (ModelMesh mesh in _playerModel.Meshes)
        {
            foreach (BasicEffect effect in mesh.Effects)
            {
                effect.EnableDefaultLighting();
                effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(modelRotation) * Matrix.CreateTranslation(modelPosition);
                effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
                effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(90.0f), aspectRatio, 1.0f, 10000.0f);
            }

            mesh.Draw();
        }
    }

I've included a link to the Player.fbx model file. Is it possible that this could be caused by something I've done wrong when creating the model.


texts: Rendering a lot of Models at once with XNA

texts:
In an hexgrid based game, I render all terrain tiles as a separate model, reusing the same texture objects on all similar tiles. The tiles is a pretty simple model.

When the terrain is set to be at 20x20 or more (so 400 tiles), the game really slows down. The "slowdown point" is about the same on my i5 laptop or my i7 desktop.  The game takes around 30megs in the memory. Here is how the render looks like :

The way I render each tile is the following :

foreach (ModelMesh mesh in ModelSupport.Meshes)
{
    foreach (BasicEffect effect in mesh.Effects)
    {
        effect.EnableDefaultLighting();
        effect.World = transforms[mesh.ParentBone.Index]
            * mScale * mRotationY * mPosition;
        effect.View = Camera.ViewMatrix;
        effect.Projection = Camera.ProjectionMatrix;
    }

    mesh.Draw();
}

Any suggestion of how I could optimize the rendering of a large amount of models?


texts:
Though I am a programmer by trade, I have barely touched game development at all. I've had this question for some time, and now that I'm looking into game development I thought it would be a good time get ask.

Why does shadow mapping seem to be the exclusive way games use to make shadows?
To be blunt, it looks terrible. Even modern games with shadow settings maxed have jagged block-y shadows that are very distracting.

Doom 3, made 11 years ago used shadow volumes that looked much better than any shadow map implementation I have ever seen, that includes AAA games released the same week this question is being posted. Third party mods for Doom 3 even softened the edges of the shadows, making them even more visually impressive.

Is there some kind of technical problems or limitations with implementing things like shadow volumes? Are shadow maps just so easy to implement that devs don't even consider anything else?

The only information I've been able to find on the subject is that the polygons that make up the the volumes can be quite large, becoming more demanding. Perhaps shadow volumes have much higher system requirements, but if that is the case how did they get away with using them in 2004?

This question isn't specific to shadow mapping vs shadow volumes, They are simply the only 2 I've seen used in full products and I just haven't been able to find much information on any other techniques.


texts: I am new to gamedev, and I have one question about architecture. Where to locate game images? Should I keep this in the class object or in the main function and draw it depending on object variables?


texts: Saving Scores on iOS and Android Devices using MonoGame

texts:
Quick question, what is the best way to save a game score in a mobile device (iOS and Android) using MonoGame (example would be a Flappy Bird score).

You can also list ways and approaches of saving scores in mobile devices and discuss the pros and cons of each one.

Just like in Android using Java, there are options like using SQLite, Shared Preferences, external and internal storage.


texts: What does "non commercial use" mean in terms of game assets?

texts:
I recently got an app for my iOS device called "123D Design." It is a 3D model editor. Upon creation of an account, the application tell you that "your models may not be used commercially."

What exactly does this mean? If I were to create a 3D game and sell it, does this mean I cannot use any models made with that app in my game?

This seems quite ridiculous if it's true. Can companies do that?


texts:
I'm want to control the direction my camera looks, so I'm using Euler angles, so rotating around an axis is relative to rotation around previous axis. Something like this.

I want to always rotate using the blue axes. So I'm using three separate matrices to track rotation along their respective axes.

...

glm::vec3 mulVec (glm::mat4 const&, glm::vec3&);

glm::vec3 camPos = glm::vec3(0.0f, 1.0f, 0.0f);
glm::vec3 target = glm::vec3(0.0f, 0.0f, -5.0f);
glm::vec3 camup  = glm::vec3(0.0f, 1.0f, 0.0f);

tulsi::ModelInput a1;

while (1) {

    ...

    a1.tick();  // Tracks user input.

    glm::mat4 lookat = glm::lookAt(
                    camPos,
                    mulVec(a1.yAxis * a1.xAxis, target),
                    mulVec(a1.yAxis * a1.xAxis, camup)
                    );
    ...
}

I get the desired output (rotate around x axis then y)

But when I switch the order of multiplication, I get different output (rotate around y then x axis)

glm::mat4 lookat = glm::lookAt(
                    camPos,
                    mulVec(a1.xAxis * a1.yAxis, target),
                    mulVec(a1.xAxis * a1.yAxis, camup)
                    );

So whats happening here. I'm assuming the order should not matter.


texts: How to make a sprite jump up and then return to original position android java

texts:
I am just starting out in game development and I am trying to make a simple android game using GDXLib. I want to make my sprite "ball" jump straight up in the air and then return to where it originally was. How would I do this? I have looked at multiple other answers from similar questions but none seem to work with my code. This is my code so far:

@Override
public void create () {
    batch = new SpriteBatch();
    background = new Texture("gamebackground.png");

    ball = new Texture("ball2.png");
    ball.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);

    spike1 = new Texture("spike1.png");
    spike1.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
    spike2 = new Texture("spike2.png");

}

@Override
public void render () {

    batch.begin();
    float scaleFactor = 2.0f;
    batch.draw(background, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    batch.draw(ball, 80, 145, ball.getWidth() * scaleFactor, ball.getHeight() * scaleFactor);
    batch.end();

Gdx.input.setInputProcessor(new InputAdapter () {
        @Override
           public boolean keyDown (int keycode) {
            if(keycode==Keys.UP)
            {
               ball.setHeight(ball.getHeight()+50);
            }
            return true;

    }

@Override
public void dispose () {

}

}


texts: Unity Shader Graph combine textures with transparency

texts:
I have two transparent textures. border.png and text png. They are both white images with transparency for the parts I dont want to affect. What I want to achieve in shadergraph is to:

1: Put both textures on top of each other.  2: Be able to adjust each textures color, including the textures to be white or black.

What I get is point 1, but if I try to put the color as black the texture becomes invisible (probably has something to do with transparency and how it is processed with black and white ...)

This is the best I managed to achieve with shadergraph but I still cant get the text color to be black. I have pretty much guessed my way till here so would appreciate if anyone can tell me if this is even the correct path to continue on...


texts: How can I give the player the impression of speed?

texts:
Possible Duplicate:
  Effects to make a speeding spaceship look faster

I am currently developing a racing game akin to F-Zero in that the race is held at very fast speeds. The player is therefore placed in a 3rd person view.

Graphically, I'm thinking of using motion blur and lowering the camera angle when the ship is going faster to give the player the impression of speed. This from the fact that the closer you are to the ground, the more you percieve speed.

This question has intersting answers, but don't really apply because the effect needs to be progressive and constant, not like a boost effect.

I was wondering if these techniques are viable, and if any other techniques exist?


texts: Unity3D: Sudden lighting change in a scene

texts:
Sorry if this is a duplicate question, but I have no idea what this would be considered.

Hello, I have recently been creating an FPS game, but while researching some things on the internet, the lighting changes within only one scene. I actually want to keep this change, but I am not sure what changed to make it look like this.

It unusually changed from this:

To this:

I want to keep the new one, but have this same lighting effect on a different scene, however, I am not sure what can cause this change. I have searched high and low for anything that could've changed, but I couldn't find anything. Any help is greatly appreciated. Thanks!


texts: How can I animate a portion of the textures on a model?

texts:
I have a model to which I have attached multiple textures. Both textures are currently static, but if I want to move (or slide) the texture which is on the top (in UV space), is that possible?

Maybe by moving the texture coordinates or something?


texts: How to Rotate a Circle Around Its Own Midpoint

texts:
I have rendered a circle using OBJ file. Now I want to rotate it around its own axis, like YouTube buffering icon.  How can I do that? I'm working in OpenGL.

I can change its x, y, and z rotation using a transformation matrix.


texts: Does Transform.childCount not work correctly?

texts:
This is my code:

void OnTriggerEnter(Collider collide) {
  if (collide.gameObject.transform.tag == "Laser") {
    Debug.Log ("Inside If");
    Transform resourceTransform = collide.transform;
    Transform[] tf = new Transform[resourceTransform.childCount];
    for(int i = 0; i<= resourceTransform.childCount-1; i++){
      tf[i] = resourceTransform.GetChild(i);
    }

    Debug.Log ("Child Count Before: " + resourceTransform.childCount);
    resourceTransform.transform.DetachChildren();

    Debug.Log ("Child Count After: " + resourceTransform.childCount);
    Vector3 centerOfMass = resourceRb.centerOfMass;
    Explode (tf, centerOfMass);
  }
}

Everything is working fine, except the childCount property is always zero and that screws everything else up. Here's an image of the hierarchy:

The script is on cube1 and the object has 12 or so children. So why is childCount equal to zero? Is it a problem with Unity itself?


texts: Clarification on the correct way to call SpriteRenderer

texts:
This is probably a dumb question, born from my own ignorance, but I haven't been able to find a satisfying answer yet.

In this post Savlon gives example code for using SpriteRenderer to cycle through two sprites. What exactly is the purpose of the line:

private SpriteRenderer spriteRenderer;

To me this looks like we are storing an instance of the class SpriteRenderer inside the private pointer spriteRenderer. Because in the Start loop they write

spriteRenderer = GetComponent<SpriteRenderer>();

which uses GetComponent to address properties of SpriteRenderer.

Is this correct? If so, what is the advantage to doing this over creating Savlon's code inside a subclass of the SpriteRenderer class?

Kensington


texts: I have a humanoid character with Ragdoll setup in Unity. However the box/capsule colliders on the various parts of the body don't collide with other static geometry. They do collide with the ground but not with any other static meshes. Is it possible to use them as colliders towards static meshes and what do I need to do for it to work?


texts: How to effectively gather info about how players play my HTML5 game?

texts:
I'm finishing another HTML5 game, and this time I'd like to do some spying business on the players... Mostly just basic stuff: when they are playing, for how long, what upgrades they are buying the most and so on. Now, my first idea was just to collect this information during the gameplay, and then have a Javascript function fire when they close the tab/browser, and said function would send it to my server via Socket.io. This, of course, wouldn't work, because anyone who takes a look at the code would realize it and could start sending a tonne of false info which would mess up my statistics.

Questions:

Is there a way to effectively do this?
If yes, what kind of info should I be looking for, aside from stuff I
already mentioned?


texts: Bounding Box in Monogame for mouse picking - Ray perspective

texts:
My mouse ray is screwing up precision. I don't really know how to fix it, maybe you guys can help.

problem :
(5.6mg gif)
https://www.dropbox.com/s/v0z67afso88hsd1/perspective_ray.gif

how i create the mouse ray:

 private Ray GetMouseRay(GraphicsDevice gd, ref Matrix view, ref Matrix proj)
    {
        //create source positions
        // i dont really understand why the 0 and the 1, since the near/far clip plane are totaly diferent, but from experimentation, this is a must
        Vector3 nearsource = new Vector3((float)MousePosition.Value.X, (float)MousePosition.Value.Y, 0.0f);
        Vector3 farsource = new Vector3((float)MousePosition.Value.X, (float)MousePosition.Value.Y, 1.0f);
        //Console.WriteLine("nearsource :" + nearsource.ToString() + " farsource :" + farsource.ToString());
        //Matrices needed are the view proj and this world
        //we are positioning the mouse ray in the origin(model origin, its a 3Dspace ray)
        Matrix world = Matrix.CreateTranslation(0, 0, 0);

        //unproject mouseposition in the clipping planes
        Vector3 nearPoint = gd.Viewport.Unproject(nearsource, proj, view, world);
        Vector3 farPoint = gd.Viewport.Unproject(farsource, proj, view, world);
        //Console.WriteLine("nearPoint :" + nearPoint.ToString() + " farpoint :" + farPoint.ToString());
        // Create a ray from the near clip plane to the far clip plane.
        Vector3 direction = farPoint - nearPoint;
        direction.Normalize();
        return new Ray(nearPoint, direction);
    }

How i am drawing the ray:
 CDebugShapeRenderer.AddLine(mouseRay.Position, mouseRay.Position * mouseRay.Direction * 1000, Color.Red);

how i am calculating the Obb:

Bounding Box in Monogame for mouse picking

How i am calculating the collision:
Line: 349
https://github.com/CartBlanche/MonoGame-Samples/blob/master/CollisionSample/BoundingOrientedBox.cs#L349

So how can i create a mouse ray that is accurate? or remove that perspective somehow.

Roger.

Edit:
I forgot to add the matrices used

 proj = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, this.GraphicsDevice.Viewport.AspectRatio, 1.0f, 1000.0f);
 view = Matrix.Identity;


texts: Does the projection matrix flip winding order in right handed systems?

texts:
I am using a right handed coordinate system for my world coordinates (so, positive x goes right, y is up, and z is towards you).

However, after projection and the w divide, nomalised device coordinates range from [-1,1] on x and y, with x pointing right, and y pointing up, and z ranging [0,1] (or [-1,1] in OpenGL) pointing into the screen. This is a left handed coordinate system.

As such, wouldn't the winding order you need to use swap? If my models define front faces using clockwise winding, then it would seem that you must cull clockwise faces in order for the hidden faces to be removed after projection. I don't remember having to do this in XNA (where I wasn't calculating my own matrices and just left the defaults), so have I made a mistake in my reasoning here?


texts:
I have a series of guns in my game. I use the Gun class/object like this:

(Just an example)

@interface Gun : NSObject
{
    NSString *name; // Six-shooter
    NSNumber *cost;

    NSNumber *clipPrice; // ie: 700
    NSNumber *clipCapacity; // 6
    NSNumber *ammoCapacity; // 6

    NSNumber *damage;   // 0-10

    NSNumber *accuracy; // 0-10
    NSNumber *fireRate; // 0-10
    NSNumber *range;    // 0-10
    // Not sure if I have all the stats, but this is fine for now
}

Lets say I want to have 3 upgrades per gun.  My problem is I am not sure how to do this.

Examples:

increase fire-rate
increase range
increase accuracy
silencer
double ammo capacity (ie: Drum)
double clip capacity (ie: Taped magazine)

Thus my question is, I'd like to implement an upgrade system to guns but I am not sure how to do it.

Would there be an Upgrade object which is a child to the Gun class, or would it be seperate class altogether.

Thanks for your time.


texts: When creating quick prototypes, is it better to use the language you are going to use in the end?

texts:
I have been working with SFML(C++) and Flash(AS3) and usually creating prototypes for some ideas I have.

Is it better to use the language you are going to use in the end (C++ usually) or use something simple and quick (AS3, Python, etc) to get it working and then start from scratch when you start on the main product?


texts:
I am trying to build a default color grading map into a 1024x32 RenderTarget.
Here is my shader code:

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;
    output.Position = float4(input.Position,1);

    output.TexCoord = input.TexCoord;
    return output;
}

float4 PixelShaderFunction(float2 TexCoord : TEXCOORD0) : COLOR0
{
    float temp = TexCoord.r*1024;
    float4 result = (float4)0;
    result.a = 1;
    result.r = (temp%32)/32;
    result.g = TexCoord.g;
    result.b = TexCoord.r;

    return result;
}

I'm using Catalin Zima's quad renderer to render the color grading map AND to render the contents of the texture back onto the screen. Here is the copy shader:

texture Texture;
sampler targetSampler = sampler_state
{
    Texture = (Texture);
    AddressU = CLAMP;
    AddressV = CLAMP;
    MagFilter = POINT;
    MinFilter = POINT;
    Mipfilter = POINT;
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;
    output.Position = float4(input.Position,1);

    output.TexCoord = input.TexCoord + halfPixel;
    return output;
}

float4 PixelShaderFunction(float2 TexCoord : TEXCOORD0) : COLOR0
{
    return tex2D(targetSampler, TexCoord);
}

When I take the resulting image into the Photoshop, the bottom right pixel of the texture always equals (247, 247, 255), even though top left color equals zero.

What could be the problem? I checked the quad renderer class - it is recording texture coordinates exactly 0,1 into the quad's corners. I am aligning pixels to texels with the halfPixel and using point texture sampling. Somewhy the V component of texture coordinates never reaches one. I have no clue where the problem can be. As I plan to use this texture for color grading, the accuracy is crucial.

UPDATE: So far I can only achieve the needed result with the folowing shader code:

float4 PixelShaderFunction(float2 TexCoord : TEXCOORD0) : COLOR0
{

    float temp = TexCoord.r*1024;
    float4 result = (float4)0;
    result.a = 1;
    float m = (temp%32);
    result.r = m/32+0.035f*m/32;
    result.g = TexCoord.g+0.035f*TexCoord.g;
    result.b = TexCoord.r;

    return result;
}

Which is very wierd.

UPDATE 2: Ok, I had to modulo divide over 33 instead of 32, but I still have to correct the V coordinate.

float4 PixelShaderFunction(float2 TexCoord : TEXCOORD0) : COLOR0
{
    float temp = TexCoord.r*1024;
    float4 result = (float4)0;
    result.a = 1;
    float m = (temp%33);
    result.r = m/33;//+0.035f*m/33;
    result.g = TexCoord.g+0.035f*TexCoord.g;
    result.b = TexCoord.r;

    return result;
}


texts: How to convert linear lerp to non-linear using animation curve?

texts:
I have some code I run when I fell a tree in my game. Basically it picks a random direction and then falls. However atm it linear and doesnt look very realistic. What Id want is for it to start slow, then speed up the more it's fallen.

I've been experimenting with animation curves but none of the material I can find works with my code:

public void FellTree()
{
    // pick a random point on the circle to match the up vector
    Vector2 pointOnCircle = UnityEngine.Random.insideUnitCircle * transform.localScale.y;

    // find the fall point, assuming the pivot of the object is at the bottom
    Vector3 fallPoint = transform.position +
        pointOnCircle.x * transform.right +
        pointOnCircle.y * transform.forward;

    // find the target up vector
    Vector3 updatedUpVector = Vector3.Normalize(fallPoint - transform.position);

    // Start the coroutine to tilt the up vector to the desired target
    StartCoroutine(UpdateUpVector(updatedUpVector, 1, 0.001f));
}

IEnumerator UpdateUpVector(Vector3 upVector, float speed, float threshold = 0.001f)
{
    // the target vector and up vector would get closer to each other until the threshold is hit
    while (Vector3.Distance(upVector, transform.up) > threshold)
    {
        transform.up = Vector3.Lerp(transform.up, upVector, speed * Time.deltaTime);
        yield return new WaitForEndOfFrame();
    }
}

Using animationCurve.Evaluate(float t) in the lerp should be what I need to do, but not working. How can I add an animation curve to my lerp?


texts: How do I stop clicks on a button from also triggering my gameplay scripts?

texts:
My character jumps when I press the right side of screen. The pause button is alsp in the top right corner. So when I press that button, the right side script always triggers and I don't want that to happen.

Here the script :
 if (Input.GetMouseButtonDown(0))
            {
                float xPosition = Input.mousePosition.x;

                if (xPosition > Screen.width / 2 && isGrounded && !isJump)
                {
                    // mouse is on the right part of the screen, shoot right

                    rb2d.velocity = new Vector3(0, jumpForce, 0);

                    isJump = true;

                    JumpSoundSfx();
                }
            }

            if (Input.GetMouseButton(0))
            {
                float xPosition = Input.mousePosition.x;

                if (xPosition < Screen.width / 2 && !isJump)
                {
                    // mouse is on the left part of the screen, so shoot to the left

                    crouch.SetActive(true);

                    stand.SetActive(false);
                }
            }
```


texts: Data Structure (or algorithm) for fast distance-based entity lookups

texts:
For example, your game has 100 enemies (on different teams) running around and their AI wants to inspect the nearby entities to see which it should attack.  What is a fast way to organize those entities so that each enemy does not have to calculate the distance between itself and all other entities?

In short, what is a fast way for an AI entity to answer the question "Who is near me?"


texts:
Im working on expanding my camera class, but having trouble defining camera/view space in the manner of this diagram:

What Im trying to achieve is to define the camera as a true object much like a person.
Blue represents world space that we are used to especially in terms of positioning objects in a world. Furthermore, to put it in a real world perspective, world space is no different than the real world constants of North, South, East, West and the yaw of the camera currently corresponds to these directions.

Red is what the end goal is that I'm trying to solve. In relation to world coordinates, the yaw of the camera has a value of 45 degrees. In relations to the real world the camera is pointing Northeast.

Issues with the current state of the camera to the world:
If an object was placed at -1, 1 (upperleft), the camera will see the object at an angle 315 degrees arbitrarily to the orientation of the camera.

In the end, how do I localize the degrees for the yaw in relation to the camera as show in red?


texts: How to determine angle of incidence, resulting position, and resulting velocity for a point with position and velocity appearing within a rectangle?

texts:
I have a rectangle positioned on a 2D Cartesian coordinate system, and its minimum x and minimum y are represented as a coordinate pair (xrect, yrect). I also know the rectangle's width w and height h.

I also have an x,y-coordinate pair for a point that intersects the rectangle (x1, y1). This point may appear anywhere inside the rectangle or touching one of its sides. I am also given the point's velocity vector components vx and vy, and I know that the point has been traveling in a straight line at constant speed.

How can I determine:

which side of the rectangle the point contacted first?
what the (x,y)-coordinate was at the point of contact?
what the angle of incidence would have been had the point been deflected at the coordinate of first contact?
what the resulting vector components would be for the point's velocity?


texts:
I'm new to game server develop.
I'm developing a card game server.
How could I make nodejs server wait for few seconds then push data to client after an event fired ?
Example : in poker game, one player have about 20 seconds to make a move, after 20 seconds server will auto fold and then push a message to another player. How could I make server wait for 20 seconds and then do next action ?


texts: Xna/Monogame How to get an object to decelerate

texts:
So I've written a statement for releasing the ball based on a certain speed and for it to move in the direction of the mouse, like so:

            MouseX = stateOfTheMouse.X;
            MouseY = stateOfTheMouse.Y;
            difference = Vector2.Subtract(position, new Vector2(MouseX, MouseY));
            direction = Vector2.Normalize(difference);
            velocity.X -= ((float)(usedSpeed / 2));
            velocity.Y -= ((float)(usedSpeed / 2));

Then in my updateI call this

            position += velocity * direction;

I assign usedSpeed as an integer with the press of a NumPad key 1-5 each on reflects the speed amount hence NumPad1 = speed of 1, etc.

Therefore, how would I make the velocity decelerate and slow down to a complete stop?


texts: How to write a unity script to observe the position of a game object (during scene creation)

texts:
I want to write a simple Unity script to be notified when a game object is moved, during the creation of the scene.

More precisly, I want to write a Unity script that can recognize when the user click on the blue, or red, or green axis of the selected game object, and then when the user release the click.

If this is not possible, I want to write a script that can recognize when the selected game object position changes.

Are there existing c# listeners that can be used from within Unity to achieve this?


texts: More efficient way to implement Line of sight on a 2d grid with ray casting?

texts:
Consider a 2d grid of tiles, and an approximated sphere of coordinates - centered on the player - that represents line of sight. The goal is to block the line of sight beyond obstacles (ie walls).

It's relatively simple to determine if an individual cell in the sphere of sight is visible: cast a ray from the player to the target cell, using Bresenham's - if one of the overlapping cells between the player and the target is an obstacle, the target cell is not visible.

Now, my first thought was to iterate through all grid cells in the line of sight - but this seems inefficient to me. For example, if the player is standing next to a wall, and you determine that the cell beyond the wall isn't visible, you can determine all cells on the ray after that won't be visible.

Also considered casting a ray to each cell along the perimeter of the sphere of sight, and iterating each cell along each ray - but then I'd be processing some cells more than once.

Is there a more efficient way to do this?

While iterating ~50 cells per turn is a relatively lightweight calculation, I'm going for speed - the goal is to be able to cycle a few turns per second on auto-play. So, the more efficient I can make this, the better.


texts: Drawing over objects occasionally leaving relics behind

texts:
I'm drawing a large number of bouncing shapes similar to an old 1990s screensaver.  I'm just doing this to study (but not hopework)  For some reason my object clearing (simply blitting a black shape over the prior position) is missing parts of the shapes and leaving fragments behind.  I could just black the whole screen between each draw cycle and avoid this, but I want to draw over the individual shapes.  Why is this periodically missing parts of the shapes?

    from pygame.locals import *
    import pygame as pg
    from random import randint as ri
    import time

    pg.init()
    display_size = (800, 600)
    canvas = pg.display.set_mode(display_size)

    canvobj = []
    running = True

    class circle:
        def __init__(self, xpos, ypos, rad):
            self.type = 'circle'
            self.color = (ri(1,255),ri(1,255),ri(1,255))
            self.posit = (xpos, ypos)
            self.radius = rad
            self.speed = (ri(-5,5),ri(-5,5))
            self.bounce = 0
        def topygame(self):
            return (self.color, self.posit, self.radius)
        def clearit(self):
            return ((0, 0, 0), self.posit, self.radius)
        def moveit(self):
            self.posit = (self.posit[0]+self.speed[0], self.posit[1]+self.speed[1])
            return (self.color, self.posit, self.radius)

    class rect:
        def __init__(self, x, y, width, height):
            self.type = 'rect'
            self.color = (ri(1,255),ri(1,255),ri(1,255))
            self.posit = (x, y, width, height)
            self.speed = (ri(-5,5),ri(-5,5))
            self.bounce = 0
        def topygame(self):
            return (self.color, self.posit)
        def clearit(self):
            return ((0, 0, 0), self.posit)
        def moveit(self):
            self.posit = (self.posit[0]+self.speed[0], self.posit[1]+self.speed[1], self.posit[2], self.posit[3])
            return (self.color, self.posit)

     def addobjs(num, iterable):
        for x in range(num):
            iterable.append(circle(ri(1,800),ri(1,600), ri(1,50)))
        for x in range(num):
            iterable.append(rect(ri(1,800),ri(1,600), ri(1,100), ri(1,100)))

    def clearobjs(obj):
        if obj.speed[0]==0 and obj.speed[1]==0:
            obj.speed=(ri(10,20),ri(10,20))
            obj.bounce=0
        if obj.posit[1] < -100 or obj.posit[1] > 650:
            obj.bounce += 1
            obj.speed = (obj.speed[0], -obj.speed[1])
        if obj.posit[0] < -100 or obj.posit[0] > 850:
            obj.bounce += 1
            obj.speed = (-obj.speed[0], obj.speed[1])
        if x.type == 'circle':
            pg.draw.circle(canvas, *(x.clearit()))
        if x.type == 'rect':
            pg.draw.rect(canvas, *(x.clearit()))
        if x.bounce > 4:
            canvobj.remove(obj)

    def moveobjs(obj):
        if x.type == 'circle':
            pg.draw.circle(canvas, *(x.moveit()))
        if x.type == 'rect':
            pg.draw.rect(canvas, *(x.moveit()))

    starttime = time.time()

    while running:
        pg.display.flip()

        if time.time()-starttime > 1:
             starttime = time.time()
             addobjs(ri(1,3), canvobj)

        for x in canvobj:
             clearobjs(x)

        for x in canvobj:
             moveobjs(x)

        for event in pg.event.get():
            if event.type == QUIT:
                running = False
                break
            else:
                pass

        pg.time.delay(30)

    pg.quit()


texts: How can I integrate IK into a hierarchical editing environment?

texts:
I have a situation where I'm trying to push the output of an IK solver back into a user editable joint hierarchy (which stores components as it's primary source), and I'm not sure how to go about it.

My IK solver returns three world space transforms representing the position and orientation of a chain of joints (0,1,2).

A:
I need to turn this into a hierarchy so that transform 2 is local to transform 1, and transform 1 is local to transform 0. Now I have local transforms for each joint.

B:
Further: I need to decompose each joint's new local matrix into source Translation, Rotation and Scale.

Can anyone give me some tips for each step? I have some ideas, but I'm worried that to do B I need to particularly careful with A.

Edit:

For example if I get my world matrices like this:

M4 world_mats[3] = IK_solve( ikparams );

And then convert them to local like this:

M4 local_mats[3] = GenerateLocalChain( world_mats );

And then extract components:

Scale     s[];
Rotation  r[];
Translate t[];

foreach ( matrix in local_mats )
    Decompose( matrix, s, r, t );

How can I implement the Decompose() function to match matrices created inGenerateLocalChain()?


texts: How can I create a height-based volumetric fog?

texts:
Recently, I have been looking for techniques to make volumetric fog on some Y position level of the game world. But all I have found are some fog made by using particle system or built-in engine fog that doesn't really fit what I'm looking for.

In my case, I need a fog that is both efficient and dense. It should be all over the gameworld, but obviously, for performance reasons, it can be rendered only as a part of a camera or shader and look like it's moving though it's just an illusion. I could set a particle system if it's the best choice, attach it to the camera and make it move.

So the main question still stays - how can I implement a volumetric fog that is both dense and performs efficiently?

As a particular engine I'm using, it's Unity.

As an example what I mean, here is the link to a game with the effect I'm looking for: Astromike


texts: Predicting the route a rigid body will take when force is applied

texts:
I'm learning 3D game development with some kind of mini golf game.

It is working well so far: I have a sphere, and I am using AddForce on its RigidBody to launch it in the desired direction.

One feature I'd like to add is to show a preview line that predicts the trajectory of the ball. Like telling the player that if he uses this direction and this force, the ball is going to follow this route, collide here, bounce, and end up there etc.

I know how to use a line renderer alright, but I don't know how to calculate the array of points from which to draw the line.

It has to be updated in realtime, and the player can quickly change the potential direction and force at any time - it has to consider that there are various objects with different bounciness/friction etc.

That seems like a lot of work. The only thing that occurs to me is to use dummy invisible balls that will be constantly firing using the potential direction/force and then recording their route, but I'd need to figure out some way to make them 'move faster' so I can get the array of points instantly.

What would be my best approach for this?


texts: Is there any way to enable the HiDef graphics profile property on a Silverlight 5 3d Web App?

texts: I have an XNA Windows Game that uses the HiDef profile to load complex fbx and obj files. Trying to move it over to a Silverlight 3d Web App, Silverlight seems to only want to use the Reach profile, and I get an error that the Reach profile does not support a sufficient number of primitive draws per call. Is there any way to change to HiDef in Silverlight 5? It is not in the project properties and attempting to change it in mainpage.xaml.cs only gives me the option of setting it to Reach.


texts: Scaling issues with Open GL viewport / scissor box (Trying to draw outside of viewport)

texts:
In my game I am currently scaling the viewport so it retains the ratio of my development device like so:

width = (int) Math.min(deviceWidth, deviceHeight * 1.702127659574468); //1.702127659574468 is the ratio of my development device
height = (int) Math.min(deviceHeight, deviceWidth / 1.702127659574468);

GLES20.glViewport(offsetX, offsetY, width, height);

//Set the ratio of the display
ratio = (float) width / height;

Matrix.orthoM(mProjMatrix, 0, -ratio, ratio, -1, 1, 3, 7);

This then displays the viewport with black bars at the top and bottom of the screen while retaining the correct ratio.  Therefore everything appears nice and even.

I want, however to now draw outside of the viewport in order to make things look better on devices that letterbox.

I'm setting my sprite's width and height like so:

sprite.width = (int) (width*0.078125);
sprite.height = (int) (height*0.1329787234042553);

This results in a 'square' quad (on my dev device the width is 2560 and the height is 1504, so the results in this case are:

Width = 200;
Height = 200;

On another device, this also therefore results in a perfectly square sprite.  So far, all is good and all works great.

Scissoring

I tried, now to set the vieweport to the full size of the device's screen and create a 'scissor box' using GLScissor like so:

width = (int) Math.min(deviceWidth, deviceHeight * 1.702127659574468); //1.702127659574468 is the ratio of my development device
height = (int) Math.min(deviceHeight, deviceWidth / 1.702127659574468);

GLES20.glViewport(0, 0, deviceWidth, deviceHeight);

//Set the ratio of the display
ratio = (float) width / height;

Matrix.orthoM(mProjMatrix, 0, -ratio, ratio, -1, 1, 3, 7);

And then drawing like so: (Psuedo)

DrawOutsideScissorBox();

GLES20.glScissor(offsetX, offsetY, width, height);  //Using the scaled width and height
GLES20.glEnable(GL_SCISSOR_TEST);

DrawOtherStuff();

GLES20.glDisable(GL_SCISSOR_TEST);

This does work (in so far as I can now draw outside of the 'game area'). I'm sizing my objects using the Scaled width and height (and not the device's actual width and height just as I was before) and they are 'square' as far as their pixels go (so, if I log the width and height  it would be for example 20 x 20, or 40 x 40), but they are still appearing 'stretched' vertically.

Why is this?  How can I make sure that the sprite's that are displayed are in proportion as they were when I was scaling my viewport?  What am I missing?  Or am I wrong in my thinking?  How can I draw in the 'black bars' left by letterboxing?!


texts:
My project has upwards of 3000 2D objects but not all of them collide with each other. Between each object that can collide, a CollisionPair is created and stored inside a flattened array.

Currently, a MaxObjects is defined for accessing the flattened array. Unfortunately, when iterating over this array for collision checks, I get a lot of overhead from the for loop and null checks.

Is there a more efficient way, both in memory and performance, to store and access CollisionPairs?

Note: Many of these objects are axis-aligned boxes - how does Minecraft handle these collisions?


texts:
I would like to create something very simple. A browser game, where user can waste its energy and ability points. Unlike other games here there won't be no levels. So energy and ability points restore with the time.

How can I do that in the most efficient way?
For example, i have 100 energy points, one point restores every 2 min.

I was thinking about cron-jobs, but that will be not so efficient.

Thank you in advance!


texts: To what extent it is legal to declare support of third party commercial products' assets?

texts:
Is it legal to say that MyGame supports other (specific) games' textures, sounds and models?

I'd like to get involved into an open source game project and implement support for Quake's weapon models (for example), but the owners of the project don't know about the legal aspect of it, so I'm asking here.


texts:
I want to make a game which would require a 3D map editor. Of course, I would like to avoid creating such an editor. My idea is now to use modeling tools (3DS Max, Maya, Blender) to create the map, and to give game specific objects specified names. This way I'd just need to write an COLLADA -> native map format converter. But I'm not sure if this is possible the way I imagine it, that's why I'd like to hear your thoughts on the matter.

Are modeling tools suitable to create big open world maps?
Can this "naming convention"-idea for game specific objects work?
Are the modeling tools able to export a scene in chunks / in a way that occlusion culling and collision detection can be properly done? If not: Is there a way to build a suitable data structure from the exported data?


texts: How can I make text-based combat more engaging?

texts:
I'm making a text based adventure in Java, and currently I have a fairly limited combat system where you can do one of 3 things:

attack with your sword
attack with magic(if its unlocked)
drink a health potion

This system works but is fairly boring and uninspired. I want to make the combat enjoyable yet given the limitations of a text based game, but I don't know how to accomplish this. If anyone knows how to make this system more engaging/fun,  it would be greatly appreciated.


texts: How to give a Jerk Effect when the player is moving left of right

texts:
float amttomove = Input.GetAxis("Horizontal") * playerspeed * Time.deltaTime;
            transform.Translate (Vector3.right * amttomove);

Currently, I have above script in Update function to move the object to left or right.But this movement is way smoother.To give it more realistic feel, I want it to have a slight jerk when it stops moving to left or right and not just stop right there and then.

What exactly needs to be done to have that effect?


texts:
I've read somewhere that a Quaternion in Unity ranges between [-1,1] values. I mean the individual XYZW values. Ex: new Quaternion(.1f,.2f,-.3f,-.4f)

Is this true?

More clearly: I know they take float values therefore the theoretical limit is floating point value limitations, I'm asking the real rotation results. For instance when I look up Quaternion values while rotating a GameObject it is usually in the [-1,1] limits. But I'm not sure if that's my case or not.


texts: Is there a good way ECS for creating variants of a behaviour like in Java interfaces?

texts:
In Java, there are interfaces - I'm not clear on the details (I don't use Java) but from what I've learned, they seem to be "classes for classes": a way to effectively make individual classes "instances" of one overarching class. For example, a "Cup" interface could be implemented by a "Mug" class, a "Glass" class, a "Goblet" class etc. As long as they have the same I/O methods such as fill(), empty() or drink(), they can be used interchangeably.
In languages with duck typing, interfaces are not needed - the language allows for classes to be used interchangeably as long as no invalid properties of methods are referenced. This is another valid was of going about things in OOP. This is how I usually go about things.
My question: how can I create varied behaviour in an ECS if components are data-only? I like to think in terms of first-class functions, but that seems to be taboo since components are not supposed to hold behaviour.

Have a massive switch or if/else chain in my System:
For example, if I have an AI component with several different behaviours, I could use an integer to define which type of AI to use for that particular entity. It seems a bit convoluted and inelegant.

Have a separate Component and matching System for each behaviour:
This would be neater in each individual System but as a whole, the program would be a mess. This wouldn't work because of the large amounts of variation such as hundreds of different guns in a shooter game.

Use a flyweight-like data structure independent of the Component:
This would mean storing all of the different behaviours elsewhere, and storing a key that a System can use to access the behaviour. This is basically a fancy version of the switch option above, but it seems neater as there wouldn't be a massive dump of code in the System.

Creating a complex way of encoding a description of the desired behaviour which the System can interpret:
This seems to be the most overkill of the lot. Unless I have to, or there are significant advantages, I'm trying to stay away from this.

If there's no other way, I'll just adopt the methodology of first-class functions as I usually do and just ignore any guidelines about ECS I've heard, just for this one case. The problem is, it probably won't just be one case in the future.
Have I missed any other good options? Is there an industry standard or recommendation? If not, what considerations should I make about which option to choose?


texts: Does putting non power of 2 sprites in an atlas makes them a power of 2?

texts: A lot of my UI sprites are not power of 2 so Unity might not compress them. However I put them inside a sprite atlas which is 1024x1024. So are they now considered a power of 2 and will Unity compress them? Or should I still convert them manually one by one?


texts:
I'm trying to render line list using indices of triangles as follow

float *vertices = static_cast<float *>(vertexBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD));

for (int i = 0; i < out.numberofpoints; i++)
{
    vertices[(i*3)] = out.pointlist[(i*3)];
    vertices[(i*3)+1] = out.pointlist[(3*i)+1];
    vertices[(i*3) + 2] = out.pointlist[(3*i)+2];

}

vertexBuffer->unlock();

uint16_t *indices = static_cast<uint16_t *>(indexBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD));

int  l, t;
int numTriangles = out.numberoftrifaces*3*sizeof(uint16_t);
for (l = 0, t = 0; t<numTriangles; t += 3) {
    // Each vertex has to be listed twice
    indices[l] = out.trifacelist[t];      l++;
    indices[l] = out.trifacelist[t + 1];    l++;
    indices[l] = out.trifacelist[t + 2];    l++;
    indices[l] = out.trifacelist[t + 2];    l++;
    indices[l] = out.trifacelist[t + 1];    l++;
    indices[l] = out.trifacelist[t];      l++;
}

indexBuffer->unlock();

The problem that ogre renders broken triangles and it's completely wrong. I'm not doing anything wrong regarding rendering the lines that the triangles are composed

I'm using ogre 1.9


texts:
I'm making a racing game in python and I kind of wrote myself into a corner.  This for loop:

 for i in objects:
     if i.name == "road":
         if i.y == 0:
             road = Road(road_x,-20,road_width,20)
             objects.append(road)

is how I generate new road tiles as the old ones move down the screen.  When a block spawns 20 pixels offscreen, it falls down until its top left corner hits 0 and then a new block spawns above it.  if you run this code: https://github.com/hailfire006/economy_game/blob/master/racing%20game
you can see that it works great, right up until the player accelerates by pressing up or "w", at which point the road stops spawning.

What I think is happening is that the road is skipping the 0 mark and that's why no new road is spawning, but increasing the acceleration in the code doesn't seem to mess it up, it's only when it's changed dynamically in game.  Can soneone explain what's happening here because nothing I try is working and I've been stuck on this for days...


texts: Why is the ownership fixed when synching objects?

texts:
I'm creating a billiard game where one white ball will be controlled by two online players.

I have set my object photonview to ownership takeover.

When a player shoots the ball in one client, it is synced on other client.
Now when I update the ball on the other client, the other client is not updated.

Why is the ownership fixed?

Only one client is sending the updates to the other client, and not vice versa.

What should I do here?


texts:
(Sorry about the bad title, it's the best I could come up with)

I've been planning a gladiator manager game for a while now. Something similar to Blood Bowl (or Football Manager, only with fighting rather than kicking a ball), only with a much larger focus on the actual managerial aspects of running a team. I'm still fairly new to game development, and have only created games with a very narrow focus (i.e. simple first person shooters), so taking on a project with a larger scope is very interesting, but also problematic since I really don't have a grip on how exactly to make the damn thing work.

Basically my two major hurdles are the interface and database. Obviously the interface is incredibly important since the player will spend most of his/her time doing managerial tasks. The game will be team-based, with various leagues in which those teams fight in, so it all relies on a database. I have never done any real work with databases, so this in particular has me stumped.

At this point, my idea is to use XNA in a WPF application, with an XML database. This just seems like a combination that would work well together, and as I have a C#/XNA background, I wouldn't need to learn a new language or graphics framework to work in.

Does that seem like a sensible combination, and if not, why? I have never done anything with WPF, so all of my information on it's uses comes from Google, and that may or may not be a good thing. Would XML be a smart choice? There will likely be a fairly low (think 20-30) number of teams, all of which will have a dozen or so fighters, so it's not a monstrously large set of data.

Thanks in advance, I know I didn't write the most intelligent post ever, but I had to get my ramblings out somehow. ;)


texts: Zooming versus panning in a 3D FPS fly camera

texts:
Imagine you have a strategy game, and it's rendered in openGL, in 3D. You have an overview of the map and the camera is currently looking at the direction of the ground at some angle (but is not limited to this angle). Like the standard view in the CIV games.

You now do one of the two actions:

A) You move the camera along its line of sight towards the ground (forward).
B) You scale the whole scene by a factor >1.

If I understand these actions correctly, both situations should have exactly the same visual result, zooming in. The player shouldn't really be able to tell which of the two has happened.

My questions is, firstly, am I right to assume this?

If no, what is the observable difference?
If yes, which mechanic should be used?

Note that I am thinking about this in regards of use in a level editor.

Thinking about it a little further, the difference should become visible if player moves the camera after the action - the camera in the scaled version would move at an apparently slower speed, right?

Would there be any other side effects? Which behavior would be expected by the player/user?

If you assume an FPS fly camera (one that yaws and tilts, but does not roll), is there any scenario where the scaling method would be preferred?


texts: Getting unit to complete rotation before moving?

texts:
I've been trying to get a unit in my project to move in a fashion similiar to that of modern MOBA games.

However, I am faced with the issue of the unit moving before the rotation is completed and the unit moving along the Y-axis.

I have tried using a cooroutine to allow the rotation to completed first, but to no avail.
Any help would be greatly appreciated.

using UnityEngine;
using System.Collections;

public class Move : MonoBehaviour {

    public float smooth;
    public float speed;

    private float z;
    private float x;
    private Vector3 targetPosition;

    // Use this for initialization
    void Start () {

    }

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

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {

            speed = 1;
            smooth = 20;

            RaycastHit hit;

            //var playerPlane = new Plane(Vector3.up, transform.position);
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            //double hitdist = 0.0;

            if (Physics.Raycast(ray, out hit))
            {
                targetPosition = hit.point;

                x = hit.point.x;
                z = hit.point.z;
                //var targetRotation = Quaternion.LookRotation(targetPoint    - transform.position);
                //transform.rotation = targetRotation;
            }
        }

        StartCoroutine(Turn(x,z));

        //transform.position = Vector3.RotateTowards(transform.position, targetPosition, speed*Time.deltaTime, 0.0f);
        transform.position = Vector3.MoveTowards(transform.position, targetPosition, Time.deltaTime * smooth);
    }

    IEnumerator Turn(float _x, float _z)
    {
        Vector3 turn = new Vector3 (_x, 0, _z);
        transform.Rotate(turn, speed);
        yield return null;
    }
}


texts: How do I debug two android devices simultaneously in Eclipse?

texts:
I have a multiplayer game which should be tested on two devices at the same time, if possible, with debugging.

Can eclipse do this?  If so, how?