texts:
After Fiddling around I am pretty sure this is not a Shader issue.

Edit 4:
The only diference I can see is that BasicEffect calls these methods before drawing:

 // Make sure that domain, hull and geometry shaders are disable.
        GraphicsDevice.DomainShaderStage.Set(null);
        GraphicsDevice.HullShaderStage.Set(null);
        GraphicsDevice.GeometryShaderStage.Set(null);

So I tried this:

technique
{
pass
    {
    Profile = 11.0;
    // TODO: set renderstates here.
    GeometryShader = NULL;
    HullShader = NULL;
    DomainShader = NULL;
    VertexShader = VertexShaderFunction;
    PixelShader = PixelShaderFunction;

    }
}

Still it doesnt render anything. Maybe this will someone to get a idea.

My matrix is calculated like this :

        Matrix MVP = Matrix.Multiply(Matrix.Multiply(Matrix.Identity, Matrix.LookAtLH(new Vector3(-10, 10, -10), new Vector3(0), new Vector3(0, 1, -0))), Camera.Projection);

        VoxelEffect.Parameters["MVP"].SetValue(MVP);

I am currently Using it with Matrix.Identity.

Visual Studio Graphics Debug shows me that my vertex shader is actually working, but not the PixelShader. I striped the Shader to the bare minimums so that I was sure the shader was correct.
But why is my screen still black?

EDIT: Before people start saying that this is duplicated of

DirectX11 pixel shader in pipeline is missing

I already checked that a few others, and none of the answers solved my issue.

EDIT 2:

RenderDevice.Quad.Draw(MyEffect);

This shows a quad on screen, as it should so the problem is not on my Shader code.
Still I am baffled, I am doing this using another call  which if I use the default BasicEffect class renders fine but if I use mine it doesnt show anything:

        VertexPositionNormalTexture[] QuadsVertices = new VertexPositionNormalTexture[]
        {
            new VertexPositionNormalTexture(new Vector3(-1, 1, 0),Vector3.Zero,new Vector2(0, 0)),
            new VertexPositionNormalTexture(new Vector3(1, 1, 0), Vector3.Zero,new Vector2(1, 0)),
            new VertexPositionNormalTexture(new Vector3(-1, -1, 0), Vector3.Zero,new Vector2(0, 1)),
            new VertexPositionNormalTexture(new Vector3(1, -1, 0), Vector3.Zero,new Vector2(1, 1)),
        };
        Matrix MVP = Matrix.Identity;

  g.Draw(MyEffect); //This renders nothing

Using Quad Render I get a nice Quad on the screen.
So what could possibly be the issue here?


texts: let me know how to save an integer for game stage level?

texts:
I am trying to make a game which there are many stages.
For example, If users are done stage 3 of the game, and then turn off the game,
they can play the game at stage 3 anytimes.

simply, I tried to make this logic, so when you press space bar, the level goes up.
However, after turning off and on, lev will start at 0.
I guess when program are ruining every single times, the lev is initialized 0.

I tried to use preference.

please let me know solutions..

AppPreferences.java

public class AppPreferences {

   private static final String PREFS_NAME = "Adventure";
   private static final String PREF_LEVEL = "Level";
   private Preferences preferences;

   protected Preferences getPrefs(){
    if (preferences == null)
        preferences = Gdx.app.getPreferences(PREFS_NAME);
       return preferences;
}

public void setPrefLevel(int level){
    getPrefs().putInteger(PREF_LEVEL,level);
    getPrefs().flush();
}

public int getPrefLevel(){
    return getPrefs().getInteger(PREF_LEVEL);
}

}

PlayScreen.java

public class PlayScreen implements Screen {
 int lev=0;

 public void render(float delta) {

     if(Gdx.input.isKeyJustPressed(Input.Keys.SPACE)){

        advanture.getPreferences().setPrefLevel(i);
        System.out.println(advanture.getPreferences().getPrefLevel()+"!!!!!!!!!");
        i++;
   }

 }


texts: Event when nodes overlap, but not collide

texts:
I am trying to implement a scenario where a dynamic object (a node that implements RigidBody2D and defines BodyType2D.Dynamic) "collides" with a static object (like the former, but defines BodyType2D.Static) by falling through it.

Think of it like Mario Cart, where you steer the cart in the direction of a box and the cart goes right through the box to collect whatever is inside. But the cart doesn't actually collide with the box. In this example, the cart is the dynamic object and the box is the static object.

Is there an event that notifies you of whether or not two nodes overlap (or collide) without implementing the actual collision?

For instance, I am aware of the following events defined by nodes, NodeCollision, NodeCollisionStart, and NodeCollisionEnd, as well as PhysicsBeginContact2D. The latter event invokes if both objects define collision properties (such as CollisionBox2D); if you remove collision on the static object (which is what I assume I ultimately have to do), the event no longer invokes.

The other three events never seem to invoke at all, though, when I tested them, the static object did not define any collision. Thus, it is possible the three events do invoke, but only when collision is defined. Needless to say, the static object shouldn't define actual collision so these events don't seem to be the answer.

I've tried a few experiments where I make the dynamic object static upon collision, remove the static object (to show that it was collected), then make the dynamic object dynamic again. Unfortunately, the physics of the dynamic object is still disrupted by the static object because it does technically still collide and changing BodyType is very expensive.

I've thought about writing some position checks in OnUpdate, but that seems hacky and very inelegant.

After perusing the documentation (primarily, here and here), I could not find anything pertaining to this type of scenario aside from the aforementioned four events, which do nothing in terms of my issue.

Is there an obscured facility somewhere meant for this type of thing? I am somewhat new to game development so forgive me if there's an important concept here I don't seem to be aware of.


texts: Methods of Creating a "Lightning" effect in 2D

texts:
well i'm just wondering on the best way to go about create some form of "Lightning" effect to be used in a game, so for example:

-In my game, i would like to have this effect in the menus and in-game in some form of random weather system perhaps.

Just wondering on the methods available? I did read this blog post:
http://drilian.com/2009/02/25/lightning-bolts/

And took a-look at the Lightning sample thats around.
I like the method placed in the blog post, just really a bit unsure on how to create the vertices from the lightning segments.
I would be great if someone could explain that seconded sub-heading (Adding glow) a bit more to me :).

But like i said, i'm really want to know if there's any other ways i could accomplish this?


texts: Handling multiple AI updates for simultaneous movement

texts: How would I go about having multiple AI on the screen all at once all calculating separate movements without too much lag and within sane working memory. Before I have had many on the screen by putting objects of them in an array and looping through calling the move method, however this isn't the fastest method of handling them. Is it okay to use threads when you have say 200 AI at the same time on the screen? Can anyone help me work out the best structure for having multiple AI (which all move)?


texts: How can I slowdown the characters to speed 0?

texts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AnimatorController : MonoBehaviour
{
    public Animator[] animators;
    public Transform target;
    public float speed = 1f;

    // Use this for initialization
    void Start()
    {
        for (int i = 0; i < animators.Length; i++)
        {
            animators[i].SetFloat("Walking Speed", speed);
        }
    }

    // Update is called once per frame
    void Update()
    {
        float distanceFromTarget = Vector3.Distance(animators[2].transform.position, target.position);
        if (distanceFromTarget < 15)
        {
            float speed = (distanceFromTarget / 15) / 1;
            for (int i = 0; i < animators.Length; i++)
            {
                animators[i].SetFloat("Walking Speed", speed);
            }
        }

        if(distanceFromTarget < 1)
        {
            for(int i = 0; i < animators.Length; i++)
            {
                animators[i].SetFloat("Walking Speed", 0);
            }
        }
    }
}

This part of the slowdown is working fine:

float distanceFromTarget = Vector3.Distance(animators[2].transform.position, target.position);
            if (distanceFromTarget < 15)
            {
                float speed = (distanceFromTarget / 15) / 1;
                for (int i = 0; i < animators.Length; i++)
                {
                    animators[i].SetFloat("Walking Speed", speed);
                }
            }

I tried to add this part to make the characters stop:

if(distanceFromTarget < 1)
            {
                for(int i = 0; i < animators.Length; i++)
                {
                    animators[i].SetFloat("Walking Speed", 0);
                }
            }

But they never stop. They are slowing down then continue walking slow and then the speed moving up again once they are getting away from the target.

I want them to slowdown when the distance is 15 and less and once animators[2] distance is 1 from target stop.

Screenshot of the Animator:
The two soldiers have the same animator controller the other character have it's own controller all of them have the same states and parameters and same settings:


texts: How do I change the material of an object with Script in Unity?

texts: I was making a game with Unity and I want to change an object's material using UnityScript when the player collects 5 collectables that I made. The collectables get stored in an int variable called Score.


texts: How to intentionally make an RPG maker game crash?

texts: I'm currently working on a game project that involves tricking the user into thinking the game experienced a bug/glitch and crashed. The reason that I want to code this is that I want to hide the file size of the main game, thus separating it into two files. So I want the first file which has x amount of game to crash at a certain point. Then manually give the second half of the game to the user and they can continue on. It may seem a little pointless, but I think stylistically this is a neat concept to try.


texts:
I have these shapes with a lineStyle to outline the shapes, however, when I tried to do colorTransform, it will completely remove the outline of the shapes. Is there a way to make lineStyle constant? To permanently stay after the colorTransform? I don't quite understand as I thought colorTransform is just changing the color of the shape.

            char.graphics.lineStyle(0, 0x000000);
            char.graphics.beginFill(0xFFFFFF, 1);
            char.graphics.drawEllipse(x, y, 25, 25);
            char.graphics.endFill();

I have the outline as black and inside is all white.

            changeColor = char.transform.colorTransform;
            changeColor.color = 0xFFFFFF;
            char.transform.colorTransform = changeColor;

Once I change the shapes back to white to their original color, the lineStyle disappears. Is there a way to prevent this from happening?


texts:
I want to design a very simple GUI for my game using OpenGL.

So far, every GUI implementation I have seen uses pixel space coordinates ( x range 0.0 to screen width and y 0.0 to screen height)

Why aren't they simply using screen space coordinates ? ( x and y range -1 to 1)

With screen space coordinates we would'nt have any issue with screen resizing, plus we won't have to transform coordinates for OpenGL since we use same space.

So why every GUI engine uses pixel space ?


texts: Relative angle in degrees between 2 lines

texts: Could anybody help to solve this? Relative angle between 2 rays(lines) which starts from same point. They could point anywhere 360 clockwise, but angle should be always relative (just inside angle).


texts: Unwanted rotations with transform.RotateAround

texts:
I didn't tough i would have issues with this, but unfortunatly I did. I have a Character (which is more a pile of cube) with a body, a empty GameObject for each leg attached to the body with a join and 2 cubes for leg too. The body and the two empty gameobject are child of a Empty gamebject. The 2 cube that represent leg are both child of one of the empty gameObject. What I want to achieve is to rotate the leg around the position of its empty parent by doing this:

if(Input.GetKey("l"))
    {
        l_leg.transform.RotateAround(l_leg.transform.parent.transform.position, new Vector3(1,0,0), 75 * Time.deltaTime);
    }

unfortunatly, I only want it to rotate on x, but all of the axis are changing, which lead to unwanted rotation. Now, I know rotations aren't independant like translations, but I don't know how to fix this. If possible, i'd prefer to rotate locked joint via script but I have now idea how, I haven't seen anything about it when I looked up]2


texts: How to randomly calculate the necessary velocity changes to reach a x,y,z target?

texts:
I am working on creating a mini vector graphics ping pong table, as described in this previous post: Trying to use 3D vectors for a 2D ping pong game

Currently, the stage I am at, I am trying to make it so that when the ball exceeds the X bounds of the table, it will reflect backwards and at a new target: a random x,y,z position on the opponent's side of the table.

Trying to use this post as a starting point:
How can I launch a GameObject at a target if I am given everything except for its launch angle?
I have attempted to adapt some of that example code in my program, but I am not quite getting the desired results.

** updated code **

update: function(paceFactor) {
  this.ball.pos3D.x += this.ball.vel.x * paceFactor;
  this.ball.pos3D.y += this.ball.vel.y * paceFactor;
  this.ball.pos3D.z += this.ball.vel.z * paceFactor;
  this.ball.vel.y += this.gravity * paceFactor;

  if (!this.stop && Math.abs(this.ball.pos3D.x) > 15) {
    this.stop = true; // for testing to prevent velocity from getting changed due to bad values returned from velocityForNextTarget()
    var modifier = this.ball.pos3D.x < 0 ? 1 : -1;
    var velocity = this.velocityForNextTarget(modifier);
    this.ball.vel.x += velocity.x;
    this.ball.vel.y += velocity.y;
    this.ball.vel.z += velocity.z;
  }

  if (this.ball.pos3D.y >= 0) {
    this.ball.vel.y *= -1;
    this.ball.pos3D.y -= this.ball.pos3D.y;
  }

  this.convert3Dto2D();
},

velocityForNextTarget: function(modifier) {
  var targetX = 5 * modifier;
  var targetY = 0;
  var targetZ = 0;

  var deltaX = this.ball.pos3D.x - targetX;
  var deltaY = this.ball.pos3D.y - targetY;
  var deltaZ = this.ball.pos3D.z - targetZ;

  var sqrMagnitude = (deltaX * deltaX) + (deltaY * deltaY) + (deltaZ * deltaZ);
  var speed = Math.sqrt((this.ball.pos3D.x * this.ball.pos3D.x) + (this.ball.pos3D.y * this.ball.pos3D.y) + (this.ball.pos3D.z * this.ball.pos3D.z));

  var gSquared = this.gravity * this.gravity;
  var b = speed * speed + (deltaY * this.gravity);
  var discriminant = (b * b) - (gSquared * sqrMagnitude);

  var discRoot = Math.sqrt(discriminant);

  var t = Math.sqrt((b - discRoot) * 2 / gSquared);

  return {
    x: deltaX / t * t / 2,
    y: deltaY / t - this.gravity * t / 2,
    z: deltaZ / t * t / 2,
  };
},

So what I am trying to do is make it so that when the ball reaches the location of a player, it will target the center of the opponent's side of the table, and the ball will move there, and right now this code is making the ball rapidly jump off the screen as soon as it hits the x bounds, and I am not sure what I am doing wrong with the math in velocityForNextTarget()...

I should also mention that gravity is just a constant that I am only adding to my Y velocity so far.  I am not sure if that's "right" ?


texts: Making a text only console game in C#. Can't figure out a way to organize states

texts:
When I say states I mean like what you would call scenes in unity. As in each phase of the game. But in straight up code for a console application in C#.

Example:
Name select.
Race Select.
Store.
Help Screen.

I've tried organizing each phase by methods, and while loops, but i've run into a lot of trouble these ways. How should I do it?


texts: Trying to make a box move around the screen with the arrow keys

texts:
I have a box and it moves around the screen when the user presses the arrow keys. It seems a bit bulky and awkward though. Any thoughts on how to make it more efficient/less resource intensive?

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

public class Box {

private float boxWidth, boxHeight;
private int gameWidth, gameHeight;
private Color boxColor;

private Vector2 position;
private Vector2 velocity;
private Vector2 acceleration;

private boolean goRight, goLeft, goUp, goDown, stopRight, stopLeft, stopUp, stopDown;

public Box(int boxWidth, int boxHeight, Color boxColor, int gameWidth, int gameHeight) {
    this.boxWidth = boxWidth;
    this.boxHeight = boxHeight;
    this.boxColor = boxColor;

    this.gameWidth = gameWidth;
    this.gameHeight = gameHeight;

    position = new Vector2(gameWidth/2 - boxWidth/2, gameHeight/2 - boxHeight/2);
    velocity = new Vector2(0, 0);
    acceleration = new Vector2(0, 0);
}

public void update(float delta) {

    velocity.add(acceleration.cpy().scl(delta));

    if(velocity.x >= 100) {
        velocity.x = 100;
    }

    if(velocity.x <= -100) {
        velocity.x = -100;
    }

    if(velocity.y <= -100) {
        velocity.y = -100;
    }

    if(velocity.y >= 100) {
        velocity.y = 100;
    }

    if(stopRight) {
        if(velocity.x > 0) {
            velocity.x -= velocity.x/20;
            if(velocity.x <= 0) {
                velocity.x = 0;
                stopRight = false;
            }
            if(goLeft) {
                acceleration.x = -100;
            }
        }
        else {};
    }

    if(stopLeft) {
        if(velocity.x < 0) {
            velocity.x -= velocity.x/20;
            if(velocity.x >= 0) {
                velocity.x = 0;
                stopLeft = false;
            }
            if(goRight) {
                acceleration.x = 100;
            }
        }
    }

    if(stopUp) {
        if(velocity.y < 0) {
            velocity.y -= velocity.y/20;
            if(velocity.y >= 0) {
                velocity.y = 0;
            }
            if(goDown) {
                acceleration.y = 100;
            }
        }
    }

    if(stopDown) {
        if(velocity.y > 0) {
            velocity.y -= velocity.y/20;
            if(velocity.y <= 0) {
                velocity.y = 0;
            }
            if(goUp) {
                acceleration.y = -100;
            }
        }
    }

    if(position.x >= gameWidth - boxWidth) {
        position.x = gameWidth - boxWidth;
    }

    if(position.x <= 0) {
        position.x = 0;
    }

    if(position.y >= gameHeight - boxHeight) {
        position.y = gameHeight - boxHeight;
    }

    if(position.y <= 0) {
        position.y = 0;
    }

    position.add(velocity.cpy().scl(delta));

}

public Box getBox() {
    return this;
}

public Color getBoxColor() {
    return boxColor;
}

public void goRight() {
    goRight = true;
    acceleration.x = 100;
    stopRight = false;
}

public void goLeft() {
    goLeft = true;
    acceleration.x = -100;
    stopLeft = false;
}
public void goUp() {
    goUp = true;
    acceleration.y = -200;
    stopUp = false;
}
public void goDown() {
    goDown = true;
    acceleration.y = 200;
    stopDown = false;
}

public float xPos() {
    return position.x;
}

public float yPos() {
    return position.y;
}

public void stopRight() {
    acceleration.x = 0;
    stopRight = true;
    goRight = false;
}

public void stopLeft() {
    acceleration.x = 0;
    stopLeft = true;
    goLeft = false;
}

public void stopUp() {
    acceleration.y = 0;
    stopUp = true;
    goUp = false;
}

public void stopDown() {
    acceleration.y = 0;
    stopDown = true;
    goDown = false;
}

}

Any ideas on how to do this with fewer lines of code? Thanks!


texts: How can I distribute the source code of my project without the imported assets?

texts:
I have a Unity project that uses some assets that I downloaded for free in the Unity asset store. I would like to make my project open source and distribute its source code in GitHub. But, I do not want to put the assets I downloaded in my GitHub, since they are not mine. Also, these assets take a lot of space in my repository.

Can I arrange my project in such a way that any user who downloads it will be automatically sent to the Unity asset store to download the required assets?

I found that it works well with TextMesh Pro: I can remove the TextMesh Pro folder from my Assets folder, and then when I open the project in Unity, it prompts me to re-import TextMesh Pro, and when the import is done, the game works well. Is it possible to achieve a similar effect with other assets?


texts: How do you test xbox (via PC) input without an xbox on XNA Game Studio?

texts: Is it safe to just hookup a wired Xbox controller to my PC via USB? Do I need to buy a special PC Xbox controller? I've read conflicting reports. Any help is appreciated.


texts: Coordinate based travel through multi-line path over elapsed time

texts:
I have implemented A* Path finding to decide the course of a sprite through multiple waypoints. I have done this for point A to point B locations but am having trouble with multiple waypoints, because on slower devices when the FPS slows and the sprite travels PAST a waypoint I am lost as to the math to switch directions at the proper place.

EDIT: To clarify my path finding code is separate in a game thread, this onUpdate method lives in a sprite like class which happens in the UI thread for sprite updating. To be even more clear the path is only updated when objects block the map, at any given point the current path could change but that should not affect the design of the algorithm if I am not mistaken. I do believe all components involved are well designed and accurate, aside from this piece :- )

Here is the scenario:

public void onUpdate(float pSecondsElapsed)
{
    // this could be 4x speed, so on slow devices the travel moved between
    // frames could be very large. What happens with my original algorithm
    // is it will start actually doing circles around the next waypoint..
    pSecondsElapsed *= SomeSpeedModificationValue;

    final int spriteCurrentX = this.getX();
    final int spriteCurrentY = this.getY();

    // getCoords contains a large array of the coordinates to each waypoint.
    // A waypoint is a destination on the map, defined by tile column/row. The
    // path finder converts these waypoints to X,Y coords.
    //
    // I.E:
    // Given a set of waypoints of 0,0 to 12,23 to 23, 0 on a 23x23 tile map, each tile
    // being 32x32 pixels. This would translate in the path finder to this:
    //    -> 0,0 to 12,23
    //        Coord : x=16 y=16
    //        Coord : x=16 y=48
    //        Coord : x=16 y=80
    //          ...
    //        Coord : x=336 y=688
    //        Coord : x=336 y=720
    //        Coord : x=368 y=720
    //
    //    -> 12,23 to 23,0 -NOTE This direction change gives me trouble specifically
    //        Coord : x=400 y=752
    //        Coord : x=400 y=720
    //        Coord : x=400 y=688
    //          ...
    //        Coord : x=688 y=16
    //        Coord : x=688 y=0
    //        Coord : x=720 y=0
    //
    // The current update index, the index specifies the coordinate that you see above
    // I.E. final int[] coords = getCoords( 2 ); -> x=16 y=80
    final int[] coords = getCoords( ... );

    // now I have the coords, how do I detect where to set the position? The tricky part
    // for me is when a direction changes, how do I calculate based on the elapsed time
    // how far to go up the new direction... I just can't wrap my head around this.

    this.setPosition(newX, newY);
}


texts: Render moveable entities into 3D isometric world?

texts:
I have a separate list of moveable entities, and then the regular 3D map, represented by a 2D array of stacks of tiles. My problem is that right now, I'm rendering my moveable entities after the map, and so they end up in the right place, but rendering over everything. If I were to render my entity list at the right place, however, in the map rendering process, it would be very slow because I'd have to iterate over the moveable entity list to find one with the correct (x, y) coordinates each tile that's rendered. Here's what my world looks like:

Here is a screenshot of a particularly awkward example of this issue. The colonists are positioned (or seem to be) on the right tiles, but they draw in front of trees and hills they are actually behind.

Here's my current moveable entity drawing code:

Apologies for using a screenshot, but I can't paste into this text box for some reason. Anyway, my map drawing code is just a nested for loop over the map, pretty much. How do I merge these two? My drawing library doesn't have a Z-axis function.


texts: Link CSS file with HTML file in Unity Power UI

texts:
I want to link css file with html in Unity with the help of Power UI. I already converted css file into bytes format but it not still worked. Here is the code

    <link href="Resources/bootstrapUnity.css.bytes"/>

Hello Game

    <button type="button" class="btn btn-success btn-lg">Play</button>
    <button class="btn btn-info">Test</button>


texts: Where to hire graphic designers for mobile games?

texts:
I need to find someone talented to create a series of 2D graphics a la cart for my mobile games.  My graphics are just not impressive enough, but the game play is solid and fun.

This is sort of a multi-part question:

Where do I start to find someone?

What should I expect to pay for custom sprites and backgrounds?

What kinds of terms should I use so I receive exclusive, royalty-free, ownership of the artwork when it's finished?


texts: When animating sprites, why subtract frametime when switching between sprites instead of resetting elapsed time to zero?

texts:
I am currently on chapter 3 of the book "Learning XNA 4.0". At the end of this chapter is a section on changing the animation speed of sprites.

timeSinceLastFrame += gameTime.ElapsedGameTime.Milliseconds;
   if (timeSinceLastFrame > millisecondsperFrame)
   {
       timeSinceLastFrame -= millisecondsperFrame;
       //code for cycling through sprite sheet here.

This code is in the Update method. It iterates timeSinceLastFrame until it's greater than millisecondsperFrame (which I have specified as 20), and then it resets by subtracting millisecondsperFrame from timeSinceLastFrame.

If I instead reset it by writing timeSinceLastFrame = 0, the animation is noticeably slower. From what I can tell, this is due to the fact that XNA updates at 60 frames per second, so timeSinceLastFrame iterates by several milliseconds each time, and likely won't have the same value as millisecondsperFrame once the if statement compares the two.

Despite this, is there anything particularly bad about writing timeSinceLastFrame = 0? Or is timeSinceLastFrame -= millisecondsperFrame safer?


texts: Find distance from Vector2 to nearest point in Rectangle

texts:
I'm setting up collision detection and I have Walls which store their positions as rectangles. I need to figure out the distance from a Vector2 to the nearest side of a rectangle. If this was two Vector2's I could just do Vector2.Distance() but I can't find similar methods for Vector2s and Rectangles. Here is an image to illustrate what I need:

So the red dot would be my Vector2 and the blue would be my Rectagle, and I need to get the distance of the orange line. Once I have this I can check the distance for my collision detection.


texts:
I have a screen class in libGDX.  In this screen, I want to change a sprite's texture a certain number of times before the screen changes to a different screen class.  I tried having a for loop in the render method, but that obviously didn't work as render is constantly called.

Can anyone help?


texts: How does server code modify game state on the server while still accepting additional server game calls

texts:
Question first, then explanation second.

How can a webservice backend to a game modify and alter the server game state while the game simultaneously accepts webservice calls from other users of the game?

These are my assumptions of how browser-based games work.  They may be full of misconceptions, and please correct me if I am wrong!

Turn-based games are intuitively games that would best be represented by a single instance of a game.
Turn-based browser games with a server backend would typically call a sort-of "webservice" on the server.
A webservice has to complete its entire operation and then return.

I'm getting confused during the conversion between the "entire operation" part of the webservice and the non-static "single instance" of the game backend itself.  How can a webservice, with their static nature, modify and alter a game while the game simultaneously accepts webservice calls from other users of the game?  The only way I can see this occurring with static method calls is that the webservice saves and loads the game for each call, which seems horrifically wasteful on resources.

For example, consider a 3-player connect-four board, where only one player can play at once but users can change their color at will.  The user should be able to change their color while waiting for the other players to play.

The question I have here is both conceptual and implementation-oriented, although it's mainly the conceptual that I'm curious about.


texts: Linking Unreal Engine with OpenCV libraries built with RTTI on Linux

texts:
Unreal Engine has a plugin for integrating with OpenCV. Currently that plugin works on Windows. I'm trying to modify this plugin to work on Linux. I've worked through many issues but I have one I can't resolve.
When I try to build the plugin without modification, I get this error:

cannot use typeid with -fno-rtti

The error is from a file any.h which is a part of the OpenCV FLANN feature set and appears to have been copied over from boost.
To address this, I enable RTTI for the module of the plugin I'm building. Unfortunately, this leads to load time errors like the following:

dlopen failed: /home/lvl-dev/Projects/TestOpenCVModules/Plugins/OpenCVLensDistortion/Binaries/Linux/libUE4Editor-OpenCVLensCalibration.so: undefined symbol: _ZTI7UObject
ModuleManager: Unable to load module '/home/lvl-dev/Projects/TestOpenCVModules/Plugins/OpenCVLensDistortion/Binaries/Linux/libUE4Editor-OpenCVLensCalibration.so' because the file couldn't be loaded by the OS.

As far as I can tell, this is because Unreal builds by default with '-fno-rtti'. And now the Unreal objects in my plugin expect RTTI information to be available for the Unreal objects when my libraries are loaded at runtime. I found you can pass RTLD_LAZY to dlopen(), which I thought would address this, but when I looked at the source it was already using it.
The next obvious thing is to just build everything with RTTI but I've been unable to accomplish this. I've seen on some forums that building Unreal with RTTI is possible after version 4.15 or so. However, when I've tried to build the engine with RTTI I get errors from attempting to link compiled third party dependencies that are now incompatible with Unreal (WebRTC for example). I'd really rather not work my way through building every Unreal dependency from source myself.
Strangely nothing is done to handle this issue on Windows. It seems the Microsoft linker and runtime handles both RTTI and non-RTTI definitions of the object without issue.
Is there a straight forward way to build and successfully run wtih C++ RTTI enabled?
Is there a way to mix RTTI and non-RTTI objects, as Microsoft seems to do, and suppress the link errors from the runtime?
Is there some solution I'm not considering?


texts:
I'm a web developer who is trying to know more about game development.

I've started trying to make Pong using canvas, just to see how far I can go (and what I can learn along the way).

I have heard a lot about the game loop but being a novice was not sure how it applies to Pong. I figured it would be something like a setInterval() that changes the game's state as it runs (ball movement, enemy position, etc).

I have also created two objects, Paddle and Ball, but looked at implementing the bouncing inside one of Ball's methods. I'm not sure if that is right.

What I want to know is am I on the right track? What suggestions would you have to my code in terms of layout/structure (and any recommended reading)?

Most of the articles I found regarding JavaScript game development were horribly outdated or didn't deal with canvas; only animating DOM elements.


texts: Would it be possible to package in a JVM with games for modern consoles?

texts:
I really like LibGDX (using Java). It has a great community with a lot of resources and many nice features included. But I would also love to develop games for the Nintendo Switch, PS4 and Xbox One.

I know that those consoles do not natively support Java applications. But with the way those consoles work (usually running somewhat modern operating systems and often just being forks of Linux), would it be possible to package a game with a JVM wrapper to support those platforms individually? The whole point of Java is that the JVM can be adapted to many platforms, so it must be possible with some work, right?

If so, what performance penalties would there be and what would be involved in this endeavor?

Thanks!


texts:
The moon is drawn with two draw calls, but both draw wrong on the xbox so I'm just displaying one draw for simplicity.

This is how the moon should look on the PC:

How it looks on the XBOX:

The texture flickers, disappears, looks like a gradient from bottom to top, lines run through it, and so on as the camera moves around. For example after moving the camera slightly it looks like this:
http://olhovsky.com/xna/xbox_moon2.png

public void Draw(Camera cam)
{
    GraphicsDevice gd = Game3.GDM.GraphicsDevice;

    Vector3 position = Position + cam.Position;
    Matrix world = Matrix.CreateScale(2.0f);
    world *= Matrix.CreateConstrainedBillboard(
    position, cam.Position, Vector3.Down, cam.Forward, null);

    _moonEffect2.Parameters["World"].SetValue(world);
    _moonEffect2.Parameters["View"].SetValue(cam.View);
    _moonEffect2.Parameters["Projection"].SetValue(cam.Projection);

    // Draw blended part of moon only.
    _moonEffect2.Parameters["AlphaTestDirection"].SetValue(-1);
    gd.BlendState = BlendState.AlphaBlend;
    gd.RasterizerState = RasterizerState.CullNone;
    gd.DepthStencilState = DepthStencilState.DepthRead;
    ScreenQuadDraw.DrawQuad(_moonQuad, _moonEffect2);
}

Here is the shader used, nothing complicated here:
http://www.olhovsky.com/xna/Moon.fx

Does anyone know why the texture is not being displayed properly on the xbox? Is there another state I should be setting perhaps?


texts:
I'm going to try and use GEGL to allow real-time texture manipulation on an open-source 3D game engine.

What are the most common and most needed operations used on images, textures in game engines?

Thank you!


texts: How do I create a multiplayer server also suitable for local single-player?

texts:
I've created a voxel game in C++, OpenGL and SFML, and I want to make it multiplayer.

I'd like to make it similar to Minecraft's client-server model: The single-player is just a client to the hidden server underneath; but can be configured to connect to multiplayer as well so that the single player and multiplayer code are one and the same.

Spitball-ideas:

Use a separate thread for the server logic and then share the data between a synchronized point in the code for the client.
Just send packets to local host from the server thread and collect them from the client thread.

How should I do this?


texts: How do I recreate this 3D "flying through space" effect resembling a tunnel?

texts:
On the "Final Destination" stage. in "Super Smash Bros. Brawl" and "Super Smash Bros. Melee", the players fight on a platform that is seemingly moving through space.

I see particle effects, but I don't understand how they made the clouds, or the rest of it. I'm currently working on a breakout-clone in Unity3D, and would like to create a similar background for my game.

How can this effect be produced? How can a texture be made to fly towards the camera endlessly / seamlessly like that?


texts: I’m working with Phaser Editor, and I was wondering if it was possible to resize the scene with the editor or just plain Phaser 2. I want to resize the world, by which I mean to make a camera follow the player past the screen, but I can’t figure out how in the docs for phaser 2 or phaser editor. Can someone help?


texts: C++ Wrapper class for raw pointer to an SDL_Texture

texts:
First time in game dev, so go easy on me. I understand it's senseless to copy textures, but I'm trying to see this from a copy/move perspective since there is a lot of that going on in my code and in general, for proper memory management.

Deep copying an SDL_Texture is a no-no since its implementation is hidden. Besides I mostly initialize and destroy it using SDL_CreateTextureFromSurface and SDL_DestroyTexture. My next approach was wherever there would be an SDL_Texture*  class member I would try to wrap it in a std::shared_ptr<SDL_Texture>, but even that didn't work because of the incomplete type error.

My main question is this:
Would the proper way of handling a raw SDL_Texture* pointer getting passed around everywhere, be to create a wrapper_class, for example

class WTexture {
    public:
    // constructor, destructor and everything else needed

    private:
    SDL_Texture* tex;
    //...

}

so, that in every class that has an SDL_Texture* tex; member I would swap it with std::make_shared<WTexture> tex;? Meaning that I can safely pass around the texture and it will only be deleted at the end of the program when the reference count reaches zero?


texts: How can I make a character Blink effect in Unity?

texts:
I am making a game where I am making a health script where I have made a blueprint of what needs to be done. I'm trying a blinking effect after the character is hurt.

Can someone help me make a blink effect in Unity for JS?


texts:
Apologies if I am missing something very obvious (likely!) but is there anything wrong with interpolating between two matrices by:

    float d = (float)(targetTime.Ticks - keyframe_start.ticks) / (float)(keyframe_end.ticks - keyframe_start.ticks);
    return ((keyframe_start.Transform * (1 - d)) + (keyframe_end.Transform * d));

As in my app, when I try an use this to interpolate between two keyframes, the model begins to 'shrink' - the severity based on how far between the two keyframes the target time is; its worst when the transform split is ~50/50.


texts: How/whether to pool bullets for a shmup in Unity?

texts:
I'm working on my first Unity project, which (maybe naively) I decided to make a shmup.

I've been doing a lot of reading about Unity, and about object pools, and about using components to control behaviors of game objects.

Right now my idea for how a bullet works is that each bullet should be a game object, with a component that controls how it moves, and another component that controls what happens when it collides with something it can damage. Depending on the enemy or player shooting the bullet, however, the way it moves or how it deals with collisions may be entirely different, which means that a bullet from enemy A may need one component to control motion, but a bullet from enemy B may need a different type of component. (And the same for damage-dealing.)

If I want to pool bullets, since a shmup tends to need a lot of bullets all the time, I'm not sure how to handle "resetting" the bullets when I'm done with them and grab them out of the pool to use the next time.

So my question is, what is the ideal way to design a bullet system for a shmup in Unity, from the point of view of an expert in Unity instead of my beginner perspective? Am I going about using components wrong? Should I have a completely different pool for each possible type of bullet (which may not be feasible since I want a good amount of variety in the game)? Should I just have one monolithic motion control component that has a ton of code and can control every imaginable type of motion a bullet could ever need (I hope not)? Should I just forget about pooling and use Instantiate and Destroy? Is there a good way to reset what components are attached to a GameObject to the state of its prefab when I'm done with it?

I'm afraid my beginner-ness to this ecosystem makes it hard to even know what the right question is.


texts: Can I legally call ninja techniques "jutsus" in a game?

texts:
I'm making a game inspired by the anime Naruto and I want to use the word jutsu, used in the anime to mean ninja techniques. Can I do that?

Does the answer change if I change the techniques' specific names, but use the same concept of the hand seals?


texts:
Should I be pessimistic about the iOS game development under VM? A virtualized environment will run on AMD (4-core 2.8 ghz Phenom II)/ATI/Linux/VMware host.

Not talking about any 3D engines, may Xcode's emulator bring at least 15-20 FPS for a simple 2D game like, errr, Airport Mania?


texts:
I'm working on a flight simulator, but I'm stuck with my airplane orientation. I tried some things but noone worked correctly. This is what I have :

To be able to move it and roll it around himself, I need two vectors, forward and up, and use them to create quaternions I need for the rotation :

void Plane::Update()
{
    m_position += ( m_forward * m_speed );

    mat4 translation = translate( mat4( 1.0f ), m_position );

    float angle = dot( vec3( 1.0f, 0.0f, 0.0f ), m_forward );
    quat direction = angleAxis( acos( angle ), cross( vec3( 1.0f, 0.0f, 0.0f ), m_forward ) );

    m_matrix = translation * mat4_cast( direction );
}

vec3( 1.0f, 0.0f, 0.0f ) is my model orientation. Note that in this code, I don't have quaternion for rolling the plane, because I first want to have a correct direction.

This works great, what doesn't work is when I want to make him taking off. To do that, I first get the right vector, then use it to create my quaternion with the angle I need, and I apply the rotation to the forward and up vector.

void Plane::FlyUp()
{
    vec3 right = cross( m_forward, m_up );

    quat temp = angleAxis( radians( 1.0f ), right );

    m_up = temp * m_up;
    m_up = normalize( m_up );

    m_forward = temp * m_forward;
    m_forward = normalize( m_forward );
}

Using debugger and an online vector visualizer, It seems to give me the good vectors, but the plane is rotating weirdly ( in fact, that's not even only rotating, he's scaled too for some reasons... ).

What am I doing/understanding wrong?

Edit :

To be more precise, here is screenshoots of what I have :

And what I'm trying to have, whatever the m_forward vector is pointing to :


texts: What are the practical differences between discrete and continuous simulations?

texts:
I've done some research regarding how to simulate a game world, and it seems that I need to decide whether I want to write a continuous or a discrete simulation.

From my understanding, in a continuous simulation, I simulate each entity based on the time passed from the last calculation. For example, if I have a moving entity which has the speed of N units per second and one second has passed since the last calculation, the entity will move N units. In a discrete simulation, I calculate "turns", and my entity will have a speed measured in units per turn.

From what I understand, discrete simulation is not as granular as a continuous simulation, but is easier to calculate. I'm not sure that I have this right. I'm in the planning stage of a Dwarf Fortress-like roguelike game and I'm not sure which method will be fine for my purposes.

What are the practical differences between continuous and discrete simulations, in terms of game mechanics and playability? In relation, what are the benefits and disadvantages of each simulation, and do I have any holes in my understanding of the concepts?


texts: How does pixeljunk shooter simulate its liquids?

texts: I am really impressed by the liquids in pixeljunk shooter. I would love to know how they do it.


texts:
I'm trying to build my first game, a really simple RTS like Age of Empires but I have a question about pathfinding.

When do this kind of games usually do pathfinding?

I've read some games do a global pathfinding once at game start but I'm not sure if that will fit this kind of games.

Do they usually calculate pathfinding each time a game entity starts a new task and has to move?

How do they handle when a obstacle suddenly appears on the path? Do they re-calculate pathfinding on every step? Or do they check if the current path is clear on every step? Or they just walk the current path until they actually hit the unexpected obstacle?

Actually if you know a link to a source code of pathfinding on some RTS game I would really appreciate it.

Thanks in advance


texts: Is BDD (Behavior Driven Development) used in games?

texts:
I have been reading about BDD - Behavior Driven Development for a while, and I find it really easy and usefull to convert features into code. BDD users often call it TDD done right.

BDD is a tool for software design, from outside to inside, from the bussiness value (or gameplay value) to code.

Dan North introducing BDD

Do you know any resources about BDD and Games other than this?


texts:
I try use uniform blocks in OpenGL, but doesn't work. First, see my vertex shader:

#version 400
uniform Buffer0
{
    mat4 worldMatrix;
    mat4 viewMatrix;
    mat4 projectionMatrix;
};

in vec3 POSITION;
in vec4 COLOR;
out vec4 color;

void main(void)
{
    gl_Position = worldMatrix * vec4(POSITION, 1.0f);
    gl_Position = viewMatrix * gl_Position;
    gl_Position = projectionMatrix * gl_Position;

    color = vec4(1.f, 0.f, 0.f, 1.f);
}

My fragment shader output color only.

Creating and drawing vertex buffer correctly.

If use

gl_Position = vec4(POSITION, 1.0f);

drawing works, but using matrices draw doesn't work.

C++ code:

// Create GL_UNIFORM_BUFFER matrices

struct Matrix4f
{
float m11,m12,m13,m14;
float m21,m22,m23,m24;
float m31,m32,m33,m34;
float m41,m42,m43,m44;
};
struct MatrixBuffer
{
Matrix4f world, view, proj;
};
//The values bellow are correct
Matrix4f world =
{
    1, 0, 0, 0,
    0, 1, 0, 0,
    0, 0, 1, 0,
    0, 0, 0, 1
};
Matrix4f view =
{
    1, 0, 0 , 0,
    0, 1, 0 , 0,
    0, 0, 1 , 0,
    0, 0, 10, 1
};
Matrix4f projection =
{
    1.81066012f, 0         , 0           , 0,
    0         , 2.41421342f, 0           , 0,
    0         , 0         , 1.00010002f  , 1,
    0         , 0         , -0.100010000f, 0
};
MatrixBuffer data = { world, view, proj };

GLuint matrixbuffer;
glGenBuffers(1, &matrixbuffer);

if (glGetError())
// "No error here."

glBindBuffer(GL_UNIFORM_BUFFER, matrixbuffer);

if (glGetError())
// "No error here."

// GL_STATIC_DRAW for example, but I have tested many other flags
glBufferData(GL_UNIFORM_BUFFER , sizeof(MatrixBuffer), &data, GL_STATIC_DRAW);

if (glGetError())
// "No error here."

// Render function
// This code works
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
double winWidth = glutGet(GLUT_WINDOW_WIDTH);
double winHeight = glutGet(GLUT_WINDOW_HEIGHT);
double ar = winWidth / winHeight;
glOrtho(-1 * ar, 1 * ar, -1, 1, -1, 1);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glUseProgramStages(pipeline, GL_VERTEX_SHADER_BIT, vertProgId);
glUseProgramStages(pipeline, GL_FRAGMENT_SHADER_BIT, fragProgId);
glBindProgramPipeline(pipeline);

// this code work without erros, but not draw triangle
GLuint location = glGetUniformBlockIndex(vertProgId, "Buffer0");

if (location == GL_INVALID_INDEX)
// "No error here."

// My question here.
glUniformBlockBinding(vertProgId, location, matrixbuffer);
// "No error here, but doesn't work, show a black screen."
// "If set directly matrices in vertex shader, triangles show corretly

// this code works
drawVBO();
glutSwapBuffers();

I tried tranpose matrices, but doesn't work too.

Something is missing? Some error?


texts: need help in implementing KeyListener for 2D game in Java

texts:
i stated coding my first game in java, i need some help in imlementing KeyListener to fit my game.
after some search in tutorials i've imlemented it like this :

frame.addKeyListener(new KeyAdapter(){

private boolean[] keys = new boolean[120];
public boolean up , down , left , right;

public void tick() {
    up =  keys[KeyEvent.VK_UP] || keys[KeyEvent.VK_W];
    down =  keys[KeyEvent.VK_DOWN] || keys[KeyEvent.VK_S];
    left =  keys[KeyEvent.VK_LEFT] || keys[KeyEvent.VK_A];
    right =  keys[KeyEvent.VK_RIGHT] || keys[KeyEvent.VK_D];
}

public void keyPressed(KeyEvent e) {
    if(e.getKeyCode() != KeyEvent.VK_F5) keys[e.getKeyCode()] = true;
    tick();
    if (up){
        yMap+=4;
        direction='n';
        xInd=0;
    }
    else if(down){
        yMap-=4;
        direction='s';
        xInd=2;
    }
    else if(right){
        xMap-=4;
        direction='e';
        xInd=1;
    }
    else if(left){
        xMap+=4;
        direction='w';
        xInd=3;
    }
    wait++;
    if(wait==5){
        yInd++;
        wait=0;
    }
    if(yInd==3)
        yInd=0;
    cha=sprites[xInd][yInd];
    panel.repaint();
}

public void keyReleased(KeyEvent e) {
    keys[e.getKeyCode()] = false;
    tick();
    yInd=0;
    cha=sprites[xInd][yInd];
    panel.repaint();
}

public void keyTyped(KeyEvent e) {
}
});

however every thing is fine in this code, the character is moving correctly the sprites are perfect but it is missing only one thing, the only thing i need is when i move the character in a direction, lets say for exemple UP, with a simple click on the up button (which normaly should make it move with only 4 pixels to up),  the character should complete walking to the next square automaticaly (each square is 32*32 pixels).
i hope i explained well my question and sorry for bad english !


texts: Get enum value "string", and get int value of that

texts:
Sorry if the title is confusing, but I literally don't even know how to summarise this into a title. So here's the problem:

I have a list of combat moves for a character. I have an animation for each of those possible moves. When the "combat manager" (instantiated to manage each individual fight) works out what move the enemy and your person will make, it should tell the Animator to play the animation specific to the selected move. I'm really not sure how to go about this so:

The player's Animator has a state for each possible move, containing that move's animation. The script controlling the Animator has a public enum "CombatMove" containing every possible move (ie. CombatMove.WhicheverMove). So the Combat Manager will get the name of the move (eg. "Right Middle Jab"), remove the spaces and search for an enum value whose name is that string (eg. CombatMove.RightMiddleJab). Now it has the corresponding enum value, it retrieves the int value of that (eg. 0). It then sends that int value to the Animator, where each move's transition will occur if the int value equals the move's int value on the enum. So summed up:

move's string name, turned into an enum value name, turned into its int value, used to specify which move animation should be played.

The questions:

1) How do you find an enum value whose name equals a given string?

2) How do you get the int value of that enum value?

If this is confusing, please comment what makes no sense and I will try to explain, I'm honestly so lost that I don't even know how to ask what I need to ask.

EDIT:

IF anyone is wondering what I mean by 'int value', Fafase's answer at http://answers.unity3d.com/questions/764091/using-c-enums-to-control-an-animator.html says that each enum value has an int value by default, which can be used in animation conditions; however I have no idea how to access them, which part 2 of my problem.


texts: StopCoroutine is not stopping my coroutine in Unity

texts:
I'm getting some attacking to work with my units and I noticed that the coroutines seem to start adding up even after the StopCoroutine(IEnumerator) as need called.

I dug around on ways to perform an attack loop, most of the time I found "Use InvokeRepeating" and "Don't use InvokeRepeating". Since invoke uses reflection it's performance heavy anyways, so I'd rather not go down that road.

How do I get my coroutine to stop? Is it because it's in a while loop inside the coroutine? If so, how do I fashion an attack loop without using invoke?

//Recieves call when a new enemy is added to the list
public void NewEnemyDetected()
{
    if(currentlyAttacking == null)
    {
        SelectEnemyToAttack();
    }
}

//Recieves call when an enemy leaves the collider area
public void EnemyGone()
{
    SelectEnemyToAttack();
}

//Will select an enemy from the array to attack
private void SelectEnemyToAttack()
{
    if(enemyObjects.Count > 0)
    {
        StopCoroutine(AttackEnemy());
        currentlyAttacking = enemyObjects.ElementAt(0);
        isAttacking = true;
        StartCoroutine(AttackEnemy());
    }
    else
    {
        currentlyAttacking = null;
        isAttacking = false;
    }
}

//Partially hacked together attacking loop
private IEnumerator AttackEnemy()
{
    while(isAttacking)
    {
        Vector3 angle = currentlyAttacking.DetectedGameObject.transform.position - transformV.position;
        angle = angle.normalized;
        GameObject projectile = (GameObject)Instantiate(AttackType, transformV.position, transformV.rotation);
        BlasterAttack projectileAttack = projectile.GetComponent<BlasterAttack>();
        projectileAttack.OnCreation(10, player);
        projectile.GetComponent<Rigidbody>().AddForce(angle * 100);
        yield return new WaitForSeconds(1);
    }
    yield return false;
}

Thanks!


texts: Phaser Pulling Data from Firebase and Loading it as a sprite

texts:
I am trying to pull img data from database to replace it with player sprite url.

    ionViewDidLoad() {
        this.profileData = this.fire.authState.switchMap(auth => this.db.object(`profile/${auth.uid}`).valueChanges());
        this.profileData.subscribe(profile =>{
        this.avatar = profile.avatar;
        console.log(this.avatar);//i got data(its an url string)

        });

        console.log('ionViewDidLoad ZombiePage');
        this.game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, 'game', { preload: this.preload.bind(this), create: this.create.bind(this),update:this.update.bind(this),render:this.render.bind(this) });
    console.log(window.innerHeight);

      }

    preload(){
    console.log(this.avatar); //Undefined
this.game.load.image('player', this.avatar);

Why i cant reach data from preload function ? btw im using ionic/angular framework.i combined it with phaser.


texts:
I have this

batch.draw(currentFrame, x, y, this.parent.originX, this.parent.originY, this.parent.width, this.parent.height, this.scaleX, this.scaleY,this.rotation);

I want to apply the alpha that it gets from the method, but theres is not overload from the SpriteBatch class that takes the alpha value, is there some wey to apply it? (i did it this way, because this are animation, and i wanted to control them) in my static ones i apply

sprite.draw(SpriteBatch, alpha)

Thanks


texts: Endless runner character stops moving unexpectedly

texts:
I've been trying to make an endless runner game in Unity in which a player moves forward automatically and can move from x to y axis while still moving forward. I do not know how to program so I used a Template.
Since then, my player stops moving forward when there is no box collider in front of it. it stops when there is a box collider by the sides and even when it's at the front. It's really frustrating.
Below is the script I used:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewPlayerScript : MonoBehaviour
{
    private CharacterController controller;
    private Vector3 direction;
    public float forwardSpeed;
    public float maxSpeed;

    private int desiredLane = 1;
    public float laneDistance = 4;
    public float jumpForce;
    public float Gravity = -20;
    void Start()
    {
        controller = GetComponent<CharacterController>();
    }

    // Update is called once per frame
    void Update()
    {
        direction.z = forwardSpeed;

        if (controller.isGrounded)
        {
            if(forwardSpeed < maxSpeed)
            forwardSpeed += 0.1f * Time.deltaTime;
            direction.y = -1;
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                Jump();
            }
        }
        else
        {
            direction.y += Gravity * Time.deltaTime;
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            desiredLane++;
            if (desiredLane == 3)
                desiredLane = 2;
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            desiredLane--;
            if (desiredLane == -1)
                desiredLane = 0;
        }
        Vector3 targetPosition = transform.position.z * transform.forward + transform.position.y * transform.up;
        if (desiredLane == 0)
        {
            targetPosition += Vector3.left * laneDistance;
        }else if(desiredLane == 2)
        {
            targetPosition += Vector3.right * laneDistance;
        }
        transform.position = Vector3.Lerp(transform.position, targetPosition, 80 * Time.deltaTime);
    }
    private void FixedUpdate()
    {
        controller.Move(direction * Time.fixedDeltaTime);
    }
    private void Jump()
    {
        direction.y = jumpForce;
    }
}

I really dont know what the problem is. I have the character controller and the sphere collider enabled in my inspector for my character and I have only the box collider enabled for my prefabs.


texts: At what stage of game development is it a good time to ask for feedback?

texts:
I'm making a 2D top-down fantasy "Nuclear Throne"-like game. I'm at the point where a player can walk around, pick up weapons and kill some enemies. I'm not an artist, so it looks pretty rough and its clearly unfinished as you can't even progress to newer levels. I want to know if its too soon to ask my friends/family/coworkers and the sort to give the game a test run to see how they like the base combat mechanics. Or even post some screenshots and start getting social media coverage up and running. If now isn't the time, when will I know it is?

I do plan on marketing the game commercially, I am the sole developer at the moment, and its my first commercial game.


texts:
I was wondering if it was possible to use the existing native components inside Unity to extend them, and create my own.

For instance, if I wanted to create a component called Hurtbox, could I maybe do something like this?

class Hurtbox : BoxCollider2D { ... }

That would allow me to use the existing logic of the component and enhance it for my purposes.

Currently I have a separated BoxCollider2D and a Hurtbox components. The latter uses the former, but I thought if I managed to combine them both in a single one, it would be more elegant.

Is it doable? How?


texts: UnrealEngine how to create pirate boat tutorial

texts:
I fount an Unity tutorial how to crate pirate boat, but I still can't find any sources (links, videos) how to create it using UE.

Kind of this. So when you use character controller it can jump, run and etc, but with a boat you should smoothly running trough the waves with some bouncing effects. So I try to find tutorial that describe how to create this pirate boat. So the question not about model, so I can even use a cube that I can move through waves.


texts: How To Fix Strange White Edges With DOF and Fog in Unity?

texts:
I'm using global fog and the standard assets Depth Of Field script but it has a strange effect on the edges of far away objects.

How can I make the white edges along the trees blend smoothly into the fog?


texts:
In Unity, low-resolution images are "smoothened out". Is there a way to keep them pixelated?

For your information, the images that I'll be using are in PNG format.


texts: Recently, I have wanted to make a game using raycasting techniques, and I saw this video where a guy used an algorithm called "Line-line intersection" . I have normally used the DDA algorithm for raycasting, and that is what I see most raycasters use, is there a reason why that is? Is DDA faster for raycasting? Is there any case to use one over the other?


texts: I can't drag'n'drop UI-Elements from the Scene-hierarchy into a public field (Unity 5)

texts: I just watched this Video https://unity3d.com/learn/tutorials/projects/survival-shooter/player-health and tried to drag'n'drop the UI-Elements on the matching script, just like they did. But this is not working for me. If I hover the public field Unity shows up an error icon and I can't drop it there. If I set this UI-Element as prefab I can place it there, but it does not update the Element which is in the Scene when the Code is live. The Elements just gets an update after each restart. Can anybody explain to me why I cannot drag'n'drop my Object from the hierarchy to the public field?


texts: How can I fix this transparency problem when my data is viewed from a certain angle?

texts:
using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX;

I render a 3D data by setting device.RenderState.AlphaBlendEnable = true

Now my top view looks like below, the outer surface layer covered the underneath layers and resulting only outer layer is displayed at top view.

I would like to view the underneath layer from top view. How do I do this? Is there any setting can be done using Microsoft.DirectX ?

Update: Question is solved by myself

device.RenderState.ZBufferWriteEnable = false;


texts: Casting Civilization V based Hex Grid on Unity Terrain and Select Certain Areas of Grid

texts:
I am looking for approach for casting hex based grid on terrain which is for now pre-made but eventually it will be procedural for my exploration game where you can scan planet and elements will be highlighted/hex grid selected. What could be the approach towards making this kind of hex grid as my terrain will be un-even.

I have seen approaches like mesh creation, using tile-map, unity projectors but eventually I feel like this should be something using shaders but what about selection?

Can someone please guide me in a right direction.


texts: How to deal with a many to many relationship between objects

texts:
In my game, I keep a list of all clients currently connected to the server and a list of all actors in the game. Each actor is "relevant" ( currently replicating ) to 0 or many clients, and each client has has 0 or many actors that are relevant to it.

In some situations, I want to do something like this:

NetworkSystem.AddMulticastRPC( rpcCall, actor.AllRelevantClients );

This would send an RPC to all clients who have this actor as relevant.

Sometimes I need to do things like this:

foreach( var actor in client.RelevantActors )
{
    ...
}

Looping through all relevant actors.

Storing a collection on both the client and actor objects would be a duplication of data. Storing a collection on only one of these leads to some complex searches.

Is there an approach to dealing with data like this that avoids both of those problems?


texts: How can I avoid the precision loss when recentering objects on open terrain?

texts:
For a better context this question is related to this one:

What's the largest "relative" level I can make using float?

When the player is moving too far away from the center, all the scene and objects are moved in the opposite direction, in order to bring the center closer to the player and avoid float precision issues.

Recentering all objects makes me doubt a little, since it might still accumulate error since it's an addition. I also don't think I can tell a physics engine to just teleport all its object without causing weird behavior.


texts: Unity: Interactive menu with sprites changing with buttons

texts:
I have a menu where the player gets to choose which team and kit he will use to play. However I don't really know how to change the sprite each time the left or right arrows are pressed. I already have the sprites for each team, league and kit the only thing I am missing is the way to arrange it via script.
Thanks.


texts: How can I approximate an "opening fan"-transformation?

texts:
Is there a way to—with matrices—transform something as if opening the image on a Japanese folding fan?

Image from Wikimedia Commons.

I'm at a loss of what to call it, so pointers towards avenues of research would be greatly appreciated.  If it isn't possible with matrices, alternate methods would also be good.

If that is not possible either, a way to approximate the perspective tool in most graphics manipulation programs would be nice also.


texts: How does the deployment of server look like

texts:
I´m kinda new to these networking stuff, but basically managed to finish server to handle client requests(wan´t it to handle connections to game and help the clients update the game and stuff). I got it working on my localhost (sending files/packets on same PC is working already - i just launch server app and then client app). However, I still wonder how it works in real, if I want to access my server from global network. I understand that I need a hosting. So to sumarize my thoughts:

Find hosting - As the server,client or engine code is in C++, do I have to look for hostings specifically for C++ applications?
Now the server works this way: I set up IP+port, that clients use for their connection. Launch the server so now its accessible. How do I launch the server application when on hosting? Is there some kind of interface, for example if I want to relaunch the application(called for example server.exe).
As I said - clients need to know servers IP and port. So the hosting will give me IP+port that will be accessible for my clients (and I use this IP also on my server)?

I know these questions are kinda basic, but networking is new world for me and deployment of the networked stuff is also a part of it, so would like to understand the proccess.


texts: Isometric to screen, screen to isometric for irregular projection

texts:
I have isometric assets that unfortunately can't change and need to work out the projection for those. Here is how a tile looks like:

The tile image width/height ratio is 0.(6) (height/widht = 1.5).
Since this is isn't the standard(2:1) isometric ratio, how can I work out the iso-screen/screen-iso coordinate conversion functions ?


texts: Moving skeletal animation blending logic to GPU: worth it?

texts:
We have a solid skeletal animation system in our engine. It allows to set up to three animations onto each bone and blend them seamlessly. The animation update (fetching animation matrix given current time) and blending (two slerps for the three matrices) is done on the CPU while the actuall skinning (vertex transforms) is done on the GPU. Each vertex in our engine can be affected by up to four bones.

I am now considering moving the aforementioned update and blend functionality onto the GPU. Our CPU is loaded much more than the GPU even though these two operations are already done in parallel. This is how it can be done:

At compile time, all the animation data for each skeletal model for each timestep is baked into textures.
The update and blend functionality is done on the GPU in a single Draw() call by instancing quads. One quad is required for each bone on the scene. Each quad will render 16 pixels - the resulting  matrix. To compute this matrix, I will need to sample the animation texture from (1) 4*12 = 48 times (to get three animation matrices for the current frame) and perform 2 slerps. I think I will be doing it in the vertex shader.
At the skinning phase, I will sample the texture, rendered at stage (2) 4*16=64 times to get four matrices for the four bones, that can affect current vertex. It will be a GPU performance hit, but that is the main purpose of this process: to free up CPU cycles.

So my question is, has anyone ever tried this? Is it even worth thinking about? This system will take quite some time to implement and if there is some serious flaw in it, I would like to know about it. From my perspective it sounds good. At the same time I have never heard of anyone using such a system, which alerts me. Everywhere I read, the animation data is passed into the vertex shader as a huge array of matrices, which implies standard CPU update/blend system.

I wonder how games like StarCraft 2 do the update and blending. They have situations when there are tones of skeletal creatures on the screen (200 zerglings is standard, each has 2000 polygons, idk how many bones though...)?

UPDATE: I am working with XNA 4.0 that is DirectX 9, that is 224 uniforms in the shader.


texts: C++/SDL Snake Game: Drawing Tail Crashes Game

texts:
I"ve been making a snake game in C++ using SDL (first game and first time using SDL), and I've run into a bug. As the tail of the snake gets longer, the game slows down (snake gets slower), and eventually the game crashes (once the length of the tail reaches 29 pieces/parts). I went and deleted little bits of code until I found what was causing the problem, and I found that the problem is the snake's draw() method. It is responsible for drawing the head, and also for looping through each part of the tail and drawing it. Since the tail keeps getting longer, so does the loop, as it has more to draw. When I take out the loop that draws the tail, the game works fine. Is there anything I can do that is more efficient and that will stop the game from slowing down and crashing? Maybe the structure of the program is just bad. Here is some code with all the unnecessary stuff cut out:

snake.h

#pragma once

...

class Snake
{
...

private:
    void drawPart(SDL_Renderer *renderer); // snake is made up of individual parts
    ...

public:
    void draw(SDL_Renderer *renderer); // draws whole snake
    ...

private:
    SDL_Texture *texture = nullptr;
    int x = 0, y = 0; // initialized to something else later, irreverent
    std::vector<Snake> tail; // tail is made up of objects of this class
};

snake.cpp

...
void Snake::drawPart(SDL_Renderer *renderer) {
    auto surface = IMG_Load("part.png");
    texture = SDL_CreateTextureFromSurface(renderer, surface);
    SDL_FreeSurface(surface);
    SDL_Rect rect = { x, y, WIDTH, HEIGHT };
    SDL_RenderCopy(renderer, texture, nullptr, &rect);
}

void Snake::draw(SDL_Renderer *renderer) {
    drawPart(renderer);
    // the code below is what slows down the game until it crashes
    for (auto i = 0; i < tail.size(); ++i) {
        tail[i].drawPart(renderer);
    }
}
...

If any more code is necessary, please let me know. Thanks!


texts: Name of this technique used in games such as Minecraft or the sims

texts:
In Minecraft, there are some blocks which are a little bit different than just cubes.

For example stairs or fences: these elements are "aware" of their surrounding blocks and render differently based on if they are an edge, in the center, etc.

Other building games such as the Sims use a similar technique in the house building mode: the "voxels" are the same 1x1 metres but the mesh itself is usually thinner (like walls, side walls, etc.).

My question is:

What is the name of this technique?

Reference image

For the user perspective, there is only one "stairs" block. But when put next to each other, they behave differently.


texts: How do I move an existing display object behind another in Corona Lua?

texts:
If I have two existing display objects in Corona, lets say do1 and do2. Assume do1 is drawn first then do2, so do2 will be on top.

Is there a way to say "put do2 behind do1" in corona Lua? If yes can you give me an example?


texts: Enum or Inheritance for event-based interaction?

texts:
I am currently considering two possibilities to a centralised interaction system within my game.

Consider that you want to produce different results for different types of objects within the game world - you interact with a signpost and dialogue appears, or interact with an item on the ground and it gets added to your inventory with a notification.

Essentially, I cannot decide whether it would be more efficient to implement such functionality all within one centralised place or to spread each function out over separate events.

Option 1: Centralised

This is what I have started coding. One Interact class which contains several "Types" of possible events in my game.

When the player "interacts" with an object implementing this script, it will implement the functionality that it is set to in the Editor. This means I drag and drop this Event Script onto a prefab and can automatically tweak its functionality within a couple of seconds and have it ready to go in the game world.

I have simplified the general consensus of my code into this block for readability:

public string eventName;

public enum EventType
{
    Movement = 0,
    Dialogue = 1,
    NPC = 2,
    ItemCollect = 3,
    Teleport = 4,
    Cutscene = 5,
    Switch = 6,
    Custom = 7
}

public EventType eventType;

/*
* #############################
* ##@@## INITIALIZATION ##@@##
* #############################
*
*/

private void Awake()
{
    SetupEvent(eventType);
}

public void Activate(bool calledFromTrigger = false)
{
    if (autoTrigger && !calledFromTrigger)
        return;

    Debug.Log("Activated " + name + "!");
    StartEvent(eventType);

}

private void StartEvent(EventType type)
{
    switch (type)
    {
        case EventType.Movement:
            MovePlatform();
            break;
        case EventType.Dialogue:
            break;
        case EventType.NPC:
            break;
        case EventType.ItemCollect:
            break;
        case EventType.Cutscene:
            break;
        case EventType.Switch:
            break;
        case EventType.Custom:
            break;
    }
}

Resulting in:

Option 2: Inheritance

It is as if I have a little devil and angel on my shoulder, one tugging me towards the easy and half-finished code of the former example, and another urging me to redesign what I am doing into a much cleaner and abstracted approach.

In the previous example, all "event types" (Movement, Dialogue, Item Collection etc.) were handled by enums that were passed through a Switch statement to check which method should be executed based on the parameters inputted into the Unity Editor for that specific Game Object.

In this system, there would be a base "Interactible" class, which various classes would inherit from to implement functionality. The Activate() method would be overridden in the children for each specific class.

public class NPC : Interactible
{
    public override void Activate()
    {
        //NPC Code...
    }
}

The unfortunate downside to this is that I can't just use one prefab for all my events and change them based on the custom editor that I define.

I would have to create a custom editor for each possible child of the Interactible class, and instead of selecting which type of event I want it to be from a simple drop down, I will have to swap out different scripts for different functionality.


texts:
I have a button, when I press the connect button, it gets connected to the server. When I press the connect button again, it's getting delay in connecting to the server. Below is the code to connect to the server:

public void setupSocket() {
    try {
        socket = new Client(Host, Port);
        theStream = socket.GetStream();
        theWriter = new StreamWriter(theStream);
        theReader = new StreamReader(theStream);
        socketConnect = true;
    }
    catch (Exception e) {
        Debug.Log("Socket error:" + e);
    }
}

And I have one more issue. When I take the desktop build of the app and opened the app, clicked button, it's getting connected to the server, but when I click the button again it's not getting connected. But when I close the app, it displays the connection message and also close message on the server. Is there anything to be set when taking the desktop build?

Can anybody help out what will be the problem?


texts:
I am currently working on loading tmx levels into my game, all is going well and i have layers being loaded textures being loaded and all the data being loaded such as level name, tile sizes etc.

The issue

Loading 1 texture for tiles is perfectly ok, but loading more than 1 the texture seems to get removed from memory (only white squares are displayed) I'm not going to include all my code as there's lot's of it but i will include a couple of snippets.

//code inside load function.
Texture texture;
texture.loadFromFile(src);
Texture *t = addTexture(texture);
loadTileSheet(twidth, theight, t);

Texture* Level::addTexture(Texture texture){
    Level::textures.push_back(texture);
    return & textures[textures.size() - 1];
}

I am then outputting all the information to the console of the tileset this is as follows:
mem adress 1 is the texture creation and mem adress 2 is the adress in the vector.

Tileset Information: nametileset2 | src G:/C++/Workspace/test/res/tileset2.png | tWidth: 32 | tHeight32 | MemAdress 1: 0x85d028 | MemAdress 2: 0xa81848

currently this works,  loading in a second texture outputs this and breaks all the first set of textures.

Tileset Information: nametileset2 | src G:/C++/Workspace/test/res/tileset2.png | tWidth: 32 | tHeight32 | MemAdress 1: 0x85d028 | MemAdress 2: 0x82522b0

I'm pretty sure this is something simple that i have over looked, and I'm pretty sure the first texture is somehow being removed from memory when the second one is created somehow.

Thanks in advance:

Jordan


texts:
i'm learning something about game programming from a book about "pyGame". pyGame is simple, but... python is a little complex and different from my previous knoweledge about programming.

I know "classical" language: C# (also C/C++), Java ... I know a lot of people love Python but for me is a little harder to learn!

So I'm looking something like "pyGame" but for java or for c# ... A library with which I can do almost the same thing i can do with pygame (so .. do more with less code ... and headache).


texts: im trying to make an editor for my game. but I want to know is it possible to edit terrain map heights or textures? if the answer is true, should i make it from scratch or can I use unity editor tools in real time? is there any asset for it? thank you for helping


texts: Mouse input position is being printed as Unity coordinates, but the actual coordinates used seem incorrect

texts:
This will be hard to explain, but I'll try to keep it short and simple:

I'm trying to set the position of a UI rectangle to the position of the mouse when clicked. When initialized, the position of the rectangle works fine (if, during Awake(), I initially set it so that x = 100 and y = 100 and then check the Rect Transform component during run time, Pos X and Pos Y are both set to 100 as intended). However, if I use the X and Y coordinates of Input.mousePosition, Pos X and Pos Y are given strange numbers that I have no clue where they're coming from.

I don't think they're pixel coordinates because the value for Pos X of the rectangle when my mouse clicks at the farthest left possible during run time is a value over 300 when it should be 0, and that value goes up as I progressively click rightwards.

Now here's the strange bit. When I try to use print() to print the mouse position x and y values that I use to set the rectangle's position, they're printed as intended (clicking the bottom left of the game area yields x = 0 and y = 0) yet the rectangle's position is far from close the values printed (rectangle's position is x = 337.5 and y = 192.5).

Can someone please explain why this happens, and how I can fix it? I suppose I can manually fix it by subtracting the new position values by 337.5 for x and 162.5, but it feels too brute-force-ish and there's bound to be consequences down the line.

Here is a screenshot to help clarify my issue: http://i.imgur.com/ivSmhKe.png


texts: How to enable sound on Base Game Activity in Andengine?

texts:
I am developing a game using Andengine , I am using a Base Game Activity with multiple scenes. I want to load a background music in it.But I dont know how to enable sound in engine while using Base Game Activity.I found this code in net to enable sound .

return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE,
   new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera).setNeedsMusic(true));

But this one is written in onLoadScene() and I dont know how to impliment onLoadScene() in basegame actvity.Do I can override onLoadScene() in base game activity or is there any other ways to achive this please help me...

Any Suggestions are Valid to me and Advanced thanks to alll....


texts: Strange quaternion camera streching in WebGL

texts:
So after a lot of researching about quaternions I almost got the quaternion camera working. Almost, cause it rotates in a proper way only in a vertical axis. Other rotations stretches and deforms the view (like on a picture below).

Wobbling horizontal moves makes only Z axis stretched

I don't like to post topics like "Please, debug my brain", but I'm in a dead end right now, and I don't know how to fix it.

My implementation looks like this:

I Convert an axis-angle rotation to a quaternion and normalize it.
Then multiply it with a camera identity quaternion.
And then multiply a position of a camera (which is a 4x4 model-view matrix) by a product of above multiplication converted to matrix.

My free quaternion camera class looks like this (for now):

function QuaternionCamera() {
    // Fake 4x4 Matrix
    this.position = new Matrix4x3();
    this.rotation = new Quaternion();
}

QuaternionCamera.prototype = {
    verticalRotation: function(angle) {
        this.rotation.multiply(new Quaternion().axisToQuaternion(angle, 0, 1, 0));
        this.position.multiply(this.rotation.quaternionToMatrix());
        this.rotation.makeIdentity();
    },

    horizontalRotation: function(angle) {
        this.rotation.multiply(new Quaternion().axisToQuaternion(angle, 1, 0, 0));
        this.position.multiply(this.rotation.quaternionToMatrix());
        this.rotation.makeIdentity();
    }
};

And on mouse movement, it runs this:

    camera.verticalRotation(degToRad(deltaX / 6));
    camera.horizontalRotation(degToRad(deltaY / 6));

I believe that this is a proper way to do it, so I'll just dump my math library, maybe you could find a typo in there (cause I have checked it a hunderd of times and found nothing): http://pastebin.com/0zYLaR1V

PS How to get rid off an additional little roll when rotating camera around, so it will move in a game fashion way?

PS2 And where did the imaginery numbers gone when implementing quaternion math to programming language?? ^^ This is a true mystery for me.


texts:
In the game, I've seen asset types for animations that are of SpriteStudio.
I have searched the documentation and cannot find any information on what this is.
I looked at the template project that purportedly covers SpriteStudio, but I don't see anything that really explains how to use it. There are various entities of type "SpriteStudio" that reference assets called SpriteStudio Animations. These assets show their source to be files with a ".ssae" extension. I assume these entities, assets, and resources are purposed to create the 2D animations within the demo.
I don't see how to generate ".ssae" files, nor is there any editor that I could find for the SpriteStudio Animation assets.
Is SpriteStudio separate software? Is it a sub-editor of the Game Studio? How do I create ".ssae" files?


texts: Animate Gradient Material Offset in Babylon.js

texts:
I'd like to create an animated gradient material in babylon.js. I set up my gardient mateiral like this:
   var gradientMaterial = new BABYLON.GradientMaterial("grad", scene);
   gradientMaterial.topColor = new BABYLON.Color3(0, 0, 1);
   gradientMaterial.bottomColor = new BABYLON.Color3(0, 0, 0);
   gradientMaterial.offset = 0.8;
   gradientMaterial.offset = test;
   gradientMaterial.smoothness = 1;
   sphere.material = gradientMaterial;

I render my scene in the render loop:
    engine.runRenderLoop(function () {
    scene.render();
    }); code here

I'd like to animate the gradientMaterial offset so that every 5 seconds it repeats. I'm just not sure where to iterate the .offset value.


texts: Mitigating the noticability of a frame drop in XNA

texts:
I have been having some minor frame drop issues in a 2D XNA game.

To start with, I am a vsync'ed, mixed timestep. That is:

IsFixedTimestep = false;
graphicsDeviceManager.SynchronizeWithVerticalRetrace = true;

This is combined with a fixed physics timestep of 120hz, implemented with the pattern used in Fix Your Timestep! to avoid jittery physics movement. So, Update runs with a variable timestep, and another Tick runs with a fixed timestep (the idea is from Unity's Update/FixedUpdate).

When a sprite moves across the screen at a steady pace, every couple of seconds a jitter/hiccup is noticable. Some googling around led me to this forum post several years ago talking about the same issue.

To test this, I added this code to an Update method:

if(gameTime.ElapsedGameTime.TotalMilliseconds > 22)
{
    Logger.Log(gameTime.ElapsedGameTime.TotalMilliseconds.ToString());
}

Sure enough, every couple of seconds the log showed a time above 30 milliseconds, usually around 32. Seeing as one frame at 60 fps is 16.6 milliseconds, it seems that a frame is simply being lost. I added some additional code to flash the screen red whenever this happens. Again, sure enough, I notice the bullet hiccuping when the screen flashes red. If it is simply dropping a frame, that means that the bullet will hold still, then when the frame finally runs, the physics will run 4 times (since it runs twice as fast as the monitor, over two frames) and move the bullet a lot.

Now, I'm not sure if I can fix this. If this is indeed a quirk of XNA (and gamedev in general?) the frame drop may be unavoidable. So, I would either know how to either get rid of the frame drop, or mitigate how visible it is. A few more points:

1. It's probably not the GC.

In that forum post, they seemed to hone the problem down to a point where the GC would never/hardly run, and still saw the problem. To check myself, I added some code that checked GC.GetTotalMemory(false) every frame, and if it dropped from the last frame, log "GC". I think a drop in that would show a GC collect, but I could be wrong. "GC" was logged independent of the other log when a frame was dropped.

2. I can't use a variable timestep

I need the physics to be reproducible across a network. This means I need it to be as deterministic as possible (it actually doesn't matter 100%, but it will cause noticable artifacts the less deterministic it is). So, I can't just multiple the velocity of objects by gameTime.ElapsedGameTime.

3. I don't want to use IsFixedTimeStep

I like to keep the framerate under my control a bit. It gives more control over drawing, and allows several somewhat independent framerates. The forum post also stated that setting IsFixedTimeStep to false helped the problem. Granted though, I basically reimplented IsFixedTimeStep myself!

Additionally, setting IsFixedTimeStep = true; doesn't help the stuttering.

4. Some ideas?

So if I can't fix the problem, perhaps I can mitigate it somehow. Some ideas I've had are:

Motion blurring
Give trails to bullets
Increase the amount of "noise" on the screen so that a frame drop is a small issue
Separate update and draw in to separate threads?
Deal with tearing and unsync from the vertical retrace? This almost completely solves the problem, but GPU usage goes to 100% as it's updating and drawing as fast as it can.

Maybe something has also happened with XNA since the forum post in 2008, that I can use. Otherwise, I'm not sure what to do about the issue. Is it a really small issue? Yeah! I'd love to have a silky-smooth game, though. I'd love any ideas!


texts:
I am a beginner in cocos2d and I wanted to display coin CCSprites as soon as it moves off the screen with a 5 second delay. So this is what I wrote in my main gameplay layer to add 7 coins in a row:

- (void)coinSidewaysRowOne {
        if (coinSide1 == FALSE)
        {
            coinSide1 = TRUE;
            NSLog(@"coinSide1 = TRUE");
            int originalX = 500;
            for(int i = 0; i < 8; i++)
            {
                CCSprite *coinHorizontal = [CCSprite spriteWithFile:@"bubble.png"];
                coinHorizontal.position = ccp(originalX, 150);
                originalX += 20;

                [self addChild:coinHorizontal];
                [coinArray addObject:coinHorizontal];
            }
        }
    }

And then, in my updateRunning method I added this, so when the coins spawn outside the screen, they move to the left and disappear:

// Move coins off the screen and make them move away
    for (CCSprite *coin in coinArray) {
        // apply background scroll speed
        float backgroundScrollSpeedX = [[GameMechanics sharedGameMechanics] backGroundScrollSpeedX];
        float xSpeed = 1.09 * backgroundScrollSpeedX;

        // move the coin until it leaves the left edge of the screen
        if (coin.position.x > (coin.contentSize.width * (-1)))
        {
            coin.position = ccp(coin.position.x - (xSpeed*delta), coin.position.y);
        }
    }

Update:
What I've tried doing is adding this below the if statement above:

else {
        coin.visible = TRUE;
        coin.position = ccp(500, 150);
     }

So right now, when I run this, the coins move in from the right and move off the screen from the left.
How do I make it so that when the coins move to the left and go off the screen, have a five second delay and then have new coins come back to the screen from the right like it originally did.


texts: Should I include 3rd party libraries in my Plugin?

texts:
I'm using Firebase services in a custom plugin that will be released later,
Should I include all 3rd party libraries like Firebase on the final plugin package or is there another way to handle this in unity ?


texts: What is the term for making an object transparent when it blocks the player's view?

texts:
In many games if your camera gets too close to certain objects, or the object starts to block your screen, the game turns it transparent so you can still see.
What is the name for this effect? It is not  occlusion culling. The model does not reduce its polygons, it simply just gets transparent so that you can look through it.


texts:
I have a 2D rectangular grid (100x100) with 3 types of cell (Empty, Base and Outline). I need to find cells inside the territory formed by Base and Outline cells.

For example, in this scheme:

I need to find the yellow cells.

The same algorithm, but with hexagonal grid, was implemented in the game in this YouTube video: https://youtu.be/6zyMHnBM5x8.

Any help on how to achieve that would be very helpful. Thanks.


texts: Draw wireframe models for Gear VR app in Unity

texts:
I want to create a 3D Android app for Gear VR that does/lets me do the following:

Read an input file with a bunch of coordinates of points (including information about how they should be connected)
Draw a wireframe model with these points
Walk around and through the model in first person to look at it from different angles using a gamepad/controller. I don't want to directly interact with it!
(Maybe have more than one model displayed at the same time, including filled ones)

Is it possible to draw 3D wireframe models in Unity using coordinates instead of using already finished models that were created in Blender/Maya/etc, and if so, how?


texts:
How do I perform a circular/rotational/spin blur on an image - using DirectX9.0 and HLSL?

For example:


texts: How do I achieve supersampling / anti-aliasing in pixel shaders?

texts:
I am trying to write a couple pixel shaders to apply to images similar to Photoshop effects. For example this effect:

But I noticed there is aliasing in my resulting image (the above image is a sample from the linked website).

What can I do to prevent this? I couldn't find any article that explains how to solve this. I read some techniques like rendering in a higher resolution and then downsizing the image, but I need to solve this in a pixel shader capacity.


texts: How to set rotation of a projectile in a parabolic arc in Box2D?

texts:
I have trouble making my projectile - in this case an arrow - rotate as it should when it's travelling in a parabolic arc. It doesn't rotate at all while travelling, only until it collides with something.

Below is the relevant code I'm using.

public class Arrow extends BodyDef{

private Body body;

public Arrow(float x, float y, float halfWidth, float halfHeight, float rotation, float velocity) {
    type = BodyDef.BodyType.DynamicBody;
    position.set(x, y);
    angle = rotation;

    body = Box2DTest.world.createBody(this);
    PolygonShape shapeShaft = new PolygonShape();
    shapeShaft.setAsBox(halfWidth, halfHeight);

    /* Creation of the shaft of the arrow */
    FixtureDef fixtureShaft = new FixtureDef();
    fixtureShaft.shape = shapeShaft;
    fixtureShaft.density = 6.5f;
    fixtureShaft.restitution = 0.4f;
    body.createFixture(fixtureShaft);

    /* Creation of the tip of the arrow, note the higher density */
    PolygonShape shapePoint = new PolygonShape();
    float[] shapePointV = {
            halfWidth, halfHeight * 2,
            halfWidth * 1.5f, 0,
            halfWidth, - halfHeight * 2};
    shapePoint.set(shapePointV);

    FixtureDef fixturePoint = new FixtureDef();
    fixturePoint.shape = shapePoint;
    fixturePoint.density = 26.0f;
    fixturePoint.restitution = 0.05f;
    fixturePoint.friction = 0.5f;
    body.createFixture(fixturePoint);

    body.applyLinearImpulse(MathUtils.cos(rotation) * velocity, MathUtils.sin(rotation) * velocity,
            body.getWorldCenter().x, body.getWorldCenter().y, true);

    //body.applyTorque(-90.0f, true); <-- My attempts to fix this but still doesn't work well
    //body.applyAngularImpulse(-0.5f, true);
    shapeShaft.dispose();
    }

}

The Box2DWorld is initialized as such:

  world = new World(new Vector2(0, -9.8f), true);

Here's a picture explaining how it looks and what I want to achieve (Courtesy of vilbeyli in github):

I have also attempted to apply the initial impulse in the bottom-left corner of the arrow but the resulting spin is very imprecise and random.

Why doesn't the heavier tip make the arrow rotate by itself?
How can this be fixed?


texts: Rotate on key down, revert rotate on key up?

texts: How would I rotate an object a certain number of degrees when the left arrow is pressed and then rotate it back to its start when the left arrow is released?


texts:
I am developing a game on android using OpenGL ES 1.0 for Android OS. It is a 2d game using a simple Orthographic projection and textures for the sprites. One of these textures has a small line (it looks like 1 pixel) all the way across the top that has the same colors as the bottom 1-pixel line of the texture. It is almost as if the bottom line of the image raster was copied and pasted as the top line as well.

Is anyone familiar with this type of error? What could the problem be?


texts: Changing coordinates of the object with velocity preservation

texts:
In Doodle jump, if a player jumps over one side of the screen he appears on another side with preserved velocity and other physical parameters.

I made two trigger colliders on the sides of the screen with OnTriggerEnter2D method.

private void OnTriggerEnter2D(Collider2D collision)
{
    collision.transform.position = new Vector3(collision.transform.position.x * -0.95f,
        collision.transform.position.y, collision.transform.position.z);
}

If I multiply collision.transform.position.x by -1f then on collision some glitching occurs. It gets stuck for a second. I believe this happens because when player is moved to the other side there is another collision detected and he is thrown back. Is there a more elegant way of handling this instead of multiplying by 0.95f?

Final solution:

[Tooltip("Controls where is the edge of the level where player is trasfered on the opposite side of the level.")]
[SerializeField]
private float xAxisMovementConstraints;

private void DetectBoundryCross()
{
    if (transform.position.x < (-xAxisMovementConstraints))
    {
        transform.position = new Vector2(transform.position.x + (xAxisMovementConstraints * 2f),
            transform.position.y);
    }
    else if (transform.position.x > xAxisMovementConstraints)
    {
        transform.position = new Vector2(transform.position.x - xAxisMovementConstraints * 2f,
            transform.position.y);
    }
}


texts:
I'm wanting to create a rope that can collide with objects like in the following youtube video:

2D Game Physics Rope

I'm thinking that you implement the verlet integration which uses points and connects these points with lines. I'm trying to figure out what type of collision detection you would apply to the rope to get the effect in the video.

I'm thinking you would have to do some cd to each point. I would like to use box2D, so I'm wondering would making each point a rigid body work? Any advice would be appreciated.