texts: How to create more vertexes from within a shader in OpenGL?

texts:
when rendering voxels in octrees, the only information necessary is the current octree-level, -position and colour/texture.
But one has to send eight vertices to the rendering pipeline in order to render a complete cube and still needs colour/texture.

Is there a better way?

Since geometry-shaders wont be wide-spread for quite some time the "emit_vertex"-method in the geometry-pass wont suffice (or am i wrong? i don't think mesa currently supports geometry-shaders).
Also, afaik, backface-culling is done before the geometry-pass, so that would lead to additional overhead.

My current idea is to send 'dummy vertices' and have the actual drawing data in between but that really shouldn't be the solution.

kind regards


texts: How to display a GUI text at run time in unity?

texts: I'd like to display a GUI text at run time in my game for a second, so I want to know if it's possible to add or remove a GUI label to the scene at run time?


texts: How to minimize the repetitive creation of component in libgdx ashley?

texts:
The below example is creation of character Entity. My problem is do I always need to call these engine.createComponent(...class) to create a component? Or should I wrap these to another class that handles the creation of entities?

PooledEngine engine = new PooledEngine();

...

CharacterComponent character = engine.createComponent(CharacterComponent.class);
TextureComponent texture = engine.createComponent(TextureComponent.class);
SizeComponent size = engine.createComponent(SizeComponent.class);
TransformComponent transform = engine.createComponent(TransformComponent.class);
PhysicsComponent physics = engine.createComponent(PhysicsComponent.class);

Entity entity = engine.createEntity();
entity.flag = Constants.CHARACTER;

entity.add(character);
entity.add(texture);
entity.add(size);
entity.add(transform);
entity.add(physics);

engine.addEntity(entity);


texts:
The other day I was looking at a opensource engine, basically it was uploading the image from a file to a RAM buffer adding some decoding while streaming (I assume this is done "in-cache" so I can't count the decoding as an extra copy), then the buffer was feeded to glTexImage2D.

According to GL specifications, glTexImage2D is free to keep a in-RAM copy of the image and wait for the best moment to upload it to the GPU.

So basically we have

From disk to RAM
From RAM to RAM
From RAM to GPU

Thos are basically 4-5 BUS runs x Textures Size in megabytes  bandwith payload

3 copies of the same data.

Isn't there anyway to reduce the copies to

From disk to RAM
from RAM to GPU

Or even

From disk to GPU

?

(Assuming hard-disk already have data in the correct memory layout and hence no decoding is necessary).


texts: What is the difference between HDRP materials and normal materials

texts: I want to understand these materials I am always confused of using HDRP materials that which one is used for low texture which one is for high texture, for glass, for particles and many other.


texts: get value from UniformParameterPtr in Ogre

texts:
I have a variable of type UniformParameterPtr decalared by Ogre and I want to get its value.
What is the right way to this?
I tried the method .get() but it doesn't really give the value.
 something else?


texts: Simple Math Multiplayer game - is Ajax sufficient?

texts:
I'm planning to create a simple math multiplayer game and I plan to just use Ajax for the server/client communication but I'm not sure if this is sufficient or if I need a socket server.

The game will look like this:

2-4 users
all get a simple math task (like: "37 + 14")
they have to solve it as fast as possible
first user who solves it is the winner

I will track the time for each user, since the game started, on the client side and everytime a user gives an answer, the answer and the passed time will be send to the server. Additionally I'll add a function which will check every 3 seconds if the other users finished, how much time they needed and who won.

Do you think this is possible just using Ajax? What alternatives are there?


texts:
I am making Pong... again. Anyway, the collision detection. In the past, I had gotten it working, but it used a bunch of globals, and other nasty things. This time, I am trying it where I have a Paddle, Ball, and CollisionManager class. Basically, the the paddle and ball have move functions, which moves as they would normally, including potentially invalid places.Then, the CollisionManager's sole function would check for and resolve and collisions. I hope to keep this structure.

That works fine for ball->top/bottom collisions, and in keeping the paddles in bounds. However, the ball->paddle collision, or its inverse, I am having trouble with it. This is because there are three situations that can happen, which I have badly illustrated in Paint:

The ball can hit the paddle as normal, it can hit the top or bottom of the paddles, and finally, the paddle can move into the ball. My question is, how to handle all these cases correctly. Note that this would be, more or less, how to determine when each case happens - how they are handled is not part of my question.

I had thought of a potential solution - essentially retracing, pixel by pixel, the steps of the ball, untill it no longer collides with a paddle. Then, determine the case and do things. However, this seems a bit buggy, with corner cases and such, and additionally, failed in determining when the paddle runs into the ball.

Any ideas how to do this correctly?


texts: Can I load OGRE's mesh file via direct3d?

texts:
I just posted this question over at the the OGRE 3D forums, and I wanted to post it here as well.

I'm a newbie here, just found that OGRE is an amazing engine for 3d programming.

Using the Entity class it's easy to load a static model which was exported via some kind of 3ds max plugin.

But I did't read the source-code of OGRE Because I'm not familar with it, and I just got started with OGRE a couple days ago.

So the question is: Does anyone know if I can load a OGRE mesh via d3d?

Or has anyone been doing something using the OgreEntity.h and split it out into a separate class which can directly be used in raw direct3d?

I would appreciate if anyone could share some information about the OGRE mesh file format.


texts: 3d complex collision and trigger detection

texts:
I'm a Unity developer and I use monobehavior functions to dot things like collision detection.
I have read about articles about collision detection. Most of them work with geometrical structures like sphere or boxes.

How are complex collisions with no formal and geometrical structures calculated?


texts: Why did sprites sometimes flicker or disappear in very old games?

texts:
I've recently been having a nostalgia run with very old video games such as Battletoads. There is one thing that these very old games seem to have in common: sprite flickering. What i mean by that is that sometimes sprites (or part of sprites) will randomly disappear and re-appear again. Why does this happen?

Here's three images showcasing what I'm talking about:


texts: String table or a tree for virtual filesystem

texts:
I am developing a binary file format to store my game's assets and I am thinking about how to implement the "file table". One option to would be to create a structure for file entries like this:

    struct Entry
    {
        uint16_t nameLength; //< This basically stores the whole path e.g "dir1/file1.txt"
        char*    name;
        uint64_t dataSize;
        uint64_t dataOffset;
    };

Or i could use a method, which I think is more elegant and is based off the ISO 9660 filesystem, however I think it may have a performance impact on traversing the file tree.

    struct Entry
    {
        uint16_t entrySize; //< This is used for going to the next entry (next = current + current.entrySize)
        uint8_t  entryType; //< 0 for file, 1 for directory + may be extended later
        uint16_t nameLength; //< Now this only stores the concrete file/directory name
        char*    name;
        uint64_t dataSize;
        uint64_t dataOffset;
        Entry*   children; //< Actually an array where entrySize is used for iterating
                            // and the last entry is a "null entry" which has entrySize = 0
    };

So which one of theese will be better considering that the resource files are "read only" and cannot be modified, only created again? Or is there a solution better tailored for virtual filesystems?

Because in the first case the system only needs to traverse all the entries lloking for "dir1/file1.txt", but in the second case it will have to first search for "dir1" in the root entry, and the for "file1.txt".

I hope that I was clean enough.


texts: How to end a game when player picks up certain number of objects

texts:
I've got a small maze game where the player has to find a certain number of objects. If the player find all of them, I want the game to end. For now, I just simply want it to stop gameplay completely. I'll worry about ending it elegantly later. This is what I have, but I can't figure out what to put in the if statement. I can't seem to find a simple game state end function or anything like that. (Not really a whole lot of code to show for this. If for some reason someone needs to see more, please let me know and I can post other code, I just don't think anything else is relevant).

void APlayerCharacter::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

    if (Score == 5)
    {
        //WHAT CAN I PUT HERE TO END GAME????
    }

}


texts: Implementing modular game control with JSON/etc. config file?

texts:
I'm having trouble wrapping my head around a method to compartmentalize my game control scheme within the game loop in an efficient way. Currently this is basically how my control works in bad pseudocode / JavaScript. I think this type of scheme is pretty standard for simple games..

Init() {

    function onKeyDown( event ) {
        switch( event.code ) {
            case 'KeyA':
                moveLeft = true;
            case 'KeyD':
                moveRight = true;
            etc...
    }

    document.addEventListener( 'keydown', onKeyDown, false );

}

GameLoop() {

    CheckControls();
    MoveWorldObjects();
    Render();

}

CheckControls() {

    if ( moveLeft ) velocity.x -= 10;
    if ( moveRight ) velocity.x += 10;
    etc...

}

This method has worked fine for me so far, especially since the eventListening is abstracted, and relatively quick for what I need it to do. However, as my game gets bigger the controls are starting to look very disorganized and I'm starting to wonder if this is a good program flow for a larger game.

Another problem is the fact that there are multiple control schemes in the game, so different characters will use different keys to activate different skills. It made sense to me to try loading different schemes at run time from JSON files, but I can't wrap my head around how I would do event handling from JSON, because I can only store values/gameStates, which I am already doing. Adding a JSON layer to the controls doesn't seem like it would help me at this point.

Is there an approach to organizing game control that I should read about? Or is it a good idea to keep all of the control responses very close to the game loop and simply try to work around that limitation. Or perhaps there is a way to separate basic controls (like movement) from more advanced/less high-speed responses like pulling up a UI?

Thanks in advance for any help! -G


texts: Coordinates on the top left corner or center of the tile

texts:
I'm setting up a tile system where every tile has x and y coordinates. Right now I assume that the top left corner of the tile is positioned on it's coordinate on the screen, x = tileX * tileWidth and y = tileY x tileWidth.

However, it seems strange that the tile with coordinate (0, 0) is completely drawn in the 'positive' side of the coordinate system as opposed to in the center of the origin.

Is it common practice to assume that a coordinate lays in the center of a tile or at the top left corner of a tile? So basically x = tileX x tileWidth or x = tileX x tilewidth - ( tileWidth / 2 )?


texts:
I'm getting back into programming my game and I can see that I've used activities for so many things. I only have one with a custom-view (my actual game), the others are activities with XML-views, like menus, level-selector, Complete-screen etc.

My question is, Should I not use acitvities for this? and instead create states in my game with different touch-listeners? because I'm afraid of memory-leaks, which tends to come with the use of having activities everywhere.

I destroy all the activities properly before I move onto the next, but still, it feels sloppy somehow. Maybe the startscreen and levelselector are ok, since they are not called in real-time. But my complete-screen is called in real-time through the UI-thread, this just feels wrong.

My heap is already out of control and I dont need any leaks, I already have to limit my app to androids from 2012 and beyond.

So I'm calling out to someone with experience, since this is my first really big game, that I intend to release.

also, if anyone can tell me what these rows that I get in my logcat means, I would really appriciate it, I get that it has to do with heap and allocations, but what is good/bad to have here?

03-20 02:26:23.142: D/dalvikvm(21837): GC_FOR_ALLOC freed 941K, 8% free 14613K/15815K, paused 15ms, total 15ms

03-20 02:26:23.158: I/dalvikvm-heap(21837): Grow heap (frag case) to 17.825MB for 3686416-byte allocation

03-20 02:26:23.181: D/dalvikvm(21837): GC_CONCURRENT freed <1K, 7% free 18212K/19463K, paused 13ms+3ms, total 28ms


texts:
I'm building a 3D tic-tac-toe game and this is what I've implemented so far:

3D renderer with texture mapping
Playing against the computer
Playing online (multiplayer)

Now I'm a little lost what I could add. Obviously, tic-tac-toe isn't that exciting or advanced, but I just miss something to salt it a little bit.

Therefore, could anyone please suggest some ideas that would be worth implementing?

Thanks!


texts: How to reach IK Pass and weight by script?

texts: I need to reach IK Pass box, and control the weight by time from 1 to 0. I tried GetLayerIndex and did not give me any of those options.


texts: Calculating real time moment of inertia around arbitrary axis in 3d

texts:
I have a 3d rigid body consisting of multiple triangles forming a closed mesh. I know how to calculate the moment of inertia around an arbitrary axis by splitting up the mesh into simpler shapes and using the parallel axis theorem and summarization to calculate the angular mass for the whole thing.

The problem is that in a real time simulation I would have to re-calculate the rotation mass for every impulse applied to the body. In my 2d simulation this is not a problem as there is just one orientation to any rotation axis, so I can calculate the angular mass just once.

Is there a way to pre-calculate the rotation mass for a 3d object, or is there a simplified way of doing this?


texts: Simulating "line of sight" with obstacles on 2d grid?

texts:
Ran into an interesting problem. I need to figure out how to simulate line of sight - simple enough, just on a 2d grid with obstacles. Either a grid cell is visible, or it's not.

I can get something really rudimentary going - like spreading n spaces from player, or blocking horizontal propagation when an adjacent obstacle is detected, but I can't let myself live with it. Plenty of other apps are using more sophisticated methods that slope the line of sight around corners etc, and I want to be up to par.

So far DCSS has been my source of inspiration when I'm stumped, I'm hoping to get something close to what they have: http://crawl.s-z.org/.

Any insight would be appreciated - thanks for the help!

(Forgive if this is embarassingly noobish - only started game dev a few weeks ago, trying hard to catch up.)


texts: How to change XNA coordinates directions?

texts:
Usually XNA increases X coordinate to right and Y to down. Like this:

But in my project i have 2D map. Drawing tile with bigger Y coodinate below OX looking strange (usually people imagines these tiles above OX).

Yeah i can just use

spriteBatch.Draw(Turf.Texture, new Rectangle(Turf.X*32, Turf.Y*32*-1),Color.White);

//32 is width and height of tile, also code simplified

But it makes a code harder and uglier. Don't XNA have any setting \ variable to make spritebatch counting Y to top?


texts: Efficiently drawing large numbers of small, moving squares to screen in libgdx

texts:
I'm trying to make a game which behaves somewhat like The Powder Toy. The world is square and can be filled with particles. Particles are drawn as small squares, constrained to integer positions, and stored in a 2D array, similar to the GOL. Here's what the world looks like:

I've tried a few different approaches of drawing particles to the screen:

Using a ShapeRenderer by calling setColor and rect for each particle. Seems to have been the slowest of the approaches.
Using a SpriteBatch to draw a Pixmap for each particle.
Writing asynchronously to a Pixmap, storing the Pixmap in a Texture, then drawing the Pixmap with a SpriteBatch.

Although these approaches work, I'd be interested in hearing about other, possibly more efficient ways to render the particles. Could VBO be used here? Or is it not accessible from within gdx?


texts: How do I detect a pinch motion on Unity for an android or Iphone?  I need to also know whether the player pinches a certain character or not.  How do i do that?


texts:
I'm from the UK and I've just about completed making an indie game and had some interest from several online retailers that sell games. This requires me filling in a basic contract.

I'm just one guy who works from home as a hobby, I go by a studio name for my game solely because that's the norm.

Do I need to register my 'company' name before I can go any further?

EDIT: I'm already registered as self employed from prior work in a different field


texts: Building an XNA Game Engine: How to load sprites outside of LoadContent()?

texts: I'd like to build an engine in XNA, primarily for a 2D RPG. At first, I began abstracting out some classes and built a Sprite class which wrapped a Vector2 and a Texture2D, and tried loading in content from the Sprite class' constructor. However, this didn't work. Now, it appears that I have to load all of the sprites within the Game class' LoadContent method. Is there anyway around this? I'd like to separate the actual Game Content from the inner workings of the engine, if possible.


texts: Unity Light Baking for Best Balance between Performance and Visuals

texts:
I'm trying to optimize my Unity game.

I have static objects, dynamic objects and (only) static lights. I wish to fully pre-compute lighting and shadows for the static objects while still maintaining realtime lighting and shadows for dynamic objects, and making them work together seamlessly.

From the documentation:

Realtime: "Unity calculates and updates the lighting of Realtime Lights every frame during run time. No Realtime Lights are precomputed." So, If I set it to realtime, I'm not really optimizing anything, am I?
Mixed: "Unity can calculate some properties of Mixed Lights during run time, but only within strong limitations. Some Mixed Lights are precomputed." It's unclear what "some properties" are and what would the consequences be.
Baked: "Unity pre-calculates the illumination from Baked Lights before run time, and does not include them in any run-time lighting calculations. All Baked Lights are precomputed." This will work for static objects. However, dynamic objects will look as if there are no lights in the scene.

From what I see, Mixed would be what I need, but I would still have to adjust its sub-modes in the Lighting window which is non-trivial for me:

Subtractive: Its description suggests it would solve all my problems and still be a nice optimization. However, static objects don't seem to receive dynamic objects' shadows or the other way around either.
Baked Indirect, or Shadowmask: Does not seem to pre-compute direct lighting for static objects, throwing away performance gains.

The final question is: what method will lead me to the best performance in Unity with these requirements:

There are static and dynamic objects that both need to be lit by direct lighting
Both static and dynamic objects should be able to cast and receive shadows from each other
All lights are static
Indirect lighting is not important in this case


texts: Why do I need to offset my aim rotation angle by 90 degrees?

texts:
I have this simple code to rotate an object (gun barrel) towards a target object (rocket ship).

The gun barrel rotates towards the ship but is always 90 degrees off. I have fixed this in my code as you can see by subtracting 90 degrees from the angle but I would like to know why it is happening and if there is a more elegant solution.

I have checked the rotation of all objects involved but that doesn't seem to change anything. Any help is much appreciated!

using UnityEngine;

public class RotateTowardsObject : MonoBehaviour {

    public float speed = 5f;        // how fast this rotates towards the target
    public Transform target;        // target to follow

    public void Update()
    {
        Vector2 direction = target.position - transform.position;                                               // direction between this position and target position
        float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;                                    // calculate the angle
        angle = angle - 90f;                                                                                // ** Temporary fix(?) for rotation being +90 degrees off
        Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);                                     // create rotation from quaternion
        transform.rotation = Quaternion.Slerp(transform.rotation, rotation, speed * Time.deltaTime);            //  set rotation acceleration towards target
    }


texts: Transform 3d viewport vector to 2d vector

texts:
I am playing around with 3d transformations and came along an issue.

I have a 3d vector already within the viewport and need to transform it to a 2d vector. (let's say my screen is 10x10)

Does that just straight works like regualar transformation or is something different here?

i.e.: I have the vector a = (2, 1, 0) within the viewport and want the 2d vector.

Does that works like this and if yes how do I handle the "0" within the 3rd component?


texts: XNA: Runtime differences in ClickOnce install versus development version

texts:
I have a game written in XNA, and I use ClickOnce installers to distribute the game to testers.  I keep once computer as a test machine which does NOT have development environments installed, so that I can test the installed version.

We've found a reproducible bug in our game, but the bug ONLY occurs on the non-development machines that use the ClickOnce installer.

The bug is related to some of our code for moving around 3D objects and is not tied to Networking or GamerServices.

Are there known differences in the ClickOnce runtime and the version on dev?  Are there any best-practices for debugging something like this?


texts: Network interpolation wont work for local player

texts:
im currently developing a little duengon crawler. It should have lan multiplayer and it works great but i think im sending to much packets. Should i send packets over network, when a player moves in delta time? But thats not my question.... Sometimes it lags when more than 2 players are online. So i thought interpolation would be a great idea. But im not sure if i did that right, because it isnt much more fluently when the player moves :/ Heres what i did :

    positionFromInput.set(posX, posY);

    differenzX = positionFromInput.x-position.x;
    differenzY = positionFromInput.y-position.y;

    position.x += differenzX/10;
    position.y += differenzY/10;

I thought this would be right ... but it wont work what i did i missed ?

>>>UPDATE<<<

I think it only wont work for the local player because , if theres another player, his position is sended to the host, right after that the other player is drawn correctly with interpolation...

Heres how i move my local player :

public void update(){

            state = 0;

           if(Gdx.input.isKeyPressed(Keys.A) && moveDirections[0]){
               position.x -= Gdx.graphics.getDeltaTime() * 200f;

               state = 1;

           }
           if(Gdx.input.isKeyPressed(Keys.D) && moveDirections[1]){
               position.x += Gdx.graphics.getDeltaTime() * 200f;

               state = 2;
               //System.out.println(currentState);
           }
           if(Gdx.input.isKeyPressed(Keys.W) && moveDirections[2]){
               position.y += Gdx.graphics.getDeltaTime() * 200f;

               state = 3;
               //System.out.println(currentState);
           }
           if(Gdx.input.isKeyPressed(Keys.S) && moveDirections[3]){
               position.y -= Gdx.graphics.getDeltaTime() * 200f;

               state = 4;

           }

}

This is being called in an Launcher, which is called in the render method.

Class Launcher{

.
.
.

public void update(){

    gameScreen.player.update();

    // other stuff like updating packets
    .
    .
    .

}

.
.
.

}

And this is called in the render thread :

@Override
public void render(float delta) {

.
.
.

launcher.update();

.
.
.

}

Thats not all, i also need to draw my player :

public void draw( final float posX, final float posY,  OrthographicCamera camera){

    interpolate(posX, posY);

      camera.position.set(position.x/Box2dVars.UNIT,position.y/Box2dVars.UNIT,0);
    camera.update();

    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    batch.draw(currentFrame, position.x/Box2dVars.UNIT, position.y/Box2dVars.UNIT, playerWidth/Box2dVars.UNIT, playerHeight/Box2dVars.UNIT);
    batch.end();

}

The interpolate() is just the interpolation....

private void interpolate(float posX, float posY){

    interpolatePosition.set(posX, posY);

    differenzX = interpolatePosition.x-position.x;
    differenzY = interpolatePosition.y-position.y;

    position.x += differenzX/10;
    position.y += differenzY/10;

}

To draw the player it is also gonna called in the render thread :

@Override
public void render(float delta) {

.
.
.

launcher.update();

.
.
.

player.draw(launcher.getPlayerX(),launcher.getPlayerY());

.
.
.

}


texts: What tools should I consider if my aim is to make a game available to as many platforms as possible?

texts:
We're planning on developing a 2D, grid-based puzzle game, and although it's still very early in the planning stages, we'd like to make our decisions well from the beginning.

Our strategy will be to make the game available to as many platforms as possible, for example PCs (Windows, Mac and/or Linux), mobile phones (iPhone and/or Android based phones), game consoles (XBLA and/or PSN)
PC will have an emphasis, but I believe that's the most flexible platform so that shouldn't be a problem.

So, what programming language, game engine, frameworks and all around tools would be best suited for our goal?

P.S.: I'm betting a set of tools won't cover ALL of them, and that there will still be some kind of "translating" effort for some platforms, but we'd like to know what the most far reaching are.


texts: game-state update structure and distribution in MMO?

texts:
I'm developing an MMO, which has to maintain a global game-state.

Now I want to distribute the updates, which the players make to this state, to players which can see those updates (area of interest etc.)

Is there a common structure/format for these updates and for a global game-state?

Like, every action a player sends to the server has to include a type, the coordinates etc.

And are the updates, which gets distributed from the server to the players in the same format or are they different?

Also should I include timestamps or use the receive-time from the server to check which action came first and which sencond etc.?

And what should I send back to the player if he send an invalid action?


texts: I'm using RTS_camera as it is the player in my scene, how can I stop the camera clipping into buildings?


texts: Optimally syncing AI movement over network

texts:
I have a server with a NavMesh component that moves a bunch of NavMeshAgents in the scene and I want to sync their movement to connected clients. I'm expecting a huge amount of AI controlled characters, so I want a way that requires as few updates as possible.

Here's my initial approach: I separated linear velocity and angular velocity. When the velocity changes (I set up a threshold so that it only syncs when the change is significant), I send an update to clients so they update their velocity, then they calculate their new position based on the last synced velocity in their update function. I do the same thing for angular velocity and I update the character's rotation in the update function.

I was also planning to send a full sync of the character's position + rotation at a certain time interval to correct any major errors in movement.

It works okay for the linear velocity, but the rotation is not precise enough, so the character gets out of sync very quickly.

Do you have ideas on other approaches I could try? Or ways to improve my current approach?

We're not using Unity high level networking, we're building from the Unity Network Transport.


texts: I'm a 3rd year Computer Science student and I would like to get started with building a game engine or at least tinkering with making one. I am curious if there are any good resources to use to get started. I get the idea behind different pieces in the engine, but I'm not really sure about how they fit together. Is there anything out there to help teach me the skeleton of a  game engine? So far I've been playing with the idea of a game engine that uses modules built in a circular linked list so that each can do it's computing and then pass move to the next piece of the engine to work.


texts: How can I implement something like Destiny's public events?

texts:
Bungie has shown a gameplay trailer for their new game, Destiny. The part that really stood out for me was the 'public events' that can happen randomly while playing. Now I've thought about it for a while but I can't figure out how I might implement a feature like this.

Perhaps a dedicated event server that all game servers (or all clients) must connect to?


texts: I am trying to use blueprints to display my character's speed using a HUD, but for some reason the text is not displaying. What am I doing wrong? I am using the First Person template.


texts: How can I create a DLC for Steam using Unity?

texts:
I have uploaded a game on Steam. I know steam deals the DLC as separate depots; I have also watched and read the documentation on steam documentation page.

The problem is how will I deal the DLC in my game (the coding part)? Is depot a full game and there is download option in the game? Please guide me about it as I am new in steam game development. What would be the global architecture of both my game and the DLC?


texts:
I'm programming a simple Snake in Java. I'm a complete newbie when it comes to Java and Game Developing, so please bear with me ;)

Until now, I have been using a UI thread, as well as a update-thread.
The update thread just set the position, set the GameObjects, and so on.

I didn't think much of concurrency, but now I've come to a problem.

I wanted to modify the ArrayList<GameObject>, but it throws a java.util.ConcurrentModificationException.

With a little research I found out that this happens because the two threads are trying to access the variables at the same time.

But I didn't really find a way to prevent this.
I thought about copying the array and swapping them out when the rendering is finished, but I would have to deep-copy them, which isn't really the best solution in my opinion.
It probably eats up more CPU resources than a single-threaded game.

Are there any other ways to prevent this?

Thanks a lot for your help!


texts: How would one determine the position of a participant in a racing game?

texts:
Now, for the record, I'm currently not implementing any racing game whatsoever, but this problem just popped into my mind and now I'm curious.

So how would one go about finding out which participant of a race is currently the first one? It can't be something trivial like just sorting by distance to the finish line because that would be highly inaccurate on most courses. I've thought about doing something like separating the route into straight segments, each of which has a direction vector. The game would then check for when someone outruns somebody else by projecting their positions onto that vector and checking which one is ahead. If the position has changed, the game would increment/decrement them appropriately. But that does seem a little too complicated.

Does anybody know of any established methods or has any experience in implementing some?


texts: How to organize a game engine in C++? Is my use of inheritance a good idea?

texts:
I'm a beginner both in game developping and programming.

I'm trying to learn some principle in the building of a game engine.
I want to create a simple game, I'm at the point where I'm trying to implement the game engine.

So I thought my game engine should control this things:

- Moving the objects in the scene
- Checking the collisions
- Adjusting movements based on collisions
- Passing the polygons to the rendering engine

I designed my objects like this:

class GlObject{
private:
    idEnum ObjId;
    //other identifiers
public:
    void move_obj(); //the movements are the same for all the objects (nextpos = pos + vel)
    void rotate_obj(); //rotations are the same for every objects too
    virtual Polygon generate_mesh() = 0; // the polygons are different
}

and I have 4 different objects in my game: plane, obstacle, player, bullet and I designed them like this:

class Player : public GlObject{
private:
    std::string name;
public:
    Player();
    Bullet fire() const; //this method is unique to the class player
    void generate_mesh();
}

Now in the game engine I want to have a general object list where I can check for example for collision, move objects, and so on, but I want also that the game engine will take the user commands to control the player...

Is this a good Idea?

class GameEngine{
private:
    std::vector<GlObject*> objects; //an array containg all the object present
    Player* hPlayer; //hPlayer is to be read as human player, and is a pointer to hold the reference to an object inside the array
public:
    GameEngine();
    //other stuff
}

the GameEngine constructor will be like this:

GameEngine::GameEngine(){
    hPlayer = new Player;
    objects.push_back(hPlayer);
}

The fact that I'm using a pointer is because I need to call the fire() that is unique to the Player object.

So my question is: is it a good idea? Is my use of inheritance wrong here?


texts: Best (for performance) practices for using texture slots (glActiveTexture)

texts:
Where exactly does the cost from switching textures come from? Would it be a good strategy to just fill all available texture slots from 0 to GL_MAX_IMAGE_TEXTURE_UNITS - 1 using glActiveTexture and glBindTexture to avoid the amount of state changes?

Or is it better to minimize the amount of texture slots that are used at the same time, and rely on sorting by material to keep texture changes for each used slot as low as possible?

Also, seeing as bindless textures are available in OpenGL 4.4+, can it be assumed that they perform better in general, i.e. should I prefer changing the uniform value to point to a new texture over re-binding a texture to a certain texture slot?


texts: How do I eliminate black bar artifacts in AndEngine/TMX plugin?

texts:
I used AndEngine gles1 along with the tmx plugin to generate my background maps.  The image width is not fit to my virtual device, so I increased the tmx image size. Here is my code for the camera width and Camera Height:

CAMERA_HEIGHT = 320;
final DisplayMetrics displayMetrics = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
float aspectRatio = (float) displayMetrics.widthPixels / (float) displayMetrics.heightPixels;
CAMERA_WIDTH = Math.round(aspectRatio * CAMERA_HEIGHT);

But it shows me black bars as follows:


texts: XNA's GameTime.ElapsedGameTime.TotalSeconds isn't working as expected

texts:
As I've seen at quite a few website, the best way to handle variable frame rate and movement (moving projectiles, monsters, swinging swords)... looks something like this:

//This
position += TotalSpeed * (float)gt.ElapsedGameTime.TotalSeconds;

//Or this (direction is being normalized)
position += direction * (float)(TotalSpeed * gt.ElapsedGameTime.TotalSeconds);

And then in the Game's main constructor (Game1.cs):

        IsFixedTimeStep = false;
        TargetElapsedTime = TimeSpan.FromSeconds(16.666); //16.666 milliseconds, or about 60 FPS.

        graphics.SynchronizeWithVerticalRetrace = true;

I started to notice that whenever my FPS was at 30, my projectiles (in this case, arrows) would move slower than when at full speed. Turning V-Sync to false above unlocked the frame rate so then I'm going around 120 FPS. Projectiles are going much faster.

Unfortunately, this applies to everything else.

Am I doing something wrong, or is TotalSeconds just that unreliable/broken? I plan to switch over to Monogame eventually, but I'm not sure if that would fix the issue.

An additional note that may or may not be related: changing 'IsFixedTimeStep' to true causes my game to not run -- no errors, just a blank window-colored (beige-ish) screen.

Thanks in advance.

EDIT: projectile movement code

        direction = new Vector2((float)Math.Cos(rotation),
                                (float)Math.Sin(rotation));

        if (direction != Vector2.Zero)
            direction.Normalize();

        position += (direction * TotalSpeed) * (float)gt.ElapsedGameTime.TotalSeconds;

Pretty normal movement code. 'rotation' is just the direction the player is looking. 'TotalSpeed' is 2300f.


texts: Which method would be best? What are the pros and cons? For example, if I have a main menu screen, I can easily start my game loop right as the user presses 'Start'. Which would be better, moving the 'Start' button as well as, 'settings, leaderboard, etc' buttons out of view? or to erase them and then recreate them when needed?


texts: How can I get OnMouseEnter to trigger on a 3D Text in Unity3D?

texts:
I've just started to learn Unity3D.

I want to create a simple 3D menu with just two 3D Text instances.
I've created and named them, then dropped this script:

function Awake(){
    print("MenuItem "+gameObject.name+" init!");
}
function OnMouseEnter(){
    print("OnMouseEnter " + gameObject.name);
}
function OnMouseDown(){
    print("OnMouseDown " + gameObject.name);
}

I only see the init/awake message printed in the console.

What am I missing ?

EDIT:

Sorry, I forgot to add the BoxCollider(Physics>Box Collider) to my object, so no events were triggered.


texts: How can I put multiple actors on a Button?

texts:
I like to have an Button with a Text and some Pictures in it.

Is there something out of the box to that ?

I mean I would like to add a Table into a button, so I could add anything I need to the table.


texts:
I'm making a small game, and I've found some free sound effects that I'd like to use.

The issue is that I can't get the sound effects to sound like they "belong" in my game. I don't know what to look for that can make sound effects match the rest of my game style.

I have some ideas on what affects the meshing of audio with graphics. For example, I have a feeling that the current SFX I may be too "realistic" for my graphical style, which is pretty cartoon-like. Also, is there a golden standard for what volume various SFX should be at? (for example, I am thinking that footsteps or other common sounds should be at barely audible volumes, while enemy deaths or something that is a "big deal" should be louder).

I found a similar question about graphics, I'm looking for a similar response with sound effects.


texts:
I'm working on my first html5 game with libgdx, it's a platform android game that I made a while back that I now want to host on my website. Everything has been going okay till I got to animating the character. The desktop and android versions of the game run just fine but with the html version the game doesn't run and I get the following error:

  GwtApplication: exception: Couldn't find type for class 'com.badlogic.gdx.graphics.g2d.TextureAtlas$AtlasRegion'

When I comment out the code sections for the animation the game runs fine (with the character not animated). What's causing the error and how can I fix it?


texts: How to draw equal length line stripes on a parabola?

texts:
Simply put I'm making a basketball game. I'm using these equations to predict the ball position and it works fine:

x = vx * t
y = vy * t + 0.5 * gravity * t * t

But I can't find a way to draw equal length line stripes on the parabola. At this moment I'm using:

t = t + dt

in which dt is the time elapsed in last frame. It works but the line segments would be longer if velocity is larger. Anybody know a way to draw equal length line stripes like the flying trails in Angry Bird? Thanks very much.

I suppose I should calculate the integral on the curve but I can't get it through...


texts: How To Set Constants Using ID3DShaderReflection

texts:
I got to the point where I am tired of hardcoding shaders and decided that it was now time to look into using ID3D11ShaderReflection to get data from the shader and set my shader's constant buffer using that data.  I have a simple system that loads up shaders and gets it's data.  Now that I have the data, I would like to know how the correct way to upload the data to the constant buffer.  I've searched on Google and couldn't find too much information on this.  Any help? Thanks!

Here's some code: http://www.gamedev.net/topic/654950-setting-constants-using-id3d11shaderreflection/


texts: Good resources for 2.5D and rendering walls, floors, and sprites

texts: I'm curious as to how games like Prelude of the chambered handle graphics. If you play for a bit you will see what I mean. It made me wonder how it works. (it is open-source so you can get the source on this page) I did find a few tutorials, but I couldn't understand some of it, though it did help with some things. However, I don't like using code that I don't understand. Does anyone know of any good tutorials for this kind of 2.5D? Any help is appreciated.


texts: How to make an application architecture a global strategy game?

texts:
I am doing a global libgdx strategy, how can I properly design the architecture?
So far, I'm in some kind of chaos, because there are different events that need to be shown to the player in the form of widgets.
For example, one problem is that I need to understand how the Province class will display a message that there is a hunger problem. Should it:

immediately inside itself display a message?
send event data to the main class of the game, which processes the data and, depending on the event, display the message or take some other action?
do something else entirely?

I had the idea to make a separate class of events and so that all game objects create this object and pass it to the main class of the game, which handles them and decides what to do with it, and if necessary, pass it to the players.
And I read about the fact that there is a class java.util.EventObject. Is it worth implementing it with the help of it, or should it be implemented like that yourself? Or maybe it should be done in a completely different way?
The game is turn-based. There are separate provinces and the units move from one province to the neighboring one in 1 turn.
At the beginning of each turn, a series of windows appear in turn, notifying of certain events, for example, famine in a province or enemy troops attacked a province, etc.
There are classes of the province, the player, various UI - windows, which display information about events.


texts:
glUniformMatrix4fv(glGetUniformLocation(program, "projMatrix"), 1, false, (float*)&projMatrix);

projMatrix is a an object of type Matrix4 where the first variable declared is a float array. Does (float*)&projMatrix therefore somehow retrieve this array? What does the casting appear to be doing?


texts: How are potentially visible sets (PVS) determined in state of the art games?

texts:
As I understand it,  potentially visible sets (PVS) are used to determine 2 things;
1. which objects are inside the camera's view volume
2. which objects are not occluded (hidden) from the camera's point of view.

I understand that things like octtrees & BSP trees have been used for PVS calculation in the past, but how are PVSs calculated in today's AAA titles?


texts:
I'm working on a 2D game. It has tiles. each tile is 50x50 px. I attached script to camera which sets the camera size to screenHeight/2/PixelsPerUnit.

Now in the player, as an example i selected 480x320 size. I expected it to show approx 9x6 tiles.
However it shows 6tiles horizontally and 4 tiles vertically.

Similarly for other sizes, it shows lesser than calculated number of tiles.

How does this corelate?

Edit i created the tiles in photoshop with 300 dpi. Not sure if that affects anything though.


texts: How does this math behind converting angles to vectors work?

texts:
I calculated the vectors of my yaw and pitch successfully. Even tho it works fine, I can't seem to understand how the math works exactly.

Could someone (graphically / demonstratively) explain me this with a picture so I can better derive the math?

Vector3d CSMath::AngleToDirection(Vector3d angle) {
// Convert angle to radians
angle.x = (angle.x) * 3.14159265 / 180;
angle.y = (angle.y) * 3.14159265 / 180;

float sinYaw = sin(angle.y);
float cosYaw = cos(angle.y);

float sinPitch = sin(angle.x);
float cosPitch = cos(angle.x);

Vector3d direction;
direction.x = cosPitch * cosYaw;
direction.y = cosPitch * sinYaw;
direction.z = -sinPitch;

return direction;
}

I'd be really grateful! Thanks guys.


texts: parametric 3D sphere unwrapping math for perfect 3D-textures

texts:
After some time looking or it on the internet I can't find the proper answer to my concern.

I'm currently generating 3D textures on a shader for my planets to avoid sphere mapping issues (pole, distortion, ...).

It works great however I'm limited due to algorithm complexity so I'd like to generate my 3D textures on the CPU side. However a fully furnished 3D texture is heavy like crazy (3 dimension remember) so I'd want to store a 3D result in a 2D texture.

I need to find the correct transformation from 3D coordinates to 2D storage. Anyone have a clever thought ?

Edit : not looking for Sphere cube Map, Octohedron or similar, several texture (like in EveOnline).

I'm looking for something that you have in 3D modelers where you can unwrap a sphere on a flat surface (not regularly).

Typically the picture on the bottom:

With a function vec2 map(vec3) which can map a 3D texture and retrieve the correct value on the sphere surface.


texts:
I wanted to make a kind of "fill the box" style game where you hold down to increase size of a ball that falls when you let go, end goal being covering a percentage of the screen.

Anyway, I wanted to attempt to make the engine myself for learning purposes (fiddle).  However, using 9.8 as a global acceleration makes it feel like really low gravity.

So far, all of my movement is done via the function below.  I feel like I'm missing something obvious, but just can't figure out why it seems more like moon gravity than Earth.

dt = new Date().getTime();
dt = (dt - lastFrame) / 1000;
for (var c in circles) {
  circles[c].v.y += acceleration * dt;

  if (circles[c].x + circles[c].v.x * dt > canvs.width || circles[c].x + circles[c].v.x * dt < 0) {
    circles[c].v.x *= -1;
  }
  if (circles[c].y + circles[c].v.y * dt > canvs.height || circles[c].y + circles[c].v.y * dt < 0) {
    circles[c].v.y *= -1;
  }

  circles[c].x += circles[c].v.x * dt;
  circles[c].y += circles[c].v.y * dt;
}
lastFrame = new Date().getTime();


texts: Is RPC Safe and what is security layer of RPC?

texts:
We're creating a MMO and I wonder is RPC safe or not ? Isn't RPC easily hackable by injecting to client and what is the security layer of RPC on Unreal Engine ?

For example; a player is walking and sending that information (new position, rotation etc) to other players, can't that player change movement speed or position with injecting ? What is validating; is that movement is valid or it was a hack ?

I checked on Google but didn't get answer for my questions.

Thanks o/


texts:
so I've made a basic game in java w/ LWJGL 2 and Slick. Right now Im working on the hud and health system. I'm kindof trying to get a minecraft like health system, 15 hearts for health,but I want the health to change from level to level.
Right now Ive got this:

    int z = (int) (Math.floor(hp/15)); // this is how many hearts are being drawn
    for(int k = 0; k < z; k++){
        if(z >= 15){
            z = 15; // here it says that it can't draw more than 15 hearts
        }
        g.drawImage(heart, x + k * 32, y); // it draws the hearts with some distance inbetween each heart
    }

I'd be happy if I get some suggestions on how could I add half a heart "mechanic", like if I have 30 max health and 15 hearts (allthought rightnow I have 200 hp, I wanna work with bigger numbers :P) that would mean that If I had 15 health it should draw 7 full hearts and 1 half heart. I don't exactly know how to do that. If you can please do help :D. Thank you


texts: Is spatial partitioning for collision detection an appropriate way for objects to "know" whats around them even if they are not colliding?

texts:
I've been puzzling over how to do spatial awareness for units and buildings. I've asked a few questions and the final conclusion was spatial partitioning in the same manner used for collision detection. So an object knows if something is close to it and can react appropriately (such as attacking an enemy)

I'm making sure this is what I expect it is, so that my monetary and time investment in reading materials is not a waste for the purpose of completing this game.


texts: How to make changes to array of prefabs in editor to be visible in game window

texts:
I attached the following script to an empty game object (EnemiesGO) in the editor.

public class EnemiesScript {

[System.Serializable]
public struct EnemyWithType {
    public EnemyScript enemy;
    public EnemyScript.Type enemyType;
}

public EnemyWithType[] enemyPrefabs;
public EnemyScript[] enemies;

void Start ()
{
    enemies = new EnemyScript[enemyPrefabs.Length];

    for (int i = 0; i < enemyPrefabs.Length; i++)
    {
        enemies[i] = Instantiate<EnemyScript>(enemyPrefabs[i].enemy);
        enemies[i].enemyCategory = enemyPrefabs[i].enemyType;
    }
}

}

When I was populating enemyPrefabs (through the editor) I didn't see the prefabs in the popup selection window so I dragged them directly from the Assets window Assets/Resources/Prefabs/EnemyPrefabs. My question is two fold.

If it is possible, how can I get the populated enemyPrefabs array to be displayed in the game window/ scene window before I run the game? In general, I would like to see changes effected from the editor in the game window before I run the game.
How can I access the EnemyPrefabs folder from the popup selection window?


texts:
I want to be able to have a gameobject that's basically just a black box on top of everything else. Then I want to be able to place other gameobjects which are just gradients on top of that and they should "cut out" of the black texture like this:

How can I achieve this sort of effect?

Please keep in mind that I have pretty much no experience with shaders :)

Here's a video that might help explain what I'm trying to achieve
https://www.youtube.com/watch?v=L1dd4fkVSAM


texts:
Inspired by BrowserQuest, I want to try my hand at making my own kind of game like this but I don't really know anything about game development other than the basics, like how the game loop works. Although, I feel more than confident with server-side/client-side JS so it's mostly just about learning concepts for me.

Some questions I've had so far when thinking about how I'll go about implementing it:

I understand there'll be unsynced client-side code and synced server-side code. If a player presses an arrow key on their keyboard, should it send that information to the server, then the server says it's ok, then the client does it? Or should the client just do it anyway then the server validate it after-the-fact and correct the client if they perform an invalid action?
The data going between server and client will initially be very simple. Currently I just have x and y positions for players. But how often is it ok for clients to send this data back to the server and the server to broadcast the data to all clients? I could do these things every 1ms which would make everything as smooth as possible, but wouldn't this kill the client/server or at least use a truck-load of bandwidth? I only have a very small VPS and wouldn't want to overload it by sending 1000 JSON objects to a bunch of clients every second when I don't have to. What's the sweet-spot here?
I want to include some PvP style combat in my game but am not sure if the websocket protocol is suitable for this. With UDP, data is sent back and forth super fast partly in thanks to its unreliable nature, right? With websockets, will the communication between clients/server be fast enough to process something like a player attacking another player?

Any other advice about this sort of thing would be great, even if it's just links to existing documentation/examples. Cheers.


texts: Spritesheets From Individual Images in Content Pipeline?

texts:
My main goal is avoid using an external program like SpriteSheetPacker.

I would like to just use sequenced PNGs and have the sprite sheets be made, updated, and saved automatically when I build my game.

Edit: The old answers I upvoted, but I updated the question and specifically asked how to do this automatically with the Content Pipeline. Please do not give an answer that involves using an external program.


texts:
I've been programming games for quite a few years now, but I recently thought I would try my hand at some simple 3D modeling and animation.  I'm currently using Unity and Blender.  In Blender, I was able to make a model and animate it using bones without too many issues.  I created an extremely simple walking animation for my basic character I modeled.  However, when I import it into Unity, the left leg always does a weird rotation around its Y axis halfway through the animation.  All the other parts work just fine.  I messed with it forever trying to fix it.  Eventually, I created a whole new skeleton from scratch, and it's still doing the exact same thing.  I've exported it in every format that Blender/Unity support and the issue persists.  I've included some screenshots below to better describe my issue.

The animation starts out fine.  All I'm doing here is rotating the left leg up and back down.

We've moved up a little further. Still going good.

Right about halfway up, the leg spins quickly once around its Y axis.

It spins all the way around and stops back where it's supposed to be in about half a second.

Then it continues on normally until it reaches the top.  One the way back down, it does the exact same thing at the exact same spot, just in reverse.

My animation in Blender plays perfectly and is very simple.  It's just a rotation on a single axis over 60 frames.  The screenshots are from my most recent attempt (I've done this animation at least a dozen times now.)  So all I did was just try animating the left leg and nothing else.

This never happens with any other bones.  The right leg animates perfectly, the arms animate just fine, etc.

Any help would be greatly appreciated.  Like I said, I'm very new to all of this.  This is my first attempt at modeling and animating.  I apologize if I missed something obvious.  I've been Googling for an answer to this issue for two days now.


texts:
I've been trying to workout the code that calculates the correct row and column in the mouse is over event the following is the code I'm using to draw the grid Tile are 64x64.

Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
  Dim mDestRect As Rectangle

  Dim mX As Int32 = 0
  Dim mY As Int32 = 0

  Using mFont As New Font("Segoe UI", 7.0F, FontStyle.Bold, GraphicsUnit.Point)
   Using mBrush As New SolidBrush(Color.FromArgb(128, Color.Black))
    For row As Int32 = 0 To 9
     For column As Int32 = 0 To 9

      If (row Mod 2) = 1 Then
        mX = (column * mTileWidth) + 32
      Else
          mX = column * mTileWidth
      End If

      mY = (row * mTileHeight) - (row * 16)

      mDestRect = New Rectangle(mX, mY, mTile.Width, mTile.Height)
      e.Graphics.DrawImage(mTile, mDestRect, mSrc, GraphicsUnit.Pixel)

     Dim mREct As New Rectangle(mX + mTile.Width * 0.25F, mY + mTile.Height * 0.25F, mTile.Width * 0.5F, mTile.Height * 0.5F)
     e.Graphics.FillEllipse(mBrush, mREct)

     TextRenderer.DrawText(e.Graphics, String.Format("[{0},{1}]", column, row), mFont, mDestRect, Color.White, TextFormatFlags.NoPadding Or TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)

     Next column
    Next row
   End Using
  End Using
 End Sub

can anybody help please


texts:
I've just read about Domain models and it enlightened me since I've been developing a game that has a class which only holds data (few behaviors/methods). I assigned the job of handling these classes to the managers...and now my manager seems to look like a God object. My game object that supposed to be handling the logic is just an anemic domain model.

My current design pattern is in Singleton and I want to do some recoding to get this stuff out. I've never seen a DDD on games (as of now) but is this a good approach? I'm just a novice programmer (inclined to game dev't) so I want to learn more about good architecture before the game gets too bloated for redesigning.


texts:
So I kinda have this working but its not correct because it just averages, so I wanted to know if anyone here has any ideas.

I'm trying to simulate loose dirt compression under the tires of a vehicle to reduce the potential bumpiness of 'chunky' terrain. Currently how I do this is that I have a bounding box shape around my tires, set a little lower so they intersect with the terrain.

Each frame, I (currently) average all of the heights of each point in the terrain that are within the box bounds of that tire, and then set them all to that average. Clearly this won't work in most cases because, for example, if i'm on a hill, the terrain will deform way too much.

One way I thought was to have a max and min amount the points could raise and lower but that still doesn't seem to work properly and sometimes looks more like steps than smooth dirt.

I wanna say that there is probably a bit more to this that what i'm currently doing but I am not sure where to look. Could anyone here shed some light on this subject? Would I benefit any by maybe looking up some smoothing algorith or something similar?


texts:
This is a really cool demo of a Canvas Doom Engine made back in 2006:

http://canvex.lazyilluminati.com/84/play.xhtml

Here is the e1m1 map in JSON format:

http://canvex.lazyilluminati.com/84/map1.js

Does anyone know of the tool used to convert Doom maps into JSON? I can't imagine this was done by hand :)


texts: Game lags when my player collides with a specific object (solution known, unsure how to implement)

texts:
I'm developing a game in Android using LibGDX (although this is more of a JAVA problem than an engine problem). My aim is to have my player bounce off one spring onto another that will eventually take him over an obstacle like so:

I have a feeling the lag is because im creating new objects in a method that gets called in update(). This is because I had the same issue with coins in the game until I stopped initialising the Coinobject in a method that gets called by update() - now they work smoothly.

However, I'm not sure how to implement the spring collision without initialising Spring objects. Currently, objects are initialised through a text file - however, Spring is only initialised in a Box object rather than the text file. In my update() method I loop through the objects and if an object is a Box which contains a Spring, the following method is called:

public void playerSpringCollision(Box containsSpring) {
        // first spring (on the box)
        Spring boxSpring = containsSpring.getSpring();
        // second spring (on the platform)
        Spring platformSpring = containsSpring.getPartnerPlatform().getSpring();
        // distance in x between first & second spring
        float dx = platformSpring.getxPos()
                + platformSpring.getSprite().getWidth() - boxSpring.getxPos()
                - player.getSprite().getWidth();
        // distance in y between first & second spring
        float dy = platformSpring.getyPos() - boxSpring.getyPos();
        directionToSpring.x = dx;
        directionToSpring.y = dy;
        // if player collides with first spring
        if (player.getRectangle().overlaps(boxSpring.getRectangle())) {
            player.springImpulse(directionToSpring); // send player to platform spring
        }
        // if player collides with second spring
        if (player.getRectangle().overlaps(platformSpring.getRectangle())) {
            directionToObstacle.x = -directionToSpring.x;
            directionToObstacle.y = directionToSpring.y;
            player.springImpulse(directionToObstacle); // send player over obstacle
        }
}

I'm not sure how to do this without initialising Spring and Vector2 objects in the method - any ideas? Highly grateful for any help, thanks.


texts: Porting libgdx game to iOS using Multi-OS engine - how to add Admob ads

texts: I want to port my libgdx game to iOS using Multi-OS (RoboVM is no longer available). I've searched whole internet but can't find any info about how to use Admob with Multi-OS engine on iOS. Every resource I found is about RoboVM, but it's not available anymore since April 17 for new developers (you can only use it if you already have an account, but it's not possible to create a new one). Libgdx with Multi-OS is available in another branch on Github, but there is no info about ads and I want to publish my game this week. Can anyone help me?


texts: Continuous Integration, what are the strategies to manage binary content?

texts:
Currently we are testing various configurations between Feature Branching and CI with Feature toggling.

I can see there are several viable options out there for the code, but I also know that CI totally relies on the possibility to merge the code.

So I wonder, how do you manage CI with binary data, like art assets?

I can also see another problem: all the code can be tested before to commit, I can even validate the data before to commit, but how can I test the art?!

Should I use another methodology for art content?


texts: Why table in libgdx game give wrong position

texts:
Can anybody guide me, I am creating a table in libgdx game on menu screen to set different buttons on my screen. here is the code for table draw

 table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

and here is the code for background for this menu screen

batch.draw(bckTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

My bcktexture image size is 600 by 400.

Now this table draws in the middle of the screen. I dont understand this why. it should be drawn by 0 , 0 corner and fill the whole screen.
I have checked table by table.debug();

what I want is that the table should cover the whole screen so that I can adjust my buttons anywhere on the screen i want especially at the corners.


texts: How does level design work in 2D Java games with multiple levels?

texts: I'm building a small platformer game with multiple levels, similar to old-school Mario, and I was wondering how devs created levels. This is my first game, so I'm pretty new to design & such. I've seen people use Paint.NET or Photoshop to create a level where certain colors in the world represent various tiles & such, that are rendered throughout the level. For instance, a red block in the world on a blue background would represent a tile that a player can jump on, and would be rendered so when the game is started. Is this an effective way of designing levels, or is there a better way? Please explain your process.


texts:
I stumbled across this really neat algorithm which I don't fully understand. It simulates a camera's bobbing effect commonly witnessed in first person shooters while running/walking. I'm mainly unsure about the timer and translation by totalAxes calculations.

Would someone with some more math skills than myself care to explain it on a comment by comment basis? If so, that's much appreciated.

    Vector3 localPosition = transform.localPosition;

    if (Mathf.Abs(horizontal) == 0 && Mathf.Abs(vertical) == 0)
    {
        timer = 0.0f;
    }
    else
    {
        waveSlice = Mathf.Sin(timer);
        timer = timer + bobSpeed;
        if (timer > Mathf.PI * 2)
        {
            timer = timer - (Mathf.PI * 2);
        }
    }
    if (waveSlice != 0)
    {
        float translateChange = waveSlice * bobDistance;
        float totalAxes = Mathf.Abs(horizontal) + Mathf.Abs(vertical);
        totalAxes = Mathf.Clamp (totalAxes, 0.0f, 1.0f);
        translateChange = totalAxes * translateChange;
        localPosition.y = midPoint + translateChange;
    }
    else
    {
        localPosition.y = midPoint;
    }


texts:
I am trying to draw a textured ractangle like in this example. But instead of a texture the rectangle is just black.

Draw method:

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

    effect.EnableDefaultLighting();
    effect.World = world;
    effect.Projection = camera.Projection;
    effect.View = camera.View;
    effect.TextureEnabled = true;
    effect.Texture = grass;
    effect.LightingEnabled = true;

    foreach (var pass in effect.CurrentTechnique.Passes)
    {
        pass.Apply();

        GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, quad[0].Vertices, 0, 4, AlignedQuad.Indexes, 0, 2);
    }

    base.Draw(gameTime);
}

The effect is like a in the example a BasicEffect. The texture is existing and is  not a black rectangle.

What am I missing or doing wrong? Thank you for your help.


texts:
So I have a few AIs walking between waypoints. What I want to accomplish here is to have my AI move to the waypoint, when he reaches it, he must stop, wait for a few seconds (Not walk just stand still), then move to the new waypoint. Lets pretend he was observing while at this point.

Issue right now - He moves to the waypoint with a twitchy behavior where he would usually avoid objects, sometimes gets stuck while moving to objects or its like the AI cant decide what to do, move or stand still. Without the Waitforseconds method the AI avoids objects perfectly.

Please note I want to use Coroutines for this even if you wouldn't use / recommend it for this. If you have a suggestion for using Unity's Random to decide when he stands still after reaching a point or not, that would be a bonus for me.

We define all fields and call the FSM() Coroutine with a default patrol state in the Start Method, from Here, This is my Code:

Update - Implemented A Boolean IsMoving variable - This works to some extent. The AI now moves perfectly to the waypoint. The Twitching however continues once the AI reaches the waypoint vicinity until he leaves the waypoint radius - The movement then continues to a normal state.

IEnumerator FSM()
{
        while (alive)
        {
            switch (state)
            {
            case State.PATROL:
                StartCoroutine(Patrol());
                break;
            case State.CHASE:
                Chase ();
                break;
            default:
                break;
            }
            yield return null;
        }
    }

    /// <summary>
    /// Patrol will move to a waypoint if too far, otherwise move to a next waypoint if one is reached.
    /// </summary>
    IEnumerator Patrol()
    {

            //Sets a common speed for the agent to move in.
            agent.speed = patrolSpeed;

            //Now we want to check the position the character is at vs the waypoint location - If i am too far, move closer
            //                        My Position           Waypoint Indexes - We Set Multiple
            if (Vector3.Distance (this.transform.position, waypoints [wayPointIndex].transform.position) >= 2)
            {
                //Telling the navmesh agent where to go.
                agent.SetDestination (waypoints [wayPointIndex].transform.position);

                //                                  false, false - Specifies if we are jumping or crouching
                character.Move (agent.desiredVelocity, false, false);

            }
            //Now we want to check the position the character is at vs the waypoint location - If i am at a waypoint, move to a new index
            else if (Vector3.Distance (this.transform.position, waypoints [wayPointIndex].transform.position) <= 2)
            {
                character.Move (Vector3.zero, false, false);
                yield return new WaitForSecondsRealtime (6.0f);

                wayPointIndex += 1; //Move towards a new waypoint in the waypoint indexes flags

                //Move to a random waypoint
                wayPointIndex = UnityEngine.Random.Range (0, waypoints.Length);

            }
            else
            {
                //Doesn't move, plays the idle movement - We know this point wont be reached but if so...
                character.Move (Vector3.zero, false, false);
                yield return null;
            }
        }


texts: Do matrix manipulations for 3D graphics ever produce singular matrices?

texts:
A singular matrix is a matrix that cannot be inverted.  The vecmath library, for example, throws a SingularMatrixException if you try to invert a singular matrix.

I think I understand what singular matrices are.  But there are plenty of matrix operations that I don't understand, so I'm not sure what might produce one.  Are singular matrices ever produced accidentally when manipulating 3D graphics transforms, the way gimbal lock can be?  If so, are there any strategies for avoiding singular matrices, and/or what can you do about them if you encounter one?


texts: How do I find which isometric tiles are inside the cameras current view?

texts:
I'm putting together an isometric engine and need to cull the tiles that aren't in the camera's current view. My tile coordinates go from left to right on the X and top to bottom on the Y with (0,0) being the top left corner.

If I have access to say the top left, top right, bottom left and bottom right corner coordinates, is there a formula or something I could use to determine which tiles fall in range?

This is a screenshot of the layout of the tiles for reference.

If there isn't one, or there's a better way to determine which tiles are on screen and which to cull, I'm all ears and am grateful for any ideas. I've got a few other methods I may be able to try such as checking the position of the tile against a rectangle. I pretty much just need something quick. Thanks for giving this a read =)


texts:
I need some advice from a Qt expert.

The background:
I have a 3D engine (ogre3d) working in concert with Qt. The 3D Content is displayed in a widget (using a custom OS window in the client area). I'm able to overlay arbitrary Qt widgets onto the 3d world using the widget render() method and a shared bitmap. This makes a great "heads up display". I can use the standard Qt style sheets and animation using this technique.

My goal
I'd like to go a step further and allow the user to move these rendered widgets using the mouse. I'd like some advice on the best way to implement this.

Possible solutions:

The widgets in the HUD are not part of the inheritance chain. I render them manually. They don't get events though. I could add them to the inheritance chain so they get events in the usual way. Then I would need to change them to render to my shared bitmap instead of to the operating system. I looked at this once but couldn't find enough information to implement it.
Capture mouse events in the 3D display widget and EMIT them to child controls. I basically create my own event handling chain.

Any suggestions on how to implement this?

I'm also considering switching to Qt5. I'm not sure how that might affect this decision.


texts: Using Unitys URP how to make sprites lit by 3D Lights again?

texts:
I'm working on 3D game and I converted my project to URP. Everything works fine expect sprites that previously were 'Sprite/Diffuse' so they were lit by 3D lights (kind of Doom style, 2D elements in 3D world, always facing you). But now 'Sprite/Diffuse' shader is not supported in URP, it converted my materials to use 'Universal Render Pipeline/Simple Lit' Shader which does not work with sprites, it's for textures. There is 'Universal Render Pipeline/2D/Sprite-Lit-Default' but it's only for using 2D Lights.
How do I make sprites littable by 3D lights again in URP?


texts: Help figuring out how to build for the iOS Unit3D

texts:
So currently I'm exporting my game strictly for testing to the iOS (iPad.)

I don't own a Mac, so I'm having my client make a build from his Mac, but that means I need very specific instructions for him as he isn't very tech-savvy. I've looked online and can't find much at all about what all you need to export from Unity and make a file for the iOS, then sync it to your iPad. Could anyone provide a video or and help at all for this?

Thanks,

Tim.


texts:
I need the ability to order the drawing of sprites and fonts. Some sprites need to be drawn behind and some in front of text. My problem is that my sprites and fonts use separate Begin() End() calls so I can't simply order the draw calls.

How is sorting generally done in DX9?


texts:
I am using Andengine and when I start the examples there are black borders on left and right of the screen. Like this:

10000001
10000001
10000001

where 1 is black and 0 is not black. On my phone (Google Nexus 4) it is always. In emulator sometimes. it is in all examples from here: https://github.com/nicolasgramlich/AndEngineExamples

What is causing this?


texts:
I have been developing a game for over a year now and I have successfully implemented the basic foundation for lighting, but there are still a few things I'm struggling with. The biggest issue right now is the lighting that should be cast from the "sun". The sun should technically light up any block that doesn't have a lot of blocks above it covering up the light that should be reaching it.

The way the current light system works is through a flood-fill algorithm that goes block to block recursively setting light based on different conditions. The light is recalculated when a light source is placed or a block is broken and the algorithm is very efficient. Currently I have a basic implementation of sun where the highest block has light generated straight down from it until the light "runs out". This works when first generated, but doesn't look natural. One case where there's problems is if there is a single block 10 blocks above the terrain which would cause the terrain to be unlit under that block because it didn't receive any sun.

I have been doing research and trying out different techniques, but nothing has worked well and efficiently. Any suggestions are appreciated.

Here is an image of the game in it's current state. You can see the lighting issue with the tree blocking the light of the ground.


texts: How closely can a game legally resemble another?

texts:
Most games build on other games' successes and many are downright clones. Where is the limit of imitation before legal issues come into play? Is it down to literary or graphic work like characters and storyline that cause legal problems, or can someone actually claim to own gameplay mechanics?

There are so many similar clone games out there that the rules are probably very slack or nonexistent, but I'd like to hear the views of more experienced developers / designers.


texts: Angled topdown perspective camera for 2.5d game

texts:
I have a 2d tile based game created using Unity's 2d tools and orthographic camera:

The tiles are created by programmatically generating a mesh, assigning a texture to each pair of triangles, and setting the normals to -Vector3.forward.

I'd now like to switch to a perspective camera, to add a 3d feel to the tiles, while still using sprites (and following the player):

How do I go about setting up this kind of camera, and will it still be possible to retain the player's x/y co-ordinates which are heavily used in my game logic.

Thanks in advance!

Update: I've realised that in terms of my original grid and sprites, I simply need to swap their vectors Y and Z co-ordinates so that the tiles and sprites are nicely positioned in the scene, however I'm still unsure about how to nicely position the camera and center it on the player.


texts: Solving 2D Collision Detection Issues with Relative Velocities

texts:
Imagine you have a situation where two objects are moving parallel to one-another and are both within range to collide with a static wall, like this:

  => 20m/s     => 40m/s
+==========+ +==========+          +======+
| Object A | | Object B |          | Wall |
+==========+ +==========+          +======+

 |-- 1m --|   |-- 1m --|  |- 1m -|

A common method used in dynamic collision detection is to loop through all objects in arbitrary order, solve for pair-wise collision detection using relative velocities, and then move the object to the nearest collision, if any.

However, in this case, if object A is checked first against B, it would see that the relative velocity to object B is -20 m/s (and would thereby not collide this time frame). Then it would see that the object A would collide with the static wall, and the solution would be:

+==========++==========++======+
| Object B || Object A || Wall |
+==========++==========++======+

And the red object passes through the blue one. So it appears to be a matter of choosing the right order in which you check collisions; but how can you determine which order is correct? How can this passing through of objects be avoided? Is ignoring relative velocity and considering every object as static during pair-wise checks a better idea for this reason?


texts:
I want to generate a town layout in a square grid (rendered isometrically, but that doesn't matter) using the following elements:

2x2 Houses
Roads, 1 unit wide
Canals, 1 unit wide

Sample layout:

I always have a specific number of houses, and as many roads and canals as necessary to connect them all.
The houses need to have two pieces of road in front of their front door (which is always pointing to the right)
It would be nice to have fields of grass (emptiness) inbetween.

Is there a ready-made algorithm for this? If not, what direction should I be thinking of to implement this?


texts:
I was bored and dragging my game window around the screen and noticed something interesting.

When I drag my game window over to my secondary monitor, the screen updating just completely freezes.

Is there something I need to do to enable updating on a screen other than the primary monitor?


texts:
Just made it with some more investigation thanks to this site: Hexagonal grid math, but the hexagons have a little bit spacing horizontally.

Here is the code:

include('class/hexagon.php');

$hexagon = new hexagon(16);

$png_image = imagecreate(500, 500);
imagecolorallocate($png_image, 255, 255, 255);
$black = imagecolorallocate($png_image, 0, 0, 0);

for($i=1;$i<12;$i++) {
    for($j=1;$j<10;$j++) {
        $x = $i * $hexagon->ver;
        $y = $j * $hexagon->height + ( ($i%2) * ( $hexagon->height / 2 ) );
        $points = $hexagon->drawHex($x,$y);
        $last_line = array($points[0][0],$points[0][1]);
        imagettftext ($png_image , 5 , 0 , $x , $y , $black , "C:/Windows/Fonts/Arial.ttf" , "{$i},{$j}" );
        foreach($points as $c):
            imageline($png_image, $last_line[0], $last_line[1], $c[0], $c[1], $black);
            $last_line = $c;
        endforeach;
    }
}
header('Content-type: image/png');
imagepng($png_image);
imagedestroy($png_image);

class hexagon {
    public $size;
    public $width;
    public $height;
    public $hor;
    public $ver;
    public $angle;
    public $rad_angle;
    public $side;
    public function __construct($xsize = 32) {
        $this->angle = 60;
        $this->rad_angle = $this->angle * (pi() / 180);
        $this->side = $this->size * cos($this->rad_angle);
        $this->size = $xsize;
        $this->width = $this->size * 2;
        $this->height = $this->width * sin($this->angle * (pi()/180));
        $this->hor = $this->width * ( 3/4 );
        $this->ver = $this->height;
    }

    public function drawHex($x, $y) {
        $points = array();
        for($i=0;$i<7;$i++) {
            $angle_deg = $this->angle * $i;
            $angle_rad = pi() / 180 * $angle_deg;
            $points[$i] = array($x + $this->size * cos($angle_rad),$y + $this->size * sin($angle_rad));
        }
        return $points;
    }
}

Result:

Any advice?


texts: After the use uninstall/reinstalls my app, all of his serialized data is gone. Is there a way to store a file on a mobile device permanently - which persists through various installs? Without using a server/cloud service or requiring the user to log into Google Play Games?


texts:
I have a problem with my XNA Game, I have a function where I need my sprite to face towards an enemy, using this code:

        Vector2 currentPosition = Position;
        Vector2 nearestEnemy = gameObjectManager.GetNearestEnemy(Position, GameObjectTypes.Zombie);

        Orientation = (float)Math.Atan2(nearestEnemy.Y - currentPosition.Y, nearestEnemy.X - currentPosition.X)

As found on an XNA forum results in my character looking 90 degrees away from the enemy.

Adding "MathHelper.ToRadians(90);" to the end of my Orientation assignment fixes this bug, why is this happening?

Thanks!


texts: How can I remap Unreal's Editor default movement (WASD) keys for a non-QWERTY keyboard

texts:
I am using a French (AZERTY) keyboard, and as such my "usual" game movment keys are ZQSD instead of WASD. I have been trying to change Unreal Editor's default keys to those I am accustomed to but I can't figure out how to do it.

Using UE 4.19.1

Here are the settings I've tried so far:


texts: What are good algorithms to generate borders / state areas on 2d star maps?

texts:
I'm trying to generate a fairly large two-dimensional star map that shows different factions / states, each owning one or more star systems. I'd like to automatically create borders / areas for the factions.

The idea is to essentially go from something like this (the dots represent star systems on a 2d plane, colors are faction affiliations)

to this

Generating maps like this seems like a fairly common requirement, so my actual question is this: Are there standard algorithms for generating state areas as shown? If so, could you point them out to me? If not, can you think of a good algorithm (basic idea or pseudo code are fine)?

The algorithm's performance is not a primary concern to me, so I'd rather have a "prettier" map than a faster-to-generate one. This similar question offers an approach that is probably applicable to my problem, albeit with some "prettification" needed:
How to create a map from graph

Let me explain what I mean when I say prettier: At the bottom of the linked question, the asker presents her end result after implementing the accepted answer. My first issue here: The areas for nodes #6, #9 and #12 are very small and oddly shaped. Also, instead of the sharp edges, I would prefer a smoother, curved look.

My own ideas so far, including the respective drawbacks / questions I see with them:

Generate a "convex hull" polygon for each faction, then expand outwards a bit. Problems: No concave features. Also, how do you deal with overlaps?
Generate a voronoi graph for the dots, then use the voronoi polygon edges between neighboring systems of different factions as borders. Problem: Large polygons at the map edges - how do I identify and fix those?
Generate a fixed-size polygon for each dot, union all polygons for a single faction (resulting in one large, potentially complex "faction polygon"). Then do something to reconcile overlapping areas between two factions. Problems: How would I do this exactly? Not exactly a trivial process. What if there is overlap between more than two factions?

Your help is appreciated.

Addendum: After thinking about the first two answers and their respective approaches to solving the problem, I've realized that my requirements above are incomplete.

I have to add that the map can have sparsely populated areas, meaning that there may be an isolated star or cluster of stars. I'd like to display each of those clusters with their own contiguous colored area. Something like this:

I realize that this might necessitate a first step which identifies clusters, and then running the actual algorithm for each of the clusters.


texts: Avoiding memory allocation in Android game development

texts:
For obvious reasons, allocating memory on the fly in Android game development is not recommended.  For example:

http://developer.android.com/training/articles/perf-tips.html:

  There are two basic rules for writing efficient code:

  Don't do work that you don't need to do.
  Don't allocate memory if you can avoid it.

I'm following this advice and am avoiding any memory allocation whilst the game is in progress; however, it's limiting my approach to certain tasks.  Whilst I could change my code to see what happens, there's a fair amount of it, and it's not going to tell me about the resulting performance on anything other than the limited range of hardware I have available to test it on.

I was wondering if there are any general rules of thumb which can provide an insight into this problem, such as how much allocation/deallocation you can get away with; whether it's the individual size of the allocation or the overall amount that's most important; things you can do to mitigate against the problem (I'm assuming the problem is chiefly having the garbage collector kick in and damage performance, and/or insufficient memory being available if it doesn't fire frequently enough); does it affect some versions of Android more than others, etc.


texts: Enable debug to show values in the flowchart editor

texts:
I am starting to learn to use CryEngine V, and have found documentation lacking, in some aspects.

Following the initial game logic tutorials, I observe the instructor selecting "debug" from the menu. The flow chart instantly comes to life, displaying all of the values going in and out of each function.

Unfortunately, when I follow this instruction, nothing happens. Clicking on the "debug" button results in no apparent action. I have looked around for further instructions, but all I can find is the general assumption that it will just work, without any additional action. As you can see from my recording, this assumption is not accurate to my situation.

Without this working, it is rather difficult to even know if I am following the flowchart creation process properly. How do I enable visual debug in the flowchart editor?


texts: How do I create a Physx heightfield from a model triangle mesh?

texts:
My question is clear: I have a mesh defined by its vertices, index... I want to transform it to a heightfield, if someone can provide some example or link to, I will really appreciate.
Thank you very much


texts: Developing a 2D Android game on Unity - Pros and Cons

texts:
Depending on your experiences, if you have created a 2D game on Android using Unity, was it painful? Have you ever said "I wish I have used X instead of Unity!"?

Tell me the Pros, Cons and the name of "X" please.

Edit: Consider it for a commercial shoot em up game. The programming language can be anything.


texts:
I am working on a 2D platformer and I decided to update unity to the lastest version. Everything went well but once I got the project updated I got 2 error that I am not sure how to fix. Some help would be greatly appreciated!!!

Here is what the console is saying

Assets/Scripts/GameMaster.cs(148,112): error CS0039: Cannot convert type UnityEngine.Transform' to UnityEngine.GameObject' via a built-in conversion

Assets/Scripts/GameMaster.cs(111,96): error CS0039: Cannot convert type UnityEngine.Transform' to UnityEngine.GameObject' via a built-in conversion

Here are the lines that it is pointing to

GameObject clone = Instantiate (spawnPrefab, spawnPoint.position, spawnPoint.rotation) as GameObject;

GameObject _clone = Instantiate(_enemy.deathParticles, _enemy.transform.position, Quaternion.identity) as GameObject;

Thanks!!!!


texts: How can I change a sprite used for a Unity Tilemap tile at runtime?

texts:
I want to change Tile's sprite during runtime, but it doesn't render.

class SwitchableTile : Tile
{
  // usable sprites
  public Sprite[] sprites;
  // index to the sprite
  private int spriteIndex = 0;

  // I don't know when it's called
  // but set sprite to current spriteIndex
  public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData)
  {
      // ..
      if (sprites != null && sprites.Length > 0)
      {
        tileData.sprite = sprites[spriteIndex];
      }
   }
  // called per Tilemap.RefreshTile
  public override void RefreshTile(Vector3Int position, ITilemap tilemap)
  {
    tilemap.RefreshTile(position);
  }
}

Also tried to refresh the tile according to the position:

// in MonoBehaviour
BoundsInt bounds = tilemap.cellBounds;
bool updated = false;

foreach (Vector3Int pos in bounds.allPositionsWithin)
{
  TileBase tile = tilemap.GetTile(pos);
  if (tile && tile is SwitchableTile)
  {
    if (!updated)
    {
      // just loop index
      Sprite sprite = ((SwitchableTile)tile).GetNextSprite();
      // set sprite
      ((SwitchableTile)tile).sprite = sprite;

      updated = true;
    }
    // refresh
    tilemap.RefreshTile(pos);
  }
}

Since Tilemap.RefreshTile calls TileBase.RefreshTile per refresh, the problem's solved after I implemented TileBase.RefreshTile.

I'm not using 2d-extra's animation tile because I want to change sprites only under certain condition. Also not using Tilemap.SwapTile because in this case I'm solving it using customized Tile, instead of creating a new Tile.

Update: Well...It proves that I need to implement RefreshTile for a Tile. Now the sprite refreshes. But I'm still not sure about GetTileData, do I need to implement it? When it is called?


texts: How to "undraw" a SetPosition on LineRenderer?

texts:
I'm animating the SetPosition on a line renderer to show a laser site quickly "spin up" so the user sees the laser head outward. I'd like to do the reverse and when a user switches off the laser sight and it also quickly retracts.
I have the spin up working good, but I can't figure out how to "undraw" the line when a user toggles the sight off. Once its "undrawn" a user can just spin it up again when they turn it back on.
Here is the code (ignore the weapons checks)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WeaponAimAlignment : MonoBehaviour
{
    // weapon assignments
    [SerializeField] private Transform rocketBarrel;

    // laser sight assignments
    [SerializeField] private float aimOnSpeed;
    [SerializeField] private Transform aimLaser;
    [SerializeField] private LineRenderer lineRend;
    private bool aimOn = false;

    private float counter;
    private float dist;

    void start()
    {
        lineRend.enabled = false;
    }

    void FixedUpdate()
    {

        if (Input.GetKeyDown(KeyCode.B) && aimOn == false)
        {
            aimOn = true;
            lineRend.enabled = true;
            lineRend.SetPosition(0, aimLaser.transform.position);
        }
        else if (Input.GetKeyDown(KeyCode.B) && aimOn == true)
        {
            lineRend.enabled = false;
            aimOn = false;
        }

        Ray rayOrigin = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitInfo;

        if (Physics.Raycast(rayOrigin, out hitInfo))
        {
            if (hitInfo.collider != null)
            {
                Vector3 direction = hitInfo.point - rocketBarrel.position;
                //machineGunBarrel.rotation = Quaternion.LookRotation(direction);
                //grenadeBarrel.rotation = Quaternion.LookRotation(direction);
                rocketBarrel.rotation = Quaternion.LookRotation(direction);

                if (aimOn == true)
                {
                    dist = Vector3.Distance(aimLaser.transform.position, hitInfo.point);

                    if (counter < dist)
                    {
                        counter += .1f / aimOnSpeed;

                        float x = Mathf.Lerp(0, dist, counter);

                        Vector3 pointA = aimLaser.transform.position;
                        Vector3 pointB = hitInfo.point;

                        Vector3 pointAlongLine = x * Vector3.Normalize(pointB - pointA) + pointA;

                        lineRend.SetPosition(1, pointAlongLine);
                    }
                }
            }
        }
    }
}
```


texts: Solving the riddle on distributing a python built game?

texts:
So, I've done the research, and i've done the try/catch process of almost getting things to work. . . almost.

I've read this chart: https://spreadsheets.google.com/pub?key=tZ42hjaRunvkObFq0bKxVdg&output=html
and i've read this post: How can I distribute a native executable for a Python program?

I'm at that point where I'm looking for either just using an installer that can run a python installer, then run the installers for all the dependencies (modules) or just copy paste the modules into the proper python directories.

So my question is: Do you have any experience with this? If so, what are your success/fail stories? Would you want to build everything into an Exe with something like pyinstaller, or just use a custom installer that would require more time to learn (like: http://www.actualinstaller.com/)?


texts:
private bool hitted = false;
private Vector3 hitPosition;

private void Test()
    {
        RaycastHit hit;

        if (Physics.Raycast(start.position, Vector3.left, out hit, 1.5f)
             || Physics.Raycast(start.position, Vector3.right, out hit, 1.5f)
             || Physics.Raycast(start.position, Vector3.forward, out hit, 1.5f))
        {
            if (hit.transform.tag == "Test")
            {
                hitted = true;
                hitPosition = hit.transform.localPosition;
            }
        }
    }

    private void Update()
    {
        if (hitted == true)
        {
            player.localRotation = Quaternion.Lerp(player.localRotation, Quaternion.LookRotation(hitPosition), 1 * Time.deltaTime);
        }
    }

What i want to detect is when the player finished rotating and then set back hitted to false.


texts: Timebased transition from start to end value

texts:
I'm trying to implement time line objects, the purpose of those would be to issue events at specific times. When and what is specified through objects called units, which is what you attach in the time line.

Got two types of time units, Action and Transit. Action counts to the end of the time unit, then issue whatever event with provided values intact.

My problem is Transit, which, frame by frame, modifies provided value(s) by multiplying time ratio before issuing the event.

I calculate ratio as: (in pseudo code)

ratio = (counter += delta time) / unit end time

My issue is that I keep getting either different results, or unbalanced progress, like adding 90% of the value quick then the last 10% of value at a much slower phase.

I've tried something like (in pseudo code) so far:

delta value = (end value - earlier delta values) * ratio

for each new frame.

Not sure how to put this together, so could really use a few pointers on this. Hope I made myself clear.

PS. I'm doing this in JavaScript, I know JS isn't the most accurate language when it comes to precision numbers, but it should be able to handle something like this.

Thank you in advance.