texts: Confused about Max Vertex Uniform Vector limit

texts:
While coding my WebGL app I've encountered an interesting phenomena:

On my first PC (with GPU Radeon HD 5850), BrowserLeaks (link) tells me that in my browser - Google Chrome Version 36.0.1985.143m the Max Vertex Uniform Vectors value equals 1024 - which is true, when I try to create inside the shader an attribute array bigger than 1024, the browser throws an error: too many uniforms, which f.e. in my case let's me draw about 85 simple cubes in a single draw call.

Meanwhile on my other PC (with GPU Intel X3100) with Opera-Next Version 12.15 installed, where BrowserLeaks shows a value 4096 next to the Max Vertex Uniform Vectors field, I can init an array of size 250 000 and even bigger, I can draw 20 000 cubes in a single draw call and everything works fine (except a very low framerate).

So now my question is: Why those numbers varies so much, why in the second case the upper limit value does not seem to be valid? How would I find the true upper limit value (and read it inside my WebGL app at the runtime)?

EDIT: Ok, I've found out how to get this parameter inside a WebGL app: gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS), but the question now is how would I adapt it to shaders...


texts: Destroy GameObject as an Array of Transform instantiated destroying the whole array

texts:
I am trying to destroy a GameObject with the Destroy() method, but when I call it the whole array is destroyed, not just that element.

//Instantiating the prefabs
public Transform[] blue;

foreach (Vector3 vec in xyid)
    {
        //vec.z is used as the object id
        Instantiate(blue[vec.z], new Vector3(vec.x, vec.y), Quaternion.identity);
    }

This is another script, I put this on every prefab

void Update () {

    if (Input.GetMouseButtonDown(0))
    {
        Destroy(gameObject);
    }

}


texts: Rotating vector based on the position of another vector?

texts: Sorry for terrible picture but lets say we have a unit vector A and we have vectors B and C. So for vector B I would want to rotate in a positive direction because the vector is "above A" and for vector C i would want to rotate downwards. Is there an easy way of detecting which way to rotate?


texts: Unity RigidBody not rebounding as expected on low-impact collisions

texts:
I have a Rigidbody2D with a CircleCollider2D, on which I display a sprite of a circle. This Rigidbody can be "shot" in my game.

I also have 4 rectangular BoxCollider2Ds on the edges of the game screen.

When I shoot the circle, it rebounds fine from the rectangular colliders, except for cases when the impact velocity normal to the rectangular collider's surface is very small. In that case, the rebound velocity in that direction is somehow zero.

Here is the circle's RigidBody2D and CircleCollider2D setup:

Here is the BoxCollider2D of the rectangular collider:

The material "New Physics Material 2D" attached to the ball and the BoxColliders has Friction set to 0 and bounciness set to 1:

Here are two gifs, the first one demonstrating how it works (correctly) in most cases, and the second one demonstrating what happens on a low velocity impact. The "choppiness" of these gifs is due their "giffy" nature. In my game, the movement is smooth.

I'm wondering why, on the low-velocity impacts, the ball doesn't rebound in the same way as on the high-velocity impacts (i.e, by the outbound angle = inbound angle rule)?

----------------------------

Edit:

----------------------------

I stepped into the circle's void OnCollisionEnter2D(Collision2D collision) method, and, sure enough, on the very slow collisions, the collision.otherRigidbody.velocity had a zero-component for the slow velocity of the incoming collision (so depending on whether the impact's x- or y-velocity was slow, the respective component of the resulting velocity was, for whatever reason, set to 0).

Oddly enough (at least for me - I am still not completely familiar with all of Unity's in's and out's), the collision.relativeVelocity had been updated to hold the correct resulting velocity of the impact. Thus, by adding following code to the OnCollisionEnter2D method, I am able to handle the collision correctly, even on low-impact collisions:

if (collision.otherRigidbody.velocity.x == 0)
{
    collision.otherRigidbody.velocity = new Vector2(collision.relativeVelocity.x, collision.otherRigidbody.velocity.y);
}
if (collision.otherRigidbody.velocity.y == 0)
{
   collision.otherRigidbody.velocity = new Vector2(collision.otherRigidbody.velocity.x, collision.relativeVelocity.y);
}

While this seems to solve the issue I am experiencing, it doesn't seem to me that I should need to be doing this...


texts: How can I easily create cloud texture maps?

texts:
I am making 3d planets in my game; these will be viewed as "globes". Some of them will need cloud layers. I looked at various Blender tutorials for creating "earth", and for their cloud layers they use earth cloud maps from NASA.

However I will be creating a fictional universe with many procedurally-generated planets. So I would like to use many variations.

I'm hoping there's a way to procedurally generate cloud maps such as the NASA link. I will also need to create gas giants, so I will also need other kinds of cloud texture maps.

If that is too difficult, I could fall back to creating several variations of cloud maps. For example, 3 for earth-like, 3 for gas giants, etc.

So how do I statically create or programmatically generate such cloud maps?


texts:
I am trying to build content(a text file contains list of triangles vertices) for an XNA application through a custom pipeline importer. It works ok. But when number of triangles gets near 1m(in this case 946612 triangle & 303112 unique vertex) I get this error:

"XNA Framework HiDef profile supports a maximum VertexBuffer size of 67108863, but this VertexBuffer is 68847328."

1- Is this number in bytes or just the number of vertices? I assume bytes which would make it ~1.3m vertex.

2- The VertexBuffer size, Does it refer to the MeshContent Position collection or the GeometryContent VertexContent or the Model.Meshes[i].MeshParts[i].VertexBuffer.VertexCount?

The reason is that the MeshContent Position collection holds unique vertices whereas the other, all of the triangles vertices which might have duplicates. ex. For a simple cube, the Position collection holds 8 vertex and the VertexContent have 36(12 tri*3) vertex which have duplicates. Once the MeshBuilder.FinishMesh() method is called it reduces to 24 vertex. Why 24? And this is exactly the number that Model.Meshes[i].MeshParts[i].VertexBuffer.VertexCount shows at the runtime.

3- Also, does this error regards only one mesh exceeding certain limit in vertex size or the whole Model.Meshes, or could be both?

Any help to understand how these things work is appreciated.


texts: What are "world space" and "eye space" in game development?

texts:
I am reading a book about 3D concepts and OpenGL. The book always talks about world space, eye space, and so on.

What exactly is a world inside the computer monitor screen?
What is the world space?
What is eye space? Is it synonymous to projection?


texts:
I have a player with rigidbody and it has a tag as Player .

I have set a sphere collider as trigger with script

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

public class Addforce : MonoBehaviour {

public int speed;

void OnCollisionEnter(Collision other)
{
    if (other.gameObject.CompareTag("Player"))
    {
        other.gameObject.GetComponent<Rigidbody>().AddForce(Vector3.up*speed);
    }
}

}

I have set speed force to 100.

But when player enters the collider, nothing happens. It doesn't tag it.


texts: How to move 2D objects based on mouse movement with pointer locking?

texts:
I'm using pointer locking for a 2D game (where you perform calculations based on the delta in mouse positions from frame to frame). I'm having some basic math/logic issues with accomplishing what I want.

I'd like the player to be able to send the character in the direction they last moved their mouse (so if they stop moving the mouse, the character continues to travel in the direction they last moved in).

The issue I'm experiencing is the movementx and movementy values are integers. If the player moves the mouse quickly so that from one mousemove event to the next many pixels are traversed, the direction to move the character is reasonably precise. Every other scenario results in the last movement having movementx or movementy only being -1/0/+1. If the character only moves based on the last movement of the mouse, it very often only moves in one of 8 directions.

How can I be more precise than 8 directions even on slow/short mouse movements while ensuring the last bit of movement of the mouse is always what's being used?

My first thought was to average out the last n movement values, but that can easily result in the character not always moving in the direction the mouse moved last. I've not really had too many other thoughts though, so I came here for assistance.


texts: Can a UIKit application co-exist with a Unity game as a single application?

texts:
I have a typical UIKit application with three buttons - one opens an RSS feed in a UITableView, the second opens some kind of gallery view, and the third opens a Unity 3D game.

Is it possible and how easy it is to support both in one application?


texts: Why is the for loop more efficient than the for each loop in Unity?

texts: During a Unity talk about performance, the guy told us to avoid for each loop to increase performance and use the normal for loop instead. What's the difference between for and for each in implementation point of view? What makes for each inefficient?


texts: Defining a coordinate system for player residing in another coordinate system

texts:
I'm making a game and I wanted to simplify some code by taking advantage of linear algebra. I'm a little stuck.

Let's say the player (green triangle) resides in a coordinate system where the x-axis is the gray arrow pointing right, and the y-axis is the gray arrow pointing down (y increases as it goes down, but that's besides the point).

I want to define some basic movements for my player, like forward, backwards, and strafe. Currently, I have these movements defined with respect to the the gray coordinate system. So if we take the first green triangle for example, giving it the "forward" command would correctly move it to the right.

However, I want these commands to act with respect to the coordinate frame of the player. For example, giving the "forward" command to the second green triangle would move it up with respect to the gray coordinate system, but it currently just moves right.

I tried accomplishing this by defining an arbitrary coordinate system on the player.

$$\textbf{x} = (1, 0)^T$$

$$\textbf{y} = (0, 1)^T$$

Whenever the player rotates $\theta$, I compute the new axes for the player.

$$\textbf{x'} = R(\theta)\textbf{x}$$

$$\textbf{y'} = R(\theta)\textbf{y}$$

Now, let's say I have some velocity vector $\textbf{v}$ that is added to the current position $\textbf{p}$. The velocity vector for the "forward" action would be $(s, 0)$ for some speed $s$.

I tried computing $$\textbf{p'} = \textbf{p} + (\textbf{x'} \cdot \textbf{v}, \textbf{y'} \cdot \textbf{v})^T$$ but this is giving some nonsensical results.

So, I'm confused about what it means to define a arbitrary coordinate system with respect to some object (which rotates and translates with the object), that resides in another static coordinate system. I'm not sure if I'm using the right vocabulary here, so please correct me if I said anything wrong.

And out of curiosity, can we model this as a “change of basis”? I’m guessing no since the transformation can be nonlinear.


texts: DirectX9 Drawing Sprites out of place due to offset

texts:
This is my very first time into DirectX. Im trying to make a simple 2D game, just for learning the basics. And i've achieved that. The next step is to draw an animation using sprites.

For that, i downloaded SpriteBuddy, a very simple and user friendly software that helps you creating the metadata for your spritesheet.

Ok, now, the problem im having is that, the metadata that i get from spritebuddy (and i know is not the spritebuddy data that is wrong because i downloaded a few more software and the result was the same) come with a offset for every sprite.

Now, when im drawing, i said, lets add the offset to the position of the sprite, that should do it. Annnnnd it didnt, so i started to manualy change the metadata to see how bad was it. The result was that on the y axis, if you doubled the ammount in the metadata, the drawing was a lot less messy.

Is there something im doing wrong?

SpriteData* metadata = this->m_pXMLTraductor->getSpriteDimension(numFrame);//the number of the frame we want the dimensions
RECT temp = metadata->position;
D3DXVECTOR3 vCenter(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 vPosition(this->vPosition.x + this->metadata->offset.x, this->vPosition.y + (metadata->offset.y*2) , 0.0f);

this->m_pSprite->Begin(D3DXSPRITE_ALPHABLEND);
this->m_pSprite->Draw(
    this->m_pTexture->GetTexture(),
    &temp,
    &vCenter,
    &vPosition,
    D3DCOLOR_COLORVALUE(1.0f, 1.0f, 1.0f, 1.0f));
this->m_pSprite->End();
long long cont = 0;
this->numFrame++;
if (this->numFrame > this->m_pXMLTraductor->spriteCounter()){
    this->numFrame = 0;
}

This is how i render the model.

Is there any other way to do this? Srry about my english. Im working on it too ^^


texts:
I have been working on a 2D physics engine for my A Level computing project and I am having trouble calculating the angular velocity from a collision. I have managed to workout each objects linear velocity and create a collision manifold containing the collision points relative to each of the 2 objects involved in to collisions centre of mass (0, 0) along with the overlap etc. I also know each objects mass, speed etc.
I have been looking for a couple weeks now at every equation I can find and non of them seem to work returning incredibly high numbers for normal collisions.
My current algorithm pulled from an article in the game development section on tuts+ (linked here) is like so:

objectArray[i].angularVelocity += objectArray[i].inverseMass * CrossProduct(collisionInfo.collisionPointB, impulse);
objectArray[ii].angularVelocity += objectArray[ii].inverseMass * CrossProduct(collisionInfo.collisionPointA, impulse);

Could someone please explain how I can calculate the change in angular velocity and give me some example values for the equations as mine are probably in the wrong scale or something.

Thank you for any help,
Andy A

Other things to note, this engine is written in C# for XNA so if there are any language specific optimisations they have to work with C#, thank you.


texts: Best way to manage thousands of objects in an multiplayer online game?

texts:
I'm currently planning to develop a real-time multiplayer online game, using the Google Maps API on Android. I thought about having survival-like game play, where you collect resources to build yourself up :)

The players should be able to build structures (houses, shelters, walls, etc.). There should also be random spawned objects, like trees or caverns. There will be many players in a multiplayer game, so there will be many of these objects. I thought about storing all of these objects in a server-based database. Every entity will get an ID and coordinates for their position.

Every player should be able to access and see those buildings, but I can't draw them all at once; I can't even calculate the distance for every structure or object - that just would make the game really slow. At some point, it would crash.

I need a way to manage, draw and calculate all of the structures and objects (which will be stored in my database), when the player is near their saved position. I googled a bit and asked some nice guys in the game development chat; they told me about some methods, like spatial mapping and quad trees. Those would be easy to implement, and the Google Maps API already supports quad trees with coordinates and latitude/longitude markers.

Is this the best way to achieve what I want, or is there a better way to manage, draw and calculate thousands of objects?


texts: Game based on Ajax polling for 12 players

texts:
I am planning on writing a small browser game.

The webserver is a shared server, with no root / install possible.

I want to use AJAX for client/server communication. There will be 12 players.

So each player would be polling the server for the current game status every X milliseconds (let's say 200ms). So that would be 200ms x 12 players x 5 = 60 requests per second

Can Apache handle those requests?

What might be the bottlenecks when using this attempt?


texts: What are some examples of MMOs with small development teams?

texts:
I'd like to see a list of MMOs with small development teams in order to better understand where small teams have found a place for themselves.

While examples of MMORPGs are of interest, so are games focusing on socializing, trade and commerce, city or empire building, crafting, exploration, strategy and so on.  Any shipping game supporting between, say 800 and 10,000 simultaneous players belongs on this list.


texts: CPU Usage on the UI thread Warning - XNA WP7.1

texts:
When I run the Store Test Kit's profiler against my game, I get a warning that says something along the likes of "Very high CPU usage on the UI thread for operations other than frame drawing."

According to the library I am using, I am still getting around 59-61 fps when I test it on a WP8, WP7.8, and a first gen WP7.5 device.

Should I be concerned? If I were to use Tasks or Parallel, does it throw it off to another thread? Or is this simply just a matter of optimizing my code.


texts: Bullet pattern isn't behaving as expected

texts:
I have a boss that's supposed to continuously shoot five streams of bullets, each at a different angle. It starts off just fine, but doesn't seem to want to use its entire array of bullets. No matter how large I set the length of bulletList, the boss simply stops shooting after a couple of seconds, then pick up again shortly. Here's what I'm using to generate the pattern:

Vector3 direction = new Vector3(0.5f, -1, 0);

for (int r = 0; r < boss.gun.bulletList.Length; r++)
{
   if (!boss.gun.bulletList[r].isActive)
   {
      boss.gun.bulletList[r].direction = direction;
      boss.gun.bulletList[r].speed = boss.gun.BulletSpeedAdjustment;
      boss.gun.bulletList[r].position = boss.position;
      boss.gun.bulletList[r].isActive = true;
      break;
   }

}
direction = new Vector3(-0.5f, -1, 0);
//Repeat with four similar for loops, to place a bullet in each direction

It doesn't seem to matter if the bulletList length is 1000 or 100000. What could be the issue here?

EDIT: This is the code that removes a bullet, when it goes out of bounds. It is inside Bullet.Update()

if (position.X > 950 ||
position.X < -950 ||
position.Y > 570 ||
position.Y < -570)
isActive = false;

This is the code that removes a bullet on contact with the player ship:

for (int i = 0; i < boss.gun.bulletList.Length; i++)
{
   if (boss.gun.bulletList[i].isActive)
   {
      boss.gun.bulletList[i].Update(timeDelta);

      if (!ship.invincible)
      {
         bulletSphere.Center = boss.gun.bulletList[i].position;
         if (bulletSphere.Intersects(shipSphere))
         {
             boss.gun.bulletList[i].isActive = false;
             ship.health -= boss.gun.damage;
         }
      }
    }
}

And just for safe measure, here's the code that draws the bullets:

for (int j = 0; j < boss.gun.bulletList.Length; j++)
{
   if (boss.gun.bulletList[j].isActive)
   {
      Matrix bulletTransform = Matrix.CreateTranslation(boss.gun.bulletList[j].position);
      DrawModel(boss.gun.bulletModel, bulletTransform, boss.gun.bulletTransforms);
   }
}

EDIT: It would appear that a large number of bullets are getting "stuck" on the boss. That is, they draw at boss.position, and never move.


texts: About Alpha blending sprites in Direct3D9

texts:
I have a Direct3D9 application that is rendering ID3DXSprites. The problem I am experiencing is best described in this situation:

I have a texture that is totally opaque.
On top of it I draw a rectangle filled with solid color and alpha of 128.
On top of the rectangle I have a text that is totally opaque.
I draw all of this and get the resulting image through GetRenderTarget call.
The problem is that on the resulting image, on the area where the transparent rectangle is, I have semi transparent pixels. It is not a problem that the rectangle is transparent, the problem is that the resulting image is.

The question is how to setup the blending so in this situation I don't get the transparent pixels in the resulting image?

I use the sprite with D3DXSPRITE_ALPHABLEND which sets the device state to D3DBLEND_SRCALPHA and D3DBLEND_INVSRCALPHA. I tried couple of combinations of SetRenderState, like D3DBLEND_SRCALPHA, D3DBLEND_DESTALPHA etc., but couldn't make it work.

Thanks.


texts:
I've got this class to store spells for my game
[Serializable]
public class Spell
{
    public SpellComponents component;
    public SpellSequence sequence;
    public float delay;
    public Vector3 offset;

    public List<Spell> next = new List<Spell>();

}

but always get warnings like this
Serialization depth limit 7 exceeded at 'Magic.SpellSystem::Spell.next'. There may be an object composition cycle in one or more of your serialized classes.

Spells are made in a node based editor and can branch off like this

How can i fix this?


texts: What methods are there for representing 3D terrain?

texts: I'm making a terrain system which needs to be procedurally generated and would like to know my options. So far I know of: Height-field terrain, Vector-field terrain, and Voxel terrain. Is there anything missing from that list?


texts: How do I make the camera aware of the position of the object it is tracking?

texts:
I'm making a 2D game with a Camera that tracks GameObjects (usually the player). At the moment, a GameObject holds a RenderingComponent.

struct GameObject {
  std::shared_ptr<RenderingComponent> renderingComp;
};

The RenderingComponent holds a CameraMotionTarget. The CameraMotionTarget is a rectangle represented by a center and half size.

using CameraMotionTarget = Math::RectCS<float, Math::Dir::RIGHT, Math::Dir::UP>;

struct RenderingComponent {
  virtual void update() = 0;
  virtual const CameraMotionTarget *getMotionTarget() const = 0;
};

struct RenderingComponentImpl final : RenderingComponent {
  void update() override {
    //modify target and do other stuff
  }

  const CameraMotionTarget *getMotionTarget() const override {
    return &target;
  }

  CameraMotionTarget target;
};

The CameraMotionTracker stores a const CameraMotionTarget * to the object in the RenderingComponent and moves the Camera according to the CameraMotionTarget.

struct CameraMotionTracker {
  glm::vec2 getMotionTargetPos(CameraProps) {
    //calculate the target position of the camera to keep the target
    //well within the window
  }

  const CameraMotionTarget *target;
};

struct Camera {
  void update() {
    const glm::vec2 targetPos = motionTracker.getMotionTargetPos(properties);
    const glm::vec2 newPos = mover.getPos(properties, targetPos);
    properties.pos = newPos;
  }

  CameraProps properties;
  CameraMotionTracker motionTracker;
  CameraMover mover;
};

This gets the job done. When the player moves, the camera moves smoothly to keep the player on the screen. If I wanted this to be safer, I could use an std::shared_ptr and an std::weak_ptr but that's not why I'm here. The reads and writes to the CameraMotionTarget need to be synchronized. This is easy in my single threaded game but what if I wanted more threads? I'd like the RenderingComponent to somehow call a function on the CameraMotionTracker but I don't know how.

Ideally, the CameraMotionTracker should only be aware of a rectangle and the RenderingComponent should only need to know that it can be tracked and unaware that it is being tracked. My current design is decoupled but unsafe. So my question is:

How do I architect a safe, decoupled, system where a camera tracks a rectangle?


texts: What are "free vertex indices" in WebGL 2 and how do they relate to geometry shaders?

texts:
In January Notch tweeted about WebGL 2:

WebGL 2 is happening. Bye, compatibility! Hello, 3d textures and pixel buffers!
oh god it's got free vertex indices in the shader. That is basically a geometry shader.
.. which is great considering I'm rendering like five triangles..

What are these "free vertex indices" and how do they relate to geometry shaders? I'm new to all this and my google-fu is failing me on this occasion.


texts: Rendering Tic Tac Toe Cross and Circle in libGDX

texts:
I am new in LibGDX. For learning purpose, I am creating TicTacToe and I spent two days to figure out what went wrong with rendering the cross and circle. Whenever I click on the cell, the cross and circle blinking at the same time. It is supposed to print alternately. What I did wrong in the code?
Here is the code

package com.mytictactoe;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;

public class MyTicTacToe extends ApplicationAdapter {

    private static final int MAX_FINGERS = 2;

    SpriteBatch batch;
    Texture tile, circle, cross;
    Vector3 mouse;
    OrthographicCamera camera;

    enum Tile { EMPTY,  CROSS,  CIRCLE  }

    final int WIDTH = 480;
    final int HEIGHT = 600;

    int tileSize;
    int boardOffset;
    Tile[][] tiles;
    Tile currentPlayer = Tile.CROSS;

    @Override
    public void create() {
        tiles = new Tile[3][3];
        tileSize = WIDTH / tiles[0].length;
        boardOffset = (HEIGHT - tileSize * tiles.length) / 2;

        camera = new OrthographicCamera();
        camera.setToOrtho(false, WIDTH, HEIGHT);

        batch = new SpriteBatch();
        tile = new Texture("tile.png");
        circle = new Texture("circle.png");
        cross = new Texture("cross.png");
    }

    public void update(float dt) {

    }

    @Override
    public void render() {
        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        //processing user input
        for (int i = 0; i < MAX_FINGERS; i++) {
            if (Gdx.input.isTouched(i)) { //using polling
                mouse = new Vector3();

                mouse.x = Gdx.input.getX(i);
                mouse.y = Gdx.input.getY(i);

                camera.unproject(mouse);

                if (mouse.y > boardOffset
                        && mouse.y < boardOffset + tileSize * tiles.length) {
                    int row = (int)((mouse.y - boardOffset) / tileSize);
                    int col = (int)(mouse.x / tileSize);

                    tiles[row][col] = currentPlayer;
                    currentPlayer = (currentPlayer == Tile.CROSS)
                            ? Tile.CIRCLE : Tile.CROSS;
                }
            }
        }

        batch.begin();
        for (int row = 0; row < tiles.length; row++) {
            for (int col = 0; col < tiles[0].length; col++) {
                if (tiles[row][col] == Tile.CIRCLE) {
                    batch.draw(circle,col * tileSize,
                               row * tileSize + boardOffset,
                               tileSize,    tileSize);
                    System.out.println("Circle is printed");
                } else if (tiles[row][col] == Tile.CROSS) {
                    batch.draw(cross,col * tileSize,
                               row * tileSize + boardOffset,
                               tileSize,tileSize);
                    System.out.println("Cross is printed");
                } else {
                    batch.draw(tile, col * tileSize,
                               row * tileSize + boardOffset,
                               tileSize, tileSize);
                    System.out.println("Tile is printed");
                }
            }
        }
        System.out.println("Outside the FOR LOOP");

        batch.end();
    }

    @Override
    public void dispose() {
        batch.dispose();
        tile.dispose();
        cross.dispose();
        circle.dispose();
    }
}


texts:
I originally built the start of my game world with a fully minecraft style structure: chunks, only visible faces rendered, noise, etc. Too blocky. I implement marching cubes. Looks great, horrible to work with:

The problem is when you try to add or remove blocks to the marching cubes as... exactly as they are supposed to... everything gets smoothed. It becomes difficult to raycast on a neighbor and if you do all the blocks around him get changed. Obviously.

I see a lot of marching cubes/metaball looking games that implement area based organic molding. You don't place "blocks" you shape an area or deshape it like Landmark mining etc.

On the otherhand Blockscape and Landmark seem to be a blend of the two? The land starts out marching but you can cut clear square chunks out of it and place square cubes onto it.

How can you make straight corners with marching cubes? Or is it a combination of two entirely different systems?

(UPDATE):
There is probably more than one answer to this, does anyone have any experience trying to do this though? I can think of a couple of possible approaches:

Separate player built objects into a separate mesh/object per chunk keeping terrain as terrain. Run smoothing (marching cubes or others) algorithms and normal calculations only on terrain. Would probably need some sort of a half-transparent cube highlighter showing what the cursor is currently selecting. I can see a number of benefits to this system, though feel as if there are some downsides I'm just not thinking of immediately that would crop up if I started coding it...?
Define a "smooth" bool per cube, only assigned at initial calculation of the mesh on any surfaces (floor/ceiling/etc). Any built/added/removed blocks are not re-labelled as "smooth" when generating the mesh use different math for smooth cubes than for blocky cubes. This is what I'm currently working with and it works, but it's still only about a third as smooth as a full marching cube approach would be. Basically I'm average each vertices y value with its surrounding four cubes height(noise) values while never letting it go beneath 0 or above 1 (to stay within the cube). I also had to re-write the raycast click detection to use the surface normals.
Re-code the marching cubes algorithms to work only on the cells I want them to/do what I want them to. This seems like the most difficult but possibly most visually rewarding approach.

or ??


texts:
I found this tutorial on youtube and it works pretty well, but I want to add more to it.

How can I draw a smooth arc path in the game view (right now the path is only visible in the editor)?

Here is the code:

public class BallLauncher : MonoBehaviour
{

    public Rigidbody ball;
    public Transform target;

    public float h = 25;
    public float gravity = -18;

    public bool debugPath;

    void Start() {
        ball.useGravity = false;
    }

    void Update() {
        if (Input.GetKeyDown (KeyCode.Space)) {
            Launch ();
        }

        if (debugPath) {
            DrawPath ();
        }
    }

    void Launch() {
        Physics.gravity = Vector3.up * gravity;
        ball.useGravity = true;
        ball.velocity = CalculateLaunchData ().initialVelocity;
    }

    LaunchData CalculateLaunchData() {
        float displacementY = target.position.y - ball.position.y;
        Vector3 displacementXZ = new Vector3 (target.position.x - ball.position.x, 0, target.position.z - ball.position.z);
        float time = Mathf.Sqrt(-2*h/gravity) + Mathf.Sqrt(2*(displacementY - h)/gravity);
        Vector3 velocityY = Vector3.up * Mathf.Sqrt (-2 * gravity * h);
        Vector3 velocityXZ = displacementXZ / time;

        return new LaunchData(velocityXZ + velocityY * -Mathf.Sign(gravity), time);
    }

    void DrawPath() {
        LaunchData launchData = CalculateLaunchData ();
        Vector3 previousDrawPoint = ball.position;

        int resolution = 30;
        for (int i = 1; i <= resolution; i++) {
            float simulationTime = i / (float)resolution * launchData.timeToTarget;
            Vector3 displacement = launchData.initialVelocity * simulationTime + Vector3.up *gravity * simulationTime * simulationTime / 2f;
            Vector3 drawPoint = ball.position + displacement;
            Debug.DrawLine (previousDrawPoint, drawPoint, Color.green);
            previousDrawPoint = drawPoint;
        }
    }

    struct LaunchData {
        public readonly Vector3 initialVelocity;
        public readonly float timeToTarget;

        public LaunchData (Vector3 initialVelocity, float timeToTarget)
        {
            this.initialVelocity = initialVelocity;
            this.timeToTarget = timeToTarget;
        }

    }
}

I found a way to Instantiate projectile along the path. Now I just need to know how to convert that line in debug mode to make it visible in game mode


texts: Pathfinding in a 2D "sidescrolling" strategy game

texts:
I've been thinking up a real-time strategy game that plays on a platformer type of map. The collidable portion of these maps will be made up of square tiles. I've done A* pathfinding in top down tile based games before, but I'm unsure how to lay out my tile map in such a way that allows for easy pathfinding. I've thought up some examples, but I'm not sure if it's the right way to go about it, so I thought I'd throw it out here and see if someone who knows what they're doing can give me some tips.

The first solution I thought of was to use a 2D array storing all of the tiles and empty space, similar to what I would most definitely do in a top down tile based strategy game. The 2D grid would be invisible in the background but really store whether each grid section is empty, or has a tile on it. like this:

In this example I'm unsure as to how I would pathfind up hills, or in that specific example, determine that a wall is too high to cross. Lets say that dude can jump over 1 tile high blocks, but 2 tiles is too much. How would I effectively determine that through a pathfinding algorithm?

The other example I was thinking of was to place pathfinding nodes on top of traversible terrain, like this:

Each node might be able to give directions or commands on how to get to the next (Like the need to jump to cross a gap, or it's faster to go under rather than over, etc). Now I would want to do this logically through code, and not manually place them at design time.

This might be a better solution, but something I'm thinking of in this game is to have destructable terrain. Say an explosion happens and leaves a big hole like this:

Suddenly those nodes I placed earlier won't work. I'd need to remake them on the fly. In this case the 2D grid sounds like the better option since I can just flip the value of that tile from full to empty.

So hopefully those 2 examples made sense, and I'd like some opinions on which might be the best option, or even if there's some other solution I didn't think about I would be glad to hear it! I'm using Unity if that helps.

I just want to get this design choice out of the way early, as it would be a pain to have to tear it apart later.

Thanks!


texts: Feasible to do all game logic on PHP server?

texts:
For the turn-based browser Flash RPG I'm working on, I'm keeping all player stats in a MySQL database, with PHP as the go-between, for the sake of persistence and to prevent cheating by memory editing. But then it occurred to me that someone could cheat by hacking the client as well by, for example, repeatedly calling the function which adds gold to the database by posting arguments to a PHP page. That means I have to do all logic on the PHP server to prevent that.

Is that a feasible thing to do? My end goal is to have a commercial game that could have a large number of people playing at the same time, and I assume I need to be mindful of the number of operations being performed on the PHP server as well as the number of queries being made to the MySQL database. Although when I look at various web hosting providers that provide PHP and MySQL, none of them seem to mention any limitations on those two things. I'm hoping speed won't be an issue as well. On the free test server I'm using, it takes a couple seconds to get a result back from the database, but you get what you pay for.


texts: Wavefront mesh: determine which face a point belongs to?

texts:
I have a 3D mesh Wavefront .obj file.

Is there any algorithm that takes an arbitrary point coordinates as input and determines which face of the mesh that point belongs to ??

The mesh is rendered on the screen, then the user clicks on it, I want to determine which part of the mesh the user has clicked on ?

Here's the code using LibGDX:

Vector3 intersection=new Vector3();
Ray ray=camera.getPickRay(x, y);
//vertices is an array that hold the coordinates of the mesh
boolean ok=Intersector.intersectRayTriangles(ray, vertices, intersection);

Thanks


texts: Calculating the shadow cast by triangle onto the YZ plane

texts:
So, one of the exercises for my computer graphics class is as follows:

Calculate the shadow cast by triangle T onto the YZ plane P.

given:

Triangle T coordinates: A=(30,10,16) B=(32,11,18) C=(31,12,24)
Light source L=(40,10,18)

The scene described above is as follows: there is a light source emitting light onto a triangle, the triangle is in front of a plane, due to the light there will be a shadow cast formed onto the plane.

In other exercises where we had to calculate whether or not a point was inside the shadow cast we made use of a line/plane equation. But this time it is not clear for me how calculate the points of the shadow cast.


texts: How are Stencil Buffer Operations Applied in ShaderLab

texts:
In Unity's Shader lab, I've read that the Stencil buffer is implemented with a mask, and an object reacting to the mask.

The mask may be defined like the following:

SubShader {
    Tags {
        "RenderType"="Opaque"
        "Queue" = "Geometry-100"
    }

    Stencil{
        Ref 1
        Comp always
        Pass replace
    }
    ...
}

To my understanding, because Comp is defined as always and Pass as replace, every pixel that this geometry covers, will have its stencil buffer replaced with 1.

The object to be masked may have a shader similar to the following:

SubShader
{
    Stencil{
        Ref 1
        Comp equal
        Pass keep
        Fail keep
    }
    ...
}

And supposedly, this object would only render if its is rendered over the pixels affected by the mask.

Does this mean that every object rendered with a shader that contains the Stencil function will automatically discard any pixels where the Comp fails, before passing it to the fragment shader?

Consider the following:
There are no masks, but only a single object containing the Stencil function. If the stencil function is declared as

Stencil{
    Ref 1
    Comp never
}

then this object will never render to the screen? What is the default value in the stencil buffer? Does rendering path affect any of this?


texts: Enumerating full game tree for small board game

texts:
I am trying to list all the possible positions in a small board game (nannon) (using C++)

So far I have decided to split it into two parts, the pieces that are in home positions and end positions (which aren't on the board) and the pieces that are in play (on the board).

Now, I can list the positions when the pieces are on the board with the  STL algorithm next_permutation (on a 6 point structure like : point_1 = "White", point_2="empty"......point_5="Black", point_6="empty")

I am left with how to list all the positions of pieces which are off the board.

I have decided to have a set of bins:

white in home position
white in end position
White in play
black in home position
black in end position
black in play

white has three pieces that can be put in any of these bins (e.g 2 in home bin and 1 in play bin), same goes for black, like this:

white in home position = 2
white in end position = 0
White in play = 1
black in home position = 0
black in end position = 1
black in play = 2

Any ideas of how I go about this?

p.s: (i tried just adding the home/end/in-play bins to the "board" structure and running next_permutation but that gives nonsensical positions like black pieces in the home bin. I guess I could just list them ALL and then prune the nonsensical ones but that seems like over kill)


texts: What are my options for building a centralized server architecture for a Unity game?

texts:
I have made in the past multiple offline game, and would like to make my first online game. I have very basic knowledge of server structure.

The game is a multiplayer RTS game, with ONE server (If possible in c#), where player can build base, attack other player and move around a world. it is in real time, but slow paced, so not many actions, and every time a user make movement it take let's say an hour to move. The game is planned for Android/iOS and (maybe) but not at all for the moment, web.

The game itself is easy, but the server I don't know where to start and I have been struggling in the last 3 days to find a informations and answer to my question. Most of the example I found are P2P/client-hosted server, this do not apply to my case, I want a single server that runs outside of Unity and that I can run on a computer as stand-alone. My question problems are.

1) for a mobile game, I have seen in some post that UDP TCP/Socket are not available in 3g? is this true ? If so, what should I Use ? I was thinking of websocket since MAYBE i make a web version, but I don't know if it's a good idea, and apparently it is not built in in Unity.

2) Related to my 2) is there any c# library that work in Unity and would fit my game needs? a user would probably load a map, and interact around 20 times with the server during the gameplay. I believe a simple server that get and send message only is largely enough, but I don't know what to use. Start from scratch? then what should I use, TCP ? Socket? WebSocket ?

3) Should I use photon ? I've seen is free to test until 20CCU, and since for probably the next 6month I will be alone on it it's OK, then at release let's say I have 100 player, is not that expensive. Is it a viable solution? I found it a bit overkill for my needs, but it looks documented and easy to start. Will I still learn stuff if I "cheat" like this?

Thank you for your time


texts: Java multiple player objects/enemy objects?

texts:
NOTE: I'm a beginner and learning :D

Alright, so in my game I have a class for the player (with the parameters of x, y, color, width, height, and health, same parameters with the enemy). But I have a problem. So, in my player class, I have a draw method which sets the color and fills a rectangle with the variables specified in the parameters. In my main class, I create an instance of that player, and call the draw method from there, too. However, when I try to create more than 1 player object, it just renders the second one, rather than both, even if the x, y, color, and pretty much everything is different.

Basically, I can't draw more than 1 player to my screen. Same thing with the enemy.


texts: Avoiding GC when rebuilding Mesh.uv and Mesh.vertices

texts:
Since unity will not allow users to iterate over mesh.uv and mesh.vertices, I am stuck having to use GC intensive calls when applying an array of uvs and vertices to a mesh. I run into high GC allocation because every time I rebuild a mesh, the uv and vert arrays will be a different size due to the mesh being modified. In turn, this results in having to resize or create new uv/vert array and that is where the garbage collection comes in to be a problem when the old array or list is discarded as well as when applied to the mesh.

Example 1 - List:
For example, building a List UVList for a mesh that is built frequently will require calls of UVList.Add(Vert), this creates garbage for the GC whenever the List is resized with List.Add because when the list is resized, it creates a new copy and the old copy goes into GC. Also, to apply this list to a mesh.uv requires the call UVList.ToArray(); which is a nasty call that creates huge GC if you have a long list of vertices because again, to convert to array, that array after it is copied mesh.uv = UVList.ToArray() the UVList array created goes to GC.

Example 2 Array:
I've instead tried using fixed array sizes but then learned that you cannot iterate over vertices or uv array of a mesh. For example, using a for loop to directly apply a vertices array to mesh.vertices will result in no mesh showing (i.e. for(i = 0; ...){ mesh.uv[i] = uvArray[i];} )

If I cannot do this, then I run into the same problem as example 1, because the only way is to create new array every time you want to update your mesh that has diff uv/vert length. Resizing array requires creating a new copy of it, and then you have the same issue with GC.

I tried reading through this example of someone else dealing with Unity GC when frequently updating meshes http://gamasutra.com/blogs/RobertZubek/20150504/242572/C_memory_and_performance_tips_for_Unity.php

He doesn't really explain his helper method in applying the UVs to the mesh and when trying from his example, it also results in GC.

I guess my question is, how can I frequently update a mesh with diff uv/vert array size without running into GC Alloc slowing down my project?


texts: what is order of implementation of matrix transforms?

texts:
What is the meaning of Tr*Sh*Ro*Sc =M ?

How is matrix M written to form the graphic transformation :  1st Sc=Scale, 2nd: R=Rotate, 3rd : Sh=Shear 4th: T=Translate ?
Is the matrix  M above written properly in a "post multiplcative" format" T*Sh*R*Sc , but executed  Scale, Rotate, Shear , finaly Translate ?


texts: Is object space the same as local space?

texts: I was in directx 11 and was wondering is local space the same as object space and if not, what is object space?


texts:
Image reference for the question:

(image from the CG tutorial)

The D3D9 API got us used to world matrices.

However, if you use world matrices, then you have to do an extra matrix multiply in the shader (which ends up being the same for a whole lot of vertices).

Hence the OpenGL convention of concatenating the modelling and viewing matrices into one matrix (the GL_MODELVIEWMATRIX = View*World).

What's better, and why?


texts: GNU GCC is a very common compiler, but it seems like almost no one uses it for bigger projects like AAA games. To me, it's works just fine, never had a problem with it. But I wonder why all AAA games seem to use commercial compilers such as Intel Studio? Why does it matter? GNU GCC also optimizes the code for all systems rather then just Intel, so why do they bother with things such as Intel Studio?


texts:
If I want to develop an android racing game set in the 1940-1950, with the real track of that period (that differs from the actual one), both closed and street circuit, and the real car of that period (F1 car), do I have to pay a license to use its name and aspect?

If so, how much it would be cost?


texts: Pattern for modular ScriptableObject-Database?

texts:
Lets say we want to store game data inside of scriptableObjects and we have plenty of them... So we need to find a way to store them efficiently in a modular way.

What pattern could we use to code a scriptableObject database for providing a substainable base for our game data- scriptableObjects?

And are there any patterns or structures for extending our game data - scriptableObjects in order to construct them modular and flexible aswell ?


texts:
Globally the number of people of all ages visually impaired is estimated to be 285 million, of whom 39 million are blind.
— World Health Organisation, 2010.

(That's 4.2% and 0.6% of the world population.)
Most videogames put a strong emphasis on visuals in their content delivery. Visually impaired gamers are largely left out.
How do I design a game to be accessible to visually impaired gamers?


texts: How can I draw orbit paths for a solar system?

texts:
I’m trying to make the orbital paths visible for my solar system simulation game. I have most around with trail renderers and solid line sprite but not achieving the desired look I want. I’m hoping to get something where the path is alway present but darker directly behind where the planet currently is, and lighter and more transparent ahead of where it’s going. This effect is achieved in the game Worbital.
If anyone could point me in the right direction how I can achieve this I would be much appreciated.


texts: Logical math behind jumping in a 3D world

texts:
I'm unsure if I should ask the mathematic part of StackOverflow or the gamedev part. I'm trying to figure out how the gravity changes the position of an element in a 3D world. I've been trying to rescript the gravity in a game so I could attach it to every element I want.

As far as I know; The movement of the player has something to do with the current position ( obviously ), the velocity, the gravity and Delta Time. As far as I'm concerned too, I know that when an element makes some kind of jump, he should go up since the velocity is still positive. Each frame should update the player's position, depending on the current position and velocity, the new position will be created. I've been able to create it in a platformer ( 2D ) but I haven't succeeded to do this in a 3D game. As far as I came, the object just flew into the air at a massive speed and ended up landing in another galaxy..

I'm currently working with Lua, if you were trying to explain something in a language. If you're working with another language and want to give me an example in that.. feel free to do so. I'm known with a lot of languages ( programmer here. ). It's just about the logic behind it, the actual math.

Thanks in advance


texts: SDL2 Gamepad triggers trigger when disconnecting the pad

texts:
I'm using MonoGame and SDL2. I'm having a strange problem with the Gamepad. When I disconnect it during the game, before the disconnected event fires, the left and right triggers return values as if they were half-pressed.

The following code demonstrates the problem. Left or right trigger isn't really being pressed at all.

(From this source file https://github.com/dineshkummarc/MonoGame-2.5.1.0-0/blob/master/MonoGame.Framework/Desktop/Input/GamePad.cs)

GamePadTriggers triggers = new GamePadTriggers(c.LeftTrigger.ReadFloat(device), c.RightTrigger.ReadFloat(device));
// The following is debug code added by me
if (c.LeftTrigger.ReadFloat(device) > 0) {
    var rawSDLvalue= SDL.SDL_GameControllerGetAxis(device, (SDL.SDL_GameControllerAxis)(c.LeftTrigger.ID));
    Console.WriteLine("DURRURRRURRRRRRRR WHY IS IT NOT ZERO, IT SHOULD BE????" + c.LeftTrigger.ReadFloat(device) +" RAW "+rawSDLvalue);
}

Is there any real solution to this? Since the disconnected event fires afterward, I have no means to distinguish whether the triggers were really pressed or not. Any ideas? Are other SDL2 users experiencing this too?


texts: Game built uses a lot of GPU processing, in the editor uses very little

texts:
I am building my project in Unity 2018.2.21f1 for Windows in architecture x86_64, with:

Copy PDB files | false
Create Visual Studio Solution | false
Develoment Build | false
Autoconnector Profile | false
Scrit Debuggin | false
Scritps Only Build | false

Mainly I built them and run because added several assets of the store and I wanted to see that there was no problem.

If at first glance everything worked fine. But I had the Task Manager open and I saw that the GPU had a lot of use 70% to 80% (I have a GTX 1080) and the game is 2D. My demo only has 22 sprites, without UI which I found very strange, so I opened the FireStorm (a Zotac GPU Manager) All the values of the graphics were extremely high (even started to sound a lot the fan) GPU core clock extreme high, GPU Temperature Very High, GPU Utilization Very High too.

But when I run the game inside the Unity editor, it's very normal values for a game with 22 sprites.

I continued making tests note that when the game is running the option of Graphic Quality in Fastest is selected by default, here the use of the GPU increases considerably 70% probe the rest and I have the following

Fastest 70% GPU use
Fast 70% GPU use
Simple 70%-75% GPU use
Good 6-20% GPU use
Beautiful 22-23% GPU use
Fantstic 22-23% GPU use

So the problem apparently is in the quality configuration.
What concept can be the one that generates this problem? Everything is by default in Unity until now

EDIT

I have 5 scenes, only in 1 there is the problem. The scene has sprites that use Shader Weaver. I removed them and did the tests again. What I notice is that in the new build, when I run in fantastic I have the problem of high GPU consumption and in "beautiful" it increases to 40

Also in imported Tower Defense 2D of GOODDAY that modifies the project configuration. And a couple of days ago import 2D Shooter Bullet and Weapon System which also modifies the configuration.

In Quality Settings actualy have this

I understand that vSyncCount limit the update rate

Because the levels with the worst performance have the "Dont sync" option set, meanwhile Good and Beatifull is in Every V Blank


texts: How do I add my phaser.js game to my pre-made web page?

texts:
First off, it's my first time doing a little bit of game development, and I have no idea of the normal flow of making a game, let alone a browser game.

My game uses the phaser framework of HTML and JavaScript. It is a simple game based on the 2D space impact game. I was able to run the game on an empty HTML site with only head, title, and body tags.

This is the code to plug in my game to the blank HTML site:

<script type="text/javascript" src="game.js" type="text/javascript"></script>

But when I tried to add it to my pre-made website, it won't show.
Am I missing anything? Do I need to put it in an iFrame, although I know phaser builds on a canvas.


texts:
I recently upgraded unity from 2018.1 to 2018.2 and also upgraded my nvidia geforce.

I have seen that the letters resolution of the program itself are better now but my game tab is going lower res then before.

In the image I attached you can see the difference between the game emulation on game tab (windows) and the scene tab

The girl on the scene tab looks much smoother and better then how it appears on the game tab , before updating these were the same look and resolution.

Is there some options that control resolution of game tab in unity? (resolution as in dpi not in width and height)

Thanks


texts: How do I create a horizontally centered "gravity line"?

texts:
Here's my ideal scenario: A game object (in blue) can change its horizontal velocity, but it will be pulled back by gravity (dotted gray arrows) toward a central vertical line (in red).

How can I do this?


texts: How do I get the InputManager to recognize a certain axis/Vector2D with a Vive motion controller?

texts:
Right. So basically I want to map the Vive motion controller touchpads (certain locations) to the certain inputs in Unity's InputManager. How do I do this? Like I want a certain area on the touchpad to equate to forwards/backwards in the InputManager. How would I do this? I am not seeing a way to do it natively.

Long story short I'm wondering if I can use the Vive with the InputManager or not.


texts: Variable height jumping in side scrollers

texts: How can I have the player jump higher if the jump key is held down longer? I am currently just reducing gravity as long as the key is held and the player is jumping, but this looks odd.


texts:
So I've been messing around with simple game development for a while and just found an interesting game idea here . I'm using SFML 2.1 with C++ and so far I have a tilemap in a VertexArray using a very similar way to this tutorial and have gotten it working with submarine movement but I feel that I have dug myself a hole with this. Here is what I have so far and you can see my simple tileset: . I am pretty lost in terms of how to handle collisions between the submarines (and anything else fired) and the walls. The only way I can really think of is pixel collision but I'm not really sure how I would implement that.

Sorry if this has been asked before but I have looked and can't find much that applies. Any help is greatly appreciated.

Thanks,

Karel

I just realised that the question is badly worded sorry. I was wondering how to do collision detection between the submarine and the walls of the level. Since I don't want to just do collision tests on the whole tile (as it would prevent the sub from getting close to the wall) but rather the section that has the actual wall part (just the line in the tile). I really don't know how to do this, should I switch out the tilemap for just a bunch of line objects and do the collision tests on those or is there a way to do it as it stands now?


texts: cocos3d versus Unity for simple IOS 3D games?

texts:
Wondering if anyone here happens to have experience in doing some simple 3D based games/apps for IOS, using cocos3d & Unity and could give some pointers....questions I have are:

GENERAL

1) It seems currently cocos3d has the most traction in terms of a free 3D games engine for IOS development?

2) If one wanted to step up from the free IOS games engine, to a commercial one it would seem Unity is a popular choice, however you would then not really be doing apple/objective-c development, but rather unity development and pushing a button to pop out an IOS deployable artifact correct?

FOR MY SPECIFIC REQUIREMENT - If I was interested in doing the following:

develop a relatively simple 3D application for iPhone/iPad
have a small 'world' such as a room with a few basic items in it (table, cupboard)
ability to 'drop' a basket ball in the room and have it bounce around based on a physics engine & perhaps some user input (not sure what, lets say control wind direction)
monitor it and react accordingly - e.g. say if it goes into a net which is in the room then add a point to the scoreboard

At a high level how would one do this using Unity versus using cocos3d, for example:

3) Which would be quicker to develop such a basic iPhone/iPad game/simulation out of Unity/cocos3d?

4) Would 'building your world/room' approach be different? Like in Unity would you build tables/cupboards within a Unity IDE which would make it very quick, whereas with cocos3d would you have to do this programmatically?

5) Would the programming aspect of letting the ball go and monitoring it be different between the two? Or would you roughly in both cases just be setting up world, release ball in certain position, and then engaging physics engine?

6) Any advice/guidance re which tool/approach to use? (Unity versus cocos3d)

7) Re using cocos3d for my requirement, what additional tools would you recommend above/beyond XCode? (e.g. just perhaps some sort of 3D design tool to help model the room and import/save somehow for us in cocos3d)

Basically I'm a hobbyist iOS developer who wants to do some 3d, so the concept of using a free/open-source approach such as cocos3d sounds great as (a) it's free, (b) keep using existing skill set re objective-c etc, BUT the biggest unknown to me is whether by chosing cocos3d would I be giving myself say 20 hours of work to develop a 3d app/animation that could be developed in 1 hour in one of these commercial product (e.g. Unity)?


texts: Frustum Culling/Only rendering what's viewed by the Camera in HTML5 Canvas?

texts:
I coded up a simple 2D Camera for my HTML5 Canvas-Based Game Engine but I noticed the performance wasn't very good. So a lot of people suggested only rendering things that are shown by the camera but I haven't found anything that helps how to implement this.

I'm thinking about iterating over through all my game entities then checking their rendering positions, etc. But is this efficient?

if(renderCoords[i].x >= 0 &&
   renderCoords[i].y >= 0 &&
   renderCoords[i].x <= camera.getWidth()+camera.offset.x &&
   renderCoords[i].y <= camera.getHeight()+camera.offset.y) {
       //render
}

It's not tiled-based, just thought I mentioned that. Just doesn't seem clean to me.


texts: Resource protection in cocos2d-x 2 and 3

texts:
I am developing a game in cocos2d-x 2.2.3 and I want to protect my resources from being extracted. Is there any way I can do this?

I don't know much about encryption.


texts:
I want to make a tile-based platformer in AS3.

I want my game to read an external maps file (in xml or json or somethimg similar) to draw a tile-based map.

I've seen loads of tutorials for this in AS2 and other languages, and the few I've found in AS3 are either incomplete or filled with extra unnecessary features. I just want to be able to draw a basic map from sprites in Flash.

Any links or information to point me in the right direction would be appreciated.


texts: Calculate bike heading from front wheel heading and velocity

texts:
I have a simple top down bike game that I'm trying to add steering to. I would like to know how I use the heading of the front wheel to determine the heading and velocity of the bike.

void Update ()
{
    //Get input from user Vertical: 0 to 1, Horizontal -1 to 1
    float forwardInput = Input.GetAxis("Vertical");
    float sidewaysInput = Input.GetAxis("Horizontal") * m_steeringAmount;

    // Turn front wheel
    m_frontWheelTransform.localEulerAngles = new Vector3(0, sidewaysInput, 90);

    // get speed and drag
    float   speed           = m_velocity.magnitude;
    Vector3 forwardDrag     = -m_forwardDragConstant * m_velocity * speed;

    // calculate acceleration
    float engineForce       = forwardInput * m_enginePower;
    Vector3 forwardTraction = transform.forward * engineForce;
    Vector3 forwrdForce     = forwardTraction + forwardDrag;
    Vector3 acceleration    = forwrdForce / m_mass;

    // update velocity and position
    m_velocity += acceleration * Time.deltaTime;
    transform.localPosition += m_velocity * Time.deltaTime;
}

I have tried to apply the bike velocity to the front and rear wheel and use the difference of there positions to determine the bike heading, but the forward drag make it confusing.

Edit based on madshogo comment


texts: What are some good game development programs for kids?

texts:
I know a very bright little boy who excels in math, but at home he's glued to his Nintendo DS.

When I asked him what he wanted to do when he grew up he said "Make video games!"

I remember a few years ago there was mention of a MIT software called Scratch and I thought maybe this kid can do want he wants to do.

Has anyone used any of the "game development" for kids softwares out there? Can you recommend any?


texts: Should I ask my artist to make Sprites in full resolution or can I scale them up?

texts:
I'm started with Unity development and my artist asked me what size she should make the sprites for the game.

They are all pixel art and she didn't know if she should make them on Photoshop on a small resolution, do them already on the iOS resolution 1920x1080 or even if she should use a vector program and then rasterize them.

How is this normally done?


texts:
Up until now, I implemented all-against-all collision detection in my games. It worked fine.

But I reached a point where implementing this kind of collision detection, makes the game run poorly, because there are two many objects to iterate through and check for collision.

I have searched this site and found something about 'uniform grids'. But I didn't completely understand what it is and how to implement it. Tried to Google it but nothing easy enough to understand came up.

I am a beginner to 2D-game programming. Do you mind trying to explain to uniform-grids, or link me to some good tutorial?

Thanks a lot


texts:
I'm having trouble with the Facebook UnitySDK when I use the FB.Feed() method for posting on user's timeline. The share dialog closes before the post is completed, Right after i press the "Post" button. This only happens when I test the app on the iOS Device since on the Unity Editor it works fine and I can post on the user's wall. User Login and getting username and profile pic, for example, work fine. The problem is when I try to share the user's score on facebook. Here's my code for the method:

public void Share_Score(){
        FB.Feed (
            toId: "",
            link: "http://www.facebook.com/appname",
            linkName: "App Name",
            linkCaption: "I just scored " + " points",
            linkDescription: "Playing this game is awesome!",
            actionLink:"http://www.facebook.com/appname",
            actionName: "Appname Fan Page"
                );
    }

The only error that appears on XCode is the following: 2015-02-11 10:13:07.025 hotdogcontest[749:224865] FBSDKLog: FBLinkShareParams: only "http" or "https" schemes are supported for link thumbnails


texts: Any open source game engines for Android?

texts: Is there any open source android gaming engine ?


texts: I have a mesh made of nearly half to a one million vertices. I also have some 6-DoF camera poses around this mesh. At these poses I'd like to find out which of the 3D points of this mesh get projected inside the image viewport of size 640x480. Basically I'd like to get the indices of the 3D points that fall inside this image window at a given pose. What is the best way to do it? Are there any shader functions or OpenGL functions that can allow me to do this quickly?


texts:
I am very new to programming. For a project I decided to make a game of cyclone using some LEDs,a push button, and a raspberry pi. I researched how to at least start on the game, but the problem that I encounter is that most examples of this game utilizes an arduino and python code, when I am familiar with the raspberry pi and c code. I would like to know to loop lighting up multiple LEDs one at a time with a decent amount of speed for a fun reaction game. My code starts out as this:

    #define pinOutYOne 0 //first yellow LED
    #define pinOutYTwo 3 //second yellow LED
    #define pinOutGOne 21 //green LED one
    #define pinOutGTwo 22 //green LED two
    #define pinOutBOne 23 //blue LED one...etc
    #define pinOutBTwo 25 //
    #define pinOutROne 4
    #define pinOutRTwo 5

    int  main(void){
      //set up pin mode as output
      pinMode(pinOutYOne, OUTPUT); //syntax for pinMode(pinNumber, Mode)
      pinMode(pinOutYTwo, OUTPUT);
      pinMode(pinOutGOne, OUTPUT);
      pinMode(pinOutGTwo, OUTPUT);
      pinMode(pinOutBOne, OUTPUT);
      pinMode(pinOutBTwo, OUTPUT);
      pinMode(pinOutROne, OUTPUT);
      pinMode(pinOutRTwo, OUTPUT);

      //clear output
      digitalWrite(pinOutYOne, 0); //write 0 (low) to output pin
      digitalWrite(pinOutYTwo, 0);
      digitalWrite(pinOutGOne, 0);
      digitalWrite(pinOutGTwo, 0);
      digitalWrite(pinOutBOne, 0);
      digitalWrite(pinOutBTwo, 0);
      digitalWrite(pinOutROne, 0);
      digitalWrite(pinOutRTwo, 0);

     //loop to allow blinking
     while (1 == 1){
       //light up the LED for 1 second
       digitalWrite(pinOutYOne, 1);
       digitalWrite(pinOutYTwo, 1);
       digitalWrite(pinOutGOne, 1);
       digitalWrite(pinOutGTwo, 1);
       digitalWrite(pinOutBOne, 1);
       digitalWrite(pinOutBTwo, 1);
       digitalWrite(pinOutROne, 1);
       digitalWrite(pinOutRTwo, 1);
       puts("LED on"); //display a message on console
       delay(1000); //1 for 1 milliseconds, 1000 for 1 second

    //turn off for 1 second
      digitalWrite(pinOutYOne, 0); //write 0 (low) to output pin
      digitalWrite(pinOutYTwo, 0);
      digitalWrite(pinOutGOne, 0);
      digitalWrite(pinOutGTwo, 0);
      digitalWrite(pinOutBOne, 0);
      digitalWrite(pinOutBTwo, 0);
      digitalWrite(pinOutROne, 0);
      digitalWrite(pinOutRTwo, 0);
      puts("LED off");
      delay(1000);
     }
 }

**I do know that this code lights all of the LEDs at once, I'm not sure how to implement a loop and light them up one at a time in sequence


texts: Momentum-wise accurate player controls in Unity regarding collisions

texts:
First post here. So I am a newbie to Unity and am willing to create a general character controller script to base my future characters. I understand a character's mechanics are pretty design (UX) dependent and I will need a few varients.

What I want
Momentum-wise accurate physical simulation (as much as game performance allows). Some examples:

If a flying canon-ball hits the player, it shall be crashed or flown away (some parameters would let us kill him in code hopefully) in accord with ball's momentum and player's mass.
If the player hits a stationary canon-ball the ball most-probably wouldn't move (due to friction), yet if they push enough it gains some torque and rolls-over. Rotational and kinetic energy would need equal energy provided.
Multiple player's could act upon a bunch of pieces just for fun.
Regular character capabilities such as stair/ladder climbing, walking, etc.

What I have read so far:

CharacterController needs to write code for desired physics, and apt when not so interactive characters (e.g. first person shooter) are at hand.
Rigidbody is good for non-agent dynamic items (e.g. falling boxes), and is hard to implement for agents (muscle powered humanoids, etc.), though possible.

What I ask
How can I implement such momentum-wise accurate physics (regarding collisions) in Unity engine?


texts: Intented name for my game already exists as a book title

texts:
I have found that the name I have planned for my game have been already used for the title of a book.

After checking the trademark database, this is the description they have used:

"Paper Goods and Printed Matter"

Would I be infringing the trademark if I use the same exact title for my game ?

(Looks like the owner wanted to trademark the same name as a videogame in 2006, but they didn't complete the proccess: Abandoned-failure to respond or late response)


texts:
I just use FTGL to use it in my app. I want to use the version FTBufferFont to render font but it renders in the wrong way. The font(texture?buffer?) is flipped in the wrong axis.

I want to use this kind of orthographic settings:

void enable2D(int w, int h)
{
    winWidth = w;
    winHeight = h;

    glViewport(0, 0, w, h);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    //I don't even want to swap the 3rd and 4th param
    //because I like to retain the top-left as the origin
    glOrtho(0, w, h, 0, 0, +1);
    glMatrixMode(GL_MODELVIEW);
}

I render the font like this:

//No pushing and popping of matrices
//No translation

font.Render("Hello World!", -1, position, spacing, FTGL::RenderMode::RENDER_FRONT);

On the other forums, they said, just scaled it down to -1, but it wont work in mine. Example:

font is above the screen

I can't see relevant problem like in mine in google so I decide to ask this here again.

How can I invert texture's v-coordinate without modifying its source code ? (assume its read only)


texts:
There is a quick and dirty appreoch to creating text boxes:

void OnGUI(){
    GUILayout.Label("Text 1");
}

It works well. But, since the Label method returns void, how do I access this later on?

Let's say I want to access the text later to change the score?

someField = GUILayout.Label("Text 1");

Is not going to work.


texts:
I have a terrain and entities(npc, house...).

I'm able to convert screen coordinates to world coordinates with the glReadPixels function:

glReadPixels(mousePosition.x, mousePosition.y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
// of course its not just that...

My character can move over that terrain without problem, but I'm not able to move when the mouse is over a big house and I try to move "behind" that house.

Do you know how I can avoid entities when converting screen coordinates to world coordinates ?


texts:
I want a text box to appear on the screen. I am doing this by:

TextButton= pygame.draw.rect(Screen,Red, (100, 100, 150,50),2)

How can I allow the user to enter a text into this text box in Pygame? The text box should say 'Enter your name here'. When the user clicks on it, they should be able to enter their name, and submit it if the textbox is not empty. How can I do this in pygame?


texts:
I'm trying to make a ball that will move in the direction I push it from, and later pull it to me based on where the player is standing.

using UnityEngine;
using System.Collections;

public class BallForce : MonoBehaviour {

    public float thrust;
    public Rigidbody rb;

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

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

        if (Input.GetMouseButton (0))
            rb.AddForce (transform.forward * thrust);
    }
}

This seems to work, but I'm not sure how I get it to move based on the position of the player. How would I do this?


texts: Creating a set of islands by subtracting gradient values from a Perlin noise

texts:
The answers to this question explains fairly well how to create a big island in the center of the screen by setting up a gradient and then subtracting its value from a Perlin Noise.

Anyway they explain how to create only
one gradient at the center of the screen to create a big, sort of circular island.

But what if I want to create an island which has more than one gradient to create a less regular shape, or if I want to create multiple separated islands by setting multiple gradients in different positions? What value should I subtract from the Perlin Noise function for each point? The sum of the distance from each gradient to that point? The average?

Edit: Jon's method of multiplying and normalizing worked, got this result with 4 gradient points:


texts: Projectiles in tile mapped turn-based tactics game?

texts:
I am planning to make a Laser Squad clone and I think I have most of the aspects covered. But the major headache is the projectiles shot/thrown.

The easy way would be to figure out the probability of hit and just mark miss/hit. But I want to be able to have the projectile to hit something eventually (collateral damage!).

Currently everything is flat 2D tile map and there would be full (wall, door) and half height (desk, chair, window) obstacles.

My idea is to draw an imaginary line from the shooter to the target and add some horizontal&vertical error based on the player skills. Then I would trace the modified path until it hits something. This is basically what the original Laser Squad seems to do.

Can you recommend any algorithms or other approaches for this?


texts: Unity3D filling visible camera area with objects

texts:
I'm developing an isometric tile-based game using Unity 3D.

I'm using an orthographic camera looking down yaw:45° and pitch:45°.

The game has an infinite world, which is loaded from a remote server. Because it is impossible to load everything at once, the game should only load visible areas of world.

But I don't know how to determine which tiles should be requested from server in order to fill up all the visible space on the screen.

I tried loading tiles by chunks e.g. 16x16 tiles chunk around camera. But this looks hacky to me and sometimes leaves blank edges visible on the screen.

Is there better solution to simulate a continuous world on the client side?


texts:
I'm currently developing a game using Kotlin and LibGDX. But this Question should be Framework/Engine agnostic. Given I have a Screen class like this:

class MyScreen: Screen {

    private val assetManager = AssetManager()

    private var anyTexture: Texture? = null

    override fun show() {
        assetManager.load("/.../anyTexture.png", Texture.class)
        anyTexture = assetManager.get("/.../anyTexture.png", Texture.class)
    }

    override fun render(delta: Float) {
        // do rendering
    }

    override fun dispose() {
        assetManager.unload("/.../anyTexture.png", Texture.class)
        anyTexture = null
    }
}

Every Screen I have manages it's own assets.
How would I achieve the same Lifecyle of my assets without using the nullable Type for every asset in the Screen? My Goal is just load all assets when the screen is loaded and then unload them when the game switches to another Screen. Has anybody got an idea for implementing this?


texts: Finding next AI move using MinMax algorithm for Checkers

texts:
I am currently working on a Checkers game using Unity ( human vs computer ) I am done with the base architecture of the game ie defining the rules, moves, jumps etc.

I am currently stuck in implementation of MinMax for computer AI. I know how it works but I am confused on two things. Firstly, the heuristics ( I am using simple red checker count - black checker count ) but I am not sure if its correct. Secondly, outputting the final path of nodes for my AI to make its next turn.

Below is my MinMax implementation so far.

int MiniMax(TreeNode node)
    {
        int depth = 2;
        List<TreeNode> pathNodes = new List<TreeNode>();
        int final = MaxMove(node, depth, pathNodes);
        return final;
    }

int MaxMove(TreeNode currNode, int depth, List<TreeNode> pathNodes)
{
    if (depth == 0)
    {
        return currNode.getPriority();
    }
    else
    {
        depth--;
        int v = -10000;
        List<TreeNode> allPossRedMoveNodes = gameBoardScript.createNewRedBoardsFromCurrent(currNode.getCurrentBoard());
        foreach (TreeNode RedNode in allPossRedMoveNodes)
        {
            int v1 = MinMove(RedNode, depth,pathNodes);
            if(v1 > v)
            {
                v = v1;
            }
        }
        return v;
    }
}

int MinMove(TreeNode currNode, int depth, List<TreeNode> pathNodes)
{
    if (depth == 0)
    {
        return currNode.getPriority();
    }
    else
    {
        depth--;
        int v = 10000;
        List<TreeNode> allPossBlackMoveNodes = gameBoardScript.createNewBlackBoardsFromCurrent(currNode.getCurrentBoard());

        foreach (TreeNode BlackNode in allPossBlackMoveNodes)
        {
            int v1 = MaxMove(BlackNode, depth,pathNodes);
            if (v1 < v)
            {
                v = v1;
            }
        }
        return v;
    }
}

Max in this case would be Black Checkers ( Computer AI ) and Min is Red Checker, the human player

Let me briefly explain what I am trying to do with my code above. I have a TreeNode structure that stores the GameBoard, next possible move and also the Heuristic value

In My Max Move, I get all the possible Red Move Nodes from the current board. Logic for finding all possible moves is working absolutely fine. And for my Min Move which would be the human player, I get all its possible black nodes.

I am currently testing the code with depths 2 to 3 for my game tree. Please correct me if my current implementation is wrong. And finally how or where do I trace the final path of all my final Tree Nodes based on Min and Max values generated and get the next move for the Black Checker?


texts: When Should You Revisit Old Web/Mobile Games To Improve Them?

texts:
Note: I would like this to be specific to mobile and web games, since they have easier distribution methods than other models.

Based on the examples in my interfaces question, it looks like (as expected) there's a lot of work cut out for me; there's a lot of room to improve that old, hoary chemistry game.

But should I?

In fact, when should (and shouldn't) you revisit old games and improve them significantly?

I can definitely think of a couple of reasons not to do this:

You're going to write a sequel (improve that instead)
You don't have players howling for your blood (or for improvements)
It's a one-off type of game you're unlikely to code anything similar to ever again


texts: Circle collider wheels push through polygon collider car chassis

texts:
I'm trying to create a simple vehicle and make it run on a terrain (from sprites + PolygonCollider2D).

I imported a chassis sprite with Rigidbody2D and PolygonCollider2D.
Then I imported a wheel with Rigidbody2D and CircleCollider2D.
I joined them with a DistanceJoint2D in the wheels and added the chassis as the parent.

But the wheel collides with terrain but not with the car. And you guys can also see the car/chassis collides with the terrain.

How can I solve this?


texts:
If I am creating a board-game type game, does anyone know if it is legal to use others' names in the game?

ie. A playing card with "George Bush" or "Michael Jackson" on it.

Also, is it the same for brand names?


texts: Does the age of test users matter? Should I get users that are around my intended age level, knowing that some games are played by younger or older people than were originally intended? Should I have my test users be all around the same age for consistency, or a variety of ages to gather more useful data?


texts:
When setting up a window I set 6 variables in my render class

int windowWidth;    // the width of the window
int windowHeight;   //the height of the window
int dimL;           // the coordinate of the left side of the display
int dimR;           // the coordinate of the right side of the display
int dimB;           // the coordinate of the top side of the display
int dimT;           //the coordinate of the bottom side of the display

In my initiation routine, i set the displayMode like this:
Display.setDisplayMode(new DisplayMode(windowWidth, windowHeight));

I set glOrtho like this:

GL11.glOrtho(dimL, dimR, dimB, dimT, 1, -1);

now my question is:

Using these variables how can i configure glViewport to have the area defined by the dimX variables fill the display?

thanks!


texts: Set specific animator-state as more important

texts:
I have a animator with 3 states:

KnifeWalk
KnifeIdle
KnifeAttack

The KnifeAttack state should be run, whenever the bool "Attack" is set to true. This always happens when the player presses the Fire1 button (e.g. Left Mouse Button):

if (Input.GetButton("Fire1") && canAttack)
{
    canAttack = false;
    Invoke("AllowAttack", fireRate);

    animator.SetBool("Attack", true);
    Invoke("DisableAttackAnimation", fireRate/2);
}

canAttack is just a bool to control how fast the player can attack. The float variable fireRate holds the time, until the player can attack again.

However, sometimes the KnifeAttack state isn't triggered. The Attack variable is always set to true, when i press the left mousebutton while testing.

In the first screenshot you can see, how i set the transition between KnifeIdle and KnifeAttack. The transition between KnifeWalk and KnifeAttack is the same.

This is the transition between KnifeIdle and KnifeWalk:

And the transition between KnifeWalk and KnifeIdle:

What i would like to know is: Is there a way to set the attack-state to more important than the other states, so that it could be triggered everytime?

During testing i had it that about every 20 mouse clicks the attack-animation is not triggered, altough the Attack-variable is set to true correctly.

I also tried to change the fireRate times, but this doesn't seem to be the error.


texts: What is the fastest way to know if the current coordinate in screen-space is odd or even in GLSL/GLES2 frag shader?

texts:
I want to make a post-effect where every second column of pixels is colored differently, and I want to implement this as a GLSL fragment shader on GLES2. The question is what is the most effective way to know if a fragment is indeed odd or even in the x direction?

My current ideas revolve around the following three approaches:

1. Integer bit-wise operator

//Pseudo code
bool even_w=((int)(viewport_pixels_width*screenspace_x))&1>0;

2. Sinus

//Pseudo code
float evenness_w=(sin(viewport_pixels_width*screenspace_x*M_PI)+1.0)*0.5;

3. Texture

//Pseudo code
bool even_w = lookupFromMyRepeating2x1CheckerTexture(viewport_pixels_width*screenspace_x);

All ideas and feedback are welcome!


texts:
I have 15 buttons on my screen at onClick event am fetching the button and hiding that button using

EventSystem.current.currentSelectedGameObject.SetActive(false);

now at the end i have to show buttons again so i am using

for (int i = 0; i < 15; i++)
 {
     tag1 = "Button" + (i + 1);
     GameObject.FindGameObjectWithTag(tag1).SetActive(true);
     Debug.Log("done");
 }

Loop is giving error becuase it is not able to find object which has been hidden or setActive(false) from other references unity forum i see same solution
but i don't know why it is not working in my case

  i know issue is with "FindGameObjectWithTag" function i will have to replace it with some other

any help will be appreciated Thanks


texts: What is the point of caling Draw() as often as possible?

texts:
From the MSDN page:

  Update and Draw are called at different rates depending on whether IsFixedTimeStep is true or false. If IsFixedTimeStep is false, Update and Draw will be called sequentially as often as possible. If IsFixedTimeStep is true, Update will be called at the interval specified in TargetElapsedTime, while Draw will continue to be called as often as possible.

What is the point of calling Draw potentially more often than Update? Why is Draw not upper-limited to the number of Update calls?


texts:
I am developing a game demo where I want a physics simulation with balls and obstacles.

I know that this is possible with the chipmunk physics-engine but I don't know how to use it. Can anybody give me suggestions how to get started and provide links to the API documentation?


texts: As3 Random movieclips from an array to the stage

texts:
For a game with orders and clients I was trying to create the following situation:

Every half minute, a client should appear at the counter. In this case I have an array with 4 movieclips (4 clients). After 30 seconds I want the first randomly choosed client to appear at the counter (y = 200). This is my solution (wich obviously isn't the right way, forgive me):

    var timer:Timer = new Timer(1000);
    var elapsedTime:Number = 0;

    timer.addEventListener(TimerEvent.TIMER, displaytime);
    timer.start();

    function displaytime(event:TimerEvent):void
        {
            elapsedTime++;
            counterDisplay.text = String(elapsedTime);
        }

    if(elapsedTime == 30){

    for (var i:uint = 0; i < mcArray.length; i++) {

         mcArray[i].x = Math.floor( Math.random()*(stage.stageWidth) );
         mcArray[i].y = 200;
         addChild(mcArray[i]);

    }

    }

My question to you is: What am I doing wrong, and how can I accomplish this?
Thanks in advance!


texts: How to change variable position within shader - Unity

texts:
I recently learned how to write shader in Unity and I'm trying to move the texture within one of my variable.

this is the texture I used on the model.

I separated the texture into two shapes, which is texRound and texStar based on position. What I'm trying to do is to move the star texture stored in texStar variable without affecting the position of texRound.

What comes to my mind right now is to use something like this code below, but it doesn't work as the texStar variable only save the color value without the position.

(texStar.x + posModifier).a = texUV.r;

What should I do to access the position of the texStar variable?
Thank you so much in advance.

Here's my full code:

Shader "Custom/ASK RGB" {
    Properties {
        _UV ("UV", 2D) = "white" {}

        // variable I intend to use as modifier value to change the y position of the star texture
        _modifier ("Modifier" , float) = 0
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Lambert

        sampler2D _UV;

        struct Input {
            float2 uv2_UV : texCOORD1;
        };

        void surf (Input IN, inout SurfaceOutput o) {
            // variable used to store the UV texRoundture mentioned
            half4 texUV = tex2D (_UV, IN.uv2_UV.xy);

            // variables used to store the round texture and the star texture
            half4 texRound;
            half4 texStar;

            if (IN.uv2_UV.x > 0.7)
            {
                if (IN.uv2_UV.y > 0.5)
                {
                    texRound.a = texUV.r;
                    texStar.a = 0;
                }

                else
                {
                    texRound.a = 0;
                    texStar.a = texUV.r;
                }
            }
            else
            {
                texRound.a = 0;
                texStar.a = 0;
            }

            texRound.rgb = texUV.rgb;
            texStar.rgb = texUV.rgb;

            o.Albedo =  texRound.rgb * texRound.a + texStar.rgb * texStar.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}


texts: How do I remove the background from pixel art sprites in Gimp?

texts:
I drew a pixel art tree using GIMP. My problem is, how can I cut out the white background, because if I want to build a tile map with it, in my case with tiled, it always has the white background with it.

I know you can cut it manually, but I want to know whether there is an easier way.


texts: Multiplayer tile based movement synchronization

texts:
I have to synchronize the movement of multiple players over the Internet, and I'm trying to figure out the safest way to do that.

The game is tile based, you can only move in 4 directions, and every move moves the sprite 32px (over time of course). Now, if I would simply send this move action to the server, which would broadcast it to all players, while the walk key is kept being pressed down, to keep walking, I have to take this next command, send it to the server, and to all clients, in time, or the movement won't be smooth anymore. I saw this in other games, and it can get ugly pretty quick, even without lag. So I'm wondering if this is even a viable option. This seems like a very good method for single player though, since it's easy, straight forward (, just take the next movement action in time and add it to a list), and you can easily add mouse movement (clicking on some tile), to add a path to a queue, that's walked along.

The other thing that came to my mind was sending the information that someone started moving in some direction, and again once he stopped or changed the direction, together with the position, so that the sprite will appear at the correct position, or rather so that the position can be fixed if it's wrong. This should (hopefully) only make problems if someone really is lagging, in which case it's to be expected. For this to work out I'd need some kind of queue though, where incoming direction changes and stuff are saved, so the sprite knows where to go, after the current movement to the next tile is finished. This could actually work, but kinda sounds overcomplicated. Although it might be the only way to do this, without risk of stuttering. If a stop or direction change is received on the client side it's saved in a queue and the char keeps moving to the specified coordinates, before stopping or changing direction. If the new command comes in too late there'll be stuttering as well of course...

I'm having a hard time deciding for a method, and I couldn't really find any examples for this yet. My main problem is keeping the tile movement smooth, which is why other topics regarding synchronization of pixel based movement aren't helping too much.

What is the "standard" way to do this?


texts: simplest way of making a sphere roll in a realistic way

texts:
rather than just moving a sphere across a plane, I want to make it roll like a ball. What is the simplest way of doing this? I assume it will have something to do with the circumference of the ball and rotating + moving it at a calculated rate.

What is the relevant maths here?


texts: How to add ambiant occlusion to a mesh created by script

texts:
We created a mesh point by point with a script (a huge mesh), and we would like to add ambiant occlusion to this mesh.
We use Unity 2019.1.6 and the LWRP template.

we already tested the unity ambiant occlusion post-processing , but it's not working on any gameobject...
We searched for tutorials but on Unity 2019 it's pretty uncommon.

Edit:
High quality AO isn't our goal, we just want to better see the difference between two faces of same colour.
We create the whole mesh (vertices and triangles) in script following the Sebastian Lague tutorial about planet generation. (Here's the first ep. link )

Our code is basically the same : loop over whole array, determine the world position of the vertex and save triangle indexs, then give all of this to the mesh component.

We "patched" the problem for now by adding a flat shader to it.

Edit 2 : How we determine world position of each vertex.

We are creating a plane mesh of [resolution * resolution] vertices. Then we apply noises to create a landscape.

(localUp, axisA and axisB can be replaced by x, y and z, we use them because we create 6 meshes for the 6 sides of the planet.)

Here's the loop for creating the vertices :

    for (int y = 0; y < resolution; y++)
    {
        for (int x = 0; x < resolution; x++)
        {
            int i = x + y * resolution; //index of this vertex on mesh
            //pointOnUnitCube determines the position of the vertex on the mesh
            Vector3 pointOnUnitCube = localUp + (percent.x - .5f) * 2 * axisA + (percent.y - 0.5) * 2 * axisB;
            //Transforms the cube to a sphere by normalizing
            Vector3 pointOnUnitSphere = pointOnUnitCube.normalized;
            //the ShapeGenerator uses noises to change the "height" of this pointOnUnitSphere
            vertices[i] = shapeGenerator.CalculatePointOnPlanet(pointOnUnitSphere);

            //Add to the triangles index array the 2 triangles this point is part of
            if (x != resolution - 1 && y != resolution - 1)
            {
                triangles[triIndex] = i;
                triangles[triIndex + 1] = i + resolution + 1;
                triangles[triIndex + 2] = i + resolution;

                triangles[triIndex + 3] = i;
                triangles[triIndex + 4] = i + 1;
                triangles[triIndex + 5] = i + resolution + 1;
                triIndex += 6;
            }
        }
    }

Have you any idea how we could achieve this ?

Thanks for your answers.


texts: How can I get the WAV data from the whole song?

texts:
I'm using FMOD (with C++ syntax, not C) and I'm having trouble getting the wave data of a whole sound file.

Channel::GetWave() only gets the wave data of the area on which it is currently playing.

The documentation says:

  Do not use this function to try and display the whole waveform of the
  sound, as this is more of a 'snapshot'
  of the current waveform at the time it
  is called, and could return the same
  data if it is called very quickly in
  succession.

  See the DSP API to capture a continual stream of wave data as it
  plays, or see Sound::lock /
  Sound::unlock if you want to simply
  display the waveform of a sound.

Unfortunately, the Sound::lock and unlock functions are pretty confusing,  at least to me.

Lock:

FMOD_RESULT Sound::lock(
  unsigned int  offset,
  unsigned int  length,
  void **  ptr1,
  void **  ptr2,
  unsigned int *  len1,
  unsigned int *  len2
);

  offset

  Offset in bytes to the position you want to lock in the sample buffer.

  length

  Number of bytes you want to lock in the sample buffer.

  ptr1

  Address of a pointer that will point to the first part of the locked
  data.

  ptr2

  Address of a pointer that will point to the second part of the locked
  data. This will be null if the data
  locked hasn't wrapped at the end of
  the buffer.

  len1

  Length of data in bytes that was locked for ptr1

  len2

  Length of data in bytes that was locked for ptr2. This will be 0 if the
  data locked hasn't wrapped at the end
  of the buffer.

Unlock:

FMOD_RESULT Sound::unlock(
  void *  ptr1,
  void *  ptr2,
  unsigned int  len1,
  unsigned int  len2
);

  ptr1

  Pointer to the 1st locked portion of sample data, from Sound::lock.

  ptr2

  Pointer to the 2nd locked portion of sample data, from Sound::lock.

  len1

  Length of data in bytes that was locked for ptr1

  len2

  Length of data in bytes that was locked for ptr2. This will be 0 if the data locked hasn't wrapped at the end of the buffer.

But as I said, my goal is to be able to get the wave data of the beginning of a song to the end.


texts: For example, I have a player and a map, to check player collision with some block we need to check entire map tiles, but the bigger the map, the slower the framerate. What's most efficient way to check collision?