texts:
I'm working on a simple selection of a RTS unit. Therefore I used a projector to display a circle on the ground around the unit.
But it happened, that the circle is only displayed on the head of the unit-placeholder, not on the ground.

At first I thought it has something to do with the terrain, but as I added a Plane there was'nt a change.

I followed the steps from this tutorial: http://hyunkell.com/blog/rts-style-unit-selection-in-unity-5/ (skipped the drag box part)

Here's a screenshot from the scene:

I'm wondering how I can solve this. I'll provide every information you'll need.


texts:
Does an engine using a vector field exist?

What I mean is that instead of calculating intersections, for example one could calculate the vector field generated by gravity and for the ground and let the object follow those fields.

What are the advantages and drawbacks of this kind of game engine?


texts: Why does the script stop working after respawning?

texts:
I have a flying enemy that follows the player:
public class MoveTowardsPlayer : MonoBehaviour
{
    public float moveSpeed, sightDistance;
    public Rigidbody2D theRB;
    public Transform target;
    private void Start()
    {
        theRB = GetComponent<Rigidbody2D>();
    }
    private void Update()
    {
        Vector3 targetDir = target.position - transform.position;
        targetDir = targetDir.normalized;
        float dist = Vector3.Distance(target.position, transform.position);
        if (dist < sightDistance)
            theRB.velocity = targetDir * moveSpeed;
    }

}

And here is what happens when the enemy dies, and then respawns:
  public void Die()
    {
        Instantiate(enemyDieEffect, transform.position, transform.rotation);
        gameObject.SetActive(false);
    }

    public void Respawn()
    {
        gameObject.transform.position = initialPosition;
        gameObject.SetActive(true);
        currentHealth = maxHealth;
    }

The enemy respawns if the player dies and goes back to the last checkpoint.
Interestingly, if the player dies before reaching any checkpoint, the MoveTowardsPlayer scripts still works after respawning. It only stops working after any of the checkpoints are reached.
For the sake of completeness, here is the Checkpoint script, which has absolutely nothing to do with the enemies:
public class Checkpoint : MonoBehaviour
{
    private Animator animator;
    public bool isReached;

    // Start is called before the first frame update
    void Start()
    {
        isReached = false;
        animator = GetComponent<Animator>();
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Player"))
        {
            CheckpointController.instance.DeactivateCheckpoints();
            animator.SetBool("isActive", true);
            CheckpointController.instance.SetSpawnPoint(transform.position);
        }
    }

    public void ResetCheckpoint()
    {
        animator.SetBool("isActive", false);
    }
}


texts: 2d Rectangle Collision Resolution: Find rollback point

texts:
I have a 2-part question:

1:
I have 2 rectangles, A and B. B is a wall and A is moving. My simple logic here is every time A moves, it moves based on some (x,y) offset and then checks if it collided with something. If it is colliding with something, roll back bit by bit in the opposite direction until it is not colliding anymore.

The problem here is if A moves in large chunks, it might skip over B entirely.

The intended behavior is to find out where A should be when it first touched one of B's faces and then roll back to that point and apply collision resolution.

2:
What if B is moving as well?

What I'm currently doing to side step this issue is to create large enough collision boxes and make sure moving objects do not exceed some maximum. This approach seems like it will be limiting in the future.

I assume there is a mathematical way to solve this but I wasn't able to find any answers from my searches. Any tips/suggestions are greatly appreciated.

Thanks!


texts: Exporting prefab includes a lot of unneccessary asset dependencies

texts:
I just exported one of my assets into a unitypackage.
It included all dependencies very nicely so I can use them.

Then I tried another prefab, but it included a lot of unrelated assets from all over the project. This is a very simple prefab and I don't know how the clutter is considered to be dependencies.

When I click "show dependencies" it brings up the clutter in the project menu. There should be no clutter dependencies whatsoever. It really isn't that complex of a prefab.

I also double checked the prefab elements to see if any of them are somehow using the said clutter, they aren't.

How can this happen? Is there a way to solve it (other than selective clicking in export menu)?


texts: How to temporarily increase the speed of a character in a Unity game

texts:
As the title would suggest, I want to give a character a speed boost for x amount of seconds, while increasing their Gameobject's mass. During this little speed boost, I also want to add a script to another player that disappears when the speed boost dies out I am new to C#, and Unity in general, any help would be appreciated.

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

public class PlayerAddMass : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Q))
        {
            rb = GetComponent<Rigidbody>();
            rb.mass = 10;
            rb = GetComponent<Rigidbody>();
            rb.speed = 5;
        }
    }
}

The code above was found on a unity website of some sorts, and I modified it to set the speed and mass numbers (I changed the 0s into a 10 and a 5) The errors I get are "rb does not exist in the current context" x 4


texts:
I am trying to code some swooping behavior for a flying enemy in my 2D platformer.

The ideal behavior has the enemy starting from an arbitrary height above the ground, then accelerating downward and horizontally until flush with the ground, after which he slows and comes to a rest.

I would like to code this in such a way that I can adjust a parameter controlling the steepness of the curve.

In other words, I want a kind of asymptotic movement, similar to this:

https://www.mathsisfun.com/algebra/asymptote.html

How can I code this kind of movement in such a way that my enemy can start from any height and smoothly and elegantly accelerates down this kind of curve before gracefully stopping?

I have recourse to all the usual stuff (for example, acceleration, velocity, friction, raycasts, etc.). I would prefer to code the movement using this stuff, rather than hardcoding movement along a curve or path.

I was thinking it might be possible to achieve what I want by raycasting downward and getting the enemy's distance from the ground, and using this distance to adjust accelerations and velocities, but I'm not exactly sure how to go about it.

I work in Godot, but would like an engine-neutral explanation of how to achieve this kind of behavior.


texts: How to put an invisible marker on a model and refer to it in the game?

texts: I am using XNA/C# to load up 3ds Max models exported in FBX format. Is there some way to mark a specific point in the model like the pipe of a gun so I can just refer to it and place a bullet in there directly to make shooting look good?


texts:
Question

I have a noise texture (perlin noise, to be precise) with its value in the alpha channel and the normal components in rgb.  I now wish to, on the fly, apply some function to the alpha part of the texture.  Is there an easy way to calculate the new normal?

My thoughts are that if we know the form of f, then

∂f/∂x = df/da * ∂a/∂x

Now, we want to know ∂f/∂x as from this we can calculate the x component of the normal, we know df/da as we know the form of f(a) and ∂a/∂x is encoded in the normal that we are given in the first place.

Context:

I am creating a procedural rock shader and want some "cracks".  To do this I need to take my lumpy perlin noise and apply some function to it.  At the moment the function is:

f(x) = 1 - 5.5 * abs(noise);

This makes it more sharp (noise runs from -1 to 1).

Here is the basic noise:

And here it is after my transformation:

Here are the normals for the first noise:

What are the normals for the second?  You may notice that the given normals are very "steep"  This is because the bump map they are computed from goes to +-1 several times per unit area.  I thus also need to know the answer to this question so that I can scale down the noise and keep the normals correct.


texts: I'm looking for a simple way to display minutes, seconds and milli seconds for timing the elapsed time in a game. Do I have to do the calculation myself with gameTime and display a variable for each part like a variable for minutes, secounds and milli seconds? Preciates some help! Thanks!


texts: Rotating Objects in OpenGL: glRotate or Quaternions?

texts:
I'm coding my first engine and I'm trying to have performance in mind since I'll probably use it for mobiles, and I have this question, should you use glRotate or Quaternions for rotating objects in the 3D space?

I have a set of classes that manage the information about all vertices and faces of the objects, and currently when I'm rendering I'm doing:

void DrawObject(Object* object)
{
    glTranslate(object->x, object->y, object->z);
    glRotate(object->rotationX, 1.0, 0.0, 0.0);
    glRotate(object->rotationY, 0.0, 1.0, 0.0);
    glRotate(object->rotationZ, 0.0, 0.0, 1.0);

    for(int i = 0; i < object->totalFaces; i++)
    {
        glVertex3f(object->faces[0]->x, object->faces[0]->y, object->faces[0]->z);
        glVertex3f(object->faces[1]->x, object->faces[1]->y, object->faces[1]->z);
        glVertex3f(object->faces[2]->x, object->faces[2]->y, object->faces[2]->z);
    }
}

From what I could understand, glRotate will make the graphics card to do the rotation calculation, while using Quaternions would make the processor do it.
But saying I have about 200 objects in a given scene, what is the best acceptable way of handling rotations?


texts:
i am trying to practice on loading data from json files my problem is about when i try to load the sprite path from the json file to load the image icon from the floder that contain it, i manged to do that but by hard code the path but when i try to use variable to hold the path its failed to load any one can help me in that please

i post the code here

public class InventoryItemDataBase : MonoBehaviour
{
    public allitemData itemsData = new allitemData();
    // Start is called before the first frame update
void Start()
{

    TextAsset asset = Resources.Load("ItemData/ItemDataBase") as TextAsset;
    itemsData = JsonUtility.FromJson<allitemData>(asset.text);

}
public ItemBase itembyid(int id)
{
    for (int i = 0; i < itemsData.ItemBase.Count; i++)
    {
        if (itemsData.ItemBase[i].id == id)
            return itemsData.ItemBase[i];
    }
    return null;
}
}

[System.Serializable]
public class allitemData
{
    public List<ItemBase> ItemBase = new List<ItemBase>();
}

[System.Serializable]
public class ItemBase
{
    public int id, Value;
    public string name, description;
    public static string path;
    public static Sprite Icon = Resources.Load<Sprite>(path);
    public Sprite sprite = Icon;
public ItemBase()
{
    this.id = -1;
}
}

&& json Data

{
  "ItemBase": [
    {
      "id": "0",
      "Value": "7",
      "name": "Teddy Bear",
      "description": "Teddy",
      "path": "IconS/Teddy/"
    },
    {
      "id": "1",
      "Value": "5",
      "name": "UFO",
      "description": "ufoos"
    }]
}


texts: How to delay jump to syncronize with an animation ?

texts:
I'm using Unity and First Person Controller.
If i press the jump button, my charachter jump immediately. I want,instead, that jump movement starts after (for instance) 1 second, to be syncronized with a jumping animation I trigger.

How to do that ?

Thanks


texts:
I am developing an Android native game, but I have problems with Data Storage.
For a better comprehension think it like as i am developing Clash of Clans, but with Native Andorid.

Now imagine I have to store all datas for Buildings, moneys, troups, ecc in my local phone DB.

I read some guides about SQLite for Android, but i don't really like it. It picks always a Cursor object and i have to create an "Helper" class for each table so I can convert the Cursor into the object I picked.

My question is: is there a way to do it in a "easier" way but still complete as SQLite?

I learned SugarORM and it is really simple and intuitive, but it has no possibilities for ID and a lot of other limitations.

I want a library or anything else that allows you to do like windows phone c#:

SQLiteConnection conn = new SQLiteConnection(DBPath);
return conn.Query<TABLE_NAME>(SQL_QUERY);
//in this way i have a list of TABLE_NAME items without any casting or similar.

Is there a way to do it?


texts: Doing an SNES Mode 7 (affine transform) effect in pygame

texts:
Is there such a thing as a short answer on how to do a Mode 7 / mario kart type effect in pygame?

I have googled extensively, all the docs I can come up with are dozens of pages in other languages (asm, c) with lots of strange-looking equations and such.

Ideally, I would like to find something explained more in English than in mathematical terms.

I can use PIL or pygame to manipulate the image/texture, or whatever else is necessary.

I would really like to achieve a mode 7 effect in pygame, but I seem close to my wit's end. Help would be greatly appreciated. Any and all resources or explanations you can provide would be fantastic, even if they're not as simple as I'd like them to be.

If I can figure it out, I'll write a definitive how to do mode 7 for newbies page.

edit: mode 7 doc: http://www.coranac.com/tonc/text/mode7.htm


texts: How can I determine a budget for RAM used (LRU involving VRAM, in particular)

texts:
After some profiling, I've determined that one of my most expensive functions involves drawing text. As a solution, I'd like to implement a LRU type of cache that will "remember" the vertices, tex coords (etc) for a given string. This is particularly complicated because some of the resources involved reside in VRAM (most do, actually; I take a given string and convert it into a long sequence of vertices / tex coords / indices), while some reside in plain RAM.

If I knew what my limits were (in both respects) I could write a decent LRU cache system and probably buy myself a substantial performance gain. The primary target for this app is the Android platform, and as I understand it, most such devices share RAM with the GPU.

I'd appreciate any answers to this, whether they directly answer my question or not.


texts: How to implement rotating rectangle around circle in libGDX Box2D?

texts:
I want to implement rotating rectangle around cicrle in such way, that circle has no rotation, and rectangle has, and I could myself control rotation of this rectangle (I mean set its angular velocity). All object's are Box2D Body objects. Here is picture, what I want to have:

In my case rectangle touches circle, but I think it doesn't matter.

At first I tried to do it with two Fictures for same Body, but there was a problem with rotation: I couldn't have one ficture with rotation and another without.

I think, it should be somehow connected, but I don't know what exactly Joint I should use.

I tried to use DistanceJoint, but there was a problem, that I couldn't control Rectangle: when I even linear velocity of rectangle to 0 in render() method it continued to rotate.

Maybe are there another solutions?

P.S. It's important, that Cicrle should be DynamicBody, not StaticBody.


texts: blending with the foreground but not the background

texts:
I want to draw some very-semi-transparent objects on top of my scene and have them blend nicely with the other pixels in the scene, but not blend with the background; if I draw a semi-transparent object over the (black) background, I don't want it tainted and drawn dark.

The top scene is what I get - the semi-transparent orange triangle on top is blended with the black background.  The bottom scene is what I want - the semi-transparent orange triangle is blended only with the blue triangle, but not with the black background.

How can this best be achieved?  Is there a simple blend func that does this?  I would like to avoid deferred rendering and such if I possibly can.

Is there some way that gl.blendFunc and perhaps gl.blendFuncSeparate can be used to achieve this?


texts: Unity3d - zooming with orthogonal camera like in Google maps

texts:
I am implementing 2d orthogonal zoom.

As far as I know - in Unity3d there are no translations like in OpenGL.
Taking this into consideration, I work with :

camera size
camera position (center)
real world mouse position

I have no issues implementing simple zoom in/ zoom out operations, combined with camera position changes ( drag'n'drop )

But I have some issues calculating camera zoom shift in this case :

camera size = (4,4)
camera position = (0,0)
real world mouse position = (1,0)

A double zoom in (2x) is applied, as a result -

camera size = (2,2)
camera position = (0.5,0)
real world mouse position = (1,0)

User shifts real mouse position to (1.5,0) and applies a double zoom out ( 0.5 ). In this case :

camera size is again (4,4)
camera position = ???????
real world mouse position = (1.5,0)

What should be the camera shift so the mouse doesn't visually move ?
What is the formula for calculation in this case ?

Thank you in advance.

P.S. Any suggestion regarding current method of handling zoom are welcome

Update

So - I resolved this issue with Blue's help. The basic idea about shifting is right. The main reason it didn't work was incorrect zoom factor.

Example :

Initial camera size is 5. User zooms in by 1, camera size is now 4 ( it displays less content on the same 'screen'). User changes mouse position and zooms out by 1. Camera size is 5 again, but the amount of zoom is actually different :

initially the change was 20% ( 1/5 )
in the second time, the change was 25% ( 1/4 )

My fault was that, when zooming out, I tried to restore position by 20%, not 25%.


texts:
I have just started off in Algodoo and have only a basic knowledge of how it works.

I want to be able to create something that when it is touched by a ball with an English flag on, it shows England and when it is touched by a ball with an American flag, it says America.

How would I do this?


texts:
I'm trying to figure out how to add two classes together with a simple arithmetic addition

The class i've written is a Vector3 class
it looks like this

public class Vector3 {

public float x, y, z;

public Vector3(){
    x = 0.0f;
    y = 0.0f;
    z = 0.0f;
}

public Vector3(float _x, float _y, float _z){
    this.x = _x;
    this.y = _y;
    this.z = _z;
}
public Vector3 add(Vector3 other){
    Vector3 temp = new Vector3(this.x+other.x, this.y+other.y, this.z+other.z);
    return temp;
}

}

I have added the add method in order to be able to add vectors together temporarily. but i really want to be able to just type vectorA+vectorB instead of having to type vectorA.add(vectorB)

is there a way to do this. i know you can do it in python.


texts: I need a free and recent SDK for use with C#. I will work first in 2D games with visual effects. Thanks for now.  Can anyone help me?


texts:
The context

I was thinking of using a versor + velocity field to implement the "moving" part of a 2D game object. For example, if the player should move right I just set the versor to be: [1, 0] and the velocity to be some variable. Then when the player movement needs to be updated we just multiply the versor to the variable and we get the vector to be summed to the current vector position.

For example if the position p is [12, 45] in the 2D space, the versor vs is [1, 0] and the velocity v is 4 we can easily apply the algorithm above:

new position = p + (vs * v)

which leads to:

new position = [12, 45] + ([1, 0] * 4)
new position = [12, 45] + [4, 0]
new position = [16, 45]

The velocity/speed is a separate field because a versor (of length always = 1) better explain diagonal cases, like we see below.

When the player position is handled by the pressing of WASD keys I'd like to be able to code something like this:

on press W -> add versor [0, +1] to current versor and normalize
on press S -> add versor [0, -1] to current versor and normalize
on press A -> add versor [-1, 0] to current versor and normalize
on press D -> add versor [+1, 0] to current versor and normalize

on release W -> remove versor [0, +1]
on release S -> remove versor [0, -1]
on release A -> remove versor [-1, 0]
on release D -> remove versor [+1, 0]

Adding versors (everything is good)

The cool thing about this is that when both W and D are pressed the player moves diagonally to the top right because we first add the W versor and normalize:

vs = [0, 0]
vs += [0, +1] // W versor
// vs is now [0, +1] which is already normalized

and then we add the D versor:

// vs is now [0, +1]
vs += [+1, 0] // D versor
// vs is now [1, 1] which is not normalized
vs /= magnitude(vs)
// vs is now [0.71, 0.71]

Substracting versors (the problem)

Now the problem is when the user later release the W key for example. We currently have the W and D key pressed (which means the player is moving of [0.71, 0.71] (towards the top right corner) at every update. But if we remove the W versor, the calculus goes as:

// vs is now [0.71, 0.71]
vs -= [0, +1]
// vs is now [0.71, -0.29]
vs /= magnitude(vs)
// vs is now [0.9258, -0.3781]

The versor should be the remaining D versor, instead, ([1, 0]). I understand that this problem is related to the fact that we are normalizing at every operation, otherwise we would have:

vs = [0, 0]
vs += [0, +1] // W versor
vs += [+1, 0] // D versor
// vs is now [+1, +1]
vs -= [+1, 0] // D versor
// vs is now [0, +1]

but if we don't normalize and for some reason two D events are sent, we end up with:

vs = [0, 0]
vs += [0, +1] // W versor
vs += [+1, 0] // D versor
vs += [+1, 0] // D versor
// vs is now [+1, +2]
vs -= [+1, 0] // D versor
// vs is now [+1, +1]

which is not what we want. How can I correctly calculate the player position with versors then?


texts: Is Quake 3's shader language copyrighted?

texts:
Right now I am using Quake 3 tools to make maps for my graphics engine, to have some kind of start and an idea on how to build one from scratch. I know that the BSP format is copyrighted and maps made with GTKRadiant cannot be used in commercial games.

But suppose that I would like to create/use a shading language with syntax that is similar or even identical to Quake 3's shading language's syntax, would I risk copyright issues?


texts:
I am implementing a sphere to sphere collision resolution and I am a little confused on where to start. First question, is there a standard way that games/engines do sphere to sphere collision resolution? Is there only like a couple standard ways to do it? Or does the resolution vary very heavily based on whats needed?
I want to implement this in my engine and I wrote a basic one that pushes a sphere and another sphere (so basically the one interacting can push the other) but this was just a super simple concept. How exactly can I improve this to make it more accurate? (Mind you the code isn't optimized since I am still testing)
It seems like there is a lack of solid documentation on collision resolution in general as it's a more niche topic. Most resources I found only concern the detection part.
bool isSphereInsideSphere(glm::vec3 sphere, float sphereRadius, glm::vec3 otherSphere, float otherSphereRadius, Entity* e1, Entity* e2)
{
    float dist = glm::sqrt((sphere.x - otherSphere.x) * (sphere.x - otherSphere.x) + (sphere.y - otherSphere.y) * (sphere.y - otherSphere.y) + (sphere.z - otherSphere.z) * (sphere.z - otherSphere.z));
    if (dist <= (sphereRadius + otherSphereRadius))
    {
        //Push code
        e1->move(-e1->xVelocity / 2, 0, -e1->zVelocity / 2);
        e2->move(e1->xVelocity / 2, 0, e1->zVelocity / 2);
    }
    return dist <= (sphereRadius + otherSphereRadius);
}


texts:
I'm trying to optimize my game. I've got object Handler that goes trought all objects and then render and tick them. If I have lot of objects in game game lags or don't start. Could you please help me? public class Handler {

public LinkedList<GameObject> object = new LinkedList<GameObject>();

private GameObject tempObject;

private Camera cam;

public Handler(Camera cam) {
    this.cam = cam;
}

public void tick() {

    for (int i = 0; i < object.size(); i++) {
        tempObject = object.get(i);

        tempObject.tick(object);

    }

}

public void render(Graphics g) {

    for (int i = 0; i < object.size(); i++) {
        tempObject = object.get(i);

        tempObject.render(g);

    }

}


texts: Distributing damage across units in an army

texts:
I'm working on a game similar to the web game Utopia, insofar as players have a number of units with different values for attack and defense.

Question: how do I distribute damage across units when a conflict plays out?

Let's say I have two units:

Infantry: 3 attack, 3 defense
Cavalry: 5 attack, 1 defense

Let's say the player has 100 infantry (300 attack, 300 defense) and 50 cavalry (250 attack, 50 defense); the player now gets hit with an attack of 100 points of damage.

How do I resolve this in a way that doesn't force players to understand damage and micro-optimize, also given that I'm not going to store individual units' health values after the conflict?

If I distribute damage to weakest units first, 33 infantry will die; but players will spam cavalry and keep a small number of "fodder" infantry around to absorb damage.
If I distribute damage to strongest units first, 50 cavalry die; but players will spam infantry, thinking that stronger units are "not worth it" because they always die.
If I distribute damage randomly (eg. some infantry get 1 damage, some get 2, some get 3 and die), I will likely end up with players thinking that conflict is not effective, because a number of units took damage but didn't die (and I don't keep track of damaged units -- they heal afterward).

Is there a distribution algorithm I can use that doesn't have any of these side-effects and appears "fair" to the player? If not, how can I make this make sense so players understand how this should work, without me hindering certain types of strategies?

I wrote an answer to a question here that looks similar, but I explicitly didn't tackle the problem of fairly distributing damage without sabotaging different strategies.


texts: How do I create my own GPU accelerated graphics API in C#?

texts:
I am creating 2D game engine in C# and I need some graphic API, so that user can draw sprites or convex vector shapes. I tried to use GDI+ for it. But I discovered that GDI+ is not GPU accelerated and it is too slow. XNA (a toolset for game developers form Microsoft) and it is GPU accelerated.

So I made a performance comparison between XNA and GDI+. XNA draws 2048x2048 px sprite in ~0.05 ms in GDI+ it takes about 400-500 ms. How to start? How to make my own graphic API (like DirectX/OpenGL).


texts: What to use as a Box2D renderer in a release version?

texts: I'm creating a game with libgdx. For testing physics I use a Box2DDebugRenderer, which is not fast. When I want to release my full game, what should I use as a renderer?


texts: I currently am working on a 2D game designed for android and iOS. I have a repeatedly spawning enemy game object which comes in from the left. I want the enemy game object to walk onto a slope which leads to a platform. I've tried adding physics rendering but it doesn't seem to work. I tried adding colliders to both and still nothing. The enemy object just goes straight through the slope and doesn't actually climb it.


texts: Face culling all faces that cannot be seen

texts:
I'm working on a simple 3d game using the Processing Java environment. I want to optimise my code so I can draw many many 'objects' (the world is made up of many different shaped objects that live inside the volume of a cube) without the framerate dropping. How can I detect which faces cannot be seen and stop drawing them? I have tried this code:

pgl = (PJOGL) beginPGL();
gl = pgl.gl.getGL2ES2();
gl.glEnable(GL.GL_CULL_FACE);
gl.glCullFace(GL.GL_BACK);

which does do backface culling but it is not all that I want. I want to stop rendering any face that the camera cannot see, i.e. inside faces etc.

The code used to draw the objects (just a simple cube for testing) is as follows:

    noFill();
    noStroke();
    noSmooth();
    push();
    lights();
    translate(this.x * this.size, this.y * this.size, this.z * this.size);
    beginShape(QUADS);
    texture(this.texture_image);
    vertex(-this.size / 2, -this.size / 2, this.size / 2, 0, 0);
    vertex( this.size / 2, -this.size / 2, this.size / 2, this.size / 2, 0);
    vertex( this.size / 2, this.size / 2, this.size / 2, this.size / 2, this.size / 2);
    vertex(-this.size / 2, this.size / 2, this.size / 2, 0, this.size / 2);

    // -Z "back" face
    vertex( this.size / 2, -this.size / 2, -this.size / 2, 0, 0);
    vertex(-this.size / 2, -this.size / 2, -this.size / 2, this.size / 2, 0);
    vertex(-this.size / 2, this.size / 2, -this.size / 2, this.size / 2, this.size / 2);
    vertex( this.size / 2, this.size / 2, -this.size / 2, 0, this.size / 2);

    // +Y "bottom" face
    vertex(-this.size / 2, this.size / 2, this.size / 2, 0, 0);
    vertex( this.size / 2, this.size / 2, this.size / 2, this.size / 2, 0);
    vertex( this.size / 2, this.size / 2, -this.size / 2, this.size / 2, this.size / 2);
    vertex(-this.size / 2, this.size / 2, -this.size / 2, 0, this.size / 2);

    // -Y "top" face
    vertex(-this.size / 2, -this.size / 2, -this.size / 2, 0, 0);
    vertex( this.size / 2, -this.size / 2, -this.size / 2, this.size / 2, 0);
    vertex( this.size / 2, -this.size / 2, this.size / 2, this.size / 2, this.size / 2);
    vertex(-this.size / 2, -this.size / 2, this.size / 2, 0, this.size / 2);

    // +X "right" face
    vertex( this.size / 2, -this.size / 2, this.size / 2, 0, 0);
    vertex( this.size / 2, -this.size / 2, -this.size / 2, this.size / 2, 0);
    vertex( this.size / 2, this.size / 2, -this.size / 2, this.size / 2, this.size / 2);
    vertex( this.size / 2, this.size / 2, this.size / 2, 0, this.size / 2);

    // -X "left" face
    vertex(-this.size / 2, -this.size / 2, -this.size / 2, 0, 0);
    vertex(-this.size / 2, -this.size / 2, this.size / 2, this.size / 2, 0);
    vertex(-this.size / 2, this.size / 2, this.size / 2, this.size / 2, this.size / 2);
    vertex(-this.size / 2, this.size / 2, -this.size / 2, 0, this.size / 2);

    endShape();
    pop();

Sorry for the long code.

Thanks in advance.


texts: Is it possible to make a TileMap that adjust it self to multiple screens?

texts:
I need to build a tile map that is supposed to fit nicely in several screen Sizes.
However, Tiled the tile map editor I use allows only to produce absolute fixed size tile maps.

Is there an easy way to make adaptable tile maps or should I build one for each screen size?


texts: Unity : Rotate object on touch looks weird

texts:
Touch and hold the screen then rotate object continue("Object is unity default cube")  that's my operation, but when object is Rotate then it's look like weird.

I upload the example for better understand, it's looks like above image.

public void StartHold()
{
    pointerDown = true;
}
public void StopHold()
{
    pointerDown = false;
}
void Update()
{
  if(pointerDown){
    Rotator.transform.Rotate(new Vector3(0, 0, 90) * 2f * Time.deltaTime);
  }
}

It's just simple way to rotate object not to much complication then why object rotation look like this, anyone can know then help me and what is the solution of this problem.
Thanks.


texts: Does it make sense to include an index for linelists?

texts: Does it make sense to include an index by using DrawIndexedPrimitives, when using linelists performance wise? I could imagine it would be easy for the GPU to generate such indexes anyway.


texts: Screen blending from Photoshop in Unity 2D

texts:
I want to use "Screen blending" from Photoshop in my Unity 2D game, I want to use that for exported lights from 3D Max that we want to use in our game, Now for a sample, I have my sprite that I want to mask it :

And I also have a mask for it :

Now my question is how to make this in Unity like this :

Can make this happen by Sprite mask?


texts: Why is BayazitDecomposer inaccessible when upgrading from Farseer 3.3.1 to Farseer 3.5?

texts:
I used the following code in Farseer 3.3.1 and it worked correctly, but in Farseer 3.5, I always get an error message in the following line:

list = BayazitDecomposer.ConvexPartition(textureVertices);
'FarseerPhysics.Common.Decomposition.BayazitDecomposer' is inaccessible due to its protection level

What is wrong? Why is the code not working with Farseer 3.5? How can I use the decomposition tools in Farseer 3.5?


texts:
There's a large number of versions of the D3DX dll, from each SDK update, each version having a unique name (list of D3DX dll names).

All-too-often, people have versions missing. So even though they have a compatible version of DirectX, your D3D-based project won't run on their machine.

I want to be able to distribute games (little spare-time projects, game jam entries, etc) as a simple zip file, without the need for an installer. But a significant percentage of users run into missing D3DX .dll errors. And without an installer, Microsoft's official solution (the DirectX web installer/updater) isn't really much of a solution.

Unfortunately, Microsoft still won't give us the option of static linking to D3DX (which would be a nice clean solution). And avoiding using D3DX isn't very practical, especially if you're working with shaders (and no, I'm not switching to OpenGL, at least for now)

Does anyone have clever solutions to avoiding this DLL hell?


texts: Why does exporting to FBX in 3dmax loses simulated animation

texts:
I made a cloth simulation (wind blowing a cloth). When I export it to FXB and the animation box is ticked on export menu it seems ok (no error in longs). When I reload it to Unity. or 3DMAX again. The wind animation is lost. How can I fix that?

Thanks


texts: Rendering overlapping normal map textures to a 2d scene efficiently

texts:
I am using modern OpenGL to render a 2D non grid/tiled world map.  I've generated some simple normal map textures to render over the base world map to provide terrain elevation/detail shading.  Terrain is not tiled (triangulated from noise), so the majority of these terrain elevation features can overlap. This is good as it gives a more continuous appearance to mountains etc.
However the normal map shader needs to sample the base terrain color and apply the lighting value to it before returning the output color.  So I can't render two overlapping normal textures without the second 'cutting out' the first where they overlap (the second texture render cannot see the output of the first).
My solution to this was to use a 3 pass render to texture via FBO.  I attempt to divide the normal textures destination locations into 3 non overlapping groups and render 1 group in each pass.  This works to a point, but of course where a texture overlaps more than 3 neighbours  the cut out problem remains.
I could just increase the number of passes/groups to 4, 5, 6... and perhaps this will resolve most cut out issues.  While this would probably still provide reasonable performance on my system I am guessing there is a limit where integrated graphics cards may struggle.
Is there an alternative solution for this that could scale better to lower end systems?  Or is perhaps even a 5 or 6 pass full-screen render viable on even integrated graphics these days?
Note:
The first render pass draws the entire 2D scene (minus terrain shading) and is obviously the slowest, but it happens only once.  The remaining passes make a screen size copy of the previous pass to a second texture (rendering to a screen sized quad) and then render normal textures to this copy using the first texture as input. Adding more passes would only repeat the screen sized texture copy and normal texture rendering.


texts: glRotatef rotation never applied to 3d cube

texts:
I have a floating cube that I want to rotate around the Y axis. The cube renders fine, the proper size, the proper coordinate, the proper texture/faces, etc.

However, the rotation is never applied. My update logic calculates a new rotation value, between 0 and 360.

// Set the coordinates, rotate Y axis
GL11.glTranslatef(x,y,z);
GL11.glRotatef(rotation, 0, 1f, 0);

// Each cube face rendered, etc...
GL11.glColor3f( //...
GL11.glTexCoord2f(//..
GL11.glVertex3f//..

No matter what combination I've tried, the cube never changes it's rotation.

Update Per a comment, I was using glBegin outside the glRotatef and the comment advised that I use glPush/Pop:

GL11.glPushMatrix();
    GL11.glTranslatef(x,adjY,z);
    GL11.glRotatef(rotation, 0f, 1f, 0);
GL11.glPopMatrix();

GL11.glBegin(GL11.GL_QUADS);
block.renderVertex(x,adjY,z,1,null,0.1f);
GL11.glEnd();


texts:
So I've been trying to make a simple RTS engine for some time and I always hit a wall because of increasing, inflexible and complicated hierarchy trees. I've ultimately found out that an ECS is a good pattern in order to avoid such pitfalls.
For many scenarios I can envision how all things would be coupled, but there are some edge cases I can not manage to figure out.
Let's say we have a simple ECS, which lets us add entities, add/remove components from entities and a system which queries for a set of components and updates all entities which have the respective components attached to themselves.

Scenario 1 - [Single-Player] Should the player be an entity?
Having the player as an entity would mean having a system just for one entity that holds a PlayerComponent...

Scenario 2 - Tech tree and updates to tech trees?

Tech tree cannot be an entity since you want buildings to have their own tech tree, so it must be a component then.
Tech tree is a component, but then you want the player to be able to research a tech from a tree.
So the UI must represent this action as an event which you send to a supposed TechSystem.
In the end this means you iterate through all the entities which have TechTreeComponent, to get the one you need, instead of just updating directly through a reference or an ID.
This could be solved by having a SelectionSystem which holds a state of selected items, but systems cannot have state...

I probably need a way to send a targeted event towards just one entity or inter-system communication, although the second one can get messy quite fast if I choose to add multithreading or priority to systems. If anyone can provide some pointers and how to optimize the architecture for such cases I would appreciate it.


texts: which courses in Computer Science are really needed for game development?

texts:
I would like to know what courses that somebody interested in game development, should take in a Computer Science Career?

I suppose that are necessary for example:

- Discrete Mathematics
- Computer Graphics
- some programming language courses, for example C++ or C#
- AI
- Web programming

what else does anybody involved in this field could recommend me? I got a group of universities that I would like to apply, but their computer science curricula are not the same for every case.

This question is not for generating a debate about which career to follow. I think the natural way will be to follow CS, but here the question is what model would be more suitable according to the standard curricula?

Somebody from mathematics would lack the background in CS, and also that problem comes with people from arts.

Any advice?


texts: How to make a sun that only illuminates stuff in sunlight?

texts:
I set up a scene with Gaia Pro, and it looks really nice so far.  It even has a script to add a Sun object and have it circle the scene, which is pretty cool.

Problem is, it's implemented as a Directional Light, which illuminates everything.  I created a cavern with Digger as a part of the scene, and the interior of the cavern is brightly lit by the sun.  For obvious reasons, this should not happen!

What's the best way to fix the sun so it won't illuminate things that logically wouldn't be in sunlight?


texts: Do "Results-Oriented Work Environments" work?

texts:
A game development company seems like an ideal testbed for experimenting with new or uncommon models for work environments.  I'm curious if there's anyone out there successfully doing something creative with their methods of doing creative work, and how it's working out.

This is a community wiki since there won't be an objective answer to the question:

What are some unconventional but effective methods of running a game development office?  In your experience, what works well and what doesn't?

I'm mostly talking about the culture and business side of things, and not so much about things like pair programming, test-driven development, scrum, waterfall, etc.  In other words: I don't mean development methodologies.  I mean development environments.  They're closely related in many cases, but please don't turn this into an evangelism platform for scrum or TDD or whatever your favorite happens to be.

Do you have strict hours and fire people who are late?  Do you have "core hours", like 10pm to 4pm, that gives people a few hours of flexibility?  Or do you just show up when you want for as long as you want?

Does forcing people to work overtime actually work?  What about forbidding overtime?  Weekends?  Do you give people free time to work on whatever they want during business hours?

Do you allow telecommuting (e.g. VPN from home)?  Clearly this will be a big issue for people who outsource a lot.  And people who subcontract or work on large projects have limited options.

If your hours are not strict, how do you handle meetings, conference calls, or emergency emails?

Some examples of what I'm talking about:

http://www.ted.com/talks/dan_pink_on_motivation.html
http://en.wikipedia.org/wiki/ROWE
http://googleblog.blogspot.com/2006/05/googles-20-percent-time-in-action.html


texts: I'm making a top down rpg game and was wondering if it was possible to show hills on a map instead of having everything completely flat. I've thought about changing to an isometric view, but if it can be avoided, I would rather do top down. How would I do this? Would I draw the tiles on an angle or something? Or is not possible without switching levels like in dwarf fortress?


texts: Unity Collider2D - Know the collider type ob the object collider with the other object

texts:
I have my GameObject which represents a soldier in my game. It has the following colliders:

1st BoxCollider2D in child named "sword". Is Trigger checked. Tag = Sword. This collider is enable when player attacks and disabled otherwise.
2nd BoxCollider2D in parent GameObject. Is Trigger unchecked, since it's the body. Always enabled.

When the sword (1st) collider collides with the the body (2nd) collider, damage happens. Until now everything works fine. Here is the OnTriggerEnter2D function I have:

void OnTriggerEnter2D(Collider2D collision)
{
    if (collision is BoxCollider2D)
    {
        Debug.Log($"{this.name} collided with {collision.name}");

        if (collision == null || collision.tag == Constants.TAG_WEAPONS
            || collision.tag == Constants.TAG_SIGHT)
        {
            return;
        }

        if (collision.GetComponent<LivingObjects>().AreEnemies(this))
        {
            Debug.Log($"{this.name} attacked with {collision.name}");

            Attack(collision.GetComponent<LivingObjects>());
        }
        else
        {
            return;
        }
    }
}

Now I want my unit to search for enemies within a said range. I added a new collider:

3rd CircleCollider2D in child named "sight". Is Trigger checked. Tag = Sight. Always enabled.

Now, when the sight (3rd) collider collides with the body collider, damage is trigger into the unit colliding with the sight collider. That is because I block damage one way around with the condition if (collision is BoxCollider2D) but not the other collision happening at the same moment.

If i can discrimate collision from CircleCollider2D into BoxCollider2D, I can remove the attack function. However, I cannot see how to do it.
My question is how do I know what Collider2D type is my object colliding with the other ?

I'm open to other suggestion if this is impossible.


texts:
I'm making a top down shooter with Three.js and Box2d. I'm displaying all of the graphics in 3d, but all of the physics are done in 2d, so it's sort of like super smash bros in a way.

Anyway, how can I make the player (a simple cube) rotate towards the mouse position? I've tried googling around, but I can't find much.


texts: how to get width and height of TiledMap in the latest Version of Libgdx

texts:
I am making a tiled based game, I want not to let the camera show places, where there is no map... this is a obvious solution I got from a tutorial

if(camera.position.x<400){
    camera.position.x=400;
}else if(camera.position.x>map.width*map.tileWidth-400){
    camera.position.x=map.width*map.tileWidth-400;
}

if(camera.position.y<240){
    camera.position.y=240;
}else if(camera.position.y>map.height*map.tileHeight-240){
    camera.position.y=map.height*map.tileHeight-240;
}

camera.update();

but I don't know how to get width & height of the tiledMap in the latest version of libgdx

https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/maps/tiled/TiledMap.java

Seems strange... I even tried the Super classes but couldn't find. Please help.


texts: Distance to rect edge from point based on direction

texts:
I have a rect that is at position (0,0) at the top left and is 2200x2200 in size.

I am trying to specify the the distance to get to the edge of the rect in specific direction (degrees) from a point within the rect.

So say I am at point 50,50, and want to move 270 degrees until I hit the coordinate of the edge of the rect. What would be the best way to go about this?

Right now I have another function I use to get distance based on direction

distance = 2200
direction = 315
toEdge = distance*math.cos(math.radians(direction)), distance*math.sin(math.radians(direction))

This will just get a point 2200 units away from direction. I think this is half the step there, but can't get the math right on on how I translate this into getting the distance to the rect edge depending on coordinate.

If anyone could help me out I would be appreciative. Thanks.


texts: Replicate GetKey & GetKeyDown like a UI button

texts:
I'm trying to make a UI Button works like the key presses Unity Input methods, but I can't realize on my own how to make this. I tried using the button event and eventTrigger but it doesn't work like it suppose GetKey and Getkeydown works.
Any ideas? thanks in advanced.


texts:
Does anyone know how to prevent a gameobject from colliding with another gameobject but can still register collisions?
Like a ball that can bounce off of the wall or ground and can pass through the player himself.
What I have tried:
Creating two Colliders on the ball(which has a rigidbody component) and making one of them bigger than the other (and turn on "Is Trigger" on the bigger collider). Then write code in the OnTriggerEnter and the OnTriggerExit functions to disable/enable the smaller collider so that the ball could fly right through the player. But that is completely useless when the ball is not in motion and the player walks over it(because it'll fall straight down through the ground).


texts: Who owns content which creation was outsourced?

texts:
What license or contract type is normally used by independent developers, when outsourcing game resources like graphics or sounds? Is there something like a template floating around? How much ownership of the work can I demand?

I'm alone, so the contract is only between me and another person who's doing graphics, sounds or so on.


texts:
I implemented color picking recently and I would like to use it as kind of highlight when mouse is over an object but I am concerned about performance. Color picking requires whole frame to be drawn, loosing effectively up to half of performance (MouseMove can happen nearly every frame).
Also, when mouse moves it is very likely to be nearly above previous point - is there any way how to use this fact to improve performance of 3D picking? Or is my best chance to use some other technique of 3D picking or approximation of results?
tl;dr If I wanted to do "realtime" 3D picking - on MouseMove, what is the best technique for doing so performance-wise?

EDIT: the exact numbers are even worse, when rendering 1m triangles render time increase from 1.5ms to 2-6ms and in spikes up to 15ms.


texts: Glow effect shader for mesh generated at runtime

texts:
I'm using the leap motion-paint module and i would like the ribbons that are generated at runtime to have a glow effect, I tried editing the existing shader by adding a glow property but the colors did not change. I'm not experienced with shaders so any help would be much appreciated.

EDIT: I tried adding post-processing effects for bloom & glows, all the objects have a glow effect except the ones i'm generating at runtime..

 Shader "LeapMotion/TubeShader" {

Properties{
    _Color("Tint", Color) = (1,1,1,1)
    _Glossiness("Smoothness", Range(0,1)) = 0.5
    _Metallic("Metallic", Range(0,1)) = 0.0
     _Glow("Intensity", Range(0, 3)) = 1
  }
  SubShader{
    Tags { "RenderType" = "Opaque" "Glowable"="True"}
    LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
#pragma target 3.0

struct Input {
  float4 color : COLOR;
};

half _Glossiness;
half _Metallic;
fixed4 _Color;
half _Glow;

void surf(Input IN, inout SurfaceOutputStandard o) {
  o.Albedo = (_Color* _Glow * IN.color).rgb * ;
  o.Metallic = _Metallic;
  o.Smoothness = _Glossiness;
}
ENDCG

}
  FallBack "Diffuse"
}


texts: How optimal do you think maintianing states in a sprite class?

texts:
Currently i'm working on a sprite system which will have frames which make animations.

Usually a sprite contains current position, current frame number to be displayed in the running animation, etc... This is what I mean is STATE.

Let's say there are 100 NPC characters in a game which will have different animations running at any time.If we are maintaining the state in Sprite class, we usually create 100 sprites and draw it as each sprite has its own state.

But I feel the same thing can be done like this,
             Imagine, position and animation state is separated from the Sprite class.When ever we want to draw we will just set it and draw the frame at certain position.With this approach there is no need to have 100 sprite  instances.We can make the exact above situation with one single sprite instance.

For me I feel separating the "state" kills encapsulation.But at the same time it will have a benefit in terms of huge memory!

Please give your Pros/Cons on this kind of approach?


texts:
First of all,  I'm a beginner in game physics, and I think this is a relatively easy problem that I'm not grasping.

Short Version:

I have a box(representing a ship on water) going forward with a constant thrust and I need to be able to steer it with the arrow keys so that it rotates and moves along a curved path. My code is not working and I'm obviously not understanding how to achieve this using Bullet-Physics.

Long version:

I'm creating a top-down-view naval game and I'm having a hard time trying to figure out how to use Bullet-physics to steer entities. I'm trying to make it feel somehow realistic by using a physics library.

I'm using SFML to prototype and test Bullet-physics. I have a 2D box representing a ship and during the main loop I'm updating its position and heading this way:

    box_bt->getMotionState()->getWorldTransform(trans);
    box_sprite.setPosition(trans.getOrigin().getX(), trans.getOrigin().getY());
    box_sprite.setRotation(RadToDeg(trans.getRotation().getAngle()));

relevant code:

  (...)

btTransform trans;

while (window.isOpen())
{
        dynamicsWorld->stepSimulation(1 / 60.f, 10);

        // Apply drag force
        box_bt->applyCentralForce(getDrag(box->getLinearVelocity().y()));

        box_bt->getMotionState()->getWorldTransform(trans);
        box_sprite.setPosition(trans.getOrigin().getX(), trans.getOrigin().getY());
        box_sprite.setRotation(RadToDeg(trans.getRotation().getAngle()));

        if (Force < 0)
          Force = 0;

      // Method to apply thrust force along the Y axis relative to the rigidbody
      // from: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=2366
        btVector3    relativeForce = btVector3(0, -Force, 0);
        btMatrix3x3& boxRot = box_bt->getWorldTransform().getBasis();
        btVector3    correctedForce = boxRot * relativeForce;
        box_bt->applyCentralForce(correctedForce);

        (...)

        if (event.key.code == sf::Keyboard::Up)
        {
            Force += 1000;
        }
        if (event.key.code == sf::Keyboard::Down)
        {
            Force -= 1000;
        }
        if (event.key.code == sf::Keyboard::Right)
        {
           box_bt->applyTorque(btVector3(0, 0, 1000));
        }
        if (event.key.code == sf::Keyboard::Right)
        {
           box_bt->applyTorque(btVector3(0, 0, -1000));
        }

    //draw box
}

I'm using applyTorque but I'm not sure if that is the best method to steer a ship in this case.

For the water drag/resistance force I'm using the simplified formula:

Force = vel*(k1*vel + k2*vel^2)   where  k1 and k2 being tweakable "drag coefficients."

btScalar getDrag(btScalar velocity)
{
    btScalar k1 = 0.06f;
    btScalar k2 = 0.03f;
    return velocity * ((k1 * velocity) + (k2 * (velocity*velocity))) * 100;
}

I tried to get the drag force on all three axes but when I use the following code the ship doesn't behave right:

 btVector3 getDragVec(const btVector3& velocity)
{
    btVector3 Rt(0, 0, 0);

    btScalar k1 = 0.06f;
    btScalar k2 = 0.03f;

    Rt.setX(velocity.getX() * ((k1 * velocity.getX()) + (k2 * (velocity.getX()*velocity.getX()))) * 100); // 100 for scaling
    Rt.setY(velocity.getY() * ((k1 * velocity.getY()) + (k2 * (velocity.getY()*velocity.getY()))) * 100);
    Rt.setZ(velocity.getZ() * ((k1 * velocity.getZ()) + (k2 * (velocity.getZ()*velocity.getZ()))) * 100);

    return Rt;
}

Both thrust and drag work well when moving forward, but once I try to introduce the steering part it rotates the box but it doesn't follow a curved path, the angles keep "flipping" once it gets to a certain limit, and the x-axis speed increases too much compared to the rotation.

Thank you for any insight!


texts:
As I was trying to adapt my game to different device resolutions I ran into a problem when adjusting the game screen between the "black bars." In my case I am using the FitViewport class from the LibGdx library to add the black bars for me. Everything works fine and the black bars (one bar in my case) are being effectively created when necessary. My problem, however, is that my screen is not centered and I end up with one ugly black bar either to the top, bottom, right, or left of my game. For example:

How can I fix this so it looks like this:

Here is my code:

public class NordicMadness extends Game implements ApplicationListener{
    private Camera camera;
    public static FitViewport viewport;

    @Override
    public void create () {
        camera = new PerspectiveCamera();
        viewport = new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), camera);
        AssetLoader.loadAssets();
        setScreen(new SplashScreen(this));
        System.out.println(Gdx.graphics.getWidth() + ", " + Gdx.graphics.getHeight());
    }

    @Override
    public void dispose(){
        super.dispose();
        AssetLoader.dispose();
    }

    @Override
    public void resize(int width, int height) {
        // All resizing shall be done in main Game class
        viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getWidth(), true);
    }
}

The libgdx API states that adding true to the third argument of viewport.update(width, height, boolean center) should do the job but it's not working in my case.

After this I tried doing the following but with no success:

public void resize(int width, int height) {
        // All resizing shall be done in main Game class
        ScalingViewport scalingViewport = (ScalingViewport)viewport;
        float leftGutterWidth = scalingViewport.getTopGutterHeight();
        viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getWidth()); // Resize screen
        camera.position.set(0, Gdx.graphics.getHeight() - (leftGutterWidth / 2), 0);
    }


texts:
I'm developing some additional options for a game (which means I don't have knowledge about whole game's methods, classes etc.).

Anyway, I have been trying to build the project for codes I've developed to test them. I've encountered some DirectX, Windows SDK Version, Compiler problems but managed to solve them. But now I'm encountering some BitScanReverse error.

It says: C3861 '_BitScanReverse': identifier not found

Here is whole code for the error I'm encountering:

#pragma once

#include <algorithm>
#include <memory>
#include <string>
#include <vector>
#include <initializer_list>
#include <functional>
#include <iterator>

    #ifdef _MSC_VER // BitScanReverse ERROR 1
        _BitScanReverse(&n, ~code);
    #else
        n = sizeof(long) * 8 - 1 - __builtin_clzl(~code);
    #endif

    code &= ~(-1 << n);
    n = 6 - n;
    ptr++;

    #ifdef _MSC_VER // BitScanReverse ERROR 2
        _BitScanReverse(&n, ucode);
    #else
        n = sizeof(long) * 8 - 1 - __builtin_clzl(ucode);
    #endif

I've downladed source codes through SVN, so whole project is actually working. I just couldn't manage to build it in my local laptop or desktop computer.

By the way, I've tried to build it with Visual Studio 2015 Enterprise (with other errors), Visual Studio 2017 Proffesional and Community Edition (with same errors). And actually this project was developed with Visual Studio 2013 and 2015.

I'm not even good C++ coder so I couldn't figured out the problem.
Does anyone have an idea?


texts: Adding rivers to procedural generated terrain

texts:
I have an heightmap generated using libnoise (c++). I am loading it from the babylon.js framework (3dWebGL).

I have my heightmap image file and also a river position image file, also generated using libnoise. I am able to load the heightmap, apply materials, etc.. everything looks good.

But I have two questions:
1.- How can I apply a river material to specifics parts of the loaded terrain according with the river map file or what should be a generic approach to do this?

2.- After everything is loaded and in place, I can see the ground, see and rivers. What is a good approach to interact with all this information? I mean, once I load the materials, How do I know when a position is water or not? Should I keep the river map in memory and check it?

I am sure all this sounds quite basic, but I just want to have a general idea to develop it and follow way that is well known that works before starting implement crazy ideas.


texts: How to calculate a quaternion rotation between 2 vectors with a specific final up vector?

texts:
I know you can calculate the quaternion rotation between 2 vectors with something like this after all the optimizations:

quat quat::fromtwovectors(vec3 u, vec3 v) {
    vec3 w = cross(u, v);
    quat q = quat(dot(u, v), w.x, w.y, w.z);
    q.w += q.magnitude();
    return normalize(q);
}

However, this returns the shortest quaternion rotation between vec u and vec v. Is there a way to calculate a quaternion rotation between orientation A (with a dir vector and up vector ) and orientation B?

something like

quat quat::from_two_orientations(vec3 u_dir, vec3 u_up, vec3 v_dir, vec3 v_up)


texts: Abstract skill/talent system implementation

texts:
I've been making small 2D games for about 3 years now (XNA and more recently LWJGL/Slick2D). My latest idea would involve some form of "talent tree" system in a real time game.

I've been wracking my brain but can't think of a structure to hold a talent. Something like

  "Your melee attack is an instant kill if behind the target"

I'd like to come up with an abstract object rather than putting random conditionals into other methods. I've solved some relatively complex problems before but I don't even know where to begin with this one.

Any help would be appreciated - Java, pseudocode or general concepts are all great.


texts:
What methods can one use to let the player experience the size of a game world in a 2D game, be it Isometric or Orthogonal?

When playing an open-world game in 3D, the player often is able to rotate the camera to see a building or mountain they can walk to. This creates (at least for me) a feeling of scale, the desire to go there and a feeling of accomplishment, as soon as the desired location is reached.

Is there a technique or game-mechanic that can let players have a comparable perception of scale in a 2D game?


texts: Place actors that attach to other actors and simulate physics as a single object

texts:
I'm super new to UE4. I'm making a block-based building game (I know, I know) in which I want to place actors (blocks) that can "attach" to another actor(block), and then simulate physics as a single object - become one object, rather than say, garys mod welding, which I definitely don't want.
Im looking for pointers rather than specific code - to be honest I have no idea where to start with this. My plan is to create some kind of a blueprint that can be hold multiple blocks,  called a structure, but even this I'm not sure how to go about. About all I have working currently is spawning actors in during run time


texts:
I have been experimenting with Panda3D lately. I have a character made in Blender with various bones and currently with one animation that I wish to export to a *.x format for Panda3D. My current attempt was to export the model was to first export with bones [Armatures] by checking the "Export Armatures" button in the export menu (file name: char.x). Thanks to the *.x file format, I read the file and it seems to have the same bone structure format as the model (with parenting and matrix positional data). The second export was selecting Animations -> Full Animation to provide just the animation (file name: char_idle.x). The models exported just fine. I am not sure about the animation yet, but the file seems to be just fine.

This is my code for loading the model into python & Panda3D: self.model = Actor("char.x",{"char_idle.x"})

When I run the program the command line provides a couple of errors, the main errors of interest are:

:Actor(warning): char.x is not a character!

and

...
  File "C:\Panda3D-1.8.0\direct\actor\Actor.py", line 284, in __init__
    if (type(anims[anims.keys()[0]])==type({})):
  AttributeError: 'set' object has no attribute 'keys'

The first error is the most interesting to me. The model works if I leave the animation dictionary blank. With no animations loaded the character appears in its un-animated T position, however the actor warning still shows up. The character should include the various bones when I exported the model right? I am not that experienced with blender, I'm just a programmer. So if the problem lies in blender please try to keep that in mind when posting a reply. I'll try my best to keep up.

I also tried to print out the bone structure without any animations loaded and it provides a similar error with the line print self.model.listJoints():

 File "C:\Panda3D-1.8.0\direct\actor\Actor.py", line 410, in listJoints
    Actor.notify.error("no part named: %s" % (partName))
  File "C:\Panda3D-1.8.0\direct\directnotify\Notifier.py", line 132, in error
    raise exception(errorString)
StandardError: no part named: modelRoot

I really hope it is a simple exporting fix.


texts: How to rotate a whole rectangle by an arbitrary angle around the origin using a transformation matrix?

texts:
Suppose, I have a rectangle ABCD. Where, A(0,0), B(7,0), C(7,5) and D(0,5).

I want to rotate the whole rectangle by theta = 50°.

I know that, a rotation transformation matrix can be used to do that.

So, I have done the following:

A' = [0   0   1] ;     B' = [7   0   1] ;

C' = [7   5   1] ;     D' = [0   5   1] ;

But the output has become skewed:

What should be the correct calculation?


texts: Video feedback effect with recursive RenderTextures in Unity 2018.3

texts:
I have a project where I'm playing with a video feedback effect by rendering a camera to a RenderTexture and pointing the camera at a quad displaying that RenderTexture.

This works great normally, but when trying out HDRP, LWRP, (and upgrading materials) or upgrading the entire project to 2018.3, the RenderTexture just stops working and shows black. I also tried with a completely new project and just had a camera, a quad, and a cube. That also didn't work.

Is there any obvious reason this wouldn't be working? I spent a while trying out various settings but couldn't find anything that had any effect, so I really don't even know where to start.


texts:
I have been trying to do a sun in Unity 3D. I have used a sphere with a texture and a flare.

The problem is that when I move the camera the flare fades until it disappears when the sun is almost out of view, as shown in the image:

I've tried changing the fade value fron the flare but I can't see any difference.

Does anybody know if this is a normal behaviour or if it can be fixed so the flare is always the same as long as the sun is in view?
Thank you!


texts: Visual Programming tool for creating game quests

texts:
I've found a question for visual script editing software tool for creating game behavior logic, but I am looking for something more flexible. I would like to configure the tool to make it produce code that I need. I use Lua for creating quests in my mmorpg game, but every time there is need of creating a new quest I feel like writing the same code all the time. I'd like to allow my co-workers to do this job in some easy way. The easiest way I can think of would be some sort of making graphs that would represent the quest, and fill all the nodes with different if statements and game texts or procedures like spawning mobs.

Is there any tool that I could use for this purpose?


texts: Procedural terrain - how to blend textures between dynamic meshes

texts:
I think I should structure this question better.

I'm developing a procedural terrain structured with voxel chunks.

Every chunk:

contains a NxNxN voxel array generated with perlin noise 3d
contains a Mesh derived from the surface points of the voxel array
is rendered with marching cubes algoritm

Every mesh has its own Material

Every Material is made of 3 texture: one main texture and 2 minor textures to be blended with the main one depending on the slope. Every material has its own shader attached.

So I have a terrain made of a certain number of chunks, that are a certain number of meshes generated as the game launches. Inside every chunk blending if okay, since I have the only material for the current mesh I have only to blend its textures depending on heights - and this is done by the shader.

In this attached image

you can see quite clearly what I acheived until now.
As you can see, everything is mostly divided in "squares", which are the meshes. Each square has a texture green or beige (grass or sand).

My concern is that:
When passing from grass to sand there is no blending, i.e. blending between 2 meshes is my real problem, because inside the shader if have the surf function which iterates over all the input vertices. But those vertices are only from one mesh. To blend correctly I would need informations also about the vertices of the mesh nearby.

So the question is:
how can I blend properly materials belonging to different meshes?


texts: How to debug a DirectX crash on client machine?

texts:
I have customers who are experiencing crashes which I can't reproduce on my machine.

From the minidumps they sent over, it appears that their crashes all seem to be in unexplained Direct3D calls, deep in the callstack in d3d11.dll.

How can I debug this problem? Is there any way to log client d3d error messages? I can't use the debug layer since they don't have the DirectX SDK, right?


texts:
How would you map the points on a spherical clipmap to a heightmap? My coarsest clipmap has an outer radius of PI and an inner radius of PI/2. My coarsest heightmap goes from -PI, PI on the x axis and 0, PI on the Y. The clipmap extends from 0,PI on the heightmap's Y axis and PI/4, 1.5 PI on the x axis.

My clipmaps are made up of 2D rings which I project onto a sphere. I'm attempting to take the points in each 2D ring and map them to the heightmap. But I'm wondering if I shouldn't take the xyz of the projected point and use that to map to the correct point on the heightmap. I'd prefer to the do the first as it should be less GPU intensive.

Here is a screen shot of my broken mapping. The 3 planes in the upper right hand corner from top to bottom are coarsest to third coarsest heightmaps. As you can see the mapping is horribly broken.


texts: LibGDX music doesn't play anymore after x times

texts:
In my App I added two sounds, the first is played when the gamescreen start the second when the game is going to game Over screen.

Everything works fine but after about 12-13 games the second sound isn't played and until the player close completly the app and open it again every sound isn't played. How to solve?

Errors :

05-24 09:04:29.773    5571-5585/ E/AudioTrack﹕ AudioFlinger could not create track, status: -12
05-24 09:04:29.773    5571-5585/ E/SoundPool﹕ Error creating AudioTrack
05-24 09:04:32.421    5571-5585/ E/MediaPlayer﹕ error (-19, 0)
05-24 09:04:32.421    5571-5571/ E/MediaPlayer﹕ Error (-19,0)


texts: Support for different resolutions in a tabletop environment

texts:
Right now I am experimenting with XAML and C# to write a small Windows Store App which supports displaying a playmat with cards. However not everyone uses the same resolution and with a somehow fixed layout I run really fast into some issues. Having a really high resolution yields

where all the zones are huge (and ugly stretched) and the icons as well as the fonts are really small. Changing to a low resolution yields

which is okayish so far, yet I would need to find out how to scale assets like the displayed card such that it fits the zones.

Are there any best practices, creating such fixed layouts and optimizing them for different resolutions? How should I correctly compute the sizes for a card on the table? And is there anything to keep in mind when creating fullscreen content for different resolutions?


texts:
I am looking for ways to import models to my game project. I am using Maya as modelling software, and GLUT for windowing of my game. I found this great parser, it imports all the textures and normal vectors, but it is compatible with .obj files of 3dsMAX. I tried to use it with Maya obj's, and it turned out that Maya's obj files are a bit different from former one, thus it cannot parse them.

If you know any way to convert Maya obj files to 3dsMax obj files, that would be acceptable as well as a new parser for Maya obj files.


texts:
I am using a fixed static background. I have a gameobject(Current ref. image) which is moving with the help of waypoints. I have made camera to follow the Current. The camera is stuttering while moving. Can anyone help me to solve the camera stuttering and make it follow the Current smoothly?

This is my code attached to camera following the star

public class CameraController : MonoBehaviour {

    void Start () {
        GameObject.FindGameObjectWithTag("OptionCamera").GetComponent<Camera>().orthographicSize =
        (20.0f / Screen.width * Screen.height / 2.0f);
    }

    void LateUpdate() {
        if (GameObject.FindGameObjectWithTag ("Current") != null) {
            if (GameObject.FindGameObjectWithTag ("Current").GetComponent<CurrentController>().Greenblast == false &&
                GameObject.FindGameObjectWithTag ("Current").GetComponent<CurrentController>().Redblast == false)
            {
                Vector3 pos = GameObject.FindGameObjectWithTag ("Current").transform.position;
                transform.position = new Vector3 (transform.position.x, pos.y, transform.position.z);
            }
        }
    }
}


texts:
I'm working on a 2D implementation of Free Cell in Unity 4.6.1, and I'm having trouble getting my click-detection code working consistently. The code below should be called every time a card is clicked (they all have BoxCollider2D components) but it doesn't always happen.

// Handle Clicks on Card
void OnMouseUpAsButton()
{
    print ("test");

    int cardLayerMask = LayerMask.GetMask("Cards");

    RaycastHit2D[] hit = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, Mathf.Infinity, cardLayerMask);

    print ("Hit length: " + hit.Length.ToString());

    if (hit.Length > 0)
    {
        print ("Hit");

    }
}

Even the "Test" print statement doesn't get called consistently, so it's not a problem with the raycast. If it manages to print the test, the raycast always works.

Each time the game runs, the cards get dealt onto the playing field randomly into stacks. On each run, some subset of the cards don't call the above code. The number of cards that work correctly varies, as does their position on the field. It's not consistent with any particular card.

I'm wondering if maybe there's an issue with the BoxCollider2D instances overlapping. The other colliders in the scene, like the one on the "table", always trigger OnMouseUpAsButton() successfully.

I need to be able to register clicks on every card, so I need to find a way to make this work.

Have any of you run into a similar issue before? If not, is there a way for me to work around this? Maybe a different way to detect the clicks on the cards?

Here's a screenshot of an example card from the inspector. Aside from transform position & script property values, all of them are identical (from a prefab):

Update w/ Solution from Accepted Answer

Using @Byte56's solution, I was able to take care of this pretty easily. I've included sample code below.

Note that to get the sample to work, the "top" object has to have the highest transform.position.z out of all the objects the raycast hits. I also put all the possible hit objects into their own layers so I can trigger different behavior based on what type of object is clicked.

// Handle clicks
    if (Input.GetMouseButtonDown(0))
    {
        // Cast a ray, get everything it hits
        RaycastHit2D[] hit = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, Mathf.Infinity);

        if (hit.Length > 0)
        {
            // Grab the top hit GameObject
            GameObject lastHitObject = hit[hit.Length - 1].collider.gameObject;

            // Determine layer of last hit object, take next steps as appropriate
            switch (LayerMask.LayerToName(lastHitObject.layer))
            {
            case "Cards":
                print ("Hit card!");
                break;
            case "Table":
                print ("Hit Table!");
                break;
            case "Cells":
                print ("Hit cell!");
                break;
            }
        }
    }


texts:
I want my car to be realistically drivable (like in real life...)

Unfortunately all I did so far is Rotate the whole vehicle using A and D; and AddForce in forward-backward direction using W and S (which didn't prevent it from moving sideways and yes, I am using Rigidbody)

I'm assuming I'd have to let front wheels rotate independently from the rest of the car, but how do I use them to move the car? And how do I force the car to move only in the direction of the wheels while still making drifting at high speeds possible?


texts: Meaning of offset in pygame Mask.overlap methods

texts:
I have a situation in which two rectangles collide, and I have to detect how much did they collide so I can redraw the objects in a way that they are only touching each other's edges.

It's a situation in which a moving ball should hit a completely unmovable wall and instantly stop moving. Since the ball sometimes moves multiple pixels per screen refresh, it is possible that it enters the wall with more than half its surface when the collision is detected, in which case I want to shift its position back to the point where it only touches the edges of the wall.

Here is the conceptual image it:

I decided to implement this with masks, and thought that I could supply the masks of both objects (wall and ball) and get the surface (as a square) of their intersection. However, there is also the offset parameter which I don't understand.

Here are the docs for the method:

Mask.overlap

    Returns the point of intersection if the masks
    overlap with the given offset - or None if it does not overlap.
    Mask.overlap(othermask, offset) -> x,y

    The overlap tests uses the following offsets (which may be negative):

   +----+----------..
   |A   | yoffset
   |  +-+----------..
   +--|B
   |xoffset
   |  |
   :  :


texts: Rotate Points with Object in world space

texts:
I posted this in the original stack overflow then realized that a game-dev specific one exists.

I am working on personal project that requires me to have 4 points surrounding an object (1 at each of its furthest points) that will rotate/move when the object does.

These points are represented as simple coordinates (x,y,z) and rotational values (ry,rx,rz). Some other stuff exists in the class but it shouldn't be to relevant.

My object has coordinates in world space and can freely move around on the X and Z axis. The y value of the object and points are calculated elsewhere, separately using the X and Z values obtained by the points.

So Basically What I am asking is How do I attach my points to the Object and have them rotate when it does, move when it does etc. Keeping in mind I need the points coordinates in world space.

My knowledge of DirectX is a bit sketchy and basic concepts (change of coordinate systems, vector/matrix transformations etc) confuse me sometimes.

Any help is greatly appreciated.

This is the Constructor for the object, it initializes the points to areas around the object.

    Object::Object(ID3D10Device *renderingDevice, float mlength, float mwidth)
{
    pd3dDevice = renderingDevice;
    length = mlength;
    width = mwidth;
    A = new CollisionPoint(width,-length); //Front Left
    B = new CollisionPoint(-width,-length); //Front Right
    C = new CollisionPoint(width,length); //Back left
    D = new CollisionPoint(-width,length); //Back Right

}

This is the code that is meant to move and rotate the points.

 void Object::doBehaviour()
{
    //origin required for rotating of collisionbox
    D3DXVECTOR3 origin = D3DXVECTOR3(x,0,z);
    setUpWorldMatrix();
    moveForward();
    speed *= 0.99;

    //update collisionbox
    A->x = width;
    A->z = -length;
    A->rotateTo(0,ry,0);
    A->doBehaviour1(origin,world);

    B->x = -width;
    B->z = -length;
    B->ry = ry;
    B->doBehaviour1(origin,world);

    C->x = width;
    C->z = length;
    C->ry = ry;
    C->doBehaviour1(origin,world);

    D->x = -width;
    D->z = length;
    D->ry = ry;
    D->doBehaviour1(origin,world);

}

This is the code the collisionPoints use to move and rotate the points, ignore the int wheel bit.

    void CollisionPoint::moveAndRotate(D3DXVECTOR3 origin, int wheel)
{
    //1 = frontleft //2 = frontright //3 = backleft //4 = backright
    float xR = origin.x + cos(ry) * x - sin(ry) * z;
    float zR = origin.z - sin(ry) * x + cos(ry) * z;

    x = xR;
    z = zR;

}

void CollisionPoint::doBehaviour1(D3DXVECTOR3 origin, int wheel)
{
    moveAndRotate(origin, wheel);
    speed *= 0.99;
}

TLDR;

How do I:

Convert coordinates to Object space.
Rotate these coordinates along with an object based on its RY (rotation on the Y axis) value
Obtain their coordinates in world space.


texts:
Currently I'm participating in a multiplayer game project as a network developer. Unfortunately, however, I'm facing an interpolation problem which makes game objects look like they are 'jumping/teleporting' sometimes. Images don't look smooth compared to the server even if the client runs at 60 frames per second.

Things about the architecture:

Based on client/server model. server sends regular transform updates at every 33 milliseconds (30fps).
Client receives and stores position updates in a queue. then, plays them from 1 second behind using interpolation between each update.
Before processing the next packet, client calculates the sent time between current and next packet to find out how many milliseconds this interpolation should take. at every frame, it deducts the delta time from the interpolation time. so, if interpolation time reaches a number equal or less than zero, it iterates to the next packet (if the value is less than zero, it means that there is a time fragment. so the client also considers that time fragment for interpolation of the jumped packet at the same frame.)
Client doesn't deal with rigidbody; only position and rotation.

I'm using Unity3D's LERP method from the Vector3 class. Using SLERP didn't solve the problem.

Any ideas? Everything looks great on paper.


texts: Is Table the only layout that I can use in libgdx?

texts:
I'm looking for the common way to handle the layout in libgdx.
I searched google and found only table layout.
Meanwhile I don't use any layout and just insert coordination into each visual object but I think that this is not the proper way to do it...
Is their any other layout that I can use?

p.s
The game layout should split into two parts, left is smaller that the right and contains things like score time and info about stuff in the game. The right part will display the game-play itself


texts: How do I separate testable game logic from my UI in Cocos2d-x?

texts:
I read some articles on why I should separate game logic and UI code: That makes it possible to test game logic code can be independently of the rest. However, I am having trouble implementing this in cocos2d-x.

For example, the model usually depends on a Point coordinate and Sprite classes of the engine, which belong to the UI part. How can I separate them?

class Projectile : public Sprite{
public:
    CC_SYNTHESIZE(cocos2d::Point, _nextPosition, NextPosition);
    static Projectile initWithFile(const char* filename);

    Projectile(void);
    ~Projectile(void);
    virtual void setPosition(const cocos2d::Point & pos);
};

I'm really confused how to test this object when I need to set its position in the unit test. How should I structure game code to be testable?


texts:
I have a texture2d loaded and wish at a certain moment to make a sort of zoom on the texture2d.

As you can see in the image i would like to expand my red square to the resolution of the black square. The aspect ratio is the same.

update

if it isn't clear, the question is how can i make that zoom?


texts: Unity PNG sequence animation changing position in animation

texts:
We are making frame by frame animation and we have a canvas size for animation. Attack animation is changing position in canvas. In Unity after the attack animation is completed it teleports back to the initial position.
I tried setting animation event and updating parent position but it does not work. It teleports to nonsense locations like player is looking at +x but it teleports to -x. Anybody have solution for this? Since it is not rigged, root motion is not working.
I tried to put animation event at the last frame and put this script to the character controller which is a child object of empty parent object:
public void animationFinished(){
 animation_finished = true;
}

 void LateUpdate () {
 if(animation_finished ) {

     transform.parent.position = transform.position;
     transform.localPosition = Vector3.zero;
 }
}

I have 25 PNG as frames of animations. From idle animation I go to attack animation. Idle is stable as a position, but attack animation is changing position in canvas for example animation canvas is 1920x1080 canvas size and animation starts from the left size to right size. I can't move the character with a script because it has its own timing that I can't set up with script. So I am trying to get the last frame position and pass it to idle animation at that position but instead of that without code it teleports back to the initial position after attack is completed.
This is a similar topic, but the solution did not work.


texts: Can't reference my custom editor script from a non-editor script even when using its namespace

texts:
I know that certain namespaces are necessary to include to specify under what scope certain methods are found, and this also saves typing. Otherwise the error CS0246 is thrown if referencing an unknown type.

The problem is, that I am using a namespace in a script in:

 Assets / Scripts

And that namespace is defined in a script in:

 Editors / Data / AnotherFile

So I am getting an error CS0246.

How could I solve this without moving that script into the Assets / Scripts location?

SCRIPT LOCATED IN EDITOR / DATA / ANOTHERFILE:

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

namespace NodeEditorWindow
{

[CreateAssetMenu]
public class LevelFlowData : BaseNodeEditorData<BaseLevelNode, LevelFlowEditorAttributes>
{
    private const string MENU_ITEM_PATH = "Create / ScriptableObjects / LevelFlowData";
    private const string NEW_ASSET_PATH = "ScriptableObjects / Level Flow Data";

    [SerializeField] private string _name;

    /// <summary>Gets and Sets name property.</summary>
    public string name
    {
        get { return _name; }
        set { _name = value; }
    }

    [MenuItem(MENU_ITEM_PATH)]
    public static void CreateAsset()
    {
        LevelFlowData scriptableObject = ScriptableObject.CreateInstance<LevelFlowData>() as LevelFlowData;
        AssetDatabase.CreateAsset(scriptableObject, AssetDatabase.GenerateUniqueAssetPath(NEW_ASSET_PATH));
    }
}

}

SCRIPT LOCATED ON ASSETS / SCRIPTS / ...:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GameData;
using NodeEditorWindow; //HERE I AM USINGTHE OTHER CLASS'S NAMESPACE

public class LevelController : Singleton<LevelController>
{
    [Header("Level Data:")]
    [SerializeField] private LevelFlowData levelFlowData;
}

These are the errors I get in console (both CS0246):

Assets/Scripts/Scene Controllers/LevelController.cs(6,7): error CS0246: The type or namespace name `NodeEditorWindow' could not be found. Are you missing an assembly reference?

Assets/Scripts/Scene Controllers/LevelController.cs(11,27): error CS0246: The type or namespace name `LevelFlowData' could not be found. Are you missing an assembly reference?

Sorry if this seems to be a repeated question, but I haven't found any solution to this error due to having scripts on different paths (but using the namespaces). Thanks in advance.


texts: How do I add a method to a class without editing the source file?

texts:
I am trying to add a method to a Minecraft source file, but I have to figure out how to do it without actually editing the source files, as it would be illegal to redistribute Minecraft's source files with the mod I am creating.

I need to add the method setInPortalZub() to the EntityPlayer class located in net.minecraft.entity.player. I am using the MCP/Minecaft Forge API. I have tried creating an EntityPlayer instance, but I'm not exactly sure how to make this work.


texts:
I made a procedural mesh and now I want to apply a texture to it. The problem is, I cannot get it to stick the way I want it to.

The idea is to have the texture painted only once over the whole mesh, so that there is no repeating. How should I map the UV to make that happen?

My mesh is a simple plane consisting of 56 triangles. I'd add pictures to clear things up but I cannot since my reputation is below 10 points.

Any help is appreciated.

EDIT(Kind people gave me up votes, thank you):

Meet my mesh:

And when textured(tried to repeat the texture):

And my texture:

EDIT 2:

bummzack's instructions worked like a charm and the mesh got textured just as I wanted it to. Thank you.


texts:
I'm currently learning OpenGL (in class) and we're using freeglut 2.8.2, which works just fine (using Visual Studio 2012). As an additional learning resource I'm reading the "OpenGL Superbible, 5h Edition". However, I've noticed that there are some functions that aren't available using the freeglut library.

For example, gluGenerateMipmap or setting anisotropic filtering doesn't work:

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest);
void glGenerateMipmap(GLenum target);

It simply does not know these functions (glTexParameterf is known, GL_TEXTURE_MAX_ANISOTROPY_EXT is not). I've googled a bit but didn't really find anything. And since glGenerateMipmap seems to belong to the standard openGL Library (and not glu/glut), it should be available (I hope).

Is there anything I'm missing?


texts: PhysX - Revolute joint around unit vector

texts:
I'm using a right-handed coordinate system with (0,0,-1) = forward, (1,0,0) = right and (0,1,0) = up. PhysX version is 3.3.0.

I have a unit vector which represents the axis around which my actor is supposed to be able to rotate, (0,1,0).

The problem is, if I build a quaternion rotation from that vector, like so:

physx::PxQuat q = (0, physx::PxVec3(0, 1, 0));

and use that for the joint, the actor will actually rotate around the direction of the rotation around the axis:

http://youtu.be/pXMlRRBVOpc

However, what I want is this:

http://youtu.be/MlBx-hC1Z9Q

In the second case I used (0,0,1) as axis and 90 degree as rotation and used that to build the quaternion.

So, how can I use my axis (0,1,0) and actually get the rotation as shown in the second video?


texts: How can I diagnose a Unity crash when running the game on a phone?

texts:
I have a 2D android game that is in beta on Google Play. It has about 100 installations, but no testers. I'm the only developer. Some of the users have reported app crashes, and because they are not developers, they can not help me with a diagnosis.

I think the origin of the problem is the phone not having enough memory to run the app. When I rub the app in a LG-D213c running Android 4.4.2, the game opens, and you can navigate the main screen (the title screen). When I select any stage, the game displays the "loading" screen that runs in the same scene as the main title, and SceneManager.LoadScene () is called with the play scene (battle). Then, the game closes. When I do the same procedure with a Galaxy S5 neo (SM-G903M) running Android 6.0.1, the app runs normally.

I have collected a log uaing  Android Monitor. Both of them include the moment of the app crash (the name is com.empresa.aplicacion, but this is not the real name).

This is the profiler capture in both cases.

LG phone case.

Galaxy S5Neo case

So. I have some questions.

What is the real origin of the problem? How can I diagnos the issue? I'm not seeing the cause, this is the filtered Log, and this is the complete log.
How can I control this error from inside Unity? Is there a way to catch exceptions from the Unity core, so that it can generate a report?
How can I make a diagnosis to the installations that I do not have access to, like a production installation or a client that has the app in their phone?

All of my questions are relative to Unity platform.


texts: Random world Points in GLSL for tree placement

texts:
I'm doing tree placement in the geometry shader in GLSL. I've made a seeded random vec3 function based on gold noise that looks like this:

vec3 randomVec3(vec2 xy, int seed)
{
  return vec3(gold_noise(xy, seed * 3), gold_noise(xy, seed * 3 +1), gold_noise(xy, seed *3 +2));
}

This works, but generates strange patterns in the trees. I can't find anything on making random numbers that isn't based on the fragment coord and unseeded - each run of the geo shader needs to generate 15~ random vec3s for trees based on a seed (area on the planet combined with an index for each tree). Here is my results so far:

You can see the diagonal patterns going through the tree clusters. This is what I want to reduce.

Thanks!

Edit: Here is my code that places trees in full

float gold_noise(in vec2 xy, in float seed)
{
    return fract(tan(distance(xy*PHI, xy)*seed)*xy.x);
}

void drawInstanceOnSphere(vec4 worldPos, vec2 sphericalCoords)
{
  //...Draws an instance at the correct height and rotation based on the
world position and spherical coords of the desired instance
}

//Generates a psuedo random vec3 based on a coord and a seed
vec3 randomVec3(vec2 xy, int seed)
{
return vec3(gold_noise(xy, seed * 3), gold_noise(xy, seed * 3 +2), gold_noise(xy, seed *3 +4));
}

//Places a set of trees
void placeTrees()
{
  //All following code assumes planet positon of 0,0,0, and no planet rotation
  //Find the point on the planet closest to the camera
  vec4 closestPoint = normalize(cameraPos) * radius;

  // if the surface is close enough
  if(distance(closestPoint, cameraPos) < 3000)
  {
    //Tree placement is based off this mechaninsim - a geo shader can draw 15
 trees per run before it becomes inefficient. Divide the spherical coords by 1000
 to generate a 1000x1000 grid across the planet. Each point becomes a new seed -
all trees will look the same in this "quadrant". This mean each shader run can
increase their own seed offset by 1 for each tree. I can then run 9 instances on
this shader, choosing the 9 closest "quadrants" to the player.

    //What are we dividing the spherical coords from ?
    float quadrantDiff = 1000;

    //Quadrant.xy is fed from the C++ code. Centre of the world map would be 0.5, 0.5
    vec2 quadrantCoord = quadrant.xy;

    //Get our world point from this coord. Centre of the world map with radius 3150 and origin 0,0,0 would be 0,0,-3150
    vec4 quadrantWorldPoint = (vec4(getWorldPoint(quadrantCoord),0));

    //Draw 15 trees
    for (int treeCount = 0; treeCount < 15; treeCount++)
    {
      //Range number - is fudge, looks okay
      float range = 8000 / quadrantDiff;

      //Position of the tree is the quadrantCentre point plus a random vec3,
 then normalized and multiplied by the radius to place it on the sphere.
Additional height to match terrain is added in the "draw on sphere" method

      vec4 treePos = normalize(quadrantWorldPoint + range *  (vec4(2.0 * randomVec3(quadrantCoord, int( treeCount + 15 * seedOffset)) - vec3(1),1))) * radius;

      //Get the tree's spherical coord for heightmap lookup
      vec2 treeCoord = getAdjustedTexCoord(getTexCoordFromPos(treePos));
      //Draw this tree
      drawInstanceOnSphere(treePos, treeCoord);
    }
  }

}

Here is another image showing the diagonal lines being worse. The centre quad seed for this image is (0.532, 0.532).


texts: How could I get composite rigid body into unity

texts:
I am developing a game, in unity, that has accurate destruction physics and from my understanding unity uses plain old rigid body physics. I was wondering if there was a way to bring composite rigid body physics into unity through a plug in or library or some other way?

Thanks, nova

edit: So composite rigid body physics is almost exact like normal rigid body physics. But the main difference is that in composite rigid body physics all of the assets will not be considered physics based objects until an outside force hits them. For example a building and all of that parts it is made out of will not be processed as physics based objects until say a rocket hits it.     This method of composite rigid body physics uses much less memory because it is only processing what is being affect and not everything else.


texts: How to specify font size in nifty GUI when using ttf fonts

texts:
I'm trying to use a font with a larger size in a ttf file using nifty GUI. All questions and answers I've seen are concerned with making fonts in fnt fonts in a different size, but the size I want to use is actually included in the ttf file. I tried setting fontSize and size attributes with no effect (no errors but the font size does not change either)
Below is the xml excerpt where I'm trying to use the ttf font with a large size:
<control id="score"
name="label"
color="#fff"
text="0"
width="50%"
height="20%"
textHAlign="left"
font="Interface/Fonts/Kenney Future.ttf"/>