texts: Unity - Smooth player input direction when changing camera

texts:
Preface- I'm very new to Unity.
I'm working on an exercise using fixed cameras like how they work in the PSX final fantasy games. I have the camera scripts working fine but it's an aspect of the character control that I'm struggling with.
My character moves relative to the cameras facing position, but when the camera suddenly changes to another angle, my running direction instantly and abruptly changes too. In the final fantasy games it sort of keeps going roughly in the same direction you were briefly.
input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
input = Vector2.ClampMagnitude(input, 1);

// get camera direction
// need to add something here for in between camera switches!
camF = Camera.main.transform.forward;
camR = Camera.main.transform.right;
camF.y = 0;
camR.y = 0;
camF = camF.normalized;
camR = camR.normalized;

transform.position += (camF * input.y + camR * input.x) * Time.deltaTime * 8;

I saw someone with a similar game comment on an article with his solution, but I don't quite know how to put it into code. The quote;

"Player just gets a rotation based on where the camera is looking and multiplies the character’s motor force by that .forward and .right. I only update that rotation after a big delta in input so you can smoothly move between shots."

This is his small (online) game which he's talking about, I'm trying to mimic the movement basically;
https://ocias.com/games/foggy-shore/
Can anyone give me some pointers?

Updated:
It doesn't quite play how it does in the demo game, but it's getting there.
    input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
    input = Vector2.ClampMagnitude(input, 1);

    if (!cameraChanged) {
        _lastCameraInput = input;
        camF = Camera.main.transform.forward;
        camR = Camera.main.transform.right;
        camF.y = 0;
        camR.y = 0;
        camF = camF.normalized;
        camR = camR.normalized;

    } else if (Vector3.Dot(input, _lastCameraInput) <= -0f) {
        cameraChanged = false;
        }

    transform.position += (camF * input.y + camR * input.x) * Time.deltaTime * 8;


texts:
It is now available for download.
It says you need twice* as many bits as I have. Why would you need more bits to compile code? Does that mean you need more bits to run flash games writtes with flasCC

Did anyone try it out and happens to know the answers?

http://gaming.adobe.com/technologies/flascc/

Minimum system requirements
    Flash Player 11 or higher
    Flex SDK 4.6 or higher
    Java Virtual Machine (64-bit)
Windows
    Microsoft® Windows® 7 (64-bit edition)
    Cygwin (included)

*This is meant as a joke. however I do own a 32-bit laptop and I am wondering why you need 64-bit.
Afaik - You only need 64-bit if you want to run a system that has more than 4gigs of memory.
Why would any flash game require more than 4 gigs of memory.

The only system that is 64-bits and does not have 4gigs of memory that I can quickly recall is that hilarious Nintendo that came ages ago with a Motorola CPU.


texts:
I'm working on iPAD game using MonoTouch which is similar to an IQ testing game. At the moment, I can write some simple games using basic UIImages and animations.

I'm wondering if I should learn XNA to create a game where people can throw a ball against a wall and see it bounce.

Has anyone seen any good examples of tutorials using XNA for simple 2d games?


texts: Exclude removed objects from list counting?

texts:
I want to count the number of objects on my list. But because I remove and add, my script keep count those empty elements.
update: This happen when I destroy the object when it inside the collider. This object does not get out from "OnTriggerExit2D".
public List<GameObject> Sorts;
public List<GameObject> ItemsInside;
public int NumSorts, NumItems;

// Update is called once per frame
void Update()
{
    NumSorts = Sorts.Count;
    NumItems = ItemsInside.Count; // it doesn't give correct number

}

void OnTriggerEnter2D(Collider2D other)
{
    if (other.CompareTag("Sort"))
    {
        Sorts.Add(other.transform.gameObject);

    }
    if (other.transform.name == ("GameItem"))
    {
        ItemsInside.Add(other.transform.gameObject);

    }
}

void OnTriggerExit2D(Collider2D otherOut)
{

    if (otherOut.CompareTag("Sort"))
    {
        Sorts.Remove(otherOut.transform.gameObject);
    }
    if (otherOut.transform.name == ("GameItem"))
    {
        ItemsInside.Remove(otherOut.transform.gameObject);
    }

}


texts: Stereo 3D: drawing 2D elements at apparent screen depth

texts:
I'm developing an application making use of DirectX11's stereoscopic features. At such I am not relying on nVidia's automatic implementation. That means I have to replicate a way to render 2d elements in clip space at an user-defined depth.

According to their 3d vision automatic best practices whitepaper, they suggest scaling the clip position by the chosen depth factor:

pClip *= depth/pClip.w

This works because the shader "footer" they add to the intercepted draw calls does:

pClip.x+= eye * separation * (pClip.w - convergence)

Where eye is the sign which alternates between left and right draw calls. This produces offsetted 2d renderings that when fused make 2d elements appear at the chosen apparent depth. Any .w greater than convergence appear beyond the screen and vice versa. I have replicated this functionality (for regular 3d drawing I am using two projection matrices) but since I need these elements to be rendered in orthographic mode I am not entirely sure if it is correct.

I am using a value of 1.25" as the interocular distance and 24" as the viewer distance (or convergence). If I plug those values in the equation above then it produces an offset that is too great to be fused. I have eyeballed a value of 0.015 that appears to produce correct positioning. So the equation becomes:

pClip.x+= +/-1 * .015 * (pClip.w - 24)

What is the correct math to use to calculate the correct offset in clip space so that two 2d ortho renderings result in a user chosen apparent screen depth?


texts: Unity - Loss of detailed shadows and shading marks on texture seams appearing after lightmap baking

texts:
I'm attempting to lightmap bake my scene and am running into the following problem -

With the lights set to realtime, the shadows have a nice amount of detail in them and the lighting on the models looks correct. However after a bake, all I end up with is a dull blob shadow underneath everything and nasty shading marks on my meshes, these shading marks are mostly appearing where the seams are on the UVs. The models are .blend files from Blender and 'Generate Lightmap UVs' is checked on the model Inspector panel.

All lights are set to static and 'Baked'

Lights are 3 x spotlights 1 x directional light

All models are set to static

Unity 5.3.3

PC standalone

Materials are using the standard shader with a diffuse and normal map on each.

I have attached screenshots of the problem and all my settings.

This is my first proper attempt at lightmapping, so I'm hoping it's just a simple oversight in my settings that someone more experienced can point out.

If anyone can suggest the cause of the problem, it would be much appreciated.

Thanks in advance


texts: Using Gimp and clone tool. Source selection selects center of four pixels

texts: I am using gimp to make tilesets. When I use the clone tool and hold ctrl to select the source, the selection is in the center of four pixels instead of just one pixel.  I don't know if I am doing something wrong or if there is a setting to change this.  Any help would be greatly appreciated.  Here is a pic.


texts: Vertex Snapping on a mesh with an armature

texts:
I've made a selection of modular walls for a game i'm working on and some of the pieces have moving parts, like doors and flaps, but the moving pieces with an armature attached don't use vertex snapping like all of the other pieces and it leaves ugly gaps in the walls.
I've tried everything I can think of to get them lined up, the closest I can get is lining them up by eye and this leaves small gaps when in game and isn't perfect.
Does anyone know of a way to get vertex snapping to work with meshes that have an armature attatched?
I've attached a picture to try and explain:


texts:
I followed the instructions on the following video: http://www.youtube.com/watch?v=SissgQ0IXvk

I'm using XNA 4.0 and Blender 2.69

I export the model with animation to a .FBX file.

The animation is a man waving

Here is what it looks like in Blender:

And here is how it renders in XNA:

The arm where the animation occurs is greatly distorted.

I believe the error occurs in the AnimationPlayer class:

        /// <summary>
    /// Helper used by the Update method to refresh the WorldTransforms data.
    /// </summary>
    public void UpdateWorldTransforms(Matrix rootTransform)
    {
        // Root bone.
        worldTransforms[0] = boneTransforms[0] * rootTransform;

        // Child bones.
        for (int bone = 1; bone < worldTransforms.Length; bone++)
        {
            int parentBone = skinningDataValue.SkeletonHierarchy[bone];

            worldTransforms[bone] = boneTransforms[bone] *
                                         worldTransforms[parentBone];
        }
    }

    /// <summary>
    /// Helper used by the Update method to refresh the SkinTransforms data.
    /// </summary>
    public void UpdateSkinTransforms()
    {
        for (int bone = 0; bone < skinTransforms.Length; bone++)
        {
            skinTransforms[bone] = skinningDataValue.InverseBindPose[bone] *
                                        worldTransforms[bone];
        }
    }

I think the bug can be fixed by editing the code above, I just don't know how to do it.
Can somebody help me fix this distortion bug?

Here is a link to the project source code: http://www.mediafire.com/download/ps5ocf1nxbfgrru/SkinningSample_4_0.zip

Here is a link to the Blender file:
http://www.mediafire.com/download/vrt8h1p83vkd76g/wave.blend


texts: Building Levels... Any tips for nice 'level enclosure'? To avoid having to make un-used parts of a level map

texts:
Hi everyone I have made myself a little SWAT action FPS style game. I have the basis of the code very well set up (by my standards!) and can easily add enemies where I want that all act differently by ticking different options in them.
I have set up a mission list and can complete them etc. The whole game is almost ready to build several levels with and then hopefully have anend product that resembles a real PC game.

But this is unchartered waters for me. Normally I can overlook all the rough edges as I am just learning, but I am really happy with this and want to try making it into a full game.

My problem: The edge of the level. I've made a 'training level' that is very small. Its 60mx60m gamemap . The level works fine but I have these edges where you can fall off the world. I could of course put a brick wall, or an invisible wall, but I thought I would ask you knowledgable folks here at gamedev for some advise and options.

Could I somehow dump my level on top of an image or plane of images to give illusion of being in a city? or would I need to create buildings in 3d just for background objects? (if not I can always give in for now and use a big brick wall lol)

Here's a screenshot to show what I mean. I understand this question will give rise to opinion based answers, but I'm really low on ideas so anything better than an invisible wall or a brick wall would be very welcome.

thanks for reading


texts: Why would an ambient occlusion (AO) shader's performance be dependent on light direction?

texts:
One of my favourite games recently implemented ambient occlusion as a graphics feature, which appears to perform very well in most circumstances - except during sunrise and sunset. As someone who is getting into shader programming, I'm intrigued by this.

My understanding of AO is that you precompute the diffuse shading for a range of incident vectors, then use that information to produce a correct shadowing scale for real-time use by enumerating over all the lights and computing how their position in relation to the object compares to each of the incident vectors, essentially interpolating across the closest values. Since the occlusion is pre-computed against a model, taking complex shapes and self-occlusion into account, you don't need to raytrace and the performance is much better.

So here's where I get lost - since the diffuse map is precomputed, and you're just comparing light positions to those maps for all objects within the screen space, why would performance suffer for cases where the ambient light (the sun) is close to the horizon? It seems like this shouldn't matter - surely the performance of such a shader scales against vertices, not the angle of the light?

The game uses the latest version of Unity (they just bumped up a minor release) but I don't know if they use the built-in Unity SSAO shader. Performance hit is major - 28fps at 1440p during "day" hours, dropping to 12-14fps during sunrise/set. This only occurs when AO is enabled.

I'm not interested in finding a solution - I'm sure they'll fix it sooner or later - I'd just like to get a better idea of how AO performance scales, what its pain-points are, and why this kind of behaviour might appear.


texts: Is there a 3D animation tool that meets these requirements?

texts:
I'm searching a 3D physics / transforms animation editor. It should be able to import 3D meshes from OBJ or FBX, then it should be able to animate transforms. I need such a tool for my 3D games, where many dynamic and inorganic elements appear, like doors, traps, robots, lifts, and so on.

Where I can find such a tool?


texts:
I have a top down Car Game. how can I implement AI for the Cars? how the car follow the way points?
I want AI cars also rotate itself along the path.

I tried this solution

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

public class waypoint : MonoBehaviour {

    public List<Transform> waypoints;
    private Transform currentWaypoint;
    public float speed = 5f;
    private float closeEnouth = 0.5f;
    int point = 0;

    void Start()
    {
        currentWaypoint = waypoints[point];
    }
    // Update is called once per frame
    void Update()
    {

        Quaternion rotation = Quaternion.LookRotation(waypoints[point].position - transform.position, transform.TransformDirection(Vector3.forward));
        transform.rotation = new Quaternion(0, 0, rotation.z, rotation.w);
        float dist = Vector3.Distance(waypoints[point].position, transform.position);
        transform.position = Vector3.MoveTowards(transform.position, waypoints[point].position, Time.deltaTime * speed);
        if (Vector3.Distance(this.transform.position, waypoints[point].position) < closeEnouth)
        {
            if (point + 1 < waypoints.Count)
                point++;

        }
    }
}

and the car moved in the path but it moves reversed and if arrives the final node it stops and corrects its direction and console displays "Look rotation viewing vector is zero" error.

Thanks in advance


texts:
I've been bashing my head against the concept of a 'camera' for my 3D world for some time now, and I'm not sure I'm doing this right anymore.  Maybe I've been working on this for too long and have confused myself, or I have a fundamental mis-understanding of the topic.  Therefor, I could use a refresher/help on the concept of a 3D camera object and how that is supposed to operate.  I have a camera class with a position, an orientation (quaternion), and a derived transformation matrix.  Currently, my draw loop looks something like this:

Start Frame
Mult current matrix with matrix: Camera.Transform.Inverse
Save current matrix
Render all objects
Restore matrix
End Frame

However, this makes the camera's position reflected about the origin (ie, the camera's position vector has negative values but DRAWS as if it had positive values) and modification of position and rotation are consequently negated from their expected values (to get closer to the origin from z=3, I must add...).

So here is my issue: am I using this correctly?  How is a camera supposed to work?  Say I want to billboard something, how would I use the camera's information to do this?

Additionally, the clipping plane suddenly cuts out my scene if I rotate too far in any direction and I'm not sure why.  How can I fix/avoid this using camera information?  Any help is much appreciated!


texts: Why is OpenGL provided with latest GeForce drivers so extremely slow?

texts:
I'm writting a code in OpenGL and using two computers - an old and a new one.

On the old computer (which I use for debugging/creating implementation for the old GL) I have GeForce 5500 FX. Before windows reinstall on it, I had NVIDIA drivers with OpenGL 1.5. And everything worked perfectly. Games made quite good FPS, even with dozens or hundreds sprites.

However, after XP reinstall, I installed the drivers provided with my video card but it seems there's no OpenGL at all (mysterious 'GDI Generic' renderer). So I tried to download the newest NVidia drivers. After their installation I saw there's OpenGL 2.3 but when I runned my app it worked with extremely low FPS (about 0.25, I mean I had to wait four seconds for any app reaction) with only one sprite. And as I loaded smaller images, the FPS relatively increased, but on the new computer it's always (no matter how big and how many sprites) speed, so it must be the perfomance problem. Without any sprites, it seemed it worked normal, but game without graphics doesn't make any sense.

That's why I downloaded the oldest drivers for NVIDIA GeForce 5500 FX I found on the Nvidia site. But they're still providing OpenGL > 2.0 (2.1 exactly). The problem's the same.

I also tried to change all the properties of OpenGL to increase performance but it didn't help too.

So what can I do? I'd like to find drivers with OpenGL 1.5 but it seems they're not on the NVIDIA site and most people say it's the best to download they from there.


texts: How to correctly import 3D max files into Unity3d?

texts: I am trying to import a downloaded 3D max (.3DS) object into Unity3D and preserve the textures correctly. I've tried to select the .3DS-file and its jpg-files and dragged and dropped it into Unity3D. Everything works fine, and the object can be added to the scene. But I am unable to add the texture to the object. I have tried to drag and drop it like you can do with other kinds of objects, but it won't work on the imported objects.


texts: Displaying a Scratch Project (.SB2) file within a Delphi EXE FIle

texts:
I would like to Display a Scratch Project (.SB2) file within my Delphi EXE file. I would like to know if it is possible to display and build the Scratch Project into your Delphi Project.

I wish to make a small game in Scratch and then use the game within my Delphi Application without the need of the Scratch 2 IDE. Perhaps a 3rd party delphi tool or component or something that can help me achieve this would also be very nice. So basically I want to host the Scratch game within my Delphi app.

Is this possible? How can this be done? (I am using Delphi 10.3.2 Rio and Scratch 2 Offline Editor)


texts: XNA / WP7 accelerometer sample / example ball rolling

texts: Does anyone know of a good WP7 accelerometer sample of a ball rolling around on a screen?


texts: Source control for storing everything of game project?

texts: Is it usual to manage not only source code, but all assets, textures, art, documentation files, etc under git repository for version controlling? For example I wanna to get back old version of texture. If it is very bad practice what tools do you use for version control of assets and other stuff?


texts: Polling events with SDL results in stuttering response when dealing with multiple objects

texts:
I'm new to SDL programming and I'm not quite sure I got how it handles events.
Given an instance like this defined in "game.c":
static struct {

  SDL_Window* window;
  SDL_Renderer* renderer;
  BinaryTree* objects;

} game = { NULL, NULL, NULL };

(Which of course gets properly initialized)
My game loop is defined in the same file as follows:
void game_run() {

  bool closeRequested = false;

  while(closeRequested == false) {

    SDL_RenderClear(game.renderer);

    binaryTree_startIteration(game.objects);

    while(binaryTree_hasNext(game.objects)) {

      GameObject* gameObject = (GameObject*) binaryTree_getNext(game.objects);

      SDL_Event event;

      while(SDL_PollEvent(&event)) {

        if(event.type == SDL_QUIT) {

          closeRequested = true;
        }
        else {

          if(event.type == SDL_KEYDOWN) {

            gameObject_onKeyPressed(gameObject);

            if(event.key.keysym.scancode == SDL_SCANCODE_UP) {

              gameObject_onUpKeyPressed(gameObject);
            }

            if(event.key.keysym.scancode == SDL_SCANCODE_DOWN) {

              gameObject_onDownKeyPressed(gameObject);
            }

            if(event.key.keysym.scancode == SDL_SCANCODE_LEFT) {

              gameObject_onLeftKeyPressed(gameObject);
            }

            if(event.key.keysym.scancode == SDL_SCANCODE_RIGHT) {

              gameObject_onRightKeyPressed(gameObject);
            }
          }

          if(event.type == SDL_KEYUP) {

            //
          }
        }
      }

      gameObject_onRendering(gameObject);
      SDL_RenderCopy(renderer, gameObject_getTexture(gameObject), NULL, gameObject_getDestination(gameObject));
    }

    SDL_RenderPresent(game.renderer);
  }
}

game.objects contains every object which has to be rendered (via game.renderer) onto the the window (game.window). So, on each frame game.objects gets iterated on and for each element various functions get executed, before its texture is loaded to the renderer.
Of course gameObject_onRightKeyPressed() is called only if the right key was pressed, so if this function is defined as
void gameObject_onRightKeyPressed(GameObject* gameObject) {

  gameObject->destination.x += 1,
}

On each frame that the right key is pressed, gameObject's texture will move by 1 pixel to the right.
This works perfectly if game.objects contains only one element, but if a second element gets added, only the first one will smoothly respond to my input, while the other will move by 1 or 2 pixels just once in a while by keeping the right key pressed. It's like the first element contained in game.objects "steals" the input, so that when the second element's turn comes, there's no input for it to respond to. What did I do wrong?


texts: How can I Instantiate an object only for me?

texts:
I am trying to make a multiplayer game, and I want to instantiate/create/spawn an object only for the player's game client.

However, when I instantiate it, it spawns for everyone.

Here is the code:

using UnityEngine.Networking;

public class Spell : NetworkBehaviour
{
    void Start()
    {
        //CreateSpell();
    }

    public void CreateSpell()
    {
        var canv = GameObject.Find("Actionbar");
        var btn = Instantiate(spellButton, canv.transform, false);
        btn.SetActive(true);
        btn.GetComponent<Button>().onClick.AddListener(SpellAction);
        btn.GetComponent<Image>().sprite = spellImage;
    }
}

Here, the btn will show for everyone; and I don't want that.

How can I instantiate the object only for the client who creates it?


texts: Is a Gaussian blur a fairly accurate representation of soft shadow edges?

texts:
I'm not sure if real life soft shadows (from close,large light sources) have a Gaussian or linear falloff, or something else.

I'm working on something where I can create the shadows by manipulating some kind of pre-rendered gradient texture so I am not having to rely on frame buffers and traditional shadowing techniques. I'm planning on baking the gradient into one channel of my mesh's texture and then manipulating the values based on how much shadow covers each quad. This is possible because I just have quads lined up like a zigzag where each peak can cast a shadow onto the next adjacent quad.

So a linear falloff would be easiest (just need to subtract some value from a linear gradient) but I have a hard time telling what actually looks realistic. Is there a simple math formula that could be applied to a linear gradient to pull out a Gaussian approximation?


texts:
As an example, I have 3 different loops that are executed in certain conditions.
I want to know if there's any way short of something like this:

if(day)
   x++;
else if(night)
   y++;
else
   z++;

Avoiding the continuous if checks, because I know under what conditions they will be executing... do I make myself clear?

I've thought of something along the lines of starting to execute a loop under the said x or y conditions, like so:

if(day)
 loopX();
else if(night)
 loopY();
else if(something else)
 loopZ();

But by doing this I'll effectively have to do checks for when to exit the loops, which ends up being the same, right?

I want to be able to say: "Start doing this!", and then eventually, at my discretion, "Now start doing this, instead!", without constant polling of conditions!

For example, were I currently in the "something else" state, I'd be doing 3 if checks every frame just to enter the loop! If I had something like 100 states, and was on the 100th, I would be checking 100 conditions just to get to the loop I want to execute!

A pratical game programming example: every frame, I do collision checking. Suddenly, I want to stop doing the collision checking.
I do not want to have it check an if(collideStuff), I want it to straight out not do it.

void gameloop() {
   movestuff();
   something();
   collision(); // this would suddenly not have effect, as if it weren't there
}


texts: OpenGL, objects disappear at a certain z distance

texts:
I'm writing a managed OpenGL library in C++, and I'm having a pretty annoying problem. Whenever I set an objects Z coordinate to -2.0 or lower, the object disappears. And at coordinates 0 through -1.9, it doesn't appear to move away from them camera. I have a world matrix (which is multiplied by the objects position to move it), a view matrix (which is just the identity matrix currently) and a projection matrix, which is setup like this:

FOV: 45.0f
Aspect Ratio: 1
zNear: 0.1f
zFar: 100.0f

using GLMs glm::perspective method. The order the matrices are multiplied by in the shader is world, view, projection, then position.

I can move the object along the X and Y axis perfectly fine. I have depth testing enabled, using GL_LEQUAL. I can change the actually vertices positions to anything I want, and they move away from the camera or towards it perfectly fine. It just seems to be the world matrix acting up. I'm using glm::mat4 for the world matrix, and glm::vec3 for positions. Whats going on here?

I'm also using OpenGL 3.1, GLSL version 140 (1.4?).


texts: How to manage a multiplayer asynchronous environment in a game

texts:
I'm working on a game where players can setup villages, which can contain defending units. Any of these units (each on their own tiles) can be set to "campaign" which means they are no longer defending but can now be used to attack other villages. And each unit on a tile can have up to a 100 health. So far so good. Oh and it's all asynchronous so even though the server will be aware that your village is being attacked, you won't be until the attack is over.

The issue I'm struggling with, is the following situation.

Let's say a unit on a tile is being attacked by a player from another village. The other player see's your village and is attacking your units. You don't know this is happening though, so you set your unit to campaign and off you go to attack another village, with the unit which itself is actually being attacked by this other player. The other player stops attacking your village and leaves your unit with say a health of 1, which is then saved to the server. You however have this same unit are attacking another village with it, but now you discover that even though it started off with a 100 health, now mysteriously it only has 1...

Solutions? Ideas?

Edit

The simplest solutions are often the best. I referred to Clash of clans below, well after a bit more digging it seems that in CoC you can only attack players that are offline! ha, that almost solves the problem. I say almost because there's still the situation where a players village could be in the process of being attacked when they come back online, still need to address that.

Edit 2

A solution to the "What happens when a player is attacking your village and you come online" issue, could be the attacking player just get's kicked out of the village at that point and just get's whatever they had won up to that point, it's a bit of a fudge but it might work.


texts: What is the highest quality way to render warped text on Windows?

texts:
I need to render highly readable text, on par with DirectWrite+Cleartype+Truetype. The Cleartype system uses sub-pixel anti-aliasing. DirectWrite takes things a step further and moves letters around slightly (sub-pixel positioning, pixel snapping, etc.) to maximize readability and minimize distortions. This was important enough that every major web browser uses DirectWrite on Windows.

The obvious plan (with major shortcomings) is to render DirectWrite to a texture with cleartype disabled (because sub-pixel AA doesn't lend itself to transforms) and pixel snapping disabled (because that pixel "grid" is meaningless after transformation.) Unfortunately the text will look worse than it could if glyphs are enlarged or shrunk, and of course the lack of pixel snapping will hurt readability.

Ignoring performance, is there a higher quality way to draw warped text in Windows?

Edit: removed comment about disabling AA (DWRITE_RENDERING_MODE_ALIASED).


texts: How to create custom gravity in unreal engine and only affect specific actors?

texts:
I am fairly new to unreal engine and I would like to know how to set custom gravity in a specific point or area instead of down. For example I do not want the gravity pull to be down but more to the center of my level (center plane not center point) and that gravity to only affect specific actors. Other actors will be affected by normal gravity or affected by no gravity at all.

How can I do this? (blueprints or c++)


texts:
I have some c++ game code that draws the game state on each game-loop cycle in "immediate mode". By that I mean that the game code does not add the sprites to be drawn to any sort of "scene graph" or other data structure. It just starts from a blank slate on each game loop cycle, and piles on the sprites from back to front. (I know you might wonder what API this c++ code is actually using. Well, it's written in Marmalade, which I'm moving away from. Marmalade provides an abstraction layer and the essence of this question is about replacing that abstraction layer.)

I am having trouble understanding what "immediate mode" really means in opengl es, and how it relates to the "fixed function" vs. "programmable" pipeline. Some things I read say, don't use the old immediate mode functions, use the modern shader-based programmable API instead." But at the same time, I believe glDrawArrays() is fine to use in opengl es 2.0, right? So that's an "immediate mode" function.

(I believe what's going on here is that "immediate mode" means different things at different levels. My understanding is that a library like cocosd2-x is "retained mode" in that you add sprites to a scene graph that's managed by the engine. But at the opengl level itself, I think "immediate mode" means something a bit different, namely whether you keep the vital drawing structures in CPU space until you draw them with a begin() end() sandwich, versus uploading them ahead of time to the GPU. So it that sense the GPU "retains" your data across calls. But still, you can draw a frame in "immediate" mode in the sense of piling on sprites one at a time using glDrawArrays() as many times as necessary.)

In the "hello world" example of cocos2d-x, we see

// add the sprite as a child to this layer
this->addChild(sprite, 0);

That is exactly what I don't want to have to do, because as I say, my code base is set up not thinking of the sprites as objects, but just as drawing a bunch of rectangles from texture sheets (atlases) stacked on top of each other. I don't want to think of adding sprites to some scene graph and "letting the engine take care of it." That may be a fine way of thinking in general, but it would involve a huge rewrite of my existing code.

On the other hand, I think I like the idea of cocos2d-x because it gives me a convenient way to develop a code base that I can develop on Windows and run on iPhone, Android, and elsewhere.

So what I'm trying to understand is: Can I use cocos2d-x in some "immediate mode" fashion?

Basically, in opengles 2.0, I am allowed to call glDrawArrays(), correct? And if I batch up my sprites in a reasonable way, I can limit the number of calls to glDrawArrays() in each frame. So I want to do that, and I'm fine writing that gl code myself. But I think even though perhaps this defeats some of the point of using cocos2d-x in the first place, there are still huge portability and not-reinventing-the-wheel advantages of using cocos2s-x vs writing things from scratch myself?

So can I use cocos2s-x in that "immediate mode" way, and still retain the write-once/run-everywhere benefits?


texts: 3D movement on an authoritiative server?

texts:
I'm developing an MMORPG, using Unity for the client and "standard" C# 4.0 for the authoritative server. The server should check each player's movement and ensure that it does not collide with props or walk through unpassable terrain (like a cliff). Collisions with other players and such are not checked. In addition, the server must be able to retrieve/calculate the position of a player at any time so it can be sent to other players (who just walked into range, for example).

To make this all a little more complex, the game is a 3D space, meaning you can have things such as a spiral staircase and flight, and it has multiple maps.

I've run into a problem, though. I'm not quite sure how to actually implement all this.

I've come up with two ideas:

Make the server interop with a Unity client tasked solely with tracking player positions and validating movement
Get the props and terrain onto the server and use math to define the character's movement and check for collisions.

The first one seems ugly to me, and I don't even know if Unity will allow me to load multiple maps onto the same client. I've made some progress on the second one: I managed to export props as OBJ files and read them on the server. But from there, I'm kinda lost.

My question is two parts: Is there a better way to achieve what I want? And if not, how should I proceed with my current plan?


texts: How do i create a random planet generator and use it on Unity?

texts:
For example : https://managore.itch.io/planetarium

Something like this, create random sprite circles who at least are realistic looking, as far as realism can be pixel, I don't think this can be done on Unity alone so i think i might need to implement it after i coded it in another language or another engine, so my how do i do it? can i do it on unity? and how would i implement if i decided that unity isn't fit for this thing?

The usage of the planets will be throughout the game and will be used as the main planet so it is of great value to the game


texts: How do I convert two vectors into a bounding box with 8 vertices?

texts:
I created two vectors named bboxmin and bboxmax using the functions
vector3
applymin_xyz() and vector3
applymax_xyz().

How do I convert them to 8 vertices,so I can test cull with them?


texts: Pretty Sure I have Support for OpenGL 4, but it's not running. What can I do?

texts:
Many Game Engines require OpenGL to run.  I have one of those.  I've confirmed that the program and any benchmarks for OpenGL above OpenGL 2 fail to run.

Is there, like, a way to confirm I have dependencies or something to that effect?  Is it installed or is it just a library included in other programs?

Specifically using Ubuntu Linux 17.10, computer specs are fairly low but I've run the Engine on Windows on the same machine before.  Linux should have more up to date graphics drivers, so I'm not sure what the root of the problem might be.


texts: How to use model matrix with integer coordinates

texts:
I'm trying to generate a real-sized planet with WebGL. After researching, I came to the conclusion that the best way to get around 32-bit float precision issues (since GPUs don't support double precision) is to use 64-bit integer coordinates. I would generate these coordinates on the CPU, then send them as integers to the GPU. After that, I would get the position of the vertices relative to the camera by doing:

vertexPosition-cameraPosition

Since the result is small, I can now safely convert to 32-bit floating point and render it. All was good until I realised that since the coordinates are large integers, I can't multiply them by a model matrix if I want to rotate the planet around it's center since the floating point coordinates are no longer relative to the planet's center.

Is it possible to scale the model matrix by a large value, then convert it to integer, multiply by the position, and then divise by that same large value? I know there is a solution but I can't find it.

Thanks


texts: ParticleSystem, performance behind the technique on batching with different materials

texts:
I found that guide:
https://thinhhb.wordpress.com/2016/03/27/unity3d-optimization-make-atlas-textures-for-particlesystem-reduce-drawcall-why-not/ which is quite clever.

As far as I know, we can't batch ParticleSystems with different materials, for example:

A star (Particles/Additive)
A smoke (Particles/Additive)

give 2 draw calls.

The guide points, that we can use a TextureSheet trick to achieve batching of different graphics on multiple ParticleSystems like that:

We create a spritesheet manually and cut it in Unity's SpriteEditor into a grid, and create a material:

Then, we create our ParticleSystems and attach generated sprites into Texture Sheet Animation Module:

And here the magic happens. They batch.

My question is, what is the overhead behind this? Is the TextureSheetModule expensive?

If I have 15 different sprites, their ParticleSystems create 15 batches, which is quite expensive on mobile.

Is it wise, to move to TextureSheet and save these 14 batches?


texts: How can I implement Objective-C libraries in Unity?

texts:
I've been a "hardcore" developer for sometime now, as I've always worked with pure code reactive rendering, and contributed to Cocos2d library some time ago , (It is the one I used for my games) . But I've come to realize that most of the work I'm doing by setting up my game environment , user interface and everything else is becoming a bit repetitive, and complicated, as position must be tested each build , debugging sometimes involves exploring the deep down framework and I've decided to try out a full game development environment.

Some friends have recommended me Unity for mobile development (If you could give me any better advice I'd be grateful) but my main concern is my custom libraries I built on Objective C for multiplayer real time connectivity, it's probably thousands of lines and I wouldn't like to write them all over again.

Is there any way I could invoke my objective-c library in Unity ?

I know it's probably a vague question but can't seem to find where to start! Any guidance will be highly appreciated!


texts: Output pixel to different position from pixel shader?

texts:
Is it possible to output a pixel processed by my pixel shader to a different position?

For example if SV_POSITION of the pixel is 14,26, can I change it to 14,27?

I see there are only two possible output semantics, COLOR and DEPTH, so I am guessing the answer is not directly.

But are there alternative techniques, workarounds for achieving this?


texts: How could I give a lifespan to my MMO characters?

texts:
A problem I've encountered in some MMO games, is that players congregate around the endgame content, meaning that when a new player joins they are basically playing a solo game until they reach a high enough level to join the other players.

To combat that, I'm considering giving the player characters a finite lifespan. For example making it so that after X hours of gameplay, or once they reach level X, they start losing power instead of gaining it. Then they are encouraged to reincarnate, starting again from level 1 and only carrying over some small subset of their abilities.

My hope is that this will make the early game content (probably randomly generated, to keep it interesting) more useful, and more busy.

My questions is:

How could I implement this to make it appealing to the players?


texts:
To start things off, I begin with the following set of procedures:

Begin with a model in 3DS Max, which I will refer to as Cube.
Confirm that Cube's pivot point is exactly in the center of it, which it is.
Export Cube in FBX format.
Import Cube into Unity 3D.
Drag an instance of Cube into the Scene.

At this point, I notice that the instantiated Cube's pivot point seems to only be centered on the Cube's local X and Y axes, when it should also be centered on the Z axis.

In the project I am working on, I'll be instantiating Cubes and modifying their positions and rotations within a script. Because of this, it's most convenient to have the pivot point centered on all three axes.

Am I doing something wrong, or is there a way I could export/import the Cube properly so that its pivot point persists?


texts: Repeating a background texture forever in libgdx

texts:
My "game" works with a pretty large playing field, so I need a repeating background. I've implemented this the following way:

Loading:

assetManager.get("texture_bg.png", Texture.class).setWrap(Repeat, Repeat);
bgRegion = new TextureRegion(assetManager.get("texture_bg.png", Texture.class));
bgRegion.setRegion(0, 0, 16384, 16384);

Drawing:

batch.draw(bgRegion, 0, 0);

This does as expected: Creates a background of 16384 by 16384 pixels from a 512x512px texture. But now that I'm getting further in the testing, I foresee running out of space quickly almost no matter what I set the region to.

Is there a way I can have it simply repeat forever and not specifying a finite number?


texts:
I recently found this question on stack exchange with a great answer that showed how to condense game time into a sine wave, where 1 = midday and -1 = midnight

Converting time of day into a smooth day/night variable?

I've implemented this fine as far as I can tell but I'm a little confused as to how one would get a clean rotation from this to drive a directional light.

Currently I'm using arc-sine to revert the wave to radians and then converting it to degrees but I feel like this is going against the whole process of getting the sine in the first place. It doesn't actually work correctly anyway because we can't tell what side of the unit circle we're on, at least not with my current setup.

Is there a clean way for me to extract a rotation from this sine value so a sun would rotate smoothly? Thanks!


texts: Cocos2d: how to add anchor points to CCSpriteBatchNode

texts:
I am doing some tests with animations in Cocos2D using sprite-sheets. The animation works ok except that the anchor-point is in the center. I need to put it in the bottom. With the code below i am not able to add an anchor-point to my sprites, after quite a few tests.

Would someone nice be able to help me with this?

-(id) init {

    if((self = [super init])) {

        [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"ratHammer.plist" textureFile:@"ratHammer.pvr.ccz"];
        CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"ratHammer.pvr.ccz"];
        [self addChild:spriteSheet];
        NSMutableArray *walkAnimFrames = [NSMutableArray array];
        for (int i = 0; i <= 5 ; ++i) {
            [walkAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"ratHammer_anim%d.png", i]]];
    }

    CCAnimation *walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.1f];

    CGSize winSize = [CCDirector sharedDirector].winSize;
    self.bear = [CCSprite spriteWithSpriteFrameName:@"ratHammer_anim0.png"];
    _bear.position = ccp(winSize.width/2, winSize.height/2);
    self.walkAction = [CCRepeatForever actionWithAction:
                       [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
    [_bear runAction:_walkAction];
    [spriteSheet addChild:_bear];

}
return self;

}


texts: Adding new components and systems in my ECS requires lots of boilerplate code

texts:
I'm writing an entity component system for a project I've been working on. It's currently in a working condition, and overall i'm pretty happy with it, but I've noticed that adding new components and systems to it requires quite a lot of boilerplate code.

I've been researching ECS a bit, and I'm not entirely sure if that's normal or not. None of the things I've read mention how much boilerplate is typically necessary to add new components or systems.

Here is how I designed my ECS. The Entity class carries an id and a map of smart pointers to it's components. Entities are defined in YAML, and a factory class parses the YAML and creates all the components an entity needs. Entities are stored in the main engine class.

Systems hold a vector of nodes, each node containing only the components needed by the particular system. Each update, the system loops through the nodes, removing ones with invalid pointers and updating ones with valid pointers.

As of right now, boilerplate for component creation is not too bad. Each new component must also come with a function that returns an instance of itself, and the factory needs to have it's map of function pointers updated to include said function.

Boilerplate for making new systems is worse. The pointers in each node are hard coded. If a node needs to hold a lot of pointers to different components, things get messy quickly. The Node constructor lists every component pointer. The function for registering entities has to check if the entity contains any of the components. The update function has to check to validity of each pointer in the node.

Obviously all of these things need to be done, but making changes to the components a node holds requires updating the system in 4 different places, and creating a new component requires updating things in the factory class.

If lots of boilerplate code is the reality of working with entity component systems, then I'm alright with it because there are a lot of benefits. However, I'm not satisfied with not knowing if there is a better way to handle these things.


texts:
I hope this is the right place to ask my question... I have been working on a game (all 2D) and I'm facing some problem with the networking part (pretty much a beginner).

My game idea is a shared screen (the server) and multiple devices (clients) where every player will get different tasks/objectives. So after I spawn the players initially I just set them to not active on the server. That way the players can share the screen. After spawning the player on the client side, the player will have a screen to select an avatar and enter their name. On the server side, I would like to have the player selected avatar and name show up by spawning another object. The problem is that once the object is spawned it's not being updated on the server with the information from the client, even when using [Command].

Images to help understand the problem: http://imgur.com/a/8pJu5

Any help is appreciated it :)


texts: When to use a vertex array and when to use a VBO?

texts:
I'm trying to learn about vertex arrays and vertex buffer objects, but I don't understand the differences in terms of:

case-of-use (static geometry like terrains, geometry that changes every frame like a particle system, etc.)
performance
portability (old graphics card, consoles, devices like Android or iPhone, etc.)

some clarifications?


texts:
Does texconv from DirectxTex support generating mipmaps for volume textures? If not what are the other alternatives?

I am asking because I have tried to create the mipmaps by using textconv.exe -m 3 my.dds, but it looks like this (I am viewing it in the DDS plugin for photoshop):

And now I wonder whether the DDS plugin is bugged that it displays only mipmap for first texture or the texconv doesn't support it?

EDIT: Acutally by taking a deeper look on this image, the mipmap is somehow blended from these 2 main textures. Why? (high resolution texture here)


texts:
I am developing 2D game in java, and I want some basic in-game scripting (spawn enemy, spawn item, change enemies properties).

What I don't know is, how to divide the game world, to easily work with it.

I need enemies (have health, basic AI) of different types, item classes (can be picked by player), tile map with different blocks. Whats the best solution to maintain the whole world and to what classes should I divide it, to easily extend?


texts: storing map data as file in 3d roguelike games

texts:
I'm currently designing 3d roguelike game. I need to come up with a map storing system but I'm quite new to game programming so I don't really know how to design.
The map will be relatively small, it's not open world. I think it would be just like 3d version of The Binding of Isaac with first-person perspective.

I want to store map data as a file(e.g txt) but I don't know how to order them and what is necessary to store.

Answers with some examples would be very appreciated.


texts: How do I remove the objects when it is not seen on the camera?

texts:
I am a beginner C# Developer and I am creating my own version of the "No Internet Dinosaur Game."
How do I remove the Object like (Platforms, Cactus, etc.) When it is not seen on the camera?


texts: Which Pathfinding Algorithm is Best For My Case?

texts:
I'm creating a top-down space shooter game where there is no real "map" per say since there is no real terrain, but there are obstacles in the form of asteroids, other ships and a few circular structures, but nothing like a maze where an AI would need to find a path to get out of -more like things an AI doesn't want to collide with.

I want my AI to navigate around these objects. However, as you may have guessed, asteroids and ships aren't static, they have a scale and a velocity and can be destroyed. What's the best algorithm/method to use for navigating around moving obstacles in open space?

For context, my AI ships have a waypoint at all times that determines where they want to move to. Basically what I'm asking for is a way to ensure that if an asteroid or other ship were to fly in front of my ships as they fly toward their waypoint that the ship would make some effort to avoid it. Currently they just keep ramming into them and dying :(


texts: Megatexturing : Evolution from Quake Wars to Rage

texts:
I remember John Carmack talking about how they initially used Megatexturing for Quake Wars: Enemy Territory.
The technology has since evolved quite a bit in Rage.

I was wondering if somebody here can give some technical details on the specifics on what and how it has evolved since then.


texts: How do I fix this access violation when I exit my custom OpenGL game engine?

texts:
I'm writing an game engine, where the engine is written in a project and exports a .dll file. In another project, in the same solution as the engine, there is a sandbox project which uses the engine. However, there is a bug.

I run the sandbox project in debug mode with the engine dll. When I spam my mouse and keyboard for a few seconds, and close the program via the exit button, the program crashes with an error:

  Exception thrown at 0x00000043 in phantom-sandbox.exe: 0xC0000005: Access violation executing location 0x00000043.If there is a handler for this exception, the program may be safely continued.

I found the source of the bug. Since I'm currently writing the engine for OpenGL, I have to initialize GLEW, and I need to create a HGLRC. If I don't initialize this HGLRC, everything works.

This is not the ideal solution, since I need to use OpenGL for my engine. I went forth without exporting the .dll from the engine, making the engine an application, instead. I made a main.cpp, and wrote it to use the engine, enabling OpenGL rendering. I tried to recreate the bug, but everything works!

I thought it might OpenGL, but then now I'm thinking it might be my engine. How do I fix this?

Here is my code, where it errors:

    int const main_result = invoke_main()

    __telemetry_main_return_trigger(nullptr);

    if(!__scrt_is_managed_app())
        exit(main_result)l

    if(!has_actor) // < this is the line being sent to the call stack
        _cexit();

    __scrt_unititialize_crt(true, false);
    return main_result;
}

__except (_seh_filter_exe(GetExceptionCode(), GetExceptionInformation()))
{
    int const main_result = GetExceptionCode();

    if(!__scrt_is_managed_app())
        _exit(main_result);

Here is the call stack:


texts:
I've got a function that basically creates different instance buffers into an array for me to use in my DrawIndexedInstanced call.

But when I pass the vertex buffer and instance buffer through to my shader, my instance data is completely lost when the shader goes to use it, so none of my objects are being relocated and are thus all rendering in the same place.

I've been looking at this for hours and literally cannot find anything that is helpful.

Creating the Vertex shader input layout:

D3D11_INPUT_ELEMENT_DESC solidColorLayout[] =
{
    //Vertex Buffer
    { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
    { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },

    //Instance buffer
    { "INSTANCEPOS", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
    { "INSTANCEROT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 12, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
    { "INSTANCESCA", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 24, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
    { "INSTANCETEX", 0, DXGI_FORMAT_R32_FLOAT, 1, 36, D3D11_INPUT_PER_INSTANCE_DATA, 1 }
};

Creating an instance buffer (called multiple times per frame, to create all necessary buffers):

void GameManager::CreateInstanceBuffer(ID3D11Buffer** buffer, Mesh* mesh, std::vector<Instance> instances)
{

    D3D11_BUFFER_DESC instBuffDesc;
    ZeroMemory(&instBuffDesc, sizeof(instBuffDesc));

    instBuffDesc.Usage = D3D11_USAGE_DEFAULT;
    instBuffDesc.ByteWidth = sizeof(Instance) * instances.size();
    instBuffDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
    instBuffDesc.CPUAccessFlags = 0;
    instBuffDesc.MiscFlags = 0;
    instBuffDesc.StructureByteStride = 0;

    int i = sizeof(Instance);

    D3D11_SUBRESOURCE_DATA instData;
    ZeroMemory(&instData, sizeof(instData));

    instData.pSysMem = &instances;
    instData.SysMemPitch = 0;
    instData.SysMemSlicePitch = 0;

    CheckFailWithError(dxManager.GetDevice()->CreateBuffer(&instBuffDesc, &instData, buffer),
        "An error occurred whilst building an instance buffer",
        "[GameManager]");

    meshBuffers.push_back(mesh->GetBuffer(VERTEX_BUFFER));
}

The draw command:

dxManager.GetContext()->DrawIndexedInstanced(instanceIndexCounts[buffer], instanceCounts[buffer], 0, 0, 0);

I've used the graphics debugger built into Visual Studio. Initially it appeared to be assigning variables in the Vertex shader back to front, however removing APPEND_ALIGNED_ELEMENT from the AlignedByteOffset has fixed that, however the per-instance data seems to be corrupt and is not getting recieved.

If there is anything else you need let me know and I'll update the post as necessary.


texts:
There is a game that I really like to play when I was young. But there are some features that are not implemented that would be cool.

How can I find copyright database from games editor ?


texts:
I would like to create a framework that would allow user to compete with his AI code against other player AI online.
The problem is that I don't know how should server simulate the fight online. If users send their AI codes to server I don't know how would I eliminate security risks without completely interpreting the AI code. Also I thought about the option that AI code would be running on client.
What's the best way? Is it by using some specific script language for AI and interpreting it by server or something else?


texts:
Here is the setup.  I have a orthogonal tile map made with Tiled.  There are 5 layers.  The bottom 4 comprise the background, while the top layer is the foreground that I will refer to as the “tree” layer.  I have a hero sprite that I have added as a child of the tile map at the same node zorder as the tree layer.

The issue that invariably comes up with this scenario is that I want my hero to be in front of trees that he is “below”, but behind those trees that he is “above”.  Below and above are determined by the Y coordinate of the hero versus the Y coordinate of any given tree.

The Cocos2d programming guide contains a section for tile maps, and in that section it specifically discusses how to achieve the affect I have described.  This information can be found here.

http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:tiled_maps

The solution is pretty simple.  Enable the depth buffer in my code.  Add a cc_vertexz property with a value of -1000 to each layer that the hero will be above.  Then add a cc_vertexz property to the tree layer with a value of “automatic” as well as a cc_alpha_func property with a value of .5.  Then as your hero moves re-adjust its sprite’s vertexz value based on its position within the map.

I did all this and it worked great.  However, a problem appeared as soon as I added other “enemy” sprites to this map.  As with the hero sprite these sprites were added to the map with the same node zorder as the tree layer, and they too have their vertexz values changed based on their Y coordinate within the map.  It should be noted that the hero sprite is added after the enemy sprites.  In addition, both the hero and enemy sprites are animated and their textures are not part of the tile map textures.  Based on the Cocos2d documentation this should not matter.

The problem is this.  If my hero is below an enemy sprite on the map then everything looks and works fine.  However, if my hero is above an enemy sprite on the map then as the enemy passes over the hero sprite the background comes through rather than the hero sprite.  The best way to describe it is to say that as soon as the enemy sprite begins to pass over the hero sprite, the transparent areas of the enemy sprite begin to fill with the background and the hero sprite is partially obscured until then enemy sprite moves off the hero.  It is like the hero sprite is not there.

I know this is related to the order that the sprites are added to the map, because if I change this and have the hero sprite added to the map before the enemy sprites, then the effect reverses in that the background comes through the transparent areas of the hero sprite rather than the enemy sprites.   It is almost like the vertexz property is not absolutely determining the order that things are drawn.

Looking into this it appears to be a blending issue and I found what seems to be the solution, which is to subclass the CCSprite class and override the draw method with the following:

-(void) draw {

   glEnable(GL_ALPHA_TEST);

   glAlphaFunc( GL_GREATER, 0 );

   [super draw];

   glDisable(GL_ALPHA_TEST);

}

The problem however is that this code is not applicable to the version of Cocos2d that I use, which is Cocos2d 2.1.  In addition this appears to be handled by the CCTMXLayer drawing function if automatic vertexz is enabled.  As such I do not know if subclassing CCSprite would just be redundant.  See below for how CCTMXLayer handles this:

// CCTMXLayer drawing function
-(void) draw

{

    if( useAutomaticVertexZ_ ) {
        glEnable(GL_ALPHA_TEST);
        glAlphaFunc(GL_GREATER, alphaFuncValue_);
    }

    [super draw];

    if( useAutomaticVertexZ_ )
        glDisable(GL_ALPHA_TEST);
}

I am not new to Cocos2d, but I am very new to anything related to OpenGL.  So in short, is the solution just to subclass CCSprite and find the Cocos2d 2.1 equivalent to the above code snippet, or am I simply doing something wrong?  I suspect the latter.

Any help would be very much appreciated.  Thanks!


texts: Testers for multiplayer game? Where to find them?

texts:
I am indie game developer and we created multiplayer and realtime game IQ Wars (www.iqwars.net). We made Windows/Mac/Linux Beta version of our game public and were hoping to find some beta testers to see if it works without problems with 50+ or 100+ players playing simultaneously.

So basically I was thinking about some kind of page or service were indie game developers publish their games so gamers can play and give (or not) some feedback. Is there any place where I can put the game (it's Setup.exe) or link to the game? Or maybe my understanding is wrong and I have to do it some other way?

Would be very appreciated for help.


texts: How to make a horizontal scrolling menu in Unity 3d 4.5

texts: I want to make a horizontal scrolling menu that will hold the levels of a game but I have a little idea about how to make it so it would be very great if anyone help me with it.


texts: Fair dice over network w/o trusted 3rd party

texts:
Though it should be a pretty basic problem, I did not find a solution for it:
How to play dice over a network without a trusted third party?

The M players shall roll N dice, one player after another.
No player may "cheat", i.e. change the outcome to his advantage, or "look into the future" before the next roll.

Is that possible?

I guess the solution would be something like public key crypto,  where each player turns in an encrypted message. After all messages were collected you exchange the keys to decode the messages. Then the sha1(joined string of all decrypted messages) mod 6 + 1 is used to determine the die.

The major problem I have: since the message [c/s]hould be anything, I don't know how to prevent tampering with the private keys. Esp. the last player to turn in his key could easily cheat (I guess).

The game should even stay fair, if all players "conspire" against one player.


texts: Optimization for lots of UV coordinates update for tilemap animation

texts:
In my game, I procedurally generate tile map mesh and modify it when travelling around the "world". Each tile is a quad. So they each, have their own UV points. (Obviously)

I am using Unity for this, and in Unity, i can't have more then 65k vertices in a single mesh.

So i made this "tile mesh", chunk based. It's still a single mesh. But while I am creating it, i first create the "chunks", (which are 16x16 quad meshes), then i "merge" the chunk meshes to create the tile map mesh.

I keep these "chunk meshes" in a list. So basicly i merge all the meshes in the list when i want to "update" the tilemap mesh.

While i am travelling in the world, i can remove farthest chunk from list, and add new chunkes when it's necessary. List capacity is fixed to 9, so i can never exceed the "65k vertices limit".

Now the problem is, when i zoom out in game, there becomes almost 40k vertices in the scene since whole mesh becomes rendered. (Actually since it's a single mesh, it always renedered as whole, but the animation doesn't occur out side of the camera view)

But when i zoom out, there are like atleast (6x6)x(16x16) = 9.216 tiles. Which makes 36.864 vertices (and UV points).

Now updating few tiles (so few uv points) is easy. But updating the whole 36k point takes like 1-2 seconds. Which is really bad for updating animation in that way.

The code snippet for single quad uv update is here

public void SetTile(Coord chunkCoord, Coord tileCoord, Sprite sprite)
    {
        Vector2[] uv = meshFilter.mesh.uv;
        Rect spriteRect = sprite.textureRect;

        int chunkIndex = SearchForChunk(chunkCoord);

        if (chunkIndex == -1)
        {
            Debug.LogError("Chunk not found");
            return;
        }

        int ui = chunkIndex * (16 * 16) + (tileCoord.Y * 16 + tileCoord.X);
        ui *= 4;

        uv[ui] = ToUV(new Vector2(spriteRect.xMin, spriteRect.yMax), sprite.texture);
        uv[ui + 1] = ToUV(new Vector2(spriteRect.xMin, spriteRect.yMin), sprite.texture);
        uv[ui + 2] = ToUV(new Vector2(spriteRect.xMax, spriteRect.yMin), sprite.texture);
        uv[ui + 3] = ToUV(new Vector2(spriteRect.xMax, spriteRect.yMax), sprite.texture);

        meshFilter.mesh.uv = uv;
    }

It takes chunk coordinate, and finds that chunk in the chunk list, so i can get the index of that chunk mesh for UV array.

The sprite that i get as a parameter is in a "sprite atlas", so i call a helper function to convert it's rectangle to uv points.

That's how i update a single tile's UV points.

But It's too slow, how can i optimize it, make it faster?


texts: Hiding World of Warcraft UI Elements with Lua

texts:
I'm tyring to make a very simple WoW addon that hides the gryphons on either side of the main menu bar and hides the micro buttons in the lower right. The addon has one Lua script, main.lua:

-- main.lua
MainMenuBarArtFrame.LeftEndCap:Hide()
MainMenuBarArtFrame.RightEndCap:Hide()
MicroButtonAndBagsBar:Hide()
CharacterMicroButton:Hide()
SpellbookMicroButton:Hide()
TalentMicroButton:Hide()
AchievementMicroButton:Hide()
QuestLogMicroButton:Hide()
GuildMicroButton:Hide()
LFDMicroButton:Hide()
CollectionsMicroButton:Hide()
StoreMicroButton:Hide()
EJMicroButton:Hide()
MainMenuMicroButton:Hide()

This works perfectly, except the micro button for the shop will not go away. In game, if I enter /run StoreMicroButton:Hide() into the chat, the button will be hidden. Why will the script not hide this element? How can I fix it? Thanks!


texts:
I'm new to LibGDX but I am making a menu with some basic animation, I would like to start with a sprite scaled up and then it would transition to the normal size.

Is it possible with LibGDX or do I have to use a third party library?


texts: I'm making a networked game for mobile. Should I worry about cheating?

texts:
I'm in the process of making a racing game for Android/iOS. I'm thinking of implementing a server/client model, should I worry about cheating and make all players communicate with a server of mine, or will I be good by letting one of the players host the game?

I'm not sure how much memory editing or packet editing is possible in Android/iOS, and that's the main reason why I'm asking this.


texts: What would be the best way to let Box2D handle collision on different (simulated) heights?

texts:
I'm working on a 2D top-down game but we are also using a Z coordinate. This is to simulate the effect of 3D/height. Now the player can walk under a bridge and also over a bridge. The next thing I did was manage collision at these different heights. I got it working that the player collides with the bridge edge when he walks over it, but when he walks under it, he doesn't collide. But I'm not sure if I've done this correctly.

The way I'm currently doing it, is using different bits for different heights:

public static final short ENTITY_Z0_BIT = 1;
public static final short ENTITY_Z1_BIT = 2;
public static final short ENTITY_Z2_BIT = 4;
public static final short COLLISION_Z0_BIT = 8;
public static final short COLLISION_Z1_BIT = 16;
public static final short COLLISION_Z2_BIT = 32;

And then a collision body on Z 1 (or second floor) will have the following filter:

fixtureDef.filter.categoryBits = COLLISION_Z1_BIT;
fixtureDef.filter.maskBits = ENTITY_Z1_BIT;
fixtureDef.filter.groupIndex = (short) 0;

This will mean the wall on the second floor will only collide with an entity on the second floor, because I also change the entity's filter depending on if their Z coordinate increases/decreases. This means I have to add more bits if I need a higher simulated Z-axis and it also doesn't allow for dynamic z-axis handling as I will need to do a big switch-case or if-statements for every Z-axis and then set the filter accordingly.

My second option was setting the groupIndex to be the same as the collision/entity's z-axis + 1. If a collision body and an entity body both have groupIndex 1, they will ALWAYS collide. However if the entity moves up on the z-axis, it's groupIndex will be set to 2 and thus it won't collide anymore. This also seemed like a nice and more dynamic idea. But then anything that needs to collide with a wall or entity, automatically also collides with all the other bodies that need the same groupIndex for the same reason. This doesn't allow for a lot of flexibility.

Which of these 2 options is best? And if there's another better way to handle this, do let me know!


texts: What are the disadvantages of marking every edge as a seam when unwrapping a mesh?

texts:
I'm a programmer who's trying to learn a little basic 3D modelling. I'm reasonably comfortable with basic geometry modelling, and can unwrap and texture simple models. But I have a question...

When it comes to unwrapping models, all the tutorials emphasise the need to mark as few seams as possible when unwrapping a mesh. My question is, why? I'm guessing this is super-obvious to people with modelling experience, but not to me (given that my texturing efforts mostly are constrained to the generation of AO or normal maps).

I’m guessing that it’s purely to do with preserving the model’s shape when it comes to editing the diffuse texture? Is that the only reason you don’t want to simply cut every edge and lay all faces out individually?

I realise I’m displaying my utter ignorance of the subject matter when asking this question, so apologies, but sometimes the super-obvious things are the hardest to find answers to .


texts: How to use Bullet physics with Entity Component Systems?

texts:
I have an Entity Component system and I want to have a Physics Component that would add the given object to the physics simulation.

My problem arises because the Bullet API requires me to add each object before doing the simulation.

How should I proceed to create a System(System in entity component terms) that wraps the Bullet Physics API to do simulation while the Physics components are getting added and removed?

Edit:

This is how my Entity component system looks like.

class Entity
{
    std::unordered_map< size_t, void* > components;
public:
    // setters getters for components based on key
}
class EntitySystem
{
    std::unordered_map< size_t, Entity* > entities; // maps entity GUID to entity*
public:
    // calls function on all entities
    void Process( void* userdata, void (function*)(void*, Entity*) );

    // Entity creation, setting, getting, component index management, etc...
}


texts: Finding a vector perpendicular to a current vector

texts: Assume, that we have a player that has a vector direction. We have an enemy, that is shooting a player. And the task is to find out from which side the enemy is shooting. I know the algorithm, how to find this.We need to find the left vector and then do a dot product with enemy direction vector. The question is to find the left or right side of player's current vision and it means to find out the vector perpendicular to the player's vector. What's the easiest and the most least computation way to find it.


texts: Is it really necessary to test collisions against triangle vertices and edges?

texts:
I'm reading this paper, and using it to perfect the narrow phase collision system for my game engine. To make the question as self-contained as possible, the essential strategy used to detect collisions is the following: scale your axes to reduce the problem to unit sphere/triangle collision, calculate the triangle plane and such, and see if the closest intersection with the plane is inside the triangle itself (probably using barycentric coordinates).

However, beyond this point (going into section 3.4 in the paper), I begin to get confused. He starts talking about some relatively intensive mathematical calculations to test whether the sphere/plane intersection point is on one of the triangle's edges or vertices after testing whether this point is inside the triangle. My question is: why should it possibly be necessary to spend so much computing power on checking against the edges of the triangle? More specifically, why does the original calculation using barycentric coordinates not necessarily account itself for vertices and edges?


texts: How do I approximate the result of battle between two armies with known strengths?

texts:
I need a simple algorithm to calculate the outcome of two differently sized armies battling.

Each army has 1-100 troops and every troop is the same value on the battlefield. The troops do not have individual stats. The only parameter on each army is the number of troops. For example: A with 57 troops battles B with 89 troops. Who wins?

Randomness can be a factor: For example, there could be a 50% chance that team A's total is subtracted by half of team B's total. Here's what I have so far (in a variation of BASIC):

lbl 1
If A>B goto2
If A<(or equal to)B goto3
lbl 2
50% chance B-((A-B)/2)→B
50% chance A-(B/2)→A
goto4
lbl 3
50% chance A-((B-A-/2)→A
50% chance B-(A/2)→B
goto4
lbl 4
If A=0:stop
If B=0:stop
goto1

So this system repeats until one of the armies reaches 0 troops.

The problem is, the battles go too fast. The battle is done almost instantly sometimes. Is there a better algorithm?


texts:
I'm working on a turn based strategy game (like Jagged Alliance), where the player moves his units individually during his turn, while the enemies (zombies) all move and react simultaneously.

I use potential fields for determining where the enemies should go. But I haven't decided yet if the units are only allowed to move in 8 directions, or if they can move in a straight lines when no obstacles are in between several tiles (eliminating zig-zag effect). Using 8d is probably a lot easier for this particular problem.

Steering behaviors seem to fit the bill quite nicely, but they do not go very well with the grid-based world (a unit should always end up within a tile), nor are they deterministic (how many AP did this unit consume). At least I never got it to work very well.

I also briefly considered Silver's cooperative pathfinding, but it does not work too well for units with slight speed differences (or it does given sufficiently small timesteps, but it consumes a lot of memory and processing power).

Any ideas on how to tackle this problem are greatly appreciated!


texts: libgdx: How do you remove a cell from TiledMap?

texts: I am making a Terraria-style sidescrolling game with an open world. I am using a TiledMap to render all of the tiles. If I want to remove a tile, like if it is broken, how would I stop it from being rendered?


texts:
I'm trying to make a target lerp between two objects based on a timer.

At the moment, I have the following code:

   float distCovered = (Time.time - waitTime) * speed;
    float fracJourney = distCovered / journeyLength;
    if (_moveDown == false)
    {
        if (startTime + waitTime < Time.time)
        {

            transform.position = Vector3.Lerp(start.position, end.position, fracJourney);

            if (transform.position == end.position)
            {
                Debug.Log("going down");
               _moveDown = true;

                transform.position = Vector3.Lerp(end.position, start.position, fracJourney);
            }

        }
    }

    if (_moveDown == true)
    {
        float distCovered1 = (Time.time - goDowntimer) * speed;
        float fracJourney1 = distCovered1 / journeyLength;
        transform.position = Vector3.Lerp(end.position, start.position, fracJourney1);

        if (transform.position == start.position)
        {
            Debug.Log("going up");
           // waitTime = 20;
            _moveDown = false;

        }

    }

This code is in my update function and is attached to each of my objects that I want to move up and down. Each object is able to set their wait time independently of the others, thus i can have 1 move after 5 seconds, another after 10 etc.

Then, each target waits a few seconds and moves back down. However, the movement isn't smooth and it tends to jump a set distance. But then, when it gets back to the bottom it goes crazy between the _movedown bool and wont move.

Does anyone know of a way I can fix these issues?

I do know of the Mathf.PingPong method that constantly moves the object back forth between two points, but that wont allow me to pause the movement at each section. Though, if someone knows a way I can do this, please let me know as well.


texts: Strange mesh import problem with Assimp and OpenGL

texts:
Using the assimp library for importing 3D data into an OpenGL application. I get some strange problems regarding indexing of the vertices:

If I use the following code for importing vertex indices:

for (unsigned int t = 0; t < mesh->mNumFaces; ++t)
    {
        const struct aiFace * face = &mesh->mFaces[t];
        if (face->mNumIndices == 3)
        {
        indices->push_back(face->mIndices[0]);
        indices->push_back(face->mIndices[1]);
        indices->push_back(face->mIndices[2]);
        }
    }

I get the following result:

Instead, if I use the following code:

for(int k = 0; k < 2 ; k++)
    {
        for (unsigned int t = 0; t < mesh->mNumFaces; ++t)
        {
            const struct aiFace * face = &mesh->mFaces[t];
            if (face->mNumIndices == 3)
            {
            indices->push_back(face->mIndices[0]);
            indices->push_back(face->mIndices[1]);
            indices->push_back(face->mIndices[2]);
            }
        }
    }

I get the correct result:

Hence adding the indices twice, renders the correct result?

The OpenGL buffer is populated, like so:

glBufferData(GL_ELEMENT_ARRAY_BUFFER,
             indices->size() * sizeof(unsigned int),
             indices->data(),
             GL_STATIC_DRAW);

And rendered as follows:

glDrawElements(GL_TRIANGLES,
               vertexCount*3,
               GL_UNSIGNED_INT,
               indices->data());


texts:
I am trying to generate an island using Simplex Noise. To actually make a island shape i used Amitp's answers to the following questions:

1.Fast, simple procedural 2d island generation

2.Generating random Pools or lakes

Using them i have snippet of code for generation:(width/height is 128)

for(int y = 0; y < HEIGHT; y++) {
        for(int x = 0; x < WIDTH; x++) {
            // amitp's solution
            Vector2 vec = new Vector2(2 * x / WIDTH - 1, 2 * y / HEIGHT - 2);
            float d = Mathf.Sqrt(vec.x * vec.x + vec.y * vec.y);
            //
            float noise = Noise.Generate((float)x / WIDTH * 10, (float)y / HEIGHT * 10);

            // amitp's solution again
            mapData[x, y] = noise > 0.3 + 0.4*d*d ? noise * 10 : 0.0f;
            //

            colors[x + y * WIDTH] = new Color(mapData[x, y], mapData[x, y], mapData[x, y]);
        }
    }

This gives me the following unwanted result:

How do i get fix it to generate properly?

Lastly i'm using Unity.

***EDIT:

Fixed/Changed a couple of things and now i am getting this(still not what i want):

with this changed code:

for(int y = 0; y < HEIGHT; y++) {
        for(int x = 0; x < WIDTH; x++) {
            // amitp's solution
            Vector2 vec = new Vector2(((2 * x) / WIDTH) - 1, ((2 * y) / HEIGHT) - 1);
            float d = Mathf.Sqrt((vec.x * vec.x) + (vec.y * vec.y));
            //
            float noise = Noise.Generate((float)x / WIDTH, (float)y / HEIGHT);

            // amitp's solution again
            mapData[x, y] = noise > 0.3 + 0.4*d*d ? noise * 10 : 0.0f;
            //

            colors[x + y * WIDTH] = new Color(mapData[x, y], mapData[x, y], mapData[x, y]);
        }
    }


texts: Can I start implementing Game Center in my iPhone app, without having created a new app in iTunes connect?

texts:
I'm in the process of developing a game for the iPhone and I want to add Game Center support to it. The problem, as I see it, is that I need to have named my app, created an icon and uploaded screenshots etc. before I can create a leaderboard and start implementation?

My game is unfinished and the iTunes Connect developer guide seems to indicate that certain information can't be edited once entered. Can anyone point me in the right direction on this one?

Thanks.


texts: Controlling spawn properties and overriding NetworkManager in Unity

texts:
I'm trying to find the best approach to controlling the spawn process in a multiplayer unity game.

Having looked over the docs, I have a NetworkManager and it's easy enough to set a player prefab and some other registered prefabs.

What I need to do, it randomly pick the prefab that the player spawns as (from a predefined set).

Having looked over the docs and tutorials I have found two potential options but have not managed to implement either.

a) Override the network manager and provide an implementation of OnServerAddPlayer as per this page: https://docs.unity3d.com/ScriptReference/Networking.NetworkManager.OnServerAddPlayer.html

With this approach I'm not sure how to attach my overridden network manager class to the scene. Do i add it as a component to the NetworkManager? Do I remove the network manage and use this script instead?

b) Provide a spawn manager class as per this page: http://docs.unity3d.com/Manual/UNetCustomSpawning.html

With this approach I'm also unsure how to attach the spawn manager to the rest of the scene. I've tried adding it in the hierachy within an empty game object, but I'm unsure then how to make use of it within my NetworkManager. The docs only give examples of using it to control bullets being created programmatically.

Afraid I'm quite new to unity and just trying to get to grips with the basics. Would really appreciate some pointers on this one.


texts: Is adding quaternions a useful operation?

texts:
I'm working with quaternions and 4x4/3x3 matrices and I have a doubt regarding the use of them.

I think that adding and multiplying quaternions is the same as converting the quaternion to a matrix, do the operation, and then convert back to quaternion.

My question is: In what situation could adding two quaternions be a thing? I mean, when you are working with matrices and you want to "add" two rotations, you have to multiply. Am I missing something?


texts: Which better? Write all scripts on timeline or write it partially on `.as` file?

texts:
I'm going to create a flash game. But I don't know which way for me to write my scripts.

Is it better if I write script part by part and by object so every object has they own script .. or write all of those object's script on single timeline?


texts: How do I calculate the points of a brush from a Source engine VMF?

texts:
I'm trying to render the brushes from a Source engine .vmf file in C++, using OpenGL.

The .vmf stores solid brushes as a series of planes which I would like to use to calculate the points for each brush. I'm pretty sure this would be done exactly the same as for all Quake engine based .map files as well.

Basically each point of the brush is the point where 3 planes intersect. I found a similar question to mine on stackoverflow and the explanation is to get the unit normals for the 3 planes, then use equation 8 on this page mathworld.wolfram.com/Plane-PlaneIntersection.html. My problem is that I have no idea how to implement that

Here's some code for a single 6 sided cube shaped brush:

"plane" "(0 0 256) (0 256 256) (256 256 256)"
"plane" "(0 256 0) (0 0 0) (256 0 0)"
"plane" "(0 0 0) (0 256 0) (0 256 256)"
"plane" "(256 256 0) (256 0 0) (256 0 256)"
"plane" "(0 256 0) (256 256 0) (256 256 256)"
"plane" "(256 0 0) (0 0 0) (0 0 256)"

I really have no idea where to start.


texts: SDL2 LogInfo not outputting with different category?

texts:
So this is probably really simple but I just cannot see it.

I've made my own log class using the SDL_Log functions to output to the console. Only thing is, is that it only outputs using one category type only.

For example. I use this:

Log::getInstance()->info(Log::getInstance()->CAT_APPLICATION, "This outputs fine.");
Log::getInstance()->info(Log::getInstance()->CAT_INPUT, "This doesn't get outputted");

which, in the log class, that uses the following code:

void Log::info(int category, const char* message, ...) { SDL_LogInfo(category, message); }

and:

int CAT_APPLICATION = SDL_LOG_CATEGORY_APPLICATION;
int CAT_INPUT = SDL_LOG_CATEGORY_INPUT;

I've also tried the normal method:

SDL_LogInfo(SDL_LOG_CATEGORY_INPUT, "but this doesn't get outputted either if the app cat is outputted first");

Any ideas on why it's not outputting "CAT_INPUT" but is outputting "CAT_APPLICATION"? And how I could get it outputting all of them?


texts: I've created a script, which is drawing a line along a bezier curve, so that I can animate whatever I want with lines, mostly for UI purposes. For the moment I'm using a line renderer, which works, but the performance is not that great in my opinion. So I was wondering if there are actually some better methods to draw lines, like simply creating a mesh along the path I've got.


texts:
I'm trying to create MMORPG with huge world divided by chunks. I was thinking a lot about servers architecture. I don't want my main game server to have direct access from clients and I do want to have some abilities for load balancing and for expanding whole system.

Finally I came up with this architecture:

The Game Server - which store game state and trigger events and so on. This server does not communicate with clients. It will be connected to database to store game state from time to time.
Streaming Servers - servers that handle client connections and stream game state to them as far as players actions to server. I suppose them to work through UDP. With this  approach I will have some benefits:

I can put then in different countries to lower pings.
I can have as many then as my budget allows me to. Adding more streaming servers would allow to handle more client online.
if something happens with one of streaming servers (due to hacker attacks or server hardware/software failure) this will not effect whole systems and other players experience. Players from this server can be routed to another.

Physics Servers - they would handle chunk physics and maybe some other heavy stuff. With adding new physics servers I can extend my system so that it would able to proceed more and more data, if needed.

What are the pitfalls of such an architecture? How good is it?

How would clients know to which streaming server they should connect? I suspect that here I should have one more - routing server that would do something like load balancing stuff and route user to one of the working streaming servers.

Would I have some problems with data synchronization?


texts: What public animation file formats are there available for 2D games? I'd like to know about both formats for procedural/skeletal animation, as well as traditional animation.


texts: LibGDX: Do I have to dispose a texture if I load it from AssetManager?

texts:
AssetManager manager = new AssetManager();

manager.load("texture1", Texture.class);
manager.load("texture2", Texture.class);
manager.load("texture3", Texture.class);
//And so on...

And then I load it from another screen, do I still have to dispose it? Or manager does it when I call manager.clear?


texts: Object completely losing orientation using Lerp

texts:
So, I am making a 2d board game with unity.
Basically, two characters are moving on the board when clicking a spot on the board.
Since it's a static one frame 2d game, I put all of my game objects children of the canvas.
All the positions seems to be aligned, in the canvas itself everything is in place, also when I am debugging I notice that both of the positions, the local position and the target position are correct, so when I'm not using lerp and just setting the character position to the target position, it works perfect.
Lerp/Smooth damp are working perfect outside the canvas
I think it's something related to the update function, as it's updating false positions, but that's all I can guess...
This is the Update function of the Player class:
        private void FixedUpdate()
{
    if (moveTowards == true)
    {
        velocity = Vector3.zero;
        this.transform.position = Vector3.SmoothDamp(this.transform.localPosition, targetSpotPosition, ref velocity, .08f);
    }

    if (this.transform.position == targetSpotPosition)
    {
        moveTowards = false;
    }
}

moveTowards set to true when clicking a spot.
    public void movePlayerTo(Spots moveHere)
{
    moveTowards = true;
    moveHere.transform.position = Camera.main.ScreenToWorldPoint(moveHere.transform.position);
    targetSpotPosition = moveHere.transform.position;
    //targetSpotPosition = Camera.main.ScreenToWorldPoint(targetSpotPosition);
}

moveHere is the spot's position, there's no problem there.
I set my canvas to camera space render mode, and of course scale with screen size. Before putting everything in the canvas, it worked perfectley.
HELP PLEASE.
Thanks in advance,
Omer


texts:
Currently, to construct a world matrix, I have the following code:

return FromScale(scale) * rotation.RotMatrix * FromTranslation(translation);

However, this is constructing three matrices, and then applying two multiply operations between them in order to assembly the final world matrix.

However, I'm pretty sure there must be an algorithm or listing for constructing the SRT matrix 'in-place', by doing the necessary multiplications for each matrix element first, and then simply assembling the resultant matrix from that.

However, I can't seem to find a reference for that anywhere; the closest I found was for an SRT transformation with a rotation around a single axis.

Can anyone show me how to make an 'inline' SRT matrix? Or TRS, I don't mind. Row-major or column-major is fine, also.


texts:
So I was making an android game in unity3d. I wrote a script to draw straight lines with touch what I do is I first create a gameobject named temp and add line renderer to it and give the line renderer properties. Then I create a collider gameobject , parent it to the line and change its dimensions to the dimension of the line. What I am trying to do is add two colliders one while the line is being moved i.e "touch.phase == TouchPhase.Moved" and delete this collider and add another collider when "touch.phase == TouchPhase.Ended". For some weird reasons I am not able to delete the first collider.

Here is my code

void Update()
{

    foreach (Touch touch in Input.touches)
    {

        if (touch.phase == TouchPhase.Began)
        {
            temp = new GameObject();
            temp.AddComponent<LineRenderer>();
            temp.layer = LayerMask.NameToLayer("lines");

            lr = temp.GetComponent<LineRenderer>();
            lr.positionCount = 2;
            lr.SetWidth(0.2f, 0.2f);
            lr.material = new Material(Shader.Find("Sprites/Default"));
            lr.SetColors(Color.black, Color.black);

            temp.transform.position = camera.ScreenToWorldPoint(touch.position) + camOffset;
            fingerUp = camera.ScreenToWorldPoint(touch.position)+camOffset;

            lr.useWorldSpace = true;
            spawnCollider = false;

        }

        //Detects Swipe while finger is still moving
        if (touch.phase == TouchPhase.Moved)
        {
            lr.SetPosition(0, fingerUp);
            fingerDown = camera.ScreenToWorldPoint(touch.position)+camOffset;
              lr.SetPosition(1,fingerDown);
            spawnCollider = true;

            lastLine = temp;

            // The first collider temporary one

            BoxCollider2D col1 = new GameObject().AddComponent<BoxCollider2D>();
            col1.transform.parent = temp.transform;
            float lineLength = Vector2.Distance(fingerUp, fingerDown);
            col1.size = new Vector2(lineLength, 0.2f);
            Vector2 midPoint = (fingerUp + fingerDown) / 2;
            col1.transform.position = midPoint;
            float angle = (Mathf.Abs(fingerDown.y - fingerUp.y) / Mathf.Abs(fingerDown.x - fingerUp.x));
            if ((fingerUp.y < fingerDown.y && fingerUp.x > fingerDown.x) || (fingerDown.y < fingerUp.y && fingerDown.x > fingerUp.x))
            {
                angle *= -1;
            }
            angle = Mathf.Rad2Deg * Mathf.Atan(angle);
            col1.transform.Rotate(0, 0, angle);

        }

        if (touch.phase == TouchPhase.Ended)
        {
            if (spawnCollider == true)
            {
                Destroy(col1);  // Deleting the first collider

                // Adding the final collider
                BoxCollider2D col = new GameObject("Collider").AddComponent<BoxCollider2D>();
                col.transform.parent = temp.transform;
                float lineLength = Vector2.Distance(fingerUp, fingerDown);
                col.size = new Vector2(lineLength, 0.2f);
                Vector2 midPoint = (fingerUp + fingerDown) / 2;
                col.transform.position = midPoint;
                float angle = (Mathf.Abs(fingerDown.y - fingerUp.y) / Mathf.Abs(fingerDown.x - fingerUp.x));
                if ((fingerUp.y < fingerDown.y && fingerUp.x > fingerDown.x) || (fingerDown.y < fingerUp.y && fingerDown.x > fingerUp.x))
                {
                    angle *= -1;
                }
                angle = Mathf.Rad2Deg * Mathf.Atan(angle);
                col.transform.Rotate(0, 0, angle);
            }
        }

    }

}

I have added comments where I am doing what.


texts: Understanding how to create/use textures for games when limited by power of two sizes

texts:
I have some questions about the creating graphics for a game.

As an example. I want to create a motorbike. (1pixel = 1centimeter)
So my motorbike will have 200 width and 150 height. (200x150)
But the libgdx only allows to load sizes with the power of 2?! (2,4,8,16,...)

First I thought about that way.
I will create my bike with the size (200x150) and save it as png. Than I will open it again (e.g. with gimp) resize the image to a size which uses values with power of 2 (128x128). I will load that as texture in the programm and set width as 200 and height as 150.

But wouldn't it be a problem? Because I will lose some pixel information when I make the first conversation.?! Isn't it?


texts: What is the science behind 3d collision relative to the ground?

texts:
To my understanding you have the model of the character and the model of the map.
It seems extremely redundant and process intensive to have to calculate that the ground exerts a force on the player model.
So to my understanding if y coord was less than a certain value then the physics would behave differently.
but what if the map becomes an incline instead of linear? the model would just walk through the ramp into nothingness....
EDIT: i remember a commercial game where you could "sink" if your speed was high enough. So it seems to me like the ground is somehow coded to exert a force on the player without putting too much work on th cpu


texts: What applications can I use to generate music?

texts: In my cocos2d iPhone app I wanted to have in game music. But I don't want to use garageband! It is just dragging prewritten loops. I wanted to compose the music for my game. Is there software that I can use to write music, such as techno music? Not taking songs that were made by someone else and adding effects.


texts: What does it actually mean by World, Window and Viewport?

texts:
I am studying Computer Graphics myself. I am stuck with the concept of World, Window and View-port.

As far as I understood:

(1) World - is an abstract and imaginary space that is imagined to exist inside the Graphics rendering software (like Blender, 3D Studio Max, and so on) or a framework/library/engine like OpenGL or Directx, or, Unreal Engine where the objects/models (to be displayed) are measured in units specific to that software or library or engine. We are generally habituated to measure pictures of all geometric objects as the units of integer/real numbers on papers or books. And, in computer monitor screens they are measured in Pixels. But, due to some problems like ________________, developers use a coordinate system imagined and implemented in their software/framework/library/ engine and that is called a World Coordinate system. For example, OpenGL uses fractional values to measure and plot an object which seems to be totally impossible, because, computer screens do not have such abilities, they only understand pixels. So what is the catch? Before displaying on the computer screen, the OpenGL's world coordinate measurements are converted to actual screen pixels (through a mechanism called Graphics Pipeline) and that is how a model or object can be displayed on the computer screen.

(2) Window - Window is the a cut-section area (that we want to display on the computer screen) of the imaginary graphics World.

(3) Viewport - Viewport is the actual image we see on the screen. That is displayed by converting the world coordinate into screen pixels.

Am I correct?

Please, fill in the blank and review my conception thus far.

And, if you do down-vote, or, closed-vote, please, leave a comment so that I can understand the reason.


texts:
I'm trying to implement the Wander Steering Behaviour but getting strange result (see .gif). What am i doing wrong? I want to move a sphere in a random direction.

I read this article Understanding Steering Behaviors: Wander

using UnityEngine;

public class UnitWander : MonoBehaviour
{
    public const float CircleDistance = 1f;
    public const float CircleRadius = 0.1f;
    public const float AngleChange = 50f;

    public float Mass = 1;
    public float MaxSpeed = 1;
    public float MaxForce = 1;

    private Vector3 velocity = Vector3.forward;
    private float wanderAngle;

    private void Update()
    {
        var steering = GetWanderForce();
        steering = Vector3.ClampMagnitude(steering, MaxForce);
        steering /= Mass;

        velocity = Vector3.ClampMagnitude(velocity + steering, MaxSpeed);
        transform.position += velocity;
        transform.forward = velocity;
    }

    private Vector3 GetWanderForce()
    {
        var circleCenter = velocity.normalized * CircleDistance;

        var displacement = transform.right * Mathf.Cos(wanderAngle * Mathf.Deg2Rad) * CircleRadius;
        displacement += transform.up * Mathf.Sin(wanderAngle * Mathf.Deg2Rad) * CircleRadius;

        wanderAngle += (Random.value * AngleChange) - (AngleChange * 0.5f);

        var wanderForce = circleCenter + displacement;
        return wanderForce;
    }
}