texts:
I come from a .net web background so I am accustomed to using xml .config files.  What is the XNA equivalent?  It seems to me that using the same practice of a xml config leaves your game open to easy modification (which can be good, I know). In my day-life web development the configs live on servers where users can't access.  XNA games live purely on the client (most of the time).

Say I have some values I want in a config, can the config be obfuscated or is there a different configuration management system for XNA?  Is the only solution to hardcode the values back in before release so they are not accessible?


texts: Where should I save game object's attributes (hp, score) in Swift?

texts:
Scenario: I have a game with several game objects on screen. Each can have different score and hitpoints. When I use collision detection for cannonball vs. ship (example) I need to know which ship is hit and how much hitpoints it has.

Problem: I had several approaches from extending SKSpriteNode or SKPhysicsBody but all failed. SKSpriteNode doesn't work, because Swifts collision detection only returns physicsBody and since you can't extend physicsBody, it didn't work to save there ships attributes as well.

Question: What would be a good approach to save such data to my game objects? I do not need code - because I think I can write it myself - but I would be happy to read a good suggestion. But if you have already some code written and a good solution for this problem, I would not be angry to read it ;)


texts: How would I display a unit that is hidden behind another object

texts:
Right, I've tried searching for this but as you might be able to tell from the title, I didn't really know how to word it anyway...

In some games such as rts games, when a unit is hidden or half hidden behind another object, such as a tree of building, the player will be able to see a translucent coloured version of that unit where it is hidden.

I was wondering how it would be possible to figure out which parts of the units sprite have actually been covered, and how to then use this information to then draw the translucent coloured version of the sprite.

If possible could the answers given relate to c++ and sfml? If not other answers will still be appreciated.

Sorry if my language is unclear its the first time I've asked a question on this site.


texts: How do I get the child of a unique parent in ActionScript?

texts:
My question is about targeting a child with a unique parent. For example. Let's say I have a box people can move called box_mc and 3 platforms it can jump on called:

Platform_1
Platform_2
Platform_3

All of these platforms have a child element called hit.

Platform_1

Hit

Platform_2

Hit

Platform_3

Hit

I use an array and a for each statement to detect if box_mc hits one of the platforms childs.

var obj_arr:Array = [Platform_1, Platform_2, Platform_3];
for each(obj in obj_arr){
   if(box_mc.hitTestObject(obj.hit)){
      trace(obj + " " + obj.hit);
      box_mc.y = obj.hit.y - box_mc.height;
   }
}

obj seems to output the unique parent it is hitting but obj.hit ouputs hit, so my theory is that it is applying the change of y to all the childs called hit in the stage. Would it be possible to only detect the child of that specific parent?


texts: In my game the main screen is the playscreen. But because I want to draw the menu and the gameover screen on top of the playscreen, I don't create separate screens for them. But if I want to replay, I must restart the playscreen. This happens very often, so should I load all the resources and dispose them when the game is closed. Because otherwise when I restart the playscreen, I have to load resources again, which will slow down the performance. Please, give me some advice.


texts: How to select multiple frames from a sprite sheet in unity

texts: I have a sprite sheet and cannot figure out how to select multiple frames in unity 5.5 I am watching a tutorial and it doesn't say how to do it. Is there a button I have to press while clicking or is it having to change some settings?


texts: libgdx strange collision detection behaviour

texts:
I am currently developing a small Spaceshooter Clone. The project can be found on github

I am having problems with my very simple collision detection (or better said some behaviour that I can't explain myself.)

I do have lasers and asteroids. (currently all represented by Rectangles)
To check for collision I'm using asteroid.overlaps(laser)

Basic handling of all my elements is as follows:

Move all my asteroids to the left
Check if an asteroid "left the screen" and if so destroy it.
Move all my lasers to the right
Check if a laser "left the screen" and if so destroy it.
If the laser has "not left the screen" I check collision with all asteroids.

asteroids is a Libgdx-Array;
lasers is a Libgdx-Array;
ship is a Libgdx Rectangle

    Iterator<Asteroid> asteroidsIterator = asteroids.iterator();
    while (asteroidsIterator.hasNext()) {
        Asteroid asteroid = asteroidsIterator.next();
        asteroid.x -= 200 * Gdx.graphics.getDeltaTime();
        if (asteroid.x < 0) {
            asteroidsIterator.remove();
        } else if (asteroid.overlaps(ship)) {
            //quitGame();
        }
    }

    Iterator<Rectangle> lasersIterator = lasers.iterator();
    asteroidsIterator = asteroids.iterator(); //<-- it seems that this does not get a fresh iterator
    while (lasersIterator.hasNext()) {
        Rectangle laser = lasersIterator.next();
        laser.x += 600 * Gdx.graphics.getDeltaTime();
        if (laser.x > 800) {
            lasersIterator.remove();
            Gdx.app.log("SC", "Laser exited screen.");
        } else {
            while (asteroidsIterator.hasNext()) {
                Asteroid asteroid = asteroidsIterator.next();
                if (asteroid.overlaps(laser)) {
                    Gdx.app.log("SC", "COLLISION");
                    asteroidsIterator.remove();
                    lasersIterator.remove();
                }
            }
        }
    }

When I do single fire everything is ok.

The strange behaviour is:

When I do full-automatic fire then some asteroids are not hit. Only newly created asteroids after begining firing are destroyed and in addition to that they should be very much to the right of the screen.

EDIT:
After further investigation it seems that the second call to asteroids.iterator() does not create a fresh instance. Is there a way to get a fresh/reset Iterator?


texts:
A cube is constructed in a 3D and can be rotated to view any side. I want to be able to drag the cube to any position with the mouse while keeping the Y-coordinate the same. I used project and unproject functions to map the mouse to the 3d world. This method seems to work fine when the green face is parallel to the camera. However, when i rotate the cube say 45 degrees around the x-axis and the cube face is now at an angle to the camera, the y-coordinates do not track the mouse. when the camera is parallel to the red face, the tracking in the y-axis is almost nothing.

When i dont fix the y-coordinate, the cube tracks the mouse perfectly, however, the y-coordinates are changed as well. How can i go about keeping the y-axis fixed and yet having the mouse cube track the mouse?


texts: developing a uci compatible chess engine

texts:
I have understanding of how chess engines work in theory. I know the algorithms like minimax and alpha beta pruning. I want to develop a UCI compatible chess engine.I know that UCI protocols are these: http://wbec-ridderkerk.nl/html/UCIProtocol.html but I don't quite get how the program is supposed to get those commands and how it is supposed to give result.

As minimal as it maybe, but a working model in a short time to test first is preferred. I'll add features on the go. Any tips are welcome. please guide me, thankyou.

If this is not the right place for this question, please guide me where to ask this.


texts: Unity: Particle System start rotation completely incorrect when set via C# script

texts:
I am trying to set the starting rotation of a particle system via c# script so that the particles orientate with another object in the scene. My particle system 3d rotation is set as follows:

void UpdateParticleSystemRotation(Quaternion rotation)
    {
        if(this.gameObject.GetComponent<ParticleSystem>() != null)
        {
            var particleSystemMainModule = gameObject.GetComponent<ParticleSystem>().main;
            particleSystemMainModule.startRotationX = new ParticleSystem.MinMaxCurve(rotation.eulerAngles.x);
            particleSystemMainModule.startRotationY = new ParticleSystem.MinMaxCurve(rotation.eulerAngles.y);
            particleSystemMainModule.startRotationZ = new ParticleSystem.MinMaxCurve(rotation.eulerAngles.z);
        }
        else
        {
            Debug.LogError("There was an error");
        }
    }

The rotation.eulerAngles.x/y/z values are coming through correctly, and by debugging in VS I can see that the values have been correctly assigned, as below:

However I observe that the particle system is not at all orientated with this X value, and the particle system is showing a completely different value:

You can see from the screenshots above that a value of 74.5f becomes 4274.2f by the time it hits the particle system.

I have double checked that the type expected by the ParticleSystem.MinMaxCurve constructor is a float. I cannot understand why this is happening.

I would be very grateful if someone would be able to provide some clarification on this.

Many thanks in advance.

I should add, rotation seems completely random for any given input value, it doesn't follow any obvious rhyme or rhythm.

I am using Unity 2017.2.0f3


texts:
Recently, I've been making a game.
I do not want to try to use VAOs and VBOs because I cannot wrap my head around that stuff.
But, in order to use custom shaders, I need an arraylist of things to add to a VBO.
So I want to grab each and every float in the glVertex3f in this line of code:
public void drawCube() {

    GL11.glBegin(GL11.GL_TRIANGLES);

    // GL11.glColor3f(toRatio(155), toRatio(202), toRatio(222));

    //FRONT QUAD

    GL11.glVertex3f(-10 * x,  10 * x, 10 * x);
    GL11.glVertex3f(10 * x, 10 * x, 10 * x);
    GL11.glVertex3f(-10 * x, -10 * x, 10 * x);

    GL11.glVertex3f(-10 * x, -10 * x, 10 * x);
    GL11.glVertex3f(10 * x, 10 *x, 10 * x);
    GL11.glVertex3f(10 * x, -10 * x, 10 * x);

    //BACK QUAD

    GL11.glVertex3f(-10 * x,  10 * x, -10 * x);
    GL11.glVertex3f(10 * x, 10 * x, -10 * x);
    GL11.glVertex3f(-10 * x, -10 * x, -10 * x);

    GL11.glVertex3f(-10 * x, -10 * x, -10 * x);
    GL11.glVertex3f(10 * x, 10 *x, -10 * x);
    GL11.glVertex3f(10 * x, -10 * x, -10 * x);

    //LEFT QUAD

    GL11.glVertex3f(-10 * x, 10 * x, -10 * x);
    GL11.glVertex3f(-10 * x, 10 * x, 10 * x);
    GL11.glVertex3f(-10 * x, -10 * x, -10 * x);

    GL11.glVertex3f(-10 * x, -10 * x, -10 * x);
    GL11.glVertex3f(-10 * x, 10 * x, 10 * x);
    GL11.glVertex3f(-10 * x, -10 * x, 10 * x);

    //RIGHT QUAD

    GL11.glVertex3f(10 * x, 10 * x, 10 * x);
    GL11.glVertex3f(10 * x, 10 * x, -10 * x);
    GL11.glVertex3f(10 * x, -10 * x, 10 * x);

    GL11.glVertex3f(10 * x, -10 * x, 10 * x);
    GL11.glVertex3f(10 * x, 10 * x, -10 * x);
    GL11.glVertex3f(10 * x, -10 * x, -10 * x);

    //TOP QUAD

    //debugColor();

    GL11.glVertex3f(-10 * x,  10 * x, -10 * x);
    GL11.glVertex3f(10 * x,  10 * x, -10 * x);
    GL11.glVertex3f(-10 * x,  10 * x, 10 * x);

    GL11.glVertex3f(-10 * x, 10 * x, 10 * x);
    GL11.glVertex3f(10 * x, 10 * x, -10 * x);
    GL11.glVertex3f(10 * x, 10 * x, 10 * x);

    //BOTTOM QUAD

    GL11.glVertex3f(-10 * x,  -10 * x, -10 * x);
    GL11.glVertex3f(10 * x,  -10 * x, -10 * x);
    GL11.glVertex3f(-10 * x,  -10 * x, 10 * x);

    GL11.glVertex3f(-10 * x, -10 * x, 10 * x);
    GL11.glVertex3f(10 * x, -10 * x, -10 * x);
    GL11.glVertex3f(10 * x, -10 * x, 10 * x);

    GL11.glEnd();

}

Is it possible to do that? How do I grab these floats? I know how to put them into an arraylist but I just need to floats first...


texts: Filling of a multidimensional array with string

texts:
I'm trying to fill a dropdown with a lis,t if some input is correct.

now when trying to create the list from a text file (to save the program) i should split the line on a comma so i have 3 settings for one asset:
For ex asset1,colour,used,broken.
the list should show the asset if the item is broken (0 is not broken, 1 is broken).

 public string[,,,] UsedAssetList;

string[] lines = System.IO.File.ReadAllLines(@"" + Application.persistentDataPath + "/assetlist.txt");
    cmbAssetNumber.ClearOptions();
    for (int i = 0; i < lines.GetLength(0); i++)
    {

        UsedAssetList = ***lines[i].Split(',')***;
        if (UsedAssetList[i,0,0,1] == "1")
        {
            list = new Dropdown.OptionData(UsedAssetList[i,0,0,0]);
        cmbAssetNumber.GetComponent<Dropdown>().options.Add(list);
        }
    }

The lines[i].Split(',')gives me the error:

Error   CS0029  Cannot implicitly convert type 'string[]' to 'string[*,*,*,*]'

I think everything is on point, except the filling of my list. any idea on how i can get this right?

EDIT: I was thinking the list should look like this: {{"asset1","Gold","1","0"},{"asset2","Green","0","1"} , ... }

EDIT: While the text file looks like:

asset1,Gold,1,0

asset2,Green,0,1

...


texts: Proper sphere to triangle collision resolution

texts:
I am working on a 3D game. For simplicity sake, the player is currently represented as a sphere. I have implemented an intersection test between a sphere and triangle, which returns a packet containing the collision depth and normal.
Simply moving the sphere along the normal with a magnitude of the depth works fine, but there are several problems. Sometimes the player just clips throught corners and walls, and you cannot go up slopes, since gravity is pushing you down.
I've also tried combining the collision normal and depth of all the current interesctions, although this doesn't make any difference.
There is no problem with the intersection code, I just want to know how to handle the collision in a fool-proof way.


texts: How can I determine whether a unit is in range or not?

texts:
I'm programming a small game that's going to be somewhat like a tower defence. I was playing around with how I determin whether a unit is in range or not.

public void Update(GameTime theGameTime)
    {
        Timer -= theGameTime.ElapsedGameTime.TotalSeconds;

        if (Timer < 0)
        {
            bool CreateNew = true;
            foreach (Unit theUnit in Lists.ennemyUnits)
            {
                if (Math.Pow(Math.Sqrt(Vector2.Distance(Location, theUnit.Location)),2) < 999);
                {
                    foreach (Arrow theArrow in Quiver)
                    {
                        if(theArrow.visible == false)
                        {
                            CreateNew = false;

                            theArrow.shootProjectile(Location, theUnit.Location);

                            Timer = 3;
                            break;
                        }

                    }

                    if (CreateNew == true)
                    {
                        Arrow theArrow = new Arrow();
                        Quiver.Add(theArrow);

                        Timer = 3;

                        theArrow.shootProjectile(Location, theUnit.Location);
                    }
                }
            }
        }

I'm running into a problem with this, when the location of my archer in Y is higher or the X is lower the archer doesn't shoot the enemy unit. I do not understand why?


texts: Where can I find legal or business resources for a game production company?

texts: Where can I find information on the legal or business aspects of running a game production company?


texts: Steam hammer.exe Load custom textures for other players?

texts:
I sometimes make maps with custom textures, models, materials, sounds, etc. and I showed one of my map creations to my friend, and the custom textures were pink-and-black. It was intended to be a 'display-case' map with custom sprays & sounds upon clicking a button, but he just saw black and pink textures. Is there a way to make it built-in to the map and have it auto-download? I had the textures in its own folder, like "cars/materials/texture1.vtf"; it wasn't in the actual materials folder of my steam, it was just in its own folder. If I place the textures in the Steam materials/models/etc folder, will it automatically download it for other users?

ON SINGLEPLAYER/LAN, BUT KNOWLEDGE FOR MULTIPLAYER WILL BE NICE FOR FUTURE REFERENCE


texts: How do I render a volumetrically lit spotlight?

texts:
To be clear, I really do mean volumetric lighting; not only calculating which area is lit, but also realistically lighting the volume of "air" that the light hits on the way.

Like this:

I've tried are 2 approaches: a pre-rendered 2D image and a 3D cone. The 2D image always looks flat, no matter how it is rotated in world space. The cone on the other hand is next to impossible to control when it comes to fade distance, doesn't look soft (smooth) and is expensive to compute.

Is there a better way?


texts: Webgl page heap size increasing in each page load then crash

texts:
I am getting aw snap or sometime not enough memory problem when I reload my webgl page. I have a webgl project which is empty (just a camera + light), developed in unity3d. I am reloading it, and profile its memory.

As you can see that its load 1.2MB in the first load than 1281 MB in second then 1574 then 2160 and then get crash. I am amazed that why it is happening?

  Another source of memory-related problems is the IndexedDB filesystem
  used by Unity. Any time you cache an asset bundle or use any
  filesystem-related methods, they are stored in a virtual filesystem
  backed by IndexedDB.

  What you might not realize is that this virtual filesystem is loaded
  into and persisted in memory as soon as your Unity application starts.
  This means that if you are using the default Unity caching mechanism
  for Asset Bundles, you are adding the size of all of those bundles to
  the memory requirements for your game, even if they are not being
  loaded.

but the problem is I didn't load anything from this build yet.

Even when I try to refresh my empty project several time in chrome I get this error:

For Mozilla, there is an error log which states failed to asynchronously prepare wasm: out of memory


texts: Unity3d how to show an image downloaded from HTTP

texts:
I am bit new to Unity3d. I am fine with any solution either of the scripts.

Can we render an image in unity3d (which we have to download from HTTP path)? If yes then how or do you have any reference?

Thanks
Vandana


texts:
I have a script to control the player simply moves Left, move right, etc..
but the animation when winning, losing, or Light, just put it on the animation and animator and no script for it.

I wanted to ask. if player enter at the collider, how to call animation light ?

void OnTriggerEnter2D(Collider2D theCollider)
    {
        try
        {
            // how can i call animation light //
        }
        catch { /*On error do nothing*/ }
    }


texts:
I've added an InputListener to my libgdx actor and I've added the actor to the stage. The stage (and all of its actors) gets drawn just fine.

The problem is my actor doesn't seem to be receiving keyboard inputs as nothing happens when I press keys.

@Override
public void show() {
 stage = new Stage();
 player = new Player();
 player.setPosition(600, 600);
 stage.setKeyboardFocus(player);
 player.addListener(new InputListener(){
   @Override
   public boolean keyDown(InputEvent event, int keyCode) {
    System.out.println("Key Down");
    return true;
   }
 });
 stage.addActor(player);
}


texts:
Where can I find 3d models of equipment  for supermarket? I will use them in XNA.

UPD. I need equipment like this http://www.the3dstudio.com/product_details.aspx?id_product=419747 without products.


texts: Rotate view matrix based on touch coordinates

texts:
I'm working on an Android game where I need to rotate the camera around the origin based on the user dragging their finger. My view matrix has initial position of sitting on the negative z and facing origin. I have succeeded in moving the camera through rotation left or right, up or down based on the user dragging the finger, but my problem is obviously that after I drag my finger up/down and rotate say 90 degrees so my intial position of -z is now +y and still facing origin, if I drag my finger left/right I want to rotate from +y to +x, but what happens is it rotates around the pole +y. This is to be expected as I am mapping 2D touch drag coords to 3D space, but I dont know where to start trying to do what I want. Perhaps someone can point me in the right direction, I've been googling for a while now but I don't know what I want to do is called!

Edit __
What I was looking for is called an ArcBall, google it for lots of info on it.


texts:
my company has developed an Android game using Cocos2D-X. Game works quite well except that for some unknown reason, save games keep disappearing. Users report that they play the game for several days, make good progress and then one day they enter and the game starts over, like there is no save game. We have circumvented this a bit with frequent saves to our backend and then if the local save game is missing, we retrieve it from the server, but this still doesn't explain why the save game file is missing in the first place.

This is what we used to implement storing of save games: http://developer.android.com/guide/topics/data/data-storage.html#filesInternal

Did anyone else encounter this kind of problem?


texts: How can I reduce the draw calls in a split screen game?

texts:
I am working on a split screen game with one camera per player.  It appears that the number of draw calls is multiplied by the number of cameras I have, which makes perfect sense.  More cameras means more drawing means more draw calls.

So for every player, there is effectively a new instance of the game that must be rendered.

What do developers do when presented this problem?  Do they scale down their game?  Or are there practices I am unaware of to where this should not be an issue?

(I am using Unity, if it is relevant.)

How can I improve rendering performance in a split screen game?

Example:


texts: Is it possible to render / project / flatten a 3d model onto a 2d plane in Unity?

texts:
If I have a 3d Object (character) could I use a renderer / shader / camera mode to essentially render the 3d object as a 2d sprite?
Not looking for a full tutorial on this one, I realize its a large question; just looking for a direction to head in.
My thought on this one is that it would be easier to create a 3d model and move it to a position for a book-style game. The character could be posed in a number of different positions. I'd add some sort of outline and Cel shader and outline to get the affect, but in order to get it to view properly on my otherwise 2d game, I would need it to be in a panel or something that could have a "Sorting Layer" added to it.


texts:
I am currently thinking of building a basic browser-based 2D(that would eventually become 2.5D) RPG. I have planned everything and I think that would be able to accomplish the current goals, but it seems that I can't think of a good way to develop the mapping. I have been able to move(currently teleporting as no animations at the moment) the character onclick, but can't think of a way to make some parts of the grid(tiles) not clickable so the players will not walk on water or over trees or anywhere else that they are not supposed to do so. the movable area will be 3-4 tiles out of the two-tiled roads/paths. each tile will be around 40-50px as well the character.

The game in general will be like Diablo 2 (Leveling, bosses, different areas/maps, different enemies with different levels, some equipment and etc.). And the map is mainly the biggest problem cuz I want to add cities and merchants, and the player shoould not be able to get on a questgiver's house(will not be able to get inside as well).

So to put everything together:

How should one create a tiled map, so that can mark unmovable and next(those that will trigger entering next part of the map) fields?

1.1  INFO: I was thinking of JSON to pass the data to jQ/javascript and to do the manipulation on client side but can't think of a way to mark fields
How to determinate the shortest path to the new char position for the purpose of animating

EDIT:

I am not asking anyone to do it for me, I would like to be explained how to manage everything in theory, any possible tools, technologies and etc.


texts: Problems with Level Architect, Citrus Engine, Flash

texts:
I am using the Citrus Engine to make a Flash game, and the Level Architect doesn't work well for me.
Firstly, when I first launch it and open my project and my level, nothing is shown, no assets and not anything I have previously done with my level.
To fix it, I open another project. The other project works fine, meaning I can see the assets and the level. Then I go back to the actual project I am working on, and the problem is fixed, only it does not fix the second problem:
I can't add my own assests. I follow the manual and add tags like this:
[Property(value="0")]

But it doesn't change a thing in the level architect window (even after I close and reopen it).
Any ideas?
Thanks!

Here's the code of the class I want to be shown in the Level Architect:

package {

import com.citrusengine.objects.PhysicsObject;
import com.citrusengine.objects.platformer.Sensor;

import flash.utils.clearTimeout;
import flash.utils.setTimeout;

/**
 * @author Aymeric
 */
public class Teleporter extends Sensor {

    [Property(value="0")]
    public var endX:Number=0;
    [Property(value="0")]
    public var endY:Number=0;
    public var object:PhysicsObject;

    [Property(value="0")]
    public var time:Number = 0;

    public var needToTeleport:Boolean = false;

    protected var _teleporting:Boolean = false;

    private var _teleportTimeoutID:uint;

    public function Teleporter(name:String, params:Object = null) {
        super(name, params);
    }

    override public function destroy():void {

        clearTimeout(_teleportTimeoutID);

        super.destroy();
    }

    override public function update(timeDelta:Number):void {

        super.update(timeDelta);

        if (needToTeleport) {

            _teleporting = true;

            _teleportTimeoutID = setTimeout(_teleport, time);

            needToTeleport = false;
        }

        _updateAnimation();
    }

    protected function _teleport():void {

        _teleporting = false;

        object.x = endX;
        object.y = endY;

        clearTimeout(_teleportTimeoutID);
    }

    protected function _updateAnimation():void {

        if (_teleporting) {
            _animation = "teleport";
        } else {
            _animation = "normal";
        }
    }
}
}


texts: Prevent parent alarms to activate a child alarm event

texts:
I'm working on a small game using Gamemaker Studio 2 and I've noticed that my Parent o_enemy.Alarm[0] Is activating the Child enemy_1.Alarm[0] event.

Both alarms were supposed to be activated under different conditions, (The parent alarm is used for all enemies, but the child alarm is used for the specific enemy) but they seem that they'll activate each other because they share the same name Alarm[0].

I could fix it by setting one of the alarms to Alarm[1], but seeing that I've only a limited amount of 9 Alarms, I think there should be an easier solution to solve this problem.

So far I've tried Event.inherited() on the child alarm, but that didn't solved the problem.

Is there a way that a child's Alarm will ignore the conditions of the parent alarm?


texts: How does one write to another process's OpenGL/DirectX context?

texts:
I want to write a short of chat client that display the messages in-game (OpenGL/DirectX), but I really don't know how to handle this.

It is easy to write my client in my graphic context... but what about the other game-apps context?.

My primary target is Windows and Win 7, then mac, then Linux. But I would be happy to solve it for Windows.

By the way, it should try to be the most compatible with different DX versions and OGL versions.


texts: Why should i set glClearColor and setProjectionMatrix in render method many time in LibGDX?

texts:
import com.badlogic.gdx.Game;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class MyGame extends Game {
    public OrthographicCamera camera;
    public SpriteBatch        batch;
    //..

    @Override
    public void create() {
        //..
        batch = new SpriteBatch();

        Gdx.gl.glClearColor(0, 0, 0, 1);
        batch.setProjectionMatrix(camera.combined);
    }

    @Override
    public void render(float delta) {
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        //..
    }

In LibGDX Doc
Gdx.gl.glClearColor(0, 0, 0, 1); and batch.setProjectionMatrix(camera.combined);
is setting in render() method at a time.
I use this definitions in create() method at once, and it is running perfect.

So why should i use this definitions in render() method? is't it a performance loss?


texts: Choosing random array indexes in Unity C#

texts:
I want to change a string by randomly choosing an index in an array, using the random.range command in unity. Bare in mind that I'm using strings here, not floats or integers. Here is a code example(not the real thing. I'm just coming up with this by example, but it still has the same meaning. I may make a few typo errors as a result):

public string ChangingString = ("");
public string[]ExampleArray = new string [2];

void Start () {
    ExampleArray[0] = ("String1");
    ExampleArray[1] = ("String2");
}
void OnGUI () {
    if(GUI.Button(new Rect(10,10,100,24), "Randomize text")){
        ChangingString = (code to choose random string using the ExampleArray);
    }
    GUI.Label(new Rect(10,30,100,20), ChangingString);
}

EXTRA NOTE: I'M NEW TO USING ARRAYS.


texts: Where can I go to find a game graphic artist?

texts:
Where's a good place to post to find a decent game artist to create a small number of 32-bit sprites? This is for an internal code war framework so it's minimal work - maybe a couple of hours.

Any suggestions where I should post to find someone to do this?


texts:
I've hit a loss in creating a "game engine" in XNA, I'm extremely confused over how to approach collision in an Entity-Part System ( following this as a reference ). I can make all the entities with a collision part speak with one another, but lets say the system I'm using to check collision between all the entities with a collision part picks up a collision how does it go "Oh, since the player is colliding with fire they should take damage" instead of only being able to check which entity should move if any and enacting that.

I've got the EPS set up in my project and all is working happily, I just really want to learn and I'm finding myself far too stuck on this problem to continue farther.

My past work with inheritance and checking these things was very uncomfortable as it checked collision then both objects ran a function that passed the other object in and then it was hardcoded to see what type of object it was and if it was a certain thing ( like an event box which lowers the players movement ) it would act onto that thing. It was just far to clunky and requires a lot of extra work to make sure there are no problems.

This whole concept just seems to fall apart for me when I think of collision including anything past position correction. I really want to learn and need help and will be very appreciative with anyone who can help me get this concept. I'm not sure why it's so elusive to me, and is causing me great distress that I just can't understand it despite thinking about it through most parts of the day the past two days. I just want to build a non-invasive and easy to understand system for this.

So far I just understand that I should attach a collisionPart to the entity and then in my EntityManager I'll add a system that can check through all these entities, determine collision, and act on that.


texts: What's the difference between setTransformMatrix and setProjectionMatrix in LibGDX?

texts:
There are two method of SpriteBatch in LibGDX: setTransformMatrxi and setProjectionMatrix.

I know one can use batch.setProjectionMatrix(camera.combined) to define how/where an object should be rendered on the screen. But then what does setTransformMatrix do?

I googled "difference between transform matrix and projection matrix" but no luck.


texts: I want to make a game with my friends on iOs, Android, WP operating systems. We decided to use a cocos2d-x and develop the core of the game on C++. What will be the right way of developing so that we can write the game all together simultaneously but just build the project differently on every platform. We thought of writing the core of the game in C++ in Visual Studio, but there is the problem: How can we test it fast on every platform? How people usually develop multi-platform projects?. Also we would really like to hear some recommendations about the source controlling of the whole project. Thank you in advance.


texts: Calculating normal map from height map using Sobel operator

texts:
So I'm trying to generate a normal map from a greyscale height map. Unfortunately the result I'm getting doesn't seem quite right.

Here is the height map I'm using to generate the normal map:

Here is my generated normal map:

For reference, here is the normal map that gets generated from http://cpetry.github.io/NormalMap-Online/:

One thing I notice in my normal map is that there seems to be edges. I'm not really sure why I am getting these edges - does anyone know why?

Here's the code that I'm using to generate the normal map:

// Source:
// https://stackoverflow.com/questions/2368728/can-normal-maps-be-generated-from-a-texture
// and
// http://www.catalinzima.com/2008/01/converting-displacement-maps-into-normal-maps/
float32 height(const std::vector<char>& data, const int width, const int height, uint32 x, uint32 z)
{
    if (x >= width)  x %= width;
    while (x < 0)    x += width;
    if (z >= height) z %= height;
    while (z < 0)    z += height;

    return static_cast<float32>(data[z*width*4 + x*4 + 3]) / 255.0f;
}

uint8 textureCoordinateToRgb(const float32 value)
{
    return (value + 1.0) * (255.0 / 2.0);
}

glm::vec3 calculateNormal(const std::vector<char>& data, const int width, const int height, uint32 x, uint32 z)
{
    const float32 strength = 8.0f;

    // surrounding pixels
    float32 tl = height(data, width, height, x-1, z-1); // top left
    float32  l = height(data, width, height, x-1, z);   // left
    float32 bl = height(data, width, height, x-1, z+1); // bottom left
    float32  t = height(data, width, height, x, z-1);   // top
    float32  b = height(data, width, height, x, z+1);   // bottom
    float32 tr = height(data, width, height, x+1, z-1); // top right
    float32  r = height(data, width, height, x+1, z);   // right
    float32 br = height(data, width, height, x+1, z+1); // bottom right

    // sobel filter
    const float32 dX = (tr + 2.0 * r + br) - (tl + 2.0 * l + bl);
    const float32 dY = (bl + 2.0 * b + br) - (tl + 2.0 * t + tr);
    const float32 dZ = 1.0 / strength;

    glm::vec3 n(dX, dY, dZ);
    n = glm::normalize(n);

    return n;
}

void calculateNormals(std::vector<char>& data, const int width, const int height)
{
    for (int i = 0; i < width; ++i)
    {
        for (int j = 0; j < height; ++j)
        {
           const glm::vec3 n = calculateNormal(data, width, height, i, j);

            // convert to rgb
            data[j*width*4 + i*4 + 0] = textureCoordinateToRgb(n.x);
            data[j*width*4 + i*4 + 1] = textureCoordinateToRgb(n.y);
            data[j*width*4 + i*4 + 2] = textureCoordinateToRgb(n.z);
        }
    }
}

std::unique_ptr<Image> generateFormattedHeightmap(const Image& image)
{
    std::vector<char> data;
    int width = image.width();
    int height = image.height();

    data.resize(width*height*4);

    if (image.format() == Image::Format::FORMAT_RGB)
    {
        int j=0;
        for (int i=0; i < data.size(); i+=4)
        {
            data[i] = image.data()[j];
            data[i+1] = image.data()[j+1];
            data[i+2] = image.data()[j+2];
            data[i+3] = (image.data()[j] + image.data()[j+1] + image.data()[j+2]) / 3;

            j+=3;
        }
    }
    else if (image.format() == Image::Format::FORMAT_RGBA)
    {
        for (int i=0; i < image.data().size(); i+=4)
        {
            data[i] = image.data()[i];
            data[i+1] = image.data()[i+1];
            data[i+2] = image.data()[i+2];
            data[i+3] = (image.data()[i] + image.data()[i+1] + image.data()[i+2]) / 3;
        }
    }

    calculateNormals(data, width, height);

    return std::make_unique<Image>(data, width, height, Image::Format::FORMAT_RGBA);
}

Does anyone have any ideas?


texts: Use "Google Play Game Services" (Multiplayer feature) with LibGDX

texts:
I'm developing a simple game (for Android, using LibGDX Framework) and I would like to implement multiplayer feature to it. So, since the main project with the logic of the game in LibGDX is separated from the android project, I have created an interface to allow my game to call the GPGS API in order to implement its services. But, it doesn't work. Have someone an example to show me how to do this? However, this is what I have done (premise: GPGS SDK is already installed and its library is linked to my Android project):

Copy the GameHelper class of BaseGameUtils (downloaded from Google) in my Android project.
Make the interface in the main libgdx project
Create a class (named MultiplayerOperations) that implement the interface, in my android project. This class is more similar of the BaseGameActivity available in the BaseGameUtils.
In the activity of my Android project a make an object of the last class type and pass it to the constructor of the main libgdx project.

mpOperations = new MultiplayerOperations(this);
mpOperations.onCreate();

initialize(new CloseWall(mpOperations), cfg);

When I start the application, it doesn't work and it exit with an exception.


texts: How should entities in a game reference each other?

texts:
I've been reading a lot about design patterns, but in using these patterns there's one question that I keep coming back to. How should my entities access information about each other?

Let's say I'm using a simple pattern where each object updates and draws itself:

class Monster extends GameEntity {
    public void update(double delta) {}
    public void draw(Graphics g) {}
}

I'm writing my update loop, but I realize that for Monster requires knowledge about where the player is, where cities on the main map are, or some other random piece of data.

How does Monster get at this? Do I initialize it with a reference to every possible thing it might need?

class Monster extends GameEntity {
    public Monster(Player player, City[] cityList) {
        this.player = player;
        this.cityList = cityList;
    }
}

That looks pretty messy. Or do I have a main Manager of sorts, which has access to everything, and pass that to everything?

class Monster extends GameEntity {
    public Monster(GiantGlobalManager manager) {
        this.manager = manager;
    }

    public void update(double delta) {
        cities = this.manager.getCities();
    }
}

Or perhaps have the manager as singleton? We could also break these managers into their areas of concern.

class Monster extends GameEntity {
    public void update(double delta) {
        cities = CityManager.getInstance().getCities();
        player = PlayerManager.getInstance().getPlayer();

        guiManager.getInstance().createMenu();
    }
}

But this still doesn't feel quite right. Now I'm having to maintain all these managers, and it seems wrong for my objects to be making all these static calls. Second, many of these objects should not have access to everything provided by these classes. Letting everything access everything feels like a cop-out to me.

Whatever patterns I'm using - whether I'm breaking entities into components, or just moving my drawing and update loops to separate objects - I still need some way for them to communicate. What is a good way to go about this? What am I missing here?

Should this all be done through events? But getting a list of cities is not really an event, it's just data the monster needs.


texts: Calculating bounds of a "dirty rectangle"

texts:
I'm following noita's GDC (10:30 is where the talk becomes relevant to what I'm doing) to implement various optimization techniques for my falling sand simulation.
The one that's currently blocking me is dirty rects, where a rectangle is stored inside each chunk that covers the area that needs to be updated. The purpose of this is to reduce the amount of particles you have to iterate over for each chunk each frame.
Currently, I'm able to create the bounds when a new particle is placed, but the tricky part seems to be shrinking the dirty rect when a particle moves/replaced with air.
Here's a gif showcasing what I currently have

As can be seen in the gif, the rectangle expands to accommodate newly placed particles, but does not shrink when they're erased (erasing is just replacing that particle with an air particle).
What's the most efficient way to calculate a new bounds when a particle is replaced?
In the GDC, the developer says that even if you don't multi-thread the simulation, the dirty rect is still supposed to give a performance boost due to how much it reduces the amount of particles you have to iterate over each frame during the update of the simulation, so is something that is supposed to increase performance and thus needs to be done in somewhat of an efficient manner.
(People have told me that I don't need to do this in the first place, perhaps due to a misunderstanding of the simulation I'm creating, which I feel is wrong, because in my profiling I've found that the game starts losing FPS when updating multiple chunks even when those chunks don't have any particles to update because of just the sheer amount it has to iterate over even if it's skipping all of them)
If anyone has any insight on this that would be great (code examples would be amazing, too) because I've been trying to figure this out for days without any progress due to how obscure this optimization method is.


texts: Unity3d:Detect a collision between an image and a sphere

texts:
So, I just realized, an image with BoxCollider2D wont detect any collision with Sphere with SphereCollider.

I tried adding a BoxCollider to my image, but it behaves in a weird manner (The Canvas position keeps shifting)

So, I can see the only way for it to work is adding a 2D Collider to the sphere? Is there any other better way to solve it? Adding a 2D Collider to the sphere wont cover the whole area


texts: Moving object along X and Z plane relative to camera

texts:
Using keys, I'm trying to move a cursor object across the X and Z plane, keeping it relative to a camera that I can orbit around the playfield.

This is my code so far, and apologies...I'm about 2 days into learning Unity. This code is on my cursor object.

        if (Input.GetAxis("Horizontal") > 0f) {
            transform.position = transform.position + Camera.main.transform.right * moveSpd * Time.deltaTime;
            }

        if (Input.GetAxis("Horizontal") < 0f) {
            transform.position = transform.position - Camera.main.transform.right * moveSpd * Time.deltaTime;
            }

        if (Input.GetAxis("Vertical") < 0f) {
            Vector3 dir = Camera.main.transform.forward;
            dir.y = 0.01f;
            dir.Normalize();
            transform.position = transform.position - dir * (moveSpd*1.5f) * Time.deltaTime;
            }

        if (Input.GetAxis("Vertical") > 0f) {
            Vector3 dir = -Camera.main.transform.forward;
            dir.y = 0.01f;
            dir.Normalize();
            transform.position = transform.position - dir * (moveSpd * 1.5f) * Time.deltaTime;
        }

        transform.position = new Vector3(transform.position.x, 0.01f, transform.position.z);```

It works, but the vertical axis affects the Y plane so I had to do another transform at the end.

What is the best way of doing this?

I'd also like the cursor to snap to grid co-ords. I've tried turning them to int but it doesn't do what I want.


texts: Make a layer over an image and adjust its co-ordinates by touch

texts:
I need to make a layer over an image and adjust the layer to fit to image and get its co-ordinates of the layer.

I need to adjust the layer by touch and pinch.

The sample image is as below. I need to do this in ios, and can I get any ideas to do this?


texts: How can I determine the direction of turn?

texts:
I want a function that gives me the turn direction for my object (1 or -1)

I have two angles

1 - current rotation(A)

0 <= A <= 360

2 - target rotation(B)

0 <= B <= 360

int turnSide = FindTurnSide(A, B);
Myobject.rotation += turnSpeed * turnSide;

public int FindTurnSide(int A, int B){
    //Find the closest side direction for return
    //return 1 for right side
    //return -1 for left side
}

The function should find the closest side for turn. And it should return 1 (turn right) or -1 (turn left).

How can I implement the FindTurnSide function?


texts: Resolving Diplomatic actions in a RISK-style board game

texts:
I'm working on a board game called Farlanthia: Lords of War. And I need some help with resolving diplomacy during play.

My original idea was to have Diplomacy be a form of "attack" like in RISK. This would force another player to perform an action (like a trade, or peace treaty, etc.) The idea is that each "season" you would send a diplomat to court, and politics would play out. Sometimes things go your way, sometimes they don't. This would allow me to use modifier cards (say, you have as prisoner a general from the other player, this would give you +2 in diplomacy with them).

However, as was pointed out on BoardGameGeek this isn't optimal for everyone. So I'm considering adding in a voluntary portion where if both parties agree to the treaty at hand, it goes into place without die rolling.

Thoughts? I'm just not sure how to arbitrate the rules of diplomacy during an otherwise concrete game if the diplomatic actions aren't just as concrete.

Thanks,

(Cross-posted to Board and Card Games)


texts: What should I consider when evaluating libraries, engines and frameworks for making a game?

texts:
I'm going to make a game.  I've noticed that there are a lot of game engines, libraries, and frameworks available out there, and I'm having a little trouble deciding which one to use.

I'm already pretty good with some programming languages, but there are others which I don't know at all.  I'm not against learning new programming languages, if that'll help, but my real goal is just to make my game.

What criteria should I use to compare engines, libraries, and frameworks against each other, so that I can decide which one will allow me to be the most productive to finish my game?


texts:
a 2d planet in the center, where the players will be able to walk on it and also will be affected by center gravity. planet will be static and there won't be any other planets. so;

Is there a way that I can change the gravity position? yes you can adjust gravity via project settings but I want it to be in the middle x,y,z(0,0,0)

I have tried creating my own gravity but it wasn't very useful because objects wouldnt fall, stand on foot and also in contact with another object they would vibrate instead of standing still. (if they stand on the planet they would vibrate)

        private void FixedUpdate()
{
    foreach(GameObject item in grav)
    {
        Attact(item);
    }
}

private void Attact(GameObject gmf)
{
    Rigidbody2D rgg = gmf.GetComponent<Rigidbody2D>();

    Vector3 direction = rg2d.position - rgg.position;
    float distance = direction.sqrMagnitude;

    float forceMag = (10 * rgg.mass) / distance;
    Vector3 force = direction.normalized * forceMag * 10;

    rgg.AddForce(force);
}

I can create a script that will change the gravity by the opposite of the object's position. this does work but I cannot see any way to do it for more than one object.


texts:
I'm using C# and Visual Studios 2010 with XNA 4.0+lua, and my teacher has asked us to make a 2D RPG game similar to zelda(top down). I was aiming to use just one image for each map region, instead of using the tile approach, however i'm stuck on the aspect of movement limitation.

My teacher mentioned being able to mask another image on top of the map's current image, using only back and white colors and using those to be able control where the avatar can move(move where black is and restrict movement where white is). He did not, however, instruct us on how to do this, and I have been unable to find any tutorials anywhere.

I'm fairly new to C# in general, so if anyone can point me in the direction of a tutorial that could help me accomplish this, or add their own advice I would really, greatly appreciate it.


texts: Why scale of my new UI texture differs so much comparing to other GUI elements?

texts:
I have created an UI Texture and set Texture to my .png file. The size was only 256x256 but in the canvas it appears huge. I can change it to minimum 2x2 which is still big.

If I compare it to other elements that are 135x135, they are a lot smaller...

So why is that happening and how can I fix it?


texts: Storing rendering data for voxel game 1 VAO and VBO or 1 for every chunk

texts:
I have a minecraft style voxel game with placing and digging blocks. it runs at 400+ fps on my computer but when I added semi-transparent water it started running at ~40 fps. so a time per frame increase of 0.0175s or 8 times what is used to be. What I am currently doing is having a VAO and VBO for each chunk and every time a chunk is changed or loaded it finds all of the non occluded blocks and puts their positions into another buffer in the chunk. then I use instancing to render the whole chunk in one draw call so every frame I am doing ~300 draw calls.

Once I added the water(using order independent transparency http://www.openglsuperbible.com/2013/08/20/is-order-independent-transparency-really-necessary/) I was individually calling gldrawelements() for every visible water block so around 9000 if half the visible area is ocean. I know using instancing with these blocks would help but then I have 2 VAOs for every chunk and 600+ draw calls of buffers with only a couple hundred blocks in them. would there be a better way to organize these things.


texts: Moving OBB vs. triangle intersection test

texts:
Requirements: to write a test function that, given a moving OBB (oriented bounding box) and a triangle, returns true whenever the OBB hits the triangle.

The OBB is described by its half extents (h1, h2, h3), principal axes (a1, a2, a3) and center point C(cx,cy,cz). The triangle is described by its three vertices (U1, U2, U3). The OBB moves with the velocity V over a period of time of 1 second (hence V is also the displacement the OBB undergoes).

Question:
I have already read Dave Eberly's mini-paper on the matter and made an attempt at an implementation. Also related to this paper, I have a question regarding the w projection of the W velocity: - is w equal to dot(W, L), where L is one of the 13 possible separating axes he considered in that paper?


texts: Stop mouse joint from dragging current rigidBody without mouse-up?

texts:
I have a hero, I drag him with-mouse joint attached to his rigidBody. But I want to stop dragging him when he hits a trap.
I want the mouse-joint stop working without event "touch-end" being fired.
But I've tried to remove even the mouseJoin-Component from the hero node without luck.
Please any one with any suggestion ?
I'm using Cocos Creator with JS
Thanks!


texts: How do I make hit damage a Gaussian distribution centered around a value?

texts:
I'd like my character's attacks to on average 10 damage, but to vary anywhere from 0 to 20.

Instead of a linear spread, I would like a normal distribution, so most of their hits are between 10-15, but they can still hit between 0-20. How can I do this?

I am using PHP.


texts: XNA clip plane effect makes models black

texts:
When using this effect file:

float4x4 World;
float4x4 View;
float4x4 Projection;

float4 ClipPlane0;

void vs(inout float4 position : POSITION0, out float4 clipDistances : TEXCOORD0)
{
    clipDistances.x = dot(position, ClipPlane0);
    clipDistances.y = 0;
    clipDistances.z = 0;
    clipDistances.w = 0;

    position = mul(mul(mul(position, World), View), Projection);
}

float4 ps(float4 clipDistances : TEXCOORD0) : COLOR0
{
    clip(clipDistances);

    return float4(0, 0, 0, 0);
}

technique
{
    pass
    {
        VertexShader = compile vs_2_0 vs();
        PixelShader = compile ps_2_0 ps();
    }
}

all models using this are rendered black. Is it possible to render them correctly?


texts:
I have been reading many resources about data oriented programming, and one thing I understand about it is that it's about keeping chunks of memory together to improve performance. Other than that, I find it hard to understand.
 can someone tell me if this counts as DOP or if I am doing it all wrong?

I can't tell if my pseudocode counts as data-orientated programming:

// attempted non-OOP format since I am bored of standard OOP and trying C instead of C++,
// where object_ids is array of objects holding their type id's

update() {
    for (int i=0;i<nObjects-1;i++) { // where i is the object id
        // get the update function for the type of object
        object_update_functions[object_ids[i]](i);
    }
}

// example
void * object_update_functions[0](int id) {
    // // object #0's update function
    object_x[id] += 2;
}

I'm still unsure of how to use data-orientated programming, without object-orientated programming. Unfortunately, all of the examples I've seen of data-orientated programming still use class-based object-orientated programming.

As far as I know, back in the day of the NES, they didn't have object-orientated programming like they did, today. They had to store object variables in different arrays, consequently leading to better-performing, data-orientated code.

I want to avoid making the mistake of writing pseudo data-orientated programming, and not really getting the benefits of caching and modularity. How do I use data-orientated programming without object-orientated programming?


texts: Unity - occlude a transparent part of a generated mesh with a non transparent part

texts:
I am making a procedurally generated voxel world made of blocks. Some of the blocks have non cubic shapes (ramps), and some of the blocks are transparent (water).

All the blocks are part of the same mesh. The mesh is made out of 2 sub-meshes, both using unity's standard shader, one with the opaque rendering mode, while the other uses the transparent mode.

I want to allow for the water block to render at the same location as a ramp block, with the water correctly appearing above the ground.

Here is an image of a ramp block next to a water block:

When I combine them however, I get the following effect:

I have set the transparent Shader to write to the Z-Buffer using:

meshRenderer.materials[1].SetInt("_ZWrite", 1);

(Otherwise only the water block is visible)

Here is my code for rendering the mesh:

filter.mesh.Clear();
filter.mesh.vertices = meshData.vertices.ToArray();

filter.mesh.subMeshCount = 2;
filter.mesh.SetTriangles(meshData.triangles.ToArray(), 0);
filter.mesh.SetTriangles(meshData.transparentTriangles.ToArray(), 1);

filter.mesh.uv = meshData.uv.ToArray();
filter.mesh.RecalculateNormals();

meshData.triangles contains the triangles of the opaque blocks, and meshData.transparentTriangles contains the triangles of the transparent blocks.

I have tried to slightly offset the water block, to avoid having 2 triangles at the exact same position, and that almost gives me the effect I want, except for some reason the opaque block becomes transparent, even though it's triangles are rendered by the opaque shader:

https:// i.stack.imgur.com/zlSKl .png

(The link is weird since it does not allow me to post a 3rd image link as I dont have enough reputation, please just remove the spaces)

Any help with solving the issue would be greatly appreciated.

Thank you.


texts: What is the difference between a "ping" and "RTT" (round-trip time)?

texts:
RTT, or round-trip time, is the time that it takes to send a message and receive the result from server. As I searched this, this seems to be the same as ping in network jargon.

Are there some important differences between the two concepts/terms or ping can be considered as RTT?


texts: Increase sound tempo in Unity when new player joins in Kinect game

texts:
I'm using Unity to create a Windows-build game with Kinect.

I have some drum beats, which can either be used as single sound effect or be edited to be a piece of continuous music. I want these drum beats to be the background sound of my game.

I want the drum beats to go at a constant pace, but when new users join, the beats go faster without changing its pitch.

Can I achieve this Unity with either plugin or code? Or do I need to use stuff like Max/MSP to run with Unity at the same time?


texts: How to make a script's Gizmo toggleable in the Gizmos menu in Unity3D?

texts:
I've implemented Gizmos for a few behaviours, and I'd like to make them toggleable in the Gizmos menu, just like the built-in ones.

Is this achievable?


texts:
The music in question is not exactly owned by the other individual either, as it's simply an arrangement of a game's soundtrack as a midi or music sheet.

Am I allowed to use these in my videogame? Should those persons be given credit or should it go to the original composers of the track in the original video game?

Should I ask for permission for the authors of the rearrange? What if the file and site list no author? What if it lists an author but I have no means to reach and ask?


texts: Starting from Scratch - Is it a Mistake if I re-invent the wheel?

texts:
Usually whenever I want to start a game, I will think to have a good basic architecture for rendering and better game loop from scratch. I usually don't want to use existing engines. The reason behind it is that I want to implement it on my own to learn stuff.

But lot of blogs and devs say it's not a good option to go for re-inventing the wheel.

Am I missing something?


texts: How can I find out from script(c#) did I download specific platfrom support for current Unity version?


texts: How to make a ball fall faster on a ramp?

texts:
So, I'm making a ball game. Where you pick up the ball, drop it on a ramp, and it flies off in to blocks. The only problem right now is it falls at a normal speed, then lightly falls off, not nearly fast enough to get over the wall and hit the blocks.

Is there any way to make the ball go faster down the ramp? Maybe even make it go faster depending on what height you dropped it from (e.g. if you hold it way above the ramp, and drop it, it will drop faster than if you dropped it right above the ramp.)


texts: My sprites do not always respect collisions in Pygame

texts:
I have a Player sprite (40x40 pixels) and Tiles (20x20 pixels) which build the terrain. At the 4 edges there are 2 rows or columns (depends on vertical or horizontal) of wall tiles. Those are the limits which the player should not be able to overpass and collisions player-wall are checked there.

Most of times, it recognizes collisions, but sometimes it doesn't. When I move the player until the map limit and it hits the wall tile, it stops, but sometimes if I continue trying to move it against the wall, it doesn't respect the collision and enters in the wall. At this point, once the player enters in the wall tile it can only moves over wall tiles...

So, am I doing something wrong or is it just a pygame collisions bug?

Here is the method to check collisions:

def checkCollision(self):
    from prueba import limitGroup
    listLimits = limitGroup.sprites()

    for i in range (0, len(listLimits)):
        if listLimits[i].kind == "wall" and self.rect.colliderect(listLimits[i]):
            return True

    return False

And here is the update() method to move the player.

def update(self):

    for event in pygame.event.get():
        mouseX, mouseY = pygame.mouse.get_pos()
        if event.type == pygame.MOUSEBUTTONDOWN:
            self.bulletsGroup.add(Bullet(pygame.image.load("bullet.png"),
                                          self.rect.x + (self.image.get_width()/2),
                                           self.rect.y + (self.image.get_height()/2),
                                            mouseX, mouseY))

    key = pygame.key.get_pressed()

    if key[pygame.K_RIGHT]:
        if not self.checkCollision():
            self.rect.x += 10
        else:
            self.rect.x -= 10
    if key[pygame.K_LEFT]:
        if not self.checkCollision():
            self.rect.x -= 10
        else:
            self.rect.x += 10
    if key[pygame.K_UP]:
        if not self.checkCollision():
            self.rect.y -= 10
        else:
            self.rect.y += 10
    if key[pygame.K_DOWN]:
        if not self.checkCollision():
            self.rect.y += 10
        else:
            self.rect.y -= 10


texts: How to deal with arbitrarily large images in 2D games?

texts:
Question

When you have a 2D game that uses really large images (larger than your hardware can support), what do you do? Maybe there's some interesting solution to this problem that never occured to me before.

I'm basically working on a sort of graphic adventure game maker. My target audience are people with little to no game development (and programming) experience. If you were working with such an application, wouldn't you prefer for it to handle the problem internally rather than telling you to "go split your images"?

Context

It's well known that graphic cards impose a set of restrictions on the size of the textures they can use. For instance, when working with XNA you're restricted to a maximum texture size of 2048 or 4096 pixels depending on which profile you choose.

Usually this doesn't pose much a problem in 2D games because most of them have levels that can be constructed from smaller individual pieces (e.g. tiles or transformed sprites).

But think about a few classic point'n'click graphic adventure games (e.g. Monkey Island). Rooms in graphic adventure games are usually designed as a whole, with little or no repeatable sections, just like a painter working on a landscape. Or perhaps a game like Final Fantasy 7 which uses large pre-rendered backgrounds.

Some of these rooms can get pretty large, frequently spanning three or more screens of width. Now if we consider these backgrounds in the context of a modern high definition game, they will easily exceed the maximum supported texture size.

Now, the obvious solution to this is to split the background into smaller sections that fit within the requirements and draw them side by side. But should you (or your artist) have to be the one splitting all of your textures?

If you're working with a high level API, shouldn't it perhaps be prepared to deal with this situation and do the splitting and assembling of the textures internally (either as a pre-process such as XNA's Content Pipeline or at runtime)?

Edit

Here's what I was thinking, from a XNA implementation point of view.

My 2D engine only requires a very small subset of Texture2D's functionality. I can actually reduce it down to this interface:

public interface ITexture
{
    int Height { get; }
    int Width { get; }
    void Draw(SpriteBatch spriteBatch, Vector2 position, Rectangle? source, Color  color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth);
}

The only external method I use that relies on Texture2D is SpriteBatch.Draw() so I could create a bridge between them by adding an extension method:

    public static void Draw(this SpriteBatch spriteBatch, ITexture texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth)
    {
        texture.Draw(spriteBatch, position, sourceRectangle, color, rotation, origin, scale, effects, layerDepth);
    }

This would allow me to use an ITexture interchangibly whenever I used a Texture2D before.

Then I could create two different implementations of ITexture e.g. RegularTexture and LargeTexture, where RegularTexture would simply wrap a regular Texture2D.

On the other hand, LargeTexture would keep a List of Texture2D's each corresponding to one of the splitted pieces of the full image. The most important part is that calling Draw() on the LargeTexture should be able to apply all the transformations and draw all the pieces as if they were just one contiguous image.

Finally, to make the entire process transparent, I'd create an unified texture loader class that would act as a Factory Method. It would take the path of the texture as a parameter and return a ITexture which would be either a RegularTexture or a LargeTexture depending on the image size exceeding the limit or not. But the user didn't need to know which one it was.

A bit overkill or does it sound okay?


texts:
I want to render very pretty smooth undulating hills.  There are objects snuggled between these hills, so I can't really use naive bump-mapping.

I am currently rendering using a very detailed mesh that I generate myself.  Its a lot of very small triangles.

Are there other approaches?  What is the current viability of displacement mapping, for example?

I would like to run on mainstream hardware, including integrated graphics, and possibly even one day across to tablets and such.


texts: How do you use SoundManager for multiple player games over the network?

texts:
I have created a basic sound manager according to this unity tutorial (https://unity3d.com/learn/tutorials/projects/2d-roguelike/audio). However, I need it to work for multiple players over the network, and it doesn't make sense for them all to be playing the same sounds. E.g. If a player loses, it should play the gameover sound, but the other player(s) should remain in the game and continue playing the game sound. But the current behavior is that once a player loses, everyone gets the gameover sound.

By the tutorial, I currently use a single instance within the SoundManager class. I think I need multiple SoundManager instances, each associated with a client. What's the best thing to attach the SoundManagers too? Or is there a different best practice for managing sounds for multi-player games?

Here's the code for my sound manager:

using UnityEngine;
using System.Collections;

public class SoundManager : MonoBehaviour {

    public static SoundManager instance = null;

    public AudioSource effects;
    public AudioSource music;

    void Awake ()
    {
        if (instance == null)
            instance = this;
        else if (instance != this)
            Destroy (gameObject);
        DontDestroyOnLoad (gameObject);
    }

    public void playSoundEffect(AudioClip clip) {
        effects.PlayOneShot (clip, 1f);
    }

    public void setBackgroundMusic(AudioClip clip) {
        music.clip = clip;
        music.Play ();
    }
}


texts:
BOOL = GREENIE, UIButton =GREEN. When I click the GREEN button, I coded that now you play as GREENIE character. However, I don't know how to code it that the game always remember that the I clicked on GREEN button a few games ago. The way I currently have it is when you click on GREEN button, you play the game as GREEN character then when you lose and go back to beginning of start, you play as original character instead of GREEN. So I want to make it that the game saves the choice of GREEN character instead of having to manually pick him before each game.

I tried using NSUserDefaults standardUserDefaults but it's not working.

[[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"save"];
GREENIE=[[NSUserDefaults standardUserDefaults]boolForKey:@"save"];

How do I makes GREENIE=YES saved as as character I picked instead of having to pick GREENIE manually every time before game starts?

(EDIT: NSUserDefaults StandardUserDefaults works for when saving integerForKey though but not boolForKey. Maybe I coded it wrong?)


texts: What are the things to know before to start Game Development Using C++?

texts: I just want to ask the question above ^. I want to learn C++ language. Someday i want to develop Game Application in c++ and I think it is so difficult for me to achieve that but im willing to learn and achieve that goals for may personal satisfaction and also for my CV as well. Can you give me a guidelines on how to achieve that goals? What are the languages that i need to learn together with c++? please help me.. Thank you!


texts: Rendering a distant star field in Unity using a separate camera for near stars

texts:
I'm currently working on a hobby project which is a universe simulator (exclusive to stars) built in unity3D. In order to deal with the raw scale of the universe I'm trying to implement two co-ordinate systems.

In my project I have two cameras; camera1 is the first co-ordinate system where all stars are loaded as high detail 3D objects. While camera2 is used for gathering a list of points within this "extended" frustum. I want to display these stars from camera2 on the farplane of camera1 in a lowdetail 2d manner.

I'm new to game development so this may be completely wrong; my plan was to generate a mesh from all the points in cameras2 frustum (this mesh now respresents my points in world space). I have a variable that represents the conversionFactor between the two co-ordinate systems. I will convert this mesh into projection view using the my conversionFactor in the translation component.

I will display this projection view on my camera1 farplane selling the illusion of far away stars? Please let me know the flaws in my deisgn! any help is much appreciated


texts:
I have a nice camera set up for my 2D xna game. Im wondering how I should make the camera have 'acceleration' or 'lag' so it smoothly follows the player, instead of 'exactly' like mine does now. Im thinking somehow I need to Lerp the values when I set CameraPosition. Heres my code

private void ScrollCamera(Viewport viewport)
    {

        float ViewMargin = .35f;

        float marginWidth = viewport.Width * ViewMargin;
        float marginLeft = cameraPosition.X + marginWidth;
        float marginRight = cameraPosition.X + viewport.Width - marginWidth;

        float TopMargin = .3f;
        float BottomMargin = .1f;
        float marginTop = cameraPosition.Y + viewport.Height * TopMargin;
        float marginBottom = cameraPosition.Y + viewport.Height - viewport.Height * BottomMargin;

        Vector2 CameraMovement;
        Vector2 maxCameraPosition;

        CameraMovement.X = 0.0f;
        if (Player.Position.X < marginLeft)
            CameraMovement.X = Player.Position.X - marginLeft;
        else if (Player.Position.X > marginRight)
            CameraMovement.X = Player.Position.X - marginRight;

        maxCameraPosition.X = 16 * Width - viewport.Width;
        cameraPosition.X = MathHelper.Clamp(cameraPosition.X + CameraMovement.X, 0.0f, maxCameraPosition.X);

        CameraMovement.Y = 0.0f;
        if (Player.Position.Y < marginTop) //above the top margin
            CameraMovement.Y = Player.Position.Y - marginTop;
        else if (Player.Position.Y > marginBottom) //below the bottom margin
            CameraMovement.Y = Player.Position.Y - marginBottom;

        maxCameraPosition.Y = 16 * Height - viewport.Height;
        cameraPosition.Y = MathHelper.Clamp(cameraPosition.Y + CameraMovement.Y, 0.0f, maxCameraPosition.Y);

    }


texts: Creating Unity Handles without any visible game objects at given regions

texts:
I am trying to create handles without any visible game objects. The image below from a sample scene shows rects (top left rect is at position (-2, 4), size is (1, 1)) of the handles I want to appear when the mouse is hovered over the rectangular areas. So basically in a scene with no game objects I want to be able to hover over with the mouse to show the squares below as handles.

I believe the issue is most likely with the Raycast in UpdateHandlePosition(). The handles only appear when there are objects on the screen and they appear at the wrong places. Please see the relevant code below.

static void UpdateHandlePosition()
{
    if( Event.current == null )
    {
        return;
    }

    Vector2 mousePosition = new Vector2( Event.current.mousePosition.x, Event.current.mousePosition.y );

    Ray ray = HandleUtility.GUIPointToWorldRay( mousePosition );
    RaycastHit hit;

    if( Physics.Raycast( ray, out hit, Mathf.Infinity, 1 << LayerMask.NameToLayer( "Default" ) ) == true )
    {
        Vector3 offset = Vector3.zero;

        if( EditorPrefs.GetBool( "SelectBlockNextToMousePosition", true ) == true )
        {
            offset = hit.normal;
        }

        CurrentHandlePosition.x = Mathf.Floor( hit.point.x - hit.normal.x * 0.001f + offset.x );
        CurrentHandlePosition.y = Mathf.Floor( hit.point.y - hit.normal.y * 0.001f + offset.y );
        CurrentHandlePosition.z = Mathf.Floor( hit.point.z - hit.normal.z * 0.001f + offset.z );

        //CurrentHandlePosition += new Vector3( 0.5f, 0.5f, 0.5f );
    }
}

    static void DrawHandlesCube( Vector3 center )
{

    Vector3 p1 = center + Vector3.up * 0.5f + Vector3.right * 0.5f + Vector3.forward * 0.5f;
    Vector3 p2 = center + Vector3.up * 0.5f + Vector3.right * 0.5f - Vector3.forward * 0.5f;
    Vector3 p3 = center + Vector3.up * 0.5f - Vector3.right * 0.5f - Vector3.forward * 0.5f;
    Vector3 p4 = center + Vector3.up * 0.5f - Vector3.right * 0.5f + Vector3.forward * 0.5f;

    Vector3 p5 = center - Vector3.up * 0.5f + Vector3.right * 0.5f + Vector3.forward * 0.5f;
    Vector3 p6 = center - Vector3.up * 0.5f + Vector3.right * 0.5f - Vector3.forward * 0.5f;
    Vector3 p7 = center - Vector3.up * 0.5f - Vector3.right * 0.5f - Vector3.forward * 0.5f;
    Vector3 p8 = center - Vector3.up * 0.5f - Vector3.right * 0.5f + Vector3.forward * 0.5f;

    //You can use Handles to draw 3d objects into the SceneView. If defined properly the
    //user can even interact with the handles. For example Unitys move tool is implemented using Handles
    //However here we simply draw a cube that the 3D position the mouse is pointing to
    Handles.DrawLine( p1, p2 );
    Handles.DrawLine( p2, p3 );
    Handles.DrawLine( p3, p4 );
    Handles.DrawLine( p4, p1 );

    Handles.DrawLine( p5, p6 );
    Handles.DrawLine( p6, p7 );
    Handles.DrawLine( p7, p8 );
    Handles.DrawLine( p8, p5 );

    Handles.DrawLine( p1, p5 );
    Handles.DrawLine( p2, p6 );
    Handles.DrawLine( p3, p7 );
    Handles.DrawLine( p4, p8 );

}
}


texts: Rifle bullets/projectiles in Unity, raycasting or rigidbody?

texts:
Hello again gamedevers :) I'm trying to create a fairly simple FPS shooter game. Im using a Rigidbody FPS Controller prefab from Unity. I have a rifle model attached to that, with a further gameobject for the bullet spawn location on the rifle.

I can see in the Editor, that the bulletSpawn object already knows which way it's supposed to be facing (ie. Z axis is pointing correct direction).
I've never really used Raycasts before except mobile games to select an object on screen, but my head is telling me that this might be the best way to make realistic bullets.

I've been reading about, particularly this: http://answers.unity3d.com/questions/22800/raycast-shooting.html

It suggests to use Raycasts and I understand how to call a ray from the bulletSpawn and set it's direction, and to see what it hits.
But what I don't understand is how fast the ray will travel, and how to limit the speed of said ray.

I'm not sure if this is a good way to acheive the gunfire or whether it might be better to create Rigidbodies and addforce() to them.

You guys are always so helpful and often make things MUCH easier to understand that travelling through dozens of old posts and the docs which I cant always follow along with.

How to achieve this effect?


texts: How do I find all game objects with particular name?

texts:
I'm trying to mimic FindGameObjectsWithTag with FindGameObjectsWithName. I know using tags is faster, but I'm trying create a way to search for objects I spawn with a child object I name on instantiation through the inspector.

My goal is create multiple enemy spawners. My current spawner has a drag and drop variable for enemy prefabs. It looks for enemies tagged "ReSpawn", then checks if that length is below a value, to start spawning more. I would like to upgrade my current single spawner to still check for enemies named "ReSpawn", but then check if those respawns have a child object a name specified in the editor.  This way, I can set the enemy spawners anywhere (e.g. near water, tall grass, forests, etc), and when I defeat one, the specific spawner will instantiate one of its opponents for that area.

Here is my code, so far:

var ThisSpot:String;
var Oppos : GameObject[];
var OppoCount : GameObject[];

var HowMany = 3;
var spawnSizeArea = 25;

function Start() {
    StartCoroutine ("Spawn");
}

function Update () {
    OppoCount = GameObject.FindGameObjectsWithTag("Respawn");
    // OppoCount = GameObject.FindWithName(ThisSpot);  This is what I am trying to achieve

    if(OppoCount.length < HowMany) {
        StartCoroutine ("Spawn");
    }
}

function Spawn() {
    var length = Oppos.length-1;
    var index = Mathf.Round(length*UnityEngine.Random.value);
    curSpawn = Oppos[index];

    var xz = Random.insideUnitCircle * spawnSizeArea;
    var newPosition = Vector3(xz.x,0,xz.x)+transform.position;

    yield WaitForSeconds(Random.Range(70,120));

    Instantiate(curSpawn, newPosition, transform.rotation);

    // Then I could use these 2 lines of code below to use multiple spawners
    //var newOp : GameObject = Instantiate(curSpawn, newPosition, transform.rotation);
    //newOp.transform.Find("fighter").gameObject.name=ThisSpot;

    StopCoroutine("Spawn");
}


texts: 3D player movement with Unity's new input system

texts:
So, I trying to get used to the new Unity input system. "Back in the days" I just got the Vertical/Horizontal axis, put them into a Vector3, multiplied them by a certain value and then moves the player.

Now, with the new input system, that changed quite a bit. So, what I'm trying to do is, to get the input of a 2D Vector, earlier called DPAD in the new system. My approach was, like

private void Awake() {
    InputAction.performed += ctx => Movement(ctx.ReadValue<Vector2>());
    InputAction.canceled += ctx => Movement(ctx.ReadValue<Vector2>());
}

private void OnMovement(Vector2 _dir) {
    moveDirection = _dir;
}

//This performed in FixedUpdate
private void Move() {
    transform.position += moveDirection * moveSpeed * Time.deltaTime;
}

Buut, you know, kinda worked, but not really. The player did unintended things like keep moving or not reacting at all to my button press. Maybe I set something wrong up. You might help me please, thanks!


texts:
Why does this happen?

I'm new to Unity development. I have installed Unity yesterday (2015-09-06). This is the error that I get:


texts: Moving sprites based on Delta time - consistent movement across all devices with different resolutions

texts:
This is the formula I am currently using to move my sprites across the screen:

Examples below only deal with X coordinates to keeps things as short as possible.

Initial variable declarations:

float frames_per_second = 30;         //Set this to target frames per second, 30 for this example.
float dt = 1/frames_per_second;       //Delta
float spriteXGrid;                    //Sprite's position on a grid (grid can be any explicit value, I use something simple like 800 x 600)
float spriteXScreen;                  //Sprite's actual final position in screen coordinates
float spriteXTime=5;                  //Time variable.  This is in seconds and is the amount of time the sprite should take to traverse the screen
float spriteXVel=1/spriteXTime;       //Velocity value used in conjunction with time value to calculate new position

To set my sprite's initial position I simply do this:

spriteXGrid = (pos/800);           //Where pos is the position on the grid (0-800) and 800 is the grid size that I chose to work with.
spriteXScreen=spriteXGrid*width;  //To convert to actual screen coordinates - where width is the actual width of the device currently running on.

Then to move my sprite, I do this:

spriteXGrid = spriteXGrid + (spriteXVel * dt);  //Update sprite's position on the grid
spriteXScreen=spriteXGrid*width;                //And convert to screen coordinates (again, width is the screen width of the current device)

Then I just use the spriteXScreen variable to plot the sprite, something like:

sprite.drawSprite(spriteXScreen,0);            //this is from a custom class I wrote that takes in sprite's x and y coordinate and draws it there.

My question is, is there an easier way I can do this?!  It's a nightmare to manage when it comes to collision detection etc.... because, you have 2 different coordinates, the 'screen' one (which I would describe as 'superficial'), and the 'grid' one which is needed for all the good stuff, and is a nightmare to actually work out and work with.

is there anyway I can just do something like:

spriteXScreen+='some value'

Which would allow my sprite to move across the screen in the same amount of time on all devices?

(I mean I can't just say move it by 1 pixel, because if I move 400 pixels in say 5 seconds on a 400 pixel wide screen, the sprite will have passed the whole screen in those 5 seconds, but on an 800 pixel wide screen it would have only passed halfway in the same amount of time).

The whole business of have a 'grid' coordinate and having to convert it to a 'screen' coordinate is extremely irritating and I'm wondering if I'm doing this all wrong....?

Suggestions and solutions would be very welcome


texts: Large values for Rigidbody Velocity (UNITY3D)

texts:
I'm making a simple FPS game. I've come across this problem that I am unable to solve for quite some time. If this is question has already been asked before then do let me know. The problem at hand is that I have to use some really large values for manipulating the velocity of the player's rigid body when I make it move.
I was successfully able to make the camera and the character look around based on mouse input. After that, however, I realized I needed to change the directions of velocity that increase/decrease on input to match the character's orientation. W key has to mean player's forward no matter where he is looking. To fix that problem, I take the player's local forward vector every frame using transform.forward, add velocity/speed to its components (x and z), convert it to a global vector and apply it to the rigidbody velocity.
This fix seems to work fine with only one issue: I have to use very large values of speed to achieve a normal pace. Why is this the case? Before I implemented the FPS camera, values upto 20 - 40 would do the trick. Now, I have to use 500 - 1000 to achieve the same speed. Is this normal? Also, because of this (I think), I am experiencing (very) slight lag.
This is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharacterControl : MonoBehaviour
{

Header("References")]
public Rigidbody rb;
public Camera MainCamera;
public GameObject gun;
[Header("Movement")] //why is this header not coming up in the editor
float speed;
public float run = 7f;
public float sprint = 10f;
public float jump_force = 5;
public float sensH, sensV = 2f;
float verticalLook = 0;
Vector3 localForward, globalForward;

// Start is called before the first frame update
void Start()
{
    rb = GetComponent<Rigidbody>();
    Cursor.lockState = CursorLockMode.Locked;
}

// Update is called once per frame
void Update()
{
    Camera();
    Movement();
}

void Movement(){
    // jump
    if (Input.GetKeyDown(KeyCode.Space)) {
        rb.AddForce(transform.up * jump_force);
    }
    // if shift -> sprint
    if (Input.GetKey(KeyCode.LeftShift)) { speed = sprint; }
    else { speed = run; }

    // local forward direction
    localForward = transform.forward;
    // set local speed
    localForward.x = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
    localForward.z = Input.GetAxis("Vertical") * Time.deltaTime * speed;
    // get global from local
    globalForward = transform.TransformVector(localForward);
    // set velocity
    rb.velocity = new Vector3(globalForward.x, rb.velocity.y, globalForward.z);

}

void Camera(){
    // apply horizontal camera view
    transform.Rotate(new Vector3(0f, Input.GetAxisRaw("Mouse X") * sensH, 0f), Space.Self);
    // handle vertical camera view
    verticalLook += Input.GetAxisRaw("Mouse Y") * -sensV;
    verticalLook = Mathf.Clamp(verticalLook, -30f, 30f);
    // apply vertical camera view
    MainCamera.transform.localRotation = Quaternion.Euler(verticalLook, 0f, 0f);
    gun.transform.localRotation = Quaternion.Euler(0f, 90f, verticalLook);
}
}

Even for jump force, I have to use values as large as 300 - 400 to get a 'good' jump.


texts:
Take this screenshot for example:

How exactly are they positioned perfectly adjacent to each other? Do they already create the label positions based upon the world map first, and then when the player drops an item it fills the space? Or do they use a simple padded array function server-side and some custom algorithm to position them right next to each other. I have a feeling I'm totally overthinking this.

I am using nodejs w/ the Phaser framework for my web based game and am stuck at how they accomplish this server-side. (Since all players in-game see the same exact position)


texts: C++ game-programming; What would be the "next step"?

texts:
I'm reading C++ Primer Plus 5th Edition. I'm over at Chapter 8 exercises, which is more than half of the book to go but I was wondering what would be the "next step" after I'm through with the book?

I want to use SDL/OpenGL and whatever cross-platform open source api's and libs there are available for other components of game development.


texts: XNA: Skinning sample, keyframes and time

texts:
I've been using the skinned sample from XNA tutorials to understand and play FBX files animation. While the animation in all my tests runs correctly, I fail to understand the technic to calculate time versus keyframes.

Most of the models I found so far for free and testing purpose on google store all animations into one "take" and split frames into all animations. So, walk would be frame 1 to 14, run 15 to 30, jump 32 to 48, etc. On the other hand, the skinning sample loads all frames and store a calculated time which it will be using to loop the animation.

The part where I'm getting confused is on the keyframe part. For example a model I've been trying to load gives me a 12 seconds timespan with 20160 keyframes. While the timespan seems right, the keyframe count seems to have been altered in some way since in Milkshape and in the Autodesk converter the frame count is at 300. What is it doing?

Here's my setup for model conversion.

I use Milkshape 3D to export a model and its animation to an FBX binary file.
Then, I use the Autodesk file converter to convert the file into an ASCII FBX (so far I tried and tested the FBX2012 and version 6.1, which is the same as the "dude.fbx" given with the skinning sample).
Processing model inside XNA with the SkinnedModelProcessor given with the skinning sample.

What I'm really trying to achieve here is to split animation into smaller clips so I can switch depending on the user action. I'm perfectly fine with counting keyframes, but as you can see, the keyframe count is way too high.


texts: Cannot Get The Texture Showed Up Correctly glDrawElements

texts:
I still have  this problem almost 1 month. Tried to search on Google but did not find any solution to this. I have loaded all the data correctly but don't know why the texture came up like this.

Here is my loader:

Header

struct SVertex
{
public:
    float X, Y, Z;
};

struct STexture
{
public:
    float U, V;
};

struct SFace
{
public:
    int X, Y, Z;
};

class CBMap
{
public:
    struct SMesh
    {
        SVertex *Vertex;
        SVertex *Normal;
        STexture *TexCoord;
        SFace *Face;
        SFace *FaceNormal;

        char Texture[32];
        int TextureID;
        int TotalVertice;
        int TotalNormal;
        int TotalFace;
    };

    SMesh* Mesh;

    CBMap();
    ~CBMap();

    int TotalMesh;

    int Load(char* szFile);
    int Get_FileHeader(FILE* pFile);
    int Get_TotalMesh(FILE* pFile);
    int GetData(FILE* pFile);
};

CPP

int CBMap::Load(char* szFile)
{
    FILE* pFile = fopen(szFile, "r");

    if (!pFile) return 0;

    int iBMap = Get_FileHeader(pFile);

    if (!iBMap)
    {
        printf("BMAP file is not valid\n");
        return 0;
    }

    TotalMesh   = Get_TotalMesh(pFile);
    Mesh        = new SMesh[TotalMesh];
    GetData(pFile);

    int iMesh = 0;

    char* pJunk;
    char szHeader[32];

    while (!feof(pFile))
    {
        fscanf(pFile, "%s", &szHeader);

        if (!strncmp(szHeader, "BMAP", 4)) continue;
        if (!strncmp(szHeader, "mesh", 4)) continue;
        if (!strncmp(szHeader, "mtl", 3))
        {
            fscanf(pFile, "%s", Mesh[iMesh].Texture);
            Mesh[iMesh].TextureID = LoadTexture(Mesh[iMesh].Texture);
        }

        if (!strncmp(szHeader, "ve", 2))
        {
            fscanf(pFile, "%d", &pJunk);
            Mesh[iMesh].Vertex = (SVertex*)malloc(sizeof (SVertex) * Mesh[iMesh].TotalVertice);

            for (int i = 0; i < Mesh[iMesh].TotalVertice; ++i)
            {
                fscanf(pFile, "%f %f %f", &Mesh[iMesh].Vertex[i].X, &Mesh[iMesh].Vertex[i].Y, &Mesh[iMesh].Vertex[i].Z);
            }
        }

        if (!strncmp(szHeader, "uv", 2))
        {
            fscanf(pFile, "%d", &pJunk);
            Mesh[iMesh].TexCoord = (STexture*)malloc(sizeof (STexture) * Mesh[iMesh].TotalVertice);

            for (int i = 0; i < Mesh[iMesh].TotalVertice; ++i)
            {
                fscanf(pFile, "%f %f", &Mesh[iMesh].TexCoord[i].U, &Mesh[iMesh].TexCoord[i].V);
            }
        }

        if (!strncmp(szHeader, "vn", 2))
        {
            fscanf(pFile, "%d", &pJunk);
            Mesh[iMesh].Normal = (SVertex*)malloc(sizeof (SVertex) * Mesh[iMesh].TotalNormal);

            for (int i = 0; i < Mesh[iMesh].TotalNormal; ++i)
            {
                fscanf(pFile, "%f %f %f", &Mesh[iMesh].Normal[i].X, &Mesh[iMesh].Normal[i].Y, &Mesh[iMesh].Normal[i].Z);
            }
        }

        if (!strncmp(szHeader, "f", 1))
        {
            fscanf(pFile, "%d", &pJunk);
            Mesh[iMesh].Face = (SFace*)malloc(sizeof (SFace) * Mesh[iMesh].TotalFace * 3);
            Mesh[iMesh].FaceNormal = (SFace*)malloc(sizeof (SFace) * Mesh[iMesh].TotalFace * 3);

            for (int i = 0; i < Mesh[iMesh].TotalFace; ++i)
            {
                fscanf(pFile, "%d %d %d %d %d %d",  &Mesh[iMesh].Face[i].X, &Mesh[iMesh].Face[i].Y, &Mesh[iMesh].Face[i].Z,
                                                    &Mesh[iMesh].FaceNormal[i].X, &Mesh[iMesh].FaceNormal[i].Y, &Mesh[iMesh].FaceNormal[i].Z);
            }
        }

        if (!strncmp(szHeader, "end", 3))
        {
            if (iMesh < TotalMesh) iMesh ++;
        }
    }

    printf("CBMap::Model Loaded\n");

    fclose(pFile);
    return 1;
}

First picture is reality and second picture expectation


texts: Setting resolution of multiple display screens

texts:
in my unity project I have multiple screens. How can I set resolution of each screen? I know Screen.SetResolution(1366,768,true); sets the resolution of a single screen but what about multiple screens?

I disabled unity pop up option before starting the game. Does unity choose maximum resolution by default?


texts:
In a few months I plan to start showing off the (hopefully commercial) game I'm working on to the public (internet). The thing is, besides screenshots and a trailer (of say feature functionality), how does one properly go about making a demo that can be protected?

Let me explain a bit. The game is a cross-platform RPG of a sort. Right now, the way I have the game coded is that it reads in map, character, etc data from files and that decides everything which allows me to expand the world/story just by config files and adding assets.

Meaning, my worry is if I make a demo version of the game, which is say the real game but then all the assets/config files/etc are removed so that its just a demo with the very first map/level. Is there a way to protect against someone just then putting out the datapack of the real game (when released) and now suddenly anyone with the demo EXE can play the real game?

The demo protection is kinda my first priority as I want the demo out there for a while before the real game is released.
I can always decide on what protection methods I choose from the real game later (before release, but still later.. )

I guess it boils down to is there any real way to protect the game anyway (I don't want to restrict users to having to do any online checks because this game will be cross-platform and not require internet to play it). Last thing I want to do is mess with legit users. And I'd like to leave the assets open if possible since that just means easily patching folders and allowing modders to mess around a bit.

I mean, even if I set up a basic key license system, whats really stopping 1 person from uploading their key and a copy of the game somewhere? I've seen people talk about doing frequent updates so that the binary changes and they have to re-crack the game. But, who needs to crack the game at all when you can get 1 legit copy and then spread it around?

I'm not sure if maybe I'm missing something, I'm just trying to make sure I'm not. Does it really just boil down to:

Slap basic key license protection on it.
Remove asset/config files from demo
Hope for the best

Any and all advice is appreciated! I'm very new to all this ; - ;)

Sorry if this is a duplicate! Couldn't find much on the demo concept.


texts: How to make a dynamic frontline system for my game?

texts:
My problem:
Basically the units, units meaning soldiers or vehicles, influence the frontline by moving into the opponents territory (See example image).
I'm trying to understand where to even start with this. I honestly have no idea what kind algorithm would be used to create this kind of system.
Example Image:

More info about the example:
https://www.eugensystems.com/steel-division-normandy-44-gameplay-dynamic-front-line/
This system is not node or tile based, but is fully dynamic (almost looks like a fluid simulation lol). I figured out I would render the line by using spline interpolation with points, but I don't understand the math behind the system itself (the part that controls how the line moves and creates points).
It's really cool and I would love to know where I would even start. Any free references would be highly appreciated.
Thank you!


texts: OpenGL ES 2.0 texture distortion on large geometry

texts:
OpenGL ES 2.0 has serious precision issues with texture sampling -
I've seen topics with a similar problem,
but I haven't seen a real solution to this "distorted OpenGL ES 2.0 texture" problem yet.

This is not related to the texture's image format or OpenGL color buffers, it seems like it's a precision error. I don't know what specifically causes the precision to fail - it doesn't seem like it's just the size of geometry that causes this distortion, because simply scaling vertex position passed to the vertex shader does not solve the issue.

Here are some examples of the texture distortion:

Distorted Texture (on OpenGL ES 2.0):

What the texture normally looks like (also on OpenGL ES 2.0):

The texture issue is limited to small scale geometry on OpenGL ES 2.0, otherwise, the texture sampling appears normal, but the grainy effect gradually worsens the further the vertex data is from the origin of XYZ(0,0,0)

These texture issues do not occur on desktop OpenGL (works fine under Windows XP, Windows 7, and Mac OS X)

I've only seen the problem occur on Android, iPhone, or WebGL(which is similar to OpenGL ES 2.0)

All textures are power of 2 but the problem still occurs

Scaling the vertex data - The values of a vertex's X Y Z location are in the range of:
-65536 to +65536 floating point

I realized this was large, so I tried dividing the vertex positions by 1024 to shrink the geometry and hopefully get more accurate floating-point precision, but this didn't fix or lessen the texture distortion issue

Scaling the modelview or scaling the projection matrix does not help
Changing texture filtering options does not help

Disabling mipmapping, or using GL_NEAREST/GL_LINEAR does nothing
Enabling/disabling anisotropic does nothing
The banding effect still occurs even when using GL_CLAMP

Dividing the texture coords passed to the vertex shader and then multiplying them back to the correct values in the fragment shader, also does not work
precision highp sampler2D, highp float, highp int - in the fragment or the vertex shader didn't change anything (lowp/mediump did not work either)

I'm thinking this problem has to have been solved at one point - Seeing that OpenGL ES 2.0 -based games have been able to render large-scale, highly detailed geometry


texts: Unreal Engine 4: How to make blueprints with FBX chunks of DestructibleMesh?

texts:
Into my project I imported a .FBX file that contains several small pieces. It's a helicopter rotor with about 220 parts. I now want to write blueprints with these pieces but not only with the whole thing.
I already created a DestructibleMesh out of the initial StaticMesh and imported the FBX chunks, so the detail pieces are known to Unreal and I can explode them properly.

During FBX import I also found the option to NOT group the parts into the root object but make a StaticMesh out of EVERY part. Then of course blueprints can be done with all rotor parts but the relative position of the parts to each other is not given anymore and I would have to reorder them from scratch - which is VERY much work in this case.

Does someone have a good solution for that? With the spare parts of the rotor, some gasification tasks should be made. For example exchanging two parts or "repair" something.

Thanks in advance!