texts: GetPixel() doesn't return properly the values

texts:
So I'm trying to use GetPixel() function to get which colors is the texture as a value of x and y. So far it works well but it only return 1 color, being unable to get the rest of the colors of the copied texture.

Let's consider this texture, my one is quite similar, I'll update as soon as I can. But it will work as example, basically, GetPixel() is only returning the red value while the rest are like doesn't exist at all. I leave here the code:
EDITED CODE

public Texture2D oldTexture = GetDistortedGradient(1f);

public Texture2D GetTexture(){
   var texture = new Texture2D(width, height);
   var pixels = new Color[width * height];

   for(var x = 0; x < width; x++){
      for(var y = 0; y < height; y++){
         Color newPixels = oldTexture.GetPixel(x, y);

         if(newPixels == hotest){
            pixels[x + y * width] = Color.red;
         }
         else if (newPixels == coldest){
            pixels[x + y * width] = Color.blue;
         }
         else{
            pixels[x + y * width] = Color.white;
         }
      }
   }

   texture.SetPixels(pixels);
   texture.Apply();

   return texture;
}

What I'm trying to do is whenever that texture is "color1" set the new texture as a red color on the specified x and y coordinate, then check again and if the texture is "color2" on the news x and y, set to blue, and so on.
However, this is only returning color1 for the correctly x, y coordinates and after that it jumps to the else function, like if color2 never existed on the old texture.
Btw, as this is an example, the oldTexture is generated procedurally but the colors are set in the inspector, so I just take the color I've set, but i don't why it only keep returning 1 of many colors, when basically it check for all colors.
Am I missing anything or am I not understanding GetPixel() function and how it work? Any help will be appreciated!

UPDATED WITH OLDTEXTURE CODE

public Texture2D GetDistortedGradient(float noiseStrength)
{
    var texture = new Texture2D(heatMap.Width, heatMap.Height);
    var pixels = new Color[heatMap.Width * heatMap.Height];
    for (var x = 0; x < heatMap.Width; x++)
    {
        for (var y = 0; y < heatMap.Height; y++)
        {
             float noise = GetNoise(x, y);
             int shift = Mathf.RoundToInt(noise * noiseStrength);
             pixels[x + y * heatMap.Width] = GetGradientColor(x, y + shift);
        }
    }

    //And apply texture ofc
}

//And here the colors to get

Color GetGradientColor(int x, int y) {
if (y <= southPoleCap || y >= northPoleCap)
    return coldest;
else if (y > southPoleCap && y <= southArcticCap || y < northPoleCap && y >= northArcticCap)
    return colder;
else if (y > southArcticCap && y <= southArcticOuter || y < northArcticCap && y >= northArcticOuter)
    return cold;
else if (y > southArcticOuter && y <= southMiddleOuter || y < northArcticOuter && y >= northMiddleOuter)
    return template;
else if (y > southMiddleOuter && y <= southTropic || y < northMiddleOuter && y >= northTropic)
    return hot;
else if (y > southTropic && y <= southMiddleInner || y >= northMiddleInner && y < northTropic)
    return hotter;
else
    return hottest;
}

I'm not at home right now, so I can't give the new code I've got for that, but that's the proper base, just few really small changes
So, once the GetDistortedGradient texture is done, it should go to the GetTexture and create based on whatever colors there's on the distorted texture


texts: How can I read a portion of one Minecraft world file and write it into another?

texts:
I'm looking to read block data from one Minecraft world and write the data into certain places in another.

I have a Minecraft world, let's say "TemplateWorld", and a 2D list of Point objects. I'm developing an application that should use the x and y values of these Points as x and z reference coordinates from which to read constant-sized areas of blocks from the TemplateWorld. It should then write these blocks into another Minecraft world at constant y coordinates, with x & z coordinates determined based on each Point's index in the 2D list.

The issue is that, while I've found a decent amount of information online regarding Minecraft world formats, I haven't found what I really need: more of a breakdown by hex address of where/what everything is.

For example, I could have the TemplateWorld actually be a .schematic file rather than a world; I just need to be able to read the bytes of the file, know that the actual block data starts always at a certain address (or after a certain instance of FF, etc.), and how it's stored. Once I know that, it's easy as pie to just read the bytes and store them.


texts: Game loop, how to check for conditions once, do something, then not do it again

texts:
For example, I have a Game class and it keeps an int that tracks the player's lives.  I have a conditional

if ( mLives < 1 ) {
    // Do some work.
}

However this condition keeps firing and the work is done repeatedly. For example, I want to set a timer to exit the game in 5 seconds.  Currently, it will keep setting it to 5 seconds every frame and the game never ends.

This is just one example, and I have the same problem in several areas of my game. I want to check for some condition and then do something once and only once, and then not check or do the code in the if-statement again.  Some possible solutions that come to mind are having a bool for each condition and set the bool when the condition fires.  However in practice this gets very messy handling lots of bools, since they have to be stored as class fields, or statically within the method itself.

What is the proper solution to this (not for my example, but for the problem domain)?  How would you do this in a game?


texts: Why game engines usually don't offer a vector3.rotate method?

texts:
Game engines like Three.js, Ogre3d and Unity3d often don't provide a default rotate method on their vector class. You usually have to do something like:

rotated = vector.applyQuaternion(
    new Quaternion().setFromEuler(
        new THREE.Vector3(0,0,Math.PI)));

This is a little confusing for me, so I just define a rotate method. Is there a special reason for this?


texts: ANDEngine : 3d rotation in Particle System

texts:
Im using ANDEngine and wants to create confetti particle system.

But im unable to make flipping and rotation of confetti particle around z-axis
Since andengine is 2d engine, it doesnot support that.

However like in the following example , 3d rotation has been implemented for a single sprite:

http://code.google.com/p/andengineexamples/source/browse/src/org/anddev/andengine/examples/Rotation3DExample.java

I want to do this for the particles.
Am i missing something ? or do i hv to modify the particle system code.


texts:
I am attempting to design mouse-aimed turning to control an aircraft in a 3D environment. To cut it short, you aim where you want to go, and the aircraft turns to face that direction (similar to War Thunder).

When turning an aircraft, it makes sense to use your elevator instead of your rudder (especially in long turns). If you need to turn 90 degrees left, it makes sense to roll 90 degrees left first, then use the elevator to turn, finally leveling out the aircraft once the target heading is reached.

Now, I want the user to be able to control the roll, but I also want the game to do it automatically when the player is not controlling it. My problem is conceptualizing what operations I need to do to get the target roll angle.

I managed to figure out that to align myself correctly, I need to align the plane that bisects the aircraft (the V plane) with the direction I want to move to (the D vector). The R angle is how much I would need to turn (in local angles) to achieve the derired orientation.

So, if I the player looks at the blue circle, the plane will roll right and hold that roll until it's almost aligned with the desired direction. At that point, it will unroll and level out.

Just figuring out the roll I need would be a big help. Preferably I'd like to get it done with dot and cross products, as these operations are already established and I have easy access to the up, right and forward vectors of the plane, as well as the direction vector.


texts: Observer pattern for clickable 2D Elements?

texts:
So i am currently thinking about the best way to handle and implement clickable 2D menu elements in a very simple DirectX Game.
I very much like the idea of having subscribers to a event where they are getting notified (e.g. the mouse click).

My question now is: Where and how do i determine which subscriber gets notified by a mouse click? Does the publisher know about all the positional data of the subscribers? Should the publisher just notify all 2D menu elements, so that they need to handle this event (check if the clicked position intersects with their own dimension)? Is this even a good idea?

As already stated, this will be a very basic game, so performance should not be any real issue yet. Still i always like to use some of the best practices, so i will at least learn some part of it (thus i will not implement a complete GUI system, only the subscriber part).

Thank you!


texts: Character controller falling with positive speed

texts:
I'm having very weird problems with my player's vertical movement. I'm using a Character Controller component with a capsule collider and no rigidbody. For testing purposes, I've ended reducing my jump script to just this line:
    owner.CharacterController.Move(new Vector3(0, 0.01f, 0));

When executing this script, the player should just fly upwards at a constant speed, right? Well, what ends up happening is that the player starts jumping in place repeatedly. The jumps are smooth, as if the movement was being affected by gravity. I thought that the standard Character Controller doesn't handle gravity automatically and you have to do it yourself, so I can't understand what's going on here. There is no other code affecting the player, if I comment that line it just rests in place. If I try a different direction (like (0.01f, 0, 0)) the player moves in a straight line in the provided direction as expected. But when moving vertically, weird stuff happens :S


texts: How can I seamlessly loop a background texture in XNA?

texts:
Using XNA, I made a looping background with several textures (whose widths are over 1024px). There are fewer than five of them. All the pictures are different, held in a list and their positions are looped. When it reaches the end of the loop, it flickers.

In my Update method I do this:

dt = (float)gameTime.ElapsedTime.TotalSeconds;
foreach(BackGroundObject bgo in myList)
{
    bgo.Position += speed * dt;
}

So that it works based on gameTime. Then, in my drawing function is this code:

foreach(BackGroundObject bgo in myList)
{
    spriteBatch.Draw(bgo.Picture, bo.Position, Color.White);
}

Here is the BackGroundObject class. The game holds a list of BackGroundObjects and Update changes their positions. If any object goes off screen, its position is set again; a BackGroundObject is loaded once and the game always uses same BackGroundObjects. MayDraw is a property of the picture's position. I.e. If in the screen or not.

public class BackGroundObject
{
    public Texture2D Picture;
    public Vector2 Position, DrawPosition;
    public bool MayDraw;

    public BackGroundObject(Vector2 position, Texture2D picture)
    {
        this.Picture = picture;
        this.Position = position;
        this.MayDraw = true;
    }

    public virtual void Draw(SpriteBatch spriteBatch)
    {
        if (MayDraw == true)
        {
            spriteBatch.Draw(Picture, Position, Color.White);
        }
    }
}

Does the flicker problem occur because of the large image sizes? Could I do this with a shader instead?

My background code works on with a graphic card with 60 FPS, but on a onboard graphic card with 30 FPS.

I have 4 background layers, each layer has 4 pictures, in total about 15pictures are drawen with widths of 1920.


texts: How would I go about updating my electronic circuit simulator's 'electricity'?

texts:
I have made an application which allows the user to place down wires, power sources, and inverters on a virtual circuit board. All connections between tiles are automatic, as shown here:

As you can see in the last image, the updating of power throughout this grid is not yet functioning. I think I understand how to do this updating conceptually, but getting it to work in my program is appearing to be much more difficult than I first imagined. My source code can be found here.

Getting tiles to pass on power to their neighbors is quite easy, but the tricky part is getting wires to "unpower" after the removal of a power source. The size of the grid is just 18x18, so efficiency really isn't a factor, for those wondering.

If you have any tips as to how to I might approach this task, please let me know.


texts:
I am making a board game in unity 4.3 2d similar to checkers. I have added an empty object to all the points where player can move and added a box collider to each empty object.I attached a click to move script to each player token. Now I want to assign valid moves. e.g. as shown in picture... Players can only move on vertex of each square.Player can only move to adjacent vertex.Thus it can only move from red spot to yellow and cannot move to blue spot.There is another condition which is : if there is the token of another player at the yellow spot then the player cannot move to that spot. Instead it will have to go from red to green spot. How can I find the valid moves of the player by scripting.

I have another problem with click to move. When I click all the objects move to that position.But I only want to move a single token. So what can i add to script to select a specific object and then click to move the specific object.Here is my script for click to move.

var obj:Transform;

private var hitPoint : Vector3;

private var move: boolean = false;

private var startTime:float;

var speed = 1;

function Update ()
{
if(Input.GetKeyDown(KeyCode.Mouse0))
{
var hit : RaycastHit; // no point storing this really
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, hit, 10000))
{
hitPoint = hit.point;
move = true;
startTime = Time.time;
}
}

if(move)
{
obj.position = Vector3.Lerp(obj.position, hitPoint, Time.deltaTime * speed);
if(obj.position == hitPoint)
{
move = false;
}
}
}`


texts: My gameObject does not move, when it returns to its original scene

texts:
I have a map where I have a 2d Ship as gameObject, which can be dragged with the finger to travel between islands and do the corresponding activities, when the player finishes playing on the island he returns to the map where the ship is, but when you try to drag it, you can not do it anymore.

for the change of scene use collisions, as shown in the code.

public string name;

public void OnTriggerEnter2D (Collider2D other)
{
    if (other.gameObject.tag == "Player")
    {
        SceneManager.LoadScene(name);
    }
}

Does anyone know the cause of this error?

The drag code:

public float moveSpeed = 5f;
private Vector3 mousePosition;
private Rigidbody2D _rigidbody;

private void Awake ()
{
    _rigidbody = GetComponent <Rigidbody2D> ();
}

private void Update ()
{
    if (Input.GetMouseButton (0))
    {
        mousePosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
        mousePosition.z = transform.position.z;

        Vector3 targetPosition = Vector3.MoveTowards (transform.position, mousePosition, moveSpeed * Time.deltaTime);

        _rigidbody.MovePosition (targetPosition);
    }
}


texts: When a sprite is rotating to follow an angle, how to prevent it from reversing direction after a point?

texts:
Below is a section of my code which handles a player's sprite rotating towards an angle after a user touches the screen:

touchState = TouchPanel.GetState();
Vector2 touchPosition;

if (touchState.Count > 0)
{
   touchPosition = new Vector2(touchState[0].Position.X, touchState[0].Position.Y);
   targetPosition = Math.Atan2(player.Position.X - touchPosition.X, player.Position.Y - touchPosition.Y);

if (angle_radians < targetPosition)
{
    angle_radians += 2 * fps;
}

if(angle_radians > targetPosition)
{
    angle_radians -= 2 * fps;
}

player.Angle = angle_radians * -1;
}

The problem I'm having is that when the angle goes past a certain point (I believe 3.15 radians?), the logic no longer functions correctly and the sprite reverses direction in a 360 circle until it meets the target position again.

I know there is something I'm missing from this logic, and I can see the problem, but I'm not sure how to approach handling it.

How would I prevent the sprite from reversing direction?

Thanks

EDIT: I tried the solution below but I only receive a positive number from 0-6 for angle_distance, what have I done wrong?

            if (touchState.Count > 0)
            {
                touchPosition = new Vector2(touchState[0].Position.X, touchState[0].Position.Y);
                targetPosition = Math.Atan2(player.Position.X - touchPosition.X, player.Position.Y - touchPosition.Y);
                angle_distance = targetPosition - angle_radians + Math.PI;
                angle_distance = angle_distance - Math.Floor(angle_distance / 2 / Math.PI) * 2 * Math.PI;

                if (angle_distance < 0)
                {
                    angle_radians -= 2 * fps;
                }

                if (angle_distance > 0)
                {
                    angle_radians += 2 * fps;
                }

                player.Angle = angle_radians * -1;
            }

EDIT: I now realise my mistake, correct solution is below

if (touchState.Count > 0)
                {
                    touchPosition = new Vector2(touchState[0].Position.X, touchState[0].Position.Y);
                    targetPosition = Math.Atan2(player.Position.X - touchPosition.X, player.Position.Y - touchPosition.Y);

                    angle_distance = targetPosition - angle_radians + Math.PI;
                    angle_distance = angle_distance - Math.Floor(angle_distance / 2 / Math.PI) * 2 * Math.PI;

                    if (angle_distance < Math.PI)
                    {
                        angle_radians -= 2 * fps;
                    }

                    if (angle_distance > Math.PI)
                    {
                        angle_radians += 2 * fps;
                    }

                    player.Angle = angle_radians * -1;
                }


texts: How to use RSSetScissorRects with multiple rects?

texts:
I try this and work only first rect.

D3D11_RECT rc[2];
rc[0] = {0, 0, 16, 16};
rc[1] = {32, 32, 64, 64};

m_d3d11DevCon->RSSetScissorRects( 2, rc );


texts: Supporting uniform/non-uniform scale in hierarchical animation

texts:
I have worked with hierarchical blended animation systems for a number of years, but I have never been quite sure how to handle scale correctly. The introduction of non-uniform scale is additionally puzzling. Does anyone have any insight into the right way of doing it? What I am trying to determine is when in the hierarchical concatenation that scale is included. My components are stored as a follows:

vector3 position;
vector3 scale;
quaternion rotation;
quaternion stretch_rotation;

What I am finding is if I include scale into the matrix during concatenation, I run the risk of grossly amplifying the accumulated errors down the hierarchy. Does anyone have any insight or articles here? To be clear - I know how to do hierarchical animation just not the right way to handle scale.


texts: character and camera not moving in the same speed

texts:
the two scripts below do the similar things,
 get the key press and calculation the direction
after the direction calculated, they multiple with the same speed,  say 0.05f,
while the character and the camera, do not move at the same speed,
and the character move faster than the camera.
if i rotate the camera a bit and move the character, the character move even faster than camera.
i believe there are something wrong in the variable direction, i would like to like how can i fix it so that both of them can move at the same speed in every direction.
Thank you.

character movement script:

    animation.CrossFade("moving");
        direction = Vector3.zero;
        myposition= transform.position;

    if(Input.GetKey("i")) {
        animation.CrossFade("moving");
        direction += Vector3.forward;
        currentkeydown=true;
    }
    if(Input.GetKey("k")){
        animation.CrossFade("moving");
        direction += Vector3.back;
        currentkeydown=true;
    }

if(Input.GetKey("j")){
       animation.CrossFade("moving");
       direction += Vector3.left;
       currentkeydown=true;
    }

if(Input.GetKey("l")){
    animation.CrossFade("moving");
    direction += Vector3.right;
    currentkeydown=true;
}

       //if two key press
if(Mathf.Abs(direction.x)+Mathf.Abs(direction.y)+Mathf.Abs(direction.z)>1){
          direction.x/=2;
          direction.y/=2;
          direction.z/=2;
         }

         //if direction change
         if (direction != Vector3.zero) {
             direction = Quaternion.Euler(0.0f, Camera.main.transform.localEulerAngles.y, 0.0f) * direction;
             transform.rotation = Quaternion.LookRotation(direction);
         }

         if(currentkeydown){
          transform.position+=direction*speed;
         }

and camera script

if(Input.GetKey("i")) {

         direction += Vector3.forward;
         currentkeydown=true;
       }

       if(Input.GetKey("k")){
         direction += Vector3.back;
         currentkeydown=true;
       }

       if(Input.GetKey("j")){
         direction += Vector3.left;
         currentkeydown=true;
       }

       if(Input.GetKey("l")){
         direction += Vector3.right;
         currentkeydown=true;
       }

       if(Input.GetKey("u")){
         transform.RotateAround(player.transform.position,Vector3.up,-2f);
       }
       if(Input.GetKey("o")){
         transform.RotateAround(player.transform.position,Vector3.up,2f);
       }

       direction = transform.TransformDirection(direction);
       direction.y = 0;
       if(currentkeydown){
         if(Mathf.Abs(direction.x)+Mathf.Abs(direction.y)+Mathf.Abs(direction.z)>1){
          direction.x/=2;
          direction.y/=2;
          direction.z/=2;
         }
       transform.position+=direction*speed;
       }


texts: Keep the same code format no matter the IDE

texts:
In webdevelopment, there is a file called .editorconfig which have all the standards and format for the IDEs to follow, so no matter with what IDE you are working, the format will be the same.

This is an example of a .editorconfig file:

# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

Is there any way to have something similar in Unity, so, no matter what IDE our team use (MonoDevelop, VSCode, VStudio, Atom) we mantain the same style when formatting the documents?

It's really annoying to have a lot of commited changes when someone else simply reformatted the code with a different style.


texts: How to make a Sprite have multiple armors/weapons/Accesories

texts: I am currently developing a game that involves a multitude of weapons, armors, etc. I am using UE4 currently as an engine because I found that easy to use. Currently in development I have found myself unable to figure out how to make it so my character has the ability to equip different items. Does anyone know of any way that I can get this to work?


texts: Baked Lightmaps never finish baking in Unity - what is a minimum "test bake" light setting?

texts:
Tried a number of different configurations. It seems lightmaps never finish baking?
How does one get the light maps to bake?
What is a minimum "test bake" light setting?


texts:
Please can someone point me in the right direction. I'm working on a slot game. that I'm having trouble figuring how to implement the probability function for. The game has a set of symbols that bets can be placed on. A symbol is selected when the start button is pressed. If there is a bet on the symbol that is selected the player wins a value equal to the [bet]*[bet multiplier]. The bet multipliers work as follows:

If the selected symbol is marked with x3 it overrides the normal multiplier and the winning value is equal to bet*3 for that symbol.
If the selected symbol is Apple then the winning value is [bet apple]*5
If the selected symbol is BAR then the winning value is the bet on BAR multiplied by the multiplier on the selected BAR symbol (x50 or x100).
The other symbols are grouped into 2 groups of 3 and share a multiplier value that is selected at the time when a symbol on the board is selected. Eg. the orange, lemon and bell form a group. and share a multiplier of 10, 15 and 20. If the selected symbol is lemon and the selected multiplier is 10 the the winning value is equal to [bet lemon]*10.

There is also a luck symbol that have the following 3 outcomes:

The player looses.
3 Symbols are selected and winning value is the sum of the bets multiplied by their respective multipliers.
A respin is triggered and a new symbol is selected (cannot be a respin but may be one of the other 2 luck outcomes)

The player may also double there winnings by selecting between two options [1-6] or [8-13] a number is generated between 1 and 13 and the winnings are either lost or multiplied by 2.

See the attached pictures for a better understanding of the game.

What I'm having a problem with is figuring out a way to select the outcome of the spin and double feature while maintaining a pay back percentage X% that should hold true over many spins/doubles and that can be adjusted manually.


texts: How to find asset by it's number? Don't know what this number means

texts: I need to find the asset that is displayed by this number inside my project. I guess this number means "GUID" but it's hard for me to understand what is it. Can you help me guys?


texts: How to draw the editor's camera position in play mode Unreal?

texts:
The blue camera that is drawn for the CameraComponent in the editor.

My intended usage is that when playing a third person template, ejecting from the pawn and then selecting it, will show the Camera debug asset instead of just the camera boom.

So in the above picture of the editor mode, the camera attached to the pawn is visible.

Yet when in play mode. Ejecting from the pawn and selecting the pawn shows only the camera boom (the red line) and not the camera 'debug asset' used in the editor.


texts:
I am coding a rather "simple" 4X game (if a 4X game can be simple). It's indie in scope, and I am wondering if there's anyway to come up with a passable AI without having me spending months coding on it.

The game has three major decision making portions; spending of production points, spending of movement points and spending of tech points (basically there are 3 different 'currency', currency unspent at end of turn is not saved)

Spend Production Points

Upgrade a planet (increase its tech and production)
Build ships (3 types)

Move ships from planets to planets (costing Movement Points)

Move to attack
Move to fortify

Research Tech (can partially research a tech i.e, as in Master of Orion)

The plan for me right now is a brute force approach. There are basically 4 broad options for the player -

Upgrade planet(s) to its his production and tech output
Conquer as many planets as possible
Secure as many planets as possible
Get to a certain tech as soon as possible

For each decision, I will iterate through the possible options and come up with a score; and then the AI will choose the decision with the highest score. Right now I have no idea how to 'mix decisions'. That is, for example, the AI wishes to upgrade and conquer planets at the same time. I suppose I can have another logic which do a brute force optimization on a combination of those 4 decisions....

At least, that's my plan if I can't think of anything better. Is there any faster way to make a passable AI? I don't need a very good one, to rival Deep Blue or such, just something that has the illusion of intelligence.

This is my first time doing an AI on this scale, so I dare not try something too grand too. So far I have experiences with FSM, DFS, BFS and A*


texts: How do I make a 2D character aim their gun toward the mouse?

texts:
Heli Attack is a perfect example of the shooting mechanic I'd like. The character aims perpetually toward the mouse. What's going on here?

From what I've read so far, you could separate the arm and rotate that. I've also noticed some people use a different sprite for each weapon.

How can I achieve this?


texts: What can be done to recover from an exploit-related PR disaster?

texts:
Let say company x makes massively multiplayer online strategy games. The game y is updated adding a feature z, but developers forgot to add server-side verification or it was bypassed (using alternative UI). Update allowed users to double their units as many times as they like. After about a day this bug was fixed. A lot of members had abused this bug - some by accident(?), others as much as possible. Damage has been done and extra units still remain.

The game has a cash shop where speedups, elite units, etc can be bought. Some members have spent hundreds of dollars to be among the best and played this game for several months if not years.

I want to know : what can be done, if rollback is not possible?


texts: Getting Bodies to go "Super Fast" in Box2D

texts:
I am making a breakout game in Android using the LibGDX version of Box2D. I have a ball that I am applying a force to with the following code...

getBody().applyForceToCenter(-10000000000.0f, -10000000000.0f);

This makes the ball move properly, but it never seems to gain a lot of speed (and I want to make it go super fast). I tried adding an accelerate method where I applied the force 40 times, but again it doesn't seem to move that fast. What is a good way to make a Body go "Super fast" in Box2D?

If there is acceleration I would like it to be as short as possible.

I tried adding the following....

World.setVelocityThreshold(1000000.0f);

But now the ball doesn't seem to "bounce" off walls, do I need to raise my restitution or something?


texts: Problem when importing fbx in Unity made in Blender

texts:
First I will explain how do I make my object in Blender:

I want to make an object with a texture that have transparecies (png image). I unwrap my object and then apply the image to it in the UV editor. Then I export my object as fbx.

To try the transparecy first I imported a PNG image as a plane on Blender and adjusted the necessary things in order to make work the transparency. You can appreciate the settings I used in the following image:

Until there is all fine. The problem appears when I import the fbx in Unity. The material that I created with the png image is not well visualized.

When I import the fbx object in Unity, this messages appears in the Materials tab:

What do I have to set here in order to visualize well the image with its alpha channel working?

Furthermore, if I try to change the material settings it is impossible because I cannot click the different options as they are disabled:

Can anybody tell me what I'm doing wrong? I don't know if my error is when creating the material in Blender or when I import the fbx in Unity.


texts: Object rotating error in Bullet Physics with OpenGL

texts:
I have got some problem in my OpenGL game. I am using bullet physics and I want to achive quite simple effect - I want one object (a sphere) to roll and hit another (box) which will fall down.

I have got almost everything but still I have got some errors. When the box is hit it is rotating almost how I would like to. Well, almost means that when ball hits it it falls and rotates however there are about 20 degrees left to the ground.

It isn't stoping on a ball because the speed is so high that it is throw away and after a while it "meets" ball

This is my code for objects (including floor) initialization:

dynamicsWorld->setGravity(btVector3(0,-10,0));

    ballShape = new btSphereShape(1);

    fallMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(2,1,0)));
    btScalar mass = 5;
btVector3 fallInertia(0,0,0);
ballShape->calculateLocalInertia(mass,fallInertia);

    groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(1.),btScalar(70.)));

    btDefaultMotionState* groundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,-1,0)));
    btRigidBody::btRigidBodyConstructionInfo groundRigidBodyCI(0,groundMotionState,groundShape,btVector3(0,0,0));
btRigidBody* groundRigidBody = new btRigidBody(groundRigidBodyCI);
    dynamicsWorld->addRigidBody(groundRigidBody);

    btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass,fallMotionState,ballShape,fallInertia);
fallRigidBody = new btRigidBody(fallRigidBodyCI);
dynamicsWorld->addRigidBody(fallRigidBody);

    fallRigidBody->setLinearVelocity(btVector3(-5,0,0));

    pinShape = new btBoxShape(btVector3(0.5,2,0.5));

    btDefaultMotionState* fallMotionState2 = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,3,0)));
    btScalar mass2 = 1;
btVector3 fallInertia2(0,0,0);
pinShape->calculateLocalInertia(mass2,fallInertia2);
    btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI2(mass2,fallMotionState2,pinShape,fallInertia2);
pinRigidBody = new btRigidBody(fallRigidBodyCI2);
dynamicsWorld->addRigidBody(pinRigidBody);

and this is how I am setting the box position and rotation:

btTransform trans2;
pinRigidBody->getMotionState()->getWorldTransform(trans2);
    cubeX = trans2.getOrigin().getX();
    cubeY = trans2.getOrigin().getY();
    cubeZ = trans2.getOrigin().getZ();

    rot = trans2.getRotation();
//...
glTranslatef(cubeX,cubeY,cubeZ);
    glRotatef(rot.getX()*(360/3.14),1,0,0);
    glRotatef(rot.getY()*(360/3.14),0,1,0);
    glRotatef(rot.getZ()*(360/3.14),0,0,1);

    glScalef(0.5,5.0,0.5);
    glutSolidCube(1.0f);

Can someone tell me what is wrong in it? I have got no idea what else I can do.


texts: How do I make my plane appear 3D like in the "Roll-a-ball" tutorial?

texts:
I am following the first tutorial on the Unity website, which details making a 'Roll-a-ball' game.

I am stuck at a point where I need to make a 3D plane object; it looks flat, to me, and unlike how it looks like in the tutorial.

How do I make my plane look 3D?

This is what I see:

This is what I see in the tutorial:


texts: Get intersecting point of Arc, X distance from centre (Unity)

texts:
I'm no mathmetician so forgive my wording when I ask this, there is no doubt an answer somewhere but I dont even know what to search for.

I want to find the intersection point (B) as a Vector2 on a perfect circle.

If I know X, Y, A and C I assume I can use the radius and distance to calulate the position of B based on the distance between X and C somehow? (using C# if there are any methods which will accomplish this)

TIA.


texts: Determine view-matrix with camera placed in a scene graph

texts:
My scene is organized with a simple scene graph where the child multiplies its transformation with the one of the parent.

For normal objects, likes meshes, this works as expected, but I also want to insert the camera into the scene graph.
To get the view-matrix I need to take the inverse of the global transformation matrix, which works except that this messes up the near/far plane dimensions. Because if a node above the camera has a scaling of 0.1 (across every dimension) the inverse will scale the whole world by a factor of 10.

Is there a simple way to get rid of the scaling or do I need to update my near and far plane based on the final view scaling?


texts: How to Simulate Height in a Tiled Top-Down Game

texts: How can I simulate height in a top-down tiled 2D game? One way I thought was to make tiles which are supposed to be higher brighter, but I was wondering if there was a standard or better implementation.


texts: How to position a 3D crosshair on an objects face and set its angles **outward** from objects face?

texts:
What I have right now, is a ray tracer for my cursor on my canvas, when I click on the object, it gets the vector of my selection in the 3D space on the object I had my mouse on.

The ray tracer returns a point which is a Vector3, so I set my crosshairs (line) position to point, only issue is, I need my crosshair to be pointing outward from my object like so: (example)

This is where my issue lies... I need to get the direction of the face that my ray tracer intersected, but I cant figure out how. I can get the direction of the object itself no problem,but I dont want that, I want my crosshair to lie flat on the face that its positioned on.

This is it incorrectly positioned on the side of my model:

So the line thats pointing outward from the cross, should point outward from the face and the cross be flat on the surface I clicked.

This is the code Im using now:

line.position.copy(intersects[0].point);
var mx = new THREE.Matrix4().lookAt(intersects[0].point,new THREE.Vector3(0,0,0), intersects[0].normal);
var qt = new THREE.Quaternion().setFromRotationMatrix(mx);
line.rotation.copy(qt);

Update

I've tried another approach as seen here but Im still haing trouble getting it to flatten out on the mesh:

var mat = intersects[0].object.matrixWorld;
    mat.setPosition(new THREE.Vector3(0, 0, 0));
    var globalNormal = intersects[0].face.normal.clone().applyMatrix4(mat).normalize();
    var lookAtTagret = new THREE.Vector3().addVectors(intersects[0].point.clone(), globalNormal);
    line.lookAt(lookAtTagret);
    var cPos = new THREE.Vector3().addVectors(intersects[0].point, globalNormal.multiplyScalar(0.05))
    line.position.copy(cPos)


texts:
Possible Duplicate:
  How do I build a 2D physics engine?

If we take the game Angry Birds that had big success lately I were thinking how do they implement the physics in a game like that?

Your are shooting of your birds and they hit something that will fall off and in turn creating a chain reaction of things either falling or exploding.. Are all this happening with calculations with rules considering all collisions together with gravity etc.?


texts: Error with Cocos2d-JS when using Skeletal animation from Cocos Studio

texts:
Here is the JavaScript code：

var size = cc.winSize;
ccs.ArmatureDataManager.getInstance().addArmatureFileInfo(res.skeleton);
// The error comes from the following line
var armature = ccs.Armature.create("Skeleton");
armature.getAnimation().play("hit");
armature.x = size.width / 2;
armature.y = size.height / 2;
this.addChild(armature);

And at runtime I get this error：

  Assert failed: AnimationData not exist!

I know that error is from the specified line, but I'm very confused as to how I can solve it.

I have tried many different methods, but unfortunately those didn't work.

In the resources, I load all the image files and JSON files which made by Cocos Studio, and the file path and name are correct.

What could be causing this error?


texts: Lights appear when run in the player although Editor playmode seems to be dark enough [Unity 5]

texts:
I've removed all the lights in my scene and the ambient lighting. It works fine in the editor play mode but when I run it on my Android or as a standalone player a light source appears.
The light source seems to be ambient in the PC standalone version and directional in the Android version.

Are there any other options that I have to look at?


texts:
I'm currently working on a Java game
I know a lot of games created all instances of objects beforehand and then bring then in and out of play when they are needed.

Will it be worth it to have a Vector of all instances that are alive, and loop through that instance of going through all of the instances and checking the alive boolean?

Thanks


texts: How do I implement the parallax effect in 3D graphics?

texts:
With a perspective projection matrix and camera system already in place, I have a scene with a small jet fighter flying high over a wide and deep canyon with many cliffs and rocky surfaces; these are all being rendered as wireframes for now. The camera is following the ship which is flying entirely on the X-Z plane.

Right now, when the ship moves by some amount r, the entire canyon moves by that same amount in the opposite direction. I want to have parts that are further away from the camera to move slower, so I need parallax.

If I were going to implement parallax, in which part of the rendering system would it go, the projection matrix?

Below is a screenshot of the game as it is. The ship is moving forward and about to pass through some rocky crags.


texts: How to do reflective collisions with particles hitting background tiles?

texts:
In my 2d pixel old-school platformer, I'm looking for methods for bouncing particles off of background tiles. Particles aren't affected by gravity and collisions are "reflective". By that I mean a particle hitting the side of a square tile at 45 degrees should bounce off at 45 degrees as well.

We can assume that tiles will always be perfectly square. No slopes or anything.

What are efficient methods and algorithms to do this? I'd be implementing this on a Sega Genesis.


texts: How do I pause/play animation in Unity without the animation getting cut off

texts:
I'm trying to achieve a common game behavior that when you hit an enemy, then whatever the enemy's action (animation) is, when the hit happens, the enemy pauses a bit, then continues with the animation. So everytime you hit the enemy, the enemy pauses for a bit.

I currently have this code:

IEnumerator StopStartMotion()
{
    _animator.speed = 0;
    yield return new WaitForSeconds(.2f);
    _animator.speed = 1;
}

Problem is, sometimes, when I hit too early in the enemy's animation (like at the beginning of a punch), the enemy pauses, and then doesn't continue the animation where he paused for a bit. Is there a better way of doing this?

I tried animator.enabled as well, but the animation also jumps.


texts: How to flip coordinate system in Pyglet?

texts: Is there any way I can flip the coordinate system in Pyglet vertically so that y = 0 is at the top of the screen and a higher y value is closer to the bottom? It is really confusing trying to use Pyglet's flipped coordinate system with Ogmo Editor.


texts: How can I locate GameObjects near the player in Unity?

texts:
I'm trying to figure out how I can find GameObjects that are close to the player so that I can delete them with Destroy().  I know how to use Destroy() but I can't figure out how to get a reference to the objects I want to remove.

public class hand : MonoBehaviour {
public Transform player;
public Transform mushrums;
private Animator anim;

void Start () {
    anim = GetComponent<Animator> ();
}
public void HandUp () {

    float dist = Vector3.Distance(player.position, mushrums.position);
    Debug.Log(dist);
    if (dist <= 59)
    {
        anim.Play("pick_up");

            Collider[] hitColliders = Physics.OverlapSphere(this.transform.position, 20);

        while (i < hitColliders.Length) {
                 thisDist = (transform.position - hitColliders[i].transform.position).sqrMagnitude;

            if(thisDist < nearDist) {
                    nearDist = thisDist;
                    nearest = hitColliders[i].transform;

                }
            }
            if(nearest != null) {
            Destroy(nearest.gameObject);
            }

    }

}
}

if the radius of the 10, subject is not and
hitColliders.Length = 0
if the radius of the 20 its freezing
if remove WhileLoop while (i < hitColliders.Length) {thisDist ... but keep if(thisDist < nearDist) {... everything works and get another object, not the one that is near


texts: Unity - Where are Asset Store assets downloaded on Mac?

texts:
I'm on a Mac, running Unity 2021.1.5f1 Personal, and am trying to remove an asset I downloaded using Package Manager.
So for the asset in question, I want Unity to have to download the package again, from the Asset Store, to my local mac. That option is currently unavailable, because I have downloaded it in the past.
I've tried deleting the contents of these folders, to remove the downloaded file, but still no "download" option shows up next to the asset.

~/Library/Unity/Asset Store/Cache
~/Library/Unity/cache
MY_PROJECT/Library/PackageCache
I also tried clearing the cache in Preferences | Gi Cache
I looked in the docs for Asset Store cache, and the closest I found was this link


texts: I don't have formal studies in programming nor in graphic design, I'm self-taught, you know I have learned some things here and there. So far have been doing amateur stuff, sort of hobbyist. I would like at some point of my life be doing professional games, don't know if that would mean acquiring formal knowledge at some gaming college. It is something even desirable or advisable?


texts: How can I pack repeated textures into one texture efficiently?

texts: I have an obj mesh with some textures, several of them are repeated(uvs are not within [0,1]). I'd like to merge all those textures into one texture and transform the uvs of obj.


texts: Cloth tool and Skeletal Bone Weight Paints in Unreal Engine

texts:
Just a quick question:
I've got my 3rd person rigged and skinned, but I have some hanging fabric around the characters waist which drapes down to the characters legs. Should this fabric be weighted so that it is affected by the characters legs as they are animated, or just the bones around the waist area?
My thinking is that I don't want the cloth to be affected by the legs, as the cloth simulation will take care of that for me. Instead the aim should just be to make the cloth orientate with the bones in the waist area, mostly "spine" and "spine1". As such I should just skin the cloth to the lower spine bones, and ignore the legs.
If I am incorrect, I'd appreciate any correction, and my apologies for any incorrect terminology, I am still learning.
Cheers!


texts: Terrain shadows not rendered to additional camera with Unity3D URP

texts:
I'm running into problems with a project using several cameras rendering to different monitors.
The first Camera (a VR camera) renders the foliage and the terrain correctly.
However, in the second camera view, I see the objects are receiving light, but are not casting shadows on the terrain.

Culling mask of both Cameras is set to "Everything"
Trees and other objects have shadow casting enabled (and render correctly to the main Camera)
I tried changing the shadow distance, without any result
I tried different terrain light modes, which didn't help
I tried using the same renderer for both cameras, and a different renderer for each camera, without success
I tried putting all the cameras and lights on the same object layer, without any success

Any hint about how to solve this issue?


texts: Finding neighboring coordinates on offset tile map

texts:
I have a grid of hexagonal tiles. Every other row is slightly offset for visual reasons. Imagine a player touches any tile - I need to compare the coordinate of that tile, with any tile they touch next so that I can ensure they're right next to each other.

If the grid had no offset, I could simply ensure we were within 1 x and 1 y coordinate, but that fails in certain scenarios here.

I can get extremely close - the following code works in all cases, but still allows coordinates 3,2 and 4,3 to count as neighbors, among others with a similar mathematical relationship.

int diffX = abs(newCoord.x - lastCoord.x);
int diffY = abs(newCoord.y - lastCoord.y);

// Never allow jumping rows
if( diffY > 1 || diffX > 1 ) return false;

// Allow same columns
if( diffX == 0 || diffY == 0 ) return true;

return false;

A friend had an idea about combining the coordinates into single numbers and ensuring the neighbor was within a certain amount, but that fails for several combinations as well.


texts: Unity - Set/Manipulate Render-Buffer for "Render Overlay Effects"

texts:
Note

This is more of a question on how/where to do furhter research into this topic becasue I do not know anything about it yet. If anyone has answers on how to accomplish this goal, I'd very much welcome it, too!

Background

I've been working on my own game (2D Arcade, Android) for quite a while and I'm currently adding "Sequences" which take controll of modular gameplay functionality and add some special behaviour as well as extra "challenges". To make the transitions more interesting - especcially transitions to bossfights
and/or dramatic scenes

What I want to do

I want to perform some sort of render overlay: basically manipulating the render buffer to either

Draw full colors (e.g. complete screen white PLUS fade out of white overlay)

and/or

Manipulate - "mix" - all pixels colors with a specific color to achieve a color mix effect (as shown below, which is just some example)

I have no idea at all on how to do this. I could write a shader, but that would have to be applied to every single object in the scene (?). The white overlay effect could be done with a simple white sprite, but I'd find it more interesing to create an overlay effect which can accomplish tasks such as 'color mixing'

Edit

I'm currently looking into CommandBuffers which have a very sparse documentation on how to actually use them but they seem to be intended for things that are way more complicated than what I intend to do.

What I'd ideally imagine is a way to get the current render buffer as some sort of array, matrix or whatnot, containing information of each individual fragment (as some brief research turned up it's not actually pixels), copy it, make some operations on it and return it to the target renderer. Is there a way to do anything alike?


texts: Who Handles Collision in a Component Based Entity System

texts:
I kind of stucking at my current plattformer protoype for learning the component based entity system pattern.

I have CollisionComponent and a CollisionSystem. The CollisionSystem checks every frame all entities with CollisionComponents for intersection. Then it marks inside the CollisionComponent the entities which are colliding with this entity. So if an entity A collides with Entity B then they both have a the other as a reference inside their CollisionComponent as data.

This works absolutely fine and I can tell which entity is colliding with something/someone.

Now I have the problem how to use this information properly. I have a MovementSystem and it moves entities with a MovementComponent based on the velocity and the acceleration.

Who is now responsible for NOT moving a entity or do something else on a collision. Should the MovementSystem check if the entity has a CollisionComponent and if there is one, should the MovementSystem handle the NOT movement?

Let's say I have this situation. I have an entity (player) with a MovementComponent and a velocity to the right (because the player presses the right arrow) and the usual downwards velocity due of gravity influences. The player entity collides with another entity. A GroundComponent entity. Now which system should put entity A (the player) upwards so that he does not colliding with the ground anymore? The MovementSystem? At the same time, the player entity collides with another entity, an enemy. Which system should now handle the damage, or the knockback or whatever that enemy does to a player unit?

I really like the CBES but it really does not get into my mind how everything glues together.

I want to threat the components as pure data, so no logic in there (besides of ScriptComponents, but this is another type of problem)

Now my question is, which system handles which cases and how to treat passes of system (e.g. Movement pass one then the other systems then movement pass 2 and so on? How many systems do I really need and should a system only handle one type of problem? MovementSystem -> pure movement no matter what. CollisionSystem -> pure collision registration no matter what, DamageSystem -> damage handling based on component data


texts: Is it a bad idea to have several audio sources on the same object in unity?

texts: The title is actually self-explanatory. I would like to know if there are any drawbacks (performance-wise, good-practice wise, etc.) for having multiple audio sources on the same GameObject. My initial intuition is that it gives me more freedom to have specific audio settings (volume, pitch, etc.) for each audio clip I want to play, but I want to know if this setup is advisable.


texts:
I downloaded the Space Kit from Kenney's assets and imported it to my project. I saw a subfolder called Models, with many files with .fbx extension (e.g. "alien.fbx", "astronaut.fbx", etc.). When I dragged them into the scene, I saw objects with some sub-objects (e.g. alien object with head and legs as sub-objects), but they seem just static objects - they have only renderers.
Is this what these .fbx files are all about?
Or maybe I am using these assets incorrectly?


texts: Input.GetKeyDown not working while Unity Remote is running?

texts:
I have this simple code:
void Update()
{
    if (Input.GetKeyDown(KeyCode.Escape))
    {
        Debug.Log("Escape");
    }
}

When I test it...

In the Editor, I press Escape, and it works.

On my Android, I press the Back button, and it works.

But when I hit play in the Editor while Unity Remote is running on my phone, neither the Escape on my keyboard, nor the Back button on my phone works.
The Update method is constantly running, just the Input.GetKeyDown returns false.
Why?


texts:
I am trying to make a pong game but I wanted to use dot products to do the collisions with the paddles, however whenever I make a dot product objects it never changes much from .9 this is my code to make vectors

vector = {
    make:function(object){
        return [object.x + object.width/2,object.y + object.height/2]
    },
    normalize:function(v){
        var length = Math.sqrt(v[0] * v[0] + v[1] * v[1])
        v[0] = v[0]/length
        v[1] = v[1]/length
        return v
    },
    dot:function(v1,v2){
        return v1[0] * v2[0] + v1[1] * v2[1]
    }
}

and this is where I am calculating the dot in my code

vector1 = vector.normalize(vector.make(ball))
vector2 = vector.normalize(vector.make(object))
dot = vector.dot(vector1,vector2)

Here is a JsFiddle of my code currently the paddles don't move.

Any help would be greatly appreciated


texts: How can I find a bounding box for a bezier curve

texts:
I am using the code from the question Adding functionality to make individual anchor points of bezier continuous or non-continuous to create bezier curves (I added a line renderer).

How can I find the center of the curve for multiple cubic Bézier segments, where the centre of a bounding box is the centre of the curve (as in the image below)?


texts: Is there a generic name for the "layered" dictionary typically used in mod-capable games?

texts:
I'm asking here rather than on SO/SE/CS because I'll probably have less to explain what I'm talking about...

I hope a lot of the users here are familiar with how many games implement modding (or sometimes even their own add-ons, levels etc.) Conceptually, what I've seen most often is a data structure that acts like a layered dictionary. With no mods, there's lookup in the base dictionary layer; whenever a mod is added/enabled, it comes with its own dictionary layer from which lookups are served first, with fallback to the underlying layers if a key is not found. (Note that I'm not talking about a nested dictionary.)

So, my question is simply if there's a generic name for this data structure. (Googling for "layered dictionary", which is how I dubbed it, doesn't turn up anything useful...) In the world of file systems, the closest thing that probably resembles it is a union mount. Alas "union dictionary" doesn't get any useful results either... (Also the word "union" is rather misleading in this context because there's an order in the layers of a "union mount".)

Added: By the way, I'm not asing how to implement it, as that's rather obvious from the description. Perhaps that's why no name have been devised for it... Also most game engines I've seen implement multi-layer (not just two) and some allow the (top) layers to be removed at any time so you can do (game) "levels" that way; others require an engine restart so it's only usable for "global mods", i.e. they optimize lookup time by "flattening" the layers down to one as they are added, which is basically why they need an "engine restart" to remove a layer.

Also, it seems the R (statistical) programming language basically has this its get functions:

  These functions look to see if each of the name(s) x have a value bound to it in the specified environment. If inherits is TRUE and a value is not found for x in the specified environment, the enclosing frames of the environment are searched until the name x is encountered.

So I guess something like "environments and their enclosures" is one term...


texts: When to use ShapeRenderer & SpriteBatch in libGdx?

texts:
As a beginner(in GdxLib+Android), i found that for rendering particular screen, we can render that using both ways then when to use specific ones?
&
What is the best option for Updating the smaller part/region of the screen?


texts: How do I "reset" the color in OpenGl ES 1.0/1.1?

texts:
In my 2D game I use glColor4f() to set the color and draw my screen border rectangles
but when I try to start drawing my game objects, made up of a texture
on a rectangular "quad", using GL10.GL_TEXTURE_2D, GL10.GL_VERTEX_ARRAY
and GL10.GL_TEXTURE_COORD_ARRAY no GL10.GL_COLOR_ARRAY, it uses the "current
color" from glColor4f().

My question is what do I need to set/reset in OpenGl ES to re-enable it to
use the colors from the texture when I try to draw them?  If I comment out the border drawing, so glColor4f() never gets called, the colors are fine.

I'm not using double buffering.  I read that once you set the color with
glColor4f() it stays set, unless you possibly use glPushAttrib(GL_CURRENT_BIT),
but I heard that that's expensive, time wise.


texts: How would I create an HLSL effect like an animated "working" image?

texts:
I want to create the effect in the image in HLSL specifically get a block of pixels to move from a specified start point to an end point, so that it can go across the entire screen, but I don't have a clue where to start. Could someone please point me in the general direction ?

This is the effect I want to replicate

This is the image I will be working with


texts: Box2d: Is there a way to have collisions but ignore the accompanying forces?

texts:
To begin, I know that you can use filtering or isSensor to remove physical collisions. However, I would like to retain the ability to, say for example, stop when trying to move past another player. Essentially, I don't want one player to be able to push another dynamic body with the force that normally accompanies a collision. I've tried static and kinematic bodies, but both obviously have their own problems with trying to have collisions.

An example might be a topdown game such as League of Legends of Starcraft, where units can impede on eachother's movements, but don't apply any force upon collision.


texts: What tech will enable a script to run after a certain amount of time elapsed following a user's action?

texts:
I'm trying to experiment in creating an MMO browser-based game using PHP, MySQL, Javascript, HTML5, and CSS.

There is this certain functionality that I want in my game that I'm having trouble with.

In detail, here's what happens:

The user clicks an action
Then a time limit will commence
After the time limit, then a script will run and the changes will take place.

I've heard of cron jobs but these changes are not in a set time. It depends on when a player makes a move or something.

Here are the possible ways I can think of carrying this out:

You save the time when the user makes a move, and when the user checks back again, there will be a script that will check if the time the user made a move and compare it with the current time. The problem with this is that, I wan't the changes to take place even when the player is offline. With this method, the changes will only happen after the player checks back again.
A cron job will do the above action of checking the time the user made a move and compare it with the current time. Probably every 30 minutes or every hour. The problem with this is, won't this be too much for the server? And still, it will be every 30 minutes or so. Will this be possible too if done in seconds?
A combination of the two. A cron job will check every hour and it will also check every time a user logged back in.

Of course these are the solutions I can think of using only cron jobs. I don't know if there is any better technology out there. I do hope that there is a better way like actually running a script after a certain amount of time elapse after an action even when offline. If there is, tell me. I'm talking server-side here ok.

Yeah, anyone can help me out with this?


texts: Get world position of random point inside bounds

texts:
I am trying to get a random world position inside my targets collider, so that I can fire an arrow at it.
I have tried a bunch of different solution but can't seem to get it right, for example (this code is on my target):
//Inside Awake
colliders = GetComponentsInChildren<Collider>(); //I want this to work on a unit with a single capsule collider and a building with 8 different box colliders

public Vector3 GetRandomPoint()
{
    Bounds b = new Bounds();

    for (int i = 0; i < colliders.Length; i++)
    {
        b.Encapsulate(colliders[i].bounds);
    }

    float minX = gameObject.transform.position.x - gameObject.transform.localScale.x * bounds.size.x * 0.5f;
    float minZ = gameObject.transform.position.z - gameObject.transform.localScale.z * bounds.size.z * 0.5f;

    return new Vector3(Random.Range (minX, -minX),
                           gameObject.transform.position.y,
                           Random.Range (minZ, -minZ));
    }

In the scenario I'm having issues with right now, the trageet simply has a single capsule collider.
This return a point quite far away from my target, but I cant find the issue.
EDIT:
Here is another one I tried without success:
public Vector3 GetRandomPoint()
    {
        Bounds b = new Bounds();

        for (int i = 0; i < colliders.Length; i++)
        {
            b.Encapsulate(colliders[i].bounds);
        }

        var target = new Vector3(
            UnityEngine.Random.Range(b.min.x, b.max.x),
            UnityEngine.Random.Range(b.min.y, b.max.y),
            UnityEngine.Random.Range(b.min.z, b.max.z)
        );

        return b.ClosestPoint(target);
    }


texts: How can I combine sprites and attach them to a GameObject?

texts:
I have the following sprites:

Background

Foreground

Combined they should look like this:

The first problem is Unity can only show one sprite with its Sprite Renderer, so I can't combine them with it.

The second problem is the bomb sprite should not be rotating along with the background, like so:

How can I do this?


texts: How do you draw a straight line between two points in a bitmap?

texts:
I'm playing around with height maps (bitmaps), trying to create some of my own in my game, and for that I need to implement some basic drawing methods. I've quickly realized that drawing straight lines isn't as basic as I thought.

It simple's if your points share an X or Y coordinate, or if they are aligned so you can draw a perfectly diagonal line. But in all other cases its trickier.

What algorithm do you use to determine what pixels need to be coloured for it to become a "straight" line ?


texts: How does the Unity coordinate system map to screen pixels?

texts:
If I have a GameObject, say at x = 0, y = 0, and I want to move
it for a 40 pixel to x how can I make that?

In don't understand which is the unit of measurement in Unity.

If I make something like this where mov is 40 the sprite goes out of screen!

void Start()
{
    transform.Translate(new Vector3(mov, 0, 0));
}

it seems like the correct values must be very low, say 0.6, 1, 3, etc.

But why?


texts:
I am writing an isometric game engine on OpenGL (version 3.3 specifically). For each wall tileset i have volume mask tileset for the wall relative volume coordinates.

Volume mask looks like this:

Now i am trying to write a simple lighting system (it kinda looks like that old game, Nox):

The idea is simple - i generate one-dimensional z-buffer for each light source (in the example i use only one test light spot), in the fragment shader for each fragment i'm figuring out is it lit or not etc.

Here's the vertex shader:

attribute vec3 scenePosition;
attribute vec3 screenPosition;
attribute vec2 screenTexCoord;
attribute vec2 volTexCoord;
attribute vec2 normalMaskTexCoord;
const int MAX_LIGHTS = 12;
uniform mat4 projectionMatrix;
uniform mat4 scrollingMatrixScreen;
out vec2 texCoordFrag;
out vec2 volTexCoordFrag;
out vec2 normalMaskTexCoordFrag;
out vec3 scenePosFrag;

void main(){
    texCoordFrag = screenTexCoord;
    volTexCoordFrag = volTexCoord;
    normalMaskTexCoordFrag = normalMaskTexCoord;
    scenePosFrag = scenePosition;
    gl_Position = projectionMatrix * scrollingMatrixScreen * vec4(screenPosition, 1.0);
}

Fragment shader:

const float specificLength = 0.177469939;
const float M_PI = 3.14159265358979323846;
const int LIGHT_Z_BUFFER_SIZE = 1024;

uniform sampler2D tex;
uniform sampler2D volumeMask;
uniform sampler2D normalMask;
uniform samplerBuffer testLightZBuffer;
uniform vec3 changingVec;

in vec2 texCoordFrag;
in vec3 scenePosFrag;
in vec3 testColorFrag;
in vec2 volTexCoordFrag;
in vec2 normalMaskTexCoordFrag;
in float wallLengthFrag;

out vec4 fragColor;

void main(){
    vec4 trueColor = texture(tex, texCoordFrag);
    if (trueColor == vec4(0.0, 0.0, 0.0, 0.0))\
        discard;

    float testLightRadius = 4.0;
    vec2 testLightCenter = vec2(2.0, 2.0);
    float lightBrightness = 0.0;
    float lightHeight = 2.0;

    vec3 volCoords = vec3(texture(volumeMask, volTexCoordFrag));
    vec3 trueSceneCoords = vec3(volCoords.x/specificLength, volCoords.y/specificLength, volCoords.z/specificLength) + scenePosFrag;
    vec3 normalCoords = normalize(vec3(texture(normalMask, normalMaskTexCoordFrag)));
    vec2 lightTangentRel = vec2(trueSceneCoords) - testLightCenter;

    if (length(lightTangentRel) <= testLightRadius)
    {
        float angle = acos(dot(normalize(lightTangentRel), vec2(1.0, 0.0)));
        float currentZBufferPoint = angle / (2*M_PI);
        int currentTexelId = int(round(LIGHT_Z_BUFFER_SIZE * currentZBufferPoint));
        vec4 obstRad = texelFetch(testLightZBuffer, currentTexelId);

        if (length(lightTangentRel) < testLightRadius)
        {
            float lightIntensity = cos((length(lightTangentRel)*M_PI/2)/(testLightRadius));
            lightBrightness = lightIntensity;

    }

    vec4 nightColor = vec4(trueColor.x*0.1, trueColor.y*0.1, trueColor.z*0.2, trueColor.w);
    vec4 lightColor = trueColor;
    if (0.0 <= lightBrightness && lightBrightness <= 1.0)
        fragColor = mix(lightColor, nightColor, 0.0);
}

The problem is, texelFetch can't handle currentZBufferPoint variable, it just doesn't draw ANYTHING, but lightBrightness should be at least 0, therefore it must draw at least black pixels. Looks like shader program crashes somewhere, but it compiles completely fine.

So, after several hours i figured out where is the problem - it is here:

vec3 volCoords = vec3(texture(volumeMask, volTexCoordFrag));

If i replace texture(volumeMask, volTexCoordFrag) with anything else, it works.
Pls help.


texts: Assimp renders a partial amount of vertices

texts:
I'm building a 3D game, and i'm trying to load some assets with the nice Assimp library. The model should look like the one in the first picture, but instead, it takes the form of some kind of avant-garde sculpture, as the second picture shows.

At least i'm proud that i get to see something, but hey, i can do better.

It's not a problem with shaders (it simply isn't, i pass no normals and no textures, just the vertex coordinate, since i set a static colour). Here is my code:

MODEL LOADING (only vertex coordinates)

void Mesh::open(const std::string file)
{
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(file, aiProcess_Triangulate);
if(!scene)
    throw STREAM("Could open mesh '" << file << "'!");

std::vector<float> g_vp;
count = 0;

for(uint m_i = 0; m_i < scene->mNumMeshes; m_i++)
{
    const aiMesh* mesh = scene->mMeshes[0];
    g_vp.reserve(3 * mesh->mNumVertices);
    count += mesh->mNumVertices;

    for(uint v_i = 0; v_i < mesh->mNumVertices; v_i++)
    {
        if(mesh->HasPositions())
        {
            const aiVector3D* vp = &(mesh->mVertices[v_i]);
            g_vp.push_back(vp->x);
            g_vp.push_back(vp->y);
            g_vp.push_back(vp->z);
        }
    }
}

glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, count * 3 * sizeof(float), &g_vp[0], GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (GLubyte*)NULL);
}

SCENE RENDERING

void renderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

program.use();
program.setUniform("transformMat", modelMat);
glBindBuffer(GL_ARRAY_BUFFER, m.vbo);
glDrawArrays(GL_TRIANGLES, 0, m.count);

SDL_GL_SwapWindow(window->mWin);
}

Depth testing is enabled, and i'm using OpenGL 4.0 with v400 shaders too.

The error will possibly be stupid, but i can't find it, and my head is all boiling at this very moment.

Thanks for your help!


texts: Doubts with results of per-vertex lighting shader

texts:
I'm researching simple shaders to add to my DirectX 11 project such as a per-vertex diffuse shader plus specular reflection component.

I'll begin with the results:

Seems specular reflection is working, but do you see the border and upper objects? They don't seem to be lit well, as a shader based on this lighting equation is not supposed to gray-scale the diffuse component (excepting when dot product < 0 in backfaces,etc).

My HLSL vertex shader rationale is as follows, I dont  know at this point of the day, if i'm missing something.

Vertex shader input / Output structs are defined as:

// Output and Input Structs
// ------------------------

struct VS_OUTPUT {
    float4 pos       : SV_POSITION;
    float4 color     : COLOR;
};

struct VS_INPUT {
    float4 pos : POSITION;
    float4 norm: NORMAL;
};

1) Transform the input position to world coordinates:

vo.pos = mul(vi.pos, worldMatrix);

2) Transform normal to world and normalize:

float4 N = normalize(mul(vi.norm, worldMatrix));

3) Calculate the vector from the light position to the current vertex position.
   Lighting is already in world coordinates. w=1.0, so:

 float4 L = float4(normalize(float4(light[0].pos.xyz,1.0f) - vo.pos));

I have camera position in world coordinates passed through Cbuffer, so camera minus vertex position yields V vector.

float4 V = normalize(cameraPos - vo.pos);

4) Use reflect intrinsic to calculate R, negating L since it's pointing towards   light.

float4 R = reflect(-L, N);

5) Finally I calculate the color to pass to the pixel shader, and transform the vertex position with the view/projection matrices.

 vo.color = ka + ke + kd * saturate(dot(N, L)) + (ks * pow(saturate(dot(V, R)), specp));
    vo.pos = mul(mul(vo.pos, viewMatrix), projMatrix);
    return vo;

Just for completion, here are the constant buffers:

#define MAX_LIGHTS 16

cbuffer bufWorldMatrix : register (b0) {
    float4x4 worldMatrix;
}

cbuffer bufViewProjMatrix : register (b1) {
    float4x4 viewMatrix;
    float4x4 projMatrix;
    float4   cameraPos;
}

cbuffer materialProperties : register (b2) {
    float4 kd;
    float4 ka;
    float4 ks;
    float4 ke;
    float  specp; // Specular-power (shininess)
}

struct LightBase {
    float3 pos;
    float3 color;
    float  intensity;
    float  isOn;
};

THanks, any help is appreciated. I'm sure normals are OK, but I can recheck in case. I can post additional debugging/ code if it's required.


texts:
I am working on a game developed on DOM using Crafty JS framework, and Greensock GSAP JS (http://www.greensock.com/gsap-js/) for animations. It is my first time working with these technologies.

I have a problem with FPS going down to 15 and less while animations are performed on bigger DOM elements. After investigating the issue with Chrome Developer Tools Timeline I discovered that 80% of bottleneck events time are:

Image Resize(non-cached)

I assume it is caused by the fact that I am using

CSS Transform scale()

for the game to adjust to browser size. Performance is acceptable once the scaling is disabled.

Is there any way to cache the resized images in browser to improve performance? The game will only be used on a local computer.

Any help and advice will be greatly appreciated.


texts: Delay shooting till player has reached the correct rotation - Twin Stick

texts: Like most Twin Stick shooters, my player both turns and shoots with the right stick. I use a Quaternion.Slerp() to smoothly rotate the player from the current rotation to the new rotation, however the player starts firing before reaching the new rotation. My question is what is the most optimal way to delay my player from shooting until they've reached the desired new rotation?


texts:
I make OpenGL render framework for my bachelor graduate work.
I created simple Model and Shader classes. But when I tried to render some vertices, they do not render. I saw with an OpenGL profiler, that I haven't vertex data, but in code I bind it.
There's my main class:

GLfloat vertex_positions[] = {
        0.0f, 0.5f, 1.0f, 0.0f, 0.0f,
        0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
        -0.5f, -0.5f, 0.0f, 0.0f, 1.0f
};
GLchar *vertexShader = (GLchar *)
                "#version 150\n"
                "\n"
                "in vec2 position;\n"
                "\n"
                "void main()\n"
                "{\n"
                "    gl_Position = vec4(position, 0.0, 1.0);\n"
                "}";
GLchar *fragmentShader = (GLchar *)
        "#version 400 core\n"
        "\n"
        "out vec4 fColor;\n"
        "\n"
        "void main()\n"
        "{\n"
        "    fColor = vec4(0.5, 0.4, 0.8, 1.0);\n"
        "}";
static const GLfloat vertex_colors[] =
        {
                1.0f, 1.0f, 1.0f, 1.0f,
                1.0f, 1.0f, 0.0f, 1.0f,
                1.0f, 0.0f, 1.0f, 1.0f,
                0.0f, 1.0f, 1.0f, 1.0f
        };
Shader shader;
shader.CompileShader(Shader::ShaderType::Fragment, fragmentShader);
shader.CompileShader(Shader::ShaderType::Vertex, vertexShader);
glBindFragDataLocation(*shader.GetProgram(), 0, "fColor");
shader.Link();
Texture texture((GLfloat *) vertex_colors, 16);
Model model (vertex_positions, &shader, &texture);
while (!glfwWindowShouldClose(window))
{
    static const float black[] = { 0.2f, 0.3f, 1.0f, 1.0f };
    glClearBufferfv(GL_COLOR, 0, black);
    shader.Bind();
    model.Draw();
    glfwPollEvents();
    glfwSwapBuffers(window);
}

And my model class:

void Model::Draw() {
glBindVertexArray(_vao);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glDrawArrays(GL_TRIANGLES, 0, 3);
}

Model::Model(GLfloat meshVert[], int m_size, GLuint vertexInd[], int
v_size, Shader *material, Texture *texture) {
glGenVertexArrays(1, &_vao);
glBindVertexArray(_vao);

glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat)*m_size, meshVert,
   GL_STATIC_DRAW);

GLint posAttrib = glGetAttribLocation(*material->GetProgram(), "position");
glEnableVertexAttribArray((GLuint) posAttrib);
glVertexAttribPointer((GLuint) posAttrib, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), 0);

GLint colAttrib = glGetAttribLocation(*material->GetProgram(), "color");
glEnableVertexAttribArray((GLuint) colAttrib);
glVertexAttribPointer((GLuint) colAttrib, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (void*)(2 * sizeof(GLfloat)));

}

P.S.: OpenGL profiler breaks on command glDrawArrays, but when I saw data info, it was empty. That's why I think I lost some data bind.
P.S.S: System: macOS Sierra, Intel HD 6000.


texts: Managing Discrete Character Animation States

texts:
I'm creating a 2D game in which each possible direction of movement for the player, (Up, Down, Left, Right), has its own distinct animation, i.e., they aren't rotations of each other. Currently I am using a FSM design to manage this, but its getting messy already, and I know it will only get worse.

For example: (in Lua)

StateComponent = {
    states = {
        walking_left = {set_animation("walking_left")},
        walking_right = {set_animation("walking_right")},
        ...
    }
},

Now say I want to add attacking, the collection of states then becomes:

StateComponent = {
    states = {
        walking_left = {set_animation("walking_left")},
        walking_right = {set_animation("walking_right")},
        ...

        attacking_left = {...},
        attacking_right = {...},
        ...
    }
},

Okay, but now what about opening up a chest from each different side... This quickly becomes very complex. I read about a using a Behavior Tree, but it doesn't seem to support the discrete division of states necessary for having a different animation for walking/attacking/etc in each cardinal direction. What kind of design would be elegant and scalable for this problem? Or how else might I represent these states?


texts: Can I speed up "potential fields" pathfinding when it's working on a large grid?

texts:
I'm looking to implement a pathfinding algorithm that will allow me to throw hundreds of spiders at the players in my grid-based game. I can implement this with A*, but I'm worried that that algorithm has too high of a "per spider" performance cost.

The "potential fields" approach looks really good to me, but my map is quite large and rebuilding the entire potential field sounds expensive (even on a background thread).

Unfortunately, there's no logical divisions on my map where I could separate the grid into smaller grids. And the map is quite dynamic (walls/bridges can be destroyed, which could have huge impacts on pathing).

Are there any options other than reducing the size of the map?


texts: Handling a smooth movement over slopes in a worms like game

texts:
I currently have a worms like game with the worms style pixel perfect terrain destruction. Its working well for pushing things around and watching them fall, but for the players movement it feels like your dragging your butt around rather than sliding around.
The code I use for the moving is the following:

private void tryMove() {

    float travelAngle = getSlopeNormal().angle() + (direction == -1 ? 180 : 0);

    while(travelAngle > 360) travelAngle -= 360;

    Vector2 travelVelocity = new Vector2(1, 1);

    travelVelocity.setAngle(travelAngle);

    Vector2 newPosition = getPosition().add(travelVelocity);

    boolean collision = false;

    for(float r = travelAngle - (float) Math.PI / 2F; r < travelAngle + Math.PI / 2.0F; r += Math.PI / 128){

        int testPosX = (int) (getRadius() * Math.cos(r) + newPosition.x);
        int testPosY = (int) (getRadius() * Math.sin(r) + newPosition.y + getMaximumStepUp());

        if (getMatch().getTerrain().isSolid(testPosX, getMatch().getTerrain().getHeight() - testPosY)) {

            collision = true;

            break;

        }

    }

    if(!collision){
        setPosition(newPosition.x, newPosition.y);
        setVelocity(travelVelocity.scl(3));

    }

}

It works well for 'some' cases but other times feels like the player is always being dragged around and I apply the velocity at the end because otherwise the player can scale down walls 90-degrees. I feel there must be a better solution. I already have multiplayer systems in but with this movement code its causing all sorts of desyncs so I need a more reliable method.


texts: Need advice for what to do with my first game idea

texts: My friends and I have this idea to make a game. None of us have much experience with programming. We think our idea is to big too accomplish. Should we present our idea to an indie company that can make it, or scrap the idea and start with something smaller? If we start with something smaller, what can you recommend us to use since we have little experience with programming?


texts: Card flip animation in a prefab. How to flip with local position?

texts:
I'm making a simple card game, with some cards laying on the table. I want to flip the card when it's clicked, so I thought I'd use an animation to do it (lift card up in the air, rotate it and lower it back down). It works as I want with one card, but when I save it as a prefab and instantiate another one next to it, the card (obviously) moves to the same position as the prefab (as the animation stores global position I guess).

Is there any way to make animations in local space, or is there any other way I should do the flip?


texts: How can I spawn and drag 2d object from a Canvas button?

texts: I want to create and drag an object from canvas button to scene. How can I do this?


texts:
I am creating a VR game. Currently, I'm testing it on an Android device.

Now I when I run the application it runs smoothly and without any issue.

However when I add the following model:

And attempt to look at it the game crashes.

The model you see doesn't have any scripts on him only a transform component and an animator.

Has anyone tried something similar? or have an idea what the issue might be?
Update i have also tried this following scene

So i tried to isolate the character completely from my original scene. So i made this:

Again if i have the character in the scene it crashes. if i remove the character it runs perfectly fine.

Another update:

If i remove the animator component from the model it works fine?


texts:
I'm currently working on a 2D game engine in XNA, and I am very interested in architecture, and how best to let my game objects communicate.

I know a lot of people use a Singleton design but I believe that this is more of a "counter-architecture" way of doing things, as every class will have access to the Singleton.

I was comtemplating using a Service-type architecture to allow for my Input, Sound, etc Manager classes to be available, but this is essentially the same problem as the Singleton as all the Classes are available to 'whoever' wants them.

I could of course pass references to the objects when they are needed, but this is bloated.

I wonder if making the 'Services' only allow certain objects to subscribe would be possible?

So is there a better way to make your classes available?

Or am I searching for an answer that doesn't have a question?


texts: Do I have to commit the downloadable assets for Unity to the repo? Or a reference for the team to download them?

texts:
QUESTION (Short version)

I am going to use the Unity Test Tools asset to do unitary testing.
Q: Do I have to commit the Unity Test Tools to my repo? (using git, by the way).

CONTEXT

Team / Workflow

We are an indie team of 10 people (of which 4 coders, 2 graphics, 1 music, 2 marketing, 1 automation-test QA), remotely located.
We built the team 2 weeks ago, have explored Unity, decided that unity shall be our devel framework, and finally we did an internal silly tic-tac-toe internal for us to check the workflow.
Now we want to start developing our 1st game. Clean code. Clean repo.
Using git for version control.
We configured Unity to write all forced in text and visible metas.
We are using Unity5 free edition.

Coding

Up to now, I've managed to create a MVC schema. MonoBehaviour acts as the Controller and then we have non-dependant classes that act as the Model of our game. The controller calls methods of this model. The model throws events to notify the changes in its state.
We want to unit-test the model.

Assets

Yesterday I discovered the Unity Test Tools.
This is the only downloaded asset, the rest of the assets are made by us.
The wonderings presented by this question may happen again if we download other assets or if we want to keep a common own-made library across several games.

QUESTIONS (Long version)

As far as I've seen, assets get "copied" into your project. Okey for working. But... comitting?? I'm feeling uncomfortable.

The same way in PHP you may use composer to handle "dependencies" so if you need a library you do not commit it inside your project, you just commit a text file saying "I want this library, this specific version" -for the sake of example, you can tell composer to install PHPUnit for unit testing, and you commit the composer text file, you do not commmit a full copy of PHPUnit-, these are our questions/wonderings:

Q1) Do I have to commit all the Unity Test Tools in my repo? It is 10 Megas - may seem an overkill or not, depending on your optics... but, as it carries "examples" and I don't know how to filter what is needed and what not, it seems so overkill to me to commit all of it - but worse: this might happen with another asset that is 500 Megas for example. Committing downloadable assets seems anti-pattern. Do I have to commit?

Q2) Or it is better that I don't, and have all the members in the team to manually download the Unity Test Tools?

Q3) If they delete that repo and download it again, the Unity Test Tools seem to be kept local to the project, then a new download is imposed if it's not kept in the repo? Or Unity may store "local in your computer; still global to your projects" things like "the testing library" you are likely going to use in several projects?

Q4) Case one thinks "maybe each project needs its own version of libraries, best practice is do not keep anything global" then, committing them to the project still seems overkill... is there any standard of "config file" that I can place and then once the "git repo" is cloned, run some kind of "dependency installer" or so (much like the composer install action is to a recently cloned repo in PHP)?

I've seeked for information, but I'm still confused on this. I've seen it exists something like an "asset manager" but I'm not sure if this is what I need. Any pointer to documentation I must read will be highly appreciated.

Note that the documentation in Unity website, as for example this one: Mastering Unity Project Folder Structure - Version Control Systems does not address my specific question.

Thanks!


texts: Lua as a stand-alone for game programming like Python?

texts:
I've used Python before with PyGame to make games, but PyGame doesn't seem to be so popular anymore, and there arent that many good resources for it. I hear lots of buzz about Lua as a fast scripting language to be used inside of projects made in other languages.

I work much faster and enjoy the higher-level programming that is Python, so that naturally leads me to Lua, which seems to be getting a lot of attention recently. I know it's been around for a while but I think WoW add-on creation made it more popular..

Can Lua make games on its own as a stand-alone language with any 2D or 3D libraries, or is that not really the Lua domain?

I won't bother asking about 3D in Python here, I'll make a new question for that. Thanks!


texts:
I want to make a simple aircraft controller, what looks like little realistic in unity. I watch some video from airplane physics. and make a simple script in unity, but if I start, my plane cant move or if I change drag to zero, it cant lift. I tried to use real data and get it from wiki(F22 Raptor). To my game object, I gave the rigidbody component mass = 19670 kg.
Engine thrust = 2 * 116000.0f Newton.

    private void calculateEnginePower()
    {
        EnginePower = engineThrust * ThrottleInput;
    }

    private void calculateForces()
    {
        angleOfAttack = Vector3.Angle(Vector3.forward, rb.velocity);
        angleOfAttack = Mathf.Clamp(angleOfAttack, 0, 90);

        coefficient = Mathf.Pow(1225.04f * rb.velocity.magnitude, 2) - 1; //M^2-2 where: M is mach.

        if (coefficient > 0.0f)
            coefficientLift = (4 * angleOfAttack) / Mathf.Sqrt(coefficient);
        lift = 1.2754f * 0.5f * Mathf.Pow(rb.velocity.magnitude, 2) * coefficientLift * 78.04f; // densy1.2754 kg/m3, speed m/s , (F22)Wing area: 840 ft² (78.04 m²)

        coefficientDrag = 0.021f;
        rb.drag = coefficientDrag * 0.5f * Mathf.Pow(rb.velocity.magnitude,2) * 1.2754f * 78.04f;

        rb.AddForce(transform.up * lift);
        rb.AddForce(transform.forward * EnginePower);
    }

roll, pitch... inputs from keyboard and mouse, EnginePower, RollInput... are simple properties and I call the Move function in a controller inside void Update.

Move(float roll, float pitch, float yaw, float throttle)
{
// transfer input parameters into properties.s
RollInput = roll;
PitchInput = pitch;
YawInput = yaw;
ThrottleInput = throttle;
AirBrakes = false;
calculateEnginePower();
calculateForces();
calculateRotation();
}

used these formulas:

for Lift force:
Lift formula
for Lift coefficient:
Cl formula
for Drag:
Drag formula
and for Drag coefficient: I used data from wiki too (0.021f).


texts: Transform point while keeping other points offset

texts:
I have the following situation: I've got a box with its center of mass transform matrix that I'm obtaining from physics simulation, i.e. it keeps changing with time. I've also got two points (actually two transformation matrices) which are static (the simulation doesn't calculate them, neither do I want it to) that I want to 'keep in sync' with the original state (t=0 in the picture).

Any ideas how do I calculate the other two matrices when the center of mass changes, while keeping their original offsets satisfied?

I'm using jBullet for physics.


texts: Vertical push doesn't let the object fall down instantly [UNITY]

texts:
An object (Wall) is continuously moving forward on the X axis with a simple script:

public float speed = .2f;
void FixedUpdate()
{
    transform.Translate(speed, 0, 0);
}

It is pushing an other object (Penguin), which is affected by gravity. It can "jump" too, with a script of:

public void Jump()
{
    transform.position = new Vector3(transform.position.x, transform.position.y + 1.15f, transform.position.z);
}

When jumping, over a certain value of speed, like 0.2f, the Penguin is not falling to the ground until it reaches a velocity Vector of around (0.0, -10.0f, 0.0).

Setting the speed to 0.02f makes it instantly fall.

How can I achieve the same result with higher speed value?

I attached the setup of the two object in inspector:


texts: Transmission implementation in a car game

texts:
I'm trying to create a simple car game with manual gear changes. However, I'm having a bit of trouble implementing the gear changes.

Here's my current code for the "car":

int gear = 1; // Current gear, initially the 1st
int gearCount = 5; // Total no. of gears

int speed = 0; // Speed (km/h), initially 0
int[] maxSpeedsPerGear = new int[]
{
    40,  // First gear max. speed at max. RPM
    70,  // Second gear max. speed at max. RPM
    100, // and so on
    130,
    170
}

int rpm = 0; // Current engine RPM
int maxRPM = 8500; // Max. RPM

public void update(float dt)
{
    if(rpm < maxRPM)
    {
        rpm += 65 / gear; // The higher the gear, the slower the RPM increases
    }

    speed = (int) ((float)rpm / (float)maxRPM) * (float)maxSpeedsPerGear[gear - 1]);

    if(isKeyPressed(Keys.SPACE))
    {
        if(gear < gearCount)
        {
            gear++; // Change the gear
            rpm -= 3600; // Drop the RPM by a fixed amount
            if(rpm < 1500) rpm = 1500; // Just a silly "lower limit" for RPM
        }
    }
}

However, this implementation doesn't really work. The first gear works fine, but the following gear changes cause the speed drop. By adding some debugging messages, I get these speed values when changing at the RPM limit:

Speed at gear 1 before change: 40
Speed after changing from gear 1 to gear 2: 41

Speed at gear 2 before change: 70
Speed after changing from gear 2 to gear 3: 59

Speed at gear 3 before change: 100
Speed after changing from gear 3 to gear 4: 76

Speed at gear 4 before change: 130
Speed after changing from gear 4 to gear 5: 100

As you can see, the speed after each change is slower before the change. How would you take into consideration the speed before the gear change so that the speed wouldn't drop when changing gears?


texts:
Everytime I have coded "working" collision, I always went about it very haphazardly and unstructured. If I use Axis Aligned, or Verlet, Or Euler, any or all of these theories, my problems always lie in the edge cases. Let me invent a scenario to better explain my question.

Imagine a 2D game, let's use Mario as the best example. So there is gravity, there is acceleration and friction. If the world is being loaded as all individual, let's say 32 x 32, tiles, while the player is moving along the ground, there will always be that edge case of when he happens to be in the dead center of both tiles, and collision ends up being checked on both tiles below him and of course he gets moved based on both tiles' positions.

So in that case, I assume I would only want to be checking top block collision (bottom of player) only, and not side collisions, but then when I'm jumping onto a tile, or block, I know I want to check bottom player collision, so I can land, but that doesn't stand for anytime the player is in the air right? Cause what if I'm falling/jumping, and I hit the side of a block or wall, I want to check side collision. And then what if I hit the side of one block, but in that frame of collision when the player overlapped the tiles, he also got into the top of one of the tiles and now gets his y position moved because of it.

So the tl;dr version of my rambling is...

What's the most sensible way to structure collision? Totally case specific, i.e. only check specific collisions dependant on surrounding tiles, or the movement of the player?

Or is there a broad way to keep all collisions being checked (top, sides and bottom of player) and deal with the edge cases as well?

Also this isn't language specific, I'm speaking totally in generics. Any code examples are welcome. (Any language)

Thanks. (Hope my rambling isn't too convoluted and it makes sense. ><


texts: Help understanding the order of vector subtraction

texts:
I always struggle with intuitively figuring out the order of subtraction in multiple situations for example

The difference between the current mouse coordinates and the last frame's coordinates

The direction an object is to the camera position

etc.

I know that A - B = A + (-B) ..my problem is figuring out which one is A and which one is B ..and those were just simple examples

Is there any hard and fast rules for this? Or is it supposed to be intuitive and obvious (which is what I'm afraid of)?

I have similar problems with figuring out which order to take the cross-product of two vectors too, depending on the scenario


texts: Render triangles without index buffer in Opengl ES

texts:
I'm reversing a 3d model format from a famous game (not sure if i should mention it), which is released both for windows (app store) and for Iphone and android.

The weird thing is that while the windows app model files contain an index buffer, the model files from the Iphone contain absolutely nothing at all.

At first i thought maybe everything is defined linearly and i should do the triangulation myself using the vertex order from the vertex buffer, but that didn't work at all. I tried reading the vertex buffer as a triangle strip, but this also didn't work.

Is there any possibility that OpenGL ES (which from what i know is what runs on the iphone) renders the models without an index buffer? Is it possible that all the tesselation is done automatically at runtime?

I'm attaching 2 version of the same model for both platforms
Iphone:
https://www.dropbox.com/s/ctgjkvv9xmpcqr3/iphone_model?dl=0
Windows:
https://www.dropbox.com/s/ghmtzux5tznw493/win_model?dl=0

The Vertex Count for this part is 1241 and the indices count: 6066.
The very first section on both files (windows version contains a 16 byte padding) is the vertex buffer (0x8 bytes per vertex)


texts: GL11.glTexCoord2f(1.0f, 1.0f); 1.0f screws the image up

texts:
I recently started using LWJGL in my java programs for the graphics. I'm currently working on a simple game, which I make, to get better at this kind of programming. I ran into some trouble when adding textures to my 2D game.

To show my problem, I have made a simple program which shows one quad with a texture.
This is how the texture looks:

http://i1197.photobucket.com/albums/aa428/GWigWam/LWJGL%20problem/Test.png

However my program shows it like this:

http://i1197.photobucket.com/albums/aa428/GWigWam/LWJGL%20problem/showsme.png

You see the right and the bottom have some strange line hanging there. the shown picture is 100x100 from the top left to the little pixel right down.

The code used for drawing this is:

texture1.bind();
GL11.glBegin(GL11.GL_QUADS);
   GL11.glTexCoord2f(0f,0f);
   GL11.glVertex2f(100, 200);
   GL11.glTexCoord2f(1f,0f);
   GL11.glVertex2f(200, 200);
   GL11.glTexCoord2f(1f,1f);
   GL11.glVertex2f(200, 100);
   GL11.glTexCoord2f(0f,1f);
   GL11.glVertex2f(100, 100);
GL11.glEnd();

This code is called before drawing:

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glOrtho(0, width, 0, height, -1, 1);

When I use

GL11.glTexCoord2f(0.9f,0.9f);

so 0.9f instead of 1.0f the weird lines don't appear. But that's no real solution because I want to use the whole texture not 90% of it.

I hope I did not ask something which has been asked before, I really couldn't find I using google, it is however quite hard to think of the right search words.