texts:
There are quite a few questions on cal3d but they are old and don't apply anymore.

In Blender(must be 2.49a for python script to work!!!):

I have a scene with 7 meshes, 1 armature, 10 bones. I tried going to one mesh to simplify it but doesn't change anything. I found a small blend file that was used for cal3d and it exported just fine. So I tried to copy it's setup with no success.

EDIT*8/13/2012

In the last week here is what I have found so far.

I made the mesh in the newest blender(2.62?) and exported it to import it in the old one(2.49a). Did an animation in the old one because importing new blend files to old blenders, its just said it would lose keyframe data and all was good. And then you get the last problem of it not exporting meshes. BUT I found that meshes made in the old one export regardless. I can't find any that won't export. So if I used the old blender to remake my model I could get it to export :)

At this point I found a modified release of cal3d (because the most core model variable would not initiate as I made a really small test subject in old blender instead of remaking my big one which took 4 hours.) which fixes the morph objects and adds what cal3d left off with. Under their license they have to release the modification but it has no documentation so I have to figure it out on my own. Its mostly the same. But with this lib it came with a 3ds max exporter.

My question now is how do I transfer armature and mesh information from blender to 3ds max in order to export into cal3d format. Every time I try the models are see through and small and there are no bones. The formats I have tried to import are .3ds .obj(mesh only) and COLLADA. In all of them the mesh is invisible and no bones. It says the default texture is on so I should be able to see it. All the vertices are present I found a vertex highlighter so I can see those.

If any of this is confusing let me know so I can clear it up. Its late >.<=sleep.


texts:
For some reason, I can't move or remove an 'invisible' cube which is on my map.
I searched on Google to find a solution but somehow I still can't remove it.

The cube looks like this:
http://screencloud.net/v/uNyz

In Brush Wireframe: http://screencloud.net/v/3C0c

In Wireframe: screencloud.net/v/oGBj

As you can see, I want to delete the brown cube. Selecting it and pressing the DEL button won't do anything.

So, how do you delete the brown cube?

EDIT:
Seriously, I wrote this post a few minutes ago and I found the solution. However, I still don't know how to delete the brown cube.


texts: Predicting trajectory of Box2D physics body using both: linear dumping and gravity

texts:
I would like to calculate position of physics body after some time because of predicting shots trajectory in my game.
I found some great answer here where Iter Ator provides equation to calculate actual velocity of body after time, provided time, starting velocity and linear dumping but no gravity. I was able to integrate this solution to get distance traveled in time equation. Problem is that this doesnt take gravity into account.
There is also this tutorial that has many information about predicting physics body trajectory but doesnt take linear dumping into account at all.
What I would love to have is combined single equation that covers both linear dumping AND gravity to predict Box2d physics body actual velocity/position but math is too hard for me :(.
Problem seems to be that physics body velocity is both accelerated by gravity and dumped at the same time.


texts: Scale one object to be cover multiple other objects

texts:
I have placed and aligned several objects next to each other. For the sake of understanding, lets just say I placed 10 cubes next to each other. I snapped them all together (Move->V->Click&Drag). The cubes look great so far. Now I want to make a plane in front of the cubes, that has exactly the width of the cubes altogether.

Now, I can place a new plane in front of the, no problem. I can snap a single edge to the cube on the most right, also no problem.

But now, how can I make the size exactly the same as all the cubes together? Sure, I could eyeball it from top view, an kind of make it about the same size, but chances are, it's a little bit too short or too long.

Isn't there a possibility to snap one edge, lock it, and snap another edge making the object scale automatically to the desired width?


texts:
I'm attempting to render terrain made out of a triangle mesh. The problem is that whenever I have a northwest -> southeast ramp in the terrain, I get this diamond pattern:

The issue is that at the top and bottom of the ramp, the terrain is more flat than at the middle, so if the ramp is aligned with the triangles, each triangle will have two light vertices (at the top and bottom), and one dark vertex (at the middle).
How can I fix this effect? Subdividing the mesh helps, but doesn't fix it completely.
Vertex shader:
uniform mat4 projection;
attribute vec3 position;
attribute vec3 normal;
attribute vec4 color;

varying vec3 f_position;
varying vec3 f_normal;
varying vec4 f_color;

void main(void) {
    gl_Position = projection * position;
    f_color = color;
    f_normal = normal;
    f_position = position;
}

Fragment shader:
varying vec3 f_position;
varying vec3 f_normal;
varying vec4 f_color;

uniform vec3 light_position;

void main(void) {
    float light = 0.5 + 0.5 * abs(dot(normalize(f_normal), normalize(light_position - f_position)));
    gl_FragColor = vec4(light, light, light, 1) * f_color;
}


texts:
I'm new in Create.js and I'm trying to make countdown progress bar.

I have this simple code:

var stage = new createjs.Stage("timerCanvas");

stage.canvas.width = document.getElementById('timerProgress').offsetWidth;
stage.canvas.height = document.getElementById('timerProgress').offsetHeight;

var square = new createjs.Shape();
square.graphics.beginFill('red').drawRect(0, 0, stage.canvas.width, stage.canvas.height);

stage.addChild(square);

createjs.Tween.get(square, { loop: false }).to({ scaleX: 0 }, 90000);

createjs.Ticker.timingMode = createjs.Ticker.RAF;
createjs.Ticker.addEventListener("tick", stage);

My canvas width is 1920px and height 5px.
My CPU average load is 20%, when this script runs...

I think it is high load, for such simple script. Am I right?
If I am, What I'm doing wrong?


texts: Isometric objects are mapped incorrect angle, but the map is fine. What am I missing?

texts:
I laid out my iso map and it's fine, but when I add my sprite actors they get located in the correct location but they are laying down not standing up. I tried rotating them on the z by 45 but then they moved to the wrong location.

Anyone have any idea what I'm doing wrong? looks like a steam roller ran over my object :-)

I'm going to try and upload pics.

https://picasaweb.google.com/114100917691803291674/20140120?authuser=0&feat=embedwebsite

**correct location,but the image is laying down...

**standing up, but wrong map position..


texts: unity rts on mobile : how can units find each other as simple as possible

texts:
Situation:

I have a grid of 100 by 100 tiles.
each tile has a list of units that are currently standing ontop of it.
in this grid 500 units of team 1 and 500 units of team 2 are randomly walking around.
while they are walking around they place themselves in the unitlist of each tile they are on.

problem:
Each unit has to check lets say a square of 6 by 6 tiles around the tile he is on, to check
if there is an enemy nearby.

my solution.
each unit checks on top of what tile he is and only when it changes tiles it will check the 36 tiles around its current tile and check all their unitlist to check for nearby enemies...

Question.

isn't there a better way to do this? Because when I need my units to have a bigger line of sight of lets say 15tiles it needs to check 1000units * 15tiles *15tiles = a gazillion...
Does there exist a very inexpensive way of using somekind of a basic circle collider in unity without the need for rigid bodies etc...?


texts: Unity2D: Automatic scaling of camera and sprites

texts:
I'm working on a point-and-click adventure game using Unity2D for mobile devices and possible PCs and I'm trying to wrap my head around supporting devices with different screen sizes and aspect ratios.

My background images are high quality and quite large (let's say 4096 x 3072), and I'm trying to scale them down to at least fit into the viewport. However, try as I may, the scaled image always seems to end up either too large for the viewport or much too small.

I'm using an ortographic camera that automatically adjusts its size based on the current screen size using the formula (Screen.height / 2f) / 100.

To scale down my Sprites, I'm using the following code:

float scaleY = background.renderer.bounds.size.y / Globals.camera.rect.height;
float inverseY = 1/scaleY;

background.transform.localScale = new Vector3 (inverseY , inverseY);

This results in a background that is way too small to work with. Removing the inverse only serves to make the background massive.

Help?


texts:
I am working on a project where I have to approximately simulate the ocean waves. Currently, I am using a mesh modification approach. I am able to simulate low amplitude waves using the following equation:

yVal = Mathf.Sin(180 * Mathf.Deg2Rad / freqUpdated + Time.time * speedOFWave) * halfWaveHeight;

Now, I want to extend this equation to simulate breaking waves for a high value of "wave height".

Approach tried:

I tried creating code similar to this plugin but the smooth transition between low amplitude waves to these breaking waves is not possible with that approach.

I have the following questions:

What kind of modification can be done to the above sin wave equation to simulate breaking waves?
Are there any other mathematical techniques that can simulate low amplitude and breaking waves?
Is it feasible to do this type of ocean simulation using water particles?

I would appreciate any suggestions and thoughts on this topic. Thank you.


texts:
im new to game development and i began with phaser which seems to be a great framework but i can't understand it's documention very well.
Lets talk about phaser groups docs examples

How you understand how to use groups based on the documention ? Examples are clearer but limited they dont cover everything.

PS: valueerror answered this question in html5gamedevs

link to answer


texts: How can the board fit the screen perfectly in Unity's 2D Roguelike tutorial?

texts: I follow the tutorial 2D Roguelike tutorial. I want to understand how happen that 10x10 board of 32x32 sprites covers screen perfectly? Like what does this depend on?


texts: Implementig State-driven agents in an Entity-Component-System

texts:
A state-driven agent is an agent that performs an action based on its current state. The logic can be implemented through the use of a D-FSM that changes state depending on the Agent's "perception" and "stimuli" and perform actions on entering, being in, and exiting a state.

I'm trying to implement this type of design in a Entity-Component-System (ECS) architecture.

My first thought was to implement an "FSM" component containing a current_state and a rulebook, a System that updates the FSM component current_state depending on its rulebook and a System that implements the actions of an Entity ( and modify its components accordingly ) depending on the state of the FSM component.

I'm not sure this is a correct ECS implementation and that it can cleanly represent the enter_state/exit_state -> perform an action behaviour.

So, how should SDA be implemented in a ECS architecture?


texts: Unity2D - collide with objects while moving to a position

texts:
How do I get my character to collide with other objects while moving to a position?

All I've managed to do is change the position, it only collides if the character is not moving, it's like he is moving behind.

void Update () {

    foreach(Touch touch in Input.touches)
    {

        if (touch.phase == TouchPhase.Began)
        {
            worldCoordinates = Camera.main.ScreenToWorldPoint(touch.position);
            posi.x = worldCoordinates.x;
            posi.y = worldCoordinates.y;
            //transform.position = Vector3.MoveTowards(transform.position, posi, speed);
            //transform.Translate(0,32.4,0);
            //rb.MovePosition(posi);
        }
    }
}


texts: Rotation of bitmap using a frame by frame animation

texts:
I have one large bitmap that has four frames drawn on it and I only draw one at a time by looping through the bitmap by increments to animate walking. I can get the bitmap to rotate correctly when it is not moving but once the animation starts it starts to cut off alot of the image and sometimes becomes very fuzzy.  I have tried

public void draw(Canvas canvas,int pointerX, int pointerY) {
    Matrix m;

    if (setRotation){
    //  canvas.save();
    m = new Matrix();
    m.reset();

    // spriteWidth and spriteHeight are for just the current frame showed
    m.setTranslate(spriteWidth / 2, spriteHeight / 2);

    //get and set rotation for ninja based off of joystick
    m.preRotate((float) GameControls.getRotation());

    //create the rotated bitmap
    flipedSprite = Bitmap.createBitmap(bitmap , 0, 0,bitmap.getWidth(),bitmap.getHeight() , m, true);
    //set new bitmap to rotated ninja
    setBitmap(flipedSprite);    //  canvas.restore();
    Log.d("Ninja View", "angle of rotation= " +(float) GameControls.getRotation());
    setRotation = false;
}

And then the Draw Method here

// create the destination rectangle for the ninjas current animation frame
// pointerX and pointerY are from the joystick moving the ninja around
destRect = new Rect(pointerX, pointerY, pointerX + spriteWidth, pointerY + spriteHeight);

canvas.drawBitmap(bitmap, getSourceRect(), destRect, null);

The animation is four frames long and gets incremented by 66 (the size of one of the frames on the bitmap) for every frame and then back to 0 at the end of the loop.


texts: SDL2.0.5 - SDL_KEYDOWN shows two identicle presses when only one key is pressed

texts:
SDL2.0.4 using this code:

SDL_Keycode key = 0;

while(SDL_PollEvent(&(Global->event)) != 0)
{
    if(Global->event.type == SDL_QUIT)
    {
        /* Allow users to exit the game */
        break;
    }
    else if(Global->event.type == SDL_KEYDOWN)
    {
        /* Actual Keypresses */
        key = Global->event.key.keysym.sym;

        if(key == getSDLKValue("p-key"))
        {
            /* ... p key is pressed */
        }
        else if(key == getSDLKValue("q-key"))
        {
            /* ... q key is pressed*/
        }
    }
}

Works fine to get a single p key press when the key is pressed down. However, when manually compiling, and using 2.0.5 logging shows that a single key press has:

Key pressed: 112
Key pressed: 112

It gets pressed twice in the window, when only once in reality.

Is this a bug with SDL2.0.5? Running on Ubuntu 16.04, manually compiled SDL2.0.5.


texts: How to draw many identical quads in WebGL efficiently?

texts:
I have recently been trying to develop a more basic one of those 'falling sand'/'powder game' style games (See here) the past few months, and after prototyping on a plain canvas, then trying PIXI.js, I decided to try and roll my own WebGL based solution so I could control the whole pipeline.

Currently I am just iterating over a 2D array representing the pixels of the canvas (500x500) then calling glDrawElements to draw a pixel sized quad at a specified location. Obviously things get pretty heavy pretty quickly in a game like this, and the frame rate drops to unusable very quickly.

I can't find examples online of drawing batches of quads in different locations with one DrawElements call in OpenGLES/WebGl, as there is no instancing support, but people seem to mention having done it. Can anyone give any pointers?

Here is my extremely simple vertex shader:

attribute vec2 position;

uniform mat3 modelViewProjectionMatrix;

void main() {
    gl_Position = vec4(modelViewProjectionMatrix * vec3(position, 1.0), 1.0);
}

And here is my relevant rendering code Javascript side:

this.setSandBuffers();
material = this.materials.sand;
this.gl.vertexAttribPointer(this.positionAttribute, 2, this.gl.FLOAT, false, 0, 0);
this.gl.uniform4fv(this.uColor, material.uColor);

for (var x = 0; x < this.grid.length; x++) {
    for (var y = 0; y < this.grid[x].length; y++) {
        var cell = this.grid[x][y];

        switch(cell) {
            case 0:
                break;
            case 1:

                this.mvTranslate(x, y);

                mvpMatrix = matrixMultiply(this.modelViewMatrix, this.projectionMatrix);

                this.gl.uniformMatrix3fv(this.uModelViewProjectionMatrix, false, mvpMatrix);

                this.gl.drawElements(this.gl.TRIANGLE_STRIP, 4, this.gl.UNSIGNED_SHORT, 0);

                break;
            default:
                break;
        }
    }
}

Any other relevant code is here.

Thanks


texts: When using IK the player head is looking at down the ground instead looking at the object target up what can be the problem?

texts:
This script is attached to the player :
using UnityEngine;
using System;
using System.Collections;

[RequireComponent(typeof(Animator))]

public class CharController : MonoBehaviour
{

    protected Animator animator;
    public bool ikActive = false;
    public Transform lookObj = null;
    public float lookWeight = 2f;

    void Start()
    {
        animator = GetComponent<Animator>();
    }

    //a callback for calculating IK
    void OnAnimatorIK()
    {

        if (animator)
        {

            //if the IK is active, set the position and rotation directly to the goal.
            if (ikActive)
            {
                // Set the look target position, if one has been assigned
                if (lookObj != null)
                {
                    animator.SetLookAtWeight(lookWeight);
                    animator.SetLookAtPosition(lookObj.position);
                }

            }

            //if the IK is not active, set the position and rotation of the hand and head back to the original position
            else
            {
                animator.SetLookAtWeight(0);
            }
        }
    }
}

When the lookObj is a sphere or a cube it's working fine but if the lookObj for example is a big spacecraft now the player head will look to the ground down and not to the spacecraft up :

The problem is that the center of the spacecraft is at the bottom this is a screenshot when it's showing the spacecraft at regular when it's in Pivot mode :

Now when I click on the Center button now the center of the object is at the bottom :

Is there any way to fix it maybe eve fix it ?


texts: Mobile game monetization idea - pay to remove ads?

texts: Has anyone tried a free app/game with Apple's iAds with an in-app-purchase to remove the ads?  Just wondering if this works.  A friend mentioned that some apps do this... is this a common and/or "user-friendly" monetization method?  Assume the ads are "tastefully" on the home screen and not in the actual game itself.


texts: Is it possible to make a text based game and filter bad stuff?

texts: I was thinking of a text based game where the users type in various "things."  But I know it will quickly degenerate into filth.  Is there any way to stop something like this?


texts: Blender to Unity weight painting doesn't carry over nicely

texts:
How to get Blender weight painting to work smoothly in Unity?
Here's my workflow:
-Do weight painting in Blender.
-Do animations in Blender.
-Export FBX.
-Import in Unity
-Set avatar to humanoid(bones are a perfect match)
But the animation doesn't play as smoothly as in Blender and deformations do not stretch correctly.
In Unity:

In Blender:

The animations work correctly overall, just doesn't in some parts such as the knee.
Update: Steps to re-create problem

Create an armature in Blender, extrude a second bone(forming a joint).
Create two cylinder meshes as "arm" and "elbow", place them to form an jointed appandage(a full arm).
Join meshes into a single mesh.
Place mesh to cover the armature.
Parent mesh to armature(Auto-weight to ease steps, do manual vertex grouping if not)
Weight paint the mesh to have a smooth human-like joint
In pose mode bend the joint as if bending an arm(make a simple animation, just one keyframe will do).
Export armature and mesh as FBX.
DragNDrop FBX to Unity
Set animation type (humanoid if you made the whole model, generic if not)
Problem can be viewed in Animation tab.

Unity Version: 2019.2.6f1
Arm in Blender:
https://youtu.be/T5UAJz2NP0E
Arm in Unity:
https://youtu.be/rbGk0Hdpyh4
Test File:
https://pasteall.org/blend/38a8b86904ea4fb2b984f523b70bc0f2


texts:
I am doing tutorials to learn Cocos2d and have a question. here is the .m code:

#import "SceneManager.h"

@interface SceneManager ()
   +(void) go: (CCLayer *) layer;
   +(CCScene *) wrap: (CCLayer *) layer;
@end

@implementation SceneManager

    +(void) goPlay {
        CCLayer *layer = [PlayLayer node];
        [SceneManager go: layer];
}

+(void) go: (CCLayer *) layer {
    CCDirector *director = [CCDirector sharedDirector];
    CCScene *newScene = [SceneManager wrap:layer];

//    Class transition = nextTransition();

    if ([director runningScene]) {
         [director replaceScene:newScene];
}else {
    [director runWithScene:newScene];
}
}

+(CCScene *)wrap: (CCLayer *) layer {
    CCScene *newScene = [CCScene node];
    [newScene addChild: layer];
    return newScene;
}

@end

My question is why is there an @interface placed in the .m file and not included in the .h file?


texts:
When implementing a max-texture-detail functionality for a game, which approach is better to use, out of:

Setting the D3D11_SAMPLER_DESC::MipLODBias value of a sampler state object, or,
Setting the min resource LOD of each texture resource with ID3D11DeviceContext::SetResourceMinLOD()?

I'm thinking it's probably the second option, because using SetResourceMinLOD() means that only the relevant subresource will be uploaded to the video memory, correct?

If that is the case, I assume that setting SetResourceMinLOD() will cause Direct3D to remove unused detail levels from video memory (if necessary) if they're already on there?

Thank you


texts: MouseLook Script "Pops" back to the last value when the script is enabled after being disabled or destroyed

texts:
I am trying to get a problem with a MouseLook script that controls my camera and a LookatGameObject script that also controls my camera when I want to force the player to look in a certain direction under control, but still no luck. I have identified where the issue is - Line 43, transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0); is the the method that sets the X Axis, makes it "POP" back to the last value when the script is enabled (I have even destroyed the component and then added the component when needed but the same result) can anyone see a solution for this?

The MouseLook Script:

 using UnityEngine;
 using System.Collections;

 [AddComponentMenu("Camera-Control/Mouse Look")]
 public class MouseLook : MonoBehaviour
 {

     public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
     public RotationAxes axes = RotationAxes.MouseXAndY;
     public float sensitivityX = 15F;
     public float sensitivityY = 15F;

     public float minimumX = -360F;
     public float maximumX = 360F;

     public float minimumY = -60F;
     public float maximumY = 60F;

     float rotationY = 0F;

     void Update()
     {
         if (axes == RotationAxes.MouseXAndY)
         {
             float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;

             rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
             rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);

             transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
         }
         else if (axes == RotationAxes.MouseX)
         {
             transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
         }
         else
         {
             rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
             rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);

             transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
         }
     }
  }

Here is my LookAtGameObjectScript:

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

 public class LookAtGameObject : MonoBehaviour
 {
     public Transform target;
     public float speed = 5f;

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

         Vector3 direction = target.position - transform.position;
         Quaternion rotation = Quaternion.LookRotation(direction);
         transform.rotation = Quaternion.Lerp(transform.rotation, rotation, speed * Time.deltaTime);
     }
     }

And And my method for turning off MouseLook and Turning on LookAtGameObject:

private IEnumerator LookAtGameObject()
     {

         GameObject.FindWithTag("MainCamera").GetComponent<MouseLook>().enabled = false;
         GameObject.FindWithTag("MainCamera").GetComponent<LookAtGameObject>().enabled = true;

         yield return new WaitForSeconds(8f);

         GameObject.FindWithTag("MainCamera").GetComponent<LookAtGameObject>().enabled = false;
         GameObject.FindWithTag("MainCamera").GetComponent<MouseLook>().enabled = true;

         yield return null;
     }


texts:
Is GML (Game Maker Language) script is clipped in C/C++ language, and GML wrote the code to Visual Studio C++, it will always be correct, because it is just under C++ language features?

I think that a bit wrong to have written that question could be to ask yet another generation of weeks. But if correct, is not need to ask again.


texts: Are there any web frameworks used primarily to produce games?

texts: Basically, the title says it all. I've seen and worked with Django, Rails and a bit with Cake PHP. I'd like to know if there is a framework that is excellent for supporting casual, 2d, browser based game development. The closest that I've seen is flash, but I'd like to find something open source. Something that could handle both the graphics and communication to a database would be ideal. Any suggestions?


texts: In OpenGL, how can I discover the depth range of a depth buffer?

texts: I am doing a GL multi-pass rendering app for iOS. The first pass renders to a depth buffer texture. The second pass uses the values in the depth buffer to control the application of a fragment shader. I want to rescale the values in the depth buffer to something useful but before I can do that I need to know the depth value range of the depth buffer values. How do I do this?


texts:
I was hoping someone could explain to me, or help me understand, the math behind rotations and origins.
I'm working on a little top down space sim and I can rotate my ship just how I want it.

Now, when I get my blasters going it'd be nice if they shared the same rotation.

Here's a picture.

and here's some code!

blast.X = ship.X+5;
blast.Y = ship.Y;
blast.RotationAngle = ship.RotationAngle;
blast.Origin = new Vector2(ship.Origin.X,ship.Origin.Y);

I add five so the sprite adds up when facing right.
I tried adding five to the blast origin but no go.

Any help is much appreciated


texts:
I have a number of five images (sprite1.png, sprite2.png, sprite3.png, sprite4.png, sprite5.png), these all I want to add as a sprite...

int rndSprtNum = (arc4random() % 5) + 1;
for(int i = 0; i < 5; i++)
{
    int rndSprtNum = (arc4random() % 5) + 1;
    CCSprite *first = CCSprite::create("sprite%d.png",rndSprtNum);

    rndSize = rndSize+(arc4random() % 20) + 15;
    int  width = rndSize + 125*(size.width/768);
    rndSize = rndSize + 90;
    first->setPosition(ccp(width,512 * (size.height/1024)));

    this->addChild(first,0);
}

Is this possible in cocos2dx v3.0?


texts: LibGDX Android Textures reload other textures, and transparent images get black backgrounds [Pictures]

texts:
I have very strange problems with my LibGDX Game in Android - The problem is that sometimes the textures get black backgrounds when they should be transparent, and sometimes when I remove the texture, or press the back button, the textures get replaced with other textures that I have.

To clarify:
I'm using x texture to show the status of health. I'm using three x textures to show how many lives the player got, and when I lose health, and remove one texture, the x texture get replaced with y or z texture, or the remaining x textures get black backgrounds. Sometimes it works flawlessly, and the x texture gets removed, and the backgrounds are still transparent.

I'm loading my textures via an AssetManager, and just load them on create().

In my render I use this:

    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    batch.enableBlending();

                  batch.begin();
                   for (Entity life : LifeEntities) {

                        life.render(batch);
                    }
                  batch.end();

I'm also using this in my Launcher Class.

 AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
 cfg.r = cfg.g = cfg.b = cfg.a = 8;

 MainGame myGame = new MainGame(arrayName);
 initialize(myGame, cfg);

I do dispose the textures also. I have looked up on google and on gamedev about this problem, but all the questions are for problems when the transparent always have black background, not when it is something that happens like a bug.

Any suggestions on where the problem could be? Thanks a lot, if you need more code, please let me know.

Pictures of the problem:


texts: Game states & passing data between scenes

texts:
I'm not entirely sure if I'm doing this right, but I always considered the scene system in Unity as some sort of state management (rather than e.g. a level system) which allows to group the contents (entities, components) into the usual main states of the game (menu, ingame), which can then be invoked or replaced together.

Now I have a very specific concern and I have no clue how to deal with that in Unity, mostly because of it's abstractions from code and other restrictions:

My game features a procedurally generate terrain where as I'd like to tweak the generator before actually launching it. The tweaking is done in some sort of 'pre-game' state (as part of the main menu) where the values are stored in e.g. TerrainData model class. Usually in other engines, I'd to it like this:

Providing an UI within the menu state to tweak the parameters of the game
Storing the parameters in a view model (and data model)
Instantiate the ingame state (which requires said data model in the .ctor
Pass the data model to a generator and start the generation

Now, here are the main problems:

Most types in unity (scenes, monobehaviors) do not allow constructors because they use it for themselves
It doesn't seem possible to instantiate scenes manually (there's only e.g. Application.LoadLevel("") which only takes the name of the scene, not a instance reference etc.
it doesn't seem possible to pass data between scenes, without reverting to awkward workarounds such as singletons, playerprefs, DontDestroy etc. which are all not really suitable for this case.

So, how can I properly solve this? Is there a better way to manage states rather than scenes? Prefabs maybe?

Backlink to UntityAnswers question: http://answers.unity3d.com/questions/1149480/game-state-management-and-passing-data-between-sce.html


texts:
I just started learning Zbrush.

While using Fibermesh, I notice that the "fiber" subtools are different from the normal ones. For example, they can be exported as curves, and BPR renders them differently.

However, when I try to merge two fiber subtools, they become a normal subtool, i.e. all fibers become normal polygons. I can no longer treat it as fibers, nor can I export it as curves.

Is there a way to merge multiple fiber subtools into one?

A related question might be: is there a way to import an obj file into Zbrush, so that it becomes a fiber subtool?


texts: Algorithm to fill a shape defined by 4 pixel points?

texts:
I'm developing an application in Unity3D where a user can define 4 pixel points on screen, and what I would like to do is fill this shape with pixels using Unity's SetPixel.

While I can do this easily for square or rectangular shapes, I was wondering if there is any efficient code or algorithm to do this for more irregular four-sided shapes, such as trapezoids etc.

Note : Filling the shape with a mesh is not an option.

So far the best option I can think of is to draw the outline, then draw a line from each pixel point of every outline, to every other outline point, but I'm not sure that's very efficient.


texts: How can I shoot when I touch the Box Collider

texts:
I want to change the Computer Input to Mobile Touch Input, if I press Space Button it shoots but how do I change this [Code] to Touch Input ?

I want it to have it into void OnTouchDown() but what do I have to put into the if(...) in the ShootingScript if I want to have it for Mobile to work ?

Here is my Shooting Script and my Player Controller Script

ShootingScript:

public GameObject shootingBullets;

// Update is called once per frame
void Update ()
{
    if (Input.GetKeyDown (KeyCode.Space))
    {
        Instantiate(shootingBullets, transform.position, Quaternion.identity);
    }
}

PlayerControllerScript:

public float jumpHeight;

void OnTouchDown()
{
    if (GameObject.FindGameObjectWithTag("Player").GetComponent<Rigidbody2D>().velocity.y < 0.001f && GameObject.FindGameObjectWithTag("Player").GetComponent<Rigidbody2D>().velocity.y > -0.001f)
    {
        GameObject.FindGameObjectWithTag("Player").GetComponent<Rigidbody2D>().AddForce(Vector2.up * jumpHeight);
    }

}

// Update is called once per frame
void Update ()
{
    if (Input.GetKeyDown (KeyCode.UpArrow) && GetComponent<Rigidbody2D>().velocity.y < 0.001f && GetComponent<Rigidbody2D>().velocity.y > -0.001f)
    {
        GetComponent<Rigidbody2D>().AddForce(Vector2.up * jumpHeight);
    }

    if (Input.GetKeyDown (KeyCode.DownArrow))
    {
        GetComponent<Rigidbody2D>().AddForce(-Vector2.up * jumpHeight);
    }

}


texts:
I am having trouble creating a tutorial level for my game in Unity. The first problem is efficiency. I have a script below, which displays the dialogue. And I want to know the best way to create goals that the player can meet without excessive amounts of script.

using UnityEngine;
using System.Collections;
using System.IO;
using System;
using UnityEngine.UI;

public class TutorialSystem : MonoBehaviour
{
bool canSpeak = true;
protected StreamReader reader;
public Text Dialogue;
string sLine = " ";
public string SourceName;
string[] lines;
ArrayList arrText = new ArrayList();
int i = 0;

void Start()
{

    reader = new StreamReader("Assets/Resources/" + SourceName + ".txt");
    while(sLine != null)
    {
        sLine = reader.ReadLine();
        if(sLine != null)
        {
            arrText.Add(sLine);
        }
    }
    reader.Close();
    sLine = arrText[i].ToString();
    StartCoroutine(Typewrite(sLine));
    i++;
}

void Update()
{
    if(Input.GetButtonDown("Submit") && canSpeak)
    {
        sLine = arrText[i].ToString();
        StartCoroutine(Typewrite(sLine));
        i++;
    }
    if (Input.GetButtonDown("Submit") && !canSpeak && i == arrText.Count)
    {
        Dialogue.text = null;
    }

}

IEnumerator Typewrite(string message)
{
    canSpeak = false;
    Dialogue.text = null;
    foreach (char letter in message.ToCharArray())
    {
        Dialogue.text = Dialogue.text + letter;

        yield return new WaitForSeconds(0.01f);
    }
    canSpeak = true;
    if (i == arrText.Count)
    {
        canSpeak = false;
    }
}

}

The second problem is how to I make it expandable, currently the text reads a .txt file line by line. Does anyone have a suggestion on how I can change this to be used in situations such as character interaction or should I just make another script entirely for that?

Many thanks in advance.


texts: SDL-2.0 library not working with codeblocks-13.12-mingw-tdm

texts:
I started following lazyfoo's sdl 2.0 tutorials. This is the very first tutorial that explains how to set up SDL 2.0 with code::blocks - SDL 2.0 with code::blocks setup. I am doing exactly what it says but still getting this error:-

|121|fatal error: winapifamily.h: No such file or directory|
    ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

This is the code that I tried to run. I copied and pasted exactly as it is given in the source code for the tutorial :-

/*This source code copyrighted by Lazy Foo' Productions (2004-2015)
and may not be redistributed without written permission.*/

//Using SDL and standard IO
#include <SDL.h>
#include <stdio.h>

//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;

int main( int argc, char* args[] )
{
    //The window we'll be rendering to
    SDL_Window* window = NULL;

    //The surface contained by the window
    SDL_Surface* screenSurface = NULL;

    //Initialize SDL
    if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
    }
    else
    {
        //Create window
        window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
        if( window == NULL )
        {
            printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
        }
        else
        {
            //Get window surface
            screenSurface = SDL_GetWindowSurface( window );

            //Fill the surface white
            SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );

            //Update the surface
            SDL_UpdateWindowSurface( window );

            //Wait two seconds
            SDL_Delay( 2000 );
        }
    }

    //Destroy window
    SDL_DestroyWindow( window );

    //Quit SDL subsystems
    SDL_Quit();

    return 0;
}


texts: How to map interaction events to game actions

texts:
When I port between Desktop games and Mobile games, I find I always make a kludge out of the interaction events.

I typically end up hard-coding event handling for mobile, and event handling for the desktop in completely separate systems.

On mobile, I need to track multiple touches.

On desktop, I only have a single mouse pointer.

But on desktop, there is a concept of "hovering" above something with a mouse.
There is no such thing on mobile.
Or pressing a modifier key like SHIFT or CTRL while clicking a button or pressing a key.

I want to design an API that I can use on both mobile and desktop that is able to translate an interaction (by user) to an action in my game world.

Are there any design patterns that I can follow, or some abstract model I can use for this? How do people successfully marry the desktop and mobile port of a game?

So in the same code-base, maybe assign Alt+Left-Click to a certain game function, but on mobile have that done via a gesture.

On Desktop, I currently use SDL2's SDL_Event. On Apple, is use UIEvent, and on Android I use NDK's AInputEvent.


texts: Player prefs is not saving data with error Namespaces cannot be used as expressions.?

texts:
code:

var score:GameObject;
function OnCollisionEnter(){

PlayerPrefs.SetFloat("Score",score.GetComponent(Events).i);

}

Events is the script I assigned to gameObject score which contain the float variable i.

I am trying to access this var from another function.

But it give an error as-

'Events' is a namespace. Namespaces cannot be used as expressions.

when I give quotation mark in Events it does not give any error initially But when OnCollisionEnter is called it gives an error as-

Object reference not set to an instance of an object


texts: Too many neighbors when pathfinding in Sparse Voxel Octree

texts:
Imagine we have upto 9 or so layers (that is depth), and due to some big colliding platform in the level, one of the empty nodes close to the root have all much smaller nodes as neighbors at one of its faces. If my calculations are not wrong, in the worst case scenario the number of neighbors on a face would be equal to power(2, absolute(depthA - depthB) * 2). For example, power(2, absolute(8 - 2) * 2) = 4096 little neighbors in direction of only one of the faces of the bigger node.

I'm implementing a linear tree (just saving all location codes in a set). I know how to find neighbors. I have no idea how to deal with high number of neighbors in cases like this when running A*. Both, finding all neighbors and iterating over all of them would take too much time.

I have taken a look at the GDC "Getting of the NavMesh by Daniel Brewer", but their example for neighbors of different sizes was only for difference of 1, which would return only 4 neighbors per face.


texts:
Hey I've just learned about pointers recently and am wondering how I can use them in c# (I just learned about them in c++) in unity. I do have some questions though.

Pointers use low level programming to find positions of different values on the computer so does that mean that you can just access a the value of a variable from any script?
If so how do I just call upon a location of a variable with just its location  code?
Are there any discernible differences between pointers in C# and C++ that I should know?
How can I use pointers with the variable types in Unity (Vector3s, Transforms, GameObjects, etc...)?

There are so many more questions I probably should and would like to ask so if you have any additional info or sources.


texts: Client/Server networking for mobile games

texts:
I am currently considering the pros and cons of two different approaches for networking an Android game.

First, I will specify some details about the game and its requirements, and then I will explain the considered approaches.

The game is a mobile game currently being developed for Android (but may be a port to iPhone in the future). The game is being built on the Unity3D engine using the Android Basic license, which does not allow direct access to .NET sockets.

The core functionality of the game consists of basic matchmaking, and the gameplay during a match. Matches are turn based. When another player finalizes his/her turn, each other player will receive the update and will see it rendered. The client will collect the turn from the player and send it off to the server. Nothing too special here.

The first approach I am considering is a mixture of a REST service and Google's Cloud2Device Messaging. With this, the general flow would be:

Collect the turn from the user.
Send the turn to the server via an HTTP POST to a REST service.
The server processes the turn and saves the match state, assigning it an "event id."
The server uses Cloud2Device messaging to send a notification down to each client. The notification consists of an "event id."
Upon receiving the notification from the Google servers, the client will perform a GET to the game server's REST service asking for details for the respective event id.

Given this approach, the pros I see are:

REST services are easy to write (much of my experience is in REST services).
No custom socket work, as Google's service is used to notify clients.
Easy to implement within Unity's Android Basic license.
Cloud2Device Messaging allows an app to be "woken up" if it is not currently running (could be helpful in certain cases, I suppose).

The cons I see are:

Networking code is at the mercy of Google's service.
If Google delivers the "turn start" notification too late, a player may miss his/her turn.
Porting to the iPhone would require a heavy rework of network management.
Google likely will begin charging for Cloud2Device Messaging.

The alternative approach is to use a workaround to the lack of .NET socket support within Unity Android Basic. This would basically use Android's built-in socket support mixed with some custom-made Unity plugins to allow sending/receiving of network messages.

The general flow of this approach would be a straight-forward client/server socket approach, where each user playing the game has a connected socket.

The pros I see for this are:

All networking is handled by my services (not Google's).
Easier porting to other platforms (iPhone, iPad, etc.)
Potential to show more real-time player actions, rather than receiving all turn data after the turn has been committed.

The cons I see are:

Very little personal experience writing socket servers for games (this point scares me the most right now).
Debating whether this is necessary or not, as a turn-based game does not exactly need constant socket communication. A REST service may be all I need.
Constant socket communication may require an unnecessary amount of CPU or network data for a mobile device (or does having a socket open not require many resources expect when transmitting data?).

My observations and speculations aside, can anybody weigh in on this issue? I do not have much experience when it comes to game networking (especially for mobile) and would much appreciate advice on this issue. Let me know if more details are needed.

Thanks!


texts: Resolution problems when porting a Unity game to Android

texts:
So, I'm porting a game to the Android for the first time in Unity3D. And I've run in to a few problems along the way. My current problem is the resolution doesn't seem to be right, it cuts off the edges of the screen and my scrolling stops for scrolling the screen left/right are no longer in the right place.

After doing a bit of research, a lot of people say you need to make your game Resolution Independent to be able to run on all Androids/Iphone/Ipad. Is this true? If so, how do I go about doing that? If not, how can I help fix the resolution so when I port to mobile devices it looks right?

EDIT:
I still don't really have what I need, resolutions still aren't working properly even with the code and tricks listed below. I need some way for the resolution to adjust based on the device. For some reason when I try to retrieve the resolution of a device using Mungoid's code it returns 0x0


texts: Understanding the perspective projection matrix in OpenGL

texts:
Setting the Perspective projection matrix in Open GL (including OpenGL ES 2.0) has the following general format:

glm::mat4 perspective(float fovy, float aspect, float zNear, float zFar);

Notice the last two parameters; First one specifies zNear plane, which is the plane closer to the camera. The second one specifies zFar plane which is far from the camera.

It is common knowledge that, in OpenGL, things that are further, in other words "deeper into the screen", have negative Z axis. Why then all the OpenGL examples, that set perspective projection  matrix (taken from reliable sources like OpenGL SuperBible and simmilar) look like the two above mentioned parameters (zNear, zFar) of Perspective projection funcion are swapped?

This example is taken from GLM(OpenGL Math) webiste:

glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f);

You can see, that the zNear parameter is actually further from the camera, than zFar parameter, which is 100 points closer to the camera/viewer.

Can you provide easy to understand explanation, please? I it is not just one but all the examples, which pass zFar as higher positive value than zNear. Thanks.

My Example:

In my code, when I set:

glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 1000.0f, -500.0f);

I assume my frustum being 1000 points long in z-positive direction and 500 points long in z-negative direction.

When I set things like this, I can see at least some object, although things are not perfect: for some reasons I see only objects positioned on negative z coordinates.

This might relate to my incorrect understanding of the perspective projection function.


texts:
I'm working on coding enemy ai for a star fox-esqe shooter and I need the enemy to approach the player, stay a certain distance away and stay in front of them until destroyed. I can get the enemy to approach the player and I can get the enemy to stay a certain distance from the player but I'm not sure how to get the enemy to actually stay in front of the player. For a bit of extra information, the player makes a number of sharp turns and the like throughout the level. Also, as a stand in I tried simply causing the enemy to parent to the player within a certain radius but that causes clipping issues with buildings and the ground.

public class EnemyCar: MonoBehaviour
{
    public float safeDistance = 20f; // How close the enemy can get to the player

    // ...

    // Update is called once per frame
    void Update()
    {
        transform.LookAt(player.transform);

        Vector3 targertLocation = player.transform.position - transform.position;
        float distance = targertLocation.magnitude;

        // Decrease our speed as we get closer
        rb.AddRelativeForce(Vector3.forward * Mathf.Clamp((distance - 30) / 50, 0f, 1f) * thrust);
    }
}


texts: Setting a uniform float in a fragment shader results in strange values, is this a type conversion? How can it be fixed?

texts:
First, some details:

I'm learning OpenGL from the tutorials on https://open.gl
My computer is running Linux Mint 18.1 Xfce 64-bit
My graphics card is a GeForce GTX 960M
OpenGL Version: 4.5.0 NVIDIA 375.66
GLSL Version: 4.50 NVIDIA
Graphics Card Driver: nvidia-375 Version: 375.66-0ubuntu0.16.04.1
CPU: Intel Core i7 6700HQ
The code I'm working on can be found here: https://github.com/Faison/sdl2-learning/blob/8a61032d20edf91cfa60f665e1bb4d72e58f634b/phase-01-initial-setup/main.c (Makefile is located in the same directory)

In a fragment shader, I'm trying to make an image do a sort of "flipping mirroring" animation (lines 44-57):

#version 450 core
in vec3 Color
in vec2 Texcoord;
out vec4 outColor;
uniform sampler2D tex;
uniform float factor;
void main() {
 if (Texcoord.y < factor) {
    outColor = texture(tex, Texcoord) * vec4(Color, 1.0);
  } else {
    outColor = texture(tex, vec2(Texcoord.x, 1.0 - Texcoord.y));
  }
}

When factor is 1, the image should be right-side up and has some color on it.
When factor is 0, the image should be upside down and has no color added to it.
When factor is 0.5, the top half should be right-side up and the bottom half should be upside down.

Currently, that is only the case if I replace factor with the number.

When I set the uniform factor with glUniform1f(), I'm getting very strange results. To illistrate, I added some debug code to lines 188-197 that sets the uniform with one number, retrieves the number from the uniform, and outputs both values to try and see what's going on.

Here's the code:

GLfloat factorToSet = 1.0f;
GLfloat setFactor = 0.0f;
GLint uniFactor = glGetUniformLocation(shader_program, "factor");

while (factorToSet > -0.1f) {
  glUniform1f(uniFactor, factorToSet);
  glGetUniformfv(shader_program, uniFactor, &setFactor);
  printf("Factor of %.1f becomes %f\n", factorToSet, setFactor);
  factorToSet -= 0.1;
}

And here are the results:

Factor of 1.0 becomes 0.000000
Factor of 0.9 becomes -2.000000
Factor of 0.8 becomes -0.000000
Factor of 0.7 becomes 2.000000
Factor of 0.6 becomes 0.000000
Factor of 0.5 becomes -0.000000
Factor of 0.4 becomes 2.000000
Factor of 0.3 becomes -36893488147419103232.000000
Factor of 0.2 becomes 0.000000
Factor of 0.1 becomes 36893488147419103232.000000
Factor of -0.0 becomes -0.000000

So with what little I understand about OpenGL and the way scalar types are stored in binary, I'm thinking that this issue is caused my GLfloat getting converted into something else on the way to the shader's uniform float. But I'm grasping at straws.

What could be causing this strange conversion between the number I send to the uniform float and the value that the uniform float becomes? What could I do to fix it if it's possible to fix?

Thanks in advanced for any help and leads, I really appreciate it :)

An additional note after receiving a working answer

George Hanna provided a link to a post where someone had a similar issue. I read over the comments and someone said to use -DGL_GLEXT_PROTOTYPES as a CFLAG. So I rolled back my local code to use glUniform1f() again, added -DGL_GLEXT_PROTOTYPES to the Makefile, and everything worked! Even crazier, all the compiler warnings I had for implicit declarations of OpenGL functions were gone!

So in addition to the answer below, if you have this issue, try adding -DGL_GLEXT_PROTOTYPES to your CFLAGS.

(You can also get this affect by adding #define GL_GLEXT_PROTOTYPES before any OpenGL #includes)


texts: Rotate Sprite in direction it is moving while beeing dragged

texts:
I am working on a 2D topdown game where you have cars you can drag around. you can touch any given car and move it around.
This kind of works but when I drag a curve the sprit of the car does not turn in direction
of its movement but rather moves sideways.
I need a way to rotate the sprite towards input (touch,mouse) and be updated as long as the input "is down" but I am unsure how to calculate and update the angle each frame.
I do not want to use velocity towards the input but rather drag and drop while "clicking" on the sprite.


texts:
Well im just a bit stuck wondering how to draw an item to a texture.

Edit:
Well unfortunately my graphics card doesn't support FrameBuffer Objects :/. So i've been trying to get the copy contents from backbuffer method working.

Edit:
So i've been trying now for the best part of a couple of hours to get this thing working. Unfortunately all i still get is a white square.

Here's my little testing code that i have set-up. What it should do is draw a red square at 100, 100. But even this isn't working for me :/.

glViewport(0 , 0, 512, 512);

glPushAttrib(GL_CURRENT_BIT);
glColor4ub(255, 0, 0, 255);
glBindTexture(GL_TEXTURE_2D, Texture);

glBegin(GL_QUADS);

// Top-left vertex (corner)
glTexCoord2i(0, 0);
glVertex2i(100, 100);

// Bottom-left vertex (corner)
glTexCoord2i(1, 0);
glVertex2i( 100 + 200, 100);

// Bottom-right vertex (corner)
glTexCoord2i(1, 1);
glVertex2i( 100 + 200, 100 + 200);

// Top-right vertex (corner)
glTexCoord2i(0, 1);
glVertex2i(100, 100 + 200);

glEnd();
glPopAttrib();
glLoadIdentity();

//Copy Our ViewPort To The Texture
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, 512, 512, 0);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
//Reset Viewport
glViewport(0, 0, 768, 480);

glBindTexture (GL_TEXTURE_2D, Texture);
glEnable(GL_TEXTURE_2D);

glBegin(GL_QUADS);

// Top-left vertex (corner)
glTexCoord2i(0, 0);
glVertex2i(0, 0);

// Bottom-left vertex (corner)
glTexCoord2i(1, 0);
glVertex2i( 0 + 512, 0);

// Bottom-right vertex (corner)
glTexCoord2i(1, 1);
glVertex2i( 0 + 512, 0 + 512);

// Top-right vertex (corner)
glTexCoord2i(0, 1);
glVertex2i(0, 0 + 512);

glEnd();
glDisable(GL_TEXTURE_2D);

Screenshot of the current output:

Any help is greatly appreciated!


texts:
I am developing a desktop application that want to load the 3D model from desktop. Using file explorer user wants to choose the 3d model then it want to show in the application scene.I tried to find the object, the path is detecting but if i tried to Instantiate it on unity it showing this error.

  ArgumentException: The Object you want to instantiate is null.

here the code is used

public class ReadData : MonoBehaviour {
string path;
GameObject go;
public void OpenExplorer(){
    path = EditorUtility.OpenFilePanel("Overright with model", "", "dae");
    Debug.Log(path);
    GetObj();
}

void GetObj()
{
    if(path!=null)
    {
        UpdateObject();
    }
}

void UpdateObject()
{
    WWW www = new WWW("file:///" + path);
    go = GameObject.Find(path);
    Instantiate(go);
}}

Anybody please help me to do this. Thanks in Advance.


texts: Should I target a mobile phone or simulation tools are good enough?

texts:
I'm starting mobile development, and I would want to know if it's necessary to target a specific smartphone, or nowadays one can run a simulation that will provide accurate data of how the game will perform on a given device.
If simulation tools are not good enough, what version of iPhone and what Android mobile should I target as of 2013, for making games like Angry Birds, Jetpack Joyride, etc? (2D games only) I would buy that smartphone and make my tests there.


texts: Triangle Line-Segment Intersection - detecting near misses

texts:
A ray is a very poor approximation of a player!  I think approximating a player with a sphere traveling a straight line each game tick will solve my problems of the player intersecting edges of scenery because their line segment missed it yet their own model is not infinitely thin...

I have a 3D triangle and a line segment.  I have the normal triangle-line-segment intersection code which I admit I have only a woolly grasp of.

To model movement and compute collisions of the player I have to determine if a line passes within sphere-radius of a triangle.  But I can find no convenient line near-miss intersection code!

I have made a little test app with classic triangle-intersection code: https://gist.github.com/3751097

The simple test code:

# barycentric coords
w = vec3_sub(hit,a)
uu = vec3_dot(u,u)
uv = vec3_dot(u,v)
uw = vec3_dot(u,w)
vv = vec3_dot(v,v)
vw = vec3_dot(v,w)
invDenom = 1.0 / (uu * vv - uv * uv)
U = (vv * uw - uv * vw) * invDenom
V = (uu * vw - uv * uw) * invDenom
W = U+V
# basic in-triangle test
A, B, C = U>=0.0, V>=0.0, W<1.0
if A and B and C:
    return GREEN
# near miss?
if U>-0.1 and B and C:
    return BLUE
if A and V>-0.1 and C:
    return YELLOW
if A and B and W<1.1:
    return CYAN
# far miss
return BLACK

generates this:

Clearly the threshold on the barycentric coordinates for a near-miss need scaling somehow by something and multiplying by the ray_radius.  Also the corners need special casing.

How can you determine if a line segment passes within some distance of a triangle?


texts:
I'm making a score system that will be based on several factors, how many collectibles you have obtained, how few hits you have taken, etc. I want to add in a multiplier based on how quickly the player manages to finish the game.

So far the only thing I've thought of is to have a maximum time, and to subtract the final time from that number. So as an example, say I set the maximum number to 300 seconds and somebody beat the game in 220 seconds, that would leave 80. This could be divided into a smaller number and then used as a multiplier on the total score.

It works but feels a little limited. What would be a better way to achieve this?


texts: What are the dangers of setting rigidbody velocity directly for movement and what are the alternatives

texts:
I'm playing around with Unity, trying to make a neat 3rd person platformer movement system using rigidbodies so that I may in the future implement things like pushing boxes/physics objects, grappling hooks, etc... as well as I'm not really knowledgeable in terms of math and physics to be able to code them from scratch using CharacterController
What I've done is I've implemented some basic movement by setting velocity directly
Vector2 input = GetInput();
bool hasInput = Mathf.Abs(input.x) > float.Epsilon || Mathf.Abs(input.y) > float.Epsilon;
bool isDashing = dashCounter > 0f;
if (hasInput && !isDashing)
{
    Vector3 direction = GetDirection(); // get camera direction scaled by forward & right vectors
    transform.localRotation = Quaternion.LookRotation(direction);

    UpdateTargetSpeed(input); // update target speed based on movement direction
    Vector3 movementVector = new Vector3(input.x * TargetSpeed, 0f, input.y * TargetSpeed); // add speed to input vector
    movementVector = transform.localRotation * movementVector; // rotate the vector to where the character is facing
    movementVector = Vector3.ClampMagnitude(movementVector, TargetSpeed); // clamp magnitude to avoid faster speed on diagonals

    body.velocity = new Vector3(movementVector.x, Velocity.y, movementVector.z);
}

And I'm also projecting velocity on ground normal for slopes so that the character doesn't fly off when moving down slopes
if (wasPreviouslyGrounded && !jumping && groundCheck.CanStick)
{
    float slopeAngle = Mathf.Abs(Vector3.Angle(groundCheck.StickyContactNormal, Vector3.up));
    if (slopeAngle < 85f)
    {
        body.velocity = Vector3.ProjectOnPlane(Velocity, groundCheck.StickyContactNormal);
    }
}

I have implemented jumping and dashing using AddForce
body.AddForce(0f, movementSettings.JumpForce, 0f, ForceMode.Impulse);

This all works okay but everywhere I looked people are always claiming that setting velocity directly is a bad practice and should be avoided. I've seen suggestions to use AddForce instead, but I haven't been able to get the same movement with it, no matter which force mode I used. I am also lost on how to control the amount of force I'm giving to the body during continuous movement. The thing I did is to check the magnitude of body's current velocity and if it's at or above the target speed then forgo applying the force but that just makes the body continuously accelerate and decelerate giving off jittery movement
if (body.velocity.sqrMagnitude < TargetSpeed * TargetSpeed)
{
    body.AddForce(force, ForceMode.VelocityChange);
}

Can anyone ELI5 me the answers to the following questions:

Why exactly is setting velocity directly a "bad practice"?
What is the preferred alternative?
How can I get snappy and responsive movement without setting the velocity directly?
How can I accomplish sticking to the ground when going down slopes without projecting and setting the velocity directly?


texts:
I'm using libGdx to create a simple platformer.

I used a set of images as an onScreen controller for Android, and use this code to fire a shot ->

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            downPressed = true;
            return true;
            //return super.touchDown(event, x, y, pointer, button);
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            downPressed = false;
            //super.touchUp(event, x, y, pointer, button);
        }

But when I keep the button pressed, the player continues to shoot which I don't want, I want the player to tap-to-shoot.

What am I doing wrong?


texts: What's the best program to learn/create 2d vector sprites?

texts:
I have Photoshop experience and a bit of drawing experience, and am looking to learn how to create sprites like this: http://www.lostgarden.com/2009/03/dancs-miraculously-flexible-game.html

Any tips on what app(s) to use and any reading material/online tutorials to get started?

Thanks!


texts: Unity C# - Modifying eulerAngles with slider issues

texts:
I'm using a slider to rotate an object on the z axis. The slider has a value of 1-360 (Whole Numbers); when the slider is moved, I use that value for the eulerAngles z axis value. (NOTE: The object is part of a child/parent 'string' of instantiated objects and it should only ever rotate on the local z axis). This method is working for some objects in the 'string', but not others. When it's not working, the object I'm trying to rotate spins wildly on the z axis because the objects z value is not a reflection of the slider value (I tested this in the inspector). I can't figure where these 'random' slider values are coming from.

Here is the rotation function I'm using for the sliders On Value Change event:

 public void SliderRotate () {
     Target.transform.eulerAngles = new Vector3(
         Target.transform.eulerAngles.x,
         Target.transform.eulerAngles.y,
         mySlider.GetComponent<Slider> ().value);
 }

BTW - If I change the x and y values to zero, the problem goes away. However, the objects then loose their correct orientation to their parent (I need the x and y to stay where they are).

Thanks in advance for any insight you can offer into this issue.

Windows - Unity 5.3.5f1

Here is an image that might help clarify:


texts: Missing textures after making a build in Unity

texts:
I am working with a 2D game, in Unity. I am able to see the texture, in the Unity editor, but after taking the desktop build the texture is not visible to the scene.

What could be the problem?


texts: Languages for creating 3d / 2.5d enviroments

texts:
I want to pick up a language that will allow me to create 2d/3d game environments. I come from web development using PHP, JS, XML and ideally I want to be able to integrate with those languages. I want to deploy to the web and to PC / Mac.

I'm considering Java, Actionscript 3, or some variant of C.

I'm pretty good at picking new languages up so that isn't a consideration.

I have briefly tried Java and ActionScript 3 and the problem is that I'm having difficulty seeing what the strengths of each language are (that is without learning the entire language anyway).

So if a few people could champion their tool of choice, what strengths/weaknesses it offers for game development (feel free to include commercial advantages!), that would certainly help me, it may help others too.


texts:
My friend and I are creating a Computer Tycoon game. We're using graphics cards and other real CPUs in the game. So can we use names like GeForce_210 in the game without issues?

Also, if the above doesn't work, can we just change a little bit in the name like LeForce and will that work?


texts:
I want to get started with XNA game development, and I have bought the Pro edition of Visual Studio 2010 so I have the required software to run XNA Game Studio.

How do I get it? Is it released yet?
Is it a free download on some Microsoft site?
Do I have to pay anything? Where?

Edit:
Is this it?


texts:
I am trying to expand my knowledge on gaming and programming and I was wondering what underlying skills people think they one should learn to be a great programmer, or developer. What are some important patterns or practices that you use frequently?

Thanks.


texts: I've been searching around the web to see if it is possible to submit a unity game onto the windows 8 store. All I have found so far are articles months old saying it is coming soon, can anyone give me an update if this is yet possible and how would i go about doing this?


texts: AI for Shogi, dealing with high branching factor due to drop rule

texts:
I'm writing a Shogi program with a computer player in Java from scratch as my undergradute
dissertation project. Due to the drop rule, when the computer player captures a few pieces, the branching factor increases a lot and the running time becomes infeasible. I haven't manage to find any research or information on drop reduction and my own selection is too slow and not "selective" enough (trying to remove drops that are not safe or not protected and don't have any use like defending or attacking). Does anyone know any heuristics that can be implemented with reasonable time complexity for selecting drops that are worth adding to the game tree ? Cheers.

So, like in (western) Chess a piece can be captured and when a piece is captured the capturing player holds on to it. Now this piece can be dropped on the board anywhere on a free tile in any of the next turns (instead of moving a piece from the board). There are a lot more rules to drops but they are irrelevant. Because of this rule, when a player makes a capture, instead of a decrease in the branching factor like in chess, an increase of the branching factor happens because of the large amount of possible drops that can be made on the next turn. This results in an average branching factor of 80 (much more than Chess which has a average branching factor of 35).


texts: How can I export the opacity of a mesh per keyframe?

texts:
I'd like to export opacity of mesh materials on a per-keyframe basis from 3DS Max using a script. How can I accomplish this?

(This is basically extension to my previous question.)


texts: How can I use a coroutine and GetAxis to rotate a game object?

texts:
For the sake of learning about coroutine, I want to convert the following to a cleaner Update that just calls a coroutine. How would I do that?

using UnityEngine;

public class Controller : MonoBehaviour
{
    public float speed = 5f;
    private float deltaX;

    void Start()
    {
        deltaX = transform.localEulerAngles.x;
    }
    void Update()
    {
        deltaX += Input.GetAxis("Vertical") * speed;
        deltaX = Mathf.Clamp(deltaX, -90f, 90f);
        transform.localEulerAngles = new Vector3(deltaX, transform.localEulerAngles.y, transform.localEulerAngles.z);
    }
}


texts: XNA + Windows Forms: How make them work together without making the trick of the custom GraphicsDeviceControl?

texts:
What I've found is a solution where you have to code a custom GraphicsDeviceControl to put inside the form (the well known tutorial from the APPHub), but that's not what I'm searching for.

I would like to say that before start to write my question here, I "googled" a lot and I saw some questions here, but I couldn't find what I'm looking for.

I would like to have the Draw/Update loops completly managed by XNAFrameWork (with XNA project and so), and not by a custom component.

I hope you understand what I asked.

Thanks in advance.

Edit

What's the most important thing for me and wasn't shown in the tutorial of APPHub is: where I have to put the input handling? That's one the problems that wasn't covered by the tutorial.


texts: I have a MapLayer with MapObjects and i want to know the ID of the MapObjects in this Layer, any idea how to get the ID?


texts: How to get a camera's frustum information?

texts:
I have a local coordinate system with three camera normalised directions, D, U and R.

I also have the following information:

camera_location
lookat_point
up_direction
distance_near_plane
distance_back_plane
fov
aspect_ratio

With this I'm trying to get the information regarding the camera's frustum, the coordinates of it's 8 vertices and the 6 planes that make it up. How do I do it?


texts: Algorithm for creating tree-like network structures

texts:
I'm trying to procedurally model tree-like network structures with the following properties:

A root with variable number of nodes
A variable depth of nodes
When graphically laid out, edges or nodes must never intersect or overlap

I don't have a background in maths or programming, so I am not sure that I am using the correct terminology. Maybe a picture would better explain what I am after:

I know my way around Ruby pretty well, so I think I should be able to implement a basic algorithm that generates these models. Any pointers or recommendations?


texts: Implementing recoil in a realistic and balanced way?

texts:
To clarify, I've seen this post already

I really like the idea that the chosen answer suggests, yet when I go to implement it the recoil still doesn't "feel" right. The problem is mainly the fact that I'm moving the crosshair instantly to a new location and it feels quite jerky when playing around with it. I think that in order to properly implement recoil I need to move the crosshair more than once over multiple game ticks.

I think the main issue is that many games with realistic recoil "auto re-aim" (if you will) the gun as part of the recoil algorithm. This is from my experiences with various Source Engine games like Garry's Mod and Counter Strike. My best way of describing what I see and thinking about how it is implemented is that a point is chosen with a variance (usually up and slightly right) from the fire coordinates. The gun follows a sort of parabolic path (height depending on velocity of recoil) and eventually gets to the new point.

I'm getting kind of long winded but I hope most of what I said makes sense. Should I attempt to model the recoil implementation in the Source Engine? How would you go about implementing a realistic recoil algorithm? Are there any open source fps game engines that may be able to provide some inspiration?


texts:
Is it possible to automatically detect walls in polygon soup?

Of course it's hard to strictly define what a wall is, my slightly vague definition would be:

A wall is a largest possible box (not necessarily axis-aligned) with its entire volume covered by subset of geometry in that polygon set.

Provided set of polygons may contain multiple walls, walls under specific low volume should be ignored, walls may overlap if it's easier for the algorithm,
subset of geometry used to construct a wall may have larger volume than the wall itself, but opposite is not allowed.


texts: What is best for 2D movement: velocity or AddForce?

texts:
So I have tried both Velocity and addForce but I'm not getting the result I was expecting which makes me wonder if I fully understand what they do.

Move script (test script 1)

void Update () {

    if(Input.GetKeyDown(KeyCode.Space)){
        rb.velocity = new Vector2(rb.velocity.x, jumpHeight);
    }

    if(Input.GetKeyDown(KeyCode.A)){
        rb.velocity = new Vector2(-moveSpeed, rb.velocity.y);
    }

    if (Input.GetKeyDown(KeyCode.D)){
        rb.velocity = new Vector2(moveSpeed, rb.velocity.y);
    }
}

Move2 script (test script 2)

void FixedUpdate() {
       float x = Input.GetAxis("Horizontal");
       float y = Input.GetAxis("Vertical");

       rbody.velocity = new Vector2(x*speed, y*speed);
  }

Both scripts are used independently.

Velocity when I press the key down (D or A) it stops after short time but addForce seems to do the same while that is set in FixedUpdate() or Update(), which is confusing as I thought it would keep it moving till the key was released? I have also found that if I press D it moves then stops but if I release D and press again and repeat the player does not move until I press a different move direction. Any ideas?


texts: Running code after after a few minutes of inactivity

texts:
I want to implement a logic that will execude after a while when no input was hapend. Like a screensaver that will get started after a few minutes of no mouse input.

Im using libGDX so I think I should use the Timer-Utilities. But this is a principal engine-agnostic question since Timer and Interval Classes exits for most languages and frameworks.

My first idea was to just start a countdown and than check everytime in my game loop if the input-variable has changed. If so I will reset the countdown. But this seems like a big overhead because I have to reset the whole timer in worst cases 60 times per second.

Is their a general pattern for that common problem?


texts: Animation for some reason doesn't trigger after death

texts:
So I am trying to trigger this explosion animation after this enemy dies, but for some reason the animation doesn't trigger. I've made sure that the explosion animation is linked to "Any State", and that the transition from any state to the explosion animation has the trigger "Death". Here is my script (only the important parts):

using UnityEngine;
using System.Collections;

public class Enemy : MonoBehaviour
{

    [System.Serializable]
    public class EnemyStats
    {
        public int maxHealth = 100;

        private int _curHealth;
        public int curHealth
        {
            get { return _curHealth; }
            set { _curHealth = Mathf.Clamp(value, 0, maxHealth); }
        }

        public void Init()
        {
            curHealth = maxHealth;
        }
        public int damage = 40;
    }

    public EnemyStats stats = new EnemyStats();

    private Animator anim;

    [Header("Optional: ")]
    [SerializeField]
    private StatusIndicator statusIndicator;

    void Awake()
    {
        anim = transform.GetComponent<Animator>();
    }

    public void DamageEnemy(int damage)
    {
        stats.curHealth -= damage;
        if (stats.curHealth <= 0)
        {
            GameMaster.KillEnemy(this);
            anim.SetTrigger("Death");
        }

        if (statusIndicator != null)
        {
            statusIndicator.SetHealth(stats.curHealth, stats.maxHealth);
        }
    }

    public void OnCollisionEnter2D(Collision2D _colInfo)
    {
        Player _player = _colInfo.collider.GetComponent<Player>();
        if (_player != null)
        {
            _player.DamagePlayer(stats.damage);
            DamageEnemy(999999999);
        }
    }
}


texts: How to calculate how much revenue a game will make?

texts:
Let's say I've made a game X.

Things we know about the game:

It's a board game
Game will run on PC, Macs, iOS and Android
Sold through Steam, App Store and Google Play store
Turn based
Has few to none competitors on the market
High-quality art
Peer reviews and impressions (100 paid impressions) rate this game as 84/100.
Game is available in 10 world most used languages.
Game will be advertised through Twitter, Facebook and through bought impressions.

How can I estimate the money the game will make? What it takes for a developer to make an educated guess?

To be clear, I'm not asking anyone to calculate the revenue, rather - how to calculate it myself, what data to look for etc.


texts: Problem with 2D game on android. Random FPS drop with OpenGLES 2.0, sudden white screen with Vulkan

texts:
I'm having a problem with my 2D game on Android.

When I use OpenGLES 2.0 as the graphics API, I experience sudden FPS drops in the game. The game starts to slow down sometimes randomly, And it can drop down to 25 FPS sometimes (from 60). I tried debugging it, and nothing special was consuming CPU time or anything.

it was only GFX.Waitforpresent.

To fix this, I tried using Vulkan as the first Graphics API, and the other two OpenGLES APIs next. The problem of FPS drop is gone! never slows down again on my device.

But I had two other problems.

The first is the screen suddenly turn all white. This is again random! can't reproducde it easily. But it does happen. And when this happens sound can be heard and it's obvious the game is running, and it's just not rendering properly.

The other problem is game won't start on an old device a friend tested it on.

I've been testing this on my Huawei P10 Lite device with Android 8.


texts: What is the difference between Vector2.Transform and this method?

texts:
I've been working on some steering behaviors and ran into trouble with my logic for converting points in world space into points in local space. I had this (it's not optimized for multiple points yet, but that is not the point of my question):

public Vector2 WorldPointToLocal(Vector2 point)
{
    var tx = -Vector2.Dot(this.Location, this.Heading);
    var ty = -Vector2.Dot(this.Location, this.HeadingPerpendicular);
    var rotationMatrix = new Matrix
    {
        M11 = this.Heading.X,
        M12 = this.HeadingPerpendicular.X,
        M21 = this.Heading.Y,
        M22 = this.HeadingPerpendicular.Y,
        M31 = tx,
        M32 = ty
    };

    return Vector2.Transform(point, rotationMatrix);
}

This did not work. The returned point was always well outside the expected range. I had collated most of the mathematics from various sources and began to suspect that Vector2.Transform wasn't doing what I thought it was supposed to do. I found an alternative implementation in C and translated it into C#:

private Vector2 VectorTransform(Vector2 vector, Matrix matrix)
{
    var tempX = (matrix.M11 * vector.X) + (matrix.M21 * vector.Y) + matrix.M31;
    var tempY = (matrix.M12 * vector.X) + (matrix.M22 * vector.Y) + matrix.M32;

    return new Vector2(tempX, tempY);
}

When I used this implementation instead of Vector2.Transform, everything worked perfectly.

However, I don't want to leave it at that. I'd like to understand why Vector2.Transform does not do the same thing, and whether there's anything I can do to leverage it instead of writing my own. The API documentation doesn't help at all and I'm a bit clueless when it comes to matrix mathematics.


texts:
So I want my game to draw to a specific "optimal" size and then be stretched to fit screens that are a different size. I'm using LibGDX and figured that I could just draw everything to a FrameBuffer and then resize that buffer to the appropriate size when drawing it to the actual display. However, my method does not work, it just results in a black screen with the top right quarter of the screen white.Intermediary is the FBO, interMatrix is a Matrix4 object, and camera is an OrthographicCamera.

    @Override
public void render()
{
    // update actors
    currentStage.act();

    //render to intermediary buffer
    batch.setProjectionMatrix(interMatrix);

    intermediary.begin();
    batch.begin();

    currentStage.draw();

    batch.flush();
    intermediary.end();

    //resize to actual width and height
    Sprite s = new Sprite(intermediary.getColorBufferTexture());
    s.flip(true, false);

    batch.setProjectionMatrix(camera.combined);

    batch.draw(s.getTexture(), 0, 0, width, height);

    batch.end();
}

These are the constructors for the above mentioned objects (GAME_WIDTH and HEIGHT are the "optimal" settings, width and height are the actual sizes, which are the same when running on desktop).
    intermediary = new FrameBuffer(Format.RGBA8888, GAME_WIDTH, GAME_HEIGHT, false);

    interMatrix = new Matrix4();
    camera = new OrthographicCamera(width, height);

    interMatrix.setToOrtho2D(0, 0, GAME_WIDTH, GAME_HEIGHT);

Is there a better way of doing this or is this a viable option and how do I fix what I have?

Edit
So I changed some things around and it mostly works. This is my code now:

        sv = new StretchViewport(GAME_WIDTH, GAME_HEIGHT);
    currentStage = new StageMainMenu(sv);
}

@Override
public void render()
{
    // update actors
    currentStage.act();

    //render
    currentStage.draw();
}

However this results in some peculiar behavior when changing the window size, that I can't explain. This is what happens:

There should only be one "Press me!" button. The top button of the two does not seem to be scaled correctly and also flickers, but it should not be showing up at all...


texts: Is there a turn-based strategy game that allows building AI from scratch?

texts:
I'm very interested in programming Artificial Intelligence for a turn-based game as a project. However, I'm looking for a (somewhat modern) game and can't really find one i'm interested in.

Particularly, i'm looking at the Civilization francise. I'd love to be able to program the AI of Civilization V for instance. However, as of now, you can only slightly modify the settings of the AI: http://forums.civfanatics.com/threads/artificial-unintelligence.536193/.

Is there any game, which has been released at least in the  last 10 years, that allows programming of the AI to (nearly) ground level?


texts: Switching a project written in Lua to a compiled language

texts:
I am experimenting with game development in Lua using the Love2D framework, and while it works fine, I am getting tired of using a dynamic scripting language. I would like to have better performance, misspellings caught at compile time, and the ability to create efficient data structures for things like 2D vectors.

I thought about some alternatives:

C++ should be very efficient, but it also would make me have to worry about low-level details like manual memory management, and compiling for different platforms.

Java is cross-platform, but as far as I know it does not support pass-by-value data structures, which I would really like. There are also the claims of it being large and slow, but I'm not sure how valid they are.

C# seems to have similar advantages and disadvantages to Java, plus it only officially supports Windows, which makes me hesitant since I mainly use Linux and would like my program to be cross-platform.

So, if my ideas about one of those languages is wrong, or you have other suggestions, I would be interested to find out.


texts: C++ - SFML - OpenGL - GLSL - smooth waving texture

texts:
I have this shaders:

Fragment:

uniform float time;
uniform sampler2D texture;

void main()
{
    float t = time;
    vec2 aux = gl_TexCoord[0].xy;

    // This would also make waving/deform the texture
    //aux.x = aux.x + (sin(aux.y * time *.5) * 0.05);

    gl_FragColor = texture2D(texture, aux);
}

Vertex:

uniform float time;

void main()
{
    vec4 vertex = gl_Vertex;
    vertex.x = vertex.x + sin(time - vertex.y * 20) / 10;
    vertex = gl_ModelViewMatrix * vertex;

    gl_Position = gl_ProjectionMatrix * vec4(vertex.x, vertex.y, vertex.z, vertex.w);
    gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
    gl_FrontColor = gl_Color;
}

I am used that shader on low resolution textures(I have for example a grass tile texture of 8x8 pixels) to create a 2D waving grass effect.
The problem is, that the shader effect is now very choppy because the texture resolution.
Now I am wonder me, is it not possible to let the shader make more steps and make that "animation" smoother ?


texts: How to efficiently spawn / instantiate a large amount of objects from a prefab

texts:
I am trying to make a game where the whole world is consists of a very large amount of cubes (sort of a Minecraft / Trove clone), but I keep running into huge performance issues due to the large amount of objects / vertices being rendered at once.

Just to clarify, the problem appears to be caused by the rendering, not the instantiation. I think so based on the fact that when I look away from the cubes, the frame rate will return back to normal (>60).

Is there any way to optimize this? Many answers to similar questions suggest disabling colliders, but that does not really seem to make much of a difference for me. I have also tried making the prefab static, but the problem still remains.

Currently I keep getting ~40 FPS with 10000 cubes (just the built-in cube shape stored as a static prefab with a disabled collider). I believe there should be a way to have a larger amount of objects on screen without having such a performance drop.

Does Unity have any way of storing information about a prefab in graphics card memory that would allow it to mass-render its instances in a more performance-efficient way (much like modern OpenGL uses vertex buffers)?


texts: Methods of procedural terrain generation that can work using DirectX 9 (SM2.0)?

texts:
I'm working on a simple game / fun project that I want to be largely procedurally generated. At first I started by using boxels (Similar to Minecraft, but not textured) for the terrain and it came out looking decent but I realized something.

I don't need, or really want, destructible terrain. Sure it'd be a nice little bonus, but no part of my game design calls for it, and using boxels requires a fair amount of data to be sent to the GPU, so I'm looking for alternatives and that's where I'm stuck...

What are some alternatives to boxels that can be used to generate terrain quickly, that looks good (Smooth terrain or otherwise), and can be rendered with XNA (Shader Model 2.0)? At first I thought that marching cubes could work, however apparently since XNA still uses DX9 - most of the work is done on the CPU. Then I looked into dual contouring, but I can't find much data on it and I'm afraid it suffers the same issues.

Right now height maps are looking halfway decent, however I don't want to abandon the idea of overhangs and whatnot completely, so... What else is there? I'd love to keep using voxels since they make procedural generation easy (And fun), but, and correct me if I'm wrong, XNA doesn't handle non-boxel rendering of them very well.

(Even if I'm wrong re: marching cubes, I'd still be interested in seeing worth-while alternatives that can run on low end machines using SM2)

Note: My highlighting of words is to help anyone who, like me, finds this after searching for methods of procedural terrain generation, and wants a quick list of what's available.

Edit: Still looking for an answer regarding different methods.


texts: Why can't I create an unordered access view of a R32G32B32_UINT buffer?

texts:
So I'm trying to create an unordered access view for a buffer having with three component elements, but it fails with this warning:

D3D11 ERROR: ID3D11Device::CreateUnorderedAccessView:
The format (0x7, R32G32B32_UINT) cannot be used with a Typed Unordered Access View.
[ STATE_CREATION ERROR #2097343: CREATEUNORDEREDACCESSVIEW_INVALIDFORMAT].

This is my code:

void test(ID3D11Device* dev_ctx) {
  D3D11_BUFFER_DESC buff_desc;
  memset(&buff_desc, 0, sizeof(buff_desc));

  buff_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS;
  buff_desc.ByteWidth = 1024 * 12;
  buff_desc.CPUAccessFlags = 0;
  buff_desc.MiscFlags = 0;
  buff_desc.StructureByteStride = 12;
  buff_desc.Usage = D3D11_USAGE_DEFAULT;

  ID3D11Buffer* buff_ptr = nullptr;
  dev_ctx->CreateBuffer(&buff_desc, nullptr, &buff_ptr);

  if (!buff_ptr)
    return;

  D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc;
  uav_desc.Format = DXGI_FORMAT_R32G32B32_UINT;
  uav_desc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
  uav_desc.Buffer.FirstElement = 0;
  uav_desc.Buffer.Flags = 0;
  uav_desc.Buffer.NumElements = 1024;

  ID3D11UnorderedAccessView* uav_ptr = nullptr;
  dev_ctx->CreateUnorderedAccessView(buff_ptr, &uav_desc, &uav_ptr);

  if (!uav_ptr)
    return;
  }

It fails for any resource with three components (R32G32B32_*), but it works
if the resource has 1/2/4 components. So what could be the problem?


texts: I used WebM video in my game but it's lagging. The audio is few secs delayed then video. Is there any way to load the video first then play so that the lagging doesn't occurs


texts: Calculating normal vector on a 2d pixelated map

texts:
I want to know an efficient way to get the normal of the surface of a 2d map. suppose an object hit the map, i want the object to bounce accordingly. The problem is, the "bounding box" of said object is several pixels in size and the map has many curves.

I thought about getting the pixels that collides with the object (don't ask me how) and calculating it's mean, and having the normal to be the line between said pixel and the center of the object

for those familiar with worms, I want to do the same when a grenade hits the map and bounces back

EDIT: I'm not looking for a 100% accurate formula, I want it to be efficient and believable enough


texts:
So i'm not quite sure exactly what "glow textures" are. For my implementation of a "lightning" effect, according to the comments on the article;
http://drilian.com/2009/02/25/lightning-bolts/

They guy uses "glow textures". To achieve the really cool effects on his beams. I'm trying to-do the same thing, except that i'm not 100% sure what a glow texture is, currently the texture i'm using produces this output *I'm also using a simple shader to adjust the color value the lightning is rendered at;
http://www.youtube.com/watch?v=dQNRYD8bJJo

Which isn't very good, it has the shape of the lightning but it doesn't have the sorta "flare" of it. This is a screenshot of my current texture that i'm using:
http://dl.dropbox.com/u/13874083/screenshots/screen120417-105326.png

So essentially what i'd like to ask is mainly what is a glow texture? And perhaps to see  an example of one would be really appreicated.

Edit:
Taking the advice of kaoD, i'm now rendering the using Additive Blending, I've also got the Max Blending working, yet, still the bolt's do not produce the required effect that i'd like. Here's another video of them in action with the current code;
http://www.youtube.com/watch?v=T0OEBobHqks

And here's specifically how i'm rendering them;

        spriteBatch.Begin(SpriteSortMode.Immediate, new BlendState
            {
                ColorSourceBlend = Blend.One,
                ColorDestinationBlend = Blend.One,
                ColorBlendFunction = BlendFunction.Max
            }, null, null, null, effect);

        //Set Brightness of The First Bolt
        effect.Parameters["brightness"].SetValue(firstBoltBrightness);

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

        //Set Brightness of the Seconded Bolt
        effect.Parameters["brightness"].SetValue(secondBoltBrightness);

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


texts: Box2D simulation running slower on lower FPS(even when the desired FPS is lower than the actual)

texts:
I´m playing around and trying to make myself an easy platformer using the Box2D physics, before that I was not using it and was using my own physics implementation(just simple movements with timestep). My gameloop architecture now works like this:

while (_isRunning) {

    //Processing input events
    processInput();

    update();

    //Rendering stuff
    startFPSCap();

    render();

    delayFPS();
}

The update function is consisting of updating a game world (normal update function without deltatime) - inside this I´m calling a Box2D step function, with desired timestep at 1/60(wanted to have simulation at 60 fps) and then I call my own timestep function to update entity components(so they can be updated also with timestep not just the physics).

void update()
{
    _physics->Step(1.0f / 60.0f, 6, 2);

    updateEntitiesWithOwnTimestep();
}

However when I tried to run it on slower FPS, the simulation slow downs (even when I capped the FPS to like 200 at the start, so running it at 100 fps is like a slowmotion). I thought that when I set the desired physics simulation for 60 fps it will be no problem when reducing the FPS, but it seems like I´m missing something. Or is there something wrong? I mean, maybe the fact I´m running also my own timestep function.. Thanks for help.

Edit1 - according to Timos answer

Do you mean I should put the delta value I pass to my update function during each step in my own timestep? Like this:

void TimestepManager::update() {

int i = 0;

while ((_totalDeltaTime>0.0f) && (i<MAX_PHYSICS_STEPS)) {

    _deltaTime = std::min(_totalDeltaTime, MAX_DELTA_TIME);

    //This is std::function - i can define my own behavior via this
    _f.exec(_deltaTime);

    _physics.Step(_deltaTime, 6, 2);

    _totalDeltaTime -= _deltaTime;

    i++;
}

}

Or should I pass the total deltaTime? Because I thought that I should keep this unchanged because I don´t want to tie the simulation with the FPS.


texts: separate fixed-size animation sheet into texture atlas

texts:
I'd like to separate a 64px x 512px spritesheet into eight 64px 64px images in Adobe photoshop cs 5 so I can use a Texture Packer image atlas rather than a fixed spritesheet.

Is this possible? If so, how?


texts: How can I fill a Polygon with a certain color on Pixmap?

texts:
Libgdx allows to fill area on a Pixmap just with circles, rectangles and triangles, but I need to fill complex figure that can be described with Polygon class, so how can I do that?

I was thinking about polygon triangulation, but it seems sophisticated to me.

May be exists some better way to fill complicated shapes with pixels?


texts: Can I include 64-bit DLLs in a Unity 5 project?

texts: I am building a C# DLL for inclusion in a Unity project. Due to some dependencies, this must be a 64-bit DLL. The last time I checked, DLLs for Unity had to be built with .NET Framework 3.5 (although this isn't explicitly stated in the DLL documentation). Are there any requirements for bitness?


texts: How to put labels at a specific point on any resolution

texts:
I am working on a project in Unity 4.6.1 and I put the label at the top:

But when I put the Scene in full view this happened:

I made a Development Build and when I select my resolution (1366x768) the label goes behind the buttons. Is there any way to put the label at a specific point no matter what resolution?


texts: Deleting faces or triangles from an object by material on load scene

texts:
I have objects that have multiple materials imported from blender as a .FBX.

I'd like to find the objects where materials are used, and destroy faces when a certain material name is used ("!null", in my case).

I know this is not the correct way to work. Normally I should delete the faces in Blender, but as I am building quite complex geometry using faces that I need in Blender but don't want the Unity engine to render, it seems the only way to go.

I tried "cutout", but although they are invisible, it does not make any difference in rendering times.

Is this at all possible? If it is, how do I do it?


texts:
I'm struggling a lot with reconstructing the world space position (or alternatively the view space position) from depth (by reading the depth buffer) in a performant way (in a full-screen post-process).

So far I've been using this approach:

vec3 calculate_world_position(vec2 texture_coordinate, float depth_from_depth_buffer)
{
    vec4 clip_space_position = vec4(texture_coordinate * 2.0 - vec2(1.0), 2.0 * depth_from_depth_buffer - 1.0, 1.0);

    //vec4 position = inverse_projection_matrix * clip_space_position; // Use this for view space
    vec4 position = inverse_view_projection_matrix * clip_space_position; // Use this for world space

    return(position.xyz / position.w);
}

While this works perfectly, it's really slow. What I'm looking for is an approach like this:

vec3 world_position = world_space_eye_position + view_direction * depth;

I have found a couple of results on google but most are based on DirectX and I didn't understand them and therefore I have failed to implement them.


texts: Box collider/rigid body eventually moves through static collider

texts:
I found this question, but I'm not sure if it applies to my problem.

I'm hacking together a Pong-style game, and my problem is with the walls (box collider, no rigid body) not completely stopping movement of the player paddle (box collider, yes rigid body.) Sufficiently fast mouse movement eventually moves the paddle through the wall. There is initial resistance, but I would expect Player Paddle to stop moving abruptly at the wall. How can I make this happen? I'm new to Unity/colliders/game dev.

My player paddle simply moves up and down (Z-axis) with up/down mouse movement:

public class MouseMovement : MonoBehaviour {
    public float speed = 10f;
    // Update is called once per frame
    void Update () {
        var translation = Input.GetAxis("Mouse Y") * speed;
        translation *= Time.deltaTime;
        transform.Translate(0, 0, translation);
    }
}

I exported an asset package that reproduces the problem. My problem objects are Player Paddle, Upper, and Lower https://www.dropbox.com/s/yx9svb51nywdvgg/pong-export.unitypackage?dl=0