texts: Why are the inputs not changing the animation on keypress?

texts:
I have been following this tutorial. You can watch 16:00 - 18:20 to see what I am trying to do.

What should be happening is: I press a key, my animation plays and the parameters or Inputs get updated depending on which key I press. There are no errors in my script, but the parameters or Inputs are not updating. I have checked that I am using floats and that all my names match up. I've watched this part of the video and checked that my code was exactly like his multiple times. When using the model that he used in the video, the inputs the inputs are working fine. So would this mean there is something wrong with my animation, or is this an issue in my script?

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour
{
    public Animator anim;

    private float inputH;
    private float inputV;

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

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("1"))
        {
            anim.Play("Armature|Walking", -1, 0f);
        }
        if (Input.GetKeyDown("2"))
        {
            anim.Play("Armature|TurnRight", -1, 0f);
        }
        if (Input.GetKeyDown("3"))
        {
            anim.Play("Armature|TurnLeft", -1, 0f);
        }
        if (Input.GetMouseButtonDown(0))
        {
            int n = Random.Range(0, 2);

            if (n == 0)
            {
                anim.Play("Armature|Walking", -1, 0f);
            }
            else
            {
                anim.Play("Armature|TurnRight", -1, 0f);
            }
        }
        inputH = Input.GetAxis("Horizontal");
        inputV = Input.GetAxis("Vertical");

        anim.SetFloat("inputH", inputH);
        anim.SetFloat("inputV", inputV);
    }
}

Anyone got any ideas?


texts:
I'm trying to find useful information on creating game levels in a reasonably efficient way.
Additionally, information in setting up a fairly painless way to edit this information would be handy (the closest I've come is some monstrosity in Flash; I would place the parts onto the stage, and run a script reading all the platforms, triggers and what have you, into an XML document).

Google hasn't been to terribly helpful in finding what I need (probably what terms I'm using as I'm not sure exactly how I would refer to this). I'm hoping there may be someone here who knows of a good solid article on handling the data for a level.

I've made a few attempts in previous projects (the latest being in Flash using XML), and I often run into issues with performance (in my case, I narrowed it down to having to many objects loaded, and started culling what was outside my view, was still slow though...).

To clarify a bit. I'm not afraid of investing time in developing tools. I don't have a specific game I am making this for so much as I am wanting to learn about the theory behind a level editor and the files it would generate to be used as a level. I'm looking to understand what goes on in a program and thus far have been un-successful in finding anything to help educate me on what makes such a system tick.

I am particularly interested in knowing how to make one that's 'good' rather than 'works'. I've already gotten something working in XML on my own, however it was poorly structured and excessively slow for relatively small levels. I am sure there are better ways to organize the information for loading and using on the screen, its more a matter of me being unsure what to use. I've heard talk of using binary space trees, quad or oct trees, however I haven't found much related to using them in a tool. (Most of what I have found is academic and more or less to abstract to make use of outside of theory)


texts: How to use 2D textures in OpenGL / WebGL for physics

texts:
Following along the answer here, it was mentioned about textures:

  They can also store things like velocities. For example, you can use a texture as a "flow field" for animating particles or other objects. They can even be used to control geometry. You can sample a texture in a vertex shader, for example, and use the result to determine how to transform the vertex.

That is a new idea to me, using it for physics stuff! That is pretty cool.

I am implementing a 2D game where there will be basic physics like gravity, light shining, things rotating and orbiting like planets, things moving fast and slow, plants blowing in the wind, things flying and flapping wings, things cracking like rocks, water flowing (simple 2D water, nothing fancy), smoke billowing, etc.

I'm wondering some specific ways I can apply textures and shaders to these physics problems, rather than implementing them on the CPU like you typically see. My understanding of shaders so far is that they are purely for mapping position  and color into the graphics renderer, so that's all I'm using them for currently. But I have tried to imagine how I could use shaders (and now textures) for velocity so I could optimize the calculations for how everything is moving around, and I don't see how it's possible. Same with calculating the geometries. It seems you need that hierarchical calculation (iterative computation) which you can't do in the GPU, for calculating relative positions of all the stuff relative to everything else (or just their parent). But if you could somehow batch GPU calculate that, that would be super cool.

Other physics things that might benefit from the texture system are raycasting. I can imagine having a 2D light like the sun, and it shines and creates shadows on the 2D objects from the side. Wondering what some pseudocode of OpenGL/WebGL might look like for that perhaps (if it is using shaders and textures only). Wondering if it's even possible to get it to work if it's only using shaders and textures, not completely implemented in JavaScript or the main CPU.

Another physics thing is just the motion of things (smoke billowing, wings flapping, water moving or splashing, leaves blowing in wind force, etc.). The sub question is if I can calculate these velocities (and hence, positions) directly using WebGL/OpenGL/the GPU, not simply calculating them on the CPU. Wondering if you could direct me to any resources/examples demonstrating how to do this in greater detail.

But the main question is simply if one could explain how you would go about generally implementing raycasting, velocity calculations, or other force calculations, using only shaders and textures, and/or perhaps some resources that describe how to do this. I would like to implement these in my game and there is a big architectural difference implementing them in shaders/textures vs. on the CPU, so it would be helpful to figure this out first.


texts: Efficient Rendering for multiple light sources

texts:
I'm building a 3D rendering engine using C++ and OpenGL.

Right now, I've added support for multiple light sources in my GLSL shaders, but I've hit a bit of a bump for my rendering methods.

I'm worried about my engines performance if it has to render a lot of objects for a lot of light sources.

The straight-forward approach would be something like this:

for every object to be rendered
    closestLights []

    for every light in the scene
        if (light closer than all lights in closestLights)
            swap furthest light from closestLights with current light

    loadLightSourcesToShader(closestLights)

    renderObject(object)

However, I'm afraid the performance of this rendering-loop will degrade quickly since when either the amount of lights or the amount of objects increases, the amount of calculations will rise even quicker.

1) Is there any way to circumvent this?

2) How is this implemented in 'real' engines?

3) How can I find the closest K lightsources to an object efficiently?

I've heard about kd-trees and octrees, but I feel like building a tree everytime I render is probably worse than what I'm thinking about doing right now.

4) I could keep an octree and a kd-tree for every object (which keeps track of all other objects), which when using (smart) pointers, could be quite efficient in terms of time (but not space?).

Is this a good approach?

I know the saying 'Premature optimization is the root of all evil', but I'm pretty sure this WILL become a problem when a game/program reaches a certain complexity/size.


texts: How to make the wheels rotate depending on the speed of the vehicle

texts:
I want to know what the right formula is, or a way to make the wheels rotate with the speed of the vehicle?
What is the standard way to make wheels look realistic and natural? Do developers use other techniques?

Thank you for helping


texts: How Can I Separate a Mesh Into Two Separate Objects Without Corrupting UV Data?

texts:
I'm working in Blender and Unity.

I downloaded my character from DeviantArt here, used Blender along with this addon to import  the character's .mmd file to Blender, and saved her as a .blend file in my Unity project's folder. For some reason, when Unity imported her, her textures weren't appearing, so I created new materials and assigned them to the proper slots on the mesh renderer and she looks the way she should:

Now I'm trying to get my character's clothing physics working. I read online that Unity's Skinned Mesh Renderer and Cloth components are the best solutions, but it recommends that the cloth objects be child objects of the main body mesh. However, the character's clothing that I wish to add physics to (her skirt) is a part of the overall mesh.

So, in Blender I selected all of the vertices that make up the skirt and separated them from the main mesh, then saved a skirt.blend file containing just the skirt, then saved another blend file containing everything but her skirt:

After this process, the textures for the main mesh look just fine in Blender, and the UV data looks exactly the same except for the missing vertices that made up the skirt:

However, when Unity imports these files, it looks like the UV data is corrupted:

What's going on here? How can I fix the UV data for the main mesh?


texts: How to hide all console output in Panda3d?

texts:
Whenever I start my Panda3d application, i.e. initialise the ShowBase class, I get the following console output:

Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)

The application works fine, so I would like to suppress these lines.
How can I disable/hide this output?

Also, what does this mean exactly?


texts:
So with the new Animator system, Unity has smartly allowed us to pre-hash the strings for looking up variables within the Animator state machine, using the Animator.StringToHash static method. This lets us access the animator variables every frame without needing to perform hashing calculations each time, allowing a nice optimization.

What I'm wondering is if there is any way to do the same for the Input.GetAxis method, since it isn't overloaded with an Integer parameter option, it seems there is not, but I wanted to confirm that.

Am I overestimating the performance boost, and is there another method for accessing inputs in a faster manner?


texts: Photon Realtime, StripKeysWithNullValues cause heavy GC Alloc

texts:
In our current project, we use Photon room properties to sync entities. and i noticed some heavy GC Allocs while deep profiling the game and it always ends down to this method.

Have anyone faced this issue before ? or attempted to fix it ? here is the source code of that method.

/// <summary>
        /// This removes all key-value pairs that have a null-reference as value.
        /// Photon properties are removed by setting their value to null.
        /// Changes the original passed IDictionary!
        /// </summary>
        /// <param name="original">The IDictionary to strip of keys with null-values.</param>
        public static void StripKeysWithNullValues(this IDictionary original)
        {
            object[] keys = new object[original.Count];
            original.Keys.CopyTo(keys, 0);

            for (int index = 0; index < keys.Length; index++)
            {
                var key = keys[index];
                if (original[key] == null)
                {
                    original.Remove(key);
                }
            }
        }


texts:
I am currently working on a board game in Java with libgdx. It is supposed to be a multiplayer game, that you can play across multiple computers and for the sake of simplicity, I use kryonet.

Even though I assume my friends are no cheaters, I want all the game logic to happen on the server. This is for learning purposes, so I get to know a clean approach of anti-cheating.

However, I have been looking for design approaches for days now and really can't get my head around how I am supposed to handle actions, their verifications and distributions. You can think of the game as turn-based and similar to Monopoly, it especially has some sort of randomness (drawing event-cards).

At first, I came across FSM and thought it would be a perfect approach, because I could easily let a state process the input and send a corresponding package to the server, who does the validation and broadcasts it to the other clients, who then.. Yeah, what do they do with it? Simply updating the model (as of "Player 1 is not at tile 8) doesn't make too much sense, because I would then not have any actions, such as walking, state transitions, etc. (the game is running in an update method, with a delta parameter, so you usually step your game forwards here).

The second approach I came across was an "action" approach, that strongly discouraged the use of a FSM, because they would easily get too big and too complicated to understand later on. Every Action would have an "isvalid()" function, so the server could check the model for the action to be legal and then broadcast it to the clients to "take action" (pun intended). Here again, I feel the need of a FSM on the server side, so I can validate, whether an action would be legal or not.

Do you think it is fine to mix two approaches? Is there an major point in my understanding of the approaches, that is entirely wrong and leads me to some misconception?

Thanks in advance and have a good weekend!


texts: Uniforms stop working when loading multiple programs via glUseProgram()

texts:
The rendering keeps happening, and the debugger shows my camera is getting its position updated properly, but for some reason the camera doesn't appear to have its position updated. I'm not sure what I'm doing wrong.

Can uniforms fail to get set when swapping between different programs/shaders?


texts: OpenGL - Drawing multiple meshes at once using VBOs and IBOs

texts:
I have been learning OpenGL 2.1 but using shaders, VBOs, IBOs, etc. I have gotten a rendering engine that can load and draw meshes, materials, forward lighting (no shadows yet), SceneNodes, and NodeComponents. There are no optimizations yet (for obvious reasons) such as occlusion culling, only Face culling at the moment.

A mesh (simplified) class looks like this:

struct Mesh
{
    GLuint vbo;
    GLuint ibo;
    GLuint size;

    void draw(Program* shaderProgram) const
    {
        glEnableVertexAttribArray(shaderProgram->attrib("vertPos"));
        glEnableVertexAttribArray(shaderProgram->attrib("vertTexCoord"));
        ...

        glBindBuffer(GL_ARRAY_BUFFER, vbo);

        glVertexAttribPointer(shaderProgram->attrib("vertPos"), 3, GL_FLOAT, false,
                              sizeof(Vertex), (const GLvoid*)(0 * sizeof(float)));
        ...

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

        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

        glDisableVertexAttribArray(shaderProgram->attrib("vertPos"));
        ...
    }
}

When I have been drawing multiple objects with the same mesh (or multiple meshes), I notice a frame drop compared to a single mesh with the same number of triangles.

Stanford Models were used.
(1 Face = Triangle)
| Model  | Num Models  | Total Faces | With Lighting | Without Lighting |
| -      | -           | -           | ms / frame    | ms / frame       |
|--------|-------------|-------------|---------------|------------------|
|        | 0 (control) |        0    |  0.47         |  0.41            |
| bunny  | 1           |    69630    |  1.2          |  0.64            |
| bunny  | 14          |   974820    | 12.4          |  3.50            |
| buddha | 1           |  1087474    |  7.87         |  2.89            |
| buddha | 10          | 10874740    | 71.4          | 23.8             |

I does look like that time/frame is ~O(n). However, drawing one vbo with 12% more faces, the frame time is decreased by 37%.

So my questions are:

Is drawing multiple VBOs actually worse than drawing one big one?
How would I combine these VBOs and IBOs into one big one if this is true?


texts:
I want to create a particle effect when my player sprite collide with my star sprite. How can I add a particleSystem in the sprite and not in a image?
Also, I wish if it could wait for the animation for some miliseconds, and then remove the star sprite.

This is my code:

- (BOOL)ccPhysicsCollisionBegin:(CCPhysicsCollisionPair *)pair starCollision:
    (CCNode *)star playerCollision:(CCNode *)_player {
    NSLog(@"----------Colisao---------");

    //update score
    score += 1;
    [scorelabel setString: [NSString stringWithFormat:@"score: %d",score]];
    NSLog(@"score %d", score);

    CCParticleSystem *particleSystem = [[CCParticleSpiral alloc] initWithTotalParticles:1000];

    [self addChild:particleSystem];
    //[particleSystem release];
    //[particleSystem setTexture:[[CCTextureCache  sharedTextureCache] addImage:@"star.png"];

    //remove stars
    [star removeFromParent];
    return YES;
}


texts:
What is the best way to handle a moving camera inside many shader programs?

I believe most games need to have one common projection matrix inside all shader programs to use a moving camera. Currently my approach will be to make one global camera object, with which I update every shader program.

I would imagine this gets a bit tedious and possibly heavy once I actually have many programs which to update every movement. So I'd like to construct the program well right away and avoid problems down the road.

What have you done about this, if anything? Do you try to share shader programs between objects?


texts: Writing a minimalistic server for vanilla WoW

texts:
This is about a personal project I've been longing to do for some time now. Since a while now I have stopped playing WoW, but as I'm quite experienced in C++ I thought I'd try the following:

Write a minimalistic server for
vanilla WoW for experimental,
personal purposes

All it would feature is being able to login with a fixed character, and being able to travel around in the standard maps (non-instance; Kalimdor, eastern kingdoms, etc.) I also don't want to use / modify existing projects such as Mangos in this case, as this would be all about the development process and trying it on my own

My questions to you:

Is the above a realistic objective?
How much work would such a project
require? (Boilerplate code excluded,
just the basic stuff to make the
client "happy")
Do you have any other recommendations
for me regarding this?


texts: Endless level support in modern engines?

texts:
Do any of the "next gen" engines support endless 3d levels?

The general idea for my game will require the ability to stream a level seamlessly (no loading screens), similar to games like for example Minecraft, where land is dynamically created based on where the player is going to.

I could not find any information about whether or not engines like Unity 5, Unreal 4 or Cryengine 3 support this and would love to get some insight on this.


texts: How can I run and jump at the same time?

texts:
I'm having some trouble with the game I started.
http://testing.fyrastudio.com/lab/tweetOlympics/v0.002/
The thing is that i have an athlete running and he must jump at the same time. A race with obstacles.

I have him running (with pressing the letter Q repeateadly). I also have him jumping (with letter P)
But the thing is that when he runs and jumps at the same time, he seems to be jumping at the same place, instead of going forward with the jump... any ideas how can I fix this??

This is the code I'm using for running and jumping on a continuos loop.

//if accelearing and the last time that he accelerated was less than X seconds ago, hes running an accelaring
     if (athlete.accelerating && timeCurrent - athlete.last_acceleration > athlete.delay_acceleration) {
      athlete.accelerating = false;
      athlete.last_acceleration = timeCurrent;
      athlete.running = true;
     }
     if (!athlete.accelerating && timeCurrent - athlete.last_acceleration > athlete.delay_acceleration) {
      athlete.decelerating = true;
     }
     if(athlete.decelerating && timeCurrent - athlete.last_deceleration > athlete.delay_deceleration){
      if(athlete.speed >= 1){
       //athlete starts to decelarate
       athlete.last_deceleration = timeCurrent;
       athlete.decelerate();
      }else {
       athlete.running = false;
      }
     }
     if (athlete.running) {
      athlete.position += athlete.speed;
     }
     if (athlete.jumping) {
      if (athlete.jump_height < 1) {
       athlete.jump_height = 1;
      }else {
       if (athlete.jump_height >= athlete.jump_max_height) {
            athlete.jump_height = athlete.jump_max_height;
            athlete.jumping = false;
       }else {
            athlete.jump_height = athlete.jump_height * athlete.jump_speed;
       }
      }

     }
     if (!athlete.jumping) {

      if(athlete.jump_height > 1){
       athlete.jump_height = athlete.jump_height * 0.9;
      }else {
       athlete.jump_height = 1;
      }
     }

     athlete.scaleX = athlete.scaleY = athlete.jump_height;
     athlete.x = athlete.position;

Thanks!


texts: Mcreator (Minecraft Mod-making) Compile Error

texts:
I'm trying to make a tool pack but every time I get the message:
New Dep: net.minecraftforge:forge:1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1
> Task :compileJava FAILED
C:\Users\MCreatorWorkspaces\tree\src\main\java\net\mcreator\tree\item\ObsidianAxeItem.java:43: error: illegal start of expression
                     new ItemStack(, (int)(1))
                                   ^
C:\Users\MCreatorWorkspaces\tree\src\main\java\net\mcreator\tree\item\ObsidianHoeItem.java:43: error: illegal start of expression
                     new ItemStack(, (int)(1))
                                   ^
C:\Users\\MCreatorWorkspaces\tree\src\main\java\net\mcreator\tree\item\ObsidianPickaxeItem.java:43: error: illegal start of expression
                     new ItemStack(, (int)(1))
                                   ^
C:\User\MCreatorWorkspaces\tree\src\main\java\net\mcreator\tree\item\ObsidianShovelItem.java:43: error: illegal start of expression
                     new ItemStack(, (int)(1))
                                   ^
C:\User\MCreatorWorkspaces\tree\src\main\java\net\mcreator\tree\item\ObsidianSwordItem.java:43: error: illegal start of expression
                     new ItemStack(, (int)(1))
                                   ^
5 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 7s
1 actionable task: 1 executed
BUILD FAILED


texts:
I'm making a 2D game and I'm starting to think about graphics. I'm pretty good at 3D modelling, but I'm not very good at drawing or painting. I was wondering if there were settings, or even a renderer that someone could recommend that could achieve the nice painted look found in Aquaria.

Thanks.


texts: Problems putting my game in fullscreen on GameMaker

texts:
All the rooms in my game have the size of 1280x720, so normally my game runs like this:

When I try to enable fullscreen, none of the game's buttons respond to clicks, but the keyboard still works. So in the initial menu I clicked on the button to go to the settings room (image 1) and nothing happened, but when I typed "c" on my keyboard went to the settings room:

OBS - There is a distortion, but not the view in that image (I had to convert image 3 to jpg, because in png it was over 2MB in size).

I've thought about switching to 1920x1080 and hiding the title bar, but I'd really like to do things the "right way".

EDIT 1 - Another way to enable full screen. (It also does not work)

create event:

window_set_fullscreen(true);

EDIT 2 - By doing a few tests I noticed that when it is in full screen, the clicks behave as if it had a ghost room at the top left of the screen. Like this:

That is, I click the right side of the word music (in blue) and the language changes.

OBS - The buttons in my game are mostly sprites that I mapped and added a global left pressed event.


texts:
This days I'm refactoring code and one of the things I want to improve is my entity manager code. More precisely, the update funcion where entities are updated. My engine is a 2D tile based engine that I'm using for an iphone game. The idea I had was to have the entity update splitted in several tasks because I'm willing to move to component based entities when I have the time. This is a Physic task, a collision detection task, AI task, etc...

For long time I have been using a simple update() function for my entity update that was called by the entity manager in a loop. Now I have come across another way to do it (in the end it is the same) but gives me some advantages like for example differnt ticks for the different tasks (Physics can run at a differnt refresh rate than collisions, etc...)

Here is the source code. I would be really happy if anyone could comment, give opinions, or improve it. Sorry ti is ObjC but I think it is pretty easy to understand:

//Run the update process o nall entities.
for(int i=0; i< numGameObjects;++i)
{
    GameObject* go=_entities[i];

    //If this game object was marked to be delted don't do any process with it.
    //It will be released when update loop is finished.
    if(! [go isToBeDeleted])
    {
        //Player does its physics (Movement, etc...)
                    //We save old position to let the onMapCollision know
                    //The previous position before physics were applied.
        CGPoint oldPos=[go position];
        [go doPhysics];

        if([go collisionEnabled])
        {
            //Check collisions against map
            CollisionMask collisionMask=[go collisionMask];
            if(collisionMask & MapEntity)
            {
                bool collision=[self checkEntityVsMapCollision:go];
                if(collision==true)
                    [go onMapCollision:oldPos];
            }

            //Check collisions against other entities (just the ones that have not been checked previously)
            for(int j=i+1; j < numGameObjects; ++j)
            {
                GameObject* otherGO= _entities[j];
                EntityType type=[go type];
                if( (collisionMask & type) && [go collidesWith:otherGO])
                {
                    [go onEntityCollision:otherGO];
                    [otherGO onEntityCollision:go];
                }
            }
        }

        //Execute AI for this game object
        [go doLogic];
    }
}

There could be some sintactical errors in the code but I just wanted to show the idea. Sorry for the long question, but I thought I had to explain everything as clear as I could.

Thanks in advance.


texts: How to make "Shaky mouse cursor" Before shoot the target Like in a Dart Game?

texts:
I develop a shooting game. To make it harder I want to make the reticle shaky/move randomly.

I use Robot class to move random as suggest here.

But I modified it by adding an infinity loop and by surrounding it in a new Thread.

The shaky mouse cursor is running well, but I can't shoot the target because the infinity loop holds mouseClicked(MouseEvent e) to make a response. I'm confused because I've already tried to make a special thread for the random displacement of the mouse cursor but it still makes no response for my mouseClicked(MouseEvent e).

Any idea/solution please?

UPDATED POST :
i include the code here :

In GPanel.java :

1. For handle input from mouse hardware (from user when clicked the mouse)

@Override
public void mouseClicked(MouseEvent e) {
     int x = e.getX();
     int y = e.getY();
     System.out.println(ter.getInnerX()+"---------------"+ter.getInnerY());
    System.out.println(x+"=========================="+y);

   if(x>=ter.getInnerX()&&x<=ter.getInnerX()+54)
   {
       System.out.println("masuk");
       if(y>=ter.getInnerY()&&(y<=ter.getInnerY()+95))
       {
           System.out.println("kena");
       }
   }
}

2. Robot class Implemented :

@Override
public void run(){

while (true){
    try {
        updateCar();
        checkCollision();
        keylistener();
        Thread.sleep(20);
Robot robot = new Robot();
Random random = new Random();
boolean masuk=true;
int SECONDS=40;
while (true) {
    if(masuk)
    {
        robot.mouseMove(MouseInfo.getPointerInfo().getLocation().x+1, MouseInfo.getPointerInfo().getLocation().y);
        Thread.sleep(SECONDS);
        robot.mouseMove(MouseInfo.getPointerInfo().getLocation().x+1, MouseInfo.getPointerInfo().getLocation().y+1);
        Thread.sleep(SECONDS);
        robot.mouseMove(MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y+1);
        Thread.sleep(SECONDS);
        robot.mouseMove(MouseInfo.getPointerInfo().getLocation().x-1, MouseInfo.getPointerInfo().getLocation().y+1);
        Thread.sleep(SECONDS);
        robot.mouseMove(MouseInfo.getPointerInfo().getLocation().x-1, MouseInfo.getPointerInfo().getLocation().y);
        Thread.sleep(SECONDS);
        robot.mouseMove(MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y-1);
        masuk=false;
    }
else
    {
        robot.mouseMove(MouseInfo.getPointerInfo().getLocation().x-1, MouseInfo.getPointerInfo().getLocation().y);
        Thread.sleep(SECONDS);
        robot.mouseMove(MouseInfo.getPointerInfo().getLocation().x-1, MouseInfo.getPointerInfo().getLocation().y-1);
        Thread.sleep(SECONDS);
        robot.mouseMove(MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y-1);
        Thread.sleep(SECONDS);
        robot.mouseMove(MouseInfo.getPointerInfo().getLocation().x+1, MouseInfo.getPointerInfo().getLocation().y-1);
        Thread.sleep(SECONDS);
        robot.mouseMove(MouseInfo.getPointerInfo().getLocation().x+1, MouseInfo.getPointerInfo().getLocation().y);
        Thread.sleep(SECONDS);
        robot.mouseMove(MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y+1);
        masuk=true;
    }

}
    } catch (Exception e) {
        e.printStackTrace();
    }
    repaint();
}}

Number 1 for detect user's input by click the mouse.

Number 2 for implemented Robot.class to make shaky mouse cursor.

Both of number 1 and 2 are in GPanel.java


texts: cant add unity scripts to obects "unity_csc.bat not found. Is your Unity installation corrupted?"

texts:
I got a new computer and on it I installed unity and signed in etc. when I load it up however and try adding scripts to objects in the scene it doesn't add them and has this error:
"cant add script component because the script class cannot be found".
I thought it might be something in the script but everything i tried didnt work even from the forums. I made sure it had the same name and the monobehaviour was there and everything. I even got a working script from a prior game i made on my other computer and put it in but it still didnt work. So i thought something was wrong with visual studio. However the last time i was playing around with visual studio and its installs my computer got sent into a bsod reboot loop and then just didnt turn on and it had to get re-imaged. The only other error that could be causing the scripts to not add maybe was this error that i got in the console:
"Exception: 'C:\Program Files\Unity\Hub\Editor\2019.1.8f1\Editor\Data\Tools\RoslynScripts\unity_csc.bat' not found. Is your Unity installation corrupted?"
However the worse part is that that file already exists
please help! I need to gamedev on this computer!
thanks in advance;


texts: Shadow & sorting issues with vertex colored PBR Shader Graph

texts:
I'm working on a custom shader using Unity 2018's new shader graph feature. Previously, I was using this shader, which worked great for awhile, but it ended up constantly breaking for seemingly no reason. I was also limited to how I could modify it, since I didn't know much about coding custom shaders.

Unity's shader graph option is exactly what I need, and I'm hoping to recreate what I was using before in the graph. So far, I was able to get vertex colors and alpha transparency working. But, there's still a few issues:

1) Shadows show through transparent faces, no matter how high the alpha value is for those colors:

2) When looking at transparent objects behind other transparent objects, there is an obvious sorting error. All objects belong to the same mesh, so the best way I can think of is to hide transparent faces behind other transparent faces. I was able to figure out how to modify the previous shader's code to achieve this, but am not sure how to implement this functionality in the graph.

3) Shadows are all the same, no matter the alpha value for vertex colors. The previous shader modified the strength of the shadows to be relative to the transparency of each face.

Is there a way to address these issues when using a PBR Shader Graph? Any help is appreciated; this is the basic setup I have so far:


texts: Triangulation A* (TA*) pathfinding algorithm

texts:
I need help understanding the Triangle A* (TA*) algorithm that is described by Demyen in his paper Efficient Triangulation-Based Pathfinding, on pages 76-81.

He describes how to adapt the regular A* algorithm for triangulation, to search for other possibly more optimal paths, even after the final node is reached/expanded. Regular A* stops when the final node is expanded, but this is not always the best path when used in a triangulated graph. This is exactly the problem I'm having.

The problem is illustrated on page 78, Figure 5.4:

I understand how to calculate the g and h values presented in the paper (page 80).

And I think the search stop condition is:

if (currentNode.fCost > shortestDistanceFound)
{
    // stop
    break;
}

where currentNode is the search node popped from the open list (priority queue), which has the lowest f-score. shortestDistanceFound is the actual distance of the shortest path found so far.

But how do I exclude the previously found paths from future searches? Because if I do the search again, it will obviously find the same path. Do I reset the closed list? I need to modify something, but I don't know what it is I need to change. The paper lacks pseudocode, so that would be helpful.


texts: How can I design lots of different attack types that can be combined?

texts:
I'm making a top down 2D game and I want to have a lot of different attack types.  I'd like to make the attacks very flexible and combine-able the way The Binding of Isaac works.  Here's a list of all the collectibles in the game.  To find a good example, lets look at the Spoon Bender item.

  Spoon Bender gives Isaac the ability to shoot homing tears.

If you look at the "synergies" section, you'll see it can be combined with other collectibles for interesting yet intuitive effects.  For example, if it combines with The Inner Eye, it "Will enable Isaac to fire multiple homing shots at once".  This makes sense, because The Inner Eye

  Gives Isaac a triple shot

What's a good architecture to design things like this?  Here's a brute force solution:

if not spoon bender and not the inner eye then ...
if spoon bender and not the inner eye then ...
if not spoon bender and the inner eye then ...
if spoon bender and the inner eye then ...

But that will get out of hand very fast.  What's a better way to design a system like this?


texts:
I would like, if it's possible, to use Emscripten code generated from C/C++ with the Javascript library three.js. For example, from emscripten code I want to pass rendering information to the three.js that will be showed in the browser.

So, can someone give me an idea of how to do that?


texts:
I have dynamically generated images in WorldSpace Canvas and I need to put them somehow on shield that crashes. Is it possible tu put that canvas on mesh shader texture or render it on texture?
How can I solve this problem?
Thank you for advice.


texts: What maps sizes did old 2D RTS games like C&C and WarCraft support?

texts: I'm looking for the size (in tiles) of the maps for the old 2D games Command and Conquer and Warcraft 1 and 2.


texts: Check collision between instantiated objects?

texts:
I am using a script to instantiate multiple objects having rigidbody with different velocities at different positions. I want to destroy two or more objects when they collide, but I'm not getting anything inside:

void OnCollisionEnter(Collision collision){}

The details of the object I'm instantiating. http://i.imgur.com/rLnOM.png

The script is attached to an empty GameObject and Instantiated GameObject is stored in a array of GameObjects:

 Block[0] = Instantiate(boxPiece) as GameObject;

where boxPiece is the Object I want to instantiate.
And I'm checking for collisions in this very same script.


texts:
Let me get this out there before anything else: this is a learning exercise for me. I am not a game developer by trade or hobby (at least, not seriously) and am purely delving into some AI- and 3D-related topics to broaden my horizons a bit.

As part of the learning experience, I thought I'd have a go at developing a basic card game AI.  I selected Pit as the card game I was going to attempt to emulate (specifically, the 'bull and bear' variation of the game as mentioned in the link above).  Unfortunately, the rule-set that I'm used to playing with (an older version of the game) isn't described.  The basics of it are:

The number of commodities played with is equal to the number of players.
The bull and bear cards are included.
All but two players receive 8 cards, two receive 9 cards.
A player can win the round with 7 + bull, 8, or 8 + bull (receiving double points).
The bear is a penalty card.
You can trade up to a maximum of 4 cards at a time.  They must all be of the same type, but can optionally include the bull or bear (so, you could trade A, A, A, Bull - but not A, B, A, Bull).

For those who have played the card game, it will probably have been as obvious to you as it was to me that given the nature of the game, gameplay would seem to resemble a greedy algorithm.  With this in mind, I thought it might simplify my AI experience somewhat.

So, here's what I've come up with for a basic AI player to play Pit... and I'd really just like any form of suggestion (from improvements to reading materials) relating to it.

Here it is in something vaguely pseudo-code-ish ;)

While AI does not hold 7 similar + bull, 8 similar, or 8 similar + bull, do:
    1. Establish 'target' hand, by seeing which card AI holds the most of.
    2. Prepare to trade next-most-numerous card type in a trade (max. held, or 4, whichever is fewer)
    3. If holding the bear, add to (if trading <=3 cards) or replace in (if trading 4 cards) hand.
    4. Offer cards for trade.
    5. If cards are accepted for trade within X turns, continue (clearing 'failed card types').
        Otherwise:
            a. If only one card remains in the trade, go to #6.
                Otherwise:
                    i. Remove one non-penalty card from the trade.
                    ii. Return to #5.
    6. Add card type to temporary list of failed card types.
    7. Repeat from #2 (excluding 'failed card types').

I'm aware this is likely to be a sub-optimal way of solving the problem, but that's why I'm posting this question.  Are there any AI- or algorithm-related concepts that I've missed and should be incorporating to make a better AI?  Additionally, what are the flaws with my AI at present (I'm well aware it's probably far from complete)?

Thanks in advance!


texts: Good technological solutions to build an ascii map and moving characters in a browser (like dwarf fortress)?

texts:
I'd like to build a webapp for my game website that involves using text characters to represent animals and people, and have them move around on map squares with independent (server driven) AI.

So essentially, a dwarf-fortress map in the browser:

With moving creatures, mobs, npcs and pcs.  Though not that I'm not looking to acheive this scale, I'd probably start of showing a quarter of this content or so at any time.

Probably some of the background/immobile tiles could be loaded statically.  But for creatures/animals and things that can move, I'm not sure what technology solutions would be most effective.

I'm aware of <canvas> though I don't know whether its capabilities fit this use case.  Certainly some amount of javascript is going to be necessary.

Are there javascript libraries or canvas libraries out there that fit this use case?  Another technology that I am not aware of?  Anyone know of any examples of websites that have done anything similar to this, so that I can crib ideas from them?


texts:
I am facing a problem in mapping 3d co-ordinate to screen co-ord . I require it because i want to draw text on the model . model is drawn at the 3d-cordinate, so if i know the position of that co-ord on the screen i can draw text at that position.

my view is on z axis
test position is on x axis

In the follwing code I did what i said above but the transformation is not happening the way it should i.e, text should appear on the model

float aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
Vector2 screenOrigin = new Vector2(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2);
Vector3 testPosition = new Vector(10,0,0);
Vector3 cameraPosition = new vector(0,0,50),

Matrix world = Matrix.Identity;
Matrix view = Matrix.CreateLookAt(cameraPosition,Vector3.Zero, Vector3.Up);
Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f);

Matrix totalEffect = world * view * projection;

Vector2 spritePos = getXYPosition(vecAndMatMultiplication(testPosition, totalEffect))+screenOrigin;

Where vecAndMatMultiplication() multiplies vector with the matrix and getXYpostion() should be fairly obvious.


texts: Is there any reason to use a "canvas" based approach to GUI in isometric games?

texts:
When designing game engine GUI systems, I know a lot of game engines (notably Unity and Unreal) use a sort of "canvas" system. However, in an isometric game where the camera is already orthographic, this seems like it might be overkill. Everything is already dictated in terms of pixels, as is the case in an isometric game; I feel that there would be little need for such a "canvas", which seems to be the bridge between world space coordinates and screen space coordinates.

With the orthographic view, world space is more seamlessly joined with screen space, so wouldn't it be simpler to get the position of the camera, define a set of points (i.e. top-left, top-right, center, etc.) on a plane that is directly in front of the camera and render controls directly in front of the camera? Would there be any downsides to this method, or am I missing the point entirely?


texts: Working in large play-area maps, what are the performance and practical differences between Unreal Terrain and a subdivided OBJ mesh terrain?

texts:
I've managed to reliably use SRTM Geotiff Raster Data with some modifications to create decent terrains in unreal, but there is a small problem with how I go about city-building when I'm not using the actual terrain from unreal in my modelling program, especially with roads and other wide-area constructs.  If I were to convert my heightmap to a mesh object for use and manipulate in modelling programs instead of using the unreal terrain, what sort of difference in performance or stability would it make?  What about load times?

Would it make a large impact with object meshes for building exteriors included in the object mesh for the terrain, thus reducing the amount of information needed to load both the buildings and terrain by a small amount?

EDIT: title, player should have been play-area


texts: Making icons for a Google Play Store game

texts:
I'm a little confused.

I've created a game using the Unreal Engine and I plan to publish in about a month. I knew my app needed an icon, but I was on Google's developer site yesterday and I saw a whole BUNCH of guidelines for icons, and there are several kinds. They say something about placing different versions of the icon in my 'resources' directory, but I didn't develop in Android Studio. I thought I would just be making one 512x512 icon, and uploading my APK (plus the other info).

Could someone who has used Unreal and published to the Play Store please help me :) Do I really have to make so many icons?


texts:
I'm new to game development and I want to know how to create a tile map. The map should be divided into squares, such that each square represents a location like x : 10, y : 10.

The width and height of the squares, as well as the number of squares, should be configurable.

How can I do this? (I'm using MVC .NET.


texts: Problem with folder structure and building project in UE4

texts:
I created a new C++ project on Unreal Engine 4. After that I close visual studio and ue4 editor. I manually added public and private folders in the source folder. Then I made folders for the player, items, AI and gamemodes.

The problem appears when I create a new class, the files appear in the respective folders but not in the editor. To fix this I open the visual studio project and I press the build solution. I restart the editor and the classes appear in the folder structure.

The real problem starts here. When i double click any class. A new visual studio appears, ue4 shows the progress bar on the bottom right corner with the text "Loading visual studio". After a couple of seconds a new visual studio pops up. A new screen appears saying that the project is opened on another visual studio and now will migrate all info to a temp folder.

Now I can't code because any attempt at using a C++ class by dragging it into the editor viewport instantly crashes UE4.

What am I doing wrong? What is the correct workflow for creating folder structures in UE4? There is no documentation on how to do this properly.


texts: How to find the optimum path, on a road, for a car?

texts:
For the moment I have an AI car, that follows points (let's call this Waypoints), that I built by myself.

Of course, it's not optimal because of my poor human hand, and car knowledge.

After this drawing, I put waypoints (about 80) on this red line, and my car is able to follow it (and dodge other cars, but that's another story).

But... It's not perfect: I read some articles, but I don't know how to  implement the generation of the perfect path..

http://www.drivingfast.net/techniques/racing-line.htm (speaking about an 'Apex', but I don't know how to find this particular point)
"Searching for the Optimal Racing Line Using Genetic Algorithms" (too complicated for my little game)


texts: Blur effect on background to make the forground more clear unity

texts:
I'm making a game in unity and I'm trying to add a background blur effect to my game to make things a bit more clear.

Here is an example of what I am looking to do:

I'm trying to get the background blurriness and cloudy effect, but I have no idea how to go about getting a similar effect. It looks like a blur + cloudiness of some sort, but I've tried blurring my background objects and it just looks terrible.

Here is what I currently have:

I'm using Unity, it's all 2D sprites so I don't think I can use shaders, which is the only solution I could find people talking about, and have no idea how to proceed. Any help would be appreciated, Thanks.

Edit: Even knowing the terms I could use to search for a solution would help as I'm not quite sure what it is called.


texts: Partnership vs. Limited Partnership vs. LLC for not-serious gamedev project

texts:
Me and one friend are getting close to releasing our first game to the App Store. Right now we're registered as a "partnership" with the IRS. I don't expect to make much money, and I have a day job so it doesn't matter too much anyway.

In this situation, what would the benefits of registering an LLC be? I really just want simplicity of taxes and legal stuff. The limited liability seems nice in some sort of crazy disaster scenario, but how likely is that to actually happen? We haven't hired anyone, and all our assets are royalty-free ones from the Unity Asset Store or similar. We've done all the coding ourselves. Our game is a straightforward, pay-a-couple-bucks-up-front, no in-app purchases or ads, type of business model.


texts: Decide which scoring system to use and number of points to assign for new game

texts:
I am developing a new game and would like to know if anyone could point me in the right direction for deciding the type of scoring system to use for my new game as well as the number of points to assign to enemies and rewards so to make the game exciting to play. I remember to have read something re this in a maths' paper/assignment during my undergraduate but cannot remember what it was about any more. I think it was something to do with game theory and the formula allowed to work out the 'best' number of points to assign to enemies and rewards as well as well as their frequency within the game so that the game would always be theoretically achievable but never/ or almost never possible to achieve the highest score. There might have been something else some other assumption but I really cannot remember more about it. Does this ring a bell to anyone?

Can anyone point me to the right track if you've kind of know what this is about?

Thank you!


texts: SDL Texture not scaling to the renderQuad

texts:
I'm building a Space Invaders clone and using a sprite sheet for my invaders, but when I grab the texture from the sprite sheet, it doesn't scale to the renderQuad that I set.
This is the original sprite map - https://imgur.com/YHdc552 (I'm only using the sprites in the left 2 columns)
This is the output - https://imgur.com/jYlcSpr
This loads in the BMP file
bool AnimationManager::loadFromFile()
{
    free();

    SDL_Surface* loadedSurface = SDL_LoadBMP("SpriteSheet.bmp");
    if (loadedSurface == NULL)
    {
        return false;
    }
    else
    {
        spriteSheetW = loadedSurface->w;
        spriteSheetH = loadedSurface->h;
        InvaderSpritemap = loadedSurface;
        loadMedia();
        return InvaderSpritemap != NULL;
    }
}

This blits the surface from the spritesheet, this is then converted into a texture
SDL_Texture* AnimationManager::getTexture(SDL_Renderer* renderer, int health, int invaderType, int animationState)
{
    SDL_Surface* invaderSurface = SDL_CreateRGBSurface(0, 40, 40, 32, 0, 0, 0, 0);
    SDL_Texture* invaderTexture = NULL;

    switch (health)
    {
    case 1:
        SDL_BlitSurface(InvaderSpritemap, &invaderSprites_redHealth[invaderType][animationState], invaderSurface, NULL);
        break;
    case 2:
        SDL_BlitSurface(InvaderSpritemap, &invaderSprites_orangeHealth[invaderType][animationState], invaderSurface, NULL);
        break;
    case 3:
        SDL_BlitSurface(InvaderSpritemap, &invaderSprites_greenHealth[invaderType][animationState], invaderSurface, NULL);
        break;
    }

    invaderTexture = SDL_CreateTextureFromSurface(renderer, invaderSurface);
    return invaderTexture;
}

This draws the invaders to the screen.
void Invader::draw(SDL_Renderer* renderer, SDL_Texture* text)
{
    SDL_Rect renderQuad;
    renderQuad.x = XPos;
    renderQuad.y = YPos;
    renderQuad.w = Width;
    renderQuad.h = Height;

    SDL_RenderCopy(renderer, text, NULL, &renderQuad);
    SDL_RenderPresent(renderer);
}


texts: Strange artifacting with textures (Pseudo 3D)

texts:
I'm using SFML to make a pseudo 3d engine (Technically not software rendered since SFML uses OpenGL) and things are going rather swimmingly, but then I tried to make another wall, the picture says everything:

The artifact gets worse the closer you get to the wall on the left.

And the Code...

#include "Quad3B.h"

Quad3B::Quad3B() {
    pos = sf::Vector3f(0, 0, 1);
    size = sf::Vector3f(1, 1, 0);
    shape = sf::VertexArray(sf::Quads, 4);
    c = sf::Color::Red;
    color = true;
}

Quad3B::Quad3B(sf::Vector3f p) {
    pos = p;
    size = sf::Vector3f(1, 1, 0);
    shape = sf::VertexArray(sf::Quads, 4);
    c = sf::Color::Red;
    color = true;
}

Quad3B::Quad3B(sf::Vector3f p, sf::Vector3f s) {
    pos = p;
    size = s;
    shape = sf::VertexArray(sf::Quads, 4);
    c = sf::Color::Red;
    color = true;
}

Quad3B::Quad3B(sf::Vector3f p, sf::Vector3f s, sf::Color c) {
    pos = p;
    size = s;
    shape = sf::VertexArray(sf::Quads, 4);
    Quad3B::c = c;
    color = true;
}

void Quad3B::loadTexture(string path, sf::Vector2f ts) {
    color = false;
    tex.setRepeated(true);
    tex.loadFromFile(path);
    texp = sf::Vector2f(ts.x * tex.getSize().x, ts.y * tex.getSize().y);
}

void Quad3B::dr(sf::Vector3f camPos, sf::RenderWindow &window, float hw, float hh, float rat) {
    bool draw = true;

    shape[0].position = sf::Vector2f((((pos.x + camPos.x) * rat) / (pos.z + camPos.z)) * hw + hw, (-(pos.y + camPos.y) / (pos.z + camPos.z)) * hh + hh);
    shape[1].position = sf::Vector2f((((pos.x + camPos.x) * rat) / (pos.z + camPos.z)) * hw + hw, (-(pos.y + size.y + camPos.y) / (pos.z + camPos.z)) * hh + hh);
    shape[2].position = sf::Vector2f((((pos.x + size.x + camPos.x) * rat) / (pos.z + size.z + camPos.z)) * hw + hw, (-(pos.y + size.y + camPos.y) / (pos.z + size.z + camPos.z)) * hh + hh);
    shape[3].position = sf::Vector2f((((pos.x + size.x + camPos.x) * rat) / (pos.z + size.z + camPos.z)) * hw + hw, (-(pos.y + camPos.y) / (pos.z + size.z + camPos.z)) * hh + hh);

    if (color) {
        shape[0].color = c;
        shape[1].color = c;
        shape[2].color = c;
        shape[3].color = c;
    }
    else {
        shape[0].texCoords = sf::Vector2f(0, texp.y);
        shape[1].texCoords = sf::Vector2f(0, 0);
        shape[2].texCoords = sf::Vector2f(texp.x, 0);
        shape[3].texCoords = sf::Vector2f(texp.x, texp.y);
    }

    if (pos.z + camPos.z < 0) { draw = false; }
    if (draw) { if (color) { window.draw(shape); } else { window.draw(shape, &tex); } }
}

Quad3B::~Quad3B() { }


texts: Does glScissor affect stencil and depth buffer operations?

texts:
I know glScissor() affects glColorMask() and glDepthMask(), but does it affect the stencil and depth buffers?

For example:

glEnable(GL_DEPTH_TEST);
glEnable(GL_SCISSOR_TEST);
glEnable(GL_STENCIL_TEST);

glScissor(X,Y,W,H);

// Is this color mask set only for the scissor area?
glColorMask(TRUE,TRUE,TRUE,TRUE);
// Does this stencil function only work within the scissor area?
glstencilfunc(GL_ALWAYS);
// Does the stencil function only work within scissor area?
glstencilop(GL_KEEP,GL_KEEP,GL_KEEP);
// Is this depth  mask set only for the scissor area?
glDepthMask(GL_TRUE);
// Does this depth function only work within the scissor area?
glDepthFunc(GL_ALWAYS);


texts:
Lately I've been working on a small personal project which is basically an Entity Component System framework with autoupdated Systems.

While I have a pretty good idea on the way the framework should work, because of lack of experience I am having trouble with actually keeping everything decoupled.

Some details on the framework:

Each entity is defined by it's components.

Systems are responsible for the actually modifying the entities by changing their components.

In order to improve locality of reference, instead of keeping each component in the appropriate entity, all components are stored in homogenous vectors and each entity keeps a list of indices to each vector.

Since each System modifies specific components, it should keep a list only of the entities with the corresponding components. This 'registration' to the Systems happens whenever a component is added or removed from an entity.

How I dealt with all of this until now was to have a ComponentManager, an EntityManager and a SystemManager. These classes however have very tight coupling with each other. The EntitManager needs to have access to the ComponentManager in order to handle the size of the the index lists and the mapping of each component type to them. It also needs access to actually add the components in the appropriate vector. Another coupling is between the EntityManager and the SystemManager. Whenever an entity is created, it needs to be added to the list of the appropriate Systems.

A general event bus would appear to help but I am not sure how to implement it without making it global.

How do I improve this design by removing coupling while still maintaining the system's functionality?


texts: Am I allowed to make my Minecraft clone open source?

texts:
I'm developing in my spare time a game like Minecraft. In fact, it isn't "like Minecraft", because I'm trying to make it a close as possible copy of it (meant as exercise for myself at the age of 16 and simply because of it is fun to me). Of course, I'm not copying the code using the Minecraft Coder Pack (MCP). I started the game from scratch in Java using OpenGL.

So, my question is: am I allowed to put my source code online on a public source code versioning host like GitHub, Google Code, et cetera (which makes my code open source, because I don't want to pay to use a private host)? Of course, I don't want to sell the game, because the game is from Notch.

A detail which might be important is that I'm using a custom texture pack (so, not the one that is shipped with the real Minecraft).

If it is allowed, are there any rules? I took a look to this page, but it seems that he doesn't say anything about this: http://www.minecraft.net/terms

Edit: There is the game called Terasology (started under the name Blockmania) from Begla. That is a nice project, but it is not meant to be as close as possible to Minecraft. That project is open source.


texts: Instanced rendering with ARB_vertex_attrib_binding

texts:
I'm trying to separate the vertex format specification from the vertex data. I was able to do that for the mesh vertices successfully. For instanced rendering I wanted to further separate the instance data (i.e. model matrices). Here is what I'm trying out, but nothing is rendered.

Loading the data:

glGenBuffers(1, &vbo_instanced);
glBindBuffer(GL_ARRAY_BUFFER, vbo_instanced);
glBufferData(GL_ARRAY_BUFFER, n_instances * sizeof(glm::mat4), ModelArray, GL_STATIC_DRAW);

Vertex format:

glGenVertexArrays(1, &vao_instanced);

glBindVertexArray(vao_instanced);

glEnableVertexAttribArray(0);
glVertexAttribFormat(0, 3, GL_FLOAT, GL_FALSE, 0);
glVertexAttribBinding(0, 0);

glEnableVertexAttribArray(1);
glVertexAttribFormat(1, 3, GL_FLOAT, GL_FALSE, sizeof(glm::vec3));
glVertexAttribBinding(1, 0);

glVertexBindingDivisor(1, 1);
for(int i = 0; i < 4; i++){ //Model Matrices
    glEnableVertexAttribArray(2 + i);
    glVertexAttribBinding(2 + i, 1);
    glVertexAttribFormat(2 + i, 4, GL_FLOAT, GL_FALSE, sizeof(glm::mat4));
}

When rendering I do the following,

glBindVertexArray(vao_instanced);
glBindVertexBuffer(0, vbo_mesh, 0, sizeof(Vertex));
glBindVertexBuffer(1, vbo_instanced, 0, sizeof(glm::mat4));
glDrawArraysInstanced(GL_TRIANGLES, 0, n_vertices, n_instances);

but I'm pretty sure the stride argument in glBindVertexBuffer of vbo_instanced should be wrong because it is the stride per vertex.

Does anyone know what I'm doing wrong and how to fix it?

EDIT 1: It seems I made a mistake in the last argument of glVertexAttribFormat, it should instead be,

glVertexAttribFormat(2 + i, 4, GL_FLOAT, GL_FALSE, 4 * i * sizeof(float));

But now, although everything gets rendered, my normals are wrong. Even if I don't transform them, they have a single value per instance instead of a single value per face.

This is what the normals look like,

And this is what it should actually look like,

Note that the normals are fine as long as I instead use the glVertexAttribPointer method, i.e. bind the vbo_instanced directly to the vao.

For reference, here is how I declare the attributes in my shader,

#version 330 core

layout(location = 0) in vec3 in_Position;
layout(location = 1) in vec3 in_Normal;
layout(location = 2) in mat4 ModelMatrix;

EDIT 2: I wanted to add that I have checked that all offset values are correct. Additionally, I used apitrace and checked that all vertex buffer data are correctly uploaded. Valgrind also doesn't show any errors.

Now for a weird finding, if I don't use vertex attribute array with index 1 and instead bind vertex positions at 0, vertex normals at 2, and Model Matrices at 3, everything is rendering correctly. Could this be some driver bug? I tried on two linux systems, both having nvidia gpus, with exactly the same results.

EDIT 3: I put together a minimal working example which you can find here. It uses SDL and GLEW and is written in C++11. If I set SKIP to 1 (which means it skips attribute 1), I get what I expect, but if I set it to 0, the normals become messed up.


texts:
While testing my player's jumpinig algorithm, I've come across two odd problems.

1) My player's hard-coded jump height is always much greater (roughly 1.5 times) than the in-game result, making me enter completely abstract numbers for the hard-coded value.

2) My player's jump height increases with lower FPS. At 60 FPS, the jump height was found to be 237, and at 30 FPS it was 269.

This has me completely bumfuzzled. I've been using this article pretty heavily while implementing my jumping function which can be seen below.

Player::Player(param1, param2, int init_jumpheight, double init_jumptime, param3..)
{
  jumpheight = init_jumpheight;
  jumptime = init_jumptime;

  m_gravity = -(2 * jumpheight) / (jumptime*jumptime);
  // other stuff
}

void Player::handleJump()
{
   if(animState != JUMPRISE && animState != JUMPFALL)
   {
      animState = JUMPRISE;
      jumpspeed = 2*jumpheight/jumptime;
      jumpTimer.start();
   }
   else if(animState == JUMPRISE || animState == JUMPFALL)
   {
      jumpspeed += m_gravity*jumpTimer.get_ticks()/1000;
      int yshift = jumpspeed*jumpTimer.get_ticks()/1000;

      if(DEBUGMODE) printf("%0.2f\t%d\t%d\t%d\n",jumpspeed,yshift,jumpTimer.get_ticks(),m_coords.y);

      shifty(-yshift);
      jumpTimer.start();
      if(yshift < 0 && animState != JUMPFALL) animState = JUMPFALL;
   }
}

And here's my console log (the bit that records the details of the jump):

1258.40 20      16      1520
1219.40 18      15      1502
1180.40 17      15      1486
1146.60 14      13      1471
1107.60 16      15      1459
1068.60 16      15      1445
1034.80 13      13      1431
1001.00 13      13      1420
962.00  14      15      1409
923.00  13      15      1397
886.60  12      14      1386
852.80  11      13      1376
816.40  11      14      1367
777.40  11      15      1358
738.40  11      15      1349
704.60  9       13      1340
668.20  9       14      1333
631.80  8       14      1326
598.00  7       13      1320
559.00  8       15      1315
520.00  7       15      1309
483.60  6       14      1304
449.80  5       13      1300
410.80  6       15      1297
371.80  5       15      1293
332.80  4       15      1290
293.80  4       15      1288
257.40  3       14      1286
228.80  2       11      1285
189.80  2       15      1285
153.40  2       14      1285
117.00  1       14      1285
80.60   1       14      1286
39.00   0       16      1287
0.00    0       15      1289
-36.40  0       14      1291
-65.00  0       11      1293
-104.00 -1      15      1295
-143.00 -2      15      1298
-182.00 -2      15      1302
-218.40 -3      14      1306
-252.20 -3      13      1311
-288.60 -4      14      1316
-325.00 -4      14      1322
-361.40 -5      14      1328
-403.00 -6      16      1335
-442.00 -6      15      1343
-478.40 -6      14      1351
-517.40 -7      15      1359
-551.20 -7      13      1368
-590.20 -8      15      1377
-629.20 -9      15      1387
-665.60 -9      14      1398
-694.20 -7      11      1409
-746.20 -14     20      1418
-782.60 -10     14      1434
-821.60 -12     15      1446
-860.60 -12     15      1460
-899.60 -13     15      1474
-938.60 -14     15      1489
-980.20 -15     16      1505


texts: monogame - how do I distribute a lib / package with content?

texts:
I wrote a UI lib for a monogame hobby project I'm working on, and I want to distribute the UI code / lib as open source for others to enjoy.

My question is - what do I do with all the content that comes with the UI lib? (widget textures, effects, etc.)

Is there a standard way to create a monogame lib that also include content? Or do I need to include the content directory with the distribution files and ask the user to add it manually to his own project Content manager?

Thanks!


texts:
I have a material with a spritesheet texture (albedo) and an emission map.
The spritesheet has 32x32 squares. The emission has a 32x32 square that is an emission for the magma-looking square.

It works well on the magma, however, the glow also spreads to the sand, grass, planks, and snow_grass textures. You can clearly see it spread on the sand (bottom-rightmost opaque texture) in the right because it isn't directly touching the magma. Here is another picture where it is attached

You can still see the spreading of glow if you look closely.
Now, you can definitely see it glow here

How do you stop that from happening? That artifact is really weird and i really need it to go away. I've tried decreasing the size of the square in the emission map but it still was there. Please help.

Thanks.

EDIT 1
Here is how I apply uv

`
public static Dictionary textureMap = new Dictionary();

public static void Initialize(string texturePath, Texture texture)
{
    Sprite[] sprites = Resources.LoadAll<Sprite>(texturePath);

    foreach (Sprite s in sprites)
    {
        Vector2[] uvs = new Vector2[4];
        uvs[0] = new Vector2(s.rect.xMin / texture.width, s.rect.yMin / texture.height);
        uvs[1] = new Vector2(s.rect.xMax / texture.width, s.rect.yMin / texture.height);
        uvs[2] = new Vector2(s.rect.xMin / texture.width, s.rect.yMax / texture.height);
        uvs[3] = new Vector2(s.rect.xMax / texture.width, s.rect.yMax / texture.height);
        //Debug.Log(s.name);

        if (!textureMap.ContainsKey(s.name))
        {
            textureMap.Add(s.name, uvs);
        }
    }

}

public static bool AddTextures (Block block, Direction direction, int index, Vector2[] uvs)
{
    string key = FastGetKey(block, direction);

    Vector2[] text;
    if (textureMap.TryGetValue(key, out text))
    {
        //Debug.Log(key);
        uvs[index] = text[0];
        uvs[index + 1] = text[1];
        uvs[index + 2] = text[2];
        uvs[index + 3] = text[3];
        return true;

    }

    text = textureMap["Default"];

    uvs[index] = text[0];
    uvs[index + 1] = text[1];
    uvs[index + 2] = text[2];
    uvs[index + 3] = text[3];

    return false;
}

`

Where Direction is a direction (example north) and Block is a short. Index is the vertex index of the mesh. Texture is the sprite texture (.png)


texts: Why does this geometry shader slow down my program so much?

texts:
I have an OpenGL program, and I'm rendering a terrain mesh. I displace the vertices in the vertex buffer and don't really color them in the fragment shader yet. I'm adding a geometry shader one part at a time.

Before I added the geometry shader, when I was just programming the fragment and vertex shading steps of the pipeline, I was getting framerates of about 30+. Enough that I couldn't notice any choppiness. After adding the geometry shader, I get around 5 frames per second. Why? This is the entirety of the geometry shader:

#version 420

layout (triangles) in;
layout (triangle_strip, max_vertices = 3) out;

void main()
{
    for (int i = 0; i < gl_in.length(); i++)
    {
        gl_Position = gl_in[i].gl_Position;
        EmitVertex();
    }
    EndPrimitive();
}

Isn't this exactly what OpenGL was doing without the geometry shader?


texts: Loading chunks of the terrain relative to the player's position

texts:
I'm making a small voxel-based multiplayer WebGL game with a Node.JS server which handles player positions and sends terrain chunk data to the clients. This is an example of how I'm currently sending the chunks:

var viewDistance = 6;

for (var x = playerPosX - viewDistance; x < playerPosX + viewDistance; x++)
for (var z = playerPosZ - viewDistance; z < playerPosZ + viewDistance; z++)
for (var y = playerPosY - viewDistance; y < playerPosY + viewDistance; y++) {
    client.send( getChunk(x, y, z) );
}

This simply loads and sends the chunks within the view distance, however I'm looking for a way to prioritize sending the chunks nearest to the player first. Obviously it's no good loading chunks that are far away before loading the one the player is standing on.

Assuming playerPosX, playerPosZ and playerPosY store the positions of the player and client.send( getChunk(x, y, z) ) will send the chunk, does any one have any ideas how I would do this? Thanks.


texts: How to sort entities order by nearest entity distance?

texts:
I have created a comparator class called DistanceSquaredComparator and implements it with Comparator<Entity>. Then in the override compare method, I get the distance square of each nearby position to owner position, then get the signum int value to return. Now the problem is I don't know if this is the efficient way of sorting the array by nearest distance.
Entity owner

@Override
public int compare(Entity o1, Entity o2) {
    Vector2 ownerPosition = Mapper.transform.get(owner);
    Vector2 nearby1 = Mapper.transform.get(o1).position;
    Vector2 nearby2 = Mapper.transform.get(o2).position;
    return (int) Math.signum(nearby2.dst2(ownerPosition) - nearby1.dst2(ownerPosition));
}

// usage

DistanceSquaredComparator comparator = new DistanceSquredComparator();
ImmutableArray<Entity> players = ...
ImmutableArray<Entity> enemies = ...
Array<Entity> sortedEnemies = ...
... // fill sortedEnemies

for(Entity player: players) {
    comparator.setOwner(player);
    sortedEnemies.sort(comparator);
}

In the image below, green circle is the observer while the red circle is the observables.


texts:
I am making a game in Unity 5 in C# and I need to make the terrain infinite. I have tried to make it infinite but it just keeps spawning the terrain too much times and then the game crashes. Does someone know how I can make the terrain infinite? Here is my
code.

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

public class TerrainScript : MonoBehaviour
{
    public Transform PlayerTransform;
    private float SpawnZ = 4139f;
    public GameObject[] prefabs;
    private float RoadLength = 2.2f;
    private int amountRoads = 6;
    private List<GameObject> roadList;

    public void Start()
    {
        roadList = new List<GameObject>();
    }
    public void Update()
    {
        if(PlayerTransform.position.z > (SpawnZ - amountRoads * RoadLength))
        {
            spawnTile(0);
        }
    }

    public void spawnTile(int index)
    {
        GameObject go;
        go = Instantiate(prefabs[index]) as GameObject;
        go.transform.SetParent(transform);
        go.transform.position = Vector3.forward * SpawnZ;
        SpawnZ += RoadLength;
    }
}


texts:
What are some good approaches to procedurally generating an infinite 2d level? The level could be constrained in either dimension but not necessarily.

The approach that makes most sense to me so far is using a grid-based radius. e.g. divide the play area into a grid with squares of a certain size and then load X squares in a radius around the player. Then when the player moves to another square build the next set and drop the farther (Persisting explored area is not necessary.) When a square is built, it contains a random arrangement of objects. When objects leave the outer ring of squares they are removed from the world. Are there better or different ways? Or if this is a good approach, what are potential issues?

For discussion's sake, you can think of the level as a top down asteroid field with power ups, etc scattered throughout.


texts: Using non-copyrighted music for a paid game

texts: I'm making a game. It will be sold and not free. Am I allowed to use non-copyrighted music in it?


texts: How can I instantiate and sync a LineRenderer in multiplayer network?

texts:
I am trying to make a laser that will be visible to all clients in a multiplayer networked game on Unity.

I've tried using a Command Attribute but that hasn't worked. I also found some ideas to use RpcClient but I am not quite sure how to implement that.

The code I'm using for the laser (I just run the method in Update) is:

public void CmdActivateLaser(bool laserState)
{
    if (laserState == false)
        return;

    pointer.SetPosition(0, transform.position);

    RaycastHit endCommand;
    if (Physics.Raycast(transform.position, transform.forward, out endCommand))
    {

        finalPos = new Vector3(0f, 0f, endCommand.distance);
        pointer.SetPosition(1, finalPos);

    }
    else
    {
        pointer.SetPosition(1, transform.forward * 500f);
    }
}


texts:
I'm trying to access a method in another script without using the keyword "static";

public void CreateFarm()
{
    new Farm().NewResourceBuilding(gameObject);
}

My question is; will Unity automatically delete this object once it's done calling the method? Or will I need to manually destroy it? If the latter, how will I go about that?

I've searched on Google and been on this problem for a few days until I've finally come to this solution lol. So annoying to reference a static yet want to add a gameobject via the inspector.

Edit (Left the previous content untouched as some of answers already provided for the above might be useful to others). I have since revised my code and the flow.

I have a scene with a number of "empty lots" which I use images as placeholders childed to a Canvas.

The following steps occur:

Clicking on any of these images calls Unity's event system to open a panel, from the onclick options of the inspector. This panel will allow me to select from a number of different buildings to construct.

ChangePanels.CS

public void RuralBuildingSelected()
{
    empirePanel.SetActive(false);
    characterPanel.SetActive(false);
    ruralBuildingPanel.SetActive(true);
}

Why I wanted to avoid "static" was because no static method is callable from the inspector (AFAIK). I could have created my own script and called a public onclick, but perhaps one of you might be able to advise which option of these is more efficient.

Whichever "emptylot" I clicked on, I wanted them to send through their data into a manager script so whatever building I built, could replace the emptylot.

EmptyLot.CS

public void CreateFarm()
{
    new GameManager().GetEmpty(gameObject);
}

The following follow gives you an option of a number of buildings to construct. If I click on the farm, I need to;

Instantiate a new Farm
Parent it to the emptyLot's parent
To replace the emptylot with the new farm, I set them to have the same positions
Destroy the emptylot that called the new farm into existence
Bring back the main panel

Farm.CS

new public void NewResourceBuilding(ResourceBuildings resource)
    {
        Farm newFarm = Instantiate(resource) as Farm;
        newFarm.transform.SetParent(GameManager.emptyLot.transform.parent);
        newFarm.transform.position = GameManager.emptyLot.transform.position;
        newFarm.levelText = newFarm.GetComponentInChildren<Text>();
        newFarm.name = resource.name;
        Destroy(GameManager.emptyLot);
        GameObject main = GameObject.Find("Main Canvas");
        main.GetComponent<ChangePanels>().MainScene();
    }

My Questions:

The "EmptyLot.CS" script creates a new GameManager to call a public method. I don't reference the object. Will this automatically be added to the garbage collector or should I just destroy it after using it? If I need to destroy it manually, how would I go about that?
I note that if I went ahead with the static methods and implement my own OnClick() method I can condense this to just two scripts instead of the three. So should I do that? Or based on the above code, is it just as efficient to keep it the way it is? I'm not a pro at this, but inline with Wondra's comment (to Almo's answer) it does seem like the approach of creating objects to delete instantly is a performance issue?

Thank you for taking the time to read/help/advice


texts: How can I transform a world space point to a camera's screen coordinate?

texts:
I'm trying to transform a point in fragment shader from world space to screen coordinate of a second camera. Not the main one.

I think I know how to achieve that to the main camera, but I'm struggling to find an easy way to transform a point in world space to screen coordinate of camera2.


texts:
Does anyone have specifications for the bio2s scripting language from Bohemia Interactive? They develop Operation Flashpoint, Armed Assault (ArmA), and Virtual Battlespace.

These scripts are sometimes called O2 or Oxygen scripts and are used in their terrain and modeling tools. Oxygen is Bohemia Interactive's modeling tool.

I found additional examples of the format in this VBS2 tutorial and this ArmA forum thread.

EDIT: I clarified the purpose of the bio2s format and provided some links to examples.


texts: How to add a tag in editor? I am working on automatic asset generation and I would like to use tags for certain objects.


texts: How do I align the cube in which shadows are computed with the view frustrum? ("View Space aligned frustum")

texts:
Short and concise:

Given 8 world space positions that form a cube of arbitrary size, position and orientation and given an arbitrary light direction.

How do I compute the View and Projection matrix for a directional light, such that the shadows are computed in exactly and only this cube?

Edit: Clarification: I want to create Shadow Maps, in the way, that Crytek calls "View Space aligned" (http://www.crytek.com/download/Playing%20with%20Real-Time%20Shadows.pdf page 54-55), so I want that the cube in which shadows are computed is aligned with the view frustrum. How do I achieve that, when I have already have the 8 world space positions of a cube, around the view frustrum?


texts:
https://www.youtube.com/watch?v=Tzf3zjPJYw4

In this game, Ink, color blobs fall then they create pretty color spots.

The color traces are unlike any other game.

For an example, in Super Meat Boy https://www.youtube.com/watch?v=snaionoxjos

The red traces of SM Boy was more of sprites aligned across the surfaces of the object.

The trace in game Ink is different from those traditional traces of other games because...

They stack infinitely.
Come in many different shapes.

The approaches I can think of are...

Prepare many different shapes sprites, then put then where traces should be.
Assign each block with their own texture, then draw the traces on that texture.

The issues I see however are...

First solution will lead to having many-MANY-MANY sprites being generated to look as if the traces are being drawn upon the object.
Heavy calls between GPU and CPU. Keep drawing traces while uploading drawn new texture onto the GPU to be rendered. Significantly slowing down the game.

I don't have a good computer. My computer cannot handle either approach 1 or 2. But it can the run the game Ink.

So I am assuming Ink must use some sort of clever approach to handle this crucial visual aspect of the game. But I am out of ideas.


texts: What should I consider when selecting a field-of-view (FOV) for a space game?

texts:
I am making a space game (like the game Freelancer). You control a space ship in third person.

What are some gameplay considerations that I should weigh when selecting a field-of-view (FOV) for such a game?


texts:
I imported a custom character and a pistol model to UDK and both work, but the pistol doesn't appear with the animation of the pistol when I shoot or reload... Also, the character doesn't change its animation from its normal posture to the posture animation holding a pistol.

How can I set the character to change the character's animations to animate correctly when holding a weapon? Can I do this in Unreal Kismet or do I need code?

I don't know UnrealScript well; only C++. :/

PS: On AnimSet, the character's posture is correct with a pistol, walking, firing, reloading, everything.


texts: Revert to closest non intersecting position

texts:
First, let me start by saying:

  Please forgive me if this question have already been asked. I've tried to search but didn't find any solution. (It might be due to my lack of terms).

I have two circles with r radius, p(x,y) position and v(x,y) velocity. I need a formula for calculating position p3 if the first circle (blue) intersects with the second circle (red), thus placing it as close as possible next to the red circle without intersecting.

Any ideas?

Vector2 c1 = new Vector2((p1.X + r1), (p1.Y + r1));
Vector2 c2 = new Vector2((p2.X + r2), (p2.Y + r2));
bool intersects = ((Vector2.Distance(c1, c2)) < (r1 + r2));


texts: How can I compute the movement of an object along a parabola?

texts:
I am working on a simple 2D game. In the game, I have a 'robot' that throws a ball towards another robot, in the shape of a parabola. Both 'robots' have the same Y coordinate.

The program knows the positions of the two robots, and it knows the position of the parabola's apex ('vertex') as shown here:

I need the ball to travel along the parabola. This means (correct me if I'm wrong), that at any given time, I need to be able to calculate the Y position of the ball, since I know it's X position.

If so, how can I calculate that Y position at any given time, knowing the information above. Please try to make your answers as clear as possible, since my math knowledge is very basic.


texts:
What are the point of boss battles in the current form? For most games, a boss encounter is usually:

A puzzle of sorts, where you have to figure out when the boss' weak
point is exposed.
An enemy with just more health and can hit harder,    or maybe having
a special attack.
A scripted fight where you have to    push the correct buttons at the
right time.
A test to see how well you've learned what the stage was trying to
teach you. (IE an ability.) etc.
An enemy that will become common at a later time.

In which they're mostly just a longer fight than normal. Some games have interesting bosses that are actually meaningful to the story, but are still nothing really substantial.

Why are boss fights so prevalent in games? Is there any research that shows the importance of boss fights? What function do they fulfil in a game, from a design perspective?


texts: Is programming skill required for game development?

texts: I do not know how to program. Can I contribute in any way to game development?


texts:
The rigid body physics engines that use a "bounding box" for collision detection, I am aware of how they are created.

What I want to know is, is there a physics engine that does not use "bounding box" but actually uses something like vertex data to do the physics calculations? What type of physics engine is this called, and does it use the GPU?


texts:
I'm coding my first Shader in my little game engine, and I have some questions about it's performance and common approaches.

Is the Shader code processed by the video card instead of the PC processor? Just so I know if it's possible to share some calculations to save some processor power.
Generally, should I do the math calculations in my code or the Shader? I could calculate them all (lightning for example) and just send the final values to be multiplied/used to the Shader, but what's the best approach?
Shaders as far as I could understand are the main party responsible for visual effects, so for example, if I want to add a "blur" effect to only one object on screen, should I use an if/switch statement in the Shader or should I have different Shader/ProgramIDs and I just switch the call glUseProgram(programID)?

Sorry if some questions seems stupid, and thanks for your time!


texts: Should I combine multiple tiles of terrain as one mesh in Unity3D?

texts:
I have a tiled terrain, generated by multiple noise algorithms. Currently, each tile is it's own GameObject, that has a handler for an OnMouseOver event. The area that is loaded at a time consists of 9 chunks that each contain 4096 tiles. This totals to 36864 tiles that are loaded at a time. On top of this, there are actual objects on top of these tiles.

Is there any considerable performance difference if I were to combine some of these tiles into a single GameObject and mesh?


texts: If I, for example, wanted to make a Spongebob game and was not asked to to do so by the company that owns the character, what would I have to do in order to get the rights to make the game?


texts: Weapon Sway Script messes up weapon rotation

texts:
So I'm in the process of learning Unity 5 and scripting in it. One thing I wanted to give a try was to make a simple weapon sway script like you see in games such as battlefield or csgo. After a bit of documentation I finally got a script going (see below).

using UnityEngine;
using System.Collections;

public class WeaponSway : MonoBehaviour {

    float mouseX;
    float mouseY;
    float movementX;
    float movementY;
    float smooth = 3;
    public float speed;

    // Use this for initialization
    void Start () {

    }

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

        mouseX = Input.GetAxis("Mouse X");
        mouseY = Input.GetAxis("Mouse Y");

        movementX = mouseX * Time.deltaTime * speed;
        movementY = mouseY * Time.deltaTime * speed;

        Quaternion final = Quaternion.Euler(defaultposition.x * movementX, defaultposition.y * movementY, 0);
        transform.localRotation = Quaternion.Slerp(transform.localRotation,final,Time.deltaTime*smooth);

    }
}

However, for some reason the simple model of the weapon I'm using changes rotation and the weapon doesn't sway like intended. I can't see the problem in the script.

Here is a gif of what is happening: http://imgur.com/zi6w6Om


texts: Formula to calculate Level and Current Experience from Total Xp

texts:
So I'm building a mobile game where I have simple XP progression system that goes like this:
Level1: 0-399 Total XP
Level2: 400-1199 Total XP
Level3: 1200-2399 Total XP
So basically for the first level the player needs 400 XP to level up. Once it reaches that the exp bar goes to zero and then needs 800 XP to level up, the XP bar goes to 0 and needs 1200 and so on.
I was wondering if there is a formula in order to calculate the current level of the player and the current experience (i.e. 400/800 when it has 800 total XP) from the Total XP.
EDIT:
So I found the formula Level = Floor(1/20 (10 + sqrt(2) sqrt(50 + TOTAL XP)))
but I still can't figure out the formula to find the Current XP
Thank you


texts: How to draw a rectangle at x,y where x & y are in pixel?

texts:
Here is my code :
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glViewport(0, 0, screen_width, screen_height);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrtho(0.0, screen_width, 0.0, screen_height, -1.0, 1.0);

glMatrixMode(GL_MODELVIEW_MATRIX);
glTranslatef(0, 0, -5);

glColor4f(rect.color.R(), rect.color.G(), rect.color.B(), rect.color.A());
glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_QUADS);

glRectd(rect.transforms.position.x, rect.transforms.position.y, rect.transforms.size.width, rect.transforms.size.height);

glEnd();

glfwSwapBuffers(window);

glFlush();

Where rect.transforms.position.x is in pixel.
Issue :
Nothing shows up.
The color was tested before & works on a rectangle that use opengl coordinates.


texts: iPhone 3d Model format: .h file, .obj, or some other?

texts:
I'm beginning to write an iPhone game using OpenGL-ES and I've come across a problem with deciding what format my 3D models should be in.  I've read (link escapes me at the moment) that some developers prefer the models compiled in Objective-C .h files.  Still, others prefer having .obj as these are more portable (i.e., for deployment on non-iPhone platforms).

Various 3D game engines seem to support many(?) formats, but I'm not going to use any of these engines as I would like to actually learn OpenGL-ES.  Am I putting myself at a disadvantage here by not using a packaged engine?

Thanks!


texts: Singleton pattern Class attached to multiple GameObjects still only 1 instance?

texts:
I'm currently working on an Inventory/Equipment System and so far have been using a Singleton Pattern to instantiate my Inventory and Equipment classes. I was wondering if i attach this Script to multiple gameObjects, whether they each have a seperate instance or whether they share it? This would be important for the Equipment classes as each GameObject should obviously have different Items equipped.
My current Singleton pattern looks like this:

public static Inventory Instance { get { return instance; } }

void Awake()
{
    if(instance != null && instance != this)
    {
        Destroy(this.gameObject);
        Debug.LogWarning("More than one instance of Inventory found!");
        return;
    }
    instance = this;
}


texts:
I'm new to OpenGL

Lets say I create an OpenGL window using glfw and I need the UI feature from glut (such as popup menu). Is it possible to use glfw and glut in one program?

Thank you


texts: can someone help me with this code for my platformer. ive been working on the script for an eternity but unity keeps saying there is an error

texts:
using UnityEngine;
using System.Collections;

public class player_controler : MonoBehaviour {

    public float moveSpeed;
    public float jumpHeight;

    // Use this for initialization
    void Start () {
    }

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

        if(Input.GetKeyDown) (KeyCode.Space))
        {
            rigidbody2d.velocity = new vector2(0,jumpHeight;)
        }

    }
}

This is what shows up:

Assets/scripts/player_controler.cs(16,53): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement


texts: Creating SurfaceView cause short screen blink

texts:
When I create SurfaceView for first time since app launch, the app screen blinks black for small time (about 1/4 second). It blinks over UI, so its really visible and doesn't look nice at all.
I've tried to comment all of my code in surfaceCreated, but effect is same, so problem is not here. How do I remove or "hide" this screen blink?
In activity:
RelativeLayout layout = (RelativeLayout) findViewById(R.id.relative);
layout.addView(new Surface(getApplicationContext())); // causes short screen black blink

Surfaceview class:
public class Surface extends SurfaceView implements SurfaceHolder.Callback
{
        public Surface(Context context)
        {
            super(context);

            getHolder().addCallback(this);
            this.setZOrderOnTop(true);
            getHolder().setFormat(PixelFormat.TRANSPARENT);
            setFocusable(true);
        }

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

        @Override
        public void surfaceDestroyed(SurfaceHolder holder)
        {
        }

        @Override
        public void surfaceCreated(SurfaceHolder holder)
        {
              ... stuff
        }
}


texts:
Me and my friends are creating a simple 3D game in LibGDX and are currently trying to implement simple collision detection with the terrain (ground). For this I thought the best way would be to simply get the y-value (height) of the piece of terrain the player is currently standing on, and limit the player's y-position to that value.

For this I need some way to get the 3 vertices that make up the triangle the player is standing on and then use some type of interpolation (probably barycentric) to get the correct height. The problem is that LibGDX's Model, ModelInstance and ModelData classes only contains a raw vertex array(s) of floats with no built in way to acquire the information we need. So my question is fairly straight forward:

Is there a way to acquire the three vertices that we need to perform this interpolation or Is there another way to acquire the height of the terrain given the coordinates (x, z)?

PS. I know using a heightmap instead of a model could solve this problem, but we'd much rather use LibGDX's built-in systems unless absolutely necessary.


texts: How can I implement the traffic(+drawing) functionality in the game?

texts:
I am a beginner game developer. Games such as "Cities: Skyline", "Simcity", "Citybounds", and "Traffic lanes 3" directly build roads and show simulations of cars moving over them. I have no knowledge to make these things. I can use Unity, construct2. How can I express things like roads, lanes, intersections, snapping, traffic simulations, path finding, driver AI,  traffic lights, even wheels on the road?

Road drawing

Traffic simulating


texts:
Good Morning,

I've been trying to learn some OpenGL by following the tutorials on learnopengl.com and I've hit a bit of a snag. I'm trying to implement the same functionality as the "Hello Triangle" tutorial (learnopengl.com->Getting Started->Hello Triangle) except I'm trying to put it in its own class. Essentially it is the same code just moved around, The issue is coming from glBufferData(...). from my understanding this function is to essentially bind the data with the buffer object. When glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); is called in my main.cpp file the program operates how it should and it draws the square. But if i comment that out on Main.cpp and move it to BindBuffers on Window.cpp the program still runs but it does not render the square. Any input on why this is happening/ what im doing wrong?

Main.cpp

#include "Engine\Window.h"
#include <glad/glad.h>

#include <GLFW/glfw3.h>

#include <iostream>

int main()

{
    Window window;

// set up vertex data (and buffer(s)) and configure vertex attributes
// ------------------------------------------------------------------
float vertices[] = {
    0.5f,  0.5f, 0.0f,  // top right
    0.5f, -0.5f, 0.0f,  // bottom right
    -0.5f, -0.5f, 0.0f,  // bottom left
    -0.5f,  0.5f, 0.0f   // top left
};
unsigned int indices[] = {  // note that we start from 0!
    0, 1, 3,  // first Triangle
    1, 2, 3   // second Triangle
};

window.GenBuffers();

window.BindBuffers(vertices,indices);
//glBindVertexArray(window.GetVAO());
//glBindBuffer(GL_ARRAY_BUFFER, window.GetVBO());
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, window.GetEBO());
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);

glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
while (window.CheckClose())
{
    window.processInput();
    window.Begin();
    window.Render(window.GetVAO());
    window.End();
    window.Update();
}
window.~Window();
return 0;
}

Window.cpp

#include "Window.h"

Window::~Window() {
    glDeleteVertexArrays(1, &VAO);
    glDeleteBuffers(1, &VBO);
    glDeleteBuffers(1, &EBO);
    glfwTerminate();
}
Window::Window() {
/*** Creates window and intializes shader, if this is needed I can edit but I chopped it to save some room*/
}

void Window::Update() {
    glfwPollEvents();
}
void Window::Begin() {
    glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
}
void Window::End() {
    glfwSwapBuffers(window);
}
bool Window::CheckClose() {
/*Checks if window was closed*/
}
int Window::GetShader() {
    return shaderProgram;
}
void Window::Render(unsigned int VAO) {
    // draw our first triangle
    glUseProgram(GetShader());
    glBindVertexArray(VAO); // seeing as we only have a single VAO there's no need to bind it every time, but we'll do so to keep things a bit more organized
                            //glDrawArrays(GL_TRIANGLES, 0, 6);
    glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
    // glBindVertexArray(0); // no need to unbind it every time
}
void Window::GenBuffers() {
    glGenVertexArrays(1, &VAO);
    glGenBuffers(1, &VBO);
    glGenBuffers(1, &EBO);
}
void Window::BindBuffers(float vertices[],unsigned int indices[]) {
    glBindVertexArray(VAO);
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    //glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
}
unsigned int Window::GetVBO() {
    return VBO;
}
unsigned int Window::GetVAO() {
    return VAO;
}
unsigned int Window::GetEBO() {
    return EBO;
}


texts:
I have a question about my code. I wrote a basic GameLoop
for an Android Game and while testing it I realized the deltaTime
is always 0.

The code looks like this:

@Override
 public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        lastTime = System.currentTimeMillis();
    }

@Override
    public void onDrawFrame(GL10 gl) {
        float currTime = System.currentTimeMillis();
        float deltaTime = currTime - lastTime;
        float msPerFrame = 1000.0f/ 60.0f;

        if(deltaTime < msPerFrame){
            try {
                Thread.sleep((long)(msPerFrame-deltaTime));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        update(deltaTime, gl);
        lastTime = currTime;

    }

    public void update(float deltaTime, GL10 gl){
           //doStuff
    }

lastTime and currTime are always the same and the deltaTime is 0. I don't know if this is right or the code is just wrong but I think the deltaTime shouldn't be 0...

I test the app with Android Studios Emulator.