texts: Why is Spritebatch drawing my Textures out of order?

texts:
I just started working with XNA Studio after programming  2D games in java. Because of this, I have absolutely no experience with Spritebatch and sprite sorting. In java, I could just layer the images by calling the draw methods in order. For a while, my Spritebatch was working fine in deferred sorting mode, but when I made a change to one of my textures, it suddenly started drawing them out of order. I have searched for a solution to this problem, but nothing seems to work. I have tried adding layer depths to the sprites and changing the sort mode to BackToFront or FrontToBack or even immediate, but nothing seems to work. Here is my drawing code:

    protected override void Draw(GameTime gameTime) {
        GraphicsDevice.Clear(Color.Gray);
        Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);

        for (int x = 0; x < 5; x++) {
            for (int y = 0; y < 5; y++) {
                region[x, y].draw(((float)w / aw)); // Draws the Tile-Based background
            }
        }

        player.draw(spriteBatch, ((float)w / aw));//draws the character (This method is where the problem occurs)
        enemy.draw(spriteBatch, (float)w/aw); // draws a basic enemy
        Game1.spriteBatch.End();
        base.Draw(gameTime);
    }

Player.Draw():

public void draw(SpriteBatch sb, float ratio){
        //draws the player base (The character without hair or equipment)
        sb.Draw(playerbase[0], new Rectangle((int)(pos.X - (24 * ratio)), (int)(pos.Y - (48 * ratio)), (int)(48 * ratio), (int)(48 * ratio)), new Rectangle(orientation * 48, animFrame * 48, 48, 48), Color.White,0,Vector2.Zero,SpriteEffects.None,0);
        //draws the player's hair
        sb.Draw(playerbase[3], new Rectangle((int)(pos.X - (24 * ratio)), (int)(pos.Y - (48 * ratio)), (int)(48 * ratio), (int)(48 * ratio)), new Rectangle(orientation * 48, animFrame * 48, 48, 48), Color.White, 0, Vector2.Zero, SpriteEffects.None, 0);
        //draws the player's shirt
        sb.Draw(equipment[0], new Rectangle((int)(pos.X - (24 * ratio)), (int)(pos.Y - (48 * ratio)), (int)(48 * ratio), (int)(48 * ratio)), new Rectangle(orientation * 48, animFrame * 48, 48, 48), Color.White, 0, Vector2.Zero, SpriteEffects.None, 0);
        //draws the player's pants
        sb.Draw(equipment[1], new Rectangle((int)(pos.X - (24 * ratio)), (int)(pos.Y - (48 * ratio)), (int)(48 * ratio), (int)(48 * ratio)), new Rectangle(orientation * 48, animFrame * 48, 48, 48), Color.White, 0, Vector2.Zero, SpriteEffects.None, 0);
        //draws the player's shoes
        sb.Draw(equipment[2], new Rectangle((int)(pos.X - (24 * ratio)), (int)(pos.Y - (48 * ratio)), (int)(48 * ratio), (int)(48 * ratio)), new Rectangle(orientation * 48, animFrame * 48, 48, 48), Color.White, 0, Vector2.Zero, SpriteEffects.None, 0);
    }

the game has a top-down perspective much like the early legend of zelda games. It draws sections of the texture depending on which direction the character is facing and the animation frame. However, instead of drawing the character in the order the draw methods are called, it ends up drawing the character out of order. Please help me with this problem.


texts: How do I get an unique hardware id with gdscript?

texts:
Using Godot Engine, I'm trying to implement digital rights management (DRM) using an uuid, and I want to get the user's MAC address.  Is there an easy way to do this with gdscript?
On Linux, I could call OS.execute to run "ip link show" and parse out mac addresses from the output.  However, I would rather not maintain platform specific versions.  I also hope to avoid having to compile in native code.


texts:
I want to create a game in which I rotate a cube around 2 fixed axes(x and y) using my mouse.

Here is what I want to do. Just use the mouse to see what kind of rotation I want.

I calculated my yaw and pitch values according to mouse movement and they work fine when I try to rotate only around one axis(x or y), but when I try to rotate around both axes it doesn't work(because OpenGL rotates axes when you apply a rotation). How do I make them both work at the same time? Here my code:

glm::mat4 model;
glm::mat4 view;
glm::mat4 projection;

float cameraDistance=3.0;

glm::vec3 center=glm::vec3(0.0f, 0.0f, 0.0f);
glm::vec3 cameraFront = glm::vec3(0.0f, 0.0f, -1.0f);
glm::vec3 cameraUp    = glm::vec3(0.0f, 1.0f,  0.0f);
glm::vec3 modelDistance= glm::vec3(0.0,0.0,3.0);

int oldX,oldY;
GLfloat yaw   = 0.0f; // Yaw is initialized to -90.0 degrees since a yaw of 0.0
                      // results in a direction vector pointing to the right (due
                      // to how Euler angles work) so we initially rotate a bit
                      // to the left.
GLfloat pitch =   0.0f;

while (running)
{
    oldX=sf::Mouse::getPosition(window).x;
    oldY=sf::Mouse::getPosition(window).y;

    yaw=oldX*0.1;
    pitch=oldY*0.1;

    projection = glm::perspective(45.0f, (GLfloat)WIDTH / (GLfloat)HEIGHT, 1.0f, 100.0f);

    view=glm::mat4();
    view = glm::lookAt(center+modelDistance, center+modelDistance + cameraFront, cameraUp);

    model= glm::mat4();

    //Here is the problem,how do i use both at the same time?
    model=glm::rotate(model,glm::radians(yaw),glm::vec3(0.0,1.0,0.0));
    model=glm::rotate(model,glm::radians(pitch),glm::vec3(1.0,0.0,0.0));
    //
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    ourShader.Use();

    GLint modelLoc = glGetUniformLocation(ourShader.Program, "model");
    GLint viewLoc = glGetUniformLocation(ourShader.Program, "view");
    GLint projLoc = glGetUniformLocation(ourShader.Program, "projection");

    glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));
    glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view));
    glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(projection));

    glBindVertexArray(VAO);
    glDrawArrays(GL_TRIANGLES, 0, 27*n*n);


texts: Rotation matrices from Quaternion.Identity and -Quaternion.Identity are the same?

texts:
If I create a rotation matrix from an identity quaternion then it is the same as a creating it from a negative identity quaternion

        Matrix m0 = Matrix.CreateFromQuaternion(Quaternion.Identity);
        Matrix m1 = Matrix.CreateFromQuaternion(-Quaternion.Identity);

        Console.WriteLine(m0);
        Console.WriteLine(m1);

        Console.WriteLine(m0.Forward);   // {X:0 Y:0 Z:-1}
        Console.WriteLine(m1.Forward);   // {X:0 Y:0 Z:-1}

Why is this the case?

If I use a negative identity matrix

        Quaternion q0 = Quaternion.CreateFromRotationMatrix(Matrix.Identity);
        Quaternion q1 = Quaternion.CreateFromRotationMatrix(-Matrix.Identity);

the orientation will be rotated 180 degrees as expected.


texts: Unity 2D Graphics Optimization For Mobile Devices

texts:
I want some advices on how to create graphical assets for mobile devices so that the game will have a good performance and not lag on mobile devices.

I had 3 issues with my games and that is they all lag after playing a little while, some lag more some less but they all lag, I think the problem is in the graphical assets. Some of the games were simple as flappy bird with a couple of images in the project but the game was lagging after playing it for a minute or two.

Now my question is, how to create graphical assets, do I need to export them on 16bit or 32bit and what is the difference, which options should I set in unity, compressed, true color, 16 bit?

And are there some other options that I can check or uncheck in unity so that the graphics will perform better on my game?

When I pack my assets in a sprite sheet, should I put them on larger sprite sheets for example 2048x2048(which is one of the options for max size in unity) or should I pack them on smaller sprite sheets?

Does a sprite sheet have to be to the power of two e.g 1024x1024 or 512x512 or I can pack my assets until they fit and the size does not matter for example the sprite sheet can be 640x410 or something like that, not on the power of two?

Does it make a difference when there is free space in a sprite sheet does that affect graphic performance or do I need to squeeze the sprites closer to each other so that there will be no empty space in the sprite sheet?

Please answer the question that I'm asking, last time I posted the same question people started asking me about the game, did I do this or that and my question then went off topic and got closed, the game is not the question, the question is everything that I mentioned above or if you have something to add that will help me.

If you can help me about this then please answer, and again please don't ask about the game and did I do this or that in the game. I hope that my question is clear, and that it is not off topic.


texts: Improving my Roguelike Dungeon generator?

texts: I am looking to find improvements upon my Roguelike Dungeon generator. I find it is not 'roguelike' enough, with dungeons just looking like a mess more than anything. What would improve my generator(images below)? I just can't seem to get it to look 'right'. Reference image for what roguelike should appear as: [link]


texts: Enabling and Disabling children in Unity

texts:
I'm trying to create an enable/ disable game objects in Unity.  I used GameObject.SetActiveRecursively but it only works one-way.

I used a collider in which when an object enters the collider.  The game objects become enabled.  When they leave or get to a certain point, they disable.

How would I make this a two way system, making it able to be enabled while inside the collider and disabled when outside the collider?

-- The collider is in the game object who is being disabled and enabled.

According to this information from Unity Answers, the object becomes disabled.  So how would I make the object enabled?

function OnTriggerEnter(other : Collider){
    if(other.tag == "Player"){
        gameObject.SetActiveRecursively(true);

    }
}

function OnTriggerExit(other : Collider){
    if(other.tag == "Player"){
        gameObject.SetActiveRecursively(false);
    }
}


texts: How can I implement framerate-independant updates?

texts:
Edit:
I fixed the problem by making jumpvelocity the one that is modified and added onto, and yvelocity just equal jumpvelocity * t. This is what I have right now:

if (GUI->Space && grounded){
    jumpvelocity = -185.f * 2  / gravity;
    grounded = false;

}

if(!grounded ){
    if(jumpvelocity < terminaly){
        jumpvelocity += 185.f * t * 4  / gravity;
        yvelocity = jumpvelocity * t;
    }
    else{
        jumpvelocity = terminaly;
        yvelocity = jumpvelocity * t / gravity;
    }
}
else{
    yvelocity = 0.f;
    jumpvelocity = 0.f;
}

Thanks for the help.

I am trying to get my gravity to work. The code I have so far is

if (jumpvelocity < 0){
   yvelocity = jumpvelocity * t *2/gravity;
    jumpvelocity += 185.f*t * 2 / gravity;
}

else if(!grounded ){
    if(yvelocity < terminaly)
        yvelocity += t / gravity;
    else
        yvelocity = terminaly;
}

Gravity scales upwards, the higher making falling and jumping slower. It's default value is 1. Jumpvelocity is set to 185 when the player wishes to jump. My problem is that you fall slower at a slower framerate, but you jump at the same speed as if it was a higher framerate. How would I make it frame independent? T is delta time.


texts:
I'm having a strange issue that I cannot seem to remedy.  I am doing some prototyping with Pygame on a desktop running windows and a laptop running OS X.  Both are running python v2.7.3 (installed via homebrew for the Macbook) and pygame v1.9.1.

For transparency, I have been using set_colorkey with a transparency color of (255, 0, 255).  Here is the applicable code:

transColor = pygame.Color(255, 0, 255)
image = pygame.image.load(playerPath + "idle.png").convert()
image.set_colorkey(transColor)

This works flawlessly on my windows machine.  On my laptop, it does not work.  It just shows the hideous magenta color.  Here's the strange part.  If I change the transColor to (0, 0, 0), all black pixels in my images are transparent.  Has anyone run into this issue before?


texts: Need help getting an objects orientation / all my OpenGL rotations are reversed

texts:
I'm using OpenGL on Ubuntu Linux with the Eclipse IDE and the GCC compiler. I am bringing blender models into a homemade renderer/game engine.
I parse a text file containing object descriptions to load models.
Example object:
begin_object generic_object
generic_object_name lampost
generic_object_parent_name world
generic_object_position -10.0000 -10.0000 2.000000
generic_object_rotation 90.000000 0.000000 0.000000
generic_object_scale 1.000000 1.000000 1.000000
end_object

begin_object ...

The generic_object_rotation 90.000000 0.000000 0.000000 line describes 3 values:

Rotation around Z (XY).
Rotation around X (YZ).
Rotation around Y (XZ).

After going through all the headaches of Euler angles and their gimbal lock and singularities, I switched all my code to quaternions (highly recommended).
I am told that a counter-clockwise rotation around the Z-axis, looking down the Z-axis toward the origin uses a rotation matrix like:
cos(theta)  -sin(theta)  0  0
sin(theta)  cos(theta)   0  0
0           0            1  0
0           0            0  1

I got this from a document (rotgen.pdf) off the Song-Ho website.
If I replace theta with +90.0 (just like in my input file above), the result is:
  0.0 ,  -1.0 ,  0.0 ,  0.0
  1.0 ,   0.0 ,  0.0 ,  0.0
  0.0 ,   0.0 ,  1.0 ,  0.0
-10.0 , -10.0 ,  2.0 ,  1.0

So, I make a quaternion for +90.0 degrees, turn it into a matrix and then print out the matrix to see if it is the same, and I actually get the same matrix.
  0.0 ,  -1.0 ,  0.0 ,  0.0
  1.0 ,   0.0 ,  0.0 ,  0.0
  0.0 ,   0.0 ,  1.0 ,  0.0
-10.0 , -10.0 ,  2.0 ,  1.0

All is well... Then, I send this matrix to the shader to draw this object and it rotates my object CW instead.
In the shader there's:
gl_Position = projection_matrix * view_matrix * model_matrix * vec4( aPos , 1.0 );

which seems correct.
So, I made a cube in Blender, attached different colour textures to each side of the cube so I could verify that my input data was good and, as long as the model_matrix is the identity matrix, the object is oriented correctly in space. Any time I add rotations, the models rotate in the
opposite direction. This happens on all 3 axes.
My current goal/project is the parenting system. I want to be able to extract orientation and position from the model matrix of any object (that data is stored with the object).
Specifically, right now, I want to extract the forward vector from the model_matrix so I can attach a light source to this rotating object. Set its light direction for the fragment shader. That is when I found this error.
What I am seeing:
The rotation of the object is opposite to what I command. When I rotate 0-360 over and over again, the forward vector I am reading from the objects model_matrix diverges from the direction of the object until it gets to 180 degrees, where the face of the object and the forward vector are coincident again; then they diverge again until we reach 360 and they are again coincident.
What I expect (and this may be part of my issue):
I want the rotation part of the model_matrix that rotates the object to be the current orientation of the object. And it looks like it is but the object does not render that way. The object rotates in the opposite direction (which is preventing me from getting the correct light direction vector, i.e. the forward vector).
Is this an OpenGL thing? Is the orientation of an object the transpose of the 3x3 rotation section of the model_matrix?


texts: Can I keep get out of Unity editor features if I'm using ECS Pattern?

texts:
I'm learning about ECS Pattern to use it in my Unity game, as I saw until now, most of stuffs is created by code.

As I know, each Unity GameObject is a Entity which contains many of Components and GameObjects are instantiated by code (created by my script, for example).

My question is, when I use ECS Pattern, can I keep using the bunch of features offered by Unity editor (like Prefabs, ScriptObjects, Drag Dropg to position, etc) or I need to control all of them by code?


texts: Occupation groups for a country simulation game

texts:
I'm trying to create citizen occupation groups or job classes for a country-management game I'm developing. I want it to be inclusionary but also very basic.

I did some research but all job lists I got contains more than 20 job types like farming, mining, education, law but It's too many for my game's setting and It still doesn't include every workforce. I need wider spectrum of jobs but I'm having trouble to categorize them, like labour, public service etc...

Any help is appreciated.


texts: Polygon count target range for MMO being released in 2 years

texts:
What would a realistic poly count target range be for NPC and player models in a 3D MMO that will be released in 2 years? What about poly count target range for the entire camera view (environment, NPC and player meshes)?

I read in some places that one should not aim too low if the game will come out in a couple years because technology is always advancing. If you can give some mesh poly stats on what other current MMOs / MMORPGs are running and future projections, that would be great.

Thank you.


texts: Reading XML working in my computer but not in my Android phone

texts:
Following code works perfect in my computer but when I try to run it in my Android Phone, it does not work.

string path = @"Assets\Layout\XML\file" + select.ToString() + @".xml";
XmlSerializer xmlSerializer = new XmlSerializer(typeof(List<Name>));
StreamReader sr = new StreamReader(path);
List<Name> listnames = (List<Name>)xmlSerializer.Deserialize(sr);

How can I make the code work in my Android Phone?

PS: It is C# , Unity.


texts:
I'm creating a space shooter using type script and I don't understand why explosions won't work meaning that nothing is drawn on the screen and I don't understand what I'm doing wrong.

for (var i = 0; i < projectileList.length; i++) {
    if (this.y >= projectileList[i].y) {
        let projDist = this.x - projectileList[i].x;
        if (projDist < 0) {
            projDist = projDist * (-1);
        }

        if (projDist >= 0 && projDist <= 30) {
            this.x = Math.floor(Math.random() * 600) + 1;
            this.y = 20;
            projectileList[i].x = 2000;
            for (var j = 1; j <= 9; j++) {
                this.sprite = "/images/explode_" + j + ".png";
                this.img.src = this.sprite;
                this.gameContext.drawImage(this.img, 200, 200);
            }
        }
    }
}

Basically when there is a collision between projectiles and asteroids, I'm just trying to draw some images on the screen but nothing is happening and the console won't give any errors :( Do you guys know what is wrong?

Thanks for help!


texts:
I know quite well how to check for collisions, but I don't know how to handle the collision in a good way.

Simplified, if two objects collide I use some calculations to change the velocity direction. If I don't move the two objects they will still overlap and if the velocity is not big enough they will still collide after next update. This can cause objects to get stuck in each other.

But what if I try to move the two objects so they do not overlap. This sounds like a good idea but I have realised that if there is more than two objects this becomes very complicated. What if I move the two objects and one of them collides with other objects so I have to move them too and they may collide with walls etc.

I have a top down 2D game in mind but I don't think that has much to do with it. How are collisions usually handled?

This question is asked on behalf of Wooh


texts: Making animations not smooth while using Record button

texts:
In my 2D sidescroller game, I want to separate the animations for the head and the body of my character.

While idling, my charcter's body bounces slightly up and down (kind of a breathing motion). Thus, the head should keep up.
However, when I press Record and make adjustments for the head, the head moves up and down smoothly instead of following the body frame by frame.

How can I remove the smooth transitions from one position to the other?

Here is a screenshot from Unity demonstrating the hierarchy and the animation keyframes.


texts: Is there a way to convert a shader code to shader graph?

texts:
I would like to ask if there is a way to convert a Coded shader into the new Shader graph, beacause i want to edit my shaders in more efficient way.

Any help is appreciated.


texts: libgdx - how to make enemies not overlap

texts:
I'm currently making a roguelike shooter in libgdx to get a better understanding of the library but I recently just stumped onto a problem where enemies would overlap each other while tracking the player's movements. The code I use to calculate the angle for the enemy to take is simple trigonometry. After moving the player around the screen a for a little bit, the enemies' paths intersect to the point where it just looks like a single mesh of textures following the player. Here's the code:

// track player
radians = MathUtils.atan2((player.getY() + player.getHeight() / 2) - (y + enemy.getRegionHeight() / 2),
        (player.getX() + player.getWidth() / 2) - (x + enemy.getRegionWidth() / 2));
dx = MathUtils.cos(radians) * speed;
dy = MathUtils.sin(radians) * speed;

An solution that allows the enemies to recalculate their angle would be much appreciated.


texts: How to make non-standard sized zones for a procedurally generated 2d map?

texts:
I am making a procedurally generated map with different zones (plains, forest, village, etc) and am currently just designing each one as a square zone. However, I think it'd be neat if the zones were more randomly distributed so that they could be irregular sizes. I'm not sure how to do that in a good way. (Any given tile needs to know what zone it belongs to quickly and deterministically based on its x, y, and random seed for the world)
Are there existing algorithms for this?


texts: Tactics for moving the render logic out of the GameObject class

texts:
When making games you often create the following game object from which all entities inherit:

public class GameObject{
    abstract void Update(...);
    abstract void Draw(...);
}

So in you update loop you iterate over all the game objects and give them a chance to change state, then in the next draw loop you iterate again over all the game objects and give them a chance to draw themselves.

Although this works fairly well in a simple game with a simple forward renderer it often leads to a few gigantic game objects that need to store their models, multiple textures and worst of all a fat draw method that creates a tight coupling between the game object, the current render strategy and any rendering related classes.

If I were to change the render strategy from forward to deferred I would have to update a lot of game objects. And the game objects I make are not as reusable as they could be. Of course inheritance and/or composition can help me fight code duplication and make it a bit easier to change implementation but it still feels lacking.

A better way, perhaps, would be to remove the Draw method from the GameObject class altogether and create a Renderer class. The GameObject would still need to contain some data about it's visuals, like what model to represent it with and what textures should be painted on the model, but how this is done would be left to the renderer. However there are often a lot of border cases in rendering so although this would remove the tight-coupling from the GameObject to the Renderer, the Renderer would still have to be all knowing about all the game objects which would make it fat, all knowing and tightly-coupled. This would violate quite a few good practices. Maybe Data-Oriented-Design could do the trick. Game objects would certainly be data, but how would the renderer be driven by this? I'm not sure.

So I'm at a loss and can't think of a good solution. I've tried to use the principles of MVC and in the past I had some ideas about how to use that in games, but recently it doesn't seem as applicable as I thought. I would love to know how you all tackle this problem.

Anyway let's recap, I'm interested in how the following design goals can be achieved.

No rendering logic in the game object
Loose coupling between game objects and render engine
No all knowing renderer
Preferably runtime switching between render engines

The ideal project setup would be a separate 'game logic' and render logic project that don't need to reference each other.

This thought train all started when I heard John Carmack say on twitter that he has a system so flexible he can swap out render engines at run time and can even tell his system to use both renderers (a software renderer and a hardware-accelerated renderer) at the same time so he can inspect differences. The systems I've programmed so far aren't even near that flexible


texts: Is there any guarantee about the graphical output of different GPUs in DirectX?

texts:
Let's say that I run the same game in two different computers with different GPUs.
If for example they are both certified for DirectX 10. Is there a guarantee that the output for a given program (game)  is going to be the same regardless the manufacturer or model of the GPU? I am assuming the configurable settings are exactly the same in both cases.

I heard that it is not the case for DirectX 9 and older, but that it is true for DirectX 10. If someone could provide a source confirming or denying it, it would be great.
Also what is the guarantee offered. Will the output be exactly the same or just perceptually the same to the human eye?


texts: How and where to transform a Camera Frustum onto a tilted screen?

texts:
In rendering tutorials for perspective projection the assumption is that the rendering surface is perpendicular to the sight line.

As shown here:

How to accommodate for a screen that is tilted vertically and/or to one side?

This would be done in the context of screens for a vehicle window shields where the monitors are tilted forward and installed in place of the glass.

(I realize it would be better if they were perpendicular but this is beyond my control.)

Is there a way to build a custom perspective transform by defining the 4 points of the monitor in camera space and projecting to a near and far clipping plane?

Edit: to add some detail... I have the ability to modify the perspective transform that is being fed to the vertex shader that performs the transform.

I can also insert a pixel shader, but do not think a pixel shader is the correct tool.


texts: Is a recursive game object update better than a linear one?

texts:
I have a tree of gameobjects, so every node contains a list of children.
In update function:
Is it better to do recursive or linear walking through game objects.

update() {
    update self;
    foreach child call update;//recursive call
}

or

array of children = root.getAllChildrenRecursive
foreach child in array of children call update; //linear walking through gameobjects.


texts:
I've been struggling with this for a while. I have been trying to create a bullet pool class for a game I have made that doesn't cause a significant fps drop.

I have tried creating a bullet pool and have also tried dynamically creating and deleting bullets, both of which drop the fps of the game around 10-15.

I ran a test a few days ago and just put a return statement in the bullet pool's firebullet function, which represented the logic leading up to this, function calling, etc.

This only dropped the fps 2-4. If I can fire bullets without dropping the fps more than another 2-3, I would be satisfied. My bullets are autorelease objects that are a subclass of a ccnode.

I create a ccsprite and a box2d b2body for each one. I am working on the ios platform. Any thoughts on how to make this more efficient? Has anyone managed to do something similar to this?


texts: Calculate speed of object for specific device

texts:
I have an object - player - which is moving X px ahead each update (updates  based on device FPS). From my results, to get average same player speed on all devices, is to do calculation screenWidth / averageFPS. This should give me speed, that player reaches mobile screen width for one second (note my game is in landscape mode). But it doesn't, it was significaly faster on Z3 Compact (720x1280; avg. 60FPS) than on tablet A5600-F (800 x 1280; avg. 62FPS).

How to get correct speed?


texts: Why is the Position Handle placed at certain distance away from vector3 unit in Unity?

texts:
I have a vector3 value that I am setting in inspector and I am drawing a ray using OnDrawGizoms to draw that vector line.

However, the position handle I made using Handles API to set the vector3 value is placed certain distance away from the vector unit. It's not placed exactly at the end point of the vector line that is drawn and I am not sure why.

My goal is to just make a handle to position a vector3 value.

EDIT: For some reason, the handle is positioned correctly for y position alone but not for x and z positions.

Here is my code:

In this script, it is the localTargetPosition vector3 value that I want to make my handle for.

public class MovePlatform : MonoBehaviour
{
public Vector3 localTargetPosition = new Vector3(5, 0, 0);
public Vector3 m_initialPosition { get { return initialPosition; } set { initialPosition = value; } }
private Vector3 initialPosition, targetPosition, targetPosDebug;
public float speed = 3;
public bool loop;

void Start()
{
    initialPosition = transform.position;
    SetTargetPosition(localTargetPosition);
}

void Update()
{
    transform.position = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.deltaTime);

    if (transform.position == targetPosition)
    {
        if (loop)
        {
            SwitchDirection();
        }
    }
}

public void SwitchDirection()
{
    if (transform.position == initialPosition)
    {
        SetTargetPosition(localTargetPosition);
    }
    else
    {
        targetPosition = initialPosition;
    }
}

private void SetTargetPosition(Vector3 localPosition)
{
    targetPosition = initialPosition + transform.TransformDirection(localPosition);
    targetPosDebug = targetPosition;
}

void OnDrawGizmos()
{
    if (Application.isPlaying)
    {
        Debug.DrawLine(initialPosition, targetPosDebug, Color.red);
    }
    else
    {
        Debug.DrawRay(transform.position, transform.TransformDirection(localTargetPosition), Color.red);
    }
}
}

This is the script used for making handle:

[CustomEditor(typeof(MovePlatform)), CanEditMultipleObjects]
public class MovePlatformEditor : Editor
{
protected virtual void OnSceneGUI()
{
    MovePlatform movePlatform = (MovePlatform)target;

    Vector3 initialPosition = movePlatform.transform.TransformPoint(movePlatform.m_initialPosition);
    Vector3 targetPosition = movePlatform.transform.TransformPoint(movePlatform.localTargetPosition);

    EditorGUI.BeginChangeCheck();
    Handles.Label(targetPosition, "Target", "button");
    targetPosition = Handles.PositionHandle(targetPosition, movePlatform.transform.rotation);

    if (EditorGUI.EndChangeCheck())
    {
        Undo.RecordObject(movePlatform, "Move Handles");

        movePlatform.localTargetPosition = movePlatform.transform.InverseTransformPoint(targetPosition);
    }

    Handles.color = Color.yellow;
    //Handles.DrawLine(initialPosition, targetPosition);
}

}


texts: How can I send someone an early version of my game made in clickteam fusion 2.5?

texts: I'm currently in the process of making my first game and have a pretty sturdy prototype, but I don't know how to send it out to select people. Any suggestions?


texts: Creating fake 3D character for 2D isometric game.

texts:
Characters in my 2D isometric game are composed of several sprites corresponding to particular body parts (head, torso, upper arm, lower arm, etc.) which let me extensively customize my characters in-game and do skeletal animations.

I would like to avoid creating animations in all eight directions and since I cannot use 3D models - there are many reasons for that and please do not suggest using 3D - I'm looking for a way to fake 3D so the character could be freely rotated in all directions, but use only one animation.

I imagine that this fake 3D could be achieved by an algorithm which would change body parts locations (x, y), their scale (xscale, yscale) and drawing order. How would I go about it?

Should I add to every sprite a fake z variable? What then? Are there any known examples of something similar?

Throw me some ideas


texts: Move model forward base on model orientation

texts:
My model rotates on it's own Y-axis regardless of where it is in the world. Here are the controls for the left ThumbStick:

UP (move model forward on Z-Axis)
DOWN (move model backward on Z-Axis)
LEFT & RIGHT (strafe to either side)

The problem is adjusting the direction the model's orientation UP and DOWN if the player should also rotate the player while moving forward or backwards.

An example what Im trying to achieve would be a car doing donuts. The car is always facing the current direction that it interprets as forward (or rear as backwards) in relation to it's local rotation.

Here is how Im calling the movement:

            // Rotate model with Right Thumbstick along X-Axis
            modelRotation -= pController.ThumbSticks.Right.X * mRotSpeed;

            // Move Forward
            if (pController.IsButtonDown(Buttons.LeftThumbstickUp))
            {
                modelPosition.Z -= -pController.ThumbSticks.Left.Y * speed;
            }

            // Move Backward
            if (pController.IsButtonDown(Buttons.LeftThumbstickDown))
            {
                modelPosition.Z += pController.ThumbSticks.Left.Y * speed;
            }
            // Strafe Left
            if (pController.IsButtonDown(Buttons.LeftThumbstickLeft))
            {
                modelPosition.X += -pController.ThumbSticks.Left.X * speed;
            }
            // Strafe Right
            if (pController.IsButtonDown(Buttons.LeftThumbstickRight))
            {
                modelPosition.X -= pController.ThumbSticks.Left.X * speed;
            }
            // DeadZone
            if (!pController.IsButtonDown(Buttons.LeftThumbstickUp) &&
                !pController.IsButtonDown(Buttons.LeftThumbstickDown) &&
                !pController.IsButtonDown(Buttons.LeftThumbstickLeft) &&
                !pController.IsButtonDown(Buttons.LeftThumbstickRight))
            {

            }


texts: Can I use a no longer protected by copyrights game's sprites?

texts:
I've been looking around but couldn't really find anything conclusive.
First of all, as the title says, in case a game's copyrights expire can I use its sprites for my own game and claim copyrights?

Secondly, how do I know a game's copyrights have expired?
In my particular case I'm interested in this game's sprites, the website is entirely in Japanese and due to their sole use of images with text, I cannot translate it. Can't seem to find any information regarding its copyright anywhere.

Thanks for your time.


texts: How can I manage complicated visual state over a simple model in puzzle games?

texts:
I've been encountering this design challenge making a few toys with Javascript (CreateJS, EaselJS)

The scenario is that you've got some sort of puzzle game with a simple game model. For a simple case, imagine a visual graph builder, where the model is a simple vanilla CS graph structure, maybe stored as nodes and edges.

However, you want to build a fancy interface for editing this graph structure, which introduces a lot more information. Colors, sizes, bezier curve control points for the edges, having a node "blink" during forming a connection, having the edited edge follow the mouse, etc.

How can I decouple the visual information from the raw model information? There's also a lot of state concerns. Some strategies I've employed:

Have an overall application state: ex. {NO_ACTION, CONNECTING}, where CONNECTING could store information about the selected node. Upon changing into the CONNECTING state after an event, I tell the node on which the connection was initiated to change into INITIATE_CONNECTION mode which, upon other things, causes the port to blink. Most of the ways I come up with to manage this feel hackish, dirty, and not abstracted.

I'm interested in resources or opinions about this type of scenario, and how I can better architect the application.


texts: Should competitive multiplayer games be pusposefully inbalanced so they don't get boring?

texts:
I've had a discussion on the internet about game balancement. Actually, this was a Pokemon fansite, and the discussion started from a simple observation that some pokemon are OP while others are outright bad.
Now I know that Pokemon is a peculiar game... Still, I believe, this topic can be easily generalized to almost any competitve multiplayer game.
Namely, most people were making the argument that while Pokemon gameplay is very inbalanced, it is a good thing, because a perfectly balanced gameplay is inherently boring and dull.
Let me try to quote some of their arguments, (redacting them so that they become more readable outside of chat):

It'd just turn into a game of "lets use my favourite pokemon yayayay". The only thing that would matter than would be type matchups. Or, if the tank/glass cannon diversity was retained, then a team full of tanks would always win.
Pokemon is inherently unbalanced and that's what makes it interesting IMO.
"Optimal" gameplay, for anything, always becomes boring. What's fun to see is to see niche pokemon and gimmicks. There will always be something better that what you say is the best.
You could just make every pokemon 100 across the board and identical everything. Of course, that loses the point of the game.
Being able to use a "bad" mon well is one of the coolest things. There's an optimal team that wins a lot but cteaming exists and you can't really make it un-exist. It's always more fun to win with a stall team than a real shoot em up team.
Perfect games becomes boring, not optimal gameplay. If everyone plays well, there's nothing wrong with that; but if everyone has a perfect team, then what?

That goes right in the face of what I always believed about game balancement. In short, I believed that, regardless of the game's genre: If we have a mon, or unit, or champion, or whatever, which is known to have little to no place in any competetively viable strategy (the Pokemon case) or, if we have a "meta", that is, a strategy that is, in general, the only competetively viable strategy (the League of Legends case), then this is what makes gameplay dull and boring, since it clearly, almost by definition, greatly reduces the pool of viable picks and strategies; and that game designers ought to avoid these pitfalls. Thus, a "perfect" game should have many viable picks, each different than another but none clearly useless, (that is, we should avoid the situation that if one wants to pick A, picking B instead will always be a better idea - some picks may and should be niche and/or situational though), that can be mixed in a plethora of ways to make a plethora of different, but viable teams, thus creating a plethora of different, but viable strategies (this doesn't mean that each team is equivalent or that a team assembled randomly is viable; teams can still be good or bad, but we should avoid the situation that there is only one viable prescription for a good team).
However, what I was being told seems to boil down to something opposite. The people I quoted seemed to think that good balancement of a game can only be achieved at the cost of making all possible picks equivalent, to the point of making it matterless what to pick. They also seemed to think that therefore, in such a scenario, an obvious winning strategy would inevitably emerge, making the game trivial.
Is it really true that a game can only be well balanced if it sacrifices all of its diversity? Is it really true that getting rid of useless picks can only be achieved at the cost of introducing a trivial winning strategy??


texts: Moving Object Interception / Projectile Collision

texts:
I am using Unity to attempt to have missile A launch at incoming missile B and blow it up.
However in order to do this accurately, A must be able to take into account B's current velocity, direction and distance in order to calculate where it needs to aim in order to succesfully hit it.
How do we go about this using the below as an example?


texts:
I've defined an abstract method in an abstract class with a generic return type. However, when I try to use the generic type as a Vector3 (or any other variable) I get this error :
Cannot implicitly convert type 'UnityEngine.Vector3' to 'Vector3'
this is my code :
the error is in the line
return direction;

using UnityEngine;

public class DashAbility : Ability
{

    public Vector3 direction;

    public override Vector3 getAbilityData<Vector3>()
    {
        return direction;
    }

    public override bool trigger(pointerData pointer)
    {
        return InputMaster.tryPointer(rollInputTest);
    }

    bool rollInputTest(pointerData p)
    {
        return (p.phase == pointerPhase.Dragging) && p.startHit.collider.CompareTag("Player");
    }
}

and this is the class I'm deriving from:
using UnityEngine;

public abstract class Ability : MonoBehaviour
{
    public abstract bool trigger(pointerData pointer);
    public abstract T getAbilityData<T>() ;
}


texts: What is the camera direction vector for an isometric view?

texts:
What values correspond to a 3D vector for screen-normal from within an isometric game?

It needs to be in game coordinates. It is a standard isometric where tiles are rotated 45 degrees and half height (in 2D projection).

For example [+x,0] in game corresponds to north-east on screen. But what is the vector leading out of the screen. This vector is always the same (a fixed orthographic projection).


texts: Abstracting Entity System animation states

texts:
I recently started designing a Game Engine using the Entity System paradigm, i.e. having entities as an aggregation of components, and systems that implement the actual game.
Whereas I've had difficulties in various aspects, what concerns me most is the abstraction / modularity of the various Components / Systems. Specifically, let's say my Player has several animation states, eg. Walking, Sleeping, Jumping, and one type of Opponent entity has several (not necessarily the same) states as well, eg. Walking, Hiding etc.

How should I design the engine, so that it handles the various (animation) states of each entity type? Should there be different animation Systems for each Entity type? Should I use flags that signal the animation System to render the correct entity? Also, can I avoid using "hard-coded" enums for the various poses? I can see that a scripting system could probably help, but I'm almost sure there is a simpler solution.


texts: How to detect whether a transform has rotated left or right

texts:
I have a game object in my scene, and I want to know how can I calculate whether this game object rotating to the right or to the left.

For example :

if(check whether the transform rotated to the right)
{
    print("rotate to right");
}
else if(check whether the transform rotated to the left)
{
    print("rotate to left");
}
else
{
    print("no rotation");
}


texts: Protecting game assets through archiving

texts:
I'm writing a game in C++ (with OpenGL) and am getting quite far into development. Currently I'm loading the data directly from different directories.

(E.G. I load textures from a /Data/Textures/...png)

This is fine, but not preferable. Ideally I would like to protect these assets without too much of a performance hit.
I looked at other games that I own, both Indie and AAA and found that the majority of them archive the data.
However, I am unable to access these archives with programs like Winrar Archiver which implies that they have some level of protection.

I'm not particularly knowledgeable in the field of encryption and data storage, so I may be overlooking something obvious but I would like to know how exactly I could achieve something similar.

(I am aware that competent individuals are able to use the GPU to gain access to the data but that's not preventable)


texts: Unity 3D, Making contiguous looking worlds

texts: Im currently involved in making a third person cooperative mobile game in Unity and in said game there will be an area for players to walk around in with various elevations and whatnot throughout the field. Its designed to be set up with 4 biomes in the area to go along with the games theme but I was wondering what would be the best way to mask the "boundaries" or "cut off points" in this area? From certain vantage points  its pretty obvious that the terrain used to make the world simply stops and I was wondering if anyone knew any tips and insights on how to best mask these boundaries without too much "padding" in the game area in order to keep it relatively less taxing on  a mobile device. Thank you in advance.


texts: Advice on how to organise the levels in a game

texts:
I'm thinking of building a 2D platformer game similar to Super Mario Bros, but I'm in the planning process and realised I don't really have a good way of storing information about each level – where should the enemies be placed, where do they walk, what happens if the player enters an area etc.

At first I thought I could make one scene per level, but with 40 to 50 levels I had a feeling that it would get messy pretty quickly. A friend of mine recommended making an array or dictionary containing every single wall, enemy and item a level contained. At first glance this too seemed like a good idea, but since every level is quite different it seems like building an effective system for detecting what the player is doing and where (s)he is at any given time is a really big challenge. This is because I would have to check which level the player is playing in addition to all the other logic, and then maybe it'll get messy anyways?

And so i figured out I maybe just should go with my first idea: It seems like making a separate file and class for each level will make it easier to tailor everything so that the game runs smooth and doesn't encounter issues at runtime. The question is whether this would slow down the loading process a lot, or if there are other issues using this method.

Since this is my first large project though, I'm not too sure what is the best thing to do for a 2D game where each level features different objects, enemies, items, audio etc. What is your advice? Thank you for your time.

Btw., I'm programming this in Swift and use SpriteKit.


texts:
I'm curious as to how stealth games work. I am working with 2d right now to get the hang of it, and so far I have come up with the following ideas.

create a bounding circle around the player/enemy
if the circle comes in contact with and object, let's say a crate, shoot out rays 360 degrees.
if the ray contacts the player/enemy, trigger something saying you have been found.
if the ray contacts the crate, the ray will never hit the player, thus making him "hidden" to the enemy

Naturally, there will be some kind of crazy vector math involved in this. What I am wondering is if this is the right way to go about doing this? Is having rays being shot out every second or half-a-second something that's feasible and won't slow down the program drastically?


texts:
I'm trying to build my first (2D) game with ECS but I always end up with some system calling other systems. Here's an example.

There is a RegionSystem that manages RegionComponents. On each frame, this system loops through all the RegionComponents and checks if the player is inside any of them.

When the player enters the water, the player's sprite must be changed from PLAYER_RUNNING to PLAYER_SIWMMING.

When the player steps onto a teleporter, an animation will play around the player, he'll be rotating and a new level will be loaded.

When the player steps into a hole, he will lose some health and will be repositioned in the level.

So, first of all, it needs the coordinates of the player's body to check if it is in a region (check point in rectangle). Hence it will ask the RigidbodySystem to get the coordinates.

Then if the player is inside a region, it will call PlayerSystem_OnInsideRegion(regionInfo).

In turn this function, PlayerSystem_OnInsideRegion must react differently depending on the type of the region:

for the water case, it needs to call the SpriteSystem to change a sprite, the PlayerSystem to set a boolean (m_inWater = True;) and the RigidBodySystem to get the coordinates of the player's body;
for the teleporter case, it needs to call the LevelSystem and tell him to switch to another level on the next frame;
for the hole case, well, simply descrease the member m_health of the player component, so no need to call another system here.

I have the feeling this is a horrible design and does not fit the ECS architecture. I read that people use a message system where systems can subscribe and unsubscribe to particular type of message. But I also read that it can be tricky to react to them in a proper order.


texts: How can I ensure a Unity game continues to run in RAM, even if the disk it loaded from is removed?

texts:
I'd like to make a game with Unity, put the build with all the data on a USB key, plug it in another Windows computer, and run the game from the USB drive, then remove the USB drive, but keep the game running flawlessly.

How could I do that?


texts: Suitable interpolation for animating explosions

texts:
Is there a standard interpolation function for animating explosions? Like there is with smoothstep or smootherstep for walking animations or cars going from point A to B.

I'm assuming the explosion needs to grow very fast at the beginning and then slow down - how much in relation to the default linear interpolation, I don't know.

I've tried inverse smoothstep and inverse squared from this article: Interpolation Tricks, but none quite cuts it, maybe I'm applying them wrong.


texts: Why do these textures tile rather than just overlap?

texts:
It might help to provide all the details, so here is the YouTube tutorial which sparked my question.

There's a prefab of the background tile called "Tile Background." This prefab has the default settings, except that Pixels Per Unit is set to 512, and that it has a script attached to it called BackgroundTile which hasn't even been opened. It's just there for the other script to reference.

An empty object was created called Board, which has Tile Background as its tile prefab. It also has a script, Board.cs, the contents of which are here:

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

public class Board : MonoBehaviour
{
    public int width;
    public int height;
    public GameObject tilePrefab;
    private Backgroundtile[,] allTiles;

    // Start is called before the first frame update
    void Start()
    {
        allTiles = new Backgroundtile[width,height];
        Setup();
    }

    private void Setup() {
        for(int i = 0; i < width; i++) {
            for(int j = 0; j < height; j++) {
                Vector2 tempPosition = new Vector2(i, j);
                Instantiate(tilePrefab, tempPosition, Quaternion.identity);
            }
        }
    }
}

Width is set to 4. Height is set to 7.
Other than that, the camera position is X:1.5,Y:3 and the aspect ratio is 9:16.

My question is this: why, when this is run, does Vector2(i,j) get interpreted as tiling the sprites, rather than placing the sources of the sprites in a 4x7 pixel grid, where they overlap almost entirely? There's no place where their positions get multiplied by the size of the tiles, right? Halving the pixels per unit doesn't even just halve the height of the board - it stays a constant size and looks really weird, despite the board not having set dimension attributes.

What's going on here?


texts: Create Script from custom templates issue: They are created with the default name and cannot been named on creation

texts:
I was just being introduced to the AssetDatabase class, and I was curious of creating Script Templates, such as Interfaces, pure C# classes, and a MonoBehaviour template more suitable for my work style.

I tried to emulate a solution I found on Unity Forums, and the template creation goes well, except that the name gets setted once it is created, and it doesn't let you name the created asset, as the Unity Scripts let you once you create them. The fact that the name is not changed by the user, makes the script on its default state, with the exact code the template has, without changing the #SCRIPTNAME#s declared, throwing errors, and being counterproductive with the time optimization goals I had in mind.

using UnityEditor;
using UnityEngine;
using System.IO;

public class CustomScriptsCreator
{
    public const string CONTEXT_MENU_PATH = "Assets/Create/Custom Scripts";     /// <summary>Custom Scripts default Path.</summary>
    public const string CONTEXT_MENU_CUSTOM_C_SHARP = "/C# MonoBehaviour";
    public const string CUSTOM_TEMPLATE_FOLDER_PATH = "Assets/Custom Script Templates";
    public const string CUSTOM_C_SHARP_TEMPLATE_PATH = "C#Script_CustomMonoBehaviourScript.cs.txt";
    public const string PATH_NOT_FOUND_MESSAGE = "Script Template Not Found";
    public const string WINDOW_ERROR_MESSAGE = "There is no Template at path: \n\n";
    public const string WINDOW_OK_ANSWER = "Ok";

[MenuItem(CONTEXT_MENU_PATH + CONTEXT_MENU_CUSTOM_C_SHARP)]
public static void Create(MenuCommand _cmd)
{
    Object selection = Selection.activeObject;

    if (selection != null)
    {
        string path = AssetDatabase.GetAssetPath(selection);

        if (File.Exists(path))
        {
            path = Path.GetDirectoryName(path);
        }
        if (string.IsNullOrEmpty(path))
        {
            path = "Assets/";
        }

        /// THIS WAS JUST A FAILED TEST...
        /*Object obj = Resources.Load("ScriptTemplates/" + CUSTOM_C_SHARP_TEMPLATE_PATH);

        if(obj != null)
        {
            AssetDatabase.CreateAsset(obj, Path.Combine(path, "NewScript.cs"));
        }
        else
        {
            EditorUtility.DisplayDialog
            (
                PATH_NOT_FOUND_MESSAGE,
                WINDOW_ERROR_MESSAGE + (CUSTOM_TEMPLATE_FOLDER_PATH + "/" + CUSTOM_C_SHARP_TEMPLATE_PATH),
                WINDOW_OK_ANSWER
            );
        }*/

        //string newName = EditorUtility.SaveFilePanelInProject("Save Your Prefab", "NewScript.cs", "cs", "Please select file name to save prefab to:");
        //File.Copy((CUSTOM_TEMPLATE_FOLDER_PATH + "/" + CUSTOM_C_SHARP_TEMPLATE_PATH), Path.Combine(path, "NewScript.cs"));
        if(AssetDatabase.CopyAsset((CUSTOM_TEMPLATE_FOLDER_PATH + "/" + CUSTOM_C_SHARP_TEMPLATE_PATH), Path.Combine(path, "NewName.cs")))
        {
            // IT CHANGES THE FILE NAME SUCCESSFULLY, BUT NOT ON THE SCRIPT.
            //AssetDatabase.RenameAsset(Path.Combine(path, "NewName.cs"), "KillMePlease.cs");

            AssetDatabase.Refresh();
        }
        else
        {
            EditorUtility.DisplayDialog
            (
                PATH_NOT_FOUND_MESSAGE,
                WINDOW_ERROR_MESSAGE + ((CUSTOM_TEMPLATE_FOLDER_PATH + "/" + CUSTOM_C_SHARP_TEMPLATE_PATH)),
                WINDOW_OK_ANSWER
            );
        }
    }

}

}

The paths are ok, since the script is being created. If there is more information you need, let me know. Thanks in advance.


texts:
I am trying to implement a simple movement for one of game objects in flash/ AS3. I am using mouseX, mouseY for my object to follow the mouse pointer. It works fine but the problem is the precision of the movement. If I move my mouse a little too fast then my game object stops following the mouse which means I have to re-focus the mouse pointer back on the game object to make it move again.

Here is the code that does this.

private function FootyMouseMove(shortestFooty : FootBall) : void {
            shortestFooty.x = stage.mouseX;
            shortestFooty.y = stage.mouseY;
            if (shortestFooty.x > stage.stageWidth - shortestFooty.width)
                shortestFooty.x = stage.stageWidth - shortestFooty.width;
            if (shortestFooty.x < shortestFooty.width)
                shortestFooty.x = shortestFooty.width;
        }

My question is, would it be possible to make the movement of my game object much more smoother and make sure that the game object is always following the mouse no matter how fast I move my mouse pointer?


texts: How can I draw beautiful lines with XNA on WP7?

texts:
I'm trying to figure out how to draw good looking lines using XNA on the WP7 platform. By good looking I mean something not skinny and flat that a simple primitive gives you. A nice gradient, or texture or something applied.
It would be pretty easy if the lines were all straight, but I need to be able to make 45* and 90* turns.
Has anyone else tried doing this? I have found ways to do it, but they all require custom shaders which the platform doesn't support. Like this one for example
Example output from that library:


texts:
Beginner question. Synopsis: my water effects does something that causes the drawing of my sky sphere to throw an exeption when run in full screen. The exception is:

  XNA Framework HiDef profile requires TextureFilter to be Point when
  using texture format Vector4.

This happens both when I start in full screen directly or switch to full screen from windowed. It does NOT happen, however, if I comment out the drawing of my water.

So, what in my water effect can possibly cause the drawing of my sky sphere to choke???


texts: Box2DLights - the center of sprites are always 100% unlit (black) unless Xray is on

texts:
I'm using a ConeLight at 180 degrees, with this setup:
pl = new ConeLight(rayHandler, 256, new Color(0.5f, 0.5f, 0.5f, 1f), 280f, 400 - x, 300 - y, 0, 180);
And the object I'm casting a shadow on (with?) is set up like so:

sprite = new Sprite(new Texture(imgP));

BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.DynamicBody;
bodyDef.position.set(x - 392.5f, y - 292.5f);

body = Main.world.createBody(bodyDef);

PolygonShape pushBlock = new PolygonShape();

pushBlock.setAsBox(((float) w / 2), ((float) h / 2));

FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = pushBlock;
fixtureDef.density = 0.5f;
fixtureDef.friction = 0.8f;
fixtureDef.restitution = 0f;

Fixture fixture = body.createFixture(fixtureDef);

body.setUserData(sprite);
body.setGravityScale(0);
body.setFixedRotation(true);
body.setLinearDamping(40f);

pushBlock.dispose();

The problem is that the light creates the shadows in a sort of glob form in the center of the square (not casting nicely around the corners as I've seen in others' projects), also leaving nearly the whole sprite black. I require the ambient colour to be black, and also require shadows, so Xray is out. I've messed around with filters but haven't been able to achieve what I want - being able to cast shadows without overshadowing the sprite.
Is it possible? How might I do this, if possible?

Edit: I took a screenshot.


texts:
What are the uses for SV_POSITION in the pixel shader?  Previously this was the POSITION semantic and it wasn't readable in the pixel shader, but now that it is, what can it be used for?

In an SM2 deferred renderer, you'd typically take the texture coordinates, transform them to the [-1, 1] range and then use an inverse view/position matrix to get the world position of a pixel.  Would SV_POSITION be usable here to reduce any of the calculations?  And if so, how would you do that?


texts:
I am teaching myself XNA and only started a few days ago. I am making a clone of Pong and have made a class for the Paddle:

I am wondering how I can create 2 paddles one for each player from the one class.

Thanks,

TeaBelliedTitch


texts: Directional lights (not) rotating with camera (opposite problem)

texts:
I am trying to implement a shader for directional lights correctly, but I am bit confused as to why it works when it shouldn't and vice versa.

People usually encounter problem with lights changing direction with camera. This is corrected by multiplying normals with model(view) matrix.

But my problem is opposite.

When I don't multiply normals with model(view) matrix then it works and when I try to use (supposedly) correct version it is having that "lights rotating with camera" problem.

Any ideas?

Working vertex shader:

#version 330
layout (location = 0) in vec3 position;
layout (location = 1) in vec2 texCoord;
layout (location = 2) in vec3 normal;

out vec2 texCoord0;
out vec3 normal0;

uniform mat4 model;
uniform mat4 view;
uniform mat4 proj;

void main()
{
    normal0 = normal;
    gl_Position = proj * view * model*  vec4(position, 1.0);
    texCoord0 = texCoord;
}

Fragment shader:

#version 330
in vec2 texCoord0;
in vec3 normal0;
out vec4 outColor;

struct BaseLight
{
    vec3 color;
    float intensity;
};

struct DirectionalLight
{
    BaseLight base;
    vec3 direction;
};

uniform vec3 baseColor;
uniform vec3 ambientLight;
uniform sampler2D sampler;
uniform DirectionalLight directionalLight;

vec4 calcLight(BaseLight base, vec3 direction, vec3 normal)
{
    float diffuseFactor = dot(normal, -direction);

    vec4 diffuseColor = vec4(0,0,0,0);

    if(diffuseFactor > 0)
    {
        diffuseColor = vec4(base.color, 1.0) * base.intensity * diffuseFactor;
    }

    return diffuseColor;
}

vec4 calcDirectionalLight(DirectionalLight directionalLight, vec3 normal)
{
    return calcLight(directionalLight.base, -directionalLight.direction, normal);
}

void main()
{
    vec4 totalLight = vec4(ambientLight,1);
    vec3 normal = normalize(normal0);
    totalLight += calcDirectionalLight(directionalLight, normal);
    outColor = texture(sampler, texCoord0.xy) * vec4(baseColor, 1) * totalLight;
}

Draw method:

glBindBuffer(GL_ARRAY_BUFFER, vbo);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);

glVertexAttribPointer(0, 3, GL_FLOAT, false, Vertex::SIZE* 4, 0);
glVertexAttribPointer(1, 2, GL_FLOAT, false, Vertex::SIZE * 4, (const GLvoid*)12);
glVertexAttribPointer(2, 3, GL_FLOAT, false, Vertex::SIZE * 4, (const GLvoid*)20);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
glDrawElements(GL_TRIANGLES, size, GL_UNSIGNED_INT, 0);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);

Matices:

ViewTranslate = glm::mat4(1.0f);
 cam->control(windowHandle, 0.01, 0.3, true, &ViewTranslate);
 cam->updateCamera(&ViewTranslate);

glm::mat4 Projection =
    glm::perspective(70.0f, 800.0f / 600.0f, 0.1f, 10000.0f);
glm::mat4 view = glm::lookAt(
    glm::vec3(0, 0, 1),
    glm::vec3(0.0f, 0.0f, 0.0f),
    glm::vec3(0.0f, 1.0f, 0.0f)
    );

shader->bind();
shader->setUniform("model", glm::value_ptr(ViewTranslate));
shader->setUniform("view", glm::value_ptr(view));
shader->setUniform("proj", glm::value_ptr(Projection));
shader->setUniform("ambientLight", ambientLight);

Not working shader code:

void main()
{
    normal0 = (model * vec4(normal, 0.0)).xzy;
    gl_Position = proj * view * model*  vec4(position, 1.0);
    texCoord0 = texCoord;
}

or

void main()
{
    normal0 = (model * view * vec4(normal, 0.0)).xzy;
    gl_Position = proj * view * model*  vec4(position, 1.0);
    texCoord0 = texCoord;
}

or

void main()
{
    normal0 = (model * view * vec4(normal, 1.0)).xzy;
    gl_Position = proj * view * model*  vec4(position, 1.0);
    texCoord0 = texCoord;
}

or

void main()
{
    normal0 = (transpose(inverse(model * view)) * vec4(normal, 1.0)).xzy;
    gl_Position = proj * view * model*  vec4(position, 1.0);
    texCoord0 = texCoord;
}

...

Any ideas how I should do this correctly?


texts:
I'm currently working on a personal project where I'm trying to load the levels and all of the geometry from the game "Medal of Honor Allied Assault" into my own C# code-base based on SharpDX.

I managed to do all that, but now that I'm trying to cleanup the code I came across a few questions on which Google and other sites don't give me a clear answer to, hence I'm turning myself to StackExchange once more!

Currently, I'm rendering the whole scene using the following equation:
1 VBO (BSP) + 1 VBO (Terrain) + (1 VBO (Model) * NumberOfModels)

For each VBO, I'm keeping track when and where I have to start a new DrawIndexedPrimitive-call (eg. Texture-swap).

Is my current setup sufficient, or should I put everything into as less VBO's as possible? Or is there a better approach. How about culling which I'm not bothered with just yet, would one massive VBO work better for that than lots of smaller ones?

To give a little more information: some models require 3-4 Texture-swaps, are relatively small (128 vertices to 4k vertices) and I'm currently not even animating them yet.

If I'd go with my feeling, I would give everything its own VBO, arranging vertices in such a way I can batch textures and use instancing techniques, but I'm unsure this the way to go.

Feel free to ask for more information!


texts: How to change animation view in Unity3D?

texts:
How can I change the animation view in Unity3D? I have only some "dot", but I want to view some curve! How do I change this?

What I have:

And what I want:

(image from the documentation of Unity3D)


texts: LibGDX - Collision detection between all bullets and all enemies

texts:
I'm trying to make a collision detection system between the player's bullets and all the enemies on screen.

So far I had something like this:

for (Bullet bullet : hero.getPistols().getAllShotBullets()) {
        for (Enemy enemy : enemies) {
            if (!enemy.isDead()) {
                if (bullet.overlaps(bullet.getBounds(), enemy.getBounds())) {
                    enemy.die();
                }
            }
        }
    }

But after a while, the frame rate drastically drops - making the game unplayable, almost (which is understandable, as the nested for loop looks terrible for performance...).
I've been looking around and found out that a common solution is to use Quad-Trees, but at the same time, I'm worried that the overhead brought by the use of that data structure will make it a bit of an overkill, if that makes sense.

Are there any more solutions? Or should I use the Quad-Tree?

Thanks in advance.


texts: How should I structure a design document?

texts: Should the design document be a continuous line of text, with real sentences, more like a description of the entire game, or should I structure it in simple points? What are the benefits, and are there more ways of structuring it?


texts:
This is how I understood the game loop, and I wanted to know if I'm correct or not:

1) Draw/render -> input
CPU    |    GPU
------------------
Update |
Draw   |
Input  | Rendering

2) Input -> Draw/render
CPU        |    GPU
------------------
Input      |
Update     |
Draw       |
(nothing?) | Rendering

By rendering I mean updating the actual frame. What happens in the second case? Is the CPU doing nothing or is it checking input for the next frame already? Are there any differences from checking input before or after the update/draw part?


texts: Is using camera and viewport in Libgdx always necessary?

texts:
I understand that camera and viewport are important to keep virtual measurement units and handle different aspect ratios and resolutions when building games with worlds bigger than the screen (e.g. side-scrollers / map based games).

I am not sure whether it is the proper way to go for a simple game that fits on the screen entirely - like a puzzle or card game for example.

Is it still better to use camera and viewport in this case, or is it more simple, effective (and hence better) to use directly screen absolute coordinates for these types of games?

Or to put it in other way - what are the advantages to use camera and viewport for games that fit on the screen entirely?


texts: Is it possible to have a SoA Vertex Buffer in DirectX 11?

texts:
Hi!

I'm wondering if it is possible to structure a Vertex Buffer in a SoA approach like this

{ x1, x2, x3 . . . xn, y1, y2, y3 . . . yn, z1, z2, z3 . . . zn }

instead of the traditional AoS approach

{ x1, y1, z1, x2, y2, z2, x3, y3, z3 . . . xn, yn, zn }

If that beeing the case.. Is it possible to design the ID3D11InputLayout like this?

D3D11_INPUT_ELEMENT_DESC inputDesc[] = {
            { "POSITION", 0, DXGI_FORMAT_R32_FLOAT, 0, 0,       D3D11_INPUT_PER_VERTEX_DATA, 0 },
            { "POSITION", 1, DXGI_FORMAT_R32_FLOAT, 0, offsetToY, D3D11_INPUT_PER_VERTEX_DATA, 0 },
            { "POSITION", 2, DXGI_FORMAT_R32_FLOAT, 0, offsetToZ, D3D11_INPUT_PER_VERTEX_DATA, 0 }
        };

And how does one call the deviceContext->IASetVertexBuffers correctly with this type of layout?

Any suggestions? Thank you!


texts:
I am creating a custom class that extends from Actor,just like this:

public class MyActor extends Actor {
ProgressBar bar;
Label nameLabel;
TextButton button;
public MyActor(String name, Skin skin){
    nameLabel = new Label(name, skin);
    button = new TextButton("Whatever",skin);
    bar = new ProgressBar(0f,5f,1f,false,skin);

}
@Override
public void act(float delta) {
    super.act(delta);
    bar.setBounds(getX(), getTop()-getHeight() / 3f, getWidth(), getHeight() / 3f);
    nameLabel.setBounds(getX(), getY()+getHeight() / 3f, getWidth(), getHeight() / 3f);
    button.setBounds(getX(), getY(), getWidth(), getHeight() / 3f);
}

@Override
public void draw(Batch batch, float parentAlpha) {
    super.draw(batch, parentAlpha);
    bar.draw(batch, parentAlpha);
    nameLabel.draw(batch, parentAlpha);
    button.draw(batch,parentAlpha);
} }

Then I try to add it to a Table:

Table myTable = new Table();
myTable.add(myActor).row();

But it always gets drawn in the 0,0 coordinates!, what am I doing wrong? Do I have to override another method?


texts: endless Thorn (deal damage when taking damage) effect

texts:
I'm developing a card-based combat system for my game. (imagine a game like Magic The Gathering, or Hearthstone, or any CCG)
I was writing the logic of the effect that I call "thorn".
If a player has the thorn effect, everytime he got struck with some damage, he deals damage to his attacker.

I already had an event raised everytime a character is being damaged, so it seemed logical to me to use it.

the thorn effect starts to listen to the onDamage event and then it deals its damage.

The issue with this solution is that it can create an endless chain of thorn effect, if both parties have the thorn effect.

Player 1 attacks player 2.

Player 2 raises onDamage event.

player 2 resolves its thorn effect, and it deals damage to player 1.

player 1 raises onDamage event.

player 1 resolves its thorn effect, and it deals damage to player 2.

and it goes on.

There are many solutions I can think of, but none of them are actually satisfying to me. Any suggestions? Thanks for the answers


texts: Isometric screen to 3D world coordinates efficiently

texts:
Been having a difficult time transforming 2D screen coordinates to 3D isometric space. This is the situation where I am working in 3D but I have an orthographic camera. Then my camera is positioned at (100, 200, 100), Where the xz plane is flat and y is up and down.

I've been able to get a sort of working solution, but I feel like there must be a better way.

Here's what I'm doing:

With my camera at (0, 1, 0) I can translate my screen coordinates directly to 3D coordinates by doing:

mouse2D.z = (( event.clientX / window.innerWidth ) * 2 - 1) * -(window.innerWidth /2);
mouse2D.x = (( event.clientY / window.innerHeight) * 2 + 1) * -(window.innerHeight);
mouse2D.y = 0;

Everything okay so far. Now when I change my camera back to (100, 200, 100) my 3D space has been rotated 45 degrees around the y axis and then rotated about 54 degrees around a vector Q that runs along the xz plane at a 45 degree angle between the positive z axis and the negative x axis.

So what I do to find the point is first rotate my point by 45 degrees using a matrix around the y axis. Now I'm close.

So then I rotate my point around the vector Q. But my point is closer to the origin than it should be, since the Y value is not 0 anymore. What I want is that after the rotation my Y value is 0. So now I exchange my X and Z coordinates of my rotated vector with the X and Z coordinates of my non-rotated vector. So basically I have my old vector but it's y value is at an appropriate rotated amount.

Now I use another matrix to rotate my point around the vector Q in the opposite direction, and I end up with the point where I clicked.

Is there a better way?

I feel like I must be missing something. Also my method isn't completely accurate. I feel like it's within 5-10 coordinates of where I click, maybe because of rounding from many calculations. Sorry for such a long question.


texts: Assigning values on multiple clients in UE4

texts:
I am currently working on a multiplayer game and I am having difficulties on assigning values on variables for each clients. Originally I looped through available clients character from HUD then assigned the calculated the value but I decided to do it inside character blueprint's instead.
I don't know why only first clients gets the calculated values but the other client still having the default value.
This is the initial value that I assigned from inside Character C++
MaxHealth = 500;
Health = MaxHealth;

This is how I assigned the value from the Blueprint.

Set Initial Attributes is where I calculated the Health value based on player's Strength value etc and the reason I'm doing this is because I am planning to retrieve the stats from the datatable in the future. But I don't know why it becomes like this instead.
This is the correct final value that supposedly assigned on both clients.

But only first client gets the correct value, not second client.

I don't want to use loop to search the player characters' inside player character's blueprint and assigned the value because I don't think it's a wise move so I am looking for a better alternative if any. Thanks!


texts:
I'm trying to draw a partly transparent texture a plane, but the problem is that it's incorrectly displaying what is behind that texture.

Pseudo code:

vertices1
basiceffect1
// The vertices of vertices1 are located BEHIND vertices2

vertices2
basiceffect2
// The vertices of vertices2 are located IN FRONT vertices1

GraphicsDevice.Clear(Blue);
PrimitiveBatch.Begin();

//if I draw like this:
PrimitiveBatch.Draw(vertices1, trianglestrip, basiceffect1)
PrimitiveBatch.Draw(vertices2, trianglestrip, basiceffect2)
//Everything gets draw correctly, I can see the texture of vertices2 trough
//the transparent parts of vertices1

//but if I draw like this:
PrimitiveBatch.Draw(vertices2, trianglestrip, basiceffect2)
PrimitiveBatch.Draw(vertices1, trianglestrip, basiceffect1)
//I cannot see the texture of vertices1 in behind the texture of vertices2
//Instead, the texture vertices2 gets drawn, and the transparent parts are blue
//The clear color

PrimitiveBatch.Draw(vertice
PrimitiveBatch.End();

My question is, Why does the order in which I call draw matter?

Edit: Added screenshots

It's like there is no Z buffering at all.
this is done with:
GraphicsDevice.DepthStencilState  = DepthStencilState.DepthRead;
I've tried other settings but they don't help

Edit:
I think I have to somehow set the BlendState of the graphic card in some way so that the textures behind other textures get rendered.


texts:
I am trying to write a movement prediction code. I have found the quadratic method with these topics:

[1]: How to calculate shot angle and velocity to hit a moving target?
[2]: http://howlingmoonsoftware.com/wordpress/leading-a-target/

I have implemented this without problems. The problem is how can I add enemy hitbox calculation (I want to fire at edge of enemy for precision)

local cos = targetDirection:dot(toTargetDirection)
local absCos = math.abs(cos)

local sin = math.sqrt(1 - (cos * cos))
local absSin = math.abs(sin)

local cot = cos / sin

local absCot = math.abs(cot)
local delta = 1 - ((cos * cos) + (sin * sin))

local position = targetPosition + targetVelocity * delay
position = position + targetVelocity * network.latency

position = position - toTargetDirection * (target.boundingRadius + width)
position = position - targetDirection * (target.boundingRadius + width)

position = position - toTargetDirection * (absSin * (target.boundingRadius +
width))
position = position - targetDirection * (absCos * (target.boundingRadius +
width))

local toPosition = position - sourcePosition
local toPositionDirection = toPosition:norm()
local spellVelocity = toPositionDirection * speed

local a = targetVelocity:dot(targetVelocity) -
spellVelocity:dot(spellVelocity)
local b = targetVelocity:dot(toPosition) * 2
local c = toTarget:dot(toPosition)

local discriminant = b * b - 4 * a * c

if (discriminant < 0) then
   return
end

local time = 2 * c / (math.sqrt(discriminant) - b)

So far tried this but it's still not casting edge with precision.


texts: Java2D Shooting in a line tangent to mouse coordinates

texts:
I am making a top down shooter in Java and I need to be able to shoot in a line tangent to the mouse coordinates. In other words I need to be able to click my mouse and have a projectile spawn from my player, then move its position in a straight line in the direction of where I clicked. I have tried this already and I have failed miserably, and after looking into it for a while I haven't found a good answer. The code is pasted below, any ideas on what I'm doing wrong?

The mouse angle is calculated like this:

mouseAngle = (float) Math.toDegrees((float) Math.atan2(e.getY() - Player.getY(), e.getX() - Player.getX()));

 VectorMath class

package vector;

public class VectorMath {

    public VectorMath() {

    }

    public static void copyVector(Vector2f v1, Vector2f v2){
        v1.setX(v2.getX());
        v1.setY(v2.getY());
    }

    public static void printVector(Vector2f v){
        System.out.println("x: " + v.getX() + " y: " + v.getY());
    }

}

 Projectile Class

package projectile;

import java.awt.Color;
import java.awt.Graphics2D;

import player.Mouse;
import player.Player;
import vector.Vector2f;
import vector.VectorMath;

public class Bullet {

    private Vector2f pos = new Vector2f(0, 0);
    private float x,y, xVel, yVel, moveSpeed = 0.1f, dX, dY;;
    private float mouseAngle;

    public Bullet(Vector2f pos) {
        VectorMath.copyVector(this.pos, pos);
        VectorMath.printVector(this.pos);
        x = Player.getX();
        y = Player.getY();
        mouseAngle = Mouse.getMouseAngle();
    }

    public void update(){
        xVel = pos.getX() + (((float)Math.cos(mouseAngle)) / moveSpeed);
        yVel = pos.getY() + (((float)Math.sin(mouseAngle)) / moveSpeed);

        dX = x + xVel;
        dY = y + yVel;

        x = dX;
        y = dY;

    }

    public void render(Graphics2D g2){
        g2.setColor(Color.green);
        g2.fillRect((int)x, (int)y, 10, 10);
    }

}


texts: How to make the paddle stop at the screen edge in my Pong clone?

texts:
Well, I'm obviously very new to game dev and Android. I've got a ball bouncing around (successfully detecting screen edge collisions so that the bitmap stays within screen) and a paddle that the user can move left and right with their finger.

At the moment there's a few things wrong with my method, but I will post it as is:

(current method from my paddle class that I use to manage touchevents:)

public void onTouchEvents(MotionEvent e, int viewW, int viewH){
        //DETECT PRESS
        if (e.getAction() == MotionEvent.ACTION_DOWN){
            // delegating event handling to the paddle
            handleActionDown((int)e.getX(), (int)e.getY());
        }
        //MOVE GESTURES
        if (e.getAction() == MotionEvent.ACTION_MOVE){
            if (isTouched()){
                //paddle is being dragged
                //Log.i(TAG, "paddle is being dragged");

                //SETTING NEW POSITION
                boolean collision = false; // to check wall collisions

                if (speed.getxDirection() == Speed.LEFT
                        && getX() - (bitmap.getWidth() /2) <= 0)
                {//Left wall collision
                    collision = true;
                    Log.i(TAG, "left wall col");

                }
                if (speed.getxDirection() == Speed.RIGHT
                        && getX() + (bitmap.getWidth() /2) >= viewW)
                {//right wall collision
                    collision = true;
                    Log.i(TAG, "right wall col");

                }

                if(collision == false){ //No wall collisions, no problem
                    setX( (int)e.getX() );
                }

            }
        }
        //PRESS RELEASED
        if (e.getAction() == MotionEvent.ACTION_UP){
            if (isTouched()){
                //no longer being dragged
                setTouched(false);
            }
        }
    }

At the moment when my paddle hits the right side of the screen it stops where it should (without the bitmap going off screen) but the user is unable to drag it back, presumably because collision is now stuck set at "false"  so setX is never called again.

Oddly, when the paddle hits the left side of the screen the bitmap can just be continued to be dragged off screen and the collision is never detected.

Obviously I can recognize that there are two different issues here and I've had several ideas of how to solve the first, still can't figure out whats wrong with the second.

To solve the first I've tried getting rid of the collision variable all together. I've tried putting setting the x position back at various points

//eg. (after right wall collision detected)
setX( (int)e.getX() - 1);

or using my toggle x direction method, the same I got working with my ball object

//eg ( xDirection = xDirection * -1; )
speed.toggleXDirection();

I've tried all kinds of re-positioning of the code that I could think of that would possibly get it working as intended but I haven't been able to figure it out, any help would be appreciated.


texts: How do I control an animation with a drag command?

texts:
I want to play an animation when someone drags a sprite from it's default position to another selected position. If they drag half of the selected position then animation will be play half. For example, I have 15 frames of a animation for a projectile arm. The projectile arm can be rotated a maximum of 30°, if someone rotates the arm 2° then the animation sprite should show the 2nd frame, if rotated 12° then the animation sprite should  show the 6th frame.... and so on.
Also when they release the arm, the arm will be reverse back to it's default position and animation frames also will be reverse back to the default first frame.

I am new on cocos2D. I know how to make an animation and how to drag a sprite but I have no idea how to combine them. Can anyone give me an idea or any tutorial on how to do this?


texts: Two BitmapFonts from one .ttf font using AssetManager

texts:
I'm trying to start using AssetManager in my game. Previously I used to generate two BitmapFonts (bigger and smaller) from my .ttf file and it worked well. Here's how it looked in the code:

FreeTypeFontGenerator generatorRoboto = new FreeTypeFontGenerator(Gdx.files.internal("fonts/Roboto-Regular.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter params = new FreeTypeFontGenerator.FreeTypeFontParameter();
params.size = 80;
BitmapFont robotoFont = generatorRoboto.generateFont(params);
robotoFont.getData().setScale(0.5f);
robotoFont.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
params.size = 40;
BitmapFont smallerFont = generatorRoboto.generateFont(params);
smallerFont.getData().setScale(0.6f);
smallerFont.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear,
Texture.TextureFilter.Linear);

Then I add it to skin and use it.

skin.add("roboto-regular-font", robotoFont, BitmapFont.class);
skin.add("roboto-smaller-font", smallerFont, BitmapFont.class);

It works well, but now I'm trying to use it with AssetManager (according to documentation):

FreeTypeFontLoaderParameter robotoFontLP = new FreeTypeFontLoaderParameter();
robotoFontLP.fontFileName = "fonts/Roboto-Regular.ttf";
robotoFontLP.fontParameters.size = 80;
manager.load("fonts/Roboto-Regular.ttf", BitmapFont.class, robotoFontLP);
manager.finishLoading();

BitmapFont robotoFontBig = manager.get("fonts/Roboto-Regular.ttf", BitmapFont.class);
robotoFontBig.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
robotoFontBig.getData().setScale(0.5f);
BitmapFont robotoFontSmall = manager.get("fonts/Roboto-Regular.ttf", BitmapFont.class);
robotoFontSmall.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
robotoFontSmall.getData().setScale(0.15f);

skin.add("roboto-regular-font", robotoFontBig, BitmapFont.class);
skin.add("roboto-smaller-font", robotoFontSmall, BitmapFont.class);

But it doesn't work, LibGDX treat them as the same font. What am I doing wrong?


texts: How to add & copy ParticleSystem attached to an existing GameObject using C# script in Unity?

texts:
I have a GameObject "FireBall" with a ParticleSystem attached to it. I want to add the same ParticleSystem to other GameObject "Avatar". Initially there is no ParticleSystem attached to "Avatar".

When I do this -

ParticleSystem fireparticlesyst = gameObject.AddComponent<ParticleSystem>();

It adds a ParticleSystem to "Avatar" but I want to set all the properties of this ParticleSystem to the ParticleSystem attached to "FireBall".

If I add all the properties by individually I can't set some of the properties as they are read only.

How to do this ?


texts: render sprites with a transparent background (XNA)

texts:
For my game I want to make a map of the world. Per country I made a file with the border of the country and the rest of background is transparent. This way all my files have the same width and height. My problem is that XNA only renders the first image and it does it in an alphabetical order. For example: if I change the name of the first sprite so it isn't first in alphabetical order, it just renders the first sprite.

The sprites are loaded in a sortedlist and each key is the name of the continent + the name of the country. And I loop through this list to render each sprite.

Code to load the files:

protected override void LoadContent()
    {
        DirectoryInfo objDirectory = new DirectoryInfo(Game.Content.RootDirectory + "/Regions");
        FileInfo[] objFiles = objDirectory.GetFiles("*.*");

        objSpritebatch = new SpriteBatch(Game.GraphicsDevice);

        foreach (FileInfo File in objFiles)
        {
            string[] FileName = File.Name.Split("_".ToCharArray());
            string strContinent = FileName[1] + "/" + FileName[2].Substring(0, FileName[2].Length - 4);
            lstBorders.Add(strContinent, Game.Content.Load<Texture2D>("Regions\\" + Path.GetFileNameWithoutExtension(objFiles[0].Name)));
        }

        base.LoadContent();
    }

Code to render the files:

public override void Draw(GameTime gameTime)
    {
        objSpritebatch.Begin(SpriteSortMode.Texture, BlendState.AlphaBlend);

        foreach(KeyValuePair<string, Texture2D> Border in lstBorders)
        {
            objSpritebatch.Draw(Border.Value, new Rectangle(0, 0, 800, 400), Color.White);
        }

        objSpritebatch.End();

        base.Draw(gameTime);
    }

I allready did some research and hoped it would be fixed by using those parameters in the begin command but it didn't help. I hope I gave you all the code you need.


texts: Direct3D & Assimp Texture is inverted weirdly!

texts:
I'm working on a rendering engine but even on the first mesh is something wrong.
I use assimp for mesh importing!
In the Assimp Viewer it looks correct:

And in my software it looks like this:

Look at the text and you will see it is weirdly mirrored.
I'm using front counter clockwise vertex winding and the texture is flipped on y coordinate - if I don't then it is completely wrong. I already tried disabling front counter clockwise winding but the texture is still inverted!

Does anybody know what else I can try?


texts:
I haven't got a lot of experience with 3D Frameworks - but was playing around with three.js and came across something that (to me) is a bit odd and I wondered why this happened. I am rendering the number "1" on screen with the following code.

shapes = THREE.FontUtils.generateShapes("1", {
    font: "helvetiker",
    weight: "normal",
    size: 0.25
});

geom = new THREE.ShapeGeometry(shapes);
mat = new THREE.MeshBasicMaterial();
mesh = new THREE.Mesh(geom, mat);
mesh.position.set(1.5, +2.5, 0);
scene.add(mesh);

Now I also implemented camera movement, so I can rotate and move along the z/x/y axis. When I move the camera past the number "1", and turn the camera 180° around - the number is gone. So the camera is behind it but I did change the point the camera is facing - yet the object is gone.

[Well, if I put the camera sideways and slide past it, it also stops rendering. So I'm 100% sure it's not rendered].

I was wondering two things.
1) Is this the normal approach in 3D? To not render things that lie behind you on the Z-axis (even though the camera is turned.)
2) I'm assuming it's not the standard, as it surely isn't the expected behaviour. So how would I, in Three.JS, have the object rendered when the camera faces it, even though the camera is behind it.

Just an explanation would already be a huge help, but if you can provide a code snippet it would be even better. Thanks!


texts: I am making a game, and I just started to think about how I am going to update and render all the sprites on the screen. Should I store all sprites in some type of list (vector or something?) and then call the draw and render method on all those? I'm using SFML and C++ if that helps.


texts: How significant is the addition of multiplayer to a singleplayer game compared to starting with multiplayer in mind?

texts:
Especially for game designers or software engineers, I was wondering how significant of an increase in difficulty/frustration/workload it would be for multiplayer to be an afterthought of a singleplayer game, as opposed to putting in all of the work for the game to be "multiplayer ready" from the start.

This question is especially important when the question of "Will there be multiplayer?" is up in the air until after the game is developed.

I only ask because coding with multiplayer in mind from the start, I assume, is a hefty chunk of extra difficulty that one could otherwise skip. Of course adding in such a engine-changing feature, I assume, would be quite frustrating given a game already close to being finished. Both strategies seem burdensome, but if the extra workload of implementing a big feature after a game is already completely is extraordinary compared to the heavy workload of engineering it from the start, then obviously one would nearly always want to prepare for multiplayer.

I am also curious on a personal level as I have seen a few indie projects declare they will never add multiplayer, and then months later after the game has over a year in development, change their mind and say they will be adding it as a high priority feature due to the large demand for what is probably the most common core feature of any game.


texts: What was the game project that felt like "YOUR" game?

texts:
This question might seem a bit vague but it is hard to formulate properly. I will try as best as I can. So here goes...

For many years I have been trying to create games but I haven't managed to finish even a single one. The main reason, among others, was that the game creation process lacked focus. There never was a concrete vision of what I was trying to create.

Now I realize that I would usually want to create a game that was similar to some other that I recently played and liked. It seems like there are many games I would like to make but there is none that I would see as THE game I want to make (or one of THE games).

I really want to create something that I (and hopefully, others too) like and can be proud of. But I'm having a hard time discovering what it is. It doesn't have to be big, graphically awesome or anything like that. It should simply be something I really enjoy and am motivated to create.

So, has anyone else here had the same or similar problem? Have you found a way to overcome it? Have you discovered "YOUR" game?

If so, what was different about it from other games you tried creating?

EDIT:

Thanks for all your answers. Just want to clarify some things a bit...

Before asking this question I already read through various older questions about things like prototyping, having deadlines, to-do lists, participating in competitions with short deadlines, etc.

What I wanted to know more by asking this question was not how to create a game in general but how to discover a project that feels like what you really want to do.

For example, I play racing games very rarely, but sometimes I might play some game that is quite fun for a while and get an idea about creating some racing game of my own. But that idea won't stay for long and I will soon get bored with it because in general I am not the kind of guy who is really "into" racing games.

It would be nice if someone here could tell how they discovered what their game was. And I would appreciate if you could tell your story with more details, especially about the things that made the difference between "it would be nice to make this game for myself" and "I want to make this game really badly".


texts: Is GL_DEPTH_COMPONENT32 deprecated in OpenGL 4.5?

texts:
I'm in the process of migrating our object oriented OpenGL wrapper from 3.3 core to 4.5 core.

Some OpenGL implementations are notoriously permissive on what inputs they'll accept which can make tracking down bugs difficult. Wherever possible the inputs to our wrapper are validated with asserts to keep them in line with the spec.

While setting up the asserts for glTextureStorage3D I've noticed that according to this page on the Khronos website it only accepts the following sized depth types: GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT16, GL_DEPTH32F_STENCIL8 or GL_DEPTH24_STENCIL8.

Non-floating point 32bit depth types seem to be missing from that list which leads me to believe they're no longer supported (or at least actively discouraged). There's also this answer to another question which states that:

  GL_DEPTH_COMPONENT32 is probably overkill, and as of 4.5, isn't a required format for OpenGL implementations to support (though 16 and 24 bit ones are).

I have tried to find some reference to this in the 4.5 core spec but turned up nothing.

Is GL_DEPTH_COMPONENT32 a deprecated size type? If so, why?


texts: I am trying to reference the System.Threading.Task assembly. If I am not mistaken, it should be part of mscorlib. But no matter what I do, my project always defaults to the .net 2.0 runtime. Even if I create a brand new XNA 4.0 Windows Phone project, it wants to use the .net 2.0 runtime. Any ideas what I could be missing?


texts: How can I show tilemap coordinates in-game in Unity?

texts:
I have a game that uses a tile map, and I'd like to draw numbers representing positions on the tile map while playing the game. This would, for example, let me easily write down a note that I want to make changes at a specific coordinate.

I've written a script which grabs the Tilemap object and assigns it to a variable called m_map, and then:

void OnGUI()
{
    for (int x = -15; x < 15; ++x)
    {
        for (int y = -15; y < 15; ++y)
        {
            //if (GetTile(x, y) == null) continue;

            if (Camera.main != null)
            {
                Vector3 coord = m_map.GetCellCenterWorld(new Vector3Int(x, y, 0));

                Vector3 screenCoord = Camera.main.WorldToScreenPoint(coord);

                GUI.Label(new Rect(screenCoord.x, screenCoord.y, 200, 200), string.Format("{0},{1}", x, y));
            }
        }
    }
}

However, this does not produce the results I would expect.  The Y-axis is inverted, for example, and X-axis seems to be off by a cell or two. Moving the camera along the Y-axis also causes the labels to move away from the tiles they are supposedly numbering, which means it definitely isn't correct.

It seems I must have made some bad assumption about one of these coordinate systems, but I can't figure out what.


texts: How does creating 2d game assets differ from regular 2d art?

texts:
I've done some digital paintings and concept sketches in the past, and I was thinking about employing those skills in my game making efforts.

From an artists standpoint, what does he have to do differently/additionally to make his artwork "game ready" or "game friendly"?

Mostly I'm interested in using 2D in Unity, perhaps with an isometric view (so called 2.5D)


texts: i've just started out with Opengl, and i've got to know what Vertex Buffer Objects are, but i really don't understand what VAOs are. Can someone help me?


texts: How do I find the intersection of a ray and a cylinder?

texts:
I'm looking for the algorithm to find the intersection (or lack of) between a ray and a cylinder. I have rotating coin like objects in my game world and need to check for a collision on that object. I also need to know the location of intersection to determine which part of the coin was hit.

The cylinder has an arbitrary rotation. I can provide as input the direction (vector) it is facing, a centre point, and a radius.

For the ray I can generalize to a line, as it'll be easy to check within the segment afterwards. Ideally I'd like the array to be an infinite cylinder, but I can easily fudge this aspect once I have the collision for a line.


texts: Problem passing variables in fragment shader

texts:
I'm trying to pass a point light from an array to a CalcLight function in a fragment shader.  It works when I hard code in the value, but not when I use a loop.  Here's the code:

#define TOTAL_LIGHTS 2
struct PLight
{
    vec4 pos;

    vec4 diff;
    vec4 spec;
    vec4 amb;

    float con;
    float lin;
    float quad;
};

layout(std140) uniform Light
{
    PLight pLights[TOTAL_LIGHTS];
}light;

vec3 CalcPoint(in PLight p)
{
    ...
}

When I pass in the light from main using hard coded values it works fine.

void main()
{
    ...
    pointLight += CalcPoint(light.pLights[0]);
    pointLight += CalcPoint(light.pLights[1]);
    ...
}

But, when trying to use a loop, the first light works fine but not the second.

for(int i = 0; i < TOTAL_LIGHTS; i++)
    pointLight += CalcPoint(light.pLights[i]);

Any thoughts as to why the loop isn't working?