texts: Entity Component System - Physics Animation Matrix Calculation?

texts:
The problem is how many times the matrices representing the bones (for animation and rendering) of an entity get calculated.

If i have these components:

Position
Skeleton (holds matrices for bones)
Physics
Animation

When the physics get's updated, the position is changed to move the entity. This sends a message, that position has changed. The skeleton takes note and updates the matrices for the changed position (and potentially rotation). The animations are then updated in a separate system, the skeleton then gets updated and changed again. So essentially the matrices are being updated twice (unnecessarily) instead of just once.

Am i going about this the wrong way? Is this just the price of having everything disjoint?


texts: How to make my characters turn smoothy while walking on a path(list of coordinates)?

texts:
I have a list with coordinates - output from A* algorithm - and I would like to make my characters smoothly follow this path with rotations.

So I have something like A and I want to get C

How can I do this ?

EDIT

To make myself a little bit more clear:

I am more interested in smooth turning as I already know how to walk from one node to another.

EDIT

As many people find this useful (me too) I am posting link to Daniel Shiffman's "Nature of code" where he discusses a lot of game AI (and physics) problems e.g. steering behaviours http://natureofcode.com/book/chapter-6-autonomous-agents/#chapter06_section8


texts: Different OnMouseDown functions based on where an object is clicked

texts: So my problem is I'd like to have one GameObject with multiple "OnMouseDown" functions. I have a target (classic looking bullseye) and I'd like to award a player say 10 points if they click on it, but 100 points if they click the center. Because the "OnMouse" functions don't pass in a collider I'm not sure how to go about doing this. I had an idea (which I think is a bad one) which would be to attach a small "empty" gameobject to my target prefab and give it a smaller hitbox with code that spits out 100 points instead of 10 and place that object "in front of" the other one while being attached. Again, seems wrong. Anybody else have to do this before or have a more elegant solution?? Thanks!


texts: How do I stop stretching during window re-size in XNA?

texts:
In my windowed mode XNA game when the user resizes the window the game stops updating the window and the last frame drawn is stretched and distorted until the user releases the mouse and the resize completes.

Is there any way to have the game continue to run "normally", updating frames and redrawing the screen, during the resize event?

I realize that keeping the render loop going while resizing may not be possible or recommended due do hardware managed resources getting continually created and destroyed, but is there any way to stop the ugly stretching?  Ideally by leaving the existing frame unscaled in the top left, or with a black screen if that isn't possible.


texts: Should I batch up debug primitives for rendering in modern OpenGL?

texts:
I've recently started porting some old rendering demos I did to modern OpenGL. I had a debug drawing class in my old code which used immediate mode glBegin(), glEnd() etc. for rendering debug objects such as triangles, cubes and spheres etc.

Originally I replaced the code in these functions with code to generate the VAO and VBOs (for position and colour), bind them, assign the vertex data, render, then disable and delete the VBOs and VAO. Is there anything wrong with this?

I've been thinking about modifying the class so that every time it gets a draw primitive call it generates the VAO and VBOs and assigns the vertex data but doesn't actually do the rendering until after all the other rendering has been completed. Then it renders all the debug prims that have been stored at once.

I'm not sure of the benefits of either way of doing this and was just wondering what people thought.


texts: How to pass array of dozens of floats to OpenGL 3.0 vertex shader?

texts:
I use PyOpengl and Python 3.

I have 50 thousand vertices. Position of each vertex could be calculated in vertex shader as

#version 300 es

uniform v_coefficients_weights[COEFFICIENTS_AMOUNT];
in vec3 v_coefficients[COEFFICIENTS_AMOUNT];
in vec3 v_initial_position;
out vec3 v_position;

void main() {
    v_position = v_initial_position + v_coefficients * coefficients_weights;
}

Amount of coefficients varies between 0 and 199 — it's not a problem  for me to generate 200 vertex shaders to cover each situation.
I need to change position of vertices tens of thousands times per application calls as fast as it's possible, so I cannot calculate them once on start.

Though, I cannot provide arrays for each vertex because documentation says:

  Attribute variables cannot be declared as arrays or structures.

I see following solutions of this issue:

(will not work) hardcode suffices of variables names to emulate arrays:

use vectors with names like coefficients_000, coefficients_001, ..., coefficients_199;
use matrices to have 4 vectors in each of variable — will it be better than previous solution with vectors (maybe performance of matrices product is faster than 4 products of vectors)?

calculate vertices positions by myself using C/NumPy;
calculate vertices positions by myself in parallel using OpenCL;
(will not work) store all coefficients in uniform int v_coefficients[COEFFICIENTS_AMOUNT*VERTICES_AMOUNT] and access needed ones according to vertex number, which will be stored in in int vertex_id;
store coefficients in textures (proposed by @HolyBlackCat).

Are there any other solutions of my issue? Is there optimal solution in proposed above?
Will I go out of memory if I will use 200 float 3-vectors for each vertex?

I imagine the solution with hardcoded indices as:

#version 300 es

uniform v_coefficients_weights[COEFFICIENTS_AMOUNT];

in vec3 v_coefficients_000;
in vec3 v_coefficients_001;
...
in vec3 v_coefficients_199;

in vec3 v_initial_position;
out vec3 v_position;

void main() {
    v_position = v_initial_position
        + v_coefficients[0] * coefficients_weights_000
        + v_coefficients[1] * coefficients_weights_001
        + ...
        + v_coefficients[199] * coefficients_weights_199;
}


texts: why does Physics.Raycast always return my player game object instead of the object I clicked?

texts:
I have 3D world. I want to detect when the player clicks on a game object in the world.

In this image, I have 2 objects I want to detect mouse click on. The white sphere does have collider on it. The dumpster does not. The behavior is the same as noted below.

I am getting the mouse down detection.  When I check the RaycastHit, I always get the player game object transform and not the game object I clicked on in the world. If I remove the raycaster checks, then I get mousedown for anything in the game not just mouse down over the game object. I need to be able to distinguish between clicks on different game objects.

I found a post here and added a PhysicsRayCaster, but it didn't change the behavior.  The problem isn't getting the event.  My problem is detecting which game object the player clicked on in the world.

Here's my code:

public class InventoryItemSearchHandler : MonoBehaviour
{
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = UnityEngine.Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                // CompareTo always fails because hit.transform.name is always "Player" and
                // not the name of the object clicked on
                if (0 == hit.transform.name.CompareTo(transform.name))
                {
                    print("mouse down");
                }
            }
        }
    }
}

EDIT:
In the image below (compared to the one above) I do get the correct transform in the RaycastHit type when I click on the white sphere (and when I click on the dumpster I get the player transform as noted above).

So it looks like the player object is getting in the way.  What would be causing that?


texts:
I'm going to make an environment with trees, walls, rocks, mountains and bushes in Unity 3D 5.1 . I don't know what game object suitable for the ground. I have used both terrain and plane in earlier simple projects.

My question is,

  What is the difference  between terrain and plane?

  Which game object is suitable for my requirement?


texts: Normal matrix space has to be eye space?

texts:
I'm doing lighting in world space (not in eye space), so I set the normal matrix as follows:

modelProgram->setUniform( "NormalMatrix", inverse(transpose(mat3(modelMatrix))) );

Now I noticed that all the tutorials set the normal matrix as the inverse transpose of the ModelView matrix. This also means they do lighting in eye space, right?

Do I have to do lighting in eye space when using the normal matrix? I actually do normal mapping too if it matters.


texts: Problem in if statement comparing GameObject name

texts:
I am trying to get the name of the game object. for that i used

    Debug.Log (gameObject.transform.ToString());

in start. My gameObject name is "PowerupItem_0" and "PowerupItem_1". in console it displayed the gameObject name correctly. then i tried to execute the statement. so i used

    if (gameObject.transform.ToString () == "PowerupItem_0") {
        Debug.Log ("PI_0");
    } else if (gameObject.transform.ToString () == "PowerupItem_1") {
        Debug.Log ("PI_1");
    } else
        Debug.Log ("Oth");

for this coding in console it displayed a message as "oth". i am not understanding why its not printing "PI_0" and  "PI_1". anybody please help


texts: How do I efficiently collide and match groups of coloured circles?

texts:
I am new to game programming and working on clone of this game in libgdx.

The game has some static balls and one ball that moves. I want to check if the moving ball collides with any static ones, but I'm concerned about the performance of my method.

I could put the positions of the static balls in an array or ArrayList and iterate over each of them in the moving ball's update()-method. However, this seems too slow to me when there are more than 10 balls.

A second issue is with how to detect the colliding balls' colours to check if 3 or more with similar colors collide. How should I approach that?


texts:
I am making an isometric game using unity 3d and 3d graphics. I have been able to figure out how to create and isometric camera that follows the player, and a basic isometric moving script for the player, and a script that rotates the player towards the mouse. Instead of moving in the same direction when moving forward, I want forward to be the direction that the player is facing when I press that key.

Here is the code for the player movement:

using UnityEngine;
using System.Collections;

public class BasicIsometricMove : MonoBehaviour
{
    void Update()
    {
        int speed = 2;
        Vector3 amount = Vector3.zero;

        if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
            speed *= 2;

        if (Input.GetKey(KeyCode.W))
            amount.x += amount.z = speed;

        if (Input.GetKey(KeyCode.S))
            amount.x += amount.z = -speed;

        if (Input.GetKey(KeyCode.A))
        {
            amount.x += -speed;
            amount.z += speed;
        }

        if (Input.GetKey(KeyCode.D))
        {
            amount.x += speed;
            amount.z += -speed;
        }

        //amount *= Time.deltaTime;
        //transform.Translate(amount);
        transform.position = Vector3.Lerp(transform.position, transform.  + amount, 0.5f * Time.deltaTime);
    }
}

Here is the code for the camera:

using UnityEngine;
using System.Collections;

public class IsometricCamera : MonoBehaviour
{
    public GameObject target;
    public float size = 10;
    public float scrollSpeed = 30;

    Vector3 pos;
    private Camera cam;

    void Start()
    {
        this.cam = (Camera)this.gameObject.GetComponent("Camera");
        this.cam.orthographic = true;
        this.cam.transform.rotation = Quaternion.Euler(30, 45, 0);

        pos = target.transform.position;
    }

    void Update()
    {
        this.cam.orthographicSize -= Input.GetAxis("Mouse ScrollWheel") * scrollSpeed * Time.deltaTime;

        float distance = 30;

        //transform.position = target.transform.position + new Vector3(-distance, distance, -distance);

        transform.position = Vector3.Lerp(transform.position, target.transform.position + new Vector3(-distance, distance, -distance), 0.5f * Time.deltaTime);
        this.cam.transform.LookAt(target.transform);
    }

    void OnGUI()
    {
        //    GUI.Label(new Rect(10, 100, 200, 50), "" + target.transform.position.x + ", " + target.transform.position.y + ", " + target.transform.position.z);
        //    GUI.Label(new Rect(10, 130, 200, 50), "" + cam.transform.position.x + ", " + cam.transform.position.y + ", " + cam.transform.position.z);
    }
}

And here is the code for the player rotating to face the position of the mouse:

using UnityEngine;
using System.Collections;

public class LookAtMouse : MonoBehaviour {

    // Use this for initialization

    Ray cameraRay;                // The ray that is cast from the camera to the mouse position
    RaycastHit cameraRayHit;    // The object that the ray hits

    void Update ()
    {
        // Cast a ray from the camera to the mouse cursor
        cameraRay = Camera.main.ScreenPointToRay(Input.mousePosition);

        // If the ray strikes an object...
        if (Physics.Raycast(cameraRay, out cameraRayHit))
        {
            // ...and if that object is the ground...
            if(cameraRayHit.transform.tag=="Ground")
            {
                // ...make the cube rotate (only on the Y axis) to face the ray hit's position
                Vector3 targetPosition = new Vector3(cameraRayHit.point.x, transform.position.y, cameraRayHit.point.z);
                transform.LookAt(targetPosition);
            }
        }
    }

}


texts: Picking college degree (want to be games programmer)

texts:
Alright, so I know there's plenty of questions that have to do with college degrees on this site, but I don't feel that any of them really answer my question. I recently got accepted into Northeastern University. The thing that drew me to the university was not only that it appears to have a comprehensive computer science program, but that it offers combined majors with the other colleges. Since i'm interested in both game art and game programming, I applied to the Computer Science and Digital Art major. However, after looking at the other combined majors, I wondering if I picked the one that is right for me.

The five majors I'm currently looking at right now:

Computer Science and Digital Art:

Pros: Teaches both programming and art fundamentals.
Cons: The mathematics requirements are the weakest of the five majors
(only require linear algebra).

Computer Science and Game Design:

Pros: Very comprehensive in both computer science and game design.
Requires the most computer science courses out of the 5 majors (the
extra courses are game design specific). I'd be the most likely to
meet like minded peers in this major as well.
Cons: Doesn't really touch on subjects of game art at all. You are
allowed to take two art+design electives, that's it.

Computer Engineering and Computer Science:

Pros: Gives a comprehensive education on computing in general
(hardware and software). The biggest benefit of this major, I feel,
is that it would teach me how to think. By that, I mean it would
teach me to think in such a way that it'd be very easy to dive into
other aspects of both computer engineering and computer science (more
so than the other majors).
Cons: It's a computer engineering major first, and a computer science
major second. Some of the information I learn may be pretty much
useless.

Computer Science and mathematics:

Pros: Naturally, it has the most math courses of any other major.
Cons: The only major con is that I'm not really crazy about math, and
don't know if I really want to subject myself to a bunch of it.

Computer Science and physics

Pros: It's actually pretty well split among math, physics, and
computer science.
Cons: Like the computer engineering major, some of the information I
learn may be pretty much useless.

I don't want this post to be ridiculously long so forgive me if I'm not specific enough. I'm guess I'm torn between different beliefs. Computer Science and Digital Art/Game Design would probably be the most fun majors for me, since they'd suit my personal interests. However, the other majors would give me information that would be useful in a broader sense (I could apply them outside the fields of game design / interactive media). I don't think any one of these majors will prepare me completely for the games industry, not even the game design one. However, I do think that no matter which of these majors I pick, I'll still be able to get into the game industry.


texts: How to make space invaders destructible scenery and conform it to a shape?

texts:
We all like the bases that can be destroyed by chunks being split out,

I originally implemented it by making a rectangle filled with individual squares (2x2 pixel size CANVAS rects) that would collision detect with any bullets (On^2 very inefficient). I am now trying to make the base into a shape instead of a boring rectangle. I also want to perform collections of nearby squares when one is hit so that chunks can be taken of the base, instead of just the part that was hit. (easy to do with a rectangular array)

Is a 2 dimensianal arry still the best way to acheive this? Is there a way to create this array by somehow performing image analysis of a PNG to populate this array? Transparent parts would hold no base item at that [i][j].


texts:
I'm trying to play sound on other clients, so they could hear gunfire in the distance, but sound only works for the shooter. Here's my code:

    void Update()
    {
        ***

        if (Input.GetButton("Fire1"))
        {
            CmdFireWeapon(this.gameObject);
        }

        ***
    }

    [Command]
    void CmdFireWeapon(GameObject plr)
    {
       ***

        if (!plr.GetComponent<AudioSource>().isPlaying)
            RpcPlayWeapon(plr);

       ***
    }

    [ClientRpc]
    void RpcPlayWeapon(GameObject plr)
    {
        plr.GetComponent<AudioSource>().Play();
    }

I'm using 3D Spatial Blend, but there's no sound even with volume == 1 across all distance. Also tried with and without if(isPlaying) - no progress. What am I doing wrong?


texts: i want to move arrow by dragging and than want to toss/throw when i give swipe event

texts:
In My Application I Have One Arrow Image With Fix Center and i Can rotate it by touch move method on same center but i also need to Toss/trow the arrow after doing some rotation with dragging or without doing that
   How Can I Put The Toss/Throw Action  in MyApplication

Thank You Very Much In/ advance


texts:
I've a condition in my game where, I want my camera to follow the Player(its a body from Box2d) and in some not.
This is the start screen of my game:

Now, when i press a button(space) the player get an LinearVelocity in x,y direction and starts flying..

As soon as it reaches the end. The box is now out of the camera.

To fix this I made my camera centered the box.

This is where I screwed. I dont want my ground to come in the center it should always needs to be at bottom.. like in Picture 1 and the player should also needs to be at the left-bottom at the start of the game.  And when player flies away ... the x and y coordinates should be moved as my player moves ... i have certain height where player can fly so camera should be able to move in y-axis also.. and the game is endless running game so x- cordinates also keeps comming in.


texts: need a pathfinding algorithm from 1 column to another

texts:
grid contains weights and I need a max path sum from one column to another possible movement directions are (right, up & down only).

Can Djikstra or A* help ??


texts:
Ok guys I'm an aspiring game designer and I'm trying to develop a racing board game using real life as a basis for my mechanics. The problem im having is I'm not very mathematically inclined
 I found a formula on an urban planning website but I don't really understand it. Can anyone help me?


texts: How many times fragment shader is executed?

texts:
I have an OpenGL code, with 3 different shader programs.
I have a simple question, I know fragment shaders are executed for every every fragment in the scene.
But is there a way using which we can find how many fragments are there in the scene?
Correct me if i am wrong, but the fragment shader is executed for each fragments, so

Number of fragments = number of times fragment shader executed?


texts:
I have some trouble understanding how does glTranslate work.
At first I thought it would just simply add values to axis to do the transformation.

However then I have created two objects that would load bitmaps, one has matrix set to GL_TEXTURE:

public class Background
{
    float[] vertices = new float[]
        { 0f, -1f, 0.0f,
          4f, -1f, 0.0f,
          0f, 1f, 0.0f,
          4f, 1f, 0.0f };

    ....
    private float backgroundScrolled = 0;
    public void scrollBackground(GL10 gl)
    {
        gl.glLoadIdentity();
        gl.glMatrixMode(GL10.GL_MODELVIEW);
        gl.glTranslatef(0f, 0f, 0f);
        gl.glPushMatrix();

        gl.glLoadIdentity();
        gl.glMatrixMode(GL10.GL_TEXTURE);
        gl.glTranslatef(backgroundScrolled, 0.0f, 0.0f);
        gl.glPushMatrix();

        this.draw(gl);
        gl.glPopMatrix();

        backgroundScrolled += 0.01f;
        gl.glLoadIdentity();
    }
}

and another to GL_MODELVIEW:

public class Box
{
    float[] vertices = new float[]
        { 0.5f, 0f, 0.0f,
          1f, 0f, 0.0f,
          0.5f, 0.5f, 0.0f,
          1f, 0.5f, 0.0f };

    ....

    private float boxScrolled = 0;
    public void scrollBackground(GL10 gl)
    {
        gl.glMatrixMode(GL10.GL_MODELVIEW);
        gl.glLoadIdentity();
        gl.glTranslatef(0f, 0f, 0f);
        gl.glPushMatrix();

        gl.glMatrixMode(GL10.GL_MODELVIEW);
        gl.glLoadIdentity();
        gl.glTranslatef(boxScrolled, 0.0f, 0.0f);
        gl.glPushMatrix();

        this.draw(gl);
        gl.glPopMatrix();

        boxScrolled+= 0.01f;
        gl.glLoadIdentity();
    }
}

Now they are both drawn in Renderer.OnDraw. However background moves exactly 5 times faster. If I multiply boxScrolled by 5 they will be in sinc and will move together. If I modify backgrounds vertices to be

    float[] vertices = new float[]
        { 1f, -1f, 0.0f,
          0f, -1f, 0.0f,
          1f, 1f, 0.0f,
          0f, 1f, 0.0f };

It will also be in sinc with the box.
So, what is going under glTranslate?


texts:
I am building a 2D board game in Unity with a static camera pointed down at the game board. During the active phase of each player's turn, I want to detect where they click on the board. Fortunately, the board is laid out in an easy rectangular grid. (Essentially a trio of 5x5 grids).
Which of the following would be best practice to implement this?

Create invisible colliders for every square on the board and create a translation function that translates those back to board positions (5,3) with Raytracing?

Get the translated coordinates of the click and use a function to figure out which square (if any) the click is in using the mouseclick event handler (by calculating which square the grid coordinates fall in)?

Make each square a button with its grid identity encoded and use that in its OnPressed function?

Edit: 4) Some other idea I haven't thought of yet?
Experience level: I'm just learning Unity, but have written a lot of C# (and tons of other code).


texts: For Blender+Unity users— Would Blender's “UV Project Modifier” work in Unity?

texts:
So, say in Blender you have a Cube that you put a "UV Project Modifier" on, with an Empty (controlled by a Bone) as the Projector. In Blender when you move the Bone, the UV moves on the cube. Great!

But now let's say you wanted to bring that to Unity. Would that still actually work (being able to move the UV around with bone movement) or would it be busted?

I'm trying to test it myself and it seems a dud but I already struggle with Blender's export process so wanted to check here.


texts:
A game I'm working on has libgdx's TextField.  They work fine in every instance I've used them, however on a play tester's phone he says no typed text appears in the box until enter or space is pressed.  His specs:
Phone: S7 Edge Root: No Keyboard: Fleksy Android version: 6.0.1

The keyboard was causing some other issues (backspaces would not be recognized unless something had previously been typed into the box)  but when he switched to the stock keyboard his text still did not appear until pressing space or enter.

I have no problems on a couple of older phones running Android 5 and 4.  Has anyone experienced this or know a way to fix this issue?

Thanks!

Added code, though there really isn't much of my own.  I don't have access to the tester's device so I can't tell you exactly what is or isn't being executed.

import com.badlogic.gdx.scenes.scene2d.ui.TextField;

...

private TextField emailField;

...

String email = "email";
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
emailField = new TextField(email,skin);


texts: Java 2D Game Hitbox Detection & Rounded Corners

texts:
I am working on a simple 2D game with Java, Swing and no framework. I have a rectangular player that the user can move around. On the map are few obstacles which the player should not be able to go through. I did this by making a new Rectangle Object for the player and each obstacle with their bounds. But I’m not really sure if this is the right way to do it. It works but the movements of the player are not really user friendly. If the player wants to pass two obstacles they must be on the perfect coordinates to pass.

Is it even a good idea to check for intersections between the player and the obstacle with a Rectangle object or should I do it another way?

Now for my 2nd question:
I’d like to replace the rectangular hitboxes with the same hitbox but with rounded corners so the player could pass more easily.

This is what the game looks like with hitboxes enabled.

The code that checks if the player and the obstacles have yet intersected:

for (Player p : this.getPlayerArray()) {
    Rectangle recPlayer = p.playerBounds();
        for (Obstacle kiste : obstacleArray) {
            Rectangle recKiste = kiste.obstBounds();

            if (recPlayer.intersects(recKiste)) {
                p.setX(100); //Not actual code here
            }
        }
}

The function that returns the hitbox of the player / obstacle:

public Rectangle obstBounds() {
    return new Rectangle(this.getX(),
    this.getY(), image.getImage().getWidth(null),
    image.getImage().getHeight(null));
}


texts:
I need a function that allows me to rotate a grid data structure an arbitrary number of times 90 degrees clockwise.
Currently it doesn't appear as though the function has any effect on the ds_grid.

Below is the code I'm currently using, the function that calls it looks like:
ds_grid_rotate_alt(global.grid, irandom(3), 10);.

/// @description rotate grid clockwise 90 degrees x times

var grid = argument0;
var turns = argument1;
var width = argument2;

var gx = 0;
var gy = 0;

if turns > 0
{
    var grid_copy = ds_grid_create(width, width);

    for (gy = 0; gx < width; gy++)
    {
        for (gx = 0; gx < width; gx++)
        {
            //grid copy
            var data = ds_grid_get(grid,gx,gy);
            ds_grid_set(grid_copy,width-gy,width-gx,data);
        }
    }
    //copy results back to origional grid
    ds_grid_copy(grid_copy,grid);
    ds_grid_destroy(grid_copy);

    turns -= 1;
    ds_grid_rotate_alt(grid,turns,width);
}


texts: What does everyone like to use for UI elements for their games on the iPhone?

texts:
I'm asking this to get everyone's opinion -- I realize there isn't one "right way" to do this.  I've tried a few ways myself, including using Cocoa for everything including the game itself (good for simpler games, like card games for example), using Cocoa for the screens outside of the game and using my game engine to present game objects on the screen as UI.

What do people prefer to use for game UI?  I'm particularly interested in hearing about why you chose to go that way and if you found that your choice was a good one after implementing it.


texts: Is there any quick and easy way to make all bodies visible with Farseer physics engine for XNA?

texts: I just want to be able to see all my bodies on the screen for debugging purposes and i cant think of an easy way, for example i have make some edge fixtures with curved arcs attached and i just want to see what they look like!


texts: What is the purpose of the Allocation Callstacks button in Unity's Profile window?

texts:
I have an idea of what this button does, but I cannot find any specific information in the documentation.

What information does this button add to the profiling data? How can I see this extra information?


texts: Why does the order of Farseer collision categories affect collisions?

texts:
I've discovered a bizarre issue with the Farseer Physics Engine that I can't figure out. I have two Farseer bodies that I'd like to only collide with each other. To that end, I have the following code.

body1.CollisionCategories = Category.Cat1;
body1.CollidesWith = Category.Cat2;

body2.CollisionCategories = Category.Cat2;
body2.CollidesWith = Category.Cat1;

Which works fine. However, if I switch the categories around (shown below), the bodies no longer collide.

body1.CollisionCategories = Category.Cat2;
body1.CollidesWith = Category.Cat1;

body2.CollisionCategories = Category.Cat1;
body2.CollidesWith = Category.Cat2;

Some additional notes that might be relevant:

body1 is static, while body2 is dynamic.
body1 is created before body2 (although I switched the order and nothing changed).

Does anyone know why this happens? Based on my understanding of how Farseer uses collision categories (i.e. as masks using bitwise operations), the order shouldn't matter. Is it something silly I'm missing?

Thank you.


texts:
I have a concern regarding buying a song from an independent/amateur music artist. How can I demonstrate, if needed, that he actually sold that song to me and agreed to let me use his work for commercial purposes?! What if he decides, for a reason or another, to screw me saying that he didn't gave me authorizations?

The transaction etc. is made entirely online.

Thank you.


texts: When making pinball flippers in Unity C#, what would be the pros and cons of using a simple mesh transform -- where the mesh is properly centered around the wanted pivot, so its rigidbody could be torque force rotated -- vs creating the flipper with a joint? Thanks!


texts: Quick question regarding the Job system in conjunction with pure ECS. When would I use IJobProcessComponentData and when IJobParallelFor? I can just assume the first one if it is just juggling data from one component to the other akin to CopyTransformToGameObjectComponent with possibly some simple thread-safe computations while the latter might be used to handle results of complex computations that have been done outside of the job such raycasts or things referring to actual GameObjects etc.?


texts:
Edit

Okay, so I partially solved the problem by adding a rigid body component to the capsule. I read somewhere that apparently you have to have one in order to move on the server.

Problem 2

The next problem I have is that I can now move a capsule that is spawned by the client fine and the host can move it as well as many times as they like. The problem I am getting now is that when the host spawns a capsule the client cannot move it at all and I get a sort of glitch effect on the client side and the capsule still doesn't move on the host side. Is there a reason why it would only work one way and not the other way around? I thought at first it might have to do with Spawn vs SpawnWithClientAuthority but that doesn't seem to make a difference.

Project Summary

I have a pretty simple multiplayer project, all I want to do is have one player host and the other join as a client. Once they are joined together the two players can spawn a capsule and then when the user clicks on a capsule. They should be able to pick it up and move it around the scene and the other player should be able to see this action. I can get both players to connect to the server and spawn their own capsule and both players can see this. The movement script is done as well. However, it is only transmitted on the host side. When the client picks up the object it does not update on the server.

Problem

I have done a bit of debugging and have found that when I call the command on the client it is not being executed at all through line breaks and simple debug statements.

Code

public void OnInputClicked(InputClickedEventData eventData)
    {
        Debug.Log("clicked");
        if (isLocalPlayer)
        {
            if (Physics.Raycast(transform.position, direction: transform.forward, hitInfo: out hit, maxDistance: range))
            {
                Debug.Log("Hit capsule");

                objectID = GameObject.Find(hit.transform.name);
                objNetId = objectID.GetComponent<NetworkIdentity>();
                playerIDThatClicked = player.GetComponent<NetworkIdentity>();

                CmdAssignAuthority(objNetId, playerIDThatClicked);
                Debug.Log("grabbed");

            }
            else
            {
                //if we are releasing the object we want to unassign our authority
                if (objNetId != null)
                {
                    CmdAssignAuthority(objNetId, playerIDThatClicked);

                    objNetId = null;
                    Debug.Log("released");
                }
            }
        }

    }

[Command]
    void CmdAssignAuthority(NetworkIdentity target, NetworkIdentity player)
    {
        Debug.Log("inside cmd");
        current = target.clientAuthorityOwner;
        playerconn = player.connectionToClient;

        if (current != null && current != playerconn)
        {
            Debug.Log("Had authority now removing and replacing");
            target.RemoveClientAuthority(current);

            target.AssignClientAuthority(playerconn);

        }
        else if (current != null)
        {
            Debug.Log("removing authority");
            target.RemoveClientAuthority(current);

        }
        else if (current == null)

        {
            Debug.Log("No authority, adding one now");
            target.AssignClientAuthority(playerconn);

        }
        else {
            Debug.Log("CmdAuthority error");
            target.RemoveClientAuthority(playerconn);

        }
    }

Question

Am I calling this command correctly? The script is attached to a player prefab and the capsule prefab contains a network id and a network transform. I am pretty new to Unet and this feels like a noob mistake.


texts: How to force a custom component on every GameObject?

texts:
I want to have a custom component which will have a drop down. I want this to be applied to ever GameObject in the project, which means every GameObject in the hierarchy and every GameObject prefab. Something like a transform component. It should not be removable, and it should be added by default when creating new GameObjects.

In the drop down, I will select a few options, and I want to store those values in an array on that custom forced component for that GameObject.

So if I have 2 new GameObjects in scene named XYZ and ABC, and the component is PQR, I should be able to do this-

ABC.GetComponent<PQR>().someArrayVar = whatever;
XYZ.GetComponent<PQR>().someArrayVar = anotherWhatever;

Anyone know how to do this? Any help appreciated. Thanks in advance :)


texts:
Are there any format for storing quest data that can be processed independently by third-party tools? I don't want to code quests in code, because it will be hard to update and extend them, so I just thinking about generic system that allows to submit to a task, track its stages and rules necessary to fulfill some quest conditions and completion of a quest by player.

Basically, I'd like a simple text file for the start, so that errors in description can be easily edited and committed to repository. But I also want to be able run complex queries against quest DB, such as - "for which quests this quest is prerequisite" or "in which quests this component is used" or "what quests are available for a given environment". So the structure of the field in the format is important. I can of course invent my own, but it would save me a lot of hours to start with something workable.

Is there something generic like that?


texts: Compress the variance in a set of numbers?

texts:
I'm not sure if there's a better way to ask that, but I have a hovercraft which hovers by imparting force at each of four corners. I'd like to clamp the maximum variance between the thrusters so if one corner hovers over something higher altitude, the effect is less dramatic.

For example, if I had 4-6-8-10, I might want it to compress to 4-5-6-7.


texts: How do I make so when user moves the camera it doesn't go beyond the scene borders in Unity3D?

texts:
How do i make so when i move my camera, it doesn't go beyond the border of the canvas while playing. This is the script i use to make the camera move:

        if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Moved)
    {
        Vector2 touchDeltaPosition = Input.GetTouch (0).deltaPosition;
        transform.Translate (+touchDeltaPosition.x * speed, +touchDeltaPosition.y * speed, 0);
    }


texts: Compute cone angle (cos) given side and hypotenuse vectors at time 0 and world matrix at time 1

texts:
I need a formula for the cosine of a cone, given normalized side vector, normalized hypotenuse vector at time 0 and world matrix at time 1. This is needed to implement custom spotlights in a level editor which can be tweaked by user via standard translation/rotation/scale gizmo.

The cosine of the cone at time 0 (when world matrix is Identity) can be computed via this formula:

Vector3.Dot(side, hypotenuse);

I tried this formula for time 1:

Vector3.Dot(Vector3.Normalize(Vector3.Transform(side, matrix)), Vector3.Normalize(Vector3.Transform(hypotenuse, matrix)));

but it does not work.


texts: In Inform 6, what is LibSerial and how does it factor into action-based dispatching?

texts:
By no small amount of pain, I have discovered that the following  Inform 6 source doesn't work as expected: instead of calling the right branch of Bar.after based on the current action, it always prints Called from Foo:

Global action;

[ R_Process a;
    action = a;
    indirect(#actions_table-->a);
];

Verb 'foo' * -> Foo;
Verb 'baz' * -> Baz;

Object Bar "bar"
  with after [;
    Foo: "Called from Foo";
    Baz: "Called from Baz";
    ];

[ BazSub;
    print "[Baz]^";
    Bar.after();
];

[ FooSub;
    print "[Foo]^";
    Bar.after();
];

[ Main;
  <foo>;
  <baz>;
];

Running it produces the following output:

[Foo]
Called from Foo
[Baz]
Called from Foo

However, if I prepend the following three lines to the Inform script above, then it works as expected:

Constant LibSerial "foo";
Global reason_code;
Property additive life;

Now the output becomes:

[Foo]
Called from Foo
[Baz]
Called from Baz

The three lines are all important:

Omitting the definition of the LibSerial constant (i.e. keeping the other two lines only) causes Called from Foo to be printed from both callbacks.
Omitting the declaration of the (as far as I can see, unused) variable reason_code gives the following compile-time error:

"<constructing output>", line -65535:
Error:  No such constant as "reason_code"

Omitting the declaration of the life property causes a similar compile-time error:

"<constructing output>", line -65535:
Error:  No such constant as "life"

So basically my question is, what is going on here? What is the effect of defining LibSerial and why does it need the life property and the reason_code global variable to be declared?


texts: Drawing game app: How to use vector graphics instead of bitmap in Android?

texts:
I have a problem concerning the concept of using vector graphics instead of bitmaps in order to draw on canvas. Usually to draw on canvas we set a bitmap to that canvas and we start drawing pixels on it by simply moving our finger on the screen. However, this method will result very pixelated - relatively low-quality drawings.

It is noteworthy that there are some drawing apps that result in very smooth curves when you want to draw via them. After doing some googling and researching, I knew that there is the new concept of use vector graphics that is being used in order to draw smooth edged drawings on the screen.

Look guys, the thing is when I developed my drawing app, I used bitmap **(which was already there as an object given by Android)**in order to draw cubic Bezier curves. No matter how much I tried to smooth my drawings out, I always get stair-like edges.

If you are interested in how I developed the curve, please read this. If not, just ignore this bold paragraph:

In order to draw the cubic bezier curves I simply took the sampled touch points and for every 4 points in these sampled points I calculated the 2 intermediate control points (the ones that the curve never touch) to create a bezier through the sampled points. For the curve to appear, I used bitmap and paint objects given by android.

After getting the undesired result (low-quality curve), I decided that I want to use vector graphics in order to do the same thing but with a higher quality. The thing is that I am very new to Vector Graphics, that I don't know where to start.

My question is simple as is:
Is there a platform given to me by Android in order to use vector drawable like in the case of bitmap? If not, am I supposed to start this from scratch? I am clueless and any tip or hint from you will be greatly appreciated.


texts: Collision Response: game character vs. density function

texts:
Introduction

I am working on my own "novelty" game-engine project, where the world is represented by a continuous density function. It has only one interface, a function that returns the density at a given point:

float sample(float x,float y,float z);

I triangulate this density into an iso-surface for density == 1.0 using marching cubes. The iso-surface is then rendered using OpenGL to display the result on screen.

I have made a function using newton's method to approximate the nearest point in the volume with density equal to 1 (within an error margin) for a certain direction, like this:

vec3d hitTest(vec3d &origin, vec3d &direction);

I can use this to perform collision detection between my main character and the volume, by seeing if the character has transitioned from "outside" to "inside" of the volume during update. I am also able to find the normal at the hit point by doing 3 hit-tests and doing some simple vector math "(a-b).crossProduct(a-c)" or some such.

Question

How would I be able to calculate the proper collision response?

I am no expert in collision detection/response, so what I am after is a clear and consise explanation of what makes a "physically correct" impulse collision under my foretold circumstances.

Source code in pseudo/C++ is a big bonus!

Thanks!


texts: How can I run native code (in a DLL) from UnrealScript in UT/UE1?

texts: I'm seeking an example showing how to create a DLL that can be called from UnrealScript in Unreal Engine 1 or Unreal Tournament.


texts:
I've been developing a modification for the Source engine for well over a year, but am now facing some troubles with the weapons, gamemovement (player physics) and player feedback from explosives.

This is all because of my weakness in mathematics!!!

What books, tutorials or any  other various texts could you recommend (that have helped you).


texts:
How can I run a shader over the entire screen without interfering with other running programs? Specifically, I'd like to adjust the screen output with usability tweaks for my severely colorblind nephew. He has trouble playing certain games.
I'd like to avoid hooking into DirectX, and just run a shader over the entire screen. Is this something I can do in Windows without draining an unreasonable amount of resources?
I can use whatever language or tool is most practical for this, but I'm most comfortable with Java and HLSL.


texts: Proportional speed movement between mouse and cube

texts:
Hi i´m trying to move a cube with the freeglut mouse "glutMotionFunc(processMouseActiveMotion)" callback, my problem is that the movement is not proportional between the mouse speed movement and the cube movement.

MouseButton function:

#define MOVE_STEP 0.04
float g_x=0.0f;

glutMouseFunc(MouseButton);
glutMotionFunc(processMouseActiveMotion);

void MouseButton(int button, int state, int x, int y){
if(button == GLUT_LEFT_BUTTON && state== GLUT_DOWN){
    initial_x=x;
    }
}

When the left button gets clicked the x cordinate is stored in initial_x variable.

void processMouseActiveMotion(int x,int y){
if(x>initial_x){
    g_x-= MOVE_STEP;
}else{
    g_x+= MOVE_STEP;
}
initial_x=x;
}

When I move the mouse I look in which way it moves comparing the mouse new x coordinate with the initial_x variable, if x>initial_x the cube moves to the right, if not it moves to the left.
Any idea how can i move the cube according to the mouse movement speed?
Thanks

EDIT 1
cube http://oct.imghost.us/S1lC.png

The idea is that when you click on any point of the screen and you drag to the left/right the cube moves proportionally of the mouse mouvement speed.


texts: I'm building a game where enemies come in waves. I want to create a file where I can define data about the waves (# of enemies, spawn times, speeds, etc.). I come from a background in iOS and would normally use something like a plist. What would be the best way to do something like this in Java and Android?


texts: How to calculate vertex normals for a mesh in Java in OpenGL ES?

texts:
Can some one point me to Java code ( in Java not C or C++) that calculates all the normals for all the vertices of a mesh for OpenGL ES application. I need this for lighting. Lets say I have a cube with following vertices and indices:

float vertices[] = { -width, -height, -depth, // 0
                      width, -height, -depth, // 1
                      width,  height, -depth, // 2
                     -width,  height, -depth, // 3
                     -width, -height,  depth, // 4
                      width, -height,  depth, // 5
                      width,  height,  depth, // 6
                     -width,  height,  depth  // 7
        };
short indices[] = { 0, 2, 1,
                    0, 3, 2,
                    1,2,6,
                    6,5,1,
                    4,5,6,
                    6,7,4,
                    2,3,6,
                    6,3,7,
                    0,7,3,
                    0,4,7,
                    0,1,5,
                    0,5,4
                  };

In above specific example how many normals we need?


texts: How to define 648 units, with 22 different values in Java

texts:
A friend and I are currently looking at developing a game. We have 648 units that need to be defined, with 22 final values.

To define the units in the game, we've created an abstract class with 44 variables and two methods. For example, if I encounter this unit in the game, I would pass a method its value, and it would look at some sort of lookup table which give all these base, final values. The problem we've encountered is finding a method of doing this effectively, and securely.

For now I have a few units defined through enumeration, and have their values stored in an array. My partner suggested to create a defining class with a plaintext lookup table. However, I see the problem with such a solution would either be the length, or quantity of lookup tables. I have searched around, but most solutions entail the use of a server. Our current goal is to just release an offline client with everything already defined.

Does anyone have any suggestions on how to store 648 units with 22 different final attributes effectively, so that such an entity could be called later and examined?


texts: How do you build a rotation matrix from a normalized vector?

texts:
I'm trying to find the correct way to build a rotation matrix from a unit vector. I have two arbitrary points in space (p1 and p2), and I'm trying to create the vertices for a rectangle to span between them.

From the points, I can get a unit vector easily enough. From there I've been trying to create a rotation matrix that I can apply to a set of hard-coded vertices to get them oriented correctly. The rectangle extends along the X axis, so I'm trying to rotate it's X axis to match the unit vector.

So far I've tried GLM::orientation:

glm::vec3 direction = glm::normalize( glm::vec3( p2 - p1 ) );
glm::mat4 rotation4 = glm::transpose( glm::orientation( direction, glm::vec3( 0, 1, 0 ) ) );
glm::mat3 rotation = glm::mat3( rotate4 );

As well as the manual matrix creation method mentioned in this similar question:

glm::vec3 direction = glm::normalize( glm::vec3( p2 - p1 ) );
glm::vec3 rotationX = direction;
glm::vec3 rotationZ = glm::normalize( glm::cross( direction, glm::vec3(0,1,0) ) );
glm::vec3 rotationY = glm::normalize( glm::cross( rotationZ, direction ) );
glm::mat3 rotation( rotationX, rotationY, rotationZ );

However, in both cases I end up with rectangle rotations that seem fine for axis-aligned rotations, but which veer off in weird directions in all other cases. In both cases, I'm attempting to specify the positive Y axis as up, to keep the rectangle level, but the rotated rectangle always ends up twisted around despite that.

I'm obviously doing this wrong, but I may just not be understanding the problem well enough. If someone could point me in the right direction, I'd appreciate it.


texts: Detect which key was pressed last each frame

texts:
Why hello there, im developing a 2D game using XNA.
My character movment is currently based on the keyboard state.
Example (in the right order):

if (state.IsKeyDown(Keys.W))
    {
          //Do stuff
    }
else if (state.IsKeyDown(Keys.D))
    {
          //Do Stuff
    }
else if (state.IsKeyDown(Keys.A))
    {
          //Do Stuff
    }
else if (state.IsKeyDown(Keys.S))
    {
          //Do Stuff
    }

That way I am able to deny diagonal movment. So my problem is, if "W" is pressed, meaning the character is moving up, And a frame after that while W is still pressed and I press "S" for example, It will keep moving up. I've been looking for a solution for a while and didn't come up with anything good enough.
What I need help with is ideas about how to detect if a different key was pressed after W (because it is the first one to check, it doesn't check the others), while denying diagonal movment.
Any help would be sincerely appreciated, Thanks in advance.


texts: When the book talk about CreateSamplerState in D3d11, what I have to do in D3d12?

texts:
I want to build a virtual earth, so I read the book '3D Engine Design for Virtual Globes' by Patrik Cozzi and Kevin Ring.
But the book talk the CreateSamplerState in D3d11.I havn't used D3d11, I just learn D3d12 from the book '3D Game Programming WITH DIRECTX 12'by Frank D.Luna.
Does it mean the Sampler state in built root signature?
I get some D3d12 sample code here,maybe it can help to understand my question:

    // A root signature is an array of root parameters.
CD3DX12_ROOT_SIGNATURE_DESC rootSigDesc(4, slotRootParameter,
    (UINT)staticSamplers.size(), staticSamplers.data(),
    D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);


texts:
I want to set the initial data of a texture in an OpenGL 4.5 program (using OpenTK.Next and .NET), utilizing the new Direct State Access methods.

However, I cannot find a DSA version of glTexImage2D. There are methods like glTextureSubImage2D which accept a texture object ID, but using those to set the intial data fails with InvalidOperation.

I'm pretty sure there should be such a method... comparing textures to array buffers, array buffers do have a DSA version to set their initial data, glNamedBufferData.

According to the documentation, the DSA methods are all named ...Texture... unlike the "old" methods which are named ...Tex..., but searching through them didn't reveal me something like glTextureImage2D.

Anyone knows if there even is a DSA method to set the initial texture data?


texts: How should I implement a Game Over menu in Android?

texts:
By Game Over menu, I mean a menu displayed when you die, with an option to play again.

I have two approaches in mind:

Use OpenGL

Have some button textures ready. When the character dies, draw them. Listen for events on those textures.
Use a view

(This is what I'm doing now.) When the user opens the game, I have a basic activity, along with a basic view with a FrameLayout: The root is a GlSurfaceView and there's a menu on top of it (embedded in a LinearLayout). When the user hits "Play", this menu is translated away (using a translate animation) from the screen, leaving only the GlSurfaceView visible, with which the user can interact. I was thinking of implementing something similar when the game ends, but I'm not sure where to start.

I don't particularly like the first approach, since implementing button events in OpenGL seems hard.

How should I approach this?


texts: Separation of world state and animation in a turn based game

texts:
How do you handle the separation of animation from the world state within a turn based game? I'm working on a 2D grid based game currently. The below code is simplified to better explain.

When an actor moves, I want to pause the flow of turns while the creature animates and moves to the new position. Otherwise, the screen could lag significantly behind the world state, which would cause weird visual appearance. I also want to have animations that don't block the flow of the game - a particle effect could unfold over multiple turns without affecting gameplay.

What I've done is introduce two types of animations, which I call blocking animations and non-blocking animations. When the player wants to move, the code that gets executed is

class Actor {
    void move(PositionInfo oldPosition, PositionInfo newPosition) {
        if(isValidMove(oldPosition, newPosition) {
             getGame().pushBlockingAnimation(new MoveAnimation(this, oldPosition, newPosition, ....));
             player.setPosition(newPosition);
        }
    }
}

Then the main update loop does:

class Game {
    void update(float dt) {
        updateNonBlockingAnimations(dt); //Effects like particle explosions, damage numbers, etc. Things that don't block the flow of turns.
        if(!mBlockingAnimations.empty()) {
            mBlockingAnimations.get(0).update(dt);
        } else {
             //.. handle the next turn. This is where new animations will be enqueued..//
        }
        cleanUpAnimations(); // remove finished animations
    }
}

...where the animation updates the screen position of the Actor.

One other idea I am implementing is to have a concurrent blocking animation, where multiple blocking animations would be updated simultaneously, but the next turn wouldn't happen until all of them were done.

Does this seem like a sane way to do things? Does anyone have any suggestions, or even references to how other similar games do such a thing.


texts:
I'm making some rudimentary AI for my side-scroller and I need to know whether an AI unit can reach point B from point A simply by taking a jump.

Flight trajectory of my characters is a bit unusal as they can apply force in mid-air (like in Jazz Jackrabbit 2 for example), so unlike the classic trajectory of a projectile which is about...

  path that a thrown or launched projectile will take (...) without propulsion.

... I suppose that my problem is more about a projectile with propulsion (e.g. rocket).

To illustrate this, this is how the flight curve looks like for my character if I jump and continually press the "left button" (it looks different at the left end, this is where I was making some manuevers in mid-air):

The force applied during flight is always parallel to the X axis, so it is F = (-f, 0) if I hold "left" and it is F = (f, 0) if I hold "right".

He can move very much like a ski jumper:

So it differs a lot from the classic trajectory which is simply a parabola (source: wikipedia):

To make it more difficult, I am simulating simple air resistance so my characters can accelerate only up to some maximum speed value.

This is done by applying a small force in the opposite direction of travel:

b2Vec2 vel = body->GetLinearVelocity();
float speed = vel.Normalize(); //normalizes vector and returns length
body->ApplyForce( AIR_RESISTANCE_MULT * speed * speed * -vel, body->GetWorldCenter() );

The AIR_RESISTANCE_MULT is a constant that in my case equals 0.1.

Let's assume that my character is an infinitely small point.

And I'm NOT taking obstructions into consideration, so my question goes like this...

How to determine (at least reliably guess), given initial velocity V, an impulse J = (0, -j) that I apply to the character upon jump, gravity G = (0, g), force F = (+-f, 0) continually applied during flight and AIR_RESISTANCE_MULT if we really decide to take air resistance into account (this is optional) , whether a point lies below the curve drawn by the path my character will take?

I have literally no idea where to start with the calculations and in fact, I am not necessarily interested in an exact answer; a well working hack/approximation would be great as the AI by no means needs to act perfectly.

edit: I've decided to solve this using simulation as Jason suggests, but how to handle such a case?

Should I draw a segment from C to D and check whether the desired point lies below this segment?

Or should I binary search the timesteps between C and D to look for the point that is close enough in horizontal distance to the desired point, and only then check the vertical difference? (seems a bit overkill to me)


texts: How to use Facebook Web Hosting for my Unity Game for both WebGL and GameRoom

texts:
As can be seen from the
Facebook's official Docs

It says that

  To have both a Gameroom and a Facebook Web Game, you should leave your Facebook Web Games URL (https) unchanged. For example, https://friendsmashsample.herokuapp.com/

and also

  Otherwise, if you only have a Gameroom title, you should enter https://localhost/ as shown here:

I wanted to know if there is a way to get both of them working instead of hosting WebGL game on my server and putting it's URL?

I have even tried to enable the Simple Web Hosting but the toggle just reverts Back to off upon saving.


texts:
In my game I want to have the different anti-aliasing option like: none, x2, x4, x8 and x16. I know that you can use anti-aliasing with Graphics2D in the way below bu is there any way that I can use the different levels of anti-aliasing (x2, x4, x8 and x16)?.

RenderingHints rh = new RenderingHints(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHints(rh);


texts:
I developing my game, which still in alpha, and plan to sell it via Steam. I already applied to Steam partnership program and want to publish my 'coming soon' Steam page to start gather wishlists, but it on hold for now.
I don't have any promotional material yet, but people on social media positively reacting to gifs of my game. Is it good idea to publish Steam page right now with temporary thumbnail and screenshots of current version and then change everything later? Or should I make my page appealing first?


texts: Simulate the player floating in the water

texts:
I am creating my first game in Unity and now I have a problem.

I created a waterpool (a blue quad) and I want to simulate the floating of the player, so when the player is in the water, its Y position would be equal to that of water.

I think a picture is clearer: the water is blue, the player is blue.

I tried to do it this way but it does not work:

public float myYpos;

void OnTriggerEnter(Collider other) {
   if(other.tag == "Water") {
      walkSpeed = walkSpeed - deltaWaterSpeed;
      jumpHeight = jumpHeight - deltaWaterJump;

      // DOESN'T WORK
      //myYpos = transform.position.y;
      //myYpos = myYpos + 1;
      //transform.position = new Vector3(transform.position.x, myYpos, transform.position.z);
   }
}

This is a gif of my game:

I also do not know why sometimes the player is hidden in the water (I see only water), why?

Thanks to anyone who wants to help me.

Thanks for the answers. It is a 2D game but I stupidly followed a tutorial for 3D and so now I go ahead with 3D.

I dont' have a rigidBody on the Player.
I added the OnTriggerStay as recommended but the result is this:

   void OnTriggerStay(Collider other) {
      if(transform.position.y < other.transform.position.y) {
         transform.position = new Vector3(transform.position.x, other.transform.position.y, transform.position.z);
      }
   }

I deleted the OnTriggerEnter() and OnTriggerExit() methods.

Why the player jumps up and down? Why it doesn't float (a few mm below the surface), but quite a bit below?

Ok, now actually it does what it should have done, but I realized that was not what I wanted.

It behaves in this way:

The water quad has Y position = 8 and when the player is inside water its Y position is rightly 8.
However, this generates this first effect while I prefer the second: the player is on the surface or nearly so, regardless of the height of the water.

How can I get this?

I know I have asked one thing and I got the correct answer but only now I realized that I didn't know what I wanted. Sorry...

In any case, why the player does not jump in the water? It jumps only if it is attached to a gray wall. If it is in the water it doesn't jump but parameters for the jump are setup...


texts: Unity is Creating Black Boxes when I look around

texts: Please help me with this issue. I believe it came about after I finished tweaking post processing behavior in a minor way. If anyone has any idea please share it. I tried to rebake lighting on both scene and lightmaps tabs and it didn't make any difference.


texts: Problem with drawing textures in OpenGL ES

texts:
I'm developing a 2D game for Android and i'm using the framework which has been told in the book which named Beginning Android Games by Mario Zechner.So my framework is well designed and using OpenGL 1.1.It's similar to libgdx.

When i put my textures adjacent each other in my 2d surface,there are some spaces size as 1 px.But this problem only occur on my tablet.There aren't a problem like this on my phone.It's like in this picture:

What can be the problem?I can't fix it from one week.


texts: VS2013: Compiling Shaders with Shader Model 5.0

texts:
When I try to compile two HLSL files included in my project, the compilation fails with an error:

  Error error X4502: invalid vs_2_0 input semantic 'INSTANCE'

However, I notice it's trying to use shader model 2.0; when I'm trying to use 5.0:

Why is the shader compiler trying to use the 2.0 model when I've told VS to use 5.0? Or have I misunderstood?


texts: Should I be worrying about limiting the number of textures in my game?

texts:
I am working on a GUI in XNA 4.0 at the moment. (Before you point out that there are many GUIs already in existance, this is as much a learning exercise as a practical project). As you may know, controls and dialogs in Windows actually consist of a number of system-level windows. For instance, a dialog box may consist of a window for the whole dialog, a child window for the client area, another window (barely showing) for the frame, and so on. This makes detecting mouse hits and doing clipping relatively easy. I'd like to design my XNA GUI along the same lines, but using overlapping Textures instead of windows obviously.

My question (yes, there's actually a question in this drivel) is: am I at risk of adversely affecting game performance and/or running low in resources if I get too nuts with the creating of many small textures? I haven't been able to find much information on how resource-tight the XNA environment actually is. I grew up in the days of 64K ram so I'm used to obsessing about resources and optimization.

Anyway, any feedback appreciated.


texts:
i'm developing a 2d game (top down), and i'm a beginner.
Now, i've to create a map, with object (to interact with) ...
I don't know how to .. manage the problem !
Does anyone can help me ? What are the methodology used ?
Thanks


texts: What are the limitations of retro consoles?

texts:
I'm interested in creating a retro look for a game, and I'm currently in the process of deciding just how retro (which generation/console). What would make it easier would be if there was some sort of wiki/document on the limitations of each console, such as maximum number of colours total, maximum per sprite, number of layers, max tiles, max tile size, sprite size, etc., etc.. Take the Game Boy for example. 4 colours, yes, and I can find the screen resolution too. But what about all the other limitations?

So if anyone knows any good resources, it would be a huge help. I find that the freedom that today's generation of computers and consoles provides is a little too much, in that I can just keep adding more and more to it, and I'll never finish. I'd love to set a limit, and do the best I can within that limit.


texts: Unity Problem with colliding instances of same object

texts:
I want to check if object's instance is overlapping with another instance (any spawned object with another spawned object, not necessary the same object). I'm doing this by detecting collisions between bodies. But I have a problem. Spawned object (instances) are detecting collision with everything but other spawned objects. I've checked collision layers etc. All of spawned objects have rigidbodies and mesh colliders. Also when I attach my script to another body and I touch that body with an instanced object it detects collision. So problem is visible only in collision between spawned objects. And one more information I have script, rigid body and collider attached to child of main object.

    using UnityEngine;
using System.Collections;

public class CantPlace : MonoBehaviour {

    public bool collided = false;
    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
        //Debug.Log (collided);
    }

    void OnTriggerEnter(Collider collider) {
                //if (true) {
                        //foreach (Transform child in this.transform) {
                        //              if (child.name == "Cylinder") {

                                //collided = true;
                                Color c;
                                c = this.renderer.material.color;
                                c.g = 0f;
                                c.b = 1f;
                                c.r = 0f;
                                this.renderer.material.color = c;
                                Debug.Log (collider.name);
                        //}
            //  }
                //}

        //foreach (ContactPoint contact in collision.contacts) {
    //      Debug.DrawRay(contact.point, contact.normal, Color.red,15f);
    //  }

    }
}


texts:
I am trying to draw a simple 32x32 PNG image using SharpGL and OpenGL 2.1.
Despite many hours of searching, reading answers to similar questions, nothing could solve my issue. The image is showed as a white square.

I tried debugging OpenGL using glGetError() but it always returns 0.
I have no idea of what could be the problem.

Some help would be very appreciated!

Loading method

public static GLImage LoadImagePNG(OpenGL gl, Bitmap bmp)
{
    bmp = ResizeTo(bmp, 32, 32);

    uint[] textures = new uint[1];
    gl.GenTextures(1, textures);

    uint texture = textures[0];

    gl.Enable(OpenGL.GL_TEXTURE_2D);

    BitmapData data = bmp.LockBits(
        new Rectangle(0, 0, bmp.Width, bmp.Height),
        ImageLockMode.ReadOnly,
        PixelFormat.Format32bppArgb
    );

    gl.BindTexture(OpenGL.GL_TEXTURE_2D, texture);

    gl.TexImage2D(
        OpenGL.GL_TEXTURE_2D,
        0,
        4,
        bmp.Width,
        bmp.Height,
        0,
        OpenGL.GL_RGBA,
        OpenGL.GL_UNSIGNED_BYTE,
        data.Scan0
    );

    Console.WriteLine(gl.GetError());

    bmp.UnlockBits(data);

    gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_S, OpenGL.GL_CLAMP_TO_EDGE);
    gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_T, OpenGL.GL_CLAMP_TO_EDGE);
    gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR);
    gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR);

    // not disposing the Bitmap on purpose (for now)

    return new GLImage(texture, bmp);
}

Render method

public static void DrawImage(OpenGL gl, GLImage img, double x, double y)
{
    gl.PushMatrix();
    gl.Translate(x, y, 0.0D);

    gl.ActiveTexture(OpenGL.GL_TEXTURE0);
    gl.BindTexture(OpenGL.GL_TEXTURE_2D, img.TextureID);
    gl.Enable(OpenGL.GL_TEXTURE_2D);

    gl.Begin(BeginMode.Quads);
        gl.TexCoord(0.0f, 0.0f); gl.Vertex(0, 0);
        gl.TexCoord(1.0f, 0.0f); gl.Vertex(img.Width, 0);
        gl.TexCoord(1.0f, 1.0f); gl.Vertex(img.Width, img.Height);
        gl.TexCoord(0.0f, 1.0f); gl.Vertex(0, img.Height);
    gl.End();

    gl.Disable(OpenGL.GL_TEXTURE_2D);

    gl.PopMatrix();
}

and GLImage being a custom class

GLImage

public class GLImage
{
    public uint TextureID { get; private set; }

    public Bitmap Bitmap { get; private set; }

    public double Width
    {
        get
        {
            return this.Bitmap.Width;
        }
    }

    public double Height
    {
        get
        {
            return this.Bitmap.Height;
        }
    }

    public GLImage(uint textureID, Bitmap bmp)
    {
        this.TextureID = textureID;
        this.Bitmap = bmp;
    }
}

Thank you!


texts: What is the best time to implement Multiplayer system?

texts: I have been starting a new online multiplayer game project this week and as the title says - Is it better to implement the Multiplayer feature right away, or is it ok to implement it when the game already has some other stuff, like maps and physics?


texts:
I have a simple function to determine whether an entity can see another, in a top-down tile-based game (this is actually a tiny bit more complex in my game, to determine whether to see the first block, but I simplified it for this example):

public static boolean canSee(int x, int y, int x2, int y2, Area area) {
    Array<Tile> blocks = new Array<>();
    Utils.Bresenham.Plotter plotter = (x1, y1) -> {
        Tile t = area.getTileAt(x1, y1);
        if (t.blocksView()) {
            blocks.add(t);
        }
    };

    Utils.Bresenham.line(x, y, x2, y2, plotter);

    return blocks.size == 0;
}

// Example below:

P = player, E = enemy, B = block

.....
.....
.....
P.B..
B...E

Now the problem I have is that in this position, the enemy can see the player, but the player cannot see the enemy (because the most top 'B' blocks the Bresenham).. and I'm not sure what's a good way to fix this.


texts: unity3D Angry bird orthographic 3d approach

texts:
i want to create a game like angry birds but in orthographic mode 3D .

i want to give the player the ability to Jump to the Red and Blue Platform (see the picture below) with the Click, Drag  and release
however i dont know how to ge the exact direction wanted by the player and with the orthographic view

Camera.ScreenToWorldPoint(Input.mousePosition)

it gives me a weird vector
so i would like to hear ur approaches to solve this.


texts:
Here is a screenshot of the Input Manager for my project:

The 9th and 10th axis refer to Axis1D.PrimaryIndexTrigger (Squeeze) and Axis1D.SecondaryIndexTrigger (Squeeze) respectively, as documented on this page.

However, Input.GetAxis(trigger) always returns 0, even when

the trigger name is correct, and
I am squeezing the corresponding trigger really hard.

While running the debugger, I used my right Oculus controller to interact with objects in my scene. Here is the debug window:

Even though I was squeezing the corresponding trigger on my right Oculus controller, Input.GetAxis(trigger) still returned 0, thus causing my method to return early.

Here are the fields and properties of my Hand class, in which I am invoking the Input.GetAxis(trigger) method:

public enum XRHandControllerNode
{
    Left,
    Right
}

private XRNode trackedXRNode =>
    this.TrackedXRNode == XRHandControllerNode.Left ? XRNode.LeftHand : XRNode.RightHand;

private const float MinimumSqueeze = 0.8f;
private string trigger =>
                   this.TrackedXRNode == XRHandControllerNode.Left ?
                   "LeftIndexTrigger" :
                   "RightIndexTrigger";

public XRHandControllerNode TrackedXRNode;

Why does Input.GetAxis always return 0, and what changes should I make to ensure that any squeeze of the trigger will be correctly detected?


texts: Why do we move the world instead of the camera?

texts:
I heard that in an OpenGL game what we do to let the player move is not to move the camera but to move the whole world around.

For example here is an extract of this tutorial: OpenGL View matrix

  In real life you're used to moving the camera to alter the view of a certain scene, in OpenGL it's the other way around. The camera in OpenGL cannot move and is defined to be located at (0,0,0) facing the negative Z direction. That means that instead of moving and rotating the camera, the world is moved and rotated around the camera to construct the appropriate view.

Why do we do that?


texts: Prefabs scaling change also the original prefab

texts:
I want to work with a prefab as local and global variable? something like that.
So my question is how to change a prefab scale without affecting the original prefab.


texts:
Trying to change text in a text box, and have multiple lines on it, i found something online talking about "\n" but this came up.

Non-invocable memeber 'Text.text' can not be used as a method.

This is my code
private void Start()
{
    if (creditEnding)
    {
        startText.text("You, died? \n well you should get some sleep anyways");
    }
}


texts:
Surely OpenGL has a way to set the vertex color mode. By default it is multiplication.

When I have an existing texture on a quad to represent a player in my game, I want to add color to it. As of now, doing so only multiplies the color with the texels on the quad. So if I have a color that represents bright light say (128,128,128) what I want is additive behavior: take the color in the texel and add the channels together.

I have not found anything to do this automatically in OpenGL without the use of shaders or including a second draw step on one sprite with a different blend mode to simulate this.


texts: Game Characters vs Characters in other medias

texts: How do a characters designed for a game differ from characters made for books or movies? When a book or a movie is converted into a game, what are the differences and similarities that have to be addressed? Are there pitfalls in character design when jumping between these different medias?


texts: Does SoundEffect.CreateInstance load from file everytime?

texts:
This is something which has been bugging me. If I create a SoundEffectInstance via  SoundEffect.CreateInstance() I'm meant to dispose of it when I'm finished with it. SoundEffect.CreateInstance() does not use ContentManager as far as i can tell.

So does it load from file or does it keep a copy in memory? Loading from file would obviously be very slow :-/


texts:
Working on my game, I'm at the point where I need to track all of the units in the world so that I can do nearest-neighbor checks for combat. This is an RTS-like game, with potentially thousands of small automated units moving around.

I've been looking into KD-Trees and Quadtrees (especially Point Quadtrees). I'm still trying to learn the details of how they work, but so far Point Quadtrees are making the most sense to me. However, I'm getting the impression that KD-Trees are quicker to search, which is important with the number of points I'll have in the tree.

On the other hand, in my case, I'm going to be tracking a massive number of units that are always moving. From frame to frame, their positions will always be different. Quadtrees are apparently faster to rebalance than KD-Trees, but I don't know if that is applicable when you are rebalancing every point in the tree.

I'm wondering if it would be better in this case to just scrap the tree each frame and rebuild it from scratch, rather than try to rebalance every single point in the tree? If a Quadtree is quicker to rebalance, does that also mean it is quicker to build from scratch? If so, that might be more important for performance than the KD-Tree's search speed, depending on how much of a burden it is to create the tree, but I don't know...


texts: Understanding constant acceleration in terms of game physics simulation

texts:
There are various integration methods that can be used for games. I am trying to write a simple physics engine deciding between semi-implicit Euler and Verlet variants.

What I don't understand is where most information says that they work well for constant acceleration. Say more than one force acts on a body, and acceleration is calculated using force/mass. Velocity and position are derived from this. This means that the acceleration is not constant surely?

Am I incorrect in my understanding that applying a force in one step, and a different force at another step, is variable acceleration? Is it simply that the error amount is small enough to be ignored. So semi-implicit Euler, with fixed time-step but variable acceleration, for example, will be a good approximation?

I'm very confused, I've read so many different things. I'd appreciate any insights. Thanks!


texts: Parsing "pick up" action in a text-based RPG

texts:
I’m coding a text-based RPG and I have my controls working: I have a string checking what you write in against an array of if statements.

It can get it right with everything other than my pick up action.

My if statements are set out as follows:

int game_main() {

    string PlayerOption;

    //I have a few lines of cout statements just for my gui/hud

    cin >> PlayerOption;

    if (PlayerOption == "look") {
        //it’s then just calling a script from a separate header file
    }
    else if (PlayerOption == "pick up") {
        //another script from that header
    }

My look command and all my others work but I don’t know how to set it up right.

I've tried putting it like "pick up", I tried it like "pick"" ""up" and a couple other ways but I don’t know how to properly write the expression.

Even then my problem might be with my string and not my if statement so any suggestions would be greatly appreciated.

And I think @DMGregory might be right about the word boundaries because even with that command if I make it accept "pick" it works it’s only when I ask it for two words it really breaks

Is there any way I could get around that?


texts: Command Shell text adventure - input methods for scrolling through text (lua)

texts:
I'm writing a simple text-based adventure in lua. The intent is the user clicks on the game.exe and it loads up the command prompt or whatever command shell they have and they play the game there.

A problem I'm having is I often want to display a small amount of text at a time so the ui isn't overflowing with chunks of words. So I'm requiring the user to input something, preferably enter, to scroll through to the next bit of text.

i.e.

print("I want you to go to the park for a bit to start out.")
io.read()
print("After a few minutes I'll contact you, can you do that? (yes/no)")
confirm=io.read()

I've been using a blank io.read() which will ask for user input and allow them to type characters and require them to hit enter, but not save what they wrote if anything. The intent is for the user not to write anything though and just hit enter, and only to write when they are given choices in brackets as seen in the second half. I feel like this is confusing and unintuitive, I was wondering if there was a simple better method. I see there are better languages for writing text based adventures, but I want to just stick to lua atm. If there is advice from another language, I can try and translate it over although you'd probably have a better idea of how. Examples are appreciated if there is a lua solution.  Ideally I'd want to prevent input outside of pressing enter to scroll through text, or a timer so the next bit of text displays with some delay if that's possible for a simple windows shell like command prompt.


texts:
I am using a simplex 2D noise to generate my worlds so far.  This however was never the plan and has the downside that I basically can only generate a heightmap.  Instead I want to aim for floating islands scattered in the sky, but I fail to see how I can utilize 3D noise properly for this.

Based on a simplex 3D noise function I am currently generating noise like this:

float
sc_perlin_noise3_ex(const sc_perlin_t *perlin, float x, float y,
                    float z, int octaves, float persistence,
                    float base_frequency, float base_amp,
                    float lacunarity)
{
    int i;
    float freq = base_frequency;
    float amp = base_amp;
    float max = 1.0f;
    float total = 1.0f;

    for (i = 0; i < octaves; i++) {
        total += sc_perlin_noise3(perlin, x * freq, y * freq, z * freq) * amp;
        max += amp;
        freq *= lacunarity;
        amp *= persistence;
    }
    return total / max;
}

Problems start there: first of all I think I got octaves wrong, at least the outcome is very unpredictable.  Persistence would be a value smaller 1 that removes the effect of the higher octaves.

Secondly however I have a general problem understanding how 3D noise works.  From my understanding a value < -1 could mean air, a value > 1 would be solid and 0 is the thin line between them (the surface).  First of all however I get a lot more values below zero than above zero, so I had to flip those two around.  That seems odd, do I have the math wrong?

The actual problem however is that I cannot locate "islands" properly.  Say I have a container of 256^3 in size and I want to have one large island in there with maybe up to three smaller islands in there I have to ensure that:

no island is cut off at the edges
that I only get two even sized islands in my block
I have some better control of the actual appearance of my island.  For instance it would be nice if it had an actual flat-ish surface where I can put a heighmap on top of that for mountains etc.

Based on that I have the feeling I am on the completely wrong track here.  Can anyone give me some pointers on where to head now?

Generally speaking I would like to have something that looks like this: floating island


texts: How often do loops repeat in game maker? Is it every step, or as fast as it can handle? I need it to loop every step, is it possible to do that? I'm talking about in code, I have a do until loop. Just interested in the facts, here.


texts:
I was given a task to make a 3D game for Android, but since I never programmed games and opengl until now I'm totally lost on how and where to start.
Right now I'm using libgdx framework to ease my development or at least I thought it would.
I looked into invaders libgdx demo, but everything is so confusing and not consistent with latest version of framework, and it also looks that it's not very clean and scalable approach.

I have two 3D models, ball and basket. Now I need to animate ball throwing with all the math for hitting the basket, bouncing from basket and floor etc.
So my question is can somebody please help me out or direct me to some useful resources about those kind of games.

I somehow managed to get ball moving by rendering ball model and calling glTranslatef to move it, but that's it, all it do is just moves constantly in same direction. I would like to pick it and throw it in arc to hit the basket.


texts: How to share values between different shader programs?

texts:
I am using Unity but this might concerns all type of shaders. I would like to know if this is possible to share values between different shader pass.Let's imagine that I am computing something in the first pass and I would like to use this value in a second pass, is it possible ?

If this is possible, how can I do that ?


texts: How come serverless functions are so much more expensive than a VPS hosting my PHP API?

texts:
I'm working on an online turn-based game. I will have a server, but it will be used strictly for storing match data and relaying it to the match's participants (or spectators). For simplicity, no game logic will be processed in the server and the participants will be the ones to decide the legality of the enemy's moves etc.

My backend cloud knowledge is limited. I can work fine with PHP and MySQL, so I can technically make a PHP API, host it, and have the players poll it via HTTP requests every few seconds to get updates on the match (or upload commands). The PHP script will always open a MySQL connection, do one or two small queries and return a tiny bit of JSON-formatted data. To summarize, I believe that a single request would take at most 2 seconds to complete, and the output will be usually less than 100 bytes.

Given this fact, I figured I could perhaps try one of those serverless cloud functions services, like Azure's. It sounds just perfect for my kind of scenario.

For this project, I am estimating at most 100 users playing a match at any given time. And given the way the game is designed, they should probably poll data every two seconds. So 100 * 30 * 24 * 60 * 30 = ~130M executions per month. With Azure, that could be around $540 monthly just to support about 100 players.

This got me thinking, what if I just host the PHP API and MySQL database in a normal VPS, like GoDaddy's perhaps? Their cheapest option is about $50 a month. They don't meter the number of requests, concurrent users or bandwidth used (my usage is pretty low anyway, less than 15GB monthly).

So my question is, how come a 'serverless function' service is massively more expensive than just using a normal VPS to host my PHP API? Is there a catch that I may be missing?

Naturally it's all about testing - I should try both of them, but I figured someone has been through this already, or perhaps there is something obvious I am missing.


texts:
I am fairly new to using Quads, so I'm not sure how I can properly describe this issue in all honesty or to even hazard a guess as to why it's happening, so I have a screenshot to illustrate.

So the white lines are actually Quads, the Red lines are just rectangles. So if you can see the issue, for some reason every "now & again" I will get this issue were I get this somewhat looking "dotted line" which will sometimes be a full end-to-end line.

I'm not too sure what's causing this issue, I have a feeling it has something to-do with the way I'm drawing the quads, I don't think it's an incorrect vertices purely because the because of the thickness of the line, this leads me to believe it's the rendering:

effect.CurrentTechnique.Passes[0].Apply();
device.DrawUserPrimitives<VertexPositionColorTexture>(PrimitiveType.TriangleStrip, vertices, 0, totalNumberOfQuads);

This is the order I'm adding the vertices:

Top Left Segment Corner
Top Right Segment Corner
Bottom Left Segment Corner
Bottom Right Segment Corner

So after getting the vertices in the correct order, things are now even stranger, as this is an image of the current output:

Here's my Current Code, including the rendering:
http://pastebin.com/yK5yBZy0


texts: How should I approach AI for Spades game?

texts: I was hoping some one could point me in the right direction about what type of AI you would use for a Spades game? For instance, would you create a behavioral tree or would you implement some other type of AI concept. I'm fairly new to AI which is why I'm hoping to get some AI vets to chime in.


texts: Need help deciding on an ability system in Unity

texts:
I'm making an RPG and got to the point where I want a player to be able to use abilities. I decided to use a command pattern to keep keybindings flexible and now I've arrived with the following dilemma:

Command is an abstract class with an abstract method called Execute(). Every ability has a command class (for example FireBallCommand). I have a PlayerInput class. All buttons and the abilities that belong to it are defined there:

public class PlayerInput : MonoBehaviour {

private Command buttonF;
private Command buttonQ;

private PlayableCharacter character;

void Awake () {
    character = GetComponent<PlayableCharacter>();
    Initialize();
}

void Initialize()
{
    //Setup controls here
    //TODO: Get user's saved controls from db

    //Temporarily hardcoded
    buttonF = new BasicAttackCommand();
    buttonQ = new FireBallCommand();
}

void Update () {
    if (Input.GetKeyDown(KeyCode.F))
    {
        buttonF.Execute(character);
    }
    if (Input.GetKeyDown(KeyCode.Q))
    {
        buttonQ.Execute(character);
    }
}
}

The FireBallCommand class looks like this, (atm it creates a GameObject because Command does not derive from MonoBehaviour because I read you should/cant create object using 'new' with MonoBehaviours, in code):

public class FireBallCommand : Command {

public override void Execute(PlayableCharacter character)
{
    GameObject go = new GameObject();
    go.AddComponent<FireBall>();
    go.name = go.GetComponent<FireBall>().Name;
    go.GetComponent<FireBall>().Execute(character);
}
}

Next, the abstract class Ability contains an abstract method Execute() as well. It also contains some properties such as name and cooldown. The actually ability derives from Ability and actually executes the ability:

public class FireBall: Ability {

PlayableCharacter character;

public override void Execute(Character character)
{
    this.character = character as PlayableCharacter;
    StartCoroutine(Fire());
}

IEnumerator Fire()
{
    //Here it fires the fireball but there's no need to post that here.
}
}

This is the first time I am making a system like this. The dilemma is that I am not sure whether this is a right way to do it. It feels like casting one ability or spell is passing way to many classes and taking too much code in general. I thought of creating an AbilityManager that is always in the scene, which could be called to cast any spell/ability and takes a player as parameters.

In short: Do you think this would be a fine and fairly clean way to create an ability system? What other way(s) do you suggest? What could I change/remove/add to improve it?

P.S if anyone feels like answering this. I'm not sure where and how to implement cooldowns for the abilities in this system. Got an idea? :)

Thanks a lot in advance guys, if there's anything I should provide please let me know.


texts: Using Part of prefab as script parameter

texts:
I'm trying add a weapon to Eithan - the third person character. So I want to take his hand, which is part of the prefab Eithan (the weapon location) and use it in the my Player.cs script to Instantiate the weapon.
I created a parameter in the script for the hand: [SerializeField] GameObject weaponSocket; and I tried to Instantiate the weapon like this like this: Instantiate(weaponPrefab, weaponSocket.Transform);, but I just cant drag the hand to the parameter.
Anyone knows how to do this correctly?
Thank you!
Images: Player script: https://imgur.com/RcvKeXN
Trying to drag the left hand to the parameter (indicated by red arrows): https://imgur.com/RB63c9d


texts: What will happen if the argument of mix() or clamp() is above 1 or below 0?

texts:
There's two magnificent intrisincs: mix() in GLSL and clamp() in HLSL, which are used to implement linear interpolation. Let's say we have a variable:

float v = ?; // where ? can be [-FLOAT_MAX, +FLOAT_MAX]

and then we do:

gl_FragColor = mix(value1, value2, v);

So, the question is: does it works the correct way under GL or DirectX? Should I EXPLICITLY normalize the value of v like this:

gl_FragColor = mix(value1, value2, clamp(v, 0.0, 1.0));


texts:
I am just beginning to dip my tow into game programming and have been reading up on SDL, SFML, OpenGL, XNA, MonoGame and of course DirectX. (Needless to say there are a lot of choices out there)

As much as I like SFMLs syntax I have chosen to read up and start with SDL as it is pretty ubiquitous and available on every platform (Windows, Linux, Mac) and also available on portable devices (Android, iOS) with the current exception of WinPhone 7

After that pre-amble here is my question.

I notice that the docs say that for the windows platform the SDL API calls through to DirectX for higher perf. ( http://www.libsdl.org/intro.en/whatplatforms.html )

Microsoft have said that for Metro Game Apps you can only use DirectX (which means no XNA, no OpenGL, no SFML, etc, etc)

My question is: If SDL just wraps DirectX calls will I (we) be able to use SDL to bring games to the new Metro WinRT environment and Windows 8 marketplace?

This would be great if possible. Additionally as WinPhone 8 is supposedly built on Win8 then this could mean SDL would be available on the win phone in the future too.

Thanks for your time in responding to this question and I look forward to hearing your response.

EDIT:

Based on DeadMG's answer I have installed Visual Studio 11 (beta) in Windows 8 Consumer Preview (CP) and went file->New to check project types. The project types:

"Blank Application", "Direct2D Application" and "Direct3D Application"

look of interest. I have selected "Direct2D App" but SDL generates its own window when you call: SDL_INIT

Is it possible to link/setup the SDL window to point to the Direct2D surface in the this project?


texts: Execute script in edit mode when scripts finish compiling, without an object in the scene

texts:
I need to inspect some method information before game starts to implement something in Unity.

I can run the script by [ExecuteInEditMode] attribute, however it only works if at least one object in the scene has the script as component.

What I want is to run the script in edit mode as soon as Unity finishes each recompilation, without a scene object, so other developers can use my library/framework without creating objects manually.

How do I run the script in edit mode after the scripts recompile, without creating an object in the current scene?


texts: Ideal draw order - sort primarily by distance or material?

texts:
When it comes to pre-sorting the draw calls for a given frame, I am aware of two different methods for optimising.

The first is to batch draw calls by their material. This minimises shader changes and limits the number of times constant buffers, textures, and other data need to be switched or updated also. Furthermore, this approach leads to easy multithreaded commandlist generation (important in the coming era of DX12 and Vulkan!), each thread can build a list of draw calls for each material independently.

However, one major source of framerate slowdown is 'overdraw'- i.e. drawing partially or fully obscured geometry BEFORE drawing the geometry that obscures it. When drawing roughly front-to-back the fragment shader has to do far less work because obscured pixels can be depth culled.

However, in order to sort geometry front-to-back, it is not really possible or practical to also try and sort draw calls by material (or is it?). Therefore, I ask, which of the two approaches is the 'better' (in terms of performance or general adoption); or is there a third or hybrid approach I am unaware of?


texts:
I'm using Vector2.distance_to to get the distance between a MeshInstance and a KinematicBody but the results aren't as expected.
I'm using distance_to like so:
var player_global_transform = $KinematicBody.get_global_transform().origin
var player_position = Vector2(player_global_transform.x, player_global_transform.z)

# Here I loop through the planes and compare positions but to simplify it I'll just show
# the one.
var plane_global_transform = $MeshInstance.get_global_transform().origin
var plane_position = Vector2(plane_global_transform.x, plane_global_transform.z)
var player_distance_to_plane = player_position.distance_to(plane_position)

Also I'm using Vector2s because I don't care about Y values for this calculation.
Lets say I have 9 mesh planes (240x240) in a grid and the player is standing in the middle mesh of them:

The distance from the KinematicBody and the middle square is (0, 0) as the player is right in the middle of it. Now if I move over a square to the left:

The distance returned is (240, 0) which is expected as I'm now 1 mesh plane distance away from the center of the previous mesh. Now if I extend the grid and add 3 more meshes to the left and move over to that one:

The distance is now (360, 0) instead of (480, 0) and I can't seem to figure out why. It also seems that if I add another column of plane meshes to the left and move over another square, it's still (360, 0).


texts: In 2d game logic, should I use pixels or world coordinates?

texts:
Currently in my game I handle the logic (collisions, movement) using pixels but I find it very limiting espiecially when thinking about variable speed.

For example Box2D requires you to use coordinates in metres instead of pixels (for example 50 pixels = 1 metr). Also using normal cartesian coordinates would allow me to use trygonometry etc.

Should I use in my logic code coordinates not bound to pixels (ie metres)? Is it a better approach?