texts: Spatial data visualization level of detail

texts:
I have a 3D point cloud data set with different attributes that I visualize as points so far, and I want to have LOD based on distance from the set. I want to be able to have a generalized view from far away with fewer and larger points, and as I zoom in I want a more points correctly spaced out appearing automatically.

Kind of like this video below, behavior wise:
http://vimeo.com/61148577

I thought one solution would be to use an adaptive octree, but I'm not sure if that is a good solution. I've been looking into hierarchical clustering with seamless transitions, but I'm not sure which solution I should go with that fits my goal.

Any ideas, tips on where to start? Or some specific method?

Thanks


texts: How to rotate to a target position over time

texts:
I know how to do rotations to vectors, but how do I rotate over time?

For instance say I made a function

RotateTo(vec2 iPosition, float iTime);

so it rotates to iPosition over iTime - how would this look? Does anyone know simple algorithm?


texts:
I am working on a game that will be a 3D-shooter (camera trailing player), and want to impose some architecture on the game being that a level is composed of rooms where each room can hold entities(the player, enemies, pickups, projectiles), AInodes, walls/floor, and doors(more on these in a little)
my first concern/iteration is to get a single room functional, and then link rooms together in a later iteration(this is so that rooms to render are dynamically chosen to accelerate render times on larger level). my direct question for this iteration is what would be an optimal data structure for holding my entities for the room? keeping in mind that whatever structure I use needs to be searchable, removable(single/group of items), sortable(this can be given up if needed), growable, and possibly be able to take pointers to the gameObjects. this structure would probably also be used for my doors. my initial thought was to use linked list though removing items from linked lists can be a chore, and if not done right can just create a memory black-hole.
I keep bouncing back, and forth on putting walls/floor into the same structure as the entities as it would be mostly efficient for collision detection (i think), but I know it can cause a graphics nightmare (more things being rendered means longer it takes), so maybe keeping walls separate, and create a separate list of walls to be rendered vs collisions.
the next part would be linking the rooms together by doors(see picture bellow where the joint between each room is a door) where my first though was adjacency list. I understand that the std::graph has an adjacency list that it uses though I don't feel that it would work in my situation as just rooms 05, and 11/15 don't work within a std::graph so would it be worth while to build a custom adjacency list (might need to see an implementation as I keep getting lost on connecting adjacent things that should be connected)

S: start
F: finish
: room number

map example


texts: 2D top down 360 degrees rotational movement - stop instant rotation

texts:
I currently have a working, decently complicated, way of moving my player around.

Using A & D you rotate the player and using W and D you increase forward or backward moving speed.

This works great!

I now want to update my code so that while rotating, the player will not instantly start moving in that direction, but it will start turning in that direction and after an adjustable "speed/time" start moving in that direction entirely.

So the player can rotate freely around without anything happening.
But when facing a new direction, the player's speed should easy towards that direction until it is moving in the direction the player is facing.
Currently this happens instantly.

An example of how I want my movement:
https://www.youtube.com/watch?v=CwkVrxYZvEE

Here's my current code, I barelly understand how this works tbh.
I do feel I'd just need a few minor tweaks to get this working?

Feel free to ask if you need any more info!
Also feel free to use any of this code for your own purposes!

var canvas = document.getElementById('canvas');
var c = canvas.getContext('2d');

// Movement
var playerWidth = 64;
var playerHeight = 64;
var playerX = 500;
var playerY = 500;
var playerAngle = 1 * Math.PI / 180;
var rotationRate = 4 * Math.PI / 180;
var playerSpeed = 0;
var maxSpeed = 4;
var moveResistance = 0.04;
var speedRate = 0.05;
var speedUp = false;
var turnRight = false;
var speedDown = false;
var turnLeft = false;

// Images
var playerSprite1 = new Image();
playerSprite1.src = '/assets/sprites/spider-red.png';

// Game loop
setInterval(function() {
    c.clearRect(0, 0, canvas.width, canvas.height);
    calculatePosition();
    drawReDrawCanvas();
}, 1000 / 60);

function calculatePosition() {
    if (speedUp) {
        playerSpeed += speedRate;
        if (playerSpeed > maxSpeed) {
            playerSpeed = maxSpeed;
        }
    }
    else if (speedDown) {
        playerSpeed -= speedRate;
        if (playerSpeed < -maxSpeed) {
            playerSpeed = -maxSpeed;
        }
    }
    else {
        // Somehow the player keeps moving if speed is < 0.05
        if (Math.abs(playerSpeed) < 0.05) {
            playerSpeed = 0;
        }
        if (playerSpeed > 0) {
            playerSpeed -= moveResistance;
        }
        if (playerSpeed < 0) {
            playerSpeed += moveResistance;
        }
    }
    if (turnRight) {
        playerAngle += rotationRate;
    }
    if (turnLeft) {
        playerAngle -= rotationRate;
    }
}

function drawReDrawCanvas() {
    playerX += Math.sin(playerAngle) * playerSpeed;
    playerY -= Math.cos(playerAngle) * playerSpeed;
    c.save();
    c.translate(playerX, playerY);
    c.rotate(playerAngle);
    c.drawImage(playerSprite1, playerWidth / -2, playerHeight / -2);
    c.restore();
}

document.addEventListener('keydown', function(e) {
    var k = e.code;
    switch (k) {
        case 'KeyW':
            speedUp = true;
            speedDown = false;
            break;
        case 'KeyD':
            turnRight = true;
            turnLeft = false;
            break;
        case 'KeyS':
            speedDown = true;
            speedUp = false;
            break;
        case 'KeyA':
            turnLeft = true;
            turnRight = false;
            break;
    }
});

document.addEventListener('keyup', function(e) {
    var k = e.code;
    switch (k) {
        case 'KeyW':
            speedUp = false;
            break;
        case 'KeyD':
            turnRight = false;
            break;
        case 'KeyS':
            speedDown = false;
            break;
        case 'KeyA':
            turnLeft = false;
            break;
    }
});
<!doctype html>
<html>
<head>
    <title>Rotation</title>
</head>
<body>
    <canvas id="canvas"></canvas>

    <script type="text/javascript" src="player.js"></script>
</body>
</html>


texts: How can I make all the objects to move between the waypoints?

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

public class MovementSpeedController : MonoBehaviour
{
    public List<Transform> objectsToMove = new List<Transform>();
    public List<Vector3> positions = new List<Vector3>();
    public int amountOfPositions = 30;
    public int minRandRange, maxRandRange;
    public bool randomPositions = false;
    public bool generateNewPositions = false;
    public float duration = 5f;
    public bool pingPong = false;

    private void Start()
    {
        if (generateNewPositions || (positions.Count == 0 && amountOfPositions > 0))
            GeneratePositions();

        StartCoroutine(MoveBetweenPositions(duration));
    }

    private void GeneratePositions()
    {
        for (int i = 0; i < amountOfPositions; i++)
        {
            if (randomPositions)
            {
                var randPosX = UnityEngine.Random.Range(minRandRange, maxRandRange);
                var randPosY = UnityEngine.Random.Range(minRandRange, maxRandRange);
                var randPosZ = UnityEngine.Random.Range(minRandRange, maxRandRange);
                positions.Add(new Vector3(randPosX, randPosY, randPosZ));
            }
            else
            {
                positions.Add(new Vector3(i, i, i));
            }
        }
    }

    IEnumerator MoveBetweenPositions(float duration)
    {
        for (int i = 0; i < positions.Count; i++)
        {
            float time = 0;
            Vector3 startPosition = objectsToMove[0].position;

            while (time < duration)
            {
                objectsToMove[0].position = Vector3.Lerp(startPosition, positions[i], time / duration);
                time += Time.deltaTime;
                yield return null;
            }

            objectsToMove[0].position = positions[i];
        }
    }
}

Now only the first object in objectsToMove is moving between the waypoints but I need all of the elements of objectsToMove to move between the waypoints. If I try this:
objectsToMove[i].position = Vector3.Lerp(startPosition, positions[i], time / duration);

I will let out of bound index exception because the size of objectsToMove is not the same the size of positions[i]


texts: SDL and software/hardware rendering. How to go about it?

texts: I know that SDL 1.2 does software rendering (CPU) and not hardware rendering (GPU). My question is, how do I use SDL but with hardware rendering? How do I not use its rendering API (software) and rather a hardware rendering API like OpenGL?


texts: How to build only specified assets into assetbundle in unity

texts:
I have searched through the few results pertaining to this particular question, but haven't found any results that work. A simple rundown of what i am looking for is to be able to make a single asset bundle of specified assets in order to be able to make an automated process for what the mod system i am making for the project i am working on.

there are two ways I can think of that would be able to do this;

build specified resources and assets into an assetbundle
build everything in a specified folder into an asset bundle

all of what i have been able to find regarding this either wouldn't allow me to make the automated process i need or builds the all of the assetbundles and they have to be defined manually before hand.

Any resources or suggestions to this issue would be greatly appreciated.


texts: How do I render a filled and stroked path using OpenGL?

texts:
I want to render a 2-dimensional geometric path consisting of Bézier curves and straight lines. Paths can be concave.

What is the most efficient way to draw this using modern OpenGL? Can I do this with a vertex shader? How should I store the path segments?


texts: Translating local to global coordinates in ARToolkit / OpenGL

texts:
Ok, so I've tried reading over the other questions and something's just not clicking for me.  I am working on an augmented reality application using ARToolkit, however it should just be straight OpenGL matrix math.

So, one of my fiducial markers is considered to be my global coordinate base. So I have an x,y,z that I pull out of the ARToolkit transform matrix (this would be something like trans[0][3], trans[1][3], trans[2][3]).  I am feeding that into a glTranslated() call in order to move my objects around, relative to the origin.

Now, when I use another marker, those are recognized with their own local coordinates.  I need to transform them into the coordinates of the original marker, and that is where I'm having issues.  I can pull out the x,y,z coordinates easy enough, but taking that relative to the origin is my issue.

So my understanding was that I could somehow create my global coordinates, take the inverse, multiply those by the new coordinates, and that would give me the coordinates of the new object relative to the origin.  I think my issue is in figuring out how to add those in properly to a matrix, since I'm dealing with x,y,z coords separately.

Any help would be appreciated...I'm doing this all in C as well, so no nifty STL functionality for me.


texts:
The question seems easy, but you simply change vertex positions to match the corners of a trapezoid but it simply fails. I've tried scaling top and bottom edges like this :

but when I apply my texture it doesn't behave as I expected rendering this texture

into this image

Edit:

so far I've managed to produce a good looking image by changing w component of vertex coordinates instead of the x component, but I'm wondering if there is any better way to solve it?

Edit2:

here are my vertex and texture coordinates when I initialize the class.

float w = mTexture->getPixelsWide();
float h = mTexture->getPixelsHigh();
mVertices[ 0+0] =-w; mVertices[ 0+1] = 0; mVertices[ 0+2] = 0; mVertices[ 0+3] = 1;
mVertices[ 4+0] = w; mVertices[ 4+1] = 0; mVertices[ 4+2] = 0; mVertices[ 4+3] = 1;
mVertices[ 8+0] =-w; mVertices[ 8+1] = h; mVertices[ 8+2] = 0; mVertices[ 8+3] = 1;
mVertices[12+0] = w; mVertices[12+1] = h; mVertices[12+2] = 0; mVertices[12+3] = 1;
mCoordinates[0] = 0; mCoordinates[1] = 0;
mCoordinates[2] = 1; mCoordinates[3] = 0;
mCoordinates[4] = 0; mCoordinates[5] = 1;
mCoordinates[6] = 1; mCoordinates[7] = 1;

and later to scale it I'm currently using:

float ts = (mSpreadTime - mDropTime) / ((mSpreadTime - mTime) + mTopSpreadRatio * (mTime - mDropTime));
float bs = (mSpreadTime - mDropTime) / ((mSpreadTime - mTime) + mBottomSpreadRatio * (mTime - mDropTime));
mVertices[3] = ts;
mVertices[7] = ts;
mVertices[11] = bs;
mVertices[15] = bs;
mVertices[1] = 0 * ts;
mVertices[5] = 0 * ts;
mVertices[9] = h * bs;
mVertices[13] = h * bs;

note: that method above solved my issue, I'm looking for a way to fix it without messing with w component.


texts: What implications does JIT (javascript/canvas) vs. AOT (Flash) have in terms of browser based game performance?

texts:
In my experience, even till this day, I still see more of a visual lag in entity movement / animation in JavaScript (Canvas) based games than I do in Flash based games.

Why is this - what exactly is the descrepancy at the most basic level between an JIT vs AOT compiler in the specific scenario of JavaScript vs. Flash.


texts: Do Game Objects which lay outside camera view consume computer/mobile resources in Unity?

texts:
In unity, let us suppose that I have some Game Objects in my scene that are not visible to camera and so are not rendered while the game is running.

Will these Game Objects be consuming computer/mobile resources when the game is running?

Where can I find details about usage like these?


texts: How important it is for a game to work on a browser in means of popularity?

texts:
I've heard many people saying that it makes games more successfull if you can just play them on your browser without downloading a file at all.

Has there been any research about this? Because i find it hard to believe that the people are so lazy they cant click one download button and just unzip the game.

I find it hard to believe because: i have never played a (good) browser game from a browser; i've always launched the Java or Flash directly in its own window, because the webpages are always full of adverts with flashing stuff that distract me too much. I hope others feel the same and i can just forget this "problem" and focus on making games on normal Windows/Linux/Mac executables instead. But i would like to see some evidence on it before i decide to do so.

Edit: I dont care about the target audience or etc, just in general, are browser games more popular than downloadable games? and is it really because the users dont want to download any files? more specifically: is there correlation between success and capability to play on a browser?


texts:
I've come to a point where optimizing my game is very much needed.My update() routine takes 0-2ms. My draw() routine takes about 100ms when drawing 3.5M triangles (Not the amount I really have to draw, but it's easier to debug.)
I've noticed that reducing draw calls is more effective than reducing triangles per draw call (and keeping the amount of draw calls the same), and would primarily like to know how to do that.

I've tried creating an array, adding items to that array every frame until it has about 65535 primitives in it (the maximum xna allows per draw call) and only drawing it then, but resizing the array is a terribly slow thing to do (drawing only 250k triangles takes about 500ms)

So long story short: In XNA, how do I properly optimize the drawing methods that use DrawUserIndexedPrimitives? Or primarily, how do I properly reduce draw calls?


texts: How can I have 2 different images seamlessly tile with each other?

texts:
If I Google for "seamless tile" I can find many great answers to create a single image that will seamlessly tile with itself. GIMP even has a filter that will automatically make an image seamless in 1 click, and it works surprisingly well.

But for my game, I would like not only 1 image to tile with itself. But I would like to have different variations of that tile, so the whole texture looks less boring. I want, for example, 10 different grass textures, 10 different dirt textures. Not only should grass01 tile seamlessly with grass01. But grass01 should tile seamlessly with grass02 and dirt08.

One great example of a game that does this is Starcraft. Even the original Starcraft from 1998 has this system where they have multiple grass textures that all seamlessly tile with each other. How do they do that?


texts:
I would like to know how people usually save the animations in order to load them easily in Cocos2d with as few hard-code as possible.

E.G. The solution I thought of is to have one plist file containing information about each frame, and the second plist to contain information about each of the animation(name of the animation, which frames to play, and the delay probably).

If this is the correct solution, how can I generate such plist files for spritesheet automatically?


texts: Specular reflections shine at the wrong angle when using a normal map

texts:
I'm using Unity with URP and I'm trying to include a normal map in my shader graph.
Here is a basic graph that just display a normal map, with properties to control tiling and smoothness.

When I render the scene, the sun reflection highlights the wrong parts of the surface.
In this example, we can see the shadow direction of the cube, and the light itself. The sun reflection is clearly at the wrong place.

I tried with several normal maps from the web, all maps behave exactly like this one, so I think I'm missing something.
Ah, and strangely, when I rotate the object, the light reflection origin seems to change!
Of course, without the normal map, the light reflects gracefully.

What am I missing?


texts: Object made of cubes looks different based on the distance in Unity3D?

texts:
I made a "Wall" from basic Unity3D cubes. They are placed tightly so the wall looks like one big rectangular prism.

If I look at it from close distance, it looks as it should be: one big rectangular prism.

But if I start moving backwards, away from the wall, the cubes' edges become visible:

And this whole thing happens in a circular way.

If I just start moving backwards from the wall,
first I start to see the cubes' edges just at the further parts of the object, and then the pure white circle starts shrinking, the edges become visible at bigger and bigger parts of the object.
then the blurrier edges appear at the further places and the previously appeared sharper edges circle starts shrinking as well. (this phase is shown on the image above)

This should be some kind of shading optimization, like mipmap, right?

How can I fix this? I want the wall to be seamless from all distances.

Update:

Changing the shader to Unlit > Color, fixes the issue.
This thing only occurs on the lit side of the wall. The shadowy side of the wall, (which isn't lit directly by the directional light of the scene) is rendered normally.


texts: Is there a way in Unity to know when an ad was clicked? Some plugins for different advertising networks have events that fire when the ad was clicked, but if there is no such event - how do I know when an ad was clicked?


texts:
I would like to know how can I do one way collision. It's the collision common in mario's games and many platforms. I try to do an code but I cannot post because it's part of a paid game.
Basically I have two rectangles like this:

struct Rect {
  int x, y; // positions in the world
  int w, h; // width and height
};

The rect A moves and the rect B is fixed with the world.
Someone has a idea of how to do this?


texts: How do you manage your game resources in XNA?

texts:
In the past I have used Content.Load<type>("filename"); all over the place. This quickly becomes a nightmare to manage and worse you start having multiple copies of the same asset loaded in several different places.

Then I moved on to using a Resources class which basically looked like the following:

public class Resources
{
    public static Texture2D particle01;
    ...
    public static Texture2D particle93;

    public static Effect shader01;
    ...
    public static Effect shader32;

    public static Load(ContentManager content, GraphicsDevice device)
    { //load all the resources }

    public static Unload()
    { //unload all the resources }
}

Then I could simply use Resources.particle01 to get a reference to the resource from anywhere within the same namespace.

This was a nice approach because it eliminated the duplicates that I had in the past. Also all loading was done in a single class, so it was easy to keep track of the resources. And finally, I could simply right click, for example, particle93 and click find all references to find all the places that used that texture.

However, there are issues with this approach and I would like to know if there is a better solution out there.


texts: Problem playing music and sound effects in Cocos2d-x

texts: I'm new to Cocos2d-x and working on a mac. I'm trying to play music in my demo project but I'm unable to include "SimpleAudioEngine.h" in the default HelloWorld Project. I tried adding CocosDenshion to my project but I got more errors. Anyone who knows how to fix this please help.


texts: Alternative to System.Drawing for breaking an image into separate tiles in Unity

texts:
As far as I can tell, System.Drawing namespace is not available in unity. I there an alternative library to load and manipulate or generate images on the fly?

Example: Imagine you want to make a jigsaw puzzle game and want to load and chop random images to use as textures or such.

EDIT: specifically I want to crop images and draw patches from one image onto another image. Or overlay images with grids.
Ultimately all the resulting images need to end up as textures on game objects. If need be, I can use texture.EncodeToPNG to save a copy for other purposes or for as a cached result.

EDIT AGAIN: Let's stick to a concrete example.
Player selects a photo from their iPhone library. It is chopped into pieces and appears on 9 cubes. the player need to arrange the cubes in the correct way to recreate the original image.


texts: How to make player jump to mouse position

texts:
Currently I have the player moving towards the mouse position , using this example :
https://kidscancode.org/godot_recipes/3d/click_to_move/
now how would I achieve jumping to the mouse position, currently my script is like this:
  void Player::move(const float &delta) {
            velocity.y += gravity * delta;

            if (target != godot::Vector3::ZERO) {

                look_at(target, godot::Vector3::UP);
                rotate_x(0.0);
                velocity = -get_transform().basis.z * speed;

                auto distance_to_target = get_transform().origin.distance_to(target);
                if (distance_to_target < 0.5) {
                    velocity = target = godot::Vector3::ZERO;
                }

// weird behavior not what I'm looking for

                if (godot::Input::get_singleton()->is_action_pressed("Jump") && is_on_floor()) {
                    godot::Godot::print(std::to_string(distance_to_target).c_str());
                    velocity.y = 100;
                }
            }

            velocity = move_and_slide(velocity, godot::Vector3::UP);
        }

I tried messing around with velocity.y , but it always result in weird behaviors and the player when landing point/look at the floor.
how would I do it correctly ?


texts: Despite the connect() method returning 0 (enum), the function specified in the connection is not called

texts:
The subject script:
    extends ColorRect

onready var subject = get_parent().get_node('Page1')

func _ready():
    var error = subject.connect('set_timer', self, 'ad')

func ad():
    print('signal connected')


texts: How to maintain artistic consistency when working with multiple artists?

texts:
I'm making a game that requires a volume of artistic content which is not practical to be created by a single person, so I've enlisted the help of additional artists.

The problem is, each artist has their own style, and mixing the content produced by all artists results in a very inconsistent experience. This is true for graphical as well as musical content.

I've tried having each artist work on completely different parts of the content, such as having a background artist, a sprite artist and a graphic designer, but this clearly doesn't scale as the art volume increases or when circumstances require me to replace an artist, and is not trivial with content such as music.

How can I work with an arbitrary amount of artists, yet maintain artistic consistency across the entire game?

Addendum: The current answers mention the creation of an art spec, but even though useful, and probably even necessary, it is simply not enough.

In programming terms, "make an art spec" is similar to "make a tech spec", which is definitely a good thing, but a spec by itself does nothing to improve overall code quality.

Same goes for having an art director. In programming terms, "get a lead programmer" is not a very useful answer for "how do I improve code quality in my team?", even though it is a very good thing.

I'm looking for specific detailed answers on how to solve specific common problems in the field of artistic consistency. For example:

When doing lineart, draw them with vector tools instead of freehand, with predetermined brush parameters so everybody gets their lines similar.
Some people use the gradation tool, while others use blurring tools, and results are very different, so make sure everybody uses the same technique for gradations.
For music, once the percussion and chord progression is set, it doesn't really matter who finishes the song, so make sure the percussion and chord progression for all the music is written by the same person.

I just made these up, so I don't know if they would work. I'm asking this question so people who do know what works can give me specific hints on how to improve artistic consistency.

In my particular case, I am not having a problem yet, but I need a relatively large volume of music for the project I'm currently planning. I have two musicians who want to help, but their styles (and skill level) are quite different. If I let them both make the music the way they want, I will have a pretty inconsistent result, and I want to avoid that before they start writing the music.

Also, I'll be needing lots of character drawings, and I have two artists who want to help (plus me), but our drawing styles are very different. In particular, this is how each artist draws the same character:

Notice how even though we're all drawing the same character, with the same palette, the results are wildly different, and telling everybody "you all have to draw in the style of artist B" is most likely not going to be very effective.


texts: How can I imbue an ability system with information about how abilities interact and can be targetted?

texts:
I am making a turn based game where player chooses a team of heroes with specific abilities for each of them. (ex. stun one enemy, deal 20 damage to all enemies, heal 10 HP to one ally,...)
The design right now is that every non-instant effect (direct heal and damage are instant) is placed as a buff/debuff on the hero. So once a spell affects an enemy it can apply a stun for 2 turns or a DoT for 3 turns, etc.

My problem is that whenever you click on an ability in the GUI, the game should show you who you can target, but enemies can have immunities to certain effects like immune to stun or immune to damage.
My first thought was to make an interface AbilityStun and then once I start checking for viable targets check in the immunity buff if the ability is an instance of a stun and if yes, don't show it as a viable target.

But I soon realized this is a bad solution because I have an ability which damages my own team member and stuns an opponent and it would show him as not viable. Or I want to apply a debuff that will disable healing abilities. Or I want to stun and deal damage.
Suddenly interfaces piled up and I would end up with 50 of them and a systems that feels like a hack.

I am pretty sure there is a better way of doing this but I simply can't figure it out even after looking through other similar articles. Maybe you guys (and girls) who are more experienced can be of more help and point me in the right direction.

Thank you for your help.

EDIT:

Current Solution

So I created a system based on CamH's answer. I have an ability which has information like cooldown, manacost, target, etc. and I added a group of effects to it. Effects can be either stun effect, heal effect, or any other effect in the future with required parameters like heal amount or stun duration as part of the effect.

Most importantly the effect has a group of checks that know what to look for in a group of buffs/debuffs and returns true/false based on whether the target passes the test.

Example: Hero A wants to cast a stun and damage spell on Hero B who is immune to stun. On target selection the Stun effect performs a check against Hero B's buffs and returns false since he is immune. The Damage check passes and since at least one check passed Hero B is a valid target.
After the ability lands every effect is applied separately and checks are performed again this time the stun won't apply and the damage takes place.

The system is more complex than this but this part shows how I solved my problem with targeting and applying abilities.


texts: Unity Surface Shader: Conditinally noforwardadd

texts:
I'd like to have this in my shader:

#if SHADER_API_MOBILE
#pragma surface surf Lambert noforwardadd
#else
#pragma surface surf Lambert
#endif

But this tries to compile both #pragma surface and ignores the second one instead of respecting the #if condition.

Anyone know how to add "noforwardadd" to a shader, but only when it's compiled for mobile platforms?

Thanks!

Allen


texts: How would you implement chromatic aberration?

texts:
How would you implement the effect of chromatic aberration with shaders?

Would rendering of the world with different focus distances for each color solve the problem (maybe with the usage of only one depth rendering pass)?


texts:
I made this thread to gather what the majority of RPG players like in terms of damage variety in a hack-and-slash game. I play quite a bit of ARPG (mostly Diablo 3 and Grim Dawn as of now) and recently have generated some game ideas of my own.

One specific criteria that I am reaching is intuitiveness. The players should be able to easily distinguish between the damage types and choose the correct way to build their character suiting to their flavors.

At the moment, I am stuck with deciding the right number of damage types and what they are. I have a basic list for myself:

Physical

Magical

Fire

Ice/Cold

Lightning

Poison

Here comes another question: should Magical be there? Is it a redundancy since the 4 elemental Fire,Cold,Lightning and Poison is "magical" already? or Should there be an independent and unique type called Magical? Or, should the Magical damage, if increased, will also modify all those elemental damage? I am looking for a good desgin here.

Next question, I want to implement the mechanics of Bleeding as a Damage Over Time type of damage. Then, what type of damage should Bleeding be? Physical? or Poison? I have a solution, which is: for each damage type, add a "Duration" counterpart which represents the DOT of this damage type, then the list becomes:

(Type,Duration damage of this type)

Physical, Bleeding

Magical, Corruption(just a random word to fill in)

Fire, Burn

Cold, Chill

Lightning, Electrified

Poison..........???

Here comes the problem, Poison is already a DOT, introducing another DOT counterpart for Poison would be weird. Another problem with this system is that it is complicated, so many stats. So my question is, how do we efficiently implement the least amount of damage type to produce the most amount of diversity in gamestyles and build types. I really want to promote freedom and creativity, which means that if someone likes playing DOT lightning he could.

Sorry if my questions aren't clear, but I would love if everyone shares their ideas of a Damage type system, how many are there is good, and how does damage over time works.


texts:
To make my game fps independent I move entities with

pos += speed * time

where time is the delta time since last frame.

That works perfectly well with speed but how do you do that with acceleration?


texts: Libgdx: movement of scrolling background is not smooth even at 60fps

texts:
I'm developing a game and I want to make a sliding background. The background is not scrolling smoothly. I logged the fps, but it was ok. This is my code, I don't know what I'm doing wrong, any ideas?

public class MyGdxGame implements ApplicationListener {
    private OrthographicCamera camera;
    private SpriteBatch batch;
    Texture back;
    float offset =  0f;

    FPSLogger logger = new FPSLogger();
    @Override
    public void create() {
        camera = new OrthographicCamera(320, 480);
        camera.position.set(320 / 2, 480 / 2, 0);
        camera.update();
        batch = new SpriteBatch();
        batch.setProjectionMatrix(camera.combined);
        back= new Texture(Gdx.files.internal("back.png"));
    }

    @Override
    public void dispose() {
        batch.dispose();
    }

    @Override
    public void render() {
        logger.log();
        offset +=  (400f * Gdx.graphics.getDeltaTime());
        offset = offset % 480f;
        batch.begin();
        batch.draw(back, 0, offset);
        batch.draw(back, 0, offset - 480);
        batch.end();
    }

    @Override
    public void resize(int width, int height) {
    }

    @Override
    public void pause() {
    }

    @Override
    public void resume() {
    }
}

I uploaded the code to bring more information, I looked for on internet and a lot of people have the same problem, but I didn't find solution. I have almost finished the game, change the library will be a pity, any can help me? Thanks!
This is the code:
https://www.dropbox.com/sh/t26gt33wcex5izn/AAD8-yBSOztZfHe4wzDPRjjQa


texts: Determining a point that reached another point

texts: I have two points, one is moving and one is stationary. I would like to know if the moving point has reached that point or not. I tried to calculate the distance between two vectors and the distance never reaches 0.


texts: Octree LOD without traversing the entire tree

texts:
I am working on a voxel engine that uses a huge Hashed Linear Octree that reconfigures when you move. Each octree leaf is a voxel. The world is procedurally generated using 2D Perlin noise.
The octree utilizes face culling and instancing to accomplish pretty good performance in OpenGL. I have implemented LODs in order to allow for much bigger scenes and my bottleneck has quickly shifted from rendering faces to generating the Octree.
Each time the camera moves I need to reconfigure the Octree's LOD in order to ensure the viewer sees high detail near him and low detail in the distance. The system works great for small Octrees (256^3) but as soon as I go to a 1024^3 Octree, the generation of the Octree LOD takes 1-2 minutes. Even done on a separate thread it isn't enough.
I am sure there is a way to generate the Octree world without traversing the whole Octree but I could not find it.
The basic outline of how I do the Octree LOD generation when the camera moves:

Start traversing the Octree at the root node

For each node, check the distance of the node's center from the camera
2.a. If the node is a leaf and the distance is smaller than the node size * CONSTANT, divide it. If it is not a leaf, traverse its children and go back to (2).
2.b. If the node is not a leaf, and the distance is larger than the node size * CONSTANT, collapse the node if needed.

That's basically it. Because the world is procedurally generated, dividing each node means iterating its entire volume (x+1,z,x+2,z...x,z+1,x,z+2...x+1,z+1....) to determine if the 2D Perlin noise passes through the node volume, above it, or below it (This has to be part of the problem as for 256^3 nodes it takes 65536 iterations).
I know that I can improve this by parallelizing the entire algorithm, but I still feel like there has to be 1) a way to calculate LODs without entire tree traversal, and 2) figuring out if to divide the node without iterating through its whole volume 1 by 1.
Would love to get some pointers, I could not find many resources about this online.


texts:
i am trying to rotate a quad at z-axis but the problem is , it is not rotating but translating towards some other direction rather than rotating at a particular point.I believe my display function is correct, and the problem exist in init() function and is related to modelView or projection matrix, i downt know the purpose of them and what will be the sequence, here is my code

#include<GL\freeglut.h>
#include<Windows.h>
#include <math.h>
#include"F:\BSCS VI\cg\cg\SOIL.h"
double moveX = 0.0;
double x = 0, b = 0;
int degree = 0;
void display() {

    glEnable(GL_TEXTURE_2D);

    glClear(GL_COLOR_BUFFER_BIT);

    //////////////quad to be rotated
    glPushMatrix();
    glRotatef(degree, 0.0f, 0.0f, 1.0f);
    glColor3f(0, 0, 0);
    glBegin(GL_QUADS);
    glVertex2d(30, 300);
    glVertex2d(100, 300);
    glVertex2d(100, 320);
    glVertex2d(30, 320);
    glEnd();
    glPopMatrix();
    ////////////////quad to be rotated , end

    degree++;
    glFlush();
}

void init(void) {
    glClearColor(.75, .75, .75, 0.0); /* background color select clearing color */
    //glEnable(GL_TEXTURE_2D);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0, 500, 0, 500);

}

void timer(int x){
    glutTimerFunc(100, timer, x);
    glutPostRedisplay();
}

int main(int argc, char * argv[]) {
    glutInit(&argc, argv);
    glutInitWindowPosition(100, 100);   glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(800, 500);
    glutCreateWindow("simple");  // default win. 300 x 300
    glutTimerFunc(100, timer, x);
    init();
    glutDisplayFunc(display);  // set callback for display function

    glutMainLoop();
    return 0;
}


texts:
I have been using unity and C# scripting now for the past 2 or 3 weeks. So yeah i am very new to unity and C#.

I wanted to know if there is a way to make a round(circle) button without using the rect.

The problem I have now, I am using a 2d sprite to make the button appear round, however when you hover or click with in the rect, it still works.

I saw this asset in the asset store called Alpha Raycaster

Check asset out: Alpha Raycaster on Unity Asset Store

I cannot afford to pay for it right now so I was wondering if there is a free alternative to the Alpha Raycaster for now.

Dose anyone know how we can solve this issue? I obviously only want the button to function when the user hovers or clicks within the sprite and NOT on the alpha surrounding the sprite.


texts:
I've got .obj model with .mtl materials.I load like this: When I get aiTextureType_DIFFUSE I create new texture object and then call glGenTextures, glBindTexture and etc.

for (unsigned int i = 0 ; i < pScene->mNumMaterials ; i++) {
    const aiMaterial* pMaterial = pScene->mMaterials[i];

    m_Textures[i] = NULL;
    if (pMaterial->GetTextureCount(aiTextureType_DIFFUSE) > 0) {
        aiString Path;

        if (pMaterial->GetTexture(aiTextureType_DIFFUSE, 0, &Path, NULL, NULL, NULL, NULL, NULL) == AI_SUCCESS) {
            m_Textures[i] = new Texture();
            if (!LoadTGA(m_Textures[i], const_cast<char*>(FullPath.c_str())))
            {
               ....
            }
            else {
        glGenTextures(1, &m_Textures[i]->texID);
        glBindTexture(GL_TEXTURE_2D, m_Textures[i]->texID);
        ....

How to load texture with diffuse, specular, ambient, shininess properties when they are all together in material file?


texts: Sphere-Sphere intersection and Circle-Sphere intersection

texts:
I have code for circle-circle intersection. But I need to expand it to 3-D.
How do I calculate:

Radius and center of the intersection circle of two spheres
Points of the intersection of a sphere and a circle?

Given two spheres (sc0,sr0) and (sc1,sr1), I need to calculate a circle of intersection whose center is ci and whose radius is ri.
Moreover, given a sphere (sc0,sr0) and a circle (cc0, cr0), I need to calulate the two intersection points (pi0, pi1)
I have checked this link and this link, but I could not understand the logic behind them and how to code them.

I tried ProGAL library for sphere-sphere-sphere intersection, but the resulting coordinates are rounded. I need precise results.


texts:
I am using Unity for a user study and I am trying to integrate audio interview questions in the game itself. I need to record the user's input to an audio file. The closest thing I found was in this thread.

https://forum.unity.com/threads/save-microphone-recording-to-disk.378038/

It works but it tries to save a 5 minutes clip at once. So, it takes a few seconds and the whole game is stuck for a few seconds. I want to create a thread that will continuously write the shorter clips to the file. I tried using a coroutine but I am having a hard time managing the header as it is dependent on the whole clip.

Any suggestions or links to any threads I might have missed will be appreciated. Thanks!


texts: How to reset the world in an infinite runner game to prevent an overflowing float?

texts:
Im following Mike Geig's 2D infinite runner tutorial. However, I'm seeing a potential problem of overflowing the float

How can I reset all objects and camera back again to the origin?

The approach I'm seeking is similar to the advice made by David Debnar on this question: http://answers.unity3d.com/questions/491411/best-practices-for-endless-runner-type-games.html

  Definitely player. It's a lot easier, but to prevent float overflow,
  you should pop everything back a few thousand units every few thousand
  units


texts: Rotating a button in Unity UI by -180 on the Y and it stops working

texts: If I rotate my button by -180 on the Y axis I can't even click on it. If for example I rotate it 180 on the Z axis everything is fine. Why does this happen and how can I fix it ?


texts: Chess engine on which to apply a custom-made OpenGL skin

texts: Is there any open source chess engine that I can use to practice my OpenGL skill-set? I think it would be a neat exercise.


texts:
I have some problems with hinge joint chain movement calculations...
Here is my algorithm for segments location/rotation adjustments after a previous segment update (C#):
void AdjustLocation()
{
    float halfWidth = Size.Width / 2;

    // Translations
    Vector parentBack = PrevSegment.Center - (halfWidth * new Vector(Cos(PrevSegment.Rotation), Sin(PrevSegment.Rotation))); // Green on the pic
    Vector front = this.Center + (halfWidth * new Vector(Cos(this.Rotation), Sin(this.Rotation))); // Blue on the pic

    // Const spacing between segments
    float spacing = *some_value*;

    Vector dv = parentBack - front;
    float k = spacing / dv.Length;

    // New front location
    front = parentBack - (dv * k);
    // New rotation
    dv = front - this.Center;
    this.Rotation = Atan2(dv.Y, dv.X);

    // Translate back to the center
    this.Center = front - (halfWidth * new Vector(Cos(this.Rotation), Sin(this.Rotation)));

    NextSegment?.AdjustLocation();
}

It's working (partially), but it seems I'm missing something as it doesn't behave like a chain. Segments always move one by another although they should not always do this. Also overlapped sections of a long chain form a "knot" going all the way to the end of the chain before its "untangling".
What am I missing?
Btw: everything screws up with negative spacing values.
P.S. Tried to visualize the algorithm on the picture:


texts: Fitting a cap for a hollow object in blender

texts:
I have a thin-walled hollow object that I made by extruding a closed path that formed an outline.  So the objecft is like a hollow pipe with  a 1mm-thick wall (but the cross-section isn't a simple oval).  Now I'd like to fit a cap for it.  Since my objectt is hollow, I can't just boolean-intersect the shape with a block to make a cap -- that just gives me the outline of a cap.

How can I produce the shape for the cap I need?

If there were a "fill hollow shape by deleting all internal faces" tool, that would help.  Or maybe there is a more obvious approach?


texts: Java Slick2d - Mouse picking how to take into account camera

texts:
When I move it it obviously changes the viewport so my mouse picking is off.

My camera is just a float x and y and I use g.translate(-cam.cameraX+400, -cam.cameraY+300); to translate the graphics. I have the numbers hard coded just for testing purposes.

How would I take into account the camera so my mouse picking works correctly.

double mousetileX = Math.floor((double)mouseX/tiles.tileWidth);
    double mousetileY = Math.floor((double)mouseY/tiles.tileHeight);

    double playertileX = Math.floor(playerX/tiles.tileWidth);
    double playertileY = Math.floor(playerY/tiles.tileHeight);

    double lengthX = Math.abs((float)playertileX - mousetileX);
    double lengthY = Math.abs((float)playertileY - mousetileY);
    double distance = Math.sqrt((lengthX*lengthX)+(lengthY*lengthY));

    if(input.isMousePressed(Input.MOUSE_LEFT_BUTTON) && distance < 4) {
        if(tiles.map[(int)mousetileX][(int)mousetileY] == 1) {
            tiles.map[(int)mousetileX][(int)mousetileY] = 0;
        }
    }

That is my mouse picking code


texts:
I want to execute a function from many scripts attached on gameobjects  which will be spawned. Since game objects are spawned, I can't assign the script in the inspector. What i want is that, there are three gameobjects, A,B,C. C is already in the scene. A and B are spawned with different scripts,the spawned gameobject's script should call the function on the gameobject C. I can make a delegate but there are different scripts that want to call the function. So should i have to create different delegates for each script on A and B and then assign them onto the gameobject C so that A and B can call their delegates and these delegates will trigger the function on C or there is something like a event that i can call from B. If it was possible, i can create a event on A and assign it on C. Now A can call the delegate and B can also call that event and trigger the function on C, but this is not possible as event can't be called from another script.
I need something like a function that i can call from any script and it calls the function from C.
Note that function should not be static.
As i can call a static function from any script but it can call only static methods, which i don't want.


texts: How to make a simple game based on navigating a set of videos?

texts:
I would like to create a simple video game as an interactive art piece.

The game goes like this:

A video (with sound!) loops while there are two options on the screen (text labels); when the player chooses one of them, another video plays; once it is finished, there are two options once again with a default video looping (?) and so on and so on.

It is quite simple, however I have had a really hard time finding a way to make it.

Someone suggested Youtube, but I don't want the player to be distracted by anything else, to be able to skip, for the video to end and for the player to choose a suggested Beyonce music video etc.

Someone else suggested Blender but it seems the video uploaded does not have audio attached so it would be extremely time consuming to write the python script. Both audio and video channels would be treated separately and the video player would artificially redraw video frames through the renderer. Unity seeems to be a similar if not a more complex set-up.

They suggested that Director used to do this but it is no longer being sold or supported by Adobe. I have a Mac and was unable to find a version on the internet that allowed me to use it.

Does anyone know how I can realize this project? Ideally to just plug in the videos, add the options text labels, arrange the sequences of videos and options and the game would play.

I cannot code or write script so I am hoping that the solution is simple. Someone was going to help me to make it in Blender but it turns out it is too difficult there. I might put it up on Fiverr if I need script written, however as I have never used it before I am not sure how reliable it is and how easy it will be to communicate all the finer points, to send over the videos etc.

Then once it is made, what sort of software would be needed to play it? Ideally it would be web-based, but I understand this complicates matters even further. I am working on a Mac but might show it on a PC - is this impossible due to incompatibility? Would it be ok running it on a computer eight hours a day?

Would it be possible to make the game run so that the player has no autonomy over the computer used - so they would not be able to exit the game?

All and any help appreciated! Thank you


texts:
I have 2D background in unity on which I would like to add multiple circle, box colliders.
Assets are not separated. I have drawn assets on background.

How to move circle colliders with mouse or keyboard shortcut on the background?
It's not very pleasant to define x,y position wherever needs to go for every collider.


texts: How to get distance from point to line with distinction between side of line?

texts:
I'm making a 2d racing game. I'm taking the nice standard approach of having a set of points defining the center of the track and detecting whether the car is off the track by detecting its distance from the nearest point. The nicest way I've found of doing this is using the formula:

d = |Am + Bn + C| / sqrt(A^2 + B^2)

Unfortunately, to have proper collision resolution, I need to know which side of the line the car is hitting, but I can't do that with this formula because it only returns positive numbers.

So my question is: is there a formula that will give me positive or negative numbers based on which side of the line the point is on? Can I just get rid of the absolute value in the formula or do I need to do something else?


texts:
I'm trying to reach uniform lighting as in this image.
This scene i've bought is rendered with 3ds and v-ray (i suppose).

This is the same scene i've imported in Unity.

I've put a "big" point light on top of my room, i've added also directional light and a Reflection Probe.

This is my (unsatisfactory) result:

This is my baking settings:

Do you have some advice to improove my Unity lightining as the first scene ?

Thanks


texts: Can I use animate characters in an iOS game if I do a citation in the credits. Ex Steven univers in a fighting game and I list Rebecca Sugar in the Credits or by the character bio.


texts: Is it a good idea to make a game for one aspect ratio and arbitrary screen resolution?

texts:
After several very small games I have decided to make something more standalone (2D) and playable. However, I have met the problem of every game that is going to be played in more screen resolutions.

Basically, after some research I see that there are several solutions.

This seems to be the simplest one: Let's say I define a constant aspect ratio for the game (16:9) and the whole game will be created for a resolution 1680 x 1050.

The game will be rendered in this resolution and then I will be able to scale the render to match the player's display resolution. Therefore the game might be playable on almost any resolution, while it would keep the aspect ratio. So, if the game was run on 4:3 display, the top and the bottom of the display would be filled with black color.

It seems easy, but my question is - Is this a good approach for a simple game? The game will be simple, but I want to maintain high quality.


texts: What economic books would you suggest for learning about economic valuation of goods and simulations thereof?

texts:
I'm looking to create an economic model for a game based on goods created procedurally.

Every natural resource and produced good would be procedurally generated, with certain goods being assigned certain uses.

  Fakesium might be used for the
  production of Weapon A and produced
  from Fakesium factories which use
  Dilithium and Widgets as reagents,
  where Widgets are also the product of Foo
  and Bar

The problem is not creating the resources and their various production utlities - but getting the game's AI empires and merchants to (Addendum: somewhat) correctly value the goods according to their scarcity, utility and production costs.

I need to create a simulation of goods which allows the various game factions to assign a common value denominator (credits) to each resource, depending on how much its worth to that empire.

I see the simulation being something like: "I have a high requirement for Weapon A. Since I don't have much of Fakesium, which is needed for Weapon A - I must have a high demand for Fakesium. If I can acquire Fakesium, devalue it. If not, increase its value - and also increase demand for Dilithium and Widgets too."

This is very naive - because it may be much much cheaper for the empire to simply purchase Dilithium and Widgets directly rather than purchasing Fakesium, for example. Another example is two resources might allow the creation of Weapon A (Fakesium and Lieron), so we'd need to consider that. I've been scratching my head over the problem and it keeps growing.

By the time the player joins the world, I'd expect enough iterations of this process to have occurred that prices would have largely normalised - and would then only trigger rarely to compensate for major changes (eg. if the player blows up the world's only Foo mine!)

Could anyone suggest resources (books, largely) which outline this style of modelling, preferably in the context of simulations? Since this problem would never occur outside fantasy worlds, I figured this is probably the most likely place to find people who have encountered similar problems and I'm sure there's people who know of good places for Games Developers to start looking at less specific economic theory too.

Additionally, does anyone know of any developers with blogs whose games or research applications perform similar modelling?

EDIT: I think I should underline that I'm not looking for optimal solutions. I'm looking to make the actors impulsive - making rudimentary decisions based on fuzzy inputs about what they care about or don't. I'm aiming to understand the problem area better not derive answers. All the textbooks I've found seem to be about real-world economics or how to solve complex theoretical problems, neither of which are terribly relevant to the actor's decision making.


texts: Unity: Animation With Motion Now running in place

texts:
I am new to unity.  I am trying to assemble a character that walks forward, stops, and walks forward again when I maneuver the joystick (ps4 controller) accordingly.

I have the whole thing pretty much set up...

However, my animations broke at some point.  Initially, when I added the animations to my character, the character moved with the animation according to the motion encoded in the animations (all of which were auto-rigged at Mixamo...so I am almost certain the bug is downstream in something I did or enabled somehow).

Now, every animation has the character running, turning, jumping etc. in place. Meanwhile, the animation subscreen (when I inspect the clip) shows the character running forward.   I tried implementing some fixes I found online;  I changed the root motion node to Root Transform, for instance...and that is when the most confusing thing happened: a few of the animations started working...but all of the animations showed the character running in place in the subscreen...so now I have no idea what is happening.

Additionally, the animation clips which do not move the character actually transform the character back to the starting position (actually, that isn't correct--I moved the character into the air to test this; the clips without motion transform the character back to the starting position on the ground).

I have disabled all scripts...so have I somehow broken the animations...??? Re-Importing the animations does not fix them either.

Here are the images of my character settings, then the controller, and then an animation clip which shows the character moving forward in the sub-clip and where motion information is clearly present...


texts: swipe effect problem using only mesh and array - libgdx

texts:
I tried to combine matdesl's and libgdx's draw lines algo ang code. but i can only create a line.

problem is i want to make a fruit ninja swipe effect but only knows this... problem is i want to make a fruit ninja swipe effect but only knows this... anyone try to help me on improving just a line to have a swipe effect like fruit ninja?

    public class GameTouch {

private static final int MAX_LINES = 1000;
private OrthographicCamera camera;
private Mesh lineMesh;
private Vector3 unprojectedVertex = new Vector3();
private FixedList<Vector2> list;

public GameTouch(){
    this.camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    lineMesh = new Mesh(false, MAX_LINES , 0, new VertexAttribute(Usage.Position, 2, "a_pos"));
    list = new FixedList<Vector2>();
}

public void update(float delta){

    camera.update();
    camera.apply(Gdx.gl10);

    if(Gdx.input.isTouched()){
        unprojectedVertex.set(Gdx.input.getX(), Gdx.input.getY(), 0);
        camera.unproject(unprojectedVertex);
        Vector2 input = new Vector2();
        input.x = unprojectedVertex.x;
        input.y = unprojectedVertex.y;

        if(list.size > 0){

            Vector2 temp = new Vector2();
            float sqlen = temp.set(input).sub(list.get(0)).len2();
            Array<Vector2> tempA = new FixedList<Vector2>();
            if(sqlen >= 3){
                list.insert(input);

            }

            lineMesh.setVertices(getVertices(list), 0, list.size * 2);

        }else{
            list.insert(input);
        }
    }else{

         if(list.size > 0){
            list.removeIndex(list.size - 1);
         }
    }
    if(list.size > 2){
        //lineMesh
        lineMesh.render(GL10.GL_TRIANGLE_STRIP);
        Gdx.gl10.glColor4f(0f, 0f, 1, 0.5f);
    }
}

private float[] getVertices(Array<Vector2> list){
    float[] vertices = new float[list.size * 2];
    int counter = 0;
    for(Vector2 vertex : list){
        vertices[counter++] = vertex.x;
        vertices[counter++] = vertex.y;
    }

    return vertices;
}

private class FixedList<T> extends Array<T>{

        public FixedList(){
            super(Vector2.class);
        }

        public FixedList(int capacity , Class<T> type){
            super(false, capacity , type);
        }

        public void insert(T t){
            T[] items = this.items;

            size = Math.min(size + 1 , items.length);

            for(int i = size - 1 ; i > 0 ; i--){
                items[i] = items[i - 1];
            }

            items[0] = t;
        }
    }
}


texts: How to randomly create stars in the background?

texts:
My player flies around the screen in any direction he wants, and the camera follows him. There are stars in the background.  I can't figure out how to randomly generate the stars.  I made a star class.  There are a few different types of stars, and some have different depths than others, hence they move slower as the player moves around.  I can create a stars around the player when the game starts, and when they get 100 pixels off the screen they are destroyed, but I can't figure out a good way to create new stars.

Here is my code:
Star Class:

#pragma once

struct Star
{
int xposition, yposition;
int type;
int velocity;

bool alive;

Star()
{
    xposition = yposition = 0;
    type = 0;
    velocity = 0;
    alive = false;
}

void create( int p_xposition, int p_yposition, int p_velocity, int p_type )
{
    xposition = p_xposition;
    yposition = p_yposition;
    velocity = p_velocity;
    type = p_type;

    alive = true;
}

void destroy()
{
    alive = false;
}
};

Background Class:

#include "background.h"

void Background::init( Engine* p_engine, SDL_Rect* p_camera )
{
engine = p_engine;
camera = p_camera;

delta_time = SDL_GetTicks();

for ( int s = 0;  s < 100;  s++ )
{
    stars[s] = new Star;
}

image[0] = engine->load_image( "star 1.png" );
image[1] = engine->load_image( "star 2.png" );
image[2] = engine->load_image( "star 3.png" );
image[3] = engine->load_image( "star 4.png" );

for ( int s = 0;  s < 30;  s++ )
{
    for ( int s2 = 0;  s2 < 100;  s2++ )
    {
        if ( stars[s2]->alive == false )
        {
            stars[s2]->create( rand() % engine->screen_width, rand() % engine->screen_height, rand() % 30, rand() % 4 );
            break;
        }
    }
}
}

void Background::cleanup()
{
for ( int s = 0;  s < 100;  s++ )
{
    delete stars[s];
}

for ( int i = 0;  i < 4;  i++ )
{
    SDL_FreeSurface( image[i] );
}
}

void Background::logic()
{
delta_time = SDL_GetTicks() - delta_time;

  //destroy stars
for ( int s = 0;  s < 100;  s++ )
{
    if ( stars[s]->alive == true )
    {
        if ( stars[s]->xposition < camera->x - 100 || stars[s]->xposition > camera->x + camera->w + 100 )
        {
            stars[s]->destroy();
        }
    }

    if ( stars[s]->alive == true )
    {
        if ( stars[s]->yposition < camera->y - 100 || stars[s]->yposition > camera->y + camera->h + 100 )
        {
            stars[s]->destroy();
        }
    }
}

  //create stars
if ()
{

}

delta_time = SDL_GetTicks();
}

void Background::render()
{
for ( int s = 0;  s < 100;  s++ )
{
    if ( stars[s]->alive == true )
    {
        engine->apply_surface( image[stars[s]->type], engine->buffer, stars[s]->xposition - camera->x, stars[s]->yposition - camera->y );
    }
}
}


texts:
Consider a setup where game clients:

have quite small computing resources (mobile devices, smartphones)
are all connected to a common router (LAN, hotspot etc)

The users want to play a multiplayer game, without an external server.

One solution is to host an authoritative server on one phone, which in this case would be also a client. Considering point 1 this solution is not acceptable, since the phone's computing resources are not sufficient.

So, I want to design a peer-to-peer architecture that will distribute the game's simulation load among the clients. Because of point 2 the system needn't be complex with regards to optimization; the latency will be very low. Each client can be an authoritative source of data about himself and his immediate environment (for example bullets.)

What would be the best approach to designing such an architecture? Are there any known examples of such a LAN-level peer-to-peer protocol?

Notes:

Some of the problems are addressed here, but the concepts listed there are too high-level for me.

Security

I know that not having one authoritative server is a security issue, but it is not relevant in this case as I'm willing to trust the clients.

Edit:

I forgot to mention: it will be a rather fast-paced game (a shooter).

Also, I have already read about networking architectures at Gaffer on Games.


texts:
I'm setting at runtime a BoxCollider2D size by taking the difference between the Y position of two bones on the model... but the size I'm getting out of this creates a collider that is almost twice as tall as the distance between the two points... am I making a dumb mistake somewhere? If it matters, it's a 3d model in a 2d environment.
BoxCollider.size = new Vector2(
         BoxDefaultSize.x,
         Mathf.Abs(head.position.y - Mathf.Min(leftFoot.position.y, rightFoot.position.y))
        );

In the picture the blue gizmo shows the foot position, the green one the head position. The collider is almost 2x the distance between them:

Maybe there's a better way to sync the collider with the model animation that I don't know about?
Addendum:

Vector3.Distance(head.position, leftFoot.position) returns pretty much the same result


texts: Hi i am very new to programming and in this community,so im recently studying on how to develop games with libgdx and all the tutorials only have one class and do all the things in that class,but is it possible to use more than one class?(ex:individual class for player, mobs , etc) thanks!


texts: 8 Directional Character Spritesheet Generator

texts:
I've searched for the past hour and didn't find anything worth looking.

I'm creating a game, and I'm just starting. I found this site to help me create my characters, but I want something to create characters with 8 directions, instead of just 4. Are there any of these online?

I don't need the animation part for now, just the 8 direction sprites


texts: Including files in an application using XNA

texts:
I'm making a game and I need to load some text files to create levels. After much frustration in trying to get them to work I placed the files in the debug folder of my project (I think this is a bad idea but I didn't really know how else to get the StreamReader to work).

The problem is that this means I can't get the project to run when I publish it because I don't know what to do with the text files. Where have I gone wrong and what can I do about it?


texts: How to pass an interface to Java from Unity code?

texts:
First, let me say that this is my first experience with Unity, so the answer may be right under my nose. I've also posted this question on Unity's answers site, but plugin questions don't seem to be as frequently answered there.

I'm trying to create a plugin that allows me to access an SDK from my game. I can call SDK methods just fine using AndroidJavaObject and I can pass data to them with no issue. But there are some SDK methods that require an interface to be passed.

For example, my Java function:

public void attemptLogin(String username, String password, LoginListener listener);

Where listener; is a callback interface. I would normally run this code from Java as such:

attemptLogin("username", "password", new LoginListener() {
    @Override
    public void onSuccess() {
        //Yay! do some stuff in the game
    }

    @Override
    public void onFailure(int error) {
        //Uh oh, find out what happened based on error
    }
});

Is there a way to pass a C# interface through JNI/Unity to my attemptLogin function? Or is there a way to create a mimic-ing interface in C# that I can call from inside the Java code (and pass in any kind of parameter)?

Thanks in advance! :)


texts: Sound isn't playing in Game Maker Studio when interacting with an object

texts:
I'm making a small game in Game Maker Studio.
I have a piece of code that moves the player to the next room when he touches obj_star: this works.
I have another line that tries to play sound_collect when the star is touched, but the game just moves to the next room without playing the sound.
This code is in the Step event

My code is as follows:

//Get the player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);

//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;

if (place_meeting(x,y+1,obj_wall))
{
vsp = key_jump * -jumpspeed
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_wall))
{
while(!place_meeting(x+sign(hsp),y,obj_wall))
{
    x += sign(hsp);
}
hsp = 0;
}
x += hsp;

//Vertical Collision
if (place_meeting(x,y+vsp,obj_wall))
{
while(!place_meeting(x,y+sign(vsp),obj_wall))
{
    y += sign(vsp);
}
vsp = 0;
}
y += vsp;

//Sounds
if (place_meeting(x+hsp,y,obj_star))
{
sound_play(sound_collect)
};
//Next Level
if (place_meeting(x+hsp,y,obj_star))
{
room_goto_next()
};


texts: How can I determine where to show a nameplate over a character?

texts:
I'm working on a naming system that displays the name of enemies above their heads.

The problem is that I have some enemies that are larger or smaller than others. So I'm trying to use a function that gets the height of the enemy, and then uses that as the modifier for the name's position.

Here's what I'm doing (I should mention that the target is the enemy that is currently being targeted):

public Vector3 offset = Vector3.up;
...
thisTransform.position = cam.WorldToViewportPoint(target.position + offset);

What I'd like to do:

public float enemyHeight;
...
enemyHeight = target.collider.bounds.size.y + .5f;
thisTransform.position = cam.WorldToViewportPoint(target.position + enemyHeight);

But obviously it is giving me an error that I can't add a float to a vector. How can I accomplish this?


texts:
For my game, now I adopt the strategy to create multiple scene.
For this I have to ask two question please provide your view for my and other members for improvement.

I have created single TextureManager class in which I load all the graphics of the game which is at least 50 MB.

-> My first question is that this much loading of texture will create any problem in game performance,So all the scene in the game have reference to this TextureManager class and they access corresponding texture region using dot operator. if other better strategy for this texture loading then please suggest me.

-> My second question is that my actual game scene uses bound camera and I perform scrolling on that camera but my other scene uses the normal camera. So in this situation what to do? how to use multiple camera for single engine? or how to reset available current camera?

My current working platform is andengine.

Thank for you support.


texts: Get Facebook Picture in Cocos2d-iphone V3

texts:
I'm trying to get the profile picture from Facebook, but I'm getting the following error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage stringByStandardizingPath]:

This is my code:

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?type=square", userid]];
 NSData *data = [NSData dataWithContentsOfURL:url];
 UIImage *image = [UIImage imageWithData:data];
 //convert UIImage to CCSprite
 CCTexture *texture = [CCTexture textureWithFile:image];
 CCSprite *sprite = [CCSprite spriteWithTexture:texture];
 sprite.position = ccp(winWidth*.5, winHeight*.5);

The error occurs in the UIImage *image line.


texts: Do game companies usually provide their artists/modelers with drawing tablets?

texts: Or do you have to provide your own? How essential are tablets for game development?


texts:
I'm trying to create a leaderboard for my game. I have the game created and added the leaderbaord using cloudonce. I have also created the app on google play console and linked the app to the game services. I have followed the following tutorial to create the leaderboard: Leaderboard tutorial
I have followed the exact same instruction as given in the tutorial. Once the game is over, the leaderboard button is activated. I have attached LeaderboardsButton script(this script comes with the CloudOnce package) to the leaderboard button.
Here is the code in the game over panel for getting the score:
void OnEnable()
{
    DisplayGameOverScore();
}
void DisplayGameOverScore()
{
    gameOverScore.text = ((int)gameManager.playerScore).ToString();
    gameOverHighScore.text = PlayerPrefs.GetInt("HighScore", 0).ToString();
    CloudOnceServices.instance.SubmitScoretoLeaderboard(PlayerPrefs.GetInt("HighScore", 0));
}

This is the CloudOnceServices script as per the tutorial:
public static CloudOnceServices instance;

private void Awake()
{
    TestSingleton();
}

private void TestSingleton()
{
    if (instance != null)
    {
        Destroy(gameObject);
        return;
    }
    instance = this;
    DontDestroyOnLoad(gameObject);
}

public void SubmitScoretoLeaderboard(int score)
{

    Leaderboards.HighScore.SubmitScore(score);
}

I have attahced this script to an empty game object along with the InitializeCloudOnce script(this is provided with the CloudOnce package).
I have also created an alpha test on googleplay. Once I open the link and start the game, the google play services console open and when I hit the leaderboard button, google play services console loads but after that nothing happens. It just goes back to the game. I read that other people ran into similar issues and the advise given was to check if the SHA1 certificate fingerprint is the same in app signing under release management and the credentials in GoogleApis. They both match. I'm not sure what the issue is?


texts:
A game is a set of Game States.

Each Game State contains game objects, may be list, may be scene graph or any other data structure.

We can use Game States as Game Locations, too.

How do you share data between Game States, for example, hero and his/her inventory when it moves from one location to another?

It looks like Composite (hierarchical) Game State is a good idea. For example,

GameState MainMenu
GameState LoadLevel
GameState Gameplay - contains inner states
    GameState Location1
    GameState Location2
    GameState Location3
    GameState MiniGame1 - contains inner states
        GameState LocationInMiniGame1
        GameState LocationInMiniGame2

So we can hold shared data (hero, inventory) in Gameplay object. But this approach does not look very correct and flexible. If some objects are outside scene graph (ie in the parent Game State), how would you include it in the scene graph? Via special node type that mounts different scene graphs or scene graph branches together?

If we have stack of active Game States, and each state can contain inner state machine, and scene graphs of different Game States can be mounted into one giant graph, it can become very complex system that is hard to debug.

Very interesting to read your suggestions. How do you organize game data between Game States in your real applications?

(For editors: possible additional tags: OOP, game-state.)


texts: Making a Photo Hunt Game using Javascript and HTML5

texts:
I am looking for a way to make a photo hunt game using HTML5 and Javascript. Where should I start after the images. And How would I make clickable areas on the image, using javascript?
If you know of any examples that would help or are willing to help let me know, please.
Thank You


texts: How do I disable user input after the player made their choice?

texts: I'm trying to make a PvP minigame where both players have to chose 1 out of 3 options, but to avoid spamming I want to make it so that when a player presses a button, he is locked in that choice until the other player makes his choice too.


texts: Unity - Raycast not hitting to BoxCollider2D objects

texts:
I'm working on 2D and I have a Quad as background.

And some wall sprites over this quad :

I'm instantiating wall prefab sprites over quad when user click to somewhere. But I don't want to instantiate a wall over another wall, so I'm sending a ray from camera to click point and if hit object is a wall object I won't instantiate.

Here my code :

RaycastHit hit;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        Physics.Raycast(ray, out hit,Mathf.Infinity);
        // If it hits ground, not another objects (like walls)
        if(hit.transform.name == "GroundQuad")
             Instantiate (wall, Input.mousePosition, Quaternion.identity)

But it's still creating wall objects. Tried Debug.Log() to print hitted object's name to console and moved pointer all over game screen, it's always GroundQuad. So ray not hitting to wall objects.

Can you tell me what is I'm missing? Is it a problem with Layer Collision Matrix ?


texts:
I have a problem with this if statement.

If the rotation is < -45. And > -140

Then this statement would be true when the rotation is = -90?

And it would be false if the rotation is = -170?

I'm using the negative values because unity rotation goes from -180 to +180.

I tried using a full 360 scale, that also didnt work.
that Statement looked like:

if the rotation is > 245 & < 325

Then do stuff

If you can change where the 0 value of the rotation is from the West point to a different one would also be a useful option

Thanks for any help

Code that is being executed:

        if (transform.rotation.z > -140 && transform.rotation.z < -45)
    {
        if(rotationSpeed < 150f)
        {
            rotationSpeed += 150f * Time.deltaTime;
        } else
        {
            rotationSpeed = 150f;
        }
        print("135");

    } else
    {
        if(rotationSpeed > 70f)
        {
            rotationSpeed -= 150f * Time.deltaTime;
        } else
        {
            rotationSpeed = 70f;
        }
        print("246");
    }


texts: Object generation from an existing object in a game engine

texts:
To simplify, let's say in en engine I'm coding for a game, I have the Main class an Object class. In the Main class' update method, I loop through the array of all Objects in the game. I also have a pool in the Main class from where I can get and return Objects.

Main.update () { for (all Objects) { Object[i].update() } }

My question is what's a good way of creating new Objects from an existing object's update method?

Do I have to pass the Main class to the Objects? or make the Main a static class?

Also another question is how to handle object destruction where I return them to the unused pool.

Thanks in advanced.


texts:
I’m making a top-down 2d game in Unity3D for Android-based smartphones. Currently I have two scenes - a preloader and the game itself with all the stuff I need packed into one scene file. Also there is a very simple game-state-manager in my scene.

My question now is: Is it better to script all the levels within one scene-file or should I seperate them into unique scene-files? I’m just asking because basically the levels are very similar to each one - only the background and the sprites are different. Is there a problem with memory management if I use one scene only?


texts: How to connect Google Domain to AWS ELB url

texts: I have recently uploaded a server with node js in my AWS environment and added a HTTPS listener in my load balancer. Also generated a certificate using ACM(AWS certificate manager) for my google domain and added it in HTTPS Listener. Added .ebextensions folder to upgrade Websocket in Proxy server. I have no Idea how can I connect my domain to my beanstalk app which url is something like "myapp.region.elasticbeanstalk.com" so that I can connect as "wss://MyGoogleDomain.com". Can you guys help me? I am new to this.


texts: I am looking for a voice over programming language. Instead of using people for voice over, I want to use a computer, which does voice over for different people. Is this type of thing possible, or is there any way that I can achieve this?


texts: How can I implement a Varying Jump Height Mechanic for my character?

texts:
First of all I want to mention that English is NOT my mother tongue, I am using GODOT to make my game and that I am only 16, so I don't have any prior programming experience, although, I understand what certain things do.
I am working on my first video game (a 2D Platformer about a mole in a deserted world), and I want to implement a "Varying Jump Height Mechanic" for my character. I try to make the controls feel like a hybrid between the games Super Mario Bros 1, Super Castlevania IV, Super Meat-Boy and Mega Man 7.
For now, I managed to give the player the desired air control, however, without having   the possibility to control the height of the jump, the movement will feel quite sloppy.
One more thing before I give you the script, all the sprites are placeholders for now, if that has to do with anything of course
SCRIPT:
extends KinematicBody2D

const SPEED = 125
const GRAVITY = 18
const JUMP_POWER = -325
const FLOOR = Vector2(0, -1)

const FIREBALL = preload("res://Fireball.tscn")

var velocity = Vector2()

var on_ground = false

var is_dead = false

func physicsprocess(delta):

if is_dead == false:

     if Input. is_action_pressed("ui_right"):
         velocity.x = SPEED
         $AnimatedSprite.play("run")
         $AnimatedSprite.flip_h = true
         if sign($Position2D.position.x) == -1:
             $Position2D.position.x *= -1

     elif Input. is_action_pressed("ui_left"):
         velocity.x = -SPEED
         $AnimatedSprite.play("run")
         $AnimatedSprite.flip_h = false
         if sign($Position2D.position.x) == 1:
              $Position2D.position.x *= -1

     else:
         velocity.x = 0
         if on_ground == true:
             $AnimatedSprite.play("idle")

     if Input. is_action_pressed("ui_up"):
         if on_ground == true:
             velocity.y = JUMP_POWER
             on_ground = false

     if Input. is_action_just_pressed("ui_focus_next"):
         var fireball = FIREBALL.instance()
         if sign($Position2D.position.x) == 1:
             fireball.set_fireball_direction(1)
         else:
             fireball.set_fireball_direction(-1)

         get_parent().add_child(fireball)
         fireball.position = $Position2D.global_position

     velocity.y += GRAVITY

     if is_on_floor():
         on_ground = true
     else:
         on_ground = false
         if velocity.y < 0:
             $AnimatedSprite.play("jump")
         else:
             $AnimatedSprite.play("fall")

     velocity = move_and_slide(velocity, FLOOR)

     if get_slide_count() > 0:
         for i in range(get_slide_count()):
             if "Enemy" in get_slide_collision(i).collider.name:
                 dead()

     if Input. is_action_just_pressed("ui_cancel"):
         get_tree().change_scene("titlescreen.tscn")
func dead():
is_dead = true
velocity = Vector2(0, 0)
$AnimatedSprite.play("dead")
$CollisionShape2D.disabled = true
$Timer.start()

func onTimertimeout():
gettree().change_scene("titlescreen.tscn")

...............................................................
I hope that I can find someone that is kind, and patient enough to help me with this issue, I would do it myself, but like I said I am 16 so I do not have any experience when it comes to programming. :)


texts: convert gl_Position into screen coordinates

texts:
Pretty simple question I think. I need to convert model space coordinates into screen space coordinates for a special shader effect.
I am of course able to just convert them into gl_Position coordinates by just multplyng them with the wold view and projection matrices.
Unfortunately though, thats where I am at my wits end. Since opengl somehow converts normal vertices them into screen coordinates itself, and I need a few extra vertices for a special effect, I have no idea how to achieve this.
So does anybody have any idea how I convert model space coordinates into gl_Fragcoord screen coordinates?
I basicly want to be able to give the vertex shader a bunch of model space coordinates and have it spit out where exactly they are on the screen if they were rendered.


texts:
I don't know what a Projectile os.

I'm not sure whether a Projectile is a spawn point which spawn a number of object or a number of multiple objects.

I'm referring to this website.

How do I use Projectiles and what does it mean?


texts: How do 2D art assets (eg. sprites) work?

texts:
I have an idea on a game and planning on developing a 2D game using XNA for Windows Phone 7.

I've started off today by free hand drawing some concept art of what I want some of the characters to looks like.  Now the problem is taking those concepts and putting them in digital form.

The first thing I realized I really don't know the different parts of game art.  I know there are sprites, textures and animation but that is about it.  I think textures are sprites on a 3D object but not sure if that is correct?  Here are some general questions about game art I have:

Do you use textures in 2D games?
Where do you apply the different parts of game art?  For example when you use sprites vs animation.
What are the difference between sprites, textures animation and other art?
Are sprites, textures and animation the only art elements to a game?
Is all 2D art in games considered sprites?  Characters, background, etc.
What size do you make your sprite sheets and each character in a sprite sheet?
Any good books or tutorials on teaching to draw art from a digital prospective?  I was thinking about getting "GIMP Bible", however most books like this teach more photo editing than digital drawing.

My objective is learn how to take my concept art(backgrounds and characters) and put them into digital form using Gimp and learning about the different parts of game art.

Anyway, thanks to anyone that can help.


texts: Technique to find a mesh intersecting with a primitive solid without using colliders?

texts:
For what it's worth I'm using Unity3d, but I believe the problem is more general.

There are hundreds if not thousands of meshes with hundreds of vertices each.
There is one sphere that can be intersecting any of those meshes and is constantly moving.

Are AABB colliders approximating the mesh's volume the best way to go about this? Or is there a more specific technique that can be used here?

(A limitation I have is that my colliders need to be rotated, so they're each stored in a game object, so the number of game objects becomes absurdly large for my meshes(tens of thousands) which is slowing down my game.)

I have a couple of properties unique to my situation I believe might allow me to ditch colliders:

I don't care about the meshes colliding with each other. Just the one sphere.
I only need to know that the intersection exists, I don't care about the point of the intersection or any other metadata. Just a boolean of the intersection occuring and what mesh it happened with.
I don't need to know the exact moment/frame when the intersection occurs. If I can find out an intersection occurred within 100-200ms/20-30 frames of it happening it'll be fine.


texts: How do I apply angular velocity vector after a collision?

texts:
I'm writing a small 3D physics engine, and I am trying to get the angular velocity vector of two shapes, specifically two cubes.

For deeper understanding I have divide the motion to linear and angular motion.

For the angular motion I have done a few steps.

I calculated the inertia tensor matrix which is 3x3 so I could get the torque as follows:

$$\tau=I\alpha \\
\begin{bmatrix}
\tau_x \\
\tau_y \\
\tau_z
\end{bmatrix}
=
\begin{bmatrix}
I_{xx} & I_{xy} & I_{xz}  \\
I_{xy} & I_{yy} & I_{yz} \\
I_{xz} & I_{yz} & I_{zz}
\end{bmatrix}
\begin{bmatrix}
\alpha_x \\
\alpha_y \\
\alpha_z
\end{bmatrix} \\
\tau_x = I_{xx}\alpha_x+I_{xy}\alpha_y+I_{xz}\alpha_z \\
\tau_y = I_{xy}\alpha_x+I_{yy}\alpha_y+I_{yz}\alpha_z \\
\tau_z = I_{xz}\alpha_x+I_{yz}\alpha_y+I_{zz}\alpha_z
$$

And for calculating the matrix I have used:
$$I=
\begin{bmatrix}
m(y^2+z^2) & -mxy       & -mxz \\
-mxy       & m(x^2+z^2) & -myz \\
-mxz       & -myz       & m(x^2+y^2)
\end{bmatrix}
$$

Using the formulas described here, I could get the impulse and the final angular velocities for all shapes as follows:

Impulse: \$j= -(1+e) \frac{(v_a-v_b)•n + (r_a×n)•\omega a - (r_b×n)•\omega_b}{
1/m_a+1/m_b+(r_a×n)•([I_a]^{-1}(r_a×n))+(r_b×n)•([I_b]^{-1}(r_b×n))}\$
Final velocity of object a:\$\vec V_{af} =Vai-J/Ma\$
Final velocity of object b:\$\vec V_{bf} =Vbi-J/Mb\$
Final angular velocity of object a:\$w_{af}=wai-[Ia]^{-1}(J x ra) \$
Final angular velocity of object b:\$w_{bf}=wbi-[Ib]^{-1}(J x rb) \$

So my question is: how could I calculate the rotational angular which each object should rotate and for how long it should last?


texts: Cross-platform ad-hoc local mobile multiplayer

texts:
I want to implement ad-hoc cross-platform (iOS, Android, and PC) device discovery for local multiplayer, like this scenario: http://www.youtube.com/watch?v=csXYZf2vGdE  Multiple players, each with different devices (iOS, Android, PC). One player starts a game. The others can search and automatically discover his game and enter into a local multiplayer match. This would all be done P2P, without any dedicated game servers.

Is this possible with current technology?


texts: XNA 4.0: Blender .fbx File Won't Display 3D Model

texts:
So I followed the basic 3D model display tutorial found here:
http://msdn.microsoft.com/en-us/library/bb197293%28v=xnagamestudio.31%29.aspx

And while I know this is for XNA 3.1, I can still get the screen to show and the background color to change fine.  The model file seems to be accepted in the method below:

protected override void LoadContent()
    {
        // Used to draw textures.
        spriteBatch = new SpriteBatch(GraphicsDevice);

        grudmud = Content.Load<Model>("Models\\Vikings_grudmud");

        aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
    }

The model was created in Blender, so perhaps I'm missing a step in creating a mesh or certain texture for it?  I have colored it in Blender and it's a simple blocky humanoid figure.  Is there a scaling I should check in Blender so the camera in XNA is not inside the object?

Here's where I actually draw the object and set out some basic properties:

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

        Matrix[] transforms = new Matrix[grudmud.Bones.Count];
        grudmud.CopyAbsoluteBoneTransformsTo(transforms);

        foreach (ModelMesh mesh in grudmud.Meshes) {

            foreach (BasicEffect effect in mesh.Effects) {
                effect.EnableDefaultLighting();
                effect.World = transforms[mesh.ParentBone.Index] *
                    Matrix.CreateRotationY(modelRotation)
                   * Matrix.CreateTranslation(modelPosition);
                effect.View = Matrix.CreateLookAt(cameraPosition,
                    Vector3.Zero, Vector3.Up);
                effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
                    aspectRatio, 1.0f, 10000.0f);
                effect.PreferPerPixelLighting = true;
            }

            mesh.Draw();
        }
        base.Draw(gameTime);
    }

The initial camera and player model positions:

Vector3 modelPosition = Vector3.Zero;
    float modelRotation = 0.0f;
    Vector3 cameraPosition = new Vector3(0.0f, 50.0f, 5000.0f);

I haven't even attempted to implement the face texture yet.

It seems to have a wireframe/mesh, I've just colored in the faces.  The model is pretty much centered around the origin.

Am I exporting it wrong?  Do I need to specify lighting/camera angles any further?


texts: Detecting the two Vector3 that determine the bottom-edge of the side of a box-collider that had collision (with C#)

texts:
So, I understand that plenty of questions have been posted on how to detect which side of a Box Collider had collision. However, what I am trying to achieve is a little different.

I want to find out, using the most efficient way possible (and avoiding RayCast if at all possible), which are the two Vector3 that determine the bottom-edge of the side of the Box Collider that had the collision (notice: in my case collision can never happen at the top or bottom faces of the Box Collider).

In the figure below, I illustrate the situation.

Notice the the Box Collider is in black wireframe representation, with blue faces being the ones that had collision in 4 different cases. The two Vector3 of the bottom-edges of the faces that had collision (which are what I want to know in the end) are in red.

PS: I don't know which face had the collision. Also, notice that in the above representation, Y axis is the vertical one.


texts:
I've been following the pixelnest tutorial to make a 2D shmup (http://pixelnest.io/tutorials/2d-game-unity/player-and-enemies/).

While working on this I've experimented with increasing the firing rate to get a continuous stream of bullets, and I've noticed that bullets are more spaced apart if the ship is moved backwards, and they get clumped up when the ship is moved forwards. Is there a way to maintain constant distance between bullets no matter the movement of the player?

Should I even care? I get the feeling that if the player moves backwards then the firing rate is essentially slower (at least until they reach the edge of the screen) and vice versa if you move forwards.


texts:
I have a script that changes the levels using

Application.LoadLevel (sceneNameToChangeTo);

Once a level is loaded using that code when testing with the editor, the lighting changes dramatically. I've checked if something changes in the light or lighting settings, but it doesn't.

This is a screen of how the scene looks when I simply press RUN in the scene in the editor:

Notice the blue tints from the sky etc. This is clearly PBS lighting.

Now after I use my code to change the scene to another one and then back to this one, the scene looks like this:

What am I doing wrong? I am using Unity 5.0.1. This effect does not happen on mobile devices.


texts: Modelling the board in a Mastermind game

texts:
Hey, I'm trying to make a Mastermind game. I'm having trouble figuring how to design the game board for the guesses. The board must consist of four columns and eight rows. I'm having trouble figuring out how to go about printing the game board on screen. I know I could use a two dimensional array to store the letters and guesses, but I need to print the game board on the screen as well as the guesses inside the game board.

I hope this was clear enough, if not i can explain more, I just need help with this game board situation.


texts: Should I use delta time (elapsed time between frames)?

texts: Unfortunately I cannot recall where but I definitely read it somewhere, that the use of delta time should be avoided for some reason. Is there really a scenario where controlling animation or other in-game events using delta time is bad or it was just a wierd dream of mine?


texts:
I'm building a game with players and missiles.

I want to fire a missile from P1 to P2. The missile should always take exactly five seconds to reach P2. The missile should also track P2. If P2 moves farther away, the missile must speed up to satisfy the timing constraint. If P2 moves left, the missile must move left (and change speed as well). If P2 moves closer to P1, the missile must slow down.

Is this possible? What's the best way to accomplish this?

I don't currently have a Vector2D class (this isn't actually a game, but the analogy works well), so if possible, I'd like a solution that doesn't require one.

Edit: This isn't actually a missile either. :)

Thanks!


texts: NGUI UIInput - Reset value of password field

texts:
How do I reset the value of a NGUI UIInput control that marked Is Password. If I set .text to "" I still see a bunch of ********** rather than the .defaultText.

Basically if the user types the wrong password during login, I want to clear the field and have is display the default text again.

Update

If I click into the field and back out, the default text shows, but until I do that I get the **********.

Code:

// Show the Create dialog
public void ShowCreate() {
    panelWait.gameObject.SetActive(false);
    panelLogin.gameObject.SetActive(false);
    panelCreate.gameObject.SetActive(true);

    username = loginUsername.text;
    createUsername.text = username;
    createPasswordA.text = "";
    createPasswordB.text = "";
}

Image:


texts: Character on Moving Platform Shaky. How to Fix?

texts:
I have an elevator (rigid body platform) that is meant to transport a character. The character (RigidBodyFPSController) shakes while platform descends.

What is an elegant way to fix their relative motions while the elevator is in motion, still allowing the character to move around in it?

NOTE: I tried parenting the character but that flips him on his side.


texts:
I was making a game with pygame and python and I wanted to blit an image of a standing man and when a right key is pressed I want the man to run and when the right key is released I want the man to stand again... I tried to make it like that but couldn't work... here's the code I tried

import pygame
from pygame.locals import *
from sys import exit

pygame.init()

screen = pygame.display.set_mode((600,600))
pygame.display.set_caption('running man')

image_1 = pygame.image.load('standing-man.jpg')
image_2 = pygame.image.load('running-man-1.jpg')
image_3 = pygame.image.load('running-man-2.jpg')

move_x = 0
x = 0

clock = pygame.time.Clock()

while True:
    running_man = [0]
    #creates a loop and make the image look like its running by swithching the two man images
    for man in running_man:
        screen.fill((255,255,255))
        x += move_x
        #first i want a standing man to be seen on the screen and when a right key is pressed i want the other two images to blit on the screen
        if man == 0:
            screen.blit(image_1,(x,100))
        if man == 1:
            screen.blit(image_2,(x,100))
        if man == 2:
            screen.blit(image_3,(x,100))
        pygame.display.update()
        clock.tick(7)

        for event in pygame.event.get():
            if event.type == QUIT:
                exit()
            if event.type == KEYDOWN:
                if event.key == K_RIGHT:
                    move_x = +1
                    #here i want the variable running_man to be 1,2 so to blit the otherr images and remove the standing man image
                    running_man = [1,2]
            if event.type == KEYUP:
                if event.key == K_RIGHT:
                    move_x = +0
                    #when the right key is released i want the value of the variable running_man to be 0 again so to blit the standing man image again
                    running_man = [0]
        pygame.display.update()