texts: How do I create a prefabs when a button is clicked(Unity)

texts:
So I want to be able to spawn prefabs when a button is pressed
Shop script -
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Shop : MonoBehaviour
{
    public static string Item01;
    public static string Item02;
    public static string Item03;
    public static string Item04;

    public static int ShopNum;
    // Update is called once per frame
    void Update()
    {
        if(ShopNum == 1) {
            Item01 = "Cannon";
            Item02 = "Tower";
            Item03 = "army Camp";
            Item04 = "Baracks";
        }
        if(ShopNum == 2) {
            Item01 = "Archer";
            Item02 = "Barbarian";
            Item03 = "Goblin";
            Item04 = "Wizard";
        }
    }
}

And then my Shop Access script -
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Shop01Access : MonoBehaviour
{
    public GameObject ShopInventory;
    public GameObject Item01Text;
    public GameObject Item02Text;
    public GameObject Item03Text;
    public GameObject Item04Text;
    public GameObject ItemCompletion;
    public GameObject CompleteText;

    void OnTriggerEnter() {
        ShopInventory.SetActive(true);
        Screen.lockCursor = false;
        Shop.ShopNum = 1;
        Item01Text.GetComponent<Text>().text = "" + Shop.Item01;
        Item02Text.GetComponent<Text>().text = "" + Shop.Item02;
        Item03Text.GetComponent<Text>().text = "" + Shop.Item03;
        Item04Text.GetComponent<Text>().text = "" + Shop.Item04;
    }

    public void Item01(){
        ItemCompletion.SetActive(true);
        CompleteText.GetComponent<Text>().text = "Are you sure you want to buy" + Shop.Item01 + "?";
    }
    public void Item02(){
        ItemCompletion.SetActive(true);
        CompleteText.GetComponent<Text>().text = "Are you sure you want to buy" + Shop.Item02 + "?";
    }
    public void Item03(){
        ItemCompletion.SetActive(true);
        CompleteText.GetComponent<Text>().text = "Are you sure you want to buy" + Shop.Item03 + "?";
    }
    public void Item04(){
        ItemCompletion.SetActive(true);
        CompleteText.GetComponent<Text>().text = "Are you sure you want to buy" + Shop.Item04 + "?";
    }

    public void Cancel(){
        ItemCompletion.SetActive(false);

    }
}

How could I spawn a cannon when button item01 is pressed into my 3d scene


texts: Is it legal to use Creative Commons art in a commercial game?

texts:
I would like to know if the following situation would be legal.

Let's say I take some pictures on wikipedia, that are licensed under CC-BY-SA license.
Then I would like to photoshop them, and use it as art in a (perhaps commercial) game.

According to the Creative Commons licence, it is legal to use the content "for any purpose, even commercially".
So I was thinking about creating a web page where I would attribute each picture to the original creator, and publish the photoshoped picture under the same license (even if it would be almost useless for anyone).

Would it be legal?  Or would I need to publish the entire game under creative commons license?


texts:
I've searched online for help and tutorials on LibGDX but I couldn't really find any, except and the wiki for asking questions on stackexchange. Besides the source (demos) and wiki, is there any other tutorials online that's hidden or indirect?

From what I read, there isn't much documentation for LibGDX, so there's only two options I see

Give up move to a different framework.
Ask people a lot of questions.


texts:
How would I "highlight" faces/edges/corners?
I would prefer an explanation OpenGL if possible.

Here's an example:


texts: Beginner flash game development: Start with framework or from scratch?

texts:
I want to write some simple flash games (as a hobby). I have a lot of programming experience, but no experience with Flash/ActionScript.

My question is:
As a beginner, is it a good idea to start with a framework like Flixel, FlashPunk or PushButton or would it be better to write my first games from scratch?

Also, if you vote for using a framework, which one would you recommend?
What are the differences?

And another question: What about Flex, would you recommend using it?


texts:
I am building a addon component that will show synthesized 3D view of the world (kind of FLIR camera simulation). The problem I am facing is that currently I am using Symmetric Perspective View with an eye pointed always on the center of the screen. I can manipulate field of view in both vertical and horizontal dimension however what I cannot do is to move the eye point view from the center, so that I can see 15 degrees up and 30 down while my eyes are pointing at at the screen at point that is located at 1/3 from the top of the viewport. Below is the picture of what I want to achieve, assuming the eye point is on sea level looking straight ahead to the horizon.

I tried several techniques, I tried to enlarge my viewport proportionally and then increase FOVY and clip the viewport to have again 45 degree view, then I tried to manipulate the camera to look 15 degrees down, but none of the results are satisfactory, because the horizon of my 3d world view was never in range of 15 degrees up and 30 down and this is my requirement

I guess the correct way is to define the correct frustum. Please confirm this is the case and how to set it assuming that:
FOV=64
FOVY=45
ratio 1:5
near plane = 1
far = 500000000.0


texts: Scaling a single scalar using OrthographicCamera

texts:
I'm trying to convert a length (well, a radius) from world coordinates to screen coordinates using an OrthographicCamera. However, the only method I've figured out so far is to do a projection, with some basic vector math before/after, but this seems...expensive.

Here's what I have so far (apologies, written in Kotlin):

val cam: OrthographicCamera = ...
val behavior: SteeringBehavior<Vector2> = ...

// calculating the center of the circle
val coords = Vector3()
val wander = behavior as Wander<Vector2> // defined elsewhere above
coords.set(wander.wanderCenter, 0F)
cam.project(coords) // coords now has wanderCenter in screen coordinates

// now, the part I'm interested in, calculating the radius
val radiusCoords = Vector3(wander.wanderCenter, 0F).add(wander.wanderRadius, 0F, 0F)
cam.project(radiusCoords)
radiusCoords.sub(coords)
val radius = radiusCoords.x // this is the value I want

The first half of the code snippet is fine, and provided for context. But the second half...I'm basically taking a scalar and plugging it through a Vector3 and a series of Complicated Matrix Math to convert it to another larger scalar. Is there an easier way to do what I'm doing? I've looked around a bit -- like at OrthographicCamera's combined.getScaleX() field, but it doesn't seem to have the value I need.


texts: In Unity, why do I get a "does not implement right interface" error when trying to sort my list of objects?

texts:
I am trying to create a crafting panel that sorts the list of items you can make alphabetically, yet I cannot figure out why .Sort() is not working.

What I have is a game object that holds a list of all the items you can make and the requirements, then in my crafting script I access the game object for the list and display the info.

Everything works fine until I try to sort anything. craftDatabase is what I need to be sorted. Also, it needs to be sorted by ItemID.

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

public class CraftDatabase : MonoBehaviour
{
    public List<Blueprint> craftDatabase = new List<Blueprint>();
}

[System.Serializable]
public class Blueprint
{
    public string itemId;
    public int itemAmount;
    public float itemCraftTime = 1f;
    public CraftPanel.subsections subsection;
    public CraftPanel.workstations workStation;
    public List<requiredItem> requiredItems = new List<requiredItem>();

    [HideInInspector]
    public string desc;

    [System.Serializable]
    public struct requiredItem
    {
        public string itemId;
        public int itemAmount;
    }

    public Blueprint()
    {
    }
}

When I try to throw in craftDatabase.craftDatabase.Sort(); it gives me this error:

  ArgumentException: does not implement right interface

How do I fix this error to use Sort()?


texts: Calculating the distance from a line to a point in 2D

texts:
I have a simple setup:

How do I calculate the orange distance?

It's the distance between the block on the left to the white line in the center (X & Z axes combined).

I don't have the intersection point. My only knowledge of the white line is that it goes through the point (0, 0, 0), running between (10, 0, -10) and (-10, 0, 10)

My problem is that I need to calculate this distance without the depth (Y value). Only on two planes combined: X & Z


texts: How to get chunks in a sphere rather than cuboid

texts:
I have a chunk system to load stars around the player. It takes a given "real" loading range (aka Unity-units of range), calculates the necessary chunk loading range (as integer), creates star GameObjects within the loading range on screen, and stores stars in cache which are within chunk loading range but outside of real loading range.
Chunks are stored in a dictionary with the key being a struct consisting of x,y,z integer coordinates. Available data are:

Real position of the player
Current chunk of the player
Center point and size of each chunk (same size for all)
I know when the player steps into another chunk

A quick calculation revealed that if I'd be able to load chunks spherically instead of cubically, I would be able to load ~40% less chunks. The amount of chunks I have to grab (currently) can vary, ranging from a range of 3 to ~8 (meaning minimum of (2*3+1) 7*7*7=343 to (2*8+1) 17*17*17=4913). Current Code:

    public Chunk[,,] GetChunksInCuboid (Coordinate coords, int range)
    {
        return GetChunksInRectangle (new Coordinate (coords.x - range, coords.y - range, coords.z - range), new Coordinate (coords.x + range, coords.y + range, coords.z + range));
    }

    public Chunk[,,] GetChunksInCuboid (Coordinate min, Coordinate max)
    {
        int xLen = max.x - min.x + 1;
        int yLen = max.y - min.y + 1;
        int zLen = max.z - min.z + 1;

        Chunk[,,] A = new Chunk[xLen, yLen, zLen];

        for (int x = 0; x < xLen; x++)
        {
            for (int y = 0; y < yLen; y++)
            {
                for (int z = 0; z < zLen; z++)
                {
                    A[x, y, z] = GetChunk (x + min.x, y + min.y, z + min.z);
                }
            }
        }

        return A;
    }

My question is the following: Is it possible, and if yes, how can I performantly load chunks in a sphere?


texts:
I need to check a "ground plane" to put objects over it without a marker, using Unity.

Right now I'm using Vuforia, but the Ground Plane on Vuforia only works on some devices, I tested on mine and my mother's Android phone, both modern and from different brands, didn't work. So it's not an option, because many many people couldn't use it.

Same with ARCore, asked me to install some sort of Google Services AR, which the download is locked for my phone.

Is there any way to use Unity with some kind of ground plane detector that many phones can "read" it? Any API, code, anything different that I didn't try yet?

Thanks!


texts:
I'm trying to convert my code to use dual quaternion skinning instead of matrix skinning because i just can't get the skinning matrix created correctly from bones+weights using matrices.

Edit: just to clarify, if each vert has only one bone the matrix version did skin correctly.

But it's just not working and i really don't understand why, i'm using code i found here:

http://www.chinedufn.com/dual-quaternion-shader-explained/

http://donw.io/post/dual-quaternion-skinning/

I've looked at the assorted papers often brought up in the answers to these questions, but for the most part i just don't understand them.  I'm not even entirely sure how the [x, y, z, w] of a glm::quat correspond to the [1, i, j, k] of a quaternion--I think that w might be the scalar because it goes first in the actual byte order of the glm::quat struct, but i'm not sure.

Anyway, in my shader bindings i have:

void gltfShader::bindBones(const std::vector<glm::mat4> & bones)
{
    std::vector<glm::fdualquat> dual_quats(std::min<int>(bones.size(), 64));

    glm::quat r;
    glm::vec3 t, s, sk;
    glm::vec4 pr;
    glm::fdualquat dq;

    for(size_t i = 0; i < dual_quats.size(); ++i)
    {
        glm::decompose(bones[i], s, r, t, sk, pr);

        dq[0] = r;
        dq[1] = glm::quat(t.x, t.y, t.z, 0) * r * .5f;

        dual_quats[i] = dq;
    }

    glUniformMatrix2x4fv(u_bones, dual_quats.size(), GL_FALSE, (float*) &dual_quats[0]);
}

In the vertex shader:

mat2x4 GetBoneTransform(ivec4 joints, vec4 weights)
{
    float sum_weight = weights.x + weights.y + weights.z + weights.w;

    // Fetch bones
    mat2x4 dq0 = u_bones[joints.x];
    mat2x4 dq1 = u_bones[joints.y];
    mat2x4 dq2 = u_bones[joints.z];
    mat2x4 dq3 = u_bones[joints.w];

    // Ensure all bone transforms are in the same neighbourhood
    weights.y *= sign(dot(dq0[0], dq1[0]));
    weights.z *= sign(dot(dq0[0], dq2[0]));
    weights.w *= sign(dot(dq0[0], dq3[0]));

    // Blend
    mat2x4 result =
        weights.x * dq0 +
        weights.y * dq1 +
        weights.z * dq2 +
        weights.w * dq3;

    result[0][3] += int(sum_weight < 1) * (1 - sum_weight);

    // Normalise
    float norm = length(result[0]);
    return result / norm;
}

mat4 GetSkinMatrix()
{
    mat2x4 bone = GetBoneTransform(a_joints0, a_weights0);

    vec4 r = bone[0];
    vec4 t = bone[1];

    return mat4(
        1.0 - (2.0 * r.y * r.y) - (2.0 * r.z * r.z),
              (2.0 * r.x * r.y) + (2.0 * r.w * r.z),
              (2.0 * r.x * r.z) - (2.0 * r.w * r.y),
        0.0,

              (2.0 * r.x * r.y) - (2.0 * r.w * r.z),
        1.0 - (2.0 * r.x * r.x) - (2.0 * r.z * r.z),
              (2.0 * r.y * r.z) + (2.0 * r.w * r.x),
        0.0,

              (2.0 * r.x * r.z) + (2.0 * r.w * r.y),
              (2.0 * r.y * r.z) - (2.0 * r.w * r.x),
        1.0 - (2.0 * r.x * r.x) - (2.0 * r.y * r.y),
        0.0,

        2.0 * (-t.w * r.x + t.x * r.w - t.y * r.z + t.z * r.y),
        2.0 * (-t.w * r.y + t.x * r.z + t.y * r.w - t.z * r.x),
        2.0 * (-t.w * r.z - t.x * r.y + t.y * r.x + t.z * r.w),
        1);
}

EDIT: video of the results:

https://youtu.be/8jIt_Xhhffk

The one on the left is supposed to be a walk cycle, the one on the right is supposed to be this:

https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Monster


texts:
Whenever I run my code to make a fullscreen GLFW window, it crashes.

Here is the code:

package ext.tpz.test;

import static org.lwjgl.glfw.GLFW.*;

public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        if (glfwInit() == false) {
            System.out.println("GLFW failed to init.");
            System.exit(1);
        }
        long fullscreen = 0;
        if(args.length >= 1) {
            if (args[0].equals("-fullscreen")) {
                fullscreen = 1;
            }
        }
        long win = glfwCreateWindow(640,480, "Test", fullscreen, 0);

        glfwShowWindow(win);
        while(glfwWindowShouldClose(win) == false ) {
            glfwPollEvents();
        }

        glfwTerminate();
    }
}

Here is the crash report:

  A fatal error has been detected by the Java Runtime Environment:

  SIGSEGV (0xb) at pc=0x000000012dd11841, pid=13565, tid=1811

  JRE version: Java(TM) SE Runtime Environment (8.0_65-b17) (build 1.8.0_65-b17)
   Java VM: Java HotSpot(TM) 64-Bit Server VM (25.65-b01 mixed mode bsd-amd64 compressed oops)
   Problematic frame:
   C  [libglfw.dylib+0x9841]

  Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

  An error report file with more information is saved as:
   /Users/a677c774/IdeaProjects/LWJGL 3 Tests/hs_err_pid13565.log

  If you would like to submit a bug report, please visit:  http://bugreport.java.com/bugreport/crash.jsp
  The crash happened outside the Java Virtual Machine in native code.
   See problematic frame for where to report the bug.

  Process finished with exit code 134 (interrupted by signal 6: SIGABRT)


texts: What are the differences betwen Texture, TextureRegion, TextureAtlas, Sprite and Image in libgdx?

texts:
I've searched around for tutorials. I've seen people using the above classes to load images.

As according to my understanding, all of the classes can read in a non-power of two images, TextureRegion/TextureAtlas are usually used to load sprite sheet, in which the sheet contains multiple images. While for Texture/Sprite/Image, they are used to load a sprite sheet with single image.

However, I'm not so sure in which situation I should use Texture/Sprite/Image and in which situation I should use TextureRegion/TextureAtals.

Please correct me if I'm wrong, as I'm a bit confused by the terminologies in the API after looking various tutorials.


texts: How do I compile a namespace to a .DLL in Unity?

texts:
I'm developing a core library that I will use in my other games. I've only heard of using Unity .DLLs recently, and have spent some time putting my core scripts into a namespace. If I understand .DLLs correctly, I should be able to take that .DLL, plop it into one of my other projects, and then immediately start using it.

The question is, how do I compile that namespace into a .DLL that I can use in other projects? I'm using Visual Studio and Unity 2018.2.17f1.


texts: How to get the Javascript equivalent of GameMaker's `hspeed` and `vspeed` given only `direction` and `speed`?

texts:
I'm using a NodeJS server to control NPC movement in a multiplayer game, and when they get too close to the edge of the room I need to reverse either the horizontal or vertical components of their velocities (how to decide which, is a bridge I'll cross when I get there).

The problem is I already have their direction and speed, and am able to convert it to hspeed and vspeed, but not back again.

I need the inverse of this function:

function velocityToSpeeds(direction, speed) {
  return {
    x: -speed*Math.sin(Math.toRad(direction - 90)),
    y: -speed*Math.cos(Math.toRad(direction - 90))
  };
}


texts: What is the best type of c# timer to use with a Unity game that uses many timers simultaneously?

texts:
I am developing a stand-alone 3d game in Unity that will have anywhere from 1 to 200 timers running simultaneously. There will be a GameObject containing 1 timer. For this game timer durations will range from 5 minutes to 4 days. There will not be any countdown displays or any UI for the timers.

Each object is a prefab, with all the necessary materials included. An attached script will handle the timer and all the necessary code to change the materials and make any sound effects. Once the timer is expired, the user will then click on the object again, and the object will be destroyed, and the user's inventory will be adjusted.

If the user wants to save or end the game before all the timers are done, the start value of the still running timers is to be saved to an XML file such that when the game is started again, any still running timers will be checked to see if they have expired, where the object's materials will be changed appropriately.

I am still trying to figure out what type of timer to use, and see also if there are any suggestions for saving and calculating times over several days.

What class(es) of timers should I use?
Are there any special issues I should look out for in terms of performance?


texts: Are there any good blogs or articles on the business of indie games?

texts:
Interested in both successes and failures (and semi-successes).

Maybe this might be better at OnStartups but I think the game market is quite a bit different than the business market that's prevalent there (i.e. selling something that's fun instead of selling something that's useful)


texts: How can I correctly use an unordered_multimap as entity and component storage?

texts:
The Setup

I've made a few games (more like animations) using the Object Oriented method with base classes for objects that extend them, and objects that extend those, and found I couldn't wrap my head around expanding that system to larger game ideas. So I did some research and discovered the Entity-Component system of designing games. I really like the idea, and thoroughly understood the usefulness of it after reading Byte54's perfect answer here: What is the role of "systems" in a component-based entity architecture?.

With that said, I have decided to create my current game idea using the described Entity-Component system.

Having basic knowledge of C++, and SFML, I would like to implement the backbone of this entity component system using an unordered_multimap without classes for the entities themselves.

Here's the idea:

An unordered_mulitmap stores entity IDs as the lookup term, while the value is an inherited Component object. Examlpe:

 ____________________________
|ID          |Component      |
 ----------------------------
|0           |Movable        |
|0           |Accelable      |
|0           |Renderable     |
|1           |Movable        |
|1           |Renderable     |
|2           |Renderable     |
 ----------------------------

So, according to this map of objects, the entity with ID 0 has three components: Movable, Accelable, and Renderable. These component objects store the entity specific data, such as the location, the acceleration, and render flags. The entity is simply and ID, with the components attached to that ID describing its attributes.

Problem

I want to store the component objects within the map, allowing the map have full ownership of the components. The problem I'm having, is I don't quite understand enough about pointers, shared pointers, and references in order to get that set up. How can I go about initializing these components, with their various member variables, within the unordered_multimap? Can the base component class take on the member variables of its child classes, when defining the map as unordered_multimap<int, component>?

Requirements

I need a system to be able to grab an entity, with all of its' attached components, and access members from the components in order to do the necessary calculations and reassignments for position, velocity, etc.

Need a clarification? Post a comment with your concerns and I will gladly edit or comment back!


texts: How and when should I update events occuring after a while?

texts:
This question is not language specific but a more generic approach on how to deal with lazy updates for some game variables.

Let's say, for instance, that I want to implement a "character age system" for a game.

I guess that the "age" attribute does not need to be updated 60 times per second for each of my 10.000 or so RTS/MMO characters.

So, how to implement in the game loop the update of this "long term" variables that may have it value changed very sparsely?

At the moment, I would implement some global variables to accumulate the delta time between the frames until it reaches a certain value, then, it resets and updates that variables.

Is that correct? I mean, that's how things work? Or depending on the language/plataform you would set some timers, or events that trigger the update of these variables?


texts:
I am importing a model from 3DS Max 2011 which has been rendered by 3rd party renderer Vray. I believe that fbx does not support Vray information.

So, my questions are:
. What others ways are there to make the model impressive?
. What are my other options?

Also please note that I am very new to the world of XNA, so please elaborate the suggestion.


texts:
The NES classic Mega Man series uses a very specific scrolling technique that I'm having a hard time wrapping my head around implementing. Essentially, the level is divided into "screens" which are all the same size. Some of the screens smoothly scroll in to one another, creating the illusion of a wider fields of play. Some of the screens stop the camera from scrolling until the player has reached the edge of the screen, at which time a transition occurs and the next screen is shown. It is also possible for a single screen to have more than one transition, for example it has a ladder that goes up to one screen, but you could also walk forward to another screen.

How can these screen transitions be modeled?

Screen 0 is the starting screen, where the player starts.
Screen 0-3 is horizontally smooth-scrolling and appears to the player as one continuous field of play.
Since there is a transition between Screen 3 and it's neighboring screens 4 and 5, the camera will not advance past the right or top edges of Screen 3 unless the player moves to that respective edge and "pushes" through to the next screen.
Once the player moves to either of the transition edges, user input is momentarily disabled and the camera transitions into the new area, after which user input is restored.
The blue screen (Screen 5) has disabled horizontal scrolling so that only vertical transitions are possible.
The green screen (Screen 6) has a vertical transition back to Screen 5 but also allows horizontal smooth-scrolling into Screen 7.

Edit: Implementing the transitions in terms of rooms lead me to this:

The small notches with an arrow are the regions in which a transition can occur. Each region has a "direction" and lies just outside of the room's visible area. As soon as the player hits a region, a transition will be started.


texts: BOX2D Kinematic Platform with parallax layer

texts:
I am using a kinematic body for my moving platform on x-axis, so I set the linear velocity to b2vec2(5,0).

When the player jump on the platform, it works like it is suppose to. But the thing is that my platform is on the obstacle layer and I am moving it with the parallax layer.

So if I setTransform the kinematic platform to follow the obstacle layer than it's physics will not work and the player will slip-off the platform.

I'm developing for iOS and using cocos2d api. Anyway around this?


texts: How do you create a game overlay that makes the underlying graphics inactive?

texts:
I've created a simple game, and I drew a large rectangle in photoshop with faded edges that I want to use to overlay the game until the user presses "Begin" (on the overlay). The problem I'm currently having is that the stage under the overlay is still responsive (i.e. I can click on the items under the overlay before I press "Begin"). Here's essentially what I'm doing:

 @Override
public void render(float delta) {
    Gdx.gl10.glClearColor(51f/255f, 51f/255f, 255f/255f, 1f);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

    stage.draw();

    overlay.setColor(0,0,0,150f/255f);
    batch.begin();
    batch.setColor(overlay.getColor());
    batch.draw(overlay, 0, 0);
    batch.end();
}

Is there a way to inactive the stage's input listener until the "Begin" button on the overlay is pressed? Is this how an overlay type feature over games is typically achieved?

Thank you!


texts: How do I prevent floating and jittering when on the ground and using spherical gravity?

texts:
TL;DR: My ship floats and jitters when it lands on a sphere.

To elaborate on the title:
I'm experimenting with a 3D space game. I have created a sphere, which in turn has a larger sphere overlapping it, within which, gravity will take place. However, once my player's ship (currently using an arrowhead) lands on the planet, it doesn't actually make contact with the surface of the sphere, and then the ship begins to rotate erratically and jitter. Code below.

private void OnTriggerStay(Collider other)
{
    if (other.CompareTag("SoI"))
    {
    inSoI = true;
    }
}

This trigger checks to see if the ship is in the larger overlapping sphere. I have another identical block for OnTriggerExit which sets inSoI to false. I also have a OnCollisionEnter which sets another variable, landed to true, and a OnCollisionExit which sets it to false.

private void FixedUpdate()
{
    if (inSoI && !landed)
        {
            gravityVector = (planet.transform.position - transform.position);
            rb.AddForce(gravityVector.normalized * planetrb.mass * rb.mass / gravityVector.sqrMagnitude);
        }
}

Simply, if in the larger sphere, then accelerate towards the planet. I tried disabling gravity if in contact with the sphere. It removed a lot of the jitter, however it still floats, and it still rotates side to side. The sphere by the way, is the standard Unity sphere, scaled 10000x in every axis.
I don't need code (though it would help), any solution is fine, even if it means abandoning the project.


texts:
I am developing a Pocket Civ game engine. (You can check the process at www.pocketciv.com). Basically there is maximum of 8 Areas (round nodes in the pic) that have Tribes (number inside the node). So area 3 has three tribes and area 5 has two tribes.

There is basic movement rules see page 7 and then the movement rules change after new advances are acquired. There is only one movement phase and you can move the tribes in any order you want.

Basic: A single tribe can cross a border once (by land)
Advancement: You can move a stack of tribes across the sea at the cost of 1 tribe (so every tribe in the stack then crosses a border)
Advancement: A single tribe can cross a border two times
Advancement: A single tribe can cross any number of borders (crossing the sea still costs one tribe)
Advancement: When you move the stack across the sea, it doesn't cost anything

Essentially, if you have the last two advancements you can move any tribes anywhere you like.

The naive way to implement this would be to track what tribes are moved where when user moves them. But this is hard for the user (for example if you move one tribe 3->5 and one tribe 5->3 you have not moved anything. My approach is to let the user move tribes around and always check if the given situation is valid. For example valid end situations from above starting point are (shown as list [area1, area2, area3, area4, area5]:

[0, 0, 3, 0, 2] (no movement at all, also the starting point)
[0, 0, 3, 1, 1] (5 -> 4)
[0, 0, 0, 5, 0] (5 -> 4, 3 -> 4)
[0, 0, 5, 0, 0] (5 -> 3)
[0, 0, 2, 2, 1] (5 -> 4, 3 -> 4)
... etc

I have implemented some kind of way to check if the proposed situation is valid. It gets hard when we take the sea movement cost into account. We would need to know what is the cheapest way to make the movement and recognize when tribes moved over the sea. For this I would need all the permutations about what tribes moved where.

For example if we have starting position: [0, 0, 3, 2, 0]

[3, 0, 2, 0, 0] (3 -s> 1, 4 -> 3) would cost 1 tribe at minimum
[2, 2, 1, 0, 0] (3 -s> 1, 3 -s> 2) would cost 2 tribes at minimum

Can anyone help me phrase this problem or say what would be the correct algorithm to find that the proposed situation is valid and what is the minimum cost. Is this a graph problem? Can this be solved with matrices? I have studied Prolog a little but haven't managed to get anything usable out of it. I can tell my implementation later but I would like a "clean-table" view of this problem.


texts: Quaternion to direction vector - flipping

texts:
I've kinda solved this myself by adapting the Camera::setDirection code from OGRE to work for my need:

Now I have the following code:

Vector3 boneDir = getBoneWorldOrientation(mEntity, mHips) * Vector3::UNIT_Z; //mDirection;
Vector3 dir = mCameraTrans->_getDerivedDirection();

Vector3 zAdjustVec = dir;
zAdjustVec.normalise();

Quaternion targetWorldOrientation;

Vector3 xVec = Vector3::UNIT_Y.crossProduct(zAdjustVec);
xVec.normalise();

Vector3 yVec = zAdjustVec.crossProduct(xVec);
yVec.normalise();

targetWorldOrientation.FromAxes(xVec, yVec, zAdjustVec);

mTransform is basically the SceneNode of the character, I'm multiplying the target orientation with it's inverse orientation to get it to parent/character-space.
mHips->_setDerivedOrientation(mTransform->_getDerivedOrientation().Inverse() * targetWorldOrientation);
The above code was taken from OgreCamera.cpp, the setDirection function, the part with the fixed yaw axis.
Now, that works... Sorta, I now get this problem at near-90 degree pitch, the orientation kind of flips to the other side, I've made another video to showcase this:

https://www.youtube.com/watch?v=6bdFhW_vtUs

Any ideas on how to fix this ?

I've asked on both the OGRE3D and GameDev.net forums, I'll link to there just in case.

OGRE3D: http://ogre3d.org/forums/viewtopic.php?f=2&t=78213
GD.Net: http://www.gamedev.net/topic/644417-vectorquaternion-help-pitch-bone-to-direction-vector/


texts:
I'm new to Unity , i use mac os catalina , unity 2019.4 and build for android/mobile.
I downloaded a unity project from internet. It's already in format of unity project. so i just copy it into my unity folder. THere's only 1 scene there. I can load , run and built with no problem. It created 160mb of .APK file. But now i need to bring this project into my other project (let's name it B project ). Basically i only need to bring that single scene (and all its linked assets) into that B project. What is the proper way to do this ?
Last time, what i did was: i export the whole things as package then imported it into my B project. When i open the scene  , i can run and build with no problem. But it create .AAB rather than .APK and size is 300mb (2x of the previous APK). Is this big size become the reason it become AAB ?
Can someone tell me what's wrong ? why the size is doubled when i just build the same scene. Does unity build includes unused asset ? because in B project there's already asset from my other scenes. What is the proper way to do this ?


texts: Can I get world-space z-near-plane vertices from projection matrix + z-near distance?

texts:
I'm trying to port ShaderToy VR shaders to WebXR (the new browser API for AR/VR devices).
ShaderToy VR shaders expect two extra parameters: ray origin (view translation) and ray direction (unit vector from ray origin to each pixel). I could easily calculate this ray direction if I had fovX + fovY + distance to projection plane.
The problem: WebXR does not expose FOVs and instead just provides us with a projection matrix (apparently some devices might need more complex projection matrices with shear, roll, etc.) WebXR also exposes zNear and zFar, but that's all the frustum info available if I'm not mistaken.
Is there any way to obtain the zNear plane corners in world-space with this information?


texts: What coordinates are we passing to pixel shader from vertex shader?

texts:
I have read articles about shader programing and understood the very basic knowledge of shader programing. One thing I always get confused is about the texture mapping. What I pass(output) from VS to PS is the vertex position and Texture Coordinates. I understood that in VS we can simply choose to pass the vertex position as it is or manipulate vertex position here (and may be something more). So what we ultimately pass is the position of the vetex.  But... it is still not clear to me that we are passing which we are calling as texture coordinates or UV?

If I understood correctly, if my model is a simple triangle consist of 3 vertices, VS will be run three times for each of the vertix and I am passing the position of the vertex. Its straight forward. But what is with the texture? Say, I am using 50x50 jpg image as texture. How are the 3 vertices are mapped to this 50x50 pixel texture?

From the book I have started reading couple of days ago explained that the rasterizer is the one which groups the vertices to form triangle and calculates the number of pixel in the triangle. But again its not clear to me that what we are passing as texture coordinates to VS?


texts: How do I morph between meshes that have different vertex counts?

texts:
I am using MeshMorpher from the Unify wiki in my Unity project, and I want to be able to transform between arbitrary meshes.

This script only works when there are an equal number of vertices between the two meshes. Is there some way to equalize the vertex count between a set of meshes? I don't mean that this would reduce the vertex count of a mesh, but would rather add redundant vertices to any meshes with smaller counts.

However, if there is an alternate method of handling this (other than increasing vertices), I would like to know.


texts:
I have a GameScene which has a character (animated sprite), AutoParallaxBackground background with quite large textures and no more than 3 other items attached to the scene at a time, previous 3 items are dispose()-ed accordingly, background music and item sounds. Background music is instantiated with MusicFactory, Sounds are played on SoundPool. In between switching these scene we are loading resources asynchronously, reading the streams and instantiation is done in AsyncTask and the loading textures to the hardware is done on UpdateThread/GLThread. If I turn off the background music, this starts to happen totally random.

I'm experiencing scene junking on at first flow: MenuScene -> 1st Stage (GameScene). After a while lag does not happen, rather than occasionally or random. Junk is happening when aforementioned 3 items are attached on the Scene and a sound is played along, note that background music is playing at the same time.

Detaching previous 3 items is "optimized" to reduce GC calling almost perfectly. When the lag occurs GC_EXPLICIT is showed in the logcat.

What I have tried:

Playing the sounds and music on different thread, IntentService, dedicated Service.
Reduced calls to mScene.detachChild(child) and other scene methods to avoid iterations over children of the scene.
Detaching IEntitys with matcher to avoid iteration.
Inspected sound files' integrity with ffmpeg for possible errors

Could .dispose(), unloading the textures from hardware or detachChild() causing this junk?

Could be marked object for GC from the async tasks be causing this?

What else could be contributing to this issue?


texts: Use heightmaps or direct vertex manipulation for runtime terrain editing in UE4?

texts:
I am creating a terrain editor and creator for in our game, in which we should be able to create hills and dales, create different shapes(forms) in the terrain etc. I came up with 2 approaches on achieving what we want,

1. modify 2d heightmaps by darkening / lightening colours; update terrain vertices based thereon.

2.  Create a plane and modify the vertices of the plane to shape what we want.

So my question is, which way would be faster/better for a ingame terrain editor? And why would you recommend that?

Or, if you know of a better way, I would love to hear.

Thanks


texts: Strange rendering issue with monogame/WinGL with HD7670M

texts:
I'm having some strange rendering issues with latest monogame/winGL code as seen below;

As you can see the xna and tomspilmans WinDX port seems just okay.

I'm having this problem on my laptop with a HD7670M and it doesn't exists on desktops (got a 7970 and 5970).

Any ideas on the issue?


texts: Weird effect when generating gradients for height map

texts:
I am experimenting with generating height maps using radial gradients and perlin noise, using a technique I found here: http://www.reddit.com/r/gamedev/comments/1g4eae/need_help_generating_an_island_using_perlin_noise/cagmlsi.

This is my code:

 public override void generate(int seed) {
        Random rand = new Random(seed);

        float[,] pixelMap = new float[gridSizeX, gridSizeY];

        // generate random starting points for the islands
        centers = new int[ISLAND_COUNT,2];
        for (int i = 0; i < ISLAND_COUNT; i++) {
            centers[i, 0] = rand.Next(0, gridSizeX - 1);
            centers[i, 1] = rand.Next(0, gridSizeY - 1);
        }

        float maxDistance = 0;
        for (int x = 0; x < gridSizeX; x++) {
            for (int y = 0; y < gridSizeY; y++) {
                // calculate the distance for each center node to the current coords.
                // pick the distance that is closest for the color value
                float distanceToCenter = 9999999; //artificially high number
                for (int i = 0; i < ISLAND_COUNT; i++) {
                    int centerX = centers[i, 0];
                    int centerY = centers[i, 1];
                    float localDistance;

                    //Simple squaring, you can use whatever math libraries are available to you to make this more readable
                    //The cool thing about squaring is that it will always give you a positive distance! (-10 * -10 = 100)
                    float testX = x;
                    float testY = y;

                    float distanceX = (centerX - testX) * (centerX - testX);
                    float distanceY = (centerY - testY) * (centerY - testY);

                    localDistance = (float)Math.Sqrt(distanceX + distanceY);

                    // let's see if the wrapped distance is shorter; if so use that.
                    // this allows our gradient to wrap along the X axis
                    if (x > centerX) {
                        testX = (gridSizeX - x) + centerX * 2;
                    } else {
                        testX = (gridSizeX + x);
                    }

                    distanceX = (centerX - testX) * (centerX - testX);
                    if (localDistance > (float)Math.Sqrt(distanceX + distanceY)) {
                        localDistance = (float)Math.Sqrt(distanceX + distanceY);
                    }

                    //is this closer than the last recorded distance? If so use it
                    if (localDistance < distanceToCenter) {
                        distanceToCenter = localDistance;
                    }

                    // record the maximum distance calculated
                    if (localDistance > maxDistance) {
                        maxDistance = localDistance;
                    }
                }

                // add the color to the pixel map, adjusted for an rgb between 0 and 255.
                pixelMap[x, y] = (distanceToCenter / gridSizeX) * 255 * 2;
            }
        }

        drawImage(pixelMap);

        // save image of final generation
        passOutput.Save(@"test.png", ImageFormat.Png);
    }

This code generates an image like this though:

the red dots (if you can see them) are diagnostics code I added to mark the center of the gradients.

I am completely stumped as to why these white borders are happening at the midway points between gradients. I feel like there is a simple solutions to this, but I have been at this for days and have been unable to fix it no mater what I try.

What I am expecting is something like this mockup made in Photoshop:

Notice how there are no sharp edges; all gradients int he image blend into each-other seamlessly.

Any ideas?


texts:
I am trying to improve my bloom system. So far I have bloom that looks like this:

What I need is to enlarge the low-bloom areas to make it look like this:

Simply increasing the bloom multiplier results in a linear brightness shift and the lantern's top gets completely lost in a bright epicenter. What I need is a non-linear system that alows to only enlarge bloom on the edges. I tried different approaches and was able to come up with the following formula:

float luma = min(dot(AccumulatedBloom.rgb, LUM_CONVERT), 1);
float bloomMultiplier = lerp(1, bloomAuraMult, pow(1 - luma, bloomAuraPower));

But this formula has a disadvantage, it makes the bloom look like this:

Could anyone help me find the right formula?


texts: How can I ensure procedural levels in an RTS are fair?

texts:
I've seen that symmetry and coherance is important in RTS level design, but I'm lazy and want to do procedurally generated levels.

How can I ensure I generate a fair playing field when procedurally creating levels for an RTS?


texts:
Are there any free XNA 4.0 post-processing libraries that are easy to hook into projects? I am looking specifically for a glow effect (although anything is great), and I should also mention that I'm using the Reach profile.

EDIT: I should add that I'm not concerned about the Windows phone, because it can't support custom shaders.


texts: What is the better way of generating levels in android game using LibGDX

texts:
I downloaded the source code of metagun for android from
https://github.com/libgdx/libgdx/tree/master/demos/metagun/metagun-android

The game uses a png image to create the level. It uses the following code.  I am finding it difficult to understanding.  The following code is from Level.java:

@SuppressWarnings("unchecked")
public Level (GameScreen screen, int w, int h, int xo, int yo, int xSpawn, int ySpawn) {
    this.screen = screen;
    this.xSpawn = xSpawn;
    this.ySpawn = ySpawn;

    walls = new byte[w * h];
    entityMap = new ArrayList[w * h];
    this.width = w;
    this.height = h;

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            entityMap[x + y * w] = new ArrayList<Entity>();

            int col = (Art.level.getPixel(x + xo * 31, y + yo * 23) & 0xffffff00) >>> 8;
            byte wall = 0;

            if (col == 0xffffff)
                wall = 1;
            else if (col == 0xFF00FF)
                wall = 2;
            else if (col == 0xffff00)
                wall = 3;
            else if (col == 0xff0000)
                wall = 4;
            else if (col == 0xB7B7B7)
                wall = 5;
            else if (col == 0xFF5050)
                wall = 6;
            else if (col == 0xFF5051)
                wall = 7;
            else if (col == 0x383838)
                wall = 8;
            else if (col == 0xA3FFFF)
                wall = 9;
            else if (col == 0x83FFFF) {
                BossPart prev = new Boss(x * 10 - 2, y * 10 - 2);
                int timeOffs = random.nextInt(60);
                ((Boss)prev).time = timeOffs;
                add(prev);
                for (int i = 0; i < 10; i++) {
                    BossNeck b = new BossNeck(x * 10 - 1, y * 10 - 1, prev);
                    b.time = i * 10 + timeOffs;
                    prev = b;
                    add(prev);
                }
            } else if (col == 0x80FFFF) {
                Gremlin g = new Gremlin(0, x * 10 - 10, y * 10 - 20);
                g.jumpDelay = random.nextInt(50);
                add(g);
            } else if (col == 0x81FFFF) {
                Gremlin g = new Gremlin(1, x * 10 - 10, y * 10 - 20);
                g.jumpDelay = random.nextInt(50);
                add(g);
            } else if (col == 0x82FFFF) {
                Jabberwocky g = new Jabberwocky(x * 10 - 10, y * 10 - 10);
                g.slamTime = random.nextInt(30);
                add(g);
            } else if (col == 0xFFADF8) {
                add(new Hat(x * 10 + 1, y * 10 + 5, xo * 31 + x, yo * 23 + y));
            } else if ((col & 0x00ffff) == 0x00ff00 && (col & 0xff0000) > 0) {
                add(new Sign(x * 10, y * 10, col >> 16 & 0xff));
            } else if (col == 0x0000ff) {
                // if (xSpawn == 0 && ySpawn == 0) {
                this.xSpawn = x * 10 + 1;
                this.ySpawn = y * 10 - 8;
                // }
            } else if (col == 0x00FFFF) {
                Gunner e = new Gunner(x * 10 + 2, y * 10 + 10 - 6, 0, 0);
                e.chargeTime = random.nextInt(Gunner.CHARGE_DURATION / 2);
                e.xa = e.ya = 0;

                add(e);
            }
            walls[x + y * w] = wall;
        }
    }
    player = new Player(this.xSpawn, this.ySpawn);
    add(player);
}

I want some advice as to whether this is a good idea or not? This game was developed in 2010 using LibGdx.

The other example I found using TiledMap is at
http://chrismweb.com/wp-content/uploads/2013/03/superkoala/
at the offical site of libgdx.


texts: How do I rotate and object around itself, and translate it at the same time?

texts:
I have this animated gif of my problem.

I have a sprite object with a box collider, and I'm trying to rotate it around its center.

My rotation script consists of this :

this.transform.Rotate (0, 0, Time.deltaTime * rotateSpeed);

and in the translation script this is the code :

this.transform.Translate (0, -tranSpeed * Time.deltaTime, 0);

but as you see in the gif it does not give me the effect I desire.
Can anyone give me what am I supposed to do to be able to rotate it around its center? Thank you.


texts:
I am making a technically top down game with a shifted perspective. It shows more of the characters side, not just above their head. I think most "top down" games have a similar art style.

Due to this, only the bottom of the character sprite should collide and interact with game objects. Should I use two separate objects for the hitbox and the sprite? It seems inefficient to do this. Is there some other solution?

For reference, I am using python3 and the pygame library. I am using the sprite class from pygame. My player class inherits from the sprite class and is comprised of a surface object for the sprite image, and a rectangle object for the coordinates and length/width. Using a separate object for the hitbox and sprite would require to classes for this.


texts: How do I detect the direction of 2D rectangular object collisions?

texts:
After this question, I need some more help.

How can I find out which side of a rectangle a collision came from and react accordingly?

The blue arrows are the paths that some circular objects would follow if before and after colliding with the box.

How can I calculate this?


texts:
I'm developing a game using LibGDX and in a part it has a pretty complex UI for profile selection and stuff. I have some general problems.

I'd like to know good practices when generate good looking layouts using the Scene2d that comes bundled with it. I've found examples online but they don't usually get to the level of complexity that I require. Is the use of a table recommended always? How can I set positions and widths precisely (I've managed to fake it using paddings but there has to be a better way). I'd need something like absolute positioning in CSS.

I need to use different font files, colors and sizes for instance. How can do that in the skin and the use it in my code?

I also need different designs on buttons (different backgrounds). How can I do that?

Also for some reason my text is very bad looking. How can I make it look sharp?

Thanks in advance.


texts:
I have a Triangle class and a list of triangles representing my 3D model shape.

When I update the position, the rotation or the scale of my model, I also want my triangles list to be updated.

I already made the function to update triangle position, but I can't make it for rotation/scale...

private void UpdateModelTrianglesPos(Vector3 oldPos, Vector3 newPos)
{
    Vector3 diff = newPos - oldPos;
    for (int i = 0; i < _trianglesPositions.Count; i++)
        _trianglesPositions[i].UpdatePosition(diff);
}

Thank you for your help!


texts:
I was wondering if its actually possible to do bump mapping with 2 normal maps... I have tried doing it this way however I get a function overload on max and dot.

uniform sampler2D  n_mapTex;
uniform sampler2D  n_mapTex2;
uniform sampler2D  refTex;

varying mediump vec2  TexCoord;
varying mediump float vTime;

void main()
{
    mediump vec4 wave = texture2D(n_mapTex, TexCoord - vTime);
    mediump vec4 wave2 = texture2D(n_mapTex2, TexCoord + vTime);
    mediump vec4 bump = mix(wave2, wave, 0.5);
    //this extracts the normals from the combined normal maps
    mediump vec4 normal = normalize(bump.xyzw * 2.0 - 1.0);
    //determines light position
    mediump vec3 lightPos = normalize(vec3(0.0, 1.0, 3.0));

    mediump float diffuse = max(dot(normal, lightPos),0.0);
    gl_FragColor = mix(texture2D(refTex, TexCoord), bump, 0.5);
}


texts: How to check distance between two different vectors?

texts:
So I have a very basic racing game, where I would like the car to stop once it hits the finish line. Respectively when the distance between the car and the finish line hits or goes under 0 the car stops, but instead of stopping it continues to go on. How can I fix this?

Here's my code:

    public float speed = 0f;
    public float gravity = 0f;
    public Transform finishline;
    public Transform car;
    public Transform finish;

    void CarMove ()
    {
        if (Vector2.Distance (finishline.position, car.position) != 0)
        {
            if ( Input.GetKey(KeyCode.RightArrow))
            {
                transform.Translate(Vector2.right * speed * Time.deltaTime);
            }

            else
            {
                return;
            }
        }
    }

    // Update is called once per frame
    void Update ()
    {
        CarMove();
    }
}


texts: Should I shade models before or after importing them into Unity?

texts:
Is it better to shade a model inside the 3D modeling software or inside Unity?

As an example, if I need to use a transparent model, should it be made transparent inside the modeling application or inside Unity?


texts: Why does this work? - camera rotation from screen space

texts:
I do not understand the math behind the linked function or why it works. I would like to know this.

https://sidvind.com/wiki/Yaw,_pitch,_roll_camera

void Camera::motion(int x,int y){
        theta+= x / 200;        /* Adjust this to control the sensitivity */
        phi+= y / 200;

        target.x = cos(theta) * sin(phi);
        target.y = cos(phi);
        target.z = sin(theta) * sin(phi);
}


texts: How can I reduce render time on scenes with lots of UI component?

texts:
I'm looking for a way to reduce rendering time for my Game Over scene. A quick look of the scene components is like this:

All yellow objects are UIButton, texts are all UIText, white areas are all UIImage (including the background). The friend list is a Facebook friends list contained inside a Scroll View. All object are inside a Canvas that resizes to the camera.

I noticed the problem firsthand when playing the game on Android. This game over scene is running at 15fps (while the main game play scenes are all running at nearly 60fps). The phone is a HTC One. On my cheap LG phone the game simply crashes at this scene.

Profiler shows Camera.Render() taking 70~90% of each game loop.

The iPhone5 & 6 on the hand is quite interesting, fps show no real difference between gameplay scenes and the gameover scene, both running smoothly at ~120fps. Still Camera.Render() was taking 40~50% of each loop in GameOver scene vs ~20% on GamePlay scenes.

Quite strange considering the fact that HTC One specs and iPhone 5's are quite similar.

I think the problem is because of the large number of UI Components on the GameOver Scene, since sprites on gameplay scenes are all batched (it's a 2d game). So I suppose I must find a way to reduce draw call on all those UI components. I thought this should be a common problem, but strange enough I've been searching for weeks without a sounding solution that actually work.

I've tried to check all UI objects static: doesn't show any notice-able change. On the other hand, Scroll View's contents are what's taking the bulk of the rendering (a long friend list), and I can't mark them as static because they do move.
Canvas pixel perfect off: already done that from the beginning.
Move the Scroll View to a separate Canvas: only improve performance when I'm actually scrolling scroll view, otherwise no change. And - could be I did something wrong - the scroll view doesn't work on Android anymore.

TL;DR; Question: Please guide me to reduce rendering time on scenes with lots of UI elements.


texts:
I am working on an action platformer using Pygame.

My player sprite has three melee attacks. Let's call them SLASH_1, SLASH_2, and SLASH_3. Each of these attacks has, let's say, 2 animation frames, the same hit box, and results in the same amount of damage.

I want the mechanics of my game to be such that if the user presses the attack button three times in quick succession, the sprite will do each attack in turn (regardless of whether there's an enemy around). For an example of what I'm talking about, see here.

I have currently implemented this in the following way:

I have an empty list called "attack_queue" into which I insert attack animation frames when the user presses the attack button. If they press it quick enough, the second and third attacks are added into the list. On each iteration of my game loop, I animate the first frame of the attack_queue (if it's non-empty).  The animation code also generates hit boxes for each attack as well as checks for whether the attacks land on an enemy. Once a frame has been animated, it is removed from the attack_queue.

Here's some pseudo-code to give you a better idea:

...
now = get_current_time()

attack_queue = []
    if attack_button pressed:
        if now - last_attack > 50 ms:
        n = 0
        add attack_animations[n] to attack_queue
        last_attack = now
    else if now - last_attack < 50 ms:
        n += 1
        add attack_animations[n mod 3] to attack_queue
        last_attack = now

animate(attack_queue)
...

This works okay for the time being, but I doubt it's the most elegant way of implementing attack chains. (One problem I am having is that this method results in a bit of input lag, since the player is able to press the attack button a third time before the second attack animation has finished.)

My questions are:

In general, what are some other methods of implementing attack chains?
Specifically for Pygame, what are the best ways of implementing attack chains?

A similar question is addressed on Reddit here, but I am looking for a more fully fleshed out answer.


texts: How to make an object with its own sprite draw an additional sprite on top of itself

texts:
I'm making character select buttons for a Game Maker Studio 2 game, hoping to do so by just having a single object I can edit on an individual basis to change which character it represents. I also want the button itself to display the sprite of the character it's meant to represent like an image overlaying the button's own sprite. I can't seem to get a clear, direct answer on how this is done.

To sum up:

Character select button is an object with its own assigned sprite.
Each individual button object holds (a reference to) a corresponding character object the player may select by clicking that specific button.
Button object should be able to check the sprite of the character object it references, and draw it on top of its own sprite without replacing it entirely.

If anyone can help show me how to do that last part- or barring that, perhaps point me toward a better way to achieve a similar effect, it would be appreciated.


texts: Strategy for detecting hits from a "cylinder ray"?

texts:
I was planning on using ray casting for collision detection in my game. However, when I use an attack similar to this:

(which would project something like a cylinder), how would I go about detecting if it hits the other player?


texts:
Just today, I was dealing with this very topic in class, and I had a hard time following through the lectures. Could someone explain to me what it means for something to be frame dependent, in layman's terms? As far as I know, it's not Unity-specific. I suppose this applies to every game, regardless of its engine.

An elaborate answer would do really good for me, as I'm a student, and I'm gonna be doing projects on this. Thanks!


texts:
For a detailed survival RPG, the data that needs to be managed can easily become overwhelming if approached in an ad hoc manner.

First, you may want to do away with HP and instead have a system of wounds, where various body parts can be specifically injured and each injury requires individual attention. Attacks can be targeted and the effect of an injury depends on its location and how well it is treated.

The next obvious step is to manage clothing so that each piece of clothing covers particular body parts and provides particular armor values to each part. We also need to keep track of clothing conflicts, where two pieces of clothing try to cover the same area and so they can't be worn together, except when they are designed to be worn under or over other clothing.

In addition, there could be magical effects on certain body parts, or perhaps claws or spikes could be added. Perhaps various limbs could be replaced by cyborg parts, or magical parts. Even worse, perhaps there are creatures alternate body plans with more or fewer than the usual limbs.

Each limb can be divided into parts, so for example a leg consists of a thigh, a knee, a lower leg, and a foot. We want to manage those parts individually, but we also want to remember that together they represent a leg. We might need this so that targeted attacks aren't forced to be overly specific and we can provide players with notifications that doesn't give excessive detail.

For example, in the game "Slaves to Armok" you can sometimes get messages about some particular toe, finger, or ear being hit. This is clearly too much detail for the middle of battle. We wouldn't want be forced to give that sort of detail because we're not storing the fact that these detailed parts add up to a greater whole. At the same time, a strict hierarchy of parts wouldn't be right, because two arms together make up "the arms" of a character, yet each arm individually is part of either the "the left side" or "the right side" of the character, and we'd want to keep track of these relationships so we can provide appropriate messages to the player.

We'd also want all this data to be stored sparsely. For example, if you're facing twenty goblins, there's no point in individually storing every limb and detail for each goblin when they are all identical. We want to store a prototypical goblin in one place, then each individual goblin can be represented only by how it differs from the prototype. Further, the prototype goblin could be represented by how it differs from the prototype human. This is not just to save memory, but also to allow the game to know what makes each character special so it can give the player relevant messages. The game could mention "the goblin with the head wound" or "the goblin with the spiked glove" because that's exactly how those goblins are represented in memory.

Obviously one shouldn't jump blindly into designing such a game, solving each problem as it arises. This level of complicated data needs a database-style system to keep all the details organized, yet a simple relational database doesn't provide an obvious solution. Could something like an Entity System be the right approach?

Is there a known strategy for managing this sort of data that experienced game developers would always use for making this sort of game?


texts:
I made a game in monogame recently, using the XNA content pipleline. I then sent the whole folder (The release folder in visual studio) to a friend of mine who does not have visual studio or monogame. He said he can't open the game. What the are files I need to give my friend for him to be able to play it?

He has Windows 8


texts:
When running a jenkins build using the Unity 3D plugin I get the following error repeatedly:

Failed to get socket connection from UnityShaderCompiler.exe shader compiler! C:/Program Files/Unity/Editor/Data/Tools/UnityShaderCompiler.exe

Not sure what's going on there, I tried giving a pass to the exe in windows firewall but it didn't help.

I have Unity 2017.1 installed...


texts: Getting angle from current position and next position

texts: I am using pathfinding to move a train along rails, but I need the train to rotate. I have the next intended position and the current position at my disposal, how would I go about this? Pseudocode will do as an answer since I am using a specialized programming language for the engine that I use.


texts: Class Structure for upgrades that depend on other upgrades

texts:
This game involves making buildings that can be upgraded. Sometimes a building's upgrade isn't available until another building is either created or upgraded to some specific level.

For simplicity's sake, there are two buildings, A and B. Level 1 of both buildings can be built at the start.

Building B can be upgraded freely but building A can't be upgraded to level 2 until building B is at level 4.

As far as class structure, I don't know if there should be a Building class and then BuildingA and BuildingB classes that inherit from it. Or if there should just be a Building class and individual building types are instances of that class. This latter solution seems ugly because there is also the layer of individual instances of building a building type.

In either case, I don't know how to design the class structure to control dependencies like the example I gave. Other than hard coding it which isn't very clean or conducive to extending it to more buildings and nuanced dependencies.


texts:
In Starcraft 2, unit formations are created when a "group" is generated from a command. Generally, the rules for a group are:

All units in the group are in the same spatial "clump".
All units in the group were given the same move command.
If any unit in the move command is not in the clump, the group is broken and units move towards the destination individually.

How do I define a clump programmatically and detect in a unit is not in the clump?


texts:
I've been experiencing this lighting bug in my game.

As you can see there is a box around the player on the back wall and underneath it. the platform and back wall are 3D objects and the player is a 2D sprite. i believe i have found an option in the past but i am unable to find where it is now. I really appreciate you help and thank you all in advance


texts: Deformable meshes based on torsional spring

texts:
I am trying to learn physics-based animation thanks to the book "Foundation of Physically-Based Modelling and Animation".
They introduce the mass-spring model for deformable meshes. Although making each pair of vertices a mass-spring system would give good results, it would be too heavy to compute. So, the authors introduce another technique : between each pair of adjacent triangles, the evolution of the angle is based on a torsional spring model. I don't know if you can read it on the Google preview. It's on page 161 : https://books.google.fr/books?id=vaqdDQAAQBAJ&printsec=frontcover&dq=torsional+spring+foundation+of+physics+based+animation&hl=fr&sa=X&ved=0ahUKEwj-oPTkvobcAhVDtBQKHfj2AaYQ6AEIKzAA#v=onepage&q&f=false

I struggle to understand this model.

For instance, let's imagine we have two adjacent triangles \$ABC\$ and \$BCD\$. Let's \$ \theta \$ be the angle between both triangles. The torque is \$ \tau = k(\theta - \theta_0) \$. We want to compute the equivalent forces \$ f_{A} \$,\$ f_{B} \$,\$ f_{C} \$,\$ f_{D} \$, and torques \$ \tau_{A} \$, \$ \tau_{B} \$, \$ \tau_{C} \$, \$ \tau_{D} \$ relatively to \$ B \$.

They state that all sums must be equal to zero :
$$ f_{A} + f_{B} + f_{C} + f_{D} = 0 $$
$$ \tau_{A} +\tau_{B} + \tau_{C} + \tau_{D} = 0 $$

I don't understand why.
Can you give me some help ?

Thanks.


texts:
I am currently trying to move an object (a square) around the stage in 2D space. Think Cuboid but in 2D platformer space, and vertical walls as well as the ground.

The idea is that during each rotation, if any collision occurs, I want the block to move onto that square.

For example, if the "player" is moving left, and there is a wall directly in front of him, he will hit the wall and start to move up the wall instead of on the ground.

There will be edge cases of the player moving left, no block directly in front of him, but a block one width and height to the left of him. I.E. there is a block diagonally up-left of the player, so when the player moves once more to the left, he will collide with the block during the rotation. When that happens, I want to continue the player's movement up the wall as well.

Below is the code of how I am rotation the object and moving it. I do not want to rotate the object around it's center point and move it at along a constant speed. It looks better moving the object with the rotation.

The questions are:

a) Is there a better way to accomplish what I am trying to do (I'm sure there is).

b) Is there a way to get the positions of each corner while the object is rotating? How I am currently doing it, the only static point is always the bottom left of the player. Since I rotate around that point, and when the rotation has rotated a full 90 degrees, I scaleX and move the object to the new position. So the registration point is always at the bottom left.

Object info: blocks and the player are both 16x16. Their registration points are bottom left.

Game info currently: I just have the player bouncing between the stage boundaries. Hence the moveLeft boolean checks.

if (moveLeft){
    rotation -= moveSpeed;
    if (Math.abs(rotation) >= 90){
        if (x == 16){
            moveLeft = false;
            scaleX *= -1;
        }
        else{
            x -= 16;
        }
        rotation = 0;
    }
}
else{
    rotation += moveSpeed;
    if (Math.abs(rotation) >= 90){
        if (x == 624){
            moveLeft = true;
            scaleX *= -1;
        }
        else{
            x += 16;
        }
        rotation = 0;
    }
}

If you need anymore information, please let me know. I hope I explained the situation sufficiently.


texts:
I downloaded the SDK from over here. Namely, I downloaded and unpacked sdk-tools-windows-3859397.zip.

What should I do next with the files, to which one of them should I provide a path in Unity in order to build an app for Android?


texts: Same scroll speed across devices with different DPI

texts:
I am creating a simple game in JS, something like the flappy bird :)
For pipe scroll, I am using a linear tween.

I noticed that the speed of the pipes are different across different smartphone screens, so
the game has different difficulty.

I observed that this has to do with different screen sizes and different pixels densities.

What I did is I defined a duration per pixel, which is multiplied by the number of pixels the screen has.
The duration per pixel, pixel_duration is constant.

So basically:

tween_duration = number_of_horizontal_pixels * pixel_duration

But this gives same speed in different sized browser windows on the (same) computer screen.
If I use this approach on some device that has higher pixel density, the pipes will move slower,
because there are more pixels, so this tween_duration value gets larger, so tween gets slower.

Then I learned of the devicePixel ratio value which can be used. So I try to factor this in the equation:

tween_duration = number_of_horizontal_pixels * pixel_duration / devicePixelRatio

This devicePixelRatio is higher as screen DPI's goes higher and should solve my problem according to the docs, right?
https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio

However, this only helps a bit. There is still a noticable speed difference.

Why is this not working, and how can I get the same scroll speed across devices in JS (in browser window) - perhaps some other approach would do?


texts:
In my game, ranged units and melee units have the same behavior. Ranged units try to maintain a fixed distance r, from their targets. If they're within r + d of the target (where d is a small value) they stop and shoot it. Note that this means the ranged unit can't be closer than r - d. Melee units are the equivalent of ranged units, but with r set to zero.

Right now, my AI for ranged units is as follows:

Find a path to the target using A*.
Walk along the path until you are within [r - d, r + d] of the target.
Stop and shoot. If the target is dead, quit.
If you are still within [r - d, r + d], goto 3.
Otherwise, move away/towards the target until you are within r + d again. Goto 4.

Here's a sort of diagram.

My problem is, if there are obstacles and the target moves, step 5 causes a lot of problems. Ranged units will end up backing into walls, unable to shoot. If instead of going to step 5 I go back to step 1 (planning a path), the problem still isn't solved, because walking toward the target will only decrease the range, not increase it.

How can I get ranged units to successfully follow and shoot their targets?


texts: OpenGL: What to do after running glBufferData?

texts:
I am interested in understanding a bit more behind how OpenGL does its memory management and what are some good practices before I start heavily coding and back myself into a corner.
The real question I have is regarding memory. I have a class called Mesh that consists of a pointer to some vertex data, a pointer to the face data, as well as the number of vertices and faces. I am familiar with one possible process that OpenGL uses to get these drawn on the screen: generate a buffer for vertices and a buffer for faces, bind them as GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER, call glBufferData to move the data to the buffers, and lastly call glDrawElements to draw them. From here I can understand how I can load several Mesh objects and draw them on screen, and I have no issue there.
My question then lies in where the memory is stored and what I should be doing in order to conserve memory. My assumption is that after the call to glBufferData, the data is copied to the GPU (or to some other register to later be copied to the GPU). Is it safe for me to delete the original Mesh object that was used with the buffer calls? In my head, the mesh data is retained inside the GPU so the data is not lost, and so long as I do not need to reload this data using OpenGL later then I won't miss this data at any point. Also in my head, this frees up RAM space for other uses, so my Mesh, in some sense, now totally lives in GPU memory and nowhere else, and I can do my drawing solely by making OpenGL calls to the correct buffers (so I obviously need to save the generated buffer IDs, but that part goes without saying).
If someone could tell me if this is correct/incorrect logic, as well as good/bad game dev practice?


texts: OpenGL SDL Texture doing really weird things

texts:
I am trying to render a .png image to the screen using C++, SDL and glut.

This the texture I made using paint

This is what I get on the screen:

Does anyone have an idea what could cause this?

How I loaded the image:

void Main::loadStuff() {
    SDL_Surface* surface = IMG_Load("C:\\Users\\VliegendeGeit\\Desktop\\Programming\\C++ Projects\\OpenGL\\texture.png");
    if (!surface) {
        std::cout << "errror";
        return;
    }

    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);

    int Mode = GL_RGB;

    if(surface->format->BytesPerPixel == 4){
        std::cout << "errror2";
        Mode = GL_RGBA;
    }

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->w,surface->h, 0, GL_RGB,GL_UNSIGNED_BYTE,surface->pixels);

    SDL_FreeSurface(surface);
}

How I rendered the image:

///TEXTURE
    glBindTexture(GL_TEXTURE_2D,texture);
    glEnable(GL_TEXTURE_2D);

    int X = 0;
    int Y = 0;
    int Width = 1;
    int Height = 1;

    glBegin(GL_QUADS);
        glTexCoord2f(0, 0); glVertex3f(X, Y, 0);
        glTexCoord2f(0, 1); glVertex3f(X + Width, Y, 0);
        glTexCoord2f(1, 1); glVertex3f(X + Width, Y + Height, 0);
        glTexCoord2f(1, 0); glVertex3f(X, Y + Height, 0);
    glEnd();
    glDisable(GL_TEXTURE_2D);

Ps.
Yes I made the GLuint texture variable, it is static defined in the header file, oh and there are no errors it could not load or something.


texts: How do I make a curved surface out of rectangular blocks?

texts:
For a Peggle-like game, I want to make blocks that follow a curve, like this:

The blocks would then disappear as the ball hits them.

I managed to draw some horizontally, but I'm having trouble making them follow a path:

How do I do this? Do I need to create Box2D objects with custom vertices?


texts: Creating Primitives and Model from Texture2D Xna 4.0

texts:
So I was playing around with XNA working on a 3d engine with 2d sprites as characters and objects.
After a while I became very unhappy with the way the sprites were being scaled and billboarded so I created a GameSprite class that takes all the information from
the texture2D(pngs) and turns it into VertexPositionColor quads on init.

these are drawn with a basic effect, a struct quad, and a quadList.

basicEffect.CurrentTechnique.Passes[0].Apply();
        foreach (ColorQuad quad in currentFrame.quadList)
        {
            graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                PrimitiveType.TriangleList,
                quad.Vertices,
                0,
                quad.Vertices.Length,
                quad.Indices,
                0,
                quad.Indices.Length / 3);
        }

(frames are different quads chopped up from the original image for animation,
like a sprite sheet)

This creates a great 3D recreation of the sprite that can be zoom entirely with no blur.

Each GameSprite has its own basic effect file.

I was wondering if there was a way, maybe during LoadContent, that I could create
these vertices and turn them into models for easier drawing and rendering in this
3D world and if this is even a good way to go about this and if I might experience
longerterm problems using lots of these GameSprites and their many quads.

Thanks for reading!


texts: How do i choose what technology to use for a 2D game like Pokemon?

texts:
I apologize in advance for the wall of text about to come.  I've had an idea for a game for a while now, and am stuck at step 1 of game development: Choosing a language/engine.  I've read a whole bunch of articles, comments, and posts, but everything recommends a different combination, and they all just give me more questions with less answers.  I'm hoping someone here has some experience with what I'm trying to do, and can let me know what's what.

So, for the sake of this post, let's assume I'm writing something akin to one of the old Gameboy Colour Pokemon games, but with nicer graphics. Like Pokemon, with "Zelda: A Link to the Past" graphics.  I've looked into the following options in terms of the technology:

C++ using SFML
Java using LWGl
Java using LibGDX
Python using PyGame

Each of the above has pros and cons, but I don't know which pros and cons apply to me.  I am comfortable with any language and library, I already know a lot, and am more than happy to learn more. My three questions that are holding me back from making a decision are:

How do I choose a technology now without knowing that it can "handle the load" without chugging along?  What if I choose Pygame, and 60% of the way through development I can't get the FPS above 15?
How do I know which engines are better suited to "2D Zelda/Pokemon" gameplay?  I've been recommended 1000 different engines and libraries, but most of them are for 3D effects or insane physic (which I likely won't need).
How do I handle cross-platform stuff?  I want to distribute on Windows/Mac, and Linux as well.  Java is easier for this, but what if it's not performant enough (compared to C++)?

So, does anyone have experience with anything like this?  Has anyone been where I am before?  I want to get started, and dip my feet into the proverbial water, but I'm too held back by indecision on technology to get my toes wet.

If anyone can recommend an engine/language/toolset for me, and maybe point me towards some tutorials or guides, I would be greatly appreciative.


texts:
First of all I have Xcode 4 installed in Mac OS X Snow Leopard 10.6.8. I have downloaded the Quake 3 source code 1.32b release but I can't open the Xcode project that is inside the /macosx folder since it is in the old .pbproj format and therefore it throws an "incompatible version" error. Has anyone been able to convert this to a Xcode format or is there any other way to compile the source code in Mac OS X Snow Leopard?

Thanks


texts: Change alpha value of object if it's closer to the camera than the player

texts:
Ok, so - I'm a complete idiot when it comes to shader programming, and while I suspect someone with some experience here may find this easy, I'm at a bit of a loss.

I'd like to create a shader that would be applied to walls, and if the wall was closer to the camera than the player is, the wall would gain alpha transparency (probably 10-20% visible).  I had tried some things with a camera that pans, zooms, and moves overhead as needed to not occlude the player, but it's sloppy and just doesn't feel very nice.  I had used an x-ray shader, that showed an outline of the player through the wall, and while it was "cool", it also didn't quite feel right.  The camera and player will always be a fixed distance and angle apart (well, at least at a given resolution).  Is there some way to use the draw buffer or otherwise calculate world space position to determine when alpha should be applied?

Any help is very much appreciated.  Thanks!

EDIT:  I was looking and found a lot of solutions like this one:  https://forum.unity3d.com/threads/global-shader-to-apply-transparency-on-objects-depending-how-far-is-the-camera.188632/

But I'd rather have it contained entirely in the shader.  Preferably something I could build into a copy of the Standard (Specular Setup) shader in Unity - that copy being applied only to wall objects.

EDIT #2: I understand that this could be done with two separate materials, using code to swap them with Raycasting (though it seems that that would only work specifically for objects directly between the camera and the player rather than objects closer to the camera than the player).  But I'm growing more uncertain that the shader can be told anything about the position of the player as an object.


texts: What methods can be used to rotate a tiled structure?

texts:
I'm trying to rotate some structures that are locked on a grid-like structure. This means I'm looking for lossless ways to rotate the tiles. Maintaining proper distances are not important, I'm aware that diagonals will be longer if we maintain the same number of filled tiles.

Here's a few examples of what I want to do (done by hand, so might be slightly off), where the red block is the front:

On the left are the four cardinal directions, which are East(0°/0.0π rad), North(90°/0.5π rad), West(180°/1.0π rad) and South(270°/1.5π rad).

On the right there's ~22.5° in the top and 315° in the bottom.

Right now I'm looking mostly to do rotations in ~22.5° increments, so a full circle in 16 steps, but a general solution for the problem would be great.


texts: How to draw a circle on the ground like in "Warcraft 3"?

texts:
I've been watching "Warcraft 3", and suddenly realized that I have no idea how to draw a circle on a surface.

Here is an example:

I guess this is projection? I also have very little idea of how to draw a shadow. I only somewhat know OpenGL.

It is also interesting how this circle seems to not perfectly repeat the shape of that cliff. My guess is that it's drawn using a height map, which is stored somewhere separately, and not as the cliff, itself. It looks like it actually goes underwater, but it may be just a compression artifact.


texts: Cannot add key in matinee for static meshes (UE4)

texts:
My problem is the following:
I was trying to make a sliding door based on a video tutorial, I had the static mesh, which was the door itself, and I added a Matinee for that door, so I went 'Add New Empty Group -> Add Movement Track', so I had the door with a movement track, but when I tried to add a key, I couldn't.
This was the error message: "Nothing to keyframe, or selected object can't be keyframed on this type of track."
And I only get this message when I try to add keys in the movement track of a static mesh. When it's a camera, everything is fine.
Any idea why this is happening, and how I can solve this?
Thanks for your help


texts:
Some of my sprites don't "Blend" in with tiles behind them Z-wise.
glEnable(GL_DEPTH_TEST);

Depth testing is enabled and works.
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

The blend function is above.
Below is a picture of four different instances of the application. As you can see, blending works on random sprites.
Why aren't some of the sprites blending?
An observation that I made is that when I move the sprites (layers 0 and 1) below (Z-wise) the button, you can see the sprites from the gaps left by letters (layer 10), yet the button itself (layer 9) doesn't show in that area. This is what I find the strangest.


texts: Is using the applet class in a Java game a wise thing to do?

texts:
I am making an 2D multiplayer game in Java project, by using Java sockets and simple  java.applet.*

Our teacher told us to use J2EE concepts in the project. Do I have to use JSP? Is it better or more employable in game development?

Am I doing the correct thing?


texts: Question about Target parameter of Matrix.CreateLookAt

texts:
I have a newbie question that's causing me a little bit of confusion when experimenting with cameras and reading other peoples implementations - does this parameter represent a point or a vector?

In some examples I've seen people treat it like a specific point they are looking at (eg a position in the world), other times I see people caching the orientation of the camera in a rotation matrix and simply using the Matrix.Forward property as the "target", and other times it's a vector that's the result of targetPos - camPos and also I saw a camPos + orientation.Forward

I was also just playing around with hard-coded target positions with same direction eg 1 to 10000 with no discernible difference in what I saw in the scene.

Is the "Target" parameter actually a position or a direction (irrespective of magnitude)? Are there any subtle differences in behaviors, common mistakes or gotchas that are associated with what values you provide, or HOW you provide this paramter? Are all the methods I mentioned above equivalent? (sorry, I've only recently started and my math is still catching up)


texts: How to monitor the collisions between multiple bodies

texts:
I'm making a 2D platformer with Box2D and LibGDX, shooter, and I'm implementing the logic for a snail in the game. The basic idea is that it walks across the ground leaving a sort of, slime trail, and when the snail is not colliding with slime, it should create more. I've set it up to where it will move across the ground creating slime objects, but I'm looking for a way to detect if the snail is colliding with any slime. I have this in my World contact listener:

begin contact:

    case Finals.SLITHERIKTER_BIT | Finals.SLIME_BIT:
        ((Slitherikter) ((fixtureA.getFilterData().categoryBits ==
        Finals.SLITHERIKTER_BIT) ? fixtureA.getUserData() :
        fixtureB.getUserData())).isColidingWithSlime = true;

end contact:

    case Finals.SLITHERIKTER_BIT | Finals.SLIME_BIT:
        ((Slitherikter) ((fixtureA.getFilterData().categoryBits ==
        Finals.SLITHERIKTER_BIT) ? fixtureA.getUserData() :
        fixtureB.getUserData())).isColidingWithSlime = false;

Depending on that variable:

if(!isColidingWithSlime && body.getLinearVelocity().y == 0) slime.add(new Slime(body.getPosition().add(0, -primaryFixture.getShape().getRadius()), color));

I understand why it doesn't work, but don't know what to do, Please help.

EDIT For clarification, I should specify, that if the snail is colliding with slime, I don't' want it to make more because this works pretty well, but I"m attempting to severely limit slime production to increase performance. I only want to create new slime if there's no collision at all.


texts:
I'm learning Unity2D by trying to make a Mega Man clone. The first thing I'm trying to do is to replicate the original series physics. It differs from game to game, but I'm leaning towards something like Mega Man 3. I found this post (#3 and #8) where the game physics is described in detail and started to "translate" it to Unity. So, for instance, it says that Mega Man moves at 1.3 pixels per frame in MM3. Since I'm working with 60FPS, I multiply it by 60 and get 78 pixels per second, and use it as my character's walking speed, i.e., its horizontal velocity. Is that correct?

My real question, however, is about the following: "Rock jumps at 4.875 pixels per frame with a gravity of 0.25 pixels per frame per frame.". As I understand it, Mega Man's initial jump speed should be 4.875 pixels per frame, i.e., 292.5 pixels per second. Considering that I'm using a Rigidbody2D of mass=1, does it mean that I should use addForce(0, 292.5)? Also, how can I "translate" the 0.25 pixels per frame² gravity? My first thought would be to multiply 0.25 by 60*60 to get pixels per s², but it gives me 900 and the character does not even get off the ground. How do I convert gravity from pixels per frame² into Unity's Rigidbody2D gravity scale parameter?

Edit: this is a learning attempt, I'm not building a MM engine. So, for now, I want to understand this specific issue. I'm not new to MM gamedev and already did this before without a physics engine. I'm new to Unity and want to learn how to do it this way.


texts:
Possible Duplicate:
  How closely can a game resemble another game without legal problems

I was thinking about making a pacman clone, I know there is a similar question here Using Copyrighted Images , but I know i can't use the original art from the game because it belongs to Namco, so if I design a character that has the shape of the slice circle it will look exactly like pacman, maybe if I use green instead of yellow?
Also if the game plays like the original pacman, it is wrong?
I just want to make the game as a personal project and and publish it in my site without getting in trouble


texts: Avoiding orbiting in pursuit steering behavior

texts:
I have a missile that does pursuit behavior to track (and try and impact) its (stationary) target.

It works fine as long as you are not strafing when you launch the missile.  If you are strafing, the missile tends to orbit its target.

I fixed this by accelerating tangentially to the target first, killing the tangential component of the velocity first, then beelining for the target.

So I accelerate in -vT until vT is nearly 0.  Then accelerate in the direction of vN.

While that works, I'm looking for a more elegant solution where the missile is able to impact the target without explicitly killing the tangential component first.


texts: iPhone 3GS - can't ever seem to hold 60fps with CADisplayLink

texts:
So I've switched from NSTimer to CADisplayLink and I'm still seeing unexpected variation in my frame counter - it fluctuates between 59-60fps, even when I'm not rendering much.

Has anyone else seen this? Is this an expected variation in iOS? Or should I look more closely at my game loop?


texts: How to create a game save file format in c++ using STL

texts:
Hey so i just learned about the i/o part of the STL, more specifically fstream. Although I can now save binary info and classes i've made to the hard drive, i am not sure how to define how the info should be read.

I saw the answer for making a file format from [this][1] post:

  Typically you would define a lot of records/structures, such as
  BITMAPINFOHEADER, and specify in what order they should come, how they
  should be nestled, and you might need to write a lot of indicies and
  look-up tables. Such files consists of a number of records (maybe
  nestled), look-up tables, magic words (indicating structure begin,
  structures end, etc.) and strings in a custom-defined format.

What i want to know specifcally is how to do this with the STL and C++...
Since the format is meant simply for the use of a game i would think it would be much easier though. The format should:

Be traversable (i can look through it and find the start of structure and maybe check it's name
Be able to hold multiple classes and data in a single file
have identifiable starts and ends to sections: such as the space in text files
Maybe have it's own icon to represent it??

How do i do this in c++ ?


texts:
I've been trying to make a barebones engine/game in VS C++ with OpenGL.

So far it's worked well, I've managed to render two green triangles on the screen and can accelerate one using WASD input.

Both triangles have an "object" class from which I control their transform, could control mesh/shader, etc.

Today I tried to add an object reference to the transform component (so that I could get the Object from the Transform class, IE reference the parent from the child) and everything broke.

How are components of a "gameobject" class typically handled? Or what is a good suggestion to handle them? Is my current tactic of create object classes of the various components of my Object (gameobject) class wise? I also considered using derived class for the components, such as an abstract Component from which Transform/Mesh/Shader could inherit.

Thanks


texts: Am I liable if my game damages someone's computer?

texts:
Do i really have to tell somewhere in my game documents that "there is no warranty for this software for any damage" etc? I see it a lot in almost every program, if not all, but is it really necessary, can someone sue me if i forgot to add that line of text and their GFX card burns out when they play my graphics-intensive game? (because that has actually happened to me few times, i didnt sue anyone though).

(Someone can fix my tags, couldnt add new tags because of low score.)


texts: In XNA, what symbols are available for conditionally-compiling platform-specific code?

texts:
In XNA, what defines are set to allow me to determine if my code is running on a PC with Windows, Xbox, or Windows Phone?

Right now I am assuming it is these three:

WINDOWS_PHONE
WINDOWS
XBOX360

Are these correct? Are there any additional symbols?


texts: Why does Animator component prevent the player from facing left?

texts:
I'm making a 2D platformer with Unity. A few days ago, I was testing the game; the player could face right and left based on its moving direction and animations were playing correctly. I exited playmode because I had to assign the player position into a slot in inspector for the checkpoints. After assigning that, I entered the playmode again and surprisingly, I encountered a strange problem. The animations were working but the player was not able to face left when it was moving to the left side. I still have this problem. This is very strange to me because I didn't change anything neither from the code nor the inspector. So I believe this is a random Unity bug. After testing the game many times, I found out these:

If I disable Animator component, the player can flip again but obviously the animations won't play.
I can have both Animator and flipping working at the same time only when I check or uncheck root motion in playmode. But when I exit, the problem returns. So the previous unchecked or checked root motion will not work in the next playtest, so I can just check or uncheck it while the game is playing; otherwise it won't work.

These are the reasons why I think the Animator component prevents the player from flipping but I have no idea why this is happening because this component has nothing to do with the facing code. Thanks in advance.
This is the code I use for flipping the protagonist:
bool isFacingLeft;

void Update()
    {
        //Move the player.
        //Target velocity is defined in another script and is not important in this context.
        targetVelocity = new Vector2(Input.GetAxis("Horizontal") * maxSpeed, 0);

       //Flip the player's localScale.x if the move speed is greater than .01 or less than -.01.
       if (isFacingLeft == true)
       {
          transform.localScale = new Vector2(Mathf.Abs(transform.localScale.x) * -1, transform.localScale.y);
       }
       else
       {
          transform.localScale = new Vector2(Mathf.Abs(transform.localScale.x), transform.localScale.y);
       }

       if (targetVelocity != Vector2.zero)
          isFacingLeft = targetVelocity.x < 0 ? true : false;
    }


texts: Is there a browser game engine with options of payments?

texts: I would like to make some browser game, where you can buy stuff for real money. Is there any engine I could use? Or should I implement it by myself?


texts:
I am fond of creating graphics and animations using the frameworks on the iOS platform; lately, I discovered that, in order to create better visual designs, those higher-level of frameworks do not provide enough controls to satisfy the needs of creating more advanced-level designs. Hence, I decided to invest my time in studying OpenGL ES.

Whilst doing so, I came across the ray-tracing topic; I have spent quite a bit of time studying the mathematics and topics related to it. And, I have been able to render simple stationary objects (geometrically) using this technique.

In order to learn deeper, I started to toy around with the idea of allowing these objects to have movements based upon user-interactions (I.e., when the user moves the object on the screen with her finger, the corresponding object will spin around or simply move to the respective location based upon the user's touch (on mobile device)).

According to what I have studied thus far on ray-tracing, however, this operation of allowing the objects to move based on user-interactions could be very costly in ray-tracing. To me, for example, it would mean that, if a rendered sphere were to spin around based on user's touch on the screen, I would need to ray-trace the whole sphere for every frames as the sphere spins.

Is my understanding correct here?

My question is, is it possible to perform ray-tracing on objects that are movable; if so, is there another ray-tracing technique specialized especially for this purpose, which could be less costly? Or, is ray-tracing more suitable for rendering only architectural objects, which are usually stationary?

Thank you.


texts: How can I handle a 2d game with tens of thousands of sprites rendering at the same time?

texts: We are trying to make a small 2d game which requires an excessive amount of sprites spawning and moving around the screen at the same time. We did try doing this in python but it started choking at around the 500 mark. Are there any good ways to handle this in python?


texts: Facebook Canvas (web) Game for Desktop & Mobile Browsers

texts:
as the title suggests - I am about to develop a game for FB canvas.
Will the game support mobile and desktop or do I have to create two different project/game setups for this?

thanks