texts: Is it possible to get the colliding sides using the separating axis theorem?

texts:
The title says it all, is it even possible to get the colliding sides?

I'm checking for collisions between two OABBs, which works fine using SAT. Now I want to set the moving object's velocity to the reflection vector of it's velocity, but for that I need the normal of the surface it collided with.

Edit:

I guess it's better if I add a bit of context. Using SAT with unaligned boxes, I check for collisions on the two axes of each object, i.e. four in total. For each axis, I determine the minimum and maximum projection of both objects on that axis and then see if they overlap. If they overlap on every axis, it's a collision.

To resolve collisions, I used a somewhat hacky approach: I'm keeping track of the overlap on each axis, then move the moving object out on the axis with the smallest penetration. Strictly speaking, that's not correct, but it works pretty well in practice so far.

What I do now is use the inverted, normalised penetration vector as my unit normal and apply the law of reflection. It works surprisingly well, but it's even wronger.

So, is there a proper way to get the colliding sides or their normals using SAT? Or should I switch to a different approach to do it properly?


texts: Rotating gradually in response to input, instead of snapping

texts:
I'm trying to replicate Silent Hill's mechanic where if you press a button, the character does a 180, but instead of getting a smooth turn around, my character is snapping from one rotation to another.
This is the code I have so far:
if (Input.GetKeyDown(KeyCode.Tab))
{
    transform.Rotate(0f, 180f, 0f);
}

I also have a Sprint(); function and I want to disable this feature if the character is sprinting.
Here's the code for that:
private void Sprint()
{
    float newTurnSpeed = _turnSpeed - 1.4f;

    vertical = Input.GetAxis("Vertical");
    horizontal = Input.GetAxis("Horizontal");

    Vector3 direction = new Vector3(0f, 0f, vertical);
    Vector3 movement = transform.TransformDirection(direction) * _sprintSpeed;

    transform.Rotate(0f, horizontal * newTurnSpeed, 0f); //add the new turn speed
    isGrounded = _characterController.SimpleMove(movement);
}

Any help is appreciated!


texts:
I cannot sign up for Cryteks CryENGINE, at this site. When I click on the "sign up and download" button, nothing happens. I would ask this on their forums, but for that, you need an account.

How do I sign up and download CryENGINE?


texts: How do I exchange information between JavaScript front end and C++ back end?

texts: I am trying to make a chess like 2-player game that has game logic written in C++ and front end in JavaScript. How do I exchange information between the two? I am not familiar with network programming, so resources regarding that would be helpful as well.


texts: How to create a MessageBox in OpenGL using C++

texts:
I have a game that needs results displayed upon exit with a messagebox. I have the following code that works but I need to add an integer variable to the text.
This works:

MessageBox(NULL, L"Description\nline2", L"Info", MB_OK | MB_ICONEXCLAMATION);

But I need to say: "Description:" + num

I tried to pass a string but it won't compile:
MessageBox(NULL, L(string), L"Info", MB_OK | MB_ICONEXCLAMATION);


texts: Check for collision without any built-in collision functions

texts: Is it possible to check for a collision between gameObjects without using the built-in functions OnCollisionEnter, OnCollisionStay, or OnCollisionExit? Preferably a solution without the use of raycasting.


texts: Why current scene in cocos2dx has no children when accessed from outside scene class?

texts:
I want to access a sprite in a scene, but I cannot get the running scene from outside the scene class.

The scene is created using:

Scene* MyScene::createScene() {
    auto scene = Scene::create();
    auto layer = MyScene::create();
    scene->addChild(layer);
    return scene;
}

bool MyScene::init() {
    this->addChild(sprite,100, 1234);
}

But if I then access the running scene from outside the class, it has no children.

Director::getInstance()->getRunningScene()
//should be the MyScene instance with sprite children, but has no children.

I also tried giving the scene layer a tagname, but with the same result.

scene->addChild(layer,100,TAGNAME);
...
Director::getInstance()->getRunningScene()->getChildByTag(TAGNAME)
//returns NULL because getRunningScene has no children.

The only way I can access the scene is making a static reference in my AppDelegate, but this doesn't seem a proper way. How can I get the current scene correctly from outside the class?


texts:
I have a problem with detecting collision between 2 models using BoundingSpheres in XNA 4.0. The code I'm using i very simple:

private bool IsCollision(Model model1, Matrix world1, Model model2, Matrix world2)
{
for (int meshIndex1 = 0; meshIndex1 < model1.Meshes.Count; meshIndex1++)
{
    BoundingSphere sphere1 = model1.Meshes[meshIndex1].BoundingSphere;
    sphere1 = sphere1.Transform(world1);

    for (int meshIndex2 = 0; meshIndex2 < model2.Meshes.Count; meshIndex2++)
    {
        BoundingSphere sphere2 = model2.Meshes[meshIndex2].BoundingSphere;
        sphere2 = sphere2.Transform(world2);

        if (sphere1.Intersects(sphere2))
            return true;
    }
}
return false;

}

The problem I'm getting is that when I call this method from the Update method, the program behaves as if this method always returns true value (which of course is not correct). The code for calling is very simple (although this is only the test code):

 if (IsCollision(model1, worldModel1, model2, worldModel2))
                {
                    Window.Title = "Intersects";
                }

What is causing this?

The way Im drawing the scene is to load the number of elements and their coordinates from a file like this (it is called from Update method):

OpenFileDialog Otvaranje = new OpenFileDialog();
        if (ks.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.L))
            {
                this.GraphicsDevice.Clear(Color.CornflowerBlue);
                Otvaranje.ShowDialog();
                try
                {
                    using (StreamReader sr = new StreamReader(Otvaranje.FileName))
                    {
                        String linija;
                        while ((linija = sr.ReadLine()) != null)
                        {
                            red = linija.Split(',');
                            model = red[0];
                            x = red[1];
                            y = red[2];
                            z = red[3];
                            elementi.Add(Convert.ToInt32(model));
                            podatci.Add(new Vector3(Convert.ToSingle(x), Convert.ToSingle(y), Convert.ToSinglez)));
                            sfere.Add(new BoundingSphere(new Vector3(Convert.ToSingle(x), Convert.ToSingle(y), Convert.ToSingle(z)), 1f));

                        }
                    }

And then in the Update() method I had the following code (this was my first attempt):

if(sfere.Count != 0){
for(int i = 1; i<sfere.Count; i++)
{
 if(sfere[0].Intersects(sfere[i])) Window.Title = "Intersects";
}
}

This code never returned that collision is true because the bounding boxes are moving when the box moves, and I don't know why. The code that moves the box is this:

if (Microsoft.Xna.Framework.Input.ButtonState.Pressed == Mouse.GetState().LeftButton)
                {
                    worldKutija = Matrix.CreateTranslation(new Vector3(0.01f, 0f, 0f)) * worldKutija;
                }

So if the model is set to be the box it is drawn into the worldKutija, and all other models are drawn into world matrix so they would not move with the box model. So why are their BoundingSpheres moving? After this started happening I tried the code I posted in the original question, and got the problems I was talking about


texts: Why my calculated value is far different from actual value?

texts:
I using CharacterController and not using a Rigidbody so I writing a script for downward velocity which is velocity=-9.81*(time) and I declare my initial velocity as 12. Supposing from this calculation, the max height it can reach from the equation is roughly 6.7891 unit on y axis. By using the formulae
distance travel=initial velocity*(time)-0.5g*(time)^2,differentiate this w.r.t time, getting time=u/g=12/9.81=1.223, then max distance travel=12*(1.223)-0.5*(-9.81)*(1.223)^2=7.339 but from the coordinate below, can clearly seen the max distance travel before falling down is 13.2803unit--0.5499unit=13.8302unit? This is far exceed calculated value, wonder what went wrong?
Initial coordinate of y on ground=-0.5499

approximate final coordinate of y=13.2803

using UnityEngine;

public class NewPlayerMovement : MonoBehaviour
{
    public CharacterController Controller;
    //speed of the character
    public float Speed = 12f;
    // earth gravitational value
    public float Gravity = -9.81f;
    Vector3 velocity;
    //hit point of character
    float hp = 90;

    bool Grounded = true;

    public void OnControllerColliderHit(ControllerColliderHit hit)
    {
        Grounded = true;
        hp -= velocity.magnitude;
        velocity.y = 0;
        Debug.Log(hp);
    }

    public void OnControllerColliderExit(ControllerColliderHit hit)
    {
        Grounded = false;
    }

    public void Checkstatus()
    {
        if(Grounded==false)
        {
            velocity.y += 0.5f * Gravity * Time.deltaTime;
        }
    }

    void Update()
    {
        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");
        Vector3 move = transform.right * x + transform.forward * z;

        Controller.Move(move * Speed * Time.deltaTime);

        if (Input.GetKeyDown(KeyCode.Space) && velocity.y == 0)
        {
            velocity.y = 12;
            Grounded = false;
        }

       //check if it grounded
        Checkstatus();
        Controller.Move(velocity * Time.deltaTime);
    }
}


texts:
Tile-based games like Chess have a simple modal: an array of arrays, each coordinate with an X and a Y value. This is easy to implement, and it is easy to figure out what is going on.

Chess Board http://www.chesscentral.com/EasyEditor/assets/chess_board_blank.gif

However, when I see games like Civilization 5, I am not sure how hexagonal worlds are implemented. I have a couple ideas, but cannot confirm them.

Each row of hexagons is represented in the modal by an array of tiles. This would be much like the first chess board, but would require more effort to figure out adjacent tiles.
Each tile only know what tiles border it. When the game renders one tile, that tile loads the 6 around it, which repeats until the screen is filled with tiles.

Are either of these guesses correct? If not, how do developers implement these hexagonal maps?


texts: Installing Unreal Engine 4 in Ubuntu -- setting OAuth

texts:
https://wiki.unrealengine.com/Building_On_Linux

When I run ./GenerateProjectFiles.sh I get this:

Github build
Checking / downloading the latest archives

Please set OAUTH_TOKEN
You can generate an access token at https://github.com/settings/tokens/new
It must have repo scope

I have the token, how do I "set" it?


texts: Update method from script doesn't called

texts:
After experiments with Unity versions, I have reproduced Mandelbrot example from scratch and got C# script doesn't called. If I set breakpoint, it says it is not reacheable

I think I set up all links. As it seem from IDE hint, inheritance is correct.

Simultaneously, shader is working, i.e. image is displayed, but not updated by controller.


texts: Good Video Game User Interface Design Books/Websites?

texts: I having been programming games for some time, but while my teachers say that my code is good and advanced, my friends say that the interface is hard to understand and not the easiest to navigate. I want to learn how to design good user interfaces so that I can program better games, and people will have a easier time getting around. Does anyone know of any good books or websites about designing video game interfaces?


texts: Character Controller and Reverse Gravity

texts:
So I have a Game object with Rigid Body, a Character controller and my Movement script. On a specific condition I am reversing gravity. The problem is that the velocity.Y when the gravity is reversed, keeps increasing to the infinity. If I try to reset it like in the first if statement (which works for normal gravity) the object keeps bouncing from the ground. Gravity scale is either 1 or -1 in order to reverse gravity and movement.
This is the code:
 void Update()
    {

        _isGrounded = Physics.CheckSphere(groundCheck.position, 0.4f, whatIsGround);
        Move();
    }

void Move(){
//Reseting States for new cycle , unless the object is falling
        if ((_isGrounded && velocity.y < 0))
        {
            velocity.y = -2f;
            _isRunning = false;
            _isJumping = false;
            _isFalling = false;
        }else if (velocity.y < 0 && !_isGrounded)
        {
            _isFalling = true;
        }
        //Moving on X axis
        float x = Input.GetAxis(KeyInputMove);
        if (x != 0)
        {
            _isRunning = true;
        }
        moveDirection = gravityScale*_transform.right * x;
        _controller.Move(moveDirection * moveSpeed * Time.deltaTime);

        //Perfoming jump
        if (Input.GetButtonDown(KeyInputJump) && _isGrounded)
        {
            velocity.y = (float) Math.Sqrt(1 * -2f * globalGravity);
            _isJumping = true;
        }

        velocity.y += gravityScale * globalGravity * Time.deltaTime;
        _controller.Move(velocity * Time.deltaTime);
//Updating animation states
        _animator.SetBool("Grounded",_isGrounded);//^This is the idle state
        _animator.SetBool("Running",_isRunning);
        _animator.SetBool("Jumping",_isJumping);
        _animator.SetBool("Falling",_isFalling);

    }

    private void OnTriggerExit(Collider other)
    {
       //Reverse Gravity and Model Rotation
        if (other.gameObject.tag == "Portal")
        {
            _transform.Rotate(0,0,gravityScale*180);
            gravityScale *= -1;
        }
    }


texts: Is it possible to publish an app based on a board game?

texts: Usually the boxes says "all rights reserved" and "registered trademark". What does it mean? Could others make an app with the game's name and mechanic? Is it possible to sell it, put banner ads or make it free?


texts: How to create custom 3D "areas" at runtime

texts:
I've been puzzled for a few days trying to solve this problem, so far with no results.

On a map, currently a Terrain, I'd need to have some "areas" which can be controlled by a specific players. The shape of those areas can arbitrarily change during the course of the game, such as you add a  marker in any point, and the area evolves (like a spline, say) to pass through that point too.

The problem isn't drawing the boundary itself, of course, but having the GameObjects detecting the area they are in.

Currently I have absolutely zero idea on how to make this exactly.

I've thought about a nice approximation, which is splitting the terrain in fixed chunks, and having the player control them "chunk by chunk": every chunk can have its own collider, and that should be easy if not trivial. So the question is how to do it "properly", since I already have this workaround.


texts:
We're working on an iOS game that we plan on having several content updates for.

It's a story type game with lots of little flags when things have been accomplished and such.  There is also an inventory system.

I'm looking for ideas on how to best design a game state save data system that will be resilient to a lot of updates and changes to the game.


texts: Unity3D: Making heavy calculation on separate thread

texts:
So, I've created a program with Kinect as its input. As you know, Kinect will send the data 30 frame per second.

I have a model that will mimic Kinect's input motion, so on Update() I read the motion from Kinect.

The problem is, on Update(), I've done a heavy computational algorithm. It makes the system lag and freezing. I've tried to do the calculation every 60 frames instead of each frame, but the system still got lag.

void Update(){
        ...
        //GET DATA FROM KINECT
        frame = new SkeletonRecorded();
        frame.root.rotation = skeletons[kinect2SensorID, playerID].root.rotation;
            ...
        frame.rightShoulder.position = skeletons[kinect2SensorID, playerID].rightShoulder.position;
        frames.Add(frame);
        if (frames.Count >= 60) {
            //CALLING THE CALCULATION METHOD (Here is the heavy part begin)
            comparatorClass.GetSkeletonData(frames);
            frames.Clear();
        }

}

The above code is just small parts of the Update() method (I cut it short for convenience). So, how should I call the GetSkeletonData() method without making the interface lag?


texts:
I'm trying to learn Android, so I'm creating a basic 2D game which using a background scrolling image, I've already made it and the character is already walking with animation my current goal is to make it jump. I've also created the character class btw am I going to put it on ontouchevent?

  import android.annotation.SuppressLint;
  import android.app.Activity;
  import android.content.Context;
  import android.content.SharedPreferences;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.graphics.Canvas;
  import android.graphics.Paint;
  import android.graphics.Rect;
  import android.view.Display;
  import android.view.MotionEvent;
  import android.view.SurfaceHolder;
  import android.view.SurfaceView;

  import java.util.ArrayList;
  import java.util.Random;

public class GamePanel extends SurfaceView implements SurfaceHolder.Callback {

public static final int WIDTH = 856;
public static final int HEIGHT = 480;
public static int Score = 0;
public static int Highscore;
private MainThread thread;
private Background bg;
private Deer deer;

public GamePanel (Context context) {
    super(context);
    getHolder().addCallback(this);
    setFocusable(true);

}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {

    boolean retry = true;
    while (retry) {
        try {
            thread.setRunning(false);
            thread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
            retry = false;
        }
    }
}

@Override
public void surfaceCreated(SurfaceHolder holder) {
    bg = new Background(BitmapFactory.decodeResource(getResources(), R.drawable.gamebg));
    deer = new Deer(BitmapFactory.decodeResource(getResources(), R.drawable.deer), 48,60,3);
    bg.setVector(-5);

    thread = new MainThread(getHolder(), this);
    thread.setRunning(true);
    thread.start();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
    return super.onTouchEvent(event);
}
public void update() {
    Score += 2;
    if (Score > Highscore) {
        Highscore = Score;
    }
    bg.update();
    deer.update();
}

@SuppressLint("MissingSuperCall")
@Override
public void draw (Canvas canvas)  {

    final float scaleFactorX = (float)getWidth()/WIDTH;
    final float scaleFactorY = (float)getHeight()/HEIGHT;
    if(canvas !=null) {
        final int savedState = canvas.save();
        canvas.scale(scaleFactorX, scaleFactorY);
        bg.draw(canvas);
        deer.draw(canvas);

        canvas.restoreToCount(savedState);

        Paint textpaint = new Paint();
        textpaint.setTextSize(30);
        canvas.drawText("Score:" +String.valueOf(Score), 0, 32, textpaint);
        canvas.drawText("High Score: "+String.valueOf(Highscore), 0, 64, textpaint);

    }
}
}


texts: Webgl, weird rendering with sprite that has alpha

texts:
So I have a webgl application where I render all kinds of objects, but in this specific example, I have two shaders. One that renders sprites and one that renders colored polygons. In this example I draw a rectangle and two sprites. The rectangle is drawn first and the sprites are drawn second. The rectangle has a lower z and the the sprites have the same z that is higher then the rectangle. This is the result with depth test function of gl.LESS and gl.BLEND enabled with blend function gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA). The texture is a png. Here is the result

This is not the correct result obviously as the sprite below is somewhat cut off. Also, if I draw the sprites before the rectangle, I get this

At first, I figured that that black around the sprites was just the pixel not being blended as alpha, but as it turns out from changing the clear color, that black is actually the background, so it looks like the rectangle is literally being cut out.

What could cause this behavior?

There is a lot of code, so tell me what is relevant and I will post it.


texts: Threads slowing down application and not working properly

texts:
I'm making a software renderer which does per-polygon rasterization using a floating point digital differential analyzer algorithm. My idea was to create two threads for rasterization and have them work like so: one thread draws each even scanline in a polygon and the other thread draws each odd scanline, and they both start working at the same time, but the main application waits for both of them to finish and then pauses them before continuing with other computations.

As this is the first time I'm making a threaded application, I'm not sure if the following method for thread synchronization is correct:

First of all, I use two global variables to control the two threads, if a global variable is set to 1, that means the thread can start working, otherwise it must not work. This is checked by the thread running an infinite loop and if it detects that the global variable has changed its value, it does its job and then sets the variable back to 0 again. The main program also uses an empty while to check when both variables become 0 after setting them to 1.

Second, each thread is assigned a global structure which contains information about the triangle that is about to be rasterized. The structures are filled in by the main program before setting the global variables to 1.

My dilemma is that, while this process works under some conditions, it slows down the program considerably, and also it fails to run properly when compiled for Release in Visual Studio, or when compiled with any sort of -O optimization with gcc (i.e. nothing on screen, even SEGFAULTs). The program isn't much faster by default without threads, which you can see for yourself by commenting out the #define THREADS directive, but if I apply optimizations, it becomes much faster (especially with gcc -Ofast -march=native).

N.B. It might not compile with gcc because of fscanf_s calls, but you can replace those with the usual fscanf, if you wish to use gcc.

Because there is a lot of code, too much for here or pastebin, I created a git repository where you can view it.

My questions are:

Why does adding these two threads slow down my application?
Why doesn't it work when compiling for Release or with optimizations?
Can I speed up the application with threads?
If so, how?

Thanks in advance.


texts: Is there an algorithm to move vertices along a planar mesh to give an area more vertex without destroying the shape too much?

texts:
Currently, I am playing around with a terrain technique called Vector-Field terrain as created and used for the game Halo Wars. I have successfully recreated the technique. However, I'm having difficulty with trying to figure out how to adjust the vertex density for the overhangs in the terrain.

Vector-Field Terrains still suffer similar problems to height map terrains. Where any time there is a vertex with a vertical scalar that is too different from it's neighbor will have UV stretching.

The way that Vector-Field terrains eliminates this, is that you can pull surrounding vertexes to give the area more resolution by giving it more density without changing the topology.

I can not for the life of me come up with a way to do this in a none destructive manner and in an automated way. I'd like to be able to keep the final shape as close as possible to the source. And only pull in as many vertexes as needed to correct this.

Does anyone know of any algorithms to solve this problem?


texts: Keeping game model and graphics/animation separate but in sync

texts:
Suppose I'm building a chess game where I want to have animations.  Pieces glide to their new squares when moved.  Pieces perform attack animations when capturing other pieces.

I'm not sure how to effectively separate the data and logic needed for these animations and the actual game model (in the MVC sense).  The pieces themselves should ideally not have to worry about their pixel coordinates or current animation frame.  At the same time, many changes to the model are effectively driven by animations.  A moved piece changes its position after (before?) its sprite is done gliding.  A piece is removed from the board after the capturing piece is finished its attack animation.

How would you suggest I manage the game model, the graphics and animations, and their relationships?  For example, where would the animations "live"?  How would animations be created and managed in response to player moves?  How would animations drive updates to the game model, or how would the game model drive animations?


texts:
This is where I am having to place my panel in canvas scene for it goes to the right place when I play it in full mode. Anyone knows how to do it correctly?

In scene:

Play mode:


texts: Move GameObject with defined lists of position and rotation

texts:
I'm working on playing a replay on every strike. For that I'm recording the positions and rotation of the sphere in the list individually. I now have the values reside in the list. How do i move my sphere with the defined pos and rot. Below is what I've tried so far.

Replay.cs

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

public class Replay : MonoBehaviour
{

    BallRecorder script;

    public List<Vector3> position;

    public List<Quaternion> rotation;

    // Use this for initialization
    void Start()
    {
        script = GetComponent<BallRecorder>();

        position = new List<Vector3>();
        rotation = new List<Quaternion>();

        position = script.position;   // Now contains all the values of the sphere(positions)
        rotation = script.rotation;   // Now contains all the values of the sphere(rotation)

        foreach (Vector3 av in position)
        {
            transform.position = av;  //transferring position to the sphere
        }

     }

BallRecorder.cs

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

public class BallRecorder : MonoBehaviour {

    // Use this for initialization

  public  List<Vector3> position;
  public  List<Quaternion> rotation;
    static int count = 50;

    void Start () {

        position = new List<Vector3>();

        rotation = new List<Quaternion>();

    }

    // Update is called once per frame
    void Update()
    {

        count = count - 1;

        if (count < 1)
        {
            position.Add(transform.position);
            rotation.Add(transform.rotation);

        }
    }
}


texts: Saving and retrieving high-score data in XNA 4.0

texts:
I made a game in XNA 4.0 and now I need to save the points in a database or in a file (or in something else). My goal is to store and retrieve the highest score if I choose that option in the main menu. What I found on the internet is not complete, or whatever, useless for me.

What techniques can I use with XNA to save and load data?


texts: Unreal Engine Niagara Particle Velocity Based on Density of Particles?

texts:
Goal: Simulation of particles where each particle moves to the direction with the highest density out of candidate directions.

I'm not sure how to do the following operations using UE Niagara.

How to look at the positions of other particles within a Niagara Emitter. I know how to access to the position of other emitters using event handlers.
How to read the positions of particles that are in a certain region in the 3D space (eg. within the bounding box of (0,0,0) (1,1,1)) efficiently.

Please feel free to suggest any other features within UE, but I think Niagara is the way to go.


texts: Adding some new velocity to player in FixedUpdate. Should I use FixedDeltaTime or nothing?

texts:
I am trying to learn how to move objects in Unity without using the built in features like AddForce etc. Some tutorials on Unity website (and other places) is where I have got most of my 'knowledge' so far from.

This script for moving players (in topdown Space SHMUP) has been working fine for me and includes acceleration and artificial drag (basically 'smooth' movement, or like being on ice).

I'm sure this code is overly long, bloated, inefficient and in most cases downright wrong, but it is written for me to understand it, rather than simply using Unity Prefabs and AssetPackages i download from Store.

QUESTION: Do I need the Time.fixedDeltaTime mutlipiers when calculating my 'delta_v' values here. And also what about on the drag part at the bottom.

As usual all help and comments are greatly appreciated. Thanks!

public class Player_Movement_SpaceShooter_TopDown : MonoBehaviour
{
public Vector2 maxVelocity;
public float drag;
public float moveForce;
private Rect moveBounds;

private Rigidbody2D rb;

private void Start()
{
    rb = GetComponent<Rigidbody2D>();
    moveBounds = Game_Manager.instance.ScreenBounds;
}

private void FixedUpdate()
{
    float input_h = Input.GetAxis("Horizontal");
    float input_v = Input.GetAxis("Vertical");
    Vector2 delta_v = Vector2.zero;

    delta_v.x += input_h * moveForce * Time.fixedDeltaTime;
    delta_v.x = Mathf.Clamp(delta_v.x, -maxVelocity.x, maxVelocity.x);
    delta_v.y += input_v * moveForce * Time.fixedDeltaTime;
    delta_v.y = Mathf.Clamp(delta_v.y, -maxVelocity.y, maxVelocity.y);

    Vector2 pos = rb.position;
    Vector2 vel = rb.velocity;
    if (pos.x < moveBounds.xMin)
    {
        pos.x = moveBounds.xMin;
        vel.x = 0f;
    }
    if (pos.x > moveBounds.xMax)
    {
        pos.x = moveBounds.xMax;
        vel.x = 0f;
    }
    if (pos.y < moveBounds.yMin)
    {
        pos.y = moveBounds.yMin;
        vel.y = 0f;
    }
    if (pos.y > moveBounds.yMax)
    {
        pos.y = moveBounds.yMax;
        vel.y = 0f;
    }

    rb.position = pos;

    rb.velocity = vel + delta_v;
    rb.velocity = rb.velocity * (1 - Time.fixedDeltaTime * drag);

}

}

It appears to me that if FixedUpdate was somehow slowed down, the velocity would get  changed slower, the same with the enemy movement but I don't know how that would effect the gameplay and if/how the slowing-down would occur


texts:
Ok, so my question is simple. How do you poll input with a GUI class without it affecting what's underneath the GUI? So suppose you have an RPG game with a gui for the d-pad and other controls:

gui.getInput(); //User taps button in the gui
world.getInput(); //The tap should have only affected the gui, but instead goes through and also affects the world

How can you deal with this problem? I thought of some ways but I don't like them.


texts: Displaying streaming video on dynamic texture

texts:
We are working in Unity 3D on pro licence and we are faced with the task to display streaming video as a dynamic texture in out Unity3D web project. We have a standard IP-camera , which is capable of delivering a stream h.264 format via RTSP, and mjpeg via HTTP.

How can we display this stream on a texture in our scene?


texts:
i'm using OpenGL 2.1 with SDL2.0 and i'm trying to render a texture, using this steps:
load the image:

    Image* image = new Image();

image->image = SDL_LoadBMP(path.c_str());

if (!image->image)
    throw std::runtime_error(SDL_GetError());

return image;

and then generate a texture for it:

Texture2D* Texture2D::fromImage(const Image* image){
GLint format;
Texture2D* t2d = new Texture2D();

glGenTextures(1, &t2d->tid);
glBindTexture(GL_TEXTURE_2D, t2d->tid);
t2d->size.setWidth(image->getWidth());
t2d->size.setHeigth(image->getHeight());

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

switch (image->getBPP()){
case 24:
    format = GL_RGB;
    break;
case 32:
    format = GL_RGBA;
    break;
default:
    throw std::runtime_error("Unsurpoted pixel format!");
    break;
}

glTexImage2D(GL_TEXTURE_2D, 0, format, image->getWidth(), image->getHeight(), 0, format, GL_UNSIGNED_BYTE, image->getPixels());

return t2d;
}

and then i try to render it:

void Painter::drawTexture(Texture2D* texture, const SizeF& size, const PointF& position){
camera.set(camera.getWidth(), camera.getHeight());

texture->bind();//only call glBindTexture(GL_TEXTURE_2D, tid);

glBegin(GL_QUADS);
glColor4f(color.getR(), color.getG(), color.getB(), color.getA());
glTexCoord2f(0.0f, 1.0f);
glVertex2f(position.getX(), position.getY());
glTexCoord2f(1.0f, 1.0f);
glVertex2f(position.getX() + size.getWidth(), position.getY());
glTexCoord2f(1.0f, 0.0f);
glVertex2f(position.getX() + size.getWidth(), position.getY() + size.getHeight());
glTexCoord2f(0.0f, 0.0f);
glVertex2f(position.getX(), position.getY() + size.getHeight());
glEnd();
}

but all i got is box with the defined color, i don't understand why, i have already followed this steps before to render a texture, but this time it is not working, i'm not using glEnable(GL_TEXTURE_2D) because i read that this is not necessary, but when i do call it i got the error code 1282, but i got no errors on the textures creation, can someone give me some light here? thanks


texts: Can I report someone for cloning my game?

texts:
I recently found out that someone cloned my game from 2018 (2d, pixel art, here: https://www.youtube.com/watch?v=fiTJn5PULnA) that was on iOS, made it in 3d for android (here: https://play.google.com/store/apps/details?id=com.goquest.angrywife). Copied name, mechanics, everything, even some of the optional gadgets.
I paused my apple dev subscription at the end of 2019 so my game is not available for download anymore, but this guy released it in mid 2019, when it was.
I was wondering if I can somehow take action and have google remove the game from the listing.


texts: How can i fix "get_transform can only be called from the main thread" error in my code?

texts:
Here's my code:

var forward = transform.TransformDirection(Vector3.forward);
var input = Input.GetAxis("Vertical");
function Update(){
transform.position += forward * input * Time.deltaTime;
transform.Rotate( 0 , Input.GetAxis("Horizontal") * 45 * Time.deltaTime , 0 );
}

I keep getting this error:

 get_transform  can only be called from the main thread.
 Constructors and field initializers will be executed from the loading thread when loading a scene.
 Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.


texts:
If you look at this Link you'll see UNet is deprecated and will be removed in the future.

I'm developing a mobile multiplayer game, i've red official advise about it but they say "You can publish it with 2018.4 (LTS)" and I can't use 2018.4 version because in my project i use LWRP which is not in the 2018.X versions.

I've found the alpha version of the new system right here

My questions are:

1- Should i use the alpha version of the new system? And can i publish my game with it?

2- Should i wait for the new system came out? (I can't wait for months)

3- Should i try to use other third party systems like Photon?

Or is there any way to publish my game with nice multiplayer system?

Note: I can't pay for multiplayer matchmaking system. Because of that i want to make Hosting multiplayer game.


texts:
I'm trying to bring traffic on my street system. The main problem for me are the different lanes and crossings and to make it complete the different types of paths.

I've tried a bit with the NavMeshes, the different types I've solved with costs, so cars prefer greater streets and ignore pavements. But there is the problem how to tell pedestrians to prefer pavements and ignore streets?

And the main problem for me are crossings cause they start to switch the lanes and drive in the wrong side, turn around and so on.

I'm thinking about that NavMeshes aren't the right thing but doesn't get any better idea!?

My usecase is that I want to tell the police Car to drive from the police Station to a bank robbery (fixed coordinates) or the Bus to drive on a fixed route. So I want to have the Option to define multiple points and let them drive/walk to this (or the nearest) point - respecting the lanes and not do a U-Turn (not prefer this).

I don't want ready to use code, just an explained idea how to go.


texts: How does Unity's multiplayer support stack up compared to other engines?

texts: I am currently starting development on a FPS game. I haven't decided on a developement tool. I am really drawn to Unity 3D but not sure how good the software is compared to others (the game has to have smooth multiplayer). Does Unity have multiplayer support? I couldn't really tell from the website.


texts: Canvas not visible in my GearVR Project with Vuforia (Unity)

texts:
I created a simple AR project with vuforia and my Samsung GearVR, like described here : https://developer.vuforia.com/library/articles/Solution/Integrating-Gear-VR-and-the-AR-VR-Sample-in-Unity-5-3-and-above . This works fine so far. Now I want to add some canvas elements, I don't want them to move, just fixed canvas elements. I tried to place my canvas on different positions in the scene :

Root
Child of CameraRig
Child of LeftCamera
Child of TrackableParent
Child of an ImageTarget in TrackableParent

But for all of these cases the canvas is not visible. I know, this question is really specific, but maybe someone with knowledge in this specific thing can help me.

This is my Canvas :


texts:
i have an issue that i hope it's easy to resolve.
I'm playing various animations in my libgdx-created game.

For a particular animation, i need that to play in loop mode but only if a particular condition is true. Simple this far.

What i need is to "reset" the animation (i mean restart from sprite n°1) when the condition become true again after the animation stopped.
I know that i can simply dispose the actual animation and create another one every time the condition is true, but this seems a complicated way to resolve this..

How do i change the value of the index used by that animation? Is it possible?
Do i have to create a class that extends the Animation class from libgdx library?


texts:
I managed to use cube maps in OpenGL to get reflection and refraction effects. So far I used images from this site, however, I want to create my own set of images to use in a cubemap, the idea is just to have checker-board patter on the "floor" and the rest of a solid color.

My question is, how can I create the 6 images in order to get the cube map textures?

EDIT

I want to be able to achieve something like this picture (on top) but without the cube, sphere and so on.


texts: How to detect collision of a wall with grid movement?

texts:
I have this little game, where my player is moving around a simple level, using a grid based movement script (See code below). My problem is that I have tried to implement a 2D raycast, which has to detect if the next 'tile' is a movable tile (not a wall). However all the examples I have found on the internet hasn't been something I could make work. So please help me with how I can detect if the player is allowed to move, before he moves.

I am using Unity 5.

using System.Collections;
using UnityEngine;

public class GridMove : MonoBehaviour {
    public float moveSpeed = 2f;

    private float gridSize = 1f;
    private enum Orientation {
        Horizontal,
        Vertical
    };
    private Orientation gridOrientation = Orientation.Vertical;
    private bool allowDiagonals = false;
    private bool correctDiagonalSpeed = true;
    private Vector2 input;
    private bool isMoving = false;
    private Vector3 startPosition;
    private Vector3 endPosition;
    private float t;
    private float factor;
    private Animator animator;

    // Use this for initialization
    void Start () {
        animator = GetComponent<Animator>();
    }

    public void Update() {
        if (!isMoving) {
            input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
            if (!allowDiagonals) {
                if (Mathf.Abs(input.x) > Mathf.Abs(input.y)) {
                    input.y = 0;
                } else {
                    input.x = 0;
                }
            }

            if (input != Vector2.zero) {
                StartCoroutine(Move(transform));
                animator.SetBool("isWalking", true);
            }
            else {
                animator.SetBool("isWalking", false);
            }
        }
    }

    public IEnumerator Move(Transform transform) {
        isMoving = true;
        startPosition = transform.position;
        t = 0;

        animator.SetFloat("x", input.x);
        animator.SetFloat("y", input.y);

        if(gridOrientation == Orientation.Horizontal) {
            endPosition = new Vector3(startPosition.x + System.Math.Sign(input.x) * gridSize,
                                      startPosition.y, startPosition.z + System.Math.Sign(input.y) * gridSize);
        } else {
            endPosition = new Vector3(startPosition.x + System.Math.Sign(input.x) * gridSize,
                                      startPosition.y + System.Math.Sign(input.y) * gridSize, startPosition.z);
        }

        if(allowDiagonals && correctDiagonalSpeed && input.x != 0 && input.y != 0) {
            factor = 0.7071f;
        } else {
            factor = 1f;
        }

        while (t < 1f) {
            t += Time.deltaTime * (moveSpeed/gridSize) * factor;
            transform.position = Vector3.Lerp(startPosition, endPosition, t);
            yield return null;
        }

        isMoving = false;
        yield return 0;
    }
}


texts: 2D SAT Collision Detection not working when using certain polygons (With example)

texts:
My SAT algorithm falsely reports that collision is occurring when using certain polygons. I believe this happens when using a polygon that does not contain a right angle. Here is a simple diagram of what is going wrong:

Here is the problematic code:

std::vector<vec2> axesB = polygonB->GetAxes();
//loop over axes B
for(int i = 0; i < axesB.size(); i++)
{
    float minA,minB,maxA,maxB;
    polygonA->Project(axesB[i],&minA,&maxA);
    polygonB->Project(axesB[i],&minB,&maxB);

    float intervalDistance = polygonA->GetIntervalDistance(minA, maxA, minB, maxB);
    if(intervalDistance >= 0) return false; //Collision not occurring
}

This function retrieves axes from the polygon:

std::vector<vec2> Polygon::GetAxes()
{
    std::vector<vec2> axes;
    for(int i = 0; i < verts.size(); i++)
    {
        vec2 a = verts[i];
        vec2 b = verts[(i+1)%verts.size()];
        vec2 edge = b-a;
        axes.push_back(vec2(-edge.y,edge.x).GetNormailzed());
    }
    return axes;
}

This function returns the normalized vector:

vec2 vec2::GetNormailzed()
{
    float mag = sqrt( x*x + y*y );
    return *this/mag;
}

This function projects a polygon onto an axis:

void Polygon::Project(vec2* axis, float* min, float* max)
{
    float d = axis->DotProduct(&verts[0]);
    float _min = d;
    float _max = d;
    for(int i = 1; i < verts.size(); i++)
    {
        d = axis->DotProduct(&verts[i]);
        _min = std::min(_min,d);
        _max = std::max(_max,d);
    }
    *min = _min;
    *max = _max;
}

This function returns the dot product of the vector with another vector.

float vec2::DotProduct(vec2* other)
{
    return (x*other->x + y*other->y);
}

Could anyone give me a pointer in the right direction to what could be causing this bug?

Edit: I forgot this function, which gives me the interval distance:

float Polygon::GetIntervalDistance(float minA, float maxA, float minB, float maxB)
{
    float intervalDistance;
    if (minA < minB)
    {
        intervalDistance = minB - maxA;
    }
    else
    {
        intervalDistance = minA - maxB;
    }
    return intervalDistance; //A positive value indicates this axis can be separated.
}

Edit 2: I have recreated the problem in HTML5/Javascript: Demo


texts:
I'm creating a minecraft clone (for practice), and I'm trying to implement a feature in which the block that the player is looking at has a block outline. The way I do this is just by creating a GL_LINES mesh that covers the edges of the block, and then translating it to the block position. I'm using the LibGDX framework to do this - the outline ends up producing a ModelInstance.

It partially works, but this is what it looks like:

As you can see, some of the pixels are getting rendered, but some aren't. My theory is that this is because of the depth buffer - because the line is intersecting with the face, some of the pixels don't get rendered. So my question is, how can I ensure that the outline gets rendered solidly?


texts: Lunar lander: why is my descent module crashing


texts: How does the logic "column < row + 1" work? The output gives half an asterisk pyramid

texts:
This code creates half a pyramid on the compiler, but I'm not sure how that works. The only thing I understand is that the column < row + 1 line is what influences the code, because when I change it to column < 10, then it creates a square when run.

for(int row = 0; row < 10; row++) {
    for(int column = 0; column < row + 1; column++) {
        Console.Write("*");
    }
    Console.WriteLine();
}

//The output gives half the asterisk pyramid.
//I don't get the logic of how "row + 1" works.
//How does this influence the asterisk to not be entered in the particular places?


texts: Level editor event system, how to translate event to game action

texts:
I've been busy trying to create a level editor for a tile based game i'm working on. It's all going pretty fine, the only thing i'm having trouble with is creating a simple event system.

Let's say the player steps on a particulair tile that had the action "teleport" assigned to it in the editor. The teleport string is saved in the tile object as a variable. When creating the tilegrid an actionmanager class scans the action variable and assigns actions to the variable.

    public static class ActionManager
{

    public static function ParseTileAction(tile:Tile) {

        switch(tile.action) {

            case "TELEPORT":

            //assign action here

            break;
        }

    }

}

Now this is an collision event, so I guess I should also provide an object to colide with the tile. But what if it would have to count for collision with all objects in the world? Also, checking for collisions in the actionmanager class doesn't seem very efficient.

Am I even on the right track here?
I'm new to game design so I could be completly off track.
Any tips on how handeling and creating events using an editor is usually done would be great. The main problem i'm having is and efficient way to read out and react to the given actions in the editor.

Thanks in advance.


texts: Is it possible to run other doom3 engine based games using the open sourced version of the engine?

texts:
Other than the doom3 mods, is it possible for example to run Quake 4 or Prey using the game data?

Let's say that I purchase Quake 4 or Prey (or any other idTech 4 game) can I just point to the game data path and run it with the source code? Is there any modification needed? If so, what is it?


texts: How to upload lights when doing one pass per light

texts:
Suppose I have a reasonable amount of light sources that I upload at once in my forward rendering and accumulate them in shader.

Now that I am willing to move to deferred, and so one pass per light,  I have a design doubt. Suppose my light struct is no more than 64B, I have two options:

Still upload them to GPU once and then using a uniform to get the right index for each pass.
Upload for each pass the correspondent light info.

With option 1 I have the advantage of not uploading info at each frame, but just once. On the other hand, option 2 allow to have less data on memory, with the downside of having to load about 64B per pass per frame.

Whilst I am leaning towards option 1, I am no expert and kinda new to the field. Knowing I don't think I'll have more than 100 lights, what's the option you'd choose? Any trade off/aspect I am missing?

EDIT: If there's no much difference, I already have all the code ready for option 1, so that's another factor that lead me towards it. However, to be honest, I am more than happy to refactor if it means an advantage.

Thanks


texts: Issue calculating new angle for player to look at some 3d world object

texts:
I am working on a Unity game where the Euler angles of the player display some weird behaviour that I cannot understand. There seem to be two full 360 degrees rotations, one positive and one negative. Depending on the direction you go when you are at 0 degrees, it will either take the negative path or the positive path. This means the player can have totally different yaw values depending on if it takes the green or red path. See the following image to get an idea of what is happening:

The issue now comes when I want to calculate the new angle for the player to look at some specific object in the 3d world space. I calculate this angle using some simple math:

// make player the origin, so the target is relative to the player
Vector3 delta = player.angles - target.angles;

float magnitude = delta.Length();

float pitch = asin((delta.y) / magnitude) * (180 / M_PI);
float yaw  = -atan2(delta.x, -delta.z) * (180 / M_PI);

This will give me back correct angles, but the yaw is from 0 to 180, then -180 to 0 again. I correct for this doing:

// this makes sure the calculated angle is from 0-360
if (yaw < 0) {
    yaw += 360; // normalize yaw
}

So, right now this is aligned with the red rotation line illustrated in the picture above. If I would set the players rotation to the new calculated angle, it would look correctly at the target object directly. But ONLY when the player is on the red rotation path.

If the player for example is on the green rotation path the calculated angle doesn't fit for the current users rotation. If I would set the rotation now, things get quirky. Somehow I need to compensate the calculated new player angle.

What is going on here? and is it possible to manipulate the new calculated angle (which ranges always from 0-360) so it is based on the current players rotation path (either green or red)?

I hope my question makes sense, I found it quite hard to follow what is going on. I hope someone could explain me the situation and ultimately help me out to fix the new calculated angle so it adjusts to the current player rotation path!

Any help is appreciated, thanks in advance!

EDIT
So I came up with the following to make sure the player is always rotated the shortest amount, taking both green and red rotation paths into consideration:

// normalize angles for when using negative rotation
if (localAngles[1] < -180)
{
    angles[1] -= 360;
}

double diffPitch = (angles[0] - localAngles[0]);
double diffYaw = (angles[1] - localAngles[1]);

// this makes sure we always take the shortest amount of degrees to target
if (diffYaw < -180)
{
    diffYaw += 360;
}
if (diffYaw > 180)
{
    diffYaw -= 360;
}

I will have to test some more to be sure this is the solution.


texts:
2.5D ("two-and-a-half-dimensional"), 3/4 perspective and pseudo-3D are
  terms used to describe either:

  graphical projections and techniques    which cause a series of
  images or    scenes to fake or appear
  to be    three-dimensional (3D) when
  in fact    they are not, or
  gameplay in an otherwise    three-dimensional video game that is
  restricted to a two-dimensional
  plane.

  (Information taken from Wikipedia.org)

I have a question based on 2.5D game development. As stated before, 2.5D uses graphical projections and techniques to make fake 3d or a gameplay restricted to a two-dimensional plane.

A good example is a TQ Digital made game: Zero Online (screenshot) the whole map is made of 2d images and only NPCs and players are 3d.

The maps were drawn manually by hand without any 3d software rendering. As I'm playing the game I feel like I'm going from a lower part of the map (ground) to a higher one (some metal platform) and it feels like I'm moving in 3 dimensions. But when I look closely, I see that the player size didn't change and the shadow too but I'm still feeling like I'm somehow higher then before (I had rendered a simple map myself that I made in 3dmax but it didn't quite give the result I wanted).

How can you accomplish such an effect?


texts:
What's the best way to represent a realistic population number (e.g USA:317,569,000) in game?

For example, Civilization your city has 1 Citizen. Obviously, a city can't just have one person in a city but Civ seems to do a good job at representing citizens that way.

What I'm after is to represent 300+ million in an easy to swallow number to a player.

I have a calculation which states that, in theory, to have 300+ people you would need 79 million 4 person dwellings. (I understand this may not be totally accurate, but it works for my needs)

It seems tedious to have the player do that with a couple of methods I've thought about.

So my question then is I need some way to make the game and the player aware that the player's city has 100,000 people in it without making the player create 25,000 dwellings.

Update 1:

As @Patrick M states, in Civ you only have to build one of a building type.

Much like dwellings, it doesn't make sense to force the player to build one police station/1000 people.

I have a formula that calculates the theoretical population limits of an area and I want to constrain the player to this limit. (Players have a reason for wanting larger regions)

However, I don't want the player to instantly have 10,000 citizens simply because he built a "house/neighborhood".

I want to represent real world constraints and requirements without the super micro management that would be present in forcing the player to build 2,500 dwellings (to get the 10k)


texts: Unity3D 5.5b : C# WebGL open email client Win32 exception error

texts:
I want to send an email in a WebGL build using C#. My code is as below

try
{
   Uri myUri = new Uri("mailto:anemailaddress@example.com? Subject=Hello%20again&body=TEST");
   System.Diagnostics.Process.Start(myUri.AbsoluteUri);
}
catch (Win32Exception e)
{
  Debug.LogError(e.Message);
}
catch (Exception e)
{
   Debug.LogError(e.Message);
}

to open an email client. But I get the following error as well as a Win32Exception : Success error

(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/WebGL/runtime/DebugBindings.gen.cpp Line: 51)

a9b4b6fe-b629-4efc-bb29-821d1f0fcea2:9085:3
 Not implemented icall: Process::ShellExecuteEx_internalUnityLoader.js:3541:3
 Success

(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/WebGL/runtime/DebugBindings.gen.cpp Line: 51)


texts: using eclipse instead of visual studio for cocos2d-x project

texts:
im using coco2d-x v 3.0  i made a new windows project to test it and it is working but when i try to build and run a project using this command cocos run -p win32
it is print this error

it seem like it need visual studio to run but how can i build and run the project throw eclipse or any IDE i have tried to open it as project using eclipse in deterrent ways but not working it printed lots of errors what should i do ?


texts:
As first I want excuse me for opening another FBO question. I found alot of them but I still can not manage to get it working. I want to implement a framebuffer class for postprocesing in my 2D Android Applikation. Since it's 2D I do not need a renderbuffer for depth testing. My current code has the problem that nothing gets rendered so the framebuffer is maybe empty. I am doing this steps:

private final int framebuffer[] = new int[1];
private final int mTextureID;
//GLTexture is my Class for drawing textures..
//I can secure that this class works with drawing normal Textures
private final GLTexture mFrame;

//init
public GLPostProcessor()
{
    //create empty Texture
    mTextureID = GLSurf.mTexMng.createNewEmpty();

    //gen Framebuffer
    GLES20.glGenFramebuffers(1, framebuffer, 0);

    //bind
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, framebuffer[0]);

    //set Texture
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, mTextureID, 0);

    //unbind
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);

    //init GLTexture
    mFrame = new GLTexture(-1, false);
    mFrame.setPos(0, 0, 1920, 1080);
    mFrame.mTextureID = mTextureID;
    mFrame.setShader(GLShader.sProgram_PostProcessing);
}

public final void beginRender()
{
    //bind framebuffer
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, framebuffer[0]);

    //reset Viewport and clear
    GLES20.glViewport(0, 0, 1920, 1080);
    GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); //white
}

public final void endRender()
{
    //unbind
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
}

public final void Render()
{
    mFrame.Render();
}

My createNewEmpty() which returns 1 as new Texture ID:

public final int createNewEmpty()
{
    final int texid = getfreeGLID(); //In this case it has the value 1

    if (texid >= MAX_TEXTURES)
        return 0;

    // Bind texture to texturename
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + texid);
    //mTextureIDs is created by glGenTextures()
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureIDs[texid]);

    // Set filtering
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
                           GLES20.GL_NEAREST);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,
                           GLES20.GL_NEAREST);

    // Set wrapping mode
    //is this necessary or not?
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
                           GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
                           GLES20.GL_CLAMP_TO_EDGE);

    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 1920, 1080, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);

    return texid;
}

I already tried a POT colorbuffer (1024x1024 at glTexImage2D() and glViewport()). That did not make a difference for my problem. But i found out, that if i change my shader code to sth. like "Color = Position" my screen gets colored.. so the rendercall is working in some way but the texture seems to be empty..

I think it's obvious but this is how I use the class:

GLPostProcessor glpp = new GLPostProcessor();
//...
glpp.beginRender();
//render some things
glpp.endRender();
glpp.Render();

Thanks in advance and comment if code is missing.


texts: My character gets stuck when It's running on a straight level ground

texts:
My project is an infinite runner that goes right in a straight line. Sometimes when it just runs without jumping the Player stops. Sometimes the Player doesn't stop. When you jump the Player usually stops a lot earlier. I've been trying to fix this, but I can't find the solution.

How I'm doing this is by making the character move to the right all the time with 1 point in the front for ground generating and 1 point in the back for deleting ground. The camera is following the player and the points are going forward at the same pace as the player. The ground is even, but the player always stops. Please help.

Code for generating the ground:

using UnityEngine;
using System.Collections;

public class PlatformGenerator : MonoBehaviour {

public GameObject thePlatform;
public Transform generationPoint;
public float distanceBetween;

private float platformWidth;

// Use this for initialization
void Start () {
    platformWidth = thePlatform.GetComponent<BoxCollider2D>().size.x;
}

// Update is called once per frame
void Update () {

    if (transform.position.x < generationPoint.position.x)
    {
        transform.position = new Vector3 (transform.position.x + platformWidth + distanceBetween, transform.position.y, transform.position.z);

        Instantiate (thePlatform, transform.position, transform.rotation);
    }

}

}

Code for controlling the Player:

using UnityEngine;
using System.Collections;

public class PlayerControl : MonoBehaviour {

public float moveSpeed;
public float jumpForce;

private Rigidbody2D myRigidbody;

public bool grounded;
public LayerMask whatIsGround;

private Collider2D myCollider;

private Animator myAnimator;

// Use this for initialization
void Start () {
    myRigidbody = GetComponent<Rigidbody2D>();
    myRigidbody.velocity = new Vector2(moveSpeed, 0);

    myCollider = GetComponent<Collider2D>();

    myAnimator = GetComponent<Animator> ();
}

// Update is called once per frame
//void Update () {
//  myRigidbody.velocity = new Vector2(moveSpeed, myRigidbody.velocity.y);
//
//  if(Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0));
//  {
//      myRigidbody.velocity=new Vector2(myRigidbody.velocity.x, jumpForce);
//  }
void Update () {

    grounded = Physics2D.IsTouchingLayers(myCollider, whatIsGround);

    if (Input.GetKeyDown(KeyCode.Space))
    {
        if(grounded)
        {
            Jump();
        }

    }

    myAnimator.SetFloat ("Speed", myRigidbody.velocity.x);
    myAnimator.SetBool ("Grounded", grounded);

}

void Jump () {
    myRigidbody.AddForce(new Vector2(0, jumpForce));
    }

}


texts: How should I position and move objects in my 3D world in relation to terrain

texts:
I'm drawing a heightfield as a piece of 3D terrain using the fairly 'dumb' method of drawing triangles, like everyone does when learning this sort of thing. There's no fancy LOD, scenegraphs or other things, it's deliberately simple and low poly because that's the look of the game. A section of X,Y height data is turned into a mesh of triangles and drawn on the screen.

I now want to scroll the heightfield in the Z axis (not the X or Y, I just want to move 'forwards' through it).

I have a player object with a 'camera' attached to it. When the player wants to go 'forwards' should I

keep the player at the same Z position and scroll the terrain towards the viewer to simulate movement
actually move the player in the Z axis and draw the relevant bit of terrain under them (because the camera is 'attached' to the player it looks like they stay in the middle of the screen, and the gameworld and gameplay will limit how far the player can go forwards)

I'm doing the first one at the moment and it works well... until I want to interact with the terrain or place stationary objects on it at specific points. It seems a bit backwards since all the 'moving' objects stay still, and all the stationary objects need to be moved towards the viewer at the same rate as the terrain is. Also the maths to translate the terrain's scrolled amount and the player's pretend location is somewhat complex.


texts:
I'm having trouble showing a simple custom VerticalGroup.

Here's my SideBar class:

public class SideBar extends VerticalGroup {
    final GameManager gameManager = GameManager.instance;
    final Image nextBackground;
    final Image nextImage;
    final Image powerImage;
    final Image powerUp1Background;
    final Image powerUp2Background;
    final Image powerUp3Background;

    public SideBar() {
        super();
        nextBackground = new Image(gameManager.getTexture("bar.next.png"));
        addActor(nextBackground);
        nextImage = new Image(gameManager.getTexture("label.next.png"));
        addActor(nextImage);
        powerImage = new Image(gameManager.getTexture("label.power.png"));
        addActor(powerImage);
        powerUp1Background = new Image(gameManager.getTexture("powerup.bg.png"));
        addActor(powerUp1Background);
        powerUp2Background = new Image(gameManager.getTexture("powerup.bg.png"));
        addActor(powerUp2Background);
        powerUp3Background = new Image(gameManager.getTexture("powerup.bg.png"));
        addActor(powerUp3Background);
    }
}

And here's where I add it to my main Stage:

    TopBar topBar = new TopBar();
    topBar.setY(DonutsGame.WORLD_HEIGHT - topBar.getHeight());
    stage.addActor(topBar);

    SideBar sideBar = new SideBar();
    Gdx.app.log(TAG, "side bar - x,y: " + sideBar.getX() + "," + sideBar.getY() + ", w,h: " + sideBar.getWidth() + "," + sideBar.getHeight());
    stage.addActor(sideBar);

My TopBar class extends Group and is displaying correctly, so I'm not sure what I'm doing wrong with SideBar that's causing it to not show.

The log output shows that the position, and width/height are all 0, which seems incorrect to me according to the vertical group's documentation. Which states that the width/height should be based on the pref. width/height of the children (height based on sum).

I've tried calling validate and layout with no success.


texts: Why hasn't OBJ been extended to support skinning?

texts:
Out of every format I know, the only one that works accross all applications perfectly is OBJ. I think it is an excellent format and I would use it for everything - except it does not support skinning.

I am wondering, why the spec has never been extended to include support for skinning.
It wouldn't require overhauling the format - just add a 'vertex weight' and 'vertex bone id' parameter, and a list of bones and transforms at the end (or perhaps store all skinning data in a seperate file in the same way as material parameters are)

Its frustrating battling with all the other formats, while OBJ is just sitting there lacking this one thing.

Could someone with more industry experience theorise as to why this extension has never been added?


texts: Unity 2d - rigidbody rotating Z axis if hit something

texts: I have problem with my player. I use rigidbody2D on my player and I had fixed rotation on Z, but now i need use rotation with some of my root animation. Ok, i enabled it, but when my player hit something (for example NPC, wall, ...), rotates on the Z axis and falls off. Can you help me? Thanks and sorry for my mistakes.


texts:
Possible Duplicate:
  Is there an algorithm for a pool game?

I think most billard/snooker games have a lot of problems with their physic engines. They are far away from realistic and you can't really enjoy the game (especially when snooker is your hobby :) )

So I want to try to make an own physic engine (and own snooker game). I think the physic engine is the most important part of such a game. So my question is:

Do anybody know an open physic enginge I can start with? Is there any literature about such physic problems?


texts:
A friend and I are working on developing a game engine in C++. He doesn't live anywhere near me, so we use Dropbox to sync our files. I opened his project to test his code, and I kept getting errors saying that the program could not start with an error that stated "This application could not start. 0xc015002." I used a dependency walker to find that ILUT.dll was causing some issues. I have done just about everything suggested on most forums to make ILUT work, and I have not had any success. I've re-downloaded it, put the DLL just about everywhere I could, and I still had issues. We then tried to compile it without Assimp, and the program compiled without errors. This was not the end of our problems though. I made a class to create a primitive cube using OpenGL. When I tested it out, there was no cube on the screen. I had my friend test the program out, and to our surprise, there was a perfectly rendered cube on his screen. So I'm honestly not sure where things could possibly be going wrong. Any help at all would be greatly appreciated. Thank you for taking the time to read this long question. I'll be happy to provide anyone with necessary info needed to help with this question!

My OpenGL version is 4.2. He has an nVidia graphics card, and I have an AMD Radeon graphics card. We are using Visual Studios 2012 as our IDE.


texts:
I've been making a roguelike-style game in HTML5 without using canvas (only divs) with pure JS (fiddle!). I've been trying to enlarge the tile size (font size) while keeping the player centered within the camera. For some reason, when the tile size isn't equal to the map size, the camera will be slightly off.

Note that the 3D effect is on purpose. Without it, the camera is still off center, and I believe it adds some much needed depth to the scene. :D

When tileScale (line 4 in the fiddle) is 9 (very undesirable; the dots on the player's y axis should be aligned, not at a slight angle):

When tileScale is 25 (on point!):

Here's some relevant (trimmed) code:

window.onresize = function(){
    game.viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
    game.viewportHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
    game.windowSize = Math.min(game.viewportWidth, game.viewportHeight);
    // Droid Sans Mono has a ratio of 3:4 (width:height), conveniently.
    // This may be problematic. I'm not sure.
    game.tileWidth = game.windowSize*.6 / game.tileScale;
    game.tileHeight = game.windowSize*.8 / game.tileScale;
}

// Update the camera position (needs help?)
this.updateCamera = function(){
    // Get player coordinates (-.5 because we need to get the player tile center)
    // times the tileWidth plus the game window (inner square) size divided by two.
    var left = ((-game.player.x-.5)*game.tileWidth+game.windowSize/2)+"px";
    var top = ((-game.player.y-.5)*game.tileHeight+game.windowSize/2)+"px";
    game.planeContainer.style.left = left;
    game.planeContainer.style.top = top;
}

How can I ensure that the dots in the center of the screen will be always lined up, instead of on a slight angle? My current evidence suggests that the position of the game.planeContainer object isn't being established correctly.

I know this is a super-tough problem, so any help will be greatly appreciated. Thanks in advance!

(Another fiddle link, in case you skimmed over the first one. :D)


texts: Blur gets displaced compared to original image

texts:
I have implemented a SSAO and I'm using a blur step to smooth it out. The problem is that the blurred texture is slightly displaced compared to the original. I'm blurring using a 4x4 kernel since that was my noise kernel in SSAO. The following is the blurring shader:

float result = 0.0;
for(int i = 0; i &lt 4; i++){
    for(int j = 0; j &lt 4; j++){
        vec2 offset = vec2(TEXEL_SIZE.x * i, TEXEL_SIZE.y * j);
        result += texture(aoSampler, TexCoord + offset).r;
    }
}

out_AO = vec4(vec3(0.0), result * 0.0625);

Where TEXEL_SIZE is one over my window resolution.

I was thinking that this is was an error based on how OpenGL counts the Texel center, so I tried displacing the texture coordinate I was using by 0.5 * TEXEL_SIZE, but there was still a slight displacement.

The texture input to my blur shader, has wrap parameters:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

When I tell the blur shader to just output the the value of the pixel, the result is not displaced, so it must have something to do with how neighboring pixels are sampled.

Any thoughts?


texts: Viewport / Camera Calculation in 2D Game

texts:
we have a 2D game with some sprites and tiles and some kind of camera/viewport, that "moves" around the scene. so far so good, if we wouldn't had some special behaviour for your camera/viewport translation.

normally you could stick the camera to your player figure and center it, resulting in a very cheap, undergraduate, translation equation, like :

vec_translation -/+= speed (depending in what keys are pressed. WASD as default.)

buuuuuuuuuut, we want our player figure be able to actually reach the bounds, when the viewport/camera has reached a maximum translation.

we came up with the following solution (only keys a and d are the shown here, the rest is just adaption of calculation or maybe YOUR super-cool and elegant solution :) ):

if(keys[A])
{
    playerX -= speed;

    if(playerScreenX <= width / 2 && tx < 0)
    {
        playerScreenX = width / 2;
        tx += speed;
    }
    else if(playerScreenX <= width / 2 && (tx) >= 0)
    {
        playerScreenX -= speed;
        tx = 0;

        if(playerScreenX < 0) playerScreenX = 0;
    }
    else if(playerScreenX >= width / 2 && (tx) < 0)
    {
        playerScreenX -= speed;
    }
}
if(keys[D])
{
    playerX += speed;

    if(playerScreenX >= width / 2 && (-tx + width) < sceneWidth)
    {
        playerScreenX = width / 2;
        tx -= speed;
    }
    if(playerScreenX >= width / 2 && (-tx + width) >= sceneWidth)
    {
        playerScreenX += speed;
        tx = -(sceneWidth - width);
        if(playerScreenX >= width - player.width) playerScreenX = width - player.width;
    }
    if(playerScreenX <= width / 2 && (-tx + width) < sceneWidth)
    {
        playerScreenX += speed;
    }
}

i think the code is rather self explaining:

keys is a flag container for currently active keys, playerX/-Y is the position of the player according to world origin, tx/ty are the translation components vital to background / npc / item offset calculation, playerOnScreenX/-Y is the actual position of the player figure (sprite) on screen and width/height are the dimensions of the camera/viewport.

this all looks quite nice and works well, but there is a very small and nasty calculation error, which in turn sums up to some visible effect.

let's consider following piece of code:

if(playerScreenX <= width / 2 && tx < 0)
{
    playerScreenX = width / 2;
    tx += speed;
}

it can be translated into plain english as : if the x position of your player figure on screen is less or equal the half of your display / camera / viewport size AND there is enough space left LEFT of your viewport/camera then set players x position on screen to width half, increase translation (because we subtract the translation from something we want to move). easy, right?! doing this will create a small delta between playerX and playerScreenX.

after so much talking, my question appears now here at the bottom of this document:

how do I stick the calculation of my player-on-screen to the actual position of the player AND having a viewport that is not always centered aroung the players figure?

here is a small test-case in processing:

http://pastebin.com/bFaTauaa

thank you for reading until now and thank you in advance for probably answering my question.


texts: Why do we use 4x4 matrices to transform things in 3D?

texts:
To translate a vector by 10 unit in the X direction, why do we have to use a matrix?

We can just add 10 to the mat[0][0], and we got the same result too.


texts: Where can I find good designers/animators for the graphics of a 2d game?

texts:
Possible Duplicate:
  Where to hire 2D sprite artists?

I've got a little bit of experience in this field already, and I noticed that it's way better to look for animators than graphic designers, because games need explosions, looping sprite sheets, etc. But it would be even better if I could go somewhere and find people with experience in making graphic assets FOR GAMES, not for general markets. Is there some specialized site or something?


texts: I'm making game in JavaScript. I have canvas for drawings and game loop. I'd like to make method readKeyboard, in game loop, to check if there is any pressed key. I don't want to attach event to canvas, because it doesn't fit game loop design. Maybe I should attach this event? What is the best solution?


texts:
I made simple spawner like this:

void Update() {

    if (PlatformPosition.spawnNewPlatform) {
        NewPlatform();
    }
}

public void NewPlatform() {

    if (active) {
        newTransform = transform;
        Instantiate(prefabs[Random.Range(0, prefabs.Length)], newTransform.position, Quaternion.identity);
    }
}

And so it looks like my platform script:

public static bool spawnNewPlatform = true;

void Awake() {
    spriteSize = GetComponent<SpriteRenderer>();
    offscreenX = (Screen.width / PixelPerfect.pixelsToUnit) / 2 + offset;
}

void Update () {

    pos = transform.position;
    posX = pos.x;

    if (posX <= -offscreenX) {

        spawnNewPlatform = true;
    }
    else {
        spawnNewPlatform = false;
    }
}

Now when I start the "game" the spawner create unexpected number of platforms. Sometimes it's 2 clones sometimes it's 10...
I don't understand what is the problem and how to fix it. Is it frame rate issue?


texts: Should independent game developers target older hardware?

texts:
A developer I work with tells me that indie developers should target hardware that is around six or more years old (at max settings). I get the idea that one should allow everyone that wants to play their game to play it at a runnable framerate, regardless of how old their hardware is, but should indie developers limit themselves to using a low-poly art style, or make their games with older hardware in mind, mainly because "most people that play indie games have old hardware?"

Is there any reason to allow your game to run at max settings for very old hardware, even though it would lower the graphical possibilities for people with newer hardware?

Are there any statistics that show that games that reach their upper graphical limits easily on older hardware are more successful than games that push their upper graphical limits higher at the expensive of a 'less-than-the-best' experience for players on older hardware?

Any insight on this will be greatly appreciated.


texts: How does one separate the acceleration due to gravity from other motion in accelerometer input?


texts: Where is the best way to store game stats?

texts:
I am building a small Android game with Unity. Everything is going OK, but I have some things bothering me, that I see no real solution.

The problem

In my game, you build your character as you like, and you can equip him with loot that you acquire as you play the Story Mode. I am currently storing the attributes for each equipment on a database, and the game makes calls to WebServices to get these attributes.

However, this becomes a problem if the user has no internet connection, and wants to play the game. I would like the game to be playable in this case, but I can't think of a good solution.

I could store the data for the current equipment in the device, but what if the user changes the equipment? Any help is widely appreciated.


texts:
I've been struggling for a while trying to figure out the best way to map two players on a single keyboard. Let's consider something generic:

Arrows
Validation
Cancel (optional)
Some common actions shared between the two players (start, reset, etc.)

So far, I used:

P1: WASD + [Space or Tab]
P2: Arrows + [Enter or Return]
Common: R for reset

The problem is that some configuration can be uncomfortable on certain keyboards (especially when there is no keypad). Plus some players like to have the direction on left hand (FPS style) and others on right hand (platformer style). Also SHIFT is usually not a good choice on windows because of the sticky keys feature.

Also I'd like to avoid using a settings screen (kind of heavy for a small game). I guess a config file would be OK, but is there another way to handle this problem that would make every one happy?


texts:
Currently writing a camera component for FNA (basically XNA), and can't for the life of me figure out why my matrix transform isn't working as expected. This is how I calculate my view & projection matrices:
// projection
// WorldSize is something like 16x9, 20x10, etc. Basically the "simulated" world size.
// Zoom is just a float to zoom the camera.
var left = Zoom * -WorldSize.X / 2;
var right = Zoom * WorldSize.X / 2;
var bottom = Zoom * -WorldSize.Y / 2;
var top = Zoom * WorldSize.Y / 2;
const float near = 0;
const float far = 100;
var projection = Matrix.CreateOrthographicOffCenter(left, right, bottom, top, near, far);

and
// view
// Position is the position of my Camera, e.g. (10, 15), (6.51, 16.612), etc.
var position = new Vector3(Position, 0);
var target = position + Vector3.Forward;
var up = Vector3.Up;
var view = Matrix.CreateLookAt(position, target, up);

// Combine them
var combined = projection * view;

This should, by all the sources I've checked, double-checked, and triple-checked, be correct. However when I apply this matrix to my batch or effects it doesn't show anything at all:
// I would expect a white square to be rendered in the middle of the screen. Since WorldSize is
// 16x9 I would expect a 1x1 square to be clearly visible.
var batch = new SpriteBatch();
batch.begin(/* the rest */, combined);
var texture = new Texture2D(Game.GraphicsDevice, 1, 1);
texture.SetData(new []{Color.White });
batch.Draw(texture, Vector2.Zero, Color.White);
batch.End();

// Also tried just rendering lines, shows nothing
var effect = new BasicEffect(graphicsDevice)
{
    VertexColorEnabled = true,
    View = view,
    Projection = projection
};
effect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.DrawUserPrimitives(PrimitiveType.LineStrip, vertices, 0, vertices.Length - 1);

I have checked so many sources and they all do exactly like this. I even tried copy+pasting the matrix source code for a Java project I made some time back that I know works, and that didn't work either so I don't think the Matrix transforms are to blame. Anyone know what I'm doing wrong?


texts: How to detect taps vs tilts in analog stick input

texts:
I'm trying to detect when a player taps vs tilts the analog stick. Ultimately, I'm trying to implement controls like Super Smash Bros. Melee. On top of this, I also want to incorporate an input buffer so the controls aren't so strict.
Implementation
This implementation was before I considered adding input buffering.

Poll for input events via SDL_PollEvent.
Update the game controller state with input events.

As the game controller's state was updated, it would also calculate changes in the analog stick and determine if the player tapped/smashed the stick or not. The game controller object also determined if face buttons were being pressed or held.
This implementation seems to work, but it doesn't maintain the order of inputs.
Q. Does the implementation above sound like a good way to detect taps vs tilts?
Q. If I used an input buffer, would it make sense to scan the buffer and label a sub-range of inputs as a tap or tilt?

With that, a state machine could respond to the label instead of the raw analog stick events.
This also helps with large amounts of analog stick events.

Q. Is it a bad idea to store the state of the game controller in an input buffer instead of individual analog stick events and button events?


texts: I am developing a Windows Phone 7 game using XNA 4.0 which I plan to later port to iOS and android using Monotouch and Monodroid. My question is how to determine what texture size should I include? This is because the in-game objects that utilize the textures dont care about the actual texture size and just re-size them. Windows phone by its own exists in multiple resolution variants. Should I pick the highest resolution emulator and then measure the sizes of my in-game objects, and then re-size their respective textures to be the same?


texts:
I am working on a network game project in python which we want to keep synchronized. I would assume we should use Network Time Protocol to cater for different levels of lag.

That being the case, is there an implementation for Network Time Protocol in python?


texts: Why do we get artifacts on objects rendered using depth node + depth render camera on Android?

texts:
I've encountered and error I can't seem to find online. I get it on all the water shaders I test, and any thing else that I have a depth node + depth render script on the camera for.

I'll share a bit more information about what we're doing in the game.

This artifact changes as we pinch-zoom on Android. So I wonder if the Render Depth script doesn't like that we are changing the zoom/depth for some reason? Maybe it has something to do with how we are handling out cameras movement in Unity?
It is adding more depth information somehow, because the shader is reacting to the artifact. Depending on where the line cuts, the other details will warp to meet it.
This problem doesn't show on all phones. Mostly Android, newer versions, but wasn't showing up on an older S5.

Some other things I've tried within the shader are different shader models 2.5 & 3.0.

Any suggestions on tests I can do, or ideas on what might be the issue?

Here are the nodes I use for the opacity / depth

Currently we've got the controls on one camera, and the depth script on another.
Update, I've found someone talking about a similar sounding problem, but I'm not sure how to do this myself.

Thread here -- https://forum.unity.com/threads/depth-texture-not-working-on-some-devices.319568/

"If I set my RenderTexture Depth format to 16 bits instead of 24 bits it's working!" -- How do I do this? Can I edit my Camera script to do this?

The Camera script seems simple, but I'm not sure how to make it render 16bits instead of 24 bits to test this out.

// Toony Colors Pro+Mobile 2
// (c) 2014-2018 Jean Moreno

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

// Makes the Camera render a depth texture.
// This is needed for some water shaders that use depth-based effects such as edge intersection.

[ExecuteInEditMode, RequireComponent(typeof(Camera))]
public class TCP2_CameraDepth : MonoBehaviour
{
 public bool RenderDepth = true;

 void OnEnable()
 {
  SetCameraDepth();
 }

 void OnValidate()
 {
  SetCameraDepth();
 }

 void SetCameraDepth()
 {
  var cam = this.GetComponent<Camera>();
  if (RenderDepth)
   cam.depthTextureMode |= DepthTextureMode.Depth;
  else
   cam.depthTextureMode &= ~DepthTextureMode.Depth;
 }
}

Thanks!


texts:
I've been experimenting with Unity3D 4.3's 2D features.  I've created a simple prototype game to learn how Unity works, how to create sprite animations, collisions and all the basic things.  My project compiled for PC was approximately 23MB.

The game includes one larger bitmap for a background (originally 1MB JPEG). The player spritesheet was black and white with almost no details. So all the assets had (in their original, compressed form) no more than 2-3 MB.  I ended up with one large executable file (about 10MB) and a folder with .dll files and assets (5-6MB).

Can that be reduced?

My experience with C# WinForms code makes me believe that executables and DLLs grow that big only when binary data was involved (images, sound, etc).  Is that the case with Unity?  I am interested in developing 2D applications for Android and iOS, where low total app size is a priority.


texts:
I have terrain separated by chunks and I would like to put environment (For example, rocks, trees, etc..) in each chunk randomly.

My question is related to how to implement such system in OpenGL.

What I have tried:

Solution: Draw the environment with instancing once for all the terrain (not a specific chunk)

Problem: I except the chunk to sometimes take a bit to load and because I am using threads the environment will appear as floating.
Solution: Draw the environment with instancing for each chunk.

Problem: To draw each chunk, I will need to bind the VBO for the chunk, draw the chunk, bind the VBO for the environment (and the VAO probably) and draw it.

I don't want to put so many glBindBuffer functions because I heard it is slow (Please correct me if I am wrong)
(Not tried) Solution: Somehow merge the vertices of the terrain with its environment and draw them together.

Problem: My terrain is drawn with GL_TRIANGLE_STRIP so this is a first problem, the second problem(?) is that I don't know how well it will function (talking speed).

I tried looking up solutions on the internet but didn't seem to find any that relate to chunks.

Anyone know how other games that uses chunks do that? Is there a way to do it without causing a lot of speed decrease?


texts: How do I come up with the game mechanics for a puzzle game?

texts: I want to make a puzzle game, but I don't know how to start. I have observed that each puzzle game has a core mechanic that enables opportunity for numerous puzzles. I'm not sure how to think of ideas. I was wondering how to come up with ideas for my game. I do not want any of your ideas because I want the game to be original.


texts: Finding point in NavMesh meeting criteria

texts:
I have build my own NavMesh representation, generation and path finding on it in c++ and it works very well so far. However i struggle archiving this seemingly easy task:

I want to find a random point within the NavMesh meeting some criteria or to be a bit more general I want to extract a subarea of my NavMesh which fulfills some requirements.

These are simple things like "get a random point which has at least distance x to the nearest wall" or "find a point which is not visible from point x". I need these for AI tactics or spawning enemies not to near to the player.

Picking a random point in the NavMesh and testing if this requirement is true is easy but not efficient if only a small subarea is valid and I end up picking and testing random points forever.

I should mention that a subarea cannot be described by a subset of polygons in the NavMesh as these have nothing to do with these criteria. For example the area with all points with a minimal distance to a wall will surely split most polygons in half.

To summarize my question:

What is a efficient way to describe a subarea of a NavMesh meeting some criteria. Are there efficient methods of finding a point inside a NavMesh which fulfills given criteria without randomly picking one and testing it?


texts:
I need to parse a SVG path expression like

m8,295c-4,-292 441,-291 446,-26c5,265 440,263 442,-9

and have a way of iterating over it in [0 ... 1]. I looked into Apache Batik but it doesn't seem to have this specified function. I also looked at Salamander SVG but in the end the path is a wrapper around java.awt.geometry, which is not ported to android so I can't really use it.


texts: XNA tiling a sprite with a camera.viewmatrix in the Draw method

texts:
I'm looking for help fixing a small problem that I have with my XNA game project.

I currently have:

spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend,
            null, null, null, null, camera.ViewMatrix);
        spriteBatch.Draw(Stone, TestPosition, Color.White);
        spriteBatch.Draw(Person, playerPosition, Color.White);
        spriteBatch.End();

and

spriteBatch.Begin(SpriteSortMode.Deferred,
              null, SamplerState.LinearWrap, null, null);
        spriteBatch.Draw(Grass, grassPosition,
             new Rectangle(0, 0, Grass.Width * 60, Grass.Height * 1),
             Color.White);
        spriteBatch.Draw(Stone, StonePosition,
             new Rectangle(0, 0, Stone.Width * 60, Stone.Height * 10),
             Color.White);

        spriteBatch.End();

I am looking to combine these two spriteBatch so that the stone and grass in the second spriteBatch will be affected by the viewmatrix.

I have tried:

spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend,
                SamplerState.LinearWrap, null, null, null, camera.ViewMatrix);
            spriteBatch.Draw(Grass, grassPosition,
                 new Rectangle(0, 0, Grass.Width * 60, Grass.Height * 1),
                 Color.White);
            spriteBatch.Draw(Stone, StonePosition,
                 new Rectangle(0, 0, Stone.Width * 60, Stone.Height * 10),
                 Color.White);
            spriteBatch.Draw(Stone, TestPosition, Color.White);
            spriteBatch.Draw(Person, playerPosition, Color.White);
            spriteBatch.End();

However when I go to run the code, I get the following error:

XNA Framework Reach profile requires TextureAddressMode to be Clamp when using texture sizes that are not powers of two.

I hope that someone can help me achieve this,
Thank You.


texts:
As new players enter a game, they are given a location on a large grid. The first player is given the location in the center.

Now, how should the second player be placed? Then, the third and so on?

New players should be placed reasonably near some other players, but not so close as to cause bunching.

My current thinking is to trace a clockwise spiral around the first player, gradually moving further and further out from that initial point. But I keep thinking this must have been done before and that a general solution must exist.

This is for a strategy resource game (similar to CoC or Throne Wars etc).

How do I do this?


texts:
I'am starting to develop a 2D game with snake or worm.

My question now is: When my snake reaches the right edge the world should move. (Like in this game) My first thought was to implement a camera and to create a huge image for the world. (e.g 4096 x 512). So I only have to move the camera to solve the problem.

Is that a good solution?


texts: How to pass a custom array of data to a shader

texts:
I want to know how to pass an array of data (it will be an encoded map, actually) to the fragment shader so I can query it as an array.

AFAIK this is sadly not implemented in unity, so I'm looking for a nice workaround.

I've thought on using a texture but I don't really know how to query the data without running into precision errors (i.e. query a single texture pixel as if it were an array). It is actually really important that it never fails because of precision, and I rather not rely on the internal floating point implementation.


texts: Orientation is off when nearing 90 degrees rotation

texts:
Context: I am using Vive Trackers to track the head of a user. It is not a Vive headset and I am restricted to the TrackingUniverseRawAndUncalibrated, which only guarantees that the Y axis will be UP. The pose (matrix) of the tracker is therefore not aligned with my axis (except for the Y) and does not take into account the orientation of the tracker on the head of the user.

First I convert the measure pose (Pm) to my axis system, which differs from the Vive one by R, to get the corrected pose (Pc):

Pc = R * Pm

(those are all rotation matrix)

Then I obtain the head pose (Ph) using the corrected pose and the calibrated pose (Pca), which is the corrected pose when facing exactly forward. This is to take into account the tracker's position on the head.

Ph = Pc * inverse(Pca)

Finally I extract the Euler angles for my needs. And it looks fine when looking straight ahead or near it: changes in yaw, pitch and roll do what we expect them to do.

But things start to be off when getting to a heading near -90 or 90 degrees. The image starts to move as if there were changes in the pitch and roll and any small head movements then has big effects on the pitch/roll of the image. In other words, the farther you look from straight forward, the more the orientation is wrong.

What am I doing wrong here?


texts:
A tutorial's code from LazyFoo wonderful place's 01_hello_SDL page doesn't show a white form, but a desktop's screen, like a screenshot. Something like:

The code:

//Using SDL and standard IO
#include <SDL2/SDL.h>
#include <stdio.h>

//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;

int main( int argc, char* args[] )
{
    //The window we'll be rendering to
    SDL_Window* window = NULL;

    //The surface contained by the window
    SDL_Surface* screenSurface = NULL;

    //Initialize SDL
    if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
    }
    else
    {
        //Create window
        window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
        if( window == NULL )
        {
            printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
        }
        else
        {
            //Get window surface
            screenSurface = SDL_GetWindowSurface( window );

            //Fill the surface white
            SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );

            //Update the surface
            SDL_UpdateWindowSurface( window );

            //Wait two seconds
            SDL_Delay( 2000 );
        }
    }

    //Destroy window
    SDL_DestroyWindow( window );

    //Quit SDL subsystems
    SDL_Quit();

    return 0;
}

Putting PumpEvents(); or while(SDL_PollEvent(&event))... didn't work, unfortunately.

The machine's characteristics:

CPU: i7 M620
GPU: Intel Core Processor Integrated Graphics Controller
GPU Driver: i915
RAM: 8GB
OS: KDE Neon 5.15.4 64bit, 4.15.0-47 Kernel, fully updated