texts: How to tie a bullet release with a firing animation

texts:
Lets say you have an animation that you want to happen when firing a bullet.  How would you get the bullet to show up at the end of the animation.  The only thing I can figure out is to know the time length of the animation, and delay setting the bullets position and setting it active until that amount of time has passed.  I was just wondering if this is the best approach, how does everyone else handle this?

EDIT:  I think i'm having trouble wording the question properly.


texts: How to avoid a boring late game in strategy games while still keeping victories satisfying?

texts:
A common thing I've noticed in strategy games (of all types, 4X, RTS, MOBA, etc.) is that most games eventually get to a point where it is fairly clear who is going to win, and the rest of the game just becomes playing out the motions, and if the winning player/team doesn't make a major misstep, they will win.

This is just kind of the nature of strategy games. They inherently have a "snowball" effect. The gameplay is all about setting yourself up for success over your opponents in the future, and whoever does this better in the earlier stages of the game should win in the later stages. This happens in every strategy game to some extent, even the most classic. In Chess, it becomes increasingly harder to win if your opponent takes more and more of your pieces and forces your remaining pieces into tough situations.

As I said, this is just a fundamental part of the genre, so I'd hesitate to call it a problem. However, on occasion, in these types of games, you have matches where no player/team gains a significant advantage early, and the game comes down to the last turn. In my opinion, these are the most exciting and interesting matches you can have. Furthermore, when this doesn't happen, the late stages of the game can feel very boring for everyone involved, where the winning player is just awaiting their inevitable victory, and the losing player their inevitable demise (this can be especially unfun for the losing player, as they probably have very few options, and it is just really unlikely that they are having a good time).

So it would be cool if we could design a strategy game that avoids consistently falling into this state, right? Well, I have seen a handful of games like this, where a losing player consistently has avenues to victory, no matter how far behind they are. The issue with this is that if an upset happens (say one player was dominating the whole game, and then a losing player makes one good play at the end of the game to win), that victory can feel very unsatisfying for the winning player, as they may feel they didn't deserve it. Similar, the player who was winning most of the game may be very unhappy, as they may feel like victory was robbed from them, and they didn't deserve to lose. So essentially, no one is happy with the result. This approach may also make the early game less fun, as players may feel like it just doesn't matter.

So is it possible to design a strategy game that avoids both of these issues? A game where we don't consistently fall into a boring lategame with a forgone conclusion, and yet also keep victories feeling satisfying and deserved? Or are these issues far too fundamental to strategy gameplay to overcome?

If this question is too vague on its own, then we can focus on 4X strategy games, as those are the games I have experience with, and that I am interested in designing.


texts: How to place a sprite in the center of the world in Phaser

texts:
I am very new to Phaser. Here is what I did:

  <!DOCTYPE html>
  <html>
    <body>
    <script src="phaser.js"></script>
    <script>
        var game = new Phaser.Game(500, 500, Phaser.AUTO, '', {
            preload : preload,
            create : create,
            update : update
        });

        function preload() {
            game.load.image('dog', 'assets/dog.png');
        }

        function create() {
            game.stage.backgroundColor = "#1BDCFF";
            game.physics.startSystem(Phaser.Physics.ARCADE);
            game.physics.startSystem(Phaser.Physics.ARCADE);
            dog = game.add.sprite(game.world.centerX, game.world.centerY, 'dog');
            game.physics.arcade.enable(dog);
        }

        function update() {

        }

    </script>
</body>

Shouldn't the dog appear in the center of the "world"?
Here is how it looks like :

I then tried something like this :

var dogImage = game.cache.getImage('dog');
dog = game.add.sprite(game.world.centerX-dogImage.width/2, game.world.centerY-  dogImage.height/2, 'dog');

And now that I edited in this way the create function it does place the dog in the center. Is this the way of doing it or there's a more elegant way ?


texts: HTML5 mobile game development vs. native game apps

texts:
What is the current state of game engines, frameworks, libraries and conversions related to the HTML5 set of technologies (including CSS3 and JavaScript libraries such as RaphaelJS, Impact, gameQuery); and how does the best of that compare with developing a native app (especially for iOS and Android)?

Especially in terms of performance, visuals and getting that "native feel".

Thoughts on solutions such as Appcelerator and Corona SDK are also appreciated.
In regards to Unity3D, is it possible to develop in it and still have the game be playable on a browser (such as current releases of Chrome or Firefox, at least) without any dependencies or having the user install anything (no unity web player).

What I'm looking for is how to develop in web standards as to reach the maximum number of platforms (including outside mobile) while still retaining a native experience for mobile without having to implement the game anew for iOS and Android.


texts: Are there resources for programmers with little to no graphics design talent, but still want to make good-enough graphics for their own programs? I'm interested in both 2d and 3d computer generated graphics techniques, as well as free graphics repositories.


texts: How do I Animate a character in Unity3D (Animator)?

texts:
first of all, I am new to Programming and Unity, but I want to create a simple game with Unity3D. I am using the StandardAssets (character) where all animations are included, but I dont get how to change animation state.

In the beginning I used this simple c# script to move the player:

    //move the player
    //A/D / LEFT /RIGHT
    transform.Translate (Vector3.right * Input.GetAxis("Horizontal") * speed * Time.deltaTime);
    //FORWARD/BACKWARDS
    transform.Translate (Vector3.forward * Input.GetAxis ("Vertical") * speed * Time.deltaTime);

But then I was only able to move the player around without any animations.

In the "Animator I am using the standard Controller "ThirdPersonAnimatorController".
But how can I interact with the Controller/Animator? The Condition to change from Idle to Walk is CharStateMove = 1.
But How can I change this value? I thought of something like "CharStateMove++;"

Or is there a more easier way to animate a character? Because I dont want to spent the whole time on animate the character. A very simple Animation would be enaught for me...


texts: How can I load and store JSON data in UE Blueprints?

texts:
For a college project that spans a few months, I'm working on a text adventure game in Unreal. I would like to state up-front that even if I wanted to use code, I can't. For some reason my college computers don't have Visual Studio or any other IDE UE supports.

I've made multiple text adventures before (in Flash and Unity) using custom frameworks that get and parse JSON data for the game.

I have no idea how I can accomplish a similar task (loading and parsing JSON data) using UE4's Blueprints. Can anyone help me come up with some sort of way I could go about doing this?


texts: I am using unity's default FPS controller script. My game switches scenes, and when it does I can't move the mouse. I know that this is because of unity's m_mouselook's lock cursor is on. What I don't know how to do is turn that boolean to false through a different script.


texts: Is there evidence that downloading assets on first use rather than bundled with a game download makes a mobile game more popular?

texts:
I've noticed quite a few mobile games on the Android platform recently that prompt you to download their assets package when you first run the game. As an example, The Sims 3 is available for iOS and Android devices (Android Marketplace, Apple App Store) but the iOS version seems to be much larger in size and as such probably doesn't use this system.

I can think of several advantages and disadvantages to doing this:

Advantages (to developer):

The game's store page reports the size of the app as much smaller than it is.
When a patch or update is released you don't need to download the entire application again. (Does the App Store release patches, or do you need to download the whole app again)?

Disadvantages (to developer):

You need to provide your own bandwidth and ensure download availability.
You need to poll your server for updates in the assets and ensure that you make assets available for old versions of the game.

Advantages (to a consumer):

You don't need to ensure you have space for app+assets before installing. Downloading the package manually means you can install the libs/logic/executable on your device and the assets on eternal storage such as SD card, rather than installing all to the device and moving afterwards.
It could be possible to download lower resolution versions of the assets depending on install device (somewhat unnecessary for Android as the market provides a way of supplying different packages to different devices)

Disadvantages (to a consumer):

More difficult for app to enforce that download is done over wifi rather than using up their contract bandwidth.

While I understand that direct comparisons of the two methods are difficult, I'm looking for statistics/reports preferably of the same app with control and sample groups. If that's not available, can anybody with experience with this method indicate whether users preferred not bundling assets? Does user opinion on this vary based on platform? Does the value to users outweigh the extra effort for the developer?


texts: How to make the whole game wait until some new feature at beginning is finished? In Unity

texts:
I have been working on a driving game and its almost finished. I'm just trying to add some polishing touches. Ironically this part im stuck on now would not have been any issue at all in purely code based frameworks i used before (LibGDX/Xna) because I could just make a boolean that's called ReadyToPlay or something and just put that around all the code i want to wait to start.

I've made a secondary camera which rotates around the players car, it works fine but my problem is that the GUI is also already loading AND the race start countdown occurs still whilst the camera is still spinning.

I'm not sure in Unity how to go about stopping that to allow the time for the camera to spin.

One idea I have to fix this (i'm checking first because this doesnt seem right to me) is to use the yield routine in the GUI loading script and tell it exactly how many seconds the camera is going to spin for. I'd rather have just have the camera detected when its done a full spin and then make a boolean true, or trigger another method to start the game properly.

I promise I have done some research trying to find ways but the only thing i can find except yield, is Monobehaviour.Invoke but the invoke method still requires me to specify the time.

The whole strategy for yield or invoke feels wrong to me.
I guess my main problem is that the code is spread over a few scripts, instead of being funneled thru a main.cs and then gameManager.cs etc etc so theres no way (that I know) to break the chain higher up. I'd have to add bools to each script to say isLuxuryCameraAlive and that still seems wrong to me as I might have  5-10 scripts and have to also section of bits of code in each script.

How would you experienced programmers attack this issue??

Thank you!!


texts:
I am making an RTS game and want to add the ability to dig a trench without redrawing the whole terrain as that is causing lag. The solution would need to allow a user to build a trench on the map and have a unit able to stand in the trench.
The game is using 3d models at the moment.

My first thought was to have the trench on a layer that is rendered on top of the layer with the terrain but that would give the problem that a trench would be seen even if it was behind a hill.

Is there an alternative or a solution?


texts: How can I combine my scrolling effect with the vertex lit shader?

texts:
I want my shader to work in both Forward and VertexLit rendering modes. I'd written a texture scrolling shader, but I also want to consider lighting which is produced by Vertex lit shader. I can't add my effect directly in the vertex lit shader, so I'd created 2 passes: the lighting one and the effect one. Here's my code now:

SubShader
{
    Tags
    {
        "RenderType" = "Opaque"
        "LightingMode" = "Vertex"
    }
    Pass
    {
        Name "Hardware lighting pass"
        Tags { "LightingMode" = "Vertex" }

        Zwrite On
        Cull Back

        Material
        {
            Diffuse [_Color]
        }

        Lighting On
    }

    // At the second pass we'we turned the multiplicative blending on to combine our texture
    // effect with the ightin that has been couputed at the previous pass.
    Pass
    {
        Name "Effect-applying pass"
        Tags { "LightingMode" = "Vertex" }

        // If you're change this, you must then change the light calculation algorithm
        Blend One DstColor
        Lighting Off
        Cull Back

        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag

        // texture samplers
        uniform sampler2D _MainTex;
        uniform sampler2D _AlphaMask;
        uniform sampler2D _ManaTexture;
        uniform sampler2D _Noise;

        // float values
        uniform float _ManaFloatSpeed;
        uniform float _ShinessSpeed;

        struct VertexInput
        {
            float4 pos : POSITION0;
            float4 col : COLOR0;
            float4 uv : TEXCOORD0;
        };

        struct FragmentInput
        {
            float4 pos : POSITION0;
            float4 col : COLOR0;
            half2 uv : TEXCOORD0;
        };

        // In the vertex shader we're just applied MVP-transform to our object
        FragmentInput vert (VertexInput i)
        {
            FragmentInput o;
            o.pos = mul(UNITY_MATRIX_MVP, i.pos);
            o.uv = i.uv.xy;
            o.col = i.col;
            return o;
        }

        // 1) Sample our fancy texture to get the pixel color
        // 2) Get the color value of scrolled pixel of the noise texture
        // 3) Set the alpha channel of an output color value to prevent glow at the textured areas
        half4 frag(FragmentInput i) : COLOR0
        {
            float4 col = i.col * tex2D(_MainTex, i.uv);

            // Now reading from the separate mask, later it will be col.a by default (this instruction will desappear)
            col.a = tex2D(_AlphaMask, i.uv).r;

            // Epsilon to prevent dx9-11, and GLES tolerance pass (not 0.0f)
            if(col.a > .0001f)
            {
                // Sample two textures and get the value from the alpla layer
                float4 tl1 = tex2D(_ManaTexture, float2(i.uv.x, i.uv.y + (_Time.y * _ManaFloatSpeed)));
                float4 tl2 = tex2D(_ManaTexture, float2(i.uv.x, i.uv.y + (_Time.y * (_ManaFloatSpeed * 2))));
                float alphaValue = tex2D(_Noise, float2((i.uv.x + _Time.y * _ShinessSpeed), (i.uv.y + _Time.x))).r;

                return half4((tl1 * tl2).rgb, alphaValue);
            }
            else
            {
                return col;
            }
        }
        ENDCG
    }
}

The problem is... Yep, 2 passes, which is extremely undesirable. How can I calculate vertex-lit lighting and apply my effect in the single pass?


texts: How to remove gameobjects that have the same transform position as each other?

texts:
If I have 4 copies of the same gameobject in my scene and they all have the exact same transform position as each other, how can I remove the 3 duplicates so that only one unique gameobject remains? This is what I tried so far...

private void Update()
{
    if (Input.GetKeyDown(KeyCode.Space))
    {
        RemoveDuplicate(GameObject.FindGameObjectsWithTag("Path"));
    }
}

private void RemoveDuplicate(GameObject[] other)
{
    for (int i = 0; i < GameObject.FindGameObjectsWithTag("Path").Length; i++)
    {
        if (GameObject.FindGameObjectsWithTag("Path")[i] == other[i]) continue;
        if (GameObject.FindGameObjectsWithTag("Path")[i].transform.position == other[i].transform.position)
        {
            Destroy(other[i]);
        }
    }
}

But it doesn't work at all. Any ideas?


texts: How can I create a 2D "gooey"/"sticky" separation effect?

texts:
I want to create an effect similar to this animation where two shapes separate over time but are connected (for a time) by something gooey that stretches and eventually breaks. Like pizza cheese, but specifically in 2D.

I'm using Swift and SpriteKit. I'm thinking this probably involves keyframes bezier path animations, but I'm not sure. How can I achieve this effect?


texts: Unity engine memory usage issue - taking up more than it should

texts:
I'm making a 2D game that consists mostly of sprites. As a lot of them were too large in file size, I swapped them into meshes with unlit materials without textures. Now, The problem is that Unity by default, just opening a blank scene, uses 20 MB of texture memory according to the profiler.

So I checked instantiating 100 of my sprites (294 kb each), where the profiler showed 100MB used.

After that I had only those meshes in the scene, still 100 pieces, vertex count 124 each, tri count 47.
The memory usage was still around 100 MB, texture usage 20 MB

Lastly I instantiated 100-100, so the sprites and meshes together.
I got around 106 MB used memory.

This is my used memory with the sprites:

And this is my used memory with the meshes.

Now, as far as I know the meshes should rock in terms of memory as they are low res and have no textures attached.
Could someone tell me what's going on, why are my meshes worse than using sprites? And how to sort this out?


texts: Is it a good idea to render many textures into one texture?

texts:
I'm making a 2D game with OpenGL. In order to avoid changing the state machine and binding at runtime, I want to make consolidate my textures into bigger textures,

for example, taking 4 128x128 textures and making 1 big 512x512. I could then just render part of the texture rather than binding a new one.

Is this a good idea? Could my newly created texture get lost, or are there major faults in doing  this?

Thanks


texts: Is WWW reliable for downloading a large AssetBundle?

texts:
I have a very large AssetBundle. More than 200MB.

Is WWW reasonable for downloading it from my server? I heard that you can't tell the timeout it has. I intend to use it for iOS and Android.

Since clearly the download will last more than 5 minutes for a lot of people, is it reliable or will it time out? Should I instead make my own application in my server to transfer the bundle's bytes using sockets?


texts: In godot, how could I make an explosion not destroy occluded terrain?

texts:
This game is in 2D, and is made out of blocks.
Normally, I would simply erase blocks that aren't indestructible and are within range of the explosion. However, if blocks are behind something indestructible they will still get destroyed, and that's not what I want.

So how could I go about coding an explosion to not damage completely blocked  off terrain?


texts: Affect of timeStep on PhysicsBodies in SceneKit

texts:
In SceneKit, I had a problem on collision of two dynamic spheres, when the one strikes to another with fast speed, it was passing through inside of it. After i have reduced physicsWorld.timeStep value from 1/60 to 1/300, collision of Spheres becomes perfect. However in this moment, if sphere strikes to static wall, it started to slide along the wall (like sticky) instead of being reflected from wall. Ball started to lose so much energy after colliding to wall.

When timeStep was 1/60, ball was bouncing on the wall even in so low speeds, instead sticking to wall. What kind of parameters are affected in physicsBody of the wall or ball by the timeStep?

Wall Parameters;

let ballMass: CGFloat = 0.08
physicsWorld.timeStep = 1/300

let wallGeometry = SCNPlane(width: (maxX - minX), height: wallHeight)
wallGeometry.firstMaterial?.diffuse.contents = UIColor.red
wallGeometry.firstMaterial?.isDoubleSided = true
let shapeWallGeometry = SCNPhysicsShape(geometry: wallGeometry, options: nil) //su an lik bir ise yaramiyor

let wallNode = SCNNode(geometry: wallGeometry)

wallNode.position = SCNVector3( x: Float(xCenter), y: Float(minY-cushionHeight/2), z: Float(cushionHeight)/2 )

wallNode.physicsBody = SCNPhysicsBody(type: .static, shape: shapeWallGeometry)
wallNode.physicsBody?.restitution = 0.82
wallNode.physicsBody?.friction = 0.91

wallNode.physicsBody?.categoryBitMask = PhysicsCategory.WallType.rawValue | PhysicsCategory.GravityType.rawValue
wallNode.physicsBody?.collisionBitMask = PhysicsCategory.BallOneType.rawValue | PhysicsCategory.BallTwoType.rawValue | PhysicsCategory.BallThreeType.rawValue | PhysicsCategory.GravityType.rawValue
wallNode.physicsBody?.contactTestBitMask = PhysicsCategory.BallOneType.rawValue | PhysicsCategory.BallTwoType.rawValue | PhysicsCategory.BallThreeType.rawValue
self.rootNode.addChildNode(wallNode)


texts:
With so many XNA asset viewers out there, how do I distribute my XNA game for PC without having my assets open for persons to steal or manipulate? I know i can create custom asset importer/processor, but that's too time consuming right now. So, are there any alternatives to securing my assets?

model viewers:

http://modelviewer.codeplex.com/

http://xnamodelviewer.codeplex.com/

https://github.com/devpro/Xna-Model-Viewer

Edit:
found a solution:
http://www.xnawiki.com/index.php/Compressed/Encrypted_Content_Archive
I was looking for something like this all along, but there is still the problem of 3d ripper dx. I guess i'll have to rely on copyright as my protection


texts: OpenGL ES multiple objects not being rendered

texts:
I am doing the following to render multiple balls move around the screen but only 1 ball is seen to appear and function. I don't know why the rest (count-1) balls are not being drawn

public void onDrawFrame(GL10 gl) {
        // TODO Auto-generated method stub
        gl.glDisable(GL10.GL_DITHER);
         gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
         gl.glMatrixMode(GL10.GL_MODELVIEW);
        gl.glClientActiveTexture(DRAWING_CACHE_QUALITY_HIGH);
         gl.glLoadIdentity();
         for(int i=0;i<mParticleSystem.getParticleCount();i++){
            gl.glPushMatrix();
                  gl.glTranslatef(mParticleSystem.getPosX(i), mParticleSystem.getPosY(i), -3.0f);
                  gl.glScalef(0.3f, 0.3f, 0.3f);
                  gl.glColor4f(r.nextFloat(), r.nextFloat(), r.nextFloat(), 1);
                  gl.glEnable(GL10.GL_TEXTURE_2D);
                  mParticleSystem.getBall(i).draw(gl);
            gl.glPopMatrix();

         }

    }

Here is  my void draw(GL10 gl) method

public void draw(GL10 gl){

gl.glEnable(GL10.GL_CULL_FACE);
gl.glEnable(GL10.GL_SMOOTH);
gl.glEnable(GL10.GL_DEPTH_TEST);
//  gl.glTranslatef(0.2f, 0.2f, -3.0f);
//  gl.glScalef(size, size, 1.0f);

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertBuff);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, points/2);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

}

I couldnt take the snapshot on my Samsung Phone but here is the emulator screenshot. In reality, the ball moves around with change in orientation and acceleration and keeps changing color randomly (due to r.nextFLoat()) . However, the other 35 balls arent even being rendered as you can see. How can I fix this?


texts:
I am sorry in advance if it's not perfectly clear.

I would like to make a game with let's say the following map (in real it will be a 3D globe).

Now this map contain point, and each point is a place where user can build stuff.

The distance between point is very important, and also, the location of each one of them (not on water and equally distant to each others)

The problem I face, is I don't know how to sync the point with the server. explaining :

I want the point to be equally distant between each others, and only on lands. Generate them is easy from the game itself. but since the game will have a server that control what is build on each case by multiple player, I should generate them in the server. but I don't know how can I do this. since only the game itself know the map and where it can place the point.

Should I generate them in the game, than copy the amount I can fit and write it in the server like if i can fit 200points, I make the server generate 200 points with id from 0 to 200 and the UI will draw them in order ?

I need a little help to find the good direction to explore.

Thank you


texts:
My game runs through a processing sketch. When I export the .jar file from Eclipse, the sketch moves incredibly slow, but it runs at the proper speed in the IDE. Is there a way that I can fix the jar file and make it run faster?

Here's a GitHub: Machlandia GitHub


texts: How to implement cheat proof trading system in a game?

texts:
I want to make a game where you can trade items you find from the world, the world would be static, so the master server would always know exactly how much items of X there are etc.

What should i take into account when building such a system?

I want to avoid people being able to cheat and filling the game with free items, but at the same time i want it to be as less server dependant as possible, as i cant afford buying thousands of servers just to run their games on them constantly, even if i had the money, i would prefer not make people to rely on my servers so they can be playing it at any time they want at anywhere, but if they want to ensure the validity of the objects he is going to buy from someone, he would have to connect to the master server if he wants to ensure the objects validity.

But how could i know which objects are genuine and which are fake? So i thought i would give each object in the world an unique ID which cannot be guessed. But then again, wouldnt i have to somehow prove that i collected those items with valid actions? And how could i possibly do that without making the server to run my game from the beginning? And how could i prevent someone trading the same item twice etc.

So i thought i could use a Bitcoin system, but i dont know much about it and im not sure would this be an option since there would be a lot of trading, and a lot more "coins" to trade, so the amount of history information might be too much to handle, not to mention i want to prevent people from cheating in any way, for example you cant trade stuff from the other side of the world and magically teleport the items there (assuming you dont own a teleport atm), you would have to move the items across the world, which would take some time. Also im not very excited about the fact that Bitcoins generation will use intense amounts of CPU power, and im not sure would there be enough Bitcoins for everyone to use; everyone should have equal chance of getting items without depending how fast CPU they have, and im not sure how it would work with fractions of items (like 0.1 of money etc).

Any thoughts and ideas appreciated.


texts: How to determine when one game object contains another

texts:
I've got two game objects a circular (circGO) and rectangular (retiGO) objects, with the rectangular larger than the circular. I want to be know when retiGO contains circGO. I tried the following but it didn't work:

retiGOBounds = retiGO.GetComponent<Renderer>().bounds;
circGOBounds = circGO.GetComponent<Renderer>().bounds;

void Update () {

    if (retiGOBounds != null & circGOBounds != null)    {
        if (circGOBounds.Intersects (retiGOBounds)) {
            Debug.Log ("We Good");
        }
    }
}

Also I saw Physics2D.OverlapArea documentation, but didn't really understand how to use it to tell when one game object contains another.


texts: Load all materials with loadallassetbundles before objects?

texts:
I have a lot of objects as assetbundles and they're growing.
I didn't want to have the user to download the materials for every asset because they all share their materials. so I put all the materials in an assetbundle and load it by LoadAllAssets() in the Awake() function so they are present in the game for the assets to use.
The problem is that asset load without materials. the ones that have material don't have shader. Is LoadAllAssets() not the answer? what should I do?


texts:
I want to create a puzzle game for my first year in college.
I will use OpeGL and C++.

The point of the game is to create a path between squares that have the same color, without making the paths intersect each other.

This is the game I want to reproduce: http://mypuzzle.org/3d-logic-2

When I first told my teacher that I want to create this game, I told him I will generate levels, not store them internally.

Then when I actually give it a little thought, I realised I don't have a great idea, just a bad-medium idea (one that doesn't generate "good levels", levels that are actually hard, that use as much space as possible, levels that have multiple solutions).

So my question is:

Does anyone of you know a great idea, an algorithm, some math etc. to use it to generate good levels?


texts: can't get File Open screen to appear in Blender? (screenshot attached)

texts:
Just starting out with blender. Did something and now I can't work out how to get the basic File Open screen to appear. Have been trying for a while.

Anyone able to tell me what to do to get back to the basic File Open screen, i.e. the one at http://wiki.blender.org/index.php/Doc:2.6/Manual/Data_System/Files/Open

Here's what I'm seeing:


texts: Are global shader variables slower than texture look ups?

texts: I want to send quite a bit of data to the GPU, the data will never change (or will change very rarely) after it has been created.  Is there a performance impact to using global shader variables or should I pack the data into a texture to perform look ups?


texts: Should I preload interstitial ads when my game starts?

texts: I just recently added interstitial ads to my game. I loaded my interstitial ads when the main game actually starts so it wouldn't take long to load after the user exits to the menu, but on profiling the memory usage, I realized that there are a lot of ad related allocations that are causing the gc to run wild. Is it that I should only request ads when I need them?


texts: Box Collider center relative to GameObject

texts:
I'm trying to get the distance from the BoxCollider center of a gameobject to the bottom of that same BoxCollider. Note that the center of the collider is slighty modified.

So far, I have:

float halfHeightCollider = (bounds.size.y / 2);

I tried the following to take care of the slight modification:

float halfHeightCollider = bounds.center.y + (bounds.size.y / 2);

But seems like bounds.center give me the position of the center of the BoxCollider in the world, not relative to the gameobject, like in the inspector:

That value is the one I want. How can I get it?


texts:
I am using core OpenGL to draw fonts. This works when I do just one font set at a time. Now I am trying to use three different sets in an array.

I have this structure:

struct _sdf_Vertex
{
    glm::vec2       position;
    glm::vec2       textureCoord;
    glm::vec4       color;
};

and I use three fonts - so this:

vector<_sdf_Vertex>     sdf_vertex[3];
vector<unsigned int>        sdf_indexes[3];

I then populate each font type like this ( this works fine - I can see all the data in each element):

void sdf_addVertexInfo(uint whichFont, glm::vec2 position, glm::vec2 textureCoord, glm::vec4 color)
{
_sdf_Vertex     sdf_vertexTemp;             // Temp to hold vertex info before adding to vector

sdf_vertexTemp.position = position;
sdf_vertexTemp.textureCoord = textureCoord;
sdf_vertexTemp.color = color;
sdf_vertex[whichFont].push_back(sdf_vertexTemp);
}

and then I want to pass one set of font data to the shader:

    glBufferData ( GL_ARRAY_BUFFER, sizeof(_sdf_Vertex) * sdf_vertex[whichFont].size(), &sdf_vertex[whichFont], GL_DYNAMIC_DRAW );

    glVertexAttribPointer ( shaderProgram[SHADER_TTF_FONT].inVertsID, 2, GL_FLOAT, GL_FALSE, sizeof(_sdf_Vertex), (GLvoid*)offsetof(_sdf_Vertex, position) );
    glEnableVertexAttribArray ( shaderProgram[SHADER_TTF_FONT].inVertsID );
    //
    // Specify the texture info
    glVertexAttribPointer ( shaderProgram[SHADER_TTF_FONT].inTextureCoordsID, 2, GL_FLOAT, GL_FALSE, sizeof(_sdf_Vertex), (GLvoid*)offsetof(_sdf_Vertex, textureCoord) );
    glEnableVertexAttribArray ( shaderProgram[SHADER_TTF_FONT].inTextureCoordsID );
    //
    // Specify the color array
    glVertexAttribPointer ( shaderProgram[SHADER_TTF_FONT].inColorID, 4, GL_FLOAT, GL_FALSE, sizeof(_sdf_Vertex), (GLvoid*)offsetof(_sdf_Vertex, color) );
    glEnableVertexAttribArray ( shaderProgram[SHADER_TTF_FONT].inColorID );

glBufferData ( GL_ELEMENT_ARRAY_BUFFER, sdf_indexes[whichFont].size() * sizeof(unsigned int), &sdf_indexes[whichFont], GL_DYNAMIC_DRAW ) );
glDrawElements ( GL_TRIANGLES, sdf_indexes[whichFont].size(), GL_UNSIGNED_INT, 0 ) );

Checking the vertex shader with renderDoc - I'm not seeing any of the sdf_vertex data coming through, or sometimes it's all scrambled.  I think it's got to do with the how I'm trying to point glBufferData to the vector of structs inside an array.

How do I pass the location of the vector inside an array?

Thanks.


texts: Determine terrain color based on slope and height with many types of terrain

texts:
I've got a specific problem. Take this as a challenge, if you will.
I have a 3D mesh representing a cliffy terrain. It's constructed from a simple height map.
The goal is to determine what type of terrain (in practice, what color) to use for any point on the map, given a height and a slope and a constant configuration. Both height and slope are between 0 and 1.
The configuration looks something like this:
const vec3 WATER_COLOR = vec3(0.0, 0.0, 1.0);
const vec3 SAND_COLOR = vec3(0.76, 0.7, 0.3);
const vec3 GRASS_COLOR = vec3(0.208, 0.624, 0.004);
const vec3 CLIFF_COLOR = vec3(0.435, 0.384, 0.380);
const vec3 SNOW_COLOR = vec3(0.894, 0.953, 1.0);

const float WATER_MAX_HEIGHT = 0.1;
const float SAND_MAX_HEIGHT = 0.15;
const float GRASS_MAX_HEIGHT = 0.5;
const float SNOW_MIN_HEIGHT = 0.9;

const float SAND_MAX_SLOPE = 0.25;
const float GRASS_MAX_SLOPE = 0.50;
const float SNOW_MAX_SLOPE = 0.75;

const float BLEND_FACTOR = 0.1; // Or whatever

I then need a function that takes a height and a slope to produce a color:
vec3 terrain_color(float slope, float height) {
    // Somehow determine the terrain color
}

I've tried to visualize the kind of function I want like this:

Where the x-axis is slope and the y-axis is height. So close to water, the terrain should be sand, but only if the slope is below SAND_MAX_SLOPE and very high up it should be snow, as long as the slope is below SNOW_MAX_SLOPE. The terrain defaults to the cliff color if nothing else fits.
It's easy to just compare the height and slope with the configuration values, but I would like to blend the colors smoothly together, except for the water, resulting in something similar to this:

A higher BLEND_FACTOR should result in more blurring/blending.
Closest thing I've got so far is the following (inspired by Sebastian Lague's similar shader):
const float HEIGHT_FADE_POWER = 16.0;
vec3 terrain_color(float slope, float height) {
    if (height <= WATER_MAX_HEIGHT) {
        return WATER_COLOR;
    }

    float sand_grow_height_fraction = smoothstep(0.0, SAND_MAX_HEIGHT, height);
    float sand_blend_height = SAND_MAX_SLOPE * (1.0 - BLEND_FACTOR);
    float sand_weight = 1.0 - saturate((slope - sand_blend_height) / (SAND_MAX_SLOPE - sand_blend_height));
    sand_weight *= 1.0 - pow(sand_grow_height_fraction, HEIGHT_FADE_POWER);

    float grass_grow_height_fraction = smoothstep(SAND_MAX_HEIGHT, GRASS_MAX_HEIGHT, height);
    float grass_blend_height = GRASS_MAX_SLOPE * (1.0 - BLEND_FACTOR);
    float grass_weight = 1.0 - saturate((slope - grass_blend_height) / (GRASS_MAX_SLOPE - grass_blend_height));
    grass_weight *= 1.0 - pow(grass_grow_height_fraction, HEIGHT_FADE_POWER) - sand_weight;

    float cliff_weight = 1.0 - grass_weight - sand_weight;

    return sand_weight * SAND_COLOR + grass_weight * GRASS_COLOR + cliff_weight * CLIFF_COLOR;
}

Which produces the following when I map it on a plane:

Which is not quite what I want and it's also missing snow.
I have considered simply using the above image as a texture but I would like a computational way to achieve the same thing. I can't really figure out how to do this while getting the blending right. Besides I may want to replace the colors with a texture eventually.
Bonus points for having a different blend factor for each terrain type.


texts: Unity2D Having trouble steering gameobject

texts:
So I am making a 2d maze game where one of the enemies has to follow the player once it detects the player. I am currently using a steering method to steer the enemy towards the player and also when it detects a wall. I am not using any sort of path finding algorithm, just using steering to make a "dynamic" path finder. But I am having some trouble steering the enemy away from the walls and then resume moving towards the player.

This is what I am doing right now:

follow the player when it is detected
set the enemy's velocity towards the player.
use a raycast to detect if a wall is ahead
if raycast detects the wall, steer the enemy towards the direction it
is moving in, then steer it towards the position of the player again.
E.g if it is moving up while following the player and hits a wall on
the left or right, it will steer up.

I am having a hard time steering the enemy away from the wall and then back towards the player again, because once it steers away from the wall and isn't hitting a wall anymore, it checks where the player is to resume it's pursuit, but then the player goes too far away from the enemy and so it doesn't know where to move towards.

Here is the code:

 void Update()
  {
     RaycastHit2D hit2D = Physics2D.Linecast(transform.position, player.transform.position, 1 << 8);
     if (hit2D)
     {
         string wallTag = hit2D.collider.tag;
         FindMovementDirection(ref wallTag);
         wallHit = true;
     }
     else
     {
         wallHit = false;
     }
  }
 void FindMovementDirection(ref string wallTag)
 {
     int len = 3;
     if (wallTag == "V_Wall")
     {
         if (currentVel.y <= 0) currentDirection.localPosition = new Vector3(0, -len, 0);
         else currentDirection.localPosition = new Vector3(0, len, 0);
     }
     else if (wallTag == "H_Wall")
     {
         if (currentVel.x <= 0) currentDirection.localPosition = new Vector3(-len, 0, 0);
         else currentDirection.localPosition = new Vector3(len, 0, 0);
     }
 }
 void seekSteer()
  {
     float maxForce = 0.8f;
     float maxSpeed = 6;
     if (wallHit)
     {
         desiredVel = currentDirection.position - transform.position;
     }
     else
     {
         desiredVel = player.transform.position - transform.position;
     }
     desiredVel.Normalize();
     desiredVel *= maxSpeed;
     steerVel = desiredVel - currentVel;
     if (steerVel.magnitude > maxForce)
     {
         steerVel.Normalize();
         steerVel *= maxForce;
     }
     currentVel += steerVel;
     if (currentVel.magnitude > maxSpeed)
     {
         currentVel.Normalize();
         currentVel *= maxSpeed;
     }
 }
 void FixedUpdate()
 {
     transform.position += currentVel * Time.fixedDeltaTime;
 }

Another thing that I would like to ask is that, should I be using a path finding algorithm? I am aware that I am not using one and that is because I want the enemy to find it's path dynamically. I also know that path finding and steering go hand in hand most of the time, so am I doing it wrong? Thanks.


texts: Gradient noise that returns closest hit point?

texts: Is it possible to develop a 3d gradient noise algorithm, that also given a ray (origin + direction) returns the closest hitpoint? Without constructing the actual geometry (grid, bricks, octree, etc)?


texts:
I'm working on libgdx project. I basically recreate my game which I coded in xna to make it available for android. Here's the problem android has many screen resolutions, and I want to know how to get them.

i tried Gdx.graphics.getWidth() or getHeight() but it gives me null pointer exceptions.


texts: Unity shaders - blend edges of tile textures stored in an atlas

texts:
I'm creating a tile based game. The tiles can have different textures. All the textures are loaded at startup and dynamically packed in a texture atlas (this is done to make modding easier). Each tile stores the UVs of it's texture.

Here is an example from the game, in which the terrain is mostly made up of "grass" tiles, and there are also "stone" and "dirt" tiles in the center:

As you can see, the edges between different tile types are "hard". I want to make them "soft", so the tiles would blend into each other.

It was suggested to me to create special "edge tile" textures and use them for the edge tiles, but I would rather avoid that because it would require creating an edge tile texture for every 2 possible tile combinations (perhaps more for corners), and would massively bloat up the texture atlas.

Therefore I thought this should be done using a shader. I'm not too familiar with shaders though. I've created simple shaders that make grass sway and such, but I have no idea how to approach this problem. For starters, I'm not even sure how to "tell" the shader what are the UVs in the surrounding tiles (I need the UVs to sample the texture from the Atlas)?

Any help would be appreciated.

Thank you.


texts:
i searching the web for glowing effect , i like to be able to create misc glowing effects ,
like lasers , glow around sprites and such .
couldn't find any thing on the web , any body have any direction ?
something like this :


texts: I have a simple car game with all the basic collision detection and movement in Unity with C#. But when I was building the "engine" for the game I didn't include a detail I later decided to include. I want the possibility so that cars can get damaged and so that the model can change. For example the car looked like it was new and after a crash it looks like a wreck. Please help me by pointing to some resources or by telling me approximate ways of implementing this new feature. Thanks!


texts: Creating a real loading screen between levels in Unreal Engine 4

texts:
I'm trying to create a loading screen to pop up between levels in Unreal Engine 4. I want to have a traditional loading screen such as the loading screen in Skyrim, where the player presses play and text alongside a small model pops up until the game is finished loading.

However, the only information I have found on the internet is related to level streaming which is definitely not what I want. The game I'm working on has very big levels with different gamemodes in each of them, which level streaming can't handle. Also I've found some obsolete plugins to do this which no longer works on the latest UE versions. I've also found some "hacks" that are pretty much display an icon on the main menu while waiting for the "Open Level" blueprint function ends up loading the level, yet I'm skeptical if this technique will work when the level to load is quite big and complex.

How can I create this loading screen? where I can find information on the topic?


texts: How can I draw a line of the raycast hit in game view while the game is running?

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

public class CameraRaycast : MonoBehaviour
{
    public Camera cam;

    public LineRenderer laserLineRenderer;
    public float laserWidth = 0.1f;
    public float laserMaxLength = 5f;

    void Start()
    {
        Vector3[] initLaserPositions = new Vector3[2] { Vector3.zero, Vector3.zero };
        laserLineRenderer.SetPositions(initLaserPositions);
        laserLineRenderer.startWidth = laserWidth;
        laserLineRenderer.endWidth = laserWidth;
    }

    void Update()
    {
        Ray ray = cam.ViewportPointToRay(cam.ScreenToViewportPoint(Input.mousePosition));
        RaycastHit hit;
        if (Physics.Raycast(ray, out hit, 100))
            if (hit.transform.tag == "Interactable")
            {
                //print("I'm looking at " + hit.transform.name);
                laserLineRenderer.enabled = true;

                laserLineRenderer.SetPosition(0, ray.direction);
                laserLineRenderer.SetPosition(1, hit.transform.position);
            }
            else
            {
                //print("I'm looking at nothing!");
                laserLineRenderer.enabled = false;
            }
    }
}

When it detect a "Interactable" object i want it to draw green line from the mouse cursor to the point where the raycast is hitting.

Now it's not drawing anything.


texts: How do I define a required component on a Unity game object?

texts:
I have a script that expected the game object to have a Terrain component.

Is there an attribute I can add (or some other way) which will prevent a designer from adding my script/component/MonoBehavior to a GameObject that does not have the Terrain component?

The only alternative I have been able to find is to attach my script to something else, and then have a public Terrain field, which requires the user to attach the terrain object to it.  (since the editor won't allow you to associate a different object type.) - I just want the reverse.

Any thoughts?


texts: Designing codes on the top of a game engine requires special knowledges?

texts:
I am a web developer who works with C# and Ruby On Rails languages – it depends of the platform my customer have – and I don't need deep knowledge of medicine to create a portal based on it. By now, I want to jump-in unto game creation.

I don't want to create games from literal scratch: I want to create things on the top of game engines such as Unity or Unreal Engine. The point is: I need some physics or mathematics knowledge?

Yes, the basics that everybody knows it's essential I think, but advanced things is necessary? I mean, I need to be a doctor in physics to create awesome things with game engines? I know if I create a game engine, the knowledge is a little necessary, but remember: I'll work on Unity or something like that.

Keep in mind...

We are talking about to designing code. I'm not talking about to drag n' drop sprites and go;
I know that a game engine is composed by some libraries that bring games to life, such as:

Audio services;
Network tools;
Graphics mechanisms;

... in other words, I know there are components that helps me to get things done, but I don't know if they do all the (hard?) work for me.
I told you "[...] to create awesome things with game engines? [...]", do you remember? So, what you must understand by "awesome things" is: imagine a simple ball kicking the floor. OK, it moves up and down, and I want to do this applying gravity realities.


texts:
I'm new to game development and design, I've been looking forward to doing FSM AI design as it seems interesting to me, but I have a question that I see no answer for in the internet.

I've seen FSM diagrams from, for example, Pac-Man, and I noticed that the FSM has no accept states, it makes sense because the enemies are always active and in their different states (Wandering, chasing Pac-Man, running from Pac-Man, recovering in their house) What obviously stops the FSM of the enemies in Pac-Man is either Pac-Man dying or the level ending, but that seems more like brute force than a design decision.

I can imagine some FSM where the enemy just "dies" and that would be an acceptation state as it ended it's process, but again, in many sources I see that some designs just have no accept states. Could someone explain why is this?

Also, what would you do to prevent no-accept states FSM?


texts: Render a 3D scene in multiple windows - extended panoramic view

texts:
Is there any resource location on how to view a 3D scene from an application or a game on multiple windows or monitors? Each window should continue drawing from where the neighbouring one left off (in the end, the result should be a mosaic of the scene).

My idea is to use a camera for each window and have a reference position and orientation for a meta-camera object that is used to correctly offset the other cameras (e.g. like in the above figure where the render targets of the two cameras reproduce the star when stitched together). Since there are quite some elements to consider (window specs, viewport properties, position-orientation of each render camera), what is the correct way to update the individual cameras considering the position and orientation of the central, meta-camera? I currently cannot make the cameras present the scene contiguously (and I am reluctant in working out the transformations without checking whether this is the actual way of doing things).


texts: Unity is reseting Dictionary when game is playing

texts:
I have a class named Item, I am storing instances of this class in list. List is created before game starts, everything works fine in that moment but when I am playing, items still are in list but components Dictionary in each seems to be reset because it haven't got any elements, before game it has.

This is my Item class:

[Serializable]
public class Item
{
    public string Name { get; }

    private Dictionary<Type, ItemComponent> components = new Dictionary<Type, ItemComponent>();

    public comp GetItemComponent<comp>() where comp : ItemComponent
    {
        Debug.Log(components == null); //in game shows true

        return
             components.Values.OfType<comp>().FirstOrDefault();
    }

    public Item AddItemComponent(ItemComponent component)
    {
        components.Add(component.GetType(), component);
        return this;
    }

    public Item(string name, string imagePath)
    {
        //components = new Dictionary<Type, ItemComponent>();

        Name = name;
        ImagePath = imagePath;
    }

}

I am not reset or changing items during game.

What could be the problem? Is it connected with Unity serialization limitations?


texts: Instantiate prefab button inside of panel

texts:
I have a Canvas GameObject with a panel inside of it and a button prefab of the default button.

When I drag the button from my resources folder onto the Canvas in the hierarchy, it places itself where I expect it to, into the panel.

However when I instantiate it like below:

GameObject button = Instantiate(Resources.Load("UI/Dialogue/Button"), new Vector3(0, 0, 0), Quaternion.identity, MyCanvas.transform) as GameObject;

it gets placed into the center of the screen because of the second parameter. However, I can't set it as a child of the parent because that doesn't happen until the last parameter. It also doesn't feel right to figure out the exact Vector3 to plug in so that it looks like its on top of the panel.

Is there a way to instantiate the button onto the panel in code as it works when dragging it from the resources folder onto the Canvas in the hierarchy?


texts: How do I parent an object to a bone in the blender hierarchy?

texts: So, I'm trying to make a simple RPG game using Blender and Unity. I would like to have an empty object to be used as a weapon holding position parented to my right hand bone so that I can switch weapons in and out and they'll be able to animate along with my character by being the child of the empty position. The problem I am having is that I can't get the empty position to be a child of the specific right hand bone, only the armature. Is there a way to make this work? Also, if this isn't a good procedure to accomplish what I am trying to do, please enlighten me with the proper way, I'm kind of a noob, thanks.


texts: How to generate houses procedurally in a voxel world?

texts:
I am developing a mod for the game Minecraft, a block-based voxel game. As part of the mod, I want to create a procedural house generator that will be generated based on specific needs/desires, such as a desire for a bed, a desire to have certain blocks as part of the 'furniture'/walling. It also needs to be able to be extended over time.

What kind of algorithms would be suitable to generate unique-ish houses of this sort? I was thinking some kind of genetic algorithm perhaps, or a collection of built in house modules. I would like to avoid manual user input / manual input of a large collection of widgets as much as possible, or at least allow the layout of a room to be dynamically generated or themed.


texts:
I need to project the light onto the quad and use its value for translating the vertices.

I'm currently having 6 vertices,  two quads,
The points are
A  X  C
B  Y  D

Point X, Y are coming from two ray casting downwards.

C =  X + RightVector
D =  Y +  RightVector
A =  X - RightVector
B =  Y - RightVector

Now I want to translate the vertices based on lightDirectionVector, how would I do that ? I have a directional light, and that mesh of the two quads acting as a shadow quad.

    Vector3 lightDir = mDirectionalLight.transform.forward;
    Vector3 normLight = lightDir.normalized;
    normaLight.y = 0;


texts: How can I make one of the agents to wait X seconds before start moving?

texts:
The same script is attached to some multiple agents. On one of them the flag waitToMove is set to true. And it does getting to the line :

StartCoroutine(WaitToMove(10));

But still all the agents including the one with the flag set to true start moving when starting the game.

How can I make that agents with the script that the flag waitToMove is set to true will wait X seconds one agent will wait 5 seconds other will wait 3 seconds and this one will wait 10 seconds ?

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

public class AgentControl : MonoBehaviour
{
    public List<Transform> points;
    public bool waitToMove = false;

    private int destPoint = 0;
    private NavMeshAgent agent;
    private Transform originalPos;

    void Start()
    {
        agent = GetComponent<NavMeshAgent>();

        // Disabling auto-braking allows for continuous movement
        // between points (ie, the agent doesn't slow down as it
        // approaches a destination point).
        agent.autoBraking = false;

        originalPos = transform;
        points.Add(originalPos);

        if (waitToMove == false)
        {
            GotoNextPoint();
        }
        else
        {
            StartCoroutine(WaitToMove(10));
        }
    }

    void GotoNextPoint()
    {
        // Returns if no points have been set up
        if (points.Count == 0)
            return;

        // Set the agent to go to the currently selected destination.
        agent.destination = points[destPoint].position;

        // Choose the next point in the array as the destination,
        // cycling to the start if necessary.
        destPoint = (destPoint + 1) % points.Count;
    }

    void Update()
    {
        // Choose the next destination point when the agent gets
        // close to the current one.
        if (!agent.pathPending && agent.remainingDistance < 1f)
            GotoNextPoint();
    }

    IEnumerator WaitToMove(int WaitTime)
    {
        yield return new WaitForSeconds(WaitTime);
    }
}


texts:
Most PC games nowadays obviously come with the standard option to change the game's resolution from between 640x480 to 1920x1080 on average, depending on your monitor and whether or not you are playing in windowed mode. However, when developing a retro pixel art game, allowing the resolution change to be between 640x480 and 1920x1080 is rather absurd.

So in a pixel art game where, at default resolution, one frame of the main character's sprite is 16x32 pixels, what would you like to see the game's default resolution to be, and by how much would it scale with each resolution option? Would a square screen be better than a widescreen? How many map tiles (at 32x32) would be best to display across and down?

So, in general, what would be the optimum game screen size and at what resolution for a pixel art game now? Your opinions are appreciated.


texts: Adding gesture recognizer (or dragging) to CCSprite

texts:
I'm trying to allow a CCSprite to be dragged across the screen. I've succeeded so far by doing it on a Layer level (from this tutorial). However, this only allows ONE sprite to be dragged at a time as the method implementation can only identify a single sprite to move at a time.

I'd like to be able to perhaps add a gesture recognizer or somehow implement ccTouchesBegan/Moved in my own little CCSprite subclass.

However, from what I understand, you can't just add gesture recognizers to CCSprites. ccTouchMoved are also not available on CCSprites?? Really confused as to how to implement touches on Cocos2D.

What is the easiest way to add some position translation code to a CCSprite so it can be dragged around? Thanks!


texts: Setting up a cross-platform Ogre project on a Git repository

texts:
I'm looking to start a cross platform game project using Ogre, and I want to host it on a git repository. I'm collaborating with a friend on this: I'm on a Mac using Xcode, and he's on a PC using Visual Studio.

I've looked around on the Ogre site, and it seems CMake is what I should be using, but I'm not sure how to set it up with a Git repository. Would you be able to give me any pointers on where to start on this – tutorials and guides etc?


texts: LOD culled gameobject still interacts with raycast

texts:
The camera is sort of top down and the player can move objects around, rotate them, delete them etc. I use a raycast to check what was hit when the player clicks. But some objects are culled by the LOD group when far away, but the LOD group only disables the renderer, not the colliders, so it still interacts with the raycast. This means a player can move or delete an object that they can't even see.

I've tried looping through all the renderers in the lod group and using renderer.isVisible but it doesn't solve the problem of collision and raycasts. I'd really rather not poll isCulled every frame in update either because there are thousands of gameobjects, that would be horrible for performance.

LODGroup lodGroup = GetComponent<LODGroup>();
LOD[] LODs = lodGroup.GetLODs();
for (int i = 0; i < LODs.Length; i++)
{
    LODRenderers = LODs[i].renderers;
}

bool isCulled = true;

for (int i = 0; i < LODRenderers.Length; i++)
{
    if (LODRenderers[i].isVisible)
    {
        isCulled = false;
    }
}


texts: Unpausing a game when a TouchScreenButton node is released

texts:
I'm making a mobile game in the Godot game engine.
I made a spike scene where the spikes will respawn at a random time in a particular position moving upwards.
Then I instanced the scene in the main scene, it worked perfectly, the spikes moving up and appearing in a particular position.
Then I created a TouchScreenButton node in the main scene and changed it pause property to process and then added a _OnPressed and _OnReleased signal to the main scene script then added this code to the _OnPressed function
get_tree().paused = true
And added this code to the _OnReleased function
get_tree().paused = false
But when ever I press and release the button it only pauses the scene
What should I do?


texts: How can this method to make a text mesh always face the camera be simplified? (Unity c#)

texts:
Despite a fairly heafty new years I am back trying to learn a bit more coding :D

This latest feature I am trying to add is a TextMesh that floats above a gameobject when the player is looking at it.

I does all work fine (except it kinda shakes a little but I'll look into that another time). But as I wrote the method to make the textMeshObject look at my camera, I just had a niggling feeling it could be written in less lines of code.

I actually get this a lot where I write several lines and think it must be able to be simplified, and after the code having several parts like this it can look pretty messed up.

Anyways, I thought i'd ask you experts on here if it was possible to do this an simpler (NOTE: I only want it to rotate on Y Axis):

  void FaceTextMeshToCamera(){
            Vector3 origRot = textMeshObject.transform.eulerAngles;
        textMeshObject.transform.LookAt(textLookTargetTransform);
        Vector3 desiredRot = textMeshObject.transform.eulerAngles;
        desiredRot.x = origRot.x;
        desiredRot.z = origRot.z;
        textMeshObject.transform.eulerAngles = desiredRot;
  }


texts: Blender wont export textures (materials) to OGRE3D .mesh

texts:
i am exporting a model from BLENDER to OGRE3D using the blender2ogre script. the desigre output is a single .mesh file but i know there should be also materials scripts that i should copy to my ogre path. the problem is that blender does not export those files for me it export only 1 mesh file (after i joined all objects) this is the model. in blender it looks fine but in my demo Ogre app it looks like :
i can use a little help here.


texts:
I know, that this question was asked before, but I could not find a proper answer to this. So how can I make my line dotted? I added a texture with a dot, but it just gets stretched for the length of the line, which is obviously not what I want. I'm using C# btw, if some code is needed here.

Edit: Inspector:

Edit: New Code :

public class dashedLine : MonoBehaviour
{
    public Vector2 newPosition;
    private LineRenderer line;

    void Awake()
    {
        line = GetComponent<LineRenderer>();
    }

    void Update()
        {
        line.material.SetTextureOffset("_MainTex", new Vector2(Time.timeSinceLevelLoad * 4f, 0f));
        line.material.SetTextureScale("_MainTex", new Vector2(newPosition.magnitude, 1f));
        line.SetPosition(0, newPosition);
       }
}

This is what I get:

Edit: This works now, when I use a Texture which has multiple dots in a row and put it to a material with Shader: Unlit/Transparent. I still don't know, why it's not working with a single dot.

Edit2: I had to recreate the dot texture with a single dot and it worked, so there was some issue on my side. Everything works now fine.


texts: How to check a value from the last frame, while using events in Unity

texts:
What I am trying to do is check if a value has changed from the last frame, while using events. Typically I could use threading to my advantage and have a check at the bottom of Update() to see if a value that is typically changed higher up in Update() was changed or not.

However, I am programming with Events, and I don't rely on Update() in several classes to change data. When an event is published, it makes method calls to all methods subscribing to that event. CameraUpButton() is called by the event manager, not by Update(). ClearUp() is called from Update().

I want to see how long an event has been constantly published for, essentially seeing how long the up button has been held. Checking how long it has been held is the easy part, clearing it once the button is no longer held is the hard part since I do not know how to see when an event stopped publishing (I don't know if that is even possible?). So I'm resorting to making some logic to figure it out for me.

In this case:

 private int up;
 private void CameraUpButton()
 {
     up++;
     Vector3 cameraPos = Camera.main.transform.position;
     cameraPos.y += 0.01f;
     Camera.main.transform.position = cameraPos;
 }

 private void ClearUp()
 {
     some logic to determine
     if up has changed since the last frame
 }

Edit: I can make a Input.GetButtonUp("") event, however I want to see if this can be solved without relying on an event triggered by the button coming up. I would prefer if it can be solved without that reliance.


texts: Converting to JSON String with JsonUtility.ToJson

texts:
I am working on converting and displaying the JSON String with unity. I have done coding for it

using UnityEngine;
using System.Collections;
using LitJson;
using SimpleJSON;
using System.IO;
public class TestDelete : MonoBehaviour {

JsonData json;
void Start()
{
    Data2 data = new Data2();
    Payload2 data2 = new Payload2();
    data.command = "state";
    data.payload = new Payload2()
    {
        text = "wwwwwww",
        image = "hello"

    };
    data2.option = new Option () {
        A1 = "k",
        A2 = "J"

    };

    string dataValue =data+ data2.ToString();
    string json = JsonUtility.ToJson(data,true);
    P(json + "\t\n");

}

// Use this for initialization
void P(string aText)
{
    print (aText +"\n");
}

}

  [System.Serializable]
  public class Payload2
   {
     public string text;
     public string image;
      public Option option;

    }

  [System.Serializable]
   public class Data2
   {
     public string command;
     public Payload2 payload;
   }

   [System.Serializable]
   public class Option
    {
      public string A1;
      public string A2;
    }

This code of working fine.But with the output Iam having problem.The out is displayed as follow

{
"command": "state",
"payload": {
    "text": "wwwwwww",
    "image": "hello",
    "option": {
        "A1": "", // not getting displayed
        "A2": ""   // not getting displayed
    }
}

}

the string value A1 and A2 is not getting displayed.What will be the issue with my code.Can anybody help me sorting out this issues


texts: Which parts of Doom (1993) are open source and which are not?

texts:
As the original publication of the source code states, you still need an original copy of the game:

https://www.doomworld.com/idgames/idstuff/source/doomsrc

What exactly do you need from those original copies?


texts:
I'm trying to render a large number of identical rigged entities with independent animation.

Compared to standard skeletal animation, I can't compute the pose of each entities and send it to the GPU for each frame. This would demand too much work for the CPU and saturate the VRAM very quickly. Let's say I have 5000 entities with 20 bones, I would have to compute and send 5000 * 20 * (size of matrix/quaternion-translation/dual-quaternion) poses to the GPU, each frame.

I recently found this article/paper : https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch02.html Their idea is to load animations to the GPU in order to access them independently with each instance.
Correct me if I'm wrong but I think this is equivalent to move the interpolation part to the GPU.

I pre-computed all the bone transformation in local space for each frame for each animation and packed it into texture buffers. It works as expected.

However, I experience strange results with my animated models...
In fact the interpolation is necessarily wrong ! I am trying to interpolate between poses in local space, not in bone space like with standard CPU interpolation. There is no problem with translations, but with rotations. (the axis is shifted to the local space origin).

I imagine I could send the bone space transformations AND the bone hierarchy. But that would impose to parse the hierarchy for each vertex (in vertex shader), in order to re-compute the interpolated bone transformations.

One other idea I had is to upsample the animations in order to have smaller interpolation intervals, but again, it will use more VRAM.

To be honest I'm not sure I understood well the paper (especially in the interpolation part)...

Any suggestion ?

EDIT 1 : It's maybe unclear : by "local space" I mean entity space, so it is more like "global space"...

EDIT 2 : To provide more details about my implementation :

In the CPU (c++) pre-process part, I pre-compute all the bone transformations in local space for each frame (natively, I get bone-space transformations using Assimp library so I have to do a bit of work here).

Then, I send this information as an array to the GPU (array of numFrames * numBones * numAnims dual quaternions).
In the vertex shader, I get information about the current instance using gl_instanceID. I get world position, current animation and time in current animation.

Then I compute the interpolated pose of the bones influencing the current vertex. I do that by finding the bounding frames using the instance's time. I interpolate my pairs of transformations (pairs of dual quaternions) for each concerned bone.

(I know there is a mistake because the interpolation must be performed in bone space).

Once they are interpolated, I blend linearly the transformations into one using the bone weights attached to my vertex (and I normalize my final dual quaternion).

It worked when i was doing interpolation in bone space in CPU, I'm just trying to move the interpolation part on the GPU.


texts: UNET spawn dynamically generated object unity

texts:
Spawning works when all clients are connected, but if a client connects after I spawn all my prefabs there are errors.  I spawn the object before changing its Rigidbody's velocity, which seems to cause the problem. I spawn objects, change them, then the other client joins, and the errors come. these are the errors:

Failed to spawn server object, assetId=953c1c6ecbb84304280d1334ef5dae0b netId=26

I also make changes to variables on other scripts.

All objects have network identities, network transforms, and are spawnable prefabs.


texts: How to rotate player to face mouse on canvas?

texts:
I'm building a basic game using plain javascript and I am trying to rotate my object to follow my mouse.

I've tried getting the client's mouse X and Y then subtracting the canvas width and height divided by two. Then taking those values and inputing it into Math.atan2(). However, I feel the issue may be in my transform and rotate. The code bellow is what I've tried.

WIDTH = c.height;
HEIGHT = c.width;
document.onmousemove = function(ve){
            let cX = -c.width / 2;
            let cY = -c.height / 2;
            let x = ve.offsetX;
            let y = ve.offsetY;
            var rX = cX + x - 8;
            var rY = cY + y - 8;
            player.angle = Math.atan2(rX, rY) / Math.PI * 180;
        }
function update(){
                        var now = Date.now();
                        dt = now - lastUpdate;
                        ctx.clearRect(0, 0, WIDTH, HEIGHT);
                        ctx.setTransform(1, 0, 0, 1, WIDTH / 2, HEIGHT / 2);
                        ctx.rotate(player.angle + 10);
                        drawCircle(player.x, player.y, 20, 0, 180, "red");
                        ctx.setTransform(1, 0, 0, 1, 0, 0);
}
setInterval(update, dt/10000);

The player spins around my mouse in wide circles with no apparent pattern.
Here's a gif showing what's happening.
https://gyazo.com/006c99879ecf219791d059de14d98b74


texts:
I'm working on a WebGL project and all my textures render fine.
When i wanted to implement a cubemap i started getting this type error.
Argument 9 of WebGLRenderingContext.texImage2D does not implement interface ArrayBufferViewOrNull. in all browsers.
A fragment of my code i use to load the textures is,

    var cubeMap = gl.createTexture();
    gl.bindTexture(gl.TEXTURE_CUBE_MAP, cubeMap);

    for(var i = 0; i < 6; i++)
    {
        var img = cubeMapArr[i];
        console.log(img);
        gl.texImage2D(
            gl.TEXTURE_CUBE_MAP_POSITIVE_X + i,
            0, gl.RGB, 1024, 1024, 0, gl.RGB, gl.UNSIGNED_BYTE,img);
    }

the cubeMapArr holds HTMLImageElements.
Any ideas or experiences about this issue?
Using gl.texImage2D() like for example this,

gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,normalMapTexture);

works with no issues.
Again normalMapTexture holds a HTMLImageElement.

Thank you.


texts: Off screen image Direct3D processing with SharpDX, pixel shader and C#

texts: I currently have a working app that can process images with a window handle. This of course makes use of the swap chain and so on... I need to process an image with pixel shader off screen without a window handle. I have not been able to successfully port this to an off screen model. Can any please help educate me on the best way to do this? I have the Device, context for both Direct3D and Direct2D available. I'm having issues with using the correct texture to image process...


texts: C# XNA colliders, physics, inclined plane/terrain/colliders

texts:
Currently I'm working on a project to learn game programming. But I'm not sure if I have the right approach on several things, and that's what I'm here for.

What I'm trying to create is a small world in 3d and simulate some simple physics. The world can be seen below.

The world is basically a box, note that I've left out the walls in the front and side view, but they will be there. The goal is to drop a ball somewhere in the green area and let physics do its work. Then the simulation will end once the ball falls into the hole. Later, once I got a better understanding of everything I want to create a pinball game out of it, but that's for a later stage.

Currently I'm creating this project in C# XNA/MonoDevelop and want to create everything from scratch. So I got my own physics engine, collider classes, math library, et cetera, which I find quite challenging, especially since I knew/know nothing about all of this, especially the math, but I am learning a lot from it, and I find it a lot of fun!

So what do I have now:

I got a GameObject class, which contains a position, a model, update and draw methods, etc. And a Physics Engine which uses PhysicsObjects and ModelObjects (both inheriting from the GameObject).

The PhysicsObject contains a mass, velocity, gravity, a collider update and draw method and the ModelObject just has a position and a collider and update and draw method.

The PhysicsEngine has a Run(deltatime) method which is being called in the update method and integrates through all the PhysicsObjects in step one, updating it's velocity, applying gravity, and finally position. In the next step the PhysicsEngine handles the collisions. It checks whether a collision was found between PhysicsObjects and PhysicsObjects and PhysicsObjects and ModelObjects and if a collision was detected it will handle the collision response.

So far I only have an Axis-Aligned Bounding Box, BoundingSphere and Plane class. And implemented the Sphere-Sphere collision, and Sphere-Plane collision.

I soon realized the AABB wouldn't be possible since I can't rotate them. So I tried creating planes, since as far as I understand, a Plane exists out of a normal vector to determine the 'up' side and a distance from the center/origin. The problem only is that there isn't a begin or end position so I can't have a hole in the terrain. So this is where I'm stuck, I have no idea on how to approach this and what to use and how most people would solve this problem. I'm not asking for code snippets or anything, but want to know if my general approach to all of this is 'correct' and how I should approach this problem for the terrain. What kind of collider should I use for the terrain to also make it possible to rotate it?


texts: Destroying 1 of 2 GameObjects with that same script attached in UNITY

texts:
So I have 2 GameObjects, and they have exactly the same script attached to them called 'RoomSpawner'. Via this script, I want to destroy just ONE of these TWO GameObjects. How can I do this? By typing Destroy(gameObject); It will destroy 2 GameObjects :/, I'm confused, any ideas?

Those 2 GameObjects are in the same positions, and I want to delete them by OnTriggerEnter2D


texts: How to replace texture maps on models in a packaged game?

texts:
I'm trying to do an experiment. I'd like to do some object masking to the assets inside of a game, so during run time, when you are playing, they're texture maps are replaced by the masks.

The masks will literally be just color maps. They are supposed to be labels for a machine learning program.

Preferably if one could replace the texture maps with color masks during runtime that would be better.


texts: Public value null after assigning it from a different script

texts:
Hello I am a beginner in Unity and still currently exploring with scripts.
So I ran into a problem.

In FetchAndAssign.cs Script

    void Start(){

         GameObject theEdge = GameObject.Find("Edge2");
         StallComponentAdder edge = theEdge.GetComponent<StallComponentAdder>();
         edge._id = _id;

    }

In StallComponentAdder.cs Script where it is attached to Edge2 GameObject

    public string _id;

    void Start () {
         string storeID = _id;
         print(storeID);
    }

When I try to print the storeID it won't print anything, why is that so?


texts: Polar movement towards cursor sfml and c++

texts:
I got smooth movement down moving based on the window but I wanted to see if I could move my sprite to my cursor when I pressed w instead of just in the -y direction but everything went wrong right away. Here is the function I'm trying to make work:

    void Ship::MoveShip(float ShipAccel, float deltaTime)
{
    float movementY;
    float movementX;
    m_ShipVel += ShipAccel * deltaTime;
    if (m_ShipVel > m_ShipMaxVel)
    {
        m_ShipVel = m_ShipMaxVel;
    }
    else if (m_ShipVel < -m_ShipMaxVel)
    {
        m_ShipVel = -m_ShipMaxVel;
    }
    movementX = m_ShipVel * (cos(m_ShipAngle * 180 / PI));
    movementY = m_ShipVel * (sin(m_ShipAngle * 180 / PI));

    m_SpriteShip.move(movementX, movementY);
}

Just made a video of what's happening with this code: Video


texts: How can I make permanent death in a MUD seem acceptable and fair to players?

texts:
I have considered writing a MUD for years, and I have a lot of ideas my friends think are really cool (and that's how I'd hope to get anywhere -- word of mouth).

Thing is, there's one thing I have always wanted, that my friends and strangers hated: permanent death. Now, the emotional response I get to this is visceral revulsion, every time. I'm pretty sure I am the only person that wants this, or if I'm not, I'm a tiny minority.

Now, the reason I want it is because I want the actions of the players to matter. Unlike a lot of other MUDs, which have a set of static city-states and social institutions etc, I want the things my players do, should I get any, to actually change the situation. And that includes killing people.

If you kill someone, you didn't send them to time out, you killed them. What happens when you kill people? They go away. They don't come back in half an hour to smack talk you some more. They're gone. Forever.

By making death non-permanent, you make death not matter. It would be similar if a climax to a character's arc is getting a speeding ticket. It cheapens it. Non-permanent death cheapens death.

How can I:
1) Convince my players (and random people!) that this is actually a good idea?, or

2) Find some other way to make death and violence matter as much as it does in real life (except within the game, of course) sans character deletion? What alternatives are there out there?


texts: How can I uniquely identify a GameObject in Unity?

texts:
I'm trying to serialize and deserialize my custom classes with Unity. I've got an ISerialize interface that mandates the class can Load() and Save(), so then I setup one master class to iterate across everyone and find the ISerialize components and trigger them to Load() and Save() correctly:

public class SerializationTest2 : MonoBehaviour, ISerializationCallbackReceiver
{
    GameObject[] gameObjects = null;
    // Start is called before the first frame update
    void Start()
    {
        gameObjects = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
    }
    // comment

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

    public void OnBeforeSerialize()
    {
        Debug.Log("Unity is serializing... saving state!");
        foreach (GameObject gameObject in gameObjects)
        {
            Save(gameObject);
        }
    }
    public void OnAfterDeserialize()
    {
        Debug.Log("Unity finished serializing... loading state!");
        foreach(GameObject gameObject in gameObjects)
        {
            Load(gameObject);
        }
    }

    private void Load(GameObject gameObject)
    {
        Debug.LogFormat("Found {0}", gameObject.name);
        ISerialize[] serializers = gameObject.GetComponents<ISerialize>();
        foreach (ISerialize serializer in serializers)
        {
            serializer.Load();
        }
        int nChildren = gameObject.transform.childCount;
        for (int i = 0; i < nChildren; i++)
        {
            Load(gameObject.transform.GetChild(i).gameObject);
        }
    }

    private void Save(GameObject gameObject)
    {
        Debug.LogFormat("Found {0}", gameObject.name);
        ISerialize[] serializers = gameObject.GetComponents<ISerialize>();
        foreach(ISerialize serializer in serializers)
        {
            serializer.Save();
        }
        int nChildren = gameObject.transform.childCount;
        for(int i=0; i<nChildren; i++)
        {
            Save(gameObject.transform.GetChild(i).gameObject);
        }
    }
}

So this works GREAT and exactly as intended - I get a list of all the top-level root objects on Start(), then I get the serialize/deserialize callback. I iterate down the tree of GameObjects for each root and get everyone.

The idea here is that this class will eventually open an XML file and save to that file for serializing or will load from that file for deserializing.

I need to build that XML hierarchy, though. I could have multiple instances of a class scattered across a bunch of different GameObjects, so I need some way of identifying which GameObject I've currently got so I can serialize/deserialize to the correct components for that GameObject.

The problem is that, when I use the above code, I get:

UnityException: GetName is not allowed to be called during serialization, call it from Awake or Start instead. Called from MonoBehaviour 'SerializationTest2' on game object 'Registrar'.

See "Script Serialization" page in the Unity Manual for further details.

So, then, how do I uniquely identify the GameObject I'm currently on? If I can't call gameObject.name, what should I be calling?

:EDIT:

As an example, consider two enemies - one has a scale of 2x the other and a hitDamage of 2x the other, but they otherwise use the same EnemyAttack script. I need to deserialize the hitDamage values to the correct GameObject, but if I can't use the GameObject's name during the serialization process then I don't know how I'm supposed to distinguish the two.


texts: Change sprite to animation in unity 5 2d (c#)

texts:
I want to do the same as this older post with one change:

Change the sprite of a Object in Unity

I want to use a .anim animation (created with unity) after the space key is pressed instead of another sprite. The problem is I can't drag the animation file to the sprite slot in the script component.

Thanks.


texts: Is there a more useful "inverse" alternative to portal rendering than antiportal rendering?

texts:
I'm in the process of sketching out the design of a 3D rendering engine as I'm learning my way around the subject. (Preemptively: yes, I have my reasons for rolling one from scratch, not least the educational value, so no, I'm not interested in just using prefab solution X.) As in the Elder Scrolls games, the engine fundamentally differentiates between "indoor" and "outdoor" areas, since in "indoor" (primarily enclosed) areas it uses a portal-and-cell approach to simplify visibility determination. I've  been trying to work out a good solution for simplifying visibility determination for "outdoor" (primarily open, freely roamable) areas, but I haven't run across anything I like nearly as much.

Primarily the issue is that, with portal rendering, you can not only skip on rendering anything behind an occluded portal, but you can actually discount it outright. If, for example, you store the cells as separate data structures and track which objects are within which cells, if a portal isn't visible, anything within the cell behind it can be completely removed from consideration without ever having to even check the objects themselves. (Aside from a few edge cases of objects that extend over the boundary of the portal into another cell, but that's not too hard to work around.) And that happens entirely without any pre-calculated visibility information, just by the nature of the rendering process. I like that quite a bit.

But I haven't found a technique that provides that kind of benefit for "outdoor" spaces, at least not without a lot of pre-baked analysis. The inverse of portal-and-cell rendering, "antiportal," seems like a not-bad approach in the broad strokes, since in the intended application "outdoor" areas will likely have fairly large areas of the screen occluded (by mountains, buildings, etc.) But as far as I can determine there's no way to use it for the kind of wholesale removal of objects/architecture at the data-structure level as you can pull with portal-and-cell rendering, since antiportal rendering requires you to actively check objects against an "occlusion volume" created from the antiportal and dependent on the camera position. Which, I guess, would work, but it seems like there should be a better way.

Maybe there isn't, and it's just the nature of the beast, but I thought I'd ask: is there a good method for removing objects from visibility determination in a primarily open environment before considering the individual shapes, without having to use more traditional pre-calculated BSP-type techniques?


texts:
I would like to know how to make a background like Super Hexagon managed to do: a hexagon in the middle and equally sized trapezoids.

There's a screenshot below & the here is the effect in motion.

How can this be done? Can I use a big sprite or procedural meshes?


texts: Fastest way to group units that can see each other?

texts:
In the 2D game I'm working with, the game engine is able to give me, for each unit, the list of other units that are in its view range.

I would like to know if there is an established algorithm to sort the units in groups, where each group would be defined by all those units which are "connected" to each other (even through others).

An example might help understand the question better (E=enemy, O=own unit). First the data that I would get from the game engine:

E1 can see E2, E3, O5
E2 can see E1
E3 can see E1
E4 can see O5
E5 can see O2
E6 can see E7, O9, O1
E7 can see E6
O1 can see E6
O2 can see O5, E5
O5 can see E1, E4, O2
O9 can see E6

Then I should compute the groups as follow:

G1 = E1, E2, E3, E4, E5, O2, O5
G2 = O1, O9, E6, E7

It can be safely assumed that there is a commutative property for the field of view: [if A sees B, then B sees A].

Just to clarify: I already wrote a naïve implementation that loops on each row of the game engine info, but from the look of it, it seems a problem general enough for it to have been studied in depth and have various established algorithms (maybe passing through some tree-like structure?).  My problem is that I couldn't find a way to describe my problem that returned useful google hits.

Thank you in advance for your help!


texts: OpenGL get the outline of multiple overlapping objects

texts:
I just had an idea for my on-going-game made with opengl in c++: I'd like to have a big outline (5-6 pixel) on multiple overlapping object when the player win something.

I thought the best way is to use stencil buffer but it's few hours that I' trying to do some off-screen render of the stencil buffer and I can't achieve any kind of result so probab. there are some other techniques!

This is what I want to get:

Any ideas?


texts: User interaction and Component based architecture

texts:
I'm working at my first game and I've decided to build a simple component based engine.
I found really useful to work in that way but I still miss some fundamentals probably.

Let say that I have a super simple game like this:
A spaceship that moves where user touches/clicks the screen. Before moving the ship the user has to select it by a touch/click over the spaceship sprite and to deselect it the user has to touch/click wherever outside the sprite.

To build something like that I'd use this structure:

Spaceship Entity
     |_____________ Movable Component  (contains coordinates)
     |_____________ Drawable Component (contains a sprite)

Rendering system:
     - Check for every entities with drawable and movable component and draw
       the sprite at the coordinate defined by movable component

Or something similar..

At this point I would like to add an input manager. But err... I really don't know which is the best way to attach an Input Manager in this structure! Do you think it's a good idea to create something like a Selectable component and then create a Input System?
The problem is that probably it would be useful to keep track of the selected object in other systems too and I suppose that this part could be managed outside the Component system.

So my question is how to deal with a behaviour that is so important and generic like user interaction in a Component based architecture. Have you had experience with this problem? Which solutions did you choose?

Edit:
And in general I suppose that is a valid idea to keep track of the current selected object. Using a component based architecture how can I manage shared information?


texts:
Is there any way to make a SpriteBatch flip when its clicked, something like Android Animation?

I know that spriteBatch.Draw() have SpriteEffects, but it literally flip it and I want to flip it like an animation.


texts: How to set up node data for Pathfinding algorithm in 2D platformer?

texts:
I've been doing a lot of research into the A* pathfinding algorithm and I'm trying to incorporate it into my program. This is not a game that I created so I have no control over the frames. However, I am reading the necessary information from memory and think I can create coordinate based way points based on the game physics. Currently, I am grabbing all the platforms which are walkable and storing them inside their own doubly linked node based on if they are connected with their vertices. However, I am not sure where to go from here. What other information should I be storing inside of these nodes and how should I be connected one node list to another?

struct Platforms{
    LONG x1;
    LONG y1;
    LONG x2;
    LONG y2;
    struct Platforms *prev;
    struct Platforms *next;
};
std::vector<Platforms*>P;
void GetPlatforms(){
    int platformCount = (int)ReadPointer(CWvsPhysicalSpace2DBase,OFS_PlatformCount);
    LONG rightWall = ReadPointerSigned(CWvsPhysicalSpace2DBase, OFS_RightWall);
    LONG leftWall = ReadPointerSigned(CWvsPhysicalSpace2DBase, OFS_LeftWall);
    LONG downWall = ReadPointerSigned(CWvsPhysicalSpace2DBase, OFS_DownWall);
    LONG upWall = ReadPointerSigned(CWvsPhysicalSpace2DBase, OFS_UpWall);
    //add_log("Platform Count: %d", platformCount);
    for(int i=0; i<platformCount-1; i++){
        LONG x1, y1, x2, y2;
        x1 = GetValue(platStruct, OFS_PlatformLeft);
        y1 = GetValue(platStruct, OFS_PlatformTop);
        x2 = GetValue(platStruct, OFS_PlatformRight);
        y2 = GetValue(platStruct, OFS_PlatformBottom);
        if((x2)-(x1) > 0){ //Make sure the platform is traversable
            //add_log("\n\nPlatform: %d X1: %d Y1: %d X2: %d Y2: %d", i+1, x1, y1, x2, y2);
            if(P.size() > 0){
                bool newHead = true;
                for(std::vector<Platforms*>::size_type i = 0; i != P.size(); i++) {
                    Platforms *curr = P[i];
                    while(curr != NULL){
                        if(curr->x1 == x2 && curr->y1 == y2){//curr->y1 - y2 > -50 && curr->y1 - y2 < 50){ //To account for slope
                            insert_front(&curr, x1, x2, y1, y2);
                            newHead = false;
                            //add_log("front segment found: X1: %d Y1: %d X2: %d Y2: %d", curr->x1, curr->y1, curr->x2, curr->y2);
                            break;
                        } else if(curr->x2 == x1 && curr->y2 == y1){
                            insert_After(curr, x1, x2, y1, y2);
                            newHead = false;
                            //add_log("connected segment found: X1: %d Y1: %d X2: %d Y2: %d", curr->x1, curr->y1, curr->x2, curr->y2);
                            break;
                        }
                        curr = curr->next;
                    }
                }
                if(newHead == true){
                    struct Platforms* head = NULL;
                    insert_end(&head, x1, x2, y1, y2);
                    P.push_back(head);
                }
            }else{
                struct Platforms* head = NULL;
                insert_end(&head, x1, x2, y1, y2);
                P.push_back(head);
            }
        }
    }
}


texts: How to drag 2D objects and stop it if collides with other 2D object?

texts:
This is the code I am using but it's not working. It drags other object on collision:

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

public class TileControllerHorizontal : MonoBehaviour
{

    private Vector3 screenPoint;
    private Vector3 offset;
    public bool check;

    // Use this for initialization
    void Start ()
    {

    }

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

    }

    void OnMouseDown ()
    {
        screenPoint = Camera.main.WorldToScreenPoint (gameObject.transform.position);

        offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
        transform.name = "draging";

    }

    void OnMouseDrag ()
    {
        if (!check) {
            Vector3 point = Camera.main.ScreenToWorldPoint (Input.mousePosition);
            point.z = gameObject.transform.position.z;
            point.y = gameObject.transform.position.y;
            gameObject.transform.position = point;
        }
    }

    void OnMouseUp ()
    {
        check = false;
        transform.name = "Tile";

    }

    void OnCollisionEnter2D (Collision2D col)
    {
        Debug.Log (col.gameObject.tag);
        if (col.gameObject.tag == "Player" && transform.name == "draging") {
            check = true;
        }
    }
}


texts:
I am working on a 2D game and I have created a simple sprite sheet. The sprite sheet represents a medkit. The size of the sprite sheet is 128x16 pixels with 8 different frames that animate the medkit bobbing up and down.

I have imported the sprite sheet into Unity as a Sprite with Sprite Mode set to multiple, Generate Mip Maps unchecked, Filter Mode set to Point, and Format set to Truecolor. I have sliced the sprite sheet using the Unity Sprite Editor and added the animation to my scene.

After doing so, I am able to see my sprite in my game. However I noticed that the animation of the sprite did not correspond to the sprite sheet. Some pixels seem to be distorted and tearing. I have searched online and couldn't find anyone with the issue I had. As you can see from the gif below, the top of the sprite is tearing.

Does anyone know what is causing this issue?

Gif of the issue:here

Sprite sheet used:


texts:
I am implementing an Entity System for my game. I am aiming for a larger procedurally generated world. The world will be filled by AI entities where "on screen" and "near screen" entities will be updated regularly, while the "far away" entities will only be updated sometimes.

My initial thought was to implement a message queue... which is filled during a loop and invoked after the loop, but before the next loop. Then I read this, in there there is an answer mentioning Blackboards(the one with 12 votes), but I haven't been able to find anything detailed on Blackboards.

The question is what exactly are they and what would I gain by using them when compared to message queue ?

My language of choice is CSharp.


texts: How do I quantize an image into an arbitrary bitdepth with dithering?

texts:
In the games I make, sometimes I need to balance the quality of the images I show with the amount of memory they consume. This is especially true for smartphones and other devices with very tight memory constraints.

Most of the time, images are saved in 24 or 32 bit formats, depending on whether or not there is an alpha channel, and graphic programs make use of the full 32 bits.

In order to reduce the memory used by some images, some times I have to reduce the memory they consume by loading them for example in 16 bits: 5 for red, 6 for green and 5 for blue. However, this process creates banding and other nasty artifacts, as the downsampling process is performed by fitting each pixel separately to the reduced palette.

I'm looking for a process to quantize an image to an arbitrary bitdepth, with dithering. In fact, I am a great fan of pngquant, which palettizes an image down to 256 colors, and applies dithering very intelligently to achieve some very impressive results. The problem is that the quantized colors are still 32 bits, and while this may reduce the size of the file, it won't reduce the amount of memory consumed once the image is loaded.

The tool I'm looking for should optimize on the decompressed size of the image, based on an arbitrary texture format, by reducing the amount of bits used by each pixel, and dithering where necessary to minimize the perceived detail and color loss. It doesn't really matter if the image is actually saved with 32 bits per pixel, as long as when it is loaded as a lower depth image, no further truncations occur. Optimally, this tool would also palettize the image, and minimize both file and uncompressed size.

In other words, how do I turn this image:

into, for example, this dithered R1G1B1 image?

Of course, I want to set the bitdepth myself. Notice that this is irrespective of the file format.


texts: How to update UI after changing text in a view

texts:
After applying a text change to a scrolling view, how do you get the new height of the text, resize other UI elements around the changed text length, etc?

Many have posted this question. Some have noted that the rect size doesn't change or that they have to wait multiple frames to then react to the UI updates.