texts:
I'm implementing my physics engine for my 3D game. So far I've been able to implement collision detection between OBB, spheres and planes. The engine generate contacts and resolve them with an iterative impulse-based approach.

The result is this (so far).

Now I need to detect and generate contacts between a height map terrain and those bounding volumes (sphere and OBB). The terrain looks like this:

I don't know how to do it. I need to detect collisions and generate contact data (contact point, contact normal and interpenetration to feed my existing engine).
I know I can't use a SAT because the terrain in not convex. What about ad hoc code for boxes and spheres? or is there a general approach?

EDIT

I narrowed down my problem to detecting (and resolving) collisions between a simple convex collidable (sphere/OBB) and triangles (always convex). Since the terrain is stored as an height map I can easily select a subset of triangles to run the algorithm against. I can use the SAT to detect interpenetrations. But what about collision response? How can I generate the necessary contact data (collision point and collision normal) to resolve the collision?


texts: Best logic to create and drop new gems in a Match-3 game

texts:
In a simple match-3 game, with a square gems matrix creating and dropping new gems is fairly simple: when needed I generate those gems above the matrix and then I make them fall into the main matrix simulating that common fall-from-the-ceiling behavior.

Let's now imagine I have a matrix with some rock-type gems, the ones that will never move from their position, and I have cleared an entire column via a "powerful" gem. I have something like this:

OOO OOO
OOO OOO
OOO OOO
OOO OOO
OOX XOO
OO   OO
O     O
OOOOOOO

Here O is a normal gem, and X is a rock gem, that is fixed in the matrix and will not move from its original position.

When the new gems flow into this matrix, they will eventually move to the left or to the right to fill that big empty space, but each one will be dropped into the same column.

I'm wondering what the best way to drop those new gems is. I clearly cannot simply make them move from the top of the screen directly to their final position (as in the previous case), since the would move diagonally across the other gems (too bad).

I'd like to know what's the easiest and most flexible way to compute and the configure the path that each gem will have to follow.


texts: Building battle ship in processing. How do i connect the ships together and randomize the location of the ships?

texts:
ive been working on this side project trying to make a battle ship game from some time now. I have come across a few things I do not know how to do. I was wondering if anyone knew how I could make each of the five ships with their appropriate lengths and then randomize their location on the boards.

I draw the two boards like this in my void setup()

 //drawing grid
  for(int i = 0; i < 10; i++){
     for(int j = 0; j <10; j++){
      squares.add(new ObjGame( 20+50*i,75+50*j));
      squares.add(new ObjGame( 580+50*i,75+50*j));
     }
  }

here is where I create the matrix for the ships and the hit icons. I do it in their own class in order to try and keep my main kinda clean

ObjGame(int xi, int yi){
   ship = random(5)<.5;

   x = xi;
   y = yi;
 }
  void draw(){
    pushMatrix();
        translate(x,y);
        fill(25,200,222);
        stroke(c1,c2,c3);
        rect(0,0,50,50);

        if(!ship && clicked){
         fill(255); //white circle for miss);
         ellipse(25,25,30,30);
        }
        else if(ship && clicked){
          fill(255,0,0); //red circle for hit
          ellipse(25,25,30,30);
        }
        else{
          fill(25,200,222);
          rect(0,0,50,50);
        }
       popMatrix();
      }

      void attacked(){
        if(mouseX <= 500){
        if(mouseX> x && mouseX< x+ 50 && mouseY > y && mouseY < y+50){
         clicked = true;
         println(x+" "+y);
        }
      }

i am also trying to print out their coordinates but I want them to print out 0 - 9 instead of their actual x and y coordinates, is there an easy way to fix that or should I just be switching them?


texts: Sliding loose dirt shader/material/effect

texts:
Im sure there is some sort of technique with a name I don't know or didn't think to search, but how would I go about making an effect similar to loose dirt sliding down the face of a slope when something disturbs it? I guess I think of it as a mini avalanche or something.

I have attempted it a couple times with pretty poor results, but some of the properties i tried to replicate was: the sliding dirt spreads out the further it gets from its start position depending on the surface shape, angle of repose, rocks or larger pieces of debris causing even more dirt to slide(quasi-recursion?), loose dirt 'sliding' over other dirt, etc. I assume id need to combine the right ratio of shaders, particles and textures to look right but I cant seem to find any real info on this type of effect. Would something like this be too intensive to do real-time?


texts:
I am trying to do something like Minecraft game in Unity. Currently I am trying to generate a chunk of blocks, given dimensions. I can successfully create a chunk of N x 0 x 0 sized chunk, but due to lack of logic, I have no idea on how to make triangles and vertices match for other blocks.

Basically, what I mean is, I can generate something like this:

But can't do this:

My Block vertices and Triangles:

Vector3[] cVerts = {
        new Vector3 (0, 0, 0), //0
        new Vector3 (1, 0, 0), //1
        new Vector3 (1, 1, 0), //2
        new Vector3 (0, 1, 0), //3
        new Vector3 (0, 1, 1), //4
        new Vector3 (1, 1, 1), //5
        new Vector3 (1, 0, 1), //6
        new Vector3 (0, 0, 1), //7
    };
int[] cTris = {
        0, 2, 1, //face front
        0, 3, 2,
        2, 3, 4, //face top
        2, 4, 5,
        1, 2, 5, //face right
        1, 5, 6,
        0, 7, 4, //face left
        0, 4, 3,
        5, 4, 7, //face back
        5, 7, 6,
        0, 6, 7, //face bottom
        0, 1, 6
    };

Chunk creation method:

     void CreateChunk(){
        ...
        for (int x = 0; x < 100; x++)
        {
           for(int y = 0; y < 10; y++){
               for (int z = 0; z < 1; z++)
               {
                  AddBlockAtPosition(new VectorInt(x, y, z), "Grass");
               }
           }
        }

        ChunkMesh.vertices = CurrentChunkVerts.ToArray();
        ChunkMesh.triangles = CurrentChunkTris.ToArray();

        //ChunkMesh.uv = uvs.ToArray();
        ChunkMesh.RecalculateNormals();
   }

AddBlockAtPosition() method:

    void AddBlockAtPosition(VectorInt pos, string name)
    {
       int x = pos.x, y = pos.y, z = pos.z;

       //create separate cube data
       CubeMesh cube = new CubeMesh(vertices.ToArray(), triangles.ToArray(), uvs.ToArray());
       //I use MoveCube() to change each Block's vertex and triangle numbers, so they will "match" in a Chunk mesh, when they become part of it.
       cube.MoveCube(new Vector3(x, y, z), (x + y + z) * 8);
       //cube.MoveUV(new Vector2(x + y + z, x + y + z));

       CurrentChunkVerts.AddRange(cube.Vertices());
       CurrentChunkTris.AddRange(cube.Triangles());
       //CurrentChunkUV.AddRange(cube.UVs());
    }

And most importantly, that's where my problems are, MoveCube();

Class Cube{
    private Vector3[] vertices;
    private int[] triangles;
    ...
    public void MoveCube(Vector3 direction, int n)
    {
        for(int i=0; i<vertices.Length; i++)
        {
            vertices[i] += direction;
        }
        for (int i = 0; i < triangles.Length; i++)
        {
            triangles[i] = triangles[i] + n;
        }
    }
}

I know that I am not the first to re-create minecraft, I have found this tutorial https://www.blockstory.net/node/56

But for me as a beginner, some "simple" parts like these I have problems with are skipped. And other tutorials just generalize the idea, which isn't enough for me.


texts:
I am trying to find the best solution for drawing a scrolling background in my app in Java. For now, I have two images and I move them by 1x and put it's thread to sleep for hmm, 5ms.

The problem is here that the background is too fast. What should I do?
Probably put the thread to a longer sleep. But when I do this, the background 'freezes' - jumps for 15 pixels each step and it doesn't look smooth.

The main question is:
How to handle a thing like this? Should it be done by sleeping it's thread, or maybe I should make positions floats, increment them by 0.1 and move only when they are integers? << this is my idea, I don't have an idea if it would work.

We have floats: width = 1000.0 height = 1000.0;
When increment width by 0.1 in each 'update iteration' in a gameloop.
If it's a int (1001, 1002, 1003), we move the background. What do you thing? What would be the best way?


texts: How do I change the speed of an object without changing path travelled?

texts:
I have a ball which is being thrown from one side of a 2D space to the other. The formula I am using for calculating the ball's position at any one point in time is:

x = x0 + vx0*t
y = y0 + vy0*t - 0.5*g*t*t

where g is gravity, t is time, x0 is the initial x position, vx0 is the initial x velocity.

What I would like to do is change the speed of this ball, without changing how far it travels. Let's say the ball starts in the lower left corner, moves upwards and rightwards in an arc, and finishes in the lower right corner, and this takes 5s. What I would like to do is change it so the ball still follows the same curve and finishes in the same position, but takes 10s or 20s to do so.

How can I achieve this? All I can think of is manipulating t but I don't think that's a good idea. I'm sure it's something simple, but my maths are pretty shaky.


texts: What do I need to know for writing code for both OpenGL and OpenGL ES 2.0

texts:
I am developing an engine that uses both OpenGL and OpenGL ES 2.0. I am well seasoned in OpenGL but not ES (although I am aware it is a subset of OpenGL). I could not find a set of differences that I should be aware of so that I can write code to take those differences into account and allow the engine to robustly handle the situation where a feature is not supported in OpenGL ES.

For example, the following forum post mentions a couple gotchas: http://forums.arm.com/index.php?/topic/13799-tips-tricks-opengl-vs-opengl-es/

A link to an exhaustive list would be nice.


texts:
Pretty much whenever anyone thinks about pathfinding, they think about algorithms like A* and DFS - graph search algorithms, which also just so happen to work as pathfinding algorithms when you quantize the space you're pathing in into a graph.

What if that's not an option, though? Are there efficient pathfinding algorithms that work in space that hasn't been split in to chunks? The "left hand rule" is one example; walk forward and when you hit a wall, turn left - but there's plenty of situations where that won't ever find the target. Are there others like that?


texts:
I finished my game while I was unaware of this error since it only shows up when I disable "WIFI" on my phone and testing it with 3G and 4G. Otherwise, when both devices are on my personal network (and I believe the same network in general) the game works perfectly fine.

Whenever two players connect via my own MasterServer I have setup on Amazon AWS services I get this error Receiving NAT punchthrough attempt from target "XXXXXXXXXXXXX" failed in the Unity console for both players. I am running both the Unity MasterServer and Facilitator on the server.

There are many question around the internet like this but not a single one with a answer. If this is really not easily fixable Unity should at least mention it's flaws where it provides the MasterServer. I would love to have an answer or at least some insight since now I have my own Linux server on Amazon I'd like to use it too. Currently it looks like my best alternative is using the multi-player options from Google Play Services.

This is the log I get from the server. Looks perfectly fine but it might help answering.

03-02-2015 02:28:31     INFO    New connection established to 24.XXX.XXX.X:62501
03-02-2015 02:28:31     INFO    Query request from 24.XXX.XXX.X:62501
03-02-2015 02:28:31     DEBUG   Version 2.0.0 connected
03-02-2015 02:28:31     INFO    Table Buckrider_Studio_FourInARow3D not found during query or row removal from 24.XXX.XXX.X:62501
03-02-2015 02:28:41     INFO    Connection with 24.XXX.XXX.X:62501 closed
03-02-2015 02:28:41     INFO    Removing rows for IP 24.XXX.XXX.X:62501
03-02-2015 02:28:41     INFO    24.132.7.159:62501 has diconnected
03-02-2015 02:28:41     INFO    New connection established to 24.XXX.XXX.X:61335 (166633197962428130)
03-02-2015 02:28:41     INFO    New connection established to 24.XXX.XXX.X:61336
03-02-2015 02:28:41     INFO    Update row request from 24.XXX.XXX.X:61336
03-02-2015 02:28:41     DEBUG   Version 2.0.0 connected
03-02-2015 02:28:41     DEBUG   Table Buckrider_Studio_FourInARow3D created.
03-02-2015 02:28:41     INFO    Sent row ID 0 in Buckrider_Studio_FourInARow3D to host at 24.XXX.XXX.X:61336
03-02-2015 02:28:41     DEBUG   Updating, inserting 4 at column 4
03-02-2015 02:28:41     DEBUG   Updating, inserting public at column 5
03-02-2015 02:28:41     DEBUG   Updating, inserting 6 at column 6
03-02-2015 02:28:41     DEBUG   Updating, inserting 7 at column 7
03-02-2015 02:28:41     DEBUG   Updating, inserting 8 at column 8
03-02-2015 02:28:41     DEBUG   Updating, injecting 24.XXX.XXX.X at column 9
03-02-2015 02:28:41     DEBUG   Updating, injecting 61336 at column 10
03-02-2015 02:28:41     DEBUG   Updating, inserting Welcome to Connect four 3D! at column 11
03-02-2015 02:28:41     DEBUG   Updating, inserting 166633197962428130 at column 12
03-02-2015 02:28:41     DEBUG   Internal port is 23466 IPs set as 192.XXX.XXX.X
03-02-2015 02:28:50     INFO    New connection established to 188.XXX.XXX.X:46374
03-02-2015 02:28:50     INFO    Query request from 188.XXX.XXX.X:46374
03-02-2015 02:28:50     DEBUG   Version 2.0.0 connected
03-02-2015 02:28:50     INFO    Fetching existing table Buckrider_Studio_FourInARow3D
03-02-2015 02:28:51     INFO    Connection with 188.XXX.XXX.X closed
03-02-2015 02:28:51     INFO    Removing rows for IP 188.XXX.XXX.X:46374
03-02-2015 02:28:51     INFO    188.XXX.XXX.X:46374 has diconnected
03-02-2015 02:28:51     INFO    New connection established to 188.XXX.XXX.X:46375 (300946669)


texts: Which key bindings to use for switchable primary and secondary attacks?

texts:
I am making a game in which the player can have a primary and secondary weapon (like an ability). These are my current planned key bindings:

 Action | Effect
-----------------
 Click  | Shoot primary weapon
 WASD   | Move
 Space  | Use ability (secondary weapon)
 Q      | Previous primary weapon
 E      | Next primary weapon
 ???    | Previous/Next ability (secondary weapon)

I am trying to think of a way to switch the secondary weapon. Here are some options I have thought of and why I have rejected them:

scroll wheel

some mice don't have scroll wheels

R / F

awkward, also primary weapon switch is horizontal and this is vertical

shift / ???

cannot think of another key

So, what is a good key binding for switching a secondary attack?


texts: Ray Picking: how can I find which copy of model to pick, if they share the same vertices, but each one is translated before being drawn?

texts:
I have a scene, in which I am drawing few different objects - each one has the same vertices and each one is translated to proper place before being drawn.

While using libgdx (but I think that this question should be generic enough to work with other libraries), I try to do ray picking, casting ray and trying to find intersections of given ray with triangles, from meshes of each object. My problem is, that because they all share the same set of vertices, how should I find which one exactly was pointed by user?

As I have no experience in this, I was thinking about translating the vertices for each object and getting rid of glTranslate(x, y, z) called before each one, but in that situation I won't be able to use one copy of mesh to work with all objects.

May I ask for a few hints / links to articles how this should be done?


texts:
I've almost finished a PC game (I'm releasing it in a day or two). I'd like a way to easily release patches over the net in case I find a bug in the game right after release, or in case I want to add features later on.

I am using InstallJammer as my install system. Are there good update/patch programs (preferably free) which can check for and send updates to players over the Internet?

For instance, if a player opens my game, the game first starts the update program that checks for updates. If updates are available, it will let the user know where to get it. I can modify the source code to the game engine I own, but I'd prefer not to re-invent the wheel.


texts: How do game developers make their game available for most of the resolutions?

texts:
I'm developing a game with Java using Slick2D and I want to make a game that could target all the recommended resolutions, as you can see in almost every game you could have an option of changing the resolution. I would like to know how game developers make their game assets once and use different screen resolutions and it still looks good.

My only guess is that when you're in game (playing-moving, jumping) the viewport of the camera is set to some size at the same aspect ratio of the player's monitor.

How do game developers do this? Not just in-game, even when just browsing the menu.


texts: Why does iOS packaging fail when I activate Apple ARKit plugins in Unreal Engine?

texts:
Steps,

Using Unreal Engine 4.21.2

1 - I created new Third Person game from the Unreal Engine template and named it FaceARSample

2 - I imported a skeletal mesh with blend shapes
3 - I added this to my DefaultEngine.ini:

[/Script/AppleARKit.AppleARKitSettings]
bEnableLiveLinkForFaceTracking=true

4 - I packaged the project for iOS and it was successful. I was able to deploy it to my iphone.
5 - I activated Apple ARKit and Apple ARKit Face Support plugins

6 - I packaged the project for iOS and it failed (error log below)


texts: Orthogonal projection and world transform

texts:
I'm reading about projection matrix. Needs of perspective projection is obvious, but I'm not sure about orthogonal projection. Because orthogonal projection effect looks possible with only world transform.

What is main purpose of orthogonal project which make it different with world transform?


texts: Pygame performance issue for many images

texts:
I've made a script for generating a game world based off of image pixel data.

Trying to make a python map editor

My progress so far has resulted in a program which loads an image and draws sprites in positions correlating with the map, like this:

Now the problem is that even for small levels, I'm noticing a drop in frame rate. The provided example level will make pygame drop from 100 fps to 80 fps. If the map is 40 x 40 the frame rate will be around 17.

This is concerning, for two reasons. The program is not doing anything else than drawing images right now, how bad will the frame rate be when game logic is also being calculated every frame? Second, the aim is to ultimately make a two-player strategy game, in which the levels would be significantly larger than the example, and in that case 20 frames per second is way below acceptable parameters.

Every sprite in the game is a 48x48 pixel png image with some portion of transparency. Everything except rendering the sprites is done once when the game starts. This is the only code being run on every frame:

    def draw(self):
    self.screen.fill((0,0,0))

    for e in self.map_layout.fixed_list:
        self.screen.blit(e.picture, e.rect)

I'm guessing pygame's method for rendering images does not scale very well. Windows task manager shows my CPU utilisation at 2% with a map of size 40x40.

My question is: What can I do to improve frame rate? I don't mind switching from (or complementing) pygame to something else, so long as the transition is not very difficult for a novice programmer like myself.


texts: Unity3d wheelcollider falling through terrain

texts:
I have created simple project with 3D car and terrain. I have added 4 Wheel Colliders on model wheels. But when I run project wheels falling through terrain.

Before run:

After run:

I am sure that at start wheel colliders above the terrain and not intersect it. Configuration is:

In what problem is? I have tried a lot of different things but I can't find a solution.


texts: Is it possible to find the distance of a pixel to a rendered sphere, in screen space? All my naive solutions for just using the 2D screen distances are failing because of the warping that occurs during projection.


texts: How can I set random speeds once inside Update?

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

public class Spin : MonoBehaviour
{
    [Range(1, 500)]
    public float[] speeds;
    public bool randomSpeed = false;

    private GameObject[] objectsToSpin;
    private bool randomSpeedInUpdate = true;

    // Start is called before the first frame update
    public void Init()
    {
        objectsToSpin = GameObject.FindGameObjectsWithTag("ClonedObj");
        if (objectsToSpin.Length > 0)
        {
            speeds = new float[objectsToSpin.Length];
            for (int i = 0; i < objectsToSpin.Length; i++)
            {
                if (randomSpeed == true)
                {
                    speeds[i] = Random.Range(1, 500);
                }
                else
                {
                    speeds[i] = 100;
                }
            }
        }
    }

    // Update is called once per frame
    void Update()
    {
        if (objectsToSpin.Length > 0)
        {
            for (int i = 0; i < objectsToSpin.Length; i++)
            {
                objectsToSpin[i].transform.Rotate(Vector3.down, speeds[i] * Time.deltaTime);

                if (randomSpeed == true && randomSpeedInUpdate == true)
                {
                    speeds[i] = Random.Range(1, 500);
                    randomSpeedInUpdate = false;
                }
                else
                {
                    speeds[i] = 100;
                    randomSpeedInUpdate = true;
                }
            }
        }
    }
}

I tried to use a helper flag variable name randomSpeedInUpdate but still when I'm changing the randomSpeed flag to true while the game is running it keep changing the speeds all the time. I want it will change the speeds to random only once when changing it to true.


texts: Fragment processing depends on polygon size?

texts:
I just set up some simple vertex/fragment shaders for handling lighting instead of using the openGL calls. I have a few terrain VBOs setup that are drawing a million or so triangles for testing (bunch of random spikey ground). I noticed that if make the spikey ground spikes higher by multiplying all of their heights by 5, I see the FPS drop from about 98hz to about 44hz.

Searching the web, I found https://www.khronos.org/opengl/wiki/Performance which says "Fragment processing takes longer for large polygons than for small ones", which would explain why I see the decrease.

However, I can't find anything that says why. So my question is, why does fragment processing time vary based on the size of the polygons?


texts: TextMesh Pro conflict in Unity2019.1.5f1

texts:
I'm having an issue with Textmesh Pro in my project. I originally got it from the Asset store a few months ago. More recently, I deleted it and downloaded it from the Package Manager. However, now in my scripts I'm getting the following error when using TextMeshPro class in my scripts:

  The type 'TextMeshPro' in '/Users/unityj/Documents/unity
  vscode/VSCode/FirstGame/Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TextMeshPro.cs'
  conflicts with the imported type 'TextMeshPro' in 'Unity.TextMeshPro,
  Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type
  defined in '/Users/unityj/Documents/unity
  vscode/VSCode/FirstGame/Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TextMeshPro.cs'.
  (CS0436) [Assembly-CSharp]

Tried to uninstall the package via package manager, deleting the package folders, deleting everything that mentions 'TextMesh Pro' and 'TMPro', reimporting all, and reinstalling, but I still get the error. Once TextMesh Pro is uninstalled, the class can't be accessed.

Asset Serialisation mode is set to 'Force Text' and I've set .Net4.x in the Player Settings

Making a new project does not replicate the problem, so I know it's a problem specific to my project, but I don't know where to start. Any suggestions would be appreciated.


texts:
How do I perform range picking in the latest OpenGL version? By range picking I mean selecting all objects which are picked using a selection rectangle, like in an RTS game.

For single object picking I'm using the ray picking method, which I guess can be used in this case as well, but I'm not sure how I should go about doing that.

Could you give me any pointers?

Thank you.


texts: How to copy FrontBuffer to BackBuffer in DirectX11

texts:
I want to render the surface base on the the last surface.
So I try to copy FrontBuffer to BackBuffer, but it does not work:
//Get the BackBuffer(it will be FrontBuffer after SwapChain swapped the BackBuffer and FrontBuffer)
ID3D11Texture2D* backBufferTexture1 = NULL;
swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBufferTexture1);
D3D11_MAPPED_SUBRESOURCE mapResource1;
HRESULT result1 = m_pID3DContext->Map(backBufferTexture1, 0, D3D11_MAP_READ, 0, &mapResource1);
assert(result1 == S_OK);

swapChain->Present(1,0); //swap the BackBuffer and FrontBuffer

//Get the BackBuffer
ID3D11Texture2D* backBufferTexture2 = NULL;
swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBufferTexture2);
D3D11_MAPPED_SUBRESOURCE mapResource2;
HRESULT result2 = m_pID3DContext->Map(backBufferTexture2, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapResource2);
assert(result2 == S_OK);

//Copy the FrontBuffer to the BackBuffer
memcpy(mapResource2.pData, mapResource1.pData, sizeof(mapResource1.pData));
m_pID3DContext->Unmap(backBufferTexture1, 0);
m_pID3DContext->Unmap(backBufferTexture2, 0);

The result1 and result2 both return E_INVALIDARG One or more arguments are invalid. How could I get this to work?


texts: Will reseting a scene instead of reloading it improve performance?

texts: I made a 2D infinite runner. My game was approved for iOS and now pending release. However, on Android, performance is a nightmare. So I'm tweaking to optimize performance. As it stands now, there is game scene and game over scene. On game over scene, there is "Play Again" button that reloads the game scene. Now, if instead of having separate scene, if i handle the play again in same scene, will it be better than reloading the scene? What i could do is, have initial speed, position etc stored in array for example and when play again is clicked, set all gameobjects to the initial values. Will the performance be better with this? since gameobjects are now not getting destroyed and reloaded?


texts:
How to use moveTo?

I do so:

actor.addAction(Actions.moveTo(500, 500, 10));

but he does not move

Thanks you

UPDATE

does not move

my code:

public class MyActions extends ApplicationAdapter {
    private Stage stage;
    private Actor actor;

    @Override
    public void create () {

        stage = new Stage();
        actor = new Actor(){
            {
                setSize(100, 100);
            }
            Sprite actorSprite = new Sprite(new Texture(Gdx.files.internal("badlogic.jpg")), 57, 10, (int)getWidth(), (int)getHeight());

            @Override
            public void draw(Batch batch, float parentAlpha) {
                actorSprite.draw(batch, parentAlpha);
            }
        };

        stage.addActor(actor);
        actor.addAction(Actions.moveTo(500, 500, 1));
    }

    @Override
    public void render () {
        Gdx.gl.glClearColor(1, 1, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        actor.act(Gdx.graphics.getDeltaTime());
        //stage.act();
        stage.draw();
    }
}

what's wrong?


texts: How can I use allocators for different systems?

texts:
I am going over the memory architecture for my game and even though I know my memory budgets may not be final, I am at the point where I can start using them in a general sense. I know that I will need several allocators (for systems such as audio, rendering, etc) but I am unsure of how they will be accessed. I do not use singletons, so I can't just have something such as AudioManager::GetInstance().get_allocator(). Instead, I need to find a different method of usage but I am not sure of how.

How can I store and call my allocators needed for several different systems over engine in an efficient manner?


texts:
I have a teenage son that wants to work in games development and design when he is older. We've been to several conferences that explain the importance of experience when looking for a job. Also being a IT developer myself that often interviews new hires, I know how critical experience is. So we've been looking to try and find him some work at Games Dev companies in London for several weeks over the Summer holidays but haven't got anywhere.

My son is very smart and is expected to get 8+ GCSEs of a high grade (7+ or A/Bs in old marks), he plans go on to get A levels and then study Computer Science at University. He has some programming experience in Python. All he wants is some work experience, if he ends up just running errands and making coffee that would be fine as long as he also gets involved in some way with the games development process. He also doesn't really expect to get paid (although that would be a bonus).

I've approached several companies with details and a CV but haven't had a single response back from them. This seems strange to me as apart from a little of their time these companies don't seem to have anything to lose here.

So my question is, is there something stopping games companies hiring teens in this kind of situation? Any other pertinent advice would be welcome.


texts: Unity + Oculus Rift - Setting field of view or rendering part of display

texts:
I need to render a small portion of the display to a texture.

I found a script to simulate a scissor rect by modifying the projection matrix - Unity 5 doesn't seem to provide any out-of-the-box scissor functionality. However, modifying the matrix in this way causes my scene to render monoscopic.

Suggestions? There used to be an OVRCameraController class that provided a SetVerticalFOV() method, but that appears to have been removed from the SDK.


texts: I was looking at the Unity site, and I was a bit confused with the pricing. It says it's free, but for iOS/iOS Pro or Android/Android Pro. I need to shell out $400 minimum each.  So if I want to develop with Unity for Android and iPhone, I need $800 to do this? (not saying that it's a lot of money, actually seems reasonable, just wondering)


texts:
I want to implement road-map like level graph where in you can see what level are you and your friends are on. Just like we see in Candy Crush Saga.For people who have not seen Candy Crush Saga, please see the image below for your reference.

I want to understand the technology I should be using here. libgdx is one option i keep hearing is best for Android gaming engine. But somehow I feel Unity for Android would provide more bang performance wise.

This is my first try at gaming, please help me understand my options.


texts:
So I have this game project which is going very well for now. I implemented OpenGL stuff, animations, interfaces, and a lot of very nice things that I'm glad I've finally gotten around.

So now that the skeleton of my game engine is made and is solid, I'd like to add AIs to make my entities more lively. Because I like the idea of a game being simple to mod, I would really like to write the AIs in Python files, that would then be read and executed from my C++ code.

So my questions are the following :

It's a game, so performance is a concern. Is it a good idea to write the AIs in scripting files ?
I've heard that there were some JIT compilers such as PyPy, are they easy to use from a C++ program ?
Finally, how easy is it to send C++ objects to be treated in the Python code ?


texts: How to zoom in and out the full tilemap from center in phaser?

texts: I am developing a game where I need to zoom in entire map also I can be able zoom out. I have created a tilemap using tiled software and rendered it using phaser.js. How can I add this function to my game?


texts: Getting width and height of view of game

texts:
well I have googled it and got some answers, asked many times, answered many times.
as I read viewport is the "inside window"
So I have 2 integers, height and width
and this code:

        heightofwindow = graphicsDevice.Viewport.Bounds.Height;
        widtthofwindow = graphicsDevice.Viewport.Bounds.Width;

However, I get the error. It doesnt matter if I put it under update or draw. This seems like a more of language problem due to my limited knowlodge.

Object reference not set to an instance of an object.


texts:
Attempting to set up a targeting array for a MMO-style game in GameMaker8 Pro, I have this code in the create event for the player's character, which is and has been running perfectly fine:

j = 0
i = 0
g = 0
for (i=100000; i<1000000; i+=1) if instance_exists(i) {if i.object_index = enemy         {global.ttarget[j] = i j+=1}  if i.object_index = rk or i.object_index = sage    {global.etarget[g] = i g += 1}}
global.rmtargets = j
global.etargets = g

Then running this code in the step event for the player character:

h = 0
g = 0
i = 0
for (i=0; i<global.rmtargets; i+=1) global.target[i] = 0
global.target[0]=101139
for (h = 0; h<global.rmtargets; h+=1){hv = -1
for (g = 0; g<global.rmtargets; g+=1){if global.ttarget[g].range > hv {hv =    global.ttarget[g].range}}
global.target[h] = hv
global.ttarget[h] = -1}

Returns this error message:

ERROR in
action number 1
of  Step Event
for object rk:

Error in code at line 8: for (g = 0; g hv {hv = global.ttarget[g].range}}
at position 61: Unknown variable range

Even though I have this in the create event for the enemy:

range = 0
range = distance_to_object(rk)

And I've used this sort of syntax all over:

global.target[target].threat[s] += damage

Help? Any ideas why Game Maker won't recognize the variable?


texts: why does a type alias to engine specific header violate encapsulation?

texts:
In a class called Sprite.h my teacher asked this question which I don't fully understand.

A generic interface has to include an engine specific header in order to expose different sprites.
This violates encapsulation between framework and specific engine.
How would you solve this?

Could anyone elaborate what the problem with this is and why this is not advised?

#include <Overlord/Engine.h>
using Sprite = Overlord::Engine::Texture;


texts:
I plan on creating a fighting game in the future, and I'm wondering how to make a roster functionally fair, and feel fair. You see, Super Smash Brothers Ultimate is functionally fair (I think), but at certain times, it doesn't feel fair (partially because I suck at the game).

Mario's up smash is one of the few that can't hit people on the lower platforms of battlefield, however, it still feels fair game somehow (up tilt is my guess). However, when playing against Ness, it can feel unfair to play because the other player can just spam PK Fire (side special) and then smash attack them at high enough HP. In other words, it is fair, but not fun.

How can I avoid something being spammed feeling unfair when creating a fighting game, and all the other moves of characters feel (and actually be) fair?


texts: To what platforms can the blender game engine build to?

texts: I used to use the BGE until I found that unity can build to lots of different platforms. What platforms does the BGE support?


texts:
I'm doing some graphics optimizing tests, especially on PowerVR transparency. Now I made a scene where there are two groups of simple objects. One group has the shape in geometry using diffuse shader and the other with quads using transparency shader. The camera looks through a plane towards a group.

The test was about the "lateness" of PowerVR's Z-tests. And whether or not use better geometry instead of transparencies for e.g leaves or flowers.

The results were not wholly what I expected. The transparency group benefitted from changing the plane from transparent to diffuse by increasing the FPS by 20(expected).

But why is the group without the plane infront so much faster than when the plane is in front?(Not expected) FPS was 38, screenshotting lowered it.

Tests on the geometry group were opposite of what I had learnt in the past few days. There was only 2FPS difference between transparent and diffuse planes. (Not expected). Shouldn't the transparent plane infront cause the whole scene to render as the Z-test is at the bottom of the pipeline?


texts: Two Colliders on the same GameObject for different purposes

texts:
I'm somewhat new to Unity and am trying to build a battle system.
Right now, I have an attack that checks collisions with enemy objects like this:
private void OnTriggerEnter2D(Collider2D other) {
  if (other.gameObject.layer != LayerMask.NameToLayer(_hurtboxLayer))
    return;

  var enemyHealth = other.GetComponent<Health>();
  enemyHealth.TakeDamage(_damagePoints);
}

My game also uses Rigidbody2D objects to let the player and enemies bump into each other.
Because I want the "bumping" Collider2D be different from the hitbox Collider2D, I made a child GameObject called Hurtbox for each enemy.
The Hurtbox objects have a Health behaviour which handles the HP and death of an enemy:
public class Health : MonoBehaviour {

  [SerializeField] private int _initialHealthPoints;
  private int _healthPoints;

  public void TakeDamage(int damagePoints) {
    _healthPoints -= damagePoints;

    if (_healthPoints <= 0) {
      Die();
    }
  }

  private void Die() {
    Destroy(gameObject);
  }

  private void Start() {
    _healthPoints = _initialHealthPoints;
  }

}

The Die method only destroys the hurtbox object and is not allowed to destroy the enemy object, which is its parent.
Is there any way I can put both Collider2Ds and the Health behaviour on the same GameObject and only check a specific Collider in the OnTriggerEnter2D method?


texts: Can I use models of real cars with logos removed to avoid copyright infringement?

texts: My friends and I have recently started making a video game. We were going to make it an open world simulator, but can't figure out if using real cars with the real logos is copyright infringement. How can we stay on the right side of the law here?


texts: Should I use object references or integral values to store pieces in a chess board?

texts:
just a general question regarding a checkers project. I built a class hierarchy for the game pieces (that could be extended for chess etc). The hierarchy looks something like

interface GamePiece() {...}
class EmptySquare implements GamePiece {...}
class Pawn implements GamePiece extends EmptySquare {...}
class Queen implements GamePiece extends EmptySquare {...}

I store an object reference in the board[][] array. In the tree search that array is cloned for each recursion (not with doMove() ... call recursion ... undoMove()). I store object refs for the game pieces so I can do something like this for generating the list of moves:

for(sq:Squares)
    sq.getPossibleMoves()
    possibleMoves.addAll(sq.possibleMoves)

I'm not sure how much space this array of references takes up and if that is any good way to it from a performance point of view. It works nicely logically though. Would you do it like that or sacrifice the nicer code for a more compact game board array and the use switch() to call subroutines for each piece to make the move list?


texts: How to make progress bar in EditorWindow with Threading in Unity?

texts:
I need to make a progress bar in EditorWindow. To do this, I perform the function of calculations in threads: Thread thread = new Thread (_worker.Work); thread.Start (); The class itself emitting calculations looks like this for me (Worker.cs):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Threading;
public class Worker
{
    private bool _cancelled = false;
    public void Cancel() {
        _cancelled = true;
    }
    public void Work() {
        for (int i = 0;i<=100;i++) {
            if(_cancelled)
                break;

            Thread.Sleep(50);
            Debug.Log("i="+i);
            ProcessChanged(i);
        }
        WorkCompleted(_cancelled);
    }
    public event Action<int> ProcessChanged;
    public event Action<bool> WorkCompleted;
}

The PlacementObjects: EditorWindow (PlacementObjects.cs) class looks like this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
using System.IO;
using System.Linq;
using System;
using System.Text.RegularExpressions;
using UnityEditor.IMGUI.Controls;
using UnityEngine.Profiling;
using Newtonsoft.Json;
using System.Threading;

public class PlacementObjects : EditorWindow
{
    private Worker _worker;
    bool pressedbool = false;
    float scaleSlider = 0;
    float scaleMinSlider = 0;
    float scaleMaxSlider = 100;
    [MenuItem("Window/PlacementObjects")]
    static void Init()
    {
        _windowPlacementObj = (PlacementObjects)EditorWindow.GetWindow(typeof(PlacementObjects));
        _windowPlacementObj.titleContent = new GUIContent("Работа с объектами и terrain");
    }
    ...
    void OnGUI()
    {
      DrawFooter();
    }
void DrawFooter()
{

    GUILayout.BeginArea(FooterSection);
        GUILayout.BeginVertical();

            if (!pressedbool)
            {
                GUILayout.Label("Выберите json");
                GUILayout.BeginHorizontal();
                    stringTextFieldURLjsonfile = GUILayout.TextField(stringTextFieldURLjsonfile);
                    if (GUILayout.Button("Обзор...", GUILayout.Width(100)))
                    {
                        stringTextFieldURLjsonfile = EditorUtility.OpenFilePanel("Выбрать json", "", "json");
                    }
                GUILayout.EndHorizontal();
                if (GUILayout.Button("Старт"))
                {
                    _worker = new Worker();
                    _worker.ProcessChanged += worker_ProcessChanged;
                    _worker.WorkCompleted += _worker_WorkCompleted;
                    pressedbool = true;
                    // ProcessJSONPlaceONmap();
                    Thread thread = new Thread(_worker.Work);
                    thread.Start();
                }
            } else {
                if (GUILayout.Button("Стоп"))
                {
                    pressedbool = false;
                }
                scaleSlider = EditorGUI.IntSlider(new Rect(3, 20, position.width - 6, 15), scaleSlider+"%", Mathf.RoundToInt(scaleSlider), scaleMinSlider, scaleMaxSlider);
                EditorGUI.ProgressBar(new Rect(3, 45, position.width - 6, 20), scaleSlider / scaleMaxSlider, scaleSlider+"%");
                Repaint();
            }

        GUILayout.EndVertical();
    GUILayout.EndArea();
}
private void _worker_WorkCompleted(bool cancelled)
{
    Action action = () =>
    {
        string messeg = cancelled ? "Процесс отменён" : "Процесс завершён!";
        Debug.Log("messeg=" + messeg);
        pressedbool = true;
    };

    // if (InvokeRequired)
    //     Invoke(action);
    // else
    //     action();
}
private void worker_ProcessChanged(int progress)
{
    Action action = () => {scaleSlider=progress;};
    // if (InvokeRequired)
    //     Invoke(action);
    // else
    //     action();
    action();
}
}

This code does not update the progress bar.

Found an example of Asynchronous tasks / methods
But here it is not clear how to call StartCoroutine (LoadingRoutine ()) from EditorWindow.


texts: Parallax background positions when jumping

texts:
I am currently building my first Mobile game. The concept is pretty simple, it's a sideways scroller.

I have implemented 5 layers to act as parallax scrolling, these are working quite well for general movement. However they look a bit weak when jumping, I would like to apply some sort of ratio which gives a  3d effect to the jump. I made a basic attempt, however it just looks a bit naff.

I have struggled to find any tutorials on this , could anyone provide any help?

As requested, here is some example code

    backgroundJumpEnd = function(){
    transition.to(hills,{time=600,y=153})
    transition.to(hills2,{time=600,y=153})
    transition.to(hills3,{time=600,y=153})
    transition.to(tree,{time=600,y=153})
    transition.to(trees,{time=600,y=180})
    transition.to(cloudsBig,{time=500,y=cloudsBig.y-6})
    transition.to(cloudsBig2,{time=500,y=cloudsBig2.y-6})
    transition.to(cloudsSmall,{time=500,y=cloudsSmall.y-2})
    transition.to(cloudsSmall2,{time=500,y=cloudsSmall2.y-2})
    transition.to(sky,{time=500,y=sky.y-3})
    transition.to(sky2,{time=500,y=sky2.y-3})
    transition.to(sky3,{time=500,y=sky3.y-3 })
    transition.to(floor,{time=500,y=floor.y-15})
`}`

`backgroundJumpStart = function (){
    transition.to(hills , {time=500, y=180,onComplete=backgroundJumpEnd })
    transition.to(hills2,{time=500,y=180})
    transition.to(hills3,{time=500,y=180})
    transition.to(tree,{time=500,y=185})
    transition.to(trees,{time=500,y=220})
    transition.to(cloudsBig,{time=500,y=cloudsBig.y+6})
    transition.to(cloudsBig2,{time=500,y=cloudsBig2.y+6})
    transition.to(cloudsSmall,{time=500,y=cloudsSmall.y+2})
    transition.to(cloudsSmall2,{time=500,y=cloudsSmall2.y+2})
    transition.to(sky,{time=500,y=sky.y+3})
    transition.to(sky2,{time=500,y=sky2.y+3})
    transition.to(sky3,{time=500,y=sky3.y+3})
    transition.to(floor,{time=500,y=floor.y+15})
}`


texts: Help with Collision of spawned object(postion fixed) with objects that there are translating on screen

texts:
Hey guys I am creating a game using Corona SDK and so coding it in Lua.
So there are 2 separate functions,

To translate the hit objects and change their color when they are tapped
The link below is the code I am using to for the first function
http://developer.anscamobile.com/sample-code/fishies
Spawn objects that will hit the translating objects on collision. Alos on collision the spawned object disappears and the translating object bears a color(indicating the collision). In addition the size of this spawned object is dependent on i/p volume level. The function I have written is as follows:

--VOICE INPUT CODE
local r = media.newRecording()
r:startRecording()
r:startTuner()

--local function newBar()
--    local bar = display.newLine( 0, 0, 1, 0 )
--    bar:setColor( 0, 55, 100, 20 )
--    bar.width = 5
--    bar.y=400
--    bar.x=20
--    return bar
--end

local c1 = display.newImage("str-minion-small.png")
c1.isVisible=false
local c2 = display.newImage("str-minion-mid.png")
c2.isVisible=false
local c3 = display.newImage("str-minion-big.png")
c3.isVisible=false

--SPAWNING
local function spawnDisk( event )
    local phase = event.phase

    local volumeBar = display.newLine( 0, 0, 1, 0 )
    volumeBar.y =  400
    volumeBar.x = 20
    --volumeBar.isVisible=false

    local v = 20*math.log(r:getTunerVolume())
    local MINTHRESH = 30
    local LEFTMARGIN = 20
    local v2 = MINTHRESH + math.max (v, -MINTHRESH)
    v2 = (display.contentWidth - 1 * LEFTMARGIN ) * v2 / MINTHRESH
    volumeBar.xScale =  math.max ( 20, v2 )

    local l = volumeBar.xScale
    local cnt1 = 0
    local cnt2 = 0
    local cnt3 = 0
    local ONE =1
    local val = event.numTaps
    --local px=event.x
    --local py=event.y

    if "ended" == phase then
        --audio.play( popSound )
        --myLabel.isVisible = false

        if l > 50 and l <=150 then
            --c1:setFillColor(10,105,0)
            --c1.isVisible=false
            c1.x=math.random( 10, 450 )
            c1.y=math.random( 10, 300 )
            physics.addBody( c1, { density=1, radius=10.0 } )
            c1.isVisible=true
            cnt1= cnt1+ ONE
            return c1

        elseif l > 100 and l <=250 then
            --c2:setFillColor(200,10,0)
            c2.x=math.random( 10, 450 )
            c2.y=math.random( 10, 300 )
            physics.addBody( c2, { density=2, radius=9000.0 } )
            c2.isVisible=true
            cnt2= cnt2+ ONE
            return c2

        elseif l >=250 then
            c3.x=math.random( 40, 450 )
            c3.y=math.random( 40, 300 )
            physics.addBody( c3, { density=2, radius=7000.0 , bounce=0.0 } )
            c3.isVisible=true
            cnt3= cnt3+ ONE
            return c3
        end
    end
end

buzzR:addEventListener( "touch", spawnDisk ) -- touch the screen to create disks

Now both functions work fine independently but there is no collision happening. Its almost as if the translating object and the spawn object are on different layers. The translating object passes through the spawn object freely.

Can anyone please tell me how to resolve this problem. And how can I get them to collide.

Its my first attempt at game development, that too for a mobile platform so would appreciate all help. Also if I have not been specific do let me know. I'll try to frame the query better :).

Thanks in advance.


texts: Simple scripting language for "one-liner"-type scripts?

texts:
Can you recommend a scripting language which allows me to easily parse "one-liner" types of scripts (they're just commands, really)?

For example, a C/C++ function which simply sets the value of a 2-dimensional vector (position, for example):

void SetVector(Vector2 &vector, float x, float y)
{
    vector.x = x;
    vector.y = y;
}

And in the scripting language, the entire script should be able to just be one line long. For example, this would be a script to set the components of vector "a" to 123.0f and 456.0f (x and y) (syntax of the language doesn't really matter, just as an example):

set_vector a 123,456

I'd use these short scripts to do simple things like change the position of objects during runtime (for debugging or other purposes), create simple config files for all kinds of entities which would go like:

bomb.script:

set_damage 1000
set_range 250
set_texture Data/Sprites/bomb.png

etc.

From a superficial glance, Lua, AngelScript etc. seem to be a little bit bloated for my simple needs (Although I must admit I haven't put tons of time into those two). Can you recommend something better?


texts:
I'm working a spotlight for my deferred renderer and I'm having trouble with matching the mesh to the visual representation of the light. Right now my mesh is a cone, the apex of the cone is at (0,0,0), it has a height of 1 and a radius of 1. The direction of this cone is (0,-1,0) when the rotation is (0,0,0).

The relevant GLSL code:

float spot_alpha = dot(-l,normalize(vec3(0,-1,0) )); // <------
float inner_alpha = cos(light.falloff);
float outer_alpha = cos(light.radius);
float spot = clamp((spot_alpha - outer_alpha) / (inner_alpha - outer_alpha),0.,1.);

As you can see, the GLSL code uses a direction to define the area to be lit, so I could get this direction as a uniform, but I would need to find a rotation from that for the mesh to follow, or I can get the rotation and find a direction, but I don't know how to do either of these things.

Can I rotate a direction? How do I do it? If I can't, is there another solution for this problem?


texts: data structure fails to instantiate GMS2

texts:
Error message:
Data structure with index does not exist.
 at gml_Object_enemy_actor_Step_0 (line 10) -           hand[i] = ds_stack_push(deck);

Code snippit that is referenced in the error message:

if global.phase == 0
{
    //fill inital hand of cards
    if global.turn == 0 && hand[0] = noone
    {
        for (i=0; i<4; i++)
        {
            hand[i] = ds_stack_push(deck);
        }
    }
}

The code that creates the ds_stack

/// @description hold the enemy player's outfit

scale = 0.25;

image_xscale = scale;
image_yscale = scale;

outfit = ds_stack_create();
hand = array_create(8,noone);
//hand[0] = noone;
draw = false;

//create a deck and fill it
deck = ds_stack_create();
fill_deck(deck);

The fill_deck() function just adds usable numbers to the ds_stack

//argument0 is the deck being passed to fill

var temp = ds_stack_create();

for (i=0; i<20; i++)
{
    var index = round(irandom(46));
    ds_stack_push(temp, index);
}

ds_stack_copy(argument0,temp);


texts:
My particle effects have gone crazy look:

In my game, bombs drop on castle and then explode

For the first few second of my game the particle effects for the explosion works.  The particle effects are made using the unity particle systems:

As you can see below, the particle effects in the scene view are also in the game view:

However after a few second the particle effects start to glitch out and while they appear in the scene view, they do not appear in the game view:

Above there is a massive explosion in the scene view but nothing in the game view.

I can make the particle effects work by doing a few weird things:

If I remove the walls on my castle the particles will suddenly work.  The walls just contain a sprite renderer component, no script or anything.

If I make a looping particle effect when the effect is visible on the game screen the particle effects start working but when I drag it off the screen  even though its still working(I see it in the scene view) because its not in the game screen my explosion particle effects instantly stop working.

I am super confused about why this is happening.


texts: Browser game architecture considerations

texts:
I am currently working on a browser game. It's not my first one, but it is the most complex I have worked on to date.

In the past, I would code everything in PHP, and have functions checking whether certain maintenance operations were required or not, carrying them out when necessary (for instance, if players must receive 50 gold every day, I would have a function which checks when was the last time 50 gold were added to each player; if it's less than 24 hours, do nothing; if it's more than 24 hours, then add 50 gold * the number of times 24 hours have elapsed (in case no one has accessed the website in more than a day)).

This worked, but was rather inelegant and resulted in a quite large and complex codebase as the game's features grew.

For my current architecture, I am thinking of having a very elementary front end that just fetches the data from a database and renders it in the browser; when players perform actions from this front end, it adds the actions to an event queue.

Then I would have completely separate server code running 24/7 (written in C++ or Python or whatever) which would be continuously polling the event queue, updating the database accordingly, and also run a set of functions at various intervals (for example, add 50 gold everyday), a bit like cron would.

I think this architecture will be better, as it will allow me to better separate game logic and front end; it will scale better; and it will just make for better code overall.

Are there any considerations/drawbacks with such an architecture?


texts: Where can I find sales figures for PSN Minis?

texts:
I work for a small game studio that develops games for iOS and Android currently. The engine we are building will be portable and our upcoming game is quite ambitious. Therefore we are considering porting it to PSP also, making it available at the PSN as a mini. I have been searching for days now but I am having trouble finding any numbers of what an average PSN mini game can sell. What a hit or a bad game could sell is also really interesting.
As we are trying to calculate if it is worth going into this market any clue would be helpful!


texts: Determining my playable area/field of view

texts:
Contrary to what I found searching for the answer, I'm not trying to see whether a character is in view of another character. What I need to find out is the size of the field of view. This is because I'm using Mercury Particle Engine in a 3D space, and while MPE emitters take parameters ranging from (0,0) being the upper left corner of the screen to (graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight) being the lower right corner of the screen, the positioning of enemy ships use Vector3 values, where (0,0,0) would be the exact center of the screen. Since my ships don't move along the Z axis, this isn't a problem. What is a problem, however, is translating their coordinates in 3D space to the correct particle emitter positions when I need to show them exploding. This is what I'm currently using to create the perspective field of view:

projectionMatrix = Matrix.CreatePerspectiveFieldOfView(
  MathHelper.ToRadians(45.0f),
  GraphicsDevice.DisplayMode.AspectRatio,
  1250.0f,
  1450.0f);

And this is how I'm attempting to obtain the X and Y values for the particle emitter from the enemy ship position (however, the positions are not quite right with my math because I have the wrong constants):

x = ((float)graphics.PreferredBackBufferWidth/2) + (((float)graphics.PreferredBackBufferWidth/1700) * enemy[i].position.X);

y = ((float)graphics.PreferredBackBufferHeight / 2) + (((float)graphics.PreferredBackBufferHeight / 1100) * enemy[i].position.Y);

That being said, how do I calculate the proper constants from the information on hand?


texts:
Hi everyone,

I'm trying to implement a 2D Grid in a simple 3D Editor. Here are some debug-rays I already implemented:

Everything is working as intended as long as the object is not rotated.
For demonstration purpose the box is aligned with the grid center (the purple box).

(I can move the object along the grid without changing the grid location):

Now if I rotate the large white cube I want the grid to rotate as well.

Here is the problem: I dont want the origin of the grid to change it's relativ location. The grid location of the green line should still align with the upper left corner of the large white box.

And I just cannot figure out the offset I have to translate the grid :(

Here is what I've tried:
Calculate the difference between the two collision points (Yellow and Green) and use this as offset but on rotation the offset is too large and the grid is shifting.

Here is the data I have available:

Vector3 Origin = new Vector3();
Vector3 GridPlaneNormal = new Vector3(0, 0, 1);
Plane GridPlane = new Plane(Origin, GridPlaneNormal);
Plane objectPlane = /*.... (it's the plane of the cubes front)*/

Vector3 GridNormalInDirectionOfObject = Vector3.TransformNormal(GridPlaneNormal, Matrix.RotationQuaternion(Object.RotationQuaternion));

float angle = GridPlaneNormal.SignedAngle(GridNormalInDirectionOfObject, GridPlane.Normal);
Vector3 rotationAxis = Vector3.Normalize(Vector3.Cross(GridPlane.Normal, objectPlane.Normal));

Please help me! :)


texts:
I need my enemies to fire at me. I have a script and I think all is correct. I couldnt figure out why it doesnt work?

public class AntagonisticElCreator : MonoBehaviour {

public GameObject boom;
public float enemySpeed;

public bool move=false;
public bool shoot=false;
public Transform character;
Vector3 pos;
int boomnumber;

 public float bulletSpeed;
public float bulletDestroyTime;

public GameObject bulletPrefab;
public Transform bulletSpawn;

void Start () {
   bulletSpeed = 15f;
bulletDestroyTime = 8f;
    NumbarofBullet = 105;
}

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

    pos = new Vector3(character.position.x, transform.position.y, character.position.z);
    distance = Vector3.Distance(transform.position, character.position);
    if (distance < 20){
        move = true;
        shoot = false;
        transform.LookAt(pos);

    }
    if (distance < 10)
    {
        move = false;
        shoot = true;

    }

    if (move)
    {
        transform.position = Vector3.MoveTowards(transform.position, character.position, enemySpeed * Time.deltaTime);
        transform.LookAt(pos);
    }
    if (shoot)
    {
        shootAt();
    }

        void shootAt(){

        Instantiate(explsn, bulletSpawn.transform.position,
        bulletSpawn.transform.rotation);
      var bullet = Instantiate(bulletPrefab, bulletSpawn.position,
      bulletSpawn.rotation);
        bullet.GetComponent<Rigidbody>().velocity = bullet.transform.forward *
        bulletSpeed;

}

}

* */


texts:
I am designing a game in Unity which has NPCs (Non-player controllers). I have worked out the path-finding but I need some help with how to implement tasks. I need the task system to be flexible and allow me to easily add new tasks. I also want to be able to have a task trigger another task.

Example for turning light on:

When mouse clicked on light switch
Wait for available/idle NPC
NPC walks to light switch (Using a walkToPostion(pos) task)
Light turns on
NPC is set to available/idle and can perform another task

Another example could be emptying the trash can:

When trash can is full
Wait for an available NPC
NPC walks to trash can (Using a walkToPostion(pos) task)
Trash can is set to empty
NPC takes garbage bag outside (Using a walkToPostion(pos) task)
NPC walks back into house/given position. (Using a walkToPostion(pos) task)
NPC waits to be given next task.

I haven't done a lot with AI before so some hits on how I could go about implements this would be very helpful.

EDIT: One thing I specifically need help with is performing a task inside a task. How do I pause the TurnOnLight task while the player is doing to WalkToPos task?


texts: Design pattern for menu transitions in C# (Unity)

texts:
I am working on my first project in Unity using C# and I am currently trying to design a menu system that does the following sequence of events when a user clicks a button:

Button does some effect for some milliseconds (for example, flashes)
Menu1 does its closing sequence for some milliseconds (for example, buttons fly off screen)
Menu2 does its opening sequence for some milliseconds (for example, buttons fly on screen)

The exact animations of the UI elements don't matter for the purpose of my question.
So far, the only design pattern I've found to achieve this kind of sequence is by using coroutines. So I ended up with something like the following:
void OnStartButtonClick()
{
    StartCoroutine(_OnStartButtonClick());
}

IEnumerator _OnStartButtonClick()
{
    yield return start_button.GetComponent<ButtonController>().DoEffect();
    StartCoroutine(MenuTransition(main_menu, data_menu));
}

IEnumerator MenuTransition(GameObject menu1, GameObject menu2)
{
    // main menu to data select
    if (menu1 == main_menu && menu2 == data_menu)
    {
        yield return CloseMainMenu();
        yield return OpenDataMenu();
    }
}

public Coroutine OpenMainMenu()
{
    return StartCoroutine(_OpenMainMenu());
}

IEnumerator _OpenMainMenu()
{
    main_menu.SetActive(true);
    // main menu opening sequence here
    yield return null;
}

public Coroutine CloseMainMenu()
{
    return StartCoroutine(_CloseMainMenu());
}

IEnumerator _CloseMainMenu()
{
    // main menu closing sequence here
    main_menu.SetActive(false);
    yield return null;
}

public Coroutine OpenDataMenu()
{
    return StartCoroutine(_OpenDataMenu());
}

IEnumerator _OpenDataMenu()
{
    data_menu.SetActive(true);
    // open data menu sequence
    yield return null;
}

public Coroutine CloseDataMenu()
{
    return StartCoroutine(_CloseDataMenu());
}

IEnumerator _CloseDataMenu()
{
    // data menu closing sequence here
    data_menu.SetActive(false);
    yield return null;
}

And the code on my button likewise utilizes coroutines:
public Coroutine DoEffect()
{
    return StartCoroutine(_DoEffect());
}

IEnumerator _DoEffect()
{
    // imagine some code that does the effect
    yield return new WaitForSeconds(1f);
}

This seems to work well enough and allows me to completely control the effect-->close-->open sequence. But it's getting a bit unwieldy as I build it out for more menus and transitions between them, resulting in a ton of methods with Coroutine return type wrapping IEnumerators (which I've been prefixing with underscore). I can't help but feel like there's a more elegant way to do this, and that I am using coroutines as a crutch ...
So my question is whether there is a more suitable or efficient design pattern that can allow me to achieve the kind of sequencing of events that I want without the proliferation of Coroutines & IEnumerators? Or are Coroutines & IEnumerators exactly the devices to solve this kind of problem?


texts: How can zoom into my object when that object is being clicked?

texts:
Suppose that I have the three game(cube,Quard,sphere) object. When I click on a particular game object suppose think I have clicked on the cube,the cube object should get zoomed in on the screen.

how can I do that?

How do I center and zoom into my cube game object after selecting the  cube? I think it has something to do with the camera but how do I center the view with the camera?

I have used the below code for zooming the object.For one object its working.But when I place different object and apply this code then when i click on one object all the three object is getting zoomed.

Can anyone help me out in solving this issue

Here is the code

  function OnMouseDown()
{
 OrthoZoom(1.5);
}
function OrthoZoom(size : float) {
 var cam = Camera.main;

 while (cam.orthographicSize != size) {
     cam.orthographicSize = Mathf.MoveTowards(cam.orthographicSize, size, speed * Time.deltaTime);
     yield;
 }

}


texts: How do network applications get around firewalls?

texts:
Forgive me if this comes off as naive; I've only a cursory understanding of network communications.

My work has a public and very restrictive network - (they appear to block everything that isn't approved) - and yet I've seen people accessing many games (World of Warcraft for example).  I don't imagine that the network admins made any explicit exceptions for these applications - but when I tried to develop a networked prototype with services like 'Photon Server' or 'Adobe's RTMFP' they all fail from the office due to the network restrictions (can't establish connection).

Is there some kind of work around that applications like WoW employ that distinguish them from an anonymous networked app I've built myself?  (Some kind of fallback channel maybe?)

I appreciate that there might not be enough information here for an answer, but any insights would be welcome.

Thank you!


texts: I wonder if I create bump mapping for my terrain is it good to add detail mapping too? Does such mix improve realism or make it even worse (because there is "too much" of it)? If this improve realism, is it even worth doing that? Maybe it takes a lot of resources for small improvement?


texts: C# - Collision Detection problem with platforms on Monogame(XNA)

texts:
So I am having issues with my platformer that I am developing. I can detect collisions fine when there are a line of parralel blocks or even single blocks. The issue I have is when blocks form an L shape.
  []   for example.
[]

When my character runs into the wall, he sort of just squeaks through and gets zoomed out. I've tried using an else statement that just sends him back a couple pixels back, but it doesn't work because I don't think it accounts for one of the two blocks. Each block is it's own object.

Any help?

This collision code is in my Player class. This is the only detection I have so far in the game. I attempted to use and adjust code from a breakernoid tutorial I found somehwere, and I realized that the code doesn't totally work for what I am doing.

public void checkYCollisions(block[] platforms)
    {

        if (position.Y >= 700)
            grounded = true;
        else
            grounded = false;

        float Xradius = Width / 2;
        float Yradius = Height / 2;
        block collidedPlatform = null;

        foreach (block p in platforms)
        {
            if ((position.X > (p.position.X - p.Width / 2 - Xradius )) &&
                (position.X < (p.position.X + p.Width / 2 + Xradius )) &&
               (position.Y > (p.position.Y - p.Height / 2 - Yradius )) &&
                (position.Y < (p.position.Y + p.Height / 2 + Yradius)))

            {
                collidedPlatform = p;
                break;
            }
        }
        //collisions work for all side of blocks.
        if (collidedPlatform != null)
        {
            if ((position.Y <
                (collidedPlatform.position.Y - collidedPlatform.Height / 1.5 /*+ radius*/)))
            {

                grounded = true;

            }

            else if ((position.Y   >
                (collidedPlatform.position.Y + collidedPlatform.Height / 2 )))
            {
                if(y_vel < 0)
                    y_vel *= -1;
                //player1.direction.Y = -1.0f * player1.direction.Y;
            }

            else
            {
                x_vel *= -2;
            }
        }

I am guessing the issue is because I only have one collided block selected at any time. So I don't really know how to fix it that I can have two blocks selected. Note, once again, this code works for all blocks that are by themselves, or just a horizontal(same x position) line of blocks. It's just that L situation where I run into a corner.


texts: How to make natural-looking paths with A* on a grid?

texts:
I've been reading this:
http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html

But there are some things I don't understand, for example the article says to use something like this for pathfinding with diagonal movement:

function heuristic(node) =
    dx = abs(node.x - goal.x)
    dy = abs(node.y - goal.y)
    return D * max(dx, dy)

I don't know how do set D to get a natural looking path like in the article, I set D to the lowest cost between adjacent squares like it said, and I don't know what they meant by the stuff about the heuristic should be 4*D, that does not seem to change any thing.

This is my heuristic function and move function:

def heuristic(self, node, goal):
    D = 5
    dx = abs(node.x - goal.x)
    dy = abs(node.y - goal.y)
    return D * max(dx, dy)

def move_cost(self, current, node):
   cross = abs(current.x - node.x) == 1 and abs(current.y - node.y) == 1
   return 7 if cross else 5

Result:

The smooth sailing path we want to happen:

The rest of my code: http://pastebin.com/TL2cEkeX

Update

This is the best solution I have found so far:

def heuristic(node, start, goal):
    dx1 = node.x - goal.x
    dy1 = node.y - goal.y
    dx2 = start.x - goal.x
    dy2 = start.y - goal.y
    cross = abs(dx1*dy2 - dx2*dy1)

    dx3 = abs(dx1)
    dy3 = abs(dy1)

    return 5 + (cross*0.01) * (dx3+dy3) + (sqrt(2)-2) * min(dx3, dy3)

def move_cost(current, node):
    cross = abs(current.x - node.x) == 1 and abs(current.y - node.y) == 1
    return 7 if cross else 5

It produces the desired path from the second pic, but does not handle obstacles very well (tends to crawl on walls) and fails to produce optimal paths sometimes on longer distances.

What are some tweaks and optimizations I can apply to improve it?


texts: Can I write plugin/extension to Unity editor?

texts: Is there possiblity to write my own plugin/extension to Unity editor ? I want to write plugin to generate map for me from xml file.


texts: Are there alternatives to Vertex Tweening?

texts:
Now that I'm getting into animating 3D entities in my game, I was wondering what the best approach for this would be. I did some research and came across something called "Vertex Tweening". However, most of these articles (like this one: http://archive.gamedev.net/archive/reference/articles/article2017.html) are from 2003, if not older!

In a DirectX 9 game which makes proper use of HLSL to do its rendering magic, is Vertex Tweening still the way to go these days (anno 2013), or are there other techniques I'm not aware of yet?


texts: Layering with slopes in Unity 2D isometric scene

texts:
I'm newer to Unity so bear with me. I'm using Unity2D and so far I have my character up and walking around, colliding properly with his surroundings, and I've implemented an effective "isometric sorting" script which swaps the order of sprites based on their y coordinate. What I'm trying to do now is create a slope that exists in the middle of the stage or front (bottom of screen). I'll illustrate what I'm trying to do as explaining it is bound to be confusing.

Right now, I have the ability to move the player up the slope, and in front of the slope (using the isometric sorting script), but it seems maybe impossible to also be able to have the player walk behind the slope.

Here's my idea for how this could be accomplished, but I certainly would need some direction.

Basically, I'm thinking if I can detect that the player has crossed the green line in the image, I could use that information to flip a switch ON which would lower the slopes sorting priority (thus lowering it beneath the players feet), then I would need it to deactivate when the Player exits the slope.

Here is the Isometric Rendering script:

    using UnityEngine;

    [ExecuteInEditMode]
    public class IsometricSpriteRenderer : MonoBehaviour {

    void Update ()
    {
         GetComponent<Renderer>().sortingOrder = (int)(transform.position.y *       -1000);
    }
}

Thank you to anyone who bothers to take the time to help me! I really appreciate it!


texts: Is there a reason to add options to not use advanced technologies in a game engine?

texts:
I have been developing a game engine, and have been discovering and reading up on game technologies such as anisotropic filtering, ambient occlusion, anti-aliasing, etc.

Usually in games, you can toggle these settings on and off. However, if these settings only add nothing but positives, is there a reason to add toggle values for these in a game engine for the developer?

I understand that performance is a major factor, but is there any other reason why these settings are always available to change?


texts: Unity) How can i loop animation 'n' times?

texts:
I usually use

currentAnimatorStateInfo.normalizedTime > n

but  is there any better way for this?

I want my animation loop n times and invoke call back.


texts: Evenly distribution of 2 or more shapes given their x and y points inside a bounding box

texts:
I have a set of dynamically shaped objects, How do I distribute them evenly either Horizontally or Vertically.The objects are surrounded by a bounding box and the objects are placed at x,y as shown.

Can anyone help me in providing the algorithm or pseudo code.

UPDATE:
It is clear that, the shapes those stay at extremes (forming a bounded box) are kept constant and the remaining objects inside the space is distributed evenly. I used a word processing application to simulate the above example.

For 2 objects inside,


texts: How to determine an irregular area of a CCSprite?

texts:
In my simple game I use boundingBox for pick coins and other stuff, but I need use irregular area detection of Sprite(with out Alpha)... There is alternative to boundingBox?
Here is code:

-(void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint location = [touch locationInView:[touch view]];
CGPoint point = [[CCDirector sharedDirector] convertToGL:location];
curentPosition = point;
arrToDel = [[NSMutableArray alloc] initWithCapacity:0];

CCSprite *coin = nil;

for (Coins *coins in self.bugs) {
    if (CGRectContainsPoint([coins boundingBox], curentPosition)) {
        coin = coins; // found sprite
    }
}

if (coin != nil) {
    NSMutableArray *checkList = [NSMutableArray arrayWithCapacity:0];

    for (Coins *coins in self.bugs) {
        if (CGRectIntersectsRect([coin boundingBoxInPixels], [coins boundingBox]) && coins != coin) {
            [checkList addObject:coins];
        }
    }

    int max = coin.zOrder;

    for (Coins *b in checkList) {
        if (b.zOrder > max)
            max = b.zOrder;
    }

    if (max == coin.zOrder) {

        [self removeChild:coin cleanup:YES];

        [arrToDel addObject:coin];

        for (Coins *coins in  arrToDel) {

            [self.bugs removeObject:coin];

        }
    }
}

}


texts: In a JRPG Battle system. Who executes the selected action?

texts:
Throughout the JRPG history, we've seen the introduction of many a battle system type. Like the classic turn-based. The ATB. The action battle system  (Most Notable is Kingdom Hearts)

In these systems, there's a variety of skill handlers like a queue or gauge to determine turn. My question put simply is who handles the executing of skills? Is it the Battle system? The Players? The Skill queue if there is one?

Right now I'm working on an ATB styled Final Fantasy in Unity. I'm leaning towards either the player or the battle system executing the commands. I have my players with each a separate state machine (WAIT, COMMAND, ACTION) And a command queue that holds the queued up actions. I can either have the player in the ACTION state and the battle system process the logic(Execute whatever queued up action). Or the player handle that.

Outside of that. I'm curious how it works for the other types of battle systems since I hope others in the future with a similar question can see this.


texts:
I have multiple objects on my isometric game, for example, NPC's doing path finding automatically to walk around the map. Now there could be any number of them from 0 to infinity (hypthetical as no PC could handle that).

My question is: is simply looping each one individually the smartest way to animate them all? Surely as the number of units increases you will notice a lag occuring on units near the end of loop still "waiting" for their next animation movement.

The alternative is a swarm algorithm to move all objects together. Is that a smarter idea or do both situations apply depending on the circumstances of the game?


texts: what makes render() and update() change frame 60 times every second in LibGDX

texts: Whenever we declare the render(float deltatime) or update(float deltatime), in any class, it automatically become a method that is repeated 60 times per second. But what makes this method repeat itself 60 fps? What makes the method do that? In some classes, I am not implementing any other interface or expending any abstract class but that still makes the render(float deltatim) and update(float deltatime) work. Also, even though I do expend a interface like Game, how does the render(float deltatime) work? I mean, there is no special code within the render() in the Game interface class as well.


texts:
I'm trying to use NVENC to encode some frames that I'm capturing from a game. I've hooked EndScene() and I can get the data from the backbuffer, which is in ARGB format.

Unfortunately, NVENC only supports NV12 buffers ("resources") as input. I checked the SDK demo source and I've found that they create their NV12 surfaces using the fourcc code like so:

IDirectXVideoProcessorService * directx_services;
DXVA2CreateVideoService(d3ddev, IID_PPV_ARGS(&directx_services));
directx_services->CreateSurface(desc.Width, desc.Height, 0, (D3DFORMAT)MAKEFOURCC('N', 'V', '1', '2'), D3DPOOL_DEFAULT, 0, DXVA2_VideoProcessorRenderTarget, &NV12_surface[0], NULL);

This works. The problem now is that i need to convert my ARGB buffer into NV12. StretchRect() does not work, and CheckDeviceFormatConversion() returns D3DERR_NOTAVAILABLE, so it doesn't seem like this is possible using high-level API's.

One idea I had was to copy the backbuffer to a texture surface, and then use that texture as an input to a pixel shader when doing some dummy draw operation, and then inside the shader i can do some math to do the conversion from ARGB to NV12. But then i would have NV12 formatted data inside an ARGB render target again. Would i be able to "cast" that to a NV12 buffer, or just use it as an input to my encoder even though the format technically doesn't match, but the data does?

Any ideas?


texts: Get range of hexagon based on specified center

texts:
I have this method to get the cells inside a given N range:

public function getRadius($range, $center) {
    // $center[0] = X or Q
    // $center[1] = Y or R
    $cell = array();
    for ($dx = -$range; $dx <= $range; $dx++)
    {
        for ($dy = max(-$range, -$dx - $range); $dy <= min($range, -$dx + $range); $dy++)
        {

            $ddy = $dy + $center[0];
            $ddx = $dx + $center[1];

            $cell[] = array($ddx,$ddy);
        }
    }
    return $cell;
}

But it returns bad coordinates by adding the offset on the delta X and delta Y.


texts: Changing color of a moving image without lowering the fps

texts:
I just added an option to my game that makes it so that all the enemies will have a random color for their clothes instead of the regular blue. I use this code to draw rectangles over the shirt of the enemy.

BufferedImage image = new BufferedImage(z.getWidth(), z.getHeight(),
    BufferedImage.TYPE_4BYTE_ABGR);
try{
    image = ImageIO.read(new File("C:\\Program Files (x86)\\ZombieGame\\
        Zombie.png"));
}catch (IOException ex) {
}
int j, k, red, green, blue;
    for(j = 0; j < z.getWidth(); j++){
        for(k = 0; k < z.getHeight(); k++){
            Color c = new Color(image.getRGB(j, k));
            red = c.getRed();
            green = c.getGreen();
            blue = c.getBlue();
            if(red == 0 && green == 0 && blue == 178){
                g2d.setColor(Color.red);
                Rectangle r = new Rectangle(j,k, 1, 1);
                Path2D.Double rect = new Path2D.Double(r, at);
                g2d.fill(rect);
            }
        }
    }

The thing is that when I apply this the game will run twice as slow (before I added this code I got a solid 80 fps but as fast as I added it I got around 30 fps). Is there a better way in which I could change the color of specific parts of the image without lowering the fps drastically?


texts:
I'm playing this voxel game named Trove, running it in DirectX, their requirements are DirectX 10 and OpenGL 3.2

The character entity in this game emits light when it gets close to any surfaces (walls, floor, etc). I am assuming that they codded that into these shaders unified files.

I want to put this light on like the smallest value or remove it completely as a personal mod for myself. (the game is very modable, another guy edited these files are moved the glare and the fog, I am interested in doing that too, since a patch came and broke his mod)

So, I was wondering what shading language is that, so that I can look up and learn the right thing to make this work in the end.

This game is free to play on steam.

I've extracted the game files and they have this folder called shadersunified and I've uploaded all the content at indexed shadersunified folder

I am completely new to this kind of modding, I have absolutely no knowledge, but I do know programming like C++, C#, Pawn, Java, Javascript.

I need some directions toward what this game uses so that I know what to look into :D . Or if any of you can do these changes, I would love that even more.


texts: Design pattern for allowing components to interact with main state machine

texts:
I am making a game using Unity in which I have a main game state machine that controls the current game scenario.

My question is how do I handle communication between different components of the game and the state machine in a way that keeps the code decoupled and scaleable and so that the code doesn't turn into a spaghetti later on.

What I have thought so far

Make the state machine a global in a static class or vice versa and allow components to directly call upon its methods
Make a global event dispatcher system allowing the FSM to subscribe to necessary events like changeState() etc and fire them from the component classes with the required data
Use the service Locator pattern to provide the FSM to locator and just use it from anywhere

Which one of these will be suited more for the application keeping it scaleable and reusable no matter how big the code grows?

Or is there any other better way of communication that I am missing out on?


texts:
I have a gameboard grid which is 20 rows high and 10 columns wide with the origin (0,0) being in the top left hand corner.
I have a tetrimino in play, which is composed of four blocks.
I have the x,y location of each block relative to the top left hand corner origin.
I also have the position of the pivot, the point around which I wish to rotate which is relative to the top left hand corner origin.

Each block has an integer position in a gameboard square and thus the pivot has a fractional position inbetween blocks e.g (10.5,10.5)

My question is: Which formula can I use to rotate each block around the pivot?

I have already looked at existing similar questions and answers but could not find an answer that I could get to work.

Help would be much appreciated.


texts: Is it possible to render a particular object on the screen for a certain number of frames without having to delay the rendering? Thanks


texts: Unity - How to don't ignore a layer when Raycasting?

texts:
For example: Physics.Raycast(ray, out hit, range, layerMask), let's say layerMask = groundMask. What I want to do is only return true if it didn't hit a ground mask. Like what I mean is like "Ignore raycast except groundMask". Is there anyway to do this?
Some example:
origin ------------ (groundmask) -------- (other mask) --- // return false;
because there is a ground mask in a range
origin ---------------------------------- (other mask) --- // return true;
because there is no ground mask in a range


texts:
As I've seen corruption in geometry, why is it a bad idea to normalize a homogeneous (divide by w) the vertex position returned from vertex shader?

Update

Vertex shader:

// float4 pos : SV_POSITION;
output.pos = mul( mvpMatrix, float4(input.pos, 1) );
output.pos /= output.pos.w; // this line causes the visual corruption below

Three images as I move to the right of a sphere in wireframe. As I get closer the geometry starts corrupting. It seems the geometry immediately around the camera gets the most corrupt.


texts: Texture Shaders vs. Pixel/Fragment Shaders?

texts:
My question is a simple one.

Functionally, practically, and performance-wise, what are the differences between using a D3DX Texture Shader, and using a Pixel/Fragment Shader rendered with a full width/height quad to a texture?

D3DXCreateTextureShader(
  _In_   const DWORD *pFunction,
  _Out_  LPD3DXTEXTURESHADER *ppTextureShader
);
HRESULT D3DXFillTextureTX(
  _Inout_  LPDIRECT3DTEXTURE9 pTexture,
  _In_     LPD3DXTEXTURESHADER pTextureShader
);

Are the above methods just syntactic sugar for performing the same task?


texts:
I am making a turn based game with tiles, much like Final Fantasy Tactics.
I am trying to develop an algorithm for mapping out a list of available tiles to walk on.
So for example, I am at (0,0) and I have a range of 2 - ie I can walk to any tiles that within two tiles away from me.

Things to account for:

I have a set number of steps I can take - which was 2 in the example above
There may be enemies or walls that will block my path
The tiles are hex-based so I have 6 possible places to move to

The plan is basically to

determine the places I can walk to
if the tile is available, add it to a list of walkable tiles from this location - so that I can use it in a pathfinding algorithm and so that I don't have check this location again

Basically I need an algorithm to map possible paths from a location. I thought of the A*,dijkstra, bfs,dfs but I think they require knowing the nodes beforehand.

Any help would be appreciated, thanks!

P.S. Path-mapping would be a better tag but I can't make a new one.


texts: NullReferenceException being thrown when I try to add a component to a dictionary

texts:
I have the following section of code from a MonoBehaviour class in a voxel engine that I'm currently working on right now:

public void CreateChunk(Position chunkPosition)
{
    GameObject newChunk = (GameObject)Instantiate(
        this.ChunkPrefab,
        new Vector3(chunkPosition.X, chunkPosition.Y, chunkPosition.Z),
        Quaternion.identity
    );

    Debug.Log("New Chunk", newChunk);

    Chunk newChunkComponent = newChunk.GetComponent<Chunk>();
    newChunkComponent.ChunkPosition = chunkPosition;
    newChunkComponent.ParentTerrainManager = this;

    this._ChunksInMemory.Add(chunkPosition, newChunkComponent);

    for(int x = 0; x < Chunk.GlobalChunkSize; x++)
    {
        for(int y = 0; y < Chunk.GlobalChunkSize; y++)
        {
            for(int z = 0; z < Chunk.GlobalChunkSize; z++)
            {
                newChunkComponent.CreateBlock(new Position(x, y, z), new Stone());
            }
        }
    }
}

The Chunk class is also a MonoBehaviour class as well. I'm trying to instantiate a chunk prefab and then get the Chunk component from the instantiated prefab. Unfortunately I get the following NullReferenceException:

NullReferenceException: Object reference not set to an instance of an object
Voxel.Engine.TerrainManager.CreateChunk (Position chunkPosition) (at Assets/Source/Engine/TerrainManager.cs:99)
Voxel.Engine.TerrainManager.Start () (at Assets/Source/Engine/TerrainManager.cs:132)

This is line 99:

this._ChunksInMemory.Add(chunkPosition, newChunkComponent);

The field this._ChunksInMemory is simply a Dictionary<Position, Chunk> containing all the currently loaded chunks.

I have done the following things so far:

I have confirmed that the TerrainManager MonoBehaviour class (the one that contains the above section of code) does in fact have a chunk prefab assigned:

I have confirmed that there is in fact a copy of the chunk prefab by looking at the hierarchy and calling Debug.Log("Chunk created", newChunk).

I have confirmed that the copy of the chunk prefab has a Chunk component attached to it:

At this point, I am clueless as to why my code isn't working. Just from looking at the code, it should work fine, but it doesn't. Does anyone know why this is happening?


texts:
I'm new to UE4 (4.24 on Ubuntu 16.04) and I'm using AirSim and the Blocks world.
Whenever I create a C++ class, I get the following message:

"Successfully added class 'MyActor', however you must recompile the 'Blocks' module before it will appear in the Content Browser. Failed to automatically compile the 'Blocks' module".

And here is my Message log:

WARNING: Library 'stdc++' was not resolvable to a file when used in Module 'AirSim', assuming it is a filename and will search library paths for it. This is slow and dependency checking will not work for it. Please update reference to be fully qualified alternatively use Public System Library Paths if you do intended to use this slow path to suppress this warning.

ERROR:'/home/user/AirSim/Unreal/Environments/Blocks/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Blocks/MyActor.generated.h': Changes to generated code are not allowed - conflicts written to '/home/user/AirSim/Unreal/Environments/Blocks/Intermediate/Build/Linux/B4D820EA/UE4Editor/Inc/Blocks/MyActor.generated.h.conflict'.

The .h and .cpp are created in a Source folder within Bocks and AirSim, but nothing appears in the "Content" folder where initially I right clicked it to add a C++ Class. I've tried closing UE4 but I've no idea how to open the Source folder on UE4, and the files do not appear in the Content folder.
I've already searched for this error message, I've found some things, but they couldn't solve my issue.
Can anyone help?
TIA


texts: Manually remove inactive CCParticleSystem from scene?

texts: When using particle systems that have a lifetime, with CCParticleSystem and its derived classes, should I manually remove the finished systems from their parent nodes once the particle animations are complete? Or this is done automatically? I don't want to leave dead particle systems in my scene, for obvious reasons.


texts:
I have added RigidBody component as well as Mesh collider to an object moved with keyboard. I know that it the object will go through another (with RigidBody and Mesh collider too) if I use transform to move the object. Could you give me example of code how to move an object with RigidBody. Here is my current code (still using Transform)

if (Input.GetKey(KeyCode.RightArrow))
{
    character.transform.position += Vector3.right * speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.LeftArrow))
{
    character.transform.position += Vector3.left * speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.UpArrow))
{
    character.transform.position += Vector3.forward * speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.DownArrow))
{
    character.transform.position += Vector3.back * speed * Time.deltaTime;
}


texts: SpriteBatch.Draw has Padding on Monogame.Android

texts:
I am using Monogame to create a small Android game.
I am trying to draw a sprite to the Android screen but it seems to have a padding of some pixels. The same game works fine on desktop.

How can I remove the padding?
The graphic itself has no borders etc; the problem is also reproducible with any other sprite.

I have created a new project in VS2019 with the Monogame templates for VS2017 and tried to reproduce this behavior in a new project.

It seems that the problem has something to do with the notch of my emulator.
In an emulator without a notch the problem seems to be non existent.
I found this thread on the Monogame community but it hasn't got any answers.

My source code looks in its simplest form now as follows:

    private Texture2D _texture;

    protected override void LoadContent()
    {
        spriteBatch = new SpriteBatch(GraphicsDevice);
        _texture = Content.Load<Texture2D>("BasicTV");
    }

    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);
        spriteBatch.Begin();

        spriteBatch.Draw(_texture, Vector2.Zero, Color.White);

        spriteBatch.End();
        base.Draw(gameTime);
    }

The result of this code is this:

The Game is compiled for Android 8.1 and I use the Monogame framework 3.7.1.


texts: Why the loop is never working in the Waypoints?

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

public class Waypoints : UnityEngine.MonoBehaviour
{
    public List<GameObject> waypoints = new List<GameObject>();
    public Animator _animator;
    public int waitTimeBeforeGo;
    public int num = 0;
    public float minDist;
    public float speed;
    public bool rand = false;
    public bool go = true;
    public bool loop = false;
    public bool waitTime = false;
    public float smoothRotation;

    private bool lastPoint = false;

    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        float dist = Vector3.Distance(gameObject.transform.position, waypoints[num].transform.position);

        if (waitTime == true)
        {
            StartCoroutine(WaitBeforeGo());
        }
        else
        {
            if (go)
            {
                //_animator.SetBool("Walk", true);

                if (dist > minDist && lastPoint == false)
                {
                    Move();
                }
                else
                {
                    if (!rand)
                    {
                        if (num + 1 == waypoints.Count)
                        {
                            if (loop == true)
                            {
                                num = 0;
                            }

                            lastPoint = true;
                            //_animator.SetBool("Idle", true);
                        }
                        else
                        {
                            num++;
                        }
                    }
                    else
                    {
                        num = Random.Range(0, waypoints.Count);
                    }
                }
            }
        }
    }

    public void Move()
    {
        Quaternion lookOnLook =
 Quaternion.LookRotation(waypoints[num].transform.position - transform.position);

        transform.rotation =
        Quaternion.Slerp(transform.rotation, lookOnLook, Time.deltaTime * smoothRotation);

        gameObject.transform.position += gameObject.transform.forward * speed * Time.deltaTime;
    }

    IEnumerator WaitBeforeGo()
    {
        yield return new WaitForSeconds(waitTimeBeforeGo);

        waitTime = false;
    }
}

For some reason when it's getting to this part it keep doing this part over and over again like in a endless loop and never continue :
if (num + 1 == waypoints.Count)
                            {
                                if (loop == true)
                                {
                                    num = 0;
                                }

                                lastPoint = true;

It keep doing the lines num = 0 and lastPoint = true all the time in a loop and never continue to the rest of the code.
For example there is only 1 waypoint it's moving to the waypoint but never get back it's staying at the waypoint. The loop(ping pong) is never working.


texts: How to crop or mask a sprite to a specific shape in Unity (2D)?

texts:
I'm trying to do a procedural 2D terrain generation. I've managed to make the function to generate the points, and I've been testing/debugging by creating the terrain using a 2D polygon collider on an object.

Now that it's done, I want to use this shape to crop a large sprite using the shape so that I obtain the shaped terrain. If I have a square terrain sprite, is there any way to crop the top or mask it to the shape of the polygon collider (or the shape of the function I'm using).