texts: Simulating circular motion with gravitational forces in Unity2D

texts:
I am currently messing around with a game where you control a black hole and use its gravity to fling planets at targets. I have the gravity calculations working pretty well when the planets start out stationary but I want to take it a step further and have the planets start out in circular orbit around the black hole.

Ideally what I want to do is place a planet, provide it with an orbital period, and have it orbit my black hole object in uniform circular motion. To do this I am following these steps:

Use the objects initial distance from the black hole (\$r\$) and the given orbital period (\$T\$) to calculate the standard gravitational parameter of the system (\$\mu\$) via the equation \$\mu = \frac{4\pi^2r^3}{T^2}\$
Find the tangential velocity of the circular motion via the equation \$v = \sqrt{\frac{\mu}{r}}\$
Assign the object an initial velocity with a magnitude of \$v\$ and a direction perpendicular to the vector between the black hole and the object
Every time the Update() function is called, apply a force to the object in the direction of the black hole that represents its gravitational pull \$F=\frac{\mu m}{r^2}\$ where \$m\$ is the mass of the object.

All of these equations came from the Wikipedia page on circular orbit.

When I do all of this I get planets that do orbit the black hole, but their orbits are elliptical and rather unstable while I want them to be perfectly circular. Here is my GravitationalForce script, which I attach to the planet object and provide the black hole object as otherBody.

public class GravitationalForce : MonoBehaviour
{
    public GameObject otherBody;

    public float orbital_period = 2;

    float grav_param;

    Rigidbody2D rigidbody2d;
    Rigidbody2D rigidbody2d_other;
    // Start is called before the first frame update
    void Start()
    {
        // get rigid bodies of this object and the object it is attracted to
        rigidbody2d = GetComponent<Rigidbody2D>();
        rigidbody2d_other = otherBody.GetComponent<Rigidbody2D>();

        // calculate the grav_param for this object
        Vector2 position_this = rigidbody2d.position;
        Vector2 position_other = rigidbody2d_other.position;

        Vector2 dist_vector = position_this - position_other;
        float dist = dist_vector.magnitude;

        grav_param = (4*Mathf.Pow(Mathf.PI, 2)*Mathf.Pow(dist, 3))/(Mathf.Pow(orbital_period, 2));

        // calculate and assign the initial velocity
        Vector2 dist_vector_rotated = new Vector2(-dist_vector.y, dist_vector.x);
        dist_vector_rotated.Normalize();

        Vector2 velocity_vector = dist_vector_rotated * (Mathf.Sqrt(grav_param/dist));

        rigidbody2d.velocity = velocity_vector;
    }

    // Update is called once per frame
    void Update()
    {
        // calculate gravitational force
        Vector2 position_this = rigidbody2d.position;
        Vector2 position_other = rigidbody2d_other.position;

        float dist = Vector2.Distance(position_this, position_other);

        float force_magnitude = (grav_param * rigidbody2d.mass)/(Mathf.Pow(dist, 2));

        float theta = Mathf.Atan2(position_other.y - position_this.y, position_other.x - position_this.x);

        Vector2 force_vector = new Vector2(force_magnitude*Mathf.Cos(theta), force_magnitude*Mathf.Sin(theta));

        rigidbody2d.AddForce(force_vector);
    }
}

Any ideas on why my orbits are unstable and elliptical instead of stable and circular? My only thought is that circular orbit is a very sensitive state and rounding errors in the physics engine or floating point number weirdness might be causing it to deviate from the circular path. If that is the problem, is there any easy fix to that and if not, what could the problem be?

Thanks!


texts: Unity engine vs JS engine for browser game

texts: I'm trying to do a browser based game and I don't want to create my own game engine, no sense in recreating the wheel.  Should I use Unity as my game engine?  Or should I focus on a more Javascript based engine like Impact since it will be a browser game?


texts: Is there a better term for a thing that hosts a game story script than "game engine?"

texts:
When I recently entered the field of game development, I actually assumed that “game engine” meant something with which you can make your game story script run in an environment where non-player characters have a state, and so you can test running your story as the bare bones of a game. A typical example of a tool for this is Chat Mapper.  This in my perspective is the core of your game, around which you build animations, sounds, etc. using say a 3D engine. A 3D engine can also be used for ends which have little to do with games. Let’s temporarily call what I mean a game-story engine.

But this does not seem the intended meaning – I guess it depends on the focus and stage of your game. Possible meanings of “game engine” seem to be:

An environment which supports creating and running a complete game; this too is quite ambiguous definition, consider Unity, http://unity3d.com/unity/engine/, Vassal http://www.vassalengine.org .
The term “game engine” is actually a shortcut for “game 2D engine” or “game 3D engine”

Now what I am asking is not to become uselessly precise with words, but just whether there is a better term used for “game-story engine” which experienced game developers use. Thanks.

P.S. And no, I’m not heading towards (nor advising to) creating “game engines” before creating games. In my startup we actually created a very simple JavaScript “game-story engine” for our browser games (it was strictly necessary) which we would like to share and am now wondering how to present it.


texts: How do I generate random mountains in a sidescroller?

texts:
So I'm trying to make a simplified Terraria style world using Perlin noise. I got that working and the terrain is randomized. However the terrain always looks like like a weird cosines curve. Hills and bottoms with different heights repeating. The effect I want to achieve is something similar to this:

Where the terrain is mostly flat looking and sometimes a large mountain will appear.

Is there an algorithm or "noise" that could achieve this effect or what other things do I need to do?


texts: Display dynamic texture image on inside of sphere

texts:
I'm displaying a ring wherever the camera 'looks'. When the camera faces the ground (green) the ring image always looks correct, see image:

However, my scene is within a sphere (purple)... and when the ring reaches the sphere it does not display correctly. See image:

This second image, the ring should be facing the camera since it's on a surface that is in front of the camera (not on the ground like the image appears).

Sorry if my images are poor representations. I basically have a flat plane which is within a sphere. The sphere has flipped normals to be able to display from within the sphere. I need the ring to "attach" or bend to the shaped of the object it is being drawn against. Any help is greatly appreciated.

EDIT: (more details). You can't raycast to a collider from within the same collider, so I'm using a raycast in the opposite direction. Code:

Ray ray = new Ray(m_Camera.position, m_Camera.forward); // get ray
Vector3 forwardVector = ray.GetPoint(100); // get a point 100 away
ray = new Ray(forwardVector, m_Camera.forward); // create new ray from this point
ray.direction = -ray.direction; // reverse ray direction
if (Physics.Raycast(ray, out hit, m_RayLength, ~m_ExclusionLayers)) {
     imageTransform.rotation = Quaternion.FromToRotation (Vector3.forward, hit.normal);
}


texts: How does heavily constrained delaunay triangulation work?

texts:
In short: I'm trying to find an algorithm for performing a Delaunay triangulation of a heavily constrained polygon (for the purpose of pathfinding), with the understanding that most of the resulting triangles will be illegal (non-Delaunay) due to the constraints. Making the effort should still help reduce generation of long/thin triangles where possible.
I'm trying to understand how constrained Delaunay triangulation works, within the context of game maps where the available ground surface for navigation and pathing is defined by a polygon on a flat 2D plane. The polygon needs to be triangulated for use in pathfinding, such that moving from point A to point B passes through as few polygons as possible (so polygons need to be as large as possible).
I first looked into regular Delaunay triangulation, and there are multiple methods available, but they all assume a point cloud where the goal is to create ideal triangles without constraints.
Then I looked into constrained Delaunay triangulation, but there is very little available I could find beyond academic papers, and many of those simply perform a regular Delaunay triangulation, then cut triangles that intersect constraints and re-triangulate around them. This seems backwards and inefficient to me when literally ALL of the triangles I want to end up with will be constrained.
I saw a GDC video, where the Starcraft 2 devs talked about using constrained Delaunay triangulation, and you can kind of see it when you look at the pathing mesh in the Starcraft 2 editor (see below). However, very few of the generated triangles are legal, due to the number of constraints in the map layout. Still, I am assuming the Delaunay algorithm influenced the selection of points to triangulate, in order to get the best triangle coverage.
However, I can't find any further info on how this might work. How does one start with constraints, points connected by fixed lines, and then "fill in" the remaining lines to generate triangles that are a best-effort attempt to not be overly stretched or narrow?
Edit: Screenshot example from Starcraft 2 editor:


texts:
today I scheduled the publication of a video on Kickstarter requesting approximately $5,000 in order to complete the iPhone shooter game I started 1 year ago after quitting my job.

I invested more than $20,000 in the game so far (for artwork, music, legal and accountant expenses) and I am now getting cold feet about my decision of publishing the video.

The game is "nearly finished", in other words: the game mechanics are working but I still have some bugs to fix. Once I will have finished this (I hope will take me 1 or 2 weeks) I plan to start working on the actual level balancing (e.g. deciding the order of appearance of enemies for each level and balancing the number of hitpoints and strength of bullets that the enemies have).

Reasons for not publishing the video are:

fear that the concept can be copied easily: the game is a shooter game set in a different environment (its a
pretty cool one, believe me :)) and I am worried that someone might
copy* the idea (I know, its the usual "I am worried story.."). A shooter game is one of the easiest game to implement and hence there will be hundreds game developer able to copy it by just adapting their existing code and changing graphics (not as straightforward).

It took me one year to develop this because I was inexperienced plus there are approximately 6/7 months of work from the illustrator and there are 8 unique music tracks composed.
The soundtrack of the video is the soundtrack of the game which is not
yet published and has not been deposited to a music society. I did
create legally valid time-stamps for the tracks and I am considering
uploading the album on iTunes before publishing the video so I can
have a certain publication date. But overall I am a bit scared and worried because I have never done this before and even the simple act of publishing an album requires me to read a long contract from the "aggregator company") which, even if I do have contracts with the musicians do worry me as I am not a U.S. resident and I am not familiar with the U.S. law system

Reasons for publishing the video are:

I almost run out of money (but this is not a real reason as I should have enough for one more
month of development time)
...I kind of need extra money as, even if I do have money for 1 month of development I do not have money for marketing and for other expenses (e.g. accountant)
It will create a fan base
I could get some useful feedback from a wider range of beta testers
It might create some pre-release buzz in case some blogger or game
magazine likes the concept

Anyone has had similar experiences? Is there a real risk that someone will copy the concept and implement it in a couple of months? Will the Kickstarter campaign be a good pre-release exposure for the game? Any references of similar projects/situations? Is it realistic that someone like ROVIO will copy the idea straight away?


texts: Libgdx detect touch on a specific object (while moving)

texts:
I have a class (I'll call it with letter "A") and class B.

A is the object (as a character) and B is the rendering class which have the aim to show A.

I am looking for a way to detect when A is pressed, with normal InputProcessor I can't because it detect touch in the entire screen, I only want detect touch over the object. If I check touch position and "A" position it doesn't work because the object is moving and the values aren't so precise

How to solve?

this didn't solve for me :Efficient way of detecting a touched object in a game?. Here is explained "what to do" and not "how to do"


texts: Feasability of mobile 2D multiplayer RPG game with interactive bitmap background

texts:
I'm looking to develop a 2D multiplayer RPG game for Android, with a bird's eye view similar to that of zelda/pokemon. The game is very simple in all ways since my intent is for thousands of players to occupy the same world which I imagine requires good performance. However, I am unsure about the performance requirements of two properties:

the tile map that is used as a background is dynamic (interactive). For example, a player steps in the water, and the water turns black. Every tile in the game does this.
the tile map is the same object used for all players, but it is displayed differently on each user's mobile device, even though the players exist in the same world. For example, the water that turned black is displayed as red on all other players' screens.

I have knowledge of java, but almost none regarding game dev. tools. Is there a best process for these requirements? Should I develop in pure java, or use some tool like Slick2D etc.? How performance intensive are these properties, if even possible?

Edit: There are no collisions in the game or difficult animations, I am imagining simply changing the colors of the tiles (like in the examples), and a client-server architecture


texts: Make an arrow to point at a direction from UI

texts:
I want to have a guiding arrow on the left side of UI. The arrow is child of the player's camera and it's rendered from another camera into render texture. The render texture is displayed on the screen. The arrow is rotated via transform.LookAt(targetPosition) The problem I'm having is that although it does point in the right direction, form player's point of view it looks like the arrow is pointing somewhere else.

I want that arrow to point from the point where it's placed on the UI. It should look something like this:

I tried to do this:
  Vector3 direction = targetPosition - _arrowRawImage.rectTransform.position;
_transform.LookAt(direction);
but it didn't work.


texts: Designing RPG player classes, and the trend to avoid a Priest or Cleric RPG class

texts:
From my experience, RPG classes ("hero" or "villain" types) are often divided into four categories:
 1. Mage
 2. Priest
 3. Rogue
 4. Warrior

However, there are quite a few popular RPGs that ignore the Priest or Cleric "base" character class entirely.  Two game series of note: The Elder Scrolls (Skyrim), and Dragon Age.

Is there a specific reason why this is so?  Perhaps the background story makes allowing players to be a Cleric difficult; for example, if there is a large amount of NPCs in the game that have the adventure class of Cleric, and making that class available to players would be detrimental to the story of the game.

I've pondered this quandary myself when working on developing my own video RPG; should the character class options be sub-categorized with the aforementioned base classes?  Or perhaps even more difficult of a question to answer, should a video RPG include some kind of Deity system?

The RPG approach to "gods" is difficult for me, particularly because I've have somewhat of a spiritual perspective on real life, I'm not sure how to reconcile my choices with game design to my choices regarding spirituality.

Any helpful responses will be greatly appreciated!


texts: How can I implement a revealing light beam?

texts:
In SEARCHLIGHT, you control a ray of light that illuminates incoming enemies that are otherwise invisible in the night sky. Here is an illustration:

How would I go about doing this, preferably in Unity? I imagine this is less about lighting and more about shaders, but I'm not sure on details. The fact that I know very little about coding shaders makes it worse.

If it is about shaders, what are the specifics? Is there a stretched quad that moves with said shader applied to it, or perhaps is using the Line Renderer a better option?

As a beginner, may I try to achieve a similar effect, or should I leave it for when I'm better?

(P.S.: The game was made in Unity. Here is its itch.io page.)


texts: How to make proper animations for a html5 game?

texts:
I am working on a web based MMORPG in html5.

Therefore, I think about using Phaser.io to be the main engine of the game on the client side.

I want the game to be isometric and I am wondering how to make proper sprites/animations/gfx for the game.

I don't want my graphic team to have too much pain.
Would it be possible, for example, to use any kind of "vectorial spritesheet" so that I can zoom in and have a better look at the character.

On the other hand, I don't want the "stuff" (hat, armor, etc) to be too hard to "plug" on the character in all the different orientations.

I thought about using some kind of flash like system (my game is based on the french MMO Dofus which only uses flash for its client side but no web based techno)

But I don't know anything about flash, can I integrate it inside a canvas and does it mux well with raster images like png or jpg?

What alternative could I use?


texts:
I am currently trying to rotate the weapons of a spaceship towards the mouse position, but in order to avoid the collision of projectiles with the ship I want to limit the angle the weapon can turn.

I've tried doing this:

    Vector3 mousePos = Input.mousePosition;
    float range = 100.0f;
    float rotStep = 0.1f;

    Vector3 positionOnScreen = Camera.main.ScreenToWorldPoint(mousePos + Vector3.forward * range);

    Vector3 targetDir = positionOnScreen - transform.position;
    Vector3 newDir = Vector3.RotateTowards(transform.forward, targetDir, rotStep * Time.deltaTime, 0.0f);

    Quaternion lookRot = Quaternion.LookRotation(newDir);

    float xAngle = lookRot.eulerAngles.x;
    if (xAngle > 10 && xAngle <= 180)
    {
        xAngle = 10;
    }
    else if (xAngle < 350 && xAngle > 180)
    {
        xAngle = 350;
    }

    float yAngle = lookRot.eulerAngles.y;
    if (yAngle > 10 && yAngle <= 180)
    {
        yAngle = 10;
    }
    else if (yAngle < 350 && yAngle > 180)
    {
        yAngle = 350;
    }

    float zAngle = lookRot.eulerAngles.z;
    if (zAngle > 10 && zAngle <= 180)
    {
        zAngle = 10;
    }
    else if (zAngle < 350 && zAngle > 180)
    {
        zAngle = 350;
    }

    lookRot.eulerAngles =new Vector3(xAngle, yAngle, zAngle);
    transform.rotation = lookRot;

The problem here is that I don't know how to limit the rotation angle since it's not the same depending on the ship rotation (for example if it's (0, 0 , 0) or (-90, -90, -90)). I've tried using transform.localRotation too, but still happens the same.
Do you how could I limit the rotation regardless of the ship rotation?


texts: Where can I find a basic algorithm for parsing tiled maps?

texts:
I have attempted to use Tiled for creating 2d maps, and saving them under a text file. The resulting text file seems difficult to parse at first, I gave it a shot here however to no good result.

I have been wondering if anyone has a basic tiled map parsing algorithm. I have searched for a possible algorithm but to no avail so far.


texts: Why is FindObjectOfType(MyType) not finding anything?

texts:
Why would I get the following log?

Start OpponentMotionReceiver
motion receiver not found
true

    public class ScoreAnimation : MonoBehaviour
    {
        private OpponentMotionReceiver cachedObject;

        private void Start()
        {
            cachedObject = FindObjectOfType<OpponentMotionReceiver>();
        }

        private void OnDestroy()
        {
                var motionReceiver = FindObjectOfType<OpponentMotionReceiver>();

                if (motionReceiver == null)
                {
                    Debug.Log("motion receiver not found");
                }

                if(cachedObject != null)
                {
                    //prints true, another proof that the gameObject is active
                    Debug.Log(cachedObject.gameObject.activeInHierarchy);
                }
        }
    }

public class OpponentMotionReceiver : MonoBehaviour
    {
        private void Start()
        {
            Debug.Log("Start OpponentMotionReceiver");
        }

        private void OnDisable()
        {
            //never enters
            Debug.Log("OnDisable OpponentMotionReceiver");
        }

        private void OnDestroy()
        {
            //never enters
            Debug.Log("OnDestroy OpponentMotionReceiver");
        }
    }

P.S. This is extremely simplified version of the code so that the rest brings no confusion. If you need more details, I'd be pleased to answer you!


texts: Spatial Hashing is set up.. now how should I go about actual collision logic?

texts:
So I have a spatial hashing system set up and it works. It puts players in buckets based on their x/y/width/height

So I was going to check collisions on each frame when I loop through the entity for updating their physics. But how would I go about duplicate collisions? Say I'm checking for player a, which is in the same bucket as bullet a.. I check if there's a collision and there is, should I do the collision logic right there? Or should I add the collision to a list and iterate through that list at the end of the frame to handle the logic for each collision? This way I can also apply logic to prevent duplicate collisions. Or should I just do all the logic right there and then when the initial collision is made?


texts:
I need to work with a Rect that has Left, Top, Bottom, Right.

Unity's Rect has x, y, width and height instead.

Also, Unity's Rect doesn't accept Rect.Compare(otherRect).

System.Windows.Rect however seems a good choice for my needs.

I would like to ask if it's ok to use System.Windows.Rect in my Unity script and if it will be cross-platform.


texts: 2D Rotation of an object along a curve line

texts:
I would like to rotate an object along a curve. I managed to move the object along the curve using bezier curve algorithm. The hard part is to rotate the object constantly(no limit on maximum angle), and have to land at the end position. The angle have to be multiply of 360 when it land on the end position. A good example would be Maplestory, the item is dropped when a monster is killed. The item is rotated constantly and it will always landed at the correct angle.
Start position and End position will be provided, as is used by the bezier curve algorithm, is there any algorithm for the rotation part?


texts: GraphicsAdapter.Adapters on openGL won`t return secondary monitor

texts:
I have been searching for this everywhere and never found the answer.

I am developing a feature to allow the user to select which monitor to run the game.

I have two monitors, primary and secondary. I tried to use "GraphicsAdapter.Adapters" but it always retrieves only 1 monitor (the one I am running the Visual Studio which is the default one).

Is this a bug?
How can I retrieve all the monitors available?

Thanks

MONOGAME 3.6 OPENGL (cross platform)
Visual Studio 2015
Windows 10 Pro 64bits


texts: What is the standard procedure for importing animations in Unity?

texts:
I need some info about importing game objects from Maya to Unity. I am making 2D Tower Defense game, I have made some basic functionality using dummy objects (cubes and spheres). Now I want to replace these dummies with objects made in Maya. The basic objects for gameplay would include walk of enemy and tower rotation towards it.

So what is the standard procedure of my query, would I need a running enemy object animated in Maya, replace it with my dummy objects, or something like multiple still images of enemy and tower movement, combined in Unity?


texts: Exporting Fbx from maya to Unity makes the model deformed

texts: So I have a female avatar model and I have attached cloth model to it by binding it to skeleton rig. After that copying weights from avatar to the cloth model. Now when i export it as an fbx and open it in unity, it converts the whole model into a deformed shape. I have removed the errors related to scale compensation as well by running the (ScaleCompenstationOff ) mel script in Maya but still no success. Kindly let me know if you guys know of any solution to this problem !!!


texts: Ive tried using a timer in the render method but that just crashes my game, so how do I change screens after a certain amount of time after rendering.


texts: I'm wondering about these two things. for what is better to use Bool rather than Trigger ? If i'm going to use Trigger, I should use it for what ?


texts: How to pause audio playback when a breakpoint is hit or resume afterward?

texts:
When my code hits a breakpoint, audio that was previously started (via an AudioSource) continues to play while the threads are paused.
I'm using a coroutine to query the status of the AudioSource, and update my UI. Because the audio continues to play, then after I've spend some time stepping through code the next frame tick when Unity gets control back runs the next iteration of this coroutine, which updates the UI. I never get to see the in-between states.
Because it's a relativley short audio clip it's usually finished playing before I've finished stepping through the code.
I'm using Unity 2018.4 with VSCode and the Debugger for Unity extension, if that helps.
I'm quite lost at what to try here. Looking for issues with Unity's AudioSource and breakpoints yields a lot of varied information about audio issues in general in Unity.
I've tried using Debug.Break(). It pauses the Unity editor, which can be useful but has the following caveats:

it requires extra effort on each breakpoint that requires enabling (if the call is not there already)
it requires manual intervention to resume the editor once you've finished stepping through code
because it is code, it cannot be added after Unity is playing, e.g. to additional breakpoints that are added once debugging has started

Does Unity have a mechanism that enables this behaviour that I've just missed? If not, what's an appropriate alternative approach?


texts: How to get a point to the left/right of a vector

texts:
I have a position vector of a point in space and a quaternion for it's rotation. What i'm trying to calculate is a point too the left and a point to the right.

I have the position and rotation(quaternion) of the red dot. What I want is to get the position of the green dots. I have a float value for the distance I want these points to be.

With only the position and rotation is it possible to get a unit direction vector pointing left/right which I can multiply by my float value?

Edit: I also know the original direction vector.


texts: Can a scrub design/develop a strong competitive fighter?

texts:
The definition of Scrub in this question comes from David Sirlin's famous article, Playing To Win

I am a fan of fighters, and I am fairly well versed in design (I get my daily dose of gamasutra). However, I am also a MASSIVE Scrub. I don't like using tactics/characters that I feel lessen the experience or go against the spirit of the game (for example, Street Fighter's roll-cancel glitch, MVC2's infinite combos, Cable, etc).

I will practice and get good at using those tactics/characters, so that I can better defend against them, but I'd never use them against another player.

My question is, can someone like me design/develop a strong competitive title, or does my outlook prevent me being able to appreciate elements of design that are a necessity for developing a competitive scene?

My question is, are such elements necessary in creating a competitive fighter? What are the "gotchas" a scrub would by hindered by when designing/developing a competitive fighter?


texts: Why use sprite tile maps on the GPU in WebGL?

texts:
I'm trying to figure out the best way of rendering my layered tiled maps with WebGL, and have come across this tutorial several times: https://blog.tojicode.com/2012/07/sprite-tile-maps-on-gpu.html
Someone even created a library for it here: https://github.com/englercj/gl-tiled
The gist of this "GPU abuse" seems to be generate a texture where each pixel as a lookup table into the tileset spritesheet. That is, the red component refers to the x coordinate and the green component refers to the y coordinate. Additionally, in the library, the blue component refers to the corresponding tileset to use.
This seems to accomplish exactly what I am attempting to do, but I am confused on two parts.
For one, the author describes this is a neat little trick and "GPU abuse". I feel as if the implication there is, "this is a fun little exercise, but don't actually use this for your game or any serious code."
Is this the case, or is this actually a potentially serious technique that I could use to power my map rendering?
Secondly, I'm somewhat confused why this is even necessary. I am still learning WebGL, so I might mess up a few terms here, but couldn't this same exact thing be accomplished in a more straight-forward manner? Why go through all these steps of creating a custom generated texture of your map, when you can just create a (static?) Vertex Buffer Object, load it with all your tiles, and then just render them?
I'm not really understanding what exactly this technique buys as that can't be accomplished in the same way by just creating a large buffer that just contains all our tile data, and then just rendering it like that. Isn't that conceptually simpler, arguably easier to implement, more straight-forward, and doesn't have weird restrictions like maximum tile count or width?
Basically, I'm having trouble understanding what advantages this has over traditional rendering where you just load up a buffer with tiles. If there are some advantages, should this technique be seriously used in a game?


texts: Are there some methodologies to define a game's rules?

texts:
I would like to write some rules for a game I have in head but I don't know how to do that.
So are there some methodologies or modeling tools (like UML) to do that? I'm thinking about a kind of tree of competencies or some kind of map to be sure that the game is well balanced.

I always wonder how the team who imagines some powers in magic the gathering for example does it. Do they have some diagrams to be sure the powers or creatures they imagine are well balanced for the entire game?

I'm pretty noob in the game creation so I'll be happy with some directions to seek.. Technical terms or basic principles to learn.

Thanks for help.


texts: How to make unit selection circles merge?

texts:
I would like to know how to make this effect of merged circle selection. Here are images to illustrate:

Basically I'm looking for this effect:

How the merge effect of the circles can be achieved ? I didn't found any explanation concerning this effect. I know that to project those texture I can develop a decal system but I don't know how to create the merging effect.

If possible, I'm looking for purely shaders solution.


texts: Find closest point from an origin, in a mesh

texts:
I want to do something similar to a raycast. With a raycast, you can set an origin and a destiny, and check where the ray collides with something but only with a line. What I want to do, is given an origin with x, y and z coordinates, check which is the closest point it collides in a mesh. so if I have a box in 0, 0, 0 with width 2, and my origin is on 0, 0.5, 0, the algorithm/function should return that the closest point it collides is 0, 1, 0. I hope I am clear enough.

I am using Ogre3D, and bullet physics. I can also use OpenGL.

Thanks.


texts:
I'm wondering how to test my client server game or how to test games in general.
Currently I'm able to run unit tests using  https://github.com/TomGrill/gdx-testing but I thing most of the critical parts in my game are the interactions of a of different ECS systems.
So I thing the best approach would be using a smoke tests-system (aka Build Verification Testing). But I'm not sure and I have no idea how to realize something like that.
There is an article from Riot Games about how they will do testing in LOL-Game. They will use RPC calls to control the game.
Is this the way how to implement smoke-tests for network-games in libgdx?


texts: How to access Lit shader properties through code?

texts:
Currently i'm using HDRP in my project, so i have a question.
How can i access Lit shader properties through code ? Or where i can see names of variables in this shader ?

For example:


texts:
Is there a way, in OpenGL, to switch off the automatic perspective divide?
I'd like to see the effect a perspective projection has by itself.


texts: How to obtain "annealing" effect via particle system

texts:
In this video demonstration, there is the annealing effect, where particles seems to loose their hue and converge into pure white, and then gradually disappear via alpha channel. And in parallel to all of this: particles are gradually becoming thicker.

I tried with my particle system and it is giving different results. How to obtain the "annealing"?


texts: Why does my mesh move when i add an avatar?

texts:
I've imported a wall model into my scene, it snaps to the other walls fine until I add an avatar to the model to animate it, then it moves.
here's some picture to explain:
The first picture in the scene:

This picture is in the game:


texts: Is it possible to load local html pages into Gamemaker games?

texts:
I was just wondering if it would be possible somehow to load locally saved web pages into a game. My primary use for them would be as menus, helping to navigate between rooms.

I know about the built in "Open URL" function but I want to know if the loaded page can interact with the actual game.


texts: What is the utility of squared radius and inverse squared radius for lighting computations?

texts:
On one of the slides from "DirectX 11 Rendering in Battlefield 3" PowerPoint I noticed the folowing code:

struct Light {
    float3 pos; float sqrRadius;
    float3 color; float invSqrRadius;
}

I don't understand why would they store the squared radius and even the inverse squared (which I believe is simply 1-squared radius) instead of simply storing the radius? How are they using this data in their computations? Moreover, what about cone and line lights? This struct must be only for the point lights, I can't see it working for other types - there is not enought data. Still I would love to know how they use that square and invSquare.

UPDATE: Ok I finally got it.

Here is the classic light attenuation equation, easily found on the net:

float3 lightVector = lightPosition - surfacePosition;

float attenuation = saturate(1 - length(lightVector)/lightRadius);

It is relatively costly as length(lightVector) is actually doing this:

length(lightVector) = sqrt(dot(lightVector, lightVector);

moreover division operation (/lightRadius) is also quite costly.

Instead of computing light attenuation this way, you can compute it the following way, which would be much faster:

attenuation = saturate(1 - dot(lightVector, lightVector)*invRadiusSqr);

where invRadiusSqr can be pre-computed at CPU level and passed as a shader constant.

Moreover, you get a quadratic light attenuation as a result (instead of linear in the former case), which is even better, as IRL light has shown to have quadratic falloff.

Thanks everyone for your help!


texts: Performance optimization when changing Textures LibGDX

texts:
In the main Screen class of my game there is a ListArray<Card> which makes up the deck of cards . The Card's texture is set in the constructor  like so :
cardTexture = new Texture(Gdx.files.internal("backface.png"));
and in the Card class there are 2 methods to show and hide the "CardFace"
public void hideCardFace() {
    cardTexture = new Texture(Gdx.files.internal("backface.png"));
}
public void showCardFace() {
    cardTexture = new Texture(("CardTextures/" + this.getFace() + this.getSuit() + ".png"));
}

(in the android\assets\CardTextures there are 52 .png files with a size of 500x726 and rangeing in filesize from 20-220 kb)
The problem is that when I have to show or hide the "CardFace" for the entire ArrayList like so :
for (int i = 0; i < deck.size(); i++) {
    ((Card) deck.get(i)).hideCardFace();
}

I experience a performance drop both on PC and Android to the point where the Game lags for 1-2 seconds until all the CardFaces are hidden or showed.(I did multiple tests and the FPS dips only when I call the 2 methods)
Is there any other way (better for performance) to change the CardFace?


texts: The physics equation for a perpetual seesaw

texts:
I am trying to create a game that involves two or more people jumping on a seesaw and propelling each other in the air. I need help with the physics equations

Assume no friction and no air resistance for now.  Ideally when you hit the sweet spot of the seesaw at the very end person B should go a little bit higher than person A who just came down.  Also, if you hit close to the pivot, then the reverse should happen (I don't know if that is really physics but that is what I am going for).

I know the classic example of two forces on each side and t = r x F so if you had a mass heavier on one side that heavier mass would have to be closer to the pivot.

What I am not grasping is if
F=ma, and assuming that the masses are all equal then F=a.  Now gravity is 9.8/m/s/s on both objects.  Is this true even if one of them is at rest on the ground so the seesaw is tilted up?

So because force is not related to velocity the following doesn't make sense:

I would have thought dropping an object from 10 meters would have created more F then from 5 meters if they hit the same spot and have the same mass. So while the velocity increases the acceleration is constant isn't the force constant?

What am I not grasping?


texts: Should I get a game focused programming degree or a computer science one?

texts:
Possible Duplicate:
  Game Development Degree vs Computer Science Degree

Heres the best education I got in ky math is AP Calculus and no technology class that teaches a programming language. So should I just go get a Computer Science degree or a game programming-based one? Might not be a lot; ask if you need more info to decide.


texts: How to make physics of motion on an inclined surface

texts:
There is the following platform:

And a coin above it:

And the following code using arcade physics:

gravity: { y: 100, x: 10 }, - in config

function preload ()
{
this.load.image('platform', 'assets/platform.png');
this.load.image('star', 'assets/star.png');
}

function create ()
{
platforms = this.physics.add.staticGroup();

platforms.create(400, 568, 'platform');

player = this.physics.add.sprite(100, 450, 'star');

player.setCollideWorldBounds(true);
}

The code is approximate, a coin above the platform, sprites in png format. But the coin falls and does not roll, but moves horizontally, after which it falls again. How to make it "roll"?

UPD: Will it help me? https://github.com/photonstorm/phaser-examples/blob/master/examples/arcade%20physics/circle%20body.js
And how to be with the platform?


texts:
I'm interested in adding to my game either recorded human or synthesized speech. I'm interested in what game devs have to say regarding the value of recorded human voice over voice synthesis. Thanks in advance!

Points to consider:

EDIT: First and foremost, the game is meant for kids (i.e. when you see an image of an apple, a voice says "a is for apple") - here it is on Appbrain (currently sans audio...)
I searched the responses for Is it worthwhile recording your own or buying stock sound effects? - I'm basically wondering the same thing but for voice-specific audio.
Do you find value or any benefit in opting for recorded human voice?
What are some good voice synthesis or text-to-speech tools (preferably free)? I'm currently trying out Fruity Loops, which seems to get the job done (I input a phrase and it generates synthesized speech) however some words do not sound as realistic/convincing as others.
The platform is Android (i.e. memory constraints).


texts: Creating multiple levels in Unity without duplicating scripts

texts:
I'm trying to create a falling word typing game like z-type.

I have used the code provided here

I want to create multiple levels in the game, and it seems like I need to make some changes in the code for each level.

For example, in the word display file, I want the active word to be changed to red for level 1 and blue for level 2.

So I created a copy of my level 1 scene, created a duplicate WordDisplay script file, changed the code for active word to blue....

public class WordDisplay : MonoBehaviour {
    public Text text;
    public float fallSpeed = 1f;

    public void SetWord (string word)
    {
        text.text = word;
    }

    public void RemoveLetter ()
    {
        text.text = text.text.Remove(0, 1);
        text.color = Color.red;
    }
    //...

Here's the duplicate script I made:

public class WordDisplay1 : MonoBehaviour {
    public Text text;
    public float fallSpeed = 1f;

    public void SetWord (string word)
    {
        text.text = word;
    }

    public void RemoveLetter ()
    {
        text.text = text.text.Remove(0, 1);
        text.color = Color.blue;
    }
    //...

Then I made a copy of the WordSpawner as well because I was getting an error: I had to change the method's return type to to WordDisplay1 and then got one more error which was in the Word file, leading to more changes...

public class WordSpawner : MonoBehaviour {
    public GameObject wordPrefab;
    public Transform wordCanvas;

    public WordDisplay SpawnWord()
    {
        //...

public class WordSpawner1 : MonoBehaviour {
    public GameObject wordPrefab;
    public Transform wordCanvas;

    public WordDisplay1 SpawnWord1()
    {
        //...

Then I created a duplicate of the word prefab and selected the appropriate word spawner file...

All of this seems like too many changes for a simple colour.

Is there a better way to have multiple levels without having to create a duplicate of all these files and the word prefab?


texts: How should I send large amounts of data from java to c++ (within the same process)

texts:
I'm writing a game that is mostly in Java (because that's the language I'm most comfortable with) while the graphics are in C++ (because of speed, and because the Vulkan API is hard enough to learn when I'm not using a third-party language binding). I start a thread in Java and have it create a Swing window, it then runs a native method that takes the HWND handle from the window and some other information as parameters. Once in native code it binds the window to a Vulkan surface and from their the graphics engine is it's own independent thread, if possible I don't want to make any more JNI calls (performance concerns).

My issue is, I handle server-client connectivity on the Java end, and my server is responsible for sending the client models and textures when the player needs them. The obvious solution would be to pass these textures and models over JNI so that the graphics engine can  make use of them but I'd REALLY like to not do that.

I've considered using memory mapped files but that would require using boost since there otherwise isn't a cross-platform mmap library, and it also seemed silly to me that I'd get the data over the network, it'd then be stored in RAM, and then I'd allocate it a different area of RAM so that it can be accessed in native.

Other than JNI and memory mapping I, with my limited experience, cannot think of any other possible solution to this problem and am hoping to find some suggestions or perhaps some inspiration. This question isn't strictly related to game development and I considered asking it over at Stackoverflow but their community is really doo doo.


texts: Can a texture's UV coordinates be animated (scrolled) when part of a SpriteSheet?

texts:
Alright so my question is about texture manipulation in Flash Stage3D / Context3D using AGAL for the shader language. But I'm pretty sure this could be applicable in other situations involving GPU programming.

So the goal is, if I wish to have a "scrolling" animation on a certain tile (like a tile of water), can I still have that texture packed along with all the rest of my sprite assets? Or does it have to be alone to avoid bleeding nearby assets?

From what I can understand, when the FragmentShader samples the portion of the texture offsetted during a scroll animation, any coordinates outside the desired texture will reveal incorrect nearby textures.

Some example to clarify:

Fluid motion (lava, water waves, acid bubbles);
Background motion (cloud, trees, houses);
Directional indicators (lines on a conveyor belt, race-circuit dash regions);

Do I need to use some extra operations to wrap the texture if it tries to sample beyond a certain point? How could those constraints be defined / transferred to the FragmentShader?

- UPDATE -

To clarify, I would like to scroll only on 1 single tile that would be part of a SpriteSheet / TextureAtlas (meaning, mixed with other existing sprites part of a game / project).

Imagine you had something like this (but better artwork, of course):

So a 256 x 256 Texture with a "Wavy Water" tile in the top-left corner (128 x 128 in dimensions).

How would you write a shader that can scroll through ONLY the water portion to give a sense of motion without running over the adjacent textures (ex: faces and cars).

How would you handle situations where the Quad is much larger than the texture and could repeat many times as well in combination to being able to scroll it?


texts: How to structure (the code in) a multiplayer game

texts:
I'm working on a rather small project where we will be developing a small engine, a client, a server and an editor of some kind. It's a component-based 3D engine with basic systems like Rendering, Simple-Physics, etc.

So far, after a fair amount of thought I've decided to structure the engine as a library. It'll contain the classes for all of the components and the sub-systems, but will not run them. Instead it will be included into another project that will initialize the engine and run the game loop. I've started calling that second project the "host application."

I see the host application as the "game" or the "editor" with the engine kind of looking like a strap-on jetpack of goodies.

The reason for this (in my mind) is to allow the engine to be reusable, and so I can develop our editor, game, model viewer, etc. using the engine without having duplicate code every which way.

This is all working out well thus far, however when considering the typical client/server model for a multiplayer game a few questions come up.

In one respect I can treat the client and server as separate projects, both referring to the engine, in the other respect I could develop the client and server as one project with a bunch of switches and a command-line argument to denote which "mode" the game should be in.

Could one of you insightful awesome people shed some light on the pro's and con's of these methods, or perhaps suggest a better way?


texts:
I'm using an opengl es based framework to create my game.I have an out of memory problem on some devices.I have 15 textures with a size 1024x1024(totally 10 mb).On memory they covers a lot of space.Some devices are exiting from game on loading time

I want to reduce memory use and how can i do that?Maybe a solution when i loading bitmaps into memory will be great.That's my texture class:Texture.java


texts:
Goal

I would like to be able to separate all my data file readers from the main thread and balance the load over multiple frames. The idea being that while the data is being read/parsed/filtered I can continue playing the game at a decent FPS and show a loading progress bar while the results of the file importing pop in one at a time when they are ready.

Information

The data files contain things like transform information for objects, points to be used in runtime mesh generation, and terrain data. They all have to be parsed, filtered, and/or modified to be ready to be used in the scene.

I already have import code for the project I just need to transplant it from blocking my main thread and being done in one frame to a multi-threaded and multi-frame approach.

Thoughts

I have little experience in multi-threading so this is also a learning project for me. I would appreciate all your comments, input, code samples, and pointers.

From my perspective I need to create a queue of tasks. Each task being a file to load, read, parse, and filter. Then if a CPU is open a task is taken from the queue and is given a thread to be executed on that CPU. The task completes and gives the resulting data back to Unity3D for it to handle.

Questions

Does a heavy load on other CPUs freeze the game like it would if it were on the main thread, and thus require some sort of system where you yield for one frame if execution time is taking too long?
How do I receive progress updates from the tasks to be used in a interface progress bar via some sort of co-routine?
If a user only has one CPU how would this system handle the situation? Is that even a realistic scenario?
What sort of C# classes (usable in Mono's subset of the .NET runtime) already exist for multi-threading and task queuing that can save me time?


texts: Do you know any 3D engines written in Objective-C for iOS?

texts:
In the next few weeks I will start a game for iOS, most of the action will happen in 2D but a 2D engine is not enough for our idea, therefore I'm doing a small research on available 3D engines for iOS written in Objective-C (we already looked on some engines written in C++).

Do you know 3D engines written in Objective-C?

I found this one http://nineveh.gl/ but is not yet ready :(.

later edit (1).......
I did a research on the engines written in C++, they are nice and probably I will go with one of them, but if there is any good engine written in Objective-C, than I will go with it, because its a matter of taste and I like very much the obj-c language.

later edit (2).......
nice presentation/teaser about what I'm looking for http://www.slideshare.net/rsebbe/designing-an-objectivec-framework-about-3d


texts:
I have set up all the config files to my game classes and am able to launch the game to test everything.

Although when I package the game, it still runs the UT deathmatch game??

What other lines in the config files should be changed to make it default to my game and default map once published?


texts:
I just got Python 3.5 from...
LINK: https://www.python.org/downloads/windows/

previously i had Python 3.4 and the Pygame version 1.9.2a0. It worked perfectly. However, my the new Python 3.5 isn't compatible with that version of Pygame that i had gotten for the 3.4. I Found the latest Pygame file at...
LINK: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

I downloaded the Pygame file, however, it is a .whl format file. What am i supposed to do?

I have tried looking it up all day yesterday. So far all i've figured out is something about pip and wheel and doing some commands like 'pip install' etc. etc. but i am completely lost. I never knew about pip or any of that before.

I am not even sure if there is a version of Pygame that works with Python 3.5, but i did try to find out by looking it up but i never found such information. All i want is to get Python 3.5 up and running with Pygame and for it to work just as fine as it used to when i had Python 3.4. If Pygame is yet to be compatible with Python 3.5 thats fine, i'll just reinstall python 3.4 and the according pygame file for it.


texts: I'm new to game development. What is a good algorithm to model the random flight of a fly? I've been looking at path-finding algorithms, but they don't give any interesting random behaviour.


texts: Event-driven vs state synchronizing networking model

texts:
I was going through the Tribes network model and the network model used in Quake3. What I understand is that Tribes is more of an event based model where as the Quake model uses game states and delta game states to sync clients. Is my understanding right?

What kind of games do these models favor? Also what are the drawbacks of one model compared to the other. I am currently developing a two player First Person maze solver game and trying to choose between the two models.


texts:
I'm trying to build an old game (Lander) where you try to land a spaceship on a flat platform.

But I have no idea how to generate a random surface. Something like in the picture would be nice.

Edit: I don't need a map generation like in Civilisation. I need a surface like hills and valleys.

I'm using QT but I think it's more a meta question than a framework question.
Thanks!


texts: How to avoid player base schisms created by levelling gaps in MMO games?

texts:
In WoW, players are split into strata (Pvp Tiers) 10-20 / 20-30 / 40-50 / 50-60...

This causes the playerbase to split. It creates a rift, players of uneven levels cannot be matched together for gameplay purposes. For example a lvl 1 player would suicide (1shotted) if he dares to attack an AFK druid from his thorn buff (30 min duration) before the autoattack lands.

Another game suffering from same issue is Clash Royale. If players power creep with additional level cap increases. And when more players reach the top strata, the other strata will become isolated.

Example: Low strata 0.1% playerbase. Top stratum 99.9% playerbase.

Matchmaker Constant Bickering: I was matched with a player N levels above me. This is unfair.

If the game was designed today from start, how would game design solve the issue before it ever began.
Is it possible to create "Power gaps" in player base, without splitting it?


texts: How can I go about testing games on a console

texts: I was wondering how I could play a game I've made on a console (PS3). I don't want to sell it or anything I just want to test it for now, also do I still have to do that whole registration thing to do this? Oh, I'm also using Unreal Engine 4 for this.


texts: GLSL Shader Solution for Ambient Occlusion?

texts: For the iOS app I am writing I want to incorporate some aspects of ambient occlusion for photo manipulation. Can someone suggest a GLSL approach that will work. Realtime performance is not super critical. Under a second compute time is fine.


texts: Calculate resources real-time. Sockets or not?

texts:
I'm currenly developing a game in Javascript. It's a Single Page Application so every change should be pulled from the server without page refresh. I'm currently wondering how I should handle the 'resources in stock' (like wood, food and gold).

I know there are more questions like this around here (regarding websockets and Ajax requests) but I'm currently looking for the best solution in my specific case.

Scenario

Resources are produced every second. So for example, every minute 100 resources are produced. This should be updated live. I know, in this case it's not necessary to really update them live. I mean, I can simply calculate how much resources are produced in the current time minus the last updated time.

So no problem here, but there are a lot of different factors regarding the production of resources:

If a player is attacked, the enemy could have robbed some of his resources. So after an attack, the resources should be updated too.
If a player is attacked, and one of his 'productionbuildings' are damaged, he, for example, doesn't produce 1000 resources a hour, but 800 resources instead. So after a building has been demolished, the application should know the new building level to calculate the right amount of new resources.

Possibilities

So, how should I update the resources for the user? These are the options I think could possibly work:

Ping a script on the server, which calculates and updates the resources, every 5 seconds.
Set up a websocket stream and trigger it after each activity (after an attack, demolished building, ...)

Are there any other options? What would be the best way?


texts: What are the options when float textures aren't precise enough?

texts:
I am currently experimenting with rendering planetary scale terrain.

I am generating the terrain on the GPU with noise, and to fix the 32 bit floating point precision problems, I generate the heightmaps that need the most precision (the deepest levels of the quadtree I am using for the level of detail) by bicubically interpolating the heightmaps generated for the parent heightmaps (that are generated with normal 32 bit floats, since they don't need a lot of precision).

Doing it this way limits the amount of details the terrain can have, because the smallest details are generated with 32 bit floats, and if more detail is needed, bicubic interpolation is used to generate the intermediate height values.

The issues with this is that if I want extremely detailed terrain, 32 bit float textures (I store the heightmaps in those) are not precise enough, resulting in terraced terrain.

Is there a way I can store more distinct values inside a texture?

Thanks.


texts: Day and Night Cycles and Skybox Blending

texts:
I've been working on adding day/night cycles and random weather to my project using the Neoaxis engine. The day/night cycles itself is pretty simple, just rotating the "sun" light around the Y axis.

dayLength = 120; // How many real seconds to a game day
degreesPerSecond = 360f / dayLength;
sunY = 180f;  // Start on the horizon (6am)
currentHour = 6;
hourChange = 0;

Then on Tick for the sun

degreesPerTick = degreesPerSecond * Entity.TickDelta;

if(sunY >= 360f) {
    sunY = 0f;
} else {
    sunY += degreesPerTick;
}

hourChange += degPerTick;
if(hourChange >= 15f) {
    currentHour++;
    if(currentHour > 24) {
        currentHour = 1f;
        prevHour = 0f;
    }
hourChange = 0f;
}

sun.Rotation = new Angles(0, sunY, 0).ToQuat();

So, that got the sun moving nicely through the sky lighting up things as expected and calculating the hours based on each hour moving 15 degrees through the rotation.

I then started looking at how to implement the changes to the color of the skybox in order to have the nice orange skys during sunrise/sunset, blue as the day progresses and to black at night. Getting the color to change was easy but for some reason I can't seem to work out how to make the color lerp progress properly.

// Skybox changes
if( (currentHour >= 20 && currentHour <= 24) || (currentHour >= 0 && currentHour <= 4) ) {

    Engine.MapSystem.SkyBox.Instance.Color = skyNightColor;

} else if( currentHour >= 4 && currentHour < 7) {

    Engine.MapSystem.SkyBox.Instance.Color = skyMorningColor;

} else if( currentHour >= 7 && currentHour < 10 ) {

    Engine.MapSystem.SkyBox.Instance.Color = skyDayColor;

} else if( currentHour >= 10 && currentHour < 15 ) {

    Engine.MapSystem.SkyBox.Instance.Color = skyDayColor;

} else if( currentHour >= 15 && currentHour < 18) {

    Engine.MapSystem.SkyBox.Instance.Color = skyEveningColor;

} else if( currentHour >= 18 && currentHour < 20) {

    Engine.MapSystem.SkyBox.Instance.Color = skyNightColor;

}

What I am a little stuck on at the moment is how to work out the lerpAmount for each of the relevant places. I guess I need to somehow look at the start rotation of the lerp (e.g. 180) and the end position (e.g. 210) and then work out how to represent the current position as a value between 0 and 1 to use as the lerp value.

Is that the appropriate way to achieve what I am looking to do?


texts:
I'm working on a libgdx implementation of mesh terrain and running into some performance issues.

The terrain is represented by a number of mesh tiles, each mesh is made of vertices laid onto a 2D plane.

The implementation of the meshes is done via libgdx Mesh, each of which is cached after its initial generation. I use GL3.0 and therefore the vertices are handled via VertexBufferObjectWithVAO which as I understand it should allow GPU caching. Meshes are indexed.

Aiming to optimise performance, I have tried to increase the number of vertices in each mesh (while keeping the same overall amount of vertices) but weirdly the performance gets worse rather than improving.

Question 1: any possible reasons why given the same total number of vertices the scenario with lower amount of meshes (#3 below) is slower than the scenarios with higher number of meshes?

Question 2: based on the OPENGL pipeline summarised below is it correct to assume that VBOs are being transferred to the GPU once and then drawn via GPU memory reference?

Performance comparison

1,600 meshes * 3,042 vert (4.8M vertices) -> 131 FPS
625 meshes * 11,250 vert (4.5M vertices) -> 132 FPS
100 meshes * 45,000 vert (4.5M vertices) -> 113 FPS

Hardware Details

GTX660 2GB
Memory Utilisation during test 70% in all scenarios. Vertex allocation memory impact seems to be negligible compared to textures.

OPENGL pipeline

From API TRACE, this is the frame life-cycle in summary

mesh generation (one off)

glGenBuffers()
glGenVertexArrays()

render (every frame)

glClear(GL_COLOR_BUFFER_BIT)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glUseProgram(...)
glUniformMatrix4fv(...)
glUniform1f(...)
glActiveTexture(...)
glBindTexture(...)
...
glBindVertexArray(...)
glBindBuffer(...)
glDrawElements(...)
[for each mesh]

*edited to clarify that I have tried to group the vertices into less amount of meshes to reduce number of draw calls

**edited to provide more data and streamline questions.


texts: Persisting Player Prefs On Build in Android

texts:
Can I ask for help/guide where I can build 2d game on android device includes the players prefs that I defined already, for example I have an "int" PlayerPrefs (PlayerPrefs.Getint ("mysavenumber")),
the data "mysavenumber" has already a saved integer value in it. How ever upon building my game and installing it on my android device it seems does not hold any value.
How can I build my game with the Playerprefs data that I have defined upon building and installing it on an android device?


texts:
I have only 20 materials in my game (19 are made with textures atlas). But the Setpass call is 72. I don't understand why. I want to know how to decrease the number of SetPass call.
This is a brief summary about the game:
Houses vertex attributes : from 43 to 270. They are low poly houses. Props too.  No normal maps. Only diffuse and ambient occlusion maps. Only the Playable character has his own texture. There 45 houses models. I have 19 textures atlas.  In the game, some houses are assembled to formed another house (modular houses). And I assembled 10 to 18 houses to form a BLOC (a piece of town). For all the gameObects, SHADER is Universal Render Pipeline. I didn't edit anything, I use the default properties. In the game, Bloc of houses are put together 3 by 3 and randomly to form town like (SUBWAY SURFER)
In Unity playmode : Tris : 54.9k  Verts: 80k Batches : 466 Saved by batching : 0 Shadow caster: 0 Visible Skinned meshes: 1


texts:
An example of offline skilling would be EvE Online. Your character (pilot) does not gain skills by getting experience. Instead, your character gains skillpoints towards a skill you are training whether you are in or out of game. Also, I am fairly certain that skills continue to build even when the game servers are down.

Anyone have any broad ideas of how they go about this, or better yet how I could go about implementing something like this in a game I am developing. I'm not looking for a detailed explanation here (don't let me hold you back though), but I am looking for a signpost that points me in the correct direction.

Thanks!


texts:
Why must the transpose value of glUniformMatrix4fv in webgl/OpenGL ES be false?

The OpenGL ES spec says that the transpose value must be false or an INVALID_VALUE is generated. Why then have the parameter?


texts:
I need to have a hole in my objects and I don't want to use terrain.

I'd like to use an object and cut them out of another object, so that there is a hole in which the player could fall into; a 'game over' would happen.


texts:
So I'm kinda new to Unity, but I've used it a couple of times before. Here's my issue:

I have two cubes with a random texture applied to them (drag'n'dropped something from the Asset Store). These cubes have different sizes, where one is a square and one is a rectangle. I want to set the tiling size to be different on them (because they are obviously stretched on the rectangle), but when I click on one and change it, the settings changes for both of them.

This is how it looks right now: http://i.imgur.com/JtubBle.png

Is it possible to make these settings unique for each object somehow?


texts:
What good free and widely used tools are there for editing 2D skeletal animations? Preferably, one that allows me to write custom animation exporters.

One pretty good indie tool that I know of Demina, but it's not ideal. It doesn't allow you to export the data as you want (although, it is open source, so you can change that) and I find it clunky in how you edit individual joints.

What other tools would you recommend?


texts:
Working on a game in the Corona SDK with Lua and I need help so the player animates on the line drawn. Right now he animates at the beggining and the end but not on the line.

Here is the player code:

function spawnPlayerObject(xPlayerSpawn,yPlayerSpawn,richTurn) --spawns Rich where we need him.
-- riches sprite sheet and all his inital spirites. We need to adjust this so that animations 3-6 are the only ones that animate when moving horizontally
    local richPlayer = sprite.newSpriteSet(richSheet1,1,6)
    sprite.add(richPlayer, "rich", 1,6,500,1)
    rich = sprite.newSprite(richPlayer)
    rich.x = xPlayerSpawn
    rich.y = yPlayerSpawn
    rich:scale(_W*0.0009, _W*0.0009) -- scale is used to adjust the size of the object.
    richDir = richTurn
    rich.rotation = richDir
    rich:prepare("rich")
    rich:play()
    physics.addBody( rich, "static", { friction=1, radius = 15 } ) -- needs a better physics body for collision detection.
end

And here is the code for the line:

function movePlayerOnLine(event)
    --for the original image replace all rich with player.
 if posCount ~= linePart then
    richDir = math.atan2(ractgangle_hit[posCount].y-rich.y,ractgangle_hit[posCount].x-rich.x)*180/math.pi
    playerSpeed = 5
    rich.x = rich.x + math.cos(richDir*math.pi/180)*playerSpeed
    rich.y = rich.y + math.sin(richDir*math.pi/180)*playerSpeed
        if rich.x < ractgangle_hit[posCount].x+playerSpeed*10 and rich.x > ractgangle_hit[posCount].x-playerSpeed*10 then
            if rich.y < ractgangle_hit[posCount].y+playerSpeed*10 and rich.y > ractgangle_hit[posCount].y-playerSpeed*10 then
            posCount = posCount + 1
        end
    end

I don't think anything has changed recently but I have been getting an error when testing of "attempt to upvalue "rich" a nil value" on the second line, richDir = etc.


texts:
I'm developing a game where the map is generated with Perlin Noise, but on the CPU. I am generating some perlin noise onto a texture with a small size, and then I stretch it out to the whole screen to simulate a map.

The reason for the CPU generating the noise is that I want it to look the same on all devices.

Now, here's the end-result.

Please ignore the bullets and the explosion on the picture. What matters is the background (the black/gray pixels) and the ground (the brown-ish pixels). They are rendered to the same texture through perlin noise.

However, this doesn't look very pretty. So I was wondering if it would be possible to double the amount of pixels using a shader, and rounding edges at the same time? In other words, improve the DPI.

I'm using SharpDX with DirectX 11, through its toolkit feature. But any help that'll lead me in the right direction (for instance through HLSL) would be a great help.

Thanks in advance.


texts: Drawing application on OpenGL for iOS (iPad)

texts:
Some help is needed. I'm developing drawing application on OpenGL (deployment target 4.0) for  iOS (iPad). We have 3 drawing tools: pen, marker (with alfa) and eraser. I apply drawing with textures using blending in orthographic projection. I can't use z-ordering because in this case I have to face a lot of troubles with cutting and erasing.
The thing that I need is to make the pen be always on the top. When I first use the marker and then the pen - it's ok. But if I use pen first and marker over the pen - I can't see the pen color under marker. I'd appreciate any help or advice.


texts: How to prepare for a game development competition?

texts:
Ludum Dare 18 is coming up and I'll be participating in it. I've done a couple other short-term game competitions in the past but this is my first big one (and my first solo one). I am REALLY excited for it, but I'm wondering if there are any tricks to preparing for this sort of thing, and any advice on what to do while in the competition. So...

How do you best prepare for, or participate in, a short-term game competition?

Your answer can be specific to Ludum Dare but I'm really talking about any game competition, as long as it's short-term -- not the month-long ones where you casually develop your game and release it; I'm talking high-pressure, finish-in-time, pull-an-all-nighter type competitions. The Global Game Jam fits here as well, if you participated in that earlier this year.

Also any tips in the context of a group of people (each working on their own solo game) would be great; I will be with the game development club at my school for most of the 48 hours (only a few other people, not a huge group).


texts:
I'm using a single view app in Xcode 6.1 for my game with Storyboards. Not unity or sprite kit. It's a small game not even 3MB. Anyways, I created un-lockable characters with a BOOLEAN.

-(void)hidden{
 if(scoreNumber  > 9  || HighScoreNumber >9){
 BlueChar=YES;
 }

 -(IBAction)Blue{

  bird.image=[UIImage imageNamed:@"BLUE.png"];

 if(BlueChar ==YES){       //BlueChar=BOOL
 BlueChar.hidden=NO;
 }

When you click on BlueChar button, the UIImageView is connected to BlueChar character. So when you tap START GAME button game starts and you play as BlueChar. Then when it's GameOver and you click START GAME button again, the BlueChar button that was clicked isn't saved and instead you play as Original Character.

How do I make it that if you click BlueChar button ONCE, now you can play as BlueChar forever unless you click on another button that represents another character? How do I make the game save the last button clicked unless user clicks on another button in Objective-C code?


texts: Problems when rotating object to animate in Unity

texts:
I am trying to create some animations for a car model in Unity and I have a problem with the rotation of the wheels

https://imgur.com/a/HcWxyob

Here I can set the rotation properly as the pivot point seems to be at the center like how I want it to be but

https://imgur.com/a/TUpXBDX

When I play the animation it rotates on some other pivot point outside of the center of the wheel and even the car

Would you know how to fix this? Sorry if this is a dumb question

Thanks!


texts: Twine disabling style characters not working when using Harlowe format

texts:
According to the Twine documentation, if a word has asterisks around it, it's rendered in italics:

Italics = *Italics*

If I want to literaly show the asterisks, then I need to put some extra characters around it:

*Boom!*   == ``*Boom!*``

What is ` ?

Is it '? Because I don't get the desired results when writing ' '*Boom!*' ' or "*Boom!*".

In fact, ''text'' seems to be equivalent to **text** even though it doesn't say that on the doc pages the program links me to.


texts:
I have a laser sprite that I wish to crop.  I want to crop it so when it collides with an item, I can calculate the distance between the starting point, and the ending point, and only draw that.  This eliminates the "overdraw" of a laser drawing past an item.

Essentially, I'm trying to crop a line, but also keep that line "attached" to the nose of my ship.  The line should not be drawn past the nose of my ship, that should be the starting point.  There is no rotation to worry about.

Currently, I thought that doing this through SpriteBatch would be best.  This is my current Spritebatch code:

    spriteBatch.Draw(Laser.sprite, new Rectangle((int)Laser.position.X, (int)Laser.position.Y,
Laser.sprite.Width, LaserHeight),
new Rectangle(0, 0, (int)(Laser.sprite.Width), LaserHeight),
new Color(255, 255, 255, (byte)MathHelper.Clamp(Laser.Alpha, 0, 255)),
Laser.rotation, new Vector2(Laser.sprite.Width/2, LaserHeight/2), SpriteEffects.None, 0);

But this doesn't quite work.  It does only draw part of the sprite, but when LaserHeight is incremented, it lengthens the line in both ways!  I believe this is due to some stupid error on my part with the Origin of the draw.

Quick recap:  I need to have my laser sprite drawn with the bottom of it at the nose of my ship, and then use LaserHeight to crop the image so only part of it is drawn.

I have a feeling my explanation is a bit...lacking.  So if you require more information, please say so and I will try to provide more information.

Thanks in advance!


texts: Should I store game settings in my game data class?

texts:
I'm working on a small-ish 2d fixed shoot 'em up for iPhone.

I have a master Game object that stores lives, score, current level, etc...

The game will have some other persistent attributes like Music and Sound mute state, difficulty level (easy, medium, hard).

Should I put those attributes in the Game class or should they be on their own?

What's the rule of thumb to decide how to partition attributes among classes?


texts: What platform is best for Android and iPhone development?

texts:
I've been developing non-mobile apps for linux; mainly stuff like interpreters, compilers, database engines and business apps.

I've been told that if I wanted to learn how to develop iPhone/iPad applications, I should buy a Mac since Apple has all it's development tools for iPhone/iPad on Mac.

Now, what about Android phones / tablets?  Are the development tools better on Mac or PC?

I need to buy a new laptop, and I would like to factor in mobile development in my choice of PC or Mac.


texts: How to create a re-usable layout of text fields that can be bound to in world space?

texts:
Current tools:

Unity 2020.3.2f1 (Win10)
UI Builder preview package

My end-goal is to do the following:

At varying intervals, change values for many data objects in the background, such as prices, resources, demand, supply, etc.
Display those values in a flat table/list (as they change) in world space to the player, e.g. on a TV screen (or a transparent panel hovering above it, etc.)
Have the ability to apply that layout (and its bindings) to another world space object of a different size, e.g. on a smaller or wider TV screen

Imagine an office with 15 desks, all with 3 monitors showing the same data feeds and changing statistics, except the monitors were all different shapes and sizes. How could you avoid building all 45 monitor layouts individually, and binding to each field separately? So my question is:
What is the "right" way to build a re-usable UI (ideally with UXML/USS), display it in world space, and have the ability to update the text in that layout?
I thought that UI Builder + UXML/USS would be the answer, but I am having trouble parsing how my end goal would be accomplished using that (or if that is even an appropriate use case for UI Builder). Fields that are displayed using UIDocuments are not exposed in the Hierarchy, and can't be dragged onto a script's input in the Inspector, for example. I'm able to project a UXML/USS layout onto a texture => material => object, but I'm not sure how to bind to the fields within the layout:

The screenshot above is my latest attempt, a POC of a live timer (on the right) manually being updated (using a TextMeshPro field, works great), and the yellow panel to the left is a UXML/USS layout pasted onto a texture/material that's applied to a panel (in a canvas). On the far left is that same layout being used as a HUD, just to confirm it works the same as the floating panel. In-game, this data will not be part of the HUD, it will only be in world space. As a POC, I have been trying unsuccessfully to get the timer value from the gray panel to bind to the "should be time" text in the UXML.
So, should I just bite the bullet and build each layout by hand using game objects (such as in the gray panel)? Or am I halfway there with the UXML and just misunderstanding how UIDocuments work? Or is there a new smarter way of doing this I haven't heard of yet? Not looking for a full code example or anything, just a push in the right direction.


texts: How can I render cloud patterns like in these examples?

texts:
I have a quick question.

I see in many games, usually in the menu, some moving "clouds" in the background, apparently additive blended into each other, which does a really nice job immersing the player, in my opinion.

A couple of examples that jump to mind right now are the Far Cry 3 main menu background: https://www.youtube.com/watch?v=B5XcMx3GjPA

and the Plague Inc main menu background: https://www.youtube.com/watch?v=RQv60ywrLxU (the first seconds show it)

These cloudy patterns seem like some kind of noise to me, like Perlin or other. So, how would you proceed to achieve that kind of blurred cloud effect with vivid colors?

More specifically, would you pre-generate sets of clouds and include them in the game package? Or generate them on-the-fly? On the CPU as a regular texture or on-draw in the GPU shader program?

I am interested in mastering this kind of visual effect, and as such any help would be appreciated pointing me in the right way. Thanks.


texts:
I'm currently working for a websites client development team and need guidance on where to go for anti-cheat with unity.

We have scripting, where a user can code in their own features via a editor we have made in lua, with a scripting api that allows them to interact with parts of the game via said scripting, others can exploit this with tools and execute scripts on games that didnt have said scripts, via "hacking". I'm trying to stop script execution exploit(eg scripts being executed that weren't put there by the author) and general hacks such as speedhacks, assembly injection, etc. We have tried the anti-cheat toolkit but it hasn't worked well for us. In terms of execution we have the lua5.2 library in a dll, of course they can hook this library and execute anything via luas execution functions built in, statistcally linking the library would help defend againist this but that is not a option that is easily done in unity, so anyone could just hook it and execute any script/lua they want. we have server-side scripts(executed on server) and client/local-side scripts(executed on client/locally), we've done our best to secure these but we're looking into more ways to help protect us, such as anti-cheat.

We have plans to possible invest into paid anti-cheats in the future such as battleeye, easyanticheat, etc.

we currently don't make a lot of capital and i have no experience making any type of anti-cheat nor anti cheat in unity, where do i start and what do i do?


texts:
I'm making 2d racing game .... and I'm using UI image in the canvas background (road) .my car and enemy cars and I have tried to instantiate enemy car with this script by attaching this script to empty gameObject then attaching the enemy prefab to the enemyCar image that in the script...but the strange thing is :the enemyCar is instantiated in the hierarchy but I can't see it in the game What is the wrong ? is the wrong related to the child and parent or what ? and how can I make that UI image a child of canvas in the script ?

using UnityEngine;
using UnityEngine.UI;
public class Generate : MonoBehaviour
{
public Image enemyCar;

// Use this for initialization
void Start()
{
 InvokeRepeating("CreateEnemy", 1f, 1.5f);
}

void CreateEnemy()
{
 Instantiate(enemyCar);
}
 }


texts: How can I animate shadow in surface shader?

texts:
I wrote wind shader that works but as you can see it have shadow problem!
when I animating vertices shadow is fixed!

Shader "Smkgames/Wind Shader" {
        Properties{
            _MainTex("Albedo and alpha (RGBA)", 2D) = "white" {}
            _BumpTex("BumpTex",2D) = "bump"{}
            _WindMap ("WindMap", 2D) = "white" {} // Add noies map like fbm noises
            _Cutoff ("Cutoff", Range(0,1)) = 0.5
            _Speed("Speed",float) = 1
            _Direction("Direction",Vector) = (0,0.2,0,0)
        }

        SubShader{
            Cull Off

            Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout" "DisableBatching"="True" }
            LOD 200

            CGPROGRAM
            #pragma surface surf Standard alphatest:_Cutoff vertex:vert

            #pragma target 3.0

            sampler2D _MainTex,_WindMap,_BumpTex;
            fixed4 _Direction;
            fixed _Speed, _WindAmount;
            half _Glossiness, _Metallic;
            fixed4 _Color;

            void vert(inout appdata_full v) {
            float4 tex = tex2Dlod(_WindMap, float4(v.texcoord.xy + (_Time.x * _Speed), 0, 0));
            v.vertex.xyz += tex.y *  _Direction.xyz * _Speed;
            }

            struct Input {
                float2 uv_MainTex;
                float2 uv_BumpTex;
            };

            void surf(Input IN, inout SurfaceOutputStandard o) {
                fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
                o.Albedo = c.rgb;
                o.Alpha = c.a;
                o.Normal = UnpackNormal(tex2D(_BumpTex,IN.uv_BumpTex));
            }
            ENDCG
        }
                FallBack "VertexLit"
    }

I couldn't fix it! so I tried to add shadow to my object from scratch by using vertex and fragment shader shadow caster and worked correctly but I want know
Is there a way to fixing this problem in surface shader?


texts: Are there any dedicated rules/scoring libraries/frameworks/engines?

texts:
Note that this is not about graphics/physics/2D/3D/etc.! Rather I'd like to know whether there are dedicated solutions available for implementing custom rules/scoring on top of an existing framework, ideally addressing most common concepts already, for example players, matches, rule variations, game selection, preferences, high scores and the like?

Or is this functionality usually included in all those graphics oriented libraries/frameworks/engines? If so, are there any that stand out in this regard and do allow reusing the rules/scoring components easily without using the graphics part of the engine for example?

Alternatively, would you consider this topic to be better addressed by a standard Business rules engine instead, as suggested in Java Rule Engine for Game AI?


texts: How to guarantee that player fits rooms of a cave created by Cellular Automata?

texts:
I've implemented a cellular automata algorithm to generate a cave for my game and now I need my player object, which occupies 3x3 tiles in total, to be able to pass between the rooms.

The problem is that some of the rooms automatically created by cellular automata do not have the necessary width/height for the object to pass (example: a 2 x 3 tiles corridor).

How can I transform the result from the cellular automata so that I guarantee that the player is able to pass in any of the rooms? The idea is that this can be done in real time so that I can do an endless game.

This was done in GDScript but any examples in any other language, like C# for Unity, are welcome.

Update

As said in the comments, I could make a map where each cell would correspond to a 3x3 on the final map but, my problem is that I need the 1x1 tiles because my player should lose a life when hitting the walls (and that way I can create some kind of "spikes" based on the walls).

Given that, how can I add 1x1 tiles to the map created from the 3x3 and still guarantee that the player fits the cave's "corridors"?

Update 2

The only rules I currently have for CA are:

If total neighbour walls > 4, the cell becomes a wall
If total neighbour walls < 4, the cell becomes empty
Else, remains as it is

The total number of iterations for the CA is 2

Solution

I was able to do this the way that DMGregory said:

First I run the CA after building the map as I did before in order to add the "empty space adjacent to wall" cells (now on called EmptyNextToWall) to the map
Then I run the CA with the following rules, until none of them are verified (it did not pass 5 iterations on my scenarios):

If my current cell is EmptyNextToWall and has more than 4 EmptyNextToWall adjacent to it, make it an Empty cell
If my current cell is EmptyNextToWall and the adjacent diagonals are a Wall and a EmptyNextToWall, make it an Empty cell
If my current cell is EmptyNextToWall and there's no Empty cells around it, make it an Empty cell
If my current cell is a Wall and there's at least one adjacent Empty cell, make it an EmptyNextToWall
If my current cell is EmptyNextToWall and there's no adjacent Walls, make it an Empty cell


texts: How can I rotate the game stage (Unity 2D)?

texts:
I have a pseudo-game which I'm developing in 9:16, to be displayed in vertical screens. The client now needs another version in 16:9, rotated in 90º.

I tried creating a empty object, puting all my elements inside it, and rotating, but it caused a lot of positioning bugs, probably because of localPosition x position.

Any help is apreciated.

Below in what in have x what I need


texts:
I have the following exception being thrown at compile time:

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.Edge.WakeUp () (at C:/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Edge.cs:114)
UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List`1[T] inEdges, System.Collections.Generic.List`1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at C:/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Graph.cs:387)
UnityEditor.Graphs.Graph.WakeUpEdges (System.Boolean clearSlotEdges) (at C:/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Graph.cs:286)
UnityEditor.Graphs.Graph.WakeUp (System.Boolean force) (at C:/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Graph.cs:272)
UnityEditor.Graphs.Graph.WakeUp () (at C:/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Graph.cs:250)
UnityEditor.Graphs.Graph.OnEnable () (at C:/buildslave/unity/build/Editor/Graphs/UnityEditor.Graphs/Graph.cs:245)

I know well enough what a NullReferenceException is and what causes one, but the stack trace above implies that it's being thrown by the editor or some other internal thing.

Does anyone have any advice on how to debug this?


texts:
I'm wondering what's the most efficient way to broadcast state changes of entities on a 2d map, to other entities. In particular, I have X players connected to a server on a 2d map and each of them has a sight radius, which defines which other players (or any abstract entities in general) can be seen. Each entity may change its state at any point in time, which needs to be broadcast to everyone who can see it. At the moment, I use a very simple approach:

Use a quadtree to subdivide the world and assign entities to nodes.
At each update 'tick', flag entities which has their visible state changed, and recompute their quadtree nodes.
For each player, determine which changed entities can be seen, and send all their state. This implies any previous entity which the player doesn't see anymore is not sent, and the client can remove it from its view.

This works, but it seems a lot of computing which might be avoided somehow (the visibility determination at each tick seems awful). Does anyone have any ideas?


texts: Calculating approximations of contact between two meshes

texts:
I'm looking for ways to calculate the degree of contact between two objects in a scene. I was thinking that calculating the hausdorff distance would be a useful approximation if it is then normalized somehow using the surface area/volume of the objects. Does anyone have any experience calculating this in Unity? Or have any suggestions for other ways to approximate this?

Edit: For some context, I'm working on a project which involves looking at the relationship between geometric properties and relations of objects, and what language/words people use to describe objects and I am using scenes in unity to test this. The notion of 'contact' appears to be an important one and it would be useful to be able to quantify the amount of contact between two objects in a scene


texts: How to integrate Tiled maps and collision detection with pygame?

texts:
I have been using pygame to make a simple rpg pokemon style game. To create maps I have used the Tiled map editor and then loading them into pygame using pytmx.

I have heard that you can add object layers in Tiled to your map, and then use this information for collision detection within your game engine (in this case pygame). Unfortunately, while I know how to load the tmx file into my pygame game, I have no idea how to use the object layers for collision detection.

Can anyone provide a minimal example on how to do this? The documentation that I have come across for Tiled appears to be quite minimal and still an active work in progress. As a result I have not been able to find information on using Tiled and object layers for collision detection in pygame.


texts: Unity3D: Disable player input but not character movement?

texts:
I'm trying to code a dash/air dash for a 2D platformer. In my character controller's FixedUpdate(), I have various if statements that cause certain actions when a button is pressed.

To disable player input while the dash was happening, I tried putting Dash() in an IEnumerator with a simple test code like this:

IEnumerator Dash() {
    if (player.GetAxis("Horizontal") < 0)
        {
            thePlayer.GetComponent<HeroController>().enabled = false;
            yield return new WaitForSeconds(0.5f);
            move = move * 2;
            thePlayer.GetComponent<HeroController>().enabled = true;
    }
}

But since the character's physics are inside the character controller, both the player's input and the character's movements are stopped when the controller is disabled. How can I disable inputs while still allowing the character to dash?


texts: Why is programmable pipeline( GLSL ) faster than fixed pipeline?

texts:
So I'm teaching myself GLSL and am trying to figure out why it's suppose to be faster than the fixed function pipeline.

The reason I am having a problem is that from my understanding , the shaders you create are replacing sections of the pipeline that were there before. So, how's simply providing your own version speeding things up?

The only thing I can think is if you tried to supply say your own lighting equation before, you would have to do the calculation on the CPU, but now you can do the calculations on the GPU which will be faster.

Am I understanding this correctly?


texts:
There are many Minecraft clones out there and I am working on my own implementation. A principle of terrain rendering is tiling the whole world in fixed size chunks to reduce the effort of localized changes.

In Minecraft the chunk size is 16 x 16 x 256 as far as I now. And in clones I also always saw chunk sizes of a power of the number 2.

Is there any reason for that, maybe performance or memory related? I know that powers of 2 play a special role in binary computers but what has that to do with the chunk size?


texts: How do I target a tank turret with an offset barrel?

texts:
I have a tank model consisting of multiple parts, a body, a turret and the barrel of the gun. The turret is offset from the body origin and can rotate around the Y axis(up). The barrel is connected to the turret and can rotate around the X axis of its connecting point to the turret.

I was wondering, given a target in 3d space and the position of the tank, how to calculate the correct rotations to give to the parts in order for the barrel to align itself to fire at the target.

The position of the tank cannot change, only the rotations given to the turret and the barrel. I would know how to solve this if the barrel is aligned with the z axis of the turret but I am having difficulty solving this problem if parts are offset from each other. Eventually I want to expand this so that multiple joined parts can get the end part (firing point) facing a target. I am using XNA C#.

EDIT:

Below is an example of what I mean, a turret connected to the body at the blue point. The barrel is connected to the turret at the red point:


texts: How is the density of a collider determined?

texts:
I read here that, once determining the density of a Buoyancy Effector, "Colliders with a higher density sink, those with a lower density float, and those with the same density appear suspended in the fluid." However, I did not find a density field in my CircleCollider2D. What I found is that:

If I increase the mass of the attached RigidBody2D, then the body sinks into the fluid - since apparently its density increases.
If I keep the mass but decrease the size of of the circle collider, then again the body sinks into the fluid - indicating that its density increases.

So my conjecture is that the density is calculated by the mass of the rigid body, divided by the volume of the collider. But I did not find the formula in the Unity manual. Is this correct?


texts: Sprites don't become lit when installing Universal RP package

texts:
I want to implement 2D lights in Unity. So, I downloaded the Universal RP package from the Package Manager.
I created renderers as shown here, then I created a light object (Point Light 2D) in a new project.

What should happen: After this last step, the scene should become black.
What happened in my case: There scene is same as before plus a warning message popped up in the other project, and when I place any object from my game, only that object appears black.

WARNING:
FlowerM_03 material was not upgraded. There's no upgrader to convert Unlit/Transparent shader to selected pipeline
UnityEditor.Rendering.Universal.UniversalRenderPipelineMaterialUpgrader:UpgradeProjectMaterials() (at Library/PackageCache/com.unity.render-pipelines.universal@7.4.1/Editor/UniversalRenderPipelineMaterialUpgrader.cs:25)

Videos I took reference from:-
https://www.youtube.com/watch?v=nkgGyO9VG54
https://www.youtube.com/watch?v=F5l8vP90EvU


texts: Repelling a rigidbody in the direction an object is rotating

texts:
Working in Unity, I have a game object which I rotate each frame, like so:

void Update()
{
    transform.Rotate(new Vector3(0, 1, 0) * speed * Time.deltaTime);
}

However, I'm running into problems when it comes to applying a force to rigidbodies that collide with this game objects sphere collider. The effect I'm hoping to achieve is that objects which touch the collider are thrown in roughly the same direction as the object is rotating. To do this, I've tried the following:

Vector3 force = ((transform.localRotation * Vector3.forward) * 2000) * Time.deltaTime;
collision.gameObject.rigidbody.AddForce(force, ForceMode.Impulse);

Unfortunately this doesn't always match the rotation of the object. To debug the issue, I wrote a simple OnDrawGizmos script, which (strangely) appears to draw the line correctly oriented to the rotation.

void OnDrawGizmos()
{
    Vector3 pos = transform.position + ((transform.localRotation * Vector3.forward) * 2);
    Debug.DrawLine(transform.position, pos, Color.red);
}

You can see the result of the OnDrawGizmos function below:

What am I doing wrong?


texts: Sprite Animation in XAML/C# for Windows 8 Modern UI (Metro)

texts:
I'm working on a project that requires doing sprite based animation in XAML / C# for a windows store app.  I've worked out a method for displaying the animation, but it causes flickering during the initial load of the images.  The method I used basically involves creating a class which subclasses canvas that loops through all children during the its CompositionTarget.Rendering event.  If any of the child objects are of type SpriteImage (another class I created that subclasses content control and is a container for the image control that displays the current frame) it calls the update method so that the SpriteImage may display the appropriate bitmap image for the current frame.

I have shared the sample project at the following link:
Sample Sprite Animation Project for VS 2012 and Windows 8.

It seems that after the animation has completed one iteration and all of the BitmapImages have been loaded from the source URIs, the animation runs smoothly.  I suspect that the BitmapImage is not loaded until the Image who is using it for the source is loaded.

So I was hoping to get two things from the community:

Anyone have any good ideas on how I can use preload those images so that the flicker does not happen?

Anyone have any good ideas on how to get these into a sprite sheet so that I do not have to have use separate files?  I haven't found a good way to do it with Win8 XAML / C#.

Any help is greatly appreciated.


texts: How to limit camera pitch (x rotation) between two angles

texts:
I use this script rotate the camera on its local X axis:

 float v = verticalSpeed * Input.GetAxis("Mouse Y");
 transform.Rotate(-v, 0, 0);

Right now this lets the player look up & down without limit, wrapping around a full 360 degrees. How can I limit this so they can look only 90 degrees up or 90 degrees down from the horizon?