texts: Fragment shader coordinates: Displacing pixels and texCoord problems

texts:
I'm trying to create a shader that creates a displacement on an object, slicing horizontally the sprite.

These is an example of the atlas I'm using and the effect I'm trying to achieve:

I tried to achieve this creating a fragment shader, that would read the Y coordinate of the texcoord, and depending on the height, displace it horizontally.

But I found two main problems:

1) If my atlas had more rows of sprites, I can't really tell at what height I'm drawing the sprite in the fragment shader. Since values of texcoord go from 0 to 1 relative to the atlas being use, the more rows I have, the smaller values should I choose to create the horizontal cut. Is there any way to know the position inside the drawn?

2) The problem is similar to the previous point. When displacing the pixels horizontally, if the displacement is too big, I end up sampling the sprite next to the one being rendered. The idea is for it to loop back the the begining of the sprite. If I had the width of the sprite, I could tell how to do so, but using texcoord alone is just not posible. How can I do this?


texts: Is it worth it, to try and prevent cheaters?

texts:
Perhaps one of the biggest issues that plague FPS-games are cheaters.

If you use a server-authoritative model, you will prevent some level of cheating. But why do this if people can still aimbot?


texts: Unity C# order of execution for multiple start functions?

texts:
I have a scene in my project where a lot objects need to access different objects to share data with.

Some objects have functions that need to be executed only once during the void Start function. These call a predefined function in a different class.

So now you know a bit what is happening I am experiencing an issue. During the Start function they call a method that only works when the Start function of that class has already been progressed.

Example:
Class A has certain values to calculate and set. Once this has happened function A will work.
Class B, C and D have a function B that is called at the last line of the Start function. Function B does some magic and then calls function A from Class A. The problem here is however that the void Start from class B, C and D executes before the Start from Class A. This results in not all values being set properly. I only discovered this through debugging and tracking timings of when each function was executed.

Is it possible for Class A to make the void Start execute before the void Start from the other classes? For example is the order of execution based on alphabetical values or something awake (per class) -> start (class A) -> start (class B) -> update (per class)? So that start A would happen before start B with a simple change of class name?

If I put this code in the awake call I will have the same issues since the awake in other classes might happen before or after the current awake will be executed.

To clarify, they all happen at the same time, but line 12 gets executed before line 13. Which is fairly logical, but how do you know which Start gets executed before the other Start? Or am I simply completely wrong?

I do realize that this might be a confusing read so please don't hesitate to ask questions so that I can explain my issue better.


texts:
I'm currently trying to render terrain in an OpenGL application I'm making (using OpenTK in C#). Something really odd is happening and I'm not sure why.

Here is the code I use to load my terrain from a heightmap (Yes I know setting up indices the way I am at the moment is silly, but it's just so I can use the mesh renderer class I made). I render the terrain using Triangle Strips.

    public Terrain(string heightmapFile)
    {
        if (!File.Exists(heightmapFile)) throw new FileNotFoundException("File not found at path '" + heightmapFile + "'");

        using (var bitmap = new Bitmap(heightmapFile))
        {
            var vertices = new List<Vertex>();
            var indices = new List<int>();

            int index = 0;

            for (int y = 0; y < bitmap.Height - 1; y++)
            {
                for (int x = 0; x < bitmap.Width; x++)
                {
                    float z = bitmap.GetPixel(x, y).R / 127.5f - 1.0f;
                    float z1 = bitmap.GetPixel(x, y + 1).R / 127.5f - 1.0f;

                    vertices.Add(new Vertex(new Vector3(x, y, z)));
                    vertices.Add(new Vertex(new Vector3(x, y + 1, z1)));

                    indices.Add(index);

                    index++;
                }
            }

            AddVertices(vertices.ToArray(), indices.ToArray());
        }
    }

Here is the result:

What's going on here? What am I doing wrong?


texts:
glVertexAttribPointer(index,  size,  type, normalized, stride,  pointer);

If I use type=GL_UNSIGNED_BYTE and normalized=GL_TRUE

how is it normalized?
would the data be divided by 256 for normalization? or?
This would mean there is no way to have a normalized value of '1.0f'..


texts: Game Object Factory: Fixing Memory Leaks

texts:
Dear all, this is going to be tough: I have created a game object factory that generates objects of my wish. However, I get memory leaks which I can not fix.

Memory leaks are generated by return new Object(); in the bottom part of the code sample.

static BaseObject * CreateObjectFunc()
{
    return new Object();
}

How and where to delete the pointers? I wrote bool ReleaseClassType(). Despite the factory works well, ReleaseClassType() does not fix memory leaks.

bool ReleaseClassTypes()
{
    unsigned int nRecordCount = vFactories.size();
    for (unsigned int nLoop = 0; nLoop < nRecordCount; nLoop++ )
    {
        // if the object exists in the container and is valid, then render it
        if( vFactories[nLoop] != NULL)
            delete vFactories[nLoop]();
    }
    return true;
}

Before taking a look at the code below, let me help you in that my CGameObjectFactory creates pointers to functions creating particular object type. The pointers are stored within vFactories vector container.

I have chosen this way because I parse an object map file. I have object type IDs (integer values) which I need to translate them into real objects. Because I have over 100 different object data types, I wished to avoid continuously traversing very long Switch() statement.

Therefore, to create an object, I call vFactoriesnEnumObjectTypeID via CGameObjectFactory::create() to call stored function that generates desired object.

The position of the appropriate function in the vFactories is identical to the nObjectTypeID, so I can use indexing to access the function.

So the question remains, how to proceed with garbage collection and avoid reported memory leaks?

#ifndef GAMEOBJECTFACTORY_H_UNIPIXELS
#define GAMEOBJECTFACTORY_H_UNIPIXELS

//#include "MemoryManager.h"
#include <vector>

template <typename BaseObject>
class CGameObjectFactory
{
public:
    // cleanup and release registered object data types
    bool ReleaseClassTypes()
    {
        unsigned int nRecordCount = vFactories.size();
        for (unsigned int nLoop = 0; nLoop < nRecordCount; nLoop++ )
        {
            // if the object exists in the container and is valid, then render it
            if( vFactories[nLoop] != NULL)
                delete vFactories[nLoop]();
        }
        return true;
    }

    // register new object data type
    template <typename Object>
    bool RegisterClassType(unsigned int nObjectIDParam )
    {
        if(vFactories.size() < nObjectIDParam) vFactories.resize(nObjectIDParam);

        vFactories[nObjectIDParam] = &CreateObjectFunc<Object>;
        return true;
    }

    // create new object by calling the pointer to the appropriate type function
    BaseObject* create(unsigned int nObjectIDParam) const
    {
        return vFactories[nObjectIDParam]();
    }

    // resize the vector array containing pointers to function calls
    bool resize(unsigned int nSizeParam)
    {
        vFactories.resize(nSizeParam);
        return true;
    }

private:
    //DECLARE_HEAP;

    template <typename Object>
    static BaseObject * CreateObjectFunc()
    {
        return new Object();
    }

    typedef BaseObject*(*factory)();
    std::vector<factory> vFactories;
};

//DEFINE_HEAP_T(CGameObjectFactory, "Game Object Factory");

#endif // GAMEOBJECTFACTORY_H_UNIPIXELS


texts: How to make collisions occur between objects using the same script?

texts:
Well what I’m trying to do is have cars travelling on the road. The cars have a trigger at the front and a hitbox at the back of the cars. What I want to happen is when the trigger hits the hitbox it compares the Variables for speed of the two cars in the collision, i.e. the make the car at the back slow down or equal the speed of the car in the front. However, what I am having trouble with is referencing the speed of both cars and comparing them. This is due to them both being prefabs using the same script. Which I’m learning means that I’m just referencing the same script and not the actual values of the individual car. But how could I get round this? Is it possible to have collisions occurring between objects using the same script?

    private void OnTriggerStay2D(Collider2D collision)
    {
        Debug.Log("TriggerStay");

        GameObject collidedParent = collision.gameObject.transform.parent.gameObject; // get parent transform and then its gameobject
        Traffic Col_speed = collidedParent.GetComponent<Traffic>();

        if (speed > Col_speed.speed)
        {
            Accelerate = false;
            ApplyBreak = true;
        }
        else if (speed < Col_speed.speed)
        {
            Accelerate = false;
            ApplyBreak = false;
            speed = Col_speed.speed;
        }

        if (transform.position.y > collision.transform.position.y)
        {
            turn = turn + 1;
            Debug.Log(this.gameObject.name + "someMessage");

        }
        if (transform.position.y < collision.transform.position.y)
        {
            turn = turn - 1;
            Col_speed.turn = 0;
            Debug.Log(this.gameObject.name + "someMessage");

        }
    }
    private void OnTriggerExit2D(Collider2D collision)
    {
        turn = 0;
        Accelerate = true;
        ApplyBreak = false;
    }

}


texts: How to manage time in a two player game?

texts:
I'm making my first online board game. After the two players accept to play with each other, I want to show a get ready message for 3 seconds, then both start playing together, each has 30 seconds to do an action in his turn.

But I don't know the process.

Should I pass to clients the time the game will start?
Should I check from server whether a player's 30 seconds is over? There may be
a slight difference in server and client time, and I end a game from
server while client still has 27 seconds for example.

What are the steps to have an accurate multiplayer game. Thanks.


texts: How to add several GameComponents of the same type?

texts:
in order to load 3D-meshes to my project i created a BasicModel class. I made it a DrawableGameComponent so I can override methods like Draw & LoadContent. Plus I have access to the GraphicsDevice etc.

Now I realized that if I try to add several instances of the same GameComponent I get an exception that says that it is not allowed to do this.

Was it even a good thing to do, making the Class a GameComponent?
Is there a way to somehow differ single Components, so that I can add several copies of it to the game?

Thanks in advance.


texts:
I am trying to make game objects, like a coin or ammo clip, gravitate towards the player when they are within a set radius. I have seen this implemented in quite a few old school 90's games; when the player walks near anything, I want it to move to the player for collection. I can already handle the collection.

This is what I have, so far:

using UnityEngine;
using System.Collections;

public class MoveCoinsTowardsPlayer : MonoBehaviour
{
    public Transform target;
    public float speed;

    void Update()
    {
        float step = speed * Time.deltaTime;
        transform.position = Vector3.MoveTowards(transform.position, target.position, step);
    }
}

How do I make game objects move towards the player, when the player is within a set range?


texts: I was wondering if it is possible to render my scene onto a depth texture then using that texture for depth testing in another pass. I have an idea to that in shaders, but is that possible hardware-side?


texts: How can I produce heatmaps based off of player reported data?

texts:
For a really good example of what I'm talking about, see how the developer of Replica Island does it based off of Player deaths: http://www.youtube.com/watch?v=7-62tRHLcHk&feature=player_embedded#t=37m

How can I easily produce heatmaps based off of data that I pass in?

Halo 3 is another good example of heatmap usage in game data reporting: http://www.bungie.net/Online/Heatmaps.aspx


texts:
As part of my game, I thought it would be fun to make a hidden level that pays tribute to Mario Bros (one of the earliest games I ever played). It would be themed in that way with 8-bit graphics and question mark blocks and completing the level would say "Thank you but the princess is in another castle" or such.

For the sound track, I'm thinking of just overlaying the standard mario theme music by playing it on a virtual keyboard using a different instrument/timing or something.

My question is, am I legally safe? I'm not using anyone else's actual music, I'm just playing the same tune in a different way myself. Do I have to get licensing for this?


texts: Creating a voxel chunk with a VBO - How to translate the coordinates of each block and add it to the VBO chunk?

texts:
I'm trying to make a voxel engine similar to minecraft as a little learning experience and a way to learn some opengl.
I have created a chunk class and I want to put all of the vertices for the whole chunk into a single VBO. I was previously only putting each block into a vbo and making a call to render each block.
Anyways, I am a bit confused about how I can translate the coordinates of each block in the chunk when I'm putting all vertices into one vbo.

This is what I have at the moment.

public void putVertices(float tx, float ty, float tz) {
    float l_length = 1.0f;
    float l_height = 1.0f;
    float l_width = 1.0f;
    vertexPositionData.put(new float[]{
            xOffset + l_length + tx, l_height + ty, zOffset + -l_width + tz,
            xOffset + -l_length + tx, l_height + ty, zOffset + -l_width + tz,
            xOffset + -l_length + tx, l_height + ty, zOffset + l_width + tz,
            xOffset + l_length + tx, l_height + ty, zOffset + l_width + tz,

            xOffset + l_length + tx, -l_height + ty, zOffset + l_width + tz,
            xOffset + -l_length + tx, -l_height + ty, zOffset + l_width + tz,
            xOffset + -l_length + tx, -l_height + ty, zOffset + -l_width + tz,
            xOffset + l_length + tx, -l_height + ty, zOffset + -l_width + tz,

            xOffset + l_length + tx, l_height + ty, zOffset + l_width + tz,
            xOffset + -l_length + tx, l_height + ty,zOffset +  l_width + tz,
            xOffset + -l_length + tx, -l_height + ty,zOffset +  l_width + tz,
            xOffset + l_length + tx, -l_height + ty, zOffset + l_width + tz,

            xOffset + l_length + tx, -l_height + ty, zOffset + -l_width + tz,
            xOffset + -l_length + tx, -l_height + ty,zOffset +  -l_width + tz,
            xOffset + -l_length + tx, l_height + ty, zOffset + -l_width + tz,
            xOffset + l_length + tx, l_height + ty, zOffset + -l_width + tz,

            xOffset + -l_length + tx, l_height + ty, zOffset + l_width + tz,
            xOffset + -l_length + tx, l_height + ty, zOffset + -l_width + tz,
            xOffset + -l_length + tx, -l_height + ty, zOffset + -l_width + tz,
            xOffset + -l_length + tx, -l_height + ty,zOffset +  l_width + tz,

            xOffset + l_length + tx, l_height + ty,zOffset +  -l_width + tz,
            xOffset + l_length + tx, l_height + ty, zOffset + l_width + tz,
            xOffset + l_length + tx, -l_height + ty, zOffset + l_width + tz,
            xOffset + l_length + tx, -l_height + ty, zOffset + -l_width + tz

    });
}

public void createChunk() {
    vertexPositionData = BufferUtils.createFloatBuffer((24*3)*activateBlocks);

    Random random = new Random();
    for (int x = 0; x < CHUNK_SIZE; x++) {
        for (int y = 0; y < CHUNK_SIZE; y++) {
            for (int z = 0; z < CHUNK_SIZE; z++) {
                if(blocks[x][y][z].getActive()) {
                    putVertices(x*2.0f, y*2.0f, z*2.0f);
                }
            }
        }
    }

What's any easy way to translate the vertices of each block into its correct position? I was previously using glTranslatef with each call to render block but this won't work now.
What I am doing now also does not work, the blocks all render in stacks on top of each other and it looks like this:

Thanks


texts: Unity GridLayoutGroup children ignoring resizing

texts:
Can anyone explain why, in the editor I get:

while, on my Galaxy S6, I get:

My Panel UI element (which is the parent) has the GridLayoutGroup component, as well as the ContentSizeFitter. The child elements have a LayoutElement component with a FlexibleWidth/Height of 120 and all anchors are set to stretch in all directions.

The Canvas is set to Scale with Screen size, with a reference res of 320x480 and screen mode is to match height.

Regardless of the amount of squares (which is dynamic) the editor perfectly resizes child elements within the parent, but my device makes them tiny. I'm really confused.

There is no setting of sizes or anchors within the script, purely an instantiate and an assignment of parent, like so:

    for(int i=0; i < amount; i++)
    {
        GameObject emptyCell = (GameObject)Instantiate(emptyCellObject);
        emptyCell.transform.SetParent(cellHolder);
        emptyCell.GetComponent<RectTransform>().localPosition = new Vector3(0f, 0f, 0f);
        emptyCells.Add(emptyCell);
    }

I've also checked all docs related to: http://docs.unity3d.com/Manual/comp-UIAutoLayout.html - And even UI tutorial movies, as well as some blog posts about the 'new' UI tools, but nothing changes the dimensions on the physical device, and seems to change nothing in the editor as that remains the same.

I'm sure I'm doing something silly, but I've exhausted all avenues and was hoping someone had come across this oddity previously.


texts: How to use Animation Player in Godot like Animated Sprite

texts:
So currently I am using the following code to play my sprites (AnimatedSprite Node).

$Sprite.play("Animation Name")

However now I want to use the AnimationPlayer Node to play my sprites. How can I do this? I have searched the docs and there is no tutorial and I have searched online but they have to use AnimationTree or a sprite sheet which I don't have. (I have individual sprites).

So my question is how can I use the AnimationPlayer Node in the same way as AnimatedSprite Node.

Note: The reason I am using AnimationPlayer instead of AnimatedSprite because I would like to change collisions during certain frames, but that's for another time.

Disclaimer: To prevent false answers I don't have a sprite sheet. I have individual sprites


texts:
I have coded my main menu for the game in HTML and CSS, and need the image buttons to function with the engine, using JavaScript.

How do I create JavaScript buttons?

Here are some examples:

Skip: One image button. Red, when disabled, and green. When enabled, skips the menu, when you come back to play to a continued game. When disabled, will return transitions to normal.
Restart: When clicked, opens a box with two images and text for "yes" and "no". If you click "yes", it restarts game, and when you click "no", it resumes the game.
Sound: Will have one image button, which will be red for "on", and green, when "off". Turns sound on and off.

Here is some example code:

function ENGINE_get_option_state(opt:string):string {
    return…;
}

ENGINE_trigger_sound(…)


texts: Is single/double frame allocator suitable only for POD datas?

texts:
Let´s say I have a single frame stack allocator, so I´m using it for allocating memories for my temporary data.

size_t freeTilesSize = 10;
int* freeTiles = _allocator.allocate<int>(freeTilesSize);

The stack doesn´t save any conditional stuff about the memory it creates(it cares only about the size of the chunk so it knows the new header offset). I see this a good for using with POD data structures or classes with default destructor, however, is it usable also for bigger entities with some behavior at the destruction? At this moment, my function rewind only sets the header ptr to the start of the allocated block so it doesn´t call any destructors.

Am i doing something wrong? What was your approach?


texts: How can I change the camera to work from an Y up system to a Z up

texts:
I am following the tutorial from learnopengl.com but it uses a Y-up system, but I would like to change it for a Z up system because I'm more used to it.

I tried changing the up vector to be 1.0 on the last coordinate but and inverting the pitch And the Yaw, but when having the camera face the positive y-axis the mouse movement breaks and starts to move slower and opposite to the way I move the mouse.

The Axis system I'm trying to achieve:

That is the same as the Blender one.

This is the function of the camera class which handles the Pitch and Yaw: (offset is the mouse movement on the x axis and y axis):

void Camera::updateCameraVectors()
{
    // Calculate the new Front vector
    glm::vec3 front;

    front.x = cos(glm::radians(Yaw)) * cos(glm::radians(Pitch));
    front.y = sin(glm::radians(Pitch));
    front.z = sin(glm::radians(Yaw)) * cos(glm::radians(Pitch));

    Front = glm::normalize(front);
    // Also re-calculate the Right and Up vector
    Right = glm::normalize(glm::cross(Front, WorldUp));  // Normalize the vectors, because their length gets closer to 0 the more you look up or down which results in slower movement.
    Up = glm::normalize(glm::cross(Right, Front));
}

Up is the vector that I initialized as (0.0f, 0.0f 1.0f)

Are there any resources available online that explain how to make the switch from a Y-up to Z-up system?


texts: Bullet Physics Scaling rotational part of 6DoF Spring Damper

texts:
I am currently trying to scale up my setup (consisting of two rigid bodies connected by a btGeneric6DofSpring2Constraint) to fall within the suggested dimensions for a concise simulation.

In order to do so, I followed to the provided Wiki http://www.bulletphysics.org/mediawiki-1.5.8/index.php?title=Scaling_The_World.

I scaled all the linear properties and concerning the resulting forces, everything turned out physically consistent.
Note that I did not scale up the liner and angular stiffness and damping values.

However I encountered significant deviations concerning the spring-related torques resulting due to a angular spring offset. I guess that this issue arises due to the fact that the torques should be scaled (*scale^2) as well. However I do not see a way of scaling the internal torque representation of the btGeneric6DofSpring2Constraint. Should i simply scale up the angular spring stiffness and spring damping by a factor (*scale^2) or is there a better more elegant way to retrieve physically consistent results (forces, torques, motion) when trying to scale a world containing the btGeneric6DofSpring2Constraint?

EDIT:
I was able to boil it down to the following:

The rotational stiffness and damping vales are chosen independent from the scale.

The stiffness itself does not alter the behavior of the system. The deviations are caused entirely by the damping part. An experiment with altering the scale and non-existent damping showed results independent from the scaling factor, just as desired (K_stiff = 20.0, K_damp = 0.0):.
]

However when repeating the same experiment with no stiffness and a positive damping factor, significant differences arise when scaling up. (K_stiff = 0.0, K_damp = 9.0): The image denotes the system responses for different scales.

I found the corresponding code snippet in

        btScalar fs = ks * error * dt;
    btScalar fd = -kd * (vel) * (rotational ? -1 : 1) * dt;
    btScalar f = (fs+fd);

    info->m_constraintError[srow] = (vel + f * (rotational ? -1 : 1)) ;

    btScalar minf = f < fd ? f : fd;
    btScalar maxf = f < fd ? fd : f;

    //printf("%.3lf\n",f);
    if(!rotational)
    {
        info->m_lowerLimit[srow] = minf > 0 ? 0 : minf;
        info->m_upperLimit[srow] = maxf < 0 ? 0 : maxf;
    }
    else
    {
        info->m_lowerLimit[srow] = -maxf > 0 ? 0 : -maxf;
        info->m_upperLimit[srow] = -minf < 0 ? 0 : -minf;
    }

    info->cfm[srow] = cfm;
    srow += info->rowskip;
    ++count;
}

Interestingly, the scaling works just fine if the if clause is commented out. Any sugestions why this happens?


texts: Why the shareware (not demo) model died?

texts:
In the early days of the industry, instead of fighting piracy, companies let the users share their games freely, and put some nag screen or something like that on the game.

Then they would sell DLC and expansions (yes, DLC is 20 years old actually :P), hintbooks, cheat codes, swags, etc...

Why this model died?

Note: I am talking about classic shareware, not the crippleware or demo crap.


texts: What is the term for how much a game's code is coupled to its engine?

texts:
Essentially, what is a word or phrase I might use/search for to describe how much the choice of an engine dictates the structure of your code, such as the language it is written in or the way objects much be structured, as well as aspects of what design patterns can be used or how assets are formatted?

For instance, Unity has a high amount of this coupling because, while it allows the use of C# (which runs on many platforms), it requires many object interconnections to be exposed as concrete classes and public member variables. GameMaker Studio is almost completely coupled in this way because it has its own proprietary scripting language and asset format.


texts:
I am currently trying to make all other objects push away from the player when the player explodes. It currently works, but it pushes close objects a little and far objects very far. What I want is for close objects to get pushed back more than far objects.
Here is the current code:

function explode () {
var all_rigidbodies = FindObjectsOfType(Rigidbody2D);

for (var r : Rigidbody2D in all_rigidbodies) {
    if (Vector2.Distance(r.transform.position, transform.position) < 6 && r.tag != "Player") {
        var px : float = r.transform.position.x - transform.position.x;
        var py : float = r.transform.position.y - transform.position.y;

        r.AddForce((Vector2(px, py) * 200), ForceMode2D.Force);
    }
}

Any ideas on how to inverse the vector or force, or better ways to achieve 2D explosions?

EDIT: Ended up just normalizing force so its all the same knockback


texts: How do I check for collision between an ellipse and a rectangle?

texts:
I am working on LibGdx framework for developing a 2D isometric tower defense game.All my sprites are drawn in 2D isometric view.

I have used an array list to store 8 points at boundary in the rectangle.LibGdx has an inbuilt function (returns Boolean) ellipse.contains(x,y),by iterating through array list I can check whether any points are inside ellipse
But the problem is as shown in below picture,it wont detect the enemies in some particular cases

So my question is:
1)Is this a correct approach for solving these kinds of problems
2)If not can you suggest better approach for solving this problem

Thank you.


texts: How to import character package in Unity

texts:
I recently made a game in Unity 3D and I tried to import the FPS Controller package as the tutorial I was following said, but when I clicked Assets/Import Package the only thing I saw was a button saying 'Custom Package'

How do I get the character option when I click 'Import Package'?


texts: How do I get realistic sliding contact between objects in a voxel grid?

texts:
I have a 3D grid of voxels in my game. Entities walk around with simple physics that represents them as an axis aligned bounding box with velocity, mass and acceleration. The way I'm doing collision resolution is fairly simple. Here's some pseudocode:

function ResolveCollisions()
    // For each voxel that could intersect the bounding box...
    foreach (Voxel neighbor in VoxelGrid.GetVoxelsIntersecting(this.bounds))
        // Check a collision between the voxel and the bounding box
        if (neighbor.Collides(this.bounds))
            ResolveCollision(neighbor, bounds);

function ResolveCollision(Voxel neighbor, BoundingBox bounds)
     // Compute the contact normal and penetration distance between the two
     // boxes.
     [Vector3 norm, float dist] = ComputeMinPenetration(neighbor, bounds);
     // Snap the position so its no longer colliding
     this.position += norm * dist;
     // Reflect the velocity over the normal to perform an elastic collision.
     this.velocity = this.Restitution * Vector3.Reflect(this.velocity, norm);

This works pretty well for instantaneous collisions and bouncing, but fails for sliding contact. If an entity is sliding across a flat plane of voxels, for instance, it will rapidly bounce, and will sometimes end up colliding with the sides of the voxels instead of the top.

How do I get realistic sliding contact between the bounding box and a voxel grid, without bouncing or "toe stubbing?"


texts:
I am currently experimenting with the DIY holograms. Does anyone know to split my windows into 4 perpendicular identical displays like this but for Windows?
I am using Unreal Engine & I want it to make something like this but the user should be able to rotate the camera.


texts:
Greetings!

I'm working on a class that loads and parses .json files and returns information from the loaded .json, but I have problems reading the nested arrays of my .json files.

Turning the serialized object public and looking at the Inspector, the 'Choises' array is not being read at all. It contains four objects, each contain a string and an integer correspondingly.

using SimpleJSON;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;

public class JsonParser : MonoBehaviour
{
    private string loadedJson;
    public StoryData storyData;

    [Serializable]
    public struct choice
    {
        public string choiceText;
        public int choicePointer;
    }

    [Serializable]
    public struct storyImage
    {
        public string imagePath;
    }

    [Serializable]
    public struct storyText
    {
        public string text;
    }

    [Serializable]
    public struct placeholderStory
    {
        public string storyText;
        public string storyImage;
        public List<choice> choises;
    }

    [Serializable]
    public struct StoryData
    {
        public placeholderStory[] placeholderStory;
    }

    public void LoadJsonFile(string filename)
    {
        loadedJson = File.ReadAllText(Application.dataPath + filename);
        storyData = JsonUtility.FromJson<StoryData>(loadedJson);
    }

    public string GetChoiceText(int storyPosition, int choiceIndex)
    {
        string choiceString = storyData.placeholderStory[storyPosition].choises[choiceIndex].choiceText;
        Debug.Log(choiceString);
        return choiceString;
    }

    public string GetStoryText(int storyPosition)
    {
        string storyString = storyData.placeholderStory[storyPosition].storyText;
        return storyString;
    }

    public string GetStoryImage(int storyPosition)
    {
        string imageString = storyData.placeholderStory[storyPosition].storyImage;
        return imageString;
    }
}


texts: How to rotate an object so it stands correctly (back always facing the camera)

texts:
I have the following scene:

And I have two 3D vectors, the camera position, and the focus position. The focus vector is always behind the monster. I know how to rotate the camera around the focus with the help of my mouse, but the monster is always facing the same direction, and I'd like to change that!

I'd like it to work almost as in World of Warcraft; while I'm standing still I can move the camera around freely, but as soon as I move, the monster should change the direction according to the camera.position >>> focus vector. Also, I need to make it move in that direction, I guess I could have a 2D vector called speed, which I should change accordingly (it would look like a rotating radius of a circle I guess).

How do I do this?

For reference, I'm working in Three.js, and this is the code with which I rotate the camera:

onDocumentMouseDown = function(event)
{
    event.preventDefault();

    game.isMouseDown = true;

    game.onMouseDownTheta = game.theta;
    game.onMouseDownPhi = game.phi;
    game.onMouseDownPosition.x = event.clientX;
    game.onMouseDownPosition.y = event.clientY;
}

onDocumentMouseMove = function(event)
{
    event.preventDefault();

    if (game.isMouseDown)
    {
        game.theta = -((event.clientX - game.onMouseDownPosition.x) * 0.5) + game.onMouseDownTheta;
        game.phi = ((event.clientY - game.onMouseDownPosition.y) * 0.5) + game.onMouseDownPhi;
        game.phi = Math.min(160, Math.max(20, game.phi));

        game.cameraBuff.x = game.radious * Math.sin(game.theta * Math.PI / 360 ) * Math.cos( game.phi * Math.PI / 360 );
        game.cameraBuff.y = game.radious * Math.sin(game.phi * Math.PI / 360 );
        game.cameraBuff.z = game.radious * Math.cos(game.theta * Math.PI / 360 ) * Math.cos( game.phi * Math.PI / 360 );
    }
}

And at render time I do this:

self.camera.position.x += self.cameraBuff.x;
self.camera.position.y += self.cameraBuff.y;
self.camera.position.z += self.cameraBuff.z;

self.camera.lookAt(self.focus);
self.renderer.render(self.scene, self.camera);

self.camera.position.x -= self.cameraBuff.x;
self.camera.position.y -= self.cameraBuff.y;
self.camera.position.z -= self.cameraBuff.z;


texts: Particle spawn on collision spawns too many particles

texts:
So i have the following code:

private void OnCollisionEnter(Collision collision)
    {
        foreach (ContactPoint contact in collision.contacts)
        {
            if (contact.otherCollider.CompareTag("Ground"))
            {
                //Instantiate your particle system here.
                Instantiate(Effect, contact.point, Quaternion.identity);
            }
        }
    }

Now this works great however it spawns way too many particles (as the animation I am doing with the item hits the ground a lot).

Is there a way to limit the particles in a sensible way?


texts:
I'm creating a RayCasting tutorial on github (click here to access it) and I'm following a lot of tutorials, implementations and other render methods in the web. One game made with it is the "Prelude of the Chambered" by Markus Persson. He made this game in 2 days with native programming.

My question is about the noise picture effect he used for rendering. I wanted to know how to do this, and if this has some render name. Check the image bellow and you will know what I'm speaking about:

If you check some render position you will find some noise pixels. What is the method to do this? This techique has some name?

Thanks a lot for help!


texts: How to move player along navmesh link's curve?

texts:
NavMesh Link creates a navigable link between two locations that use NavMeshes.
This link can be from point to point or it can span a gap, in which case the Agent uses the nearest location along the entry edge to cross the link.

I don't know why when I use navmesh link player move along horizontal plane (that I demonstrate it by red line) between gaps in navmesh link
Is there a option that player jump along curve (that I demonstrate it green curve)?
should I use force?

you can see player move horizontally! that isn't interesting.
Offmesh Links - Unity Official Tutorials


texts: Would landscape left/right make difference when developing Google VR CardBoard Game with Unity?

texts:
I'm trying to make a simple VR cardboard game using Google VR SDK for Unity. I'm really confused about the problem as my title. Will the values got from

GvrViewer.Instance.HeadPose.Orientation.x;

change when the orientation of smartphone change from Portrait to Landscape Left/Right?

The following code works in Unity demo (after press play button and use alt+right-click to trigger head movement simulation), but I don't have a cardboard so I'm not sure whether it will still work on smartphone with landscape left or right attached to a cardboard.

private void Update()
{
    // forward if the value is positive.
    float forwardValue = GvrViewr.Instance.HeadPose.Orientation.x;
    // turn left if the value is negative.
    float turnValue = GvrViewr.Instance.HeadPose.Orientation.y;
}

private void Move()
{
    Vector3 movement = transform.forward * forwardValue * m_Speed * Time.deltaTime;

    // Apply this movement to the rigidbody's position.
    m_Rigidbody.MovePosition(m_Rigidbody.position + movement);
}

private void Turn()
{

    // Determine the number of degrees to be turned based on the input, speed and time between frames.
    float turn = turnValue * m_TurnSpeed * Time.deltaTime;

    // Make this into a rotation in the y axis.
    Quaternion turnRotation = Quaternion.Euler(0f, turn, 0f);

    // Apply this rotation to the rigidbody's rotation.
    m_Rigidbody.MoveRotation(m_Rigidbody.rotation * turnRotation);
}


texts: OnTriggerEnter : is it called in both collider object?

texts:
I've 2 object: a Player and a Bonus object.

In both script I've "OnTriggerEnter" script.

In Player OnTrigger I:
  Take Bonus value and add it to my Player (health, point, ammo)

In Bonus OnTrigger I:
  Play audio (when take it), Play Particle System and so on...

But, it seems it's called only Player's OnTriggerEnter ... Why ?

In Unity, if I have OnCollision/OnTrigger enter in both object, which event is called ? Both ?

Thanks


texts: How can I make sure all army compositions are counterable in an RTS game?

texts:
Most RTS games I played have some kind of rock-paper-scissors system that ensure that there is no single best unit you can mass and win with all the time.
However this breaks down when players start to combine different kinds of units. Just make one unit type then make the counter of its counters to protect it. Eventually players will find the best pairing that mutually protect each other, then everyone will copy that and all other combinations become inferior to that and won't see play.
We can see this in Empire Earth 1 for example, where up to middle ages all you need to do is just mass chariot/cavalry archers and swordsmen. Although spearmen and knights wreck the swords, they are destroyed by arrows. And archers are destroyed by swords, but your swords are blocked by enemy swords so you'll have hard time reach enemy archers... So all you can do is just try to make more swords and archers than the enemy.
You can also use area of effect siege weapons against archers, but they are expensive and totally wrecked by swords.
So all players use just swords and archers against everything - including buildings. This what I would like to avoid and I would like to make sure other units also see play.
So the question is: How can I make sure that not just individual unit types but but all possible combinations of them have a counter combination that costs less resources than the opponent's army?
Is there a mathematical framework for that?


texts: For my enemy AI, I only need decision making to be done every second or every half second. Would it make a meaningful difference if I didn't run the analyzing method in the Update, but rather invoked a SlowUpdate every second?


texts: Changing properties for multiple objects in unity 3d free?

texts:
So my team and I need to assign values to specific values in the inspector to large numbers of objects.

For example, we have a script that's assigned to all the walls, and all the floors.

We want to select all the walls in the Scene view and assign the value "1" to a variable in the inspector and then go and select all the floors and assign the value "2" to the same variable, for those objects.

Right now, when we select multiple objects and assign a value to the variable in the inspector, it just changes it for the last selected object.

We've got (potentially) hundreds of object that we need to do this to and it would suck to have to go in and change the values one at a time.

The equivalent I'm thinking of is the Attribute Spreadsheet in Maya, where you can see a list of objects, and assign the same value to a bunch of their attributes.

Hope somebody out there has an answer for this! Haven't been able to find one yet!


texts:
I've been working on project for quite a while, and I've returned to dilemma about level loading.
The problem is i trust the client with it's local level loading, when it's done loading it tells the server to join it to server room data stream and server start to send data.

My current setup

Client logs in, on login server sends the characters.
Client chooses the character and start to load level locally.
When client scene done loading, it request to add to room.
Client receives the data he needs.

I fear that user could hack the client and actually load other scene, that would result in players and characters going through props and models, it could also be an exploit to see hidden data and items.

Instead, after server sends the chosen character it could "wait" for user to send response that level has finished loading. After that, server joins the character to room and send data to the user. That way client doesn't know anything about rooms or it's names.

Any suggestions?


texts:
I was thinking to make my arcade game match the players strength in the hard level mode. Like checking the score and if the human player's score is above computer's for certain number of units then the computer player would automatically increase the speed of its reactions, just like a human companion who gets more determined to fight back.

Does this sound a good idea to you? Are there other ways to approach this, so to make a game, like air hockey for a crude example, permanently challenging for anybody?

EDIT:
I agree with the answers below. I believe that most people like to win about 70% time over the computer in order to be motivated. Hence an adaptive intelligence must not be become too superior to the player and depending on human player's concentration and some random elements in the game (good 'old' quantum RND), the outcome should be always uncertain.

A nice thing about this is that such a system could handle week and strong players and would adjust to the human's learing curve.


texts: How to properly commission professional artwork

texts:
Possible Duplicate:
  How do I find artists to work on my game?

I am trying to commission an artist to do professional work for my game Fimbulvetr.  A sample of the current state of the game can be found here:

http://www.youtube.com/watch?v=uN90R-yCy14

Of course, my intention here is neither to advertise the game itself here, nor to make said request for an artist to this community, as neither of those would be appropriate questions.  Viewing my work-in-progress, however, may help understand the circumstances.

The issue is that my project is significantly larger-scoped than it seems most Indie Artists are used to.  Containing large amounts of elements from Fighting Games, the project is designed to possess no less than 8 fully-animated fighting game characters, with several hundred frames of animation each.

The game currently uses much filler art, all created by myself personally.  Not only are they low-quality stick-figures, meant only to visually articulate the motions and designs and not to be permanent, but they also take a huge portion of my time away from programming, of which I am also the sole group member.

I have attempted no less than 4 times so far to find an artist who would be willing to take up the job, but each time it has ended the same: they do a small amount of work, and then give up.  While personal, specific reasons are always involved, I suspect similar psychology behind the reasoning.  It could be simply a matter of bad luck, or perhaps not.

Is there a particularly tried-and-true method of finding someone to do such work?  I would like to be as professional as possible in this endeavor.  I am offering significant payment for the services, attempting to manage reasonable schedules, and doing everything else I can think of to make this as professional, efficient, motivating, and successful as possible.


texts: Libgdx, how do i get the translation and rotation of a node from a model instance?

texts:
I have a model instance of a character, and a model instance of a sword weapon. THe character has a node on his right hand so he can "carry" the sword. Right now I use this code so the sword's transform follows that of the node.

weaponModelInstance.transform.set(modelInstance.transform).mul(weaponAttachmentNode.globalTransform);
weaponModelInstance.transform.rotate(Vector3.Z, -90); // adjustment for blender coordinates
world.modelBatch.render(weaponModelInstance, world.environment);

this works, except that the model instance gets scaled to the scale of the node, which i do not want, i want the weapon to keep its scale. I've tried doing the following code to fix this but I end up getting weird (and wrong) rotations for the sword

weaponModelInstance.transform.set(modelInstance.transform).mul(weaponAttachmentNode.globalTransform);
weaponModelInstance.transform.set(
        weaponModelInstance.transform.getTranslation(new Vector3()),
        weaponModelInstance.transform.getRotation(new Quaternion()),
        new Vector3(1, 1, 1)
);
weaponModelInstance.transform.rotate(Vector3.Z, -90);
world.modelBatch.render(weaponModelInstance, world.environment);

do anyone know how to properly copy the world translation and rotation from the node, but not its scale?


texts:
I teach a basic course on game development, in which students design a game idea and write a digital prototype in Unity - about 5 minutes demonstrating the main idea and gameplay. Some of the teams did really great jobs and I would like to encourage them to continue developing their game beyond the course, but I am not sure what the next steps should be. In particular:

Where can they get more professional review on their prototype? There are websites that review games, but usually they are looking for complete games, not just prototypes.
Where can they get playtesters that will help them improve their prototype and make it a full game? Currently their game is in itch.io, but it is hard to draw attention to it.


texts: How would I create colouring such as in Splatoon?

texts:
For those who don't know, Splatoon is a game where you color ground with your teams, and other team tries to color more area in their color.

It looks like the whole ground is color-able, which makes every ground part (maybe not every pixel, but very big part of it) rendered every time a color is being sprayed. I would think is a big load on the GPU, but the Nintendo Wii U handles it pretty well.

My question is, how is it possible? Is there a trick behind that kind of process?


texts:
do people find unity better than flash for 2d games while unity is 3d engine , or Flash still better because it's made for 2d games and flash can get the job done faster ,and now flash is better for ios/android 2d games .
so what platform is the best for 2d games?


texts:
How can I hide the camera gizmo in Unity?
As said here I tried to use the gismos menu in the top of my Scene view. But it does not work. Why?
Also, I tried saving my scene and project after the gizmo changes. Did not help. I have the Unity 2020.1.17f1.


texts: Prevent UI Button focus loss when clicking somewhere else

texts: I have a set of UI buttons in a canvas. The user is be able to navigate the buttons through both mouse clicks and arrow key movements. However, clicking anywhere not on the buttons results in focus being lost from the buttons, making arrow key navigation no longer work. Is there a way to solve this?


texts:
I am thinking of making a simple game with Unity. The aim would be to keep a person healthy by feeding it well balanced food and drinks.

Rather than hard codding every single type of food or drink I can think of I was thinking of letting the player choose any type of food he wants and then screen the internet for it's calorific value, saturated fat, sugars etc ...

This would make the game much more enjoyable than being limited by the foods I can think of.

I was wondering how you would go about doing that ? Could I use an API to extract data from google or wikipedia.

I noticed that when you type "[food] calories" in Google you get a return from the Wikipedia page like this:

Obviously, there is a way of extracting the data from Wikipedia and I could automate the searchs by taking the player's entry as a string and running a search with it.

How would one recommend going about this ? Also, is it safe ?

Thanks


texts: Adding mesh's\objects to procedural isosurface terrain

texts:
Thanks again for reading!

So following on from my last question, I have my fully working isosurface terrain and now its time to add my trees and grass and whatever to the world.

The old way I was doing it was to cast rays in a grid faceing down over the terrain, I would then read the normal from the ray hit and place things if the normal was < as value.

I would do this at different grid resolutions for each plant\tree\grass time and offset there x, z and scale by some random value then adding the object to my 2d BV tree because I was only working with height map terrain so I only had one row of bounding volumes for the tree.

I can still use the above method but as you know it will only place objects on parts of the terrain that can see the sky.

Part of building my new terrain system involved making a real octree so I no that I will use that to store my objects but what is the best way to generate my object positons.

From what I have read around I should somehow use the voxels I build but I'm not really sure how I would go about it.


texts:
I use the unreal engine 4 to bounce a ball off of walls in a 2D space, but over time the ball gets slower and slower.

Movement happens in the tick function of the ball

FVector location = GetActorLocation();

location.X += this->Velocity.X * DeltaSeconds;
location.Y += this->Velocity.Y * DeltaSeconds;

SetActorLocation(location, true);

When a wall gets hit I get a Hit Event with the normal of the collision.
This is how I calculate the new velocity of the ball:

FVector2D V = this->Velocity;
FVector2D N = FVector2D(HitNormal.X, HitNormal.Y);

FVector2D newVelocity = -2 * (V.X * N.X + V.Y * N.Y) * N + V;

this->Velocity = newVelocity;

Over time, the more the ball bounced around, the velocity gets smaller and smaller.
How do I prevent speed loss when bouncing off walls like that? It's supposed to be a perfect bounce without friction or anything.


texts: Everything "invisible" when launching map from launcher

texts:
I downloaded the CryENGINE SDK, and I tried the map Forest from within the editor and it worked fine. However, if I launch it from the Launcher using the console it looks like this:

I can use the weapons (although they are invisible) and interact with objects despite not seeing them.  I also did my own map and had the same problem. What am I doing wrong?


texts:
For some research purpose I've build a small tanks game where you have 1 tank controlled by a player and one or more NPC tanks.

Now I want these NPC tanks to navigate through a field which they have no knowledge of. They can detect obstacles if they are in a certain range. If they detect those obstacles they should save them in a certain data construct that's easy to query. So that they can take them in account in pathfinding.

Now here is where I'm stuck : if my field would be a grid (level discretized in tiles) it would be quite easy for me, I would just save which tiles the obstacle is on.

But I haven't really worked with a grid, my tanks just move forward a few pixels depending on their speed, so a tank can be located on any pixel combination. Is this bad game design?

I could probably make a grid just for my obstacles, but that restricts a bit the kind of obstacles I can have.

Any suggestions/tips ? Please ask more information if needed, I was not really sure what to include.


texts:
Let's say I already have an A* algorithm.

How can I handle the cases when the goal cannot be reached, and still attempt to get there?

For instance on the following example:

Notice the amazing GIMP skills!

The yellow unit needs to reach the green spot, but it's on island and can't actually reach it.

Yet, on a typical RTS, the unit will try to go as close as possible.

My problem is that I don't know how to tell A* that the closest tile to the goal is the square near the sea.

How can I have this partial pathfinding? Is A* still a good choice?


texts: Problems with 3D rotation when creating a 3D skeleton

texts:
I am writing a simple BVH parser in C# using the XNA framework. At the moment I have managed to parse in all the data and my goal is to find out the global coordinates of all the joints in the skeleton.

The problem I am encountering is that the bones don't seem to take into account the rotation of its parents. For instance, if I move my lower leg, I would expect my foot to change orientation as well and keep the same angles between the foot and the lower leg. What I am noticing is that the translation of the bone joints is correct, but the global rotation of a bone is the same as the local rotation of the bone. The picture below might help you understand what the problem is:

note: there is a mistake in the pic captions,  it should read "the left upper leg is rotated around the z-axis" not the x-axis.

I would have expected the lower leg portion to also be rotated by 1 radian as a result of its parents' change in orientation.

So the code is as below (I am using XNA and C#):

foreach (Bone b in bones)
{
            //Calculate the local transform matrix
            b.localTransform = Matrix.CreateTranslation(b.Offset) * Matrix.CreateRotationZ(MathHelper.ToRadians(b.z)) * Matrix.CreateRotationY(MathHelper.ToRadians(b.y)) * Matrix.CreateRotationX(MathHelper.ToRadians(b.x));
            Bone parent = b.parent;
            if (parent != null)
            {
                //Calculate global transform matrix
                b.globalTransform = parent.globalTransform * b.localTransform;
                b.location = b.globalTransform.Translation;
                lines.Add(new Tuple<Vector3, Vector3>(parent.location, b.location));
            }
}

Each bone assumes its parents global transformation is correct as the list is ordered so the parents always come before the children. The root bone has no rotations and no offset and has its global transform already set based on this. I am wondering what I am doing wrong here?

I have done a simple example using only 2D:

Matrix bone1 = Matrix.CreateTranslation(new Vector3(3, 0, 0)) * Matrix.CreateRotationZ(1);
Matrix bone2 = Matrix.CreateTranslation(new Vector3(3, 0, 0)) * Matrix.CreateRotationZ(1);

lines.Add(new Tuple<Vector3, Vector3>(Vector3.Zero, bone1.Translation));
lines.Add(new Tuple<Vector3, Vector3>(bone1.Translation, (bone1 *bone2).Translation));

Drawing this onto the screen shows what I expect. The 1st bone is rotated 1 radian around the origin, 2nd bone is rotated 2 radians around the origin.

I am using the below as a reference for parsing and interpreting the BVH data:
http://www.dcs.shef.ac.uk/intranet/research/resmes/CS0111.pdf


texts: How can I implement pre-rendered 2D sprites that can face any direction?

texts:
I've been Googling how games like Clash of Clans render their troops, and it appears they are pre-rendering 3D models to 2D sprite sheets before runtime, and rendering those 2d images at runtime. However, troops in Clash of Clans can face any direction.

In my similar game, if I were to create an image for every orientation (0-360 degrees) for every troop type (there are 18 types) at each frame in their animation, they would have to produce a massive amount of images. I can't imagine this is what other developers are doing, so how can I actually accomplish this?


texts:
I've been struggling with the text for my game labels, as can be seen below. Unity has even included it as an official bug, although no timeline is set to fix it.

The text just looks poor. I've seen artifacts too, like this one:

Looking around the internet, the suggestion seems to be buy Text Mesh Pro, currently on sale for $69.50. While it's not completely out of possibilities I have, I'd rather not pay so much for a tool that has uses far beyond what I need. All I really want is a UI Text that looks reasonable!

My questions are these:

Will Text Mesh Pro work as a drop in replacement for world space UI.Text?
Are there any other options out there to improve the text quality?


texts: How to put a reference to my player (already instanced) into a prefab that will be instantiated later

texts:
I'm making an enemy in my game. He stands at the side of road with a rocket launcher and fires when you get close. It nearly all works fine, except I just need a reference to the players position so that I can make his rocket explode when it reaches the same height on the map as the player car.

The enemy is a prefab which is NOT instanced at build-time, there a several spawn-points all with n% chance of spawning a guy there using the prefab. The player IS instanced at build-time. And here is my problem..

Although I have put a "public GameObject player" into my variables in the script on the prefab, it doesnt let me drag the already instanced player into it. I've read about a bit, and I see that Unity will not allow this (or at least thats what I gathered!)

So after much searching I came up with

player = GameObject.FindGameObjectWithTag("Player");

But i havent even tested yet because the source where i got that advice in the very next comment the guy says I shouldnt do this because it takes too much system resources up.

EDIT: I have tested it with that line, it does work. But is there a better way

But he doesnt say the way that it should be done! And the thread is about 6 years old. So I thought I'd write here again and ask you fine folks for more help.

I hope I explained the problem clearly enough, I think i got the terminology right. Basically, the RocketerEnemy prefab is going to be instantiated in runtime, but the PlayerCar is already instantiated by my dragging it into the heirarchy at the beginning of the project. This is stopping me from dragging the PlayerCar object into the box in the Inspector (for the Enemy prefab) .
All I really need is the PlayerCar.transform.position.Y value for each frame.

THANKS IN ADVANCE !


texts:
I am programming a 3d solar system (simulator).
To describe the path of a planet I wanted to add 3D rectangles.. and draw them.
But to no surprise it decreased the frame rate extremely.
Also it does not look nice:

Do You know how to handle this problem?
Is there another way to solve this?
Didn't found anything on 3D HLSL Circle Plotting.


texts: Determining whether an object is in field of view considering obstacles

texts:
I'm thinking of stealth games where an object has a certain field of view that you want to avoid otherwise game over.

The field of view may be linear or circular or any arbitrary group of pixels/tiles.

If I don't consider obstacles (for example, if you're standing behind a wall, they can still see you), I can determine whether the player is within an object's field of view using simple geometric properties using the two object's positions and range. This can be done efficiently, though it kind of assumes the objects are points.

However, to make it realistic, you should be able to hide behind a wall or a tree without being seen.

How is this problem usually solved?
What are some articles that I can read to understand more about this problem?


texts: How to do offline notifications for Android in Unity3d

texts:
I am making a game for Android with Unity3d.
I've been looking for a solution to this on the web for a little, but I couldn't find anything suitable:

I want to make my game have offline notifications.Like...I want to set up an alarm that notifies the user at some point in the future e.g.

  "Building complete!"

but the app should not have to be running.

How do I accomplish that?


texts: In Game Maker Studio, why does the image rotation have to be performed every step?

texts:
I'm a software developer who's trying to get into game development casually on the side. I picked up Game Maker Studio a while ago on a Steam Sale, and I'm finally getting into using it, especially after hearing that games like Undertale and Hotline Miami were products of said studio. I'm going through Shaun Spalding's Game Maker tutorials to familiarize myself with some of Game Maker's features and GML's coding syntax.

Following this tutorial, I rolled my eyes a little when he said to put the image_angle = direction; in the step event for my object rather than the creation event to rotate my object's sprite. "Why would you want to set a variable to the same value every frame when you could just set it once upon creation?" I thought to myself in my apparent naivety. But lo and behold, when running my project, the images aren't rotated if the image_angle = direction; is in the create event, and not the step event. Why? If image_angle is a member of my bullet object, shouldn't I be able to set it once upon creation? Or does it somehow reset on every frame?


texts: Is it possible to use the 2D camera, but just for a part of the screen? Perhaps I want some info on the screen about score and other things, but I want that at a fixed place, just like when not using a 2D camera?


texts:
My script works fine except I don't know how to not let the slow-motion affect the main player.

public GameObject player;

void  Update () {
    if (Input.GetKeyDown(KeyCode.A)) {
        Time.timeScale = 0.5;
        Time.fixedDeltaTime = 0.02F * Time.timeScale;
    }

    if (Input.GetKeyDown(KeyCode.Z)) {
        Time.timeScale = 1.0f;
    }
}


texts:
I have managed to get a point light working, but I am facing problem with directional lightning.

    Fragment shader
 uniform vec4 lightColour ;
 uniform vec3 lightPos ;
 uniform float lightRadius ;

in Vertex {
vec3 colour ;
vec2 texCoord ;
vec3 normal ;
vec3 tangent ;
vec3 binormal ;
vec3 worldPos ;
} IN ;

  void main ( void ) {
  vec4 diffuse = texture ( diffuseTex , IN . texCoord );
  mat3 TBN = mat3 ( IN . tangent , IN . binormal , IN . normal );
  vec3 normal = normalize ( TBN * ( texture ( bumpTex , IN . texCoord ). rgb * 2.0 - 1.0));
  vec3 incident = normalize ( lightPos - IN . worldPos );
  float lambert = max (0.0 , dot ( incident , normal ));
  float dist = length ( lightPos - IN . worldPos );
  float atten = 1.0 - clamp ( dist / lightRadius , 0.0 , 1.0);
  vec3 viewDir = normalize ( cameraPos - IN . worldPos )
  vec3 halfDir = normalize ( incident + viewDir );

  vec3 viewDir = normalize ( cameraPos - IN . worldPos );
  vec3 halfDir = normalize ( incident + viewDir );
  float rFactor = max (0.0 , dot ( halfDir , normal ));
  float sFactor = pow ( rFactor , 33.0 );
  vec3 colour = ( diffuse . rgb * lightColour . rgb );
  colour += ( lightColour . rgb * sFactor ) * 0.33;
  gl_FragColor = vec4 ( colour * atten * lambert , diffuse . a );
  gl_FragColor . rgb += ( diffuse . rgb * lightColour . rgb ) * 0.1;

As far as I know, directional lightning do not have a radius or a position, just direction.
How should I calculate directional lightning?


texts:
I am trying to simulate particles moving around the scene with OpenCL for computation and OpenGL for rendering with GLUT. There is no OpenCL-OpenGL interop yet, so the drawing is done in the older fixed pipeline way. Whenever circles get close to the edges, they start to flicker. The drawing should draw a part of the circle on the top of the scene and a part on the bottom.

The effect is the following:

The balls you see on the bottom should be one part on the bottom and one part on the top. Wrapping around the scene, so to say, but they constantly flicker.

The code for drawing them is:

void
Scene::drawCircle(GLuint index){
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glTranslatef(pos.at(2*index),pos.at(2*index+1),  0.0f);

    glBegin(GL_TRIANGLE_FAN);
    GLfloat incr = (2.0 * M_PI) / (GLfloat) slices;
    glColor3f(0.8f, 0.255f, 0.26f);
    glVertex2f(0.0f, 0.0f);
    glColor3f(1.0f, 0.0f, 0.0f);
    for(GLint i = 0; i <=slices; ++i){
        GLfloat x = radius * sin((GLfloat) i * incr);
        GLfloat y = radius * cos((GLfloat) i * incr);

        glVertex2f(x, y);
    }
    glEnd();
}

If it helps, this is the reshape method:

 void
 Scene::reshape(GLint width, GLint height){
     if(0 == height) height = 1; //Prevent division by zero

     glViewport(0, 0, width, height);

     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();

     gluOrtho2D(xmin, xmax, ymin, ymax);
     std::cout << xmin << " " << xmax << " " << ymin << " " << ymax << std::endl;
 }


texts: Did Street Fighter II Employ Machine Learning?

texts:
As a kid hanging out in my local arcade, me and my friends used to swear up and down that our computerized sf2 opponents would learn our strategies.

I wonder if anyone here might know whether that was the case. It feels as if it couldn't have been as simple as a finite state machine, because the opponent's tactics were definitely different depending on how early in the session you'd encounter them. And as each fight went on, it was as if old tactics would stop working. Brilliant games :)

anyways, I know it's a relatively open ended question. I had so many great memories playing that game, and it would be interesting to know whether the AI was that sophisticated, or otherwise what techniques it may have used so I can potentially use similar techniques in my own game designs.


texts: Should collision detection be done server-side or cooperatively between client/server?

texts:
I am working on an online game that will have very heavy collision detection processing. Player models will collide with other players, mobs, structures, terrain, and solid objects that only exist server side (not stored in client data files).

For security purposes, should I do all collision detection server-side? Or should I have the client do the detection and have the server follow up on it somehow? I feel like it will be too much for the server to do by itself (I am designing the engine for hundreds of players on one server).

Does anyone know how mainstream MMOs do it? I know that almost all MMOs right now are susceptible to physics hacks and usually deal with them by detecting hacks and banning people. I would rather the hacks did not work at all, at least for the physics component.


texts: Calculate speed vehicle physics 2d racegame

texts:
I am currently working on a 2d racegame where I am using physics to move a vehicle. On my form I would like to add a label containing the speed on the vehicle.

My physics knowledge is a little rusty, haven't done anything with it for a while, so I am asking the following question. Which of the calculations in my code represent the total velocity of my vehicle?

My relevant code:

    //our simulation object
    class RigidBody
    {
        //linear properties
        private Vector m_position = new Vector();
        private Vector m_velocity = new Vector();
        private Vector m_forces = new Vector();
        private float m_mass;

        //angular properties
        private float m_angle;
        private float m_angularVelocity;
        private float m_torque;
        private float m_inertia;

        public void Update(float timeStep)
        {
            //integrate physics
            //linear
            Vector acceleration = m_forces / m_mass;
            m_velocity += acceleration * timeStep;
            m_position += m_velocity * timeStep;
            m_forces = new Vector(0,0); //clear forces

            //angular
            float angAcc = m_torque / m_inertia;
            m_angularVelocity += angAcc * timeStep;
            m_angle += m_angularVelocity * timeStep;
            m_torque = 0; //clear torque
        }
   }

Hopefully someone will be able to help.


texts:
I've wanted to save progress of my game (i don't have the code , sorry)
without using PlayerPrefs.
If it's possible ; with UnityEngine.


texts:
I'm making a multiplayer game which involves drawing lines. It's based this game:  http://curvefever.com/sites/default/files/resize/remote/ef86488088c618df13b34f8b87aafd4e-1107x808.jpg. The game is setup so each "worm" has an own bitmap. All these bitmaps then get drawn in another single bitmap for best performance.  Now i'm trying to implement online multiplayer into the game. However I've had some doing struggle implementing online multiplayer. The thing is that I will need to reverse the state of the draw lines in case a packet from the server comes late to the client. The biggest problem is that the drawing needs to be done very fast since the game updates every 20th millisecond. However I figured out and tried some different approaches to this:

-Save the state of the whole context and then redraw it. This is probably the slowest method.

-Only save a part of the context (100x100) in a another bitmap hidden by looping through each pixel, then looping through each pixel from that bitmap to the main bitmap that is shown on the screen.

-Save each point of the drawn path in a some kind of path reference, then when reverting the context, draw this path with the background color (0,0,0,1).

-Saving the position in the bitmap of each pixel that gets drawn in a separate array and then setting that pixel alpha to 0 (in the drawn bitmap) when I need to undo.

The last approach or 2nd one should be the fastest of them all. Are my approaches that I've listed above correct or is there some method that I'm missing that I should use? I've been prototyping my approaches in code above but they have been rendered to slow or they haven't worked.


texts: how to make skills and their animations in opengl ? are skills 3d model or 2d?

texts:
1)slash effect
2)area skills like dota2 crystal maiden ulti and first skill
3)over an enemy skills example dota2 crystal maiden second skill

how they make in opengl

i know opengl billboards way and texture atlas i can make basic flame effect with using these 2 way together.
But how they make others ? area skills are 3d model animation ? then its texture is changing every frame? over an enemy skills can 3d model i think? how they make skills transparent ? with glblend ? what is best way to make them sorry for bad english i searched but i couldn't find any suggestion help please
im using c++,sdl,opengl


texts: Why are my Unity procedural animations jerky?

texts:
I'm working in Unity and getting some crazy weird motion behavior. I have a plane and I'm moving it. It's ever so slightly getting about 1 pixel bigger and smaller. It looks like the it's kind of getting squeezed sideways by a pixel. I'm moving a plane by cos and sin so it will spin on the x and z axes. If the planes are moving at Time.time, everything is fine. However, if I put in slower speed multiplier, I get an amazingly weird jerk in my animation. I get it with or without the lerp. How do I fix it? I want it to move very slowly. Is there some sort of invisible grid in unity? Some sort of minimum motion per frame?

I put a visual sample of the behavior here.

Here's the relevant code:

public void spin()
{

         for (int i = 0; i < numPlanes; i++ )
    {
        GameObject g = planes[i] as GameObject;

        //alt method
        //currentRotation += speed * Time.deltaTime * 100;
        //rotation.eulerAngles = new Vector3(0, currentRotation, 0);
        //g.transform.position = rotation * rotationRadius;

        //sine method
        g.GetComponent<PlaneSetup>().pos.x = g.GetComponent<PlaneSetup>().radiusX * (Mathf.Cos((Time.time*speed) + g.GetComponent<PlaneSetup>().startAngle));
        g.GetComponent<PlaneSetup>().pos.z = g.GetComponent<PlaneSetup>().radius * Mathf.Sin((Time.time*speed) + g.GetComponent<PlaneSetup>().startAngle);
        g.GetComponent<PlaneSetup>().pos.y = g.GetComponent<Transform>().position.y;
        ////offset
        g.GetComponent<PlaneSetup>().pos.z += 20;

        g.GetComponent<PlaneSetup>().posLerp.x = Mathf.Lerp(g.transform.position.x,g.GetComponent<PlaneSetup>().pos.x, .5f);

        g.GetComponent<PlaneSetup>().posLerp.z = Mathf.Lerp(g.transform.position.z, g.GetComponent<PlaneSetup>().pos.z, .5f);
        g.GetComponent<PlaneSetup>().posLerp.y = g.GetComponent<Transform>().position.y;
        g.transform.position = g.GetComponent<PlaneSetup>().posLerp;

    }

    Invoke("spin",0.0f);
}

The full code is on github.

There is literally nothing else going on. I've turned off all other game objects so it's only the 40 planes with a texture2D shader.

I removed it from Invoke and tried it in Update -- still happens. With a set frame rate or not, the same problem occurs.
Tested it in Fixed Update. Same issue.

The script on the individual plane doesn't even have an update function in it. The data on it could functionally live in a struct.

I'm getting between 90 and 123 fps. Going to investigate and test further. I put this in an invoke function to see if I could get around it just occurring in update. There are no physics on these shapes. It's a straight procedural animation.

Limited it to 1 plane - still happens.
Thoughts?

Removed the shader - still happening.


texts: How do I run an OpenGL shader on just a portion of an off screen texture and leave the rest of the texture unmodified? Are there any calls that restrict the sampled pixels to just a rectangle or do I have to filter out the rectangle in the shader code?


texts: Can you recommend a good beginners book or project for a young person?

texts:
I'm sorry if this question is a bit subjective but I'm sure you'll understand why.

I participate in a volunteer program, Big Brother Big Sister, and my match loves computer games and he'd love to make them. He's 16, and he's not that technical yet, I was showing him some html5 canvas stuff (I'm a web-dev, so it's easiest for me to explain that to him) but it's a little opaque to him, and of course the technology is still pretty limited.

What would be a good way for him to get into the fundamentals of making a game without having to know tons of code? Something like 3D Game Maker maybe?

Everyone, your answers have been really helpful, and I wish I could accept multiple answers, this will be really useful. Thank you all.


texts: Is HTML5/WebGL performance unreliable on low-end Android tablets and phones?

texts:
I've developed a couple of WebGL games, and am trying them out on Android.  I found that they run very slowly on my tablet, however.  For example, a game with 10 sprites or so runs as 5fps.  I tried Chrome and CocoonJS, but they are comparably slow.  I also tried other games, and even games with only 5 or so moving sprites are this slow. This seems inconsistent with reports from others, such as this benchmark.  Typically, when people talk about HTML5 game performance, they mention well-known and higher-end phones and tables.  While my 7" tablet is cheap (I believe it's a relabeled Allwinner tablet, apparently with the Mali 400 GPU), I found it generally has a good gaming performance.  All the games I tried run smoothly. I also developed an OpenGL ES 2 demo (in Java) with 200 shaded 3D objects, and it ran at 60fps.

My suspicion is that the WebGL engines have unacceptably limited support for many low-end and white-label devices (for example, relying on software fallback for no apparent reason), which means there may be a large section of gamers you will not reach when you choose this as your platform. I've heard rumors about inconsistent performance of HTML5 and WebGL on different devices, but no clear picture emerges.

I would like to hear if any of you have had similar experiences with HTML5 or WebGL, or whether I can find information about the percentage of devices I can expect to have decent performance.

EDIT: As a "thorough" way to prove my point, I've started on a WebGL implementation of my own, to see if I can do any better than CocoonJS.  Results are promising so far. On said tablet I can draw like 10,000 sprites at 60fps, all updated and drawn in JS through a WebGL compatible API. Check out the APK here.  So, I guess that proves that the existing WebGL implementations are really doing something wrong.  I'm now in the process of making my games playable in my framework.


texts: How can I exploit multithreading in collision resolution?

texts:
I'm trying to speed up my collision resolution by using multiple threads.

I'v read through Box2D's source code and while it was challenging and educating, it didn't really point me to how I could use multiple threads.

I'm ready to make some sacrifices with accuracy. I am investigating this because I have boatloads of game objects.

My current implementation handles AABB checks for 100000 objects in about 10 ms. I have no idea if this number is good, but for my purposes it seems sufficient.

Next, I'm trying to figure out how to resolve collisions. How could I get power out of multiple threads here?

This is what i'm currently planning to do: (Do you see any issues with it?)

Calculate position for each object in separate threads based on manifold data
Update existing manifolds in separate threads
get New collisions for moved objects in separate threads
Repeat 10 times or until no changes


texts:
I've been working on creating the GUI system for a 3d game I've been working on, and have hit a bit of an obstacle in trying to rotate GUI elements (Google searching did not yield what I was looking for). This is how the screen looks without any rotation. As of now, rotating each element distorts the GUI elements, like this, whereas I want an effect closer to this, without any stretch or skewing.

My code, using glm, looks like this:

void GUI::NewGUIBase::rebuildMatrix()
{
    glm::vec3 newModel = glm::vec3(absoluteTopLeft.x, absoluteTopLeft.y, 1.0f);

    glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), glm::radians(this->rotation), glm::vec3(0, 0, 1));
    glm::mat4 trans = glm::translate(glm::mat4(1.0f), newModel);
    this->setModel(trans * rotate);
}

I believe that the issue is due to the fact that my game window is not a square given that OpenGL uses window coordinates from -1 to 1. However, I can't figure out how I would take this into account to achieve the desired effect of rotation without any stretch.

In case it helps, a GUI element knows its own top left corner and its own dimensions (in OpenGL coordinates), and the game window's width and height in pixels.


texts: How can I add directional friction like asteroids with SPEED and DIRECTION?

texts:
I'm trying to make asteroids, and right now I'm setting the direction based on the mouse angle, like so:
let r = Math.atan2(ct.mouse.x-this.x, ct.mouse.y-this.y) * 180 / Math.PI;

this.rotation = Math.round(r - 180);
this.direction = Math.round(r - 90);

which works more like a car, as soon as you turn, you are moving in the new direction at the same speed.
but in asteroids it's more slippery, and the direction doesn't change immediately when you're thrusting, it's like it has to fight against the current direction and speed.
How can i change the direction and speed variables over time to reflect this? I don't have true physics available.
I'm in ct.js by the way, but this is a mostly general question.


texts:
I use btBvhTriangleMeshShape for static world collision. Generally this works fine, but recently I have encountered situations where the construction of btBvhTriangleMeshShape would crash.

In debug builds I get an assert from:

btQuantizedBvh::quantize(unsigned short *,class btVector3 const &,int)
btQuantizedBvh::mergeInternalNodeAabb(int,class btVector3 const &,class btVector3 const &)
btQuantizedBvh::buildTree(int,int)
btOptimizedBvh::build(class btStridingMeshInterface *,bool,class btVector3 const &,class btVector3 const &)
btBvhTriangleMeshShape::buildOptimizedBvh(void)
btBvhTriangleMeshShape::btBvhTriangleMeshShape(class btStridingMeshInterface *,bool,bool)

If I disable useQuantizedAabbCompression during construction the issue does not occur and all appears to work well.

Are there some requirements for the mesh geometry that I am missing?


texts:
I am unable to wrap my mind around designing a good way to manage resources in my game.
For instance, a vertex buffer in DirectX or OpenGL would lead me to believe I should have one central buffer in which I would adapt to my game. But how would I efficiently manage this?
If I had 2 game objects which used the same model but with different properties such as color or position, I would I assume reading from the same section of memory for geometry and having them each passing there own properties to the vertex/pixel shader. But what boggles me is having them read from the same section of the vertex buffer and having the vertex buffer manage the streaming of new data.

Textures and sound surface the same problem to me.


texts: Xbox Controller Not Connecting in Monogame Project

texts:
I have recently been playing around with the support of the wired XBox 360 controller in Windows development.  I am developing in C# in Visual Studio 2012.

I have created 2 projects.  The first (Project A) is an XNA project compiled in .Net 4.0.  The second (Project B) is a MonoGame 3.0 Windows Open GL project also compiled in .Net 4.0.

My issue is that my wired Xbox 360 controller can only be picked up in Project A - the XNA project.  I would really like to continue working with the Monogame type, but have hit a brick wall here.

I have verified that all the requisite libraries (OpenTK, Tao.SDL, SDL) are the exact same files being referenced by both projects.  Still, the Monogame project does not pick up the controller.

The exact state of the GamePadState variable is Connected = false.

Any ideas?

Again, same computer, same code for accessing the controller, only difference is XNA vs Monogame.


texts: Is there a name for assets in a video game which allude to a depth they don't have?

texts: A very particular question, hoping it's not too out of place here: is there a name within video game development for assets in a game that allude to a depth they don't have? Without knowing enough about video games to use the proper vocabulary, I'm thinking of houses which are hollow inside, distant landscape which you can't reach (and doesn't truly extend as far as it implies), etc.


texts: 3D zooming technique to maintain the relative position of an object on screen

texts:
Is it possible to zoom to a certain point on screen by modifying the field of view and rotating the view of the camera as to keep that point/object in the same place on screen while zooming ? Changing the camera position is not allowed.

I projected the 3D pos of the object on screen and remembered it.

Then on each frame I calculate the direction to it in camera space and then I construct a rotation matrix to align this direction to Z axis (in cam space).

After this, I calculate the direction from the camera to the object in world space and transform this vector with the matrix I obtained earlier and then use this final vector as the camera's new direction.

And it's actually "kinda working", the problem is that it is more/less off than the camera's rotation before starting to zoom depending on the area you are trying to zoom in (larger error on edges/corners).

It looks acceptable, but I'm not settling for only this. Any suggestions/resources for doing this technique perfectly? If some of you want to explain the math in detail, be my guest, I can understand these things well.


texts: Project 360 video on the inside of a iso sphere / polygon sphere

texts:
I'm creating a game in Unity. I have a iso sphere or polygon sphere, and I want to project a 360 video on the inside of the polygon sphere.

I've learned thow to put a 360 video on the inside of a sphere, following this thread, but how can I do it inside a polygon sphere, since the 360 video was created based on a sphere but not a polygon sphere?

Shader "Flip Normals" {
    Properties {
        _MainTex ("Base (RGB)", 2D) = "white" {}
    }
    SubShader {

        Tags { "RenderType" = "Opaque" }

        Cull Off

        CGPROGRAM

        #pragma surface surf Lambert vertex:vert
        sampler2D _MainTex;

        struct Input {
            float2 uv_MainTex;
            float4 color : COLOR;
        };

        void vert(inout appdata_full v) {
            v.normal.xyz = v.normal * -1;
        }

        void surf (Input IN, inout SurfaceOutput o) {
             fixed3 result = tex2D(_MainTex, IN.uv_MainTex);
             o.Albedo = result.rgb;
             o.Alpha = 1;
        }

        ENDCG

    }

      Fallback "Diffuse"
}


texts: Why isn't my mouse input working as expected in a DX10 game?

texts:
I've made myself a camera for a DirectX 10 game, and the keyboard control works fine. However, I can't see to get the mouse to work. My biggest problem is I can't find out how to hide the mouse on the display to allow a crosshair (I don't need a visual one) and make movement like it would be in any other common 3D game. I looked at this tutorial, but it doesn't seem to work (The mouse part, that is). Everything I try just seems to result in the camera spinning very fast...

I'm using C++ and DirectInput.


texts: Unity GIT - managing `.meta` files / Working with multiple repositories in Unity

texts:
(Original Question) → ScriptableObject has empty inspector after cloning from git

After cloning repository from git the data from the ScriptableObject asset isn't there.

An example of the problem:

A working example:

I assume the problem is in .gitignore because there is *.meta, so the data of ScriptableObject is lost. Is there a way to configure .gitignore to leave the *.meta files in some subdirectory?


texts: How to initialize a BitmapDrawable Android

texts: I have been using a shapeDrawable object for my android games player but now that i want to add some graphics in I have to use something different I was thinking of a BitmapDrawable but as I am new to this I have no idea how to initialize these sorts of classes, or how to get the image from the game resources could anyone put me on the right track or point me to some helpful tutorials.


texts: Orthographic Projection with variable FOV

texts:
We are building agame with orthographic view. The problem we face is the fact that with different resolution you can see different area of the game world. E.g. if you have higher resolution you can see more around you. To solve this we currently use a common scale factor that every model is scaled by, depending on resolution. But this has drawbacks when drawing shadows - I cannot set a higher view angle for the orthographic shadow camera, while when using the perspective shadow camera I get significantly worse shadow quality.

So the question is is there any way to controll FOV when using orthographic projection, or, more specifically, what is the easiest way to scale the world uniformly up or down with orthographic projection matrix?

I saw that in 3ds MAX you can control FOV for an orthographic camera I wonder how they implemented it.


texts: Relative movement in Box2D (keep object from falling off planet)

texts:
I'm creating a game with planets orbiting around a sun, like this:
The brown square is the earth, rotating around its center and around the sun. The yellow square is the sun, which doesn't move.
Now imagine a player standing on the planet, the planet moves at a velocity of 20 m/s. How do I prevent the player from falling off? I have to give the perception to the player that the planet isn't moving.
I got the gravity on earth working, but I don't know how I can keep the player on the planet! I have thought about two solutions until now:

Just apply the angular velocity and linear velocity of the planet on the player (if it's in a specified radius), I think this method will cause jittery movement/glitches.

Create a separate Box2D world for the planet and render this Box2D world with the rotation/translation of the planet. This method is complex though since it would add the problem of moving bodies between different worlds if the player would leave the planet. This image explains it:

I think there is another (better) way to fix this problem, but I haven't found a solution yet.


texts:
I'm trying to code a tic tac toe game in java and I need help figuring out how to efficiently and without freezing the program check if someone won the game.

I'm only in the design stages now, I haven't started programming anything but I'm wondering how would I know at all times the state of the game and exactly when someone wins?

Response to MarkR: (note: had to place comment here, it was too long for comment section)

It's not a homework problem, I'm trying to get more practice programming GUI's which I've only done once as a freshman in my second introductory programming course. I understand I'll have a 2D array. I plan to have a 2D integer array where x would equal 1 and o would equal 0. However, won't it take too much time if I check after every move if someone won the game? Is there a way or a data structure or algorithm I can use so that the program will know the state (when I say state I mean not just knowing every position on the board, the int array will take care of that, I mean knowing that user 1 will win if he places x on this block) of the game at all times and thus can know automatically when someone won?


texts: Why might render target in DirectX9 fail to work?

texts:
I'm trying to render to a texture, but nothing is being drawn. Everything before SetRenderTarget is rendered properly, everything after second SetRenderTarget is visible on the screen. Just the part that should have been rendered to a texture is ignored.

Below is a Delphi code showing what I'm doing. What am I missing?

//Random texture size, non-power-of-two textures supported by card
//Tried with 512x512, same results
FStaticWidth := 806;
FStaticHeight := 413;

//Error checking code left out for clarity
//But every operation is checked

//Create texture
dev.CreateTexture(FStaticWidth, FStaticHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, FStaticText, nil);
FStaticText.GetSurfaceLevel(0, surf);

//Save everything;
dev.GetViewport(oldVp);
dev.GetRenderTarget(0, oldTarget);

//Change render target
dev.EndScene;
dev.SetRenderTarget(0, surf);
dev.BeginScene;

//Reset viewport
vp.X := 0;
vp.Y := 0;
vp.Width := FStaticWidth;
vp.Height := FStaticHeight;
vp.MinZ := -1000;
vp.MaxZ := 1000;
dev.SetViewport(vp);

//Draw
dev.Clear(0, nil, D3DCLEAR_TARGET or D3DCLEAR_ZBUFFER, $FF112233, 1.0, 0);

//...whatever I do here, it's ignored.
//It doesn't appear neither on the surface, nor on the screen.
//Not even dev.Clear() above works.

//Restore render target
dev.EndScene;
dev.SetRenderTarget(0, OldTarget);
dev.BeginScene;

//Restore viewport
dev.SetViewport(oldVp);

//Dump the texture to a file
D3DXSaveSurfaceToFileW(PWideChar(AppFolder+'\static-surf.bmp'), D3DXIFF_BMP, surf, nil, nil);
//The file is a FStaticWidth x FStaticHeight bitmap,
//containing only black transparent ($00000000) pixels.

Here's how it looks like in PIX:

12570   <0x05AC9EA0> IDirect3DDevice9::GetViewport(0x0018FD40)
12571   <0x05AC9EA0> IDirect3DDevice9::GetRenderTarget(0x00000000, 0x0018FD80 --> 0x05ACA9B8)
12572   <0x05AC9EA0> IDirect3DDevice9::EndScene()
12573   <0x05AC9EA0> IDirect3DDevice9::SetRenderTarget(0x00000000, 0x05B53878)
12574   <0x05AC9EA0> IDirect3DDevice9::BeginScene()
12575   <0x05AC9EA0> IDirect3DDevice9::SetViewport(0x0018FD58)
12576   <0x05AC9EA0> IDirect3DDevice9::Clear(0x00000000, NULL, 0x00000003, D3DCOLOR_ARGB(0xff,0x11,0x22,0x33), 1.000f, 0x00000000)
12577   <0x05AC9EA0> IDirect3DDevice9::EndScene()
12578   <0x05AC9EA0> IDirect3DDevice9::SetRenderTarget(0x00000000, 0x05ACA9B8)
12579   <0x05AC9EA0> IDirect3DDevice9::BeginScene()
12580   <0x05AC9EA0> IDirect3DDevice9::SetViewport(0x0018FD40)

Render target 0x05B53878 remains empty (transparent black) after each event.


texts: What's better - drawing every interval that the window updates, or drawing when necessary and updating when drawing?

texts:
So what's better?

In case the title is a bit confusing I mean:

1) Drawing every window update interval. For example, for a 60FPS window, every 17 milliseconds. For example:

window.setFramerateLimit(60); //Update every 17 milliseconds for 60FPS
while(window.isOpen()) {
window.display();
}

Or

2) Drawing when you need to (for example, when a sprite moves) and displaying it straight after.
For example:

void func(sf::RenderWindow& window) {
window.draw(sf::Sprite()); //Whatever you're drawing
window.display();
}

Or is there a much better way?


texts:
I am looking for documentation that explains the different kinds of (well the major ones anyway) 2D space partitioning algorithms & data structures.

Any pointers besides 'Google it and sift through hundreds of papers'. A book perhaps?


texts: Opening an XML in Unity3D when the game is built

texts:
At the moment, my game can open up an XML file inside the editor when I run it. In my XMLReader.cs I'm loading in my file like so:

_xmlDocument.Load(Application.dataPath + "\\HV_Settings\\Settings.xml");

This class also deals with what the XML should do once it has been read in.

However, when I build the game and run the exe, this file isn't called. I know that I can store this file in the C drive, but I want to keep everything in one place so when I start to release what I'm working on, the user doesn't need to do anything.

Am I doing something silly which is causing the XML not to be read?


texts: Does Pokemon use any deep A.I in battle?

texts:
A Pokemon wild battle. The enemy may have up to 4 moves.

I am wondering, is there any.. A.I going on here, or does the enemy simply take a random move and then executes it? Are there not any battle factors/conditions that may change the enemy's behavior?

I guess it makes sense to categorize moves by "Offensive" "Defensive" and/or "Healing", and from there make choices depending on HP etc... dunno.


texts: Render 2D textures on a 3D object's face

texts:
I am not familiar with 3D graphics, and I'd like to know the right way to render some 2D figures on different points of a wider face of a 3D object. My 3D object is just a cube representing a poker table. I have a 2D png for players' placeholders, and I'd like to render these figures on the 3D object where needed. An alternative solution would be to render the whole face with a big picture containing all the placeholders figures. However, it would be a waste of memory and thus less efficient.

What do you suggest?


texts: Questions about property-centric game object runtime

texts:
I was reading Game Engine Architecture by Jason Gregory

So according to him, I should use an array of entities, and arrays for each property, such as an array gameObjectsPosition, gameObjectsHealth... But in my case, the world is divided in a chunk grid. Each chunk have its own array (or for the moment vector but I plane to change that) of entities (game objects). Then, what should I do? Create a single array containing all entities positions wherever there are (and so one for health, level, orientations, dimensions...), or create the property specific arrays in each chunk?
Then how to process these property arrays? I mean, for each dynamic entity, I could update dimensions, sizes and health or I could for each property update each entity. Example:

 UpdateWorld() {
     for each entity in dynamicEntities
          entity.updatePosition()
          entity.updateHealth()
          entity.updateDimensions()
          entity.updateMesh()
 }

 UpdateWorld() {
     for each entity in dynamicEntities
          entity.updatePosition()
     for each entity in dynamicEntities
          entity.updateHealth()
     for each entity in dynamicEntities
          entity.updateDimensions()
     for each entity in dynamicEntities
          entity.updateMesh()
 }

How to handle sizes for each chunk? That'd mean each chunk have an array with MAX_ENT_PER_CHUNK (say in my example 1024), and then if a chunk have 24 entities there would be 1000 entities useless. Also, I can't use more than 1024 entities. I could use pointers, but then the CPU cache would hit a lot of misses.
How to handle IDs? If I have an array of entities I need to use IDs. I can use macro SID has specified in the book, but the IDs are not ordinals (they may not begin at 0)


texts:
I'm building a system for distributing ingame events for a strategy game. The game is heavily driven by the events and each country/player should receive one or more per time unit.

The algorithm is similar to the "The Soft-coded Probabilities Solution" from this question: How do I create a weighted collection and then pick a random element from it?

The main differences are:

I need conditions for if events can happen or not, like only triggers if unrest is above 2% or if you are at war etc. Maybe half the events will have conditions (but this may change over time as more are added while the algorithm probably won't).
I need a mechanism to prevent the same event repeating for the same player in too short a time period. This applies to some events but not all.

It seems that no matter how I go about this I have to do either a lot of condition checking in advance to maintain my list(s) or a lot of iteration over events that are anyway not selectable. So is this algorithm still a good choice to build upon in this case or should I be looking elsewhere?