texts: How to displace a segmented line along a sine wave with Shader Graph?

texts:
I have a mesh made of three identical cylinders (conceptually just line segments with a non-zero thickness) crossed over each other at 60 degree angles, so the ends describe the points of a regular hexagon.  The cylinders are divided into a lot of segments, which I'd like to displace in a sinewave pattern.  The pivot is in the center of the mesh.
My concept is pretty straightforward:

Subtract object position from vertex position to get vertex position relative to the pivot (VPR).
Normalize VPR and swap the X and Y to get a vector in the XY plane perpendicular to the orientation of the cylinder.
Take the magnitude of VPR, multiply by a V1 parameter (Waviness), then take the sine.
Multiply the sine by the perpendicular orientation vector to get the displacement.
Add the displacement to the vertex position.  Assign result to master node's vertex position.

This really feels like it should work.  Each cylinder should be distorted along a sine wave, with the magnitude of the distortion increasing the further it gets from the center, so I end up with three wavy lines crossed over each other at 60 degree angles.  Increasing Waviness should increase the frequency of the wave, as the base value is multiplied by it before feeding into the sine node.
Instead, things curve just a little bit at a low Waviness, but as I increase it the cylinders get both thicker and longer, neither of which should be happening, and start wrapping themselves around the mesh in weird patterns.  I have no idea what I'm doing wrong!
Here's my graph setup, with the mesh assigned to the preview so you can see what a mess it's making of it:

Any ideas how I can fix this?


texts: Making a GUI shader in GLSL c++/opengl/freeglut

texts:
How do you make a shader that will draw ontop of everything else? Im using an approach where I draw square faces in 3d space to simulate a 2d box, but when I make a 3d object, it will clip over the 2d boxes as I move around.

How do you go about making 2d boxes that are drawn directly onto screen, but without clipping thru stuff in 3d space.

Im using openGL and glsl, swapping between shaders as I call objects draw call.


texts: Player sprite animation in 2D platform game

texts:
It's pretty easy to get animations rolling from a sprite sheet. Though which ways there are on combining the animations with player dynamics and motion?

I've figured there's two starting points anyway:

Player animation contains motion (the animation slab defines how the sprite moves)
Player animation does not contain motion

Simple state machine might do the stuff, but are there alternatives? How would you write the state machine itself for doing it?

I'm writing a small hack&slash&jump platform game in html5. The player should stay in place when he strikes a sword, perhaps even move a bit (one can accomplish it through a hack), but otherwise move pretty much without limits. I've got couple frames and I'd like it all to mesh together well.


texts: Where can I find a BRDF reference implementation?

texts:
Does anyone have a link to a sample implementation of how to create/handle 4D BRDFs?

I found a few interesting papers and websites,

Szymon's (student, Princeton) BRDF survey, 1997
SIGGRAPH survey

but cannot seem to find any reference implementation to play with. Anyone have any?

Image from Predicting reflectance functions from complex surfaces


texts: Why do I have an uneven sprite line, when zooming and moving in libGDX?

texts:
I'm having trouble zooming in and moving my sprites. I made a simple drawing to demonstrate what happens.

No zoom:

Zoomed out:

Some lines disappear, when moving a sprite. If I use a filter, this effect improves, but the image is now blurred.

    textureParameter = new TextureLoader.TextureParameter();

    textureParameter.genMipMaps = true;
    textureParameter.minFilter = Texture.TextureFilter.MipMapLinearLinear;
    textureParameter.magFilter = Texture.TextureFilter.Linear;
    game.getManager().load(ResourcesString.image, Texture.class, textureParameter);

This is the way I deal with my camera:

//Code
private void zoomCamera(Vector3 origin, float scale){
    main.orthographicCamera.update();
    Vector3 oldUnprojection = main.orthographicCamera.unproject(origin.cpy()).cpy();
    if(scale > zoomMin) scale = zoomMin;
    if(scale < zoomMax) scale = zoomMax;
    main.orthographicCamera.zoom = scale;
    main.orthographicCamera.update();
    Vector3 newUnprojection = main.orthographicCamera.unproject(origin.cpy()).cpy();
    main.orthographicCamera.position.add(oldUnprojection.cpy().add(newUnprojection.cpy().scl(-1f)));
    main.orthographicCamera.update();
}

public void pan(float x, float y, float deltaX, float deltaY) {
    main.orthographicCamera.translate(deltaX * -2f, deltaY * 2f);
}

Why do my lines display as uneven when I zoom out, and how do I fix it?


texts: VS2017 (and 2019) Community Intellisense only showing part of the Unity class/method information, missing descriptions

texts:
If I hover keywords like Input.GetKeyDown, for example, I know it should tell me something about using it for autofire.

I get autocompletion and the syntax examples / override counts, all great things, but no descriptive text blurbs.

I would really like to get those descriptions turned on.

I yanked a screenshot of an old Unity forum post that has visual evidence of the problem I'm having. I know that the text blurbs exist because I've watched enough Unity videos now with VS being used and more info.

This second image is a screenshot from a video.  In my editor, I do not see the line "Base class for all entities in Unity scenes." I only see the first line "class UnityEngine.GameObject"... helpful but not as helpful as it could be.  Same thing is missing in every class/method.

How can I get these Intellisense description texts to show in my version?


texts: How can I give the mouse position to my GameObject nicely?

texts:
I am making a basic Asteroids game in SFML, and I want the Player ship to always look at the mouse. I have a LookAt(x,y) function which works, but I am not sure how to get the mouse position from the Player's Update() method!

I see several possible solutions to this:

The LookAt(x,y) function is changed to be public, and instead of the Player calling it within its own Update() function, it is called externally (maybe in an Update() function in the GameManager class, which has access to both the Player and the InputManager)
The Player is given a pointer to the mouse position on creation, which is updated every frame in the InputManager on MouseMotion
The Player is given a pointer to the InputManager, which it can then use in the Update() function to access mouse coordinates.
The InputManager class is made 'static', and the Player accesses the mouse position directly via InputManager.GetMousePos()

Ideally I want the Player's behaviour to be contained. I don't feel that it is neat to create new properties, functions or callbacks outside the player class just so that the player has access to two integers. The last solution (making the InputManager static) seems neat to me (especially since it only requires 1 new line of code in the Player class, and doesn't require the Player to hold onto new properties), but I've heard that using singletons is an 'anti-pattern' and should be avoided!


texts: What sort of data should be sent for mouse-based movement in a multiplayer game?

texts:
I'm new to the Multiplayer Rodeo here so please bear with me...

I am just getting started and I'm trying to figure out how to deal with movement.
I've looked at the question Best way to implement mouse-based movement in MMOG which gives me a pretty good idea, but I'm still struggling with what kind of data should be sent to the server.

If a player is on position [x:0, y:0] and I click with the mouse on [x:40, y:40] to start movement, what information should I send to the server? Should I calculate the position based on velocity on client side and just send the expected location? Or should I send current location and velocity and direction? When the server is updating the clients on the players' whereabouts, should the position be sent only, and the clients expected to interpolate/predict movement, or can the direction sent from the client (instead of just coordinates) be used.

My concern(or confusion) is regarding the ping/lag frequency of data update and use of a predictive algorithm, as I'd like the movement to be smooth even with a high latency, and prevent ability to cheat(though that's not the top priority).


texts: Can I use assets from the Unity store in a non Unity project I host publicly?

texts:
I'm working on a simple game for university that I'm making using HTML and Javascript (not Unity) that I'd like to be able to put up on a public github repo and/or maybe host online somewhere. I'd like to use some free assets from the unity store on it.

I've read Can free Unity Store assets be used in non-Unity games? so using Unity Assets is probably alright but if I store my project on a public github repo, anyone would be able to access those assets from there and not need to use the Unity Store for those specific ones.

To quote the linked page, "The only catch appears to be that you must download the assets through Unity, and that you are purchasing a license for the asset."

Also, if it's okay to store Unity Store Assets in a public repo, how should I do it? Just put each asset within a separate folder with a text file containing its license?

Edit: I found this in the Unity Asset Store Terms of Service:

Unless you have been specifically permitted to do so in a separate
agreement with Unity and except as permitted under the Unity-EULA,
you agree that you will not reproduce, duplicate, copy, sell, trade
or resell any Asset that you have acquired from the Unity Asset Store
for any purpose.

So, is that a definite no to what I'd like to do?


texts: How to pass parameters to a Blueprint function called from C++?

texts:
I have found this piece of code showing how to call a blueprint function from C++:
 UFUnction* Func = Obj->GetClass()->FindFunction(FName("FuncName"));
 if(Func == nullptr){return;}

 FStructOnScope FuncParam(Func);
 UProperty* ReturnProp = nullptr;

 for (TFieldIterator<UProperty> It(Func); It; ++It)
    {
     UProperty* Prop = *It;
     if (Prop->HasAnyPropertyFlags(CPF_ReturnParm))
     {
         ReturnProp = Prop;
     }
     else
     {
         //FillParam here
     }
 }

 Obj->ProcessEvent(Func, FuncParam.GetStructMemory());

But… I don’t know how to //Fillparam here.
How can I fill the FuncParam with the parameters that I need to pass?


texts:
I have a Cocos 2d game in which I want to have achievements and a leader-board. What are the steps I would need to take?

Thanks

P.S All of the tutorials I have found are outdated. So please write instructions


texts: Box2d :What is the best approach to build static Box2d smooth curve line

texts:
i want to know what is the best approach to simulate smooth curved line as static body
it will be like path for car to drive .
something like this :
http://www.freeriderhd.com/

how does its box2d static body are constructed ?
Thanks


texts: How to calculate FPS and what factors affect FPS?

texts:
In this case, FPS means Frames Per Second and that means the number of frames that graphic hardware render in one second. I'm wondering what kind of stuffs could affect FPS?

So, for some tests I created a simple scene in Unity with some cubes and capsules and then create a empty game object and then add this c# code to it:

public class FPSReport : MonoBehaviour {

    public double Fps;

    void Update ()
    {
        Fps = 1.0 / Time.deltaTime;
    }
}

I think it can tell me the FPS. When I played it it worked but it wasn't more than 30.

I was saw a lot of games that their fps was normally on 150. Is this fps rate ok?

If I add more objects, textures, animations , etc ... to my scene.

What happen to my fps?
Could it attain zero? and
If it attain zero, what is the meaning of a zero FPS (the hardware stopped working?!)?


texts: How to implement toroidal mapping in SDL?

texts:
I am making an Asteroids clone in SDL2. I think the kind of world asteroids takes place in is called toroidal map. I'm refering to the fact that the edges of the world are connected so when you exit from one side, you appear at the opposite.

My first approach was with SDL_DrawRect(), but I don't know how to "break" the rectangle in order for it to appear in two (or more) sides at once. I faked the effect by creating another rectangle, like a shadow, when the original rectangle was touching an edge. It worked somehow, but I wanted the real deal: render the diferent parts of the rectangle in different edges.

My second approach is creating the rectangle by SDL_FPoints in a std::vector, like this:

struct SpaceObject {
  std::vector<SDL_FPoint> shape_;
  // more members
  void generateSquareShape(const SDL_FPoint& where);
  void move(float delta_time, const SDL_Point& screen_size);
  void render(SDL_Renderer& renderer) const;
  void warpCoordinates(SDL_FPoint& point, const SDL_Point& screen_size);
  // more functions
};

The shape is generated once with generateSquareShape(). It just sets the appropiate coordinates to each SDL_FPoint.
The movement function is just applying deltas to each point:

void SpaceObject::move(float delta_time, const SDL_Point& screen_size) {
  for (auto& point: shape_) {
    point.x += delta_.x * delta_time;
    point.y += delta_.y * delta_time;
    warpCoordinates(point, screen_size);
  }
}

Render is more of the same, another vector travesal:

void SpaceObject::render(SDL_Renderer& renderer) const {
  for (const auto& point: shape_) {
    SDL_RenderDrawPointF(&renderer, point.x, point.y);
  }
}

The warpCoordinates() is called at every move to check if a point must go to another side:

void SpaceObject::warpCoordinates(SDL_FPoint& point, const SDL_Point& screen_size) {
  if (point.x < 0) {
    point.x = screen_size.x + point.x;
  } else if (point.x > screen_size.x - 1u) {
    point.x = point.x - screen_size.x;
  }

  if (point.y < 0) {
    point.y = screen_size.y + point.y;
  } else if (point.y > screen_size.y - 1u) {
    point.y = point.y - screen_size.y;
  }
}

All in all it accomplishes with the effect nicely, but I think it performs poorly (at least in my laptop i5 2,6ghz, 6gb RAM, win10) and it hasn't collision detection yet.
One optimization I think is moving and rendering on the same function so it only loops through the points vector once, but I think that breaks the one function, one job, doesn't it?

So, is there anything I'm missing to improve performance? A faster algorithm to implement this toroidal world? Maybe a most suitable SDL class to work with? Or some C++ technique I'm not using and I should? Thanks in advance, any help appreciated.

Using win10, SDL2.0.12, and the latest visualC++ compiler.


texts:
This image is pretty self explanatory I hope:

How can I achieve this effect without animating it? I want to avoid animations as there are many objects hanging and I dont want them to move the exact same way.


texts: Unity VR: How to draw camera on top of VRSettings.showDeviceView mirroring

texts:
We're using VRSettings.showDeviceView = true to mirror the VR display to the main window. We also have a camera that we'd like to draw over top of the main window's mirrored VR image. This other camera renders an overlay for people who are watching the mirrored VR view.

Right now the overlay camera has a depth of 5 and the VR camera has a depth of 0, but as far as I can tell I think the overlay camera of depth 5 is being overwritten by the mirror drawn by showDeviceView = true.

Anyone know an easy trick to get this behaviour?

Thanks for your time,

Allen


texts: Which input event is suitable for this game?

texts:
I am trying to clone this game:

http://www.ferryhalim.com/orisinal/g3/bells.htm

As i am using libgdx, so the game is both for Android and PC. I was wondering which input event would fit in nicely. SA you can see, bunny moves in accordance with the position of cursor. There is no cursor in android so i will have to do something different. Any help would be appreciated. Thanks in advance.


texts: Terrain deformation via mouse in real time using OpenGL

texts: The main problem I’m facing is how I can, given a spot on a terrain mesh (x and z coordinates) change the mesh so that the surrounding points also change height but will be less affected. What’s confusing me is how I could change the mesh when that spot is not a vertex within the mesh so that the mesh will accurately represent the given point changing height. Would I need to change the mesh entirely, changing the vertex points completely to accommodate for the new shape (so possibly making that point a new vertex in the mesh and thus changing the mesh entirely) or is there some other way to do it without having to restructure the mesh so that the vertices that are affected by the height change move which will then change the faces to be in accordance with the change in height


texts: Improving the efficiency of my bloom/glow shader

texts:
I'm making a neon style game where everything is glowing but the glow I have is kinda small and I want to know if there's an efficient way to increase the size of it other than increasing the pixel sample iterations.

Right now I have something like this:

float4 glowColor = tex2D(glowSampler, uvPixel);

//Makes the inital lines brighter/closer to white
if (glowColor.r != 0 || glowColor.g != 0 || glowColor.b != 0)
{
    glowColor += 0.5;
}

//Loops over the weights and offsets and samples from the pixels based on those numbers
for (int i = 0; i < 20; i++)
{
    glowColor += tex2D(glowSampler, uvPixel + glowOffsets[i] + 0.0018) * glowWeights[i];
}

finalColor += glowColor;

for the offsets it moves up, down, left and right (5 times each so it loops over 20 times) and the weights just lower the glow amount the further away it gets.

The method I was using before to increase it was to increase the number of iterations from 20 to 40 and to increase the size of the offset/weight array but my computer started to have FPS drops when I was doing this so I was wondering how can I make the glow bigger/more vibrant without making it so CPU/Gcard intensive?


texts: Creating/Displaying Image at Specific Size in Unity with C#

texts:
I'm trying to draw an image background for Dialogue in a RPG I'm working on and having issues with preventing the image from taking up the whole screen.  The goal is to create an object (if it needs to be created), and otherwise show it, via code.

At the moment, it draws the image successfully, but it takes up the full screen every time.

Here's the code:

        GameObject canvasObject = GameObject.Find(DialogueObject);  //DialogueObject is a const string ID

        if (canvasObject == null)
        {
            canvasObject = new GameObject()
            {
                name = DialogueObject
            };

            var canvas = canvasObject.AddComponent<Canvas>();
            var background = canvas.gameObject.AddComponent<Image>();

            canvas.renderMode = RenderMode.ScreenSpaceOverlay;

            canvas.transform.parent = canvasObject.transform;
            background.transform.parent = canvas.transform;

            background.rectTransform.anchorMin = new Vector2(0f, 0f);
            background.rectTransform.anchorMax = new Vector2(1f, .5f);

            if (background.sprite == null)
            {
                background.type = Image.Type.Sliced;
                background.fillCenter = true;
                background.sprite = Resources.Load<Sprite>(DialogueBackgroundResource); //DialogueBackgroundResource is a const string
                background.color = new Color(1, 1, 1, 0.5f);
                background.rectTransform.sizeDelta = new Vector2(40, 40);
            }
        }

        canvasObject.gameObject.SetActive(true);

The above is literally all of my code.  I've tried setting the sizeDelta, per a number of queries on the web, and even though it changes, the image is always full screen.  Is there something else I am missing?  My understanding is that the anchors are telling it to basically only take up the spot in the bottom half of the screen.

Any help is appreciated!


texts: How to render water reflections on multiple heights

texts:
I'm making a voxel game on OpenGL, and are trying to find a way to render semi-realistic water (At least partially good looking, it doesn't need to be strictly scientific accurate).

All sources written about that topic I find seem to assume that all the water in the scene has the same height, which is not the case on a voxel game, where you can have (And see at the same time) multiple bodies of water, with different height each.

The tricky detail lies in the multi-height part of the problem, which makes really difficult to render the scene in real time using typical water reflection algorithms aimed at single level water surface.

As an example, consider the following image:

The dirt pillar at the left should be reflected on the water at its front, as so should be the mountains near the horizon. The water collindant to the pillar is ~20m higher than the general sea water, so traditional reflection methods (Considering a fixed water level) would simply not work in this case. Considering that a lot of different water levels can be seen in a single scene, performing a traditional water reflection method for each water body height is not an option if we want to achieve a acceptable frame rate execution.

How can I overcome this problem? There is any way to render it in real time?
If it isn't actually possible to do, what approximation should I take to get a good looking result, even if reflections aren't 100% realistic?


texts: How can I cast light onto a sprite in 3D environment?

texts:
I'm making a 2.5D game, where 2D sprites are in a 3D environment. I'm using URP and I have a problem with lighting the sprites. The sprites are lighting up from behind, and not front. I tried with directional, spot and point lights but the result is the same no matter what official shader I use they only light up when they receive light from behind. Front light has no effect whatsoever on the sprites.
I spent the entire day looking for a solution but I've got almost nothing. Only solution I saw someone else mention is making the game object with the "sprite renderer" on, a child of another gameobject and rotate it 180 degrees on Y. But that is not an option for me cause I'm using custom scripts to rotate that game object already.
So can there be a custom shader? Can one be created using shadergraph maybe? I know some others have faced the same problem but did anyone really solve it?
Thanks.


texts:
I have a sprite that I want to rotate smoothly and face the opposite direction:

This is my render function:

public void render() {
    // Game Loop

    Gdx.gl.glClearColor(0.7f, 0.7f, 0.2f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    spriteBatch.begin();

    if(bug.getX() >= (int)(Gdx.graphics.getWidth() - 100) && bug.getY() >= (int)(Gdx.graphics.getHeight() - 100)){
        bug.rotate(rotDeg);
        turn = !turn;
    }
    else if(bug.getX() <= 0 && bug.getY() <= 0){
        bug.rotate(rotDeg);
        turn = !turn;
    }

    if(!turn){
        bug.translate(v.x * Gdx.graphics.getDeltaTime(), v.y * Gdx.graphics.getDeltaTime());
    }
    else{
        bug.translate(-(v.x * Gdx.graphics.getDeltaTime()), -(v.y * Gdx.graphics.getDeltaTime()));
    }

    bug.draw(spriteBatch);
    spriteBatch.end();
}

What my code does is that when it reaches the destination (top right corner, or bottom left corner), it immediatly turns facing the opposite direction. How would I make this turn smoothly?


texts: Why will my server not execute a command sent by the client in Unity 5.1?

texts:
I'm working on a very simple/basic client-server networking program, the basis of a future game I hope to create. Now the client program/project DOES successfully connect with the 'server program/project' (both completely separate). However when it comes to having the client send a request/command to the server. Well it doesn't send the command to the server, it executes it on the client.

I read about changing the 'Monodevelop' inheritance to 'NetworkBehaviour' so I did and it resulting in an error along the lines of;

Command xxx was sent to the server
...Debug.logerror(object
So I seemed to have got half way there, it allegedly sent the command to the server, but the server did nothing with it. I don't know why.

Below are the relatively short programs I've got for my server and client and are pretty much the same, but if anyone can help me out I'd greatly appreciate it, as my University course didn't really go into Network Programming all that much;

Server Code

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class server : MonoBehaviour
{

    public string IP = "127.0.0.1";
    public int port = 25001;
    public int prevConns = 0;
    private int currConns = 0;

    public virtual void OnServerReady (NetworkConnection conn)
    {
        NetworkServer.SetClientReady (conn);
    }

    void OnGUI ()
    {
        if (Network.peerType == NetworkPeerType.Disconnected) {
            if (GUI.Button (new Rect (100, 100, 100, 25), "Start Client")) {
                Network.Connect (IP, port);
            }
            if (GUI.Button (new Rect (100, 125, 100, 25), "Start Server")) {
                Network.InitializeServer (20, port, false);
            }
        } else {
            //CLIENT - NOT NEEDED
            if (Network.peerType == NetworkPeerType.Client) {
                GUI.Label (new Rect (100, 100, 100, 25), "Client");
                if (GUI.Button (new Rect (100, 125, 100, 25), "Disconnect")) {
                    Network.Disconnect (250);
                }
            }
            if (Network.peerType == NetworkPeerType.Server) {
                currConns = Network.connections.Length;
                GUI.Label (new Rect (100, 100, 100, 25), "Server");
                GUI.Label (new Rect (100, 125, 100, 25), "Connections: " + currConns);

                if (prevConns != currConns) {
                    if (prevConns < currConns) {
                        Debug.Log ("NEW CONNECTION");
                        prevConns++;

                    } else if (prevConns > currConns) {
                        Debug.Log ("Lost CONNECTION");
                        prevConns--;
                    }
                }

                if (GUI.Button (new Rect (100, 15, 100, 25), "Shutdown")) {
                    Network.Disconnect (250);
                }
            }
        }
    }

}

Client Code

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class connection : MonoBehaviour
{

    public string IP = "127.0.0.1";
    public int port = 25001;
    public GameObject player;

    public virtual void OnClientConnect (NetworkConnection conn)
    {
        ClientScene.Ready (conn);
    }

    void OnGUI ()
    {
        if (Network.peerType == NetworkPeerType.Disconnected) {
            if (GUI.Button (new Rect (100, 100, 100, 25), "Start Client")) {
                Network.Connect (IP, port);
            }
        } else {
            if (Network.peerType == NetworkPeerType.Client) {
                GUI.Label (new Rect (100, 100, 100, 25), "Client");
                if (GUI.Button (new Rect (100, 125, 100, 25), "Disconnect")) {
                    Network.Disconnect (250);
                }

                if (GUI.Button (new Rect (100, 150, 100, 25), "Send Cmd")) {
                    CmdSendCommand ();
                }

            }
        }
    }

    [Command]
    void CmdSendCommand ()
    {
        NetworkBehaviour.print ("HELLO");
    }
}


texts: Unity - Can not select Desired unity version

texts:
I'm coming back to Unity after around a 4 month break and finding that opening my past unity projects/ creating a new project will not create it in the unity version I select(v2018.4), and rather always creates it in v2018.1, regardless of having both installed.(image attached below, file I speak specifically of is RPGprojr)

If anyone has a clue to why this is happening any solution would be very much appreciated. I have tried reinstalling 2018.4 version and deleting the 2018.1 version altogether, to no avail.


texts:
I'm working on creating an inventory system for a game. The inventory system will use cells and 2D images to represent items, like Minecraft, Diablo, or WoW. I've hit a bit of a snag when trying to let the player place items in the bag (click and drag style).

So far, I've successfully created the inventory grid, which is really smoke and mirrors:

public class InventoryMenu {
boolean objectSelected = false;
Item selectedItem;

public final int COLUMNS = 5;
public final int ROWS = 7;

ArrayList<Item> inv = new ArrayList<Item>((ROWS + 1) * COLUMNS);
Sprite slot;

public void render(Graphics g) {

    for (int i = 0; i < 40; i++) {
        int col = i % COLUMNS;
        int row = ROWS - i / COLUMNS;

        slot.draw(g, (Camera.width - slot.getWidth() * COLUMNS) + slot.getWidth()* col, row * slot.getHeight());

        if (inv.get(i) != null) {
            inv.get(i).render(g);
        }
    }
    if (selectedItem != null) {
        selectedItem.render(g);
    }
}

Basically, I have an arraylist that can hold items, and it just draws the "slot" image 40 times and if there's an item in that "slot" it draws the item image too. Cool? Cool. The problem comes if I want to allow the player to select an item in their inventory and move it to a different slot. I have no problem letting them pick it up (I use a pretty primitive brute force, but with any reasonably sized inventory, it works):

private Item grabItem(Point2D mouse) {
    for (Item i : inv) {
        if (i != null) {
            if (i.getPhysicsShape().contains(mouse)) {
                Item pick = i;
                selectedItem = pick;
                objectSelected = true;
                i = null;
                return pick;
            }
        }
    }
    return null;
}

That bit of code lets a player pick up an item, but placing it fails - it rarely gets the right slot, except if its the bottom row (0-4):

setDown(){
    int slotLoc = calcSlot(InputHandler.mouseCoords);
    placeItem(slotLoc);
}

private void placeItem(int loc) {
    if(loc < 0 || loc > ROWS * (COLUMNS + 1))
        return;

    int col = loc % COLUMNS;
    int row = ROWS - loc / COLUMNS;
    selectedItem.pickUp((Camera.width - slot.getWidth() * COLUMNS) + slot.getWidth() * col, row * slot.getHeight());

    inv.set(loc, selectedItem);
    selectedItem = null;
    objectSelected = false;
}

private int calcSlot(Point2D mouse){
    int colPos = (int) (COLUMNS - (Camera.width - mouse.getX()) / slot.getWidth());
    int rowPos = (int) (ROWS+1 - (mouse.getY()) / slot.getHeight());

    if (colPos > COLUMNS || colPos < 0 || rowPos < 0 || rowPos > ROWS + 1) {
        dropItem();
        return -1;
    } else {
        return colPos + 4*rowPos;
    }

}

I'm fairly confident that the problem is in calcSlot, but I can't seem to find where. Any help would be greatly appreciated, I'm sure it's something silly.

Images!!

So, I can pick up an item with no problem, and it automatically places it in the last slot. So far, everything is gold.

I can then click that image and lift it out of the grid, and it follows my mouse (mouse is hidden by PrntScrn, but its at the top left corner of the image:

When I try to place the item by clicking in the middle of slot 33, however, it derps and places it, inexplicably, in slot 27.


texts: Object movement in Unreal using BPs and input touch and ARCore

texts:
So I am trying to move an object in Unreal through input touch using ARCore. The problem is that I can't use the simple Screen to world position because it just returns a world position wherever the camera is at the time that you touch. I'm trying to convert the X and Y positions to actual space but, I am having a difficult time with it. Here's what I have so far:

This works okay, but the movement isn't equal if that makes sense. Obviously it's because I am just pulling the raw coordinates but, I honestly have no idea what I need to do to them in order to get it to move smoothly.

If you're still not following, basically, the closer I get to the left, top edge the slower the object moves and the closer I get to the right bottom edge the faster the movement. This happens because the X and Y coordinates get smaller/larger

What can I do to compensate for this disparity between coordinates?

Is there a way to get like a percentage from the edge of the screen?


texts: Why does lightmapping take so long compared to real time shadows?

texts:
I am using Unity 5. As a test, I set the realtime shadow resolution to max and the distance to cover my entire scene with no cascades. As expected, it lagged severely, but I could still move the camera and the shadows updated in real time.

As a second test, I lightmapped the scene using the absolute lowest settings. This took about a minute to complete.

Basically, I can use lightmapping, and it takes much longer to work than real time shadows even though it looks worse. Why does lightmapping take so long to bake in comparison to real time shadows?


texts: Need some advice on designing components

texts:
So after reading about components for a bit I want to make a very simple spaceshooter game that uses components and systems. However, I'm a bit confused on how much scope each component should have. For example, let's say the game had asteroids that fly around and if you hit them, you take damage. They also have health. The asteroid entity may then contain these components:

SpriteComponent (Texture2D texture)
HealthComponent (int amount)
CollidableComponent (bool rigid)
MovementComponent (int x, int y)
RotationComponent (int degrees)

Now let's say we had a RenderSystem. Its Update() method would require SpriteComponent, MovementComponent, and RotationComponent to draw an entity.

That's all fine and good but when would have MovementComponent and not RotationComponent? Couldn't we just have a TransformComponent that contains the x, y, and rotation? It feels a little weird designing these components to only be a container of one data-type. But then where do you draw the line? All sprites also have a position and rotation amount, so should the SpriteComponent contain the TransformComponent, or should the members of TransformComponent be moved to SpriteComponent?

But then the problem is if you wanted an entity with a position and rotation but no sprite. Then you either have to give it an empty texture (not necessarily a bad solution) or maintain TransformComponent and just make SpriteComponent contain it as well (or just pass both).

There's a lot of decisions to be made and I really feel similar to when I began object-oriented programming. "What should be objects? What should its methods be? Should this be public or private?" Obviously I've figured all that out now but this new component-based paradigm is giving me these same problems now. Does anyone have any advice or standards for component-based design for typically used components and how one normally would set something like this up?


texts: Multiplayer game communication framework for mac/ios

texts:
(Cross post from stackoverflow)

I am creating a multiplayer 2D game for Mac and iOS devices. I'll be using cocso2d for graphics/game engine, however I am largely blank on what to use for multiplayer communication. Please note that I cannot use central severs e.g. SmartFox, RedDwarf, etc since I want the players to "host" games for others and be able to play it on their LAN, VPN or my own servers.

Any pointers? I checked lidgren but it's for .NET only and hence not an option for me.

EDIT: just in case it wasn't clear, the messaging has to be real time hence it's probably going to be over UDP


texts: Actionscript 3: Which side of object is hit?

texts: I have a two objects colliding with each other. I am testing for the collision with if(ob1.hitTestObject(ob2)){//do something }. Is there a way to determine which side of the object was hit, i.e. if ob2 is a square, which side of the square was collided with?


texts: Unregister touch sprite when background scene is zoom and moving

texts: I am new to game development on Android, I use AndEngine framework. I'm developing an application with isometric view, at this time I had problems with touchlistener area on the sprite in the scene background, I intend to turn off the touch function on the sprite when the background is shifted, so as not to disturb the background when being moved. How it works?


texts:
I have seen different "basic" game loops both from books like "Introduction to 3D game programming with DX11" or online tutorial ( Rastertek ) and if we take off all the fancy stuff to control framerate and more they all look roughly like this :

while (msg != WM_QUIT) //
{
    if (PeekMessage(&msg,0,0,0,PM_REMOVE)
    {
        // Translate and dispatch message
    }
    else
    {
        // Do update, rendering and all the real game loop stuff
    }
}

If you run it this way it works perfectly, but the thing that i do not understand is the else.
If i look naively at the loop i might think that if the system keeps sending events ( key presses, mouse clicks and more ) the else part will never be executed, am i wrong ? ( yes!! i am but this is exactly the point, i don't understand why! ).

I'd like to understand why the loop works this way. If the messages were strictly related to the window ( resizing,moving,closing ) i'd understand it, but they are not. Let's say that i keep pressing any key a WM_KEYDOWN message is repeatedly sent and a message is peeked, thus never allowing the else part to execute

I have not a lot of experience with the Win32 library and i'm probably missing something^^.

Thank you for your time and happy coding!


texts:
Solution:

To move a unit forward:

forward = Quaternion(0,0,0,1)
rotation.normalize() # ocassionally
...
pos += ((rotation * forward) * rotation.conjugated()).xyz().normalized() * speed

I think the trouble stemmed from how the Euclid math library was doing Quaternion*Vector3 multiplication, although I can't see it.

I have a vec3 position, a quaternion for rotation and a speed.

I compute the player position like this:

rot *= Quaternion().rotate_euler(0.,roll_speed,pitch_speed)
rot.normalize()
pos += rot.conjugated() * Vector3(0.,0.,-speed)

However, printing the pos to console, I can see that I only ever seem to travel on the x-axis.

When I draw the scene using the rot quaternion to rotate my camera, it shows a proper orientation.

What am I doing wrong?

Here's an example:

You start off with rotation being an identity quaternion: w=1,x=0,y=0,z=0
You move forward; the code correctly decrements the Z
You then pitch right over to face the other way; if you spin only 175deg it'll go in right direction; you have to spin past 180deg.  It doesn't matter which direction you spin in, up or down, though
Your quaternion can then be something like: w=0.1,x=0.1,y=0,z=0
And moving forward, you actually move backward?!

(I am using the euclid Python module, but its the same as every other conjulate)

The code can be tried online at http://williame.github.com/ludum_dare_24_evolution/
The only key that adjusts the speed is W and S.  The arrow keys only adjust the pitch/roll.

At first you can fly ok, but after a bit of weaving around you end up getting sucked towards one of the sides.  The code is https://github.com/williame/ludum_dare_24_evolution/blob/cbacf61a7159d2c83a2187af5f2015b2dde28687/tiny1web.py#L102


texts: Spawning units in a world made by Perlin noise?

texts:
There's some issues that I've come across in my Perlin noise-based game. Take a look at the attached screenshot below.

The white areas you see are walls, and the black areas are walkable. The triangle in the middle is the player.

I've implemented physics in this game by drawing it onto a texture (white or black pixels), and then getting that from the CPU.

However, now I stand with a different problem at hand. I want units (or creeps, whatever you call them) to spawn constantly, at the edge of the screen. The point here is that in the final game, there will be a "fog of war" that doesn't allow the player to see that far anyway.

I figured that I could just scan the pixels at the edge of the screen and see if their physics texture is black, and then spawn stuff randomly there. However, if you take a second look at the screenshot, there is (in the upper-left corner) an example of where I wouldn't want the creeps to spawn (since they wouldn't be able to reach the player from there).

Is it possible to somehow have the GPU determine these spawn-spots for me, or some different way? I thought about making vectors between the proposed point at the edge of the screen and the player, and then following it every 10 voxels, and see if a wall collides, before spawning a unit there.

However, the above proposed solution may be too CPU intensive.

Any suggestions on this matter?

Note 1
For the units spawned, I do not want to be using any form of pathfinding to avoid wall collisions as these units run towards the player. Therefore, the units must spawn at the edge of the screen, at a location where walking in a straight line towards the player would not collide with any walls.


texts: Get Closest point between a Box 3D and a Point

texts:
I have a point A (x, y, z),
and a Box: Center (x, y, z), Size (Width, Height)

How to get the closest point in the box from the point A ?

In Unity I can create a bound, and I can find the non-rotated position like that:

Bounds bounds = _mesh.bounds;
Vector3 closestPoint = bounds.ClosestPoint(pointA);

But then If the bound is rotated, the result is not correct.
So I have 2 options:

Find the way to rotate my closestPoint from the pivot.
Find the math formula myleft.

If someone can help ! thanks.

EDIT: here a video:
the red point is the one find with bound.ClosestPoint
the yellow point is the one find with:

Vector3 closestPointInverse = _currentTarget.InverseTransformPoint(closestPoint);

https://youtu.be/RMRRtSaJv8w

I have also tryed to do my own rotateFromPivot function:

public Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles)
    {
        return Quaternion.Euler(angles) * (point - pivot) + pivot;
    }

When I use it, I get the same result with the InverseTransformPoint method.


texts:
Is there any good reason for tiles (e.g. Minecraft's) to be 16×16?

I have a feeling it has something to do with binary because 16 is 10000 in binary, but that might be a coincidence.

I want to know is because I want to make a game with terrain generation, and I want to know how big my tiles should be, or if it doesn't really matter.


texts: How can I put my game into a cheap portable console?

texts: I've seen some cheap gaming consoles on Amazon, and I was wondering if it would be terribly difficult to put my RPG Maker game on it. Basically, a while ago, the creator of a never-solidifying game called Bob's Game had this idea to invent a cheap little console for indie developers. It was going to be called the nD. Well, the project never went anywhere, but it has left me with the itch to package my game in a cheap little gaming machine. How can I go about this?


texts: Multi Threading - How to split the tasks

texts:
if I have a game engine with the basic 'game engine' components, what is the best way to 'split' the tasks with a multi-threaded approach?

Assuming I have the standard components of:

Rendering
Physics
Scripts
Networking

And a quad-core, I see two ways of multi-threading:

Option A ('Vertical'):

Using this approach I can allow one core for each component of the engine; e.g. one core for the Rendering task, one for the Physics, etc.

Advantages:

I do not need to worry about thread-safety within each component
I can take advantage of special optimizations provided for single-threaded access (e.g. DirectX offers a flag that can be set to tell it that you will only use single-threading)

Option B ('Horizontal'):

Using this approach, each task may be split up into 1 <= n <= numCores threads, and executed simultaneously, one after the other.

Advantages:

Allows for work-sharing, i.e. each thread can take over work still remaining as the others are still processing
I can take advantage of libraries that are designed for multi-threading (i.e. ... DirectX)

I think, in retrospect, I would pick Option B, but I wanted to hear you guys' thoughts on the matter.


texts:
I am in the process of developing a 2D digging game for mobile. I need an efficient method to dig tunnels through the levels (Similar to the game play in Death Worm), and build colliders around the tunnels.

How would I go about it?


texts:
I am currently working on a game which should be your basic RPG style and in this game I am using an Ability system based on ScriptableObjects. Each Ability has its own ParticleSystem (prefab) and AudioSource.

Basically all Ability.asset files are added to a list of Abilities.
Using PageUp/Down buttons the player equips the next/previous Ability of the List.

When "Fire1" is pressed the ability is then cast which works just fine before equipping the next Ability. Then, no matter how many times I press "Fire1" no Ability is cast unless I click out of game-view and inside of it again. However in the Inspector everything seems OK.

Here's my code:

void Update ()
{
    abilityCount = AbilitySystem.Instance.allAbilities.Count - 1;
    abilityCooldown -= Time.deltaTime;
    if(Input.GetButtonDown("Fire1") && abilityCooldown <= 0f)
    {
        Shoot();
        abilityCooldown = 1f / castingSpeed;
    }

    if (Input.GetKeyDown(KeyCode.PageDown))
    {
        abilityIndex--;
        if (abilityIndex < 0)
        {
            abilityIndex = abilityCount;
        }
        currentAbility = AbilitySystem.Instance.allAbilities[abilityIndex];
        UpdateAbilityStats();
    }

    if (Input.GetKeyDown(KeyCode.PageUp))
    {
        abilityIndex++;
        if (abilityIndex > abilityCount)
        {
            abilityIndex = 0;
        }
        currentAbility = AbilitySystem.Instance.allAbilities[abilityIndex];
        UpdateAbilityStats();
    }

}

void UpdateAbilityStats()
{
    abilityDamage = currentAbility.abilityDamage;
    abilityRange = currentAbility.abilityRange;
    abilityCooldown = currentAbility.abilityCooldown;
    particles = currentAbility.Particles;
    particlesOnTarget = currentAbility.onTargetParticles;
}


texts: How to create random seeds, randomly in gamemaker studio?

texts:
So, I'm working on a match-3 game similar to Ironcast (in concept, it's just seeing if I can). I've finally got the board to generate properly, and to place down random gems. Problem is, it's always generating the same placement, as though it were seeded (which it isn't, as far as I know).

Here's the code that directly generates the randomness (scr_generate_gem).

var insert = irandom_range(1, 4);//randomizing the gem inserted
var gem_insert;

        switch (insert)
        {
        case 1: gem_insert = obj_Food;
        break;
        case 2: gem_insert = obj_Fuel;
        break;
        case 3: gem_insert = obj_Parts;
        break;
        case 4: gem_insert = obj_Meds;
        break;
        default: gem_insert = obj_Parent;
        break;
        }

return gem_insert;

And here is where it's used.

//hardcoded height and width of the board. could change later
Large_Width = 6;
Large_Height = 6;

var i = Large_Width-1; //5, at the moment
var jreset = Large_Height-1; //5. Used to keep a reference to when j
//needs to be reset to maximum, so the board fills out.
var j = jreset;

repeat(Large_Width) //repeat 6 times; i goes from 5 to 0 through repeats
   {
    repeat(Large_Height) //repeat 6 times; j goes from 5 to 0 through repeats
    //ends up repeating this repeat 6 times, because of the above Repeat, making 36 in total
        {
        //initialize the board by generating the objects
        BoardGems[i, j]  = instance_create((i-1)*36, (j-1)*36, scr_generate_gem()); //creates an object, and places it here
        j -= 1;//decrement j so we aren't overwriting the last object created.
        }
    j = jreset;//resets j
    i -= 1;//decrements i to make a new column
   }


texts:
I create a Monogame Content Project to convert assets into XNB. For FBX file without texture there is no problem: the file is correctly converted and when I load XNB into my project everything is ok.
The problem occours when i have associated to fbx file a texture map: in this case both FBX and PNG files are converted to XNB but when i try to load these XNB files into my project the following problem occours:

"ContentLoadException: Could not load Models/maze1 asset as a non-content file!"
Note: maze1 is the XNB file that was converted from FBX.

How can I solve this problem?
Thank you in advance


texts:
I'm developing my own game and for that I want to implement frustum culling, to archive an performance optimization. I found a description on the internet (enter link description here) and this one looked really good - but I didn't understood it...
Maybe you can read through it and explain me the concept of this technique. Firstly I don't know the exact concept and secondly I don't know, how I could implement this.

Maybe you can explain it to me and then give me an Idea, how to implement this..

Second Question:
Is this a good technique? (Currently I have implemented frustum culling with boundingspheres, but the technique presented in the blog seems to be even better..)


texts:
I have a world made of many cubes (like in Minecraft), they have only color (not texture). I am rendering them using OpenGL 3.3 core profile (GLFW3, GLAD, GLM). I am already have done some optimizations:

not rendering internal faces
backface culling
rendering faces using GL_TRIANGLES and indexing

But it's still a lot slower than Minecraft, but Minecraft is in Java and blocks have textures, there is bigger world (there are entities etc. too)! How can I optimize my program further?
It may be something with pre-computing. Player rarely change the world (only small part of ticks).
I am currently filtering faces with this code:
// for every block
if (blocks[x][y][z] != nullptr) { // nullptr means that block is air
    bool drawSides[6];
    if (world.GetBlockAt(BlockPos(x, y, z - 1)) != nullptr)
        drawSides[0] = false; // internal face, culled
    else
        drawSides[0] = true; // draw that side
    // other 5 sides
    // ...
    blocks[x][y][z].draw(sides);
}


texts:
Anyone have any idea how the scaling is accomplished in angry birds?  I want to make sure my images/background always scale to match the screensize and this game seems to have a similar effect.  I have been playing with the manifest settings lot on setting preferred screen sizes but I have yet to duplicate exactly what I want.

Are there any effective ways to make sure your game will always display X Y space, scaling down as needed depending on the pixel size?

I want to make sure everything is always displayed on the screen for all devices and not cut things off on small devices or add black space on large devices.

I am calculating my drawing space by getting the size of the view and using this as bounds for my sprites but it doesn't seem to be working too well.


texts: How to support more than 4 XInput controllers?

texts:
I'm making a multiplayer game in GameMaker Studio 2. The game supports upto 12 controllers, where the first four are XInput controllers. The rest would be DirectInput.

If I try playing with 8 Xbox controllers, only 4 of them are detected in the game, as expected.

But, is there a way to get more than 4 Xbox controllers working?


texts:
When I call the IDXGISwapChain::SetFullscreenState method, it does not return. The window goes fullscreen, but accepts no further input. A println!() put right after never fires. I am assuming there is some sort of deadlock happening behind the scenes, but the docs don't go into what all it locks.

Does SetFullscreenState perform any locking?

If so, what does it lock?

What other issues could cause SetFullscreenState to never return?

I am using Rust 1.44.1 with winapi 0.3.9. I am passing minwindef::TRUE and a null pointer as arguments (passing minwindef::FALSE returns, but does the opposite of what I want). I am using the following options in the swapchain desc:
desc.BufferCount = 1;
desc.BufferDesc.Width = width;
desc.BufferDesc.Height = height;
desc.BufferDesc.Format = dxgiformat::DXGI_FORMAT_R8G8B8A8_UNORM;
desc.BufferDesc.RefreshRate.Numerator = 60;
desc.BufferDesc.RefreshRate.Denominator = 1;
desc.BufferUsage = dxgitype::DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.OutputWindow = *hwnd.inner();
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Flags = dxgi::DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
desc.Windowed = minwindef::TRUE;


texts:
I spent some time writing a shader on shadertoy but now, when I try to translate my code to opengl I don't know how to calculate the uv that they describe as like this:

vec2 uv = fragCoord.xy / iResolution.xy;

How can I do that in a typical opengl 330 core fragment shader?


texts: Why am I getting a down arrow in my Unity scene when using Oculus Rift and how do I get rid of it?

texts: In Unity, I have set up a scene to try out in Oculus Rift. When I hit play in Unity, everything works fine until about 5 seconds later when I get an arrow (Assets>OVR>Textures>out.png) that appears in the center of my screen and won't go away. What does this arrow mean and how can I get rid of it? It is obstructing my view of the level that I am trying to view.


texts: How can I diminish my voxel terrain's height smoothly instead of randomly?

texts:
I have a script that is supposed to diminish height smoothly when an int is lowered, I tried perlin noise to make it lower like it would if it where terrain, which is the goal I'm after, but it only does removes entire layers.

public float heightIndex;
private height Height;

public void Start()
{
    Height = FindObjectOfType<height>();
    //the failed perlin test
    //heightIndex = transform.position.y + Mathf.PerlinNoise(heightIndex, heightIndex);
    heightIndex = transform.position.y + Random.Range(3, 10);
}
public void Update()
{
    if (Height.heightdetermine<heightIndex)
    {
        Destroy(gameObject);
    }
}

Thank you @DMGregory for fixing my dyslexic mess and bad grammar.


texts: Help Me Make Sense of the Canvas and Text-Based Non-UI Objects in Unity

texts:
I am trying to wrap my head around the concept of the Canvas in Unity and its many uses especially outside of user interfaces. However, I cannot really find a good tutorial that digs deep enough into it; so, I was hoping that I can find some help here.
The concept of a user interface needing to have a separate wrapper layer to position elements overlaying the game window does, kinda-sorta, make sense, and I have created one that works fine at the moment. What does not make sense is how everything that contains text also needs to be inside a canvas object to even be visible. I don't understand how a canvas makes sense when I want to display non-UI game elements that contain text, such as damage counters or, as in the case of the game I started working on, playing cards.
Furthering the concept of playing cards, it gets even more complicated. If I understand it correctly, I would not only need a canvas to place my cards on (preferably separate from the one that contains my UI elements) but if I want to put text on my cards and make them come from a reusable Prefab, the Prefab itself needs to be a canvas (or somehow contain one), otherwise text elements would not show up on it (at least based on my trials).
Now, I have read about and actually tried the Text Mesh Pro framework, but honestly I don't need that bloated functionality; a simple text would be perfectly fine for my needs, if only I could make it work.
My question is, can someone briefly illustrate how to work with canvases and text-based game objects (preferably  in the context of a card game). My cards need to contain an image and several text fields to display various information. What would be the best way to create a Prefab to initialize these cards? Then, what would be the most optimal way to display these cards on the scene (they should not be part of the UI but the game itself).
My game is 2D and uses a pixel art aesthetic if it is relevant.
Many thanks for your answers!


texts: Unity not updating sprite animations (possible bug)

texts:
I have a simple animation of a foot which i want to change sprites from one sprite to another, which is seen in the following two images:

now as one can see in the animation timeline there is a change in sprites of the foot (a slight distortion), however if one looks in the inspector the sprite remains constant. The sprite in the inspector seems to choose whichever sprite was last placed on the animation timeline, until the game is played and at this point it reverts to foot1. The sprite never changes whenever you scrub through the timeline. This is a 2D project and I am running a 64 bit version of windows 8.1 running the most recent version of unity (which has been reinstalled), this looks like a bug to me but if i am doing it wrong then please feel free to tell me so. I am using C# in order to develop my project. I am not using any mods, or anything downloaded from the asset store.

I have tried uninstalling and reinstalling unity, so that is not the problem, my project is available here:

http://www.filedropper.com/newunityproject6-copy

I have tried to give as much information as possible, but please do not hesitate to ask any further questions.

My computers properties:
8gb of ram
64 bit
intel i5-3230M CPU@ 2.60 GHz
Windows 8.1
Lenovo g780


texts: SteamCMD Failed to get application info app

texts:
I am trying to push my first build to a depot and I keep getting this error and I can't figure out why.

Logged in OK
Waiting for license info...OK
[2015-05-17 20:11:58]: ERROR! Failed to get application info for app <appID> (check login and subscription)

I am using SteamCMD obviously, and I am logging in with the account that I use to login to Steamworks.

Has anyone had this problem before? If so, what is the fix? Thanks.


texts: How to make box2d bodies block each other but not push each other?

texts: I want to use box2D to create a movement system for an RTS game.  How can I make bodies block the movement of other bodies while preventing these bodies from pushing each other?


texts: Help me understand this vbo/rotation, and how its done opengl c++

texts:
Im pretty new to opengl, and I just cant figure out how to rotate this vbo/vao in 2d space. This is how I bind my coordinates:

float points[] =
{
    0.0f,  0.10f,  0.0f,
    -0.10f, -0.10f,  0.0f,
    0.10f, -0.10f,  0.0f
};

glGenBuffers(1, &points_vbo);
glBindBuffer(GL_ARRAY_BUFFER, points_vbo);
glBufferData(GL_ARRAY_BUFFER, 9 * sizeof(float), points, GL_STATIC_DRAW);

I place the vbo at vao[0]

glBindBuffer(GL_ARRAY_BUFFER, points_vbo);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);

And I enable the array

glEnableVertexAttribArray(0);

and call to draw in the cpu, with

glDrawArrays(GL_TRIANGLES, 0, 3);

In my shader, I load the array by:

//glsl shader
layout ( location = 0 ) in vec3 vertex_position ;
void main()
{
 gl_Position = vec4(vertex_position, 1.0);
}

Ive edited out the coloring/fragment to save space, but this is my problem:
I can make a uniform to move my triangle around, but idk how to apply a transformation matrix to a vec4.

It seems the shader reads my vertex_position VAO one vec/element at a time, and trying to apply any matrix just gives an error.

How do you make or apply a rotation matrix on vao, am I inputting it wrong? All the uniforms I apply seem to only stretch, zoom, or move the overall triangle.

Sorry if the question is bad, or partially confused, shading is new to me overall, so thanks in advance.'

my shader:

#version 410 core
layout ( location = 0 ) in vec3 vertex_position ;
layout ( location = 1 ) in vec3 vertex_colour ;

out vec3 colour;
uniform vec3 fade=vec3(0.0,0.0,0.0); //fade
uniform float zoom=1.0;
uniform mat4 transform = mat4(vec4(1.0,0.0,0.0,0.0),
vec4(0.0,1.0,0.0,0.0), vec4(0.0,0.0,1.0,0.0), vec4(0.0,0.0,0.0,1.0));

void main()
{
colour=vertex_colour+fade;
gl_Position=transform*vec4(vertex_position,1.0);
}

this example https://open.gl/transformations and the answer made it doable.


texts: Implementing algorithms via compute shaders vs. pipeline shaders

texts:
With the availability of compute shaders for both DirectX and OpenGL it's now possible to implement many algorithms without going through the rasterization pipeline and  instead use general purpose computing on the GPU to solve the problem.

For some algorithms this seems to become the intuitive canonical solution because they're inherently not rasterization based, and rasterization-based shaders seemed to be a workaround to harness GPU power (simple example: creating a noise texture. No quad needs to be rasterized here).

Given an algorithm that can be implemented both ways, are there general (potential) performance benefits over using compute shaders vs. going the normal route? Are there drawbacks that we should watch out for (for example, is there some kind of unusual overhead to switching from/to compute shaders at runtime)?

Are there perhaps other benefits or drawbacks to consider when choosing between the two?


texts: Why does my Character Jump only Half as High?

texts:
I am trying to implement simple Newtonian physics for my game. However, my character only jumps half of the height I would expect him to.

Physics says that the take-off velocity (impulse) v for an object to reach a height h is

Thus, to achieve a height of 2.0 meters, an impulse of 6.264 (per unit of mass) would be required. I used this as a benchmark to test the correctness of my physics code.

However, aforementioned impulse only raises my object 0.97 meters into the air before it falls down again.

I've tried Euler integration, Euler (midpoint) integration and Runge-Kutta 4 integration, all resulting in a jump height 0.97. My delta time is fixed to 1 / 120.

// Calculate the movement of the game object in this physics frame
Vector3 translation;
{
  Vector3 acceleration = this.queuedForces / this.Mass;

  // Convert impulses
  Vector3 impulses = this.queuedImpulses / this.Mass;
  acceleration += impulses / delta; // turn impulse into force over 1 delta tick

  // Apply half of the force scaled by time
  this.Velocity += acceleration * delta / 2.0f;

  // Apply impulses directly to velocity
  //this.Velocity += this.queuedImpulses / this.Mass;

  // Integrate into position
  translation = this.Velocity * delta;

  // Apply second of the force scaled by time
  this.Velocity += acceleration * delta / 2.0f;

  // Finally, queued movements (root motion, etc.) go directly into translation
  translation += this.queuedMovement;
}

Gravity is a force, applied each tick as this.forces += Vector3(0, -9.81, 0) * this.Mass). The jump is an impulse added once as this.impulses += Vector3(0, 6.264, 0).

Where does my mistake lie?

Adding the impulse directly to this.Velocity instead of converting it to a force quadruples the jump height, which equally puzzles me.


texts: FormatMessage not working for HRESULTs returned by Direct3D 11

texts:
I am using Windows 7 x64 and Visual Studio 17 (v15.9.7).

Say I try to create a swap chain using IDXGIFactory2::CreateSwapChainForHwnd and pass in DXGI_SCALING_NONE. I will get the following message in debug output (if I have enabled Direct3D debugging):

DXGI ERROR: IDXGIFactory::CreateSwapChain: DXGI_SCALING_NONE is only supported on Win8 and beyond. DXGI_SWAP_CHAIN_DESC{ SwapChainType = ..._HWND, BufferDesc = DXGI_MODE_DESC1{Width = 816, Height = 488, RefreshRate = DXGI_RATIONAL{ Numerator = 0, Denominator = 1 }, Format = B8G8R8A8_UNORM, ScanlineOrdering = ..._UNSPECIFIED, Scaling = ..._UNSPECIFIED, Stereo = FALSE }, SampleDesc = DXGI_SAMPLE_DESC{ Count = 1, Quality = 0 }, BufferUsage = 0x20, BufferCount = 2, OutputWindow = 0x0000000000290738, Scaling = ..._NONE, Windowed = TRUE, SwapEffect = ..._FLIP_SEQUENTIAL, AlphaMode = ..._UNSPECIFIED, Flags = 0x0 } [ MISCELLANEOUS ERROR #175: ]

The function returns 0x887a0001 in form of a HRESULT. If I put @err,hr in the watch window, I get a nice error message there:

ERROR_MOD_NOT_FOUND : The specified module could not be found.

However, if I pass this HRESULT to FormatMessage, it just puts NULL in the output and returns 0. @err,hr helpfully informs me that the new error is ERROR_MR_MID_NOT_FOUND : The system cannot find message text for message number 0x%1 in the message file for %2.

My questions are:

Why is FormatMessage not giving me right error string (the one starting with ERROR_MOD_NOT_FOUND...)?
Where is Visual Studio getting these pretty error strings from?
Can I get them too? Who do I pay?

PS. I am using the Windows 10 SDK version of DX11, not the older DirectX SDK version. Thus, I can't really link to dxerr.lib either.

This is the code that is used to print the error message:

LPTSTR error_text = NULL;
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
              FORMAT_MESSAGE_ALLOCATE_BUFFER |
              FORMAT_MESSAGE_IGNORE_INSERTS,
              NULL,
              hr,
              MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
              (LPTSTR)&error_text, 0,
              NULL);


texts: I use the program Tiled to create tile maps, which export to the TMX format. However, I can't find a way to load them into my LWJGL game. I don't want anything that renders them automatically, I want to render them myself. I just need a way to read the data required for me to know where and what to draw in my game. Are there any libraries or code I can use to accomplish this?


texts: How can I manually syncronize render calls with a monitor's refresh rate in Direct3D 9?

texts:
I have an application that utilizes Direct3D 9 to render 3D graphics. I'm trying to manually control the number of frames rendered in a given second. Here is pseudocode:

while( bInGame )
{
    // handle window stuff
    dispatchEvents();

    // handle d3d9 stuff
    if( !windowMessages )
    {
        // process animation
        OnD3D9FrameMove(GetElapsedTime());

        // when work is done render a frame (30 frames per second)
        while(GetElapsedTime() < 0.03333333f){ Thread.Sleep(1); }
    }
}

The above code is very rough but explains what I'm trying to do. I want to allow time between frames to process work( i.e. visibility, animation, etc. ). The actual code works well except for one problem. Screen anomalies occur due to rendering frames out of sync with the screen's refresh rate. The anomalies are best described as horizontal tearing, an undesirable result.

When I activate vsync while using this code the screen anomalies do not appear. However, I can't use vsync because it prevents my game loop from continuing until the frame is rendered and thus consumes the spare time that I would like to set aside for work.

How can I get around this problem? I would like to sync with the monitor using my application rather than the Direct3D API. This way I can control the work flow...Any ideas?


texts: Compiling a shader with fxc results in invalid ps_5_0 output semantic 'COLOR0'

texts:
I'm attempting to compile a shader at the command prompt.  What am I doing wrong that would make it generate this error?

fxc /Od /Zi /T ps_5_0 /E "ps_main" /Fo "basic.pso" "basic.ps"

Here is the pixel shader

struct VS_OUTPUT
{
    float4 Color    : COLOR0;
};

float4 ps_main(VS_OUTPUT input) : COLOR0
{
    return input.Color;
}

The return is:

<path here>\basic.ps(8,33-40): error X4502: invalid ps_5_0 output semantic 'COLOR0'

compilation failed; no code produced


texts: Which K-factor should be used in case players have different K-factor values

texts:
I am implementing a ranking system based on the Elo rating and cannot get a point about the K-factor. If two players with different skills and, therefore, different K-factors are playing, which exactly K-factor should be used when changing their ratings?

For example, player A has rating 2500 and K-factor 16 (probability ~75%) while player B has rating 2300 and K-factor 24 (probability ~25%). If player A wins, do I need to use 16 as K-factor for both players or 16 for player A and 24 for player B?


texts: How do I create a game that runs on Windows, iOS and Android?

texts:
I use C++ to create windows games and now I want to step into another other OS like Android or iOS. I'm totally familiar with C++ so I tried to create app for iOS using objective C it was working awesome. However, I also want to publish games for Android but not by using Java.

I don't want to create a single game 5-6 times for other platforms. Is their any way that if I create game for Windows then it will work in Android and iOS ? Or should I use Action Script 3.0? If I use action script 3.0, will it require Flash player to run the game in Windows, Android, iOS?


texts: Does a thread in a mobile game serve the same purpose as a view model in a mobile application?

texts:
I'm trying to confirm up my understanding of the coding differences and similarities between mobile game design and mobile app design for Android devices using Java/Kotlin.

~~ ~~ ~~

In mobile app design, a good design principle is "Separation of Concerns" where the app will have any number of distinct classes to handle different purposes. One design architecture separates these concerns into two classes, namely, the "View Model" and the "UI Controller" (where the UI controller is an activity or fragment).

The View Model's purpose is to have code that holds data and makes logical decisions with that data. The UI Controller's purpose is to draw that data on the device's screen, as well as, receive Input and OS events.

~~ ~~ ~~

In mobile game design, I've seen an Activity class, a GameView class (which implements SurfaceView) and a Thread subclass. The Activity will instantiate the GameView class and place the GameView class into its view hierarchy using  setContentView(GameView(this)). This differs from how mobile app design where setContentView(R.layout.layout_xml_file) is used to supply views

The GameView object has a surface to have bitmaps drawn on. The GameView object manipulates that surface using surface-specific callback functions which is much like how the UI Controller manipulates lifecycle state using lifecycle-specific callback functions. The GameView object also handles User Input like the UI Controller.

Obviously, the GameView and the UI Controller have the same roles.

~~ ~~ ~~

Does a Thread in a mobile game serve the same purpose as a View Model in a mobile application?
If not, where are is the data and logical decisions supposed to go? Do they go in the various Bitmap classes?
If Bitmap classes serve the same function as View Models, how do they make logical decisions (i.e. a Mario object collects a Coin object)?


texts: In a semi-infinite procedural (chunk based) map, how do you handle objects larger than a single chunk?

texts:
I'll use an example to try and be more specific. Assume this is for a 2D top-down game. Chunks in this are made up of 32x32 tiles.

If procedural buildings were to be generated based on some kind of noise algorithm and a building was typically 3x3 chunks in size, how do you ensure the seed for this map will always produce the same buildings?

Given two adjacent chunks: chunk A and chunk B, what if they both meet the noise algorithm's requirement for being a spawn point for a building?

If they are both far from the player's current view range, it could depend on how the player approaches these chunks as far as which one gets generated first.

My first thought was to only check for buildings every so many chunks, however, I'd also like to have some objects that may span tens of chunks. I don't think this is a proper solution.

Should I simply be using a different type of algorithm to identify where buildings should be able to be spawned at, an ever expanding Voronoi diagram as an example, or is there something else I'm just not considering with how I'm already trying to attempt this? Perhaps I should be handling cross chunk objects on a grander scale (like a collection of 32x32 chunks)?

Thanks!


texts: The Correct Usage of DLLs with a DirectX Game?

texts:
I'm using DirectX 10 (in C++) to make a game engine, and a test driver program on top of it.

Now that I've written many messy rough drafts of an engine, I want to make the final (or sorta final) clean version. I choose to follow how I've seen other engines do it, and that's to have all the core nasty messy crap in a DLL, and then you can create games with just a few functions (well, not really :D).

However, I'm unsure of what nasty messy crap to put in that DLL. I don't know about speed restrictions with DLLs. What I've done is put my winproc in the DLL, and have a class that takes the messages, and sends them through to the program using the DLL. Then that program does what it needs to do, and calls a rendering functions back in the DLL that renders everything.

Only problem is it gets very low FPS (2, to be exact...). I've looked through everything, and I don't know if the way I'm using DLLs in causing this, or its something different.

Whether it's the DLLs or not, I still want to know how to use a DLL correctly with a game engine. I like being neat, I hate having to see all those long names of DirectX classes. I use typedef a lot.


texts:
I'm trying to write a 3D model exporter addon for Blender in Python and need some help.

The spec of the 3D format uses some compression on the vertices, there is a vertex buffer that contains vertices as 32bit floats. When this is compressed it is stored as 16bit float or half precision float.

I've seen lots of examples online of code in C to convert a 32bit float to 16bit float but not much luck with Python.

I was wondering if anyone here can help?

So far I've attempted to take some of the code here conversion of float and put it into Python. I managed to get this working and testing with a triangulated cube rendered only half the cube.

F16_EXPONENT_BITS = 0x1F
F16_EXPONENT_SHIFT = 10
F16_EXPONENT_BIAS = 15
F16_MANTISSA_BITS = 0x3ff
F16_MANTISSA_SHIFT =  (23 - F16_EXPONENT_SHIFT)
F16_MAX_EXPONENT =  (F16_EXPONENT_BITS << F16_EXPONENT_SHIFT)

for byte in self._byteBuffer:
   f32 = int(byte)
   f16 = 0
   sign = (f32 >> 16) & 0x8000
   exponent = ((f32 >> 23) & 0xff) - 127
   mantissa = f32 & 0x007fffff

   if exponent == 128:
       f16 = sign | F16_MAX_EXPONENT
       if mantissa:
           f16 |= (mantissa & F16_MANTISSA_BITS)
   elif exponent > 15:
       f16 = sign | F16_MAX_EXPONENT
   elif exponent > -15:
       exponent += F16_EXPONENT_BIAS
       mantissa >>= F16_MANTISSA_SHIFT
       f16 = sign | exponent << F16_EXPONENT_SHIFT | mantissa
   else:
       f16 = sign
   file.write(struct.pack(">H",f16))


texts: How to clamp a mouse angle within a field of view range of the facing direction

texts:
In my top down shooter game, the player can face in any of the 8 compass directions using the keyboard.
Depending on the direction, the player will have a 90 degree field of view to turn based on the angle selected by the mouse position. Obviously the mouse can go anywhere so it has to be restricted within -45 and 45 of the angle faced.
The eight direction angles:
    135 90 45
180            0
   225 270 305

So if the player is facing to the left at 180, their range of view will be -45 and 45 of that ie 135 to 225. So it's simply mouseAngle - facingAngle, which works fine, except if the player is facing around 0, 45 or 305 degrees where the mouse angle passes zero causing issues in calculation.
As it is I'm using this formula.
private void setAngleFOV() {
    if (facing == 0 || facing == 360)
        facing = mouseAngle < 360 && mouseAngle >= 180 ? 360 : 0;
    angleFOV = mouseAngle - facing;
    angleFOV = Math.max(Math.min(angleFOV, 45), -45);
}

It can either be 0 or 360 for either facing or mouseAngle, whichever works best but I haven't found an ideal solution. The above formula works for facing right at angle 0, but not with diagonal angles 45 and 305.
It could maybe work with lots of if statements and such, but I feel there must be a better way?


texts: Why the camera is not moving only up but also to the right?

texts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraMove : MonoBehaviour
{

    public float smoothSpeed = 3f;

    // Use this for initialization
    void Start()
    {

    }

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

    }

    private void FixedUpdate()
    {
        transform.localPosition = Vector3.MoveTowards(transform.localPosition, new Vector3(0, 500, 0), smoothSpeed * Time.deltaTime);
    }
}

The script is attached to the Main Camera.

I want the camera to move directly up and a little bit also to the back.
But the way it is now it's moving up but also to the right. Why it's moving also to the right ? I tried transform.localPosition and also only transform.position


texts: How to transfer the player into a new scene, loaded in the background?

texts:
I'm porting an old BuidBox 2 game to the Godot game engine. I already added all assets and scenes to the Godot project. The game is a 2.5D (isometric) endless runner. What I want now is to add a mechanism to load the next scene offscreen, remove the player's character from the current scene, and add it to the next scene seamlessly, without breaking the game physics or causing the player character to go behind or in front of other game objects that it's not supposed to.
For instance if I have this scenes:
Scene1
|-bg
|-player
└-fg

Scene2
|-bg
|-player
└-fg

I would like to load Scene2, remove player from Scene1 and replace player from Scene2 with the player node I removed from Scene1, without the player node changing its velocity or position abruptly in the physics world or appearing behind the bg node in Scene2 or in front of the fg node in Scene1.


texts: What does changing GL_TEXTURE_WRAP)_(S/T) do?

texts: I am working through some beginner OpenGL tutorials, and the current one teaches how to apply a texture to a simple rectangle. The tutorial states tells me to set the texture parameters GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T to GL_CLAMP_TO_EDGE, however I am uncertain as to what this actually does. I am aware it is something to do with how textures larger/smaller than the space they are being mapped onto are handled, but I'm not sure what behavior this actually causes. What does GL_CLAMP_TO_EDGE do, and how is this different from GL_CLAMP, GL_CLAMP_TO_BORDER, GL_REPEAT? Thanks very much in advance, and bonus helpfulness if you can provide images for an idiot like me.


texts:
Hey and thanks in advance for any help/pointers

The solution is probably straight forward but i am still a little inexperienced (while creating quite a few different VR unity projects mostly study related, i never really build anything so the editor allowed for some shortcuts. see below).

I am currently developing for Windows mixed reality with unity. I am struggling to figure out how to make a (possibly secondary) application window run on the desktop that can be used during facilitated VR-experiences to change settings and generally provide facilitator input to the application while the participant would just perceive the VR world.

Edit:
I have a similar project that is developed with Steam_vr library / Open_VR that works exactly as expected and portrayed by the unity editor; i.e. the desktop will shows the ingame footage + the screenspace overlay UI (which is interactable).Nevertheless quite a few features where implemented with the MixedRealityToolkit so I'd prefer to stick with that. And was wondering if there is a way to achieve the same/similar behavior with it.

Now with MRTK everything works straight forward when running from unity editor just making a canvas screenspace will prevent it from showing in vr while it can still be interacted with. the problem is that the facilitators themselves are a third party and having a build would just make their handling of the solution much easier. Not to mention performance gains from building and cleaning the project(?).

it will probably come down to creating a secondary window that runs on the desktop since my understanding is that uwp with MRTK just runs in the wmr portal rather than a separate app; and that the WMR portal simply copies the Headset render to the desktop. But i am completely blank on how to achieve this and was hoping that someone might have struggled with this before. But i couldn't really find anything. I'd prefer not to have to resolve to Networking, and will attempt to convert to Steam_VR /OpenVR in the meantime..


texts:
I need to draw a curved line, I have searched the Internet but found nothing that would suit my needs.

I used b2ChainShape but it's not completely what I need.

How can I draw a curved line with Box2d?


texts: Rotate to a set degree then reverse and repeat in Unity

texts:
I'm making my first project in Unity, a simple game where touching objects adds points to the player's score.

I'd like the objects to have a pleasant back and forth swaying animation on the Z axis. Nodding to the right 30 degrees, then to the left 30 degrees, on and on.

Here's what I've got...

public class Rotator : MonoBehaviour
{
    void Update ()
    {
        transform.Rotate(new Vector3(0,0,12)*Time.deltaTime);
    }
}

This gives me a nice slow rotation. But I am clueless how to tell Unity to stop at +30 degrees, reverse to -30 degrees, rotate again to +30, stop and repeat, etc, etc.

I'd really appreciate any help. Maybe there is a thread like this that I was not able to find? I assume it will involve some kind of 'if then' function?


texts:
Here is my noobish scenario I'm trying to understand:

Some class, Terrain:

       void Start()
        {
...
            switch (Type)
            {
                case TerrainType.StartPoint:
                    renderer.material.color = Color.blue;
                    break;
                case TerrainType.EndPoint:
                    renderer.material.color = Color.red;
                    break;
                case TerrainType.Wall:
                    renderer.material.color = Color.black;
                    break;
                default:
                    renderer.material.color = Color.green;
                    break;
            }
...
        }

some other class, SomeOtherClass: ('target' is Terrain object)

void Awake()
{
...
temp = (Terrain) Instantiate(target, new Vector3(0,0,0), Quaternion.identity);
...
}

At this point everything is ok.

If, down the road, i try assigning different type to one of the existing Terrain objects, the type will change sure, but the color will not since color change switch is in Start()

If i put the color updating code in Update() function sure it works and the color is changed but is this the right way of doing something like this?

I feel like it is an overkill since Update is called every frame and i might have only one or two calls to change the type throughout the whole game life time.


texts: Unity - Button get function from GameObject

texts:
So I have two gameObjects, the blue one the player character and different spheres of difference colors. Each sphere has a function lets say SphereFunction().
When the player character touches a sphere gameobject I want a button to appear on the screen. This can be done using the ontriggerenter2d and ontriggerexit2d.

What I want is the button OnClick to call the SphereFunction() of the sphere if pressed. This function can have different implementations depending on the color of the sphere, just the function name is the same.
How can this be done using a single button?


texts: Game companies - Involvement of programmers in the design process

texts:
This is a question basically to programmers with experience working in game companies.

How common is it that game coders participate in the design process of the game? Both gameplay design, and content design. Do you participate in related meetings and such, or do you have some other (formal/informal) opportunities to sound your opinions of game features / levels / even story, and for them to be actually considered?

Another question, not completely unrelated - is it possible for a programmer with interest in the field to move from the technical job to a gameplay design related job (or do both in smaller companies)? Does that happen?


texts:
For my specific case, I am trying to find a path finding implementation similar to what described here.

I could see reference implementation for A* and HPA*, but I wonder how to extend A* to simple roadmaps (say 20 nodes). I am not sure how to extend A* to use non-grid network. Any examples would be useful.

Thanks.


texts: Unintended stuttering when moving camera

texts:
I am using opengl and GLFW to make a rendering engine.

Things work per se, but there is some weird flickering happening when I move the camera.

Due the nature of the problem I need to link a youtube video:

https://www.youtube.com/watch?v=XhFrXadnWbs&feature=youtu.be

If you pay attention you will see the stuttering happening as I move the camera.

I beleive this problem occurs due to how I have implemented my camera movement, which is:

GLFW key callback:

#define CAM_SPEED 0.2f
void static key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
    if(key == GLFW_KEY_W)
    {
        c.translateForward(CAM_SPEED);
    }
    if(key == GLFW_KEY_S)
    {
        c.translateForward(-CAM_SPEED);
    }
    if(key == GLFW_KEY_A)
    {
        c.translateSideways(-CAM_SPEED);
    }
    if(key == GLFW_KEY_D)
    {
        c.translateSideways(CAM_SPEED);
    }
}

Camera code:

    void inline translateForward(float speed)
    {
        glm::vec3 hForward = forward;
        hForward.y = 0;
        hForward = normalize(hForward);

        position += hForward*speed;
    }

    void inline translateSideways(float speed)
    {
        position += side*speed;
    }


texts: How to get characters to be aware that their path is obstructed?

texts:
I'm using Unity with Arongranberg's A* pathfinding project to move my characters. However, it appears that my characters are contending for a position on the terrain when they are told to move together to a same position.

For example, I have 5 characters being told to move to PositionA. They will move together based on their waypoints to PositionA. One of the characters, call it CharacterA, will reach PositionA before the rest. Now, the other 4 characters who arrived later will continue to keep walking and "sliding" around CharacterA. They seem to stop only when CharacterA moves away from PositionA so that they could reach their destination to break out of the loop. Even so, only one character can be in PositionA while the rest will continue to contend for the place.

So, how can I get the characters and objects to know that they have reached their destination and should stop beside the other characters instead of contending for the same place?

A naive method could be I get the characters to detect if they are blocked by something straight ahead of them. If they are, break out of the loop and stop the walking state. But at times when the character hasn't reached his destination yet and is blocked by an object, say another character, breaking out of the waypoint loop will stop him at the wrong destination. I can't recalculate for a new path from his current position either since the blocking object is another character, which the initial pathfinding grid scanning did not take into account. One way is I re-scan the whole terrain for a new grid of nodes with the characters in the scene taken into account. But this wouldn't be efficient and will lag a whole ton.


texts:
How can I make grab Shader similar to https://docs.unity3d.com/Manual/SL-GrabPass.html in GLSL.

The idea, is that you grab exact pixels from background (ex. from composited renderTarget) and put on rendered object. So it's like 100% transparency, because it always has the pixels right behind. Later if you disort the pixels, can give very cool effects like https://www.shadertoy.com/view/Mdc3Rl.

SO far I have texture of background (plane to renderTarget), and object cube right before it. My vertex shader for cube is gl_Position = WVP * spos; and I have no idea how do the frag shader to copy the pixels from background. Any help appreciated.


texts: How can I cut a graph representing 2D positions into two sub-graphs?

texts:
I have a graph where each node is associated with a 2D position. I would like to use a finite line to "cut" this graph into two halves, as shown below:

Note that the cutting line does have a direction. All vertices in that direction remain and aren't cut away.

How can I implement this?


texts: Slide 2d Vector to destination over a period of time

texts:
I am making a library of GUI controls for games I make with XNA. I am currently developing the library as I make a game so I can test the features and find errors/bugs and hopefully smash them right away.

My current issue is on a slide feature I want to implement for my base class that all controls inherit. My goal is to get the control to slide to a specified point over a specified amount of time. Here is the #region containing the code

#region Slide
    private bool sliding;
    private Vector2 endPoint;
    private float slideTimeLeft;
    private float speed;
    private bool wasEnabled;
    private Vector2 slideDirection;
    private float slideDistance;

    public void Slide(Vector2 startPoint, Vector2 endPoint, float slideTime) {
        this.location = startPoint;
        Slide(endPoint,slideTime);
    }

    public void Slide(Vector2 endPoint, float slideTime) {
        this.wasEnabled = this.enabled;
        this.enabled = false;
        this.sliding = true;
        Vector2 tempLength = endPoint - this.location;
        this.slideDistance = tempLength.Length(); //Was this.slideDistance = (float)Math.Sqrt(tempLength.LengthSquared());
        this.speed = slideTime / this.slideDistance;
        this.endPoint = endPoint;
        this.slideTimeLeft = slideTime;
    }

    private void UpdateSlide(GameTime gameTime) {
        if (this.sliding) {
            this.slideTimeLeft -= gameTime.ElapsedGameTime.Milliseconds;
            if (this.slideTimeLeft >= 0 ) {
                if ((this.endPoint-this.location).Length() != 0){//Was if (this.endPoint.LengthSquared() > 0 || this.location.LengthSquared() > 0) {
                    this.slideDirection = Vector2.Normalize(this.endPoint - this.location);
                }
                this.location += this.slideDirection * speed * gameTime.ElapsedGameTime.Milliseconds;//This is where I believe the issue is, but I'm not sure. It seems right to me... (Even though it doesn't work)
            }
            else {
                this.enabled = this.wasEnabled;
                this.location = this.endPoint;//After time, the controls position will get set to be the endpoint.
                this.sliding = false;
            }
        }
    }
    #endregion

this.location is the location of the control elsewhere defined in the class. I have looked at this blog as a huge reference and have googled around quite and have looked on many forums but can't find anything that shows how to implement it.

Please and Thanks for your time!

EDIT:

I have switched this line "this.location += this.slideDirection * speed * gameTime.ElapsedGameTime.Milliseconds;" several times to see what it does. My issue is getting the control to smoothly move to the end location. It moves after the time has expired, but It doesn't move other then that except flash in my face.

EDIT2:

I have used the first slide method with 3 parameters and it works except it doesn't do it in a period of time and once it gets to its destination, it starts moving randomly towards the previous location and the end location.


texts:
This is a screenshot showing two small images on the panel and I want that when the mouse cursor is over the image/s to highlight the current image the mouse is over.
On the right the canvas settings and the rawimages.

This script is attached to the canvas :
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;

public class SavedGamesSlots : MonoBehaviour
{
    Texture2D thisTexture;
    byte[] bytes;
    string fileName;
    public GameObject[] ImageHolder = new GameObject[1];

    // Start is called before the first frame update
    void Start()
    {
        var imagesToLoad = Directory.GetFiles(Application.dataPath + "/screenshots", "*.png");
        for (int i = 0; i < imagesToLoad.Length; i++)
        {
            thisTexture = new Texture2D(100, 100);
            fileName = imagesToLoad[i];
            bytes = File.ReadAllBytes(fileName);
            thisTexture.LoadImage(bytes);
            thisTexture.name = fileName;
            ImageHolder[i].GetComponent<RawImage>().texture = thisTexture;

        }
    }

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

    }

    public void OnHover()
    {
        Debug.Log("Enter");

    }

    public void OnHoverExit()
    {
        Debug.Log("Exit");
    }
}

I have two problems :
How to know what image the mouse is over now ?
How to highlight the current image the mouse is over ?
I also created Trigger Event component on each RawImage then calling this two functions OnHover and OnHoverExit :

And this is when I tried to make one of the rawimages the left one brighter changed it's color to white but still the image is too dark :


texts: Testing Live Ads Before Publishing Admob

texts:
I am testing ads with the test device method and test ads are showing perfectly but when I try to load live ads they won't load.

I have implemented the OnAdFailedToLoad which tells me that ads are not loading, this only happens when I try to load live ad but in the test ad everything works fine.

Does this happens all the time? we can't see live ads without publishing the game first? or there are no ads available at the moment if so when do the get available or they even get available for new users. How can I make sure that I will get live ads after publishing the on Google Play Store.

I don't know I am just confuse about this thing, I am using Unity 3D and building for Android.

I have searched on internet but everybody says that ads might not available at the moment I am just curious why are ads not available its been two days and I haven't seen any ad when are the ads going to be available. Thanks for reading this.


texts: xna model scaling - model is bigger than world

texts:
I'm having trouble scaling my model in XNA with C#. The model is bigger than the world itself and I can't seem to scale it down. Below is the code I'm using and an attached screenshot. How can I scale my model down?

       private void DrawModel(Matrix currentViewMatrix)
    {

        Matrix[] bones = animationPlayer.GetSkinTransforms();

        // Compute camera matrices.
        Matrix view = Matrix.CreateTranslation(0, -40, 0) *
                      Matrix.CreateRotationY(MathHelper.ToRadians(cameraRotation_model)) *
                      Matrix.CreateRotationX(MathHelper.ToRadians(cameraArc)) *
                      Matrix.CreateLookAt(new Vector3(0, 0, -cameraDistance),
                                          new Vector3(0, 0, 0), Vector3.Up);

        float fieldOfView = MathHelper.ToRadians(4);

        Matrix projection = Matrix.CreatePerspectiveFieldOfView(fieldOfView, device.Viewport.AspectRatio, 1, 100000);

        // Render the skinned mesh.
        foreach (ModelMesh mesh in currentModel.Meshes)
        {
            foreach (SkinnedEffect effect in mesh.Effects)
            {
                effect.SetBoneTransforms(bones);

                effect.View = view;
                effect.Projection = projection;

                effect.EnableDefaultLighting();

                effect.SpecularColor = new Vector3(0.25f);
                effect.SpecularPower = 16;
            }

            mesh.Draw();
        }
    }

edit: when I change the following lines, I'm able to scale the model, however when I turn my model, it rotates in a circle; the model isn't properly scaled. If I do not scale the model, it turns properly around itself.

How can I fix this?

Matrix view = Matrix.CreateTranslation(0, -50, 0) *
                      Matrix.CreateScale(0.01f, 0.01f, 0.01f) *
                      Matrix.CreateRotationY(MathHelper.ToRadians(cameraRotation_model)) *
                      Matrix.CreateRotationX(MathHelper.ToRadians(cameraArc)) *
                      Matrix.CreateLookAt(new Vector3(0, 0, -cameraDistance),
                                          new Vector3(0, 0, 0), Vector3.Up);


texts: Flixel text causing memmory leak (FlxText) - AS3

texts: I am calling kill() and destroy() on flxText when i dont need it anymore, how come its still using the memmory it let the game run for a while it went up to 1,5 gig of ram, then i commented it out the code where flxText is made and got this http://shrani.najdi.si/?3u/x6/1MkFPi08/fac.png (using only 170m-190m), so its obviously flixel text not cleaning up propperly , wat do ?


texts: Google Analytics collect and visualize custom data

texts:
I was wondering if Google Analytics (GA) can be used to collect custom metadata about app usage and performance.

An example would be to measure and collect the average frame rate (fps) of the app on the device. How can this data be presented into the Google Analytics Report? If possible, please make an example by sample source code.


texts: AndEngine: Density, Elasticity, Friction, Gravity concepts

texts: I am new to AndEngine. I have seen some physics examples from AndEngine Example package. I want to know the role of density, elasticity, friction and gravity while implementing physics. How they effect a physical object in andengine? I know its very basic example but I want to start andengine from very basics. Can anybody make these concepts clear to me?


texts: fragment shader directional light positioning with camera

texts:
Im trying to set up directional lighting in the fragment shader. So the direction of my light moves with the camera position.

      #version 150 core

      uniform sampler2D diffuseTex;
      uniform vec4 lightColour;
      uniform vec3 lightDirection;

      vec3 LNorm     = normalize(lightDirection);
  vec3 normal    = normalize(IN.normal);
      vec3 calColour = lightColour[i].rgb  * intensity;
  gl_FragColor   = vec4(diffuse.rbg * calColour, diffuse.a);

It lights the entire scene.