texts:
I've been having trouble getting my SAT code working using AABBs, and I've been trying to find a solution but, I'm scratching my head.

For some reason, it detects collisions very wrongly, as shown by this desk check I did.
(AABBvsAABB method at bottom.)

Consider two AABB, A and B.

A = X: 0, Y: 0, W: 102, H: 19

B = X = 87, Y: 6, W: 1, H: 1

These are colliding.

First, calculate normal

Normal = (0,0) - (87,6) = (-87,-6)

Next, we get half widths

aExtent = 102/2 = 51
bExtent = 1/2 = .5

Now lets calculate the overlap of the two.

 xExtent = 51 + .5 - |-87| = 51.5 - 87 =  -35.5

xExtent is less than zero so it says its not colliding, obviously this is wrong.

   /// <summary>
   /// Compares bounding boxes using Seperating Axis Thereom.
   /// </summary>
   public static bool AABBvsAABB(AABB a, AABB b, ref Manifold manifold)
   {
        manifold.Normal = a.Position - b.Position;

        //Calculate half widths
        float aExtent = a.Width / 2f;
        float bExtent = b.Width / 2f;

        //Calculate the overlap.
        float xExtent = aExtent + bExtent - Math.Abs(manifold.Normal.X);

        //If the overlap is greater than 0
        if (xExtent > 0)
        {
            //Calculate half widths
            aExtent = a.Height / 2f;
            bExtent = b.Height / 2f;

            //Calculate overlap
            float yExtent = aExtent + bExtent - Math.Abs(manifold.Normal.Y);

            if (yExtent > 0)
            {
                //Variable to multiply the normal by to make the collision resolve
                Vector2 faceNormal;

                //Check to see which axis has the biggest "penetration" ;D

                //Collision is happening on Y axis
                if (xExtent > yExtent)
                {
                    faceNormal = manifold.Normal.X < 0 ? -Vector2.UnitX : Vector2.UnitX;
                    manifold.PenetrationDepth = xExtent;
                    manifold.Normal = Physics.GetNormal(a.Position, b.Position);
                    manifold.Normal.X *= faceNormal.X;
                }
                //Collision happening on X axis
                else
                {
                    faceNormal = manifold.Normal.Y < 0 ? -Vector2.UnitY : Vector2.UnitY;

                    manifold.PenetrationDepth = yExtent;
                    manifold.Normal = Physics.GetNormal(a.Position, b.Position);
                    manifold.Normal.Y *= faceNormal.Y;
                }
                manifold.AreColliding = true;
            }
        }
        return manifold.AreColliding;
    }

Any idea what I am doing wrong here?


texts: How can I make my program load music from files?

texts:
I'm working with a XNA game and I want my program to load music files from libary/music so I can play that music in the game.
It would be great if the mediaplayer class could play a playlist of all the music in library/music.


texts: Project development in a long distance Indie Dev environment

texts:
Myself and 4 other coders have been working as a modding team for the past 7 months. We all have a very good grasp on our preferred language (C#), and also use versioning (GitHub / BitBucket / Assembler) to organize our code, and updates.

We want to now get into developing our own game. We have an idea, and have a very basic engine in place.

How do we project manage from here?

Obviously we dont want to dive into adding content, but how do we manage the project from here? Should we assign tasks to each person? How do we manage the project do that each person gets a fair share of work? Once we have a game, how should profits be split?

Any advice on this is welcome.

Thanks
Twitchy


texts: Generate 2D Triangular Mesh from Vertices on a Map

texts:
Given a map of vertices {(x1,y1), (x2,y2), ... (xn,yn)}, how can I generate a 2D triangular mesh covering all vertices, and where the area of all triangles completely covers the map?

The triangular areas may fully enclose other triangular areas, but no two triangles may intersect.


texts: How to calculate view matrix for OpenGL 3.+ 2D Camera Roll

texts:
I'm trying to create a camera object for my 2D game engine, but I just can't seem to get the view matrix down right.

Here's the code I'm currently using:

glm::mat4 Camera::GetViewMatrix()
{
    glm::mat4 view;
    glm::vec3 camPos = glm::vec3(this->pos, CAM_Z);
    GLfloat xup, yup;

    xup = sin(this->rot);
    yup = cos(this->rot);
    view = glm::lookAt(camPos, camPos + glm::vec3(0.0f, 0.0f, -1.0f), glm::vec3(xup, yup, 0.0f));

    return view;
}

The result I get from this is as follows
Before rotation:

After rotation:

As you can see, the camera is rotating around its top left corner. The top left corner is the origin point (0,0,0) and the camera's position is (0,0). Shouldn't the lookAt function position the camera at (0,0,1) and point it at (0,0,0)? That's not what seems to be happening.

I'm just trying to get the camera to roll about it's set position.
Any help would be greatly appreciated! Thanks in advance!


texts: Can I set the unity camera to have the same position in a real world?

texts:
I have a problem about setting the camera in the unity to have the same extrinsic parameters as my real world camera to the origin. So let's me describe my problem step by step.

I have a camera in a real world and Its extrinsic to an aruco plane was calculated. So I use the Aruco plane(You can think as a plane reference) as an world origin(0, 0, 0).
The in my unity, I want to set my camera to have the same extrinsic as my real world camera. So I take an translation to set the Position in unity transform toolbox. And set the rotation by convert my rotation matrix from extrinsic to the euler's angle and set it to x, y, z rotation.
So I test this by use the unity properties named "camera.cameraToWorldMatrix". You can treat this as an extrinsic of the unity camera transform to the world coordinates(0, 0, 0). So this value should equal to my extrinsic since it's use the same rotation euler's angle. But unfortunately it's not.

So how can i solve this problem or there's a simpler way to set the cameraToWorldMatrix equal to my extrinsic parameters.

For more information : All of my coordinates system is respect to opengl (In Opencv coordinates system are negated in y and z axis from opengl)

1.Here's my extrinsic that i got from the solvePnp() function. This is an extrinsic from camera to my aruco plane. Then I use this [R|T] to get the euler's angle rotation and translation. And in my image also show my euler and translation. So this extinsic is also my expected extrinsic.

I use these euler's angle rotation and translation to set my camera in unity.

Here's my code to map from the camera coordinates to the aruco plane coordinates

def mapBallToArucoPlane(camera_coordinates, rvec, tvec):
  # Mapping ball in left camera_coordiantes to the camera_coordinates(Aruco plane coordiantes)
  # By using the inverse of [rvec|tvec]; Since [rvec|tvec] is the transformation matrix from Aruco->camera, but we need camera->Aruco
  R = cv2.Rodrigues(rvec)[0]
  # print(R.shape, cv2.Rodrigues(rvec))
  T = np.array(tvec)
  # print(R.shape, T.shape, np.hstack((R, T)).shape,
  # np.linalg.pinv(np.hstack((R, T))).shape)
  arucoPlaneToCameraMatrix = np.vstack((np.hstack((R, T)), np.array([0, 0, 0, 1])))
  cameraToArucoPlaneMatrix = np.linalg.inv(np.vstack((np.hstack((R, T)), np.array([0, 0, 0, 1]))))
  plane_coordinates = cameraToArucoPlaneMatrix @ camera_coordinates
  plane_coordinates = plane_coordinates/plane_coordinates[-1]

  return plane_coordinates, arucoPlaneToCameraMatrix

My output extrinsic. (Should be the same as above)

Thank you very much.


texts: Many years ago I did some programming in TurboPascal (on DOS!), but have not programmed since. Since retiring, I have "invented" a few solitaire games that I have given to people who sell solitaire collections. Recently I've invented a game that is different enough from existing solitaires that it does not "fit" into these collection packages. I would have no difficulty writing a simple program to do the job in TP, but that is no longer an option. I purchased BlitzPlus, but would like some help getting started. I hate the idea of reinventing the wheel; ie, learning from scratch how to shuffle decks, assign graphic files to cards in the program, etc, so, ideally, I'd like some basic source code from a very basic (ie, nothing fancy required) solitaire program, but, if necessary, would start from just tutorials on some of the procedures likely to be required. As I said, I've already purchased BlitzPlus, but would be willing to use some other language if that would be better or offer more tutorial assistance. Any help greatly appreciated.


texts: How can I replicate Quantum Break's distortion particle effect?

texts: Quantum Break has this fantastic particle effect, it's a distortion effect like broken glass. I want know how I can replicate this effect? You can see it below, and a full video is available on YouTube:


texts: How to correct shooting in touch-screen shooting games?

texts:
Assume a shooting game for iPhone that the character shoot toward where player has touched.

But as we know, There may be fault in touching screen by player and it conclude to bad game play and low fun.

So, How can I correct shooting method ?


texts: How do I draw an animated object in OpenGL ES?

texts:
I have a VBO, which I initialise like this (just an example):

- (void)setupVBOs {

    GLuint vertexBuffer;
    glGenBuffers(1, &vertexBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);

    GLuint indexBuffer;
    glGenBuffers(1, &indexBuffer);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices), Indices, GL_STATIC_DRAW);

}

As you can see, I'm  using GL_STATIC_DRAW, which is good for visually unchanging objects (not including translations and such).

How do I draw animated objects though? I mean things that might be changed by user interaction. This video is a good example. It is obvious OpenGL is being used, as the vertices are manipulated by gestures.

How is it done? by changing the x y z coordinates on every touch? Are they using GL_DYNAMIC_DRAW? Is this hard?


texts: How could I implement a halo to glow around my spaceship

texts: I have a 2D Spaceship sprite and I'm interested to know how I can create like a glow effect that leaves a trail behind the game object when it moves. Later on I am going to implement a dash function on the ship, so this glow trail should be consistent and visible.


texts:
I have a simple scene with only one empty box. Within that box I have the camera attached to a scene node, which the user can move (translate/rotate). Additionally a spotlight is attached to the camera's scene node, facing into the same direction as the camera. So when the camera is moved, then the light moves as well.

m_pCamera = m_pSceneMgr->createCamera("Camera");
m_pCamera->setNearClipDistance(0.01);
m_pCamNode->attachObject(m_pCamera);

Light* spotLight = m_pSceneMgr->createLight("spotLight");
spotLight->setType(Light::LT_SPOTLIGHT);
spotLight->setDiffuseColour(1, 1, 1);
spotLight->setSpecularColour(1, 1, 1);
spotLight->setSpotlightRange(Degree(50), Degree(100));
spotLight->setSpotlightNearClipDistance(0);
spotLight->setDirection(m_pCamera->getDirection());
m_pCamNode->attachObject(spotLight);

So, this basically works fine. There is one problem though: As soon as the user moves the camera very close to a side of the box, then suddenly all is black, I can't see anyting. I am sure the camera is NOT moving through the box's side, it is still within the box.

So the problem seems to be that the light does not "work" when it is too close to an object, as if the object (the box side in my case) is not reflecting the light any more.

Any ideas?


texts:
What good practice in paralleling of rendering, main game logic and networking on iPhone/iPad? If I program on Windows I use threading and IOCP, but I am new to iOS. So what patterns, io async libraries or something like kernel queues you choose when program complex mobile games? I need your advices on how do not stuck on waiting of server's answer and show animation at the same time? How must be organized main loop of client of the game? My interest first of deals with C++ approach and Marmalade SDK, but I'll be happy to any solutions!

So, for game logic, rendering, networking, user input and audio:

What paralleling mechanisms do you use? Pure threading or some library?
How does your waiting logic for server's answer work? I guess that animation, rendering and game logic still play and not wait server.
Any know how, links, post mortems from client-server iPad/iPhone games?


texts: Difference between GUILayout and EditorGUILayout?

texts:
Is it matter if I use GUILayout or EditorGUILayout for my custom editor? I need to use one of them in the OnInspectorGUI function.

which one should I use? What are the differences between the two?

Thank you in advance.


texts: Determining which way a wall faces in a 2D grid with minimal boilerplate

texts:
I have a 2D grid of quadrilateral tiles, some of which are walls, some are floor; each tile has four vertices, which are shared with the tiles around it (so each rendered "wall" is at least two wall-tiles thick). In order to render this scene, I need to know, for each tile:

is it a wall?
if so, is it a straight wall, a convex corner (pointing outwards), or a concave (inwards) corner? (so that I can select an appropriate texture to use – for the sake of example, ignore tiles that are totally surrounded by walls)
which direction is the free space in? (so that I can rotate the texture correctly)

e.g. for tile @ with walls W and floor ., this would render a straight wall facing east:

WWW
W@.
WWW

whereas this would be a convex corner facing north-west:

...
.@W
.WW

Some more interesting arrangements: this would ideally be treated as a special case (with a valley down the middle of two walls):

WW.
W@W
.WW

and something like this would ideally be two convex corners at A and B, as if there were two independent 2x2 squares of walls:

WW..
WABW
..WW

I'm not worried about handling invalid patterns of walls (e.g. a cross-shape of 5 walls) for now.

It's easy to track whether each tile is a wall or not, but I don't see a clean way to determine the other two conditions from that data. Is there a nice algorithm to do this without enumerating every possible arrangement of neighbouring tiles?


texts: How can I move an object over a drawn tile map in HTML 5 without constant buffering?

texts:
I've been messing around with HTML5 for quite some time now but this is something that I guess I haven't figured out how to handle well yet. I'm sure there's an extremely easy solution and I just haven't opened my eyes to it but anyway.

The problem is thus: I have an HTML5 canvas on which I've loaded image tiles using a function (called once on page load) which sets up an image object called imageObj, and on imageObj.onload, it draws the image that I want it to draw at the specific coordinates.

Now, I generally always run my main canvas game code in a setTimeout that runs at 30 frames per second. I have a separate function which checks what keys have been pressed and stores them in an array (to account for multiple key presses), and if arrow keys are pressed, then global variables that store the player's x and y position are incremented/decremented accordingly.

Now, in the setTimeout loop, here is where i draw a small rectangle with the x and y coordinates as that of the player x-and-y variables. However here is where I have the problem.

I do not refresh my canvas in the sense, I do not clear the screen or put a new black background covering the screen at the beginning of each frame, because then I would have to reload the tilemap and that's incredibly slow on my localhost, and would be even more so online.
Furthermore, since I do not clear the screen, the rectangle of the player is leaving a trail of rectangles behind it (i.e, all previous instances of its position have a rectangle in its place)

How do I handle this? How do I manage dynamic objects over the tile map and refreshing the canvas without having to constantly reload the tile map? (or reloading the tile map in some smart way. I believe there are certain methods such as drawing the next frame beforehand or as such; I'm not too sure)

Edit: I'd rather not use any third party apis or libraries or game engines, bit of a purist that way. Also, just occurred to me, what if I had 2 canvases back to back? One with the tile map and the other containing the objects?


texts: Is it legal to sell or monetize games created with the Unity 3D free edition?

texts:
Is it okay to use Unity 3D programming and gaming software to create mobile game apps for Android and iOS? I am using a free version of Unity 3D and planning it to sell my current game app I've created by publishing it to Google Play. I also use this method for earning money by setting as a free app with ads on it.

I saw some developers relied on using free version of Unity 3D to create games and published it via App Store or Google Play. If it does, should I have to pay or share contribution to the Unity development team for earnings since I use the free version in order to rely for producing several game apps for business?


texts: Unity - SpriteRenderer. Trying to make sprite from code using Texture2d.whitetexture

texts:
I have been trying to write a method that fills a rectangle with a color. I've tried it as a new 2D and 3D project just in case, but this gives the same results.

Basically, i want the script to make a new GameObject, give it a SpriteRenderer component and then fill the given rectangle with the given color.

I have tried to work from the Unity docs and other sources of info, but no matter how much I look around, this now looks correct to me but doesnt work.

The result (as pictured) shows the new object with the sprite renderer and even shows the right size (there are blue 'corner' icons in the scene view I can see but no sprite or rectangle of any kind.

using UnityEngine;

public class GameBoard : MonoBehaviour
{
    const ushort cellCount_x = 10;
    const ushort cellCount_y = 24; // only 20 will be visible to player
    const ushort cellsize = 50;

    GameObject testBlock;
    SpriteRenderer testBlockRen;

    private void Start()
    {
        testBlock = new GameObject();
        testBlockRen = testBlock.AddComponent<SpriteRenderer>();
        testBlockRen.sprite = CreateRectSprite(new Rect(0, 0, cellsize, cellsize), Color.red);
    }

    Sprite CreateRectSprite(Rect rect, Color color)
    {
        Texture2D tex = Texture2D.whiteTexture;
        tex.SetPixel(0, 0, color);
        tex.Resize((int)rect.width, (int)rect.height);
        Sprite sprite = Sprite.Create(tex, rect, Vector2.zero);
        return sprite;
    }
}

By the way: I have made sure the camera 'z' is less than 0 (it's -10). And the camera is centred where the sprite is supposed to appear.

Note: I can get a sprite to render fine if I create a texture in gimp and then use Resources.Load() . But I am trying to create the sprite using no source texture whatsoever (other than Texture2d.whitetexture)


texts:
I would like that particle system travels only on sphere surface.
I have set sphere and particle system as it's child.
How to constraint particle system ?

How to make trails follow along sphere surface?

On sphere it would look something like this

with trails:

without trails:


texts: Changing orientation by applying torques

texts:
Suppose you've got an object floating freely in space. You have a vector you want this object to point towards, and a vector representing the direction it's currently facing. From these two, you can get the rotation (matrix, quaternion, whatever) that represents the change in orientation to bring the two vectors into alignment.

If you only have the ability to apply torque (derivative of angular velocity) to your object, what's a good algorithm for applying torque over time that won't over/undershoot the destination?

(In this case, it's a space ship that wants to automatically orient itself in the direction of travel using thrusters. Roll is irrelevant.)


texts: added a pipeline and now my terrain is pink...how do I fix it?

texts:
I needed to add a pipeline to my world because an asset required it.  I was following the directions here.

Since adding the pipeline, my terrain is pink.

I found a references that stated the pipelines do not support terrain, there are problems with more than 4 textures (I have 1) etc...but this was a year ago.

Is this fixable or am I at choice between no pipeline or buying pipeline enabled terrain (and hence redoing all of my scenes)?

What is the solution?
Thnx
Matt


texts:
I wrote a little 4 spatial dimension game, it's a 4D snake. The rule are the same as the game for the old Nokia cell phone - eat the food, don't cross yourself, don't go out of the borders.

What do you think of the idea? How do I make a better graphic of the UI? Do you have any suggestion? Like this actually seem a DOS game ...

Here is a little explanatory video: http://www.youtube.com/watch?v=8IUnqm8j4BE

And here there is a new version I did with OpenGL and C++: http://www.youtube.com/watch?v=NaeqUp3jbls

Moreover I have a question, which from the two representation above you like more? Or better, do you have any idea how to represent the 4 dimension at the best?

Btw any comments, suggestions, and questions are appreciated about the UI, the game concept, etc.


texts: How do I create a fire sphere (fireball) in opengl? (opengl Visual C++)

texts:
I'm making an evil Pacman in OpenGL and I need to make my spheres look like a fireballs, does anyone know how I do that?

And what material colour should I use?

Also, is there a colour palette to change the colour of my materials?

This is how I create a sphere:

GLfloat mat_ambient[] = { 0.25, 0.25, 0.25, 1.0 };
GLfloat mat_diffuse[] = { 0.4, 0.4, 0.4, 1.0 };
GLfloat mat_specular[] = { 0.774597, 0.774597, 0.774597, 1.0 };
GLfloat mat_shine = 0.6;

glMaterialfv (GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv (GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv (GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialf (GL_FRONT, GL_SHININESS, mat_shine * 128);

glPushMatrix();
glTranslatef(x,y,0);
glutSolidSphere(size, 20, 10);
glFlush();
glPopMatrix();


texts:
I am developing a golf game using the GameSalad framework for iPhone. I have one attribute named speed of type integer with value 5000. I also have one boolean attribute named speedControl which is initially false.

When the ball is pressed and its sppedControl is true, I accelerate it with game.speed i.e. 5000.

Now I want to decrease the speed of the ball every 0.5 seconds, so i added a timer behavior and set it to every 0.5 seconds. Every tick of the timer, I set the CHANGE ATTRIBUTE game.speed to game.speed-300. but it's not working.

Sorry, I have no reputation, therefore I can't send you screenshots.

Please help me. I am very new to GameSalad and this is my first project.


texts: I have a number of prefabs in unity and I regulary update them, is there an easy way make sure unity updates these prefabs so that I don't have to update 20+ identical objects in identical ways acros 10  different scenes?


texts: How can I debug _why_ glDrawArrays is very slow?

texts:
I'm working on a game that uses CEGUI and Ogre.  Recently, we've discovered that some of our customers with GeForce4 MX 4000's, performance is terrible.

After a night spent debugging, I've tracked the issue down to a glDrawArrays call inside the Ogre GL Renderer.  Most executions of this call are pretty quick (<10ms, which still sucks but is ok for this terrible card).  But one execution of the GLRenderSystem::_render function takes 3500ms every single frame.

It's only drawing a 54-element TRIANGLE_LIST.  All the other calls to it are drawing similar-sized TRIANGLE_LISTs, so it's not the size of the array or its type that is the problem.

I've:

disabled fragment shaders (the GF4 MX doesn't support them)
disabled vertex shaders (it supports them, but CEGUI can only do all types of shaders or none of them)
attempted to disable a nearby call for multitexturing
massively simplified the UI that I'm drawing so that it is only a single CEGUI::Window

But I'm really just shooting in the dark.  I'm in a windows environment.  What's a good tool to figure out the OpenGL state at the time of a function call?  I'm guessing that there's a particularly piggish texture or a fragment shader somehow slipping through and getting rendered.

If there aren't any tools to do what I need, can anyone suggest ways that glDrawArrays could be made really slow on an old card?

Update:

I grabbed GLTrace and compared the calls that precede both a fast glDrawArrays and a slow one.  They're absolutely identical, they're even binding the same texture IDs.
One consistent difference however, is that the call that executes slowly is the first one in each OGRE/cegui render frame.  Perhaps there is some copying-over of texture data to the video card each frame (which would be ridiculous and clearly doesn't happen on other cards...).  Update: this isn't the case - no matter where in the queue I draw the offending object, it still takes forever.  See below.
There are 3 main objects being drawn: a full-window background (plain white, gets textured with a 128x128 texture), a smaller rectangular label, and text in that label.  The ratios between their draw speeds are approximately the same the ratios between their areas
If I force the slow object to be drawn several times instead of drawing the entire render queue, it is slow every time, which means it's not a one-time-loading issue.

Update for current theory: this is somehow a fill-rate issue.  Is there a way to configure a window so that the card has issues filling it?  Since I'm drawing in windowed mode, will that mess up a card sometimes?  My window doesn't have power-of-two dimensions (or dimensions similar to any standard resolution), could that be a chokepoint?


texts: How can I load a script once in LuaJit/Lua and use it across multiple VMs in different threads?

texts:
So, I came across an interesting problem. I'm implementing some threaded game logic, and one of the things I decided to do was to use Multiple Lua VMs, with each worker thread containing its own VM.

I don't intend for the scripts themselves to actually handle any data across threads. For the most part, the VMs will very rarely use the heap - as most things will be handled on the stack. The VMs are basically workhorses that drives the logic of the game, while the C++ end handles all of the data.

One of the things I noticed very quickly, is that as I get more scripts, I'm basically increasing my memory usage by a multiple of however many worker threads I am creating. This is because each State needs to load a copy of a script.

Is there a way, and how can I handle this without flooding my memory with 4+ copies of the same script? As in, one state loads in all of the scripts at the start, and puts them in memory. Then all other VMs are able to access those scripts?


texts: How do C++ games handle memory allocation failure?

texts:
I am aware of several games which are written in C++ but do not use exceptions. Since handling of memory allocation failure in C++ is generally built around the std::bad_alloc exception, how do these games handle such a failure?

Do they simply crash, or is there another way to handle and recover from an out-of-memory error?


texts: MVC (Model-View-Controller) Game Engine Architecture - Yes or No?

texts:
I am reading one great book, Game Coding Complete, and that book strongly recommends using MVC (Model-View-Controller) approach, with three key layers:

Game Application Layer
Game Logic
Game View

To me, this approach looks like an overkill for a mobile computer game.

What is your opinion, please? Is it worth of implementing this architecture, even if it adds extra communication needed between modules? Can this design consume so much CPU power, that at the end, the result would be significantly slower, than if it weren't implemented?


texts: How do I create cinematic (trailer like) shots of my game?

texts:
Background

We are in the midst of developing a trailer for our game.

It is a 3rd person adventure platformer. As such, the camera is an over the shoulder position, which is great for gameplay, but not so much for creating cinematic shots of our game.

Problem

I need to create cinematic shots of my game. This means I need to use separate camera angles to record gameplay.

As far as I am aware, I can only record the active viewport with Unreal, which leaves me stumped as to how I am supposed to play the game and record a moving camera at the same time.

What I have tried

I have attempted to use the level sequencer recorder to track the actors required, then playing the game and recording all my actions into the sequence created. From here, I can use a cinematic camera in a viewport and play the sequencer in the level (whilst recording), or directly rendering out the sequence.

Issue with this: The output of the sequence when rendered out is never the same as what is recorded. This issue seems to vary between machines we do it on. For instance, at my work PC, the sequence that gets played had the player mesh rotated to a completely wrong angle.

A colleague has also tried this same method, but for him some of the animations for the main character simply do not play.

Question

How do I create cinematic footage of my game akin to my proposal?

Is the level sequencer recorder the correct approach to be taking?

How have you done this in the past for your game etc.?


texts: Mapping TrueSkill scores to a ranking system

texts:
I have a 1v1 game that I would like to apply a ranking system to like most competitive multiplayer games out there.

I'm specifically looking for systems like League of Legends where they have Silver, Gold, Plat, Diamond etc and players can move between those ranks as they win or lose.

I'm calculating player ratings with TrueSkill. I actually have not a clue if I'm using it correctly I'm starting off everyone with a mu of 50 and a sigma of 10?

After some iterations people end up with different mu and sigma values. How should I determine what mu values are what ranks?


texts: How to blend the surface with HTML5 canvas?

texts:
I can simply blend the surface in GameMaker using these codes:

//colour with which to blend the surface.
draw_surface_ext(index, x, y, xscale, yscale, rot, colour, alpha);

or set "the Fade to a Color" property, it will looks like this:

For now I want to do the same thing with HTML5 canvas, but I don't know where to start, is there any canvas API that could do that?


texts:
I'm learning DirectX11 and since I'm beginning to write some shader code I don't understand the difference between binding slots and HLSL registers. The shader model 5.0 introduced the keyword register, that I assumed is a synonym for slot but it's not.

What I know:
I know that a register is 4 floats (16 bytes), and that a variable cannot straddle two registers so padding is added according to HLSL packing rules.
I also know that if I compile two shaders (say, vertex and pixel shader) in from the same file the register specified are by shader usage so if I use register b0 two times everything compiles fine if resources are accessed by each shader indipendently.

but what about this:

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

cbuffer clipPlane : register(b1)
{
    float4 clipPlane;
};

I bind my resources to the shader like this:

Game::GetInstance()->GetDeviceContext()->PSSetConstantBuffers(0, 1, &mCameraConstantBuffer);
Game::GetInstance()->GetDeviceContext()->PSSetConstantBuffers(1, 1, &mLightsConstantBuffer);

But if a register is 4 floats shouldn't the two resource overlap?
What about sampler and shader resource registers?

Can someone provide me with a reference about the structure of these registers? MSDN documentation is really of no help sometimes.


texts: calculate force betwen two objects like angry birds game

texts:
I'm trying to make a game like angry birds. in the game materials break and destroy based on force they receive. really what is the right or best way to implement it in unity?

thank you for helping.


texts: How does Mikktspace work for calculating the tangent space during normal mapping?

texts:
Increasingly the 3D industry is adopting the standard of Mikktspace for calculating tangent space for normal mapping and other effects which rely on accurate and consistent calculation of tangent space from one application to another. Blender, xNormal, Unity, Substance Painter and Unreal Engine are just a few I can think of which now use Mikttspace. I'm personally attempting to re-code my own projects to adopt this standard as well.

But there are very few resources on how Mikktspace works as it is a relatively new thing. What little resources there are, are usually scarce on details and very technical, not very user friendly to understand, or assume the coder has a certain level of knowledge which is a bit above the average newbie just starting out who needs things explained more carefully.

I am looking for a clear explanation of how Mikktspace works and how to implement it, with a simple explanation of how the maths and code works in a way which is not limited to just one language.

For the sake of example, lets suppose a programmer has a mesh object, with a index of vertices, each with a position, normal and UV coordinate, and list of triangles which reference that index.

For example:

Vertex: { X Y Z NX NY NZ S T }
VertexIndex: A list of Vertex
Triangle: { V1 V2 V3 } (in correct winding order for normal direction)
TriangleList: A list of Triangle

In simple terms, how would one go about calculating per vertex a tangent vector (TX TY TZ) and bitangent vector (BX BY BZ) for each vertex in a way which conforms to Mikktspace?


texts: Unity Make sprite visible only to shaders

texts:
I have made a shader for my UI buttons, the sprites should be black and white, so they can be used as a mask when blending. They should allow for the image behind them to pass through the whiter pixels and be blocked by the darker ones.

I want to use this effect for my menu, have a black background and a colored one (like a gradient or a pattern), let the colored one pass only through the buttons and the black one everywhere else.

My shader does just that, but with one problem. I can't hide the colored background from the camera. If I change it's layer it is useless (I guess because it is the child of a canvas), and if I use a regular sprite (non UI) it is just ignored by the camera and the buttons don't pick up the color.

How can I achieve this effect, having the sprite be invisible to the camera but visible to the shaders of the buttons.


texts: Comprehension question to MVC Pattern in Game Programming

texts:
So is my assumption right?

If I use MVC in Games I will have to implement a Model,Controller,View for every kind of interaction object.

For example in an Motorbike game. My Motorbike object will have its own controller, view and model class. Or is it enough if I define a model,view and controller for the world object and just use that view for drawing my bike?!

Or am I mixing something up?


texts: How can I improve the current enemy spawning system for my strategy game

texts:
I'm currently making an RTS game for mobile where mini battles would take place on tiny battlegrounds.
The problem is that currently the player is spawning its units based on a currency system, whereas the enemy is spawning based on a timed system. The timed system would make sense in a tower defense game, but not here.
Here is a short clip of it in action: https://twitter.com/LewanayG/status/1378009426808950794
This is my current spawn script:
void Start()
    {
        //start spawning waves
        StartCoroutine(SpawnWaves());
    }

    IEnumerator SpawnWaves()
    {
        //before spawning the first enemies, wait a moment
        yield return new WaitForSeconds(startWait);
        while (true)
        {
            //if not all characters of this wave are spawned, spawn new enemy and that wait some time before spawning next enemy in this wave
            for (int i = 0; i < startEnemyCount; i++)
            {
                int random = Random.Range(0, enemies.Length);
                GameObject newEnemy = Instantiate(enemies[random], transform.position, transform.rotation) as GameObject;
                newEnemy.transform.parent = enemyParent.transform;

                yield return new WaitForSeconds(spawnWait);                         // to add some randomness between spawns
            }

            //make sure the next wave contains more enemies than this one
            startEnemyCount += extraEnemiesPerWave;
            //wait before starting the next wave
            yield return new WaitForSeconds(waveWait);
        }
    }

Under the current system, as long as the player has more units on the battleground than the current spawn rate of the enemy it will win, and its really difficult to balance this game based on the two spawn systems.
How do you suggest I handle this problem and the spawn system of enemy units?


texts: How should I handle a modelview stack with multiple shader programs involved?

texts:
I'm building a framework where each object has an associated program and each object has a 'draw' method.

What is the best choice, to have a single modelview stack handled by a Renderer class or to have a modelview stack for each program? In the preferred case how can I handle optimally a "world" transformation that affects all the objects independently by the program (i.e. moving the camera)


texts: The true cost to get my XNA game on XBox?

texts:
There seem to be many hurdles to get ones game onto Xbox, so far I have uncovered:

You need Visual Studio (once your game becomes commercial you cannot use Express - but have to pay for professional). $1000+
You then buy a XBox to find you also need a harddrive - so buy a Xbox harddrive too. $400
You need to buy XBox Gold LIVE subscription. $70 (Free)
You need to buy AppHub Creators Club subscription $100

Then after all that I cannot even find the place on my XBox to download Indie games?!!! Seriously WTF - after doing all this I could have come proficient in WebGL and done it all for free...

Before I go all the way down this path (hole) are there any other hidden hurdels before I can publish my game?

UPDATE: "Indie Games are not available in Australia, due to the requirement for all games to be rated by the Australian Classification Board, and the prohibitive expenses involved."....... im going to have to break something....


texts: How to collide with a 45degree wall in XNA

texts: I want to make a PAC MAN imitation game to start working on AI, and while my first version will feature rectangles with widths or heights of 1 to makes walls for collision detection, I want to eventually make walls that are at 45 degree angles. I have found no guides out there to do this, only that rectangles can't be rotated apparently.


texts: How to make a countdown timer based on local time

texts:
I have a problem. In my GetTime.cs script, I am getting local time from an Android/iOS device, and simply assigning it to a Text component.
private void Update()
{
    time = System.DateTime.Now.ToLocalTime().ToString("HH:mm:ss");
    timeText.text = time;
}

I am making a travel system, that takes X amount of seconds to get from point A to point B. While in travel, you cannot do any actions.
How can I make this into a countdown timer based on local time? For example, I want to do travel from point A to point B like this:

I am in point A

I choose an option to travel to point B

I wait 30 seconds

I am at point B

But it has to be based on local time, and it has to work in the background, even when the app is not running.


texts: What's a simple way to send statistics from my game back to me?

texts: For example, I set up my game to keep track of how many times people play x, y, and z game modes, and also to keep track of how often players reach a certain point. What's a simple way to send this data to me so that I can see it?


texts:
I'm having trouble with actors and actions. I have a list of actors, they all have either no action, or 1 sequence action

This sequence action has either :

a couple of actions (some are instant, some have duration > 0)
a couple of actions followed by a parallel action.

My problem is the following:

some of the instant actions are used to set the position and the alpha of the actor. So when one of the action is "move to x,y and set alpha to 0" the actor is visible for one frame at position 0,0 , move instantly to x,y for the next frame, and then disappears.

Though this behaviours is to be expected, I want to avoid it. How can I achieve that?

I tried to intercept the actions before I put actors in the stage but I need the stage width/height for some actions. So something like :

Action actionSequence = actor.getActions().get(0);
Array<Action> actions = ((SequenceAction) actionSequence).getActions();
for(Action act : actions){
    if(act.act(0))
        System.out.println("action " + act.toString() + " successfully run");
    else
        System.out.println("action " + act.toString() + " wasn't instant");
}

won't work.

It gets even more complicated when an actor can also have a repeat action in stead of the sequence action (because you have to only run the actions that have duration 0 once without repeat, and then start the repeat).

Any help is appreciated.


texts: Why is my texture displaying incorrect colours using dx11?

texts:
I am trying to load my data from a binary file (ppm) and create a texture using this data. It is important that I learn to do it this way as I am eventually going to be packing all of my textures into a single binary file and then index them so creating the texture with pure binary data is something that I need to be able to do.

It seems that the texture is drawing correctly, but the colours are incorrect. I saved my image as .ppm just for this test application.

Here is the code to load my data

ppm ppm;

ppm.read(std::string("textureppm.ppm"));

//just to ensure the data is correct
uint32_t val = ppm.pixels[0];
unsigned char r = (val & 0xFF000000) >> 24;
unsigned char g = (val & 0x00FF0000) >> 16;
unsigned char b = (val & 0x0000FF00) >> 8;
unsigned char a = (val & 0x000000FF);

ID3D11ShaderResourceView* texSRV = nullptr;
D3D11_SUBRESOURCE_DATA initData = { &ppm.pixels, ppm.width * sizeof(uint32_t), 0};

D3D11_TEXTURE2D_DESC desc = {};
desc.Width = ppm.width; desc.Height = ppm.height; desc.MipLevels = 1; desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.SampleDesc.Count = 1;
desc.Usage = D3D11_USAGE_IMMUTABLE;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;

ID3D11Texture2D* tex;
HRESULT hr = getDevice()->CreateTexture2D(&desc, &initData, &tex);

if (SUCCEEDED(hr))
{
    D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {};
    SRVDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
    SRVDesc.Texture2D.MipLevels = 1;

    hr = getDevice()->CreateShaderResourceView(tex,
        &SRVDesc, &texSRV);
}

if (FAILED(hr)) {
    throw 0;
}
else {
    setTexture(texSRV);
}

I have packed each byte into a uint32_t as it seems that is the format that is required DXGI_FORMAT_R8G8B8A8_UNORM

Here is the packing

uint32_t ppm::CreateRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
    uint32_t value = 0;
    int r2 = (r & 0xff) << 24;
    int g2 = (g & 0xff) << 16;
    int b2 = (b & 0xff) << 8;
    int a2 = (a & 0xff);

    value += r2 + g2 + b2 + a2;

    return value;
}

This code produces the following texture

When the original texture is

Does anyone know what I am doing wrong?


texts: Can I publish an indie game on XBL made with directx

texts:
So I know that XNA can be used to publish games on Xbox Live Indie Games and I signed up for the $100/year subscription thing.

I haven't downloaded XNA yet but I was wondering if I can publish a game made entirely in DirectX onto it or do I have to go through XNA?


texts:
Is it possible to add one texture to another texture, at specific coordinates?
Like if I want to add a small texture(16x16) to big texture (1368 x 768) with coordinates ( 100, 100) so the small texture goes to specific coordinates (100, 100 ).


texts: How to get more than one window in Java LWJGL

texts:
I'm trying to write a game in Java LWJGL. And I need more than one (multiple) display window. By default I've got one display window where I can draw everything. But I'd like to split some data to other window. Any one know a way or tutorial to achieve this?

Regards.


texts: How to get Unreal find headers needed for my code to work?

texts:
I am trying to open a dialog to select files under UE4, using OpenFileDialog.
I added this to my build.cs
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "DesktopPlatform" });

In my header:
#include "IDesktopPlatform.h"
#include <Developer\DesktopPlatform\Private\Windows\DesktopPlatformWindows.h>

Second line suggested by IntelliSense...
I am adding dummy values to my code to start with:
void AFileDialogOpenerActor::OpenFileDialog() {
    FString defaultFile = "";
    FString fileTypes = "";
    TArray<FString> outFileNames;
    uint32 flags = 1;
    FDesktopPlatformWindows fpl;
    fpl.OpenFileDialog(0, dialogName,defaultPath, defaultFile, fileTypes,flags, outFileNames);
}

When I try to compile, I get these linker error messages:

If I replace the above includes in the header to these:
#include "IDesktopPlatform.h"
#include "DesktopPlatformWindows.h"

In message log:
cannot open include file: "DesktopPlatformWindows.h" no such file or directory

If I play around with these includes, I get a mixture of these messages.(Either a linking error, either no such file, or the bunch of linking error messages)
I took a look at containing folders of the headers and they are indeed there and public.


texts: Replacement for glDrawElementsBaseVertex in OpenGL ES?

texts:
I am porting my game engine(c++) to Emscripten, which unfortunately only  supports OpenGL ES 3.(Not 3.2) Therefore I don't have access to glDrawElementsBaseVertex, which is needed by my renderer(Canvas2D Renderer). It is needed because this way I can combine all my triangles in one draw call, instead of multiple hundred draw calls. So I need something that does the same. I can't just use normal draw calls, because it would be horribly slow and would require redesigning my Canvas2D class.

The reason I need so many draw calls is because the user can use a Canvas2D to draw single/multiple 2D triangles on the screen, which are then combined into one array. Because the user can also send multiple triangle set's, the indexes need an offset to work correct, which is why I need glDrawElementsBaseVertex.

Does anyone know how to replace glDrawElementsBaseVertex with something that does the same?

Thanks!


texts: Experiences of test-driven devleopment in large projects

texts:
I've used TDD in personal projects, but I wondered if anyone had any experience of using this approach across a large team? Was there resistence to the test-first approach? Did you keep code coverage high for the whole project? How did coverage survive fixing those two-in-the-morning-and-you-ship-in-four-hours crash bugs?  Did you run tests on all platforms, or just assume that passing on one meant passing the others?

I love the decoupled code that TDD produces, and the large suite of regression tests you get for free, but if you only have a few in the team who don't want to contribute tests, won't everyone suffer?


texts: Calculating the number of tiles shown on an isometric map

texts:
I'm currently changing an existing computer game from a top-down view to an isometric view. The map consists of an infinite number of tiles. Only the tiles which are currently visible in the players window should be shown.

What i know is:

How many pixels the worldmap has been scrolled on x and y axis
The width and height of a single tile
The width and height of the players window

What i need to know is

The coordinates of the first tile to be shown
The amount of tiles that will fit in the players window

To visualize the old approach was something like this (the dashed square represents the players window):

So with the old approach this calculation was pretty simple.

The new one looks like this:

And this is where i'm stuck at the moment. I can't figure out how to calculate which tile is in the upper left corner of the players window and how many tiles fitting inside the players window on the two new axes.

Can anyone help me with that? If yes, it would be really nice if the solution also contains a short explanation.

Thanks a lot in advance.


texts: How do I refer to the object that called a function?

texts:
I have a large number of buttons instantiated from a prefab using a loop, as follows:

public void LayoutButtons() {

        GameObject newCanvas = Instantiate (canvas) as GameObject;

        for (int i = 0; i < 10; i++) {
            GameObject newButton = Instantiate(button, new Vector2((i * 100.0F)-500, -100), Quaternion.identity) as GameObject;
            newButton.transform.SetParent (newCanvas.transform, false);
        }

    }

I would like the OnClick function to output the clicked button's text. However, I don't know how to reference the clicked button. I tried doing Debug.Log(this.GetComponent<Text>().text) but I get a NullReferenceException: Object reference not set to an instance of an object.

I'm not positive I'm using this correctly but I have limited connectivity at the moment and can't think of what else I'm doing wrong.


texts: Libgdx change to other screen and dispose current one

texts:
I am trying to switch to a GameScreen when the LinearVelocity of a Box2D - Object is x = 0.
If it is so, I am using the setScreen() - Method by calling the main class. This works perfekt, but when the screen should change, it just flickers, which is most likely caused by the render() - method in the screen class.
So my question is now, how to dipose that render method or how to dispose the whole screen class, so that I only the new screen appears!
Thanks


texts: Why does Unity not detect my camera attached via the inspector?

texts:
I want to use camera.ViewportToWorldPoint() to show the bottom center bounds of my screen. So, I created a script and added that component to my object that needs it.

using UnityEngine;
using System.Collections;

public class PathMovement : MonoBehaviour {

    public Camera cam;
    private Vector3 bound;

    void Awake () {
        cam = GetComponent<Camera> ();
    }

    void Start(){
        bound = cam.ViewportToWorldPoint (new Vector3 (0f, 0.5f));
        Debug.Log (bound);
    }
}

and then, I attach the MainCamera via the GUI

And then, when I run it, there's still an error says:

  MissingComponentException: There is no 'Camera' attached to the "RiverPath" game object, but a >script is trying to access it.
  You probably need to add a Camera to the game object "RiverPath". Or your script needs to check if >the component is attached before using it.
  UnityEngine.Camera.ViewportToWorldPoint (Vector3 position) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineCamera.gen.cs:408)
  PathMovement.Start () (at Assets/Scripts/PathMovement.cs:21)

This is quite weird since I've attached the main camera, but somehow unity didn't detect that. I also have tried to put the cam = GetComponent<Camera>(); on Awake() as well as Start(), but none work. :(

This is an Android app, using Unity 5.

How do I do this correctly?


texts:
I'm implementing a messaging system and I'm wondering about how I should handle events. Should I post them and send them to the appropriate listeners as soon as I receive them, or should I queue them and only dispatch when I am prompted to (most likely by the main game loop)?

Edit: More info

My game is a 2D platformer, so performance isn't going to be very hard to achieve. Considering what Roy T. said, I guess I might as well send out the event as soon as it is posted; there doesn't seem to be a need to queue it (unless I'm missing something, of course).


texts:
I'm working on implementing the physics surrounding a player walking on a heightmap. A heightmap is a grid of points which are evenly spaced on the x and z axes, with varying heights. The physical representation of my player (what is exposed to my physics engine/manager) is simply a point-mass where his feet are, rather than complicating the problem by treating him as a sphere or a box.

This image should help further explain heightmaps and show how triangles are generated from the points. This picture would be looking straight down on a heightmap, and each intersection would be a vertex that has some height.

Feel free to move this over to math, physics, or stack overflow, but I'm pretty sure this is where it belongs as it is a programming question related to games.

Here's my current algorithm:

Calculate the player's velocity from input/gravity/previous velocity/etc
Move the player's position (nextPos = prevPos + velocity * timeSinceLastFrame)
Figure out which triangle (all graphics is done in triangles!) of my heightmap the player's new position is vertically aligned with
Use the three vertices of that triangle to calculate the equation for the plane which that triangle lies in
Plug in the player's x and z coordinates into the plane's equation to get the y coordinate for the player's position on that plane
Set the y coordinate of the player's position to this (if newPos.y < y)

This is all fine and dandy, but I'm wondering if there's anything that I can optimize. For example, my first thought is to store the plane's equation with the triangle's vertex information. This way all I have to do is plug in the x and z values to the equation to get the y. However, this would require adding 4 floats to every vertex of the heightmap which is a little ridiculous memory wise. Also, my heightmaps are dynamic (meaning the heights will change at runtime), which would mean changing the plane equations every time a vertex's height changes.

Is there a faster way to calculate that point than digging up the plane's equation and then plugging in x and z? Should I store the plane equations and update them on vertex height change or should I just regenerate the plane equations for every triangle every time the player moves on that triangle? Is there a better way to do heightmap physics that maintains this simplicity? (this seems very simple to me as far as physics engines go)


texts: Drawing shapes and images in libgdx dialog

texts:
I am currently working on a dialog window for my android game using libgdx. This dialog window contains a collection of labels and buttons, but should also contain an image. The image represents the "remaining health indicator", i.e. an empty indicator with a symbol indicating the health of the player. This indicator has to be filled with a colored rectangle representing the remaining amount of health (see screenshot below).

In order to render this on a dialog of libgdx, I have to draw an image and a colored rectangle (the red rectangle indicating the real amount of remaining health). I know that the dialog supports the rendering of images, but I don't know how to first draw the rectangle.

This is the code I have so far:

public FuelFacilityDialog(GameWorld world, GuiComponent gui) { super("Health check", gui.defaultSkin);

    this.world = world;
    this.gui = gui;

    setModal(true);
    setMovable(false);
    setResizable(false);

    Image healthIndicator = new Image();
    Button button1   = new TextButton("heal", gui.defaultSkin);
    Button button4   = new TextButton("Exit", gui.defaultSkin);

    healthIndicator.setDrawable(new TextureRegionDrawable(AssetLoader.healthIndicatorV));
    healthIndicator.setScaling(Scaling.fit);
    setObject(button1, true);
    setObject(button4, false);

    Table imageTable = new Table();
    Table buttonTable = new Table();

    imageTable.add(healthIndicator).width(100).height(200);
    buttonTable.add(button1).width(100).height(50).expandY();

    this.getContentTable().padTop(20);
    this.getContentTable().padBottom(20);
    this.getContentTable().add(imageTable);
    this.getContentTable().add(buttonTable).height(200);
    getButtonTable().add(button2);
}


texts: Can't enable script component on a prefab instance in Unity

texts:
Prefab structure:

 MainObject (parent; prefab instance in the scene)
 |-Child
 |-Child
 |-Triggers
     |-Trigger1

MainObject has: ScriptIWantToEnable (Script) component (Disabled)

Trigger1 has: ScriptThatTriesToEnableIt (Script) component

Hello,

I'm trying to enable a script component on a prefab instance(MainObject) from a child object script component(Trigger1). For some reason though it doesn't get enabled. Run-time error shows up and the game breaks. Trigger works fine, up until the "enable" part. I checked it with the Debug.Log(). The MainObject is in the Hierarchy view already when the game starts.

Error:

  NullReferenceException: Object reference not set to an instance of an
  object ScriptThatTriesToEnableIt.Update () (at
  Assets/Scripts/ScriptThatTriesToEnableIt.cs:30)

Part of the code in ScriptThatTriesToEnableIt that tries to enable the ScriptIWantToEnable script component of MainObject:

 public class ScriptThatTriesToEnableIt : MonoBehaviour {
     public GameObject MainObjectRef; //MainObject prefab instance drag&dropped in the Inspector

     void Update() {
         // if triggered
         MainObjectRef.GetComponent<ScriptIWantToEnable>().enabled = true; //breaks here and throws the error
     }
 }


texts: Why do I get white highlights at the edge once light build complete?

texts:
Whenever I build my lights in Unreal, why do I always get white highlights at the edges? I can't seem to solve this. I get this problem with both static and stationary lights. Can someone please help? I have also seen this problem in Unity and I could not solve it.

-Kumsan-


texts: Some of the model's vertices are incorrectly positioned in skeletal animation

texts:
Everything is almost ready . I do not understand what the problem is.
The animation works, but some vertices are not where they should be.

I am using an SMD file from Half Life. I found that these vertices have a parent bone at index 2. "Bip01 Pelvis" This bone is in the right place - at the height of the pelvis.
version 1
nodes
  0 "Bip01"  -1
  1 "Bip01 Footsteps"   0
  2 "Bip01 Pelvis"   0
  3 "Bip01 L Leg"   2
  4 "Bip01 L Leg1"   3

Here is my code:
Animation:
// void modelUpdate()...
Mat4 TranslationM;
TranslationM[3] = objJoint.m_position;
TranslationM[3].w = 1.f;

Mat4 RotationM;
RotationM.setRotation(objJoint.m_rotation);

Mat4 NodeTransformation = TranslationM * RotationM;

if (mdlJoint->m_parentIndex != -1)
{
    objJoint.m_globalTransformation =
        m_joints[mdlJoint->m_parentIndex].m_globalTransformation
        * NodeTransformation;
}
else
{
    objJoint.m_globalTransformation = NodeTransformation;
}

objJoint.m_finalTransformation = objJoint.m_globalTransformation * mdlJoint->m_matrixOffset;

objJoint.m_finalTransformation - matrix for shader
Here how I read bind pose:
Mat4 R;
SMDAngleMatrix(v3f(nt.m_rotation.y, nt.m_rotation.z, nt.m_rotation.x), R);

Mat4 T;
T[3] = nt.m_position;
T[3].w = 1.f;

joint->m_matrixBind = T * R;

if(node.m_parentID != -1)
{
    joint->m_matrixBind = object->m_mdl->m_joints[node.m_parentID]->m_matrixBind * joint->m_matrixBind;
}
joint->m_matrixOffset = joint->m_matrixBind;
joint->m_matrixOffset.invert();

I have no experience with skeletal animation.
Perhaps someone has encountered a similar problem and knows the solution.
UPDATE
I disabled animation (for testing)
Mat4 NodeTransformation = mdlJoint->m_matrixBindNoParent;

if (mdlJoint->m_parentIndex != -1)
{
    objJoint.m_globalTransformation =
        m_joints[mdlJoint->m_parentIndex].m_globalTransformation
        * NodeTransformation;
}
else
{
    objJoint.m_globalTransformation = NodeTransformation;
}

objJoint.m_finalTransformation = objJoint.m_globalTransformation * mdlJoint->m_matrixOffset;

maybe problem with m_matrixOffset
How I create matrix from Tait–Bryan angles (ZYX)
// up / down
#define PITCH   0
// left / right
#define YAW     1
// fall over
#define ROLL    2
void SMDAngleMatrix(v3f& angles, Mat4& matrix)
{
    float       angle;
    float       sr, sp, sy, cr, cp, cy;

    angle = angles[YAW];// *(math::PI * 2 / 360);
    sy = sin(angle);
    cy = cos(angle);
    angle = angles[PITCH];// * (math::PI * 2 / 360);
    sp = sin(angle);
    cp = cos(angle);
    angle = angles[ROLL];// * (math::PI * 2 / 360);
    sr = sin(angle);
    cr = cos(angle);

    // matrix = (YAW * PITCH) * ROLL
    matrix[0][0] = cp*cy;
    matrix[0][1] = cp*sy;
    matrix[0][2] = -sp;
    matrix[1][0] = sr*sp*cy + cr*-sy;
    matrix[1][1] = sr*sp*sy + cr*cy;
    matrix[1][2] = sr*cp;
    matrix[2][0] = (cr*sp*cy + -sr*-sy);
    matrix[2][1] = (cr*sp*sy + -sr*cy);
    matrix[2][2] = cr*cp;
    matrix[0][3] = 0.0;
    matrix[1][3] = 0.0;
    matrix[2][3] = 0.0;
}

OpenGL shader:
"void main(){\n"
    "   mat4 BoneTransform = Bones[inputBones.x] * inputWeights.x;\n"
    "   BoneTransform     += Bones[inputBones.y] * inputWeights.y;\n"
    "   BoneTransform     += Bones[inputBones.z] * inputWeights.z;\n"
    "   BoneTransform     += Bones[inputBones.w] * inputWeights.w;\n"
    "   vec4 vertexPosition = BoneTransform * vec4(inputPosition.xyz,1.0f);\n"
    "   gl_Position = WVP * vertexPosition;\n"
    "   texCoord.x = inputTexCoord.x;\n"
    "   texCoord.y = inputTexCoord.y;\n"
"}\n";

My matrices:
class Mat4{
    ....
    vec4 m_data[4];
}

Where m_data[3] - position;
That's all I have.
I will try to use quaternions instead of function SMDAngleMatrix...no same result...


texts: What's the difference between UClass and UObject?

texts: I know that UCLASS() macro creates a seperate UClass for every UObject class ,but what is the need for this seperate class , how both of these classes relate to each other and what is the basic difference between both of them??


texts: How to give individual tiles their own collider in Unity's tilemaps?

texts:
My floor tile is a 2D drawing of a 3D platform, for lack of a better description. I want my player character to stand not on the top of the tile but a little inside it, as the red circle does in the picture.

How do I give this tile its own collider that would fit this shape, while letting others have a normal, square one?


texts: Are there methods faster than Strings for sending a sprite's state over UDP?

texts:
I'm programming a 2.5D networked game in Java. The networking works like this right now:

Create new networked sprite object at the client. Send it to the server. Server distributes and saves it. (TCP-ObjectStreams are used)
The Sprite's state is represented by a String that contains its id (Player's name+Index) and values. You can request the state with the method getState():

return getID()+"|x"+getX()+"y"+getY()+"#";
//Example: "Grimey2|x402y123#"

These states are collected multiple times a second by adding them to a single big String:

zState += spriteArray[x].getState();
//Example: "Grimey1|x752y133#Grimey2|x410y31#Grimey3|x202y13#"

All sprites' states are then saved in a HashMap at the client, sent to the server (Java DatagramSocket) and saved there too.

Is there a more performant way to handle sprite-updating than with Strings?


texts: How to smooth low-res sampling of noise for voxel terrain

texts:
I am attempting to create a new terrain generator as part of a minecraft mod, which works very well if it samples at the full terrain resolution (16x256x16 voxels per terrain chunk). This is extremely laggy, so i attempted using a lower-resolution sample, x4x64x4, with an extra one sample on each positive axis to interpolate with (5x65x5, representing 20x260x20 space).

It all works fine until i try to smooth out the resulting 4x4x4 cubes of terrain. I have tried interpolating the noise value (0.0 to 2.0) of each block with the value next to it along each positive axis, each value weighted by how close the block is to it.

The result has some smoothing, but some of it seems to be rotated 90 degrees, and some areas are unsmoothed. I know this is possible, minecraft does it internally (the code is illegibly obfuscated and messy, about half a page, 20 variables and 6 loops).

Does anyone have any ideas about a reliable method for smoothing, only knowing the contents of the chunk and one sample to the north/east/top?

my current noise array generator:

protected double[] getNoise(float x, float z)
{
 // get a rough noisemap every 4 blocks, 1 more past the edge to round with
 double[] n = new double[1625]; // x65x5x5 3D space in order y,x,z  represents one chunk at 1/4 precision (1024 blocks plus 601 blocks padding along the positive-axis sides for rounding. Minecraft uses 825 doubles internally, 5x33x5)

 for(int lx = 0; lx < 5; ++lx)
   for(int lz = 0; lz < 5; ++lz)
   {
     // some extra noise that controls terrain thickness along Y
     double m = 32+(1f+SimplexNoiseGenerator.getNoise( (x+(lx*4))/256, (z+(lz*4))/256) )*32;

     for(int ly = 0; ly < 65; ++ly)
     {
       n[ (ly*25) + (lx*5) + lz ]= ( 1f+SimplexNoiseGenerator.getNoise( (float)(x+(lx*4))/512f, ((float)ly*4)/m, (float)(z+(lz*4))/512f ) ) * (1.5f-(Math.abs(32f-ly)/32f) ) ;
     }
   }
   return n;
}

Someone posted this on stack overflow, it is exactly the same problem and seems to be unresolved. https://stackoverflow.com/questions/35852194/smooth-lower-resolution-voxel-noise


texts: OpenGL ES 2. How do I Create a Basic Fading Streak Effect?

texts:
For the iPad app I am writing using OpenGL ES 2 I have a single quad - shaded using GLSL - that is dragged around the screen. Very basic. This works fine. But is rather boring.

I want to increase the coolness a bit in the following way: when the user drags the quad it leaves a streak behind that fades over time. Continuous dragging would be a bit like a streaking comet across the night sky.

What is the simplest way to implement this?

Thanks.


texts: Unity Animation isn't played once despite using trigger parameter

texts:
From the unity documentation: https://docs.unity3d.com/Manual/AnimationParameters.html

Trigger parameter: a boolean parameter that is reset by the controller when consumed by a transition (represented by a circle button)

So it should play the animantion once right?

In my current game I already set my animation transition condition to trigger, then in gameObject script I also set the parameter, but it plays more than once.

Here are my animation parameter

Here are my animation transition condition

And here are my gameObject script to set the parameter

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

void shoot() {
        anim.SetTrigger("shoot");
    }

EDIT:
this is the transition out of PlayerShoot, returning to PlayerIdle


texts: Destroy physics triggered GameObject in Unity ExecuteInEditMode

texts:
To destroy GameObjects I'm using this code :

try
        {
            DestroyImmediate(g);
        }
        catch (Exception e)
        {
            Destroy(g);
        }

It is giving me error, something like this :

Full code :

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

[ExecuteInEditMode]
public class Road : MonoBehaviour
{
    public List<Vector3> points = new List<Vector3>();
    public List<GameObject> gameObjects = new List<GameObject>();
    void Start()
    {

    }
    void OnValidate()
    {
        foreach(GameObject g in gameObjects)
        {
            try
            {
                DestroyImmediate(g);
            }
            catch (Exception e)
            {
                Destroy(g);
            }
        }
        gameObjects.Clear();
        foreach (Vector3 point in points)
        {
            GameObject tem = GameObject.CreatePrimitive(PrimitiveType.Cube);
            tem.transform.position = point;
            tem.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
            tem.transform.parent = gameObject.transform;
            gameObjects.Add(tem);
        }
    }
}


texts: Should we always prefer OpenGL ES version 2 over version 1.x

texts:
OpengGL ES version 2 goes a long way into changing the development paradigm that was established with OpenGL ES 1.x. You have shaders which you can chain together to apply varios effects/transforms to your elements, the projection and transformation matrices work completly different etc. I've seen a lot of online tutorials and blogs that simply say "ditch version 1.x, use version 2, that's the way to go". Even on Android's documentation it sais to "use version 2 as it may prove faster than 1.x".

Now, I've also read a book on OpenGL ES (which was rather good, but I'm not gonna mention here because I don't want to give the impression that I'm trying to make hidden publicity). The guy there treated only OpenGL ES 1.x for 80% of the book, and then at the end only listed the differences in version 2 and said something like "if OpenGL ES 1 does what you need, there's no need to switch to version 2, as it's only gonna over complicate your code. Version 2 was changed a lot to facillitate newer, fancier stuff, but if you don't need it, version 1.x is fine".

My question is then, is the last statement right? Should I always use Open GL ES version 1.x if I don't need version 2 only stuff? I'd sure like to do that, because I find coding in version 1.x A LOT simpler than version 2 but I'm afraid that my apps might get obsolete faster for using an older version.


texts: How to improve my input handling in GLFW?

texts:
Currently I'm busy working on a game engine. I have my own window class with GLFW functionalities. Currently, I have a very primitive way to handle input in my class:

It is not fast, and not "extendable" enough. I'm essentially using something along the lines of

void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
    if (key == GLFW_KEY_E && action == GLFW_PRESS)
        //do something
}

I would like to call something like the following:

// Create a window object
Window window("title",800,600);
//the parameters specify the key pressed and what the window has to do when the event occurs.
window.getKeyPressed(KEY,ACTION);

How would I go about implementing a more flexible input handling system?


texts: Need guidelines for quest xp and reward balancing

texts:
Where would I look to get guidelines for how much XP and gold/items to give as rewards for quests? The following is the algorithm I'm using to determine the XP needed for each level:

/** This starts at level 1. If you're at level 1, to get to level 2 you call getXpForLevel(1). */
public static long getXpForLevel(long level) {
    return 40 * level * level + 360 * level;
}

If I know roughly how long it'll take the player to complete a quest, how much xp should I award for that quest? How much should difficulty factor into the xp for the quest?

How do I balance the amount of gold you get for completing a quest vs the cost of items that can be purchased?

Do people just go by their gut feelings and then try to balance the values through playtesting or are there good rules to follow?


texts: Unity - using WWW to download image from web. Not working from my own website, but does from other urls

texts:
I have this script attached to a RawImage file in my games UI

public class DownloadImage : MonoBehaviour {
     string url = "http://megabrogames.rf.gd/pic.jpg";
     //string url = "https://i.imgur.com/xBSyvRx.jpg";

     IEnumerator Start () {
         WWW www = new WWW(url);
         yield return www;
         GetComponent<RawImage>().texture = www.texture;
     }
 }

Both jpg files are the same. One I uploaded to Imgur, this works. The other is on my own website. The url to my website works fine, I have checked in on two computers and several browsers.

All I get is the red question mark. But if I uncomment the other one instead it all works perfectly.

My problem is that I have hard-coded the url into the game, and I want to change the image each week. It has to be the same URL for that to work, but i think with Imgur it will auto assign whatever url it feels like.

thanks for any help


texts: Use references to UIManager script or direct for children OBJs

texts:
So I've got a canvas with UIManager script attached to it, the canvas has a lot of buttons and texts as children OBJs and they somehow need to communicate to each other. Should this be done through the UIManager or through direct scripts?

EDIT: Fixed, the point was to set other buttons and other UI elements active or de-active, I ended up using different methods in the UImanager script to do so, without having like 20 scripts.


texts: bullet character controller sliding down any slope gradient

texts:
I've been experimenting with the btKinematicCharacterController. I've seen very old complaints that it has issues but I can't find anything recent stating that these issues remain (and nobody ever says what the issues were).

The problem I'm seeing is that the character is sliding down slopes at absolutely ANY gradient. It will only stand still on level ground. If I have a ramp with a very gentle gradient it will slide slowly. I've found posts asking about this on the Bullet forums but haven't found any solutions.

I've set the friction and rolling friction for both the ramp and character capsule to a very high value but it doesn't seem to impact the sliding. I'm sure there's something else I'm missing or is there something wrong with the controller's implementation of recoverFromPentrations (It seems to shift the object by the collision normal on the other surface which is necessary to avoid going through walls).


texts: What are some ways I can create random but consistent levels with an increase in difficulty

texts:
So I am relatively new to gaming, however, I am working on a breakout style game and I am not sure how to generate levels. In theory I would like some approach that will let me generate tons of levels with slightly increasing difficulty. After these are generated I would like them to be the same for every user every time. That last part got me thinking about maybe using some sort of noise to generate the maps.

Does anyone have experience in this area? Are there some best practices? It would be great if the answer was "broader" than Breakout, but I can live with just Breakout.


texts: What events invalidate the Unity machine identification?

texts:
I bought a new solid state drive, cloned the old one to the new using CloneDrive, removed the old drive and booted. Everything went well, but when I tried to start Unity I got this popup:

I am currently just toying around with the free version anyway, so this is no problem to me, but I guess it could be quite troublesome when someone would be in the middle of an actual project with the paid version.

It seems like replacing your hard drive invalidates your Unity license. What other changes to the PC hardware can cause this to happen?

I do not want to know how Unity detects hardware changes, I want to know which kind of hardware changes need to be avoided to prevent Unity from causing trouble which might lead to disruption of a project schedule.


texts: Using PS3 controller for input on Mac OSX

texts:
I've managed to find a USB driver to connect to the PS3 controller in OSX, and as reported here, can connect to the controller via Bluetooth.

I've verified that the input is working properly via Snes9x.

Anyway, that's just background for my actual question. Is there any way to access the PS3 HID, via C++, on the Mac? I'm relatively new to C++ development on Mac using XCode, and the internet has been disappointing in my search for a possibly library to use.

Does anybody have any ideas on how I could access the controller button/axis states in code, so I can transfer them to my input maps?


texts: How can I use ParallaxBackground in AndEngine?

texts:
I'm new to game development with  AndEngine. I want to add ParallaxBackground but I don't know how to change the background when the player moves. I'm using arrows for moving a player.

Now my question is where I write the code parallaxBackground.setParallaxValue(5);?

I have written this line in onAreaTouched method of arrow but it does not work.

Code

private Camera mCamera;
private static  int CAMERA_WIDTH = 800;
private static  int CAMERA_HEIGHT = 480;

private BitmapTextureAtlas bgTexture;
private ITextureRegion bgTextureRegion;

@Override
protected void onCreateResources() {

    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
    bgTexture = new BitmapTextureAtlas(getTextureManager(),2160,480,TextureOptions.REPEATING_BILINEAR);
    bgTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bgTexture, this, "background.png", 0, 0);
    bgTexture.load();
}
@Override
protected Scene onCreateScene() {

    this.getEngine().registerUpdateHandler(new FPSLogger());

    Scene scene = new Scene();
    scene.setBackground(new Background(Color.BLACK));

    final ParallaxBackground parallaxBackground = new ParallaxBackground(0, 0, 0);
    final VertexBufferObjectManager vertexBufferObjectManager = this.getVertexBufferObjectManager();

    parallaxBackground.attachParallaxEntity(new ParallaxEntity(0.0f, new Sprite(0, CAMERA_HEIGHT - this.bgTextureRegion.getHeight(), this.bgTextureRegion, vertexBufferObjectManager)));
    scene.setBackground(parallaxBackground);

Robot robot = new Robot();

    // add Player
    final AnimatedSprite animatedRobotSprite = new AnimatedSprite(robot.centerX, robot.centerY, 122, 126, (ITiledTextureRegion) robotTextureRegion, getVertexBufferObjectManager());
    scene.attachChild(animatedRobotSprite);
    animatedRobotSprite.animate(new long[]{1250,50,50});

    // add right arrow button
    Sprite rightArrowSprite = new Sprite(0, CAMERA_HEIGHT-70, rightArrowTextureRegion, getVertexBufferObjectManager()){

        @Override
        public boolean onAreaTouched(TouchEvent pSceneTouchEvent,float pTouchAreaLocalX, float pTouchAreaLocalY) {

            switch (pSceneTouchEvent.getAction()) {

            case TouchEvent.ACTION_DOWN:
                moveRight = true;
                parallaxBackground.setParallaxValue(5);
                break;

            case TouchEvent.ACTION_MOVE:
                moveRight = true;
                break;

            case TouchEvent.ACTION_UP:
                moveRight = false;
                break;

            default:
                break;
            }
            return super.onAreaTouched(pSceneTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
        }
    };
    scene.attachChild(rightArrowSprite);

    scene.registerTouchArea(rightArrowSprite);

    scene.setTouchAreaBindingOnActionDownEnabled(true);

    scene.setTouchAreaBindingOnActionMoveEnabled(true);

    scene.registerUpdateHandler(new IUpdateHandler() {

        @Override
        public void reset() {

        }

        @Override
        public void onUpdate(float pSecondsElapsed) {

            if ( moveRight ){
                animatedRobotSprite.setPosition(animatedRobotSprite.getX()+speedX, animatedRobotSprite.getY());

            }
        }
    });

    return scene;
}


texts:
Take Doodle Jump and other games that rely on the accelerometer. The movement of the character is very smooth and I have no idea how they implemented it. I've seen a number of SO/GameDev/forum questions, but the discussion ends abruptly when someone recommends a high/low pass filter. I've tried that (unless I'm missing something) and the results are nowhere near smooth.

All I'm trying to do is move a character on the x axis. This is the code I have and it's very "choppy". It's actually the code you can see on the official Android tutorials.

float alpha = 0.9f; //tried many values from 0.1f to 0.99f. chopiness still there

@Override
public void onSensorChanged(SensorEvent event) {
    if(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
        if(init) {
            gravity[0] = event.values[0];
            gravity[1] = event.values[1];
            gravity[2] = event.values[2];

            init = false;
        } else {
            gravity[0] = alpha * gravity[0] + (1 - alpha) * event.values[0];
            gravity[1] = alpha * gravity[1] + (1 - alpha) * event.values[1];
            gravity[2] = alpha * gravity[2] + (1 - alpha) * event.values[2];
        }

        // Remove the gravity contribution with the high-pass filter.
        linear_acceleration[0] = event.values[0] - gravity[0];
        linear_acceleration[1] = event.values[1] - gravity[1];
        linear_acceleration[2] = event.values[2] - gravity[2];

        character.setX(character.getX() - linear_acceleration[0]);

    }

I also tried multiplying linear_acceleration[0] with a sensitivity, where 0 < sensitivity < 1 but the choppiness still doesn't go away. What is the next step from here to achieve a smooth movement like in Doodle Jump?


texts: Unity Hit Collider GameObject is Null when Collider is Child (Line-of-Sight Detection Problem)

texts:
I'm creating line-of-sight code in Unity. It allows a radar to check whether it can see an object, or whether the object is behind an obstacle (a collider).

Similarly to Unity's suggestion, I check to see whether a Linecast going from radar to target strikes a collider that belongs to the target's game object.

In my implementation, a Target is a type that buildings and vehicles inherit from. Radar is a script attached to any game object, tracking from the transform of that game object towards any Target within the radar's scope.

The method giving me trouble is below. It is called every time a radar checks whether or not a collider stands between it and the Target (targets behind a wall or mountain can't be tracked).

/// <summary>
/// Check whether two objects can see each other. This does not verify any maximum distance.
/// </summary>
/// <param name="seeker">The object seeing</param>
/// <param name="target">The object being seen</param>
/// <returns>True if within line of sight, false if another collider is in the way</returns>
protected bool InLOS(Transform seeker, Transform target)
{
   RaycastHit hit;
   Physics.Linecast(seeker.position, target.position, out hit);
   if(hit.collider.gameObject == target.gameObject) // Null error? Make sure the sensor is not within a collider/rigidbody, or that trigger is on
      return true;
   else
      return false;
}

This method works to a degree. The image below shows its result. Green lines represent unobstructed radar tracking. (There are two radars in the scene: one on the airplane, and one on the dish).

Note that the airplane cannot see the radar dish, nor can the dish see the airplane (although they are both targets). Accordingly, there are two null errors at every frame: NullReferenceException: Object reference not set to an instance of an object.

The error points me to the following line: if(hit.collider.gameObject == target.gameObject). That's because, unlike the other, simpler targets, the airplane does not have its collider on the parent, but has many different colliders in its children.

I've tried finding the parent game object from the collider, but that didn't work either:

// Raycast
// ...

try
{
   if(hit.collider.gameObject == target.gameObject) // Null error? Make sure the sensor is not within a collider/rigidbody, or that trigger is on
      return true;
   else
      return false;
}
catch
{
   if(hit.collider.GetComponentInParent<Target>().transform.gameObject == target.gameObject)
      return true;
   else
      return false;
}

Same null error on hit.collider.GetComponentInParent<Target>().transform.gameObject == target.gameObject.

Well then, let's check for nulls:

// Raycast
// …

GameObject raycastHit = hit.collider.gameObject;
GameObject desiredHit = target.gameObject;

if(raycastHit == null)
{
   // Collider must be child raycast target hit, then
   raycastHit = hit.collider.GetComponentInParent<Target>().transform.gameObject;
}

if(desiredHit == null)
{
   // Collider must be child...
   desiredHit = target.transform.GetComponentInParent<Target>().transform.gameObject;
}

// Check hit equivalency
if(raycastHit == desiredHit)
   return true;
else
   return false;

Nope, same old null reference. Man are those GetComponent<> methods always a pain.

So let's go simple:

if(Physics.Linecast(seeker.position, target.position))
   return true;
else
   return false;

In this case, obstacles are not detected anymore. Hmm.

Question: how can I write GetComponentInParent<> correctly to find the Target game object's transform, knowing that sometimes Target will be a component of the same game object as its collider, while at others, Target will be the parent, and various colliders will be children?


texts: Storing 2D animation frames and sharing them between objects

texts:
I store 2D animation frames in some class.
But the problem is that when I want to create multiple objects for example I want to spawn explosion or enemy
void ExampleScene::update()
{
    if (needToSpawnEnemy())
    {
        this->objects.add(Enemy());
    }
}

It means that everytime I want to spawn object I will need to access TextureHolder, pass string, get texture and load or compute animation frames and any other calculations that derivered object wants. It's not problem for example with player beacuse I load it on Scene::onCreate only once during entire game but with enemy I would do this during some update function.
My likewise simplifed implementation
struct Animation
{
public:
    void addFrame(Rect rect);
    //The rest of implementation
private:
    std::vector<Rect> frames;
}

class AnimatedSprite
{
public:
    void addAnimation(Animation& animation);
    //The rest of implementation
private:
    std::vector<Animation> m_animations;
}

How do I represent objects (this is gonna be very small project which will evolve later to ECS architecture but I think my problem will not change anyway so I want to solve it already)
struct Context
{
    TextureHolder textureHolder;
    //The rest of stuff...
}

class Object
{
public:
    //The rest of implementation
private:
    Context* context;
    AnimatedSprite sprite;
}

class Player : public Object { //implementation }
class Enemy : public Object { //implementation }

And how I add animation frames
void Enemy::onCreate()
{
    this->sprite.setTexture(this->context->textureHolder.getTexture("assets//graphics//enemy.jpg"));

    Animation walkAnimation;
    walkAnimation.addFrame({0, 0, 64, 64});
    walkAnimation.addFrame({64, 64, 64, 64}); //etc...
    //Surely it can be changed so frames will be loaded from file on disk

    this->sprite.addAnimation(walkAnimation)
}

Maybe NOW it's not very big problem unless I would get animation frames from file (which I want in future). So is there any gamedev standard / pattern / another aproach for this? I was thinking to store frames in dynamic memory and somehow share that data between objects of same class but I'm getting headache of thinking how I could manage that memory. (I don't see how smart pointers would help me beacuse there could not exist any Enemy objects for some time)
class AnimatedSprite
{
public:
    void setAnimation(Animation* animation)
    //The rest of implementation
private:
    AnimationState* animationState;
    AnimationFrames* animationFrames;
}

Should first object load everything but how do I delete it? I don't know if x enemy will be last one.
Or maybe should I add some methods to Object class
virtual void Object::loadDataFromDisk();
virtual void Object::unloadDataFromDisk();

But it seems to be bit clumsy.
I was also thinking to use my Context class to create somewhat AnimationHolder and use it like this->context->animationHolder.getAnimation("ENEMY_WALK"); but I'm not sure about this.
Or maybe some prefab system?
TLDR;
To be precise my shorter question is how to avoid loading same 2D frames data (not textures) while spawning new objects.
So any help and ideas?


texts: Unreal Android game crashes after google play integration

texts:
I'm fairly new to android game dev but after some months of work I finished making my game in ue4.
However, when uploading it to google play on an alpha track and then trying to launch the app, it crashes.

The error itself might be connected to either gradle or proguard (from what I gathered in information over the past 2 days), but as the build.gradle file in unreal projects gets a reset with every fresh build, I can't just edit that.

I've also read in the forums by one unreal dev how you are supposed to add dependencies to the build.gradle by using an "additions.gradle" file, but there was no further documentation about that.

I have already looked up every thread online with a similar problem - yet none of those could solve my problem.

Crash logs:

java.lang.NoClassDefFoundError:

 at com.google.android.gms.c.c.<clinit> (Unknown Source)

  at com.epicgames.ue4.GameActivity.onCreate (GameActivity.java:2785)

  at android.app.Activity.performCreate (Activity.java:7383)

  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1218)

  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3250)

  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3405)

  at android.app.ActivityThread.-wrap12 (Unknown Source)

  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1994)

  at android.os.Handler.dispatchMessage (Handler.java:108)

  at android.os.Looper.loop (Looper.java:166)

  at android.app.ActivityThread.main (ActivityThread.java:7523)

  at java.lang.reflect.Method.invoke (Native Method)

  at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245)

  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)

build.gadle in Intermediate\Android\APK\gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    apply from: 'buildscriptAdditions.gradle', to: buildscript
}

apply from: 'baseBuildAdditions.gradle'

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle in Intermediate\Android\APK\gradle\permission_library

apply plugin: 'com.android.library'
android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        minSdkVersion 13
        targetSdkVersion 23
    }
}
dependencies {
    implementation 'com.android.support:support-v13:25.0.0'
}

build.gradle in Intermediate\Android\APK\gradle\downloader_library

apply plugin: 'com.android.library'
android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        minSdkVersion 4
        targetSdkVersion 15
        versionCode 2
        versionName "1.1"
    }
}

buildAdditions.gradle in Intermediate\Android\APK\gradle\app

 apply from: 'aar-imports.gradle'
    apply from: 'projects.gradle'
    android {
        defaultConfig {
            ndk {
                abiFilter "arm64-v8a"
            }
        }
        signingConfigs {
            release {
(Keystore removed)
            }
        }
        buildTypes {
            release {
                signingConfig signingConfigs.release
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
            debug {
                debuggable true
            }
        }
    }
    dependencies {
        implementation('com.android.support:support-v13:27.1.0')
    }
    dependencies {
        implementation('com.google.android.gms:play-services-gcm:11.8.0')
    }


texts: Changing background images frequently within a specific time range with Cocos2D

texts:
I am working on a game development project for Android. We use the Cocos2d framework. I have to design a page which contains two background images, I need to switch these images repeatedly within 1sec. How can I do this? How can I use CCTransitionScene in my Java code and change these images repeatedly?

Thanks in advance.


texts:
Is it possible to use multiple keys so that they combined will do the action?
Say for instance you want a jump attack that would require two buttons to be pressed at the same time. in this case: space + mouse 1 ?
I tried creating  that however it didnt seem to take my input.

Does anyone know how this can be achieved?


texts: How to attach one sprite to another in LibGDX?

texts: I want to attach one sprite to another so that it is always located at the 'bottom' of the other sprite, regardless of how the main sprite is rotated.


texts: Optimized rendering of a cube mesh world

texts: I want to render a cube-mesh (a.k.a. Minecraft-style) world. If I render each existing cube it will eat up FPS pretty quickly. How can I optimize it? I understand that the point is to not render invisible meshes (faces?) but my problem is to find out what is invisible and what isn't.


texts: multiply matrix by vector: what to do if need to change y-up to z-up?

texts: I multiply a matrix with a position vector to get a new position, however, now I need to change my matrix from y-up coordinate space to z-up. Changing only the matrix won't work: how to apply the change to the vector (change position vector from y-up to z-up)?


texts: UDP sending important data often - Should I use a reliable send or unreliable with resend?

texts:
I'm making a multiplayer RPG. My problem is that I send player data very often (100 ms), that contains:

Position (float x, y, z)
Radius (float angle)
Animation (int16_t id)

And because the package is unreliable, sometimes packets are lost and here the problem starts. The packet is only sent if something changes, like animation; but animation is important, they must arrive to the clients.

So the question is, should I change reliability to reliable? Or just split packet into two? Or simply resend packet?


texts:
I have been troubleshooting a problem I have encountered with some of my raycasts, and have arrived at a perplexing brick wall. I fire a Physics2D.Raycast in order to determine if my character is grounded; however, it would not always return a reference to the ground object in situations where it should.

Breaking down the method call, I have fired a raycast without a layer mask. This returns the correct reference; I then send the layer mask associated with the reference transform to the debug log.

public void FireTestRay()
{
    RaycastHit2D hit = Physics2D.Raycast(startPosition, Vector2.down, 0.1f);
    Debug.Log(hit.transform.gameObject.layer);
}

  8

I want to be checking against my platform objects, which I have proven to contain the layer index of 8. However, when I use layer masks, the raycast fails.

public void FireTestRay()
{
    RaycastHit2D hit = Physics2D.Raycast(startPosition, Vector2.down, 0.1f, 8);
    Debug.Log(hit.transform.name);
}

  NullReferenceException: Object reference not set to an instance of an object

I am not moving my game object; in fact, the only thing that changes at all is the above mentioned lines of code.

I seem to be able to successfully hit the intended object if I do not use a layer mask, and in turn, can successfully retrieve the value of the intended objects layer mask. As soon as I filter my raycast to only hit that layer mask, it fails.

Why does Physics2D.Raycast automatically fail if applying a layer mask?


texts: I have a character who walks to random points in my room in Unity. The problem is he always faces one direction, I want to write in C# a piece of code that will get the direction the character is currently facing and the position of the target, then works out the angle between them to turn the character that amount. I have tried the LookAt function but that makes the character walk in an arc shape towards the target which looks very unnatural as it constantly looks at the target.


texts: How do I avoid interpolation artefacts when scaling up a heightmap?

texts:
I am using a bicubic interpolation algorithm in order to upscale a height map, and I am noticing some artifacts around the pixels boundaries. However, these artifacts don't seem to appear when I use a simple cubic interpolation (spline).

Could it be because the bicubic interpolation doesn't guarantee the second derivative to be continuous, unlike the cubic spline ? If so, is there known algorithms that have a continuous second derivative ? Otherwise, is there a way to deal with these artifacts ?

Linear interpolation (shows the pixels boundaries):

Bicubic interpolation (artifacts visible at pixels boundaries):

Cubic interpolation (no noticeable artifacts):

I tried several bicubic formulas, which gave me the same results. Here are some examples:

http://paulbourke.net/miscellaneous/interpolation
http://www.paulinternet.nl/?page=bicubic


texts: Efficient movement of units to different points with different speeds

texts:
I have a series of units and have been given 2d points that they must go to. However they are free to go to what point they like as long as all the units get to all the points  in the quickest time possible. Each unit has its own speed.

What is the best algorithm if I ignore unit collisions and terrain is perfectly flat with no obstacles.


texts: Unity3D: Rendering images weirdly in GUISkin

texts:
So i'm trying to make a gui skin in Unity3D and i'm having some problems with the images, what I mean is the images are being rendered all weirdly, not properly and some have lines through them. I have some photos of what is happening.

Background (GUI Box)

Button (GUI Button)

Anyone know why the images are being rendered weirdly and how to fix it? Appreciate any help!


texts:
I would like to generate graphs randomly, like this:

I have found that Box2d maybe can do it to me. But I do not know, how to use it, so how can I generate bobies after world initialization?


texts: How can I use a custom payload name for my GameMaker game?

texts: I have finished compiling my GameMaker Studio .win file. I then copied the Runner.exe binary to the game's directory to run it. The issue I face is that unless I name the game's payload "Data.win" the launcher asks me to manually browse for the payload. How can I use a name other than Data.win and have the launcher run as if it uses the default name?