texts: How do I check if there is already an object in this scene with the same name upon reloading the scene?

texts:
If the title wasn't clear enough (I don't really know how to explain it), basically I have an Audio Manager that is DontDestroyOnLoad. I also have a pause menu, that takes me back to the main menu, and in the main menu, I can reload the scene again. The problem is, upon reloading the scene, multiple copies of AudioManager is created in DontDestroyOnLoad, and I don't know how to solve it. My AudioManager script to give you a reference (only the important parts):

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

public class AudioManager : MonoBehaviour
{
    #region Instances
    private static AudioManager instance;
    public static AudioManager Instance
    {
        get
        {
            if (instance == null) //if instance doesn't exist, find an AudioManager
            {
                instance = FindObjectOfType<AudioManager>();

                if (instance == null) //if instance still doesn't exit, then it will create a new one
                {
                    instance = new GameObject("Spawned AudioManager", typeof(AudioManager)).GetComponent<AudioManager>();
                }
            }

            return instance;
        }
        private set
        {
            instance = value;
        }
    }
    #endregion

    #region Fields
    //the audio source can only play one looping sound at a time
    private AudioSource musicSource;
    private AudioSource musicSource2; //purpose of having 2 musicSources is that we can use them to achieve effects like CrossFade
    private AudioSource sfxSource;

    private bool firstMusicSourceIsPlaying;
    #endregion

    private void Awake()
    {
        //Make sure we don't destroy this instance
        DontDestroyOnLoad(this.gameObject);

        //Create audio sources, and make them as references
        musicSource = this.gameObject.AddComponent<AudioSource>();
        musicSource2 = this.gameObject.AddComponent<AudioSource>();
        sfxSource = this.gameObject.AddComponent<AudioSource>();

        //loop musicSource
        musicSource.loop = true;
        musicSource2.loop = true;
    }

If you are reading this, thanks for taking your time and try to help me!


texts: Unity5 using non-convex meshcollider with rigidbody

texts: I want to build a car using wheel collider, mesh collider and rigidbody. The problem is that unity wants the meshcollider to be convex, and that cannot happen because my base model is bigger than 255 poly's.


texts: How to derive euler angles from matrix or quaternion?

texts:
Currently working on steering behavior for my AI and just hit a little mathematical bump.

I'm in the process of writing an align function, which basically tries to match the agent's orientation with a target orientation. I've got a good source material for implementing this behavior but it uses euler angles to calculate the rotational delta, acceleration, and so on. This is nice, however I store orientation as a quaternion and the math library I'm using doesn't provide any functionality for deriving the euler angles. But if it helps I also have rotational matrices at my disposal too.

What would be the best way to decompose the quaternion or rotational matrix to get the euler information?

I found one source for decomposing the matrix, but I'm not quite getting the correct results. I'm thinking it may be a difference of column/row ordering of my matrices but then again, math isn't my strong point. http://nghiaho.com/?page_id=846


texts: Getting started using C# and Physics (Resources, Tutorials, Samples, etc.)

texts:
As an application developer, I plan on now getting started in game development so I have come along to this site.

I am a proficient C# developer so I guess it makes sense to start game development in the same language, unless someone directs me otherwise.

I'm looking for some "getting started" type of tutorials that cover basic game architecture and essential physics such as collision, velocity, gravity, friction etc.

I know about XNA and physics engines such as farseer but, at the moment, I'd like to get started without attaching myself to a particular framework or set of classes.

Please let me know of good resource, tutorials, etc. that will get me started in this manner.


texts: Partial recalculation of visibility on a 2D uniform grid

texts:
Problem
Imagine that we have a 2D uniform grid of dimensions N x N. For this grid we have also pre-computed a visibility look-up table, e.g. with DDA, which answers the boolean query is cell X visible from cell Y?

The look-up table is a complete graph KN of the cells V in the grid, with each edge E being a binary value denoting the visibility between its vertices.

Question
If any given cell has its visibility modified, is it possible to extract the subset Edelta of edges which must have their visibility recomputed due to the change, so as to avoid a full-on recomputation for the entire grid? (Which is N(N-1) / 2 or N2 depending on the implementation)


texts: I want to ask that I have a player in my game. I may walk. I have a image which has five different frames for walk and two frames for standing position. I want to ask that how can I change the images on runtime depending on the player state? I have loaded the image in tiledtextureregion. Also player can walk in forward and backward direction as well. How to use the same image strip for walking back and forth? I am new to andengine.


texts:
I have already referred the animator by using the statement,

       Animator anim;

But,What is the use of getcomponent in awake() function.What happens without it.


texts:
I've been noticing that using multiple sf::Text objects has a huge impact on performance.

The difference between using 1 or 4 sf::Text objects can result in almost a 40FPS drop (From 120 to 80).

ExampleText = new sf::Text();
ExampleText->setFont(*ResourceManager::GetInstance()->GetAceFont());
ExampleText->setColor(sf::Color::White);
ExampleText->setCharacterSize(36);

Am I not making them right? If somebody could even explain why this happens as the docs tell me sf::Text is really lightweight.

Any help would be appreciated.


texts: Ideas for time-keeping in a webbased RPG?

texts:
I'm assigned a task of doing the preliminary research stuff for a web-based MMO RPG. Now my buggiest problem here is "web based" vs "MMO RPG". I did some research about time keeping systems and I'm totally confused as how exactly something as real-time as an MMO-RPG can work on some pull-only (unidirectional) platform like HTTP.

I know there is also a turn-based alternative to time keeping but can it work in an MMO setting ?

EDIT:
Take a battle for example, player A (human) wants to attack Player B (also human) in the open. How does it work when when player A issues the "attack" command on player B ? how do I inform player B that he is being attacked ? and then how exactly the battle goes on between the two in an HTTP based communication channel?

To my knowledge this is impossible unless you resort to another technology (HTML is 1-way, that is you can just ask server and get response, server can't update you unless being asked to. this is very well-known and simply explained). So I though maybe I can somehow change the whole timekeeping model from real-time to a more non-real-time model (towards a turn based RPG for example) and somehow work around the whole problem of "interactivity".

EDIT2:
It is not that I don't wanna use any server side technologies. For sure it is not gonna work client-side-only even for the most trivial of the multi-player games, let alone an RPG. So sure there would be a (probably complex) server side component to it (the so called Game Engine I suppose). The problem is not the technology that implements the logic (game mechanics) bits but the communication technology and how it limits the game mechanics abilities (like how real-time or turn based it is gonna be). HTTP is a request-response protocol meaning you get served only if you ask for it (explicitly send a GET or POST request to the server). HTTP server can not inform you if anything of interest happens in the game world unless you refresh the page (as some suggested) or you use some bi-directional tech (totally different animals) like Flash, WebSock, HTML5 etc etc.

So maybe the question is: Is it possible to implement a MMORPG using only HTML5/PHP and no periodic page refreshes? if so what would be rules to make it an MMO-RPG?

Can't explain it any clearer. Sorry :D


texts:
I want to hack together a roguelike. Now I thought about entity and world representation and got to a quite big problem.

If you want all the AI to act simultaneously you would normally(in cellular automa for examble) just copy the cell buffer and let all action of indiviual cells depend on the copy. Actions which are not valid anymore after some cell before the cell you are currently operating on changed the original enviourment(blocking the path) are just ignored or reapplied with the "current"(between turns) environment. After all cells have acted you copy the current map to the buffer again.

Now for an environment with complex AI and big(datawise) entities the copying would take too long. So I thought you could put every action and entity makes into a que(make no changes to the environment) and execute the whole que after everyone took their move.
Every interaction on this que are realy interacting entities, so if a entity tries to attack another entity it sends a message to it, the consequences of the attack would be visible next turn, either by just examining the entity or asking the entity for data. This would remove problems like what happens if an entity dies middle in the cue but got actions or is messaged later on(all messages would go to null, and the messages from the entity would either just be sent or deleted(haven't decided yet)

But what would happen if a monster spawns a fireball which by itself tracks the player(in the same turn). Should I add the fireball to the enviourment beforehand, so make a change to the environment before executing the action list or just add the ball to the "need updated" list as a special case so it doesn't exist in the environment and still operates on it, spawing after evaluating the action list?

Are there any solutions or papers on this subject which I can take a look at?

EDIT: I don't need information on writing a roguelike I need information on turn based ai in respective to a complex enviourment.


texts: How do I draw non-smoothed fonts in MonoGame 3.5?

texts:
I don't want to smooth the tiny fonts I'm building but even disabling ClearType system wide doesn't let me create SpriteFont files with sharp characters. There doesn't seem to be an option for smoothing in the .spritefont file I could set to "disabled". Are there any configs that affect how spritefonts are generated?

I'm using MonoGame 3.5 with Visual Studio 2015 and building the spritefonts via Content.mgcb thing that is added automatically into a MonoGame project.

I tried using Give Your Fonts Mono(spacing) tool but it doesn't have an option to disable smoothing.

Trying to follow this tutorial with BMFont generator and added the reference in the example, but the MonoGame.Extended thing doesn't appear and instead of automatically recognized importer I get [missing] [null]. After that I tried adding some other packages that come with MonoGame pipeline DLLs but no luck.

Tried to use XNA Content Compiler but it throws me an exception with some important object contentBuilder being null. Installing XNA framework doesn't fix the issue.

If there are ways to draw text without using SpriteFonts that allow to use non-smoothed characters, I'd like to know how.


texts:
I'm trying to set up GLEW with Visual Studio 2012 and I'm having some trouble with it.

I downloaded the GLEW binary from http://glew.sourceforge.net/ and moved the contents from it's lib folder to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib folder, and the contents from the include\GL folder to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include\GL folder.

Then I started up Visual Studio, and linked the glew32.lib in the linker properties section.

When I try to compile, I get the error: error LNK1104: cannot open file 'glew32.lib'.

How can I get this to work, preferably without copying the libs to system32? (I'll do that if I really can't get this to work)


texts: How to rotate and move a model in the direction it is facing?

texts:
I am not using Unity or XNA. Eventually, I will probably use OpenTK for graphics. But for the concept of a game I'm writing, I am using the console for keyboard input and visual logging of events, etc.

I am also using a WPF window to display world and player data.

Update: I am using 0 deg as North. I understand that this may not be 'standard'. I don't mind switching to the standard where 0 deg is East if necessary.

The standard keys are W, A, D, S and Left/Right arrows.
W: move forward
A: move left
D: move right
S: move backward

L Arrow: rotate left 2.5 (degrees)
R Arrow: rotate right 2.5 (degrees)

I am new to the physics of movement within a 2D space (as if I am looking down from overhead). What I have is a World and Player model; each Player encapsulates an IEntityVector object.

Edit: added the conversion to radians in the following method. Seems to work more correctly as long as the orientation is 0, 90, 180, or 270 degrees.

Move Model:

  public static void MoveEntity (Guid EntityId, Direction Direction) {
     var entityVector = default(IEntityVector);
     var gameWorld = default(World);

     if (entityRealms.TryGetValue(EntityId, out gameWorld)) {
        if (gameWorld.entityVectors.TryGetValue(EntityId, out entityVector)) {
           var heading = (Math.PI/180) * entityVector.Heading;

           switch (Direction) {
              case Direction.Forward:
                 entityVector.AddMovementX((float)Math.Sin(heading));
                 entityVector.AddMovementY((float)Math.Cos(heading));

                 break;
              case Direction.Left:
                 entityVector.AddMovementX(-(float)Math.Cos(heading));
                 entityVector.AddMovementY((float)Math.Sin(heading));

                 break;
              case Direction.Right:
                 entityVector.AddMovementX((float)Math.Cos(heading));
                 entityVector.AddMovementY((float)Math.Sin(heading));

                 break;
              case Direction.Backward:
                 entityVector.AddMovementX((float)Math.Sin(heading));
                 entityVector.AddMovementY(-(float)Math.Cos(heading));

                 break;
              default:
                 break;
           }
        }
     }
  }

Rotate Model:

  public static void RotateEntity (Guid EntityId, float Heading) {
     var entityVector = default(IEntityVector);
     var gameWorld = default(World);

     if (entityRealms.TryGetValue(EntityId, out gameWorld)) {
        if (gameWorld.entityVectors.TryGetValue(EntityId, out entityVector)) {
           entityVector.Heading += Heading;
        }
     }
  }

#1 I am trying to understand the rotation first of all. If Heading is increased or decreased by 2.5 per rt/lf arrow key press, how do I keep the resulting value as a true degree value?

#2 How can I use the Heading degrees as the facing to properly move the entity?

Btw, here are the AddMovement methods:

  public static void AddMovementX (this IEntityVector Vector, float X) {
     var newPosition = Vector.Location.X + (X * Vector.Thrust);
     Vector.Location = new Vector(newPosition, Vector.Location.Y);
  }

  public static void AddMovementY (this IEntityVector Vector, float Y) {
     var newPosition = Vector.Location.Y + (Y * Vector.Thrust);
     Vector.Location = new Vector(Vector.Location.X, newPosition);
  }


texts: Logical operations per component in GLSL

texts:
According to the OpenGL spec in GLSL, the logical operators: &&, || etc work between booleans, not vectors of booleans.

So, what is the best way to perform the logical and/or per component in GLSL?

For example in cg and HLSL you can do this:

float2 x_ = ( (x >= 0) && (x < a) ) ? float2(0., 0.) : float2(0.5, 0.5);

I actually used this code on a cg script in unity and when it tried to convert it to GLSL I got this error:

Shader error in 'Sprites/Advanced': '&&' : wrong operand types no operation '&&' exists that takes a left-hand operand of type 'vec2' and a right operand of type 'vec2' (or there is no acceptable conversion) at line 83 (on gles)

So, I am trying to find if something similar  exists in GLSL.


texts: Following waypoints, condition is never fulfilled

texts:
Given a 2D-grid which is defined like below and is used to draw a grid consisting of cells:

int[,] grid; //filled with 0 (blocked) and 1 (walkable);

I also have a A*-algorithm implemented which returns a List<Vector2> with the grid cell positions of the waypoints of the path. The actual screen-positions of the cells can be calculated using the cell width. So for example a Vector2 waypoint = new Vector2(0,2); is a Cell in the first row and third column.

I also have a Player class which holds and displays a texture. When I let the Player follow the path, the texture is moving towards the top waypoint in the List. Once the waypoint is reached with position == currentgoal //comparing Vector2 here I delete it from the list and set the next waypoint as the current goal.

Here is how I update the Player position, in this case it is moving down as the direction Vector2 is set to Vector2(0,1);

float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

position += new Vector2(0,1) * speed * elapsedTime; //direction * float * float

First I was using an integer as speed and omiting the elapsedTime in the calculation. As this is not how it is supposed to be implemented I changed the speed to float and added elapsedTime. Also with an speed value of int speed = 1; the texture was moving too fast already.

Unfortunately with the float values the Vector2 comparison of position and waypoint vectors is almost never exactly reached and therefore the condition never fulfilled. This is because the goal values although being floats always hold values with a 0 after the point.

What I tried is to check for a (+/-)1 value so if the position is somewhere between currentgoal +/- 1. This does lead to a inaccuracy and other side effects.

Is my position calculation a common and right way to do it? If so, how could I modify my code which is checking whether the goal is reached or not?


texts: I am a newbie so when ever i start over i get stuck how to organize things (code) or what should be the order of my work. Can you share your experience of project granularity so i can make my mind what should be done first and so on.


texts:
I'm pretty new to Game Development world. I'm using Unity 3D (4.6 - Latest version I think) and Visual Studio to code the script and something when I edit the script un VS 2013 and go back to Unity the script I edited does not match what unity "have". And Unity does not even show a compile error.

Exemple I have is :

(in a 2D environment)  i wrote this script

void Update(){
    Vector2 tweak = new Vector2(Math.Random(0f,0.2f), Math.Random(0f,0.2f));
    rigidbody.velocity += tweak;
}

Well unity gave me the error that rigidbody does not exist on the Transform (aright that's cool im in a 2d env. so it's rigidbody2D.velocity. I edited the script, with the fix, but Unity was still executing the line BEFORE the fix. I had to close VS and Unity to fix this.


texts:
http://www.kickstarter.com/projects/539087245/spriter

At 3:00 they discuss that there is a method used to separate the parts of character into individual sprites and move them saving production time and video memory. What is this method called I am thinking that I want to implement it for my game but need to do more research.
Thanks alot =)


texts:
I'm working on a TCP turn multiplayer game.

I've read many tutorials and stuff, and they all said to use Async IO, but, none of than give practical examples on how to do it.

I was thinking that in every TCP data stream sent, the client would have to send who is he, and what he's doing. Is it really necessary? What's the best way to deal with host identifying? If I should deal with this at all...

Should I check in every message if he's who he's claiming to be?
There's any comprehensive game packet analysis avaiable on the web? I think I would learn much from this kind of source.

EDIT: I'm doing a server/many-clients model.

Thanks,
Julio Rodrigues


texts: PHP Browser Game Question - Pretty General Language Suitability and Approach Question

texts:
I'm developing a browser game, using PHP, but I'm unsure if the way I'm going about doing it is to be encouraged anymore.

It's basically one of those MMOs where you level up various buildings and what have you, but, you then commit some abstract fighting entity that the game gives you, to an automated battle with another player (producing a textual, but hopefully amusing and varied combat report).

Basically, as soon as two players agree to fight, PHP functions on the "fight.php" page run queries against a huge MySQL database, looking up all sorts of complicated fight moves and outcomes. There are about three hundred thousand combinations of combat stance, attack, move and defensive stances, so obviously this is quite a resource hungry process, and, on the super cheapo hosted server I'm using for development, it rapidly runs out of memory.

The PHP script for the fight logic currently has about a thousand lines of code in it, and I'd say it's about half-finished as I try to add a bit of AI into the fight script.

Is there a better way to do something this massive than simply having some functions in a PHP file calling the MySQL Database?

I taught myself a modicum of PHP a while ago, and most of the stuff I read online (ages ago) about similar games was all PHP-based. but a) am I right to be using PHP at all, and b) am I missing some clever way of doing things that will somehow reduce server resource requirements?

I'd consider non PHP alternatives but, if PHP is suitable, I'd rather stick to that, so there's no overhead of learning something new. I think I'd bite that bullet if it's the best option for a better game, though.


texts: Verifying that two words match — false negatives

texts:
In my first game, I am trying to validate whether two words match: whether an input word matches a reference word from an array.

Unfortunately the only word for which it finds a correct match is the last value in the array I created. All the other words report an incorrect match even when input correctly.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class MatchLetters : MonoBehaviour {
    public string word = null;
    public int wordIndex = 0;
    public string alpha;
    public Text WordMatch;
    public Text Question;
    public string name;
    public static string[] quest;
    int num;
    public List<string> Words;

    void Start () {
        TextAsset wordText = Resources.Load<TextAsset> ("Words");

        quest = wordText.text.Split ("\n" [0]);
    }

    void Update () {
       //  Question.text = quest[Random.Range(0, quest.Length)];
    }
    public void AlphabeticFunction(string alphabet){
        wordIndex++;
        word = word + alphabet;
        WordMatch.text = word;
    }

    public void WordsGenerate (){
        name = Question.text = quest[Random.Range(0, quest.Length)];
    }

    public void ValidateAnswer (){

        if (name == WordMatch.text) {
            Question.color = Color.green;
            Debug.Log ("Correct");
        } else {
            Question.color = Color.red;
            Debug.Log ("Incorrect");
        }
    }

    public void ResetAnswer(){
        wordIndex = 0;
        word = "";
        WordMatch.text = word;
    }
}


texts: Is there an alternative to decals that will let me put bullet holes on a complicated object?

texts: I'm trying to figure out a way to do "bullet holes" but actually apply the texture at the shader level?  If I'm dealing with a model which doesn't have a "flat" face I'd like to be able to wrap the "decal" across the model.  Anyone point me at a tutorial that will do something similar to this.


texts:
I'm currently trying to build a mobile application that, for the purposes of trying to keep small in size, I would like to have store much of its content Online and be downloaded to the users mobile when the application requires it.

Ideally I'd like to do so not just as a means to reduce the applications original size, but also to allow new assets to be introduced over time (such as new objects and textures) without the user having to reinstall the application or download a new update.

I am at the moment researching into the use of Unitys Addressible Assets for these purposes, and am currently trying to test and implement this idea on a small scale using assets stored using Google Cloud storage.

If possible however I would like to to ask whether anyone here has any experience with storing and accessing assets on an external server, and if so, might they have any advice as to whether or not this could be a feasible solution for these purposes?

Any help would be really appreciated, as this is an area that is completely new to me.

Thanks in advance.


texts: I need to keep music playing but still be able to mute it between games, how?

texts:
I have a game built in Unity.  The game plays music continuously, which can be muted on button press on the scene.  This works fine using the below code:

MuteButton.cs

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class MuteButton : MonoBehaviour {
    public GameObject audioObject;
    private AudioSource audioSource;

    void Start()
    {
        Button b = gameObject.GetComponent<Button>();
        b.onClick.AddListener(Pause);
    }

    void Pause() {
        Debug.Log("mute toggle");

        audioSource = audioObject.GetComponent<AudioSource>();
        if(!audioSource.isPlaying) {
            audioSource.Play();
        } else {
            audioSource.Pause();
        }
    }
}

However, when the player loses the game restarts by reloading the scene, using this code:

public void Restart()
{
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}

In order to keep the music running I have attached the following script to my music game object:

using UnityEngine;
using System.Collections;

public class Music : MonoBehaviour {
    static Music instance;
    void Start() {
        if(instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
    }
}

All working fine up until now.  Once the scene is reloaded when the user tries to mute the music I get the following:

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.

I understand that the error is that I'm trying to mute a now non-existent game object, but how can I pause the music if this is the case?


texts: Are shader-based antialiasing methods making traditional multisampling obsolete?

texts:
See an analysis of FXAA here, and the page for SMAA here

Now these methods have a drawback which is that they are not capable of improving quality in a physically accurate way, like multisampling does (what I mean by this is that it brings out the sub-pixel details from geometry by super-rasterizing), but they are a terrific method for curtailing visual artifacts which are a result of regular rasterization.

Case in point: I run an Nvidia GTX 260, it came moderately overclocked from the factory, it is a Gigabyte Super Overclock model. I also run a 1920x1200 screen.

It's sometimes difficult to maintain good framerates when I play Battlefield 3, but I've noticed some general improvements in terms of speed recently which has made the game play quite a bit better today than it did back when it was released.

The point is, the performance hit caused by 4xMSAA or even 2xMSAA is very noticeable in this game at my full resolution, because it needs all the power it can get. However, FXAA post processing antialiasing comes at almost no cost! A month or two ago, I found myself running the game in windowed mode most of the time because it achieved better framerates that way. But now I've discovered that disabling MSAA and using FXAA almost completely eliminates edge-artifacts without the performance hit of MSAA.

I find that shader-post-process AA is extremely good at producing smooth edges when lines are near-horizontal or near-vertical, and also with thin objects, like the cables on the telephone pole in the link. On still images, a similar smoothness quality is unobtainable until you crank MSAA to 16x.

However shader-post-process AA does not eliminate temporal aliasing artifacts: Even though edges are smoothed terrifically, they "jump" as they move across pixel boundaries.

The reason why this happens is because the shader-AA has no knowledge of actual geometric coverage data, which is what MSAA and friends are essentially based on. As an edge traverses the pixel boundary, our smooth edge will "jump" the length of a pixel, rather than smoothly blending in and out like we would see with 16xMSAA/CSAA. CSAA is particularly good for this because it rasterizes at a higher resolution than MSAA.

So with all this in mind I don't think that shader-based antialiasing methods are a replacement for traditional methods. However I think they are a really cool way to improve image quality in almost every situation. They have the benefit of not requiring a different render buffer storage format.

I think that, going forward, the best way to apply antialiasing in games would be a combination of coverage sampling AA and post-process AA.

Jeff Atwood claims that FXAA made MSAA/CSAA obsolete overnight. What do you think? What are some other ways to compare and contrast traditional antialiasing with shader-based antialiasing?


texts: What's the difference between Tiled maps' various tilewidth/tileheight values?

texts:
I'm parsing Tiled maps (.tmx) for my game, and even after reading the documentation, I don't understand what the difference is between the attributes tilewidth and tileheight of the map element versus the attributes of the same name in the tileset element. They are often the same; an example where they differ is the map _isometric_grass_and_water.tmx_ from Tiled's examples folder:

<map version="1.0" orientation="isometric" width="25" height="25" tilewidth="64" tileheight="32">
<tileset firstgid="1" name="isometric_grass_and_water" tilewidth="64" tileheight="64">

Also, there's this child element of tileset whose purpose I don't understand:

    <tileoffset x="0" y="16"/>

Do those distinct values exist for isometric maps? If anyone could shed some light on this, my hurty brain'd be very thankful.


texts:
I've found a bunch of tutorials on how to make this work on Open GL 1 & 1.1 but I can't find it for 2.0.

I would work it out by loading the texture and use a matrix on the vertex shader to move through the sprite sheet.

I'm looking for the most efficient way to do it. I've read that when you do the thing I'm proposing you are constantly changing the VBO's and that that is not good.

Edit:
Been doing some research myself. Came upon this two Updating Texture and referring to the one before PBO's. I can't use PBO's since i'm using ES version of OpenGL so I suppose the best way is to make FBO's but, what I still don't get, is if I should create a Sprite atlas/batch and make a FBO/loadtexture for each frame of if I should load every frame into the buffer and change just de texture directions.


texts: How do I create a draggable object which snaps to obstacles in the way?

texts:
I bring yet-another-drag-with-mouse question (I am using Unity with C#), but with a less common particular detail: the existence of obstacles in the middle of the way trough which dragging occurs (3D space, not 2D).

Let me explain. Suppose I have a plane over which I want to drag a cube called "obj" .That's easy. Here is my simple implementation for that:

void Update () {
  Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  RaycastHit hit;
  if(Physics.Raycast(ray, out hit, 1000000))
  obj.transform.position = new Vector3(hit.point.x,0.25F,hit.point.z);
}

It works. However, suppose that I also have a few other cubes over the plane, which are the obstacles. Obviously, when the player moves "obj" over the plane, such movement should be blocked by the obstacles. And then, while colliding with the obstacles, "obj" should move only snipped to the sides of that obstacle. If mouse is moved and "obj" stops colliding with obstacles, free dragging-style movement resumes again.

To make the challenge harder, I am trying hard to achieve that without the use of RigidBody components at the obstacles (the dragged object can have it). Any ideas on what is the most efficient way of achieving that? Many thanks!

EDIT:
Commentators have brought to my attention that I should mention that objects are allowed to rotate when snapping.

EDIT 2:
Considering the difficulty of the original formulation, I changed the question allowing the use of Rigidbody components at the dragged objects. The solution just can not use Rigidbody components at the obstacles.


texts: Gravity Simulation failing at short distances

texts:
I have a 2D space simulation with gravity acting on three bodies (e.g. sun and 2x planets). The simulation seems pretty stable with RK4 (was unstable with Euler). The problem arises if the orbit of one of the planets get VERY close to the sun (or other planet), it is liable to shoot off towards alpha-centuri.

I think the problem is due to the  asymmetric nature of numerical integration in this situation; if a planet is VERY close to a sun in one time step, it will experience huge acceleration and end up (next update) on the far side of the sun, much further away with much weaker gravity (1/r^2), which won't counteract the huge acceleration experienced in the previous update.

Implementing RK4 had improved the situation over Euler, but not eliminated  the problem. The game I am working on requires bodies to fly very close to other bodies and still behave correctly.

Any potential solutions?

Edit

One the the answerers, @Thelvyn suggested using fixed elliptical orbits, but that is not an option here as the planets can interact gravitationally. Also, yes I am using a fixed timestep.


texts: How can I place a ProgressBar in Android using Cocos 2d?

texts:
I want to place a horizontal progress bar in my Android application and I want to change its progress color. I used the following code, but the progress bar is not being displayed.

CCProgressTimer progressBar = CCProgressTimer.progress("progressbar.png");
progressBar.setType(kCCProgressTimerTypeHorizontalBarLR);
progressBar.setScale(5);
progressBar.setAnchorPoint(CGPoint.ccp(0, 0));
progressBar.setPosition(CGPoint.ccp(0,0));
addChild(progressBar);


texts:
I have an app that's currently working with a single stage but i need to add a side display/section as a HUD, with scores/lives etc on it, so that the HUD is on the left, and the main hand screen on the right. The main game screen will be fixed and will not move around.

From researching I've found a couple of solutions.

1 - two stages 2 - a group with two groups to it, possibly using a horizontalgroup 3 - two cameras one stage 4 - one stage, one camera, but changing the position of the camera for each set of actors.

I think, option 1 is my preference, but i have some questions.

Do stages always fill the whole screen, or can i start then where i want? This would make it easier for the right hand screen to calculate positions based on 0,0 of that screen rather than always having to add the width of the HUD on to any calculations.
Do i need to work about viewports? Currently I'm not using one (which i think means my stage is set to scaling by default) but nothing looks stretched as a result of this. I don't know much about viewports, but there always seems to be a compromise to be made with them, i.e. black bars top or sides.
If I have two stages, do they each have their own camera? Do I need to with about this? Can I possibly aim the right hand camera at an offset so i can still draw things from 0,0 with that being the bottom left corner of the right stage, not the whole screen?
Finally, off topic, I am a little confused about spritebatch. I'm not currently using one, because I use a stage. Is that OK, or should i still be using one in conjunction with a stage somehow? And add all my actors to that?


texts: Is it possible to add touch screen functionality to a Windows Standalone build for a Surface Pro?

texts:
I have an application which is currently PC/ Windows Standalone, however I need it to be able to work with the touchscreen on a Surface Pro tablet when the same build is run on here. The interaction the user has is that of clicking buttons to open and close windows etc (all buttons use the OnClick() functionality), so any input required would just be simple button taps.

I simply need this to work on a Surface Pro touchscreen display when it is run on there, so mouse clicks to be replaced with taps of the buttons.

I've read many posts on the subject, but many are from Unity 4.6 and nothing conclusive for Unity 5. Many posts I found stated that this feature was introduced for Unity 5, but others suggest it is not supported and third party plugins are needed.

I don't currently have access to a Windows touch screen device, so am unable to do a quick check. I therefore want to make sure it is possible before I purchase a device and commit to the update.

From what I gather, the 'Standalone Input Module' has now replaced the 'Touch Input Module' which apparently had a checkbox to tick if you wanted to have it work in Standalone. As such a checkbox does not exist in the former, I am unsure whether this feature is still supported.

So I would like to know -

Is it supported in Unity 5?

If so -

Does it 'just work' automatically or does extra work need to be done to tell it to use touch screen if it is running on a Windows touch screen device?

Many thanks in advance


texts: Is it possible to import UV-maps in Unity3D without manually importing the associated texture?

texts:
When i import an object from Maya with a defined UV-map i have to manually import the texture (image) and assign it to the material.

Is there a way to keep the materials texture reference from Maya when importing into Unity?


texts:
Suppose one is working on a game which has more than one component of code where the data, view, and logic is disjoint from the workings of another component of code (i.e. all games have a main menu and the game itself, with their looks, logic, and data being independent). How best should one lay an application out?

I see at least two options:

Top-level code creates model, view, and controller objects which then each have fields of each area of the application. For example, the model object may have a menuData field and a gameData field. Each of the view and controller would also have something similar. Additionally, the main controller would have access to the main view and main model.
Top-level code creates an object for each area of the code (i.e. menu and game), and then each of these has their own model, view, and controller.

Are either of these the best way to go about this? Is there a more common approach than MVC?


texts:
I have a scene in my game that takes place in a subway. I created a NavMesh so I can easily have the enemies chase the player. There seems to be a problem though as them enemies sometimes have a problem crossing the track. When looking at the NavMesh it appears that some parts of the track stick out above the NavMesh and I believe this is the reason the enemies sometimes have problems crossing the track. I have tried changing the step height up and down but that doesn't seem to change anything. What can I do to make the NavMesh cover the track in all spots so enemies can cross the track anywhere? Or is there maybe something else causing the enemies to not be able to cross the track in some spots?

EDIT

The rails and the ground are the same object and it is set as Navigation Static. Do they need to be 2 different objects for this to work?


texts: UNITY 3D - Get X and Y components relative to a value and an angle

texts:
I have an algorithm, that, once the gameObject collides with a trigger, a method is called, on which the current collectibles (almonds) picked are instanciated around the circular area of the gameObject on the (x,y) plane. The spawning distribution is correct (at least that seems to be). The problem is the translation, I want to push each almond relative to the Y Axis of the object, so I figured out that with geometry I could take both x, y component for a vector with the angles, then to pass that Vector3 to the DOMove method (I am also using DOTween).

Maybe the approach isn't the right one, or maybe the trigonometric functions change relative to the position.

Here is the code that spawns and translates each almond:

public void takeAlmondsAway() //Will take as parameter the current position of the nerve impulse when it's backed after collision...
{
    int quant = gm.getAlmondsScore(); //The quantity of almonds that will be taken away from the player, relative to the almonds score, duh...
    float angle = 360 / quant; //The angle distribution each individual almond will have when instanciated, the iterator will multiply the angle...
    GameObject[] almonds = new GameObject[quant];
    Vector3 tempMov;
    float tempX;
    float tempY;
    int distance = 1;

    for(int i = 0; i < quant; i++)
    {
        Quaternion rot = Quaternion.Euler(0, 0, (angle * (i + 1))); //The i jump will be necessary here since we care about the i values from 1 to 'quant'

        if(rot.z > 180) rot.z -= 360; //Since the transform rotation goes from 180 to -180, we have to caompensate it with the minus 360 to get the inverse...

        almonds[i] = (GameObject)Instantiate(almond, this.transform.position, this.transform.rotation);
        almonds[i].transform.localRotation = rot;

        //Trying to, based on the prediction distance vector, determine the x & y components needed for the DoMove parameters...
        tempX = Mathf.Cos((angle * (i + 1)) * Mathf.Rad2Deg) * distance;
        tempY = Mathf.Sin((angle * (i + 1)) * Mathf.Rad2Deg) * distance;

        Debug.Log("X: " + tempX);
        Debug.Log("Y: " + tempY);

        //tempMov = new Vector3(almonds[i].transform.localPosition.x, almonds[i].transform.localPosition.y+5, almonds[i].transform.localPosition.z);
        tempMov = new Vector3(tempX, tempY, almonds[i].transform.position.z);

        almonds[i].transform.DOMove(tempMov, 0.5f);
    }
}

Thanks in advance!


texts:
I have been struggling to find an algorithm to implement something that will make a direction oscillate within a cone constraint, in a helix-shaped fashion as in photo (it will always go back to the centre after traveling toward the boundaries of the constraint, it doesn't have to hit the max amplitude everytime).
Do you know any algorithm that does this?

EDIT: My mind is telling me that this is somehow similar to a gravity pull but I don't know how to ensure that it always goes back to the centre.


texts: How can I add a sprite to gameobject to make the gameobject highlight?

texts:
When I'm running the game and then moving the mouse cursor over the menu it's highlighting it with some blue color: In the screenshot the OPTIONS is highlight.

Now I want to use the same highlight sprite to highlight the word THE in white at the top in the screenshot but to make it highlight all the time without the mouse cursor.

I have New Text in the Hierarchy and in the Assets I have Select and Select is the sprite I want to highlight with the word THE:

I tried to add a Sprite Renderer component to the New Text but the New Text have already a Mesh Renderer so I can't add the Sprite Renderer.


texts: Game not accepted in Google Play even though it's built in 64 bit (Unity)

texts:
I tried building my game according to the google play rules, but I get the following error message:
"This release is not compliant with the Google Play 64-bit requirement

The following APKs or App Bundles are available to 64-bit devices, but they only have 32-bit native code: 1.

Include 64-bit and 32-bit native code in your app. Use the Android App Bundle publishing format to automatically ensure that each device architecture receives only the native code that it needs. This avoids increasing the overall size of your app."

According to the documentation (https://developer.android.com/distribute/best-practices/develop/64-bit) for Unity I should get a working version when I do:

Set Scripting Backend to IL2CPP
Select the **Target Architecture > ARM64 checkbox
Build as normal

I've built the game both as APK and as AAB, but neither are accepted. I am using Unity 2018.3.14f1.

I have downloaded this NDK: https://dl.google.com/android/repository/android-ndk-r16b-windows-x86_64.zip and put the content to: C:\Users\MyName\AppData\Local\Android


texts: XInputDotNet not working when building for UWP in Unity

texts:
I am working on a game where a controller has to vibrate. I have found the XInputDotNet plugin which worked very well in the editor and a normal windows build, but if I build for UWP (both Xaml and D3D) the controller doesn't vibrate.

When building in unity for UWP it also gave me an error saying this:

Plugin 'XInputInterface.dll' is used from several locations:
Assets/Plugins/x86/XInputInterface.dll would be copied to
<PluginPath>/XInputInterface.dll
Assets/Plugins/XInputInterface.dll would be copied to
<PluginPath>/XInputInterface.dll
Plugin 'XInputDotNetPure.dll' is used from several locations:
 Assets/Plugins/x86/XInputDotNetPure.dll would be copied to
<PluginPath>/XInputDotNetPure.dll
 Assets/Plugins/x86_64/XInputDotNetPure.dll would be copied to
<PluginPath>/XInputDotNetPure.dll
Please fix plugin settings and try again.

UnityEditor.Modules.DefaultPluginImporterExtension:CheckFileCollisions(String)
UnityEditorInternal.PluginsHelper:CheckFileCollisions(BuildTarget) (at
C:/buildslave/unity/build/Editor/Mono/Plugins/PluginsHelper.cs:25)
UnityEditor.HostView:OnGUI()

The only way I found to remedy this is by deleting one of the plugin folders.

I tried manually copying the ddl's to the build folder, but this didn't help. I tried using the 32 bit dll's and the 64 bit dll's, I tried building for x86 and x64 and I tried all three modes in visual studio(Debug,Master,Release).

I found some links to the Windows.Gaming.Input namespace, but I dont't know if it is possible to add this namespace to unity and if so how.

Does anybody have an idea how to fix my problem?


texts: In Unity, how can I modify the shape of a sprite?

texts:
I am new to Unity and programming in general, however, I wanted to know how to change a sprite's shape. I want to do this while the game is running, so I was thinking about removing a set of pixels given some condition after an event has happened and then adjusting the collider around the object. However, I don't know how to do this. I have searched in YouTube and Google but so far I have not found anything that is useful to me.

My first thoughts were to make the pixels in a sprite's texture transparent given a condition, and I was able to achieve this, but when the time came to translate the texture into the shape of the sprite I failed miserably. Then I thought about using meshes, but I think that meshes might be too hard on the engine and cause some slowdown. I want to make a digging game where I can dig through many different objects and those are my ideas thus far. If you think there are better ways or know of a place where I can learn or, ideally, were willing to give me some coding techniques in C# for achieving the above, I would be very grateful.


texts: mouseButton.y and mouseButton.x is -858993460 for every event except MouseButtonPressed

texts:
Using SFML, every event type will produce a large negative value for x and y of -858993460.

if (menuEvent.type == sf::Event::GainedFocus
    || menuEvent.type == sf::Event::LostFocus
    || menuEvent.type == sf::Event::KeyPressed
    || menuEvent.type == sf::Event::KeyReleased
    || menuEvent.type == sf::Event::MouseEntered
    || menuEvent.type == sf::Event::MouseMoved
    || menuEvent.type == sf::Event::MouseButtonReleased
    || menuEvent.type == sf::Event::MouseButtonPressed) {

    return HandleFindExit(menuEvent.mouseButton.x, menuEvent.mouseButton.y);
    // Except for when menuEvent.type is MouseButtonReleased
    // or MouseButtonPressed x and y will be -858993460
}

I am wondering if this is an intended result or am I attempting to use these events incorrectly?

It seems to me there is a use case for knowing the position of the mouse cursor on MouseMoved, for example so you can have a button change to a different sprite as if you are hovering over it.


texts: Having trouble with grouping in 3D Studio Max

texts:
I'm using 3D Studio Max 2012. I've got a simple mesh and several other polygons and I want to group everything all together. But the option is greyed out, I can't actually select 'Group' under the menus.

I've tried exploding and collapsing the mesh but nothing seems to work.

How can I group them together, what things can I do to try to diagnose the problem?

EDIT:
My object hierarchy looks weird:

scene root:
 . object 1
model:
 - object 2 ... 99


texts: Fastest way to render image data from buffer

texts: Currently I am doing my rendering by using a 3D array window_width x window_height x rgb as a buffer, then looping through the buffer and plotting pixels on screen using SDL2 (SDL_RenderDrawPoint). I know this is horrible and stupidly slow but I am not well experienced in graphics techniques. What is the better way to do this?


texts: How can I recreate the camera used in Swordigo game?

texts:
What sort of camera does the Android game (2.5D) Swordigo uses? Is it an orthogrpahic camera? I think it is an angled orthographic projection.

How can I recreate that sort of camera in Unity?


texts: Is it possible to develop a game with Lua/Löve and have the source code compiled?

texts: I've been looking at Lua and Löve for developing simple 2D games. But since Lua is interpreted and I know it can be compiled to some point, but how secure is that to decompiling. Or is there a better way to distribute the game?


texts: Godot: How do I create a temporary invincible state or invincibility frames?

texts:
My issue
I have been racking my head around how to achieve invincibility frames. Working in the Godot Engine I have considered a few methods for this:

Setting a Timer Node when damaged to trigger the invincibility
setting a knockback variable, converting it into an int which is then multiplied by the movement vector.

move_dir * int(self.knockback)

Each of these runs into the problem of how do I return the state back at a set interval to prevent some sort of ping-pong effect when many enemies are present.
there likely is something better that I haven't yet considered for this, but I just want to know what else is out there for this. Any algorithms or techniques will be welcome. I just want to help get the end of this.


texts:
I got an OpenGL Context Working in SDL, and I'm trying to set it up so I can render with pixel coordinates of the screen. I got this trying to fill the entire screen with a white rectangle:

glViewport(0, 0, MonitorWidth, MonitorHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, MonitorWidth, MonitorHeight, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glColor3f(1, 1, 1);

glBegin(GL_QUADS);

glVertex2f(0, 0);
glVertex2f(MonitorWidth, 0);
glVertex2f(MonitorWidth, MonitorHeight);
glVertex2f(0, MonitorHeight);

glEnd();

It doesn't work, and the entire screen appears black. What's wrong with this?


texts: How to properly use Unity component approach?

texts:
It may sound like an opinion-based question, but I feel like I am not alone with such problem and this may help others too. I spent a lot of time trying to understand how to make things Unity-way, use the best of the component approach. I read almost everything I can get access to and watched every presentation that I found. But at the end I found myself very confused when it comes to implementation of all this abstract ideas that people were talking about. The last thing that I did not try is asking a question here.

Also I want to mention that I have an experience in programming (mostly OOP) and I am aware of different design pattern, difference between component approach and inheritance, Unity EC vs ECS and all that things. But when it comes to practice with Unity it seems like I am missing something. I will show you an example:

Component approach encourage us to make components small and independent. So we can composite objects from this components easily. I like this idea very much.
I decided to make a 2d roguelike to try this approach.

Firstly, I was thinking of what components do I need and there are some from my list:

Solid
Move
Health
Activate

So besides Transform and SpriteRenderer:
Wall has Solid and Health component. Actor has Solid, Move and Health component. Door has Solid and Activate component. Floor will be empty.

I decided that all objects in my game would be just containers of components, no specific names or tags. Objects interaction logic will be based just on components that object has. In other words, when object with Move components will try to move on specific tile I should somehow get all the components on that tile and then do some logic like (some crazy pseudocode):

Move(x, y) {
    components = getAllComponentsAtCoordinate(x, y);

    if (there is health component in components)
        component.TakeDamage(); //attack
        return;

    if (there is activate component in components)
        component.Activate();
        return;

    if (there is no solid components)
        startMoving();
}

And I got stuck at this point. I thought about using raycast to get all objects at the specific coordinate and then get all components from them in some array. But there gonna be too many GetComponent(); methods and this just feels like a wrong way to do it (because getComponent is an expensive operation in Unity).

Or I can use a data structure, that will represent a cell like:

Cell {
    bool passable;
    Actor currentActorStandingHere;
}

(+ inheritance for destructible walls)
and then access this cell directly and wrap my logic around this (that how I usually do it in OOP) -- but I will lost all that component prettiness. All objects are now hardcoded (also I dont think that this approach will make use of Unity inspector and all that stuff, because this will be plain c# classes representing the model).

So my question is: how can I use Unity component approach to handle this situation? May some sort of event system help here? Or am I solving this problem a wrong way? I just want to understand how components works in real life. But almost all Unity tutorials that I found were using strong dependencies between components and it seems like it violating the main principle of how unity was made.

Thank you for your attention


texts: Is there an IDE that can simplify the process of creating a game matchmaking website?

texts:
Yes, I'm an old guy. And I'm well versed in "C" and have written several games which I have been selling on the web for a number of years. And now, I would like to adapt one of my games to be "online". Sounds simple. I'm sure I can use the thousands of lines of "C" code that I've already written. Right?

So my initial investigation begins. First, I think I'll need a server program that lives on a dedicated server (or a VPS probably) that talks to a bunch of client applications that live on individual devices around the world. I can certainly handle that! (I think to myself). I'll break up my existing game into two pieces, a client piece that is just the game displays and buttons, and a server piece that does everything else. Piece of cake, right?

But that means that the "server piece" must be executed on a remote machine somewhere and run 24/7. Can I do that? [apparently, that question is so basic, so uneducated, and so lame, that nobody has ever posed it before. Because hours of Googling does not yield an answer. Fine. I'll assume I can do that and move on.]

I'll need a "game room", which to me means a website where you log in and then go to a lobby of some kind where you can setup your preferences, see if any of your friends are connected, and create or join games. Should be easy, but it's not. No way. Can I do all this with my local website builder? (which happens to be 90 Second Website Builder, a nice product, btw). It turns out, I can not. I can start with that, but must modify each page, so I can interact with my sql database. So I begin making each page a "PHP" page and dynamically modifying the HTML code with PHP code.

I'm already starting to get a headache.

Because the resulting web pages looked terrible, I began looking at using JQuery. I want to user a JQuery dialog on my website to display a list of friends and allow the user to select one to invite to the game. [google search for "how to populate a JQuery dialog from a sql database" yields nothing but more confusion.]

Javascript? Java? HTML? XML? HTML5? PHP? JQuery? Flash? Sockets? Forms? CSS? Learning about each one of these, and how they interact with each other and/or depend on each other is too much for my feeble old brain.

Can anyone simplify this process for me? Is there an IDE that will help me do all this without having to go back to college for a few years?

Thanks,
Scott


texts: How to create a XNA texture from a GDI Image with source rectangle?

texts:
A Texture2D in XNA can only hold so much. Depending on which profile I use that limit is either 2048 or 4096 pixels wide. As far as I could tell from my research (someone correct me if I'm wrong) GDI Images do not have any limitation other than not exceeding the user's memory.

I'm looking for the most efficient way to take a GDI Image and a source rectangle (within XNA's size limitations) and create a new Texture2D from that data at runtime. The process must also take into account XNA 4.0's pre-multiplied alpha!

OR...

A way to take Texture2D.FromStream and adapt it so that it takes a source rectangle too, as that would be even better for my needs.

The requirements are:

No content pipeline, I need to be able to load them at runtime.
Using only Reach profile if possible!
Only care about Windows. Don't worry about portability.

TL;DR:

I need a method such as:

Texture2D Texture2DHelper.FromStream(GraphicsDevice, Stream, SourceRectangle);

Or

Texture2D Texture2DHelper.FromImage(Image, SourceRectangle)

Preferably the first.

Big picture:

Ignoring the source rectangle for a moment (to make things easier to visualize), I've tried loading a whole texture in GDI and passing the data to a Texture2D using a completely a brute-force approach:

using (System.Drawing.Image image = System.Drawing.Image.FromFile(path))
{
    int w = image.Width;
    int h = image.Height;
    System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(image);
    uint[] data = new uint[w * h];
    for (int i=0; i!=bitmap.Width; ++i)
    {
        for (int j=0; j!=bitmap.Height; ++j)
        {
            System.Drawing.Color pixel = bitmap.GetPixel(i, j);
            Microsoft.Xna.Framework.Color color = Color.FromNonPremultiplied(pixel.R, pixel.G, pixel.B, pixel.A);
            data[i + j * w] = color.PackedValue;
        }
    }
    _texture = new Texture2D(device, w, h);
    _texture.SetData(data);
}

And the result was really slow. It took many many times longer than simply doing:

Texture2D.FromStream(GraphicsDevice, new FileStream(path, FileMode.Open));

I also thought about using Bitmap.LockBits and a Block Copy but doing that would leave out the pre-multiplied alpha correction, and I don't know how to apply it after the copy.

I'm tempted to think that a better solution would be to work around Texture2D.FromStream directly... I'm not too familiar with how Stream works but I've seen some methods in .NET that take a Stream and a Rectangle. How would I achieve something like that? Either an entirely new FromStream method or a wrapper around any Stream that provides "Rectangle" functionality.


texts: Smooth+Flat shaded meshes cause shadow artifacts (understanding the source of the problem)

texts:
I'm using blender to create assets to use in Unity3D, and I'm having some trouble understanding how the smooth/flat shading interacts with shadows, I'm sorry if it has been asked before, but all the "related" answers refer only to the shading of the object itself, not the shadow it casts.

I'm a 3D artist, I do not understand Unity and the mechanics behind it the same way I understand 3D stuff, I'm also trying to understand if the problem lies in the 3D object or some configuration in Unity.

I'm using a real time directional light.

1 and 2 are flat shaded. 2 has open geometry while 1 has closed geometry, both have such artifact but it's clearly seen on 2.

3 and 4 both have closed geometry. 3 is fully smooth shaded while 4 is flat shaded.

Solution A: Mess around with Bias and Normal Bias. With Normal Bias at 0, the shadow artifacts are gone but the mesh itselt gets some other artifacts.

Solution B: Use Two-sided shadows, this method completely fixes the problem, in any situation, but it adds another draw call and makes it more expensive (I'm not 100% sure it does) - is this an optimal solution?

This same issue was discussed in a closed group but no one could give me a conclusive answer. However, someone who works with 3DS Max said that exporting a mesh with proper smoothing groups does not result in these artifacts, I tested that in 3DS Max and it did not work - I think I did it the right way, but I'm not 100% certain.

For all the proposed methods, I tested several times, with diferent mesh/modifier and exporting options. I'm using mostly .fbx but I also tested in .obj format (which includes a specific option for smoothing groups in blender).

Smooth shaded objects work perfectly, flat or smooth+flat shaded objects result in this drama.

Please help me to bring light to this issue, I might be blind to some obvious aspect, I'm confused because in the other discussion I was presented with contradicting arguments without conclusive proof of anything. Now I don't know if the problem lies with Blender/export or Unity configuration.

Let me know if I can provide more information.


texts: Display crosshair that is diplaying where the ship is aiming at

texts: I am creating a 3D asteroids game. I got the bullets, asteroids, and ship all done. They work perfectly. Now I want a crosshair to display where the ship is pointing at. The crosshair will be a 2D sprite.


texts: Volumetric lighting not working when building and running game

texts:
I have a volumetric lighting system implemented into Unity and when I am making the game and run it in the Unity editor the volumetric lighting shows up. When I build it and run it though it doesn't.
I think this is caused because it has not exported the script with the volumetric lighting so I exported it again and it still didn't show. I dont know what is up. Any suggestions would be appreciated.
In Unity with the thing working:

Unity built game:


texts:
So I have this tile-based game (something like Farmville). As "tile-based" implies, the save data could potentially become very large. Game saves are stored on cloud, and any change to the save data forces me to send the whole save file to the game client, which you can imagine is terribly inefficient if the changes are very small (changing even a single tile will trigger sending of all the save data).

I'm looking at the possibility of version control to mitigate the network load. In this solution, I imagine that:

The client sends the server a version number.
The server matches the number to an older version of the savefile and compares it with the latest version.
The server sends a diff file back to the client, which uses it to interpret and re-produce the latest version, along with the latest version number for future reference.

How can I implement this?


texts: What popular/famous games are written in C?

texts:
It is very similar to this question: https://gamedev.stackexchange.com/questions/3789/famous-games-written-in-java

Does anyone know of any popular or famous games only written in C?


texts: How can I get multiple sprites on a Unity2D Sprite Renderer

texts:
I have a GameObject that I want to have multiple sprites.  I tried adding an extra Sprite Renderer, but it tells me I can't add the same component multiple times.

I'd really rather not have to have four GameObjects just to display this thing correctly.

For example, I would want to have a tile background, a tile artwork, a tile character, and a nice shine on the top.  If I were to make that all a single image, I would have to export nearly a thousand images to get all possible combinations.

Tile Background:

Tile Artwork:

Tile Character:

Shine (Barely visible):

Everything put together how I want it in-game:


texts: Standard decibel range for sound effects/music?

texts:
Is there a standard for a decibel range of sound effects and music in games?

I've been getting sound effects from various sources and some are much louder than others so I've had to adjust them with Audacity to be closer in volume.

Of course the user can just adjust their volume up or down if it's too loud/quiet but I'd prefer that my game's audio be in the same range as other games

(Note: specifically I'm asking for iOS/mobile games but this could apply to other systems)


texts:
I'm currently working on A* pathfinding on a grid and I'm looking to smooth the generated path, while also considering the extent of the character moving along it. I'm using a grid for the pathfinding, however character movement is free roaming, not strict tile to tile movement.

To achieve a smoother, more efficient path, I'm doing line traces on a grid to determine if there is unwalkable tiles between tiles to shave off unecessary corners.

However, because a line trace is zero extent, it doesn't consider the extent of the character and gives bad results (not returning unwalkable tiles just missed by the line, causing unwanted collisions).

So what I'm looking for is rather than a line algorithm that determines the tiles under it, I'm looking for one that determines the tiles under a tile-wide extent line.
Here is an image to help visualize my problem!

Does anyone have any ideas? I've been working with Bresenham's line and other alternatives but I haven't yet figured out how to nail this specific problem.


texts:
I have an object with a capsule collider on its root, with IsTrigger=true (triggered by the player). The trigger works fine, but is also triggered unexpectedly some times when the player walks near the collider, but still way out of its range.

See attached image: the capsule collider limits are wel within the round circle object. On the right you see that the player has triggered the trigger, while it was far away from the collider.

When I run circles around the collider, this will happen sometimes. Location appears to be random and it doesnt happen if the player is further away than say 10 meters.

Anyone else have this issue or can tell me what is causing it?


texts: How do I handle window resizing in SlimDX?

texts:
I'm considering the use of SlimDX in a managed Windows Forms Application. Available with DirectX is DXUT. I use DXUT to handle events such as window resizing and 'lost devices.'

How well does SlimDX account for these occurrences? If I were to use SlimDX, how would I account for the functionality of DXUT in managed code?


texts: Algorithm to generate random shapes that fill up a rectangle?

texts:
The final result can be like this

I've thought up several approaches:

Generate random curved lines to "cut" the rectangle (or generate random dots and form the line from the dots)
Break the rectangle with Fracture Voronoi algorithm and shrink the broken parts to make the curved lines thicker.
Generate random shapes and let it fall into the rectangle like the game Tetris

But before implement the ideas, I want to know if there is an algorithm (with pseudo code) to generate random shapes that fill up a rectangle?


texts: How can rotate a 2D textured quad in legacy OpenGL immediate mode?

texts:
I have a texture of a tank, and I want to it appearance on the screen depends on its current direction, so I decided to use rotating texture functions of OpenGL. I followed some advices through Google and received unsuccessful results. Anyone can help me with this problem?

This is my render() function:

#define UP 0
#define DOWN 1
#define LEFT 2
#define RIGHT 3

void GameObject::render()
{
    glBindTexture(GL_TEXTURE_2D, textureID);
    glLoadIdentity();
    glTranslatef((GLfloat)coord.getX(), (GLfloat)coord.getY(), 0.0f);
    glDrawArrays(GL_QUADS, 0, 4);
}


texts: GLM: Camera attached to model moves in opposite direction from the model

texts:
I have been working on a component based engine with nested game objects each with there own transformation's. Each game object calculates its position in the world based on its parents world transformation multipled by there own local one (ModelsWorldTransform = ParentsWorldTransform * LocalTransform).

This all works great until I attach the camera component to a model and in this scenario, as the model the camera is attached to moves away from the origin, the camera moves in the opposite direction to the movement whitest still seeming like it is in the correct position according to its mat4.

All local transformations are stored in a mat4 rather then three vec3's for position, rotation and scale to save on calculations each update having to generate new mat4's.

Transformation Component Update Code

m_world_transformation = m_local_transformation;
// If we have a parent object
if (m_parent_transform_component)
    m_world_transformation = m_parent_transform_component->GetWorldTransformation() * m_world_transformation;

Camers position buffer being updated

BufferData.view = m_transformation_component->GetWorldTransformation();
m_camera_buffer->SetData();

I'm not sure what i'm missing, if anyone has any sugestions that would be apreatiated.


texts: Screen Space reflections not tracing correctly - GLSL

texts:
I've been trying to implement screen space reflections for the past couple of days, however it's been difficult finding specific implementation instructions or guides.

Most of the hits on the subject that I can find relate to UE4 or Unity, or a sample implementation in HLSL derived from GLSL work both using different coordinate systems for the y and z axes.

Following what little I could find, I've been using the following shader:

#version 430

layout (std430, binding = 2) buffer Camera_Frag
{
    mat4 pMatrix;
    mat4 InvPMatrix;
    vec2 ScreenSize;
};

uniform sampler2D ViewNormalMap;
uniform sampler2D DepthMap;
uniform sampler2D LightMap;

in vec2 TexCoord;
layout (location = 0) out vec4 FragColor;

vec2 RayCast(vec3 dir, inout vec3 hitCoord, out float dDepth)
{
    dir *= 0.25f;

    for(int i = 0; i < 20; ++i) {
        hitCoord               += dir;

        vec4 projectedCoord     = pMatrix * vec4(hitCoord, 1.0);
        projectedCoord.xy      /= projectedCoord.w;
        projectedCoord.xy       = projectedCoord.xy * 0.5 + 0.5;

        float depth             = texture(DepthMap, projectedCoord.xy).r;
        dDepth                  = hitCoord.z - depth;

        if(dDepth < 0.0)
            return projectedCoord.xy;
    }

    return vec2(0.0f);
}

void main(void)
{
    vec3 View_Normal            = texture(ViewNormalMap, TexCoord).xyz;
    float View_Depth            = texture(DepthMap, TexCoord).r;
    vec3 ScreenPos              = 2.0f * vec3(TexCoord, View_Depth) - 1.0f;
    vec4 View_Pos               = InvPMatrix * vec4(ScreenPos, 1.0f);
         View_Pos              /= View_Pos.w;

    // Reflection vector
    vec3 reflected              = normalize(reflect(normalize(View_Pos.xyz), normalize(View_Normal)));

    // Ray cast
    vec3 hitPos                 = View_Pos.xyz;
    float dDepth;
    float minRayStep            = 0.1f;
    vec2 coords                 = RayCast(reflected * max(minRayStep, -View_Pos.z), hitPos, dDepth);

    FragColor                   = textureLod(LightMap, coords, 0);
}

I get the scene projected further down, but it isn't upside down. Notice the vases and the plants on top of them. Its like the scene gets resampled and pushed downwards.

Can anyone help me understand why I'm not getting the expected results?
I've never done any raytracing before, so perhaps I'm misunderstanding how this is supposed to work.


texts: When to destroy Google AdMob InterstitialAd object?

texts:
There are a few answers on this question but they don't give a satisfactory answer.

I am using a singleton AdManager class that persists throughout the game. I am not sure if I should destroy the instance of InsterstitalAd each time after displaying an ad. This answer says that an InterstitalAd object can only be used once, however in my current implementation I use the same instance multiple times without any ill effect.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using GoogleMobileAds.Api;

public class AdManager : MonoBehaviour
{
    public InterstitialAd interstitialAd;
    private string InterstitialAdId = "test-code";
    public static AdManager Instance = null;

    void Awake()
    {
        MobileAds.Initialize(initStatus => {});
        RequestInterstitialAd();
        SceneManager.sceneLoaded += OnSceneLoaded;

        // Singleton class
        if (Instance == null) {
            Instance = this;
        } else if (Instance != this) {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }

    void OnSceneLoaded(Scene scene, LoadSceneMode mode) {
        DisplayInterstitialAd();
    }

    public void RequestInterstitialAd() {
        interstitialAd = new InterstitialAd(InterstitialAdId);
        interstitialAd.OnAdClosed += HandleOnInterstitialAdClosed;
        interstitialAd.LoadAd(new AdRequest.Builder().Build());
   }

    public void HandleOnInterstitialAdClosed(object sender, EventArgs args) {
        interstitialAd.LoadAd(new AdRequest.Builder().Build());
    }

    public void DisplayInterstitialAd() {
        if (interstitialAd.IsLoaded()) {
            interstitialAd.Show();
        }
    }

    public void DestroyInterstitialAd() {
        interstitialAd.Destroy();
    }
}

As I understand the InterstitalAd object refers to a UI element, while the actual content of the ad comes from AdRequest, so I can reload the ad content without affecting the InterstitalAd object. Do I need to call DestroyInterstitalAd() after each time after an ad is displayed? I want to prevent any memory leaks from happening during long plays.


texts: How can I manually draw a Sprite in Unity?

texts:
I'm creating a simple workaround on the unsupported prefab-on-prefab.

I've thus created this simple class:

[ExecuteInEditMode]
public class PrefabLinker : MonoBehaviour
{
    public GameObject prefab;

    private GameObject spawn;

    void Awake ()
    {
        #if UNITY_EDITOR
        if (!EditorApplication.isPlaying)
            return;
        #endif

        spawn=(GameObject)Instantiate(prefab);
        spawn.transform.parent=transform.parent;
        spawn.transform.localPosition=transform.localPosition;
    }

    #if UNITY_EDITOR
    void Update ()
    {
        if (EditorApplication.isPlaying)
            return;

        // Manually draw the Sprite

    }
    #endif
}

However I've no clue on how to manually draw the Sprite, without adding it to the scene.
Obviously I can't add it to the scene like I do when I play it, because otherwise the spawn would be saved in the prefab, polluting it and creating a mess.

I'm hesitant to add the spawn to the scene "somewhere else" and updating its position, because I'd like to prevent the level designers from mistakenly move this spawn instead of the PrefabLinker object.

This only needs to work with 2D stuff. I've found this link which I guess does something similar to my needs, but I've no idea how to fix it to work with sprites (and doesn't work out of the box).


texts: If I want to create a top-down 2D game should I rotate the camera?

texts: Do I have to rotate the camera to top-down view if I want to crate a top-down 2D game or just disable gravity?


texts:
I love XNA. I really do. As president of the Game Development Club at my school, we use it and I teach it. But I'm worried about it.

I've always wondered, are there any signs that XNA will ever become more than just a prototyping/arcade game language? I've always gotten the feeling that Microsoft is on the cusp of abandoning it, like they did Managed DirectX. The Xbox Live Arcade is an amazing idea but it's shoved off to the side, well overshadowed by the "real" Xbox games when I feel like it would've had so much more potential, had Microsoft given it more emphasis.

Now with XNA 4.0 CTP for Windows Phone 7 only, it seems to be morphing into some sort of phone-only thing. I'm really unsure about exactly why they are doing that.

What's the current state of XNA, and where is it headed? Is it going into mobile-only, or will 4.0 eventually be released for Xbox and desktop usage?

In other words, is it a language to invest time and money into, or should it be only tentatively developed on, with the constant fear of abandonment? And when I ask this, I'm talking about desktop and Xbox games, as I can pretty clearly see that it is the game framework of choice for the Windows Phone 7 platform.

Since this question is somewhat subjective (but I'm really looking for facts alongside your opinions!) I am making this a CW.


texts: Raytracer texture mapping (to triangle mesh) leaving artifacts

texts:
So I am trying to get OBJ loading working in my raytracer. Loading OBJs works fine, but I am having some trouble with getting the texture mapping working.

Here is an image of my result. It is supposed to be a black sphere with colored "latitude and longitude" lines, with a black spot in the middle. But it seems like every second triangle is left black. You can see the result here:

My prof said that it looks like the normals are backwards, but I don't think that is the case because the shape is still being hit - and the color of the "wrong" triangles is the color of background color of the texture (ie. black in this case).

When I load the OBJ, each vertex has a UV coord associated with it. What I do to get a UV coord when a ray hits the shape is as follows:

T: the triangle that was hit
hp: where on the triangle the ray hit
v1,v2,v3: the vertices of the triangle, each has a UV coord UV1, UV2, UV3

find the distance to each v[i] from hp (d1,d2,d3 respectively)
find the weight of each of these (w1 = d1/(d1+d2+d3), same for d2,d3)
find the weighted UV coord: UV1/w1 + UV2/w2 + UV3/w3

find the pixel color based on this weighted coord

Does anyone have any ideas what might be going on? I can post parts of my code if you think that would help.


texts:
I'm using this code to make a square that orbits a circle . When I use it however the rect(); is quite far away from the circumference of the circle, I would like to make it closer. All variables are floats. YPos and XPos are the x and y of the circles origin.

charx = XPos[0] + cos(angle)*Sizes[0];
chary = YPos[0] + sin(angle)*Sizes[0];
angle += 0.1;
fill(255,255,255);
rect(charx, chary, 10,10);}

Any idea what I should change?
This is probably something very simple, but I'm very new to Java.


texts: In general, are programmers or artists paid better?

texts:
I'm in a private game programming school where there also are 3D art classes; sadly, there seems to be a lot more students in those latter classes, something like 50% or 100% more.

So I was wondering: in the real video game industry, which of the artist/modeler or the programmer is more likely to be wanted in a company, so who will be paid more ?

I'm sure there are artists which are obviously paid better than other programmers and I'm sure there are other sorts of jobs in the game industry (sound, management, testers), but I wanted to know if there is a general tendency for one or the other. And sometime I wonder even if an artist can happen to write scripts...


texts:
I am using the collision_line_list function to detect all objects of a type.
In this case, the object is obj_CapMan.
Code:
collision_line_list(obj_HatMan.x,obj_HatMan.y,mouse_x,mouse_y,obj_CapMan,false,true,listaCap,false);

This code is in an object that would be equivalent to the game administrator. What should not influence anything, but in any case, is the information.
Full Code:
listaCap=ds_list_create();
listaNum=collision_line_list(obj_HatMan.x,obj_HatMan.y,mouse_x,mouse_y,obj_CapMan,false,true,listaCap,false);

if(listaNum>0){
    instance_destroy(listaCap);
    ds_list_destroy(listaCap);
}

As a result, none of the objects on the list are being destroyed, but another one that is neither the manager nor the obj_CapMan, is being destroyed.
Documentation Link:
https://manual-en.yoyogames.com/#t=GameMaker_Language%2FGML_Reference%2FMovement_And_Collisions%2FCollisions%2Fcollision_line_list.htm&rhsearch=collision_line&rhhlterm=collision_line_list%20collision_line

This red square is an object to detect a headshot.
That same object that is being destroyed, even though it is not mentioned in that part of the code at any time:


texts: Is it possible to copyleft license a game engine and still allow users to sell games made with it?

texts:
I have recently been studying and working on implementing my own game engine. I am interested in making my work open source so that others may use and modify it freely. However, I also want to make sure any modified or improved versions of my engine would also be free to use or modify. This led me to believe a copyleft license would be most appropriate. However, despite wanting all future versions and modifications to the engine source code to be open source, I want people to be able to sell or profit off the games made with the engine. In other words, while the source code of the engine for the sake of the engine itself should remain open source, anything made with the engine for the sake of being played should be allowed to be closed source. Is there an appropriate license for this?

The reason I include the architecture tag is to also ask: If no simple license exists, then is there a way to architect my engine such that what I want to accomplish with licensing is possible? For instance, if my engine uses a scripting language with some entity component system written in the engine's compiled code, then maybe the scripts (which a gameplay programmer using my engine would write to dictate game logic) would be allowed to be closed source? But then anyone playing the game would still require the compiled engine in order to run said scripts. I do not know if this particular example could work, but it is just to give an idea of what I am getting at.


texts: Tips on combining the right Art Assets with a 2D Skeleton and making it flexible

texts:
I am on my first attempt to build a skeletal animation system for 2D side-scrollers, so I don't really have experience of what may appear in later stages. So i ask advice from anyone that been there and done that!

My approach:

I built a Tree structure, the root node is like the center-of-mass of the skeleton, allowing to apply global transformations to the skeleton. Then, i make the hierarchy of the bones, so when moving a leg, the foot also moves. (I also make a Joint, which connects two bones, for utility).

I load animations to it from a simple key frame lerp, so it does smooth movement.

I map the animation hierarchy to the skeleton, or a part of it, to see if the structure is alike, otherwise the animation doesnt start.

I think this is pretty much a standard implementation for such a thing, even if i want to convert it to a Rag Doll on the fly..

Now to my question:

Imagine a game like prototype, there is a skeleton animation of the main character, which can animate all meshes in the game that are rigged the same way.. That way the character can transform into anything without any extra code.

That is pretty much what i want to do for a side-scroller, in theory it sounds easy, but I want to know if that will work well. If the different people will be decently animated when using the same skeleton-animation pair. I can see this working well with a Stickman, but what about actual humans? Will the perspective look right, or i will need to dynamically change the sprites attached to bones?

What do you recommend for such a system?


texts: Circular lighting mask stretches to ellipse in Monogame using Pixel Shader

texts:
I am trying to implement a very simple pixel shader for some basic lighting using this tutorial http://www.xnahub.com/simple-2d-lighting-system-in-c-and-monogame/

My problem is that when the effect is applied the circular gradient ends up looking like an ellipse(left) instead of its circular shape(right).

The technique I use is to have two render targets in monogame and blend them together. The first one is all of the light masks textures, and the second is the render target I want to add the lighting effect to.

I believe the problem is related to the shader itself because when I use this code I get the ellipse(left picture)

//Blend both render targets together onto the backbuffer
GraphicsDevice.SetRenderTarget(null);
GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
effect1.Parameters["lightMask"].SetValue(lightsTarget);
effect1.CurrentTechnique.Passes[0].Apply();
spriteBatch.Draw(mainTarget, Vector2.Zero, Color.White);
//spriteBatch.Draw(lightsTarget, Vector2.Zero, Color.White);
spriteBatch.End();

However, when I comment out the effect and just draw the light render target. I get a nice circle(right picture)

//Blend both render targets together onto the backbuffer
GraphicsDevice.SetRenderTarget(null);
GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
//effect1.Parameters["lightMask"].SetValue(lightsTarget);
//effect1.CurrentTechnique.Passes[0].Apply();
//spriteBatch.Draw(mainTarget, Vector2.Zero, Color.White);
spriteBatch.Draw(lightsTarget, Vector2.Zero, Color.White);
spriteBatch.End();

This is my effect file

sampler s0;

texture lightMask;
sampler lightSampler : register(s1) = sampler_state {Texture = <lightMask>;};

float4 PixelShaderFunction(float4 pos : SV_Position, float4 color1 : COLOR0, float2 coords: TEXCOORD0) : COLOR0
{
    float4 color = tex2D(s0, coords);
    float4 lightColor = tex2D(lightSampler, coords);
    return color * lightColor;
}

technique Technique1
{
    pass Pass1
    {
        PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction();
    }
}

Thanks.


texts: Scanline filling of polygons that share edges and vertices

texts:
In the image below (a perspective projection of an icosahedron),
the scanline (red) intersects that vertex at the top. In an icosahedron each edge belongs to two triangles. From edge a, only one triangle is visible, the other one is in the back. Same for edge d. Also, in order to determine what color the current pixel should be, each polygon has a flag which can either be 'in' or 'out', depending upon where on the scanline we currently are. Flags are flipped according to the intersection of the scanline with the edges.

Now, as we go from a to d (because all edges are intersected with the scanline at that vertex), this happens: the triangle behind triangle 1 and triangle 1 itself are set 'in', then 2 is set in and 1 is 'out', then 3 is set 'in', 2 is 'out' and finally 3 is 'out' and the one behind it is set 'in', which is not the desired behavior because we only need the triangles which are facing us to be set 'in', the rest should be 'out'.

How do process the edges in the Active Edge List (a list of edges that are currently intersected by the scanline) so the right polys are set 'in'?

Also, I should mention that the edges are unique, which means there exists an array of edges in the data structure of the icosahedron which are pointed to by edge pointers in each of the triangles.


texts:
I would like to port this mesh in Unity but in a way that smaller face, which is selected, has emission material and rest of the mesh has albedo material.

I know how to apply material in Blender on different faces but I don't know how to port it in Unity this way.

Updated post: emission texture


texts:
I am a 3D artist, not a game developer but I am interested in dabbling none the less.
Would anybody know the texture sizes currently used for games like WOW or Guild Wars 2?
Don't worry, I'm not trying to make a massive game that takes teams of hundreds, I'm simply interested in the efficiency of MMO type games. From what I can find on the net, it's roughly 512k x 512k textures for the base character although its surprisingly hard to find the information and I don't have the games installed anymore to see if I can check.
And...
If anybody can explain Geo-sets to a noob like me that would be great. My general understanding is that the model is separated into pieces such as head, hands, legs etc then the model with textures swapped some how to show new models and textures for say a new pair of gloves.
Many thanks.


texts:
public GameObject button;

public void Start()
{
       GameObject button1 = Instantiate(button) as GameObject;
       button1.transform.SetParent(canvas.transform, false);
       button1.transform.position = new Vector3(7, 0, 2);
}

I have cloned the button game object now want to add color to that game object how can i do it ?


texts: Unity random.range value not same as last value

texts:
Quick one,

Currently using Unity Random.Range to set a var with the value of an enum state.

State has 4 possible values, up, down, left,right. I call it like :

currentState = (StateType)Random.Range(0, 3);

This gets set at certain conditions.

My issue is though I don't want the new setting to be the same as the current one.

I have taken a look at the random.range on the API but haven't found anything useful.

Is there an easy way to basically say "randomize but not the same as the current state"

EDIT:

Currently im using a while loop.

while (currentState == LastState)
{
    currentState = (StateType)Random.Range(0, 3);
}

Is there anything i can do to remove the while loop?


texts: How to render a texture partly transparent?

texts:
Good Morning StackOverflow, I'm having a bit of a problem right now as I can't seem to find a way to render part of a texture transparently with openGL.

Here is my setting : I have a quad, representing a wall, covered with this texture (converted to PNG for uploading purposes). Obviously, I want the wall to be opaque, except for the panes of glass. There is another plane behind the wall which is supposed to show a landscape. I want to see the landscape from behind the window. Each texture is a TGA with alpha channel.

The "landscape" is rendered first, then the wall. I thought it would be sufficient to achieve this effect but apparently it's not the case. The part of the window supposed to be transparent is black and the landscape only appears when I move past the wall.

I tried to fiddle with GLBlendFunc() after having enabled it but it doesn't seem to do the trick.

Am i forgetting an important step ?

Thank you :)


texts: I want to know that I can connect micromax a100 with the eclipse for android development or not. From other community I found that for development purpose micromax device can not be used. Also I doesn't found any usb driver for that. So please help to come out that.


texts:
I'm trying to make a game where you play basketball as a catapult. Obviously an idea like this leans heavily on the unity physics engine. The cup of the catapult has a bucket on it to keep the ball from falling out. When you hit space, the arm of the catapult spins, which should throw the ball out of the bucket of the catapult. Instead, the ball passes through the cup of the catapult(when it isn't spinning, it acts normally and rolls around the bucket) and then it doesn't fall whatsoever, eve though has gravity is enabled. Here are my physics settings:
The ball

The cup(and also a cup with flipped normals)

The Rim of the bucket

Here's my ball throwing code:
public class BallThrower : MonoBehaviour
{
    private Vector3 axis;
    // Start is called before the first frame update
    void Start()
    {
        axis = transform.position;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Space))
        {
            if (transform.rotation.z > -95.4)
            {
                transform.Rotate(0f, 0f, -5f, Space.Self);

            }
        }
    }
}

What's missing here? Should I make the cup a rigidbody? Let me know if you need more info, Thanks!


texts: Using real football player photo in a trivia quiz game, is it legal?

texts: I don't know whether this question was already been asked before, but my team is currently developing a trivia quiz game about football (soccer not NFL). And we want to put player's images or club emblems as part of the questions and answers. My question is, is it legal? Or should we just put text without the images? Please your help is much needed. Thank you.


texts: I've set up a simple scene with some triangle and quads. With  glPushMatrix() and  glPopMatrix() i achieved to move an object to a new position, relative to another object in my render scene, but what i want is, for example, that the first triangle translates every render() call -2 units on the z axis, but the other triangle translates only -1 unit. I couldn't find any information how to manage this. As yet every glTranslatef() affects all objets. So what I have to do?


texts: How to determine which thrusters to turn on to rotate the ship?

texts:
The configuration of the ship changes dynamically, so I have to determine which thruster to turn on when I want to rotate the ship clockwise or counter clockwise. The thrusters are always axis aligned with the ship (never at an angle) and are either on or off. Here's one of the possible setups:

What I've tried so far is to visualize the firing vector and the direction vector to the center of mass of the ship:

Unfortunately, I didn't get very far with that.


texts:
I recently read this GPU GEMS 3 article Volumetric Light Scattering as a Post-Process. I like the idea to add volumetric light property to realtime render i'm working on. Question is will it work for multiple lights? Our renderer uses one render pass per light and uses additive blending to sum incoming light.

I'm mostly convinced that it have to work nice. Do you agree? Maybe there can be problem where light rays crosses each other.


texts: How to add (not blend) non-looped animation clip to looped animation with Mecanim?

texts:
I have a GameObject with Animator and looped animation clip.
This animation changes X coordinate from 0 to 10 and back.

I need to add another animation to the first one that increases GameObject's scale and changes its color to red simultaneously.

After scale and color change GameObject keeps these parameters and continues to move according to the first animation clip.

The only way I managed to work it around is writing a custom script with couroutine:

IEnumerator Animate()
{
    float scaleDelta = 0.2f;
    float colorDelta = 0.02f;
    for (int i = 0; i < 50; i++)
    {
        spriteRenderer.color = new Color(
            spriteRenderer.color.r,
            spriteRenderer.color.g - colorDelta,
            spriteRenderer.color.b - colorDelta);

        transform.localScale = new Vector3(
            transform.localScale.x + scaleDelta,
            transform.localScale.y + scaleDelta,
            transform.localScale.z);

        yield return new WaitForSeconds(0.02f);
    }
}

This works for linear interpolation, but requires to write additional code and write even more code for non-linear transformations.

How can I achieve the same result with Mecanim?

Sample project link: https://drive.google.com/file/d/0B8QGeF3SuAgTU0JWNGd2RnpUU00/view?usp=sharing


texts: Supported Orientation, Monogame, Windows Phone 8

texts:
I am developing a game in which I need to rotate the screen on Landscape mode or Portrait, and lock it that way.

In Monogame, targeting Windows Phone 8.1 adding this code:

Graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
            Graphics.ApplyChanges();

Was enough, but in Monogame, targeting Windows Phone 8 I can switch from Portrait mode to Landscape, even if I put the code above in the game constructor.

How can I stop/freeze the user from chaning the orientations on a specific category in my game?

Thanks.


texts: Left-Hand and Right-Hand Coordinate Systems

texts:
In Blender and other 3D modeling tools, the coordinate system is right-handed, while in Unity 3D and Orbiter Space Flight Simulator, they are left-handed, why this could happen? Why they don't simply use the right-hand coordinate system all the time to make things easier? Why don't all programs that deal with 3D graphics use Z+ as up?

 Y         |  Z
 ZX        |  YX
RIGHT-HAND | LEFT-HAND
TOP VIEW   | TOP VIEW

(fortunately, Unity3D converts from Blender coordinate system to Unity3D coordinate system)


texts:
Currently, I'm calling glGetError() after each OpenGL function call in order to be able to detect and report bugs.

I've been reading that glGetError() calls should be reduced to once per frame in release builds. But if I do this and something does not work properly I won't be able to report where the code is failing, I would get an exception report saying that something related to OpenGL is not working properly but I wouldn't be able to detect where the code is failing.

What are the most common aproaches to report errors related to OpenGL? Should I keep all the glGetError() calls or should I call glGetError() just once per frame?