texts: How to properly setup unit testing for my c++ game project?

texts:
I'm currently creating a 2d game in C++ using visual studio and utilizing gtest/gmock for my testing framework. The problem I'm having is I'm not sure what my best option is for testing. I'm using SDL and opengl and if I try and test normally my test project crashes when it hits any opengl calls. I'm using glew to access opengl so in my game I setup glew and call glew.init() within my window class:

void Window::Initialize()
    {
        if (SDL_Init(SDL_INIT_VIDEO) != 0)
        {
            SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SDL Error", "SDL did not initialize", nullptr);
            SDL_Quit();
        }

        /** All attributes need to be set before window creation **/

        p_window = SDL_CreateWindow("Shadow Gods", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1024, 768, SDL_WINDOW_OPENGL);
        if (!p_window)
        {
            LOG("ERROR: SDL window failed to initialize! SDL error: %s\n", SDL_GetError());
            SDL_Quit();
        }

        glContext = SDL_GL_CreateContext(p_window);

        glewExperimental = GL_TRUE;
        if (glewInit() != GLEW_OK)
        {
            LOG("ERROR: GLEW failed to initialize!");

            SDL_GL_DeleteContext(glContext);
            SDL_DestroyWindow(p_window);
            SDL_Quit();
        }

        //Sets the values that the depth and color buffers will be set to when glClear is called
        glClearDepth(1.0);
        glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    }

Now in order to test any of my classes that utilize openGL calls I need to make sure to create a window object first and initialize before calling any other code:

#include <gtest\gtest.h>
#include "GameEngine\Window.h"
#include "GameEngine\Sprite.h"

TEST(SpriteClassTest, SpriteInitialize_True)
{
    Blz::Window win;
    win.Initialize();
    Sprite sprite;
    ASSERT_TRUE(sprite.Init(23, 32, 100, 100, "../Game/CharImage.png"));
}

I don't want to have to do this for every class that utilizes opengl since 1.) It's redundant and 2.) My tests might be failing because there is something wrong with the window initialize() function instead of what tests were designed for. So is there a better way? If not, how could I get around having to include my "window.h" header in every file and having to initialize the window in every test? Can I do this globally with gtest?


texts:
I am using opengl, and a simple texture or mesh to draw a leaf.

Can somebody show me a nice movement method to simulating leafs in a 3d world?

thanks,
Leslie


texts: Improving the monster tamer battle mechanics: 2 choices

texts:
I'm developing a new monster taming/hunting game and I wanted to make some changes to the battle mechanics.  Which would you find more fun and can you offer any suggestions to improve on what I've done.  I'm leaning more to just option 2 although it will be a bit more difficult to deal with the AI.

Current base for the mechanics:

2 monsters face off head to head
They use different moves to damage
each other trying to kill the other.
Various non damaging moves can
be used to (increase/decrease stats, cause poison, paralyzing
effects)
There are different types of attacks that can be resisted or
more effective against certain types of monsters (eg. Holy attacks do
extra damage to Demons).

Basically, I'm starting with the simple Pokemon style battle.  I would like to add either one or both of these changes:

Option 1: Add in a recovery stat for moves so that the "turns" are based on how much the monster has to recover.  When a monster uses a move, the move's recovery stat is added to the monster's. When a monster's recovery stat reaches 0 it can perform a move.
     Explode - A high damaging move requires 50 recovery after being used.
     Poke - A smaller damaging move requires 20 recovery after being used.
     (Both start at 0 recovery, A goes first just because)

Monster A uses Explode (its recovery is at 50)
Monster B uses Poke (its recovery is at 20)
a check is done to see which has lower recovery and they go next
   (20 "time units" goes by and A now has 30 recovery, B is down to 0 and can perform a move again.
Monster B uses Poke again (recovery at 20) (A is still at 30)
Another 20 "time units" goes by and A is at 10 and B is at 0 again.
Monster B can attack again

This adds a timing element to the battle.  Instead of each monster being able to attack once a turn, you can use smaller attacks or status changing moves quickly before your opponent recovers from their attack.  Status effects may cause a monster to require more recovery each turn (like a slowing effect) or a hasting effect could be applied.

Option 2:  Use 2 monsters in the same battle with a forward and rear position.  Moves have a range value that determines if you can hit the forward, rear, or both monsters.

I think generally, melee style attacks would be higher damage but only affect the forward monster.  You would often want a tank (high defense) monster to take these hits with a ranged attacker in the rear position like an archer or mage.  Certain moves could damage both positions and you could have the option of having the monsters switch positions.

I think the strategy wouldn't be limited to a melee tank in the front with ranged in the back, as a melee tank may be susceptible to special attacks and certain monsters would do more damage in the front while being vulnerable to attack.

Example moves that take advantage of this mechanic:

Intercept - forward monster takes the next attack aimed at the rear position.
Force switch - forces the opponent monsters to switch positions
Pierce - 1/2 damage is done to the rear position if an attack on the front is successful.
Dragon's breath - all monsters (including your forward position if you are the rear) in front of you are hit with fire damage. (this would be a good move to switch your positions prior to using)
Goblin Mortar - fires 3 spaces away (requires the attacker to be in the rear to hit the rear opponent)


texts: I have a 2D grid with a number of cells. I need to find a path from one cell to another. There are no obstacles or opponents, and all cells are identical. What is a SUPER SIMPLE routine to calculate the shortest path? I have read about A* and other routines, but they are waaaaaaaay overkill in my case at this point. (Maybe I will need them later, in the future.) Thanks!


texts:
I am trying to get the sprite of a tile in unity from where a raycast hits. Right now it only works in some cases, and always in positive x.

This is my current code.

Vector3Int LocalPos = new Vector3Int((int)hit.point.x, (int)hit.point.y,0);

Sprite spr = tilemap.GetSprite(LocalPos);

From what I can tell it gets the correct sprite.

Edit: I removed pointless code


texts:
Sorry if this is such a simple thing, but for some reason I can't get my head around it.

Imagine you have a world, that you have "seeded" with a value.  You base all your randomisations off this value - perhaps you made mountains, monsters, or any other such thing.

Then the user saves her game, and then picks up where she left off a few days later.

We can store the seed we started with easily enough.  But, it will reset to the beginning.  What I would actually like is to "start off where we left off".  Therefore, with persistence, do I need to be storing the iterations that we applied on said random number generator?  When loading the saved game, do we go through the iterations to arrive at the place we should be?

An alternate would be to initialise a world using a random seed, and then throw it away when we save, so that any subsequent load, has a new random number generator.

Thoughts and ideas welcome :)

Edit

To reiterate from the comment I made below, my first thought was to wrap all access to the Random class, and track the number of iterations.  This could be saved alongside the seed.  When loading, one would re-initialise the class, and then loop through the iterations (effectively throwing away the result) to arrive at the point you'd have been at originally.

Also, added c# tag.


texts: Use of Collections in Android Game Development is not encouraged?

texts:
While working on a game project for Android i was digging for some information on performance optimization for game code. And i came to know that use of Java Collections like List,Arraylist etc are not encouraged in game codes,though collection is an useful tool in Java programming.Why is it so? I would like to know technical details as how much impact can Collection framework have on Android systems and why?
Any help in this regard will be great.


texts:
Right now, I'm planning a new FPS single-player Half-Life 2/Call of Duty: Black Ops/Crysis 2-like, and I'm trying to determine what game engine should I use. Right now, my team is me, as a programmer, and only one models/textures artist, so each model takes us a lot of time.

I thought about:

Source Engine - because it has a lot of existing content I can use to write my game much more quickly. The main disadvantage of Source is that it lacks in the graphics area (especially in vegetation).
Unity - the ability to use C#, which is my favourite programming language. It is perfect when it comes to graphics, but it doesn't have so much existing content like Source.  Plus, it is cross platform.

I also thought about some open source game engines, but most of them (Ogre3D, for example) lacks in development speed and some graphics capabilities.

If there was some model/textures/sound repository (not necessarily free, but also not really expensive), I'd use Unity.

UDK is not an option, as it doesn't give me access to native code and I'll need to use some libraries wrriten in C++.

Are there any more advantages/disadvantages to each engine? Feel free to suggest new  game engines. Also, in your opinion, what game engine should I use? Do you know some content repository I can use?


texts: What is the connection between these LibGDX concepts?

texts:
In LibGDX, what is the connection between these concepts: stage, camera, viewport, batch (spritebatch), projection matrix, tiledmap?

Currently my game has

3 stages:

UI stage
entity stage
tiledmap stage

2 cameras:

hud camera (for UI)
map camera (for map)

2 batches:

spritebatch for rendering particles
batch from the tiled map renderer (used in map and entity stage)

3 viewports:

for entity stage
for UI stage
for tiled map stage

I am very confused at this point at how all these components connect. My whole game works, except when I resize my main menu screen, the particles in my next screen get drawn in the wrong position. Meaning that the resize information does not reach the particle drawer.

I feel like the reason I am having a lot of trouble debugging it, is because I don't understand well enough how they relate to each other.

Can anyone help me clarifying this structure?


texts:
I am using CocoonJS launcher on iOS for a simple tiled game. Calling canvas drawImage for tiles adds a shadow or ghost border around tiles. See this screenshot:
http://martindrapeau.github.io/cocoon-mario/img/screenshot.png

The canvas is 960 pixels wide. Using viewport meta tag:

Using CocoonJS Launcher 2.1.1.2 on iOS 8 (iPad mini and iPhone 6).
Same behavior with anti-aliasing turned off.
Same behavior with Scale Aspect Fit and No Scale.

If someone could help me eliminate this problem, would be great.

Extra notes:
See here for the zip to try it out in the CocoonJS launcher:
http://martindrapeau.github.io/cocoon-mario/cocoon-mario.zip

And the HTML5 game to play in your browser. Notice it looks find in any browser.
http://martindrapeau.github.io/cocoon-mario/


texts:
I recently started learning python and I'm working on a dungeon generator, using images for the rooms, hallways and junctions. Example of desired result.

So far I managed to generate a X * Y map and avoid the rooms from escaping the background image or colliding with each other (collision test); I was going to work on pathfinding to generate the corridors but ran into a problem. As you can see in the first image, some corridors and junctions are 1-tile wide while others are 2, and potentially wider.

Ideally I would use the generated grid to see where the corridors would go and "paste" whichever corridor or junction image would fit in that space.

Any tips on how to incorporate that into the pathfinding algorithm?, or if you have a better idea to generate the corridors, I'm all ears. Perhaps generating a single room, growing a corridor from there and adding a room at the end of that corridor, rinse and repeat?


texts: Polygon trigger colliders for 2D platformer

texts: I'm creating a 2D platformer in MonoGame and I'm thinking of using AABB as physical colliders for characters and then have a trigger polygon collider on each character for checking for example if an enemy's weapon is touching the player, making it more precise. The polygon collider is animated so every frame in every animation has its own points. That's a lot of work. Is that precision needed? What is usually done in this situation?


texts:
Id' like to create impression of shaking holographic image of NPC in Unity 2018, but moving it with transform will cause unnecesary transform-rigidbody syncing, and using Rigodbody.position isn't an option for other reasons (too long to explain). I could write custom shader for moving vertices by given vector, but I'd like to keep flexibility of Standard Shader.

Is there any way to properly render object at different position than it's transform.position? I was thinking about passing custom matrix to shader, but not sure which matrix should I overwrite and if it's not gonna complicate things (like break shadows or something).


texts: How can I make orange/lemon skin normal map?

texts: What would be the easiest way to make a bump map of the dimples on a citrus fruit such as an orange or lemon in gimp/photoshop without using pictures of it? e.g:


texts:
In most games the whole world is small enough to fit into memory, however there are games where this is not the case, how is this archived, how can the game still run fluid even though the world is so big and maybe even dynamic? How does the world change in memory while the player moves?

Examples for this include the TES games (Skyrim, Oblivion, Morrowind), MMORPGs (World of Warcraft), Diablo, Titan Quest, Dwarf Fortress, Far Cry.


texts: How to account for speed of the vehicle when shooting shells from it?

texts:
I'm developing a simple 3D ship game using libgdx and bullet.

When a user taps the mouse I create a new shell object and send it in the direction of the mouse click. However, if the user has tapped the mouse in the direction where the ship is currently moving, the ship catches up to the shells very quickly and can sometimes even get hit by them - simply because the speed of shells and the ship are quite comparable.

I think I need to account for ship speed when generating the initial impulse for the shells, and I tried doing that (see "new line added"), but I cannot figure out if what I'm doing is the proper way and if yes, how to calculate the correct coefficient.

public void createShell(Vector3 origin, Vector3 direction, Vector3 platformVelocity, float velocity) {
    long shellId = System.currentTimeMillis(); // hack
    ShellState state = getState().createShellState(shellId, origin.x, origin.y, origin.z);
    ShellEntity entity = EntityFactory.getInstance().createShellEntity(shellId, state);

    add(entity);
    entity.getBody().applyCentralImpulse(platformVelocity.mul(velocity * 0.02f)); // new line added, to compensate for the moving platform, no idea how to calculate proper coefficient
    entity.getBody().applyCentralImpulse(direction.nor().mul(velocity));
}

private final Vector3 v3 = new Vector3();
public void shootGun(Vector3 direction) {
    Vector3 shipVelocity = world.getShipEntities().get(id).getBody().getLinearVelocity();
    world.getState().getShipStates().get(id).transform.getTranslation(v3); // current location of our ship
    v3.add(direction.nor().mul(10.0f)); // hack; this is to avoid shell immediately impacting the ship that it got shot out from
    world.createShell(v3, direction, shipVelocity, 500);
}

Edit - I switched to:

    v3.set(direction);
    v3.nor().mul(velocity);

    if (platformVelocity != null)
        v3.add(platformVelocity);

    entity.getBody().setLinearVelocity(v3);

And it seems to work (so adding the velocities and setting them on the body).

However, I'm not sure what the drawbacks are and why the tutorial application used impulses instead of setting velocities.

I also think that while this is physically correct it leads to strange results (gun range is two times further when shooting forward than when shooting sideways).

The root cause is because really the shells are indeed too slow, but I like them slow as otherwise the gameplay is too fast-paced, and they travel too far.

I think I need some compromise between physics-realistic and ignore-platform-velocity.


texts: How do I get buffers from another class for CreateBuffer

texts:
I believe this is not strictly specific to DirectX but just to pure c++ language problem.

I have a class (simplified):

class A {
public:
    ID3D11Buffer* getVBuffer() const {
        return m_vbuffer;
    }

    // I will make this public for this example
    ID3D11Buffer* m_vbuffer;
};

and then in some other place I am creating vertex buffer:

device->CreateBuffer( ..., &instanceOfA->m_vbuffer );

it works ok, but why with the getter method doesn't?

ID3D11Buffer* _vertexBuffer = instanceOfA->getVBuffer();
device->CreateBuffer( ..., &_vertexBuffer  );

it crashes at Map function with access violation, but I'd like to have getter method used.

// EDIT

when I wrote like this:

device->CreateBuffer( ..., &instanceOfA->getVBuffer()  );

the compiler (VS2012) told me:

error C2102: '&' requires l-value

Is it then even possible to use getters in this situation?


texts:
What I don't need is an MMORPG engine, at the moment.

What I do need is a flexible easy-to-use engine that I can make a mock-up with. I don't need support for more than 10 players in an instance, so any multiplayer platform is probably fine.

I need an engine with which I can create the following core features:

Waves of simple AI enemies that have specific objectives (move to point A, destroy target, move to point B). The units present can be between 50-200 in number.
An over-the-shoulder view and the ability to control a team of 3 (like Mass Effect or the latest Dragon Age)
Functioning inventory system

Right now, all I can really think of is Unreal or Source. Any other suggestions? Again, this is a proving mock-up, not an actual MMO.

I'm not terribly worried about the visual aspects as we just want to test mechanics.

Note: Can write some scripts in Python, Ruby, or Lua, if necessary.


texts: How to retrieve vertex information from ID3DXMesh

texts:
I need to know the position of each vertex (and triangles) from a mesh (a pointer to ID3DXMesh, created by calling functions like D3DXCreateBox, D3DXCreateTeapot and D3DXCreateSphere) to perform some collision detection.

I've tried using GetVertexBuffer() and GetIndexBuffer() but I don't know how to use the structures to retrieve point data in the world coordinate system. How can I achieve that?


texts: How do I use the morpher modifier in 3dsmax to morph into several targets simultaneously?

texts: I have a 3D-Face from Facegen here including all necessary phenomes' positions. But these targets are separated into upper, lower teeth, sock and eyes. How do I combine them for the face to morph into each facial position at once?


texts: How can I add 3D animation to my Pygame window?

texts:
I've developed a quiz game using Pygame but now I'm being asked to implement a 3D animation element (a game show host) to the game.

I used Pygame as I was told it would be an easy enough language to learn and make something simple, however I see now that it seems very limited in terms of 3D animation.

I've seen OpenGL being used with Pygame and what I need is for my game to run exactly as it is, but with the 3D element (game show host) added on the corner of the window for example.

How can I use OpenGL in Pygame in order to do this?


texts: How can one implement a 3D Grid-based Line of Sight algorithm?

texts:
I'm creating a grid based Tactical RPG game in XNA.

Image below kinda explains the idea. But if you've played Dwarf Fortress before, I'm basically trying to create that 3D line of sight and you can ignore my explanation.

(Also I don't care about how efficient the algorithm is at this time.)

Currently I am drawing a Bresenham line to each square within a radius, and each square I visit I check in the direction I am headed if I run into any walls.

The code below is my check for if a position is visible. sx, sy, sz is the change in the grid. For instance, if the line is traveling north east, sx = 1, sy = -1, sz = 0. if I'm headed straight up it would be sx=0, sy = 0, sz = 1; etc.

    private bool IsVisible(APoint Cur, int sx, int sy, int sz)
    {
        bool Visible = true;
        if (ValidCoordinates(Cur))
        {
            int newsx = -1;
            int newsy = -1;
            int newsz = -1;
            switch (sx)
            {
                case -1:
                    newsx = 3; //west
                    break;
                case 0:
                    newsx = -1;
                    break;
                case 1:
                    newsx = 1; //east
                    break;
            }

            switch (sy)
            {
                case -1:
                    newsy = 0;// north
                    break;
                case 0:
                    newsy = -1;
                    break;
                case 1:
                    newsy = 2; //south
                    break;
            }

            switch (sz)
            {
                case -1:
                    newsz = 4; // down
                    break;
                case 0:
                    newsz = -1;
                    break;
                case 1:
                    newsz = 5; // up
                    break;
            }
            if (ValidCoordinates(Cur.X + sx, Cur.Y + sy, Cur.Z + sz))
            {
                if (newsx != -1 && newsy == -1 && newsz == -1) // X only.
                {
                    if (TileArray[Cur.X + sx, Cur.Y + sy, Cur.Z + sz].AllowSight(newsx))
                        Visible = true;
                    else
                        Visible = false;
                }

                if (newsx == -1 && newsy != -1 && newsz == -1) // Y only.
                {
                    if (TileArray[Cur.X + sx, Cur.Y + sy, Cur.Z + sz].AllowSight(newsy))
                        Visible = true;
                    else
                        Visible = false;
                }

                if (newsx != -1 && newsy != -1 && newsz == -1) // X and Y only
                {
                    if (Visible && TileArray[Cur.X + sx, Cur.Y + sy, Cur.Z + sz].AllowSight(newsx))
                        Visible = true;
                    else
                        Visible = false;

                    if (Visible && TileArray[Cur.X + sx, Cur.Y + sy, Cur.Z + sz].AllowSight(newsy))
                        Visible = true;
                    else
                        Visible = false;
                }

            }
            return Visible;
        }
        return false;
    }

The Allow sight function is here:

        public bool AllowSight(int i)
    {
        if (i == -1)
            return true;

        if (i >= 0 && i <= 3)
        {
            if (TileCreateCliff && HDifferenceUp > 0)
            {
                return false;
            }
        }

        if (i == 4)
        {
            if (TileVoid)
                return true;
            else
                return false;
        }
        if (i == 5)
        {
            if (TileVoid)
                return true;
            else
                return false;
        }
        return true;
    }

This works fine when my character is on the base level, but looking up at higher elevations, or looking down just causes everything to break.

How should I implement this?


texts: If we generate mipmaps for a texture using GL_GENERATE_MIPMAP (or glGenerateMipmap), how big can the original texture be? Is it the size returned by GL_MAX_TEXTURE_SIZE, or half of it?


texts: understanding spatial hash function behaviour and Knuth for int64

texts:
I implemented open-indexing sparse 2D spatial HashMap, and I'm quite satisified with performance ( ~30-70 CPU cycles to get object at particular location for size ~16 Milion objects ).

However, I don't understand behaviour of hashFunction. Just by trial and error I found out that best performing for my case is slightly modified  Knuth's hash function:

return i * 2654435761 >> 8;
( original Knuth's hash function is return i * 2654435761 >> 16; )

with this hash function I get no more than 1-2 buckets maped to the same hash (when capacity is sufficient) ... the histogram looks like:

689780 without collision (buckets mapped to same hash)
358791 with 1 colision
5 with 3 collisions

but I have no idea why, and why it is performing better with >>8 than >>16), and if this behaviour is general or somehow specific for my settings

I also tried other hash functions which are used as pseudo random generators .. some are here:

inline ULONG hashFunc( ULONG i ) {
// see http://stackoverflow.com/questions/664014/what-integer-hash-function-are-good-that-accepts-an-integer-hash-key
//return  ( ( 2166136261UL ^ i ) * 16777619 );              // VERY BAD
//return  ( 2166136261UL ^ (i * 16777619) );                // VERY BAD
//return ((i >> 16)^i);                                     // NOT WORKING
//return ( i * 2654435761 >> 16 );                          // Knuth's multiplicative method // GOOD
return ( i * 2654435761 >> 8 );                             // GOOD, even better than Knuth for map size 2^16 ( 65536 fields )
//return ( i * 2654435761 >> 16 ) ^ i;                      // REASONABLY GOOD but worse than pure Knuth
//i = ((i >> 16) ^ i) * 0x45d9f3b; i = ((i >> 16) ^ i) * 0x45d9f3b; return  ((i >> 16) ^ i);                                        // REASONABLY GOOD but worse than pure Knuth
//i = ((i >> 16) ^ i) * 0x45d9f3b; return  ((i >> 16) ^ i); // LESS GOOD
//i = ((i >> 16) ^ i) * 0x3335b369; i = ((i >> 16) ^ i) * 0x3335b369; return  ((i >> 16) ^ i);                                        // LESS GOOD
};

all are performing worse than Knuth or modified Knuth. ( Just empirical observation, no idea why )

The questions:

Do you have experience that some other hash function performs better for such job ?
Do you understand the behaviour?
Do you know how to properly make analogy to Knuth 32bit for 64bit integer ( because if I understand it correctly, the 32bit golden ratio multiplicator is prime number, I'm not sure If it is easy to get multiplicator with such property for 64bit )

some details for explanation:

I have to say that I use the hash function somewhat differently than is common:

First I discretize double x,y to uint16 ix,iy
Then I compute bucket index as uint32 bucket = (iy<<16)+ix;
Then I compute the uint hash = hashFunc()&mask where mask = capacity -1 and capacity is power of 2 ( &mask is basically modulo capacity  ). I know that many people recommend use prime-number capacity for hashmap, but I find it tricky to find proper prime number during resize-ing, and also & is faster than modulo.

My hashmap is open-indexing, and it is able to realize if the object is in particular particular grid tile (ix,iy = bucket ) without actually dereferencing the object pointer, which I think gives it speed advantage.

each memory field of the hashmap stores not only pointer to the object TYPE* object but also the bucket index uint32 bucket to which the object belong and number of objects uint n with the same hash. The bucket index is used to check if object belong to particular (ix,iy) position or if it was mapped to that hash by chance (when there are collisions). I do not store hash since I think it is faster compute it on the fly than use more memory.

( you can see code here ( HashMap | HashMap2D | test_HashMap2D) If you are interested


texts: Costs/profit of/when starting an indie company

texts:
In short, I want to start a game company. I do not have much coding experience (just basic understanding and ability to write basic programs), any graphics design experience, any audio mixing experience, or whatever else technical. However, I do have a lot of ideas, great analytical skills and a very logical approach to life. I do not have any friends who are even remotely technical (or creative in regards to games for that matter).

So now that we've cleared that up, my question is this: how much, minimally, would it cost me to start such a company? I know that a game could be developed in under half a year, which means it would have to operate for half a year prior, and that's assuming that the people working on the first project do their jobs good, don't leave game breaking bugs, a bunch of minor bugs, etc.. So how much would it cost me, and what would be the likely profit in half a year? I'm looking at minimal costs here, as to do it, I would have to sell my current apartment and buy a new, smaller one, pay taxes, and likely move to US/CA/UK to be closer to technologically advanced people (and be able to speak the language of course).

EDIT: I'm looking at a small project for starters, not a huge AAA title.


texts: Storing player's tilemap position inside the player object

texts:
I'm trying to create a multidimensional array as a sort of 2D map for a text-based RPG game. I want to create a multidimensional array that's, for example, 5x5. The array would be filled with 0s to represent a space void of an object. Other numbers would represent the player on the map, an enemy, an npc, a skill-object (like an enchantment table, etc.), doors that link to maps, and chests. They would all have different values to represent what object is there. If a player tries walking into a chest, it would instead loot the chest. Then the chest would be reset to 0 to represent the empty space, letting the player walk there and representing that there is no more chest. If the player tries walking over an enemy, it would instead engage combat (handled by a separate class and functions). Walking over a number representing a door would link to another multidimensional array that represents another map.

I want to know what kind of property I need to put inside the player class to handle where he is on the map. A function would then change that value to move him around the map. Would creating a class for a map be a good idea? Would I store the values for the objects there or in the individual classes for those objects? How would I go about this? Thank you for your help. For reference, here's my player class (careful, it's long...):

public class Player
{
    public string   name        { get; set; }        //Name of Player
    public int      level       { get; set; }        //Player's combat level         (average of combat-related skills' levels)
    public int      health      { get; set; }        //Player's health               (player dies when this value reaches 0)
    public int      health_max  { get; set; }        //Player's maximum health
    public int      stamina     { get; set; }        //Player's stamina              (used for power attacks, slowly recharges on own)
    public int      stamina_max { get; set; }        //Player's maxiumum stamina
    public int      fatigue     { get; set; }        //Player's fatigue rate         (player cannot fight or run while fatigue is 100)
    public int      hunger      { get; set; }        //Player's hunger level         (player becomes weaker as hunger increases)
    public int      style       { get; set; }        //Player's fighting style       (refer to styles.txt)
    // tons of skills fields
}


texts:
I'm trying to create a super simple no frills off-screen process... I have the device, I can export the texture to Image... etc... I'm having one heck of a time just getting a simple Triangle Strip to display an image so I can run pixel shaders on it... I have found examples and even have the Direct3D cookbook.. However, I don't need all the camera functions and so on... I can't seem strip out the unnecessary bits and still have it work... please help...

I just need a super simple quad renderer that aligns to the renderer target...


texts: I know how to implement pixel perfect collision, but how would I do this with rotations applied to my sprite?


texts: Are there still favored of using bluetooth devices today in modern games for multiplayer gameplay?

texts:
I was wondering. Most multiplayer gameplay always favored by Wi-fi during team-up or to compete each other. I know that when in comes in huge groups (say 100 to 500 players or more online) in online games whether it's cooperation or battle, most players relying on Wi-fi to play in very huge group.

What if some persons wants to play in small groups and can be played offline (like in racing games or fighting games for example) using smartphones via bluetooth? The question is that are there most game apps for multiplayer gameplay still favored or popular of using bluetooth when playing in a very few no. of players (let's say only two players) on a certain game?

Also, is it possible to create a game app for iPhone or any smartphones that run on Android that features bluetooth for multiplayer via Unity 3D game development software?


texts: Unity - change sprites to something that uses less memory

texts:
I have a game that uses only silhuette textures, but they take up waay too much memory (360 MB overall and this is a mobile game) so I plan to avoid using sprites with alpha punchouts (1 bit alphas). From what I gathered, I could use an asset from Unity store like SVG importer, but I have no financial means to do so. So I plan to make low poly 3D (in fact 2D) planes that somewhat cover my textures.
Now, I have a lot of sprites already. I saw that Unity can create a 2D mesh collider around my sprites. Can I use that to create my meshes and then apply a single colour unlit material to them? How would it roughly effect memory usage as opposed to my generally 500x600 sprites?
If I'm going in the wrong direction, is there a way to create Shapes, just like in Photoshop or GIMP?


texts: What programs could I use to render an animation based on points ("atoms") rather than models?

texts:
I've rendered the following animation using JavaScript and canvas:

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

For that, I used points exclusively - i.e., there is no mesh/trigs, not only the photons, but the geometry of the prism itself is made out of tons of small atoms. I then projected each atom to screen, ordered by depth and blended transparencies. I really like this atom-based rendering strategy, because it is very flexible, allowing me to create all sort of crazy geometries procedurally easily; doing the same for meshes would be hard. Obviously, this is way too slow on JavaScript/canvas, so it isn't really practical. I could do it with WebGL, but that'd be a lot of work.

Are there game engines and/or 3D software that I could use to make this kind of rendering strategy possible in an actual game? What exactly am I looking for? Is this a known pattern/feature? Keywords and references would be greatly appreciated.


texts: How can I achieve a similar day/night cycle of the sky, but in a 2D game?

texts:
I'm currently working on a 2D game, and I was wondering if anyone around here has experience/tips in achieving this sort of day/night transition of the sky?

I've done some reading, and some people do it as a shader and change gradient values in the shader; others swap out planes. I've not done anything similar before, thus my question here.


texts: How do I generate a 3D race track from a spline?

texts:
I want to generate a 3-dimensional race track around a spline that describes its shape.  Here's an illustrative video.

The track should be an endless tunnel that sweeps along a 3D spline, with some obstacles thrown in.  My best idea so far has been to loft a circle shape along the spline.

I would also like some pointers into how to manage the geometry i.e. how to create it from the loft operation, manage its 'lifecycle' in memory, collision and texturing.


texts: Facebook link gives "This game is not available for your phone"

texts:
I am developing a game in Unity and have connected to FB using the plugin.
I am able to login and send a request to another user with no problems.

However, when I click on the notification I get the message "This game is not available for your phone".

Everything is set up as it should be and both users are defined as developers for the app.

The only thing is that I have not yet published the app in FB. Is that a requirement?


texts: Which approach is better: Frequent small updates, or occasional large ones?

texts:
I recently released the first publicly available free Alpha for my top-down shooter: Dread

I'm trying to decide whether a weekly / bi-weekly small update release schedule is better than the more traditional monthly (or longer) large updates.

The more frequent schedule would mean that players would have a new build to play more often, but the new builds would likely only have a few bug-fixes / feature additions at a time. Would players grow tired of the constant updating, or would they feel more attachment as they are more involved in the development process?

I'm thinking that, due to the somewhat experimental nature of my game, it might be a good thing for people to have the opportunity to suggest tweaks to the new features during their infant stages. But I don't want my desire for feedback to bias my decision.

What are your thoughts / experiences on the matter?


texts:
I create archviz in oculus using unity. I didn't use any texture, just simple solid white color. But inside the room there is gradient from light to dark where i can see the color banding. i'm using baked GI and a single directional light. This banding effect is visible in 3d scene window and when i run on oculus as well.
What setting do i have to modify to fix it ?


texts: Smooth behaviours at high Time.timeScale

texts:
When I set the Time.timeScale in unity very high, many scripts seem to do werid things (because of the high deltaTime they use for their logic).

Is there an option to let unity split up one update - call with a high deltaTime to multiple calls per frame, each with a lower deltaTime?


texts: How to calculate falling and accelerating velocity?

texts: I'm thinking of making a lander game, where you control a spaceship and need to land it without crashing. What is a simple formula to calculate speed of falling or acceleration with relation to  working time to time engines?


texts: Draw depth works on WP7 emulator but not device

texts:
I am making a game on a WP7 device using C# and XNA. I have a system where I always want the object the user is touching to be brought to the top, so every time it is touched I add float.Epsilon to its draw depth (I have it set so that 0 is the back and 1 is the front).

On the Emulator that all works fine, but when I run it on my device the draw depths seem to be completely random.

I am hoping that anybody knows a way to fix this. I have tried doing a Clean & Rebuild and uninstalling from the device but that is no luck. My call to spritebatch.Begin is:

spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend);

and to draw I use

spriteBatch.Draw(Texture, new Rectangle((int)X, (int)Y, (int)Width, (int)Height), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, mDrawDepth);

Where mDrawDepth is a float value of the draw depth (likely to be a very small number; a small multiple of float.Epsilon.

Any help much appreciated, thanks!


texts: Rotate can I rotate an object to a target angle using Euler Angles?

texts:
How do I rotate an object from its current angle to the desired angle in increments on 1 axis? The problem is the wraparound at 360 degrees
What I have so far (Note: pseudocode):

double MaxSpeed = 5;

double CurrentAngle = -170;
double DesiredAngle = 40;

double Distance = DesiredAngle - CurrentAngle; //How do I calculate this value considering angle wraparound?

CurrentAngle += Mathd.clamp(Distance, -MaxSpeed, MaxSpeed); //Caps the rotation speed


texts: Implement dynamic 2 player splitscreen based on player positions

texts:
Having a local 2 player game, when the distance between the player is big enough, we have a splitscreen whose shape is defined by the angle between the two players. When they get close enough to each other it should fall back to single screen and when they get farther, the screen zooms out before becoming a splitscreen again.

Pretty much the way it's demonstrated in this video: https://www.youtube.com/watch?v=XzIzHKwVDH4

How would that be implemented? What would be a decent GameObject-Hierarchy for this?


texts: What are AI characters doing when not in the viewport?

texts:
In a game like star wars battlefront, 100+ AI characters are competing against each other both onscreen and offscreen to shoot each other and capture bases. My question is what types of efficient techniques may be used to handle the processing of this activity for the characters not in the viewport?
Obviously, the actual game objects/meshes can't be moving around. Is there a global game AI that selects characters and then actions, then records them, and then places the game objects only when they get into the viewport? Or is it decentralized and each game object knows it's own position/goals but just becomes visible/hidden by a global manager based on the viewport? Any other tricks I'm not thinking about?
Edit: My military sim game has similar functionality. Multiple factions are fighting, dying, and occupying land. Terrain is all land but has caves and rudimentary buildings.


texts:
I want to make a simple 2d terrain with just a few bumps and height changes:

I thought about just using random numbers to describe the height of a certain vertex, but I don't see how I can make one mesh from this. I'm looking for a way to find the vertex and indices buffers for the terrain.
How do I do this?


texts:
How can I achieve this kind of rotation or vertical text using Bitmap Font?

I already used Matrix but didn't get the result same as above.


texts: What controls the platform override codes in AudioClip (and maybe other Assets) .meta files?

texts:
My game needs to use Unity 2019.3 for the console versions, and 2020.3 for the mobile ports.
The Console Project is the master project. Virtually any changes done to it are replicated to the Mobile project.
I would like to setup import overrides for Android (e.g. the compression quality for my soundtracks). To be consistent, I perform this change in my Console Project using the "Override for Android" checkbox (which affects the .meta file), and then replicate the change to the Mobile Project (a program checks for differences between both projects and applies most changes).
Ideally, the Mobile Project will now reflect the compression quality I want for said soundtracks, but it actually doesn't - in fact, the "Override for Android" checkbox does not appear to be checked in the Mobile Project, despite having a .meta file identical to the Console Project.
I digged into the .meta files, and noticed that when I use "Override for Android" in my Console Project, the .meta file adds an entry code 27:
  platformSettingOverrides:
    27:
      loadType: 2
      sampleRateSetting: 0
      sampleRateOverride: 44100
      compressionFormat: 1
      quality: 0.5
      conversionMode: 0

But, when I go to my Mobile Project and check the checkbox, it adds an entry coded 7:
  platformSettingOverrides:
    7:
      loadType: 2
      sampleRateSetting: 0
      sampleRateOverride: 44100
      compressionFormat: 1
      quality: 0.5
      conversionMode: 0

I don't understand this inconsistency. Does anyone have any insight on the exact conditions/rules Unity uses for the platform codes in the .meta files?
I can only think of a few dubious reasons:

Maybe they changed from 2019 to 2020.
My Console Project actually supports more platforms than the Mobile Project (the consoles, obviously), so maybe they "pushed" the Android code from 7 to 27.

It is not the end of the world; I could make a script that duplicates the settings of 27 into 7... But only if this behaviour is predictable or consistent. So my question is, what is Unity's logic behind the choice of these platform codes?
Note: so far I've only found this behaviour on AudioClip files. With Textures, I see that it actually uses the name of the platform in the .meta file, so the settings do work thankfully, but it is even more puzzling because now I don't understand why Textures and AudioClips use different conventions to begin with... What other Asset Type has numeric conventions?


texts: Godot: error(10) expected '(' after Identifier

texts:
When trying to write up a new shader for a material, I've been trying to create a variable to use to alter speed and test animation. Now, the below outputs fine until I try to assign a value to number.

shader_type canvas_item;

uniform float time_factor = 1.0;
uniform vec2 amplitude = vec2(10.0,5.0);
uniform sampler2D frame1;
uniform sampler2D frame2;
uniform sampler2D frame3;
uniform float speed = 1.0;

float number = 1.9;

void vertex(){
    VERTEX.x += sin(TIME * time_factor + VERTEX.x + VERTEX.y) * amplitude.x;
    VERTEX.y += cos(TIME * time_factor + VERTEX.y + VERTEX.x) * amplitude.y;
   }

I had seen tutorials demonstrating that this would have worked fine in previous versions.


texts: How can I delete an enemy's bitmap from a canvas?

texts:
I'm learning to create an Android shooter game where I'll have multiple enemies. I must control the position on the screen and be able to delete each of then (via, for example, a die() function).

But I use a canvas, which is most recomended, is it possible to delete just one bitmap and not the entire canvas (by delete I mean make it vanish from the screen, not just erase its value)? If so, how?

Another approach, I guess, would be using the Android image view, which can be deleted and as well as controlled and positioned, but I think that can make my game run slow if I create various objects of a class enemy; is that correct?


texts:
I need to scale the texture in unity3d.In unity we are able to adjust the scale using the option in the toolbar

How will I scale the texture at runtime using the mouse pointer.

the texture should scale when i click and drag on the any four corners of the image as shown in the below image

Can anybody please help me in solving this.


texts: What is the hardest thing in game development process?

texts:
I am new to the game-dev area, although I have professional experience in programming and some other qualities like making graphics in Photoshop or 3D modelling. Currently I am learning one widely used game engine connected with another free 3D modeling tool and my problem is that from my beginner's perspective, it all seems relatively easy and I know that this is not true. Right now It seems I can find all knowledge I need in some online tutorials, courses and if something is missing I can still ask a question on websites such as this one.
I plan to do an FPS multiplayer game as my first game and I wonder what is the hardest (most time, energy or money consuming) stage of game development in 2020?
I am asking because right now I think I can make 30-50% (prototype and some assets like 3d models) of the game myself in around year period of time and maybe later get more money to finish the project, but I know it is not true and this is only my beginner's unexperienced imagination, because similar games are usually being done by a team of experienced developers and their games still have bugs, glitches and other issues and I know some other similar but amateur projects that were started by one or two people and eventually were abandoned due to unknown reason (mostly lack of time I assume). So I am wondering what are the stages that cause most amateurs to fail and abandon their ideas, is it modeling, programing, networking, debugging?


texts: How do I make something visible only when I'm looking at it?

texts: So I'm making a basic 2D game in C# XNA. I want it so wherever my character is facing there is a cone of light and only that part of the level is visible while the right of the screen is dark. Please excuse my ignorance, I haven't been working with C# too long.


texts: How to solve problems with movement in simple tile based multiplayer game?

texts:
I'm making a simple tile based 2D multiplayer game in JavaScript using socket.io where you can move one tile every 200 ms. The two solutions I've tried are as follows:

The client sends "walk one tile north" every 200 ms. Problem: People can easily hack the client to send the action more often.
The client sends "walking north" and "stopped walking". Problem: Sometimes the player moves extra steps when "stopped walking" doesn't arrive in time.

Do you know a way around these problems or is there a better way to do it?

EDIT: Regarding the first solution I've tried adding validation on the server to check if it has been 200 ms since last movement. The problem is that latency still encourages people just to spam the action as much as possible, giving them an unfair advantage.


texts: Inverse Distance Weighted interpolation between N Vector3s in Godot

texts:
I have a number of Vector3s in Godot arranged in a grid, let's say they look like this (looking at them from above, with Godot Y-is-up):
z
|(0,6,2) (1,5,2) (2,3,2)

|(0,2,1) (1,A,1) (2,3,1)

|(0,2,0) (1,3,0) (2,4,0)
--------------------------x

I would like to interpolate the center Y-value marked as A based on the surrounding vectors. The thing is, the center value is not bound to the grid, so it can be closer to the lower left corner for example, so I want to weight the interpolated value based on the distance to each vector.
So, is there some clever trick in Godot using built in functions, or do I need to implement my own Inverse Distance Weighting-code?


texts:
I'm working on creating a multiplayer game, with the client in ActionScript and the server written in Java. I'm using XMLSocket in the client to connect to the server. The server code looks something like:

ServerSocket server = new ServerSocket(port);

while(true)
{
    Socket client = server.accept();
    ClientHandlingProcess child = new ClientHandlingProcess(client);
    child.start(); // starts new thread for client
}

The client handling process looks something like:

while(true)
{
    byte[] arr = new byte[1024];
    if(socket.getInputStream().read(arr) == -1)
    {
        break;
    }

    handleInputMethod(arr);

    while(!message_queue.isEmpty())
    {
        socket.getOutputStream().write(message_queue.get(0).getBytes());
        message_queue.remove(0);
    }
}

The issue is that the read method is blocking, meaning I can't send any data while I'm waiting for data to come in. What would be a good way to fix this? Have two processes: one for reading and one for writing, have the client send empty requests when it has no proper messages to send, or is there another way I can proceed?


texts:
I'm developing a game, and the game has a shop.  In that shop there is an option for a house expansion.  This is a movieclip that I want the user to be able to spend their coins to increase their house in the following ways:

-> stretch house to right <- stretch house to left ^ stretch house upward v stretch house downward.

The thing is, I've been thinking of using ScaleX and ScaleY to accomplish this.  The only problem:  It stretches the left and right, I can't make it do one.  I'm sure there is a way to do this, but I haven't yet figured it out.  Any ideas?


texts:
I am making an air hockey game for Android using AndEngine and its Box2D extension.

How would I make an AI for an air hockey game? For it to work the AI would not only need to move its paddle side to side to defend but also move forward for an attack. What kind of code would I need to implement this?


texts:
I wonder how I can become a game publisher locally. For example, I know a Japanese game that I want to publish in India, where I live.

How do I acquire a license to do this? I tried emailing the Japanese game company, but they didn't reply. I also asked if they need to know my company size or credits in India before proceeding with a contract, but they also keep silent.


texts: How can you effectively filter your community feedback?

texts:
I am not asking for myself, I am asking for someone else who will likely not read this question because he is too busy reading his email, but I am sure that this question will be of a lot of value to others.

The poor guy has the problem that his development project got quite a bit more attention during development than he liked. Now he gets bombarded with emails full of bad suggestions and useless bug reports. Reading through all these emails takes him several hours of development time each day. However, not reading it is not an option either as it would mean that he could miss some emails which are actually important, like mails from potential project members, useful bug reports or press and business contacts.

He recently called it the biggest problem for the development of his project in a 20 minute video (you don't need to watch this rant entirely. The blog post linked in the first sentence of this question summarizes it very well)

How can a game developer canalize and filter their feedback stream to improve the signal-to-noise ratio?


texts: What does a game programmer and graphics programmer do?

texts: I'm quite the novice in terms of my knowledge of game development, and I'd incredibly appreciate any further insight on this. To be a bit more specific, I encountered this video, (https://www.youtube.com/watch?v=_GyFRMr4uf4) and It documents the roles of game programmers and graphics programmers at Naughty Dog but even with the descriptions, I'm still uncertain of what those jobs actually entail. Sorry If this wasn't a suitable place for the post, but for any help thanks in advance.


texts: How can I remove unnecessary nodes from my path?

texts:
How do I remove the unnecessary nodes from the path to make it as short as possible? Idealy I'd like the result path to look like the green line. The red thingy is not walkable.

        var newPath = new List<Vector3>();
        var nodes = p.vectorPath;
        int lastCp = 0;

        List<int> toRemove = new List<int>();

        for (int i = 2; i < nodes.Count; i++)
        {
            if (IsPassable(nodes[lastCp], nodes[i]))
            {
                toRemove.Add(i - 1);
            }
            else
            {
                lastCp = i - 1;
            }
        }

        for (int i = 0; i < nodes.Count; i++)
        {
            if (!toRemove.Contains(i))
            {
                newPath.Add(nodes[i]);
            }
        }

Here's my attempt to solve the problem and it usualy works well but sometimes if I stand next to obstacle I get the orange line in the picture above.

I'm assuming the path has at least 3 nodes.

nodes is a list of Vector3 (the positions of grey dots on picture), IsPassable returns true if the path between two given Vector3 is passable.

newPath idealy should contain two points in the case of example path above.

EDIT:

I know why the algorithm doesn't work in this case (look at @Draco18s answer below). What I don't know is how to fix it so it always returns the shortest path regardless of start and target location.


texts:
I have have a rotation problem in the Slick2d library, the image is just not rotating (ie I set a rotation but no result is shown). Here is the rotation code:

if (input.IsKeyDown(Input.KEY_LEFT))  {
    velocity.x = -1;

    rotation = (float)Math.toRadians(180);
}

That is meant to set the rotation of image to 180 degress.

Then I render the image with an origin of the center of the image:

image.setCenterOfRotation(image.getWidth() * scale / 2, image.getHeight() * scale * / 2);
image.setRotation(rotation);

image.draw(position.x, position.y, scale);

Any ideas? Thanks.


texts: How is time/duration handled in strategic games?

texts:
I'm considering developing a space opera game, having already done some game design. Technically, though, I'm coming from a business applications background. Hence I don't really know how I should handle time and duration.

Let's state the matter clearly: what if something is bound to happen in 5 hours and on which other events depend.

For example the arrival of some space ship in some system where some defense systems are present, hence a fight would start.

The aim is to do some web application, so with multiple nodes for better scalability and the like. Hence a single loop on one node wouldn't do it. Should there be a master node or are they some better known solution?

Furthermore, the loop in itself doesn't resolve this duration issue: between firing of the event on its ends, many loops happen. Does it mean every loop should check such "waiting" actions?

Should I use some kind of scheduler (like Quartz in my java land) to trigger the corresponding event when due (I plan to use events for communication)? Something else?


texts:
I've recently discovered the power of Quadtrees and Octrees and their role in culling/LOD applications, however I've been pondering on the implementations for a Dynamic Quad/Oct Tree.

Such tree would not require a complete rebuild when some of the underlying data changes (Vertex Data).

Would it be possible to create such a tree? What would that look like? Could someone point me in the correct direction to get started?

The application here would, in my scenario, be used for a dynamically changing spherical landscape with over 10,000,000 verticies. The use of Quad/Oct Trees is obvious for Culling & LOD as well as the benefits from not having to completely recompute the tree when the underlying data changes.


texts: I want to implement free-running movement (like Assassin's Creed) in 2D. What to do?

texts:
I would like to implement free-running as popularized by Assassin's Creed, albeit in 2D.
What are some specific techniques or algorithms that I can use to achieve free-running in 2D without having to reinvent everything?

I tried to Google for resources, but couldn't really find any leads (no surprise there). Ideally, I'd like to know how did Assassin's Creed did it.


texts: The value of VSync on vSync Count in Unity

texts:
In Unity, we can set the vSync value as "No sync" = 0, "Every V Blank" (60 fps) = 1 and "Every Second V Blank" (30 fps) = 2. But in the Unity Quality Setting documentation , it's written the vSync count value must be either 0, 1, 2, 3, or 4. What is 3 and 4 ?

You can set this vSync value on your code, the value must be either 0, 1, 2, 3, 4. But in Quality Setting in Unity, the option is only for : No Sync, Every V Blank, and Every Second V Blank. So basically only for 0, 1, and 2.

There's no option for 3,4. If we set the value on the code as 3 or 4, how should we set the value in Quality Setting Properties ? Because we need to choose a value other than No Sync for the vSync to work. How the vSync count in Properties and Code related if they accept different value ?


texts: What is a bank payment gateway concept upon publishing a game app?

texts:
I was asking a local bank about the possibility of transferring money to my account there upon publishing a paid app on play store. The reply was that they have their own payment gateway that deducts a percentage of the profits besides monthly and yearly charges.

My first question is what exactly is a payment gateway? (The information written on google about this is very confusing and very broad that after hours of research I still do not know what exactly is the benefit of a gateway.)

My second question is do all banks around the world impose this "gateway"deduction?

I always thought that money is transferred directly from google to the concerned developer's bank account without the concept of gateway. Please correct me if am wrong.

Thank you!


texts: Why doesn't light continuous on my model?

texts:
I created a basic textured cube model with Blender to practice modeling, and then I imported it into Unity. After I put up some lighting it looks pretty ugly. The light is not continuous on a row of textured cubes:

What is more odd, the light on the blocks that makes up the floor is continuous. What am I doing wrong?

This is what it looks like without textures:

If I did not know that these are perfect cubes, I'd say there is a slight curve on surface. I also tried lightening the texture but it also didn't help:

I just simply exported the model from Blender and did not set up any normals or things like that. However, I also did not do anything special with the floor brick model.

Checked the normals and they seem to point to the right direction.

Also I don't really see the difference between the two models.
On the textures panel I also set the projection to flat:

I checked the different panels in Blender and the only normal-related option on the "Object Data" panel is this "Auto Smooth" and it is turned off by default:


texts: Where to hire someone to make a trailer?

texts:
Developers are found on coding forums, artists are found on art forums, etc... but where to find someone who is good at making trailers? Is there some community of "trailer makers"? Should I look for someone in a game enthusiasts forum? Any hints where to look at?
...let me also mention that we have very low budget, and a volunteer would be even greater.


texts:
I am working on a medieval isometric RPG in which the player can ride on horses and in horse drawn carriages.  The player's movement is not restricted to the common eight directions; he may move in whichever direction he points his joystick in.  What is stumping me is the problem of animating this sucker.  I'd rather not have my horse and carriage sliding along unnaturally at an angle to their animation's direction, but I would also like to keep my player movement system.

I have considered a snake-like algorithm where the carriage parts bend along a curve when they turn, but I am not sure this can be done with 2D artwork.  I have also considered creating large numbers of animations for the horse and carriage, but this is too time intensive to be feasible.

Now maybe I'm off topic and maybe this question is going to get deleted, but I am wondering if anyone out there can either suggest an idea on this or point me to a game which has implemented thi kind of functionality before (with cars, carriages, or other kinds of vehicles).


texts: VertexColor shader is not working correctly in built application

texts:
I want to change the vertex colors of my mesh. The light sources must not affect the objects with this shader, its lighting must be determined only by its vertices colors, so I turned the Lighting Off. I use this simple shader:

Shader "VertexColored/Simple" {
Properties {
    _MainTex ("Base (RGB)", 2D) = "white" {}
}

SubShader {
    Pass {
        ColorMaterial AmbientAndDiffuse
        Lighting Off

        SetTexture [_MainTex] {
            Combine texture * primary
        }
    }
}
Fallback "VertexLit"
}

And this script:

using UnityEngine;
using System.Collections;

public class BehaviourScript : MonoBehaviour {
    void Start() {
        Color[] exclrs = new Color[11]
        {
            new Color32(25, 25, 25, 255),
            new Color32(50, 50, 50, 255),
            new Color32(75, 75, 75, 255),
            new Color32(150, 150, 150, 255),
            new Color32(200, 200, 200, 255),

            new Color32(255, 255, 255, 255),

            new Color32(200, 200, 200, 255),
            new Color32(150, 150, 150, 255),
            new Color32(75, 75, 75, 75),
            new Color32(50, 50, 50, 255),
            new Color32(25, 25, 25, 255),
        };

        Mesh mesh = GetComponent<MeshFilter>().mesh;
        Vector3[] vertices = mesh.vertices;
        Vector3[] normals = mesh.normals;

        Color[] colors = mesh.colors;

        for(int i = 0; i < vertices.Length; i++)
        {
            for(int j = 0; j < 11; j++, i++)
            {
                colors[i] = exclrs[j];
            }
            i--;
        }

        mesh.colors = colors;
    }
}

When the game is launched, in editor I can see this:

This is EXACTLY what I wanted to achieve!

But in built for PC(x86) version I see this:

Why the results from the editor and from the built .exe differs? What should I do to see my effect in built version? Maybe I need to use an another shader?


texts: What is the fastest algorithm to check if two cubes intersect (where the cubes are not axis aligned)?

texts:
I am looking for an algorithm to check if two cubes intersect. One can check if each of the 6 faces of cube A are intersected by each of 12 edges of cube B, but that is 72 checks. I've heard there is a paper from 1997 or so, describing a method that uses just 15 intersection checks, but I can't find it. Can you please share the name of the paper, describing it or describe it in your words.

This question deals with axis aligned cubes which is not really useful.
https://stackoverflow.com/questions/5009526/overlapping-cubes


texts: Entity Type specific updates in entity component system

texts:
I am currently familiarizing myself with the entity component paradigm.

For an example, take a collision system, that detects if entities collide and if they do let them explode.

So the collision system has to test collision based on the position component and then set the state of those entities to exploding.

But what if the "effect" (setting the state to exploding) is different for different entities? For example, a ship fades out while for an asteroid a particle system must be created.
Since entities and components are only data, this must happen in some system.

The collision system could do it, but then it must switch over the entity type, which in my opinion is a cumbersome and difficult to extend solution.

So how do I trigger "entity type dependend" updates on an entity?


texts:
I'm trying to solve what seems to be (or should be) a very simple problem. I'd like to sequence several steps in a GameManager class with some time delay between them. In my case, I'd like to clear the screen of objects, then ask my UIManager class to display a "Starting Level" message for 3 seconds, then spawn all the objects I need. This sequence should be repeatable unless a event that the GameManager subscribed to is triggered.

I'm trying to do this in the most generic, flexible and elegant way I can find. This is not a technical, "whatever works" question. I can do this with coroutines. I can do this with the GameManager calling an Action delegate to which UIManager is subscribed, then make the UIManager call an event that the GameManager is subscribed to when the displaying is done. But all these solutions seems convoluted to me.

I've started a thread on Unity Answers with some example code about this, which has generated a small discussion. In posting here I am hoping to find some new ideas, maybe generic to C# and not specific to Unity, on how to sequence a chain of methods. How would you achieve this?

To make this clearer, imagine a more complex sequence inside a GameSequence method:

Initialize variables (level, difficulty etc).
When done, play an introductory animation to that level, which can be of varying lengths depending on the level.
Show a "Get ready" message for 3 seconds.
Spawn the level and let it play.
If the level ends successfully, animate some sort of cutscene (which can be of any duration).
If the level doesn't end successfully, trigger a GameOverManager or something to that effect.

I hope I'm being clear in my question. Thank you for your help.


texts: How to set up Azure Spatial Anchors with Unity Android project?

texts:
I'm building an AR app in which I wish to use Microsoft's Azure and it's web service Spatial Anchors. I cannot seem to get the sample demo, which I downloaded from https://github.com/Azure/azure-spatial-anchors-samples, to work for storing spatial anchors on the external server.

Following their tutorial I can create the Azure account, set up the resource group and individual Spatial Anchors resource. However, in the Unity project, there is a config file called 'AzureSpatialAnchorsDemoConfig' which requires that you specify an account id(I have this), a primary key(i also have this), and a base sharing url: which is what I am struggling to find and is what I assume is the cause of being unable to store my anchors to the cloud.

This is a snippet from the tutorial that I'm having issues with, if I fill in the address in my web browser I can't even find that ip.

  In the Inspector pane, enter the Sharing Anchors Service url (from your ASP.NET web app Azure deployment) as the value for Base Sharing Url, replacing index.html with api/anchors. It should look like this:

  https://<app_name>.azurewebsites.net/api/anchors.


texts: Any idea to be able to make the character still continue the game until no heart left

texts:
I am newbie I am making a 2d game in unity 3d my code for the character game over is this.. I can get the heart less one heart if game over but turn back to five again I just want to decrease heart whenever character die until it loss all the five heart

and my code for the heart is this...

function Start () {
    coins = PlayerPrefs.GetInt("Coin");
    moveSpeed=10;
    anim=GetComponent(Animator);
    MainCode.Hearts = 5;
}

function Update () {

    transform.rotation.z=0;
    if(Input.GetKey(KeyCode.UpArrow)){
         transform.position.y+=moveSpeed*Time.deltaTime;
    }

    if(transform.position.y<-5) {
         Application.LoadLevel(Application.loadedLevel);
         MainCode.Hearts -=1;
    }
    if (MainCode.Hearts <= 0){
         GameOver();
    }

}

var image : GUITexture;
var Image_01 : Texture2D;
var Image_02 : Texture2D;
var Image_03 : Texture2D;
var Image_04 : Texture2D;
var Image_05 : Texture2D;
var Image_06 : Texture2D;

function Update {
    if(MainCode.Hearts == 5){
         image.texture= Image_01;
    }
    if(MainCode.Hearts == 4){
        image.texture= Image_02;
    }
    if(MainCode.Hearts == 3){
        image.texture= Image_03;
    }
    if(MainCode.Hearts == 2){
         image.texture= Image_04;
    }
    if(MainCode.Hearts == 1){
        image.texture= Image_05;
    }
}

however its not working properly any help would be really much appreciated thank you in advance


texts: AI to move custom-shaped spaceships (shape affecting movement behaviour)

texts:
I'm designing a networked turn based 3D-6DOF space fleet combat strategy game which relies heavily on ship customization. Let me explain the game a bit, since you need to know a bit about it to set the question.

What I aim for is the ability to create your own fleet of ships with custom shapes and attached modules (propellers, tractor beams...) which would give advantages and disadvantages to each ship, so you have lots of different fleet distributions. E.g., long ship with two propellers at the side would let the ship spin around that plane easily, bigger ships would move slowly unless you place lots of propellers at the back (therefore spending more "construction" points and energy when moving, and it will only move fast towards that direction.) I plan to balance all the game around this feature.

The game would revolve around two phases: orders and combat phase. During the orders phase, you command the different ships. When all players finish the order phase, the combat phase begins and the ship orders get resolved in real-time for some time, then the action pauses and there's a new orders phase.

The problem comes when I think about player input. To move a ship, you need to turn on or off different propellers if you want to steer, travel forward, brake, rotate in place... These propellers don't have to work at their whole power, so you can achieve more movement combinations with less propellers.

I think this approach is a bit boring. The player doesn't want to fiddle with motors or anything, you just want to MOVE and KILL. The way I intend the player to give orders to these ships is by a destination and a rotation, and then the AI would calculate the correct propeller power to achive that movement and rotation. Propulsion doesn't have to be the same throught the entire turn calculation (after the orders have been given) so it would be cool if the ships reacted as they move, adjusting the power of the propellers for their needs dynamically, but it may be too hard to implement and it's not really needed for the game to work.

In both cases, how would that AI decide which propellers to activate for the best (or at least not worst) trajectory to be achieved?

I though about some approaches:

Learning AI: The ship types would learn about their movement by trial and error, adjusting their behaviour with more uses, and finally becoming "smart". I don't want to get involved THAT far in AI coding, and I think it can be frustrating for the player (even if you can let it learn without playing.)
Pre-calculated timestep movement: Upon ship creation, ALL possible movements are calculated for each propeller configuration and power for a given delta-time. Memory intensive, ugly, bad.
Pre-calculated trajectories: The same as above but not for each delta-time but the whole trajectory, which would then be fitted as much as possible. Requires a fixed propeller configuration for the whole combat phase and is still memory intensive, ugly and bad.
Continuous brute forcing: The AI continously checks ALL possible propeller configurations throughout the entire combat phase, precalculates a few time steps and decides which is the best one based on that. Con: what's good now might not be that good later, and it's too CPU intensive, ugly, and bad too.
Single brute forcing: Same as above, but only brute forcing at the beginning of the simulation, so it needs constant propeller configuration throughout the entire combat phase.
Coninuous angle check: This is not a full movement method, but maybe a way to discard "stupid" propeller configurations. Given the current propeller's normal vector and the final one, you can approximate the power needed for the propeller based on the angle. You must do this continuously throughout the whole combat phase. I figured this one out recently so I didn't put in too much thought. A priori, it has the "what's good now might not be that good later" drawback too, and it doesn't care about the other propellers which may act together to make a better propelling configuration.

I'm really stuck here. Any ideas?


texts: Calculate total area of a composition of images

texts:
I'm trying to calculate the total area of a game object composed of several images. For each image, I know:

Width, Height
X, Y
Rotation
ScaleX, ScaleY
OriginX, OriginY

Where OriginX/Y are floats in the range [0, 1] indicating the relative point inside the image. Also, this is the center of the rotation and the location where the image is placed regarding the X/Y coodrinates.

I have this algorithm which works fine without taking the rotation into account.

float left = float.MaxValue;
float right = float.MinValue;
float bottom = float.MaxValue;
float top = float.MinValue;

foreach (Image i in images)
{
    float w = i.Width * i.ScaleX;
    float h = i.Height * i.ScaleY;

    float l = i.X - i.OriginX * w;
    float r = l + w;
    float b = i.Y - i.OriginY * h;
    float t = b + h;

    left = Math.Min(left, l);
    right = Math.Max(right, r);
    bottom = Math.Min(bottom, b);
    top = Math.Max(top, t);
}

float totalW = right - left;
float totalH = top - bottom;

What do I have to do to take rotation into account?

I know how to calculate the area of the rotated rectangle but don't know how to take the pivot point into account.

Also, I know this can be achieved easily by using transform matrices but this is going to be a part of a standalone library with no dependencies (including a math library with matrices).

EDIT

My goal is to compute the axis-aligned bounding box of the whole composition.


texts: Large Blob of landmass in Minecraft Terrain Engine in XNA

texts:
I am creating a Minecraft Terrain engine in XNA, and want to create a large blob/cluster of blocks, in a random sort of blob thing, shaped somewhat like the stuff under the Volume Rendering heading on the following page:

http://paulbourke.net/geometry/blob/

This post might be somewhat like my post How can I generate floating land masses for a Minecraft-like engine? but I believe this is an entirely different because this is more of a 3D approach rather then 2D, also I would prefer it without the crater bits ;).


texts:
I'm going over different ways to implement attacking in a "dungeon crawler".

What I have kind of abstracted out...

There are 2 kinds of people, The Player, and the enemies, these are both living creatures.

Living Creature will the the superclass for all living entitie's in the game(NPC is still a little murky...

Player and Enemy both use weapons, even it is only a fist.

I have decided that creating a Attack, on the weapon superclass, may be the best way to implement.

LivingCreature.Weapon.Attack(LivingCreature) will be the implementation.

This means no player attacks anything, the weapon itself will be the attacker. My question is, are there any negative side effects to this that I am not seeing. I have looked through some different design structures of games, and I haven't seen this exact implementation, and wasn't sure why.

To clarify-

Should Player have knowledge of how attacks works, or should the weapon know how attacks work.


texts: What forms of non-interactive RPG battle systems exist?

texts:
I am interested in systems that allow players to develop a battle plan or setup strategy for the party or characters prior to entering battle. During the battle the player either cannot input commands or can choose not to.

Rule Based
In this system the player can setup a list of rules in the form of [Condition -> Action] that are then ordered by priority.

Gambits in Final Fantasy XII
Tactics in Dragon Age Origin & II


texts: As an aspiring game developer, which game engine should I learn?

texts:
I am currently a full-time student and part-time game developer. I have released six 2D games into Android and WP7 markets. I have also dabbled in 3d development with C++ and DirectX. I am decent at 2D, but have a lot to learn in 3D. I want to be a professional 3D game developer for PCs and/or consoles.

As I understand, most game developers use off-the-shelf engines in AAA games.

My situation is as follows:

I will learn alone. No team involved.
I am interested in graphics programming (writing shader code) as well as gameplay programming.
I am not (currently) interested in learning core game engine architecture in depth.
I have no plans on releasing any commercial 3d game any time soon. Learning purposes only.
I want to code in C++ and for Windows platform only.

Which 3D game engine should I invest my time learning? Which one is industry standard? Will it help my resume?


texts: How to get the next line character to work in a self-typing dialog box?

texts:
With the help of a tutorial, I've created an almost successful dialog box that types itself out (just as older RPGs do, and some still do). The only problem is that I've wrapped the text so that if a word is too long for the line within the dialog box, it goes on down to the next line.

However, since my code is typing out the dialog character by character, it probably can't use the "\n" directly. And even when I do use "\n" it does not go to the next line. It simply prints those characters exactly.

I initially tried using a single character ("*") that my code would then replace during the typing with a "/n" character. However, this just printed the "/n" per usual. Whether I use '\n', "\n", or \n, it doesn't seem to work.

You can see, I've got some special characters being used to signal whether the text should go slower than usual, or whether or not there should be a longer pause. I also included the function that goes through and takes out those special characters. But anyway, here's the code in general, how can I add a next line?

private IEnumerator TextScroll(string lineOfText)
{
    int letter = 0;
    theText.text = "";
    isTyping = true;
    cancelTyping = false;
    while (isTyping && !cancelTyping && (letter < lineOfText.Length)) {

        if (lineOfText[letter] == '@')
            {
            letter += 1;
            yield return new WaitForSeconds(0.5f);
            }

        if (lineOfText[letter] == '<')
            {
            typeSpeed = 0.5f;
            letter += 1;
            }

        if (lineOfText[letter] == '>')
        {
            typeSpeed = 0.025f;
            letter += 1;
        }

        theText.text += lineOfText[letter];
        letter += 1;
        yield return new WaitForSeconds(typeSpeed);
    }

    newLineOfText = lineOfText;
    theText.text = TrimString(newLineOfText);
    isTyping = false;
    cancelTyping = false;
}

public string TrimString(string line)
    {
        var charsToRemove = new string[] { "@", "<", ">"};
        foreach (var c in charsToRemove)
        {
            line = line.Replace(c, string.Empty);
        }
        return line;
    }


texts: Keeping the meshes "thickness" the same when scaling an object

texts:
I've been bashing my head for the past couple of weeks trying to find a way to help me accomplish, on first look very easy task. So, I got this one object currently made out of 5 cuboids (2 sides, 1 top, 1 bottom, 1 back), this is just for an example, later on there will be whole range of different set ups. Now, the thing is when the user chooses to scale the whole object this is what should happen:

X scale: top and bottom cuboids should get scaled by a scale factor, sides should get moved so they are positioned just like they were before(in this case at both ends of top and bottom cuboids), back should get scaled so it fits like before(if I simply scale it by a scale factor it will leave gaps  on each side).

Y scale: sides should get scaled by a scale factor, top and bottom cuboid should get moved, and back should also get scaled.

Z scale: sides, top and bottom cuboids should get scaled, back should get moved.

Hope you can help,

EDIT
I am asking you, if any of you have any idea on how to accomplish this scaling.

I have tried whole bunch of things, from scaling all of the object by the same scale factor, to subtracting and adding sizes to get the right size. But nothing I tried worked, if one mesh got scaled correctly then others didn't.

Donwload the example object.


texts: How to implement rotating Earth effect in 2D?

texts:
I've modeled a photorealistic scene of the Earth rotating in 3DS Max and would like to use it as a backdrop of a menu screen in a 2D game. What would be the appropriate way to implement this effect in-game, a sprite sheet? That seems like it would require a whole mess of frames to appear convincing. Does that matter?

What if I then wanted to add the moon orbiting the Earth? A second sprite sheet for the moon's positions, with blank frames where it should be hidden behind the Earth?

Is there a better method?


texts: What is dead reckoning and how do you deal with it?

texts: I've come across this problem before and it would be good to know the different ways of solving this problem.


texts:
I'm currently working on a c# online multiplayer game in real-time. The aim is to have client/server based connection using the UDP protocol. So far I've used UDP for players' movements and TCP for events (a player shooting, a player losing life) because I need to be sure such data will arrive to all players connected to the server. I know that UDP is said 'unreliable' and some packets may be lost. But I've read everywhere to never mix TCP and UDP because it can affect the connection.

The main question is how should I organize my network?

UDP is connectionless, how should I save who's is who? Should I save ip adresses of the clients in a list?

Should I use TCP for important events or use UDP? If I need to use UDP, how can I make sure that data will not be lost?

By using both TCP and UDP, I need to save for each player their IP in a list (for UDP) and the TcpClient which is connected in another list (for the UDP). How could I change that to be more effective?


texts:
I am trying to write an ice shader in Unity that looks good and at least semi-realistic.

If the following shot (found on Google) was CG, what would its shader include? (the foreground cave). I might be wrong but it looks like it even has a different lighting model than the default diffuse.


texts: Problem with camera drag and draggable UI elements

texts:
I implemented my camera drag using the following method:

 if (Input.GetMouseButtonDown(0))
        {
            dragging = true;
            followPlayer = false;
            oldPos = transform.position;
            panOrigin = Camera.main.ScreenToViewportPoint(Input.mousePosition);
        }

        if (Input.GetMouseButton(0))
        {
            Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition) - panOrigin;
            transform.position = oldPos + -pos * panSpeed;
            transform.position = new Vector3(Mathf.Clamp(transform.position.x, xMin, xMax), Mathf.Clamp(transform.position.y, yMin, yMax), transform.position.z);
        }

        if (Input.GetMouseButtonUp(0))
        {
            dragging = false;
            //  followPlayer = true;
        }

But i also have draggable UI components that implement the  IBeginDragHandler, IDragHandler, IEndDragHandler interfaces. Problem is of course while draging the item in the canvas the camera still moves. Any idea how to solve this besides the obvious setting of bools in the inplementation of the interfaces to prevent the camera drag code from executing. An other problem is that I have other non UI object in the game that I want to click so implementing a transparent UI element behind all other UI will not work for me.


texts: How to access a variable from another C# script in Unity

texts:
I am working on a simple game project, and have a problem. The problem is accessing the variable from one script to another.

For example :-

I have 2 Scenes (Game Scene and Game Over Scene), Game Scene has a Player Game Object , who has a int Variable Score.

using UnityEngine;
using System.Collections;

public class Game_Scene_Script : MonoBehaviour
{
     private int Score ;

     // Use this for initialization
     void Start ()
     {
          Score = 0 ;
     }

     // Update is called once per frame
     void Update ()
     {
          // Let us assume some one played the game
          // And Now the Score is 207
          Score = 207 ;
     }
}

Now I want to access that int Variable Score in Game Over Scene which a Game Object.

So how can I access that int Variable from that script?

I searched for, but couldn't find any proper answer I wanted. Even-though some answers are in JavaScript , some are in Unity 4.x etc.


texts: WaitforSeconds() not working as it should

texts:
I searched for using WaitforSeconds and used as it was mentioned(using a return type of IEnumeration and using coroutines instead of update). but it did not work. Initially it showed Waitfor Seconds and IEnumerator were not "present in the current context". I had to r-install unity to get it fixed but this problem still remains. The following is my code. Am I using WaitforSeconds in correct way? Is it the 'if' code block that ruin my complete work(I mean have I used it in wrong place)?

using UnityEngine;
using System.Collections;

public class EnemyCreeator : MonoBehaviour {
public float xmin,xmax,zmin,zmax;
public GameObject enemy;
public float spawnWait,StartWait,waveWait;
public int turretCount;
public int enemyCount;
int i=0;
void Update() {
    StartCoroutine (TurretWaves());
}
IEnumerator TurretWaves() {

    while (true) {
        Vector3 pos=new Vector3(Random.Range (xmin,xmax),0.5f,Random.Range(zmin,zmax));
        yield return new WaitForSeconds(StartWait);
        while(i<turretCount) {
            //Debug.Log ("The vaue of game time in spawnwaiting is: "+Time.time);
            Instantiate (enemy, pos, Quaternion.identity);
            enemyCount++;
            i++;
            //Debug.Log ("value of i in loop is: "+i);
            //Debug.Log ("The vaue of game time is: "+Time.time);
            yield return new WaitForSeconds (spawnWait);
        }
        //Debug.Log("cHECKing Before WAVE WAIT(value of time )is: "+Time.time);
        yield return new WaitForSeconds(waveWait);
        if(i>=turretCount) {
            i=0;
        }
        //Debug.Log("cHECKing AFTER WAVE WAIT and value of time is: "+Time.time);
        //Debug.Log ("value of i outside the while loop is: "+i);
    }
}
}

The code needs to wait until the spawnWait before spawning each turret and wait till the wavewait before spawning the next wave. even though the Startwait works fine, I still am unable to find the problem with others...

(I had this question asked in StackOverflow but since i did not get any answer ,and i didnt know about this specific game-development website, so sorry for the repetition)

Thanks in advance.


texts: Unity UNET, problems spawning and then destroying that instantiated prefab

texts:
I am very new to networking, and have ran into an issue, read below.

I have multiplayer system setup, where players can spawn, they can pick up weapons and drop them, there is an object representing a pickup with network identity component attached and local player authority enable, the player can come up to it and press "E", which will destroy the pickup object, then the player can press I to to "drop" that weapon, which instantiates it infront of the player, now this is what should happen, and it works on single player, but when there's 2 players, for second player(client only) it doesn't work as it should.

I have 1 script weapon manager and another small, Pickup (on pickup object child with trigger).

Below is the code and according description of my attempt so far:

Below is PickUp script (on 1st child of pickup object with trigger enabled)

private void OnTriggerStay(Collider other)
{
    if (other.CompareTag("Player"))
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            //Call pickup function on player, passing the weapon id and parent gameobject
            other.GetComponent<WeaponManager>().PickUpWeapon(weaponID, transform.parent.gameObject);
        }
    }
}

Below is WeaponManager script (on player)

public void PickUpWeapon(int id, GameObject go)
{
    CmdDestroyObj(go);

    //... (other code, not relevent)
}

[Command]
void CmdDestroyObj(GameObject obj)
{
    RpcDestroyObj(obj);
}

[ClientRpc]
void RpcDestroyObj(GameObject obj)
{
    // HERE obj is NULL   (!!ERROR!!)
    Destroy(obj);
}

Above in RpcDestroyObj() obj is null

void Update(){
  if(isLocalPlayer)
  {
    if (Input.GetKeyDown(KeyCode.I))
    {
       if (slots[currentActiveSlot] != null)
       {
          CmdDropWeapon();
       }
    }
  }
}

Then here's CmdDropWeapon() function:

[Command]
void CmdDropWeapon()
{
    RpcDropWeapon();
}

Here's RpcDropWeapon() function:

[ClientRpc]
void RpcDropWeapon()
{
    GameObject _drop = (GameObject)Instantiate(drops[currentGun.GetComponent<WeaponStats>().id], transform.position + transform.forward, Quaternion.identity);
    _drop.GetComponent<Rigidbody>().AddForce(transform.forward * 25000f * Time.deltaTime);

    CmdDestroyWeaponHeld() //Destroy currently held weapon (don't pay attention, not relevent to current problem

    currentGun = null;

    if (isLocalPlayer)
    {
        GetComponent<PlayerSetup>().playerUIInstance.GetComponent<PlayerUI>().SetInventorySlotFill(currentActiveSlot, -1);
        emptyHanded = true;
    }
}

On single player (so host & client), everything works besides destroying the pickup prefab that is Instantiated.

On multiplayer, second player (client only), can pick up and drop weapons as well as the originally spawned weapon is destroyed, but destroying the newly instantiated (so after player drops it) pickup object doesn't work.

(In the console there are no errors when UnityEditor is the Lan host/server, when 2 players are playing and I try picking up and dropping weapons several times from client side)

Why is this not working? I would appreciate any help/assistance in getting this right and sync over network for all players.

My guess is that, rpc function Instantiates the drop prefab but it's kind of different on all clients, so the server or another client doesn't have exactly the same object in the scene which means it will not find it and return null.

Let me know if you need any additional information.

Thanks a lot in advance!


texts:
I'm trying to make a collider appear every 1 second.  But I can't get the code right.  I tried enabling the collider in the Update function and putting a yield to make it update every second or so.  But it's not working (it gives me an error: Update() cannot be a coroutine.)

How would I fix this?  Would I need a timer system to toggle the collider?

var waitTime    : float = 1;
var trigger     : boolean = false;

function Update () {

        if(!trigger){
            collider.enabled = false;
            yield WaitForSeconds(waitTime);
        }
        if(trigger){
            collider.enabled = true;
            yield WaitForSeconds(waitTime);
        }
    }

}


texts: problem using OnStartServer() for unity multiplayer networked game

texts:
UPDATE: i am still scratching my head over this. The way i see it, the Awake() function is only invoked when I load it in the Editor, but if I put the prefab Loading line into OnStartServer() it just doesnt load anything, presumably because it hasnt managed to load the prefab yet ... i think it is something to do with when it switches Scenes from the offline to online in NetworkManager, i think this script and others are being dropped because the DontDestroyOnLoad command wasnt called due to Awake not being called.

Hello everyone I am making a football game which you control one player from the team. It will connect 11v11 players per server (using a "Host" acting as server and client,  and other clients connecting to them)

I believe I have followed the examples and information provided by Unity to the letter, but I can't seem to get it working properly.

The problem: My code seems to work fine, provided I open the 'Host' instance from the Unity Editor, but if I make the full build version the Host it doesnt work.

Strangely all my player-objects will all spawn and act exactly as I intended, but the ball will not spawn unless the 'Host' instance is the one opened inside Unity Editor.
I've made the Ball a Network Identity, NetworkTransform etc and Registered Prefab in the NetworkManager in inspector.

Here's the code I am using to spawn the ball on the server, what could be the problem as I really have no ideas, thanks:

using UnityEngine;
using UnityEngine.Networking;

public class MatchdayManager : NetworkBehaviour {
GameObject ballPrefab;

private void Awake()
{
    DontDestroyOnLoad(this);

    ballPrefab = Resources.Load<GameObject>("Prefabs/Ball");
}

public override void OnStartServer()
{
    Debug.Log("on server start called");
    GameObject go = Instantiate(ballPrefab);
    NetworkServer.Spawn(go);
}

}


texts: Convert a transformation matrix from world-space to camera-space using Eigen

texts:
I have a transformation matrix, in world space. I need to convert it to local(camera) space.

I have done the reverse of this (Local - to - world) using:

Eigen::Matrix3f R0; //rotation matrix
Eigen::Vector3f T0; // xyz translation values
Eigen::Vector3f C0; //result

R0.transposeInPlace();  //invert rotation matrix

C0 = -R0 * T0;   //return world-space coordinate

Can I simply run this exact same thing to invert it the other way? Or is it a different equation?


texts:
I was hoping if you could help me out here. I'm developing a 3d table tennis game, and got the collision detection working perfectly when the ball hits the racket. However, now I would like the ball to move depending on where it hit the racket (example if it hit the far left side, it goes to the left etc..) Heres the collision detection I used:

private bool IsCollision(Model model1, Matrix world1, Model model2, Matrix world2)
    {
        for (int meshIndex1 = 0; meshIndex1 < model1.Meshes.Count; meshIndex1++)
        {
            BoundingSphere sphere1 = model1.Meshes[meshIndex1].BoundingSphere;
            sphere1 = sphere1.Transform(world1);

            for (int meshIndex2 = 0; meshIndex2 < model2.Meshes.Count; meshIndex2++)
            {
                BoundingSphere sphere2 = model2.Meshes[meshIndex2].BoundingSphere;
                sphere2 = sphere2.Transform(world2);

                if (sphere1.Intersects(sphere2))
                    return true;
            }
        }
        return false;
    }

Any help would be greatly appreciated as to how i could improve this so as to get what I desire. Thanks


texts: OpenGL 2 and back vs 3 and forward: What are the key differences for 2D graphics?

texts:
OpenGL contexts before and after OpenGL 3.0 are rather different. So far I've really only worked with buffers on either side anyway, I do know the most notable difference is lack of Immediate Mode.

Throwing out Immediate Mode considerations all together, what important differences should I look out for specifically when coding low-level two dimensional operations in a 2-D graphics engine?