texts: Scale / NonUniformScale is not applied to entity

texts:
I'm just learning the new Unity ecs and trying to change the size (scale) of an entity.
Everything works fine, I can change the rotation, the position but not the scale.

I'm wondering why.
I did various tutorials, I tried Scale, NonUniformScale, LocalToWorld, CompositScale but nothing works. Maybe some of the methods are deprecated.

Here is what I have tried so far.

I have multiple prefabs (planes) which are spawned correctly and each of them having a transform component.

Now I want to change the scaling of all the planes.
For that I use a JobComponentSystem.
In the following pice of code the rotation works fine, but not the scaling.

I tried LocalToWorld.

public void Execute(ref Rotation rotation, ref LocalToWorld scale) {
            rotation.Value = math.mul(rotation.Value, quaternion.RotateZ(math.radians(0)));
            scale.Value = float4x4.Scale(2, 4, 5);
        }

I tried NonUniformScale

public void Execute(ref Rotation rotation, ref NonUniformScale scale) {
            rotation.Value = math.mul(rotation.Value, quaternion.RotateZ(math.radians(0)));
            scale.Value = new float3(2, 1, 4);
        }

I tried Scale.

public void Execute(ref Rotation rotation, ref Scale scale) {
            rotation.Value = math.mul(rotation.Value, quaternion.RotateZ(math.radians(0)));
            scale.Value = 5;
        }

None of these is working.
What did I wrong (the scale just stays at 10,1,10) or what is the current propper way of doing that?


texts: What are the advantages of using SAT(seperating-axis theorem ) in collision detection?

texts: Lets say i need to check if two AABBs are colliding with each other. I would simply compare their corners. When am i gonna need SAT(heavy vector calculations) to do the same thing?


texts: Memory allocation patterns used in game development

texts:
I have been researching creating my own allocator methods (that will support things such as a memory pool and profiling), however, as I continue my research I have been looking for how this was done in game development.

What memory allocation technique could I use, and why is it a good technique?


texts: Huge input delay although framerate is stable - possibly related to the DirectX Tool Kit?

texts:
I'm in the process of learning how to use the DirectX 11 API and came upon the following problem:
Although my rendering function executes quite fast at around 150 fps (as one expects considering how little geometry is rendered), the mouse and keyboard input is massivly delayed. Sometimes the "game" reacts several seconds too late or doesn't react at all; looking around is a pain.
When I increase the framerate even further to, let's say, 400 (by reducing the rendering resolution/rendering less objects), the effect vanishes and the every keystroke is detected precisely.

My update() function (see code below) is called by the StepTimer class of the DirectX Tool Kit from the main message handling loop. I tried both fixed and variable timestep mode.

Main loop calling update() and render()

while (msg.message != WM_QUIT)
{
    if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    static DX::StepTimer stepTimer;
    stepTimer.Tick([&]() { update(stepTimer); });
    render();
}

The update() function:

void update(DX::StepTimer const &timer)
{
    static Keyboard::KeyboardStateTracker keyboardTracker;
    static Mouse::ButtonStateTracker mouseTracker;
    Keyboard::State keyboardState = keyboard->GetState();
    Mouse::State mouseState = mouse->GetState();
    keyboardTracker.Update(keyboardState);
    mouseTracker.Update(mouseState);
    fps = timer.GetFramesPerSecond();

    if (keyboardState.Escape) PostQuitMessage(0);

    static float pitch = 0.0f;
    static float yaw = 0.0f;

    if (mouseState.positionMode == Mouse::MODE_RELATIVE)
    {
        pitch = std::max(std::min(pitch - float(mouseState.y) * 0.001f, XM_PI / 2.0f - 0.01f), -XM_PI / 2.0f + 0.01f);
        yaw -= float(mouseState.x) * 0.001f;
        if (yaw < -XM_PI) yaw += XM_PI * 2.0f;
        if (yaw > XM_PI) yaw -= XM_PI * 2.0f;
    }
    if(mouseTracker.leftButton == Mouse::ButtonStateTracker::RELEASED) mouse->SetMode(mouseState.positionMode == Mouse::MODE_ABSOLUTE ? Mouse::MODE_RELATIVE : Mouse::MODE_ABSOLUTE);

    Vector3 cameraDir(-sin(yaw) * cos(pitch), sin(pitch), cos(yaw) * cos(pitch));

    Vector3 motionVec = { 0.0f, 0.0f, 0.0f };
    float speed = 4.2f;
    if (keyboardState.W || keyboardState.Up)
    {
        motionVec.x += cameraDir.x;
        motionVec.z += cameraDir.z;
    }
    if (keyboardState.S || keyboardState.Down)
    {
        motionVec.x -= cameraDir.x;
        motionVec.z -= cameraDir.z;
    }
    if (keyboardState.A || keyboardState.Left)
    {
        motionVec.x -= cameraDir.z;
        motionVec.z += cameraDir.x;
    }
    if (keyboardState.D || keyboardState.Right)
    {
        motionVec.x += cameraDir.z;
        motionVec.z -= cameraDir.x;
    }
    if (keyboardState.Space || keyboardState.PageUp)
    {
        motionVec.y += 1.0f;
    }
    if (keyboardState.LeftShift || keyboardState.PageDown)
    {
        motionVec.y -= 1.0f;
    }
    motionVec *= speed;

    static Vector3 cameraPos = { 0.0f, 2.0f, 0.0f };
    if (keyboardState.R)
    {
        cameraPos = { 0.0f, 2.0f, 0.0f };
        pitch = 0.0f;
        yaw = 0.0f;
    }
    cameraPos += motionVec * float(timer.GetElapsedSeconds());
    matrixCamera = XMMatrixLookToLH(cameraPos.XMVECTOR(), cameraDir.XMVECTOR(), { 0.0f, 1.0f, 0.0f });
}

Is there any hint you can give me? Or might this even by a bug in the StepTimer class?


texts: Is there any way to get Unity 3D to run on Ubuntu. I am currently running Ubuntu 12.04 64bit edition. I also have Wine installed.


texts: How frequently do my game server need to message the client?

texts:
I am writing a game-server and a game-client. In the client there is a game loop that has a delay of ~16ms (because that would be nearly 60fps). All the logic is at the time handled at server side so I need to send the latest frame to the client every 16 ms. Is this a good solution? I know that I probably have to do some game logic at client side just to smooth things out but this is an early version.

Is it possible to make the server send frames to the client each 16ms? Each client is handled in different threads (or actors, as the server is written in Erlang).


texts: How do I deal with scale of the universe when generating a simulated universe?

texts: I have a dataset of 100,000 actual stars. I wish to create a game where I can fly between the stars and fly up to them and click on them etc. How do I go about dealing with the problem of the scaling of the universe, even If I were to allow fast as light travel it would be too vast. Should I cluster my data and then implement a subtle sort of scaling to move around? Sorry for the broad question but I'm rather stuck at the moment.


texts:
I'm using glViewport as a camera of sorts, but I'm not quite sure how it works. For example when I change do:

glOrtho(0, 800, 600, 0, -1, 1);
glViewport(0, 0, 400, 200);

It makes the viewing area larger rather than just viewing a 400x200 area...


texts: Physics2D.IgnoreCollision not work when rb not moving

texts:
I want to use Physics2D.IgnoreCollision for ignoring collision between enemy and player, when player have shield.
But I have enemy who some time is static and some time jump only on y axis. When enemy not moving Physics2D.IgnoreCollision not work and physics collision between player and enemy occur even Physics2D.IgnoreCollision is called. When i add some velocity to enemy in update method
Code (CSharp):
rb.velocity = new Vector2(0.1f, rb.velocity.y);

IgnoreCollision work like it should.
Can some one tell me why this happens?
Thanks


texts: How can check a collision between 2 non-axis aligned boxes?

texts:
I'm making a simple and easy game and I need to detect the collision between 2 boxes. It only needs to return trueor false, no physics involved.

I started working and couldn't find an algorithm that would check the collision for turned squares.

Here I visualized the problem.

As you can see squares 1, 2 and 3 would return true because they collide with the green squares. 4 would return false because it isn't colliding.

I do have all the squares of both colors in separate array lists.

Does anybody know a library or algorithm for this problem? Thanks in advance.


texts: What's the reason behind collision-boxes?

texts: I was surprised that some games use extra models called collision-boxes for collision. What is the benefit of doing so? Can't we calculate collisions between the vertices of any game model? Is this possible? Are there performance reasons?


texts: Choose your own adventure - choices stack

texts:
I'm currently building a choose your own adventure game. Now it's easy enough to have one outcome to every choice and create a linear flow, but is there a good algorithm for having all previous selections affect the next outcome? I could obviously store every previous selection and have big 'IF' statements to decide but I wondered if there was a better way?

Part of me wonders if every choice should have a 'score' and then I use this (maybe with a threshold) to determine what the next action should be and each action gets added to the score.

I'm primiarly doing this in swift/SpriteKit but I think it's more about the concept then the code at this point.

In response to Josh's comment below:

I suppose I'm still in the conceptual phase at the moment, but each 'page' would either be a custom object or a json file. I was thinking about your answer (now removed) and maybe having each ENUM option as a bit. Then each page could have a 'score'. Then using the previous options selected work out what bits are set and that determines what page. I guess I just wondered if there was an existing solution to this problem before I began to almost help decide how I should format the 'story'

Rough guess at format :

  { "text":"You arrive in the dungeon and there are 2 doors",
   "options":[
    1: "Go left",
    2: "Go Right"
    ],
   "score" : 0 // first page
  }
  {"text" "You went left and meet a dragon",
  "options":[
    0: "Game over, you were eaten" // something to handle game over
    ],
   "score" : 1
  }
  {"text" "You meet a mushroom who tells you the princess is in another castle",
  "options":[
    4: "Give up, game over", // something to handle game over
    8: "Jump down the pipe"
    ],
   "score" : 2
  }

Thanks


texts:
I am trying to implement instanced rendering for objects that repeat, so I came up with idea I could simply group objects that loaded same model files, create array with their Model matrices and so on, and finally pass this array as uniform array to shaders, which will be indexed by gl_instanceID to get correct model matrix for given objects.

C++ implementation looks pretty much like this:
    std::vector RelativePositions, Scales;
    std::vector Models;

int ctr = 0;
bool first = true;
int isz = 0; obj->getIndices(isz);

// pDrawData->refObjects holds all Object3D instances which share same model geometry

for (std::list<IObject3D*>::iterator pObj = pDrawData->refObjects.begin(); pObj != pDrawData->refObjects.end(); pObj++) {
    IObject3D *obj = *pObj;
    int render = prepareForRender(obj, flags, isShadow, offset);
    if (!render) continue;
    if (first) {    //this is gonna be same for all objects of this class
        setUniform(Type, (int)obj->getType());
        setUniform(Flags, (int)obj->getFlags());
        first = false;
    }
    Scales.push_back(obj->getScale());
    RelativePositions.push_back(obj->getPos());
    Models.push_back(obj->getModel());
    ctr++;
}
if (ctr) {
    int Rem = 0;
    const int Step = MAX_OBJ_PER_INST;  // = 64
    for (size_t i = 0, j = Scales.size(); i < j; i+=Step) {
        Rem = Scales.size() - i;
        if (Rem > Step) Rem = Step;
        //following functions set uniform array of specified length
        setUniform(Scale, Scales.data()+i, Rem);
        setUniform(RelativePosition, RelativePositions.data()+i, Rem);
        setUniform(Model, Models.data()+i, Rem);
        glDrawElementsInstanced(GL_TRIANGLES, (GLsizei)isz, GL_UNSIGNED_INT, 0, Rem);
    }
}

Rendering object is done via Vertex Shader > Tess Control Shader > Tess Eval Shader > Geom Shader > FragmentShader.
Instance ID is being passed using flat out/in int InstanceID; from shader to shader while being once set in Vertex shader as gl_InstanceID.

Tessellation Evaluation Shader logics look like this:

    #version 430
    layout(triangles) in;

    in vec3 tcPosition[];
    in vec3 tcTexCoord[];
    in vec3 tcNormal[];
    flat in int tcInstanceID[];

    out vec3 tePosition;
    out vec3 teDistance;
    out vec3 teTexCoord;
    out vec3 teNormal;
    flat out int teInstanceID;

    #define MAX_OBJ_PER_INST 64

    uniform mat4 Model[MAX_OBJ_PER_INST];
    uniform vec3 Scale[MAX_OBJ_PER_INST];
    uniform vec3 RelativePosition[MAX_OBJ_PER_INST];

    // ... other uniforms

    void main(void)
    {
        vec3 p0 = gl_TessCoord.x * tcPosition[0];
        vec3 p1 = gl_TessCoord.y * tcPosition[1];
        vec3 p2 = gl_TessCoord.z * tcPosition[2];

        // ... other stuff ...

        teDistance = gl_TessCoord;
        tePosition = (p0 + p1 + p2);
        teInstanceID = tcInstanceID[0];

        switch(Type){
            // ... other types ...
            default:
                tePosition = (vec4(tePosition,1)* Model[teInstanceID]).xyz * Scale[teInstanceID] + RelativePosition[teInstanceID];
                break;
        }
    }

This works fine when I run it on any nVidia GPU when on laptop, but when I try to run it on AMD GPU or Intel Integrated Graphics, it suddenly doesn't work and I only get blank screen.

But if I remove uniform arrays and pass only single variable for uniform, so all instances would suddenly have same model matrix, position and scale, it works even on other GPUs, so problem is definitely with arrays...

Is there any solution to this?


texts: Adding actors/musicians/famous people in a videogame

texts: Let's say I want to make a videogame with several famous characters in it, you can't copyright a name and a face, right (I'm talking about names and surnames, not branded ones)? How does it work? Are there any royalties to pay? To whom? If there are royalties, can I get away by making my names similar to original ones?


texts:
First a bit of background.  I have yet to read a book on game development, though I do plan on picking one up sometime.

A long time ago I made a simple pong game, followed by a simple Arkanoid-type game.  In both  games I figured the collision detection by comparing the x, y, and z of the ball to the paddle.  I did this calculation for each side of the ball and each side of the paddle.  It was the only way I could think of to do it at the time.

It was something along the lines of:

if (thing.x >= otherthing.x) {
    if (thing.y >= otherthing.y) {
    }
}

And so on.

Is this the normal way of figuring collision detection?  Did I over-complicate it, or is this the basic way that it's done?


texts: How to create glowing line with andengine?

texts: today I have played this game and still wondering about this effect: when I touch the target, some lines will appear (as those yellow lines in the image). How could I create this effect in andengine. In more detail, I want to create effect lines like that, I have no clue about methods they used.


texts: Possible / How to render to multiple back buffers, using one as a shader resource when rendering to the other, and vice versa?

texts:
I'm making a game in Direct3D10. For several of my rendering passes, I need to change the behavior of the pass depending on what is already rendered on the back buffer. (For example, I'd like to do some custom blending- when the destination color is dark, do one thing; when it is light, do another).

It looks like I'll need to create multiple render targets and render back and forth between them. What's the best way to do this?

Create my own render textures, use them, and then copy the final result into the back buffer.
Create multiple back buffers, render between them, and then present the last one that was rendered to.
Create one render texture, and one back buffer, render between them, and just ensure that the back buffer is the final target rendered to

I'm not sure which of these is possible, and if there are any performance issues that aren't obvious. Clearly my preference would be to have 2 rather than 3 default render targets, if possible.


texts: Unity 5.3 C#: How to disable multiple game objects with one collision?

texts:
I'm making a top down perspective game with a gunner automatically moves on a pre-set path, and you shoot and destroy targets to remove barriers. The idea is that you control the bullet's direction after firing and it can pass through laser gates, but the gunner cannot. There are several targets and barriers.

What I want: If the bullet hits the local target, the local target and local barrier are destroyed.

I tried making each target and barrier as children of empty game objects, and I attempted to destroy the empty parent to solve this problem. Please advise.

(Showing only relevant code)

using UnityEngine;
using System.Collections;

public class MagicBulletScript : MonoBehaviour {

    public Transform magicBulletTransform;

    void Start () {
        magicBulletTransform = transform;
    }

    void OnTriggerEnter (Collider other){
        var progressParent = this.transform.parent.gameObject;

        if (other.gameObject.CompareTag("Obstacle")){
            Destroy (this.gameObject);
        }

        if (other.gameObject.CompareTag("Target")){
            Destroy (progressParent.gameObject);
            Destroy (other.gameObject);
        }
    }
}


texts:
Platform: Android OpenGL ES 2.0

I'm drawing a texture on to a square using OpenGL ES2.0.
The texture scrolls infinitely in vertical direction.

The rendering quality drops very rapidly after a few frames and the texture quality is deteriorated.

Screenshot #1

Screenshot #2

How to correct this issue?


texts: Determine wheter an octree node needs to be continue

texts:
For collision detection (moving vs. non-moving) in my current project, I decided to implement an octree approach after the preselection.

The only collision detection I'm currently using is a AABB-vs.-AABB collsion detection. Now, if this detection returns true for two objects (n, m), I want to subdivide the AABB into eight smaller axis-aligned boxes, and so on. (Octree)

Implementing the subdivision itself is now problem for me, but I'm stuck at the following:
How can I determine whether a node needs to be divided further, or whether further subnodes are unnecessary?

Since I got objects of various complexity (a model with ca. 1500 vertices vs. a cube with 8), I can't simply check for the amount of vertices inside an octant.

What ways are there to determine whether a subdivision is necessard? Or am I even using a wrong approach any something else might work better?

Edit: I now think that an octree might be the wrong approach. What would be the best way to check for a more exact collision detection after an AABB collision detection returns true?


texts: Displaying animations during loading screens

texts:
Games like Karateka (which uses UDK) seem to be able to asynchronously load GL assets as well as display animation.

The splash is incredibly short, then presumably their glView shows up.

I can think of 2 ways to simultaneously load textures, models and assets into OpenGL:

1) Create 2 contexts: the "real" one (which is doing the loading) and a "fake" one (which will be on a separate viewcontroller.. on a separate thread.)  I'm not sure if this will work however as I don't know if you can create a 2nd GL context on not the main thread.

2) Cut the load sequence into small, small jobs.  Each iteration of your draw loop, load one tiny asset (like a single texture or a single model).
The effect of this is probably a much longer total loading time!

Are either of these 2 right or are they both wrong?  Is there another way to do it?


texts: Sidescroller variable terrain heightmap for walking/collision

texts:
I've been fooling around with moving on sloped tiles in XNA and it is semi-working but not completely satisfactory. I also have been thinking that having sets of predetermined slopes might not give me terrain that looks "organic" enough. There is also the problem of having to construct several different types of tile for each slope when they're chained together (only 45 degree tiles will chain perfectly as I understand it).

I had thought of somehow scanning for connected chains of sloped tiles and treating it as a new large triangle, as I was having trouble with glitching at the edges where sloped tiles connect. But, this leads back to the problem of limiting the curvature of the terrain.

So...what I'd like to do now is create a simple image or texture of the terrain of a level (or section of the level) and generate a simple heightmap (of the Y's for each X) for the terrain. The player's Y position would then just be updated based on their X position.

Is there a simple way of doing this (or a better way of solving this problem)? The main problem I can see with this method is the case where there are areas above the ground that can be walked on. Maybe there is a way to just map all walkable ground areas?

I've been looking at this helpful bit of code:
http://thirdpartyninjas.com/blog/2010/07/28/sloped-platform-collision/
but need a way to generate the actual points/vectors.

EDIT:
I did try pregenerating sloped paths using the link I posted but now I'm convinced I should use per-pixel collision as you suggested. I've been looking at the example at: http://create.msdn.com/en-US/education/catalog/tutorial/collision_2d_perpixel and am trying to figure out how to adjust the sprite once a collision has been detected. As David suggested, I made a few sensor points (feet, sides, bottom center, etc.) and can easily detect when these points actually collide with non-transparent portions of a second texture (simple slope). I'm having trouble with the algorithm of how I would actually adjust the sprite position based on a collision.

Say I detect a collision with the slope at the sprite's right foot. How can I scan the slope texture data to find the Y position to place the sprite's foot so it is no longer inside the slope? The way it is stored as a 1D array in the example is a bit confusing, should I try to store the data as a 2D array instead?

I also noticed several people mention that it's best to separate collision checks horizontally and vertically, why is that exactly?


texts: Is it possible to use C++ in SDL for Android?

texts:
I have successfully compiled SDL for Android using the example, which uses C. Is it possible to use C++ too?

I am trying to port a C++ game which uses SDL 2 to Android.

If it is possible, how can I do this?


texts: Implementing simple proportional navigation for a homing missile

texts:
I'm trying to implement the simplest possible form of proportional navigation, i.e, the missile turns in the direction that its bearing-to-target is changing, and once its bearing-to-target is unchanging, it's on an intercept course.

So, I have a 2d missile moving at a constant speed in the direction it is facing, which can turn at a constant rate, and every interval I update the missile with something like:

Position += VectorProduct (Direction * Speed * TimePassed)

PreviousTargetBearing = TargetBearing
TargetBearing = AngleBetween(TargetPosition, Position)
TargetBearingDelta = TargetBearing - PreviousTargetBearing

If TargetBearingDelta > 0: MissileDirection += TurnRate * TimePassed
If TargetBearingDelta < 0: MissileDirection -= TurnRate * TimePassed

Problem is, the missile always oscillates around its launch direction, because as soon as the missile turns the first time, this reverses the sign of TargetBearingDelta, making it then turn in the opposite direction, and so on...

What is the simplest way I can resolve this problem? I'm sure I'm missing something simple.

Related StackOverflow question: How to create an “intercept missile” for a game?

To reiterate, I am interested specifically in implementing the proportional navigation algorithm, not in homing algorithms in general.

Update: I guess the obvious answer is to not check bearing and adjust heading every turn, but to alternate between the two. I'll try that.


texts: Unity, understading Layout element - Min size and preferible size

texts:
I have been some time working with unity, and I am trying to get a better understand of the UI system.

I am a mobile developer and I am redesigning the UI but I am unable to achieve what I want.

My game is portrait and I have a panel. I want the panel to have a maximum width of 1080. In case that the panel doesn't fit in the screen when the aspect ratio is less ( like new iPhone X) . I want it to shrink it a bit with a minimum of 700. In the case that the screen is larger than 1080 ( like iPad pro). I want the panel to have the maximum size.

Visual of what I want to achieve.

Nexus 6P ( 1080x1920)

iPhone X(1125x2436)

iPad pro (2048x2732)

I have been playing with layout element and content size fitter without good result

If I set the min width size to 700 and preferred size to 1080 nothing happen (even playing with flexible width)

If I set the content size fitter. If I choose the preferred size it just get always the preferred size and same with min.

How these elements works, and how I can achieve the desired effect?

Canvas configuration:


texts: how can I visually compensate for latency in a diep.io style game

texts:
implementing extrapolation using linear velocity, orientation and position like on here gafferongames.com/post/state_synchronization/ I'm a little confused if I want to extrapolate from a known position, velocity and orientation forward 8 tick ahead for example, how could I do that, any simple example?

I'm using p2.js physic engine.


texts: How do you do FlashPunk-style animation in libGDX?

texts:
In FlashPunk, you can have multiple animations set, and then choose which one to play at any time, and it'll do it.

Example:
    animatedSprite.add("running", [0, 1, 2, 3], 50);
    animatedSprite.add("falling", [4, 4, 4, 5, 1], 50);
    animatedSprite.play("running");

How do you accomplish this in libGDX?

I can only make it play one animation, looping, and I have no idea how to add multiple.


texts:
Possible Duplicate:
  How should I structure a design document?

I'm planning to apply for a game designer position at a big company. But the problem is, according to my CV, I'm not fit for being a game designer. (I'm a programmer).

But, I don't like this and still would like to try my chances. Even though I'm a programmer, I have lots of ideas which I can put on paper in any detail depth imaginable. (It's not like "bro, I have this cool game idea in which you fly a spaceship and you see these scary monsters just like in ....", I can really make it professional).

To be able to achieve this, I want to send a game design with my application, written in proper way, that will make it easy for them to accept me.

Question is, what is the proper format for game design documents? Is there a template? What is the detail level? Where can I find a final game design document for a released professional game?


texts: LWJGL: loading textures of various types

texts:
I googled around a bit and nobody seems to have asked this question.

I have images in multiple color formats (all of them are PNGs).  Most of them are ARGB but my bitmap fonts are gray scale, and I would like them to stay that way.  All I want to do is find out what format BufferedImage uses to store my pixel data and then use that information with glTexImage2D.  Java, in all its wisdom, seems to be determined to hide that information from me at all costs...

I also need to know how BufferedImage aligns its pixel data in both of these formats (glTexImage2D cares).

Could someone please tell me how to:

Determine the pixel format of my BufferedImage.  If it is ARGB32, I'm going to have to reorder the bytes and use GL_RGBA.  If it's grayscale, I will be using GL_INTENSITY.
Extract the actual bytes from the image.  I have seen a few examples on the web that use BufferedImage.getRaster().getDataBuffer().  This is nonsensical.  Why are there different types of buffers like DataBufferInt?  Because of Java's strong typing, I need DataBufferByte.  If this is the only way, could somebody give me specific directions to use the different type of buffers with glTexImage2D?
Figure out how the aforementioned image data is aligned.  I will use this information with glPixelStorei.

In addition, I come from C and C++ programming.  In C this was 100 lines of simple libPNG and GL calls.  Should I expect more trouble like this in the future?


texts: Do multiple small script files use more RAM than one bigger script file?

texts:
So I'm still new to making games that have a baseline for computer resource usage and I'm confused with my question. I can't find an answer anywhere on the internet so I'm here.

Simple Question:

  Which uses more resources? x10 small scripts or x1 mega script?

Detailed Question:

  Would x10 small scripts that consist of about 70 - 100 lines of code, be more resource consuming than x1 mega script containing about 700 - 1000 lines code?


texts:
I'm writing my own RTS game in Delphi. Single-player part is almost done and works well and I'm thinking about adding multi-player to it now. There's going to be a lobby where players should be able to chat and organize games. I tried googling for a convenient way to do it, but couldn't find anything related ..

My idea looks like follows:

Players are identified by Names they choose and their IPs
There's main chat area where all players meet
There are rooms, where players may select game options (map, teams, flag colors, etc..).
After everything is settled players exchange IPs and multi-player engine starts.

I want to avoid usage of server-side software. Currently I'm looking into running everything through SQL database where each player commits posts and his state and reads other players posts/states.

Whats the common practice of organizing in-game chat lobby?


texts: Play audio in javascript with a good performance

texts:
I'm developing a browser game where the player can shoot. Everytime he shoots it play a sound.

Currently i'm using this code to play sounds in JavaScript:

    var audio = document.createElement("audio");
    audio.src = "my_sound.mp3";
    audio.play();

I'm worried about performance here. Will 10 simultaneous sounds impact my game performance too much?

Will all audio objects stay in memory even after they are played?


texts:
I would like to spawn a cube if I press space and apply a short impulse of force and torque to make the cube rotate. I have some calculations for the impulse but I think they are wrong since the cube only gets faster over time and not fast on the impulse.
The formular for the impulse is p = m · v. In my case I decided to give the cube a mass of 1.

At the moment I calculate the whole impulse thing this way in c++:

                f = 8.f / dt; //force = impulse / dt
                a = f / 1; //acceleration = force / mass
                v += dt * a; //velocity = velocity + a * dt
                p = m_pObject1->getPosition()[0];
                p += v * (float)event.dt; //position= position + v * dt
                m_pObject1->setPosition(glm::vec3(p,m_pObject1->getPosition()[1], m_pObject1->getPosition()[2]));

I am sure I am doing something wrong here also I am a little bit lost in implementing the torque here.
I hope my code and question is clear and I would be happy to see some suggestions. :)

Kind regards


texts: Allow a game object to pass out of a collider but not back in - Unity

texts:
In my game I have enemies that shoot projectiles out at the player, the only way for the player to get rid of them is by guiding them into a structure.

An example of my enemy shooting a projectile.

The problem I have is that sometimes the enemy spawns on top of one of these structures as seen below.

This results in the projectile exploding/colliding with the structure the moment it is spawned.

I'm not entirely sure how to go about fixing this issue.

I have tried to find a way to disable the collider on the projectile for a few seconds but I couldn't get the timer right. I also think this might cause some odd game-play issues.

The second thing I tried was a platform effector, however I could only get it to form a circle and this didn't work out because my structures are of all different sizes and shapes.

If anyone could point me into the right direction or even help me find a better solution I'd be extremely grateful.
Thanks

ublic class MultiBullet : MonoBehaviour {

    public float speed = 1f;

    private Rigidbody2D rb;

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

    }

    // Update is called once per frame
    void Update () {
        rb.velocity = transform.up * speed;
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        ////Add explosion Effect
        //if (collision.gameObject.tag == "Player")
        //{
        //    // Add game over screen here
        //    Debug.Log("Player Killed");
        //    Destroy(gameObject);
        //}
        ////Debug.Log("BOOM");
        ////Destroy(gameObject);
        if(collision.gameObject.tag != "BulletIgnore" && collision.gameObject.tag != "Cloud")
        {
            //Debug.Log("BOOM");
            Destroy(gameObject);
        }
    }
}

Just a simple class to handle when projectiles collide with objects.


texts: Faster way to scale images than gluScaleImage?

texts:
I'm porting a C++ game to Android using the NDK and there's one bottleneck that's really slowing down the code: gluScaleImage().

Does anyone know of a faster way to scale image textures?


texts: Is it cheaper to let each tile have its own collision?

texts:
I'm just now playing around with Tiled, and I think this is the way I'm going to go to create tilesets for my game maps, but I'm curious about the cost (memory/CPU) difference between setting a collision for a specific tile so that Tiled creates them all individually versus manually drawing collision polys around larger sections by hand.  For instance:

By Tile:

Manual:

There are fewer polygons in the manual draw (4), and it's not terribly difficult to create them, but is there a benefit one way or the other?


texts: How to Translate and Position at the same time?

texts: Hi I'm having problem Translating and Positioning at the same time e.g take example of retro spacecraft shooting games in which your spaceship moved in x-axis automatically and you just needed to control position on y-axis. I'm using transform.Translate(new Vector3(0f,Time.deltaTime * speed,0f),Space.World); to translate and then transform.position = new Vector3(Input.mousePosition.x,0f,0f); to position using mouse but it doesn't seem to work. Help !


texts: Animator consecutive set parameter problem

texts:
I'm having a little problem with my animations transitions.

I have this diagram: http://imgur.com/Se8Ix1L

My transitions is made by updating the parameter "stateparam".

My code, changing the parameter: http://imgur.com/HlypG2L

I change stateparam to 2 and right after to 0, then my animation don't restart every frame.

But when I play, the my parameter doesn't change the animation and only change the stateparam to 0. I already debugged and it's passing in the line that change to valid transition value. But i don't know why my animation doesn't changes. If I play and change stateparam manually, it works.

If I take off the SetInteger "0", let only the valid value, the code works, but my animation keep restarting before it can finish itself.

I don't know if the parameter change it's too fast to do the transition or it's any buggy. Any help ?


texts: Level/Map file creation and processing with OpenGL

texts:
How do levels/maps work in the game development world? Counter strike, which is a popular FPS that uses OpenGL as it's graphics library, has it's levels/maps created as *.bsp files. How do you create files like this, and use OpenGL to load them?

Thanks!


texts: SpriteBatch.Draw with scale or rotation trigger a new batch?

texts:
I recently read that any transformation changes will cause a new batch to be triggered.

So, if I have 10 Sprites and each has a different rotation or scale will there be 10 batches sent up?

Or is this somehow limited to SpriteBatch.Begin, where a Matrix is used?

I'm not clear on how the Begin/End relate to scale/rotation in draw calls or if they do at all in terms of how many batches are created.

I appreciate any info on this topic...


texts: Can you adjust the proportions of a 3D model via scripting?

texts:
We are developing a game in Unity where the character is different ages in different levels. Would it be possible to use a single 3D model asset, and alter its proportions via scripting to achieve this effect? For example, stretching the head to make it more oval for older self, or increasing head size for toddler self?

We don't have a model yet. We are envisaging a simplistic, cartoony look rather than something realistic. Is this doable?


texts: How to transfer drag control from one sprite to another? (Phaser)

texts:
I have some sprites that are set to horizontal drag only.

What I want to do is, if someone drags vertically up from one of those sprites, when they leave the bounds of that sprite (top edge), spawn a new sprite and be actively dragging that new sprite.  The user should not have to release the mouse button, they should just instantly be dragging the new sprite.

I can successfully calculate when the pointer is leaving the first sprite, and spawn a new sprite at that location, but I can't seem to transfer the drag control.

I tried Pointer.swapTarget, but that doesn't seem to work - the new sprite is spawned, but just sits there and I have to release the mouse button and re-click on the new sprite in order to drag it.

How can I make the transfer seamless?


texts:
How can I generate water in a procedural 2D sideview landscape?

Here's what I currently have:

First generate the heightmap of the land
Then generate the water, based on the land

Here's how I generate the water based on the land:

Assign each block a lake target for water (rain) flow.

First, choose the best direction.
Then, for each block it checks along the way, calculate the slope between that block and the next block. If that slope is zero, keep on going to create a noninteger slope, until a MAX_BLOCK_DELTA_X is reached. If this accurate slope is close to zero, we say the water drains or evaporates. Otherwise, keeping searching for the bottom of a lake, until the slope goes up again.

Next, lakes are created, based on the most targets chosen in one proximity.
Lastly, the lake height is calculated from the lake's amount of water (I don't know how to do this).

I see some problems with my current algorithm, like if the bottom of a lake is flat the water drains. Could this be improved? If so, how? Either way, how would I calculate the lake's height? How would I do rivers?

Edit: Caves and overhangs are not allowed.

Edit 2: This answer of my other question provides a way to identify valleys. I think this could be used, but I don't know which end to start scanning.


texts: How do I avoid "too" lucky / unlucky streaks in random number generation?

texts:
I'm currently dealing with a multiplayer combat system where the damage dealt by the players is always multiplied by a random factor between 0.8 and 1.2.

In theory, a truly random RNG may eventually yield the same number many times (see the Tetris dilemma). This could result in a match where player is always making very high damage while the other always makes very low damage.

What can I do to make sure this doesn't happen? Are some RNGs better than others at avoiding repetition?


texts:
(This question was split off from 3D collision-detection middleware)

Are there any recommendable middleware available for 2D collision detection?

I believe I've heard that Box2D could be used for collision detection without the physics part. I'd like to hear if people have any experiences on Box2D or others libraries for 2D collision detection specifically.


texts:
I'm working on a roller coaster game, and I have computed a function that represents the path of the track in the 3D space. Since the track will be tubular and will be dynamically generated(as opposed to a very large obj file), I was wondering if there was any elegant way to render something like this.

Something like this is what I'm aiming for

PS: I'm currently working in SceneKit on iOS/OSX


texts:
I am using GLUT library for my research/game.

In my game I have 25 windows created using glutCreateWindow(title), and each of them have their own display callback registered using glutDisplayFunc(Draw).

I am trying to stream the screen of each of the 25 windows on my computer
to another client which will do some processing with all the screen capture of the 25 windows.

Currently I am capturing the screen of each of the 25 windows with:

glReadPixels(0,0,Xres,Yres,GL_RGB,GL_UNSIGNED_BYTE,pixels);

Just doing the call to glReadPixels for each of the 25 windows slows my fps down to 7 fps.

However I require the fps to be at least 25 FPS, is there any way I can improve the fps?


texts:
I'm trying to make a platformer. I'm trying to figure out how to make my character jump. I have tried setting a direction variable (after I enabled physics on the room, the character, etc), and it does jump, but it spins, and falls weird. I just want a simple Mario jumping up or something.

I'm using Game Maker Studio 2 (drag-n-drop).


texts: Making an 'anim in circular motion' get attracted by gravity of the center

texts:
I am working on a project, where the main player anim is in circular motion with respect to a center point. This video shows what I have done to the anim till now.

In that video, there are multiple apples are in circular motion. However, in my case, there is only one anim which is in circular motion. I have tried the following code for the circular motion.

public Transform center;
public float degreesPerSecond = -65.0f;

private Vector3 v;

void Start() {
    v = transform.position - center.position;
}

void Update () {
    v = Quaternion.AngleAxis (degreesPerSecond * Time.deltaTime, Vector3.forward) * v;
    transform.position = center.position + v;
}

The above code works perfect for the circular motion.

At the center (0, 0), I placed a circle sprite with 'point effector 2d' component. (see below image).

The reason why I 'added point effector 2d ' is to apply gravity effect to the player. But that didn't work. The player anim which is in circular motion around the circle sprite should get affected by gravity of that circle sprite and it should be pulled towards the center.

Changing the 'Point effector 2d' parameters is good enough to create gravity? or do I require any change in code?


texts: Help needed in getting the correct hit position a raycast hits a sphere in Unity

texts:
I'm trying to get the actual position a raycast from a controller hit's a sphere gameobject.

The raycast is cast from the controller (gear vr controller) out in the forward direction when the trigger is pressed, but when I test the value of the hit.point, I get varying values depending on what sphere I hit.

Shouldn't the hit point be roughly the same if I say always hit the sphere's more or less dead center?

Here's the code I use to cast the ray, this runs when I click the trigger of the controller:

if (OVRInput.GetDown(LaserInputModule.instance.trigger) && triggerdown == false)
    {
        triggerdown = true;
        RaycastHit hit;
        if (Physics.Raycast(LaserInputModule.instance.helperCamera.transform.position, LaserInputModule.instance.helperCamera.transform.forward, out hit))
        {
            Debug.Log(hit.transform.name + " got hit at: " + transform.InverseTransformPoint(hit.point) );
        }
        else
        {
            Debug.Log("PlayerMissed");
        }
    }

LaserInputModule.instance.helperCamera is basically the controller the player has in their hand.

When I test the values in logcat, for the first picture, I get back what I assume to be correct values

Sphere(Clone) got hit at: (-0.2, 0.1, -0.5) (so x,y are roughly in the center of the sphere)

But when I do the same for another sphere (2nd Pic)enter image description here, I get back some spurious values
Sphere(Clone) got hit at: (-7.2, 2.0, -0.4)


texts: Continous horizontal animation of objects

texts:
We have to continously animate objects from right to left in a panel. The player has to pop the first object.

If the first object could not be destroyed by the player and it reaches the left border of the panel, the game is over:

We have experimented by implementing this using Android widgets.

The panel is a HorizontalScrollView and the objects are ImageViews placed in a LinearLayout. The HSV is continously scrolled using ObjectAnimators and when the first object is popped by the player, a new object is added to the LinerLayout. This solution has some problems: the LinearLayout gets infinitely big, adding new objects to our model and layouting them causes small hiccups and the animator speed is changable through the Android developer options which makes implementing high score pointless.

What would be a "standard" solution for games with an infinite animation where constant animation speed and good performance are critical? Is using native widgets possible with these requirements or should we throw everything away and use a Canvas?


texts: When connecting a physics engine to another engine, should you do all your logic in the units used by the physics side or the rendering side

texts:
I'm currently intergrating pygame and pyBox2D, and am wondering which side is best to try to keep to in terms of game units of size.

Box2D is Meters

PyGame is Pixels

At the moment I am thinking I will keep everything on the box2D side where it makes sense, and then just use a scaling method to turn those numbers into pixel locations. But sometimes I will want to detect something in pixels (mouse location) and have this relate back to the location in the Meters side. Obviously I can use the reverse scaling to get that point, but I was wondering if there are any tips about this?

In order to make the scale easier, I have aligned the box2d world horizonal 0+ and vertical 0+ to match the location of pygame, which takes top left as 0,0 . First attempt I was doing something crazy with 0,0 being in the middle of my pygame world. Seems no reason not to calibrate the Box2D world to match the pygame rendering one to some degree.

Any thoughts or tips?


texts:
so I have a method for taking a screenshot, it works just fine on PC, but I've tried everything and cannot get it to work on Android. I've tried creating custom folders, saving to persistentDataPath, saving to dataPath, and none of it works.
I had a way of testing it which said the name of the screenshot, logically it should keep the name as screenshot1 if it fails to take the screenshot, which it does on mobile, whereas the one on desktop increments properly.
Here's the method I most recently attempted...
    public void captureScreenshot(string name)
    {
        if (!countDown)
        {
            for (int i = 1; i < 500; i++)
            {

                if (!File.Exists(Application.dataPath + name + i + ".png"))
                {
                    if (!Directory.Exists(Application.dataPath + "/appScreenshots"))
                    {
                        Directory.CreateDirectory(Application.dataPath + "/appScreenshots");
                    }
                    ScreenCapture.CaptureScreenshot(Application.dataPath + name + i + ".png");
                    break;
                }
            }
        }
    }

    public void captureScreenshot(string name)
    {
        if (!countDown)
        {
            for (int i = 1; i < 500; i++)
            {

                if (!File.Exists(Application.dataPath + name + i + ".png"))
                {
                    if (!Directory.Exists(Application.dataPath + "/appScreenshots"))
                    {
                        Directory.CreateDirectory(Application.dataPath + "/appScreenshots");
                    }
                    ScreenCapture.CaptureScreenshot(Application.dataPath + name + i + ".png");
                    break;
                }
            }
        }
    }

So, it works just fine on PC, just not on mobile... Do I need to get special permissions or something?
Thanks


texts: How do I import service references to Unity3D?

texts:
I'm attempting access a service reference in Unity. I need two: the SOAP framework and a separate service called ContentVault.

The respective service URL's are:

SOAP: http://api.microsofttranslator.com/V2/Soap.svc
ContentVault: http://ioun.wizards.com/ContentVault.svc

Both services import fine in to Visual Studio. I've tried everything I can think of but they won't work with Unity. I just get various errors (changing depending on which solution I'm trying out).

I've attempted using svcutil to export the services as external scripts, but all I got was a bunch of using errors. I've tried converting the code to work with .NET 2.0 to no avail, I've even tried making the services in to .DLL's to no success.

How could get these services working with Unity?


texts: How to sync new object (weapons/bullet) in a multiplayer photon game ?

texts:
I'm using Photon to develop a multiplayer game.
I would like to know the best way to synchronize "weapons" bullets object between network players.
Thanks


texts: Libgdx shaperender within a circle as limitter

texts:
I encountered a problem, where my small entities would be rendered
out of the bounds of my radar.

At the time I solved it like this: ensure, that the object would be within the circle, but, that's not optimal, because I need variable scale for different entitie sizes, which causes further problems to be solved.

So is there a way, that I can do the following:

  draw all items within the circle and ensure that nothing is drawn outside

I thought about something, like a circle canvas, which draws all, but displays only that, which is in the bounds.

The points and lines within the circle are of a variable width / height.
I'd prefer to draw everything, and cut the other stuff off.

Thanks in advance!

€dit: Gosh forgot an important thing: I draw the items with a shaperenderer, and all things are rect's , and it probably wont be polygons


texts: Should I continue studying OpenGL or just switch to DirectX to  give me a better chance of landing a job in the game industry?

texts:
I've been learning graphics programming for some time now using OpenGL and Linux. I'm pretty familiar with most of the concepts, but I would really like to further my knowledge and eventually pursue a career in game development, especially game engine development.

So far it seems to me that the majority of game studios make games for Windows using DirectX.

Edit: I know that the OpenGL vs DirectX question has been asked here before, but I haven't found an answer in the perspective I want.

Edit 2: After reading all the responses/comments I've decided to continue diving deeper into graphics with OpenGL/GLSL, but I'll try to play around with DX as well, just to have a basic understanding of the API.
I'd like to thank everyone for the answers and insight you've given me.


texts: Is it legal to develop a game using other games skill names/flavor/mechanic?

texts:
I am starting to develop a new game and i'm thinking about using some names for some features coming from other games (such as WoW and D&D).
I have already read this Is it legal to develop a game using D&D rules? and i know about Beholders and Mind Flyers (before reading this question) which i'm not going to use anyway in my game (neither specific D&D rules nor those monsters) and i'm not going to use an aready existing game system as i'm developing mine (which will use some classical RPG concepts but will have its unique flavor, at least i hope so...).

What i'm interested in is to know if i can legally use names those games use for skills, statistics, classes, enemies and so on...

I'm not talking about classic names such as Wizard, Mage, Warrior but more specific names you will find almost exclusively in that game (such as Bladesinger, Charisma, Power Attack or Warbringer...which apparently is a metal band and a monster in WoW and nothing else), these features won't be an exact copy of what you can find in other games, but will inherit just the "flavor" (sometimes not even that) of that feature

for example can i make a skill called "Power Attack" which gives you more damage per attack but a lower chance to hit (which is similar to D&D's power attack, though not exactly the same since mine will have a fixed % of damage increase and lowered chance to hit)?
What if this skill gives you more damage when using a weapon two-handed (which is a key feature of D&D's power attack in the 3.5 edition)?

I am aware that those are simple words and they can't be under copyright, what i'm more worried about is the flavor of a skill, statistic and so on and using a mechanic very similar to those found exclusively in other games


texts: generate box2d bodies from isometric tiled map

texts:
I followed the tutorial here to generate box2d bodies from a tiled map and that worked fine.... for orthogonal tiled maps. Unfortunately isometric maps use their own coordinate system where (0, 0) is at the leftmost corner of the map, and this causes the bodies to be in the wrong place.

I tried implementing a transformation matrix or just transforming the body but I don't think that is possible (or at least I could never find a way). How else can this be solved? Here is the relevant method that needs to be changed:

private Shape getPolygon(PolygonMapObject polygonObject) {
    PolygonShape polygon = new PolygonShape();

    float[] vertices = polygonObject.getPolygon().getTransformedVertices();

    float[] worldVertices = new float[vertices.length];

    for (int i = 0; i < vertices.length; ++i) {
        worldVertices[i] = vertices[i] / units;
    }

    polygon.set(worldVertices);
    return polygon;
}

As you can see I need a way to convert the isometric coordinates to game coordinates using just plain math or something else like a matrix. I think the only line needing to be changed is the line in the for loop.


texts: Best way to create icon for UI , based on 3d model player can use in game

texts:
I'm trying to figure the best way to create icon (for UI) from my 3d model (object) that player can use in the game.
Maybe this is a silly question, but: how do you create icon ?
Do you create a new scene, place object and use a "shift-print" to take screenshots ?

Others way ?

Thanks


texts:
What is the complete code (C#, pseudo, does not matter) for calculating the resulting segment (or its absence) for the intersection of asegment and a cylinder?

The segment is defined by Vector3(x,y,z) as Start andVector3(x,y,z) as End.

The cylinder is defined by the same parameters plus a value for Radius.


texts: Questions about scaling in a 2d game in unity

texts:
Okay, so:

I am making an android game. I want everything to scale to the size of the screen I'm using. Further, my static background needs to scale (as well as every other object), but if the aspect ratio is less than the AR of the background image I want the image to be cut off at the edges.

Further, I have a game object I need to always be at the corner of the screen. I'm guessing I should use a script to determine the width of the screen and place it a few coordinates up and right of that on start?

The game is only in landscape mode if that matters. How do I go about this? I previously had the background as a plane with an image on it but it didn't take up the whole screen and I think it might not be the right thing to do? Maybe use a quad?

How do I test to make sure that this works? I only have my one android phone to test it on.


texts: Importing FBX with multiple meshes in UDK

texts:
I need to import into UDK a several amount of FBX models (representing buildings) which are composed by various submeshes (walls, windows, roof...). I need to keep the individual meshes (can't use the merge option) but I also need to work with the building as a whole. Do you know if this is possible? How?

Also, is there a way to keep the textures assignment for the FBX models after importing them to Unreal? Doing the process manually (importing model, importing texture, assign to the material, assign the material to each mesh and submesh) for 100 or 200 models (to import an entire city from City Engine), isn't viable.


texts: Problem with Factory Method Pattern when I try to create a Weapon:MonoBehaviour

texts:
I'm learning about Design Patterns using Unity and I'm not sure about how to solve the following problem with the Factory Method Pattern:

I want to read a XML file and using the Factory Method Pattern to create a Component (a Weapon) to add it to a GameObject which will be cointained on a Pool Manager, but Weapon "Is A" MonoBehaviour and for that reason It can't be instantiated using a "machineGun = new MachineGun();"

public abstract class WeaponFactoryMethod
{
    protected string fileName = "weapons.xml";
    public abstract Weapon CreateWeapon();
}

public class MachineGunFactoryMethod : WeaponFactoryMethod
{
    public override Weapon CreateWeapon()
    {
        string filePath = Path.Combine(Application.streamingAssetsPath, fileName);
        Weapon machineGun = null;
        XmlReader xmlReader = new XmlTextReader(filePath);
        if (xmlReader.ReadToDescendant("Weapons"))
        {
            if (xmlReader.ReadToDescendant("Weapon"))
            {
                do
                {
                    // I CAN'T DO THIS:
                    machineGun = new MachineGun();
                    machineGun.ReadXml(xmlReader);
                } while (xmlReader.ReadToNextSibling("Weapon"));
            }
            else
            {
                Debug.LogError("There aren't definition for Weapon");
            }
        }
        else
        {
            Debug.LogError("There aren't definition for any Weapon");
        }

        return machineGun;
    }
}

public abstract class Weapon : MonoBehaviour, IXmlSerializable
{
    public float AttackRange { get; set; }
    //Every weapons Shoots in a different way
    public abstract void Shoot();

    //Serialization
    public XmlSchema GetSchema()
    {
        return null;
    }

    public void ReadXml(XmlReader reader)
    {
        XmlReader childReader = reader.ReadSubtree();
        while (childReader.Read())
        {
            switch (childReader.Name)
            {
                case "AttackRange":
                    childReader.Read();
                    AttackRange = childReader.ReadContentAsInt();
                    break;
            }
        }
    }

    public void WriteXml(XmlWriter writer)
    {

    }
}

public class MachineGun : Weapon
{
    public override void Shot()
    {
        //Raycasting..
    }
}

At the end I want something like

GameObject (player)
 - Component (A Weapon script with the data from the xml)

Should I just create a GameObject (player) and do an "AddComponent < MachineGun >" and later copy the info from the xml file instead using the Factory Method Pattern??

Is there a better way??

Any suggestions, corrections or advice will be very grateful.

I'm sorry by my English.


texts: LibGdx, conflicting UI button clicks and screen touch events

texts:
My game's main game class is a Screen which also implements InputProcessor to handle touch events.

The screen renders a TMX map using an HexagonalMapRenderer and a Camera, like this:

_camera = new OrthographicCamera();
_map = new TmxMapLoader().load("1087.tmx");
_mapRenderer = new HexagonalTiledMapRenderer(_map);
_camera.setToOrtho(false, Gdx.graphics.getWidth(),  Gdx.graphics.getHeight());

To allow the user to scroll the map, I am overriding the touchDown and touchDragged methods; it works.

However, I also have a Scene2D Stage rendering on the Screen, which I use to display some buttons.

They get displayed. and I have created a ClickListener like this:

 button.addListener(new ClickListener(){

    @Override
    public void clicked(InputEvent e, float x, float y){
        System.out.println("Clicked!");
    }
 });

If I use

Gdx.input.setInputProcessor(this);

Only the Screen scrolling functions will work, and the buttons will become unresponsive.

On the other hand, if I use:

    Gdx.input.setInputProcessor(stage);

I will be able to use UI buttons, but the map will become unresponsive.

I'd like to enable both (map will scroll if user clicks anywhere BUT the UI buttons, it will then fire the button clicked listener), is there any way to do this?

Thanks.


texts: Deterministic Procedural Wave Function Collapse

texts:
I've been looking into the Wave Function Collapse algorithm and was wondering if there is a way to make it (appear) deterministic regardless of starting position.
I can see how this is trivial if the starting position remains the same. We can simply always collapse the tile with the lowest entropy and use a seeded pseudo random number generator or a noise function to decide which is next whenever there isn't a clear winner.
Now what would be the best solution if I wanted to procedurally generate a world around the player? Say I generate the world in chunks. If a player moves far enough away distant chunks get unloaded and new chunks are generated.
This works perfectly fine until the player starts to backtrack. Since tiles depend on their neighbors, a revisited chunk might very well look completely different if approach from a different direction.
I can think of two possible solutions:
a) Always generate the world from a set starting position.
This doesn't seem feasible in big worlds, as it would require more resources the further away from the starting position the player is.
b) Only generate chunks once and then save them.
I don't really like this approach, because it could potentially require a lot of disk space. It's also not really deterministic, because the order in which the player explores the world would still influence what individual chunks look like.
Is there a solution I'm overlooking or is this simply not possible because of how the algorithm works? Keep in mind that I don't care if the algorithm itself is actually deterministic regardless of starting position. The result just has to appear that way, so that already visited chunks can be recreated unchanged.


texts: How to bend a 2D rectangle in an animation?

texts:
It is something done often in 3D but I've never heard of it in 2D. I want to bend a 2D rectangle looking a bit like that:

I've seen people adding lots of vertex around knees and elbows of 3D models for that purpose. Should I make my 2D rectangle be lots of smaller triangles in order to bend it, just like in 3D? I feel like it's overkill just to bend a rectangle. Is there a better way to do this? I'm using LibGDX. I would like the rectangle to stay proportioned. Is there common algorithms to do that?


texts: Why do I see spaces between polygons in OpenGL, only on an Nvidia 720M?

texts:
I'm developing an OpenGL application that renders .obj 3D models.  I use VBOs to render the polygons.  Using the same code, the loaded models appear fine on all PCs, except on my Nvidia 720M.

My laptop sports an Intel HD 4000 embedded graphics GPU, and an Nvidia 720M. When I use the Intel GPU, it looks fine, but when I load it on the Nvidia 720M, spaces appear around polygons like so:

On Nvidia 720M GPU:

On everything else:

No other 3D application that runs on the Nvidia 720M GPU has the same issue.  I am using the latest drivers.

Is this a problem with my application?  How can I fix it?


texts: Mobile Unity Shader - how to work with on/off boolean

texts:
How do you set a boolean for a shader?
How do you write a conditional or assign a boolean in a shader?

So, it seems that shaders do not take booleans... so I tried assigning the float to 0 or 1 ren.material.SetFloat("_ZWriteVal", 1f);, but it doesn't seem to work...

 Shader "ZTestLess"
{

 Properties {
_Color ("Color", Color) = (0,0,0)
[Toggle(Z_WRITE_VAL)]
_ZWriteVal("Z Write Val", Float) = 0
}

SubShader
 {
    Tags { "Queue" = "Background" }

    Pass
    {
        CGPROGRAM
        #pragma shader_feature Z_WRITE_VAL

         #ifdef Z_WRITE_VAL
            ZWrite On
         #else
            ZWrite Off

           ZTest Less
            Color [_Color]
            Lighting Off

         ENDCG
    }
}
}


texts: Can the time it takes for a packet to be transmitted from a client to the server fluctuate?


texts: How to preserve generated textures in XNA?

texts:
My game generates small "minimaps" for each room you go to, which are rendered onto render targets then stored in textures and displayed on the world map. When the game is saved, each new minimap is saved on the hard drive. If the game is in full screen and the user minimizes the game, the minimaps that were generated, not loaded off the hard drive, will become blank.

Since I don't know exactly what render targets are doing in the background, I have no idea how to prevent this, or restore the textures if they are lost.

How can I prevent/workaround this problem?

EDIT:
I did do

textureToDisplay = (Texture2D) textureRenderTarget;

but alas, this conversion doesn't seem to prevent the issue from occuring. I believe this is because textureToDisplay is still a reference to a render target. Perhaps I need to perform a deep clone? If so, how?
Also, the preserve contents thing doesn't work for this situation either.


texts:
I am trying to create a ListBox where each ListItem is just some text. I can make it so if a ListItem goes off the ListBox's height then don't show it. This is just a simple if statement in my render function checking to see if the ListItem's position is inside the ListBox's rectangle.

I want to improve this by making the ListBox scrollable. So similar to the picture below, I should be able to partially see the ListItem if I start scrolling down until it's fully in view.

How would I go about doing this? I'm thinking I would need some Camera and only render things inside the Camera's rectangle. Though, I do not know how to begin this.

My current code just doesn't render the ListItem if it goes off the ListBox's rectangle:

class ListBox {
  private:
    std::vector<ListItem*> list_items;

  public:
    ListBox();
    ~ListBox();

    void update();
    void render();
}

void ListBox::render() {
  // Loop through list items here
  if(item->rectangle.h + item->rectangle.y <= this->rectangle.h + this->rectangle.y) {
   item->render();
  }
}

Without the if statement, it looks like this:

I want "Test: 8" and "Test: 9" to be hidden inside the white rectangle until I scroll down.


texts: Equal 3D icon size visualization in Unity

texts:
I have some Icons (Sprite rendered in 3d world) whose icons are equal size (scale 1). Now I am trying to implement a solution that icons visually show at same size.  If you see the icon at distance then it looks very small when you near the icon then it look bigger. So I want to visualize them equally.
For this reason, first I got the near scale value which is .5 (suitable) and far scale maybe around 1.5. Now, here is my code but it producing very large scale value.
 void Update()
    {
        foreach (var item in iconsObjects)
        {

            float size = Vector3.Distance(activeCamera.position, item.transform.position);
            if (size < 2000)//for optimization purpsose only conside near object under 2000m distance
            {
                float finalSize = Mathf.Clamp(size, 0.5f, 2f);
                item.localScale = new Vector3(finalSize, finalSize, finalSize);
            }

        }
    }

I thought Mahtf.Clamp will work within the context but it is not suitable here as it is applying scale 2 to the near objects where it should be around .5.


texts:
Lately I tryed a few times to create characters for some games, but at some certain point (especially when collision detection came in) everything became messy and the interaction between chars, the world and certain items had a lot of bugs. So here is my question, how do you ussualy keep track of actions that your character is allowed to do, or more in general do you have some links / advices how to set up a char efficiantly?

I´m working on a char right now, who should at least be able to run, jump, pick items up and use different fighting animations. Most ideas I came up with until now use some kind of action.priority / action.duration system to determain whats possible and what not, or a "action-manager" which defines for every action what is possible from that action on but it all doesnt work that well together.


texts: How do I find the intersections between colliding circles?

texts: I want to find whether 2 circles with radii r1 and r2 intersect, and if so, where they do so. Is there a simple solution?


texts: What is the difference between DXGI_SWAP_EFFECT_DISCARD and DXGI_SWAP_EFFECT_SEQUENTIAL?

texts:
I have difficulty understanding the difference between those two values of the DXGI_SWAP_EFFECT enumeration. MSDN documentation states:

  DXGI_SWAP_EFFECT_DISCARD

  Use this flag to specify the bit-block
  transfer (bitblt) model and to specify that DXGI discard the contents
  of the back buffer after you call IDXGISwapChain1::Present1. This flag
  is valid for a swap chain with more than one back buffer, although,
  applications only have read and write access to buffer 0. Use this
  flag to enable the display driver to select the most efficient
  presentation technique for the swap chain.

  DXGI_SWAP_EFFECT_SEQUENTIAL

  Use this flag to specify the bitblt model and to specify that DXGI
  persist the contents of the back buffer after you call
  IDXGISwapChain1::Present1. Use this option to present the contents of
  the swap chain in order, from the first buffer (buffer 0) to the last
  buffer. This flag cannot be used with multisampling.

So, Sequential is for displaying the contents of the chain "in order", in other words, in the same order as you called Present(). If so, is Discard not in order? Obviously an older picture should never be shown before a newer one. What kind of "most efficient presentation technique" would this flag enable then?

What if your monitor's refresh rate is 60fps and your code is able to render at 90fps. In this case, every one out of two Presents, the queue will be full. What happens then? Does Present block until the next vsync, capping your rendering rate to 60fps and introducing input lag, or does it discard the oldest buffer in the queue with the new one and allows you to go on with your rendering code as fast as you can? Do these DXGI_SWAP_EFFECT flags have any bearing on the issue?

Thanks.


texts: Wall-sliding Collision Response Only Works On One Axis (2D)

texts:
"sprite" is the player object, velocity is a Vec2 that tracks movement (is set to -1, 1, or 0 at any given time), each sprite in "sprites" is a wall of the same size as the player (everyone is a block for testing purposes).

if (velocity != Vec2.Zero)
{
    Vec2 oldPos = sprite.Position;
    sprite.Position = sprite.Position + velocity;
    foreach (Sprite s in sprites.Except(new List<Sprite> { sprite }))
    {
        if (sprite.BoundingBox.Intersects(s.BoundingBox))
            sprite.Position = new Vec2(oldPos.X, sprite.Position.Y);
        if (sprite.BoundingBox.Intersects(s.BoundingBox))
            sprite.Position = new Vec2(sprite.Position.X, oldPos.Y);
    }
    velocity = Vec2.Zero;
}

So, this actually works quite well - except for some reason it only works in one direction. Collisions work in both, but when sliding against a wall by holding two direction keys it only works sliding along the Y axis.

The bounding box for "sprite" is updated whenever the "Position" variable is written to via an accessor, so the bounding box is always up to date. The walls do not move, so theirs are also up to date.

At first glance, it seemed that there were a few obvious spots to check - I am modifying the bounding box for the second check, and at the time I hadn't been doing it automatically, so I tried disabling that. Doing so broke the working parts, so it wasn't that. I get no change in behavior when I add "else" to the second if statement, confirming that the first block always runs and the second block never does. If I flip them around, the other axis works instead.

I tried separating them into two foreach loops (just to see) and the behavior still remained the same. I'm kinda confused as to why none of these changes produced any hints as to the issue - it's likely something I'm overlooking, so I was hoping someone else would see.

If you need me to post any other code, just ask.

I was trying to do this in 3D and had a very bad time, so I figured I'd make a 2D version of my engine and get things sorted there before moving the collision back into 3D, heh..


texts: Get tile position on what a mouse clicked

texts:
I am writing a chess game using Java and Swing, And I wanted to get the tile position on which a mouse clicked. I searched through internet, but all of them were really off, and never accurate. When I clicked on a tile's first half, it said it was tile 1, but on the second half, it said it was tile 2, but it was still tile 1. So I was wondering, how can I do it?
My tile size is (75, 75)
This is the code I've written for tileX: Math.floor((double)evt.getX() / 75), and this is the code I've written for tileY: Math.floor((double)evt.getY() / 75).


texts: Things not appearing in front of canvas (follow up)

texts:
Follow up/related question to: Things disappear in front of Canvas

I'm having a very similar problem, where things are not appearing in front of my canvas. This time a particle system. I have tried the suggestions outlined in my previous questions (which worked then) but this time none of them will work:

You can see that the particle system is on top of the children and also I have added a canvas and overwritten sorting (the two suggestions in my previous post) yet the particles are not visible in front of the canvas.


texts: In Pong, how do you calculate the ball's direction when it bounces off the paddle?

texts:
I'm trying to wrap my head around this very Hello World-y problem in game development. I've created a TicTacToe game in XNA so I guess the next step would be a Breakout clone.

Keep in mind that I have no knowledge on game programming or even what maths I should apply to where. That's why I'm asking this question.

To the question: How can I determine where the ball should bounce when it hits the paddle at the bottom of the screen?

I'd imagine it would be something like:

Capture speed and angle from incoming ball.
Detect where it touched the bar (far left, far right, center) and according to that give it a higher speed if it touched the outer areas.
This is where I'm stuck. Hehe.

Any insights? I realize this is not a straightforward answer type question, but I'm sure it's one everyone faces at some point.

I'm reading the book Linear Algebra that was recommended on this website, but I still have no idea if I should apply it here.


texts:
This is a follow-up question to my last one. I am developing a game which has an Icon on a JLabelwhich the user controls with WASD keys. Right now it can go up, down, left, and right, but I want to know how I can make it move diagonally if two keys are held. I have recreated a short example and posted it below along with a gif(sorry, it's not very smooth), and I am hoping you can help me out. Thanks!
public class Experiments extends JFrame {
    javax.swing.Timer movement;
    int x = 230;
    int y = 120;
    boolean wPressed, aPressed, sPressed, dPressed;

    public Experiments() {
        layoutGame();
        setTitle("Example");
        setSize(500, 350);
        setLocationRelativeTo(null);
        setVisible(true);
    }

    private void layoutGame() {
        JLabel bg = new JLabel();
        bg.setIcon(new ImageIcon(this.getClass().getClassLoader().getResource("space.png")));
        add(bg, BorderLayout.CENTER);

        JLabel you = new JLabel();
        you.setBounds(x, y, 50, 50);
        you.setIcon(new ImageIcon(this.getClass().getClassLoader().getResource("happy.png")));
        bg.add(you, JLabel.CENTER);

        JTextPane direction = new JTextPane();
        direction.setText("Direction");
        add(direction, BorderLayout.SOUTH);
        move(you);

        direction.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent e) {
                movement.stop();
                if(e.getKeyChar() == 'w') {
                    wPressed = true;
                    move(you);
                } else if (e.getKeyChar() == 'a') {
                    aPressed = true;
                    move(you);
                } else if (e.getKeyChar() == 's') {
                    sPressed = true;
                    move(you);
                } else if (e.getKeyChar() == 'd') {
                    dPressed = true;
                    move(you);
                }
                direction.setText(null);
            }
            public void keyReleased(KeyEvent e) {
                wPressed = false;
                aPressed = false;
                sPressed = false;
                dPressed = false;
            }
        });
    }

    private void move(JLabel icon) {
        int delay = 10; //milliseconds
        ActionListener taskPerformer = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                if(icon.getX() >= 0 && icon.getX() <= 450 && icon.getY() >= 0 && icon.getY() <= 250) {
                    if (wPressed) {
                        y = y - 4;
                    } else if(aPressed) {
                        x = x - 4;
                    } else if(sPressed) {
                        y = y + 4;
                    } else if(dPressed) {
                        x = x + 4;
                    }
                    icon.setBounds(x, y, 50, 50);
                    icon.repaint();
                }
            }
        };
        movement = new javax.swing.Timer(delay, taskPerformer);
        movement.start();
    }

    public static void main(String[] args) {
        new Experiments();
    }
}

The output is smooth, but I had to make a gif, so it looks bumpy(sorry again):


texts:
Can someone provide me an explanation of how the lookAt matrix works?

+----+----+----+----+
| Xx | Xy | Xz |  0 |  <- x axis
+----+----+----+----+
| Yx | Yy | Yz |  0 |  <- y axis
+----+----+----+----+
| Zx | Zy | Zz |  0 |  <- z axis
+----+----+----+----+
| Tx | Ty | Tz |  1 |  <- camera position
+----+----+----+----+

From my current understanding using the diagram above from this tutorial, the zAxis is created by subtracting camera position from the target position. Then you create two more perpendicular vectors calculated by: xAxis = zAxis x up, yAxis = xAxis x zAxis.

However, I don't understand how these exact operations result in the camera facing towards something? Like why are these exact calculations needed? Why could it not have been zAxis = camPosition - targetPosition? Or yAxis = zAxis x down instead of zAxis x up? Or have xAxis = targetPosition - camPosition instead of the zAxis?


texts: How to correctly combine scoreboard data?

texts:
I need a help with a scoreboard I am making. Here's the scoreboard I want to achieve:

I actually have 4 tables and each tables has its own scoreboard but for this question only one table matters.

Here's how I am creating this kind of scoreboard:

if (gametable_no == 1)
{
    for (int i = 0; i < tzPlayInfo.Instance.bc_gametable_history_list.Count; i++)
    {
        newString[0] += tzPlayInfo.Instance.bc_gametable_history_list[i].r;
        newString[0] += ",";
    }
    string[] groupedString = newString[0].Split(',');

    foreach (string allchars in groupedString)
    {
        int x = 0;
        int y = 0;

        GameObject o = Instantiate(prefab_big_road[0]) as GameObject;
        o.transform.SetParent(pos_big_road[0]);
        o.transform.localScale = Vector3.one;
        o.transform.localPosition = new Vector3(2.0f, -5.0f, 0f);
        o.transform.localPosition = new Vector3(o.transform.localPosition.x + x,
            o.transform.localPosition.y + y, o.transform.localPosition.z);

        if (allchars.Contains(playerwinnopairboth))
        {
            o.GetComponent<UISprite>().spriteName = "layout_player_bigline-01";
            NGUITools.SetActive(o, true);
        }
        if (allchars.Contains(bankerwinnopairboth))
        {
            o.GetComponent<UISprite>().spriteName = "layout_banker_bigline-01";
            NGUITools.SetActive(o, true);
        }
        if (allchars.Contains(tienopairboth))
        {
            o.GetComponent<UISprite>().spriteName = "layout_tie_bigline-01";
            NGUITools.SetActive(o, true);
        }
    }
}

The result I get with this code is this:

Here's what the data I use to generate the table looks like:

Gametable 1 history : P  ,P  ,P  ,B   ,B P,P P,TBP

So I need a way to know if the character is changing in the gametable 1 history data.

Here's the expected scoreboard output with the data above:

If the value is not changing like P  ,P  ,P then the position should only increment on the y-axis. If the next value is different like B   , then it will move on the x-axis.

So, how would I implement this?


texts: How can I use multiple meshes per entity without breaking one component of a single type per entity?

texts:
We are just switching from a hierarchy based game engine to a component based game engine. My problem is that when I load a model which has a hierarchy of meshes, and the way I understand, is that an entity in a component based system can not have multiple components of the same type, but I need a "meshComponent" for each mesh in a model. So how could I solve this problem.

On this site they implemented a Component based game engine:
http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/


texts:
I'm creating an RPG / Adventure game with an educational foundation aimed at 7th-12th grade. I'm having trouble balancing quests and storyline with the foundational nature of learning.

Meaning, since this is a true video game, and is meant to immerse students in a game world, it's challenging to implement the necessary repetitive nature of education/learning while ensuring the game itself is not repetitive. So, if you have a certain concept/chapter you want to engrain into the mind of a student, how can you design seemingly non repetitive/non linear quests to encourage review of those concepts.

This question is inspired by my own interest to design an EdTech game, but also from Ted Talks like Gabe Zichermann's How Games Make Kids Smarter and Jane McGonigal's Gaming Can Make a Better World.

Gabe brings up several sources, like Gamification By Design, but I'd like to know more sources that you can recommend that explain the components of an engaging EdTech game.


texts:
As an exercise set to myself, I wanted to make a Mesh loader using modern OpenGL.

However, I have to ways of representing the notion of face of a mesh.

Currently, I am using what seems the most natural. A mesh contains a

std::vector<Triangle>

and a Triangle is simply

struct Triangle
{
    unsigned int Vertices[3];
}

(i.e. each triangle stores the three indices of its vertices).
NOTE : a mesh contains others things (such as the vertices and the normals but I didn't include them here for simplicity).

However, OpenGL require a different representation for using EBO : only one static array on indices (implicitly grouped by 3).

What I have come up with is a trade-off between these representations : once the mesh is loaded, I generate a static array of size

3 * mesh->Faces.size()

but I assume this is not the best option for memory use and redundancy.

So my questions are :

If I want to keep my current representation of a mesh (with a vector of faces), how should I set OpenGL to properly render such a mesh ? Is my current solution of generating a new static a good practice ?
Assuming I can use the representation I want for my mesh. What would you recommand and why ?


texts: I'm able to Lerp the color of a UI panel within the Update method. However I'd like to trigger behavior a single time when needed. If I put it in a method and call it it only changes for a brief time and doesn't fully complete. I could probably set a bool flag within the update method but that seems sloppy.


texts: Cutout fragment shader pixels arent square

texts:
It has been solved, link to the final shader:
Shader

The problem (as portrayed by the image below) is that the pixels seem to be, for lack of a better word, cut off. I wish to either display a pixel, or not.

My fragment function, it uses the red value of the vertex colors (displayed by the image blow) on the edge of the mesh which are assigned during mesh generation to determine the pixel cutout "weight" by multiplying it with the texture.

fixed4 frag (v2f i) : SV_Target
{
    fixed4 tex = tex2D(_MainTex, i.uv);

    if (i.color.r * tex.r > 0.4f) discard;

    return fixed4(tex.rgb * clamp(i.color.r, 0.3f, 1.0f), 1.0f);
}


texts: How can I use another script from a script?

texts:
The first script is very long, and I need to use only the top of it:

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

public class mBitmap2MeshV30a : MonoBehaviour
{
    public Texture2D SourceTexture;
    private float Pixel_vs_Unit_Scale = 1;
    public float extrudeDepth = 1;
    private Vector2 scanpoint;
    private bool gotStart = false;
    private int maxsteps = 512;
    public bool invertFaces = false;
    private Mesh srcMesh;
    private mMeshExtrusion2.Edge[] precomputedEdges;
    private List<ExtrudedTrailSectionBM3> sections;

    public class ExtrudedTrailSectionBM3
    {
        public Vector3 point;
        public Matrix4x4 matrix;
        public float time;
    }

I need to assign a value to SourceTexture from another script. This is the other script:

void Start ()
{
    text2d = new Texture2D(10, 10, TextureFormat.ARGB32, false);
    System.Drawing.Font myf = new System.Drawing.Font(FontFamily.GenericSerif, 12);
    Image myimage =  DrawText("Hello", myf, System.Drawing.Color.Red, System.Drawing.Color.Black);
    Bitmap mybitmap = new Bitmap(myimage);

    MemoryStream msFinger = new MemoryStream();
    mybitmap.Save(msFinger, mybitmap.RawFormat);

    text2d.LoadImage(msFinger.ToArray());
    filter.GetComponent<Renderer>().material.mainTexture = text2d;

    mBitmap2MeshV30a bb = new mBitmap2MeshV30a();
    bb.SourceTexture = text2d;
}

The problem is I can't make a new mBitmap2MeshV30a bb = new mBitmap2MeshV30a();. Both scripts are attached to the same GameObject, in the hierarchy.


texts: Is Frustum Culling by itself enough for Consoles and Mobiles?

texts:
Software occlusion culling is often expensive, especially for smaller and older devices.

Is frustum culling alone adequate on systems that can optimally display 10k triangles at most?

If not, are there any relatively fast techniques for determining which objects (both moving and static) occlude others?


texts: What is a good method for coloring textures based on a palette in XNA?

texts:
I've been trying to work on a game with the look of an 8-bit game using XNA, specifically using the NES as a guide.

The NES has a very specific palette and each sprite can use up to 4 colors from that palette. How could I emulate this? The current way I accomplish this is I have a texture with defined values which act as indexes to an array of colors I pass to the GPU. I imagine there must be a better way than this, but maybe this is the best way?

I don't want to simply make sure I draw every sprite with the right colors because I want to be able to dynamically alter the palette. I'd also prefer not to alter the texture directly using the CPU.


texts:
From what I understand, resizable BAR (aka. Smart Access Memory) makes it possible to access the whole GPU memory from CPU code. But how can a programmer make use of that?
Is there an example or code snippet somewhere, that makes use of that feature? Or is that just an automatic that improves the performance of staging resources?
I'd also be happy if you can recommend further search terms that I can look up.


texts:
I'm having trouble passing values that are inside an int function to an onclick delegate.

this script causes the object to move in vector3 (-1 to the left and 1 to the right), these two values are inside the (int value), but I am trying to pass them to a delegate, but when inserting it it is adding different values than being in the script

video of the problem

private int index, index2 = 0;
[SerializeField]
private Vector3[] Myposic1, Myposic2;
[SerializeField]
private Button left, right;//here I change the positions of Myposic1, Myposic2
[SerializeField]
private float time;
public int slide = 0;//index between Myposic1, Myposic2.

void Update() {
    call();
}

public void previous()
{
    slide--;
    call();
}

    public void next()
{
    slide++;
    call();
}

void call()
{
    if (slide <= 0)
    {
        slide = 0;
    }

    if (slide >= 1)
    {
        slide = 1;
    }

    if (slide == 0)
    {
        left.onClick.AddListener(delegate { player(-1); });
        right.onClick.AddListener(delegate { player(1); });
        this.transform.position = Vector3.Lerp (this.transform.position, Myposic1[index], Time.deltaTime*time);
        if (index == Myposic1.Length - 1)
            right.interactable = false;
        else
            right.interactable = true;

        if (index == 0)
            left.interactable = false;
        else
            left.interactable = true;
        Debug.Log("1");
    }

    if (slide == 1)
    {
        left.onClick.AddListener(delegate { player2(-1); });
        right.onClick.AddListener(delegate { player2(1); });
        this.transform.position = Vector3.Lerp (this.transform.position, Myposic2 [index2], Time.deltaTime*time);
        if (index2 == Myposic2.Length - 1)
            right.interactable = false;
        else
            right.interactable = true;

        if (index2 == 0)
            left.interactable = false;
        else
            left.interactable = true;
        Debug.Log("2");
    }
}

public void player(int valor) {
    index = index + valor;
}

public void player2(int valor2) {
    index2 = index2 + valor2;
}


texts: Unity -- custom shader behaves differently on WebGL deployment (correct) and editor view (incorrect)

texts:
I started working on shaders and lighting on Unity3D 5.2.1f1. I set up a scene where the sun object rotates the directional light (the only light in the scene) based on its position to simulate a light object orbiting around the model object while rotating the directional light accordingly.

Here, I have implemented Phong reflection model by writing the custom shader below.

Shader ".Tutorial/Phong"
{
    Properties
    {
        _Diffuse("Diffuse Color", Color) = (1, 1, 1, 1)
        _Specular("Specular Color", Color) = (1,1,1,1)
        _Ka("Ambient Light", Vector) = (0.3, 0.3, 0.3)
        _Shininess("Shininess", Float) = 1000
    }

    SubShader
    {
        Pass
        {
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag

        struct appdata
        {
            float4 vertex : POSITION;
            float3 normal : NORMAL;
            float2 texcoord : TEXCOORD0;
        };

        struct v2f
        {
            float4 pos : SV_POSITION;
            float3 normal : NORMAL;
            float2 texcoord: TEXCOORD0;
        };

        fixed4 _Diffuse;
        fixed4 _Specular;
        float4 _LightColor0;
        float4 _Ka;
        float _Shininess;

        v2f vert(appdata IN)
        {
            v2f OUT;
            OUT.pos = mul(UNITY_MATRIX_MVP, IN.vertex);
            OUT.texcoord = IN.texcoord;
            OUT.normal = mul(float4(IN.normal, 0.0), _Object2World).xyz;
            return OUT;
        }

        fixed4 frag(v2f IN) : COLOR
        {
            float3 N = normalize(IN.normal);
            float3 L = normalize(_WorldSpaceLightPos0);
            float3 V = normalize(_WorldSpaceCameraPos - IN.pos.xyz);
            float3 R = 2 * max(0.0, dot(N, L)) * N - L;

            float4 Kd = _Diffuse * max(0.0, dot(N, L));
            float4 Ks = _Specular * pow( max(0.0, dot(R, V)) , _Shininess);

            float4 Illumination = Kd + Ks + _Ka;

            return _LightColor0*Illumination;
        }

        ENDCG
        }
    }
}

Here's the issue: This shader works correct on the WebGL deployment but
looks like this in the editor scene and play views.

You can see the specular component is far off in the scene/play view in the Editor, but is right on the WebGL deployment.

If you want to give yourselves a try here are the links to

The repository
The WebGL deployment

What causes this? How can I begin to debug such an issue? Anyone experienced this before?


texts: How to make and render a simple game just with 3d max?

texts:
I want to make a simple EXE file, where there is one object in the scene and the user can rotate that object by using arrow keys (or mouse).
Is there any way in which I don't have to use a game engine and do it only using 3dsmax script?
Cause there is a special renderer I want to use, which is V-Ray a kind of renderer which provides 3D images for 3D glasses.
I am not good at making games and engines so I want to know if I can do it only with 3dsmax scripts?


texts:
I tried to find an answer to his problem but i wasn't successful. When i press play to test my game, instead of the play mode going to the Game tab and play the game there, with all the unity tabs and options still on the screen, it goes almost full screen, all of the unity window goes to the game mode and i can't see anything but the game, to see the scene, options, etc.. again i need to stop the play mode. For example, if i want to test triggers in play mode, i can't because all i see is the game window. How can i test the game just in the Game tab? Perhaps i changed some setting.

I'm not sure if im explaining my problem correctly.

Thank you


texts: Is it possible to customize the Scriptableobject inspector for Simple level data, without the use of PropertyDrawers?

texts:
I've invented an innovative, new game mechanic for Bricker Breaker Quest and want to create a quick prototype to recruit a game development team. After wasting a week researching the best way to easily represent the simple level data, I reluctantly started using Scriptableobjects. Each level is defined as a List<Block>, where :

public class Block : MonoBehaviour, IComparer<Block>
{
    public int x;
    public int y;

    public int lives = 0;
    private int pastLife = 0;

    private SpriteRenderer spriteRenderer;
    private TextMeshPro text;

    private void OnCollisionEnter2D(Collision2D collision)
    {
        lives--;

        if (lives > 0)
            UpdateVisualState();
        else
        {
            gameObject.SetActive(false);
        }
    }

    private void Awake()...

    public void AddLives(int life)...
}

How do I properly serialize the Block object so that I can enter the X, Y, and Lives integers directly in the Inspector? As a quick hack, I created a List<Vector3Int> instead of the Block List and use the Z input field to enter the lives. Seems like overkill to create a PropertyDrawer just to relabel one field.

Any other advice is appreciated.


texts: How can I make an soundsystem with Slick?

texts:
My question would be, how can I develop an easy-to-use sound system under slick-util?
Under the function

a.playAsSoundEffect(1, 1, true, x, y, z);

it already works to create a static position for the source. But if I adjust my CameraPosition in-game. So how can I change the position of the listener in Slick?

Answers would be awesome :)
Thanks,
Mineorbit!


texts: Add touch screen support to tile navigation

texts:
I saw this awesome tutorial that is related to Grid-based Movement in Godot
What I want is to add touch screen support for this kind of movement i.e. with virtual on screen joystick or gestures.
How it can be done?
What is the best way to implement that so the user will have the easiest way of movement?


texts: What is an ArchVisCharacter? What is it used for?

texts:
As the question states.

I can't really find any useful documentation surrounding this.

What is an ArchVisCharacter and what do you use them for?


texts: How can I implement A* so that it accounts for the size of the actor?

texts:
I'm trying to make a little A* implementation using polygon verticies as nodes instead of grids and I ran into the problem of figuring out what paths are wide enough to accommodate the actor moving through them.

Lets say the actor was 10x10 and the space between two verticies was only 5 units wide, the actor shouldn't be able to fit into that space but with the regular A* algorithm it would. How can I prevent this?


texts: What are the best resources on multi-threaded game or game engine design and development? As this is obviously where computers are headed, I intend to study this topic and I'd like to know what resources and examples are out there.


texts: When is it possible to discontinue the Unity 3D paid license?

texts:
Lets assume we have created and published in some stores (Steam, Epic, etc) a game made with Unity paid license.

Case 1. The game was soo dull and tedious that we sold less than a thousand copies during a sufficient period (like a year). Our revenue is not even close to the $100K revenue threshold (when at least Unity Plus is required).

Case 2. The game was quite well and reached $100K+ revenue in the past but now we allmost have no sales.

After what term may we downgrade to Personal?

Should we remove our game from stores, leave it as it is or rebuild it using the free engine version and republish?

I'm not trying to fool. The questions are more about situation when you want to quit gamedev hobby or it is too small to pay even $25 monthly for years.