texts: How to perform a fast ray cylinder intersection test?

texts:
I need an algorithm in c++ to get the intersection point of a line if there is an intersection. My cylinder is defined by a 3d vector center point, a float height and radius. I don't need to take rotation into consideration at all so I don't need any rotation parameters.
The only one found similar to my needs was this: https://github.com/iceman201/RayTracing/blob/master/Ray%20tracing/Cylinder.cpp
but after implementing it gave me wrong results. All the other ones I found used weird arguments that weren't even close to my desire. So I am pretty stuck now.


texts: What are pros and cons of different social gaming networks from developer's point of view?

texts:
I am developing a game for a mobile platform and I want to integrate it with either Scoreloop or Openfeint.

So my question is which of the platforms has better SDK (by that I mean that its has better tools to implement achievements and global leader board and other things) and more features?

Which of those has larger user base?


texts: Particle Turbulence Effect in Babylon.js

texts:
Is there any way to implement a turbulence effect in a babylon.js Particle System? I know that its possible to use physics engines on mesh objects, but I've not seen any discussion of using them on a babylon particle system.
Might there be a way to bake a particle system as a .vdb and import it if real-time simulation is not an option?


texts: How to shoot a triangle out of an asteroid which floats all of the way up to the screen?

texts:
I currently have an asteroid texture loaded as my "test player" for the game I'm writing. What I'm trying to figure out how to do is get a triangle to shoot from the center of the asteroid, and keep going until it hits the top of the screen. What happens in my case (as you'll see from the code I've posted), is that the triangle will show, however it will either be a long line, or it will just be a single triangle which stays in the same location as the asteroid moving around (that disappears when I stop pressing the space bar), or it simply won't appear at all. I've tried many different methods, but I could use a formula here.

All I'm trying to do is write a space invaders clone for my final in C#. I know how to code fairly well, my formulas just need work is all.

So far, this is what I have:

Main Logic Code

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(ClearOptions.Target, Color.Black, 1, 1);

            mAsteroid.Draw(mSpriteBatch);

            if (mIsFired)
            {
                mPositions.Add(mAsteroid.LastPosition);
                mRay.Fire(mPositions);
                mIsFired = false;
                mRay.Bullets.Clear();
                mPositions.Clear();
            }

            base.Draw(gameTime);
        }

Draw Code

            public void Draw()
            {
                VertexPositionColor[] vertices = new VertexPositionColor[3];

                int stopDrawing = mGraphicsDevice.Viewport.Width / mGraphicsDevice.Viewport.Height;

                for (int i = 0; i < mRayPos.Length(); ++i)
                {
                    vertices[0].Position = new Vector3(mRayPos.X, mRayPos.Y + 5f, 10);
                    vertices[0].Color = Color.Blue;
                    vertices[1].Position = new Vector3(mRayPos.X - 5f, mRayPos.Y - 5f, 10);
                    vertices[1].Color = Color.White;
                    vertices[2].Position = new Vector3(mRayPos.X + 5f, mRayPos.Y - 5f, 10);
                    vertices[2].Color = Color.Red;

                    mShader.CurrentTechnique.Passes[0].Apply();
                    mGraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, vertices, 0, 1);

                    mRayPos += new Vector2(0, 1f);

                    mGraphicsDevice.ReferenceStencil = 1;
                }
            }


texts: UE4 "get" and "set" component without using an actor specific reference

texts:
i'm using Unreal Engine 4 and I want to get the variable mode from some actors by referencing them but the only option that i can find in the menu is actor specific like this.

So what i want is a version of the component in my image that is not "Target H1" specific. And i also need the same thing for the "set" component please. and if this is not possble can someone tell me please.


texts:
I'm trying to fugure out all the spaces transformations, and currently have some inconsistency I can't understand. I'm working on a 2D game (so we assuming Z is always 0 for now), on a device with 960x544 resolution. So, as far as I understand my World Space is left-top (0, 0) to right-bottom (959, 543), with Y axis inverted (going down). Let w = 960, h = 544. To transform it to Eye Space we need to move (0, 0) to center of the screen, so it would be simple translation, viewT:

1, 0, 0, -w/2
0, 1, 0, -h/2
0, 0, 1, 0
0, 0, 0, 1

Next step is Clip Space. I want all world space to be rendered so it's just scaling. But we also need to invert Y axis and that's the part I'm unsure of. My assumption would be that we just add minus sign for the Y scale, and thus projT:

2/w, 0, 0, 0
0, -2/h, 0, 0
0, 0, 1, 0
0, 0, 0, 1

Then viewProjT = projT * viewT would give me:

2/w, 0, 0, -1
0, -2/h, 0, 1
0, 0, 1, 0
0, 0, 0, 1

But in samples I have, "reference" matrix is:

2/w, 0, 0, 0
0, -2/h, 0, 0
0, 0, 1, 0
-1, 1, 0, 1

i.e. it's my viewProjT, but transposed. And that's the part I don't understand. Can someone clarify why I need to transpose matrix to get correct matrix? Is this somehow related to inverting Y axis?

Note: I'm using this, as a basis for my calculations.
And image to illustrate my World and Clip spaces:


texts: Surprisingly, in SpriteKit game engine, "deltaTime" is not frame time?

texts:
In Apple's cocos-like 2D enginer, SpriteKit, they have what they call a custom field:

testField = SKFieldNode.customField{
      (position: vector_float3, velocity: vector_float3,
      mass: Float, charge: Float, deltaTime: TimeInterval) in

            print("deltaTime \(deltaTime)")
            return vector_float3(0,0,0)
        }
addChild(testField)

the values printed out are simply the cumulative time, not the frame delta time!

Interestingly the documentation is ambiguous or just wrong:

https://developer.apple.com/documentation/spritekit/skfieldforceevaluator

notce there it uses the argument name "time", however
however, the documentation-writer wrote "time that has passed since the last time the simulation was executed" (ie, the usual frame time you'd expect), and
each Apple code fragment I've dug up uses "deltaTime" as the argument name, and the author treats it as a normal frame time like you'd expect in any game engine setting

I've tried it on as many devices/OS as at hand - has anyone found the definitive resolution of this?  Is it really meant to be (fairly uselessly) time rather than deltaTime?

Question, Does anyone definitively know if the value returns cumulative time, or, delta time?

(If the former it would appear that the doco is completely wrong.)

Question, In the so-called "deltaTime" argument of Apple's spriteKit, what is returned?


texts: GameMaker child objects not inheriting layer structure

texts: Using Game Maker Studio 2. I have a parent room. When I create a child room to that parent, it inherits everything properly. But when I add a feature to the parent room, or simply rename the layer in the parent, the child does not inherit or update properly. But if I toggle 'inherit', now I get the original layer as well as the edited layer, when all I expect to see in the child object is the edited layer. This doesn't seem to be expected behavior, any idea what's up?


texts:
I've been writing a game in my free time, and I'm planning to add a transportation network based on a buildings demands and production. However, I'm not sure how to manage this efficiently, and most importantly with limited CPU time.

The two key issues are, how do I pair producers and consumers efficiently, and how do I route vehicles between them?

I have A* working for path finding now, but how do I alter this to include the congestion that will occur from many transports? Perhaps as each vehicle is assigned to a road, that road's cost increases some given value?

An open source project that seems to have similar features is OpenTTD. They define the problem as a Multi-commodity flow problem, but don't give many more details. The paper that describes their algorithm is no longer linked unfortunately, and I feel it may be a bit complex.


texts: A formula for point calculation based on value A's proximity to value B

texts:
I am trying to find a formula to use for my rhythm game's scoring. Basically there is a Guide entity and a Live entity. You control the Live entity and have to match it as closely as possible to a Guide entity in position and radius (both entities are circles drawn on HTML5 canvas).

Guide entities appear automatically and are pre-programmed in an array. For example: a beat trigger is at the 30 second mark in the song. A Guide entity is spawned at 30 - 2 seconds. Over the course of the two "buffer" seconds a visual cue lets the player know when to hit the trigger to spawn a Live entity (so there are two spare seconds for the player to orient themselves before the Live should be spawned). The Guide entity then starts to expand (increasing in radius) based on a pre-built duration setting. The player needs to hold down the Live entity key to expand their live entity along with the Guide entity, keeping them as close as possible.

Each Live entity has an attribute called tempPoints. When the Live circle is created, its tempPoints is set to 100 (the maximum, or "perfect" amount).
On initialization of the Live entity (triggered by a key press on the user's side), I calculate the position offset from the Live entity to its matching Guide entity. Eg if guide.pos.x === 100 and live.pos.x === 110, live.pos.x is 10% off of guide.pos.x and tempPoints = 100 - 10 (same for pos.y)

That is done in the init function of the Live entity.

Here is where I'm having trouble:

The closer the Live entity's radius is to the Guide entity's radius as it expands (and then contracts) the more points the player should keep from their tempPoints. I think this would need to be done in the update function. The issue is that I don't know what formula to use. I originally did something similar with this as with the position points - calculate the percentage offset of the Live entity's radius from the Guide entity's radius and subtract this offset from the player's points. This would run every single frame and points plummeted into the negative within seconds. I then set up a timer to do this same thing but only run it every x seconds (eg 1 or 2), but am running into the same problem. It works in some instances, but seems dodgy because when the Live entity radius gets just a little too big or too small the offset becomes huge and removes a whole bunch of points. I've even tried dividing the offset by 10, 20, 50 to remove a smaller number of points, but can never get it to feel quite right. The point subtraction actually seems too minor until the offset is just a little too large, in which case it starts to look too drastic.

Is there something like an existing formula for this kind of point system? That is, points based on value A's proximity to value B (in this case the radius of your Live entity and the radius of the Guide entity), with both values continuously changing each frame as the guide and live entities expand and contract?


texts: Setting useImmersiveMode to true makes a moving sprite blink in a LibGDX game

texts:
I'm developing a simple game where i have gravity and a body which jumps when i touch the screen and a sprite displaying in its position. All is good until i set useImmersiveMode to true on AndroidLuncher for the game to be in full screen. when i do that, while the body is moving ,the sprite is blinking all the time, when resting it's not.

Is there something that i missing?

Should i use a different way for displaying my game on a full screen?

Thanks


texts: What is the most common art creation process?

texts:
I am a developer and when I think about the creation of art assets I am a little lost. My idea is to create concept art first to get my thoughts into real images and after that start creating the backgrounds, sprites, menus, etc.

It sounds simple written like this and I expect lots of inner work, but is there a more formal way to do it? or at least something like a standard procedure?


texts: Rendering multiple strings/text using SpriteBatch from LibGDx library

texts:
I am using the LibGDX library to render a 3D model in my Android application. Now, I am stuck, where I want to render multiple dynamic texts on to different 3D boxes located on different coordinates of the screen. I am able to render a single text using SpriteBatch, but I need to render different string values on different boxes.

SpriteBatch spriteBatch = new SpriteBatch();
BitmapFont font = new BitmapFont();
spriteBatch.maxSpritesInBatch = 5;

spriteBatch.setProjectionMatrix(camera.combined.cpy().scale(camera.combined.cpy()
    .getScaleX()/25,camera.combined.cpy().getScaleY()/25, 0.8f));

spriteBatch.begin();

font.setColor(1.0f, 0.0f, 0.0f, 1.0f);
float xPos = -90;
int count = 0;

for (Widget widgets : display.getWidgets())
{
    float boxWidth = widgets.getBounds().getWidth();
    float boxHeight = widgets.getBounds().getHeight();
    float boxHeightCenter = widgets.getBounds().getCenterY();

    if(count==0)
    {
        font.draw(spriteBatch, "Hello"+count, xPos, boxHeightCenter-25,
            boxWidth, 0, true);
        ++count;
    }
    else
    {
        font.draw(spriteBatch, "Hello"+count, xPos+boxWidth, boxHeightCenter-25,
            boxWidth, 0, true);
        xPos = xPos+boxWidth;
        ++count;
    }
}

spriteBatch.end();`

The above code renders only one string value. While debugging, the "for" loop is getting traversed, but no positive result is obtained. How do I fix this?


texts: How do I perform my "String.Format" call with correct localisation?

texts:
I am currently using this to create a string of a certain length from an integer variable. This is the only way I know of, at the moment; but Android Studio complains, saying it won't work work in all countries.

I will soon have some games that I might release on to the Play Store, and I wouldn't want there to be any unnecessary problems like this.

Is there a better way to achieve the same thing without reams of new code?

timeRemainingLabel = new Label(String.format("%03d", worldTimer),
        new Label.LabelStyle(font, Color.WHITE));


texts:
i want correct UV Coordinates model
likes this model

but Model load and render at my importer result is likes this

My fbx uv coordinates extract code is here

     FbxLayerElementUV* layerUVs = pMesh->GetLayer(0)->GetUVs();
                if (NULL != layerUVs)
                {
                    int uvIndex = 0;
                    FbxLayerElement::EReferenceMode referenceMode = layerUVs->GetReferenceMode();
                    FbxLayerElement::EMappingMode mappingMode = layerUVs->GetMappingMode();

                    if (FbxLayerElement::eByPolygonVertex == mappingMode)
                    {
                        int id = pMesh->GetTextureUVIndex(j, k);
                        if (FbxLayerElement::eDirect == referenceMode ||
                            FbxLayerElement::eIndexToDirect == referenceMode)
                            uvIndex = id;
                    }
                    else if (FbxLayerElement::eByControlPoint == mappingMode)
                    {
                        if (FbxLayerElement::eDirect == referenceMode) uvIndex = iControlPointIndex;
                        else if (FbxLayerElement::eIndexToDirect == referenceMode)
                            uvIndex = layerUVs->GetIndexArray().GetAt(iControlPointIndex);
                    }
        FbxVector2 uv = layerUVs->GetDirectArray()[uvIndex];

        vtx.u = (float)uv[0]; vtx.v = (float)uv[1];
        vtx.u = 1 - vtx.u; vtx.v = 1 - vtx.v;

What I do, can we solve this problem??
Please Answer to me


texts: Texture not carrying over to game correctly?

texts:
I have created my map for my game using 3DS Max. I have then applied textures to the map within 3DS Max, where the textures all show correctly. I export the map as a .fbx file to use within an XNA project.

However as you can see from the below screenshot, the textures are not displayed correctly in XNA.

Does anyone know why this is happening?

I am using the Autodesk FBX content importer and the Model - XNA Framework Content Processor.

As you can see my model which was created in the same way has the textures displayed correctly, it is only doing it to my map.


texts: How to implement fake 3D like distortion effects for a 2D side scrolling game?

texts:
I'm not certain of the proper terms to search on or even where to begin though I imagine it is some sort of post processing effect.

I've seen games like I Wanna Be The Boshy and You Have To Win the Game which manage to modify the perspective of 2D games to give a sort of 3D effect to them (see images below). Boshy basically makes it look like you are inside a tower (cylinder) while You Have To Win the Game distorts the image so that it looks like you are playing on an old CRT monitor, specifically the slightly rounded look.

Is there a term for this effect?
What is the standard way for implementing this effect (terminology)?
How would I go about implementing such an effect in a high level engine / framework such as Unity or XNA/Monogame from a 20,000 foot view? (detailed code happily accepted but not necessary - I realize exact implementation details might vary but high level details on what needs to be done would be greatly appreciated)

I Wanna be the Boshy

You Have To Win The Game


texts: Network communication via Sockets. Is there a better way?

texts:
I'm building a game engine on the OpenTK framework that needs to support multiple players.

How I have the basic framework established is that there is a Client and a Server.  The Server binds and listens on a specified port, and the Clients connect to the Server's IP Address and Port to make a TCP socket.  The server then transmits a World object to all clients as they connect.

A World object contains all of the Light objects, Surface objects, Mesh objects and Camera objects.  With all of these objects, the World is responsible for rendering the game environment.

My idea is that each Camera object has a Unique ID, a position (X,Y,Z), and 2 angle values representing Zenith and Azimuth.  When any of these values changes (only the camera can move at this point.  Basics first!) I want to Serialize and send the updated Camera object to the Server, which then transmits this object to all of the Clients.  The Client then deserializes the new Camera object, uses its Unique ID and updates the existing Camera object in the World.  Since the Camera object consists of only 5 double values (X,Y,Z,Az,Ze) it shouldn't be a lot of data being sent over the network, but my implementation seems to slow down the Game Screen significantly

Is there a better model for Multiplayer network communication?  Is there any built in functionality in C# that handles this kind of communication?

Basically, I just need to update all of the other Clients when one Client's Camera changes.

Thanks for any help!


texts:
im trying to create simple pong game, and learning some XNA.
im creating for each paddle 3 rectangles, who represnt the collision when the ball hit them, so i can dicide where to throw the ball back.
here is the function that i create the rectangles:
List<Rectangle> collisonRectanglesList = new List<Rectangle>(3);
      private void creatCollisonRectangles()
        {
 smallPaddleWidth = collisionRect.Width;
             smallPaddleHeight = collisionRect.Height / 3;
            for (int i = 0; i < collisonRectanglesList.Count; i++)
            {
                if (collisonRectanglesList[i] != null)
                    collisonRectanglesList.RemoveAt(i);
            }
             collisonRectanglesList.Add(new Rectangle((int)position.X + smallPaddleWidth, (int)position.Y + smallPaddleHeight * 2, smallPaddleWidth, smallPaddleHeight));
             collisonRectanglesList.Add(new Rectangle((int)position.X + smallPaddleWidth, (int)position.Y + smallPaddleHeight, smallPaddleWidth, smallPaddleHeight));
             collisonRectanglesList.Add(new Rectangle((int)position.X + smallPaddleWidth, (int)position.Y , smallPaddleWidth, smallPaddleHeight));

        }

now i want this to follow the paddle it self so i put this function in the update method
and made a simple texture so i can draw them and see where they are on the screen.
my problem is that when i call the creatCollisonRectangles() 1 of the rectangles paint it self in the middle and not in the place it should be.
any idea why?
this is when im not calling it in the Update method:

and this when i do:

(sorry for my english)


texts: Storing tile grid in a matrix: row major vs column major

texts:
I'm using a generic matrix container to store the tile grid for my RTS game.

This is where I am confused: a matrix is traditionally row major, i.e. matrix(0, 10) means 'at 0th row, 10th column.' A map on the other hand is 'column major,' i.e. grid(0, 10) intuitively means 'a tile at X=0, Y=10.'

This leads to a quite a few places where I need to swap X and Y to access proper element of the map.

I tried to make them both consistent (i.e. make a matrix column major or a grid row major) but that adds more confusion, maybe because I'm a slave of my habits.

How should I do this?


texts: Spin camera around origin/focus in Unity editor

texts:
I have used Blender a bit, and like the way the camera in the editor orbits around the focus/origin when dragging with middle click.

I've recently been using Unity a little and despise the camera controls; right-dragging sort of moves the camera's view a little and middle-dragging moves the camera along a plane. Not very good to get to different angles I'd like to see from.

Is there a way to set the Unity 3D editor's camera to work like Blender's?


texts: In a Tower defense game, how to do buffs/debuffs

texts:
The question is at the very bottom. If you understand Buffs/Debuffs in tower defense games then you should skip the bulk of this question and go to the bottom (seperated with the long line)

I plan on making an IPhone TD game. The fact that its an iPhone game isn't relevant but I am coding in Objective-c with Cocos2D.

I am relatively inexperienced in the field of game design so I'm looking for some advice from someone experienced in this field.

In tower defense, there are two things that are relevant to my question: towers/enemies (both have their own classes/children). They each have stats like hp, damage, speed, etc.

I want to add buffs/defuffs, for instance: Towers A,B and C each have 15 base damage. Tower D would be a buff tower with no damage, a tower with an AOE(area of effect) aura that gives 10% damage to all towers in range. Tower E might slow enemies in its AOE, a debuff. Stuff like that.

The same could go for enemies. Enemy A is a boss that has a slow aura that affects towers and slows their base attack speed or something along those lines.

So the question is, what would be the most effective way to implement this? If it was just towers then I would just mess around with the tower classes, but since tower classes and enemy classes are both affected, should I make a buff class?

TD games can consume quite a bit of memory with large amounts of creeps and towers, and buffs I feel like would also consume quit a bit... So I'm trying to be as effective as possible.


texts: Delta time causing comparison issues due to floating points

texts:
I am working on a game in Game Maker Studio: 2 and am using Delta Time for the time. I understand what it is, how to get it, and how to use it, but I am running into issues when I need to make comparisons that contain values that have been modified by Delta Time.

Example: an item from my game is moving along the x-axis at 2 pixels-per-sec. at 60 frames. The speed the item is moving is then modified by Delta Time, with the x-coord of the item effectively being 'x = 2 * delta'.

Now, I want to check for when the x-coord of the item has reached a certain spot, i.e. 'if(x = "specific spot on axis") {do something}.

The "specific spot on axis" that I am looking for is an integer (no digits after the decimal), but when using delta time, the x-coord is always off by usually miniscule amounts due to adjusting its position relative the speed of change of each frame. Instead of 'x = 12', it is 'x = 12.00387562' or 'x = 11.99943345'.

Right now, I'm thinking that just rounding 'x' at end of each step is all I have to do to fix this, but I also have a nagging feeling that I am possibly missing something right in front of my face. One reason being that, If I round the x-coord at every frame, does that not make a lot of the adjustments made by Delta Time pointless? Is there a (preferably easy and/or concise) way to do comparisons looking for values inside a certain range of digits after the decimal?

All help and insight is appreciated.


texts:
I'm trying to create a good designed "skill system" for my game, but curious if anybody knows a good design?

Skills can Heal,Damage ofc, they can be single target,multiple(chain), AOE.
Instant dmg/heal or overtime. some skills can do damage and heal together and so on.

Maybe a little bit to complex for me to start, but can anybody help me?

Update:

lets say i have a Character class, and each character ofc has hitpoints and also a method TakeDamage(float amountOfDmg,Character damage_causer);

should this TakeDamage(..) method be used inside each Skill class e.g.?:

class AnySkill
{
 public:
 void Execute()
 {
   *(somehow get the character who takes damage)*->TakeDamage(damage, *(somehow get the causer)*)
 }

 private:
 float damage;
}

Would this be a good design?

class Character
{
 public:
 void SetTarget(Character* target)
  {
    target_ = target;
  }
 void TakeDamage(float damage, Character* causer)
 {
   hit_points_ -= damage;
 }
  void UseSkill1()
  {
    skill1->Execute(this,target);
  }

private:
 Character* target_;
 AnySkill* skill1;
 float hit_points_
}

class AnySkill
{
 public:
 void Execute(Character* causer,Character* taker)
{
  taker->TakeDamage(damage_value,causer);
}

 private:
 float damage_value_;
 Character* target_;
}

And somewhere:

player->SetTarget(enemy);

if(skill1_key_pressed)
{
  player->UseSkill1();
}


texts: How can it be that if I click on rawimage it's getting the right file name from the hard disk ? I don't understand it

texts:
In this script once only I'm getting the all the files from the hard disk type png images.
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;

public class SavedGamesSlots : MonoBehaviour
{
    public GameObject saveSlotPrefab;
    public float gap;

    private Transform slots;
    private string[] imagesToLoad;

    // Start is called before the first frame update
    void Start()
    {
        imagesToLoad = Directory.GetFiles(Application.dataPath + "/screenshots", "*.png");
        slots = GameObject.FindGameObjectWithTag("Slots Content").transform;

        for (int i = 0; i < imagesToLoad.Length; i++)
        {
            var go = Instantiate(saveSlotPrefab);
            go.transform.SetParent(slots);

            Texture2D thisTexture = new Texture2D(100, 100);
            string fileName = imagesToLoad[i];
            MouseHover.savedGameFName = fileName;
            byte[] bytes = File.ReadAllBytes(fileName);
            thisTexture.LoadImage(bytes);
            thisTexture.name = fileName;
            go.GetComponent<RawImage>().texture = thisTexture;
        }
    }

    // Update is called once per frame
    void Update()
    {

    }
}

At this line I'm doing reference from another script to a public static variable:
MouseHover.savedGameFName = fileName;

Then in the MoueHover script that I'm using it calling it from each raw image event trigger I'm using also the mouse button down:
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class MouseHover : MonoBehaviour
{
    public SaveLoad saveLoad;
    public SceneFader sceneFader;
    public RawImagePixelsChange rawImagePixelsChange;
    public static string savedGameFName;
    public static string folder;
    public static bool loadingwithfolder = false;

    private bool loadGame = false;

    public void OnHover()
    {
        Debug.Log("Enter");
        rawImagePixelsChange.modifyPixels(0.3f);
        PlaySoundEffect();
        loadGame = true;
    }
    public void OnHoverExit()
    {
        Debug.Log("Exit");
        rawImagePixelsChange.restorePixels();
        loadGame = false;
    }

    private void Update()
    {
        if(loadGame)
        {
            if (Input.GetMouseButtonDown(0))
            {
                MenuController.LoadSceneForSavedGame = false;
                loadingwithfolder = true;
                folder = Path.GetDirectoryName(savedGameFName);
                StartCoroutine(sceneFader.FadeAndLoadScene(SceneFader.FadeDirection.In, "Game"));
                loadGame = false;
            }
        }
    }

    private void PlaySoundEffect()
    {
        transform.GetComponent<AudioSource>().Play();
    }
}

At this line :
if (Input.GetMouseButtonDown(0))

After clicking the mouse left button inside I'm using a break point on one of the lines and I see that the variable savedGameFName contains the correct clicked raw image full directory with the file name, for example:
d://screenshots//screen_1920x1080_2021-01-26_18-56-46.png
But how does it know to assign to the variable savedGameFName the correct file name of the clicked raw image? It's not a list or something, it's just public static string variable. and the only other using is in the first script when running the game once first time.
I don't understand it.
It's working fine!!! but I don't understand how.


texts: Disadvantages of using a singular scene in Unity

texts:
In my previous experience with Unity, I have had an organized level structure where each level instance was easily separated into a different scene.

For my current project, it would be much more natural to avoid such transitions, and instead disable or remove GameObject instances far from the player's position, and of course loading them in when necessary.

It strikes me that this must be how titles like Gone Home & Firewatch must have been made, and while my game won't be huge in scope, it will be bigger than those ("distance" wise).

Basically, I don't want to get halfway down this road and realize I've made a terrible mistake, so any input is appreciated. Are there disadvantages to using a singular scene in Unity?


texts:
I know yall are probably going to hate me.....but I can't figure out what im doing wrong, im trying to make a SIMPLE Vertex Grid (for Terrain) but I get a black screen for some reason And I can't figure out why. It does run, but I just get a black screen afterwards....I hate posting such huge code on this site but I figure if anyone can explain what the heck I did wrong i'd be able to understand a little bit better.

I think the problem....may be in the matrix, but my code is simple and im 100% sure im doing the Grid right because I took it from a working tutorial that does grids (but it's large and VERY confusing for a beginner, so I just took the appropriate code).

I know it's alot to look at (vars.h is very small) and main.cpp is pretty small too but I know it's still alot.....but im just completely stuck.

vars.h
http://pastebin.com/SupcqB8N

main.cpp
http://pastebin.com/vAnSUTpp

shaders.hlsl

cbuffer ConstantBuffer
{
    float4x4 matFinal;
}

struct VOut
{
    float4 position : SV_POSITION;
    float4 color : COLOR;
};

VOut VShader(float4 position : POSITION, float4 color : COLOR)
{
    VOut output;

    output.position = mul(matFinal, position);
    output.color = color;

    return output;
}

float4 PShader(float4 position : SV_POSITION, float4 color : COLOR) : SV_TARGET
{
    return color;
}


texts: Unity - Rotating image on button made button un-useable

texts:
I recently started trying to teach myself Unity2D development using some tutorials and something weird was happening last night while I was working on my project.

Basically I have an image that serves as a dialog window. On this image (as a child object) I added a button to essentially act as "next" button for paging through NPC dialog. I set the button to use an image of an arrow poiting to the right. This worked great, got the click method hooked up with no issues. The weirdness happenened when I added a second button.

I duplicated the first button and then, since I wanted it to be a previous button, just did a 180 degree rotation on the Y axis of the button to have it be reversed. When I did this though the button did not work at all. It acted as if it was disabled (click event never fired even though code was there). Ultimately, after fiddling with it for 30 minutes I decided the cause was because I had flipped the button on the Y axis (undoing this rotation caused it to work like I expected).

So my question is: Why did doing that rotation cause the button to be un-useable?

Note: I dont care about how to fix it to make it work, Ive decided to get rid of that button all together. Im really only interested in the mechanics behind unity that would cause the button to not work after being flipped. Also, if someone can point me to relevant links on the matter that would be great. My googling did not return anything useful however Im not sure I really googled it correctly.


texts: Is it "wrong" to build Unity games entirely with UI elements VS sprites?

texts:
I find myself coming on board a Unity project with an outsourced programming team. Our mobile game has a number of minigames and they have built them entirely out of UI elemetents, or raw images on only one or two canvas elements. Now, I know the term "wrong" is open to interpretation since the games are quite simple and they run fine on the modern devices we've tested them on.

However my somewhat perfectionist attitude often has me concerned about the "correct/best practice" way of doing things and I have a hard time letting go of the idea that this is not the best way to be developing the games. I look at the Unity best practices of not having too many elements in a canvas due to redrawing it anytime something changes, sprite renderers optimized polygon trimming as opposed to max rects to keep overdraw down, etc. And the response I get from the programming team is, "the screen-ratio ability of canvas elements makes it easy to handle different aspect ratios, so that's how we build games".

I don't want this to be a down voted "personal" question, so is there a more compelling reason to not build simple mobile games in this fashion? Or is it a case of if it works on targeted devices and isn't causing issues why not?
Thanks in advance for any replies,
Jaysin


texts: How can a game handle all characters at once?

texts:
This question is just to gain knowledge about how a game can handle so many characters at once. I am new to gaming so I beg your pardon in advance.

Example

I am creating a tower defense game in which there are 15 tower slots where towers are built and each tower ejects projectile at a certain rate; lets say that every second, 2 projectiles are created by each of the towers and there are enemies marching on the battlefield, lets say 70 (each with 10 types of attributes like HP, mana, etc., which will change as they move around the battlefield).

Summary

Tower Count = 15
Projectiles Created By Each Tower Per Second = 2
Total Number of Projectiles Created Per Second = 30
Units in Battlefield Count = 70

Now, does the game handle those 30 projectiles and 70 units by handling them on 100 different threads (which is too much for a PC) or 1 thread that moves all of them, reduces their value, etc. (which will be kind of slow, I think)?

I do not have a clue about this so can anyone guide me on how this will work out?


texts: How to use assimp textures with openGL/getting a better understanding

texts:
I recently learned how to load a model to openGL using assimp, but I am having trouble figuring out how to do lighting calculations on this model. Previously with my own created objects I would set the normals manually and pass them to the shader as attributes. Then I would use one diffuse and one specular texture passed as uniforms for lighting.

I'm trying to do the same with a model, but I can't seem to get it to behave correctly. When I use my own objects everything works normally, but when I try to draw the model some weird lighting occurs.

Here's how the model should look:

But mine looks like this:

What confuses me in particular is that assimp loads both normal vertices and normal textures. I'm not sure what the difference between them is or if there is more about model loading that I've yet to learn, which is entirely possible since I don't know much about heightmaps and other things yet.

Anyway, here's what I'm doing for calculations:

void main()
{
    vec3 normal = normalize(Normal);
    vec3 viewDir = normalize(viewPos - fragPos);

    vec3 result;

    for (int j = 0; j < sizeModels; j++)
        result += CalcDirLight(DirLights, normal, viewDir, models[j]);

    FragColor = vec4(result, 1.0);
}

vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir, Material textures)
{
    vec3 lightDir = normalize(-light.direction);
    // diffuse shading
    float diff = max(dot(normal, lightDir), 0.0);
    // specular shading
    vec3 reflectDir = reflect(-lightDir, normal);
    float spec = pow(max(dot(viewDir, reflectDir), 0.0), textures.shininess);
    // combine results
    vec3 ambient = light.ambient * vec3(texture(textures.diffuse, Tex));
    vec3 diffuse = light.diffuse * diff * vec3(texture(textures.diffuse, Tex));
    vec3 specular = light.specular * spec * vec3(texture(textures.specular, Tex));
    return (ambient + diffuse + specular);
}

Notice that I'm providing my own diffuse values to the DirLight struct. The Material struct is what contains the diffuse and specular textures, as well as a shininess float.

For reference I am following guides from this site:
https://learnopengl.com/

Any help would be appreciated!


texts: What is the average cost of hiring a programmer mid development to implement online features?

texts:
I guess my real question is more specific than that.

I'm working on a game by myself and it has 2 player local multiplayer implemented already (it's a pretty simple 2D arcade-platformer type game). I'd like to add online multiplayer into the mix but figure it'd be more within my time frame to hire someone who already has the know-how than to learn it myself at this time.

I have no idea what the average cost of something like this would be. I figure the programmer would have to go through the original code first to get their bearings (which would take time and some back-and-forth), figure out the best way to host the players, and then centralize the already made local code around net play. Or maybe I'm way off on this. Maybe it'd be faster to learn it myself than to acquaint someone else with the game.

Any help or insight would be appreciated.


texts: Most efficient way to create/modify terrain in real time?

texts:
In my game players can modify terrain in real time, but I am not sure what is best practice for this scenario.  I have redesigned and refactored the way the player does this a few times, and am feeling at a loss.

Initially I created small blocks of terrain as GameObjects, but this I quickly realised was grossly inefficient.  Later I devised a system which procedurally generated the 3d mesh by creating vectors and tris for a much larger terrain chunk GameObject, but this is also unfit for purpose.  As I would like the player to be able to place new terrain pieces (replacing old) from premade 3d art assets.

The question is how should one string these pieces together into one map, so that the player can enjoy a large map with a fine level of control?  And for this not to break the game with inefficiency?  Consider that the terrain system is composed of blocks of premade terrain segments, like river or cliff sections.  I feel like I'm missing some basic knowledge of how and when to merge 3d meshes into GameObjects for this purpose?


texts: Changing the hit box position in melonjs

texts: I'm trying to follow the platformer tutorial from the melonJS website, but using assets from kenney.nl instead of the tutorial assets. My problem is that the hit box is always centered at the center of the entity, and I need to move it. I've looked through the docs, and I can not figure out how to do it.


texts: Moving camera, or camera with discrete "screens"?

texts:
I'm making a game with a friend, but having trouble deciding on a camera style.

The basic idea for the game, is having a randomly generated 2-dimensional world, with settlements in it. These settlements would have access to different resources, and it would be the job of the player to create bridges and ladders and links between these villages so they can trade. The player would advance personally by getting better gear, fighting monsters and looking for materials in the world, in order to craft and trade them at the settlements.

My friend wants to use an old-style camera, where the world is split into a discrete number of screens that the player moves between. Similar to early Zelda dungeons, or Knytt Stories. This is opposite to me, as I want a standard camera that follows the player around as I feel the split-screen style camera limits the game.

Can anyone argue the case either way? We've hit a massive roadblock here and can't seem to get past it.


texts: problem on enable and disable GameObject

texts:
I'm trying to enable and disable GameObject (canvas) using this code:

public int canvaslevel = 1;
public GameObject one;
public GameObject two;
public GameObject three;

void Update(){
    if(canvaslevel=1){
        one.SetActive(true);
        two.SetActive(false);
        three.SetActive(false);
    }
    if(canvaslevel=2){
        one.SetActive(false);
        two.SetActive(true);
        three.SetActive(false);
    }
    if(canvaslevel=3){
        one.SetActive(false);
        two.SetActive(false);
        three.SetActive(true);
    }
}

but it doesn't work!!!

error:

  Cannot implicitly convert type int' tobool'


texts: NullReferenceException when importing model

texts: This error most certainly is not caused by an error in my Script. I don't know where it came from, I don't know why it's here and I don't understand what problems it causes because everything seems to work just fine. But I've been getting this error for quite a while now every single time I run the Game Engine:


texts: Why do I keep getting two exceptions: Slope Limit must be smaller than 90 degrees and offset must be less?

texts:
The two exceptions/errors in the editor:

Slope Limit must be smaller than 90 degrees
Step Offset must be less or equal to  +  * 2

In the Hierarchy I have a a First Person Character named Player under it as child a Player Camera and as child of the Player Camera a NAVI object.

I changed in the Inspector the NAVI scale to 0.01 on XYZ:

And I have another empty gameobject in the hierarchy with a script attached to it:

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

public class ObjectsManipulation : MonoBehaviour
{
    //Camera
    public Camera playerCamera;

    //Scaling
    private Scaling scaling;

    //Lights
    public DimLights dimlights;
    private Coroutine lightCoroutine;

    //Colors
    private Colors colors;

    //Rotating
    public bool stopRotation = false;
    private Rotating rotating;

    private void Start()
    {
        scaling = GetComponent<Scaling>();
        scaling.Inits();

        colors = GetComponent<Colors>();
        colors.Start();

        rotating = GetComponent<Rotating>();
    }

    // Use this for initialization
    void Update()
    {
        //Scaling
        if (Input.GetKeyDown(KeyCode.F))
        {
            //Flip the scale direction when F key is pressed
            scaling.scaleUp = !scaling.scaleUp;

            //Stop old coroutine
            if (scaling.scaleCoroutine != null)
                StopCoroutine(scaling.scaleCoroutine);

            if (lightCoroutine != null)
                StopCoroutine(lightCoroutine);

            //Scale  up
            if (scaling.scaleUp)
            {
                //Start new coroutine and scale up within 5 seconds and return the coroutine reference
                rotating.rotateBack = false;
                scaling.scaleCoroutine = StartCoroutine(scaling.scaleOverTime(scaling.objectToScale, scaling.maxSize, scaling.duration));
                if (dimlights.lightsOnOff == false)
                    lightCoroutine = StartCoroutine(dimlights.dimLightOverTime(1, scaling.duration));
            }

            //Scale Down
            else
            {
                //Start new coroutine and scale up within 5 seconds and return the coroutine reference
                rotating.rotateBack = true;
                scaling.scaleCoroutine = StartCoroutine(scaling.scaleOverTime(scaling.objectToScale, scaling.minSize, scaling.duration));
                if (dimlights.lightsOnOff == false)
                    lightCoroutine = StartCoroutine(dimlights.dimLightOverTime(0, scaling.duration)); ;
            }
        }

        //Rotate
        if (Input.GetKey(KeyCode.R) && !scaling.scaleUp)
        {
            rotating.x += Time.deltaTime * rotating.rotationSpeed;
            scaling.objectToScale.transform.localRotation = Quaternion.Euler(0, 0, rotating.x);
            rotating.keyPressed = true;
        }
        if (Input.GetKeyUp(KeyCode.R))
        {
            rotating.keyPressed = false;
        }

        if (!rotating.keyPressed && !scaling.scaleUp && rotating.rotateBack == false
            && DetectInteractable.detected == false)
        {
            scaling.objectToScale.transform.rotation = Quaternion.LookRotation(playerCamera.transform.forward);
        }

        if (DetectInteractable.detected == true && !scaling.scaleUp && stopRotation == false)
        {
            rotating.x += Time.deltaTime * rotating.rotationSpeed;
            scaling.objectToScale.transform.localRotation = Quaternion.Euler(0, 0, rotating.x);
        }
    }
}

In this script in the Inspector in the Scaling part I changed the Min Size on xyz also to 0.01

Since then Im getting this exceptions.

Tried to google for a solution , But not sure how to fix it yet.


texts:
I have a five game objects (ornament1, ornament2, ornament3, ornament4 and ornament5) and  two buttons ("Next" and "Previous"). When I click "Next", the object should change from ornament1 to ornament2. When I click "Next", again, it should change from ornament2to ornament3; when I then click "Previous" it should change from ornament3to ornament2.

I have the "Next" button working, but the "Previous" button is not working. How do I change the game object on a button click?

Here is my code:

if(GUI.Button(new Rect(10, 20, 80, 50), "Ornament1"))
{
    Debug.Log("hhhhhhhhhhhhhhhhhhhhhhh" + countbool);

    if(count==0)
    {
        Debug.Log("hhhhhhhhhhhhhhhhhhhhhhh");
        ornament1.transform.position = new Vector3(-0.1428955f, -0.1894745f, 4.108555f);
        ornament1.SetActive(true);
        ornament2.SetActive(false);
        ornament3.SetActive(false);
        ornament4.SetActive(false);
        ornament5.SetActive(false);
        count++;
    }
    else if(count == 1)
    {
        ornament2.transform.position = new Vector3(-0.1428955f, -0.1894745f, 4.108555f);
        ornament2.SetActive(true);
        ornament1.SetActive(false);
        ornament3.SetActive(false);
        ornament4.SetActive(false);
        ornament5.SetActive(false);
        count++;
    }
    else if(count == 2)
    {
        ornament3.transform.position = new Vector3(-0.1428955f, -0.1894745f, 4.108555f);
        ornament3.SetActive(true);
        ornament1.SetActive(false);
        ornament2.SetActive(false);
        ornament4.SetActive(false);
        ornament5.SetActive(false);
        count++;
    }
    else if(count == 3)
    {
        ornament4.transform.position = new Vector3(-0.1428955f, -0.1894745f, 4.108555f);
        ornament4.SetActive(true);
        ornament3.SetActive(false);
        ornament1.SetActive(false);
        ornament2.SetActive(false);
        ornament5.SetActive(false);
        count++;
    }
    else if(count == 4)
    {
        //ornament1.SetActive(true);
        ornament5.transform.position = new Vector3(-0.1428955f, -0.1894745f, 4.108555f);
        ornament5.SetActive(true);
        ornament3.SetActive(false);
        ornament1.SetActive(false);
        ornament2.SetActive(false);
        ornament4.SetActive(false);
        count++;
    }
}


texts: So, I'm developing a 2D game where I'm dealing with sprites with vastly different scales. I'm attempting to represent the scales accurately, where I have a 10-m wingspan fighter and a 1400-m carrier that launches it. The trouble I'm running into, is if I draw the fighter out to be 100px wide, then the carrier needs to be 14,000 px. I believe the XNA game engine I'm running supports only up to 8096x8096 sizes, so I'm a little unsure what to do. Thank for your help, guys!


texts: Outputting wrong colours from pixel shader in Direct3D

texts: The output from the pixel shader in Direct3D is four floats, normalized 0-1 for each channel (RGBA). But what happens if these floats haven't been normalized correctly and are above 1?


texts: Hinge joint annoying wheels rotation in Unity

texts:
I try to made a little skate game prototype in Unity 5 and I just encountered an issue. I added a hinge joint between the board and each of the wheels couples (front and behind) so the board can move forward. My problem is that when I try to rotate a wheels couple around the red axis (see picture below), the hinge joint seems to hindered the rotation, however I'm not sure. Is someone see how to do the trick ?

Here is a sample of my source code (0 index is the front couple of wheels, 1 is the behind) :

private void Turn(float hAxis) {
        wheelsTransform[0].Rotate (wheelsTransform[0].right * hAxis * turnAngle * Time.deltaTime, Space.Self);
        wheelsTransform[1].Rotate (wheelsTransform[1].right * hAxis * -turnAngle * Time.deltaTime, Space.Self);
    }

Thanks in advance !


texts: GUI.Button inside GUI.Window not responding

texts:
I am trying to do some GUI work with unity but am having some issues.

I call a window with this code:

fortuneRect = GUI.Window(0, fortuneRect, fortuneWindow, "Your future");

and inside the window I have a button

if(GUI.Button(new Rect(10, 10, 150, 20), "save fortune")){
       Debug.Log("save fortune button press");
       writeToFile("Button pressed!", "fortune.txt");
       Debug.Log("After save fortune button press");
    }

but the button doesn't fire any of its events on click. I tried commenting out the writeToFile but even with only Debugs in the body it doesn't fire.


texts: Object has its heading stored as Euler angles. After it makes a turn, how do I calculate the new angles?

texts:
Assume said object is an aircraft. I store three angles (in degrees) that describe where it's headed: yaw, pitch and roll - in that order. Let's say the plane is flying vertically, upwards. The angles would then be: (0, 90, 0). Then, I command the plane to turn left; this results in the following angles: (0, 0, 90).

Given the plane's current angles and a command (turn left, right, up, or down), how can I calculate its new angles?
Would it be easier if I were using a directional vector and an extra "up" vector (i.e., the normal of the surface that cuts the plane in half, horizontally)?


texts: How to convert the unity standard assets first person controller to rigidbody?

texts: I'm using the standard assets first person controller but I just realised I need the rigidbody controller instead. I don't want to switch them out though because I've made a whole bunch of customizations to the first person controller script and I don't want to redo all of them. Is there an easy way to convert it into a proper rigidbody character?


texts: Why loading ~250mb of compressed texture data spills Out of memory error on Windows

texts:
I am making SDL2/OpenGL 2D game for Windows with a lot of pre-rendered sprites. When testing on my laptop I got SDL_Surface creation failed: out of memory error during loading assets.

Windows' Application Manager on other machine shows that my game in stress uses less then 170 mb of ram memory and MSI Afterburner shows that vram usage for entire system is below 800 mb.

My laptop has 8 gb of RAM and 2048 mb of vram (GeForce 840 M).

I am obviously doing something terribly wrong, but I don't know wheres my ram usage counting technique is wrong, or maybe for some reasons I have less memory then available on system, or something completely else is happening. But I don't know where to search for.

I will gladly post some code if I need to, but I don't know which parts will be useful in diagnosing the problem.

One more thing, I am using GL_COMPRESSED_RGBA_ARB for all textures

Edited

It's not exactly the same situation as what's described here. I've already measured vram usage, and numbers are way below available count, yet still I get out of memory error. So, the question is: "How measure properly vram usage", not "How measure vram usage", as in other question. I am not a native English speaker, so maybe there is some cloud in my title - I will gladly accept correction for title

Edited

I reckon the image load procedure might be useful here, since it is heavily related to issue.

Game::Texture * Game::Asset::GetTex(const UString & path)
{
    Texture * ret = _assetsTex[path];
    if (ret)
        return ret;

    const UString & absolutePath = GetAbsolutePath(path);
    SDL_Surface * surface = IMG_Load(absolutePath.GetCStr());

    if (!surface)
        ERR(_U("Failed to load surface: #1#"), UString::FromA(IMG_GetError())); // Here's my problem!

    int bpp = surface->format->BytesPerPixel;
    UInt8 * pixels = (UInt8 *)surface->pixels;

    if (bpp != 3 && bpp != 4)
    {
        WARN(_U("Texture '#1#' is not 24 bpp or 32 bpp! Aborting load..."), path);
        SDL_FreeSurface(surface);
        return nullptr;
    }

    GLuint tex;
    glGenTextures(1, &tex);
    glBindTexture(GL_TEXTURE_2D, tex);

    if (bpp == 3)
        glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ARB, surface->w, surface->h, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels);
    else if (bpp == 4)
        glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ARB, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    ret = new Texture(tex, surface->w, surface->h);

    SDL_FreeSurface(surface);

    _assetsTex[path] = ret;

    return ret;
}

Edited

I moved from SDL_Image to stb_image for image load, but I still got out of memory error message

Edited

I've installed VS Studio 2015 on my laptop and found out:

Task Manager shows application eats up 650 mb in the moment of Out of memory casted
GetProcessMemoryInfo returns PeakWorkingSetSize ~720 mb and WorkingSetSize 650 mb as well
But Visual 2015 UI (Debug Diagnostic, memory usage) shows that application actually consumed 1.7 gb. Even if this is true and both former are not, there is still plenty of room for allocations (application is 32 bit, there are 8 gb of on-board memory, not counting page file)
I tried to convert png -> tga and load them up, to check if png uncompressing is eating memory, but the result was exactly the same, the same Out of memory error
Out of memory is spit in png load function which has nothing to do with OpenGL and GPU at all. I am retagging and retitleing the post


texts:
I have a set of 3D points. All these points are on the same plane. I have the normal of the plane.

Now I need to rotate them in such a way that the Z value of all these points become zero. (that is, 3D to XY plane)

I have Googled a lot. I got very few results and most of them are very much mathematical. Few are about projection and few are with solution with OpenGL APIs.

I have seen this solution:
Rotating 3d plane to XY plane

Based on this, I have implemented something like this:

public static List<Vector3D> RotateCoplanar3DPointsToXY(IList<Vector3D> points, Vector3D planeNormal)
        {
            var zAxis = new Vector3D(0, 0, 1);
            var rotationAxis = zAxis.Cross(planeNormal);
            rotationAxis.Normalize();
            var rotationAngle = (float)Math.Acos(zAxis.Dot(planeNormal));
            var matrix = Matrix4x4.FromAngleAxis(rotationAngle, rotationAxis);
            var newPoints = new List<Vector3D>();
            for (var i = 0; i < points.Count; i++)
            {
                var p = points[i];
                var newPoint = p.Transform(matrix);
                newPoints.Add(newPoint);
            }
            return newPoints;
        }

But this implementation is not working.

I have another implementation below based on @Bálint's comment. This is also not working.

public static Vector3D Cross(Vector3D a, Vector3D b)
        {
            return new Vector3D(
                a.Y * b.Z - a.Z * b.Y,
                a.Z * b.X - a.X * b.Z,
                a.X * b.Y - a.Y * b.X);
        }

        public static Matrix4x4 GetMatrixForRotatingCoplanar3DPointsToXY(Vector3D planeNormal)
        {
            var Z_NORMAL = new Vector3D(1, 0, 0);
            var d = planeNormal;
            var u = Z_NORMAL;

            var r = Cross(d, u);
            var t = Cross(r, d);
            var matrix = new Matrix4x4(
             r.X, t.X, d.X, 0,
             r.Y, t.Y, d.Y, 0,
             r.Z, t.Z, d.Z, 0,
             0, 0, 0, 1);

            return matrix;
        }


texts: Most Efficient Way to Check Player Distance from a Line?

texts:
I need to get the player's distance from a line (or the outside edges of an Gameobject, if that's easier) throughout their time in the game. I need the code to be fairly simple because I'm a novice (though if it's thoroughly explained, I can implement more complex solutions).

Is there an optimal way to do this that doesn't involve resorting to using the full formula for a point to a line? Because I think I might have some trouble implementing that in unity's system (translating to/from coordinate systems, maybe).

Thanks!


texts: 2D HUD overlay drawing based on 3D coordinates and camera azimuth and elevation

texts:
Assume you have the 3d coordinates of the player and another unit N as well as the azimuth and elevation of a camera always looking at the player. In the following illustration the sun would be the camera of course:

(source: permetix.com)
Let's say one wants to draw something on a different transparent window (not using the game window or any hooks) that is always displayed on top of the unit. An example would be TurboHUD for Diablo. In the linked video you can see that it displays affixes using textboxes right on top of the blue elite mobs.
In Diablo doing this is much simpler since the camera cannot be rotated and moved thus only simple projections depending on the distance are necessary, but what about situations with more degrees of freedom? How can one estimate 2d coordinates to draw at that match the position of the 3d units on the screen without access to more than described in the first paragraph? What is the mathematical background and what are the necessary computations?


texts: Convert triangle mesh to group of line segments

texts:
I have a 3D .OBJ model file that is loaded in my OpenGL ES 2 Android application using ASSIMP library. All the faces are triangulated.

I want to draw the wireframe for my mesh. In OpenGL we have something called glPolygonMode that enables wireframe drawing just in one line.

Is there a function I can use to convert those triangulated faces into a pair of Line segments and then draw these line segments using GL_LINES?

Any better approach to draw wireframe for 3D mesh in OpenGL ES 2 would be appreciated. Maybe something based on GLSL shader.


texts: How to combat exponential growth in sprite messaging?

texts:
In my 2D platformer game, I have a number of sprites moving around the world. When two sprites collide with each other, I calculate how deep the collision is and then call a virtual method on both sprites that lets them handle the collision (for instance, a fireball would kill the other sprite).

Each sprite is checked for collision against each other sprite "near" it. "Nearness" is determined through my lazy Quadtree which is really just a list of evenly-sized cells that objects are sorted into.

However, the number of virtual method calls (or messages) increases exponentially with the number of sprites colliding at once, leading to <1fps with only about 120 sprites onscreen. If three sprites overlap each other, six messages need to be send. Four sprites need 12 messages, and twenty sprites need 380.

Just checking for collisions can be costly, even with the game world being divided into cells - if 30 sprites are in the same cell, 900 collision checks are required.

Now, I don't expect 120 onscreen sprites to be the norm - it'd probably be closer to 20, but I'm really concerned with how little range there is between playable and slideshow.

I strongly suspect that if I really want each sprite to message each other, there's no way to do any better than N*(N-1)/2 messages. Is there anything I can do to reduce the costs?

Edit: On request, here's the relevant code:

foreach (var collidableSprite in Sprites.GetItemsNearItem(sprite))
{
    if (Object.ReferenceEquals(collidableSprite, sprite)) { continue; }

    BoundingRectangle hitboxA = sprite.Hitbox;
    BoundingRectangle hitboxB = collidableSprite.Hitbox;

    Vector2 intersectA = hitboxA.GetIntersectionDepth(hitboxB);
    Vector2 intersectB = hitboxB.GetIntersectionDepth(hitboxA);

    if (!intersectA.IsNaN() && !intersectB.IsNaN())
    {
        sprite.HandleSpriteCollision(collidableSprite, intersectA);
        collidableSprite.HandleSpriteCollision(sprite, intersectB);
    }
}

Essentially, for each sprite in the world, for each sprite near this sprite (in the same grid cell(s)), check to see if there's an intersection and how deep it is. If there is, call the collision handlers on both sprites.

internal IEnumerable<T> ItemsInCells(SparseCellRange range)
{
    foreach (T item in items)
    {
        if (GetCellsItemIsIn(item).Equals(range))
        {
            yield return item;
        }
    }
}

internal IEnumerable<T> GetItemsNearItem(T item)
{
    SparseCellRange range = GetCellsItemIsIn(item);

    return ItemsInCells(range);
}

Here's the code that checks for nearness. The SparseCellRange is a pair of Vector2 instances for TopLeft and BottomRight cell numbers.


texts:
Im trying to make a solid object to stay always in the terrain level, but I am facing some problems. The terrain is not flat, I mean, it can have mountains and craters for example. I just have a ASE (ASCII Scene Export) file of the 3D map. The problem is, I know what is the object's X & Z values are, but I don't know how to determine the Y value for that specific location. I suppose I'd need Y value to always stays with the ground level, so I can realistically make the object walk through the cratter or the mountain.

The only info I have of the map (which I think it should help but I'm not that good in physics or in math, so I can't do much with it) is some vertex coordinates, like:

*MESH {
    *TIMEVALUE 0
    *MESH_NUMVERTEX 5424
    *MESH_NUMFACES 8357
    *MESH_VERTEX_LIST {
        *MESH_VERTEX         0  32472.1055  52576.4922  1245.4102
        *MESH_VERTEX         1  32660.6992  52576.4922  1245.4102
        *MESH_VERTEX         2  32472.1055  52632.8086  1245.4102
        *MESH_VERTEX         3  32660.6992  52632.8086  1245.4102
        *MESH_VERTEX         4  32467.2617  52576.4922  1550.3711
        *MESH_VERTEX         5  32607.6055  52576.4922  1550.3711
        *MESH_VERTEX         6  32467.2617  52632.8086  1550.3711
        *MESH_VERTEX         7  32607.6055  52632.8086  1550.3711
        *MESH_VERTEX         8  32578.9648  52576.4922  1396.7617
....

*MESH_FACE_LIST {
        *MESH_FACE         0:    A:         7 B:         6 C:         4 AB:    1 BC:    1 CA:    1   *MESH_SMOOTHING 1  *MESH_MTLID 0
        *MESH_FACE         1:    A:         4 B:         5 C:         7 AB:    1 BC:    1 CA:    1   *MESH_SMOOTHING 1  *MESH_MTLID 0
        *MESH_FACE         2:    A:        15 B:         0 C:         1 AB:    1 BC:    1 CA:    1   *MESH_SMOOTHING 1  *MESH_MTLID 0
        *MESH_FACE         3:    A:         1 B:        12 C:        15 AB:    1 BC:    1 CA:    1   *MESH_SMOOTHING 1  *MESH_MTLID 0
        *MESH_FACE         4:    A:        12 B:         1 C:         3 AB:    1 BC:    1 CA:    1   *MESH_SMOOTHING 1  *MESH_MTLID 0
        *MESH_FACE         5:    A:         3 B:        13 C:        12 AB:    1 BC:    1 CA:    1   *MESH_SMOOTHING 1  *MESH_MTLID 0
        *MESH_FACE         6:    A:        13 B:         3 C:         2 AB:    1 BC:    1 CA:    1   *MESH_SMOOTHING 1  *MESH_MTLID 0
        *MESH_FACE         7:    A:         2 B:        14 C:        13 AB:    1 BC:    1 CA:    1   *MESH_SMOOTHING 1  *MESH_MTLID 0
        *MESH_FACE         8:    A:        14 B:         2 C:         0 AB:    1 BC:    1 CA:    1   *MESH_SMOOTHING 1  *MESH_MTLID 0
        *MESH_FACE         9:    A:         0 B:        15 C:        14 AB:    1 BC:    1 CA:    1   *MESH_SMOOTHING 1  *MESH_MTLID 0
....

Should I take all the vertices and faces and draw the whole map to simulate the object walking server-side to pass the correct Y values to the client, or can I use somekind of math equation to get them? I don't think it would be wise to "render" the map in the server aswell...


texts:
I don't really think this is an issue with the fact that UDP can drop packets (I'm using Lidgren and using ReliableInOrder), but basically, in my game, the client send the input keys (if forward is prsesed, backward is pressed, etc)

Now, when lag occurs, it's not noticeable at all if the packet that says "I'm pressing forward" right now is behind schedule, because I have interpolation.  However, it's really annoying when you press the space bar (jump button), and nothing happens because the packet was dropped and Lidgren needs to resend it.

How can I fix this?  Please keep in mind that the server controls all position data to prevent hacking, so I can't just make jumping client-sided and send the position.

Thanks!


texts: What is the best approach for networking a basic HTML5 pong game?

texts:
I'm working on the design of a basic multiplayer HTML5 pong game, and I have a very basic question about architecture.

The implied physics is very basic, and the movements are not a problem. The players will be connected to the server via sockets, and the refresh rate is controlled in order to make things run smoother. My problem is with the ball movement. Where should I put the ball logic?

If I run logic on the client sides, the balls may be desynchronized.
If I run all the logic on one client side, acting as a host, this could work; but I don't know if this is a good practice.
I could run the logic on the server side, but I think that I will replicate all the physics and rules for the game that I can have with a simple javascript framework for game development.

What is the best approach, here?


texts: What is the maximum number of shaders I can have in OpenGL 4?

texts:
What is the maximum limit of shaders I can have on the GPU?

With 1000 different objects, I might have 1000 * 5 shaders (vertex, tcs, tes, geo, frag) on the GPU at a time. Though only one will be active at once, I wonder what the upper limit is.


texts: What is the memory impact of having a pointer to the containing class type as a member of that class?

texts:
If I have a class called Something, what will the consequences for memory be if I include, in that class, a pointer to another object of the same class? So if the objects ThingOne and ThingTwo are both Something objects, ThingOne's contained pointer could point to ThingTwo (and vice versa, I assume)? I am trying to create a very simple alternative to both typical arrays (I need something more dynamic) and classic vectors (they keep gumming up my work. Please do not misinterpret this question as asking for help on vectors, though).

Needless to say, the pointers would be empty in the class, only to be set when an instance of the object has already been created.


texts:
I got the following code :

public ParticleSystem PS;
public GameObject origin;
public float thrust = 1.0f;
public GameObject bullet;
private GameObject _bullet;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
    if (Input.GetMouseButtonDown(0))
    {
        Debug.Log("Pressed left click.");
        PS.Play();
        _bullet = Instantiate(bullet, origin.transform.position, origin.transform.rotation);
        _bullet.GetComponent<Rigidbody2D>().AddForce(origin.transform.forward * thrust);
    }
}

Where everything is working except the AddForce, the bullet is just dropping out of my weapon. I've made some research and my script seems to be correct. The bullet has attached a circle collider and a rigidbody2D.

Update: This did not change anything :

_bullet.GetComponent<Rigidbody2D>().AddForce(origin.transform.forward * thrust, ForceMode2D.Impulse);

And this neither :

_bullet.GetComponent<Rigidbody2D>().velocity = origin.transform.forward * thrust;

It's weird, because all of these should work actually.


texts: Linear algebra: Are vectors that define a game object considered to be a subspace?

texts:
In Linear-algebra a subspace is a collection of vectors that when added with each other or scaling would result in another vector in that same subspace.
How does subspaces relate to objects/players within the game world?
An object (player or enemy) in a game itself is just a collection of vertices that can be defined as a collection of vectors right? Does that mean that each object is also a subspace?
If I scale one object to be large enough to overlap/collide with another object does that mean those two objects are still in their own subspaces?


texts: How can I make a look around effect of the player some kind of cutscene?

texts:
I want that at some point in the game the player will be looking over the view out of the window.
So I added a new Camera and positioned the camera close to the window.
Then using a small script I'm turning the Camera on.

But after turning the camera on I wan to make that the camera will rotate around the window area so it will give a natural feeling that the player is looking over the view outside.

And the script that is attached to another GameObject that activating the Camera:

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

public class ItemAction : MonoBehaviour
{
    public Camera viewCamera;

    private void Update()
    {

    }

    public void ViewCamera()
    {
        viewCamera.enabled = true;
    }
}

The part I'm using is the ViewCamera method.
But I messed it up.
But the idea is after turning on the Camera to make it feel like looking around the view outside.

How can I make the camera move first to one direction and then mirrored to the other direction ?

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

public class ItemAction : MonoBehaviour
{
    public Camera viewCamera;
    public float Speed;

    public void ViewCamera()
    {
        viewCamera.enabled = true;
        StartCoroutine(animate());
    }

    IEnumerator animate()
    {
        while (transform.localEulerAngles.y > -45)
        {
            transform.Rotate(0, -Time.deltaTime * Speed, 0);
            yield return null;
        }
        //and then possibly the same but mirrored to look in the other direction
        while (transform.localEulerAngles.y < 45)
        {
            transform.Rotate(0, Time.deltaTime * Speed, 0);
            yield return null;
        }
    }
}

The way it is now it's just keep rotating to the same direction nonstop.


texts: How do you reference one game object from another?

texts:
I am trying to reference a game object that was created in the editor and added to the scene (not created dynamically).  How can I reference this object in a script added to another gameobject?

For example I have a Mesh called QuantumCold_B (in the editor), and I try to get its position in a script to be added to First Person Player, but instead I get

  Unknown identifier ('QuantumCold_B').

Here is my script:

function Update () {
   transform.RotateAround(QuantumCold_B.position, Vector2,20 * Time.deltaTime);
}

Also is position the right way to get the Vector position on QuantumCold_B?


texts: Backend for data-driven multiplayer game

texts:
I am working on a match-based (5v5) multiplayer steam game that is similar to TF2, LoL, Dota 2, etc.

I am planning a data-driven approach where character/abilities/items/etc are defined in data (JSON). This will allow for easy patching to constantly balance the game.

So I have something like the following. (obviously simplified)

{
    "Troll": {
        "name" : "Troll",
        "health" : "100",
        "abilities" : [
            {
                "name" : "ClubSwing",
                "damage" : "50"
            },
            {
                "name" : "FootSmash"
                "damage" : "100"
            }
        ]
    },
    "Orc": {
        "name" : "Orc",
        "health" : "50",
        "abilities" : [
            {
                "name" : "SwordSwing",
                "damage" : "10"
            },
            {
                "name" : "ArrowShoot",
                "damage" : "25"
            }
        ]
    }
}

I am wondering what the best practice way is for storing this data. I obviously can't store it client-side or the player will be able to cheat. Is it normally stored in the database? I haven't setup any backend for my game yet.
Should I setup a nodejs server with a nosql database like mongodb to be the master of this data? And then build a REST API on top of that for reading this data?

I also need to write some things to a database. Such as the users rank, items, game stats, etc.

Would it be better to have two separate databases? One for reading gameplay data like I have above and another reading/writing user information (stats, rank, items, etc.)

Or would it be wiser to use a single database? Would you recommend nosql or sql based?

Note: The game engine I'm using is unreal engine 4. Currently I am using a listen server (peer-to-peer), but think it may be necessary to eventually use the dedicated server instead.


texts: Attach an Animated Texture to a Character in Unity

texts: Is it possible to have an animated texture of facial features on a characters face in unity? (I haven't made the game yet, I'm researching).  I would like to achieve a cartoon effect.


texts: How can I implement a command system for a point-and-click style adventure game?

texts:
I'm making a point and click adventure game, and I'm currently trying to figure out the best way to implement a command system.

Assume a Monkey Island or Maniac Mansion style interface, with a palette of verbs, and objects in the scene and in the inventory. Clicking on these, you build up a sentence to execute.

for example, you might click look at and then a tree to get "look at tree" or click on an apple, and then give, and then a girl, to get "give apple to girl".

There are three possible forms of a sentence:

verb, for example "save"
verb noun, for example "pick up apple", "look at octopus"
verb noun noun, for example "give pickle to rabid dog", "use crowbar with pickle jar"

In different situations, I'll want the action to be carried out to be defined by different objects.

For example, for the give verb, there might be a default action defined that makes the character say something like "I'd prefer to hang on to that", or the rabid dog might define an action where it eats anything you attempt to give it.

If the interface is to work like Maniac Mansion, then you build the sentence, and then tell it to execute (in Maniac Mansion, by either clicking the sentence, or clicking again on the last thing you clicked on).

If it's to work like Monkey Island, the sentence executes as soon as it's complete, which poses a problem for verbs like use which might sometimes take one noun, and other times two.

So how would you implement a system that handles this?


texts:
Is there a way in Unity to change the animation speed of an animation managed by an animator controller (Mecanim)?

I'd like to do that at runtime so that I can speedup and slow down an animation based on conditions in code.


texts: Unity-UI not scaling correctly on android

texts:
My UI appears extremely small when i build and launch my game on my android device. Im working with unity 4.6. I've tried changing the UI scale mode of my canvas to all 3 types. Scale with screen size option and constant physical size option makes it too big. Constant pixel size makes it too small.
With constant pixel size this is what it looks like on my mobile:

I could increase the scale factor but then it looks like this on PC. Also, I don't think it would look right on a tablet then.


texts: How to remove an element from the scene while keeping it in array?

texts:
I combined cube meshes to make a big one. I stored the info of every cube in an array within a list of chunk. Now i want to delete the cubes in the scene to only keep the combined result, but without deleting the elements in the array. After combining meshes, i want to be able do destroy cube from it. So i want to keep the info so when i click the mesh, i get the position of the cube that would be there and check if it matches wit ha cube from the array. If it does, i want to remove it from the array and regenerate the mesh without that deleted cube.

How would I do that ?


texts: Spherical fragment shader shockwave regardless of screen dimensions

texts:
I've been working on a shockwave shader based on some examples I've looked at. My primary issue is that the screen/resolution dictates the shape of the shockwave. I need it to be spherical, but with default screen shapes it's an oval.

I can resolve the issue by reverse the resolution ratio calc but that winds up stretching the actual texture.

https://www.shadertoy.com/view/XlfBWj

void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
    float offset = (iTime- floor(iTime))/iTime;
    float CurrentTime = (iTime)*(offset);

    vec3 WaveParams = vec3(10.0, 0.8, 0.1 );

    vec2 center = vec2(0.5, 0.5);

    vec2 uv = fragCoord.xy / iResolution.xy;

    //float ratio = iResolution.y/iResolution.x;
    //WaveCentre.y *= ratio;
    //texCoord.y *= ratio;

    float dist = distance(uv, center);

    vec4 Color = texture(iChannel0, uv);

    if (dist <= CurrentTime + WaveParams.z &&
        dist >= CurrentTime - WaveParams.z) {
        //The pixel offset distance based on the input parameters
        float Diff = (dist - CurrentTime);
        float ScaleDiff = (1.0 - pow(abs(Diff * WaveParams.x), WaveParams.y));
        float DiffTime = (Diff  * ScaleDiff);

        //The direction of the distortion
        vec2 dir = normalize(uv - center);

        //Perform the distortion and reduce the effect over time
        uv += ((dir * DiffTime) / (CurrentTime * dist * 40.0));
        Color = texture(iChannel0, uv);

    }

    fragColor = Color;
}


texts:
I am currently making a pressure heat map that will be overlaid on a bent shape (let's say cylinder). I am using a 2d texture that is mapped to the object. The pressure points are also mapped to the texture matrix. As there are only few pressure points giving values, I am interpolating the pressure for the rest of the texture, however, there is an issue...

As you can see because the texture data is in 2d array the interpolation does not account for the place where it connects.
Is there an algorithm that would help account the borders of the matrix being connected?


texts: How to use vertex and fragment shaders without using VBOs and VAOs?

texts:
Recently, I am trying to make a 3D game in LWJGL 2, not LWJGL 3, just because I am more familiar with LWJGL 2. Since LWJGL decided to shut down their legacy wiki website, I've been researching alot lately on adding shaders. The thing is, most of these tutorials use VBOs and VAOs to render objects.
I am trying to use vertex and fragment shaders to edit the objects. Yes, I am using the depreciated methods glBegin(); and those rendering methods to draw shapes. I am not sure if this affects the use of shaders or not, so that is why I am asking this question.
If anyone wants to know, I am using the depreciated methods because I don't want to really use VAOs and VBOs, I know it reduces performance to use the depreciated methods, but I am fine with this for now.


texts: Efficiently calculate 2d world position based on parent(s) recursively

texts:
I am writing a small 2d html5 game engine in javascript that relies on the concept of a hierarchy. The scene is the root node or entity, and its children make up the game objects. These children can have other children, recursively. Every entity has a relative position and an absolute position. By relative, I mean in object space, and by absolute, I mean in world space - based on its own and its parents' transformations.

To calculate the world position of an entity, all I have to do is apply its transformations (translation, rotation and scale), and that of its parent, and of its parent's parent, to its local/relative position up until the root entity of the hierarchy.

The problem I'm having is when to calculate this the most efficient way. Should I calculate the world position every time I get its worldX or worldY properties? What about every time the position, scale or rotation properties of the entity or any of its parents are set? Or is there a completely different way?

Note: along with knowing an entity's world location, I also need to know its world bounding box.


texts:
So, I've been trying to make a minecraft 1.11.2 client for minecraft. Thing is, the mcp/src/minecraft folder is empty, without any net files. The only error I had while decompiling was missing lwjgl 2.9.4, which does not exist. I have everything ready, but those files are missing, and thus I cannot code anything on my client(I am only using allowed mods.) This is a massive project I am taking for my favorite server, and I would like some help. Can anyone be kind and tell me how to fix this?

I have installed Optifine files for my client, and seems to have got about half of the files that I need.

What I need:

What I have:

As you can see, I am missing a lot of packages and have errors in most of them.


texts:
I'm working on a Voxel project in Unity3D for fun and learning. I've been reading up on how this is done and have implemented a simple Voxel map in my project. My question is about the lighting. I've read several articles on how Minecraft implemented lighting. It doesn't seem too complicated but I'm wondering if it's necessary in Unity (and also I'm unsure how I would actually implement that in Unity)

So far I'm just using Point Lights on blocks that should emit light. Is Unity's Point Light efficient enough on a Voxel map if there are many light sources? So far on my scene it works OK with several lights on it. Adding many lights slows down the game as expected but since my computer is not a gaming beast I don't know if it's because Unity's Point Light is not optimized for this type of map or if it's just due to my low end computer. (To give you a point of comparison, I run Minecraft with a lot of lag but Eldritch with absolutely no lag, if you're familiar with both those games)

I would like some thoughts from more experienced users on this subject. If you had to develop a Voxel game in Unity, that may include 100 torches and 100 cubes of glowing lava, would you just use the Point Lights?

If the answer is no, is playing with the RGB values of the block textures the way to go?


texts: What are the typical day-to-day tasks of a games writer?

texts:
I am interested in plot writing for games, and wondered first of all:

Is this available as an entry-level position, or is it accessed through other avenues (even external to games development)

And secondly, what are the daily tasks of a games writer, both at the entry level and at a higher level?

Thank you.


texts: Benefit of storing chunks as Octree leafs vs single block as Octree leaf

texts:
I saw many voxel game developers opt for a strategy that involves using an octree whose leaf nodes include a 16x16x16 (or 32^3 or 64^3) chunk instead of having leafs represent a single voxel.
What is the reason for this? I also don't understand how this will coincide with LOD, if the leaf is a 32x32x32 chunk, how does the tree manage LOD levels inside the chunk?
If it doesn't, then wouldn't you lose a lot of detail when considering this chunk as 1 voxel? I can't wrap my head around the benefits of doing this :)
I implemented my own version of Octree (Single voxel leaf) with face culling between nodes and I can get the following result (512 ^ 3 voxels):

This takes about 50 MB of RAM (60 FPS) and when transitioning to 1024 ^ 3 it jumps up to 190 MB of RAM (60 FPS).
I am trying now to optimize memory that's why I wanted to start experimenting with LOD but the more I researched the more I found mentions of chunks as leafs.


texts: Easily split up a ripped spritesheet with no downloads?

texts:
So, I'm new and all to game development, and I use the free version of Construct 3.

I want to make a Mother 3 fan game, as it's one of my favourite games of all time and seems like fun practice for a top down RPG.

I downloaded a ripped sheet of Lucas, but the background is green, and also it's in one image.

Is there an easy way to split the sheet into multiple images, without any downloads? I'm using someone else's computer and I can't download anything.

It's a windows 7 computer, with like nothing but chrome


texts: Programmatically Modifying Images to Create Morning, Sunrise/Sunset and Night-Time Modes

texts:
I'm using RPG-Maker-XP-like sprites (any 2D adventure/RPG style sprites). I would like to tint them so that they look different at different times of day.

Times of the day are the set of:

Daytime (normal)
Early morning (bluish?)
Sunrise and Sunset (orangish?)
Night time (dark)

What do I need to do to tint them, and make them look good, during different times of the day? Are there any "known" formulas for any of these times, like "delete the green blue component and tint heavily red+green for a sunrise effect"?

Ideally, I have just the original sprites, with no additional information or images (like spot-highlights or shadows separated out).

Finally, I'm using Silverlight/FlatRedBall for this, so I do have access to per-pixel information, as well as RGB tinting (adding, subtracting, multiplying, etc.)


texts:
It accepts two parameters, the first is an out parameter - a pointer type, so a referenced variable or a pointer to a variable - the second parameter is an in parameter of the same type but const.

This is strange to me, normalizing is a simple calculation, I would expect the function to have one parameter - the vector to be normalised. Why does it have two? could somebody write an example of how I would use it?


texts: The best way to store and protect game data

texts:
I'm writing a sandbox-type game and i'm looking for a good way to store game data. I tryed Lua and plain text files, but the have a big minus - player can edit them his self!

So how do I protect data from player? Thank you!


texts: Framerate-independent game loops and discrete tasks

texts:
When writing good framerate-independent game code, you take some sort of deltaTime parameter in your main render() function and then scale your calculations based on that -- this is essential for things like physics engines.

However, in my game there are often discrete tasks -- the AI system might add components representing a "task" to the agents that should be removed (finished) after x seconds have passed. To make a contrived example, if a task/component takes 60ms to process, and the game is running at 60fps (16.6ms/frame), then the first three frames will run, bringing the "work done" on that task to 50ms, and then one last frame will do 10ms of work, but then the remaining 6.6ms will be "lost", because the AI system won't run and schedule new work until the next frame.

Ideally, I'd like to not lose the "loose change" of ms that occurs at the end of tasks.

How do people normally deal with this? I can think of a few options:

Ignore it -- the shortest tasks will probably never be less than 100ms anyway, generally more in the 1-5 second range. It's not multiplayer, and provided the game can maintain 60 fps (which it probably can), the experience should be the same for all players.
"Carry" the remainder over to the next frame. In the example above, give the agents 23.2ms of time to "spend" in the next frame.
Amp up the framerate. At 60fps, the most time you can possibly waste is 16.6ms, but at 200fps you can lose at most 5ms. (Currently my logic loop and render loop are coupled and capped at 60fps, but I can easily change that.)


texts: 2D jerky motion with AddForce and physics

texts:
I have a problem smoothly motion - I see jerking when I am using physics and AddForce.

It's not a question related to Update or Time.deltaTime -
I created simple scene with few lines and sphere.
When player clicked ">" button, I apply force to sphere, but motion is jerky and is not smoothly (please see web version below).

Project: fixed ortho camera, sphere with disable gravity, few cubs and bouncy as default material.

To fixed this problem, I tried to use some solutions from posts, related with jerking motion in Unity:

http:// answers.unity3d.com/questions/10907/smoothing-rigidbody-movement-over-a-bumpy-track.html
answers.unity3d.com/questions/228095/why-is-the-motion-jerky-in-a-simple-2d-game.html
answers.unity3d.com/questions/275016/updatefixedupdate-motion-stutter-not-another-novic.html

Things, that I tried:

Interpolate for sphere rigibody - slightly better, but jerky is still here.
Change Vsync(Dont Sync, Every Blank, Every Second Blacnk) and Quality (Fastest-Fantastic) - nothing
Use different object for collission (just rigibody and collision object) and display object(mesh renderer). This InterpolateToTarget.cs script in source folder - nothing.
In previous other game (with gravity, other default material, etc.) I used motion forward without AddForce, but I faced with jerky motion, too. I tried all solutions, that I find (FixedUpdate/Update with deltaTime, Coroutine, Transform.Translate, Interpolation, Lerp, LateUpdate...) and I saw that only one combination (small AddForce/Interpolation and Simply Quality setttings (VSync is turn off)) give me acceptable smoothly motion. But in this game I need AddForce with larger value and this solution is not work in this case.

Web version:
https://dl.dropbox.com/u/15321992/2DjerkyMotion.rar

Sources:
https://dl.dropbox.com/u/15321992/2DjerkyMotion.rar

Android apk:
dl.dropbox.com/u/15321992/2dJerkyMotion.apk

Code that I am using for motion:
    public class TestMovingScript : MonoBehaviour {

private Rect restartBtnRect = new Rect(20, 20, 120, 60);
private Rect rightMoveBtnRect = new Rect(Screen.width - 100, Screen.height - 100, 100, 100);
private GameObject _player;
private Vector3 _movingVector = new Vector3(1, 0, 0);

// Use this for initialization
void Start () {
    _player = GameObject.FindGameObjectWithTag("Player");
    _player.rigidbody.AddForce(_movingVector * 20);
}

// Update is called once per frame
void Update () {

}

private void OnGUI()
{
    if (GUI.RepeatButton(restartBtnRect, "Restart"))
    {
        Application.LoadLevel(0);
    }
    if (GUI.RepeatButton(rightMoveBtnRect, ">"))
    {
        {
            _player.rigidbody.AddForce(_movingVector * 20);
        }
    }
}

}

I suppose in web version this jerking is not as noticeable, but on Android it is a horrible.
Also, try to play in web version few minutes and you will see it.
I don't believe, that Unity3d does not allow to build smoothly Android game, so maybe I missing something in physics/player setting.

I will be grateful for any suggestions and ideas.

Thanks,
Dmitry.


texts:
I am learning OpenGL ES and I have setup the environment. I believe the best way to learn things is to grab a dummy project and start working on it. So what I plan to do is...

Flare on a parachute http://goo.gl/8vN4R

Now I want this parachute to be created in OpenGL ES with sparkling effect at its tip. The sparkling effect must be shiny and animating like it's really sparkling. And the whole parachute would be moving down from top of the screen slowly and slightly fluctuating its position.

Please tell me if this is what I can do using OpenGL ES or I should use some other framework for fast development.


texts: The best way to communicate between multiple iPhones/iPads in a card game

texts:
I have been looking around for information about this topic but not found what i need.

Here is the scenario, i am planning a card based game (cocos2d) where the idea is that up to four players should be able to play.

One player will hand out the cards to all four and then they play. Next round the next player should do this and so on..

On the screen i would like the actual player to see his/her own cards as well as the others cards that they have played out meaning that each player should see the others active cards.

I would like to ask the following:

How would be the best way of implementing this from a communication point of view?
Would this go via game center?

A reference to information is appreciated.

Cheers


texts:
How to align the Polygon Collider 2D in Unity to match the position of Sprite?
I have a game object. It has a Sprite Renderer with an image. Now I add a Polygon Collider 2D component to the game object, that generates a collider. The shape of the generated collider is correct as expected - i.e. it matches the image from the Sprite Renderer. But the position of the collider is wrong. Here you can see what I mean:

For sure I have a solution - I can manually configure the Offset of the Polygon Collider 2D. But that would take a significant amount of efforts and time (because I have a lot of such game objects, which need to have a sprite and collider). So, I am hoping to find a solution which would position the generated collider correctly. I.e. in such a way, so that the boundaries of the collider would match the boundaries of the sprite.


texts: Is there an equation to determine when to invoke extrapolation in response to lag?

texts:
I've implemented interpolation to smooth character drawing in my networked game.  But now I want to fall back on extrapolation if too much time has passed from a user sending an update and the interpolation buffer has been used up.

I'm just wondering if there is an equation that suites the following :

If it has been X since this user's last update, extrapolate the user position using the current time.

That determines the optimal amount of time for X.

I could try lots of different things like "we have surpassed the standard deviation of the last 100 moves + a constant", but I'm convinced there has to be an optimal strategy for deciding when we need to extrapolate.  Surely this is a solved problem, is my thinking.

I've searched thoroughly but have found nothing.  Also, for reference, I'm interpolating and extrapolating on the client.


texts: Rigidbody & Ray alternative or optimization

texts:
I am creating an AI that moves around to certain points, but should interact with ais or objects seen.
The ai should find other ai to comunicate or look for objects on the ground.
It works with all those solutions with a low number. But when I have +300 ais the fps drops a lot, caused by Physics2D.FixedUpdate or something related with physics.
How would you deal with this?
I have tried those solutions:

Solution 1
AI:

Rigidbody2D Kinematic
SphereCollider2D Trigger
OnTriggerEnter & Exit Script.

Objects

Rigidbody2D Kinematic
SphereCollider2D Trigger

Solution 2
AI:

Rigidbody2D Kinematic
SphereCollider2D Trigger
OnTriggerStay Script executed each 120 frames & a Coroutine to simulate OnTriggerExit.

Objects

Rigidbody2D Kinematic
SphereCollider2D Trigger

Solution 3
AI:

No RigidBody
SphereCollider2D Trigger
Cone of Rays executed each 2 second to detect colliders at certain layers.

Objects

No RigidBody
SphereCollider2D Trigger

EDIT
In solution 1 and 2, all AI have an "eyes" children GameObject with a TriggerCircleCollider2D and no RigidBody2D, to detect near AIs and GroundObjects.


texts:
I'd like to use Matricies to transform primitive geometric shapes and draw them using the Allegro library using version 4.2 (I can not switch to 5.x just yet). This works fine for non-filled objects that are just a series of lines and any filled object that require explicitly telling allegro each point in the shape (triangles and polygons).

However, I want to be able to draw a filled rectangle that is not axis-aligned.

Is there an algorithm that given the pixel locations of the four corners of a rectangle, allow drawing individual lines to fill it? That would solve the problem for the time being.


texts: How can I edit a float that is in another script? (In C#)

texts: So basically, I have one script for the UI, which holds the float, score. Then I also have another script on my coin that detects when the player collides with it. What I want it to do is change the value of score, but I don't know how to change it, as it is in the UI script. How can I do this?


texts:
Can I remake a game I don't own any copyright to?

There's a online browser game which I played 5 years ago. Some time ago, this game was shutdown because its developer went bankrupt. I want to re-make this game and provide it to Web again. Can I do this? Or there's some copyright problem or something like this?