texts: Can I legally use mechanics from a game that is removed from the store?

texts:
There was a mobile (android, ios) card game that I really liked playing. Last year, the game was removed from the store and noone were able to play it. The company is still up.

That game had a really original Rock-Paper-Scissor battle system. Cards with rock attribute could beat cards with scissor attribute, etc.

Each card had one or more skills to change the board situation slightly so that you can beat the opposing card.

  (For instance, A Paper could turn to a Rock to beat opposing Scissor,
  if it had the skill ready.)

  (As another example, a card could turn all opposing forces to Papers.)

The game had a rare damage mechanic where you lose points according to the cards that lost the battle for you.

The game also had a card crafting mechanic where you could create your own card with selected skills.

Is it legal to copy above mentioned mechanics with a customized art, as a new game? How can I check the laws regarding to that situation? Is there a way to find reliable lawyers in that area?

Note: I am asking this as a new question because the game is not even in the stores right now. It should make a legal difference in my opinion.

Thanks in advance.


texts: Attributes for calculating a hit in a turn based game or Roguelikes

texts:
I'm trying to figure out a good formula for determining a hit when the player attacks an enemy in a Roguelike. I'd like to come up with something simplistic but, still true to the way it's done in D&D or popular Roguelikes like AngBand or NetHack.

What I have so far is adding the differences between player and enemy attributes, along with a random integer:

if ((player.dex - enemy.dex) + (player.speed - enemy.speed) +
    (player.luck - enemy.luck) + random_integer_below_6()) >= 10) {
    hit(enemy);
}

This makes for unnatural gameplay: the player never misses weak enemies and vice versa for strong ones. Does anyone know of a guide to attribute based combat used in turn based games etc? Should I (and can I) copy the D&D rules verbatim?


texts:
I'm working on a project, and my current milestone is pathfinding. I have a working prototype that consists of several components:

a manually drawing of a path, that matches the visual path that the characters are allowed to walk on
a grid for A* calculations
a ray that pokes through the grid cells neighbors during the A* evaluation, and if it intersects a perfect GREEN  pixel, sets the cell as walkable for A* calculations, and if it hits a transparent pixel, leaves the cell as not walkable
after the rough A* path is calculated,  an algorithm for nurbs makes the turns in the path, more ease in, so to speak

My current issue is that the nurbs path Looks like it can use some optimization, And I can use your help to nudge me in the right direction, either pointing me to some literature or directly brainstorm.. Please see the picture below, it should be clearer what I mean, my goal is to have nurbs in a more straight-line, perhaps using some sort of extrapolation algorithm that is based on the A* result, and simplifies it in such a way that the nurbs curve is straighter from start to end

the project is browser-based Away3D framework(sea3D framework more specific)

its github repository can be found here

Thanks!

below is an example that shows the components described above: in GREEN the path that was draw manually, in RED the A* walkable path, in BLUE shades the nurbs

And another example how it actually looks in game, without all the pathfinding visual representations


texts: How to create an illusion of movement in space?

texts:
I am currently making a space game. The player's ship is stationary at world origin while things come towards it. However, the player is supposed to move towards the next destination.

To create the illusion of movement, I have particles moving backwards while my ship remains stationary. However, the particles seems to get lost visually during complex battle scenes.

Is there any other way to give the illusion of movement where there is an absence of stationary reference points?

Here are some screenshots of the game

The referenced question that has been identified as a duplicate does not answer my question. It is somewhat unclear what some of the implementations are. I seek a tried example that is used in other games if possible.

Most of the implementations suggested is more relevant to a first person perspective. I am looking for 3rd person effect where the player cannot "Visually Feel" the effect through a jolt.


texts: Determining if player-created structure matches a template in a 3D block-based game

texts:
Disclaimer: this is one of those dreaded Minecraft-style questions, but I feel it's more a data structures and algorithms question

I'm really new to 3D data structures and am wondering what the best way to store and match a 3D block structure.

Right now, the player is able to place blocks in any arbitrary space and when these blocks match a pre-defined structure an event happens. The way I'm doing it currently is when a player places a block the game recursively checks each adjacent block to find the block with the lowest x, y, z coordinate and makes that block the root block. Then it checks the rest of the blocks, based off of the root block, to make sure they match a certain template. The problem is that as the template gets more complicated, so does my (terribly inefficient) code.

I'm thinking the best way to do this is to store some type of matrix that defines the structure and then match against the matrix whenever a player places a block. Are there already data structures/algorithms that would match this type of problem?


texts: VBO in a class doesn't draw when The class has a destructor

texts:
I am making this class QuadTemplate

class QuadTemplate
   {
    public:
    QuadTemplate()
    {
        vbo=0;
        uvbuffer=0;
        vao=0;
        TextureID=0;
        vboType=0;
        drawStart=0;
        drawCount=0;
        programID=0;
        TextureShaderID=0;
    }

    ~QuadTemplate()
    {
        glDeleteBuffers(1, &vbo);
        glDeleteBuffers(1, &uvbuffer);
        glDeleteProgram(programID);
        glDeleteTextures(1, &TextureShaderID);
        glDeleteVertexArrays(1, &vao);
    }

    GLuint vbo;
    GLfloat vboData[12];
    GLenum vboType;

    GLuint uvbuffer;
    GLfloat uvDate[8];
    GLenum uvType;

    GLuint vao;

    GLint drawStart;
    GLint drawCount;

    GLuint TextureID;
    GLuint TextureShaderID;
    GLuint programID;
};

this class like the name says is a template where I store all the Vbo's date, it doesn't have any other function because I have a function that give it the values, the problem is when I try to draw the Vbo, it doesn't work, not only that it also presents some graphics mistakes, but when I comment the destructor, it work perfectly fine. why it doesn't work with the destructor?


texts: How to deal with different resolutions in a 2D game?

texts:
For example, you have a sprite of mario with a size of 20px x 20px.  This sprite however was made for a game resolution of 1000px x 1000px. What if you want to provide a different game resolution as an in-game option? You could offer to change the game resolution to 2000px x 2000px, but then Mario should be drawn again for this particular resolution. And if you offer many resolutions, this can be very much to draw and the amount of space the image files will take, are going to get too big.

So, my question, what's the trick here?


texts:
I am using Unity and I want to reconstruct position from depth and frustum corners in pixel shader.

I am doing this:

In my App, I calculate view-space corners of the far frustum plane and pass them to shader. (this is correct, I render spheres in world coordinates at corners and they are there).

In Full screen Vertex shader:
Select corner based on corner index calculated from texcoord. This is also correct, I have rendered colors.
This is passed to Pixel Shader as "ray"

In Pixel shader:

float3 normal;
float depth;
DecodeDepthNormal(tex2D(_CameraDepthNormalsTexture, i.uv), depth, normal);
depth =  Linear01Depth (depth);
position = depth * ray;

Reconstructed position is incorrect. The result I got for cube, that covers whole viewport is this:

But in reality, I should have this:

(or similar image with white, blue, pink for different handness)

My output is somehow "blured" around the middle. Why ?


texts: Maya Animated Character export for XNA 4.0 problem

texts:
To begin with, I'm trying to export an animated character in .fbx format from Maya 2013 to XNA 4.0

In Maya, The Model has a basic rig and the animations are in clips made in the Trax editor.

so the issue i'm having is after selecting the model and the root joint and then hitting export in .fbx format, for some reason when i open the exported .fbx file the joint system is detached from the model with no animation.

Btw, i have the animations in clips so that they can be called in code, for example "run","walk","attack".

So, what can i do to solve this problem?

Thank you.


texts: Creating a highlight halo around a selected object

texts:
I'm looking to create a halo highlight around the selected objects in my game screen.
The main platform is android, but I am writing an iOS version as well, updating it whenever I successfully add the next feature.

I am trying to ensure that the game is capable of working in both OpenGLES 1 and 2, but of course I expect v2 to have more effects eventually.

The effect I want to achieve is to have a halo around the edge of the selected object (I believe Diablo II did something similar). In theory my idea is to render the scene, enabling stencil ops when the selected object is rendered then enable stencil testing, disable depth and set an orthogonal projection and draw the halo colour 5 pixels larger in each of the X and Y dimensions from the object's centre with 0.2 alpha then successively draw again reducing the size and blending.

Using this method, I also need to figure out the most efficient way of determining the centre and extents of the objects.

EDIT:
Another technique I just thought of after posting is, after the stencil op render, render a coloured ortho rectangle to texture through the stencil then shrink and re-enlarge the image to blur the edges then render the resultant texture back on top of the scene, around the stencilled area

Are either of these a good/efficient way to achieve the effect? Is there a better/faster/more efficient/more common way of doing this?
Should I bother doing it for v1 and make it a v2 only effect?
Should I bother with v1 at all if I want these sorts of effects?


texts: Checking whether moving object has reached target position

texts:
So I have a fast-moving object in my game, let's say a bullet. At each iteration of the main loop I update the object's position based on the delta time value dt and draw it at the new position.

I also check whether the object's new position is close to a target position. In that case the object will be removed:

S....|...|....|....|......|...|....|....|...|..T..|X

The object starts from location S, moving towards target position T. Each dot . represents one ms time. The vertical bars | represent a game loop iteration, in which I check whether the object has reached its target destination. At X the object will be removed.

Since these checks (ie. game loop iterations) might take place before or after the 100% exact target position (even if only a few pixels off), I perform this check with a distance between a line segment from the last position to the current position, and whether the target position is on that line. This approach works well.

There is one issue though: Since the check in which I recognize that the target has been reached happens after the real position of the target, the object moves a little bit further than desired. That's becoming more severe when the object is moving very fast.

Now my question: Is there kind of a "best practice" how to deal with this issue? I assume this is a common problem in game development.

PS: The only solution I could think of is to re-position the object to the real target position as soon as the check succeeds. However, that can look a bit like a "jump" back, which does not look great.


texts:
So lately I wanted to use the Z buffer in opengl to order my 2D sprites in my program. Now I didn;t relaize that if you use the Z buffer then you cant blend these sprites. And some of these sprites are translucent.

My question is what can I do to fix this, by still using the handly Z buffer?


texts: How to efficiently keep the player from moving outside the gameobject he is colliding with?

texts:
I am developing a game with Unity 2017.
The game mechanics are as follow:

Classic top-down RPG;
Movements are: UP, DOWN, LEFT and RIGHT;
Player evolves in a 16*16 map;
He can dig in the direction he wants to make his way through the map one tile at a time;

At first I was using a very classical approach using tilemaps, RigidBody2D and BoxCollider2D on tiles and the player GameObjects.

Collision detections went fine and my tilemap looked pretty much like that (red being the walls and white the empty spaces):

The problem with this approach is that I have to keep in memory the state of 256 tiles in a List<Vector2f> and to create the 256 expected GameObjects representing either my walls (which a totally black), or my floor (the empty space).

Creating a black GameObject with its own BoxCollider2D for each of the tile seems a little bit overkill. And this brings me to the second iteration of my game: to keep in memory only the tiles the player digged.

What I would like to achieve efficiently, is to let the player evolve as long as he is colliding with an underlying tile, but stop moving as soon as he doesn't.

This is ok:

This isn't, and player should be placed to previous state.

I could take advantage of OnTriggerEnter2d and handle custom collision and response, but I have the feeling that something more simple and more optimized may exists somehwhere in the wild!

Thanks to any help provided!


texts: How can I disable the forward/back buttons in AS3?

texts: How can I disable the Flash player forward and back button in AS3? These buttons make it possible to cheat in my game by moving from level to level.


texts: How can I create and load models with additional information?

texts:
I want to create game similar to original DOOM in Unity (using 2017.2). I'd like to make it possible to load entire levels from file, but I don't really want to write my own level editor that would serialize and deserialize Unity objects.

I'd like to allow the player base to create new levels using blender, without them needing to use Unity: all the logic and shapes should come from that single blender file.

I'm wondering how it could be possible to create levels in blender with some additional data, that could be processed from the Unity game. Just simple markers, for example stepping on platform A will open door B.


texts: Implementing an interaction system that can perform different tasks dependant on the object you are trying to interact with?

texts:
In No Mans Sky there are objects to interact with in the world and the result of the interaction changes depending on the object. For example, if you interact with a plant it will give you resources but if you interact with the save point it will save the game. I was wondering if it would be efficient to add an 'Action' class that had different methods for each different action (save(), grab resources(gameObject)), then call each action depending on what object you are interacting with...

Another possible solution I came up with is to have a base class of 'Action' and have each action as a script that inherits from this class, then attach them as a component to the interactable objects. Then have the interaction system check if it has an 'Action' script and perform that action if required.

I am just wondering if any of my solutions would be effective, or if there is a much simpler way around this problem that I am missing.


texts:
I'm very new to game development, and I'm working with Godot engine.
I'm making a platform game and I downloaded a package from the web with assets, it contained some sheets.
I have used a 2D atlas importer in Godot before bt it requires a .json file which contains the coordinates.
The sprite sheet i downloaded does not have a xml or json.
How can i get sperate images from that sheet? Or any work around to make a tiled map in Godot?


texts: Handling player and AI in a component based structure dynamically?

texts:
I'm trying to find a way to allow both input and AI to call actions of an actor in a component based structure for a 2d turn based game. The actions make use of the components. To keep the system flexible I don't want to statically set what actions the actor has in the actor class.

Right now I have action classes who have ids and I'm using maps to hold the actions and allow the input and AI to execute actions by calling a function in the actor class. Now I've run into all sorts of issues like it not working well with using different parameter types or amounts and other things. So is there a better way to do what I try to achieve?

This is my actor class that holds a map with actions that take two ints:

class Actor
{
    friend Scene; /* allows the scene to move the acotr */

public:
    Actor();
    ~Actor();

    int getCellX() { return m_CellX; }
    int getCellY() { return m_CellY; }

    void addComponent(Component* component);

    void addAction(PositionAction*);

    bool executeAction(string, int, int);

private:
    int m_CellX = 0;
    int m_CellY = 0;

    map<string, Component*> m_Components;

    map<string, PositionAction*> m_PositionActions;
    map<string, TargetableActorAction*> m_TargetableActorActions;
};

This shows the hierarchy of the action class:

class Action
{
public:
    Action();
    ~Action();

    virtual string getID() = 0; /* used to identify the action in the map */
};

class PositionAction : public Action
{
public:
    PositionAction();
    ~PositionAction();

    virtual bool execute(int, int) = 0;
};

class MoveAction : public PositionAction
{
public:
    MoveAction(MoveComponent&);
    ~MoveAction();

    bool execute(int, int);

    string getID() { return "move"; }

private:
    MoveComponent& m_MoveComponent;
};

And this is what the move action does:

MoveAction::MoveAction(MoveComponent& moveComponent) : m_MoveComponent(moveComponent)
{
}

MoveAction::~MoveAction()
{
}

bool MoveAction::execute(int dX, int dY)
{
    /* will check whether some conditions hold */

    /* move the actor, returns false if failed */
    bool sucess = m_MoveComponent.move(dX, dY);

    return sucess;
}

This creates the player actor with a move component and the move action.

Actor* player = new Actor();

MoveComponent* moveComponent = new MoveComponent(scene);

player->addComponent(moveComponent);
player->addAction(new MoveAction(*moveComponent));

return player;

And you can execute an action like this:

actor.executeAction("move", 1, 0);


texts:
I can't seem to find any well executed code examples for Android joystick controls.

Whatever it may be, algorithms, pseudo code, actual code examples, strategies, or anything to assist with the design and implementation of Android joystick controls; I can't seem to find anything decent on the net.

What are some well executed examples?

More specifically,

Pseudo Code
Current Examples
Idea/Design
Functionality Description
Controller Hints Related Directly to Android Architecture

What kind of classes will I have making this? Will there be only one? How would this be implemented to the game architecture? All things I am thinking about.

Cheers!

UPDATE

I've found this on the subject Joystick Example1, though I am still looking for different examples/resources.
Answered my own question with a link to the code of the above video. It's a fantastic start to Android Joystick Controls.


texts: Does VK_SNAPSHOT not send a WM_KEYDOWN; only WM_KEYUP?

texts:
On my machine, every key sends a WM_KEYDOWN message except for SysReq/Print Screen key: which only seems to send WM_KEYUP.

Is this actually the case?


texts:
I am writing a mod for Minecraft (in Java, duh) and want to apply a random potion effect like this:
    private static Effect[] poss_effects = new Effect[]{
        Effects.SPEED,
        Effects.SLOWNESS,
        Effects.HASTE,
        Effects.MINING_FATIGUE,
        Effects.STRENGTH,
        Effects.INSTANT_HEALTH,
        Effects.INSTANT_DAMAGE,
        Effects.JUMP_BOOST,
        Effects.NAUSEA,
        Effects.REGENERATION,
        Effects.RESISTANCE,
        Effects.FIRE_RESISTANCE,
        Effects.WATER_BREATHING,
        Effects.INVISIBILITY,
        Effects.BLINDNESS,
        Effects.NIGHT_VISION,
        Effects.HUNGER,
        Effects.WEAKNESS,
        Effects.POISON,
        Effects.WITHER,
        Effects.HEALTH_BOOST,
        Effects.ABSORPTION,
        Effects.SATURATION,
        Effects.GLOWING,
        Effects.LEVITATION,
        Effects.LUCK,
        Effects.UNLUCK,
        Effects.SLOW_FALLING,
        Effects.CONDUIT_POWER,
        Effects.DOLPHINS_GRACE,
        Effects.BAD_OMEN,
        Effects.HERO_OF_THE_VILLAGE
    };

    private long prev_milli = System.currentTimeMillis();

    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
        if (System.currentTimeMillis() - this.prev_milli >= 60000) {
            Effect to_apply = poss_effects[(int) (Math.random() * poss_effects.length)];
            int duration = (int) (Math.random() * 15 * 20);
            int amplifier = (int) (Math.random() * 2);
            playerIn.addPotionEffect(new EffectInstance(to_apply, duration, amplifier));
            this.prev_milli = System.currentTimeMillis();
        }
        return super.onItemRightClick(worldIn, playerIn, handIn);
    }

However, when the timer ticks down to zero on the potion effect, the effect stays there with the timer at 0:00. The first time I right-click it, I get two potion effects: one that works properly and only lasts for the given amount of time and one that has the problem described previously. All subsequent right-clicks produce the latter.
When I do this:
    @Override
    public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker) {
        target.addPotionEffect(new EffectInstance(Effects.WITHER, 60, 2));
        target.setHeadRotation((float) (Math.random() * 360), (int) (Math.random() * 180 - 90));

        return super.hitEntity(stack, target, attacker);
    }

the effect applies normally and runs out normally every time I hit an entity.
What's wrong?


texts: An object twice as close appears twice as big?

texts:
So I was thinking about creating a 2D game where you can also move along the Z-axis, by changing in which layer you are. Depending on the depth I want to scale my 2D sprites.

Once, someone had shown me a demo in which he had a lot of 2d sprites, and by scrolling he could change the depth of the camera. So when zooming in, the objects would come closer to the player, and appear bigger. Then I wondered, how much bigger should an object be when it gets 1 unit closer. How would you calculate that?
So the guy told me: There is one basic rule I am using: "objects twice as close, appear twice as big."

Now, by testing it myself, I know that rule doesn't apply in the real world ;)
But is there some constant that is used in real world calculations for perspective or something? Or a formula?

I know this might not be the best place to ask such a question,
but since this is the only site I use for game-related questions, and my context is a game, I thought I'd give it a try. Also, I am kind of expecting that there is this person here that knows everything about 3D perspectives and matrices or something, since it might relate to 3D games ;)

tl;dr:

"an object twice as close, appears twice as big"
That is not true in the real world.
But which constant or formula is correct?


texts:
Is it possible for me to use Blender to generate a 3D skybox?

The concept is fairly simple: I create a scene that I want to display on the skybox (mountains, clouds, water, etc). Then, couldn't Blender render it from the origin, calculating the images that would be placed on the six sides of the skybox?

Is there a way of doing this? It'd be a very easy way of making one's own skyboxes...


texts:
This draws a white vertical line from 640 to 768 at x512:

glDisable(GL_TEXTURE_2D);
glBegin(GL_LINES);
      glColor3f((double)R/255,(double)G/255,(double)B/255);
      glVertex3f(SX, -SPosY, 0); // origin of the line
      glVertex3f(SX, -EPosY, 0); // ending point of the line
glEnd();
glEnable(GL_TEXTURE_2D);

This works, but after having a problem where it wouldn't draw it white (Or to any colour passed) I discovered that disabling GL_TEXTURE_2D Before drawing the line, and the re-enabling it afterwards for other things, fixed it. I want to know, is this a normal step a programmer might take? Or is it highly inefficient? I don't want to be causing any slow downs due to a mistake =)

Thanks


texts:
I'm having issues rendering rounded shape figures.
I have a Texture with different images in it and I get this whale figure from it with TextureRegion but the stroke of it looks pixelated.

The original whale image is 357x721 px and the program scalate it up or down depending on the device.

And I use TextureFilter to Nearest but it doesn't solve problem as I thought it would.

Does someone knows a bit about this issue?

    texture = new Texture(Gdx.files.internal("texturepack_nuevo.png"));
    texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);

    pilar = new TextureRegion(texture,591,0,357,721);

    whale_1 = new TextureRegion(texture,0,0,591,323);
    whale_1.flip(false, true);

    whale_2 = new TextureRegion(texture,0,323,591,323);
    whale_2.flip(false, true);

    whale_3 = new TextureRegion(texture,0,646,591,323);
    whale_3.flip(false, true);

    TextureRegion[] whales = {whale_1,whale_2,whale_3};
    whaleAnimation = new Animation(0.15f, whales);
    whaleAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);


texts: Simultaneous events in a realtime system, where processing order causes different outcomes

texts:
I am working on a realtime dungeon crawler, focusing on a relatively complex and flexible skill system. Somewhat similar to MMORPGs with many compound spells, area effects, buffs/debuffs, ect. I am working on the last few subsystems of the engine.

I found a problem with actions happening in the same logic frame which change an actor's attributes.

For example, let's say two actors use a skill on eachother in the same logic tick, which deals 100 damage and leaves a debuff which halves damage done.
If I simply iterate over each actor and process their abilities, the one which gets processed sooner will deal full damage, the other will do so with the debuffed state, dealing only 50.
Ideally, I'd like both of them to work similarly, dealing full damage and leaving the debuff.
What annoys me is the undetermined nature arising from the order of iteration.

One solution I thought about was to defer all the stat value changes and buff/debuff application until all the abilities are processed, since these are the only things which can affect the behaviour of abilties.
So essentially I loop over actors, process their ability methods, but queue up the stat and status effect changes in a list.
Once I processed every ability I iterate over once more, this time changing the actual stats from the queued values.

This fixes the determinism problem, but causes another.

To use another example (since I can't exactly phrase the general case):
Let's say the player has 100 mana, and gets hit by ten manaburn attacks in one frame, each burning at most 50 mana, and dealing damage equal to the mana burned.
If I don't use the former fix, it'll work correctly, two will burn out the 100 mana of the player dealing 100 damage, the rest eight will do nothing.

With the fix however, since the player's mana value doesn't change yet, all ten attacks will land and deal 500 damage, more than the amount of mana the player has, which is an even more silly situation than before.

I'm quite an amateur, I have less experience than wit for designing complex systems.
Is it possible to have determined behaviour for actions happening in the same frame while avoiding nastier consequences like the second example?

I know the player will unlikely notice the errors in the first case, and I don't think other developers bother with this issue either.

I'm still curious though, is such thing possible, a pipe dream, or just I have a warped idea about how the game logic should work?

Thank you!


texts: Very strange trigger behavior in Unity2D (4.5)

texts: I am developing 2d platformer and I've faced with a very strange triggers behaviour in Unity. I have made the enemy that can throw objects into main player. So I have made two empty GameObjects with Circle2D colliders on them and attached them into the enemy GameObject. The first trigger ensures that when enemy hand will pass through it, it will spawn an object that will be thrown in future, and the second trigger is responsible for the throw that object into player. The first trigger ensures that when the enemy's hand will pass through it, it will spawn an object that will be thrown in future, and the second trigger is responsible for throwing an object into main player. Every trigger has a Rigidbody2D component attached to it. The hands of the enemy have tags "right hand" and "left hand" and I am checking the in the OnTriggerEnter2D method. This method is calling and I have log messages and this method is detecting that left or right hand are entering trigger. But the problem is in that this method is calling when the hand has already passed through trigger and get out of its bounds. Can anyone help me and explain why this is happening? I have attached a picture where I draw a scheme and described my problem.


texts: UNET (Multiplayer) calling [command] function twice

texts:
I am playing around with UNET but stuck into this weird problem/scenario while testing on same machine (unityEditor and buildRun to create "2 players/instances"

The problem is weird interaction of [Command] attribute and void OnStartLocalPlayer() when hosting the game in Editor's instance and in standalonePlayer instance

Basically, when I am host in editorInstance (host), the function associated with [Command] is triggered twice by the standaloneInstance (client)
When I am hosting in standaloneInstance (host), the line which calls the function associated with [Command] throws warning "Trying to send command for object without authority."
But the function works as expected

I am spawning a PlayerObject from my NetworkLobbyManager and then that PlayerObject spawns its own pieces (sub-objects) using NetworkServer.Spawn(playerUnit);

Any help would be appreciated :( I like learning by trial and error but since 3 days I have not progressed or understood whats going on.

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

public class playerManager : NetworkBehaviour
{
    public int playerID;
    public GameController GC;
    public int playerUnitID;
    public bool localPlayer;
    public bool serverPlayer;
    public bool clientPlayer;

    // Use this for initialization
    void Start () {
        //Assign player unique ID as per order of joining
        if (!GC)
        {
            GC = GameObject.FindObjectOfType<GameController>();
            //playerID = this.GetComponent<NetworkIdentity>().connectionToClient.connectionId; connectionToClient is for serverOnly, connectionToServer is clientOnly
            playerID = (int)netId.Value;
            Debug.Log("(PM) Created GC in Start: " + playerID);
            //CmdCreatePlayerUnit(playerID);        //this gets called in OnStartLocalPlayer anyway(Trying to send command for object without authority)
        }
        localPlayer = isLocalPlayer;
        serverPlayer = isServer;
        clientPlayer = isClient;

        Debug.Log("Player: "+playerID+" isLocalPlayer: "+localPlayer+" and isServerPlayer: "+serverPlayer);
    }

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

    }

    public override void OnStartLocalPlayer()
    {
        if (!GC)
        {
            GC = GameObject.FindObjectOfType<GameController>();
            //playerID = this.GetComponent<NetworkIdentity>().connectionToClient.connectionId; connectionToClient is for serverOnly, connectionToServer is clientOnly
            playerID = (int)netId.Value;
            Debug.Log("(PM) Created GC in OnStartLocalPlayer: " + playerID);
            CmdCreatePlayerUnit(playerID);
        }
        //Debug.Log("(PM) OnStartLocalPlayer: " + gameObject.name);
        Debug.Log("Player: " + playerID + " isLocalPlayer: " + localPlayer + " and isServerPlayer: " + serverPlayer);
    }

    [Command]
    void CmdCreatePlayerUnit(int playerID)
    {
        Debug.Log("Creating player unit with ID: " + playerID + " and isLocalPlayer: "+isLocalPlayer);
        GC.registerPlayerNetID(playerID);
        Debug.Log("(PM) Registered Players: " + GC.playerNetIDs.Count);
        for (int i = 0; i < GC.playerNetIDs.Count; i++)
        {
            //Debug.Log(GC.playerNetIDs[i]);
            if(GC.playerNetIDs[i]==playerID)
            {
                playerUnitID = i;
                Debug.Log(playerID+" player's unitID is "+i);
            }
        }
        GameObject prefab = GC.players[playerUnitID];
        GameObject playerUnit = (GameObject)Instantiate(prefab, prefab.transform.position, prefab.transform.rotation);
        NetworkServer.Spawn(playerUnit);

        //Update the same in GC
        GC.registerPlayer1(playerUnit,(int)playerUnitID);
    }

}


texts: Difference between Update method and FixedUpdate in Unity?

texts:
i am starting to learn Unity3d and one of the confusion i get is difference between Update() and FixedUpdate().

I am following Lynda Unity 2D game development tutorial there, the instructor uses Update method, the player has RigidBody2D component and Box collider, he uses the Update method to translate the player, but when i do same in Update the player doesn't move but when i do it in FixedUpdate, everything works. He is giving tutorial from Unity 4.3 and i am taking the course in Unity 4.6.

Where should i use Update and FixedUpdate?


texts: How to make sure that when two bodies collide, there is only one collision detection on box2d?

texts:
I'm using LibGDX with Box2D and, when two bodies collide, the collision is detected multiple times.

Here's the code:

public void preSolve(Contact contact, Manifold oldManifold)
{
  Body a = contact.getFixtureA().getBody();
  Body b = contact.getFixtureB().getBody();

  if ((Utils.IsPlayer(a) && Utils.IsEnemy(b)) ||
      (Utils.IsEnemy(a)  && Utils.bodyIsPlayer(b)))
  {
    player.isHit = true;
    player.destroy();
    System.out.println(player.isHit);
  }
}

The player is destroyed multiple times; I want the player to be destroyed only once.


texts:
I'm making a top-down shoot-em-up in XNA, and I have placeholder blocks for my characters and bullets. Here's a picture:

I have all the Bullets stored in a List<Bullet>, such that a Bullet is deleted whenever it collides with the window bounds. So I have a List<Bullet> called bullets, and I call bullets.RemoveAt(i) to delete a Bullet object.

However, if I keep on holding down Space to shoot Bullets, my "Mango Warfare" application starts "bleeding bullets," or bleeding memory. The app starts to climb up the memory rankings in Windows Task Manager:

Here's my code for removing out-of-window-bounds bullets:

private void CheckBulletCollisions()
{
    foreach (Bullet bullet in bullets)
    {
        if (bullet.X > GraphicsDevice.Viewport.Width ||
            bullet.X < -5 ||
            bullet.Y > GraphicsDevice.Viewport.Height ||
            bullet.Y < -10)
        {
            bullet.Enabled = false;
            continue;
        }
    }
}

private void RemoveDisabledBullets()
{
    int num_bullets = bullets.Count;
    int count = 0;
    int i = 0;
    while (count < num_bullets)
    {
        if (!bullets[i].Enabled)
        {
            bullets.RemoveAt(i);
            ++count;
            continue;
        }
        ++count;
        ++i;
    }
}

Clearly, RemoveAt() is not working. Is there anything else I can do to free up memory for out-of-window-bounds bullets?


texts: How can I prevent cheating in my collecting and trading game?

texts:
I develop and manage an online game where users collect and trade virtual pets (it is entirely online).  It's a simple game, we periodically release new pets, users collect them and get random ones, then they trade for the ones they want, and some are rare.  We also do holiday events.
The problem is, there's nothing preventing people from creating new accounts, collecting a bunch of free pets, and then trading them all to their main account, or at least the rare ones.  They could also trade them all to other users in exchange for things on other sites.  This is against our rules, but enforcing it is subjective and difficult.
Historically, we've fought this by manually catching these users and banning them, looking at ip addresses, messages, trading patterns, etc.  The common defense is usually "that's just my friend/sibling and they don't play as seriously as I do".  And that may be true, I have no way to prove it, I just have to determine myself if they've gone too far or are abusing the system.  This type of cheating can be bad for our economy as it hurts rarity values, and gives cheaters an unfair advantage in the market.
I believe this is a fundamentally flawed system and am trying to figure out how to fix it so cheating is not possible, or at least very difficult.  I've seen other similar games force users to play mini-games to earn currency to get things, whereas we just give away free stuff periodically.  I don't like this approach because 1.programming mini-games is a lot of extra work and 2.we're known for being a casual game, I don't think users would like playing tedious mini-games over and over to collect pets.
The solution I've been considering would be implementing a currency, say gold, that you get periodically for logging in and "being active" on the site.  Gold would be required to collect the free pets, and to trade them.  So even if you create a new account, you can't just trade away everything you just collected.  In order to do big trades where you give away large amounts of stuff, you would have to accumulate lots of gold.  Pokemon Go used this approach with stardust, but then again, there's a lot more to do in that game to earn it, and perhaps that's my problem.  This has always been a simple, free to play game, and that's why people like it.  Also, it's just me working on this, and my skill set is mostly web development.
Can anyone offer advice?  I would really appreciate any feedback.
EDIT: Thanks for all the great suggestions, the answers and discussion this generated helped me a lot.


texts: How to tell right from left: Finding the vector pointing towards the right side of a character?

texts:
We have two vectors:

Pointing from the floor to a 3d character's head.
Pointing from the character towards where it's facing.

How do I find the vector point from the character towards the right?

The vector has to be orthogonal with the other two but also face in right direction and not to the left.

This is very similar to the question: Determining if something is on the right or left side of an object?
But I just want the math to computer the third vector from the first two.


texts: How does ECS handle systems which need to know more about the environment of the entities it processes?

texts:
I'm trying to wrap my head around the concept of ECS (Entity Component System). I think I grasp the concept of the different parts, Entities, Components, and Systems.

Entities: Basically just a container for components

Components: Data. E.g Transform component holding position, rotation and scale.

System: Runs on a subset of entities matching a combination of components. E.g. RenderSystem rendering all entities with a Mesh and a Transform.

What I'm having trouble wrapping my head around is how a system is supposed to assign data regarding the surrounding environment to the components without using global data. And it's probably because of a lack of understanding.

Example of what I'm getting stuck on:

Lets say I have a Player entity consisting of, among others, a Transform component. And lets say that there are multiple Zombie entities roaming the game world, which has a Transform and a AIPathfinding component. So I would naturally create a System that operates on Transforms and AIPathfinding to make the zombies chase the player.

My only problem is, how is the system supposed to know where the player is, or if there even is a player within range, without having to grab the player globally?
Sure I could pass the player into the creation of the system. But what if along with the player the zombie are also chasing a constantly changing amount of civilians. Do I pass them to the system at creation as well? Or should I have some global way to fetch entities matching a component query, similarly to how the system detemines which entities to operate on?

I understand that this might be entirely up to the implementation of the ECS. But I'm having a hard time finding resources that explains any further that the most basic systems (RenderSystem etc.).


texts: Are these all possible mobile devices resolutions?

texts:
In Unity, there's a switch where you can set your desired resolution and check if the game looks ok:

If I target the app for portait only - do I have to worry only about these here, marked as 'portrait', or list the possible aspect ratios from somewhere else?


texts: Unity - Post process foreground, but leave background as is

texts:
I am using Unity 2019.3.5f1 and I am using the Universal Render Pipeline (URP).

I am trying to use the post processing in URP for the foreground only (in my case, the players), and I want the leave the background (which in my case, is just a quad with a texture), as is.

I have tried using the Camera Stack but it wont work for me because the overlay camera can't have post processing effects according to the documentation.

The only solution that I could come up with is create the some sort of custom render which:

Render the background to buffer A.
Render the foreground to buffer B, and save the depth.
Combine the two using a shader that gets both textures, and the depth texture, and based on the depth, takes buffer A or buffer B.

The problem with this I believe is that I cant use it with the post processing for Unity.

Any idea what I can do?

EDIT:

I tried another thing in Unity which seem to not be working (might be a bug):

I created 3 cameras: Foreground Camera, Depth Camera (only render the foreground), and a Background Camera.
I set up the Depth camera so it will render to a render texture and, indeed now I have a render texture with the proper depth I need.

Now, from here everything went wrong, there seem to be odd things happening when using Unity new Post processing (the built in one):

The Foreground Camera is set to Tag=MainCamera, and when I enable Post Processing and add an effect, indeed we can see it. (as expected)
The Background Camera is essentially a duplicate of the Foreground one, but with Tag=Untagged, I use the same options (enabled Post).

Now, the expected thing is we see the Background Camera with effects like Foreground, but no:

When using Volume Mask on my background layer, the Post processing just turns off, no effect at all no matter what (and I have set my background the Background layer).
When I disable the Foreground Camera (or remove its tag) and set the Background Camera to MainCamera, still nothing changes, the post still wont work.
When I set Volume Mask to Default (or everything), the result is shown ONLY in the scene view, I tried rendering the camera to a RenderTexture but still, you clearly see no effect applied!


texts: How to make an animation play when a button is pressed once?

texts:
I have added an idle and jump animation to a character in unity. I can make the animation happen when the button is pressed. If the button is up middle at the animation the character goes to the idle position. But I want the whole animation happen in one press to the button and then go back to the idle position. My current script and Animator views are:

if (Input.GetKeyDown(KeyCode.Space))
    {
        Anim.SetBool("is_jumping", true);
        ApplyInput(moveAxis, turnAxis);
    }
    else if (Input.GetKeyUp(KeyCode.Space))
    {
        Anim.SetBool("is_jumping", false);
    }


texts: Are Tilesets more efficient than single pictures?

texts:
i want to program a 2D game and as i did lots of tutorials and read books about creating simple 2D games, nearly always tilesets were used for the graphics.
But are tilesets really more efficient compared to loading not from one but from several pictures?

Thanks


texts:
I am learning the basics of geometry shaders and I came across references to the "Z plane." It's pretty easy to visualize the X and Y planes, but where does the Z plane reside in Cartesian space? Wikipedia says

  it can be thought of as a modified Cartesian plane

So how exactly am I going to visualize it? Looking at google images doesn't help either. I am not a math savvy person so can someone help me understand the Z plane better?


texts: Why does my game freeze when I try and display a menu?

texts:
I make a MenuScene when my Game loads, which grabs some intro text from levelData and displays it and a button to start playing the level. When the MenuScene is created and displayed in onLoadComplete() it's fine. However when I display it again when advancing the level (levelData is loaded with new data and the MenuScene reset) it freezes, showing the game at the point the level was beaten. The menu is not displayed at all. I'm just calling

loadIntro();
this.mScene.setChildScene(this.mIntroScene, false, true, true);
this.mEngine.stop();

to display the MenuScene (the same both times, it works the first time but not the second), where loadIntro() is

private void loadIntro() {
            this.mIntroScene = new MenuScene(this.mCamera);

            final TextMenuItem intro = new TextMenuItem(-1, mFont, levelData.getIntroText());
            intro.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
            intro.setSize(400, 150);
            this.mIntroScene.addMenuItem(intro);

            final SpriteMenuItem startMenuItem = new SpriteMenuItem(MENU_START, this.mMenuStartTextureRegion);
            startMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
            this.mIntroScene.addMenuItem(startMenuItem);

            this.mIntroScene.buildAnimations();
            this.mIntroScene.setBackgroundEnabled(false);
            this.mIntroScene.setOnMenuItemClickListener(this);

    }

What am I doing wrong?


texts: Monogame - how to make a smooth color transition with Color.Lerp()?

texts:
I would like to know how to dynamically change a color. My code:

Color myColor;
Color startColor = new Color(255, 255, 255);
Color finalColor = new Color(231, 214, 90);
myColor = Color.Lerp(startColor, finalColor, 0.5f);

spriteBatch.Draw(myTexture, Vector2.Zero, myColor);

But the color does not change, in fact I get something similar to the finalColor, that's perhaps because I need to decrement the RGB values of startColor and check if they match finalColor? Help would be much appreciated.


texts: How to achieve this style of view in XNA?

texts:
I would like to use a Perspective projection to create the following effect in XNA:

Cubes are simply made up of 8 vertices and drawn using DrawUserIndexedPrimitives().

Any extra suggestions, are also welcome.


texts: C# class works in Unity, but not in Android build

texts:
I am using Unity to program a simple Android game in C#. Right now, all the game does is to randomly load one of 196 flags upon startup (view: https://hastebin.com/suxonayoce.cs or code below). This class file is currently the only class file there is. When I play the game in Unity everything works as expected (i.e. each time the game is started a random flag is displayed). However, when I build and run the game on my Android phone only the placeholder flag is displayed and never a randomly chosen one.

So far I've tried relaunching Unity, re-importing all assets, and recreating the game in a new project. Nothing of this has resolved the problem.

using System.IO;
using UnityEngine;
using UnityEngine.UI;

public class GameManager : MonoBehaviour
{
  private int _flagCount = 196;

  private string[] _ccTlds;
  private void GenerateCctldsArray()
  {
    _ccTlds = new string[_flagCount];
    _ccTlds = File.ReadAllLines(@"Assets\ccTLDs.txt");
  }

  private void DisplayRandomFlagSprite()
  {
    // Randomly gets the file name of a flag.
    int flagArrayPosition = Random.Range(0, 195);
    string flagImageName = _ccTlds[flagArrayPosition];

    // Gets the sprite of the flag called "flagName".
    Sprite sprite = Resources.Load<Sprite>(@"FlagSprites\" + flagImageName);

    // Loads the image associated with "flagName".
    FlagImage.GetComponent<Image>().sprite = sprite;
  }

  [SerializeField]
  private GameObject _flagImage;
  public GameObject FlagImage
  {
    get { return _flagImage; }
    set { _flagImage = value; }
  }

  private void Awake()
  {
    GenerateCctldsArray();
    DisplayRandomFlagSprite();
  }
}

Does anyone have any ideas why the games stops working when it is run on the phone and how this can be fixed?


texts: Slow Firefox Javascript Canvas Performance?

texts:
As a followup from a previous post, I have been trying to track down some slowdown I am having when drawing a scene using Javascript and the canvas element.  I decided to narrow down my focus to a REALLY barebones animation that only clears the canvas and draws a single image, once per-frame.  This of course runs silky smooth in Chrome, but it still stutters in Firefox.  I added a simple FPS calculator, and indeed it appears that my page is typically getting an FPS in the 50's when running Firefox.

This doesn't seem right to me, I must be doing something wrong here.  Can anybody see anything I might be doing that is causing this drop in FPS?

<!DOCTYPE HTML>
<html>
<head>
</head>
<body bgcolor=silver>
<canvas id="myCanvas" width="600" height="400"></canvas>

<img id="myHexagon" src="Images/Hexagon.png" style="display: none;">

<script>
window.requestAnimFrame = (function(callback) {
    return window.requestAnimationFrame ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame ||
            window.oRequestAnimationFrame ||
            window.msRequestAnimationFrame ||
            function(callback) {
                window.setTimeout(callback, 1000 / 60);
            };
})();

var animX = 0;
var frameCounter = 0;
var fps = 0;
var time = new Date();

function animate() {

    var canvas = document.getElementById("myCanvas");
    var context = canvas.getContext("2d");

    context.clearRect(0, 0, canvas.width, canvas.height);

    animX += 1;
    if (animX == canvas.width)
    {
        animX = 0;
    }

    var image = document.getElementById("myHexagon");
    context.drawImage(image, animX, 128);

    context.lineWidth=1;
    context.fillStyle="#000000";
    context.lineStyle="#ffffff";
    context.font="18px sans-serif";
    context.fillText("fps: " + fps, 20, 20);

    ++frameCounter;
    var currentTime = new Date();
    var elapsedTimeMS = currentTime - time;
    if (elapsedTimeMS >= 1000)
    {
        fps = frameCounter;
        frameCounter = 0;
        time = currentTime;
    }

    // request new frame
    requestAnimFrame(function() {
        animate();
    });
}

window.onload = function() {
    animate();
};

</script>
</body>
</html>

--EDIT--

I did some additional experimentation, and now I'm not sure that this issue really has anything to do with canvas at all.

I added a "frame duration" counter in miliseconds, and neither Chrome nor Firefox ever go above 1 ms, so the code I am running inside animate is certainly not exceeding the 60 FPS frame time.  My current theory is that the Firefox browser just isn't giving me a consistent animation frame that is locked to V-sync; I had read some old posts about Firefox being capped in the 50's, and maybe this is still true?

So I tried a new method to compensate for the problem.  I started "pooling" my update time, and running an updatge step for each 16.6666 milisecond increment in the pool.  Frankly, this looks almost MORE jittery, but I am guessing that it at least maintains a more consistent timeline for a game.  Blech though :(  Is this really the best way to go?


texts: Fixed timestep updates with a variable timestep update

texts:
Many suggest that a game loop looks something like this. See:

http://gameprogrammingpatterns.com/game-loop.html

http://www.koonsolo.com/news/dewitters-gameloop/

https://gafferongames.com/post/fix_your_timestep/

while (1) {
    lag += Chronograph.getDelta();
    while (lag >= msPerTick) {
        update(msPerTick);
        lag -= msPerTick;
    }
    render(lag);
}

However, is it equally viable to have a game loop as follows?

while (1) {
    lag += Chronograph.getDelta();
    while (lag >= msPerTick) {
        update(msPerTick);
        lag -= msPerTick;
    }
    update(lag); // 0 <= lag < msPerTick
    lag = 0;
    render();
}

I'm posing this question because my game should only be drawing sprites in the render call. Everything else should be handled by updates, particularly when sprites advance frames. In other words, the logic for advancing sprite frames should be handled by updates and rendering shouldn't have any affect on the state of my sprites.


texts: What's the best control scheme for an arena shooter on a touchscreen phone?

texts:
I am developing Android an game. It's going to be a top-down shooter with stealth features. I am now thinking about how to the make controls. Most top-down games are now twin stick (joystick on the left and right sides) but I need more buttons (for choosing weapons, commanding your squad, and using skills).

So here are my ideas:

Two (virtual) sticks like in other games, when you tap somewhere on the display, a circle with buttons appears, where you can choose abilities or weapons.
One stick on the left side for walking, shoot where the second finger is pressed, weapons and skills on the right side.

What do you think is the best? Or do you have any other idea? I want to choose the most intuitive and simplest.


texts: Creating maps and tileset for a 2d java game

texts:
I'm not a completly beginner to java, so I decided to write a map loader and a tileset loader myself instead of using a tilemap editor like Tiled. I'm using Slick & LWJGL for my game.

The plan was to load every map and tileset from external files. When creating a new map, you'd be able to assign tilesets to your map which define the tiles used to paint the map.

I've already written a tileset loader which creates tiles from an external file.
For example:

  0|floor|tiles/floor.png;

is a tile where id=0, floor means the player in the game would be able to walk on that tile, tiles/floor.png is the texture of the tile.

The tiles are stored in an array in the tileset class.

But I don't know how to create the map loader.
Example for a map:

  1, 1, 1, 1, 1;

  1, 0, 0, 0, 1;

  1, 0, 2, 0, 1;

etc. The numbers symbolize the id's of the tiles.

Is there any way to realize my plans? Or is there a better way?

Thanks in advance.

PS: Sorry for my english, I'm no native speaker.

My current solution:

public void createTiles() {
    for(int y = 0; y < map.length; y++) {
        for(int x = 0; x < map[y].length; x++) {
            for(int i = 0; i < tileSets.length; i++) {
                for(int j = 0; j < tileSets[i].tiles.length; j++) {
                    if(map[y][x] == j) {
                        Tile tile = new Tile(tileSets[i].tiles[j].texture, x, y, xOff, yOff, tileSets[i].tiles[j].isWall);
                        tileList.add(tile);
                    }
                }
            }
        }
    }
}


texts: Unity3D 3.5 pro - Moving the camera vs setting draw distance

texts:
I move the camera mostly via right-click + WASD, sometimes with [shift] if I want it to move faster. Occasionally, instead of moving my camera, it alters the draw distance / FOV / some visual aspect of the editing scene that causes trees and other object to disappear when I scroll enough, and eventually even the terrain starts disappearing. It is not m "zooming out". My camera does not move, the width and height of the FOV stays the same (one might say the depth is being altered though). What key am I hitting to cause this to happen, and is it possible to disable it?

side note: "keybinds" is probably the most spot-on tag for this question but it doesn't exist (surprisingly) and I lack the rep to create it.


texts: How do I work around the "You are missing the recommended JDK" error?

texts:
After switching to 2019.4 LTS I got this error (using Windows 10)

You are missing the recommended JDK. Install the recommended version using Unity Hub.

I installed the JDK using Unity Hub many times now, still the same error.
Tho I don't think it's getting installed.
As you can see below, the "OpenJDK" checkbox remains blue no matter how many I try to install it.

When I tried downloading and installing the JDK (JDK 1.8.0_181) myself I get this error instead:

You are missing the recommended JDK, versions other than 1.8.0 are not officially supported.


texts: I have created a menu on Unity using the built in UI components,I can't create this on a seperate scene because I used the toggle button, which basically when you click it, it spawns a specific object (I have 4 of these toggle buttons). I have completed making the menu on the my current scene. My problem is that when I start on runtime,  the menu appears in front of the first person character controller, and when I move the mouse to click the toggle, the camera controller follows the mouse movement. How do I fix this? Also when I click all of the toggle buttons, I want the UI to dissapear, so it isn't shown when I am playing the game because atm when I click the toggle buttons, the actual buttons stay on the screen whilst I am navigating around the scene, is there any way to make this invisible?


texts: Do programmers in the industry get to participate in the game design process?

texts:
My main goal is to create games which is why I'm planning on studying IT so I can later on be a game developer/programmer.

My question is: does a game programmer get involved in the game designing process or is that only the game designer's job? Is a game designer always needed or can programmers work on game design some of the time?

Do programmers need to have game designing knowledge or do they just follow orders? Similarly, do game designers require programming knowledge?

I'm kind of confused over what I want to be which is why I'm asking here. Basically, do game programmers also get to be game designers?


texts:
In old, 8-bit/16-bit games, sprites flashing every other frame were common. I don't want to use the hacks I've used before. Is there an elegant/clean way to do this? This is how I usually do it:

bool everyother = false;
// update
everyother = !everyother;
// draw
if (flashing && everyother)
    // do nothing
else
    // draw

Seems like a hack to me.


texts:
Trying to figure out exactly what causes branching and what doesn't in GLSL.

I'm doing this a lot in my shader:

float(a==b)

I use it to simulate if statements, without conditional branching... but is it effective? I don't have if statements anywhere in my program now, nor do I have any loops.

EDIT:
To clarify, I do stuff like this in my code:

float isTint = float((renderflags & GK_TINT) > uint(0)); // 1 if true, 0 if false
    float isNotTint = 1-isTint;//swaps with the other value
    float isDarken = float((renderflags & GK_DARKEN) > uint(0));
    float isNotDarken = 1-isDarken;
    float isAverage = float((renderflags & GK_AVERAGE) > uint(0));
    float isNotAverage = 1-isAverage;
    //it is none of those if:
    //* More than one of them is true
    //* All of them are false
    float isNoneofThose = isTint * isDarken * isAverage + isNotTint * isAverage * isDarken + isTint * isNotAverage * isDarken + isTint * isAverage * isNotDarken + isNotTint * isNotAverage * isNotDarken;
    float isNotNoneofThose = 1-isNoneofThose;

    //Calc finalcolor;
    finalcolor = (primary_color + secondary_color) * isTint * isNotNoneofThose + (primary_color - secondary_color) * isDarken * isNotNoneofThose + vec3((primary_color.x + secondary_color.x)/2.0,(primary_color.y + secondary_color.y)/2.0,(primary_color.z + secondary_color.z)/2.0) * isAverage * isNotNoneofThose + primary_color * isNoneofThose;

EDIT: I know why I don't want branching. I know what branching is. I'm glad you're teaching the children about branching but I would like to know myself about boolean operators (and bitwise ops but I'm pretty sure those are fine)


texts: Should I use "conventional" colors to represent item rarity?

texts:
I'm making a new RPG that has loot. In fact, a majority of the game is based around loot. It's going to have colored borders to denote the rarity of the loot as it's drawn.

WoW uses Grey, White, Green, Blue, Purple, Orange and some others. GW2 uses Gray, Black, Blue, Green, Yellow, Orange, Pink, Purple. The colors don't match but you can see some distinct overlap.

I'm wondering if those colors are important or intuitive to users understanding of the rarity or if they can be messed with? If they can be changed how do you determine what colors to put in what order?

For instance, if I went with White, Blue, Green, Yellow, and Red, would that be fine as long as I made it clear in other ways or would those colors be confusing?


texts: Unity3d: Position a gameobject such that its forms a right angled triangle with other two gameobjects

texts: How do I position C gameObject such that it forms a right angled triangle with A and B. I tried to use (B.transform.position.x,A.transform.position.z) but it still gives me something which is close to A (it takes it globally). I want the C to be along the local red axis of A and local green axis of B as seen in the picture. What do I do?


texts:
I'm using Direct2D to render a PNG image using a ID2D1BitmapRenderTarget and then caling it's GetBitmap() function and rendering the image using ID2D1HwndRenderTarget::DrawBitmap().

Some of the images rendered this way are clear but others appear blurry. I did some research and followed a tutorial to make my application "DPI Aware" but it didn't help.

(sample with a blurry image on the left)

What could cause the rendered image to appear blurry? Has anyone experienced this issue before? What can I do about this?


texts: What image sizes should I use for a mobile cross-platfom game?

texts:
I'm new to mobile development. I use Monogame.

What device screen resolutions should I consider to target all Android, iOS and Windows Phone devices?

Assuming we have three screen sizes, should I be using different images for each target resolution?


texts: How to Find Collision Reflection Vector on a Sphere

texts:
I have a game I'm building in Unity with some objects orbiting a sphere via rotating around a pivot point (0,0,0) at a radius of 10 units on the z-axis. The orbiting objects all have the same velocity. This all works great, but now I need to add a bouncing effect when they run into each other so they start orbiting in a new direction when colliding.

I am currently detecting a collision between two orbiting objects, and trying to determine the resulting reflection vector of the collision. The orbiting objects all have sphere colliders on them.

Here is a relevant code example for how I am orbiting the objects:

var velocity = 15f;
var directionVector = new Vector2(Random.Range(-1f, 1f) * velocity, Random.Range(-1f, 1f) * velocity);
transform.Rotate(directionVector.y * Time.deltaTime, -directionVector.x * Time.deltaTime, 0.0f);

Here is how I am currently trying to reflect the collision on the directionVector:

var bounceVector = Vector3.Reflect(transform.forward, collider.gameObject.transform.forward).normalized;
directionVector.x = bounceVector.x * velocity;
directionVector.y = bounceVector.y * velocity;

This does cause the objects to "bounce" off of each other, but the bounce direction doesn't seem right, so I have something screwed up. I also feel like this probably doesn't even matter that it's on a sphere because all I need to do is take two direction vectors and find their resulting reflection vector on a collision. Any thoughts?


texts: How do I get an XNA 4.0 game to run on other machines?

texts:
Whenever I try and run a game made in XNA 4.0 on a machine other than one used for development, it just won't run. I've followed the instructions here to ensure that all the dependencies are present.

To be clear I've done the following:

Downloaded and installed the Microsoft .NET Framework 4 Client Profile.
Downloaded and installed the Microsoft XNA Framework Redistributable 4.0.
Made sure I am not using anything contained within GamerServices and XNA.Net.*, my references are as follows:

  Microsoft.Xna.Framework
  Microsoft.Xna.Framework.Avatar
  Microsoft.Xna.Framework.Game
  Microsoft.Xna.Framework.Graphics
  Microsoft.Xna.Framework.Storage
  Microsoft.Xna.Framework.Video
  Microsoft.Xna.Framework.Xact
  mscorlib
  System System.Core
  System.Windows.Forms
  System.Xml
  System.Xml.Linq

I also followed the advice here to ensure the problem was not within the code itself.

I've tried the follow methods to get it to run (on both Vista and 7):

Use the built in publishing functionality. This results in an error saying that Microsoft.Xna.Input.Touch needs to be present in the GAC. I've tried adding Microsoft.Xna.Input.Touch to the references, and this does not fix the issue.
Copy the XNA dll files locally. This results in an error message stating that Microsoft.Xna.Game.dll or one of its dependencies could not be located.
Copy over everything contained in Release. This results in an Application X stopped working... or APPCRASH error message the second it starts. My code is never reached.

Is there any way to get this to work? I've been trying to get this to work with the deadline looming, and it's been a source of unneeded stress.


texts: Why is there a gameObject inside a GameObject

texts:
In order to manipulate a game object via script in Unity I need to access the gameObject inside the main GameObject.

Why is it structured this way?  What is the main GameObject representing compared to the gameObject?

public class Sun : MonoBehaviour
{
    private GameObject[] _satelliteGameObjects;
    private Rigidbody[] _satelliteRigidBodies;
    public GameObject[] Satellites;

    private void Start()
    {
        if (Satellites == null)
        {
            Debug.LogError($"You haven't added a {nameof(Satellites)}.'");
            throw new InvalidOperationException($"{nameof(Satellites)} should not be null");
        }

        _satelliteRigidBodies = new Rigidbody[Satellites.Length];
        _satelliteGameObjects = new GameObject[Satellites.Length];

        for (var i = 0; i < Satellites.Length; i++)
        {
            var satellite = Satellites[i];
            _satelliteRigidBodies[i] = Satellites[i].gameObject.GetComponent<Rigidbody>();
            _satelliteGameObjects[i] = Satellites[i].gameObject;
            _satelliteRigidBodies[i].AddForce(Vector3.up * 100);
        }
    }
}

In the example above, I'm passing a GameObject into this class.  However, in order to call members on the actual game object, I need to go through the gameObject property.


texts:
In XNA (and Direct3D in general AFAIK), rather than creating individual vertex and fragment shaders, you bundle potentially many related shaders into 'Effects'. When you come to use an effect you select a 'technique' (or iterate through all of them) and then each 'technique' has a number of 'passes'. You loop through the each pass it selects the relevant vertex and fragment shader and you draw the geometry.

What I'm curious about though is what you would need multiple passes for? I understand in the early days of 3d you only had one texture unit and then you had 2 and that often still wasn't enough if you also wanted to do environment mapping. But on modern devices, even in the mobile class, you can sample 8 or more textures and do as many lighting calculations as you'd want to in a single shader.

Can the more experienced here offer practical examples of where multi-pass rendering is still needed, or is this just over-engineering on the part of XNA/Direct3d?


texts: If I use my own normal values, should I turn off winding order culling?

texts:
I've discovered that I managed to program a series of boxes with indexed vertices in such a way that every other triangle (Half of each face) has a backwards winding order.

As a result, XNA is culling half of them.

However, my Vertex objects contain normal data that I have explicitly set, and I am going to implement my own backface culling shortly to reduce the size of the VertexBuffer.

Should I turn off winding order culling and manage it myself, or should I make sure the winding order is consistent and let XNA handle it?


texts: How do I read input from multiple keyboards/mice on one computer?

texts:
I want to be able to read inputs from multiple keyboards and still differentiate them. It's for split-screen. I know it's possible, because Serious Sam 3 allows it.

Edit : Well a whole lot of my description has been removed, anyway, one of the maine details was that it had to be cross-platform! However, I found just today a POSSIBLE solution, which is using libusb 1.0 (it's Windows-compatible since 1.0), I'm using 1.0.15 (which is actually libusbx, they've created a branch and have come back to the main branch for 1.0.16 =/ )! So my actual answer now is (because I have no PS/2 port :S), is libusb recognizing PS/2 devices (I know nothing about PS/2 standard, so I don't know, but I have some reasons to think it can be recognized). Does anyone know it? If noone knows, I wrote a program that enumerates USB devices and displays their Product and Manufacturer name, is anybody willing to test it? (you can run it in Avast! Sandbox if you prefer, it still works ^^)

Thanks in advance, and thanks for all the responses yet!

Oh by the way, using RawInput is out of question because of its Windows exclusive API, I thought about it once, but I want my game to be Windows/Linux/Mac compatible ;)

Edit2 : As marked in the tags, I'm coding in C++ (was also part of the original post)! I really don't understand what happened, since the original post title even changed =/ That was not my original question, the question was about the PS/2 / USB thing!


texts: Adding 'xna content project' reference to monogame project(visual studio 2013 pro)?

texts:
I want to add reference to an xna content project. Which should be like the content project reference we have in an xna windows game. I am on visual studio 2013. I got the xna extensions to work by following this method.
  http://jaquadro.com/2013/11/migrating-monogame-projects-to-vs2013-and-windows-8-1/

But i dont see an option to add content reference in visual studio 2013. I searched everywhere and couldnt find an answer. Is this even possible? Or am i running in the wrong direction?


texts: Does Unity use a different version of C#, or is it all the same? It looks different from regular C# but there are some regular C# elements in there.


texts: Is there any way to change compression type of TMX file?

texts: Basically it's all in the title, you can choose compression type then you create new tile map, but after it's done the "Save As..." option doesn't provide compression type selection.


texts:
My friends and I are creating a game for mobile platforms. We are now in the phase of creating the multiplayer part of the game.

We know how to do it but we are not sure how the multiplayer should work. Our game is turn-based, so if we would do something like Wordfeud. Where there is a time limit.

How could we be certain that [User2] knows that [User1] has ended his turn if lets say [User2] has his phone turned off.

Should we let the server control this time limit or should we let the client count for itself?


texts: Custom shader with stencil breaks Unity built-in masking

texts:
my custom shader works like a charm for what I wanted it, but if it is referenced in the scene, Unity built-in masking stops working (both the Sprite Mask component and the rect-based Mask stop masking).

What I needed is a 2D unlit shader that would combat overlapping semi-transparency for 2D non-light based shadows. In other words, instead of this:

I want this:

Since I don't know the first thing about shaders, I've copied the shader (like a clueless monkey) from here.
It works but, as I mentioned it breaks other stuff (masking). As soon as I change the shader of the referenced material to any other shader, the masks start working without problems, so I know the shader is the culprit.
I found out the problem has to do with the stencil. Trying different shaders that use the stencil and expose stencil properties shows that stencil ID, Comparison and Operation values that help achieve the required effect always break Unity built-in masking. This leads me to the conclusion stencil is "shared" between shaders and masking effects. I've also tried different Stencil Write/Read Mask values, but that didn't help. Please keep in mind my understanding of the stencil topic is super-shallow.


texts: Online card games: game loop or event based?

texts: The only games I've made have been the game loop variety. I'm just starting to think about building an online poker game where people could meet up in a lobby, etc. Cards seem event based... is the game loop strategy viable here? Or is it just a waste of time to keep running while waiting for someone to make a move?


texts: Usually in a game scene there might be tens of animations going on at the same time, each being in its own state. I wonder usually how is this managed in game engines? Do they just stack a variable indicating the state of the animation on entity? Or do they use a separate animation system to keep all states?


texts: How to recycle unity scroll list of game objects?

texts:
In my game, I have a scrollrect which its content have a VerticalLayout component. When I fill that with so many count of GameObjects, the game will fall in problem!

I know that I have to recycle my objects, but I don't know how!


texts: How can I handle errors when there is no valid OpenGL context?

texts:
I'm writing cross-platform (iOS, Android, OSX, Windows) library code that draws its output using OpenGL. I expect my users will often try to call my library's rendering functions without a valid OpenGL context (especially when they are first getting started), so how can I cleanly handle the error?

So far I have tried calling some OpenGL function and then calling glGetError() to see if it failed (and printing my user a helpful error message), but glGetError() segfaults if there is no context:

// Test for OpenGL Context

glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This line segfaults

if (glGetError() != GL_NO_ERROR)
    printf("You tried to call a rendering function but no OpenGL context was found!");

Is there a way to check for a valid context within OpenGL without getting a segfault?


texts: Lag compensation with networked 2D games

texts:
I want to make a 2D game that is basically a physics driven sandbox / activity game. There is something I really do not understand though. From research, it seems like updates from the server should only be about every 100ms. I can see how this works for a player since they can just concurrently simulate physics and do lag compensation through interpolation.

What I do not understand is how this works for updates from other players. If clients only get notified of player positions every 100ms, I do not see how that works because a lot can happen in 100ms. The player could have changed direction twice or so in that time. I was wondering if anyone would have some insight on this issue.

Basically how does this work for shooting and stuff like that?

Thanks


texts: How to use 16/32 square pixel tiles in tilemap on arbitrarily sized canvas in Phaser

texts:
My question is about Phaser and Tiled but I'm not quite sure how to ask it so please bear with me.

Do I need to make the size of the canvas or area on which I want to display my tilemap a multiple of the size in pixels of an individual tile in my tileset?  Or is there a way of scaling a tilemap to fit a particular screen area?

I'm not really sure how to explain my question better so I will give an example of what I'm talking about.  Because I'm using only freely available game art (such as that found on opengameart.org), most tilesets come with tiles sized 16x16 or 32x32 pixels.  Does the game area I want to display the tiles in have to be a multiple of 16 or 32, respectively?

Or put another way, if I wanted to have a grid of 32x32 tiles fit inside of a canvas of say, 900x900 dimension, must I have to draw/design my tiles to be of size ~28x~28 pixels?

And if I want to use a tileset with tiles of size 32x32 must I make the canvas a multiple of 32, like 1024x1024 for example?

Thanks for bearing with me and for any help.


texts: How do I configure a joint for a sliding door in Unity?

texts:
I have this sliding door where i want to use a joint to limit its motion:

...but I am confused about how to configure a joint to provide this sliding motion.

I've found the Hinge Joint component, but the comments below say this is for rotating motion. What kind of joint do I use to create a sliding motion?


texts: D3D11 shader signature validation with SV semantics

texts:
I'm trying to figure out what the rules are for linking the outputs of one shader stage to the inputs of the next.  Since D3D11 does not have any error checking for linkage between shader stages, I have written some code to check them by comparing the D3D11_SIGNATURE_PARAMETER_DESC struct from each input and matching it to an output of the previous stage. The code for checking the signatures is here.

This mostly works, except when there are certain special inputs to a stage that don't get passed from the previous stage. One example is the SV_IsFrontFace input to the pixel shader. Another example is the SV_PrimitiveID input to any stage after the vertex shader.

I've been googling and reading msdn.microsoft.com and so far it's totally unclear to me exactly how these special SV semantics work. In particular:

Q1. Does the ordering of them matter? Or must they occur AFTER all inputs that are passed in from the previous stage?

Q2. Some of these "special" SV values can be identified by looking at the SystemValueType field of the D3D11_SIGNATURE_PARAMETER_DESC. For example SV_IsFrontFace can be identified by checking if the SystemValueType field is D3D_NAME_IS_FRONT_FACE. However, what about SV_GSInstanceID? There doesn't seem to be a corresponding value in the D3D_NAME enumeration for that.
http://msdn.microsoft.com/en-us/library/windows/desktop/ff728724(v=vs.85).aspx

Q3. Is there a link where the rules for shader input parameter linkage is explained clearly?  Or better yet, code for validating shader signatures?


texts:
I am making a small game for a course in my school and was planning on using QT to build it. I have worked with pygame[last year] and turbo c++[about 5 years agao] to make games, small easy stuff. This time I am planning to make a game that supports multiplayer over lan, the game idea is simple however, information about the game is here.

I was hoping to know from you all, if it is a good choice to use QT for this! I am totally new to QT, but a decent c++ programmer. Also what problems would I encounter when it is a LAN game, for a start I just want it to support 2 players on the local network.

Thanks


texts:
Where do you usually implement player motion when going through the state machine of a combo system?

An example, when player presses X+Y it must do an uppercut like movement (Like street fighter) where the player jumps and hits. Another example could be the Devil may cry series where you can press down+sword button and the enemy is thrown up and the player authomatically jumps to let player hit target in the air.

When creating a combo, you have 2 things to take care of. One is the media that will be played when the combo is done (sound, animation, etc...) and the other the movement of the player when doing this combo.

How do you handle the movement of the player? I have 2 posible options:

1) Include the player motion (translation, rotatio, etc...) in the animation

2) Delegate the player motion to the combo nodes while they are being linked.

First option could be the easiest but seems a bit restrictive. For example if you want to let the player do some other action while the current combo node media is playing (ej. jumping) could be tricky (Jump + hit).

Second option would need to have some many diffeernt nodes (We could use some kind of delegates here to minimize the node count(IOC)) to cover all the motion needs of every part of the combo.

What do you think. Am I thinking too much?

Cheers.


texts: Respawn not working properly upon scene reload. Why is this?

texts:
So I made a respawn function and what is supposed to happen is the script it supposed to load a saved checkpoint. However I need to reset the scene (and again this worked just fine last night which was odd...).

Essentially the checkpoint waits for a player and then when the player enters the current checkpoint is written to a .txt file. Upon reload or death the scene is restarted, the .txt file is read and grabs the checkpoint. Everything works fine without Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name); //Reload scene. but I need that in order to "refresh" the scene.

CheckPoint Code:

using UnityEngine;
using System.Collections;

public class Checkpoint : MonoBehaviour {

    public LevelManager levelManager; //Empty level manager.

    // Use this for initialization
    void Start()
    {
       //levelManager = FindObjectOfType<LevelManager>(); //Unnneeded
    }

    void OnTriggerEnter(Collider coll)
    {
        if (coll.tag == "Player")
        {
            //levelManager.currentCheckPoint = gameObject; //<-DISABLE WHEN ES2 is fixed!!!
            Debug.Log("Activated Checkpoint " + transform.position);
            ES2.Save(gameObject.name, "myFile.txt?tag=checkpoint"); //Saves checkpoint to file.
        }
    }
}

LevelManger Code:

using UnityEngine;
    using System.Collections;
    using UnityEngine.SceneManagement;

    public class LevelManager : MonoBehaviour {

        [Tooltip("Note this will also serve as the spawnpoint for the player!")]
        public GameObject currentCheckPoint;
        private GameObject player;
        private int PHP;
        public int RespawnHP; //Amount of health to give player upon respawn.

        void Awake ()
        {

        }

        // Use this for initialization
        void Start ()
        {
            player = GameObject.FindGameObjectWithTag("Player");
        }

        // Update is called once per frame
        void Update ()
        {
            PHP = GameObject.Find("InventoryManager").GetComponent<InventoryManager>().PlayerHealth;

            if (PHP <= 0)
            {
                Debug.Log("Player HP has been depleted. Respawning.");
                RespawnPlayer();
            }

            if (Input.GetKeyDown("r"))
            {
                Debug.Log("Restarting level!");
                RespawnPlayer();
            }
        }

        public void RespawnPlayer()
        {
            Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name); //Reload scene.
            currentCheckPoint = GameObject.Find(ES2.Load<string>("myFile.txt?tag=checkpoint")); //Load saved checkpoint.
            Debug.Log("Player Respawning...");
            player.transform.position = currentCheckPoint.transform.position;
            GameObject.Find("InventoryManager").GetComponent<InventoryManager>().PlayerHealth = RespawnHP;
        }

        void RestartLevel()
        {
            //ToDo: Restart level, and reload last check point.

        }

        public static void SaveLevel() //Saves the current level to file.
        {
            //ES2.Save(SceneManager.GetActiveScene().name, "myFile.txt?tag=levelName"); //Saves level to file.
            //ES2.Save("none", "myFile.txt?tag=checkpoint"); //Overwrite checkpoint?
        }
    }

Does anyone have a clue what is wrong? Like I said earlier the problem seems to arise on scene reloading.

Response to comment(s):

  What behaviour are you observing at the moment? - Jack

Currently what happens is the player enters a checkpoint, the checkpoint is saved to a file, and upon respawn the checkpoint is loaded. After this I get spawned to the checkpoint that was saved but then immediately the level reloads itself and the player is not respawnd at the checkpoint. Here is a video to better demonstrate the issue (it will take a minute or two to finish up processing here as I've just pasted the link).


texts: Overlap detection does not work correctly when there is more than one warrior colliding with the tower

texts:
I have a project where warriors are generated and they follow a route. In this route has a tower, when a warrior overlaps that tower, it takes 5 of it life, and he does it every 1 second.

Code of the moment of the collision of the warrior with the tower (Warrior Blueprint): Call Even Lose Life

Look that the moment he overlaps the tower, he starts to move towards it. After that he calls an event that is present in the blueprint of the tower.

Event that was called (Tower Blueprint): Execute Event Lose Life and call Event Attack Tower

This event causes the life of the tower to be shortened by 5. Soon afterwards it is called an event in the warrior that is colliding with the tower.

Event called by the tower (Warrior Blueprint): Execute Event Attack Tower and Call Event Lose Life

This event is only to be given a 1 second interval between each attack by each warrior. At least that was the idea.

I could simply loop in the blueprint of the tower and multiply the damage (5) by the amount of warriors colliding, but it does not seem right to me.

I imagine the problem is because the event in the tower (image 2 of question) is being called multiple times without even being finalized.

In the game, when there is only one warrior overlapping the tower, everything happens correctly:

1 second interval between images.

With more than one warrior overlapping the tower, tower life only decreases with the arrival of a new warrior. While a new warrior does not come to life he remains intact:

When in reality what should happen was each of them take 5 life per second. Then 3 warriors, 15 life per second.

The way I did these 15 lifetimes will not be taken away at the same time, as the warriors have come at different times.

Exemplifying:

Warrior 1 arrived in the tower at 15.2 seconds.
Warrior 2 arrived in the tower at 21.5 seconds.
Warrior 3 arrived in the tower at 32.8 seconds.

Then in the second 33 (moment where the three warriors have already arrived):

Warrior 1 will take 5 life from the tower at 33.2 seconds.
Warrior 2 will take 5 life from the tower at 33.5 seconds.
Warrior 3 will take 5 life from the tower at 33.8 seconds.

How to make the damage to the tower correctly applied, regardless of the amount of warriors?

EDIT 1 (Attempt made based on Stephen's answer)

Warrior Blueprint:

It works perfectly when it is colliding with only one warrior, when it reaches 1 more, life stops to decrease and decreases 5 for each new warrior that overlaps.

EDIT 2 (getting deeper into the tests)

Pretty much the same code as the first edition, with the difference that I added a print at the end of the loop (when it is finalized) and added another condition to take the test:

In the print will appear the actor's name + the word "acabou" + condition value.

In Game:

As soon as the second warrior overlaps the tower, the loop of the first and second warrior ends. This happens with both conditions.

The loop is ending incorrectly and I do not know why. Something is making the condition false.

Message Log:


texts:
why is the cube moving when I use a controller, but not with the accelerometer?

void Update () {
    text.text = "X: " + Input.acceleration.x + "; Z: " + Input.acceleration.z;
    //transform.position = new Vector3(10* Input.acceleration.y, 0, 10* Input.acceleration.z);

    transform.Translate(Input.acceleration.x, 0, Input.acceleration.z);

    //transform.position = new Vector3(10* Input.GetAxis("Horizontal"), 0, 10* Input.GetAxis("Vertical"));

    transform.Translate(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
}

(I'm on a Xperia Z3 compact by the way)


texts:
I'm experimenting with building a game engine from scratch in Java, and I have a couple questions. My main game loop looks like this:

        int FPS = 60;
        while(isRunning){
            /* Current time, before frame update */
            long time = System.currentTimeMillis();
            update();
            draw();
            /* How long each frame should last - time it took for one frame */
            long delay = (1000 / FPS) - (System.currentTimeMillis() - time);
            if(delay > 0){
                try{
                    Thread.sleep(delay);
                }catch(Exception e){};
            }
        }

As you can see, I've set the framerate at 60FPS, which is used in the delay calculation. The delay makes sure that each frame takes the same amount of time before rendering the next. In my update() function I do x++ which increases the horizontal value of a graphics object I draw with the following:

bbg.drawOval(x,40,20,20);

What confuses me is the speed. when I set FPS to 150, the rendered circle goes across the speed really fast, while setting the FPS to 30 moves across the screen at half the speed. Doesn't framerate just affect the "smoothness" of the rendering and not the speed  of objects being rendered? I think I'm missing a big part, I'd love some clarification.


texts: convert orientation vec3 to a rotation matrix

texts:
I've got a normalized vec3 that represents an orientation.

Each frame of animation, an object's orientation changes slightly, so I add a delta vector to the orientation vector and then normalize to find the new orientation.

I'd like to convert the vec3 that represents an orientation into a rotation matrix that I can use to orient my object.

If it helps, my object is a cone, and I'd like to rotate it about the pointy end, not from its center :)

PS I know I should use quaternions because of the gimbal lock problem.  If someone can explain quats too, that'd be great :)


texts: Modify random distribution functions :: Make it less likely to get multiple similar values in a sequence

texts:
I want to generate a sequence of numbers for procedurally generating planets in a galaxy sector. Each planet should be placed randomly, however it should be very unlikely that two planets are directly next to each other. How can I achieve that?

I know that you can modify the chances by applying a distribution function, but how can I control them in order to make specific values more/less likely?


texts: XNA triangle grid not drawn using DrawIndexedPrimitives

texts:
I have just recently started working with Monogame (XNA). Now I had code that was drawing a grid using DrawUserIndexedPrimitives. However I read that it reloads the vertices in the GPU each draw, and I don't think that is going to cut it for me. Therefore I wanted to use DrawIndexedPrimitives instead.

However, when I made the switch, my pretty grid suddenly dissapeared. The question is thus: What did I do wrong using DrawIndexedPrimitives? The code within the draw method is given below:

game.GraphicsDevice.Indices = terrainIndexBuffer;
game.GraphicsDevice.SetVertexBuffer(terrainVertexBuffer);

game.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList,
                                          0,
                                          0,
                                          terrainVertices.Length,
                                          0,
                                          triangleIndicesList.Length / 3);
// This worked VV
// game.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList,
//                                               terrainVertices,
//                                               0,
//                                               terrainVertices.Length,
//                                               triangleIndicesList,
//                                               0,
//                                               triangleIndicesList.Length / 3);

Here terrainVertices is the list of vertices for the triangles, triangleIndicesList is a list representing the triangles (each three entries here refer to the vertices of one triangle).
Outside of the Draw method, I initialized the grid and index list as follows:

terrainVertexBuffer = new VertexBuffer(game.GraphicsDevice,
                                       typeof(VertexPosition),
                                       terrainVertices.Length,
                                       BufferUsage.None);

terrainIndexBuffer = new IndexBuffer(game.GraphicsDevice,
                                     IndexElementSize.SixteenBits,
                                     sizeof(short) * triangleIndicesList.Length,
                                     BufferUsage.None);

terrainVertexBuffer.SetData<VertexPosition>(terrainVertices);


texts: How do I calculate the z-coordinate for a perspective-camera in 2D?

texts: I'm new to LibGDX and trying to use DecalBatch with PerspectiveCamera, simply to have Z-coordinate for my sprites, as SpriteBatch does not offer that. However, I don't know how to calculate the Z-coordinate for the PerspectiveCamera for "pixel-perfect 2D-projection". How do I do that?


texts: How to organise an XNA client/server solution

texts:
I was wondering what would be the best way to go about organizing the projects for the XNA project I have been working on. It is a simple game that uses a client/server architecture.

Currently everything is in one solution that I open in Visual Studio. This solution consists of multiple projects. The client project, server project, content project, the game API project, and the networking library. It works this way, but it all feels cluttered it doesn't seem right from an architectural stand-point to have both the client and the server in the same solution.

Does it make sense to keep everything in one giant solution or should I have a separate solution for the client application and a separate solution for the server application. If I go about separating them how could I continue to use a shared API project between both solutions?


texts: Doubt about texture waves in CG Ocean Shader

texts:
I'm new on graphical programming, and I'm having some trouble understanding the Ocean Shader described on "Effective Water Simulation from Physical Models" from GPU Gems. The source code associated to this article is here.

My problem has been to understand the concept of texture waves. First of all, what is achieved by texture waves? I'm having a hard time trying to figure out it's usefulness.

In the section 1.2.4 of the article, it does say that the waves summed into the texture have the same parametrization as the waves used for vertex positioning. Does it mean that I can't use the texture provided by the source code if I change the parameters of the waves, or add more waves to sum?

And in the section 1.4.1, is said that we can assume that there is no rotation between texture space and world space if the texture coordinates for our normal map are implicit.
What does mean that the "normal map are implicit'? And why do I need a rotation between texture and world spaces if the normal map are not implicit?

I would be very grateful for any help on this.


texts: Unity 2D Rotating Cannon to Mouse Position Inaccuracy Issue

texts:
I am trying to rotate a 2D cannon to clicked mouse position and having accuracy issue. It's working but the angle seems to be losing more and more accuracy when I move the mouse to further up or down position.

Here's my code,

void Update()
{
        if (Input.GetMouseButtonDown(0))
        {
                // display a test cannon ball on mouse location
                Vector2 BallPos = MainCam.ScreenToWorldPoint(Input.mousePosition);
                TestBall.transform.position = BallPos;

                var p2 = MainCam.ScreenToViewportPoint(Input.mousePosition);
                var p1 = MainCam.WorldToViewportPoint(Cannon.transform.position);
                var p3 = p2 - p1;

                var angle = Mathf.Atan2(p3.y, p3.x) * Mathf.Rad2Deg;
                RotAngle = Quaternion.AngleAxis(angle, Vector3.forward);
                Cannon.transform.rotation = RotAngle;
        }
}

And attached screenshot below,


texts: CS0118 framerate is a field but a type was expected

texts:
I'm making a mobile game in Unity and I'm trying to write a script that will set the game to either 30 or 60 frames per second based on a public bool, but I am getting error CS0118 on line 12 with

  fps.framerate is a 'field' but a 'type' was expected.

I am pretty new to Unity so I need help with this?

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

public class fps : MonoBehaviour
{
  public fps framerate;

    // Use this for initialization
    void Start ()
    {
    framerate = GameObject.Find("gameSettings").GetComponent<framerate>(); <= error CS0118
    {
      if (framerate == true)
        Application.targetFrameRate = 60;
      else
        {
            Application.targetFrameRate = 30;
            }
        }
    }
  }