texts: maya: cannot rotate ik control in command

texts:
I use maya default human ik example, see my gif, when i rotate in viewport, rotate work, but when i undo and rotate with same command in script editor, it cannot rotate, how to rotate ik control in command

I try maya 2018 and maya lt 2018, it has same problem


texts:
Is it possible to get the location of a drawable in Android Studio?

Example: drawable.getLocationonScreen();

I want to use it for collision detection.


texts: How to split sprites into multiple pieces, like in image below

texts: Or how it should be called? I will change color programmatically. Sorry for my English.


texts: I would like some help regarding whether Amazon Lumberyard supports augmented reality (AR) or not. It clearly mentions VR is supported but nothing about AR support. It looks as if we just have to attach an AR plugin on engines like unreal, unity, etc. So will it work here?


texts: Add oceans to an earth model with only continents?

texts:
I have the following earth model, it only has continents:

I wanted to add water but as you can see, some of the continents are now hidden due to the water sphere being more round than continents:

I tried the following:

downscale water sphere, kinda works but only when it's significantly smaller, overall result is then unconvincing.
change shader and render queue offset, does not do anything actually.

I was hoping that maybe there could be a way to render transparent parts of this earth model as a specific color or eventually another material.

Please do not suggest to use another earth model, I wouldn't have asked the question otherwise :)


texts: What is causing these texture edge artifacts on some video cards?

texts:
I have a 2d heightfield converted into a very simple mesh and textured with tiles from a texture atlas.  The tiles texture is drawn with:

glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);

On my integrated Intel card, it draws as I intend (top picture).  On a friend's ATI card, it has very visible edges (bottom picture).

What causes this, and how can I avoid it?

Extra info:

glColor4f(1,1,1,1) has been called before drawing the mesh
the texture atlas is a simple vertical strip, so the right-side of each tile has x=1.0f
the vertices are being shared so there isn't really a 'hole' between my rows
the resolution on both systems is the same
the vertices and texture coordinates are all passed as GL_FLOAT
the tiles atlas is mipmapped


texts:
I have a scene that is rendered from the point of view of the light using an orthographic projection matrix.

For an arbitrarily shaped and oriented object that doesn't change its shape or size in any way, the amount of pixels that get rasterized change with its position. I guess it's better to explain this with an images:

The depth of the quads (their y coordinates) are constant. Their x and z coordinates are slightly different. However, since it's an orthographic projection matrix, their "world space" floating point sizes are the same as seen from the camera. Just in one case, one additional lines of pixels is rasterized (I drew the two white lines with mspaint to illustrate their size difference).

This is highly undesirable for my application. Is there a way to keep the amount of rasterized pixels consistent? How would I go about implementing it using OpenGL?


texts: How do I create a wide-angle / fisheye lens with HLSL?

texts:
What are the concepts that need to be implemented in order to achieve the effect of a wide angle lens of varying extremities?

Pseudocode and specific explanation referring to the various stages of the content pipeline, as well as what information needs to be passed in from the source code to HLSL would be very useful.

Also, what are the differences between implementing a wide-angle lens, and a fisheye?


texts: What is the difference between Djikstra and flow fields?

texts:
I understand flow field pathfinding (as illustrated in recent Gas Powered Games titles) consists of 1) computing a vector field covering the map for a given destination, 2) deriving unit directions from their position on that field, and 3) recomputing it at each frame to take dynamic obstacles into account.

I was wondering if the very same steps could be used, but by computing the vector field simply with Dijkstra. After all, if you apply Dijkstra in reverse (from the destination), and continue until you've covered the whole map, you end up with a vector field giving the best direction for each unit trying to get to that destination. If you recompute it each frame, don't you end up with the same behavior and efficiency as flow field, only without the math I don't understand?


texts:
Is it possible in Unity to make some sort of bounding box (with a running application) within the current viewpoint of the actual screen?

Let me explain:

I'm working on a project which uses a projection for visual output, the screen I am projecting on is smaller than the actual projectors resolution. This means that the unused spaces around the actual working application, are black and visually hidden.

Made an image for exra explanation:

As i'm new to Unity and still learning, I'm not sure if this is even possible because of the use of camera's and environment. I happen to know that it's possible in three.js. But if anyone could point me in the right direction or explain that it's impossible would be much appreciated because I'm not sure where to look anymore!


texts: Libgdx Texture Sides Are Cropped Automatically for Seemingly No Reason

texts:
I'm trying to render some textures using libgdx SpriteBatch. This sounds very easy but I have a serious problem. I'm testing on desktop and depending on the resolution of the app window, textures are automatically cropped. This happens when I configure width and height attributes of LwjglApplicationConfiguration or when I just resize app window manually. Right and bottom sides of some or all of the textures are cropped depending on the resolution (maybe it depends on x,y coordinates of texture rectangles, some are shown good others are buggy). I load textures from atlas. While atlas uses MipMapLinearLinear filter, I also tested with Nearest filter, the problem still persists

Here are important parts of the code (the rest is default things taken from example like creating SpriteBatch, etc.)

// I use premultiplied alpha blending
batch.enableBlending();
batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);

myAtlas = new TextureAtlas(Gdx.files.internal("test.atlas"));
textureRegion = myAtlas.findRegion("testtexture");

batch.draw(textureRegion, 100, 100, 40, 40);

Here is a image below showing app windows.


texts:
I'm implementing a framerate independent FPS camera and I'm having a problem with jerky camera. The camera is smooth if I translate it or if I make it rotate at a fixed rate, but as soon as I start to move it with the mouse, it starts stuttering.
This is the part of the code in the main loop that keeps track of the time and calculates the rotation around the y axis:
std::chrono::high_resolution_clock::time_point newTime = std::chrono::high_resolution_clock::now();
uint32_t frameTime = static_cast<uint32_t>(std::chrono::duration_cast<std::chrono::microseconds>(newTime - oldTime).count());

oldTime = newTime;

double mouseXInput;
double mouseYInput;

glfwGetCursorPos(window, &mouseXInput, &mouseYInput);
glfwSetCursorPos(window, 0, 0);

float mouseX = static_cast<float>(mouseXInput);
float mouseY = static_cast<float>(mouseYInput);

float rotateSpeedModifier = 0.0000005f;

// Fixed rotation rate
camera.rotation.x += frameTime * 0.0000006f;

// or mouse controled rotation rate (pick just one of the two lines)
camera.rotation.x += frameTime * rotateSpeedModifier * mouseX);

// Overflow and underflow control
if (camera.rotation.x > 2.0f * PI) {
    camera.rotation.x -= 2.0f * PI;
} else if (camera.rotation.x < 0.0f) {
    camera.rotation.x += 2.0f * PI;
}

Note that I disabled the cursor and enabled raw mouse motion at the start of the program (it is supported).
I also centered it:
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
glfwSetInputMode(window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE);
glfwSetCursorPos(window, 0, 0);

Since the stuttering only appears when I'm moving the mouse, I'm guessing it's some kind of precision problem. Variable frameTime is anywhere between 400 and 5000. I think using milliseconds doesn't give enough precision. Variables mouseX and mouseY are usually within [-10, 10] if I'm not too aggressive with the mouse, and they are always a whole number which is odd to me. I don't think casting it to float is the problem then either.
What can I do here to improve mouse tracking precision? Is that even what the problem is? How do I fix this?


texts: Navmesh bound in ue4 topdown and third person template

texts:
The Topdown template has a navmesh volume to build walkable area, if remove that volume, the character will be unwalkable. However, the third person template has no such thing, but the character movement is OK.
What's the difference between them? Why third person template don't need a navmesh volume?


texts: XNA/MonoGame screen scale and keeping aspect

texts:
My aim is to make a simple 2D platformer, the idea is that it will be a base resolution of 480x270 (16:9) which can scale x2, x4(1920x1080) or go full screen.

I basically do:

graphics.PreferredBackBufferWidth = 480;
graphics.PreferredBackBufferHeight = 270;

and call methods do double or x4 them and then call graphics.ApplyChanges() which work well, I assume any 1x1 pixels from 1x resolution now appear as 2x2 or 4x4.

However in full screen the image is just stretched to whatever fits, how can I make it "letterboxed"?


texts: Has an open console any chance to give more strength to the indie game world?

texts:
I have heard about the GPX, but i don't really think the embedded market is mature enough in terms of performance, but what about the home console market ?

I'm not talking about last-generation graphics, because that would be economically impossible, but what about an hardware as fast as a playstation 2/Xbox 1/Gamecube ?

For games, the trick would be to ask some editors to recompile their best sellers  for the new machine: those games being from the PSX age or even older console generations, I think this would have a very low cost job and they could still make some good profit, but I need to know if this is doable technically, considering the architecture which can be quite exotic.

Do you think it would be a viable project to talk about to investors ?


texts: Where do I find the code for the open-source game Warmux?

texts:
I found an open source game called Warmux but I don't know how to get the code.  I downloaded the file from here, but I don't know where to go from there.  I didn't find any instructions on how to use the source.
While I was looking for it, I came across something called git and repo. Do I use that?


texts: How could you model "scent trails" in a game?

texts:
Say you want to create a 3D game, and have either players, or mobiles, be able to tract other entity by following their scent trails. Is there any known data-structure that matches this use case?

If you have only few individuals going about, you can probably do something like a map of 3D coord to entity ID, but real scent works differently, because it fades over time, but slowly. And most of the time, you can only know approximately what went there, and approximately how many things of that type went there. And the approximation becomes worst with time, until it's gone.

I imagine it's kind of like starting with an exact number, and slowly loosing the least significant digits, until you loose the most significant digit too. But that doesn't really help me, because entity IDs aren't normally encoded to contain the entity type, in addition to it's individual ID.


texts: Unity Change Ball Direction after hitting paddle in a Pong game (like in dx-ball)

texts:
I'm struggling with how to get the ball to change the bounce based on where it hits on the paddle. Normally in a pong game, the angle changes, depending on how far from center the ball bounces, and which direction of the center it bounces. I managed to do something like that:

//rb = rigidbody, velOnPaddleHit = predefined float
float dist = transform.position.x - paddle.position.x;
dist = transform.position.x > paddle.position.x ? dist : -dist;
dist /= paddle.localScale.x/2;
dist *= velOnPaddleHit;
rb.addForce(dist, 0,0);

But it's just not working / it's weird. Can anyone help me?

Edit: Here's the video showing this kind of behaviour. When the ball hits the left side of the paddle, it goes left, the velocity doesn't matter

https://www.youtube.com/watch?v=fHX_2DLDp1w


texts: OnTriggerEnter2D or OnCollisionEnter2D not getting called

texts:
I checked the other answers for this but mine didn't get fixed
Here's the code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DestroyCollectibles : MonoBehaviour
{
    private void Start()
    {
        Debug.Log("Hallo");
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("Trigger");
    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Debug.Log("Collsion");
        // if (collision.gameObject.CompareTag("Collectible"))
        // {
        //     Debug.Log("Apple");
        //     Destroy(collision.gameObject);
        // }
    }
}

And screenshots:


texts: How to get the directional vector (for IrrKlang) from pitch and yaw?

texts:
Currently my game engine allows the player/camera to pitch and yaw, so there's no roll.

The pitch angle starts at 0°, which means the camera is facing straight ahead. From here it can go up to +85° (looking almost straight up) or down to -85° (looking almost straight down).

The yaw angle starts at 0°, which means the camera is facing east. The rotation is clockwise so 90° is south, 180° is west and 270° north. What would be 360° is 0° again obviously.

How do I get from this to the direction vector (lookdir) IrrKlang's SetListenerPosition requires to get directional audio working?

PS: x and z are my horizontal axis, y is the vertical one.


texts:
I'm trying to write a map editor for a unity game using openGL. In order to do that, I need to unpack it's resource files to get meshes, textures and other good stuff.

In doing so, I've discovered that unity mesh asset stores vertices, normals, texture data, and any other per-vertex type data in one interleaved array.

I have two choices here. First is to leave the data as is and push it into a single VBO and then use attrib pointer to adjust strides and whatnots to make it work. When I read data from file into memory, I can just read whole array with a single ifstream::read method call.

Second choice is to unravel all data into it's separate channels and have a separate VBO for each data type. I personally prefer it this way, but this means that I need to deinterleave that array. I'm unsure how to do this efficiently. The most obvious way (and very inefficient) is to read it char by char and store each char in appropriate array, depending on channel structure. I could maybe mess with it a bit and set it up to read it channel per channel (meaning 2-4 chars at once) instead of char by char. This still seems very slow to me.

Maybe I could load the whole array into memory and then deinterleave it there, but I'm still unsure of method that would be fast.

The priority is for the program to be fast while drawing, and deinterleaved multiple VBO setup is said to be faster due to lesser amount of cache misses.

To give you a sense of numbers, the game I'm looking at contains about 2630 different mesh assets, with each containing an estimated average of 500 vertices.

How do I deal with this? I will be loading all this data just once on program startup anyway, so it doesn't have to be super fast, but I don't want to force the user to wait for too long even then. Maybe number of vertices altogether is small enough for it to be very fast regardless, but I don't want to commit to either way before I have some idea of what I'm doing.

Bottom line is, should I just leave it interleaved, or is there some efficient way to deinterleave it? Am I jumping the train here, being scared of leaving it interlaved? I know I should probably benchmark both cases, but both cases are drastically different in my case and would require huge code changes, not to mention I'm nowhere close to actually drawing the scene I need to.


texts: MonoGame sprites not consistently drawing

texts:
Please don't mark this as a duplicate of my previous question which was asked anonymously. this is a reattempt because i cannot edit the first attempt.

What I have so far is:
- randomly generated tile set with items on SOME tiles
- one creature spawner that spawns up to 5 creatures which can be controlled by the player
- the ability for creatures to pick up items and bring them back to the spawn and store them for later use

What I am noticing is when i launch the game, it doesnt always show all the sprites. Sometimes the spawner is missing, or the creatures, or the GUI. ANd when things DO appear, if i tell the creatures to pick up anything, other items on the ground randomly appear and disappear. even the spawn sometimes disappears! what I do notice is that when i have multiple creatures, some will disappear when crossing invisible lines but not all of them. i forced two creatures to go east at the same speed and time, and one vanished and the other didnt.

If you have any ideas as to what might be causing this, please let me know. if you have any questions, i'll try to edit to appease you.

thanks for reading!

I have my draw method like this:

GraphicsDevice.Clear(Color.CornflowerBlue);

// TODO: Add your drawing code here

spriteBatch.Begin(SpriteSortMode.BackToFront,
          null, null, null, null, null,
          camera.GetTransformation());

worldEntity.Draw(spriteBatch);

guiManager.DrawGUI(spriteBatch);

spriteBatch.End();

base.Draw(gameTime);

for the world entity...
its draw method systematically goes through each tile in the world and calls its draw method.
the tile draws itself using

Vector2 topLeftOfSprite = new Vector2(this.X, this.Y);
Color tintColor = Color.White;
spriteBatch.Draw(tileTexture, topLeftOfSprite, tintColor);

and then proceeds to call the draw method of any items on it.

creatures and items have very similar draw methods.

the gui also draws itself in a similar fashion.

what i DO notice is that ive NEVER seen ground tiles vanish, only the items on them or creatures in the world. Could it be their Z isn't set appropriately?


texts: Convert gl_FragCoord range to fragment range

texts:
I'm working with shaders so far, but I'm not sure how I can make my shader gl_FragCoord relative to the window. To be more clear, this is what I have:

and this is what I'm looking to achieve no matter where I place the fragment on the screen:

As you can see, the shader take the whole window as the refference canvas insted of the fragment. I'm playing with ranges and division based on resolution and fragment size/position, but couldn't figure it out.

The second image was compiled based on hardcoded data, need to find a general solution..

EDIT: This is my vert & frag glsl code:

#version 330 core
layout(location = 0) in vec2 position;

void main() {
    vec2 fp = vec2(position.x, position.y);
    gl_Position = vec4(position.x, position.y, 0.0, 1.0 );
};

$

#version 330 core
layout(location = 0) out vec4 color;

void main() {
    vec2 pos = gl_FragCoord.xy/vec2(800., 600.);

    float r = 0.4 / 2.0;
    float c = smoothstep(r, r - 0.01, distance(pos, vec2(0.5)));

    color = vec4(vec3(c) * vec3(0.0, 0.5,1.0), 1.0);

};


texts:
I want to scale the start button from the center with initially scaled to 0.3 times.

    start = new ImageButton(new TextureRegionDrawable(new TextureRegion(startTex)));
    start.setTransform(true);
    start.setScale(0.3f);
    start.setOrigin(Align.center);
    start.addAction(forever( sequence(scaleTo(1.5f,1.5f,1f), scaleTo(1, 1, 0.5f), delay(0.5f)) ));
    table.add(start).expandX().colspan(2).size(start.getWidth()*0.3f);

It scales the button but not from the center.

When I remove size method from above, button scales from the center, but it starts from its initial size rather than 0.3 times.
I am stuck at this. Please help me.


texts: LibGDX - How to export a texture as a .png onto, say, the desktop

texts: I'm making a game in which I need to export a texture which the user has edited as a .png into a specified location. I'd like it if I could have the default saving window thing (like on other apps when you do cmd+s). If this isn't possible, is there any way in GDX to export a texture (as a .png) to the computer (and preferably not the assets folder)


texts: Why is my alpha transparency not working correctly in Unity?

texts:
In Unity I have never seen a bug quite as weird as this one.

As usual, I import my texture with a transparent background and then check the alpha is transparency box and apply it, and everything seemed okay. It had worked like it usually does and made the background of my texture transparent. When I apply it to an object or even just paint it onto the terrain it shows the original texture, but in the areas where there should be nothing it replaces it with some nightmarish plaid hell.

I have tried other transparent textures but that doesn't seem to work either same result but for each different picture there is a different pattern and color of plaid. I really would appreciate any help I can get on this because I'm just stumped.


texts: Unity Graphics.DrawMesh lags behind rotation?

texts:
I have a setup in unity using Graphics.DrawMesh() to draw a mesh on my players camera location in the update loop, Graphics.DrawMesh(viewModel, matrix, material, layer, null, 0);
matrix = Matrix4x4.TRS(cam.transform.position, cam.transform.rotation, scaleFps);
when I use my mouse to move around the camera, it lags behind where the camera is, as can be seen in the video. I have no idea how to fix this. I've tried not using the matrix, and it doesn't change anything.

https://youtu.be/eWFFYcOX_4Q

Here's the script I use for moving the camera:

    //Get the current mouse input.
    yaw += Input.GetAxis("Mouse X") * mouseSensitivity;
    pitch -= Input.GetAxis("Mouse Y") * mouseSensitivity;

    //Clamp the camera rotation.
    pitch = Mathf.Clamp(pitch, -maxLookAngle, maxLookAngle);

    //Calculate and rotate the camera.
    currentRotation = Vector3.SmoothDamp(currentRotation, new Vector3(pitch, yaw), ref rotationSmoothVelocity, mouseSmoothScale);

    //Rotating the player.
    Vector3 bodyRotation = new Vector3(0, currentRotation.y, 0);
    transform.localEulerAngles = bodyRotation;

    //Rotating the camera.
    Vector3 cameraRotation = new Vector3(currentRotation.x, 0, currentRotation.z);
    playerCamera.transform.localEulerAngles = cameraRotation;'


texts:
I am having an issue with the walls in my game. I have set them as objects and used the script:

depth = -y;

inside their create event.

However, when I walk my character in front of them, the correct depth is only kept until the character kindof goes half in front of the wall.

Like this:

These are the collision shapes

And this shows how I inherit from one door parent and add the depth = -y; script to the create event of the wall child.

My character also has depth = -y; but on its step event.


texts: Unity Physics.Raycast give false positive while using layer mask

texts:
I'm very new to Unity so please excuse my question if this sounds very basic to you.

I'm following various tutorials and I have a small question regarding Physics.Raycast:

if (Input.GetButton("Fire1")) {
        // check ground hit first
        RaycastHit hit;
        if (Physics.Raycast(ray, out hit, LayerMask.GetMask("Ground"))) {
            Debug.Log("[PlayerMotion]: Hit" + hit.collider.name + " " + hit.point);
            agent.SetDestination(hit.point);
        }
}

Here, even tough I expressively set the layer mask to "Ground", I still get a hit with the Player game object itself (the ground hit is working fine). I thought ok maybe I put the "Ground" layer as well on the player by mistake but I checked several times and it's not the case.

I'm attaching a gif so you can see what's the issue exactly

There's an easy by checking the collider.name but I still find it odd that the Raycast gives me a false positive with the player hit. Any idea what's going on ?


texts:
I am getting my 3D modeling pipeline started and a few questions have come up about modeling packages and formats:

What 3D model format is easy to parse, free to use, and is usable on the iOS/Mac platforms?
Will I be able to create my own wrapper classes for said 3D model formats, or is it a code-and-format packaged deal?  Does this format come with a free or cheap toolchain for creating new models and editing old models?

Thanks for the insight ahead of time!


texts: How can I develop a Lights Out solving algorithm?

texts: I am programming the game that named Lights Out. The purpose of this game is turning all the lights out. There's a flash version of the game here. I want to develop a way of solving the game. How can I do this?


texts:
I asked this question some time ago. Now I ended up with just a sorter method that will sort the items based on their bulkiness/nSlotsRequired. Here's what I'm doing:

I store all the items I have in a one-dimensional array.
Empty the bag.
Sort the array.
And start putting them back into the bag again.

Now, this is clearly not the best way to sort something, I mean, if I have an array I wouldn't just store its values somewhere else, empty it, sort the other array and then copy them back. Even if I had a 2D array, I would sort it by considering it a 1D array.
1st element's index is 0, 2nd is 1, 3rd is 2, 4th is 3, 5th is 4, etc.

General formula to convert from a 1D index to a 2D:

row_index = _1D_index % nRows;
col_index = _1D_index % nCols;

For example the 5th element has the 1D index of 4, to get the row: 4 % 3 = 1, to get the col, 4 % 4 = 0, so your element is at 1,0. What's the point of all this? Now you can just make a function

int GetAt(int index)
{
    return array[index % nRows][index % nCols];
}

and something along the lines of:

void Swap(int index1, int index2)
{
   int r1 = index1 % nRows;
   int c1 = index1 % nCols;
   int r2 = index2 % nRows;
   int c2 = index2 % nCols;
   int temp = array[r1][c1];
   array[r1][c1] = array[r2][c2];
   array[r2][c2] = temp;
}

But the problem is:
1- items take more than one slot.
2- Even if I were to just swap them in a way that they're sorted, they still have to get to their positions, I mean, the biggest one would go to the top left, beside it is the smaller, etc.

Taking notice that:

I already have an array of the items' indices/places in the bag, so I don't have to look for them.
I have an array of the available slots in the bag, that way I don't
have to go through all of them to find where items fit. I just start
from the next available slot placing the items (I update those arrays everytime I add/remove an item)

is there a more efficient way of doing this? Can I just, sort the items right away without having to empty the bag, store them somewhere else, etc? - It would make more sense. I couldn't think of a way :/ Maybe sort only the items that needs sorting? Thanks for any help.

EDIT:
Here's what I have so far (sorting feature @~9:00)


texts: Entity component system implementation choices

texts:
// Ex.1
    for (Component& component : m_components)
    {
        UpdateComponent(component, dt);
    }
// Ex.2
    for (Component& component : m_components)
    {
        component.Update(dt);
    }

Assume that:

UpdateComponent() and the class method Component::Update() have identical logic.
Component::Update() is not a virtual function.
m_compoents is a container that uses a contiguous memory block (e.g. std::vector).

From the caching perspective, is there any performance difference between the 2 examples?


texts: Keeping object a fixed distance from the ground, buggy behavior

texts:
I'm trying to make a script that will keep my object exactly 1 meter from the ground. So far I've got the following code :
    using UnityEngine;
    using System.Collections;

public class HoverScript : MonoBehaviour {

    public Transform target;
    public float hoverDistance;
    void Start ()
    {

    }

    void Update ()
    {

    }

    void FixedUpdate ()
    {
        if (Physics.Raycast(transform.position, Vector3.down, hoverDistance))
        {
            RaycastHit hitInfo;
            Physics.Raycast(transform.position, Vector3.down, out hitInfo, hoverDistance);
            float correction = hoverDistance-hitInfo.distance;
            //Debug.Log(correction);
            //Debug.Log(target.position);
            target.position = new Vector3(target.position.x, target.position.y+correction, target.position.z);
            //Debug.Log(target.position);

        }
    }
}

Basically, if the raycast hits, then it finds the distance of the hit. If it's .9 and the hoverDistance is 1, it would push the object up by .1, and keep checking every update. It seems like it would work, but I get this result : http://www.gfycat.com/IllfatedMediocreAquaticleech

In case the link goes down, basically the object falls like normal because of gravity until the distance is reached, then it slows down dramatically and slowly sinks into the ground.

The objects are set up like this

gameObject(has hover script, rigidbody, the camera following script)
 |
 ----> mesh(just a mesh, mesh renderer, and collider)

The target of the script is the parent gameObject.

Any ideas why this script isn't working?


texts: How can I color in only specific regions of my scene?

texts:
I am interested in having large portions of my game be grayscale, but I'd like certain parts of the scene to have full color.
Something like this:

Is this something that is possible with shaders or the like within unity? What sort of techniques would I need in order to leech color from most areas like in my screenshot above?


texts: How do I implement dynamic objects in a voxel engine?

texts:
I am writing my own voxel engine, based on cubes of different sizes and properties. In order to store and efficiently use voxels, I implemented Sparse Voxel Octree storage, but I plan to have many dynamic structures in the engine that would change their position in space.

How could that be implemented, in my case? Should I use a separate storage for dynamic objects? It would be more desirable to treat those objects as voxels, too, but how do I move them smoothly?


texts: ToonRamp Shader + Normal Maps: How to keep strict lighting bands?

texts:
I'm trying to achieve a shading similar to the one on this image:

Image 1: https://imgur.com/a/eTTvSCD

To get something similar to this I wrote a toon ramp shader (similar to the one in the Standard Assets) with normal maps. The shader works, and without a normal map you can see the lighting bands strictly defined, with visible seams separating them (Image 2). But once you add a normal map, the toon bands won' t have well defined seams anymore, and will blend smoothly all across the mesh (Image 3).

Image 2 & 3: https://imgur.com/a/SI3BxED

This is my current shader:

Shader "Custom/ToonRampWithNormals"
{
    Properties
    {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _BumpMap("Bumpmap", 2D) = "bump" {}
        _Ramp("Toon Ramp", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Ramp

        // Use shader model 3.0 target, to get nicer looking lighting
        #pragma target 3.0

        sampler2D _Ramp;

        half4 LightingRamp(SurfaceOutput s, half3 lightDir, half atten)
        {
            half NdotL = dot(s.Normal, lightDir);
            half diff = NdotL * 0.5 + 0.5;
            half3 ramp = tex2D(_Ramp, float2(diff,diff)).rgb;
            half4 c;
            c.rgb = s.Albedo * _LightColor0.rgb * ramp * atten;
            c.a = s.Alpha;
            return c;
        }

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
        };

        sampler2D _MainTex;
        sampler2D _BumpMap;
        half _Glossiness;
        fixed4 _Color;

        UNITY_INSTANCING_BUFFER_START(Props)
            // put more per-instance properties here
        UNITY_INSTANCING_BUFFER_END(Props)

        void surf (Input IN, inout SurfaceOutput o)
        {
            // Albedo comes from a texture tinted by color
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
            o.Albedo = c.rgb;
            o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

So, what have I done wrong? How can I have well defined lighting bands and have normal mapping?

If you can think of a better way to achieve something similar to the reference or have any thoughts about it please share, any contribution is much appreciated.


texts: Can't make sprite collide with tilemap made with Tiled

texts:
I'm a newbie who just started learning phaser.

I have created a tile map with Tiled.

It is composed of two tiled layer: background & collision.

In collision layer I put some walls.

And in the game code,

I have loaded tilemaps, create them, and they shows perfectly.

Then I set the collision, and sense the collision in update();

I think it should make the sprite collide with wall, but it didn't..

I tried adding "collison" properties in Tiled as I found from some tutorials, but it didn't work either..

Can someone help me?

Below is the critical part of the collision code.(And Also I have all my codes packed and you can download with below hyperlink.)

//load tilemaps in preload.
this.load.tilemap('zombieset', 'assets/tilemaps.json', null, Phaser.Tilemap.TILED_JSON);
this.load.image('tiles', 'assets/tileset.png');

//start physic systems
this.physics.startSystem(Phaser.Physics.ARCADE);

//create tiles, and it shows perfectly.
this.map = this.add.tilemap('zombieset');
this.map.addTilesetImage('tileset1', 'tiles');

//set collision.
this.map.setCollision(1);
this.layer = this.map.createLayer('background');
this.layer = this.map.createLayer('collision');
this.layer.resizeWorld();

//sensor collison in update()
this.physics.arcade.collide(this.asuna, this.layer);

PS. I have my all code & img & json packed here... Thanks~

https://db.tt/AAdpu3zd


texts: Algorithm for "mipmapping" terrain vertex heights and normals

texts:
I am creating an engine in opengl. As the distance from the player increases, the width and height of the tiles increase by factors of 2. How can I do this? I am currently just averaging, but I miss some of the peaks and valleys, so the slopes are less intense as the tile size increases. This causes some of the textures relative to slope angle to disappear (e.g. grass isn't formed on large slopes, but at distance everything becomes grassy).

The slopes/textures and lighting are based on my vertex normal map.

Here is pseudo code for my current procedure:

float heightmap[layer][x][y]
float normalmap[layer][x][y]

For i=1; i<num_mipmaps; i++
    For x=0; x<(width>>i); x++
        For y=0; y<(height>>i); y++
            heightmap[i][x][y] = 0;
            For x2=x*2-1; x2<x*2+1; x2++
                For y2=y*2-1; y2<y*2+1; y2++
                    heightmap[i][x][y] += heightmap[i-1][x2][y2];
            heightmap[i][x][y] /= 9;

... then I just calculate all face normals and vertex normals separately for each layer.


texts: Scene management system for simple terraria-like game

texts:
I am building the engine for a terraria-like 2D sandbox game using SDL2. Currently, I am working on a scene management system. I was wondering if just having a single local variable in main called scene_num and some if statements in main to control the scene the player is currently on would suffice, especially as the game gets more complex?

This is what I meant in terms of basic structure:

int scene_num = 0;
// scene_num guide:
// 0 = title screen
// 1 = actual game
// 2 = inventory screen
// 3 = pause screen

// game loop
bool running = true;
while (running == true) {
    while (SDL_PollEvent(&ev)) {
        // handle user inputs here (ie: keyboard, mouse, etc.)
    }

    // handle game updates here
    if (scene_num == 0) {
        // handle title screen here
    } else if (scene_num == 1) {
        // handle gameplay updates here
    } else if (scene_num == 2) {
        // handle inventory screen here
    } else {
        // hanlde pause screen here
    }

    // handle rendering here
    if (scene_num == 0) {
        // handle title screen rendering here
    } else if (scene_num == 1) {
        // handle gameplay rendering here
    } else if (scene_num == 2) {
        // handle inventory screen rendering here
    } else {
        // handle pause screen rendering here
    }
}


texts: How do they do this bounce? Looks awfully complicated in 2D.


texts: Is a sequential update method really acceptable and is there a sane alternative?

texts:
A sequential update method is the update method pattern (e.g. as described here) where all game entities have their update methods called sequentially, even if this means the order of the entities ends up impacting the end result.

This has two obvious downsides (simplified, of course):

Order matters, which also makes its results technically incorrect (since you're meant to be simulating simultaneous action).
Because it is sequential it can't be parallelized very easily.

Simplicity is always good, and it really does shine on that front. Still, is it really acceptable? Do real-world games actually use this?

As far as finding a more acceptable solution (which thus far I haven't): The previously linked article mentions Double Buffering as a possible solution, and most alternatives I've thought up thus far seem to boil down to some form of that.

Based on my own research and experimentation, alternatives to the sequential update method have problems of their own:

Simple double buffering isn't enough in practice. Changes from multiple sources end up overriding each other, so some way to cumulate them is needed (incrementing a value in the next buffer instead of just writing to it). At best this means a tiny bit of extra complexity, at worst it ends up being order-dependent again.
Complexity spirals out of control. Say you seperate out the physics into its own series of order-independent updates (e.g. move entities, check collisions, adjust positions), it quickly follows to do the same thing for every mechanism, which ends up becoming unmanageable.

Physics seem to want to be order-independent the most, though - and maybe I just haven't looked in the right places - I wouldn't know of good way of seperating physics from other updating logic. I've been going in circles on this for a while now. Maybe I'm missing something really obvious here.

My problem boils down to how to deal with update ordering. More specifically, is there a way to structure a game update that is order-independent (and parallelizable if possible) that doesn't drastically escalate complexity? If not, is there some reasonable middle ground? E.g. doing only the physics in a seperate order-independent update and everything else in a naive order-dependent sequential update.


texts: How does the InsideTessFactor affect points of a triangle in a DirectX11 domain shader?

texts:
I found this example in this Chinese language document.
In the image above, I can understand the value of SV_TessFactor because for every side of this triangle, there are 4,1,6 line segments respectively. But I don't understand how InsideTessFactor is 5.
There are 12 points and 12 line segments inside the triangle. It seems to me that 12 is not relevant to 5.


texts: determining view boundaries based on z position when using a perspective projection

texts:
I'm using three.js to make an animation of a box moving around the screen in 3 dimensions.

It is moving pseudo-randomly, according to a noise function. So, I want to place an invisible wall just outside of view, so the box tends to stay in the screen.

I have accomplished this. However, it only works correctly when the box's z coordinate is 0.

I need a function that calculates the boundaries based on the z coordinate of the box. Right now, if z is negative (farther away) the boundary is too small and if z is positive the boundary gets too big.

I am not sure how to go about this. This is how I am creating the camera, I am new to three.js and this part I just copied from a tutorial:

var camera = new THREE.PerspectiveCamera(45, window.innerWidth/window.innerHeight, 1, 10000);
camera.position.z=1000;

This is the function signature from the docs:

PerspectiveCamera( fov, aspect, near, far )

fov: Camera frustum vertical field of view.
aspect: Camera frustum aspect ratio.
near: Camera frustum near plane.
far: Camera frustum far plane.

I'm not really sure what FOV does but I think it may be the key here....
If FOV allows me to get a relevant angle than I can probably use basic trig to find my offset value.


texts: Instantiating a GameObject at my desired position not working

texts:
I'm sure I am misunderstanding something about Unity vectors or something here. I am brand, brand new to Unity so this is part of the problem.

I am trying to make a simple atomic model and I am trying to model valence electrons.

I've got a game object with two children - the symbol (which is working perfectly), and a child electron.

If an atom has more than 1 valence electrons, I add those as additional child objects.

All of this is working just fine - except for one part. I have a default position for the original child valence electron, but when I try to add additional children and set their positions, they're not anywhere near where they should be.

For example:

My Model:

My base electron:

My additional electrons look like this:

And here is my output - obviously not right:

So here's my function to add additional electrons:

  void addElectrons(Rigidbody2D atom)
  {
    AtomData.AtomData atomData = atom.GetComponent<Atom>().atomData;

    if (atomData.ValElec > 1)
    {
      for (int i = 1; i < atomData.ValElec; i++)
      {
        GameObject electron = Instantiate(electron_obj, new Vector2(0.2f, 0), Quaternion.identity) as GameObject;
        electron.name = "Electron " + (i + 1).ToString();
        //electron.transform.localPosition = new Vector3(.02f, 0, 0);
        electron.transform.localScale = new Vector3(.05f, .05f, 0);
        electron.transform.parent = atom.transform;
      }
    }
  }

I've tried Vector2 (currently shown above), a new Vector3 in transform.localPosition (shown and commented out), as well as in transform.position (not shown, but similar to localPosition).

What exactly am I doing wrong here? I am strongly guessing that I am misunderstanding the vector math or something here.


texts: Why is my picture distorted after switching from D3D9 to D3D11?

texts:
I have moved app from Directx9 into Directx11.

After this upgrade strange thing happened with my world. Objects get skewed and became 2D, also they are clipped in unexpected places.

The two arrows at the image I attached point to my HUD reference frame - three nice cones, arranged to point along the 3 axes, which are supposed to be shown in the lower left corner of the window.

Also you can see that sphere got clipped in difference positions and all objects are 2D. There side and front view. Thanks for your suggestions.

Need to point out that sphere is moving.

I use XMMatrixPerspectiveFovLH to get projection matrix.

Example of matrices:

World
2  0  0  0
0  10 0  0
0  0  1  0
0  0  10 1

View - Identity

Proj
1.72 0    0   0
0    2.41 0   0
0    0    1.  1.
0    0   -1.  0

Both previous images are wrong rendered. Just side view and fromnt view of wrong rendering.
Thanks to Tordin i got this:

This one is almost correct, only some problems with culling in cones which form reference frame.

EDIT: Question was answered, but nobody wants to frame his comment as an asnwer. First was

  Tordin:  transpose your matrices. All of them, World, View,
  Projection. DX11 is Row major and not Colume major like dx9 was


texts: Most practical isometric tile, or does it even matter?

texts:
I am asking for the most practical/convenient isometric tile. I have seen a lot of tiles, some like this (you have to zoom in somehow to see the pixels, sorry):

I know there are different types of isometric, but I am asking for the best one for games, not the most realistic one. Please ask further questions if something is not clear.


texts: Why are floats not changing unless I've selected the prefab?

texts:
I am making a really simple game where you are a dot and you go around and shoot other dots.  I have it set up so in the start menu you can spend points to upgrade your dots stats. (ie. make it shoot faster, move faster.)  I am using a prefab NumberHolder object with a script on it to hold the numbers between scenes and I am having an issue.  If I have the NumberHolder selected in the inspector the game works perfectly, but if I don't have it selected the numbers all change like normal while I am on the scene that adjusts the numbers, but when I go to the next scene which is the game the numbers seem to have a 50% of not updating to the player.  Furthermore, if I select the NumberHolder at this point the numbers are all still at their starting stats.  I used to have the NumberHolder located 3 folders deep, Assets/Prefabs/StatHolders and it didn't work at all unless it was selected.  I have since moved it up to the Prefabs folder and it now works around 50% of the time.  Do I have it to deep?  If so is there a way to work with it that deep because I want to try and stay organized or is there a whole better way of doing what I am attempting to do here?

I am using Unity 5.4.0f3 and coding in C#.


texts: Farseer: What can I do so that a body can move through a special kind of bodies?

texts:
I have three different kinds of rectangles. Black, white and blue rectangles. The rectangles are moving and can collide with each other. But with one exception, the blue rectangle can collide normally with the black rectangle, but the blue rectangle should move through the white rectangle if it's touching the white rectangle. The white and black rectangles can collide normally.

How can I do that? In the moment, the blue rectangle isn't moving through the white rectangle if it's touching the white rectangle. What can I do so that the blue rectangle can move through the white rectangle, but not through the black rectangle?

I solved the problem with CollisionWidth.

For expamle:
Body.CollisionWidth = Categorie.Cat5

In this case, the body just collides with bodies which have the CollisionCategorie 5.


texts: How do I deploy my JavaScript/HTML 5 to desktop and smartphone?

texts: I'm looking for framework that will let me code on JS for HTML5 canvas and then will let me deploy to desktop and Android. I'm not looking to learn new stuff like Haxe or Lua. I want to do it in plain JavaScript. Is there a frame work that will allow me to do this?


texts:
Possible Duplicate:
  learning Direct3D 9, 10 or 11?

I'm just starting to learn DirectX, and I was wondering what the best version would be best to develop for. I'm trying DirectX 9 right now, but was wondering if I should use 10 or 11... Which version is the most commonly used version for games nowadays? I want to be able to play my game on most versions of windows... Is DirectX 9 still used a lot now?


texts: How would I implement procedurally generated tiles in libgdx?

texts:
I'm creating a simple top down Zelda-esque game in libgdx, and I want to implement tile-based dungeons that are procedurally generated, similar to this.

Libgdx does have a class called TiledMap which would seem to fit my needs, however documentation outside of the official docs suggests that TiledMaps can only be used in conjunction with .tmx files, or in other words pre-designed maps.
I've done a fair amount of Googling to no avail, so I'm asking here as a last resort hoping that someone has experience using libgdx for dynamically-generated tile maps.

edit: Could I use StaticTiledMapTiles in conjunction with the tutorial I linked to above to achieve my goal?

Thanks!


texts:
i have this enumerator that loads a folders images asynchronously and i would like to be able ta pass the array as a parameter, but when i try to do it even though i get no error the array (source) does not get populated.
private IEnumerator GetTextureFromPath(string _dirname) // here it would be ,Texture2D _source
    {
        var fileNames = Directory.GetFiles(Application.persistentDataPath + "/" + _dirname, "*.jpg");
        source = new Texture2D[fileNames.Length]; // this source array would be referenced in the params.
        Array.Sort(fileNames, (s1, s2) => Path.GetFileName(s1).CompareTo(Path.GetFileName(s2)));
        int index = 0;
        foreach (var fileName in fileNames)
        {
            UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture("file://" + fileName);
            while (!webRequest.isDone)
            {
                yield return webRequest.SendWebRequest();
            }
            if (webRequest.isNetworkError || webRequest.isHttpError)
            {
                Debug.Log(webRequest.error);
            }
            else
            {
                source[index] =  LoadTextureFromPath(fileName);
                source[index].name = fileName;
                index++;
                Debug.Log("Ends server comm");
                Debug.Log("FileNames :" + " " + fileName);
            }
        }
    }

what this function does is get all files from a directory and populate a texture2d array with each image. now this call happens on game load so since i have 4 more arrays (source1 , source2 etc) i would like the array to be in the parameters so i can tell the script as to which array to populate from that directory
it seems its due to it being asynchronous and an enumerator. Because i made the function into a void one with the texture as a ref and it worked.
public void LoadTextureArray(string _dirname, ref Texture2D[] arr)
    {
        var fileNames = Directory.GetFiles(Application.persistentDataPath + "/" + _dirname + "/", "*.jpg");
        arr = new Texture2D[fileNames.Length];

        Array.Sort(fileNames, (s1, s2) => Path.GetFileName(s1).CompareTo(Path.GetFileName(s2)));

        //Debug.Log(string.Join("\n", fileNames));

        int index = 0;
        foreach (var fileName in fileNames)
        {
            arr[index] = LoadTextureFromPath(fileName);
            arr[index].name = fileName;
            index++;
        }
    }

So my take on this is i need to be able to use ref into the enumerator but that is not possible from what it seems since if i do put it as a parameter i get this error. or if there is another way to be able to pass the texture array from the function call! Thank you!
iterators cannot have ref in or out parameters
```


texts: How can I run homebrew program discs on unmodified Wii consoles?

texts:
I know that one can play backup games on any Wii console via burned discs, but is there a way to actually run homebrew programs on a Wii?

I am asking this because I have run across GameCube Linux more than once, but most homebrew programs require using the Homebrew Channel, which must be installed on the internet through the Wii console, or via SD card. For Wii consoles that do not have this capability (specifically the Wii Mini), is it possible to run homebrew software discs that will work on Wii consoles without having to modify them? If so, can anyone show me which ones?


texts:
I want a method, which takes two "ObjectBox" objects (A "ObjectBox" has .getX() .getY() .getZ() .getSizeX() .getSizeY() .getSizeZ() methods) as a parameter and return true if the two Boxes are colliding and false if they aren't.

So it should be something like this:

public static boolean checkCollision(ObjectBox box1, ObjectBox box2){
return //TRUE IF COLLIDING - FALSE IF NOT COLLIDING
}

I tried figuring it out but it seemed pretty hard to me.


texts: Do textures that are inside a shader resource need to be explicitly released too? (DirectX 11)

texts:
I have a ID3D11Texture2D (that I've created manually) inside a ID3D11ShaderResourceView. When I want to Release() the resource view, do I need to Release() the texture that it is inside too? Or is it not necessary to do so?

Msdn doc and Google couldn't help me on this one. :/


texts:
I'm developing a J2ME game which uses tiled backgrounds for the levels. My question is how do I store this tile information in my game. At the moment it is stored as an array; with each number representing a different tile from the tile-sheet. This works well enough, however I don't like the fact that it is 'hard-coded' into the game because (at least in my opinion) it is harder to edit the levels, or design new ones. I was also thinking that it would be difficult if you wanted to add a 'level pack', I'm not sure on how this would be achieved though; it's not something I was planning on doing, I'm just curious.

I was wondering if there was a way I could store level data in some external file and then load this in to the game. The problem is I don't know what the limitations are for J2ME regarding file I/O, can it read in any file like Java? I am aware of the RMS, but from my experience I don't think this would work (unless I am mistaken).

Also, would loading the data in this way be too big a performance hit? Or is there another way I can achieve what I am trying to do. As I said, the way I have it at the moment works fine, and if this is the only viable option then it will suffice.


texts: draw two models changing the MVP matrix (android opengl)

texts:
I'm newbie with opengl2 in android, and I'm making an app in which I'm testing some things. Now I was trying to duplicate a sphere object with a texture, so I thought it was enough to change my MVP matrix applying a small translation to the Model matrix, using same View Matrix and same projection matrix.

int[] numIndices = balon.getNumIndices();
ShortBuffer[] indices = balon.getIndices();

GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
for (int j = 0; j < numIndices.length; j++) {
    GLES20.glDrawElements(GLES20.GL_TRIANGLES,
            numIndices[j], GLES20.GL_UNSIGNED_SHORT,
            indices[j]);
}

GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix2, 0);
for (int j = 0; j < numIndices.length; j++) {
    GLES20.glDrawElements(GLES20.GL_TRIANGLES,
            numIndices[j], GLES20.GL_UNSIGNED_SHORT,
            indices[j]);
}

balon is an object of type Sphere. mMVPMatrix and mMVPMatrix2 are the MVP matrices I was talking about. I simply changed the MVP matrix and did the drawing again. The result is that I have the two spheres, but one of them is behaving strangely, appears distorted, the position in which appears is right, the two spheres move along, but one of them changes it's shape.

What I'm missing?, I guess I have to duplicate some things in my code before I do this, but what?, thought that being the same model, this was enough...

This is how I changed the MVP matrix:

Matrix.setIdentityM(mModelMatrix, 0);
Matrix.setIdentityM(mModelMatrix2, 0);
Matrix.translateM(mModelMatrix, 0, posX, posY, posZ);
Matrix.translateM(mModelMatrix2, 0, posX+0.5f, posY+0.5f, posZ);

Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0);
Matrix.multiplyMM(mMVPMatrix2, 0, mViewMatrix, 0, mModelMatrix2, 0);
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
Matrix.multiplyMM(mMVPMatrix2, 0, mProjectionMatrix, 0, mMVPMatrix2, 0);


texts: Recommended method for XML level loading in XNA

texts:
I want to use Blender as my level designer tool for an XNA game. Using an existing plugin, I can export my levels to DotScene format which is basically an xml file like this one:

<scene formatVersion="1.0.0">
  <nodes>
    <node name="scene-staircase.001">
      <position x="10.500000" y="1.400000" z="-9.600000"/>
      <quaternion x="0.000000" y="0.000000" z="-0.000000" w="1.000000"/>
      <scale x="1.000000" y="1.000000" z="1.000000"/>
      <entity name="scene-staircase.001" meshFile="staircase.mesh"/>
    </node>

    <node name="Lamp.003">
      <position x="11.024290" y="5.903862" z="9.658987"/>
      <quaternion x="-0.284166" y="0.726942" z="0.342034" w="0.523275"/>
      <scale x="1.000000" y="1.000000" z="1.000000"/>
      <light name="Spot.003" type="point">
        <colourDiffuse r="0.400000" g="0.154618" b="0.145180"/>
        <colourSpecular r="0.400000" g="0.154618" b="0.145180"/>
        <lightAttenuation range="5000.0" constant="1.000000" linear="0.033333" quadratic="0.000000"/>
      </light>
    </node>

    ...

  </nodes>
</scene>

Using naming conventions I could easily parse the file and load the correspondent in game content. I am new to XNA and I have seen that there are several methods to load XML files into a game like serializing and deserializing. Which one would you recommend?


texts: Could I implement MakeHuman into a UE4 game as a character creator?

texts:
Would it be possible to take MakeHuman and put it into a game made in Unreal Engine as a character creator?

Of course many unnecessary features would have to be removed, but would it work at all, and would it be easier than making such a system from scratch? MakeHuman is open source so there shouldn't be any legal issues.


texts: Unity gameobject design approach for item drops

texts:
In a game like Minecraft, the player could have any of several hundred types of items in their inventory. Players can drop those items into the world, but obviously how they're rendered in the world differs from how they're rendered in the inventory.

I'm trying to understand how to design for this scenario using Unity's GameObject concept.

Individually, it seems like the expectation is that:

I would have one GameObject (with at least a SpriteRenderer) for every unique item that can appear in-world.
I would have one GameObject (with at least an Image component) for every unique item that can appear in inventories.

With so many, I also need to come up with some sort of directory so that I can associate bulk prefab objects for use in-game.

Is this accurate? I feel like that's a lot of overhead.

Would I be able to create one GameObject with both a SpriteRenderer and an Image and maybe toggle between then based on whether its in world or an inventory?

I had also considered using one generic GameObject and replacing the sprite/image based on the item needed, but that feels like it's misusing what GameObjects are meant for. It also likely subverts the benefit of pooling them, etc.

Is there another approach I'm missing?


texts:
Does anyone have an algorithm for creating a sphere proceduraly with la amount of latitude lines, lo amount of longitude lines, and a radius of r? I need it to work with Unity, so the vertex positions need to be defined and then, the triangles defined via indexes (more info).

EDIT

I managed to get the code working in unity. But I think I might have done something wrong. When I turn up the detailLevel, All it does is add more vertices and polygons without moving them around. Did I forget something?

EDIT 2

I tried scaling the mesh along its normals. This is what I got. I think I'm missing something. Am I supposed to only scale certain normals?


texts: Damping in Unity Shuriken Particle System

texts:
Is there no damping functionality in Unity Shuriken Particle?
"Velocity Over Lifetime" is different from damping.

I try to find it on particle system, but can't.
Or is there any other way to apply particle damping?

I want to control each particle's velocity decrement?

Update: Add a poor art work :)


texts: Unity Mirror Network Transform not working

texts:
I am having an issue with Mirror's network transform component in unity. Players cannot see each other move, and in the inspector window only the host's player moves (this is not updated to the connected player though). In the inspector window you see a sphere moving and facing in the direction of the connected player (I did not program this so it must be Unity trying to tell me something) as per the picture below.

Any help is much appreciated as there doesn't seem to be anybody that I can find online with a similar problem.

Thank you!


texts: Distribute circles evenly on Screen - circle packing

texts:
I want to evenly distribute a random amount of circles with random diameter on the screen for. This level doesn't scroll so the users screen resolution sets the limits. Further I would like the circles to be as big as possible to fill out the screen.

I have no problem writing the code for collision detection and so on, my problem is the basic theory to solve this kind of problem.

My current approach doesn't work properly because the problem could be the following thing, where (1) is the first circle and (2) is the second circle and | is the "wall" or screen edge.

(1) (2)|
So if 1 and 2 overlap, I would move 1 half of the overlapping distance to the left, 2 with the other half to the right. I then see that 2 is already at the wall and can't be moved, so 1 must move the whole overlapping distance to the left.

How would I correctly approach this situation?


texts:
Please take a look at the picture below:

It is and attempt in creating a "game" only with the DOM and jQuery.

The blue boxes are "obstacles" and the user can move his pointer (not drawn in screen in the picture", which is a single point, by clicking where he wants it to go.

The problem I am facing now, it to create a collision detection in the DOM itself with jQuery only. I am not using a pathfinding: that means that if a user wants to go across an obstacle, he has to click all the way around it. Now, how do I check if there will be a collision BEFORE the pointer actually collides?
Another problem that might arise from this is if a user clicks on the opposite side of the obstacle, the collision would be checked and just walk past by.

Any ideas?

Thanks in advance.


texts: Getting isometric grid coordinates from standard X,Y coordinates

texts:
I'm currently trying to add sprites to an isometric Tiled TMX map using Objects in cocos2d. The problem is the X and Y metadata from TMX object are in standard 2d format (pixels x, pixels y),  instead of isometric grid X and Y format. Usually you would just divide them by the tile size, but isometric needs some sort of transform.

For example on a 64x32 isometric tilemap of size 40 tiles by 40 tiles an object at (20,21)'s coordinates come out as (640,584)

So the question really is what formula gets (20,21) from (640,584)?


texts: Unity3d UnityWebRequest EscapeURL standard does not match Swift url encoding. How to decode it?

texts:
How should I decode escaped URL by unity in Swift?

I am developing a game with Unity3d. Something MMORPG. With server implemented by me in Swift under Kitura framework
A framework doesn't matter that much. It is more about swift and Unity itself.

Let me describe the problem here.

Unity

UnityWebRequest.EscapeURL("First Last")

Escapes string with encoding used in the application/x-www-form-urlencoded content-type: https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
Which produce string First+Last where + maps to " " space.

Swift:

import Foundation

var str = "First+Last"
print(str)
print(str.removingPercentEncoding)

The character used on this string + isn't considered as a percentage encoding in the standard used by swift. It would be if the character escaped as this would be represented by %20.

So my server and client ended up with different string values.
Later on returned from one to the other weren't equal. Which ended up considering them as two different clients.


texts: Instantiated object not tracking collision

texts:
I have an issue, and I'm not sure why it's happening. I have a prefab that I've built in a colour-changing game. It has the following:

Four 2D objects that if they collide with the player (2D collider attached to all), they cause the player to die.
One 2D object that if the player strikes, it generates a duplicate of itself with the Instantiate function.

All 2D objects are created; The four objects that cause the player to die are being created as normal and continue to cause the player to die. However, the object that instantiates the prefab and increments the score can no longer be collided with. The player appears to pass behind it. I'm pasting my code below. I would really appreciate if anyone can offer advice on this:

void Update () {
    if (Input.GetButtonDown("Jump") || Input.GetMouseButtonDown(0))
    {
        thing.velocity = Vector2.up * bounciness;
    }
    scoreText.text = score.ToString();
}
private void OnTriggerEnter2D(Collider2D collision)
{

    if (collision.tag == "plusScore")
    {
        score++;
        Destroy(collision.gameObject);
        Instantiate(barrier, new Vector2(transform.position.x, transform.position.y + 7f), transform.rotation);
        return;
    }

    if(collision.tag != currentColour)
    {
        Debug.Log("You DIED!");
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        score = 0;
    }
}


texts: What happens to allocated video memory when the program terminates?

texts: Using OpenGL it is possible to load textures, buffer arrays, compiled shaders and more to the video memory. When a C++ program exits, heap memory that was allocated by it is cleaned. What happens to the stuff allocated on the video memory? Will memory leak beyond program's scope?


texts: How is text/scripts/dialogue stored and accessed in games?

texts:
For large, complex games, I imagine that text descriptions, dialogue lines, etc, are organized in some sort of database, and not actually hardcoded into the source.

Are there any conventions on how such textual data is organized and inserted/loaded into the game? And how does this "database" get "compiled" into the executable along with the source code? (Because for most AAA games there aren't additional files containing said database, etc).

In particular, I'd like to know how to load text into a game, without opening some external client-side file (so the client can't just browse the file and read the ending!). I don't see how an external file/database could be bundled into the compiled source executable (for example, how would you do this in C)?


texts: Is it OK to release the source code for your own Xbox Live indie game?

texts:
Between not being sure how to phrase my question for Google and not being a lawyer, I thought it might be easier to ask you guys. Specifically, I want to know if it's OK to sell an Xbox Live indie game while simultaneously distributing the source code and other assets via GitHub or something.

Edit: The Communist Duck asked "why not?" One reason I can think of is that Microsoft has a small stake in a game's sales. They are hosting the demo/full game, they might be dedicating an advertising slot to the game in their "latest" section, etc. It's true they get a cut of each sale, but they get nothing if everyone just goes and downloads the free version.

Anyway, it's not a matter of what is reasonable and logical, it's a matter of what the terms and conditions allow. I'm going to read through them regardless, but I was hoping someone already knew.


texts: How do I get the depth data of objects closer than 800mm?

texts:
I'm trying to scan the layout of blocks on a table. My Kinect can be at most 1m away from the surface and I need to stack those blocks higher than 20 cm. I'm using Zigfu.

Using the kinect 1 I have to deactivate the near mode, which results in every depth data smaller than 800 (0.8m) to be defaulted to 0.

Is there a workaround? I know, that objects this close aren't detected correctly. I just need about 10 cm more and I am willing to sacrifice precision for it.


texts:
I used Tiled Editor for making maps for my own game, I do not run any engine or anything. I have separated terrain layer and object layer in TiledEditor.

However I have problem with trees I want to make my character move behind the tree. But I have no idea how because even if it is different layer I am still rendering it by 8x8 pixel blocks.

Now my character is always on top as it is the last thing that I render.

But if I change the render order my character would be behind the tree even if the character will stay in front of the tree like this:


texts: Is there a way of limiting the sprites you can select in unity

texts:
So, if you had something like:

public sprite;

in a monobehavior, and that was dragged onto a gameobject, in the editor you will have the option to click the variable and select a sprite to use.

For me, I have many many pictures that I can choose from, and it takes me a while to select the correct image that I need to use.

Is there any way to categorize pictures, and only show pictures from that category? For instance, can I add some kind of tag or something to the picture assets something like "UI", so then when the developers that use my scripts go to select an image, they are not bombarded with every possible image in the game, but instead something contextual that makes sense?

I am wondering if this functionality exists already or any other way to achieve similar results.

Thanks for your time!


texts: Passing multiple Vertex Attributes in GLSL 130

texts:
(note this question is closely related  to this one however I didn't fully understand the accepted answer)

To support videocards in laptops I have to rewrite my GLSL 330 shaders to GLSL 130. I'm trying to do this but somehow I don't get vertex attributes to work properly.

My 330 shaders look like this:

#version 330
layout(location = 0) in vec4 position;
layout(location = 3) in vec4 color;

smooth out vec4 theColor;
void main()
{
    gl_Position = position;
    theColor = color;
}

Now this explicit layout is not allowed in GLSL 130 so I referenced this page to see what the default layouts for some values would be. As you can see position should be the 0th vertex attribute and color should be the 3rd vertex attribute. Because this is a test case I had already configured my explicit layouts in the same way, which worked, so I now simply rewrote my shader to this and expected it to work:

#version 130
smooth out vec4 theColor;
void main()
{
    gl_Position = gl_Vertex;
    theColor = gl_Color;
}

However this doesn't work, the value of gl_Color is always (1,1,1,1). So how should I pass multiple vertex attributes to my GLSL 130 shaders?

For reference, this is how I set my vertex buffer object and attributes (I've just adapted this tutorial to JAVA+JOGL)

gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vertex_buffer_id);
gl.glEnableVertexAttribArray(0);
gl.glEnableVertexAttribArray(3);
gl.glVertexAttribPointer(0, 4 , GL3.GL_FLOAT, false, 0, 0);
gl.glVertexAttribPointer(3, 4, GL3.GL_FLOAT, false, 0, 4*4*4);

gl.glDrawArrays(GL3.GL_TRIANGLE_STRIP, 0, 4);

gl.glDisableVertexAttribArray(0);
gl.glDisableVertexAttribArray(3);

EDIT
I solved the problem by querying for the layout locations of position an color using glGetAttribLocation however I still don't understand why the 'hardcoded' values like gl_Color didn't work, can't I upload data in there as normal? Shouldn't they be used?


texts: How to find a material through a raycast in Unity 5?

texts:
I have an empty object with a script on it and I want to be able to move the empty over other objects and then have it print out the name of the material for the triangle that it's hovering above. (Its for something else, but I only need help getting to that stage, I can do the rest from that point). I found this on the topic but the answer is very vauge. I finished steps 1 and 2 but I can't figure out number 3. Here is my code so far...

void Update (){
        Ray ray = new Ray(transform.position, new Vector3(0, -100, 0));
        RaycastHit hit;

        if(Physics.Raycast(ray, out hit)){
            print ("Triangle Index: " + hit.triangleIndex);

            Mesh mesh = hit.collider.gameObject.GetComponent<MeshFilter>().mesh;

            print ("Submesh Count: " + mesh.subMeshCount);
        }
    }

Could someone show me how to finish it off so that when I move the empty over different objects, it would print out the name of the material per triangle?

Thanks, Matthew


texts: Rotate 2D Object Towards Mouse & Stop After Full Revolution

texts:
Essentially what i'm trying to recreate is a dial with a min and max setting. The player clicks and drags the mouse around the dial to move its position but I would like for it to stop at a full rotation even if the mouse keeps revolving around the object.

The only way I've come up with this is to keep track of the distance covered by the drag.

So I use 360f - StartingAngle for the distance it is allowed to travel ( I know this doesn't account for negative direction however you want to think about it ).

I then calculate a previous angle and next angle and find the difference and then add that to the total.

Then I was checking if the total > 360f - starting angle for slerping my rotation.

Problem I'm running into is when it crosses the threshold between 359.9 degrees and 0 degrees of course the difference comes up with a negative number and I'm not sure if I'm going about this the best way cause I can't seem to come up with a way of determining whether they crossed that threshold or they just went back really far.

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

public class Dial : MonoBehaviour
{
    Vector2 direction;
    float speed = 20f;
    float startingAngle;
    float angle;
    float angleRotationTotal;
    float previousAngle;
    Quaternion rotation;

    void Update()
    {

        if (Input.GetMouseButton(0))
        {
            direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
            angle = angle < 0f ? angle + 360f : angle;

            if (startingAngle == 0f)
            {
                startingAngle = angle;
                SetPreviousAngle(startingAngle);
            }

            SetAngleRotationTotal(angle);
            SetPreviousAngle(angle);

            if (angleRotationTotal > 360f - startingAngle)
            {
                rotation = Quaternion.AngleAxis(0f, Vector3.forward);
                transform.rotation = Quaternion.Slerp(transform.rotation, rotation, speed * Time.deltaTime);
            }
            else
            {
                rotation = Quaternion.AngleAxis(Angle, Vector3.forward);
                transform.rotation = Quaternion.Slerp(transform.rotation, Rotation, Speed * Time.deltaTime);
            }
        }
        else
        {
            angleRotationTotal = 0f;
            previousAngle = 0f;
            startingAngle = 0f;
        }
    }

    private void SetAngleRotationTotal(float currentAngle)
    {
        if (currentAngle - previousAngle > 0f)
        {
            angleRotationTotal += currentAngle - previousAngle;
        }
    }

    private void SetPreviousAngle(float currentAngle)
    {
        previousAngle = currentAngle < 0f ? currentAngle + 360f : currentAngle;
    }
}
```


texts:
I'm not satisfied with the quality of video playback in Unity (Movie texture which I run after converting video with Miro converter and importing it to Unity),... so, is there any chance that there is a 3rd party library which I can integrate inside Unity to play my movie file? My movie is full HD intro movie to my 3d app which can be played from application menu.

I've tried to use Media Player Classic (MPC) as external application, but the problem is, when I run MPC as new Process from application menu, my menu minimizes and this looks awkward for one stand alone app. When intro finishes, I have to maximize my menu by clicking on application icon placed on Windows taskbar.


texts: Should have one device per application or per form when doing MDI Forms work with XNA?

texts:
I am just making a simple editor for a project I am working on and as part of this I need to add a few different MDI forms within a larger container form.

Now the XNA (4.0) example Windows Forms projects use a shared graphics device for all controls, however I was assuming I would have a graphics device per control (assuming we have an XNA-specific panel/control element).

So is there any reasons that you should share the same graphics device? As I can imagine there being problems if you are changing render states in one panel but do not want it to effect the other panels...

It would make sense to share it if the GraphicsDevice object is literally a representation of the underlying graphics card, but thats what the GraphicsAdapter is, so I wasn't sure if there would be any problems with isolating a graphics device per control.


texts: I need a professional icon for my Android/iPhone game: how should I proceed?

texts:
I need a great looking icon for my mobile game.

I have a few questions regarding the process of hiring a graphic designer to do it:

Which is (are) the best website to publish the Request For Proposal ?
Is it common practice to ask for a couple of logo/icon drafts so that I can pick the one I prefer ?
When does the client usually pays the designer (at order, final delivery time?)

Any feedback or advice will be appreciated.


texts: Part of the back side of a transparent object disappears

texts:
I did some blending and culling to get the image below.

As you can see, it is messed up. On the right side of the image, only the front side of the mesh shows. On the left side of this image, it works, you can see both the front and back sides.

I'm pretty sure it is the culling. Here are my settings for blending and culling:

opaquePsoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT);
opaquePsoDesc.RasterizerState.CullMode = D3D12_CULL_MODE_NONE;

AND blending

D3D12_GRAPHICS_PIPELINE_STATE_DESC blendPsoDesc = opaquePsoDesc;

    D3D12_RENDER_TARGET_BLEND_DESC blendDesc;
    blendDesc.BlendEnable = true;
    blendDesc.LogicOpEnable = false;
    blendDesc.SrcBlend = D3D12_BLEND_ONE;
    blendDesc.DestBlend = D3D12_BLEND_ONE;
    blendDesc.BlendOp = D3D12_BLEND_OP_ADD;
    blendDesc.SrcBlendAlpha = D3D12_BLEND_ZERO;
    blendDesc.DestBlendAlpha = D3D12_BLEND_ZERO;
    blendDesc.BlendOpAlpha = D3D12_BLEND_OP_ADD;
    blendDesc.LogicOp = D3D12_LOGIC_OP_NOOP;
    blendDesc.RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL;

    blendPsoDesc.BlendState.RenderTarget[0] = blendDesc;
    ThrowIfFailed(md3dDevice->CreateGraphicsPipelineState(&blendPsoDesc, IID_PPV_ARGS(&mBlendPSO)));

What am I doing wrong?


texts:
I'm experimenting a bit with pathfinding. I'm using Javascript.

I have a map array as follows:

mapArray = [
             [0, 0, 0, 1, 1, 0],
             [1, 0, 0, 1, 0, 0],
             [0, 1, 0, 1, 1, 0],
           ];

The map is fairly excessive in size and I would like to take out a portion of it to pass to the pathfinding algo. How could I go about doing this? From the above, I could take out a section to leave this for instance:

mapArray = [
             [0, 1, 1],
             [0, 1, 0],
             [0, 1, 1],
           ];

Which would be copying from 0,2 through to 1,4 (xy).

My first thought was a for loop but it is failing for a reason I don't fully understand. Probably a misunderstanding of inserting into arrays?

var pathfindingMapArray = [];

for ( y = startRow; y < endRow; y++ ) {
    for ( x = startColumn; x < endColumn; x++ ) {

        pathfindingMapArray[y][x] = mapArray[y][x];
    }
}

The above fails as a TypeError.


texts:
I've implemented a simple simulation of two planets (simple 2D disks really) in which the only force is gravity and there is also collision detection/response (collisions are completely elastic). I can launch one planet into orbit of the other just fine.

The collision detection code though does not work so well. I noticed that when one planet hits the other in a free fall it speeds backward and goes much higher than its original position. Some poking around convinced me that the simplistic Euler integration is causing the error.

Consider this case. One object has a mass of 1kg and the other has a mass equal to earth. Say the object is 10 meters above ground. Assume that our dt (delta t) is 1 second. The object goes to the height of 9 meters at the end of the first iteration, 7 at the end of the second, 4 at the end of the third and 0 at the end of the fourth iteration.

At this points it hits the ground and bounces back with the speed of 10 meters per second. The problem is with dt=1, on the first iteration it bounces back to a height of 10. It takes several more steps to make the object change its course.

So my question is, what integration method can I use which fixes this problem. Should I split dt to smaller pieces when velocity is high? Or should I use another method altogether? What method do you suggest?

EDIT: You can see the source code here at github:https://github.com/elektito/diskworld/


texts: I just want to run any Box2D "Hello World" or test apps.  I've downloaded the source twice (zip file the first time and via svn the second time), followed the build instructions (do stuff w/ cmake, "make", "make install" etc) and don't know where to go from there.  How do I run the test apps or Hello World apps that come w/ Box2D on my iPhone (or simulator)?


texts: Multiple objects listening for the same key press

texts:
I want to learn the best way to implement this:

I have a hero and an enemy on the screen. Say the hero presses "k" to get out a knife, I want the enemy to react in a certain way.

Now, if in my game loop I have a listener for the key press event and I identify a "k" was pressed, the quick and easy way would be to do:

// If K pressed
// hero.getOoutKnife()
// enemy.getAngry()

But what is commonly done in more complex games, where say I have 10 types of character on screen and they all need to react in a unique way when the letter "k" is pressed?

I can think of a bunch of hacky ways to do this, but would love to know how it should be done properly.

I am using C++, but I'm not looking for a code implementation, just some ideas on how it should be done the right way.


texts: AABB - AABB Collision, which face do I hit?

texts:
To allow my objects to slide when they collide, I need to :

Know which face of the AABB they collide with.
Calculate the normal to that face.
Return the normal and calculate the impulse that to apply to the player's velocity.

Question

How can I calculate which face of the AABB I collided with, knowing that I have two AABB's colliding? One is the player and the other is a world object.

Here's what that looks like (problem collision circled in white):

Thank you for your help.


texts: how to display current time as a static value in lua/pico8

texts:
Pico8 has a function time() that when called displays the current time from start of program.
i.e. print(time(),0,0,14) --prints time at (0,0) with colour 14

However the function doesn't stop and keeps drawing the time each frame. I'm trying to figure out how I would draw the time without it increasing/changing. So If I printed this 5 seconds from the start of the program I'd want it to display 5, but not change from that 5 value.

https://pico-8.fandom.com/wiki/Time
I don't know how to store a static value of this time as a variable. Although according to the wiki, assigning  var=time() will cause time at 0 to be stored.

Another way of phrasing this is...how would I display the time of 10 seconds when the following print is triggered? So after 10 seconds "time's up" is displayed. How would I display the current time 10, as well, as a static? Maybe I don't know what the time is when the event is triggered, so how can I count using time()?

function _init()
  last = time()
end

function _update()
  -- (empty update to use game loop)
end

function _draw()
  cls()
  if (time() - last) > 10 then
    print("time's up!", 44, 60, 7)
  end
end


texts: Why does changing texture change it for both objects?

texts:
I have two identical objects in my Unity scene. When I change the texture of one, the texture is changed on the other, almost as though the first one is a prefab. Why is this happening and how can I treat them independently?

Steps taken:

Import .obj file and two .png files
Drag object into scene
Look at the object in the hierarchy (where the list of all objects in the scene is)
It has a child called pSphere1
pSphere1 has a mesh renderer with 2 materials on it - RedGold and pSphere1Mat
It also has two components controlling each of these materials
In those control components, I can select a shader from the dropdown and I can also select a texture.
For either one of them, if I change the texture say to PolkaDots, both objects have their materials changed, instead of only the one I am working on.


texts: Bring the blender .blend file into unity : replacing materials

texts:
i bring my .blend file (Blender) into the assets/prefab folders in unity. The model is a house with a lot of windows. In unity my glass material become solid/opaque.
My questions :

Since the material is locked i can't change in unity so is there anyway to do it in Blender ? Maybe some setting in blender to modify so that glass material will be imported as transparent type material in unity?

if i replace with new glass material in unity , is there anyway i can do it to replace all the glass (same glass material) without doing it manually one by one ?


texts: How could you create an SSX style snow trail in unity3d?

texts: So it SSX (a snowboarding game) when you are snowboarding you leave behind a dents in the snow(like a trail) .It's like how if you take a step in the snow you will leave a footprint behind but with a snowboard you leave a trail of where your snowboard has been. Can you create this or is this not supported by unity? If you can, how? Thanks in advance


texts:
I wrote a script that moves a game object(w/ trail render) in a circular motion via the sin/cos functions

x = center.x + Mathf.Sin(t) * r;
z = center.z + Mathf.Cos(t) * r;
position = new Vector3(x, 0, z);

i would like to know how to tweak the y axis to wobble/tilt it like a spinning coin as it slows down.

what kind of math would i apply to do that? I applied x to y which tilts it, but it remains that way instead of moving its high/low ends around


texts:
I am trying to make a class which will handle all of my inputs, however Keyboard.next() isn't returning true. Here is my code.

    while(Keyboard.next()) {
        if(Keyboard.getEventKey() == Keyboard.KEY_SPACE) {
            if (Keyboard.getEventKeyState()) {
                System.out.println("Pressed");
            }else {
                System.out.println("Released");
            }
        }
    }

When I removed the while loop, it infinitely outputs Pressed/Released so I know that part of the code is working. Is there something that I am missing to make this fully work?


texts: What does glBlendFunc(GL_DST_COLOR, GL_ZERO); mean?

texts: I need to write a description about a filter method I made but I don't know what glBlendFunc(GL_DST_COLOR, GL_ZERO); means.


texts:
My company is making Android apps, mostly little games...
Most of them have a view with the users profile and a view with a ranking list.

In the users profile you can see what rank the user is and of course you can see it in the ranking list. The ranking list shows ranks 1 - 100 and if the user is rank 35476 we are showing ranks 35466 to 35486 too, so whatever your rank, you are always in the ranking list.

Now my boss wants me to scroll the ranking list to the users position and I don't understand why you'd want this. You can see the rank in the profile and in my mind, when I go to the ranking list, I want to see the top guys and see how much points or whatever they have and I am not interested in seeing rank 35475 or 35477...this just doesn't make sense to me.

Is there some consensus on where to scroll the ranking list?


texts:
I'd like to find a way to add holes caused by a 'bomb' to my floor sprite, a bit like what is in this game here.

Basically there is a sprite (the green floor) and another sprite (the bomb) that falls on top of the green floor and the bomb then explodes. Once exploded part of the green floor sprite is gone. The player (red ball) can then move the sprite inside the new cavity that was created in the green floor sprite.


texts: Design pattern that can be used for data driven ability system

texts:
What are recommended design patterns for designing data-driven attribute system with data-driven abilities that would apply effect on target based on source attributes.

I have looked at following threads:

Making character's skills and abilities as commands, good practice?
C# Design for Ability System

and tutorial:

https://gamedevelopment.tutsplus.com/tutorials/using-the-composite-design-pattern-for-an-rpg-attributes-system--gamedev-243

What is the best design pattern to apply effects and abilities?
Making character's skills and abilities as commands, good practice?
It seems that command + composite pattern composition is the most recommended.

Are there any recommended design pattern compositions that would serve the purpose?


texts:
My question is; I am developing a game for XNA and I am trying to create a weapon attachment for my player model. My player model loads the .md3 format and reads tags for attachment points. I am able to get the tag of my model's hand. And I am also able to get the tag of my weapon's handle. Each tag I am able to get the rotation and position of and this is how I am calculating it:

Model.worldMatrix = Matrix.CreateScale(Model.scale) *
                    Matrix.CreateRotationX(-MathHelper.PiOver2) *
                    Matrix.CreateRotationY(MathHelper.PiOver2);

Pretty simple, the player model has a scale and its orientation(it loads on its side so I just use a 90 degree X axis rotation, and a Y axis rotation to face away from the camera). I then calculate the torso tag on the lower body, which gives me a local coordinate at the waist. Then I take that matrix and calculate the tag_weapon in the upper body. This gives me the hand position in local space. I also get the rotation matrix from that tag that I store for later use. All this seems to work fine.

Now I move onto my weapon:

Matrix weaponWorld = Matrix.CreateScale(CurrentWeapon.scale) *
                            Matrix.CreateRotationX(-MathHelper.PiOver2) *
                            TagRotationMatrix *
                            Matrix.CreateTranslation(HandTag.Position) *
                            Matrix.CreateRotationY(PlayerRotation) *
                            Matrix.CreateTranslation(CollisionBody.Position) *

You may notice the weapon matrix gets rotated by 90 degress on the X axis as well. This is because they load in on their sides. Once again this seems pretty simple and follows the SRT order I keep reading about.

My TagRotation matrix is the hand's rotation. HandTag.Position is its position in local space. CreateRotationY(PlayerRotation) is the player's rotation in world space, and the CollisionBody.Position is the player's world location. Everything seems to be in order, and almost works in game. However when the gun spawns and follows the player's hand it seems to be flipped on an axis every couple frames. Almost like the X or Y axis is being inversed then put right back. Its hard to explain and I am totally stumped. Even removing all my X axis fixes does nothing to solve the problem. Hopefully I explained everything enough as I am a bit new to this! Thanks!


texts:
Today I downloaded Nvidia Nsight in order to profe my game GPU side and I came across some doubts:

I can't find only any resource of what are the average times for the
different DirectX functions (such as map/unmap, clear the target
view, draw (even if is strongly dependant on shader and similar my
are really basic), ...) and so I can't know if my values are normal
or not. For example for the map function (with write_discard) I've
got an average of 0.8-1 microseconds.
There are always peaks in each function: map() for example goes up to
200 microseconds (randomly and rarely).

Here's a screenshot:

Is it normal?


texts: How can I create a large space background that repeats, in an unnoticeable way

texts:
How can I create a large space background that repeats for an rts game. I want to have complex nebulae and dust fields also, but since the units will have lots of space to explore I can't have a 120000px by 1200000px jpeg, so I want to have the image repeat, but not have change lines between segments.

I'm using this with Babylon framework by Microsoft for web GL canvas


texts:
I would like to make a game field in a indie-strategic 2d game to be some a-like this popular picture.

So every "pixel"(blocks) changes it's color slowly, sometimes a bright color wave happens, etc, but the spaces beetwen this pixels should stay dark (not to count shades, lightning and other 3rd party stuff going on). Units are going to be same "pixelized" and should position them-selfs according those blocks.

I have some experience in game-developing, but this task seems not trivial for me. What approaches (shader, tons of sprites or code-render, i don't now) would you recommend me to follow?
(I'm thinking of making this game using Unity Engine)
Thanks everyone! :)


texts: Procedurally Generated Structures over large quantitys of chunks in 3D Terrain Generator

texts:
I am creating large scale worlds using 16*16*16 voxel chunks which are stacked up to 32*32*32 in dimensions and I have hit a bit of a Bump in the road so to speak.

I want to create large structures that span 20+*20+*20+ chunks in volume which are created from procedurally generated structures as well as using templates for some of the content. Now I have an issue. The visual render range is up to 32*32*32 chunks and while I have up to maybe 40*40*40 chunks held in memory at a time when possible.

The structures can be anything like towns, dungeons and roads. I was thinking something like perlin worms for roads and just lay them over the terrain in the x,z and then analyze the path for bridges etc..

The structures and collection of structures need to be pre-generated before the player is within visual range or work more like perlin noise does for heightmaps (best solution). (to avoid the players seeing the generator at work). They also need to be consistent with the world seed every time.

I have thought about this a bit and have 3 possible solutions.

1) Generate the structures based on a point of origin for the structure generator. This causes several issues though as even if I generate from the center of the structure, the structures can easily cross into the potential visual range of the player.

2) Pre-Generate "unreachable" chunks and then page them in and out in order to generate the structures using the above method. This also seems rather unnecessary.

3) I had an idea for dungeon generation in which I generate point clouds/nodes for rooms.

Steps:

a) When the generator finds a "node" it creates an x, y and z size to create a box basing it from the originator point of the room** (centre or corner of the room) and the room type.

**x,y,z relative to 0,0,0 worldspace calculated like so new Vector3((chunkX*16)+voxelX,(chunkY*16)+voxelY,(chunkZ*16)+voxelZ)

b) Once a room size is calculated, check for overlaps and if one is found do one of several things. If the room overlap is high up lower it down till either the roof or the floor are flush. If the roof is flush build a stairs up to the room and remove the walls that intersect.

b) Look Down, North and East for a room maybe with a small cone and attempt to create a hallway between them.

This would probably work somewhat, especially if the center of the dungeon is the main hall/boss room.

This would be different for towns, cities, and surface dungeons. Still seems a little choppy though. Any ideas?

All methods need to analyze the terrain in large quantities for a valid location to spawn the structures.

I was hoping somebody might have a more organic solution or even just a simpler solution that doesn't require me to "Look" so far ahead.

Thank you in advance.


texts: since unity upgrade, OnSceneLoaded not getting called on scene start

texts:
I upgraded my unity project to 2018.3.11f.  Since that upgrade, the OnSceneLoaded event is not getting called, even though I am registering the event handler.

Here's the class:

public class SceneSwitcher : MonoBehaviour
{
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        print("scene loaded: " + scene.name);
    }

    void Start()
    {
        print("SceneSwitcher.Start() called");
        print("adding event handler to SceneManager");
        SceneManager.sceneLoaded += OnSceneLoaded;
    }
}

here's the console output:

SceneSwitcher.Start() called
UnityEngine.MonoBehaviour:print(Object)
SceneSwitcher:Start() (at Assets/Scripts/SceneSwitcher.cs:45)
adding event handler to SceneManager
UnityEngine.MonoBehaviour:print(Object)
SceneSwitcher:Start() (at Assets/Scripts/SceneSwitcher.cs:46)

scene loaded: 3 is never in the console output.

I see others have had this problem, with no answers.

This code worked before the upgrade.  Now I am stuck.  Not sure what I can do.  Any help is appreciated.

Thnx