texts:
The title isn't great,  but let me try and explain my problem. I'm working on a little game at the moment the gist of which is that you're an entity in this 2-D world and you have to dodge obstacles. These obstacles approach form all 4 directions and you're stuck in the middle and simply have to survive as long as you can without dying (from hitting the walls, obstacles, etc.) Right now, my problem is this:

The obstacles are randomly generated, so they often collide with obstacles coming from the other directions. I feel like something should happens when they collide, but I don't really know what to do with them. Ideally, I would have the blocks generate such that they never collide, however this as proven to be both mathematically and computationally difficult. I'd still like to get this to happen if possible (if you have any clever tricks let me know) but I'm willing to consider other ideas as well. One thing that sounded cool to me was that upon collision, and explosion happens that abruptly shoves your entity away from the collision and deals a little damage. Conversely, a "black hole" could form and suck you towards the collision possibly dragging you into oncoming obstacles, etc. The problem I have with both of these ideas is that they're random. So there's no guarantee that it'll be consistent between play throughs. Seeing as they could potentially deal damage to the entity, it seems unfair. One person could have a significantly easier time than another because there were no collisions. Am I right to have these concerns? Or does the randomness add to the fun of things? Any ideas on how I could fairly handle such collisions?

Thanks!


texts: Tiled game: how to correct load background image?

texts:
i'm a newbie. I'm trying to develop a 2d game (top-down view).
I would like to load a standard background, a textured ground... My "world" is big, for example 3000px X 3000px.
I think it is not a good idea to load a 3000px x 3000px image and move it...
So, how is the best practice ?
To load a single small image (64x64) and repeat it for N times ?
If yes, ok, but how i can manage the "background" movement ?
Thanks
Bye!


texts: How do I make my character change his ability's when his sprite changes

texts:
I am making a platformer and am currently trying to have it so that my character will have different powers based on his emotions, and his sprite will change to match those emotions.

I have got it so that his sprite will change but I don't know how to get his powers to change as well. Note that I haven't even made his other powers yet, but even if I did I don't know how to change his ability's with his sprites as I am still very new to this whole coding thing. Can anyone please help me?

Here is my code for changing his sprites, if that would help.

using UnityEngine;
using System.Collections;

public class MoodManager : MonoBehaviour {

  public Sprite sprite1;// happy//
  public Sprite sprite2;// angry//
  public Sprite sprite3;//sad//
  public Sprite sprite4;//default//

  private SpriteRenderer spriteRenderer;

  void Start ()
  {
    spriteRenderer = GetComponent<SpriteRenderer>(); // we are accessing the SpriteRenderer that is attached to the Gameobject
    if (spriteRenderer.sprite == null) // if the sprite on spriteRenderer is null then
      spriteRenderer.sprite = sprite1; // set the sprite to sprite1
  }

  void Update ()
  {
    if (Input.GetKeyDown (KeyCode.Alpha1)) // If the space bar is pushed down
      ChangeMoodHappy (); // call method to change sprite

    if (Input.GetKeyDown (KeyCode.Alpha2)){
      ChangeMoodAngry ();

    if (Input.GetKeyDown (KeyCode.Alpha3)){
      ChangeMoodSad ();
  }

  void ChangeMoodHappy (){
    if (spriteRenderer.sprite == sprite1) // if the spriteRenderer sprite = sprite1 then change to sprite2
      spriteRenderer.sprite = sprite4;
    else
      spriteRenderer.sprite = sprite1; // otherwise change it back to sprite1
  }

  void ChangeMoodAngry (){
    if (spriteRenderer.sprite == sprite2) // if the spriteRenderer sprite = sprite1 then change to sprite2
      spriteRenderer.sprite = sprite4;
    else
      spriteRenderer.sprite = sprite2; // otherwise change it back to sprite1
  }

  void ChangeMoodSad (){
    if (spriteRenderer.sprite == sprite3) // if the spriteRenderer sprite = sprite1 then change to sprite2
      spriteRenderer.sprite = sprite4;
    else
      spriteRenderer.sprite = sprite3; // otherwise change it back to sprite1
    }
  }

}


texts: How can I ensure my game complies with all asset/source licenses when preparing it for distribution?

texts:
I put together a 3D space scene demo, but I bought some models from turbosquid and using the jmonkey engine I must comply with BSD licence (jmonkeyengine) and also package the models, but I don't think that the 3D artist who created the 3D models agrees, could you tell me if there is a solution to "lock" or "encrypt" the assets that I bought from turbosquid or other ways to handle content and assets with a different licence than the source code / libraries?

In practice I've purchased a 3D model from turbosquid and I don't think that I can just include it with a BSD-licenced open source 3D scene.


texts:
I am just starting to get into using pyBox2D as I already knew python well and I was wondering if I have 500 points of a large polygon, how would I be able to check if a point lies inside of this polygon. I tried to just make a polygon with 500 vertices but this isn't allowed in pyBox2D as the maximum vertices is 16.

I thought about splitting the polygon into many smaller polygons but I don't full know how to check if the point is inside all of these polygons. Do I need to create a body and add the polygon fixture or can I just use b2PolygonShape and then query the point from the shape?

I have been writing all my code using the github wiki for pyBox2D and they have a section on point querying a shape but I don't know how to implement this in my project.


texts: How to draw a character behind and in front of a building? (isometric map)

texts:
how is it possible to draw the player behind and in front of some building in an isometric map : should I slice them, replace the number in the map (one number for a tile usually) by an array of number (each being a piece of a bigger tile), and somehow add a Z-order related to each small number (the pieces of building), something like this?

//replace :
var map = [
    [1,0,1],
    [0,1,1],
    [0,0,1],
    [0,0,1]
];

//by :
var map = [
    [["2-zOrder/1","3-zOrder/1"],0,1],
    [1,1,1],
    [1,0,1],
    [0,0,1]
];


texts: Unity LLAPI Connection Problems: NAT/Routers?

texts:
I have created a bespoke networking system using Unity's LLAPI.  It works fine on the same machine, and sometimes works even to direct connect across the internet!

The problem however, is that it sometimes does not want to connect to other players across the internet.  It seems impossible to host the game on some ISPs, as clients cannot detect or connect to them.  I assume this is related to Router/NAT issues.

I would like to know how I can deal with this problem, integrating with Unity's LLAPI.


texts:
Projectiles need to accommodate timed, homing, linear, and arced behaviours and have single, cone, and splash effects on hit. What is a good pattern to accommodate these different behaviours that require different parameters?

I want a system where I can call something like ProjectileManager.Fire (*Projectile Parameters*) from anywhere and have a projectile get fired. How would parameters like timeToDetonate, coneAngle, and aoeRadius be handled in a user-friendly way?


texts: Unity multiplayer (online) - How to connect to a 'Client-Host' without using Unity Paid Service

texts:
I'm slightly annoyed with the official Unity guides here, because I have been following through some, and they have indeed helped me create a local network mulitplayer situation. However, at no point did they mention that using these methods (ie. UnityEngine.Networking // NetworkManager // NetworkManagerHUD // NetworkIdentity) will require me to pay Unity for Pro, and a monthly server usage fee, if I wanted to play via internet.

I've set up my own Rust server in the past and it was very simple. I just installed a Rust Dedicated Server on my desktop PC (which I have fibre internet connection) and ran the server. I could then have 20 people playing with me and we didn't notice any slow-down or lag or any problems with it. (Rust is made in Unity I believe)

I've tried searching lots on this matter, and there are many many differing voices of how I can do this (many out-of-date, and many explicitly stating its impossible without hiring a server) - I disagree, and think I can make my desktop run the server, BUT I haven't a clue if I'm correct and also how I would be able to make it.

Unity docs seem to be trying to hide this solution if it exists (perhaps I'm being paranoid).

I have the NetworkManagerHUD all working and can play locally as I say.

So, it appears that the NetworkManager allows a user to start my game in 'Client-host' mode, it also allows another instance elsewhere to click "Connect Client" and has a space for IP address.

Would I even need a dedicated server if a player has clicked to start as 'Client-Host'? assuming I don't, how can I then connect to this host from another machine? Does typing the client-hosts external IP allow this?

Sadly, I don't have anybody to help me test this right now.

If a dedicated server version is the preferable way to go, could anybody please help me in the direction of how to start creating this?

For info: The game at this stage is a very simple FPS shooter. The NetworkManager is assigning the 'isLocalPlayer' flag correctly to one instance of the player object. I see in the Editor Hierarchy that it is handling the game overall and has two player objects once I have logged in with two instances locally.


texts: How do I move an object with an accelerometer in libGDX?

texts:
I am working on a game which uses the accelerometer to move an object called "plane". I know how to add an accelerometer, but I can't get the plane to move.

package com.wyvern.pp.states;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.wyvern.pp.PPlane;

public class PlayState extends State{
    private boolean peripheralAvailable;

    private Texture walls;
    private Texture bg;
    private Texture plane;

    public PlayState(GameStateManager gsm) {
        super(gsm);

        walls = new Texture("walls.png");
        bg = new Texture("bg.png");
        plane = new Texture("plane_left.png");

        cam.setToOrtho(true);

        peripheralAvailable = Gdx.input.isPeripheralAvailable(Input.Peripheral.Accelerometer);
    }

    @Override
    protected void handleInput() {

    }

    @Override
    public void update(float dt) {
        handleInput();

        float xRot;
        if(peripheralAvailable) {
            xRot = Gdx.input.getAccelerometerX();
        }
    }

    @Override
    public void render(SpriteBatch sb) {
        sb.begin();
        sb.draw(bg, 0, 0, PPlane.WIDTH, PPlane.HEIGHT);
        sb.draw(walls, 0, 0);
        sb.draw(plane, xRot, 15 ); // gives an error
        sb.draw(walls, PPlane.WIDTH - walls.getWidth(), 0);
        sb.end();
    }

    @Override
    public void dispose() {

    }
}

How do I get the plane to move left and  right on the X axis?


texts: How do you make top down tileable mountain ranges like fire emblem?

texts:
TL;DR: my goal is to gain the knowledge necessary to make these kinds of mountains from scratch.

Hello all,

sorry if this has already been asked, and sorry for any incorrect grammar.

I've been searching hard all over for tutorials and dissecting tilemaps but i just can't figure out how to actually go about making an original tileable mountain range.

some examples of what I'm trying to figure out;

first, a fire emblem map, this is ideal for the kind of maps i want to make for a project, but it just doesn't make sense to me how it looks so damn great and is tileable.

second is the same map tiles, dissected to 16x16 tiles;

doing this helped me find that the maps are not the normal 16x16 i thought they where, only increasing my confusion as to how the original arts started making them...

and third; the same 16x16 tileset, now dissected to 8x8 tiles... now its basically to small for me to make heads or tails of it, spent a few hours trying to put them together like a puzzle, but i can only make small mountains when the tiles are... so indistinguishable to me. I'm just still having a hard time understanding how they tile to extend into large mountain ranges.

if anyone has experience or input or even tutorials, just anything, I'd really appreciate it


texts:
So let's say I have a project that contains 100 scenes or levels. Each scene contains a token (some coin or diamond) that can only be grabbed once. If the player takes the token in level N and replays level N the token should no longer be there but saved in some sort of wallet when he first grabbed it.
What would be the correct way to implement such a system? I'm looking just for a general idea of how this is implemented in most games.


texts: Data structure for logical representatios of maps for a 2D top-down RPG

texts:
I wish to logically represent a map for a 2D top-down RPG using a a bidimensional list (in python) structure. The map is like a variable size chess board. The first dimension represents the north-south direction of the map and the second represents the west-east direction.

For a square map of i.j cells ,in other words, a list of i lists, of j elements each, each element containing another list of variable representing what is contained in that square cell of the map, like type of terrain, any object, character occupying it, etc, which can be dinamically modified during gameplay.

Is this a good practice that can be easily interpreted by a graphical engine to draw a map?

I have the logical part of the game in python clear in my head, but I know nothing of graphical engines and don't wish to create something that cannot be tranformed easily by a graphical engine in future. Does any one knows a graphical engine that could use this data structure and draw based on it? It does not need to be in python itself, as long as it can be worked with without MUCH programing in other languages.


texts: What's the state of the art in biome generation?

texts:
That is, given a terrain + seas, what are the most advanced approaches available, for game dev, for generating the climate and hence biomes for various areas of the terrain?

Are there tools that, given the aforementioned input, will model things such as:

Ocean currents
Prevailing winds
Rain shadows

And generate outputs for biome assignment (most typically moisture and temperature as inputs into the Whittaker diagram)?

I've studied Amit Patel's great article on this subject, but it does not do much to model climate or precipitation.

Note: by "available for game dev" I don't need a turnkey tool, just interested in approaches that people have tried and how well they work in practice. This means it could be some hacked-together monstrosity in an obscure roguelike, but not something that only exists in a PhD dissertation or requires a supercomputing cluster to run.


texts: How do I choose an optimal texture size for a mobile Unity game?

texts:
I am developing a 2D game with Unity2D for Android, iOS, WebPlayer and maybe for desktop computers. I think the working resolution of my game is 1280*800.

How do I choose the optimal size of textures? May the textures be high resolution, for example 1920*1080? I read somewhere that it could be bad for devices with a small resolution.


texts:
I have a custom file format that has all the needed information for a 3D mesh (exported from 3ds Max). I've extracted the data for vertices, vertex indices and normals.

I pass to OpenGL the vertex data, vertex indices and normals data and I render the mesh with a call to glDrawElements(GL_TRIANGLES,...)

Everything looks right but the normals. The problem is that the normals have different indices. And because OpenGL can use only one index buffer, it uses that index buffer for both the vertices and the normals.

I would be really grateful if you could suggest me how to go about that problem.

Important thing to note is that the vertex/normal data is not "sorted" and therefore I am unable to use the functionality of glDrawArrays(GL_TRIANGLES,...) - the mesh doesn't render correctly.

Is there a way/algorithm that I can use to sort the data so the mesh can be drawn correctly with glDrawArrays(GL_TRIANGLES,..) ? But even if there is an algorithm, there is one more problem - I will have to duplicate some vertices (because my vertex buffer consists of unique vertices - for example if you have cube my buffer will only have 8 vertices) and I am not sure how to do that.


texts:
For my game I have decided to create my own hand-painted/stylized textures, and was curious about how my game would theoretically perform later down the road. Essentially, my game world is comprised of several "pieces" which are combined together within my editor to create the scene. Here is a picture showing three of these objects being rendered within my engine:

The textures for those objects are all kept together in a single 1024x1024 sheet. (It looks barren right now, but I plan on adding at least 30 other pieces to the sheet, too)

I went with this initially, because I wanted to avoid texture swapping in OpenGL as much as possible, which is known for being a bottleneck in rendering. The thing is, though, I don't like the quality of the textures that I am using. The pixel count is too low quality in my opinion and I would prefer bringing each model into its own 1024x1024 texture. Naturally, this would require that I have numerous texture swaps during a render-cycle, instead of just one. The quality of the textures would not be held back by anything except my own skill. This brings forth an intrinsic problem though...should I take the risk of sacrificing performance down the road? Would having each object contain its own 1024x1024 texture perform horribly? I already plan on ordering my objects based upon texture, so that way I won't have to reload the same texture multiple times for instanced geometry. I am also aware of texture-atlasing, but know that would also be an impossibility given the texture size of 1024x1024.

Basically, I want to hear from people who have made games. Did you use large textures like this? What challenges arose? What are your opinions on how I should proceed?


texts: Unity Profiler - What would cause PlayerEndOfFrame to have 10-16MB in GC Alloc?

texts:
I can't find much documentation on what "PlayerEndOfFrame" does. Sure it is the end of a frame but what would cause the GC Alloc to go so high?

This is the profiler results from a debug build on a remote machine using the IP connect to unity profiler.


texts: In which game use cases or contexts is it safe for a game client (end user application) to talk directly to a data store?

texts:
I have noticed countless messages that discuss the architectural design of nodes, networks, middleware, databases, and how the clients (as in a game client on a phone, browser, console, PC, etc) should read and write data.

My question here relates to who the client should be directly connecting to. For writes, I take the road that you don't want to trust a client to do safe things to a database or even a cache (like REDIS) so you would simply not let the client do that.

But there are interesting possibilities for a client to talk to a db or cache only to read data. I can see leaderboards, game server locations, and even dynamic MMO state data being validly put onto a bunch of READ-ONLY caches (obviously, a server entity will be able to update these caches) being potential use cases where the client gains performance economies by reading from this cache directly.

Which use cases make sense? If you want to give examples, that's fine but I know I am supposed to stick to one question at a time here, so if you are giving an example, please give it in the context of a use case.


texts: How can I generate terrain like SimCity 3000 does?

texts:
Are there any tips anywhere on generating terrain such as is used in SimCity 3000? I have used World Machine before, but I want something low-fidelity. I think there are only a few allowed vertical "steps" in SC3K, as well as a maximum slope. Thanks.

[edit]

Here are some screenshots.

Several more pics here.


texts:
How do I get basic collision, in Unity, for an imported sketchup model?

My friend and me are new to game development, and we have to submit the game within a week. Please help me.

I downloaded an airport model from 3D Warehouse, and we imported it in to Unity 5.1.2, but our character is going through all the objects in the airport. Please find us find a solution.


texts:
I don't think I fully understand how rendering shaders work. I get that you give a shader to an object/sprite when drawing it, and it applies the shader to it. But I don't think I'm doing it right.

For example, I wrote a shader for when the player is underwater. It makes the player sway side to side, but the problem is I'm not sure how to tell when I can use it. Do I loop through all the water blocks, and If the player intersects, run the shader on the player? This brings up the problem where all of the player would wave instead of just the part of him below the water.

I'm not sure what else I could do, and I apologize if this sounds confusing, I'm very confused myself and am not sure how to explain it. Do I run the shader on the water and somehow get it to run on all the pixels intersecting the water? What do I do? Also, just to make sure, I am using 2D.


texts:
I have a question, I need a formula to calculate the distance and a force based on the speed that drags the finger up on the phone. And is there any way I can get a look? And also shows the trajectory of the ball with lines ...

An example is the Pokemon Go, see the image (the user presses the ball and drags the finger upwards).

Are there any examples so that I can study?


texts:
What's the best method to save the player's data to the server?

Method to store the game saves
Which one of the following method should I use ?

Using a database structure(e.g.. mySQL) to store the game data as blobs?
Using the server hard disk to store the saved game data as binary data files?

Method to send saved game data to server
What method should I use ?

socketIO
web socket
a web-based scripting language to receive the game data as binary?
for example, a php script to handle binary data and save it to file

Meta-data
I read that some games store saved game meta-data in database structures.
What kind of meta data is useful to store?

Edit-1
This question was to actually see what technology is better to use based on the situation.
The situation is a game that will be on cross-platform, save game throughout the cloud.

Method of delivery from game client(iOS, Android, Windows Phone 8, etc..) to game server(Linux, Windows, etc.)
Im using a Ubuntu server at this moment.

Method of storage of binary data
Inside a database system or file system.
The up and down side to it and the community options of existing structures.

Storing of meta-data
Well, I'm not too sure about how to store saved game data to server at the moment.
Thus, was wondering if the community can provides tried and tested methods used by the community. and their preferences.


texts: XNA 2D - How can I draw a sprite over another?

texts:
I'm working on a simple 2D game that is similar to the classic Invader arcade. What I want to know is:

How can I draw a new sprite over the player sprite upon colliding with an enemy/a bullet?
Better yet, how can I hide the player so that the hit animation can be shown?

I got the collision detection up and running except for the hit animation. It's being drawn behind the player current position which is awkward.


texts:
i'm rendering an attack animation with the following code:

currentFrame = attackAnimation[3].getKeyFrame(stateTime, false); //3 : left, 2: right
batch.draw(currentFrame, getX(), getY());

This renders the CurrentFrame on the x and y position of the character. This works fine for the right animation as you can see here:

but when i apply the same code for left for example it doesn't draw the character on the correct place and like "pushes himself away" from the bottom left corner and leaving the bounding box.

What am I doing wrong or what am I not seeing?

setGameObject(new Sprite(txtIdle[2]));
setSize(getWidth(), getHeight());
setOrigin(getWidth() /2.0f, getHeight() /2.0f);
setPosition(500, 500);

this code sets an idle image and the size of the bounding box (and the sprite)


texts: MSAA/ CSAA / FXAA How to set the mode in OpenGL?

texts:
I'm learning OpenGL and something I am stuck with is AA. Specially when I want to turn it on and off at runtime. I know that I can set the samplecount when I create a FBO and blit it over to the final window. When I want to change the mode I switch the FBO and everything is fine. The question I am completely stuck with is, how do I change the mode and also important, how do I query the modes that the card supports. With mode I mean CSAA,MSAA,.. .I can't find a lot. At least I know that it is vendor specific.
Hope anyone can point me in the right direction. Thanks


texts:
I have a buffer I am rendering gl_FragDepth (remapped to range 0-1) to a color buffer (instead of color) in OpenGL

I would like to, in a second pass, read this depth and use the x and y coordinates of the current fragment to re-calculate the world coordinates.

I'm rendering my scene to an FBO, then I screenquad this FBO's contents to the screen and during that render i'd like to find the worldspace coordinates I rendered with initially.


texts: Sprite sheets with buffer objects and shaders

texts: What is the "best" way to handle sprite sheets with shaders and buffers? In immediate mode it is easy to modify a sprite's texcoords when it is drawn, but I don't know how to do this with modern opengl. Should I store all the texcoords in a buffer and change the pointer for every sprite, or is there a better way?


texts: 2D Point Light XNA , Why my point light radius is Oval?

texts:
I friend of mine , taught me how to make a simple 2d point light with shader, so i follow his steps and finally done it !

but something happend , the light shape is like an oval and not like a circle , my friends couldnt explain me why,

could you help me how to fix it, and explain me why it happend?

here is how it looks like http://dl.dropbox.com/u/2553973/screengrab/PointLight_07.png

ShaderCode

Texture InputTexture;

sampler InputTextureSampler = sampler_state {
    texture = <InputTexture>;
    magfilter = LINEAR;
    minfilter = LINEAR;
    mipfilter = LINEAR;
    AddressU = mirror;
    AddressV = mirror;
};

struct VertexShaderOutput
{
    float4 Position  : POSITION0;
    float2 TexCoord  : TEXCOORD0;
    float4 Color     : COLOR0;
};

float4      ambientColor = float4(1.0,1.0,1.0,0.0);
float       ambientIntensity = 0.3f;

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
    //float4 color = float4(1, 0, 0, 1);
    float4 texCol = tex2D(InputTextureSampler, input.TexCoord);

    float4 color = ambientIntensity*ambientColor;
    float dist;

    //Light 1
    float  lightRadius = 0.2f;
    float  lightIntensity = 15.0f;
    float4 lightPos = float4(0.3f,0.3f,0.0f,0);
    float4 lightColor =  float4(0, 0, 1, 1);

        dist = distance(lightPos, input.TexCoord);
    color += saturate((lightRadius-dist)*lightIntensity)*lightColor;

    texCol = saturate(color) *texCol;

    return texCol;
}

technique PointLight
{
    pass Pass1
    {
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}

XNA CODE

    GraphicsDevice.SetRenderTarget(normalRender);
    GraphicsDevice.Clear(Color.Black);
    spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, effectLight);
      spriteBatch.Draw(background, Vector2.Zero, Color.White);
    spriteBatch.End();

    normalRenderTexture = normalRender;

    GraphicsDevice.SetRenderTarget(null);
    GraphicsDevice.Clear(Color.Black);
    spriteBatch.Begin();
       spriteBatch.Draw(normalRenderTexture, Vector2.Zero, Color.White);
    spriteBatch.End();


texts: How to implement mutable functionality at runtime?

texts:
I am making a game in which the player character can gain traits that change how their character behaves in my world model or add functionality to it. For example, the character might gain the "feather" trait that changes how fall damage is calculated or the "strong" trait that means the player can now pick up items that were previously just part of the scenery.

I have been hard coding traits in their relevant classes and switching a boolean to change behavior when they come into play, but it is getting rather unmanageable as my trait list grows.(I am also missing out on a lot of the emergence I was hoping to get) There must be a more scalable and decoupled way of doing this.

How would you code such a feature where code behavior changes or expands at runtime? If you are not inclined to do my work for me, which programming patterns would you use to achieve this kind of behavior?


texts: How to map changing stances (southpaw/orthodox) to gamepad controls?

texts:
I am developing a third person hack n slash style game which features a variety of melee and projectile weapons as well as unarmed combat. The player will be able to dual wield any combination of the above weapons eg. a sword and a pistol, or a knife and a bare fist. I'm trying to work out the gamepad controls based on the game mechanics, but I've come to a dilemma regarding the movesets.

Originally I had the left and right triggers mapped as the left and right hand attacks. However, some of the attack moves that I have planned involve the player taking a step forward. Meaning they may have started in orthodox stance (left foot forward) but will end up in southpaw (right foot forward). For some weapons like firearms the stance makes no difference, since the attacks will be the same from either. But for some melee weapons and especially for unarmed combat this is a significant difference. For example, from orthodox stance the left trigger should logically do a jab attack from the front hand, while the right trigger should do a straight punch attack from the back hand. If the player now does a lunging attack in which they take a step forward, they end up with their other foot infront, meaning that now the left trigger cannot do a jab but must perform a straight punch since the left hand is no longer in front.

So the question is how to resolve this without having a controls system that confuses the player. There are a few options I have considered after studying other games, but I am looking to see if a better alternatives exists.

1) Seen in Elder Scrolls, Dark Souls, Tekken:

Use 2 attack buttons but have the player always stay in a single stance. This way they the left and right limbs will always perform the same move. The downside of this is that attacks which would normally leave the player in another stance have to either be avoided or the animation has to include the player returning to their original stance. While this solves the problem it can look unrealistic.

2) Seen in DOA, VF:

Use only 1 attack button, instead of one for each limb. This will mean that the stance of the player is irrelevant since a single button will play the correct attack animation of either the left limb or right limb depending on the stance. While this is more realistic it makes it difficult to have dual wielding weapons with only one button controlling both. For example, consider if a pistol and sword are being dual wielded, the left trigger may swing the sword while the right trigger may fire the pistol; but if both weapons are mapped to only the right trigger what attack should happen? The sword, the pistol, both? Here lies the problem.

3) Seen in MK:

Use 2 attack buttons which refer to the front or back limb, not the left or right limb. This method allows for the player to switch stances, since for example the left trigger may refer to the front hand irrespective of which stance the player is in. In a side scrolling game this may not be a problem, but in a third person game where the camera is behind the player, I am concerned that this type of controls will be confusing. Especially since the convention (correct me if I'm wrong) for dual wielding seems to be that the left and right triggers control the left and right weapons/limbs.

So are these the only options, or is there a better way of mapping the controls for this use case?


texts: Unity3D Raycasting in Start behaves uncorrectly, but works correctly in Update?

texts:
I have this method, which just raycasts at a position downwards, and checks what tile is there, if there is one:

    public static Tile RaycastTile(Vector3 position)
    {
        Debug.Log("raycastTile at pos: " + position);
        var layerMask = 1 << LayerMask.NameToLayer("Floor");
        RaycastHit hit;
        Debug.DrawRay(position, new Vector3(0, -10, 0), Color.red, 50);
        if (Physics.Raycast(position, new Vector3(0, -1, 0), out hit, 10, layerMask))
        {
            var tile = hit.collider.gameObject.transform;
            Debug.LogWarning(tile.name + " - " + tile.parent.name + " - at pos: " + tile.position);
            var coordinates = new Vector2Int(Mathf.RoundToInt(tile.position.x) / 2, Mathf.RoundToInt(tile.position.z) / 2);
            return map.GetTile(coordinates);
        }
        else
        {
            Debug.LogError("Tile not found under position: " + position);
            Debug.Break();
            return null;
        }
    }

Currently it is called for the player

at Start() ("starting at: < player's absolute position >")
and at Update() ("update at pos: < player's absolute position >")
And the map is being generated (tiles created, destroyed, etc) in Awake().

and for some reason this is the output:

And the map generation works like this:

Creates a room at (0, 0) with tiles and all, then it searches for a connection point on the existing map, whom the new room could be connected to. (with some rotation, if it's needed)
(Every tile is 2x2 meters, and they are on a strict grid)

So for some reason calling this method at Start() (with the same position) hits a totally different tile. While in Update() it works correctly.

At first I thought that it's because of Destroy(), because the objects are only destroyed at the end of the frame. But I tried DestroyImmediate() and it didn't help. (And after thinking, I realised that destroying objects at the end of the frame wouldn't cause issues. Or is it?)

Then I had the idea, that maybe Start doesn't wait for Awake because it compute heavy. And the raycast in the Start hits a (yet) non translated newly generated room. So I edited the code so every room is initially created at very far away, which is relatively "infinite far away" from the player: at (9999, 9999). But the issue remained.

EDIT: With (9999, 9999) Sometimes (maybe half of the time?) now it is correctly raycasted even at start, while before it was never correct in start.

EDIT2: With (0, 0) it hits correctly at start as well, but very very rarely.

Do you have any idea what could cause this issue?

Sorry if there isn't enough info, feel free to ask. :)


texts: Why released games usually contain their scripts sources?

texts:
AFAIK people like scripting because it's easier, and it makes development cycle faster. But what about when games are shipped. No one expects shipped binaries to be changed, unless there is an update or a DLC. So why developers don't compile their script files before shipping?

Potential benefits:

Faster run time
Obfuscating binary a little mode

and I can't think of any possible draw backs.

Examples:

Civilization 5 had lots of lua scripts inside their assets folder.
Angry birds also had a lot those scripts along side binary.
Age of Mythology had lots of xs scripts for their AI.
Civilization 4 had lots of python scripts.

I'm pretty sure the list could have gotten a lot longer if I had more games installed on my device.


texts: How do I find the closest points(thereby forming a polygon) enclosing a particular point?(see image)

texts:
I am working with a game engine, and my task is to add code for simulating fracture of rigid meshes.

Right now I'm only working on breaking a cube.

I am using Voronoi's algorithm to make a (realistic)fractured shard and I am using the half-plane method to generate a Voronoi cell.

Now the way I do this is for every seed point, I make planes that are perpendicular bisector planes(the straight black lines in the image) with rest of the seed points and I calculate the intersections of all these planes to give me distinct points(all the orange dots).

I've gotten this far.

Out of all these calculated intersection points, I only need the ones that are closest and enclosing the seed point(the points encircled in red) and I need to discard all the rest.

Information that I have :

1) Plane equations of all planes(defined by normalized normal vectors and their distance from origin)

2) Points of intersection(that I've calculated)

Can anybody help me find out how I can find the points encircled in red?


texts: Is there a library that handles hexagon tiled 2D maps?

texts:
It would represent a map that is semi-square of arbitrary size. It would have a simple system for representation of the map coordinates, such as 0101 (first column, 1st hex). I'd want the map to be able to tell me the distance between two points and what other hexes lay between those two points, as a list or array.

I don't care as much about the language, but C# or Python would be ideal.

Does one exist?


texts: Physically based shading - ambient/indirect lighting

texts:
I implemented a physically based path tracer after studying PBRT by M. Pharr and G. Humphreys. Now I'm trying to apply physically based rendering to real time graphics using OpenGL.

I want to start using Oren-Nayar and Cook-Torrance as diffuse and specular BRDF but I have a problem: how do I model indirect lighting?

In a path tracer (like the one contained in PBRT) the indirect/ambient light is given "automatically" from the path tracing algorithm, as it follows the path of light rays taking into account direct and indirect lighting.

How do I model the indirect lighting in a physically based render written in OpenGL, so using real time computer graphics?


texts: When is messaging/observing preferable to 'built-in' functionality in game objects?

texts:
In working on a Python/Pygame project I recently came to an impasse which couldn't be solved elegantly via my previous methodology - using wrapping functions as an Observer pattern - and it was impressed on me to look at some kind of event system instead.

As an example:

class Player(sprite):
    ...
    @property
    def lives(self):
        return self._lives
    @score.setter
    def lives(self, new):
        old = self._lives
        self._lives = new
        self.fire_event(LifeChanged(self, old, new))
    ...
mainchar = Player()
scoreboard = Scoreboard()
scoreboard.listen_for(LifeChanged, scoreboard.on_life_changed)

So this was literally the only thing in-game that I felt I 'needed' to handle in this way, and while I prefer it to calling scoreboard.text = mainchar.lives in every loop, it gives me a bit of pause because at present it is pretty much the only thing I'm using events to manage.

I realize that a lot of this stuff is by-preference, and I'm not looking to refactor my entire game here or get a breakdown of why MVC/Entity Systems/whatever is preferable, but it did raise a question for me regarding the practice of objects that create objects. The simplest example being something like a character which fires projectiles:

def fire(self, shot_direction):
    newshot = Bullet(self.rect.center[0], self.rect.center[1], shot_direction)
    newshot.add(self.groups())

Again, it may just be an implementation detail, but it does start to "feel like" a better way is to send a message to a Bullet factory instead of letting the object doing the firing instantiate the Bullet and add it to Sprite.group instances that it happens to belong to. After all - why does my Player object need to 'know' anything about the groups it belongs to, or have the responsibility to add things to a game object that is more or less not part of the game action?

I could be overthinking all the things -- I do that. :/ But I'm genuinely curious as to whether or not there is a fundamental consensus on 'best practice' (regardless of design patterns) that dictates whether or not game objects should be doing the creating of game objects directly, or whether there should instead be a factory sitting in the background somewhere that churns out all instances of new bad guys, projectiles, powerups, and so on.


texts:
I'm trying to create a visual effect where an arbitrary part of the main scene is either clipped out by or cropped to an arbitrary volume.  That is to say, I might want to draw just the area of the scene inside the volume, enhanced by other elements, or only the area outside the volume, leaving empty an area I can fill in later.

The main scene is mostly a 10k-500k face surface (not solid).  The clipping volume is an extruded polygon, usually 200-300 faces for the entire volume, not generally convex but easy to convexify if needed.

I've tried an approach basically identical to stencil shadow volumes, but where instead of drawing a lighter/darker version of the same scene, I just don't draw the pixels either in or out of the stencil area.  This is about 85% of the way to the solution, except that (for the clip mode), pixels from the scene inside the clip volume that would normally occlude other parts of the model, but should be ignored, are left in the stencil.

The problem also seems eerily similar to constructive solid geometry.  I would rather not solve it by manipulating the geometry itself, as manipulating 500k+ faces in-browser has not shown itself to be terribly performant (yes, I tried).  There's a little bit of work on doing arbitrary CSG via stencils (like this) but it doesn't seem to have gotten much attention in the last decade.

In my ideal case, I'd be able to use some set of techniques to individually identify regions of the viewport that contain:

Pixels outside the clip volume, even if they would normally be occluded by pixels inside the clip volume
Pixels that the mesh inside the clip volume would occupy, even if normally occluded by other pixels outside the clip volume

My target is WebGL, but happy to look at plain OpenGL techniques that may be applicable, or those enabled by WebGL2.


texts:
At least I think it is. I have the following functions:

kmQuaternionRotationAxis - Constructs a Quaternion from an axis and angle
kmMat4RotationQuaternion - Constructs a 4x4 matrix from a quaternion
kmMat4RotationAxisAngle - Constructs a 4x4 matrix from an axis and angle

My problem is, when I run the following code:

kmQuaternion q;
kmMat4 initialized;
kmMat4 quaternion_rotated;

kmQuaternionRotationAxis(&q, &KM_VEC3_POS_Z, kmDegreesToRadians(90));
kmMat4RotationAxisAngle(&initialized, &KM_VEC3_POS_Z, kmDegreesToRadians(90));

kmMat4RotationQuaternion(&quaternion_rotated, &q);

I would expect *quaternion_rotated* to match initialized, but they don't.

Initialized:

 | 0 -1  0  0 |
 | 1  0  0  0 |
 | 0  0  1  0 |
 | 0  0  0  1 |

quaternion_rotated:

 | 0  1  0  0 |
 | -1 0  0  0 |
 | 0  0  1  0 |
 | 0  0  0  1 |

The contents of initialized looks like I would expect, but I can't figure out how quaternion_rotated is wrong. I've included all the code below, where is my conversion code wrong?

kmQuaternion* kmQuaternionRotationAxis(kmQuaternion* pOut, const kmVec3* pV, kmScalar angle)
{
    kmScalar rad = angle * 0.5f;
    kmScalar scale  = sinf(rad);

    pOut->w = cosf(rad);
    pOut->x = pV->x * scale;
    pOut->y = pV->y * scale;
    pOut->z = pV->z * scale;

    kmQuaternionNormalize(pOut, pOut);

    return pOut;
}

kmMat4* kmMat4RotationAxisAngle(kmMat4* pOut, const kmVec3* axis, kmScalar radians)
{
    kmScalar rcos = cosf(radians);
    kmScalar rsin = sinf(radians);

    kmVec3 normalizedAxis;
    kmVec3Normalize(&normalizedAxis, axis);

    pOut->mat[0] = rcos + normalizedAxis.x * normalizedAxis.x * (1 - rcos);
    pOut->mat[1] = normalizedAxis.z * rsin + normalizedAxis.y * normalizedAxis.x * (1 - rcos);
    pOut->mat[2] = -normalizedAxis.y * rsin + normalizedAxis.z * normalizedAxis.x * (1 - rcos);
    pOut->mat[3] = 0.0f;

    pOut->mat[4] = -normalizedAxis.z * rsin + normalizedAxis.x * normalizedAxis.y * (1 - rcos);
    pOut->mat[5] = rcos + normalizedAxis.y * normalizedAxis.y * (1 - rcos);
    pOut->mat[6] = normalizedAxis.x * rsin + normalizedAxis.z * normalizedAxis.y * (1 - rcos);
    pOut->mat[7] = 0.0f;

    pOut->mat[8] = normalizedAxis.y * rsin + normalizedAxis.x * normalizedAxis.z * (1 - rcos);
    pOut->mat[9] = -normalizedAxis.x * rsin + normalizedAxis.y * normalizedAxis.z * (1 - rcos);
    pOut->mat[10] = rcos + normalizedAxis.z * normalizedAxis.z * (1 - rcos);
    pOut->mat[11] = 0.0f;

    pOut->mat[12] = 0.0f;
    pOut->mat[13] = 0.0f;
    pOut->mat[14] = 0.0f;
    pOut->mat[15] = 1.0f;

    return pOut;
}

kmMat4* kmMat4RotationQuaternion(kmMat4* pOut, const kmQuaternion* pQ)
{
    double xx = pQ->x * pQ->x;
    double xy = pQ->x * pQ->y;
    double xz = pQ->x * pQ->z;
    double xw = pQ->x * pQ->w;

    double yy = pQ->y * pQ->y;
    double yz = pQ->y * pQ->z;
    double yw = pQ->y * pQ->w;

    double zz = pQ->z * pQ->z;
    double zw = pQ->z * pQ->w;

    pOut->mat[0] = 1 - 2 * (yy + zz);
    pOut->mat[1] = 2 * (xy - zw);
    pOut->mat[2] = 2 * (xz + yw);
    pOut->mat[3] = 0;

    pOut->mat[4] = 2 * (xy + zw);
    pOut->mat[5] = 1 - 2 * (xx + zz);
    pOut->mat[6] = 2 * (yz - xw);
    pOut->mat[7] = 0.0;

    pOut->mat[8] = 2 * (xz - yw);
    pOut->mat[9] = 2 * (yz + xw);
    pOut->mat[10] = 1 - 2 * (xx + yy);
    pOut->mat[11] = 0.0;

    pOut->mat[12] = 0.0;
    pOut->mat[13] = 0.0;
    pOut->mat[14] = 0.0;
    pOut->mat[15] = 1.0;

    return pOut;
}


texts: Save and retrieve image from database in unity

texts:
I have done a sample to insert and retrieve data from MySQL in unity.Now I need to insert and retrieve image from MYSQL in unity. The images are files selected by the user from their filesystem.

Can anybody please help me?

Below is the sample code for inserting data

<?php

  $database = mysql_connect('localhost', 'root', 'amma') or die('Failed to connect: ' . mysql_error());
    mysql_select_db('igrms_db') or die('Failed to access database');
    $query="INSERT INTO igrmsdata(id,name,description) VALUES('$id','$name','$description');";
    //$query="INSERT INTO igrmsdata(id,name,description) VALUES('100','Tippu','Welcome to Tippu');";
    $result=mysql_query($query);
    echo "DataEntered";

 ?>

Unity code for inserting data

string IGRMSDataEntryCode="http://192.168.173.243/IGRMSDataEntry.php";
public InputField artifactidField;
public InputField artifactnameField;
public InputField artifactdescriptionField;
public Text messagebox;
public static string artifactid="";
public static string artifactname="";
public static string artifactdescription="";

void Start () {

}

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

}
public void IGRMSDataEntryDetailsDB()
{
    artifactid=artifactidField.text;
    artifactname=artifactnameField.text;
    artifactdescription=artifactdescriptionField.text;
    if(artifactidField.text=="" || artifactnameField.text=="" || artifactdescriptionField.text=="")
    {
        messagebox.text="All fields are mandatory";
    }
    else {
        StartCoroutine(AddArtifacts(artifactid,artifactname,artifactdescription));
    }

}

public void IGRMSDataReset()
{

    artifactidField.text="";
    artifactnameField.text="";
    artifactdescriptionField.text="";
    messagebox.text="";
}

IEnumerator  AddArtifacts(string id,string name,string description)
{

    //string register_url = getscoreCode + "?name=" + user + "&score=" + scor;
    string register_url = IGRMSDataEntryCode + "?id=" + id + "&name=" + WWW.EscapeURL(name) + "&description=" + WWW.EscapeURL(description);

    WWW entereddata = new WWW (register_url);
    yield return entereddata;
    messagebox.text="Data Uploaded Successfully";
    artifactidField.text="";
    artifactnameField.text="";
    artifactdescriptionField.text="";
}


texts: How do I make a daily challenge on a game with randomly generated levels?

texts:
I am currently making a game with randomly made levels, but I have an interest in making everyone play the same level in a daily challenge section, like Spelunky.

At first I thought about letting the clients decide the seed based on their date, but dates can be locally spoofed.

I have access to a parse.com free account, so I can execute code in the cloud and expect results back. So then I considered asking cloud code for a hash based on the current date, but this could be spoofed to play a different level while sending the server the score for THAT level instead of the daily one.

Then I thought of encrypting the date in the server and decrypting it on the client, but then this might be problematic if I used symmetrical encryption. So... maybe use assymetrical encryption?

Am I missing a simpler solution here? This feels like I'm overcomplicating myself, but I'm not sure. Is there a generally accepted solution for this kind of problem? I haven't found anything after googling for a good while.


texts: My pixel art looks weird in the game view in Unity

texts:
I am making my first 2D game in Unity and something has been bothering me. If I'm in the scene view, my game looks fine but when I go to the game view the pixels in the sprites aren't rendered correctly and everything looks distorted.

Does anyone know an answer to this?


texts: Creating new static sprites for Warhammer 40K Armageddon Pc Game

texts:
I want to create new unit sprites for the Warhammer 40K Armageddon pc game.

Game uses simple 3D static PNG sprites facing 6 different direction for all units. They don't animate in game, just pictures (as shown in link).

If I simply copy already-made sprites and just rename them with my own liking, I can integrate to game easily (with adding strings, sound and animation files etc.). But I want to create my own unique sprites. I know this can be done because other people already did this (I of course tried to contact them through game forums and steam at first but couldn't succeeded, so I wanted to ask here).

How can I make these sprites?

P.S. I don't have any kind of modelling experience, but I'm a coder.

Some of already-made sprites: http://imgur.com/a/b3M0q


texts: I've been developing a game targeted at android. I know not to think about program optimization until the project is finished, but I have to wonder how many textures most phones can handle safely without melting or murdering battery. I've seen that the max SIZE of a texture should be 1024 or 2048 pixels squared (I've been combining sprite-sheets into 1024x1024 atlas's) but I can't help but wonder if there is a limit to how many of these I can use at runtime. I understand it should depend on the GPU but what spec determines it?


texts: Unity: Exporting Game creates Texture Glitches

texts:
In the editor the textures are fine, however upon exporting I'm constantly faced with glitches like these:

I mainly use the Built-in Standard Specular Shader and the texture that gets glitched is always the Detail Texture. When re-exporting the game multiple times the texture gets glitched exactly the same way in the same spots.

Meshes are always below 65536 polygons. In game size is usually around 2x2 kilometres. The smallest Terrainmesh is 500x300metres and the origins are usually close to the terrain, always at 0,0,0. Scale and Rotation are always reset.

This has happened in pretty much every scene so far.

Screenshot of UV coordinates:


texts: What do I need to change in Box2D to work in pixels?

texts: Box2D seems to be set up in such a way that you cannot work in pixels (i.e. physics scale = 1). It produces very strange results as it hits maximum speed limits at low speeds and looks very strange. It only seems to work well at a physics scale of around 15 or 30. For me, working in pixels is the logical way to handle physics and movement in a game, as you are already using that measurement for lots of other things. I don't want to have postionX/30 all over my code, so what variables do I need to hack in the box2d source in order to make physics scale 1 work as if it was physics scale 30? I'm using the latest version from box2dflash.org.


texts: Licensing for assets in a game but it is free for commercial use

texts:
In my game, there is this music that I use and of course before releasing anything for commercial use, I have to have a license for what I dont create for my game for example ( game engine, music, fonts and etc ) some of them are free to use even for commercial purposes.

My question is do I need license for it even though it is free for commercial use? and if there is no license for it at all, what should I do to avoid copyrights and legal issues?


texts:
I've been trying to make use of the GPU as part of a project of mine. I've looked into both CUDA and OpenCL, but the lack of information showing you how to introduce these into a project is shocking. Even their dedicated forum groups are dead. So now, I'm looking into DirectCompute.

From what I can tell, it's simply a new type of shader file that makes use of HLSL. My question is this, does my program (aside from being DirectX 10 / 11 ) need its structure changed?

I mean, is it simply a case of creating the CS file, setting in the project like I would any other shader, and watch the magic happen?

Any information on this would be appreciated.


texts: Multiplayer tile based movement collisions cause client prediction to fail

texts:
I am developing a tile-based online multiplayer game, but I am stuck. Players can move across the grid in the four cardinal directions, as can enemies, but two players/enemies cannot occupy the same tile at the same time. Positions of all players/enemies are synced for all clients.

My current implementation of movement: Clients send a 'request to move' to the server whenever they are stationary on a tile.

I have implemented client prediction. When a button is pressed to move, the client shows their character immediately moving in that direction, as opposed to waiting for confirmation from the server, preventing lag between player input and visible results.

The issue arises when the player attempts to move to a position that will soon be occupied. For example, the player presses up when an enemy is very close to entering the tile above the player (though they can't currently know that the enemy will choose that tile next). Locally this is confirmed and the upwards animation begins, but by the time the request to move up arrives at the server, the tile is no longer free, and the player is not moved up on the server.

This creates a situation where the player's local position is out of sync with that of the server. My current solution to this is snapping the local player back to the server's position when this happens, but this looks awful. It seems to be happening a lot, making the game nearly unplayable.

Is there a way around this?
Any help would be very much appreciated, thanks.

Some other notes: I send updates from the server 10 times a second, which consist of every object's position (and other stuff). When a movement event is processed, the object's position is updated immediately, even though an animation follows.


texts: Turning a board game idea into a browser based, slow paced gameplay

texts:
Suppose I want to create a strategy game with global mutable state shared between all players (think game board). But unlike a board game, I don't want it to be real time action and/or turn-based. Instead, players should be able to log in at any time of the day and spend a fixed number of action points per day as they wish. As opposed to a few hours, game sessions would run over a few weeks.

This is meant to reward good strategy rather than time spent playing (as an alternative, hardcore players could always play multiple games in parallel instead) as well as all kind of issues related to live playing like disconnections and synchronization. The game should remain addictive still have a low time investment footprint for casual players.

So far so good, but this still leaves open the question of when to solve actions and when they should be visible. I want to avoid "ninja play" like doing all your moves just a few minutes before daily point reset to take other players by surprise, or people spamming F5 to place a well-timed action which would defeat the whole point of a non real-time game.

I thought of a couple of approaches to that :

Resolve all events in a single scheduled process running once a day. This basically means a "blind" gameplay where players can take actions but don't see their results immediately. The thing is, I played a similar browser game a few years ago and didn't like the fact that you feel disconnected and powerless until there's that deus ex machina telling you what really happened during all that time. You see the world evolve in large increments of one day, which often doesn't seem like seeing it evolve at all.
For actions that have an big impact on the game or on other players (attacks, big achievements), make them visible to everyone immediately but delay their effect by something like 24 hours. Opposing players could be notified when such an event happens, so that they can react to it.

Do you have any other ideas how I could go about solving this ? Are there any known approaches in similar existing games ?


texts: Cheap way to soften contactpoint of character with ground

texts:
The view of my game is always semi topdown. I'm trying to make the contactpoint between characters and the floorplane more grounded without rendering hundreds of sprites.

One thing that I think could work well is to just hide some pixels of every object that is i.e. 2 cms above the floor.

See GIF below of an example I did in Photoshop:

Things that I'm thinking about:

check the z depth before rendering - if it's very close, then randomly don't render the pixel
randomly writing "wrong" depth buffer values for the ground plane
a small layer 2cm over the groundplane that writes z values only - draw this before the character

As I'm still in the research phase, I'd like to also explore other possibilities.

Is there already a well established way to do this?


texts: JiglibX addition to existing project questions

texts:
Got a very simple existing project, that basically contains a lot of cubes. Now I am wanting to add a physics system to it and JiglibX seemed like the simplest one with some tutorials out there.

My main problem is that the physics don't seem to be working how I imagined, I expected my tower of cubes to come crashing down, but they dont seem to do anything.

I think my problem is that my cubes do not inherit DrawableGameComponent, they are managed by a world object that will update and render them. So they are at no point put into the games component list. I am not sure if this means that JiglibX will not be able to interact with them as in all the tutorials there are no explicit calls to add the Body objects to the physics system, so I can only presume that they are using a static/singleton under the hood which automatically hooks in all things, or they use the game objects component list somehow.

I also noticed that in alot of the tutorials they use the following when setting up the physics system:

float timeStep = (float)gameTime.ElapsedGameTime.Ticks / TimeSpan.TicksPerSecond;
PhysicsSystem.CurrentPhysicsSystem.Integrate(timeStep);

Would it not be better to keep a local instance of the created PhysicsSystem object and just call myPhysicsSystem.Integrate(timeStep)?


texts:
I've started to study game design and I couldn't really find an answer for this one. Let's imagine a small level with a nice (non passable) background in the distance. The background has mountains, hills, town and a forest. The background, should it be a part of the skybox? or 2D sprites? or low poly models? What's the best approach?

(...and sorry for the bad english, long day and I'm really tired...)


texts:
I'm evaluating solutions for creating a VR videogame that should run on cellphones. The assets will be streamed from our servers and that could be a problem on limited capabilities devices.

Since the geometries are not going to be too complex (mostly boxes and wardrobes) I was thinking about procedurally generating them.

Is generating geometries procedurally usually faster or slower than just streaming a bunch of vertex data?


texts:
I have recently added some Sound Effects to my game, but the problem that I am dealing with now, is that they have for a half of second delay, or more sometimes.

Also, if I press repeatedly on that button, the sound effect does not play each time that I press on the button, and when I finish pressing, it plays at least once (I think from the previous presses).

How can I fix this problem?
Here is my Play function, if it will help with something ...

public void Play(SFX effect)
    {
        if(!Muted)
        {
            switch(effect)
            {
                case SFX.ButtonTap:
                    tapSfx_Instance.Play();
                    break;
                case SFX.Hit:
                    hitSfx_Instance.Play();
                    break;
                case SFX.Die:
                    dieSfx_Instance.Play();
                    break;
            }
        }
    }

Thanks.


texts:
I just want to ask a general question. According to that answer, I'll continue thinking.

You know in games there are lots of clickable items. Play button, exit, combo-boxes, etc.

My question is: Are those buttons drawn in same canvas with background and all other things, or for every different thing there is another canvas object?

My question is a general sense. I'm not asking about a specific game, I'm asking how they are made generally.

I'm planning to start a game on Android, and I'm confused actually how to design buttons, and other object. Probably I'm going to use View/SurfaceView for now. I don't have much experience with OpenGL yet.

Thanks in advance.


texts: Detect obstacles in path on a tile-based map

texts:
I'm creating a 2d game with a tile-based map, but smooth movement. I currently use A* in combination with some other tricks for pathfinding, and one issue what I've been dealing with is getting the units to move smoothly despite tile-based pathfinding.

My solution at the moment is the use raycasting to determine if there is an obstacle between a unit and its target. If there is, it uses A*. Otherwise, it just sets its next move directly as the coordinates of its target. In the case that it uses A*, I also use raycasting to determine which point in the path the unit should move to next, by finding the nearest point in the path that is not obstructed from the units current location, and setting that as the next move. This is necessary so the unit doesn't have to move in a jerky fashion based on the tile-based path that the A* found.

Raycasting is faster than A* every time, but it still has some overhead with a large number of units since it checks every point on the line in small increments. (More so since I'm doing double raycasting each time to account for the size bounds of the unit)

My question is: Is there a better algorithm than raycasting to determine if there is an obstacle between two points (independent of the tiles structure) on a tile-based map? My thought is that there is some way to take advantage of the tiled nature of the map.


texts:
I want to rotate my model and I have X and Y rotations. Here is my code:

D3DXQUATERNION q, qrotation;

D3DXQuaternionRotationAxis(&q, &D3DXVECTOR3(1.0f, 0.0f, 0.0f), m_matrixRotX*0.0174532925f);
qrotation = q;

D3DXQuaternionRotationAxis(&q, &D3DXVECTOR3(0.0f, 1.0f, 0.0f), m_matrixRotY*0.0174532925f);
qrotation *= q;

D3DXMatrixRotationQuaternion(&worldMatrix, &qrotation);

But I get the same gimbal lock. What is the problem?

EDIT 1: OK, but how can I rotate my object if I have X Y and Z rotations?

EDIT 2: Here is all my code:

m_matrixRotY += (float)m_mouseStateX;
m_matrixRotX += (float)m_mouseStateY;
if (m_matrixRotY >= 360.0f)m_matrixRotY = 0.0f;
if (m_matrixRotX >= 360.0f)m_matrixRotX = 0.0f;

D3DXQuaternionRotationYawPitchRoll(&qrotation, m_matrixRotY*0.0174532925f, m_matrixRotX*0.0174532925f, 0.0f);

D3DXMatrixRotationQuaternion(&worldMatrix, &qrotation);

I want to rotate my object in world static XYZ axis (world orientation not
 local orientation).
Each frame I get mouse x y states and add them to total rotation. Is it wrong that I am counting total rotation and then creating the quaternion from it?

NOTE: m_mouseStateX = current_mouse_state - previous_mouse_state


texts:
(I've gone through tons of articles on this, but not found a working solution I can run in Unity 5.5.2+)

I'm looking for C# code I can run that will allow me to mute and unmute the default microphone.  This ONLY needs to run on Windows 10.


texts: Unity: Built-In Shader Transformation Explanation Resource

texts:
I'm working on some of my first shaders and taking a look at the variables included by cginc I see this  list of transformation matrices:

I've watched some beginner talks and I understand what the first one does but pretty much every other one I'm not sure what it does or how to apply it. Does anyone know of a good resource for explaining these transformations?


texts: Collision detection between image and drawables

texts:
I'm trying to collide my ball_1 to greengreen drawable. How can I determine the collision?

public  class MainActivity extends Activity  implements Runnable{

    private Imageview ball1

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ball1 = (ImageView) findViewById(R.id.ball_1);
        Drawable gr1 = new Drawable(R.drawable.greengreen)

        public void run() {
            startballanimation();
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }//trying to use an if else statement here to collide imageview ball1 to drawable"greengreen"
        }
    }
}


texts: Why is my application getting more CPU usage while it's halting the operation

texts:
I have a question about the way OS gives CPU time to the applications. Usually when I render my scene with a single object in it I get ~8% CPU usage, but when I stop the framework for further process while my window has lost focus I see that my application has a ~50% CPU usage. Now, I'm a little bit confused about this behavior because supposedly I should get no CPU time at all.

The pseudo code is something like this:

while(open)
{
  // Window
  window->update();

  // Freeze when we have no focus
  if (freeze) continue;

  // Physics, Input, Render ...
  do_the_stuff();
}

The situation that I'm talking about is when I set freeze to true and just process the window messages. It means there is only one job to do per frame.


texts: Can sampling an input texture in shader return values updated in same pass?

texts:
In my hlsl, (I am using Direct2D helpers which I guess just call tex2D), can D2DSampleInputAtOffset() return a pixel value that was only updated in that same pass of the shader? Or will it always return the value the sample had before the shader has processed any pixel? e.g.:

#define D2D_INPUT_COUNT 1
#define D2D_INPUT0_COMPLEX
#include "d2d1effecthelpers.hlsli"

D2D_PS_ENTRY(main)
{
    float4 color = D2DGetInput(0);

    float4 above = D2DSampleInputAtOffset(0, float2(0, -1));
    // will above be the value in the sample before drawing with this shader?
}

Further is there a specific sequence in which pixels are processed by my shader, e.g. left to right, top to bottom?


texts: The Command pattern and multiple inputs per frame?

texts:
I'm reading Game Programming Patterns by Robert Nystrom. As a test I've implemented the command pattern, but a little farther in he changes it to return commands, rather than instantly executing them.
An example of the first command pattern:
void InputHandler::handleInput()
{
    if (isPressed(BUTTON_X)) buttonX_->execute();
    else if (isPressed(BUTTON_Y)) buttonY_->execute();
    else if (isPressed(BUTTON_A)) buttonA_->execute();
    else if (isPressed(BUTTON_B)) buttonB_->execute();
}

Changing it to return commands:
Command* InputHandler::handleInput()
{
  if (isPressed(BUTTON_X)) return buttonX_;
  if (isPressed(BUTTON_Y)) return buttonY_;
  if (isPressed(BUTTON_A)) return buttonA_;
  if (isPressed(BUTTON_B)) return buttonB_;

  // Nothing pressed, so do nothing.
  return NULL;
}

// Executed in game loop:
Command* command = inputHandler.handleInput();
if (command)
{
  command->execute(actor);
}

My question is, how would I go about processing multiple user inputs each time input is handled? In my sample implementation, I check with an if on each button, instead of how he does it using an else if. I can see the benefits of returning the command (execute the command on any game actor you send to it), but it appears to be limited to one command process per loop.


texts:
I'm currently working for pathfinding for a game where units are moving, but they have inertia.  Most typical pathfinding algorithms (A*, Djikastra, etc.) are simply designed to minimize the length of the path.

However, these techniques do not apply, as far as I know, to instances where the unit has inertia.  If the unit has inertia, then there is a significant difference in the cost to leave a tile in a particular direction based on the direction you want to go.

For example, the cost of leaving a tile proceeding North is significantly higher if you entered the tile from the East than if you entered from the South.  (In the former example, you would have to slow down to halt you East-West velocity, while in the latter, you could go straight through.)

The fact that the system has inertia means that in order to make a turn, you may have to slow down well in advance of making the turn.  My best thought to date is that you calculate the additional time it would take to slow down, and then add it to the heuristic cost of moving.  However, this would seem to imply that you could never add a tile to the closed list, as entering from another direction could fundamentally change the cost of moving.

In addition, the concept of using a grid is an abstraction anyway, because both position and velocity are floating-point concepts.  Is there some algorithm that could handle pathfinding on an open plane with inertia better than A*, or what modifications could I make to a pre-existing algorithm to make it suitable to this kind of motion?


texts: How do I access objects that are in the next scene I'm loading?

texts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class HouseExit : MonoBehaviour
{
    public Transform player;

    public void Houseexit()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
    }

    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.CompareTag("Player"))
        {
            Houseexit();
            GameObject.Find("Wizard").transform.position = GameObject.Find("SpawnPos").transform.position;
        }
    }
}

This code belongs to the scene "Goblin House 1" and I'm trying to find the wizard and the spawn position both from level 1.


texts: Which one have to use Canvas or Open GL for 2D game in Android

texts:
I am compleatly new to android gaming.I want to develop a 2D game with some physics in it.I want to know which one i have to use Open GL or Canvas and the reason for selection I want to include a physics engine i dont know anything about that too It will be very help full if anyone can share any idea's and suggections.
Advanced thanks to all ...


texts:
Can I create relative filepaths to images in an XCode SDL project?

I have to use absolute filepaths as it is, but it would be much easier if I could make the filepaths relative.


texts:
I'm implementing gravity over a 3D terrain and I'm struggling with how to check if surface "under your feet" is flat or sloping.

I read some tutorials but gravity is always considered along a single axis.

How do I proceed?


texts:
I am new into this field of testing. I just developed a basic game using unity engine but i want to test it.

I have checked with selenium but i don't know how to get the value that is being returned which has the information of the action that is being performed in the game. If i am able to get the value then i will be able to take necessary action accordingly.


texts:
I want to load an object created with Maya in c++ with opengl, how could I do this?

Thank you.


texts: Why does my Unity animator state "finish" before the visible motion does?

texts:
Example:

The TopAppearing motion -  boost the alpha of the sprite from 0 to 1 for total of 2 seconds:

After TopAppearing state has been finished:

The TopAppearing's transition settings:

Question:

Why is the Top's sprite alpha 235 after the TopAppearing animatior state has been finished?


texts:
I'm working on implementing combat into my isometric rpg game which uses an ecs architecture. When synchronizing the actions of the different clients, is it preferable to serialize and synchronize raw components, actions or a mix of both.
For example, an action might be "entity X attacks entity Y", whereas the components approach would need to send stuff more like raw component state (which animation to play, frame, sound, etc). I currently use an action-based approach for movements, and that works very well locally, but implementing combat this way seems more difficult as systems become more complex and components are added down the road, and I want to be as aware as I can about possible friction now.


texts: I'm trying to instantiate different prefabs at once. But couldn't figure out how. I tried to use Random.Range method but didn't worked for me. It instantiates only one of the prefabs. I want it to instantiate all of the prefabs.


texts: Setting adaptive icon for Android from script(C#)

texts:
Want to set adaptive icon for Android from script. I am using Unity example: https://docs.unity3d.com/ScriptReference/PlayerSettings.SetPlatformIcons.html
so, what am I doing:

     void Start()
    {
        Texture2D[][] jaggedArray =
         {
             new Texture2D[] { (Texture2D)AssetDatabase.LoadAssetAtPath(pathToTexture, typeof(Texture2D))},
             new Texture2D[] { (Texture2D)AssetDatabase.LoadAssetAtPath(pathToTexture, typeof(Texture2D))}
         };

        SetIcons(jaggedArray);
    }

void SetIcons(Texture2D[][] textures)
{
    var platform = BuildTargetGroup.Android;
    var kind = UnityEditor.Android.AndroidPlatformIconKind.Adaptive;

    var icons = PlayerSettings.GetPlatformIcons(platform, kind);

    //Assign textures to each available icon slot.
    for (var i = 0; i < icons.Length; i++)
    {
         icons[i].SetTextures(textures[i]);
    }
    PlayerSettings.SetPlatformIcons(platform, kind, icons);
}

What am I doing wrong, coz I am getting InvalidOperationException?


texts:
This is the first time I'm trying to make a 2D game, so I'm having quite a few difficulties in getting things right. Right now I'm trying to figure out exactly how the entity state machine should work.

1. I noticed entity states are... well, stateless. Basically, they just act on the data in the entity accordingly, they hold no data of their own. When an entity forwards events to its states it does it like this:

void Entity::handleEvent(const Event& event)
{
     // We pass this to the state so it could act upon the data in
     // the entity in a manner appropriate for the given event.
     state_->handleEvent(event, this);
}

That means that I don't really ever need more than one instance of a particular entity state; doing something like entity.setState(new StandState) is therefore highly wasteful. Then again, making each entity state a singleton hardly seems appropriate. What do you suggest I do?

(The same can be said about game states, so whatever the solution to this is, I guess it can be applied to game states as well.)

2. The state of the entity sprite. Most of the time, whenever the state of the entity changes, the sprite that is used to represent it must change as well. How should the entity representation be notified of the change in state?

Then again, should it be notified at all? It seem that if the representation needs to be made aware the entity has changed, then it (the representation) starts having an internal state. I would much rather have it stateless so that I require only one instance of every representation (just as before).

Edit: How the Entity and its sprite interact in my current setup.

class Entity
{
  public:
    void handleEvent(const Event& event);
    void render(Surface* surf, unsigned long currentTime);
    // void update(unsigned long currentTime);

  private:
    // The representation holds the actual sprite.
    EntityRepresentation* representation_;
};

void Entity::handleEvent(const Event& event)
{
    // The representation changes its internal state depending on the event.
    // This means a representation can only be used for a specific entity,
    // and thus may be wasteful.
    representation_->handleEvent(event);
}

void Entity::render(Surface* surf, unsigned long currentTime)
{
    representation_->render(surf, currentTime);
}


texts: Planar mapping/projecting UV coordinates from normal

texts:
I've got set of vertices, and would like to calculate their UV coordinates by projecting them by a given normal. Similar to what "planar mapping" does in 3ds max.

Another way of looking at it is that I want to flatten the vertex positions from a given normal direction, so that I can simply use their X & Y (or X & Z depending on your preference) coordinates as UV coordinates.

I'm thinking it's a simple matter of a mathematical Vector function, basically rotating vertex positions along the normal, but I can't figure out the math behind it. I'm using C# and XNA, so I've got Vector3, Matrix and Quaternions. Preferably as cheap as possible.

Any help?


texts: Drawing the same mesh or drawing the same material?

texts:
I was wondering. Suppose I have a 1000 grass meshes. They all have the same material, but I create them separately, because they look slightly different, because they have different heights.

Does my GPU speed up if I only draw one mesh over and over again? Or is only the material switching and uniform setting the main problem?

So: Should I consider going to only one mesh a 1000 times, or is it ok to have a lot of different meshes with only the same material?


texts: Implementing an automatic navigation mesh generation for 2d top down map?

texts:
I am currently in the middle of implementing an A* pathfinding for enemies. In order to implement the actual A* logic, I need a navigation mesh for my map.

I am working on a 2D top down rpg map. The world is static, meaning there is no requirement for dynamic runtime mesh generation. My world objects are freely placed (not snapped to grid), rotated and scaled, which means that using a grid based A* is going to be a little complicated.

For example, how would I know a grid tile contains a collidable object? Lets say that object is actually located on the tile next to this, but is rotated and scaled such that it is still blocking the way?

I could check for the middle pixel of the grid tile to see if it contains any of the nearby objects color data, but it still wouldn't be all that accurate and occasionally enemies could get stuck in between objects.


texts: What are the differences between using GetComponent() and this.transform?

texts:
I've been reading some example code and working on my own stuff in Unity. I've been seeing a lot of GetComponent<>(), and often this will be done for the transform as Transform _transform = GetComponent<Transform>().

However, I have already had access to the attached game objects transform, as transform, this.transform or gameObject.transform. I can understand using GetComponent() in most cases, but why would you specifically use the function for GameObject and Transform when the two items are accessible from the script to start with?


texts: How to handle keyup events in game loop?

texts:
I'm writing a simple game in JavaScript, which already handles basic keyboard input like so:

var input = {};
while (!done) {
    handleInput(input);
    update();
    render();
}

document.onkeydown = function(e) {
    input[e.keyCode] = true;
}
document.onkeyup = function(e) {
    input[e.keyCode] = false;
}

Now I need the game to handle key combos (like CTRL+X for example). I would like it to accept such combos on keyup only.

Two possible solutions that come into my mind are:

exposing an array containing a list of keyup events (object with "main" key plus modifiers). The handleInput function would be responsible for draining the queue every time it polls it
keeping track of possible key combos inside handleInput (watching for held down modifier keys) and trigger the combo behavior when the "main" key goes up (I actually don't like this that much)

Would you suggest me an elegant way to extend the current functionality?


texts: How to be sure that a target goal in a match 3 game level will not be impossible?

texts:
This is clearly not a coding problem but the logical one. I am starting to learn how to make a match 3 game.
but there is a question rising in my mind.

when i will set goal to complete the level, how will i know the goal is achievable ?

suppose in a level where i have to collect 5 Red, 12 blue, 9 green objects by matching the same(like farm heros).
how would i decide how much moves i need to set to make this goal achievable. i mean it should be challenging but  not be impossible.

since the objects spawn in a random whats the surety that there will be enough number of gem in the game to not make impossible.

is there some logical explanation for this, or i just have to test and look out how many moves it takes to achieve the goal.

Is there an algorithm which generates the gems according to target set, or they are generated in random manner?

To be more clear towards my question i am going to take an example of King.com's farm-heros-saga .

In level 9 the target is to collect number of four types of objects 26,26,14,5 respectively. and the maximum number of moves are 22.

now this goal may be achievable and challenging(i mean you can achieve it in two or three trials ) but not impossible.

Now my question is what made those guys so sure that it will not be impossible, how they decided that 22 move will be enough and challenging.

well.. they could have put the maximum number of moves to 5 or 6. but that would surely make it impossible to clear the level. so how they decided to keep move 22 or this.

Are they using static pattern to generate and spawn objects, or ratio of collectible gems is fixed(i.e in total gameplay there will be X%,Y%,Z%,M% of gems respectively ), or there is some other way.
I just need some hint what should i look for..


texts:
I'm scripting my first game with Torque2D and have not fully understood the difference between "Class" and Datablock.

To me it seems like Datablock is similar to a struct in C/C++ or a Record in Pascal. If I create Datablocks with keyword new, are they instantiated in the same way as a "Class"?

I have a large TileMap and need to attach some information to each Tile. I was thinking to use a Datablock, as a struct, to attach this information to the tile's CustomData property.

The two questions are: What is a Datablock and should I use a Datablock or a "Class" for this tile information?


texts: Sprite animation frames in Adobe Photoshop CC

texts:
I am creating 64x64 px sprites for my game and want to test the animation play before saving the sprite sheet in game.

I watched this video to learn, which told me:

1) Click Window->Timeframe

2) Add selected Frame

3) Click duplicate frame, then Tween frames in between. These icons on the bottom left of timeline:

The issue is, he doesn't show how to do it if my sprite needs to animate in place... only if it moves across a canvas as such:

My game uses Texture Packer to pack individual 64x64px images and then renders the frames. Therefore, I need to make little adjustments to the single frame in place, and animate them:

I tried selecting my next frame layer for my sprite and duplicating it, but it only ends up duplicating the first frame.

How can I add my selected layer in my Layers to the timeline?


texts: How could I make a shader graph that makes spheres that look like on this image? I'm new to shaders and I don't know how to do this. Also, if it's possible I would like a property to change the glowing intensity


texts: What Unity object is my script linked to?

texts:
I am fixing an issue in a unity code that I have inherited. I have found the code file but need to fix the Canvas that is attached to that script.

Is there a way to determine, and load, the Canvas for the code file that I have found.

This is part of a vuforia enabled app.  Here is the start of the file for the Canvas that I"m looking for

using UnityEngine; using System.Collections; using Vuforia;

public class InitErrorHandler : MonoBehaviour {
    #region PUBLIC_MEMBER_VARIABLES
    public UnityEngine.UI.Text errorText;
    #endregion //PUBLIC_MEMBER_VARABLES

    #region PRIVATE_MEMBER_VARIABLES
    private Canvas errorCanvas;
    private string key;
    #endregion //PRIVATE_MEMBER_VARIABLES

    #region MONOBEHAVIOUR_METHODS
    void Awake ()
    {
        // Get the UI Canvas that contains (parent of) the error text box
        if (errorText)
        {
            errorCanvas = errorText.GetComponentsInParent<Canvas>(true)[0];
        }

        VuforiaRuntime.Instance.RegisterVuforiaInitErrorCallback(OnInitError);
    }
    #endregion //MONOBEHAVIOUR_METHODS
...
}


texts: XNA: weird effect by matrixTransform of spriteBatch on isometric tile

texts:
I wrote a Camera class that contains Matrix (for zooming and moving around). When I zoomed it with any zoom scale other than 1, some isometric grids becomes visible on each of my isometric tile.

//Camera.cs
//Producing the matrix from previously set Zoom and Location
        public static void Update()
        {
            Transform =         Matrix.CreateTranslation(Location.X, Location.Y, 0) *
                                Matrix.CreateScale(Zoom,Zoom,1);
            InverseTransform =  Matrix.Invert(Transform);
        }

//Game.cs
            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, Camera.InverseTransform);

                /* Some Drawing */

            spriteBatch.End();

PS: Actually, I really want these grids to be visible for zoom scale of 1.0f too. Having these grids make my game looks more like a tile-based game.

Before Zoom (Scale = 1.0f):

After Zoom (Zooming in):

After Zoom (Zooming out):

Zooming very close (Grid line appears to be more than one pixels):


texts:
I have a destination and 2 players.

I want the players to reach the destination and not overlap in the process.

I attached to each player a circle 2D collider and a rigidbody 2D.

Also this script:

using UnityEngine;
using System.Collections;

public class Agent : MonoBehaviour {

    public Transform destination;
    private Vector2 destPostion;
    private Vector2 playerPosition;

    public float rotation = 0;

    Vector2 velocity = Vector2.zero;

    public int maxForce = 5; //rate of acceleration
    public int maxSpeed = 4; //grid squares / second

    //private Rigidbody2D rb;

    void Start () {
        //rb = gameObject.GetComponent<Rigidbody2D>();
        destPostion.x = destination.position.x;
        destPostion.y = destination.position.y;
    }

    // Update is called once per frame
    void FixedUpdate () {
        Vector3 temp = transform.position;
        destPostion.x = destination.position.x;
        destPostion.y = destination.position.y;

        playerPosition.x = transform.position.x;
        playerPosition.y = transform.position.y;
        //Work out the force for our behaviour
        var seek = steeringBehaviourSeek();

        //Apply the force
        velocity = velocity + (seek * Time.deltaTime);

        //Cap speed as required
        var speed = velocity.magnitude;
        if (speed > maxSpeed) {
            velocity = velocity * (4 / speed);
        }

        //Calculate our new movement angle
        rotation = Mathf.Atan2(velocity.x, -velocity.y) * 180 / Mathf.PI;
        transform.rotation = Quaternion.Euler(0, 0, rotation);

        playerPosition = playerPosition + (velocity * (Time.deltaTime));

        temp.x = playerPosition.x;
        temp.y = playerPosition.y;
        transform.position = temp;
        //rb.MovePosition(temp);
    }

    private Vector2 steeringBehaviourSeek() {

        //Desired change of location
        Vector2 desired = destPostion - playerPosition;

        //Desired velocity (move there at maximum speed)
        desired = desired * (maxSpeed / desired.magnitude);

        //The velocity change we want
        var velocityChange = desired - velocity;

        //Convert to a force
        return velocityChange * (maxForce / maxSpeed);
    }
}

The problem is they start moving for a bit and they stop.

Also in the scene when I move them with the mouse they overlap. Any ideas?


texts: How should I handle animation states in Mecanim?

texts:
I did a tutorial which associated an integer to each state and manually set transitions from one state to another based on that integer, but that seems really sloppy.

Is there a more elegant way? I want to be able to change animations from code.


texts: Offline XNA Deployment to XBOX. Can it be done?

texts:
Well,

The question is pretty explicit on its own. I want to know if I can deploy a game from my PC directly to a XBox. I'm not a professional developer of games, I do it on my free time because it amuses me, but nothing else. Im planning on buying an XBox but only if I can connect directly to my Visual Studio and test the games. I don't want to connect to XNA creators club or anything like it, is this possible?

I have XNA 4.0 with VS Ultimate 2k10

Best regards and many thanks in advance,
David


texts:
When a player connects to a game, he needs to be sent all the entities currently on the map. This is done by creating entities one by one. Three ways of implementing this come into my mind. Which one them is the best?

1) Implement sending entities in the game engine: Game engine listens to "connected" event from a player object and send all the entities to the player when this happens.

2) Implement sending entities in the entity class: Entity listens to "player connected" event from the game engine and when this happens, it sends itself to the connecting player.

3) Implement sending entities in the player class: When a player connects, it gets list of entities from the game engine and sends each of them to itself.


texts: How do I get light to go through a window texture in Unity?

texts: I'm having trouble with the lighting (I have windows and the light wont go through). How do I get the light to proceed through the glass?


texts: How do I make my character jump in any angle?

texts:
My character is a square which can spin in any angle but it can not jump in certain angle.

Can anyone help?

public class Player: MonoBehaviour {

  public float maxspeed = 10f;
  bool facingRight = true;

  Animator anim;

  bool grounded = false;
  public Transform groundCheck;
  float groundRadius = 0.2f;
  public LayerMask whatIsGround;
  public float jumpFocre = 500f;

  bool doubleJump = false;

  void Start ()
  {
    anim = GetComponent<Animator> ();
  }

  void FixedUpdate () {
    grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);
    anim.SetBool ("Ground", grounded);

    if (grounded)
      doubleJump = false;

    float move = Input.GetAxis ("Horizontal");
    anim.SetFloat ("Speed", Mathf.Abs (move));

    GetComponent<Rigidbody2D>().velocity = new Vector2(move * maxspeed, GetComponent<Rigidbody2D>().velocity.y);
  }

  void Update()
  {
    if((grounded || !doubleJump) && Input.GetKeyDown ("up"))
    {
      anim.SetBool("Ground", false);
      GetComponent<Rigidbody2D>().AddForce(new Vector2(0, jumpFocre));

      if(!doubleJump && !grounded)
        doubleJump = true;
    }
  }

  void Flip()
  {
    facingRight = !facingRight;
    Vector3 theScale = transform.localScale;
    theScale.x *= -1;
    transform.localScale = theScale;
  }
}


texts: Handling movement in an Entity Component System

texts:
I'm working on a 2d RPG game in C# using an Entity-Component-System architecture, and I'm currently working on movement. Right now, I'm wondering how to organise the code so it looks a bit more.. pretty, or dignified, than it is. Currently, I have four components:

VelocityComponent - Contains the speed (velocity) of an Entity. The behaviour currently is that if an Entity does not contain a VelocityComponent, then we continue onto the next Entity, because we cannot move if we haven't a velocity.

TransformComponent - Contains the Width, Height, X and Y fields for the Entity. Basically, the position. Similar to VelocityComponent, if an Entity does not have a TransformComponent, then the GPSSystem just continues the next iteration, because we cannot move anywhere if we don't have a position.

MovementComponent - Contains a pair of co-ordinates for use as a destination position, and a boolean indicating if the Entity is currently moving.

MoveFromKeyboardComponent - Signals whether or not a key is pressed so that the Entity that this Component is attached to should move or not.

The update loop currently goes that the GPSSystem collects a list of all entities (by accessing the EntityManager. The EntityManager simply contains a key-value pairing of Guid to Entity of all active entities. All systems have access to it), then iterates over the whole lot.. It'd be better if I just posted the code;

    /// <summary>
    /// Update the GPS System.
    /// </summary>
    /// <param name="gameTime"></param>
    public override void Update(GameTime gameTime)
    {
        // Handle the movement.
        foreach (Entity entity in entityManager.GetEntities())
        {
            VelocityComponent velocity = (VelocityComponent)entity.GetComponent("Velocity");
            MovementComponent movement = (MovementComponent)entity.GetComponent("Movement");
            TransformComponent transform = (TransformComponent)entity.GetComponent("Transform");
            MovementFromKeyboardComponent movementFromKeyboard =
                (MovementFromKeyboardComponent)entity.GetComponent("MovementFromKeyboard");

            // can't do any movement manipulation without a transform (position) component.
            if (transform == null || velocity == null)
                continue;
        }

        base.Update(gameTime);
    }

However, I am unsure of how to proceed after this point. I just don't know how to manage the movement. I am aiming to have a movement style similar to Pokémon, where all Entities move one square (16 x 16) at a time and have smooth movement across those tiles, however the player can hold down a button and keep moving square after square, and when he releases that key, he stops moving (and snaps to the nearest tile if he is in the middle of two).

So, on to the question:
Am I going about this correctly? Have I got too many (or too few) components for movement? And lastly, how would I manage the fact that an Entity may have a MovementComponent and a MoveFromKeyboardComponent? I'm just confused I suppose.
I am not looking for the code for that, I am just wondering whether I am going about this correctly? This is my first whack at an entity component system, you see.

Best regards.

EDIT 1:
I should add I have now changed the structure of the System class, such that it now has a ComponentAdded and ComponentRemoved method; that is, we no longer iterate over every Entity in existence every Update(), instead we store the entities that have components we want to listen to in a data structure in the class. My question remains the same, though.


texts: Unity - Raw Image Size scaled to Photoshop

texts:
I'm just a beginner in Unity, so basically, I want to find out the exact measurement unity of the raw image so that I can now design in photoshop. I tried in Pixels in photoshop but when I import it in unity, it seems that the image is stretched out. I also tried mm, cm, inch but none of these worked. How to scale it so that my designed image's dimensions in photoshop will be exactly the same as the dimensions in unity? How to scale it?

I tried pixels in photoshop but the image is stretched out indicating that it is not the right measurement unit.


texts: Can custom maps in Starcraft 2 automatically enable certain unit upgrades?

texts:
If I create a custom map with the Starcraft 2 map editor, how can I specify that some unit upgrades are already researched?

For example, if I want all the units to already have the weapons upgrade 1 at the beginning of the game, can I specify this in the editor?

I've looked through the menus but didn't find anything that looked like it would relate to unit upgrades.


texts: touch.phase == TouchPhase.Canceled not worked

texts:
i m tired to handle and solve issues related to multitouch. i m use maximume 5 touch simultaneously but when two touches are down on two object and i moved my fingures then that both touches fired TouchPhase.Ended event but not fired TouchedPhase.Canceled.

I want to fired TouchPhase.Canceled when i my fingures out of those objects.

if (touch.phase == TouchPhase.Began) { hitObject.GetComponent ().TouchDown (hitObject); }

if (touch.phase == TouchPhase.Ended) { hitObject.GetComponent ().TouchExit (hitObject); }

if (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary) { hitObject.GetComponent ().TouchStay (hitObject); }

if (touch.phase == TouchPhase.Canceled) { print ("Touched canceled...."); hitObject.GetComponent ().TouchExit (hitObject); }