text:
Name generation
I'm making a game (or planning to, at least) and to do that, I need a way to automatically generate names for the NPC "bosses" (long explanation and irrelevant here). Something like this is a good example of what I mean.
I have an idea that I can just build a database of names by nationality, maybe first/last pairs, and assign them randomly, with an ignored names list so I don't get something like Homer Simpson and get sued or something.
The problem with that is that I'd need to build up a massive database of names for that to work. It would either take forever or cost money, unless someone has a list of names available for free already.
I have another idea where I make random pairs of vowels and consonants, flip a few, and add them together, but a quick program that does that generated names like these:

Seermeecpa
Cime
Ofmiahwumafi
Gozidi
Effawided

(For anyone interested in the code, you can see it here)
These are... kind of a mouthful. Well, except "Gozidi" -- that one could work. Still, the success rate is clearly not very good.
Is there anything I could do to make the names sound nicer (see below), or should I start making that list? Can I somehow mimic the way humans decide if a name is decent or not, with at least some accuracy? I'd much prefer something like this to a lookup in a big list.
What I mean by "nicer" is that, instead of random combinations of characters (which it is, to be fair), things that sound like actual names. They can be from any culture (or sound like they are), real or imaginary, anything at all, so long as your stereotypical dumb, monolingual American like me can say 'em without too much trouble.
If you need extra clarification, go ahead and ask. I'm not really sure what to put here.
Addendum: So far as I can tell, there really aren't tags that fit this question all that well. If anyone who's been here longer can recommend some, that'd be awesome.

Unfortunately your question seems too broad right now. Different methods of name generation will suit different kinds of names - realistic (also, which culture?), fantasy, sci-fi, aliases etc. Each method has their own strengths and weaknesses - are you asking for a comparison, and on what criterion? How do you personally judge whether a name sounds "nice"? You can improve your question by narrowing it down along these lines.

Thanks! I'll edit it to make it clearer. What I meant, though, was just any name, and pronounceable to the average, monolingual American. Give me a moment and I'll toss that in.

@congusbongus I think I fixed it.

you could try and compose names using various prefixes and postfixes, e.g. the 'ith' from Smith could make names like qith, hith, kith which all sound somewhat reasonable and pronouncable, you could also get a list of names and chop them in half, then replace with the other half of another name. For example Matt would be Ma, and Josh would make Mash

@MatthewPigram That still requires compiling a list of names, which is something I want to avoid. Still, it's a good idea, the pre/postfixes bit.

You could probably take names out of the "deceased" Social Security list.  At one point I found an online, searchable, Japanese dictionary that had Japanese names in it (because of how Kanji is used for names) - those are all pronounceable, when rendered in romaji.  I'd imagine there are lists for other nationalities, too, although you might have trouble with some of them...

@Clockword-Muse The problem with that is that I don't want some disgruntled family member seeing their dead relative's name, getting mad, and suing me. Even if there's no way they could win, and I would get reimbursed for the costs, I can't afford any amount of time in court, and even if I could get a lawyer to work pro bono I'd still rather avoid being sued at all. If it weren't for that, I'd have taken a list of real names. With a list from a random generator I could at least claim deniability, but if I'm taking dead people's names, it's pretty obvious people used to use them.

Most name generators work via some variation of Markov Chain, which are fairly remarkable (remarkovle?) constructs that have many uses in games, as well as other domains.
The basic approach does invoke a list of some kind. These do not need to be fairly huge. The purpose of this list is merely to inform the algorithm what syllables are likely to be paired together for a given category of name.
This allows you to put together different lists for e.g. male names, female names, family names, or names for different cultures/regions/species.
The time you'll spend tweaking an algorithm that randomly assembles made-up syllables into a pleasing fashion is likely going to be more than you'd spend just generating a list of names that you think sound good and fit a common theme.
There are many lists of names available. Download the latest US census database for modern day names easily separated by age, gender, and ethnicity, or grab lists of old Norse names or the like. These are all quite easy to find via Google; that last link was literally my first hit for "list of norse names."

This and again this. Markov chains rule for names, as they can be trained with examples (feed it a database of names you want to sound similar to) and  are even flexible in how closely they match the example names (2-letter chains? 3-letter chains? 4?).

+1 for the stupid pun. Also the great answer, but mostly for the pun. I'll be looking at the Census and seeing if I can't make a list of syllables to use. I'm probably going to end up accepting this, just because it mentions the terminology, as opposed to just describing it.

Most names in languages follow a series of patterns. For example Russian or Greek names may have five or ten different prefixes, thus if you find a name ending with -ov you may suspect its Russian because it kinda fits the pattern.
If you want real names (or real like) I think you should start building your list (which shouldn't be so long) because analyzing real names of some languages, finding their pattern, and creating an algorithm to produce such names is not worth the effort in my opinion.
If you want random names that could be a name in some language, you could build a small list of rules to follow (like a subset of the above). Already, what you are doing is that: you made a rule about vowels and consonants. You could add a few more like surnames should end in these 10 syllables or some consonants can be followed only by vowels like 'q' followed only by 'u' and some others can be followed by other consonants like 's' followed by 't' or 'k'. Again, this is more to create some words that can be actually pronounced and feel a bit real than creating actual names.
Something that may be relevant is the way "Papers, Please" generates names.
http://papersplease.wikia.com/wiki/List_of_names

I feel like this is the best I'm going to get, just from the sheer complexity of the problem. Thanks for the help, even if it's not what I was going for.

In the Papers, Please example, it is noteworthy how the latest changelog entry is not about generating names, but about how to exclude some of the generated names, because they resemble names of real people (possibly not that important; while it may seem slightly confusing to users, there are just too many somewhat known real people to exclude all of their names), because the names resemble undesirable words (might also happen when just combining real first and last names), or because the names are copyright (possibly very relevant, depending on the legislation).

I've changed which answer I accepted because Sean provided a link to a more detailed description, rather than an overview without it, and a link to a list of names I could look at. Thanks for the help, anyway.

I think the easiest way to do this is to use an existing random name generator or an existing list of random names that meet your requirements. Then store it somewhere as a list. When you need a random name, just pick from the existing list at random.

That's what I'm trying to avoid. I want to have a system that can make them on the fly, rather than having to have a list to pick from. Also, I looked for a preexisting list. The reason I said I'd have to make one is that I couldn't find one for free.


text:
How to make a game from the ground up
I've been using unity to make 2d indie type games for a while now. However, i've tried to branch into different genres and unity cant do some of the things that i want it to do(although it is still very good).
I really want to make a game from scratch were i have complete control over what happens, although i wouldn't have the slightest clue were to start.
tldr what resources do you need to build a game from the ground floor. or more or less. what resources/software/libraries did most well made indies such as super meat boy, braid or limbo use.

If you're really interested in the whole do-it-from-scratch;
This guy, http://handmadehero.org/, is live-casting coding a game from scratch, using no libraries. He does one hour a day and is currently on day 40 (something). He explains every single line he types. Full archive of past sessions available on youtube.

Questions about "how to get started," "what to learn next," or "which technology to use" are discussion-oriented questions which involve answers that are either based on opinion, or which are all equally valid. Those kinds of questions are outside the scope of this site. Visit our help center for more information.

Really curious what you're trying to do that Unity can't do...

A great place to start is from this book, but I'll go over the basics. This list is built on the basis that C++ is the language you would be using and you're developing a desktop game.

Games rely on maths, so you need a good maths library. A good place to look is at glm.
You also need some way of displaying an output to a screen. You need a some way to get a window open and handle input (glfw, SDL) and some way to access the graphics card(opengl + tuts) to render.
Assets such as texture (FreeImage), models & animations(AssImp, roll your own), shaders(roll your own) and sound(ffmpeg) need to be handled.
Most games have some form of collision and physics so you need something for this (bullet, box2D).
Sound playback needs to be handle as well (OpenAL, FMOD).

This list is by no means exhaustive but this list and book should give you a pretty good start.
As for "what resources/software/libraries did most well made indies such as super meat boy, braid or limbo use.", I have no idea.

I question the person who down-voted this. Although the question isn't right for the site, the answer gives suitable references.

Even though the answer may be reasonable, it's an answer to an off-topic question, which can be considered "not useful" by providing encouragement or validation of the "slip the question in under the radar" approach (which is harmful to the community overall).

I would recommend using HaxeFlixel for the programming part. You have a control over almost anything in the game because it relies on it's programming(but you need to know programming in Haxe (Although it's not very difficult)). You can build an entire system from that, if that's what you're searching for.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
AI to help player by suggesting upgrades
Suppose I'm creating a racing game.. I would like to implement an awareness system AI, that will suggest to the player that he can buy that booster or some other upgrade, .. etc. How should I start implementing that? A FSM ? A decision tree ?
Suppose that I have variables like, how many crashes, how much is the damage, how many gates I have passed, .. etc how would I use those variables then to say for example you need to buy that stuff?

I would use some sort of points system assigned during the race.
So each time a player crashes in the corner - add a point to "steering upgrade suggestion", each time he looses a race add a point to "engine upgrade", brakes for prolonged periods and misses an apex - "better brakes", gets overcome by an opponent in a straight line - "booster" and "engine" upgrades. You get the picture.
Detecting the right events can be tricky. You might need to add some cooldown period between adding more points or diminishing returns to the same item, so that e.g. multiple crashes during the same race wont make the steering upgrade score go sky-high. For example when player crashes into the corner you need to foresee and account for player could be hitting the walls of the corner a dozen of times before coming to a stop - that should be treated as a "one cornering fail", not a dozen. Said that, counters probably should be float values.
Another tricky part is to come up with the right triggers and balance the points required to fire up a suggestion.
Considering that events won't happen that often and will be read even rarer, optimizing the underlying data structure does not really matter.

What data structure should be used ? just a dictionary is enough? about the right triggers,isn't a threshold is not enough ? like if the points of streeing upgrade suggestion is over 50, then fires it ?

@andre: I have expanded my answer to address these questions.

So it's just a counter, the implementation to each item ?

I'd make it a bit more complicated than a simple int counter. But the idea is there, yes.

you can tell me how complicated you want to do it, I'm really interested :)

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Upload Games to Steam without Greenlight?
I've been working on a little game, (which is nowhere near completion) and wanted to know, that when I'm finished, if I would be able to release it onto Steam without having to get it Greenlit.
The reason why this is, is that I already payed for tools and editors for making my game, and don't want to have to pay another $100 in order to release my game.
Is this possible?

There's a Steam Support article on this subject: https://support.steampowered.com/kb_article.php?ref=1657-WHKN-6841

Also, there's an article explaining how Greenlight works.

Uploading your game to itch.io is free and a good way to distribute your game. If your game gets a lot of interest, you can still think about going steam greenlight.

Don't use Steam. They control, price and basically own your game and you are paying for that.

@Lolums That seems like a pretty strong statement considering it's the #1 video game distribution service. Simply avoiding it altogether is a great way to miss out on the majority of your potential sales.

No
Quoting Steam's description of the Greenlight process:

Who should submit their games to Steam Greenlight? Is there another
  way to submit my game to Steam?
Steam Greenlight has replaced our
  previous submission process. Any developer or publisher who is new to
  Steam and interested in submitting their game to the platform should
  submit their game through Steam Greenlight.

The idea behind Greenlight is to do an effort to prevent very low quality games into Steam, and let in only games that users are genuinely interested in (whether or not it succeeds at it is another discussion).
In my experience, getting a game through Greenlight is hard. There are so many games with so many interesting concepts, and so many games with much larger teams and budgets, that it is very difficult to gain enough traction to get released.
In addition, making a game is very hard. Just like anything in life, making good games takes practice, and I would say it would take at minimum 4 or 5 completed games to actually start making games that people like, and therefore get voted on greenlight.
Don't despair though, Steam is not the only way to get your game known. Focus on making your game, focus on finishing the game, show it to other people, make a blog about it, sell it (or give it away) on your site, and before you know it, you will have a few games under your belt, hundreds of loyal followers, and enough traction so the next game you make will actually make it on steam.

Thanks for the information. I was just wanting to release it on Steam when I finish it because of the user-base. Such ashame you actually have to pay for Greenlight though... The sheer amount of good developers they could make.... $100 it is then.

The idea behind the $100 is to make sure you are a serious developer. In principle, a serious developer with a real budget should have no problem pulling $100 for a registration fee. Their point is: if you have trouble paying $100, then you should probably become a bit bigger before you waste your time getting rejected on Greenlight. I'm not stating agreement or disagreement with this statement, I'm just explaining what I understand their point is.

Yeah, I understand. It's just that I already payed for the Professional edition of this, and am thinking of buying Modules for Mac & Linux. Then theres another $100 poured into Greenlight.

Considering a tiny game, made by three people in 6 months, paying say, $1000 per person per month, makes $18000. Plus tools and other stuff, you can consider an extreme minimum budget of $20000. A registration fee of $100 is 0.5% of that budget, and paying it should be no problem at all. The idea is that if $100 is a lot of money for you, then you don't even qualify as a tiny developer, and should get a bit bigger before entering greenlight and start competing against projects with much larger budgets.

Oh no! I have the money! That's not a problem. I was just stating that, even though it's not much, it's still "Money". Which is partially why I asked this question. I don't want to just throw money away if I can find a better way of uploading games.

@Finn When Valve first started Greenlight it was free, but a lot of people were putting up games they wanted on Steam, but they weren't the developers or publishers for. Valve couldn't remove these bogus submissions fast enough so they started charging a $100 fee.  Which like Panda Pajama says, should be an insignificant amount for anyone serious about releasing a game on Steam.

Their point is: if paying $100 is an issue to you, then you pretty much have no chances at getting your game past Greenlight. By that logic, the very existence of your post means that you are still way too small for Greenlight. But that by no means means that you are too small to -make- games! Just make your game, publish it yourself, or via other outlets (have you heard about Desura?), and when you get big enough that paying $100 is not a problem, -then- join Greenlight!

In my experience, even if you get your game past Greenlight, getting the actual store page set up, getting the necessary documents to register as a partner, and getting your game actually on Steam consumes a lot of time. if budgeting $100 is a problem to you, then budgeting the time and effort to actually selling your game on Steam will be an even greater problem. In my opinion, you should save your time, money and effort to avoid a huge frustration, and publish by other means.

Keep in mind comments are not for discussion. Please take further discussion to chat.


text:
Explaining Unity Sprite-Default Shader
I would like to know why we would use alpha blending in that shader for just rendering a sprite, which is just a texture ?
What is tint color ?
Why we multiply the alpha value by the color here ?
fixed4 c = tex2D(_MainTex, IN.texcoord) * IN.color; // why ?
c.rgb *= c.a; // why ?
Shader "Sprites/Default"
{
    Properties
    {
        [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
        _Color ("Tint", Color) = (1,1,1,1)
        [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
    }

    SubShader
    {
        Tags
        {
            "Queue"="Transparent"
            "IgnoreProjector"="True"
            "RenderType"="Transparent"
            "PreviewType"="Plane"
            "CanUseSpriteAtlas"="True"
        }

        Cull Off
        Lighting Off
        ZWrite Off
        Fog { Mode Off }
        Blend One OneMinusSrcAlpha

        Pass
        {
        CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile DUMMY PIXELSNAP_ON
            #include "UnityCG.cginc"

            struct appdata_t
            {
                float4 vertex   : POSITION;
                float4 color    : COLOR;
                float2 texcoord : TEXCOORD0;
            };

            struct v2f
            {
                float4 vertex   : SV_POSITION;
                fixed4 color    : COLOR;
                half2 texcoord  : TEXCOORD0;
            };

            fixed4 _Color;

            v2f vert(appdata_t IN)
            {
                v2f OUT;
                OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
                OUT.texcoord = IN.texcoord;
                OUT.color = IN.color * _Color;
                #ifdef PIXELSNAP_ON
                OUT.vertex = UnityPixelSnap (OUT.vertex);
                #endif

                return OUT;
            }

            sampler2D _MainTex;

            fixed4 frag(v2f IN) : SV_Target
            {
                fixed4 c = tex2D(_MainTex, IN.texcoord) * IN.color;
                c.rgb *= c.a;
                return c;
            }
        ENDCG
        }
    }
}

Tints are used often in sprites. This helps change the colour very quickly without having to change the texture itself, or make a copy. Alpha blending may be used when drawing sprites. For example, you'll probably want alpha blending for 2D particle effects.

So If I just want to draw a 2D GUI Texture(an image) is it ok to remove the tint and the alpha blending from that shader ?

Yeah, if you don't want these features, I'd assume so.

The "tint" color is a color that gets modulated (multiplied) with the texture color. This color is used with sprites for effects like making the player sprite blink red when hit by an enemy. To do so, you could set the tint to red when the player gets hit and leave it red for a couple frames, them restore it to white. Do that repeatedly for a few seconds and you'd have a blink effect for your sprite.
Multiplying the texture's RGB with the A could be used to give you a fade in/out effect. The alpha channel in the RGBA is a normalized value in the [0,1] range, so if you were to multiply the RGB with an alpha of say 0.2, you would get a very dark sprite. Multiply it by 1 and you will get the texture color as it is. You could get this same effect by multiplying the color with a back/white tint, BTW.
Finally, alpha blending should be on to ensure that sprites that have transparent areas get drawn properly. Most sprites have transparencies, so blending is required, otherwise the transparencies would be draw as if they where filled with some color. If you are sure you don't have transparencies in your sprites, then alpha blending could be safely disabled.


text:
How to determine areas of pixels of different colors or luminosities?
I want to create a program that determines all the areas of a given picture that have a different color, or the same color with different luminosities.
Are there known algorithms that do this job ? I would love to study such algorithms and implement them.
Thank you in advance for any help.

It might be worth converting the image into YCrCb and discarding the Luma component

This is a big topic with lots of kinds of answers. You can make a histogram of brightness for all the pixels. But to decompose the 2d structure of the image, terms like feature extraction, boundary detection, flood-fill, and posterization may provide some starting points...

I think this is too broad. You can start by what @david suggested. Otherwise try to reduce the scope of the question, for example, why do you want to do this ? maybe this is not the solution you want. Maybe if you tell us more we can give you better answers, so far I suspect the answers to be generic.

@concept3d Thank you for the advice. I thought my question is clear, but I will edit it in few hours. Regards

I've been researching Sobel Filters for edge detection.  I then use that information to identify bounding information so I can crop out borders programmatically.
I also like OMGtechy's comment on converting to YCrCb or YUV and throwing out the Luma component.  MSDN has an article on RGB to YUV  Strangely enough, looks like it's HLSL (shader).

I hadn't heard of those filters, interesting.

One possible approach is this:

Convert to the YCrCb colour space and discard the Luma (Y) component.
Compute a quality metric (see below),
See if the quality metric is above a threshold (see below),

Quality Metrics

ASNR
PSNR
SSIM

Threshold
This will be largely trial and error; you'll just have to tweak it until you get the results you want. I'd start at about 50 for PSNR/ASNR, or 0.9 for SSIM and work from there.

@Begueradj if you're happy with the answer, please accept it when you can. Otherwise, suggest improvements and I'll do my best to make them. Please note that problems with specific implementations are separate questions and should not be included in the answer to this one (although I may link them at a later date if people find this useful).


text:
Applying statements to a single instance in Game Maker?
I'm currently in the process of making a platformer, and am currently in the process of creating "depth" into my game, by making Up/Down-W/S control your depth. (Come closer to screen, go further).
The reason I chose to do this is so I can walk around stairs, go behind tables, etc.
But I have run into a problem.
When I call in my player code, if (depth == oWall.depth) {//code}, it is applying to every single wall ever. Is there a way to only make it apply to the object you are currently touching?
Here is my code so far:
/// Collision

// TODO: Make "depth" apply to a singular instance.
//   \/          \/
if (depth == oWall.depth) {

    /*
        Colliding with a wall on the Horizontal Axis, causes the player to stop moving.
    */

    if (place_meeting(x + h_speed, y, oWall)) {
        while(!place_meeting(x + sign(h_speed), y, oWall)) {
            x += sign(h_speed);
        }
        h_speed = 0;
    }

    /*
        Colliding with a wall on the Vertical Axis, causes the player to stop moving.
    */

    if (place_meeting(x, y + v_speed, oWall)) {
        while(!place_meeting(x, y + sign(v_speed), oWall)) {
            y += sign(v_speed);
        }
        v_speed = 0;
    }
}

Hope you understand what I'm asking.

You probably need to check for collision first, then check for depth. You can get the wall you are colliding with using wallHit = instance_place(.., .., oWall) then compare depth with wallHit.depth.
Since you are checking collision twice, once for movement on each axis, you will need to check twice just in case there is a different collision result in each case.

Wow. Was it really as simple as that?! Thanks alot. I appreciate it. I just changed all the if (place_meeting(...)){}'s with what you said. Thanks again.

No problem. If you get on with visual learning, Tom Francis (creator of Gunpoint) is currently doing a video series on GameMaker "Make A Game With No Experience". It starts from no assumptions about your level in programming / GameMaker, so you may need to skip through if you're already familiar with GameMaker, but it covers a bunch of practical stuff and you may pick up some tricks. I know I did.

Haha! I've been following that from Day One! Tom Francis... Gotta love him. I did programming in Java a while back, so GML is actually quite familiar in a sense that many things are similar to Java.


text:
Updating sprite Rect each frame
I have made a struct which sets 4 variables that define a rect
void setDestSize(int width, int height)
        {
           Width = width;
           Height = height;
        }
        void setSrcRect(int x, int y, int width, int height)
        {
           SrcX = x;
           SrcY = y;
           SrcWidth = width;
           SrcHeight = height;
        }

and I have a class that uses CSprite and it draws an Image. In my Render function it has
if (Visible)
    {
        Transform.SetIdentity();
    // Build transform
    Transform.SetRot(Angle);
    Transform.ScaleRot(Scale);
    Transform.SetTrans(Position);
    Iw2DSetTransformMatrix(Transform);
    Iw2DSetColour(Colour);
    // Render image
    if (ShipBullet != 0)
        Iw2DDrawImage(ShipBullet, CIwFVec2(Position.x, Position.y));

    boundingRect.srcX = Position.x;
    boundingRect.SrcY = Position.y;

    Iw2DSetColour(0xff0000ff); // Set red
    Iw2DDrawRect(CIwFVec2(boundingRect.srcX, boundingRect.SrcY),
        CIwFVec2(boundingRect.Width, boundingRect.Height));

When I draw that rect, It's drawn somewhere else, and its not bounded on the sprite..

you need to pass the position parameter in your draw function

pass it where ? in which function?

in the draw function ? Iw2DDrawImage(Image, CIwSVec2(x, y)); isn't the second parameter supposed to be the position of image you want to draw ?

yes, correct. I will edit my code, to the new one. Still the bounding rect is drawn to other places, not bounding the sprite.

im not exactly sure what you are doing and how much experience you have doing this, but usually draw functions are something like draw(image,position,source) where position is the draw position(x,y), and source is the rectangle which describes which part of the image you want to draw for example rect(x',y',width,height), i don't know the variables of the functions you are calling, but it shoudn't be too hard to figure it out

I don't have a src rect in my api. it just draws an image with a position. so I made a bounding rect on my own, and I want to use it for collision detection

Then all you need is to use a draw(image,position) function

yes but what about the bounding rect ? how would I update its srcx, srxy

you need to explain better what you are trying to do. you are supposed to update the X and Y variables (depending on your game logic) and draw your image to the (X,Y) position, are you trying to do something different ?


text:
explaining collision check code
I came across the following code in a game book but I can't get it, does it check if a point (left, top) in a rectangle?
bool CheckCollision(float left, float top,  float SpriteX, float SpriteWidth, float SpriteY, float SpriteHeight)
{
    return !((left >SpriteX + SpriteWidth) ||
            (top > SpriteY + SpriteHeight) ||
            (SpriteX > left + SpriteWidth) ||
            (SpriteY> top +SpriteHeight));

}

Yes, that's what it seems to be doing. Do you have any specific questions about how it does this? It seems really trivial to me, but on the other hand I have no idea of how much you know about C++, so I wouldn't know where to begin my explanation.

Just a visual figure is enough. So the above function is different than Rect to Rect collision ?

I don't have enough reputation to comment, so I will post this as an answer.
To get the most out of this exercise, I suggest you take a piece of paper, draw a rectangle and then try to map out each check on the paper.
For example: if the left coordinate of my actor is bigger than the wall, it will look like so.
Hopefully you understand what I mean, it's hard to explain with words. :P

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Unity light object not affect some parts of a 3D model
So far I've used Unity only for 2D projects. But now I need to implement a 3D scene in my game. I downloaded a tree model from the asset store and placed it in my scene. I couldn't help but notice that my light objects do not affect some parts of such tree.
It affects the leaves, but the trunk remains dark. Even with a point light right next to the trunk, it doesn't seem to be affected by the light.
The tree I refer to is the Shanty Town one: https://www.assetstore.unity3d.com/en/#!/content/44
Since I don't know much about 3D, I've been meaning to ask if this is normal behavior (the fact that the tree's trunk is not affected by light objects) and if I am expected to see other models with the same issue. Is there a way to fix this? I have someone that will make some 3D models for my game, but now I am concerned that my light objects will not properly work on his models.

Check Use Light Probes on the mesh renderer

This may be related to a light problem in Unity, not a tree problem.
In Unity, the amount of point lights are limited.
If you have more than 4, the colors do not blend properly.
If you have way more than 4, the Unity choses to light up only the closest light.
This is very annoying, but it's a way to prevent Unity from crashing.
If you aren't using point lights, you should not be experiencing this problem.


text:
How can I implement simple object orbits in Game Maker?
I've seen a lot of tutorials for things like "fixed circular orbit" and "elliptical orbits" which end up never been what I actually want.
I have two objects: oPlayer, and oPlanet.
I am trying to allow the player to move around freely, but be able to be caught by the gravity of oPlanet, causing the player to go around in circles/elliptical orbit. I also need the player to be able to escape thate orbit, and end up on a trajectory. In fact, I want it to work for any oPlanet.
What I am looking for is something similar to the orbital gravity in Kerbal Space Program.
Is there any way I should go about this? If anyone can be of help, I would rather answers be in GML rather than the Drag and Drop, but any help is great!

I know absolutely nothing about game maker, but I am quite well-versed in orbital mechanics. Would you be interested in a purely pseudocode explanation of how to calculate the movement of an object affected by multiple gravity sources?

@Philipp I have a mediocre understanding, but perhaps it may provide some sort of help. Sure! Tell me! Very interested!

I use Game Maker 8.1 all the time, and I've done orbital sims in them too. More good news: Game Maker has a built-in function that does vector addition for you:
motion_add(direction, acceleration) this will automatically change an object's hspeed and vspeed with the correct vector addition.
Remember that Game Maker treats 0 degree angle pointing right, 90 degree pointing up (which is the negative y direction), 180 deg pointing left, 270 deg pointing down. However, with motion add, you don't even need to know that.
Here's what I would do. In oPlayer, use the built-in variables x, y, hspeed, vspeed so that GM automatically does motion based on speed. Now you just need to do the acceleration from gravity, using motion_add. In the step event of oPlayer, write this:
var g, gdir; // it's necessary to make these temp vars because GM code remembers them in the scope even if you go into "with" for other objects. THIS ALSO ASSUMES YOU HAVE NO OTHER VARIABLES NAMED g OR gdir IN EITHER oPlayer OR oPlanet

with (oPlanet)
{
   // this assumes each planet has a mass variable, I used 1000
   g = mass/sqr(point_distance(x, y, oPlayer.x, oPlayer.y)); // handy built-in distance function
   gdir = point_direction(oPlayer.x, oPlayer.y, x, y); // VERY HANDY built-in get direction function from point 1 to point 2

   with (oPlayer)
     motion_add(gdir, g);
}

Now in the key down events for oPlayer, for all 4 arrow buttons, put this
hspeed += 0.2; // for right arrow
hspeed -= 0.2; // for left arrow
vspeed -= 0.2; // for up arrow
vspeed += 0.2; // for down arrow

So if you hold down the right arrow, each step will add 0.2 to your hspeed. Softcode this with whatever variable name you want.
I tested this exact code myself in a GM example. The room speed was 60, oPlanet mass was 1000, and things seemed to flow at a normal pace. One orbit took 1 or 2 seconds and I could easily break or re-enter orbit by pressing the arrows.
There is 1 caveat: If the player goes too close to the planet, such as sinking beneath its surface, it will get SO close to the center that gravity becomes extremely strong, which tends to make the ship go flying off in a random direction and never coming back. To avoid this, you should make a destruction event so that the ship just crashes when it hits or goes below a planet's surface, then restart the game. Use point_distance() to test if the distance is less than or equal to the planet's radius.
Finally, like I said, I use GM 8.1. I have never used GM 9, also known as GM Studio because it looks very bloated and way, way different than the nice interface of GMs 5, 6, and 8 that I am used to.

This looks promising!!! I will give it a go when I get home later. Thanks!

Great!!! Thankyou! It still however suffers very minor Apsidal Precession. Any ideas?

As for GameMaker Studio, TRY IT! You can easily change the skin back to GM8 and below easily. I personally feel the same way, and it looks no different after changing.

Apsidal precession has occurred in every single one of my orbital sims no matter how I implement it. I'm pretty sure it comes from the discreet steps of calculations instead of being truly smooth and continuous. For example, this program calculates things in steps of 1 second. If you want to try, you could get it down to 1/100th of a second, which will be more "accurate" and have less precession, but will cost a lot more computation and could easily slow your game down. BTW this would make a great question on gamedev.SE, go ahead and post it. Some people might have a clever solution.

Thanks for responding. Would you be able to answer such question for me? You know what you're doing.

@FinnRayment No I have no answer except to implement greater precision with 1/100th or even 1/1000th of a second. This solution will obviously slow down your program by 100 or 1000 times :( But there may be a clever way to get around the drifting precession problem that I'm not aware of.

Incase you are interested: http://gamedev.stackexchange.com/questions/106688/gamemaker-studio-slow-down-calculations

The first thing to do when you want to model space as it is is to understand Newtons laws of motion. An object keeps moving with a constant speed and direction unless a force acts on it.
That means you need to get away from the methodology of moving an object by changing its position. Give an object a speed in x- and y-direction and then change its position by its current speed every frame. When you want to change the motion of the object, change the speed through acceleration and deceleration.
Now you can add a gravity source by adding another constant acceleration to it every frame in addition to the acceleration from the player input.
When you want to simulate a point gravity source (like a planet), you first need to make the acceleration directed into the direction of the planet. You can do that by calculating the distance between gravity source and object with the Pythagorean law:
dist_x = object_x - source_x;
dist_y = object_y - source_y;
dist = Square_root(dist_x * dist_x + dist_y * dist_y);

Then you can calculate the horizontal and vertical portion of the acceleration vector by dividing each axis distance by the total distance:
acceleration_x = dist_x / dist;
acceleration_y = dist_y / dist;

You now have a constant acceleration away from the gravity source. But you want attraction, not repelling, so you need to invert it:
acceleration_x = -acceleration_x;
acceleration_y = -acceleration_y;

But keep in mind that in astrophysics, the magnitude of gravity is reduced by the distance squared. Also, different objects have different mass which means they are stronger gravity sources:
 gravity_power = source_mass / (dist * dist);
 acceleration_x = acceleration_x / gravity_power;
 acceleration_y = acceleration_y / gravity_power;

You should now have a proper simulation of orbital mechanics.

Hmmm... I love reading this sort of stuff. :P Lets see what I can do in Game Maker and I'll get back to you.

Also Philipp, is source_x, source_y | object_x, object_y referring to the Satellite, or the Body? And what is gravity_power, G-Force? Like Earths 9.81 m/s?

Hmm... Well... I sort of got it working. Except I don't orbit the Body. I just sink into it. As if I immediately dropped my velocity to 0m/s in mid air.

I literally typed word for word what you wrote, apparently a source_mass of around 5000 makes you move smoothy. (I don't want to wait 90 minutes for an orbit) Then, I wrote x = x + acceleration_x | y = y + acceleration_y And I sink. 0_0

@FinnRayment Add the acceleration to the current speed of the object, not its position.

Ah! I have a really good feeling this is going to work!!

Wow. Well, it's starting to look more like an orbit now. So again, I just wrote word for word, then hspeed (horz speed) += acceleration_x | vspeed (vert speed) += acceleration_y Now though, it's acting like N-Body, multiple bodies affecting it as it's orbit keeps changing. Their not elliptical either, their... thin(?) ovals. I can post a picture if you like.

Still alive Philipp?

I've found that motion_add behaves weirdly for simple orbital mechanics. There's the precession problem and acceleration is much faster when approaching the object you're using as the gravitational source.
This code gets rid of the precession and the velocity of the orbiting object is more manageable when approaching the planet:
object = obj_player;
source = obj_planet;
ddist = point_distance(object.x, object.y, source.x, source.y)
dsquare = ddist * ddist
grav_power = source.mass / dsquare;
ad = point_direction(object.x, object.y, source.x, source.y)
cx = cos(pi / 180 * ad)
cy = sin(pi / 180 * ad)
hspeed += grav_power*cx
vspeed -= grav_power*cy

Just copy it into a script file in GameMaker and drag it into the step event of your orbiting object.


text:
Camera.WorldToScreenPoint not working with perspective
transform.position = Camera.main.WorldToScreenPoint( new Vector3( origin.position.x, origin.position.y, origin.position.z ) );

I have this code on a Unity 4.6 UI object. The origin is some transform I want the UI element to stay above( like a floating health bar ).
The camera is top-down, but angled slightly on the x-axis. When the camera is moved, the UI element moves away from the origin slightly as if the camera was orthographic.
How would I go about compensating for the perspective? Is there another method I should be using to convert from world space to canvas space?
EDIT: Pictures added. Note that the transform is at the center of the model, not the base.

Please cleatify what you want to do.

You have to just subtract y coordinate from Screen.height please check my answer below

You want to move 2d UI (Label) with respect to your game object. WorldToScreenPoint transform the position from world space into screen space.
Here you are on right track, what you are missing is that
screenPosition = Camera.main.WorldToScreenPoint(transform.position);
screenPosition.y = Screen.height - screenPosition.y;

So, according to me your script like this:
var screenPosition :  Vector3;

function Update (){
    screenPosition = Camera.main.WorldToScreenPoint(transform.position);
    screenPosition.y = Screen.height - screenPosition.y;
}

function OnGUI (){
    GUI.Label(Rect(screenPosition.x, screenPosition.y, 50, 20),"Health...");

}

Or you can use this script:
Ready to use Script (Tested & works )
using UnityEngine;
using System.Collections;
using System;

public class SingleLbl : MonoBehaviour {

    private bool mShowGUIButton = false;
    public GameObject targetObject;
    public float btnWidth = 400f;
    public float btnHeight = 180f;

    void Start () {

    }

    void OnGUI ()
    {
        // Find the 2D position of the object using the main camera
        Vector3 boxPosition = Camera.main.WorldToScreenPoint(targetObject.transform.position);

        // "Flip" it into screen coordinates
        boxPosition.y = Screen.height - boxPosition.y;

        // Center the label over the coordinates
        //boxPosition.x -= boxW * 0.5f;
        //boxPosition.y -= boxH * 0.5f;

        GUI.Button(new Rect(boxPosition.x, boxPosition.y, btnWidth , btnHeight), targetObject.name);
        Debug.Log (boxPosition.z + "--x--" + boxPosition.x + "----y--" + boxPosition.y);

    }

}

Thanks for the answer, man. Also thanks for reminding me about this question. However, I made a stupid mistake and didn't realise the transform origin is actually at his feet, meaning it's working perfectly. I'll delete this question soon.

:) at first me too do the same..never mind.. .but other ll learn from it

would it be better for you to add a object you can reference as a child of the game object.  It could be damage1 or something and then on a trigger you could
Instantiate(damage1, transform.position, transform.rotation);
you could then set that to a animation effect like moving up and fading out or whatever effect you like.

I don't think you understand the problem. The GUI isn't in world space. Setting the position isn't the problem, the conversion from world space to screen space is.

Are you just trying to add a damage effect? like he gets hit and it show -1 damage text. I was suggesting another way to implement without all the worldspace to screenspace calculations.

Yeah. I don't understand how this would solve the problem, though. We want the text to be on the a child of the canvas, not a world space object.

damage1 would be gameobject with a TextMesh and animation on it in the example I showed. you would get your desired effect. but if you must have it a child of the canvas then sorry for suggesting a method that doesn't fit your needs.

Yeah, I should have clarified, I'd much prefer to use the new Unity UI stuff. A TextMesh seems a bit unnecessary here.

I prefer using the new UI for lots of stuff but damage and point effects I been using the still useful text mesh :) Another suggestion would be to assign your text to a canvas set to world space.

you can add this to the update function of your UI object:
transform.forward = -Camera.main.gameObject.transform.forward;

This just seems to mess up the GUI element.


text:
Rotating an object continously in UNITY with onclick
I have a script that works but it does not do what I want it to do. My script makes an object rotate on when another is clicked. However, I want the object to continuously rotate until I click on the other object again. Right now when I click it rotates just a bit and stops.
Here is my script
 using UnityEngine;
 using System.Collections;

 public class Rotate : MonoBehaviour {

public float speed =50f;
public GameObject target;

public void OnMouseDown(){

    target.transform.Rotate (new Vector3(0, Time.deltaTime, 0) * speed);

}

 }

Any assistance? I created what I have now using what I found on the internet but cant find another solution.


text:
Changing the texture filtering methodology within the same SpriteBatch Begin/End pair
How would I go about using changing the texture filtering method being used within the same SpriteBatch Begin/End pairing?
I have this code so far.
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null);

spriteBatch.Draw(PixelArtTexture, new Vector2(x, y), null, Color.White, 0f, Vector2.Zero, new Vector2(8, 8), SpriteEffects.None, 0f);

spriteBatch.End ();

This draws a pixel art texture using point filtering, however I want to draw another texture using linear filtering, so how would I do that?

Create a second SpriteBatch Begin/End combo...

Ok ClassicThunder but is there a way of doing everything in the same Begin/End, Or ever change a textures filter mode?

You can do something like this.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp, although I don't know if it can be done with an an .Begin()/.End() block.

No that dosent even work outside of the Begin/end for some reason :/ but thanks for the comment :)

@William'MindWorX'Mariager That works only if the sort mode is SpriteSortMode.Immediate.

So long as the SpriteSortMode is SpriteSortMode.Immediate you can make alterations to graphics device in between draw calls which allows you to change the ScissorRectangle, RasterizerState, SamplerStates, ect...
Of course you lose the performance optimization from the batching; however, it is sometimes worth it if the alternative is creating many begin/end pairs.
For Example
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null);
spriteBatch.Draw(PixelArtTexture, new Vector2(x, y), null, Color.White, 0f, Vector2.Zero, new Vector2(8, 8), SpriteEffects.None, 0f);

//Changing the SamplerState
GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
spriteBatch.Draw(PixelArtTexture, new Vector2(x, y), null, Color.White, 0f, Vector2.Zero, new Vector2(8, 8), SpriteEffects.None, 0f);

spriteBatch.End();

The first Draw call would use SamplerState.PointClamp and the second draw call would use SamplerState.LinearWrap.


text:
Calculating Bounding Rect
I'm trying to clone space invader of atari and I have problem with bounding rect calculations.. the rect is not correctly bounded.. maybe I have problem with the transformations
void Barrier::Render()
{

    if (mBarrierImage)
    {
        CIwFMat2D Transform;
        // Build transform
        Transform.SetIdentity();
        Transform.SetRot(0);
        Transform.ScaleRot(1);
        Transform.SetTrans(Position);
        Iw2DSetTransformMatrix(Transform);

        Iw2DSetColour(0xffffffff);

    CIwFVec2 pos = Transform.t;
    BoundingRect.x = Position.x;
    BoundingRect.y = Position.y;
    BoundingRect.w = (float)mBarrierImage->GetWidth();
    BoundingRect.h = (float)mBarrierImage->GetHeight();
    Iw2DSetColour(0xff0000ff); // Set red
    Iw2DDrawRect(CIwFVec2(pos.x, pos.y), CIwFVec2(mBarrierImage->GetWidth(), mBarrierImage->GetHeight())); // Draw red outline

Are you sure your Position.{x/y} are top-left corner and not center?

@tkausl I'm using Position{x,y} for movement of the image.

What tkausl means, is that maybe Position{x,y} points to the center of the image, instead of it's top-left coordinate. If you set position.x to 0 AND position.y to 0, do you see the entire image or just a quarter?

I will test it and will tell you the results. but is bounding rect calculations is correct ? like I have to set the position of the image to the bounding rect's x,y ?

Well, if your position is the top-left corner, then yes. if its the center, then you have to subtract (width/2) from x and (height/2) from y.


text:
Object orientated design for RPG character creation
This question may not be helpful to some but I'll ask anyway. I've hit a bit of a object orientated design issue. Making a RPG and the user gets to choose their own class i.e warrior/rogue/etc.
Sample:
int main()
{
    CharacterP *cPntr = new CharacterP // creates base pointer
    cPntr->createClass(cPntr, "Warrior"); // creates a new Warrior object which cPntr is now
                                           //pointing to.

    cPntr->printCharacterName();  //will print the warriors print name function

    return 0;
};

class CharacterP
{
    void createClass(CharacterP* &samp, string choice)
    {
        if (choice == "Warrior")
            samp = new Warrior;
         // other classes go here...... i.e Rogue, Mage
    }

    virtual void printCharacterName() //I don't want this function here
                                      //as this function will never be used, however it is
                                      //needed as the type of pointer for cPntr is CharacterP
                                      //which is the base of warrior.
    {
        std:: cout << "i don't want this function here, although it is required;
    }

};

class Warrior : public CharacterP
{
    virtual void printCharacterName()
    {
        std::cout << "you printed warrior";
    }
};

The main problem is the way I've designed this: If I want to use a Warrior function, I also have to define it into the base class CharacterP. When i start branching this out and adding more classes i.e Mage/rogue its going to be a maintenance nightmare as the base class would have a lot of functions that won't be used at all.
Questions:
Why does this happen?
Why does the base class also need to have the same function even though the derived function is virtual?
What is a more efficient way of doing what i am doing? (giving the user
the ability to create any classes they want i.e Warrior,Warrior,Mage/Rogue,Mage,Mage) maybe a way to create a warrior object with its own pointer which can be repeated so 3 warrior objects are created and can be used at runtime.

I don't know if this is your actual code, but as it stands you have a memory leak. You first assign cPntr to a new character and then reassign this pointer to a new Warrior without deleting or keeping the first pointer. I suspect your createClass wants to be static so you can call it directly.  However, you're probably better following the other answers and using constructors, but in case you don't you should be aware of this.

You should never ever use strings to distinct different cases (unless it comes from somewhere else of course, i.e. a config-file, user-input, ...) use enums instead.

this is not the actual source code. i just tried to replicate it as close as possible. i used structs to identify each class, but an enum sounds better.

The questions you should be asking yourself is if it makes even sense to treat different character classes as different code classes.
You usually use code-classes when you have objects which behave differently in terms of programming. But in many games, this isn't actually the case. Fighter, Warrior, Knight and Barbarian all can use the same programming, but only have different stats. These stat templates are better represented by instances of one code-class CharacterClass where each instance carries the data about how this character-class differs from the others. Your PlayerCharacter class would then reference the CharacterClass which applies to the character.
You could hardcode the stats of each CharacterClass, but it might be better to read this information from external config files for better maintainability.
When you have more different character-classes with notable differences in game mechanics (warriors, mages, archers, clerics...) it might still be possible to put them all into one code-class and instead extract their character-class features into individual code-classes. Each CharacterClass might have a list of CharacterClassAbilitys which are available to characters of that character-class. Examples for such class abilities would be MeleeAttack, RangedAttack, MagicAttack, PickLock or CureLightWounds. When your game features a progression mechanic where the character-class abilities are unlocked progressively, the information which abilities are already unlocked would be stored in PlayerCharacter, not in CharacterClass, because multiple characters can share the same character-class.
You might notice that this system easily allows you to create hybrid character-classes like "Spell Sword" which combines some of the character-class abilities typical to mages with some of the character-class abilities typical to warriors.

I'm somewhat confused about "Your PlayerCharacter class would then reference the Characterclass which applies to the character"

@tropicalmemes What confuses you about that sentence?

There is nothing wrong with the approach of defining the methods in the base class. In other languages, we would use interfaces for this, however this does not work in C++.
You should make your base class abstract and define the methods as abstract as well. This way you do not need to implement them in the base class.
class CharacterP
{
   void PrintName() = 0;
   void Walk() = 0;
   void Die() = 0;
}

As an additional benefit, you just have to take a look at your base class and know the features of the derived class. Being abstract, the methods force you to re-implement them when creating a new 'class' class.
Edit: The keyword in this context is 'polymorphism'. Have a look at it!

I think an important question is whether your character IS A warrior-rpgclass, or HAS A warrior-rpgclass
with an IS A relation, you would make the Warrior class inherit from your CharacterP class.
with a HAS A relation, you would give the CharacterP class a property called "Class", which holds an object of the Warrior class (which could inherit from a base Class abstraction)
a good principle for OOP is to favor composition over inheritance, as it allows for easier maintainability down the line.

I am working on a similar problem (granted I am using a different language so I'll try to only focus on principle). I basically made just a function for each part of the player that could be different at any point in the game and gave it conditions that would just add to the player's stats (I.e. Shield could be none, paper, glass, wood, or metal. Each different type added a certain number of points to the player's defense. ). I also added the currently unused ability to enchant the shield or armor or whatever (this currently is just a point system that does nothing but I'm thinking about doing something like giving a shield attack points). The only problem with this is it makes for some messy if statements.
What you could do is make a function that reflects the player's species and one for their class. You might want to start with some base stats (jump_height = 1 strength =  3 etc.) and then have the species and classes modify them (for an elf add 2 to the jump_height). I'm not that great with graphics but I would expect them to work on the same principle.
Hope this helps!


text:
Is sidescroller movement just offsetting the background?, MonoGame/XNA
When I make a sidescroller game and what to move my character do I just offset the background, or is there another better way?

there is a property called viewport, you are better off searching 2D camera class for XNA

http://www.david-gouveia.com/portfolio/2d-camera-with-parallax-scrolling-in-xna/

A sidescroller involves you having 2 background images. When one's position crosses the screen it goes behind the other one and it keeps looping. This involves using the Rectangle struct. Here's a video I have for your problem exactly.
https://www.youtube.com/watch?v=NZEzD0GvImg


text:
Choppy edges with sub pixel movement MonoGame/XNA 4
When I move a texture slower that one pixel it moves using sub pixel movement inside but the edges jumps from pixel to pixel.
Video : https://www.youtube.com/watch?v=zcai1PUfzzA
Sorry for the low quality (Its hard to see), I'm using linear filtering. How do I fix it so everything moves smooth?
spriteBatch.Begin();
spriteBatch.Draw(texture, position, Color.White);
spriteBatch.End();

I think this is because I dont have enought space on the image so it can blur the edges, anyone know how I can allow the image to scale without adding a trancperant frame around my img?

What does your draw code look like?

Jzx it looks like this spriteBatch.Begin(); sprite batch.Draw(texture, position, Color.White); spriteBatch.ENd();

The coordinates of position might be getting rounded to integers before that. This can also happen if you're using the Rectangle based version of SpriteBatch.Draw. So how are you setting position?

jzx Im chancing the Vector2s X and Y values

I fixed it by using a transparent frame around my image, It didn't have enough space to be able to blur the edges so in juped from pixel to pixel to prevent the image from being scaled

Any idea of how I can go about doing this without adding transparency?

Your YouTube video is "private". I cannot view it.


text:
Loading different navmeshes at runtime in Unity 5
In order to improve the extend ability of our maps, we load different components of the map at run time. The idea is a user can use Unity to make a map, drop it into a folder and it will be loaded.
The problem I'm facing is loading in navmeshes at run time. Before Unity 5, it was possible to give a scene a navmesh using Resources.Load and then NavMesh.Instantiate. NavMesh.Instantiate is now gone for whatever reason, and nothing seems to replace it.
Now when trying to use Object.Instantiate with a navmesh asset and instantiating an agent, I get the error "Failed to create agent because there is no valid NavMesh". Is there any known way to set a navmesh at run time anymore?

If I remember correctly, navmeshes should be stored into levels. If instead of instantiate an object you load additive the level with the additional mesh data it should work fine.

Which means a scene file for each navmesh, right? I don't believe new scenes can be loaded once the game is built.

yes you can stream scenes with bundles

If you want to load navmeshes baked with different settings you can not load it additively. What you can do is bake twice in a different scene (resulting in three scenes) then delete the geometry from the scenes containing the navmeshes and load like this:
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    bool _navMesh1Loaded;
    bool _navMesh2Loaded;

    void OnGUI()
    {
        if (GUILayout.Button("Load NavMesh 1"))
        {
            if (_navMesh2Loaded)
                Application.UnloadLevel(2);
            Application.LoadLevelAdditive(1);
            _navMesh1Loaded = true;
        }
        if (GUILayout.Button("Load NavMesh 2"))
        {
            if (_navMesh1Loaded)
                Application.UnloadLevel(1);
            Application.LoadLevelAdditive(2);
            _navMesh2Loaded = true;
        }

    }
}


text:
Weird rendering of bounding box
I'm trying to make a bounding rect for my bullet which is in space invader game.
I'm using marmalade, and the bounding rect seems translated and doesn't bound the bullet at all, however the math is correct.
Here is a video of the behavior and a snippet of code
http://youtu.be/SbjMPKQ7ilE
void Bullet::Render()
{
    if (ShipBullet == nullptr)
        return;

    if (Visible)
    {
        Transform.SetIdentity();

        // Build transform
        Transform.SetRot(Angle);
        Transform.ScaleRot(Scale);
        Transform.SetTrans(Position);
        Iw2DSetTransformMatrix(Transform);
        Iw2DSetColour(Colour);

        CIwFVec2 pos = Transform.t;
        BoundingRect.x = pos.x;
        BoundingRect.y = pos.y;
        BoundingRect.w = (float)ShipBullet->GetWidth();
        BoundingRect.h = (float)ShipBullet->GetHeight();

        // Render image
        if (ShipBullet != 0)
        {
            int x = -(ShipBullet->GetWidth() / 2);
            int y = -(ShipBullet->GetHeight() / 2);
            Iw2DDrawImage(ShipBullet, CIwFVec2(x, y), CIwFVec2(ShipBullet->GetWidth(), ShipBullet->GetHeight()));
        }

// render bounding rect
#if 1
        Iw2DSetColour(0xff0000ff); // Set red
        Iw2DDrawRect(CIwFVec2(BoundingRect.x, BoundingRect.y),
            CIwFVec2(ShipBullet->GetWidth(),ShipBullet->GetHeight()));
#endif

    }
}

You have to use the same coordinates for both of your objects.
void Bullet::Render()
{
    if (ShipBullet == nullptr)
        return;

    if (Visible)
    {
        Transform.SetIdentity();

        // Build transform
        Transform.SetRot(Angle);
        Transform.ScaleRot(Scale);
        Transform.SetTrans(Position);
        Iw2DSetTransformMatrix(Transform); // Set a 2D transform to apply to all
                                           // subsequent drawing operations. This
                                           // is taken into considration for the
                                           // Iw2DDrawImage and Iw2DDrawRect calls,
                                           // bellow.
        Iw2DSetColour(Colour);

        CIwFVec2 pos = Transform.t;
        BoundingRect.x = pos.x;
        BoundingRect.y = pos.y;
        BoundingRect.w = (float)ShipBullet->GetWidth();
        BoundingRect.h = (float)ShipBullet->GetHeight();
        // I don't know where but the BoundingRect must be used somewhere else.

        // You have already applied the transformation with the position of your
        // object, which you consider as being the center. You now have to offset
        // the graphics by its size to draw it around the center.
        int x = -(ShipBullet->GetWidth() / 2);
        int y = -(ShipBullet->GetHeight() / 2);

        // Draw the image, x/y is top left, per the documentation (http://api.madewithmarmalade.com/group__iw2dImages.html#ga60855d305af26248dd9eb71fcb4c656d)
        Iw2DDrawImage(ShipBullet,
            CIwFVec2(x, y),
            CIwFVec2(ShipBullet->GetWidth(), ShipBullet->GetHeight()));

// render bounding rect
#if 1
        Iw2DSetColour(0xff0000ff); // Set red
        Iw2DDrawRect(
            CIwFVec2(x, y),
            CIwFVec2(ShipBullet->GetWidth(),ShipBullet->GetHeight()));
#endif

    }
}

From what I understand from marmalade, a call to Iw2DSetTransformMatrix(Transform) sets the transformation for all your subsequent calls. Then you have to use the same data if you want to have both your objects at the same location.
Edit:
See my comments in the code, and more explanation:
You could have used the x/y of the Position and of the BoundingBox if you did not use the position in the calculation of the Transform (and the subsequent call to Iw2DSetTransformMatrix). By using the x/y of the bounding box, you were actually moving your bounding box twice: one because of the position/call-to-Iw2DSetTransformMatrix, and once because you were offsetting it by it's position again.


text:
Space invader barrier implementation algorithm
I've been struggling with implementing the space invader bullet to barriers. I wanted right now to blast a circle around, when the bullet hits the barrier and modifies the circle. As shown in the video, the algorithm looks wrong, http://youtu.be/VMBczCsP3J4
I have tried my best to debug it, but I've failed.
here is the algorithm:
// if there is intersection
    if (IntersectsWith((*it)->BoundingRect, barrierRect))
    {
        // subtract (*it) bullet position from barrrier's rect
        int normX = (*it)->Position.x - barrierRect.x;
        int normY = (*it)->Position.y - barrierRect.y;

        // barrier image pixels
        uint32* ptr = (uint32*)pixels;
        // height of the barrier
        int y = 31;

        for (int i = 0; i < 31; i++)
        {
            int pixelOffset = y + normX * 51;
            int color = ptr[pixelOffset];
            // look up the color if its not black, it should be green
            if (color != 0xFF000000)
            {
                // delete the bullet
                Bullet *bullet = *it;
                it = ship->Bullets->erase(it);
                delete bullet;
                ship->Canfire = true;
                isCollision = true;

                // blast a circle around that bullet hit position
                int radius = 9;
                for (int y = -radius; y <= radius; y++)
                {
                    for (int x = -radius; x <= radius; x++)
                    {
                        if (x*x + y*y <= radius*radius)
                        {
                            int j = x + normX;
                            int i = y + normY;
                            int pixelOffset = j + i * 51;
                            ptr[pixelOffset] = 0xff000000;
                        }
                    }
                }
                break;
            }
            // go up
            y--;
        }

Your pixelOffset calculations are inconsistent...
int pixelOffset = y + normX * 51;

is different than...
int j = x + normX;
int i = y + normY;
int pixelOffset = j + i * 51;

One uses x * 51 + y and the other uses y * 51 + x.
EDIT
You are also reusing variable i and y.
I think you want your blast circle to be based on your outer y value in addition to the inner.  Notice y + yy + normY below.
            // blast a circle around that bullet hit position
            int radius = 9;
            for (int yy = -radius; yy <= radius; yy++)
            {
                for (int xx = -radius; xx <= radius; xx++)
                {
                    if (xx*xx + yy*yy <= radius*radius)
                    {
                        int jj = xx + normX;
                        int ii = y + yy + normY;
                        int pixelOffset = jj + ii * 51;
                        ptr[pixelOffset] = 0xff000000;
                    }
                }
            }

Looks to me that your intersection code is not returning the correct position of impact. This could due that that when the game checks whether the bullet collide with the object, the bullet is already inside the barrier. You need to modify the intersection code to return the exact moment when the bullet hits the barrier.

which intersection code ?


text:
Security of Unity Rpc calls
Im just starting to code my game in unity and have been reading up that rpc calls are not validated and can run havoc on the server. For example a modified client can connect to your server and just disconnect everyone by sending:
networkView.RPC("disconnecteverybody", RPCMode.All);
[RPC] void disconnecteverybody () {
Network.Disconnect();
}
Is there a way to validate packets?

Have you looked at this? http://answers.unity3d.com/questions/500386/security-and-rpcs.html


text:
missiles skip in collision detection
I'm trying to work on spaceinvader. I have problem that missiles or the bullets skip frames due to its fast speed. I tried to use the previous position of the bullet in the collision check, but still, the collision does not work. it's pretty working on bullets with slow speed. Kindly see the attached video.
https://www.youtube.com/watch?v=jOVc-HGNI9Q&feature=youtu.be
  void Bullet::Update(float dt)
{
    Position.y -= 0.50 * dt;

    Vel = (Position - prevPosition).GetNormalised();

    if (Position.y < 0)
    {
        IsDestroyed = true;
    }
    else
        IsDestroyed = false;

    prevPosition = Position;

}

and for collision check:
// if there is intersection
        if (IntersectsWith((*it)->BoundingRect, barrierRect))
        {

            // subtract (*it) bullet position from barrrier's rect
            int normX = (*it)->prevPosition.x + (*it)->Vel.x - barrierRect.x;
            int normY = (*it)->prevPosition.y + (*it)->Vel.y - barrierRect.y;

            // barrier image pixels
            uint32* ptr = (uint32*)pixels;
            // height of the barrier

            int pixelOffset = normY*51 + normX;
            unsigned int color = ptr[pixelOffset];
            // look up the color if its not black, it should be green
            if (color != 0xFF000000)
            {
                // delete the bullet
                Bullet *bullet = *it;
                it = ship->Bullets->erase(it);
                delete bullet;
                ship->Canfire = true;
                isCollision = true;

                // blast a circle around that bullet hit position
                int radius = 9;
                for (int y = -radius; y <= radius; y++)
                {
                    for (int x = -radius; x <= radius; x++)
                    {
                        if (x*x + y*y <= radius*radius)
                        {
                            int j = x + normX;
                            int i = y + normY;
                            int pixelOffset = i*51  + j;
                            ptr[pixelOffset] = 0xff000000;
                        }
                    }
                }

            }

Issues like this often come from the fact that the bullet gets through the target; frame A it's before and frame B it's passed it, and neither in frame A nor frame B you had a bounding box intersection.
A way to solve this is: in frame B, you extend your bullet's bounding box from the position it was in in frame A. This would encompass 'all the infinite positions the bullet have been in' during the 'frame transition'.
Edit:
As per request, here is a pseudocode sample. Note that it is assumed that everything is axis-aligned, that the origin is bottom left, and that bullets are going from 0 to infinite in the y-axis.
// Stuff to add to your main update
update()
  // When you update your bullet posisiton
  bullet.previousPosition = bullet.position
  bullet.position  = blaBlaBlaUpdatePosition()
  bullet.mositionBoundingBox =
    makeMotionBoundingBox(
      bullet.previousPosition,
      bullet.position,
      bullet.size )

// Take into considration the traveled distance between this frame and the
// previous frame
makeMotionBoundingBox( positionLast, positionNow, itemSize )
  rect = new rectangleBoundingBox
  rect.position = positionLast
  rect.size.x = itemSize.x
  rect.size.y = positionNow.y - positionLast.y + itemSize.y

isInMotionCollision( bullet, target )

  if ( bullet.mositionBoundingBox.intersect( target.boundingBox )
    return true;

  return false

can you elaborate that in pseudo code ? or picture ? I didn't get it

what's rect.size.y ? you mean rect height ?

Yes, if a vector is used to represent a size, the width is going to be kept in the x, and the height is going to be kept in y.

I adapted your code, but still I don't get accurate collision all the time :S

so basically you try to adjust the bounding box height to work from FrameA when the bullet is in FrameB so that it collides

It's more like a 'ray casting' from the position in frame A to the position in frame B. You could try to intersect your target with a line segment from positionLast to positionNow. I don't know if marmalade has this kind of feature, though..

is the calculation of the bullet impact correct ? because the bullet sometimes hit the some parts of the barrier that are away from the hit point

You'll forgive me, it's hard to see the big picture here...

I mean is that code correct ?  // subtract (*it) bullet position from barrrier's rect
int normX = (*it)->prevPosition.x  - barrierRect.x;
int normY = (*it)->prevPosition.y  - barrierRect.y;

and why not only adjusting the bounding box position to be the prevposition and not adjusting the size ? does adjusting the size matter ?

It looks as if your code just creates a hitbox that encompasses both the last and now iterations of the object. Which is a huge mistake, because if the object is moving diagonally, the hitbox increases disproportionately in size the faster the object moves, resulting in many erroneous collisions. I had a similar idea involving...well, they say pictures are worth a thousand words, so I drew this. In each illustration, the black boxes on each end represent one "cycle" (frame) of the game.

@BradenBest I suggest you write an answer with this :)


text:
resolving per pixel collision issue
In space invader, I'm doing bullet to barrier intersection using rect to rect, then I'm testing the first bullet's impact pixel, if it's green I blast a circle, if it's black, it continues travelling. now there is a situation that there is part of the barrier that won't be checked for intersection, as shown in the image, the first intersection test will fail, because the first pixel is black...

How would I resolve that issue ?

can you explain the "intersection test will fail, because the first pixel is black" part. which intersection will fail ? your image doesn't demonstrate any intersection

I mean I first doing rect-rect intersection between the bullet and the barrier. Then I check if the pixel is green, then I blast the circle, otherwise, I skip the collision part. But in the case in the image, there were some green blocks and they are blasted, but the intersection is called, and the first pixel it sees is black, then the bullet will travel over the green part that is in the picture


text:
MonoGame Point filtering movement appears Choppy/Jerky
When you move a sprite that is drawn using point filtering with a decimal number, example : 0.1 pixel or 100 * deltaTime (1.6) the movement appear choppy/jerky because it jumps from pixel to pixel. How would I go about doing to make the movement smooth?

please don't answer : linear filtering because I get some issues with my map then

Nothing. Pixel is smallest part of image. You cannot divide it more. If you don't want smooth image then humble with it. :|
BUT!
Problem also can be in how you calculate draw positions. See first answer on this question. It can helps you. If not please post code of your Draw method.

"how you calculate draw positions" : isn't float converted to int in draw time anyway ? I haven't noticed any difference when I draw using float (vector2) or int (retangle or point)

@Shiro there is something called subpixel movement that instead of jumping from pixel to pixel it blends smoothly between them. By moving the colors instead of the img itself

@VinnieH01 There is a difference between subpixel movement and smooth subpixel movement. There is an answer on this relevant question about ways to make the movement smoother  http://gamedev.stackexchange.com/questions/87353/how-do-you-move-a-sprite-in-sub-pixel-increments. Two interesting techniques are anti-aliasing (basically blurring pixels) and animated sprites (http://i.stack.imgur.com/QZakB.gif) . "Moving the colors" as you describe doesn't really solve the problem. Blurring the colors on certain pixels though, can fake the movement into looking smoother.

@VinnieH01 Using float seems to simply be rounded to the closest int. If you draw something on (0.51f,0) and (1.49f,0) it is drawn at exactly the same position which is (1,0). The only benefit from this, is for precision on physics simulations.


text:
How common are game engine bugs, and can I claim damages for them?
Are game engine bugs (in popular ones like Unreal and Unity, not some unknown ones) common? I know engines like Unreal, Source and Unity3D are well tested and maintained, but, for example, is there any threat like: I create a game, the engine programming is fine, so is everything I do, but I get a bug in the game because of a bug in the engine?
And as most of you guys here are game developers, has any one had such an experience? Also, can I take legal action on the creators of that engine incase I am under loss because of their bug?

No one is going to claim their program is bug free. Unless they're completely stupid. It is why they always offer it with no warranty.

It can be assumed that all non-trivial software contains bugs.

Unreal Engine 4 has a bugtracker here.
Unity has a bugtracker here.

If you browse these sites you can see the many known issues with these engines.

The licensing agreements for these engines (and most software generally) will contain clauses similar to this:

No Warranty.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND. UNITY AND ITS LICENSORS DISCLAIM ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT, AND ANY WARRANTIES AND CONDITIONS ARISING OUT OF COURSE OF DEALING OR USAGE OF TRADE. NO ADVICE OR INFORMATION, WHETHER ORAL OR WRITTEN, OBTAINED FROM UNITY OR ELSEWHERE WILL CREATE ANY WARRANTY OR CONDITION NOT EXPRESSLY STATED IN THIS AGREEMENT.

These No Warranty / "as is" clauses are intended to reduce any liability brought against the software developers/publishers.

I'm fairly certain that no, you cannot take legal action against the creators of software because of a bug. I'm not even sure how you get this idea, and what specifically you would sue them for.
There are known bugs (as Kelly said), and probably also unknown ones, but you have to think about the likelyhood of you even encountering these bugs, and even then you can probably work around that. In addition to that, Unreal has released their source code, so you can fix it yourself if you really have to.
The bigger question is: reliable enough compared to what? Writing an engine on your own? Unless you are The Chosen One, your homemade stuff will most likely have far more and/or serious bugs than something that has been used and tested not only longer, but by several orders of magnitude more people.

I've seen this idea come up on forums for various games; it's a somewhat common "threat" when the internet hate mob decides to descend on a game, unfortunately.

Hmm, you raised an actually interesting point there, but what do you actually mean by the term legal action? That does matter a lot in this case. And another thing, the creators of those engines aren't forcing you to use their engines. So it won't be possible that you can take an action on them.
The only thing that you are able to do is to report a bug to them, and ask them for a possible solution that you can take in regarding that bug. Given that you mentioned engines like UE4 and Unity, it is really unlikely (I'm not a user of those engines) that you encounter a bug that nobody has spotted before, considered the fact that there are a lot of successful titles that use those engines.
Even if you have spotted such an error or bug, the workflow is that you report the bug to them in their bug trackers. Most successful engines do have a large communities often, so it is guaranteed to be fixed unless the bug you are thinking of is not a bug actually, but is the intended behaviour.
So the conclusion is, it is mostly certain that you are not eligible to take an action on the creators of those engines.

 does it mean Epic Ganes gonna write a patch for my game in case Unreals got bugs?

It's not that they will write a patch for your game, they will release a patch for their engine. You have to download the updated headers.

It means that if you've found a bug, it's actually a bug (and not just a by-design feature or something similar), and you submit it to their tracker, they will consider fixing it if it's feasible and critical enough.


text:
Why aren't all public methods BlueprintCallable by default?
Considering the entire point of public/protected/private encapsulation is to abstract the class so it's easy to use, why does the programmer also have to decide if a method is callable from blueprints? Shouldn't all public methods/variables be visible in blueprints?
How should I determine if a member should be visible in blueprints? Should I only add the macro when they're strictly needed? Should I aim to make blueprint interfaces even more abstract than the corresponding C++ interface?

Shouldn't all public methods/variables be visible in blueprints?

The point of encapsulation is not only ease of use, but also to decouple parts to create a more robust and maintainable system. The idea to only expose certain parts of your code to others has proven to be one of the best practices in software development, so I think it is only natural for EPIC to unclude such a mechanism into their c++-blueprint system.
The other reason I can think of is that the Unreal Engine was built to be used in really big dev teams, with a lot of code. And maybe it is only me, but I find the "create a new blueprint node" popup very cluttered as it is. Adding hundreds of additional variables and methods might not be a good idea.

How should I determine if a member should be visible in blueprints? Should I only add the macro when they're strictly needed?

I don't think there is a general answer to that, just do what feels right for you and your team. I personally try to only expose stuff to blueprints or c++ if it is absolutely needed, but sometimes I expose my stuff anyway out of lazyness ;)


text:
How can I get the "SelfActor" in OnBeginActorOverlap?
The signature it takes is
void ( AActor* OtherActor )

However, The actor that is handling this event is not involved in the overlap. How can I access the actor that owns this delegate? Assuming I can't store a reference to this elsewhere. Is there another delegate that takes that parameter? Is this reference stored in OtherActor somewhere?

Irritatingly, I don't believe there isn't a simple way (which is why most events in other frameworks have a sender parameter...). Instead, one way I've worked around is:
Bind to the collision event inside the actor that has the UPrimitiveComponent you want to listen to.
Create an event in that actor that others can subscribe to. But this event has the signature void (AActor* OtherActor, AActor* Sender).
When the first event is triggered, simply fire the other event, filling in this as the second parameter.
This also works in BP using event dispatchers.

This workaround is a crap, but I'm not saying that you did any wrong, I mean Unreal should definitely add a sender. By the way, I also uses this workaround now...

The actor that is firing the event is the current instance:
(this-> )  Will get you the actor that is firing the event.
(OtherActor-> )  Will get you the actor that it collided with.

Like I said, the actor that is handling the event has nothing to do with the overlap.

How does it have nothing to do with the overlap? It has to overlap with something in order to fire the delegate.


text:
How can I add an animation curve to an object with no animations?
I want to scale text in different ways over time. I figured the best way to do this would be an animation curve. It turns out I need an actual animation clip just to create this curve.
My question is, is there a way to create and use an animation curve, or something like it, without making a redundant animation for this object? If not, is there anyway to create empty animation clips from the Unity editor?
Importing empty animations from third party applications into Unity just to use the animation curves seems ridiculous.

You can simply create an AnimationCurve, sample it overtime and use the value to modify an object parameter, such as scale:
public AnimationCurve myCurve; //let's say you edit from inspector, but you can built at runtime if you prefer

float t;
void Update()
{
  t+= Time.deltaTime;
  float val = myCurve.Evaluate(t);
  transform.localScale = Vector.one * val; //or do whatever you want with the curve value
}

Ahhh didn't think about exposing it to the editor. Thanks a lot, man. Exactly what I was looking for.


text:
How did Blizzard implement replay like in Warcraft 3 with not consistent data(attack damage)?
Units in wc3 has range of attack damage and it isn't consistent most of the time e.g critical hit and so on. Yet, they managed to make a replay that could even reconstruct bugs scene. I am just curious how they do it. It could be useful for fighting games or perhaps to easily submit evidence of recurring bugs. The best part is it's not even a big of a file and even could be used on a customize games. Come back to the title, how did they do it?

I'm voting to close this question as off-topic because how a game implemented a certain feature is best answered by the developers, otherwise it's just speculation.

Please see this related question about implementing your own: http://gamedev.stackexchange.com/questions/6080/how-to-design-a-replay-system

They would include that damage (or the data needed to get to the damage value like the RNG state) in the replay information. Each attack is only a numerical value of the damage value, the id of the attacker and the id of the victim. That is 3 values with a limitation on number of units those IDs could be a single byte each.
Crucial information is often RNG seeds, player input and (most importantly) fully deterministic implementation. Anything not deterministic would otherwise need to be included in the replay stream. A perfect implementation would use the "replay" engine for actual real-time play. Where input is nothing but the RNG seed and player input as it comes in.
For scrubbing efficiency and a failsafe you can include full board snapshots, these would contain the location of all units and their health, position of the buildings and unit building progress, etc.

I found few documents, that describe the replay file, so from those you can figure out what kind of model they are using for commands etc.
They have to use some kind of command pattern. That means, that each command issued is capsuled in instance of command (or ICommand ). Thus, if everything in the game happens with those commands, you could just push them to the engine and see previous actions replayed ( ofcourse, initial position of everything has to be the same ).
This method is quite like the one that Half life uses for HLTV, it's simple, compact and efficient way to accomplish the streaming, replaying and undoing actions.
I found these documents, that you might be interested:

Fan made page about WC3 replay format
Replay format description
Replay actions description
Another format description


text:
Pack four alpha maps into one
I have read an article about texture splatting that says:

Because the alphamap only has to be in a single channel of a texture,
  we can pack up to four alphamaps into a single texture – one in red,
  one in green, one in blue, and one in alpha.

But it does not mention a way to this. Can anyone tell me or point me to an article on how to do this? I've been googling it the whole afternoon but can't find any. Or maybe I just don't know the correct terms to search. :?
Thanks.

You can use a tool like Photoshop or Gimp to manipulate the channels of an image independently, eg: http://docs.gimp.org/ca/gimp-channel-dialog.html

That's it! I was actually playing with Gimp's dialog channel last night but can't figure out how to use it properly. Move this as an answer please. Thanks.

I mean make your comment as an answer so I can accept it. :)

You basically put a one alpha value in each channel.
For example you have Alpha0 = 0.5, Alpha1 = 0.2, Alpha2 = 0.7, Alpha3 = 1.0.
The "packed" texture would be R = 0.5, G = 0.2, B = 0.7, A = 1.0.

You just explained what is quoted. I already understand that. What I need is a "how to". For example, I already have 4 individual alpha maps, how can I pack them into one? What tool should I use? Can I do it with gimp? or imagemagick?

That's a bit broad. Where are you getting the Alpha values from? Where are they gonna be "unpacked" too?

I'm texturing may model in Blender. Similar to this [link]https://vimeo.com/3837224[/link]. The only difference is I have more that 1 stencil maps(max will be 4). Then I export the stencils as images.

So you want to create it blender and then use it in blender?

No, I'm using it in a game engine.

Blender Game Engine?

No, Gameplay3D.


text:
Is it possible to completely avoid copying image data when uploading textures to the GPU on iOS?
I am not a game developer, but I have been doing iOS software engineering for many years. I have a particular interest in graphics and animation, but the finer details are still a little foreign to me.
Here is the scenario I am working with:
I have an extremely memory-contrained iOS environment (i.e., no more than 16-20MB of active memory usage) where I am trying to display many high-resolution sprite frames in rapid succession to show an animation. Each frame might be up to 1210x1210 pixels, and I can have up to 200 frames in a single animation.
Obviously, these constraints mean I have to completely optimize my memory usage. There's no way I can even consider having more than one frame of an animation inflated and being used by my application's memory at any given point. Yet I need images to be loaded super fast.
I had considered trying to pack a bunch of frames together into a PVRTC2 or PVRTC4 image file. The quality and disk-space usage of PVRTC files is superior to other formats, considering they're only using 2 or 4bpp.
I attempted to use SpriteKit to read the texture atlas I created and display the image frames. This "worked" in that it did what I wanted, but the memory usage was insane, around 600-700MB. Apparently, SpriteKit is always going to make copies of texture data for its own use, which is unfortunate.
My question is if it's possible to completely bypass copying image data by my application before sending it to the GPU for rendering. My understanding was that the whole point of PVR image formats was to be an exact representation on disk of the uncompressed image data that the GPU can use directly, without the need for copying the image into its own format. (As far as I know, PVR is the format the GPU needs to render the texture.)
Indirectly, I was able to mostly achieve what I wanted using a framework I helped develop for iOS called Fast Image Cache. Basically, it creates image tables on disk that are fully uncompressed and are page-aligned in advance such that Core Animation can use the image data directly without doing a single memcpy. Fast Image Cache uses mapped memory to further avoid any copies whatsoever. In essence, data goes directly from disk to being rendered on display without any copies being made. (At least, no copies that are made within the context of your application, which could be held against your memory usage limits.)
The problem with FIC is that it is a very naive image table. It doesn't do any sort of texture packing. For my testing, I loaded each frame of the animation as a separate image inside FIC. There was a ton of disk IO overhead going on. In addition, FIC only supports 32bpp (with or without alpha) and 16bpp bitmap formats, which means the image tables are huge.
Is there a way for me to achieve something similar to FIC using OpenGL and PVRTC images? If I need to build out my own simple texture atlas support to map regions of PVRTC images to individual animation frames, I'll do that, though it'd be nice if something else besides SpriteKit could do this for me.
The crucial point is being able to quickly load fairly large image data to be rendered without impacting my app's memory footprint.

Your memory footprint doesn't seem surprising to me (600-700MB). Remember that you have two framebuffers allocated all the time, with the size of the screen, for double-buffered rendering. With those crazy-high DPI retina displays, the framebuffers alone will consume more memory that you can spare in your 20MB target.

Now one tangent that you might look into is Virtual Texturing. Not sure if it would be suitable to you, but you might investigate. I have tested it on the iOS with promising results. Here is my (unfinished) implementation.

Thanks. I'll check that out. I should reiterate that I'm unconcerned if system-level memory consumption varies using whatever techniques let me do it. I just need to a) avoid my app doing any expensive copies and b) only keep one or two frames in memory/bound to GL at once. So streaming them from disk would be ideal so they're swapped in and out of memory only as needed to display a particular frame (or series of sequential frames, if I pack a few into a single texture).

[Disclaimer]I don't do IOS programming but I know a reasonable amount about PowerVR GPU's and also texture compression[/Disclaimer]
Apologies for being lazy and not reading everything, but a) you aren't modifying a given texture from frame to frame are you? That might easily result in extra memory consumption as a TBDR GPU could be running asynchronously and the driver might want to avoid dependencies. b) If it's of help it seems to me the FIC system could be extended to use either 4bpp or 2bpp PVRTC instead of uncompressed data.

Nope, I'm not modifying the textures in any way. I just need to display them in rapid succession. The problem is that FIC works directly with Core Animation and Core Graphics. These systems don't have any notion of PVRTC. I'd have to create an OpenGL ES context and work directly with the GPU, which I may try to do soon. (I don't know much of anything about GL programming yet...)

So the short answer to my own question is, "Yes."
The long answer is...
Using Metal—and, I assume, OpenGL ES—you can create no-copy data buffers from memory-mapped files on disk. From there, you can create textures from those buffers. There are constraints, however, in that the texture data must be an uncompressed pixel format, can only have one mipmap level, etc. This makes sense, since if Metal is going to trust you to provide the texture data entirely without it touching the bytes, it must be in a "color-renderable" format right away.
The problem with this is that uncompressed textures aren't appropriate for me, as my disk usage would be enormous. However, I learned that PVRTC textures are decompressed on-the-fly as needed by Metal. So while I can't avoid any memory usage with PVRTC, after the initial texture load operation, the memory footprint is rather low.