texts: How to do lighting for endless runner game?

texts:
I have been working on a endless runner game for a month now and have to do basic lighting. In my game Player moves forward and world is being generated according to player position. So the positions of world is not fixed means I cannot have baked lights. Since Im not an artist and the game is for mobile so what should be the best approach to have a lighting setup for this type of game?

Also I have some 3D menu scenes like shop or character selection scene so I have setup baked light as shown in the picture below:

Kindly help for my endless runner scenes.


texts: Why my keyPressed method stops reacting to any key i press after i hold (W/A/S/D) for 1 or 2 seconds?

texts:
public class Testing extends JPanel{

    public void Action() {
        Timer t = new Timer();
        t.schedule(new TimerTask() {

            public void run() {
                if(move2==true) {
                    switch(direction2) {
                    case 1 : x-=2;
                    break;
                    case 2 : x+=2;
                    break;
                    case 3 : y-=2;
                    break;
                    case 4 : y+=2;
                    }
                }
                repaint();
            }

        }, 10, 20);
    }

    public void paint(Graphics g)
    {
        g.clearRect(0, 0, 526, 690);
        g.drawLine(x, y, x, y-30);
        g.drawLine(x+1, y, x+1, y-30);
        g.drawLine(x-1, y, x-1, y-30);

    }
    static boolean move2 = false;
    static int x = 200;
    static int y = 100;
    static int direction2 = 0;
    public static void main(String[] args) {
    JFrame f = new JFrame();
    Testing t = new Testing();
    f.setVisible(true);
    f.setSize(526,690);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLocationRelativeTo(null);
    f.setFocusable(true);
    f.add(t);
    t.Action();
    f.addKeyListener(new KeyListener() {

        public void keyTyped(KeyEvent e) {

        }
        public void keyPressed(KeyEvent e) {
            System.out.println("did");
            switch(e.getKeyCode()) {
            case KeyEvent.VK_A:
                move2 = true;
                direction2 = 1;

                break;
            case KeyEvent.VK_D:

                move2 = true;
                direction2 = 2;
                break;
            case KeyEvent.VK_W:

                move2 = true;
                direction2 = 3;
                break;
            case KeyEvent.VK_S:

                move2 = true;
                direction2 = 4;
                break;
            }

        }

        public void keyReleased(KeyEvent e) {
            switch(e.getKeyCode()){
            case KeyEvent.VK_A:move2 = false;
            break;
            case KeyEvent.VK_D:move2=false;
            break;
            case KeyEvent.VK_W:move2=false;
            break;
            case KeyEvent.VK_S:move2=false;
            }
        }
    });
    }

}


texts: Why does this exported cube have more vertices than I expected?

texts:
I'm trying to export md5mesh models. Just as a test I decided to export a simple cube (i.e. with 8 vertices). When I opened the md5mesh file it lists the following:

numverts 24
numtris 12
numweights 24

Obviously the number of triangles makes sense: 6 faces * 2 to triangulate = 12.

The model only has one bone so again it even makes sense that there is one weight for each vertex. The question is though, why is the file listing 24 vertices?

Is the problem the exporter or is this normal for md5mesh's? Is it something that you have to rectify when you come to parsing the file in engine? I don't want to be parsing or drawing duplicated vertices without reason.

I'm guessing it's something to do with shading and normals. Is it a case of listing each vert 3 times, one for each facing normal?


texts: How to I rotate a triangle by dragging the mouse in libGDX?

texts:
More specifically, I have rotation working in a way I don't like as follows:

    //Draw the triangle using this draw method
    //batch.draw(texture, x,                            y,                                          originX,                 originY,                                        width,               height,      scaleX, scaleY, rotation, srcX, srcY, srcWidth,   srcHeight, flipX, flipY)
    batch.draw(triangle, 240 - triangle.getWidth() / 2, (float) (400 - triangle.getWidth() * .289), triangle.getWidth() / 2, (float) ((double) triangle.getWidth() * 0.288), triangle.getWidth(), triangle.getHeight(), 1, 1, rotate, 0, 0, triangle.getWidth(), triangle.getHeight(), false, false);

    batch.end();

    //Touch input
    if(Gdx.input.isTouched()){
        Vector3 touchpos = new Vector3();
        touchpos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
        camera.unproject(touchpos);
        rotate = touchpos.x;
    }

This rotates the triangle around the center of the triangle that is at the center of the screen (the 0.289 corresponds to the height of the middle of an equilateral triangle according to its side length).

The rotation will be equal to the touch position on the screen which works great when the finger is dragged. However, what this code does is moves the rotation to the specific location whenever I touch the window with the mouse. What I would like it to do is to rotate the triangle when the mouse is dragged, but only based on its previous rotation, not its absolute rotation. For example, if I click and drag the mouse from the left side of the window to the right, the triangle will rotate accordingly. When I lift the mouse then click and drag it the same way a second time, I don't want it to reset it's position to my 2nd click, I want it to move the amount I dragged my mouse from it's previous rotation.

Can anyone help with this? I've been trying to wrap my head around it for hours. Let me know if you need any clarifications.


texts: Implement an action "while" touching event

texts:
I'm making a game using Xcode for iOS. This is a segment of code I have that makes the sprite jump up when the screen is tapped:

//tap/touch to jump (& play sound)
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *) event{
       [self playSound];
       jumpUp = 16;
}

It's pretty simple to achieve that, but how can I implement it so that the sprite just keeps going up whist you are touching the screen instead of just a single tap?

//Simple pseudo code:
while touchingScreen Event {
    jumpUp +=1;
}


texts: How can I make a hole in an object with Unity 3D? I've something like this object and I want to make a hole in it.


texts:
I was wondering if someone could explain to me how to implement a seemingly dynamic infinite map like the one at http://wordsquared.com/

My main issue is really generating new tiles in any direction when the user drag the board.

I'm also trying to figure out how to handle the coordinate system, and actually what/how to store the map in a database.


texts: iPhone app activated before associated in-app-purchase activated?

texts: I recently submitted my iPhone game for review.  I also approved the in-app-purchase for my game (and provided the in-app-purchase screenshot).  It's a few days later and the app status has been updated from "waiting for review" to "in review"... while the in-app-purchase status is still "waiting for review".  Could the app go live in the store before the in-app-purchase?  If so what happens when the user tries to make the in-app-purchase?  Anything the developer can do to remedy this?


texts: How to prevent fish eye effect when using CCOrbitCamera in Cocos2D?

texts:
Note: I'm using CocosSharp, a Xamarin C# version but the question is valid for all Cocos2D versions I presume. I'm also fine with answers in any Cocos2D dialect (there is no tag yet for CocosSharp here).

I'm trying to create a card flip animation using CCOrbitCamera. This works pretty well with the code below - unless the sprite ist not in the center of the screen.

var animateInFirstHalf = new CCOrbitCamera(animDurationSeconds, 1, 0, 0, 90f, 0, 0);

My idea is to flip the card 90 degrees, then exchange the texture, and flip further. At 90 degrees the only thing that's visible is a thin line if the sprite is centered. If it is out of the center, it looks something like this:

The picture is from a blog post where the issue was solved by faking the animation with skew and scale. However I wonder if it is possible to somehow run the animation as if the sprite was centered? Something like virtually translating it to the center.


texts: Move to specified coords - libgdx and java

texts:
So I am making my bullets go to a point and travel further. Only its acting really really weird. Its like its thinking that the 0,0 location is at the top left instead of the bottom left.

This is the code:

float speed = 100;

    Vector2 direction;
    Vector2 thisPos = new Vector2(getX(), getY());
    Vector2 mousePos;

    public Bullet(){
        super();
        setSprite(sprite);
        setX(0); setY(0);
        float dx = Gdx.input.getX() - getX();
        float dy = Gdx.input.getY() - getY();
        mousePos = new Vector2(Gdx.input.getX(), Gdx.input.getY());
        direction = new Vector2(dx, dy);
        //sprite.setRotation(direction.angle(thisPos));
        direction.nor();
    }

    public void update(){
        Vector2 dirAd = new Vector2(direction);
        thisPos.x += dirAd.x * speed * Gdx.graphics.getDeltaTime();
        thisPos.y += dirAd.y * speed * Gdx.graphics.getDeltaTime();
        setPosition(thisPos.x, thisPos.y);
        super.update();
    }

I hope someone can help me what I did wrong with this.


texts: Can I remove Unreal Engine Splash Screen and put my own?

texts:
In Unity, I can change the splash screen if I buy the Pro version.

Can I do the same with Unreal?


texts: Unity InputSystem using Unity Events not maintaining values

texts:
I am testing out using the new Input System and cannot get the values from context.ReadValue<Vector2>() to pass into a private variable.
The simple setup is below:
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
    Vector2 leftThumbstickValues;

    void Start()
    {
        leftThumbstickValues = Vector2.zero;
    }

    void FixedUpdate()
    {
        Debug.Log("FixedUpdate: " + leftThumbstickValues); //Always displays "FixedUpdate: (0.0, 0.0)"
    }

    public void Move(InputAction.CallbackContext context)
    {
        leftThumbstickValues = context.ReadValue<Vector2>();
        Debug.Log("Move: " + leftThumbstickValues); //Displays correct values
    }
}

As you can see, in the Move function it correctly pulls the values from the thumbstick, but when it tries to use the values in FixedUpdate it always equals Vector2.zero. It seems like it should just work, but I think I must have overlooked something very simple.
Player Input Settings

Input Action Move Properties

Input Action Left Stick Properties

EDIT: I decided to remove the Player Input component and subscribe to the events in code:
 controls.Player.Move.performed += cntxt =>
 {
     Move(cntxt);
 };
 controls.Player.Move.canceled += cntxt =>
 {
     leftThumbstickValues = Vector2.zero;
 };

This now works as expected. I'm not sure I should mark this as the answer though as it doesn't explain why it doesn't work with the original setup, just offers an alternative solution.


texts: How to correctly Dispose a SourceVoice once its finished

texts:
i am starting to play a sound with XAudio2 and SourceVoice and once its finished, it should be correctly disposed to not have any leaks.

i was expecting it to be something like this:

        sourceVoice.Start();
        sourceVoice.StreamEnd += delegate
            {
                if (!sourceVoice.IsDisposed)
                {
                    sourceVoice.DestroyVoice();
                    sourceVoice.Dispose();
                }
            };

but that crashes with a read access violation in native code deep in XAudio2.dll which i cant debug.


texts: Should I care about CPU affinity of threads?

texts:
I am currently developing a rendering engine, which I plan to use for creating games. The engine makes heavy use of multithreading; I have a thread for OpenGL rendering, a thread for updating, a thread for processing user input, a thread for audio, etc. I have heavily tested it, and the threads work like clockwork. The multithreading approach has shown to be faster, more robust and flexible on a multicore processor, which I verified by profiling.

However, something which I have not considered is CPU-core affinity for threads. Should I care about it? What benefits does pinning threads provide, and to which CPU core do I pin which thread?


texts: how to create a curve movement of slider in unity

texts:
I am trying to create a curved (not circular) movement of slider. Here is my demo images for reference:

I have watched some tutorial but those are for circle images. I want to make this movement along the arrow images below car. Also if this can be done with just images without using slider that will be ok too. I just this done the simpler and easy way.


texts:
I came across the following code in a game book but I can't get it, does it check if a point (left, top) in a rectangle?

bool CheckCollision(float left, float top,  float SpriteX, float SpriteWidth, float SpriteY, float SpriteHeight)
{
    return !((left >SpriteX + SpriteWidth) ||
            (top > SpriteY + SpriteHeight) ||
            (SpriteX > left + SpriteWidth) ||
            (SpriteY> top +SpriteHeight));

}


texts: Best algorithm for different shapes maze

texts:
Based off my previous question here Maze or puzzle algorithm for something similar to noodles are there specific algorithms that would be best suited to building a maze with only 1 solution for

A grid made of squares.
A grid made from hexagonal tiles

Thanks


texts:
I'm working on a programming project, in this project I'm receiving an angle as a quaternion value, I partially understand how they work but I don't find any math to get the values I need.
What I would need is the angle between a fictional line/vector going to the the quaternion point from the origin (yes I know what you are thinking, but I couldn't think of a better explanation) and the "earth" a plane that is perpendicular to the gravitational vector, in this case one of your planes of reference.
Also I would need to get the rotation of the line/vector, this time the rotation should be according to the plane perpendicular to itself.
If possible all angles should be described as an angle between -180° and 180° (that's were my troubles are from.

In this picture γ complementary angle of the first questing and R is the secondary angle.
Angles

PS: This is the last formula I tried to use.


texts: Best way to manage weapons as GameObject on a script in Unity with C#

texts:
I have a player game-object with a script Player. In the Player script I have a public properties weapons.

I want to have to just drag in this properties a script/prefabs. And the Player script must can get the properties of the weapons selected.

For example: imagine, we have two weapons, one is a pistol with 5 attack power, the other is a knife with 7 attack power.

Now I want to set pistol in the Player script.

What should I drag here ? A game-object with a weapon script ? Or a weapons script who instantiate a weapon ? Or maybe an another solution ...

The idea is to be able to create easily some weapons without scripting more. Just place a sprite, and modify some properties.


texts: Phaser/HTML5 - Trying to add five instances to a group and display on the screen!

texts:
just started using Phaser today after seeing Thomas Palef's lessmilk series. I completed PhotonStorm's "Make your first Phaser game" tutorial, and grabbed the skeleton, some CSS, and started to throw together a game. It's pretty barebones right now, but this is what I have.

The issue is that the game doesn't display the additional "orc" units I've requested. I used a for loop to throw five orcs around the map within the specified borders (32 pixels from the outside boundary. I even wrote a check for the x and y of each in the Update() function, but they don't appear at all.

I don't know how to move on from where I am, and I'm not sure that any of what I've written has been written the right way, you know what I'm saying? Thanks.

http://pastebin.com/if2VTq7j


texts:
I have a tile map that I would like to be able to move while playing the game. In the code you will see the posX and posY variables. I used these variables so that when I complete this, I can have the player control movement via the map like in early Final Fantasy games(1-6). The problem is that it is currently not rendering. It was rendering just fine when I was using the x and y variables from the loop, but I need to be able to move the map around, and I don't know how I would achieve this using the loop variables. I debugged the file and all the variables were updating correctly, so I don't know why it's not rendering in the correct place.

public class TileMapEditor
{
   BufferedImage[] tiles = new BufferedImage[19];

   //array of tile types
   int[][] map = new int[32][32];
   //position coordinates
   public static int posX, posY;

   public TileMapEditor(int posX, int posY) throws IOException
   {
       int x = 0, y = 0;
       this.posX = posX;
       this.posY = posY;
       BufferedReader in = new BufferedReader(new FileReader("res/tileMap2.txt"));

       String line;

       while((line = in.readLine()) != null)
       {
           String[] values = line.split(",");

           for(String str : values)
           {
               int str_int = Integer.parseInt(str);
               map[x][y] = str_int;
               System.out.print(map[x][y] + " ");
               y += 1;
           }
           System.out.println("");
           x += 1;
           y = 0;
       }

       in.close();
   }

   public void update()
   {
   }

   public void render(Graphics g)
   {
       for(int x = 0; x < 32; x++)
       {
           for(int y = 0; y < 32; y++)
           {
               int textureType = map[x][y];
               BufferedImage texture = tiles[textureType];
               setTile();
               g.drawImage(texture, posX * 32, posY * 32, null);
               posY += 32;
           }
           posX += 32;
           posY = -Game.HEIGHT / 2;
       }
   }

   public void setTile()
   {
       tiles[0] = Assets.grass;
       tiles[1] = Assets.dirt;
       tiles[2] = Assets.water;
       tiles[3] = Assets.tree;
       tiles[4] = Assets.multiTree;
       tiles[5] = Assets.NSpath;
       tiles[6] = Assets.uprtPath;
       tiles[7] = Assets.EWpath;
       tiles[8] = Assets.upltPath;
       tiles[9] = Assets.dnltPath;
       tiles[10] = Assets.dnrtPath;
       tiles[11] = Assets.watgrsdn;
       tiles[12] = Assets.watgrslt;
       tiles[13] = Assets.watgrsup;
       tiles[14] = Assets.watgrsrt;
       tiles[15] = Assets.watgrsSE;
       tiles[16] = Assets.watgrsSW;
       tiles[17] = Assets.watgrsNW;
       tiles[18] = Assets.watgrsNE;
   }

}


texts: What role does developing with events have in games?

texts:
Most application development is based around developing with events, but considering the game-loop style of developing games and the (often) need for high performance/throughput, what role does developing using events have and what are the trade-offs? Does the synchronization/locking that is often involved have a greater impact?

For instance:
- How does the network [layer] notify the game-loop of data received?
- How does the physics system notify of collisions

I ask, because I can remember a time when game development using events was a strict no-no. Has this changed?


texts: Unreal Engine - Scaleform - How do I capture a button click event?

texts:
I'm new to Unreal Development.

In a nutshell, how do I create a button, install it in a basic game, and capture the button click event?


texts: 2D Rectangle/Circle Continuous Collision Detection

texts:
I'm looking for a fast 2D continuous collision detection algorithm for circles and rotated rects.  It needs to determine the time of collision. Both shapes may be moving at high speed, so the algorithm should not assume that one is stationary.

What I found so far (what I'm not looking for):

I've found several tutorials for swept tests for AABB's, but these all involved axis-aligned (not rotated) rects.
I've found and implemented a separating axis theorem (SAT) algorithm to determine if rotated rects are intersecting with other rects or circles, but obviously that is not continuous.
I'm not looking for reduced-time-interval-based tests here; the objects' speeds are potentially very high so that kind of inelegant solution is impractical due to computational costs.

What I already have:

I already have continuous collision detection between circles implemented  (Small, High-Speed Object Collisions: Avoiding Tunneling).  Now I just need the circle/rect and rect/rect versions.
As I said above, I also already have the SAT implemented to detect circle/rect and rect/rect intersection (but obviously that's not continuous).

Thank you very much for your time and help!

Edit: I'm not worried about rotational velocity over the space of a frame.


texts:
I am trying to embed Unity WebGL to a web page.

I wonder, is it possible to make this responsive, so it will always fit whatever the screen size? How to do that?

Thank you for answering.


texts: Switching from software Engineer to Game developer

texts:
I don't know if this is the right place to ask this.

I've been working as a software engineer for 3.5 years so far, mostly web apps, mobile apps, web pages in banking systems, educational, etc but I always wanted to work as a game developer.

Currently I have a university degree in CS, and I'm attending a masters degree in Apps design.

I've very little experience in game dev (only for hobby), some space shooters and some steps in unity, also I took some courses of blender, and did some simple sprites (those 8 bit characters but animate them is a big problem for me atm.) but I've never gone too far.

I know I cannot focus on all aspects of game development, because it is a huge world integrated with different disciplines, but I need to make a portfolio with some of my games at least. (I only have partial prototypes, some of them work, some don't...)

I need some advise of people who are in the game business.

Which platform/framework do you recommend for me ? I already know a bit of Unity and I feel pretty comfortable with it. I can get some assets to work with (models/audio, etc), there are some free material in the store, and I have budget to spend on that too if necessary.
How do game companies hire people? What am I suppose to aim for a job? I mean this is a world full of disciplines and I need to focus in something particular I guess, I'm a senior frontend developer too, so I guess I should focus on coding. I think portfolio is the best way of showing your work.

Any suggestions are welcome! thanks!


texts:
I am not sure if this is the right site to put this question on.

What would be a good, time saving method to reference an AABB with an integer id in Java programming language?

AABB class:

public class AABB {
private EndPoint[] min = new EndPoint[3];
private EndPoint[] max = new EndPoint[3];
private int entityId = 0;
private Boolean isStatic = false;
private static Map<Integer, AABB> table = new HashMap<>();
private Vector3f pos;
private int id = 0;

public AABB(Vector3f min,Vector3f max,Vector3f pos,int entityId,Boolean isStatic) {
    this.min[0] = new EndPoint(true,pos.x - min.x,id);
    this.min[1] = new EndPoint(true,pos.y - min.y,id);
    this.min[2] = new EndPoint(true,pos.z - min.z,id);

    this.max[0] = new EndPoint(false, pos.x + max.x,id);
    this.max[1] = new EndPoint(false,pos.y + max.y,id);
    this.max[2] = new EndPoint(false,pos.z + max.z,id);
    this.pos = pos;
    this.entityId = entityId;
    this.id = UniqueIdentifier.nextInt();
    this.isStatic = isStatic;
}
public static AABB setAABB(AABB aabb) {
    return table.put(Integer.valueOf(aabb.getId()), aabb);
}

public static AABB getAABB(int id) {
    return table.get(Integer.valueOf(id));

}

public static AABB getAABB(EndPoint endpoint) {
    return getAABB(endpoint.getId());

}

@Override
public boolean equals(Object arg0) {
    if(arg0 == this) {
        return true;
    }
    if((arg0 == null) || !(arg0 instanceof AABB)) {
        return false;
    }

    AABB aabb = null;
    try {
        aabb = (AABB) arg0;
    } catch (ClassCastException e) {
        return false;
    }

    return ((aabb.getMax() == getMax()) && (aabb.getMin() == getMin()) && (aabb.isStatic() == isStatic || aabb.isStatic().equals(isStatic())) && (aabb.getPos() == getPos()) && (aabb.getId() == getId()) && (aabb.getEntityId() == getEntityId()));

}

@Override
public int hashCode() {
    int hash = 17;
    hash += 5 * ((Boolean) isStatic).hashCode();
    hash += 5 * ( min == null ? 0 : min.hashCode());
    hash += 5 * ( max == null ? 0 : max.hashCode());
    hash += 5 * ( pos == null ? 0 : pos.hashCode());
    hash += 5 * id;
    hash += 5 * entityId;
    return hash;
}

}

SAP class:

 public class SAP {
public static List<EndPoint> xaxis = new ArrayList<>();
public static List<EndPoint> yaxis = new ArrayList<>();
public static List<EndPoint> zaxis = new ArrayList<>();
private SAP() {}

public static void addObject(AABB aabb) {
    if(!PairManager.isInPairs(aabb)) {
        xaxis.add(aabb.getMax()[0]);
        xaxis.add(aabb.getMin()[0]);

        yaxis.add(aabb.getMax()[1]);
        yaxis.add(aabb.getMin()[1]);

        zaxis.add(aabb.getMax()[2]);
        zaxis.add(aabb.getMin()[2]);

                    // Where i set table
        AABB.setAABB(aabb);
    }
}

private static boolean  intersects(AABB a,AABB b, int axis)
{
            // Where exeption is thrown a and b == null
    return !(a.getMax()[axis].getValue() < b.getMin()[axis].getValue() || b.getMax()[axis].getValue() < a.getMin()[axis].getValue());
}

private static boolean intersects(AABB a,AABB b) {
    return intersects(a,b,0) && intersects(a,b,1) && intersects(a,b,2);
}

}


texts: Examples of 2D side-scrollers that achieve open non-linear feel?

texts:
I'm working on a 2.5D platformer prototype that aims for an open feel while maintaining familiar core mechanics.

Now, there's some obvious challenges with creating a non constricted feel in a spatially constricted environment. What I'm interested in, is examples of how game designers deal with the "here's a level, beat the bad guys/puzzles to get to the next level" design that seems so natural to most platformers (eg. Mario/Braid/Pid/Meat Boy to name a few).

Some ideas for achieving openness I've come across include:

One obvious successful example is Terraria, which achieves openness simply through complexity and flexibility of the game-system
Another example that comes to mind is Cave Story. Game is non-linear, offers multiple choices and side-stories
Mario, Rayman and some other 'classics' with a top-down level selection. I actually really dislike this as it never did anything for me emotionally and just seems like a bit of a lazy way to do things.

Note: I've not actually had much experience with most of the 'classical' console platformers, apart from the obvious Marios/Zeldas/Metroids, since I've grown up on adventure games. By that I mean, it's entirely possible that I simply missed some games that solve the problem really well and are by some considered obvious 'classics'.


texts: Do game testers have to live locally to be considered?

texts: I've been told by a few former game testers that you must live in their city because game testing has few educational requirements so it's easier to hire someone local. Some descriptions say "you must live in or near (insert city)". Some won't tell you this until you get on the phone with them.


texts: Widget button hover event works but not click

texts:
This is my first time making a widget and I'm trying to make a super simple one, just a button. However, when I attach the widget to an actor and try to press it, it doesn't register any click events but it does register hover events and responds to those.
I have my widget blueprint which looks like this:

I then have the mouse events set up like so:

In my scene I just attached a widget component to an empty actor:

And lastly I added a WidgetInteraction component to my player:

Now when I hit play and test it out, I get the hovered message but I can never get the click message when I click on the button and I'm not sure why.


texts:
Hi i'd just like to preface this by saying i'm new to game development and currently learning the ins and outs of libGDX.

I want to create the board game scrabble however i'm having trouble figuring out how i would display the board and the pieces each player has.

So in my game the board will probably be 14x14 , each player (4 maximum) at the start of the game will have about 6 letter tiles in their hand. The player whos turn it is , is able to place letter tiles from their hand onto the board and do so until a word is spelt on the board. The player should also be able to pick up individual letter tiles that they have placed down.

From searching on the internet I figured out that i should probably make the board a 2d array of either actors or buttons. For example, the player would click on the letter tile and then click on the board and the tile would be placed. However, as there is limited information online about libGDX in the form of tutorials I do not have a complete solid understanding of this. If anyone could help me understand how I would go about implementing my ideas i'd really appreciate it.


texts: How do I check to see if a tile corner is visible in 2d space?

texts:
I am trying to implement fog of war, and I have run into trouble. I want to check to see if the player is able to see the corners of each tile within a certain radius, however I am unsure how to check if the vision of the corners is to be obstructed or not. Is there a quick way to do this? I used a system of drawing a line and checking if the tiles the line is on are solid blocks in a rougelike, but I am unsure if this method would be suitable, as it is possible to see parts of a tile, unlike in a rougelike where it's a yes or no type thing.

For example, the black tile is obstructing the view partially of the white tile.

The red lines signify that the player is able to see the corner, while the blue signifies they can't (as the black obstructs it).


texts: Obtain rectangle indicating 2D world space camera can see

texts:
I have a 2D tile based game in XNA, with a moveable camera that can scroll around and zoom.

I'm trying to obtain a rectangle which indicates the area, in world space, that my camera is looking at, so I can render anything this rectangle intersects with (currently, everything is rendered).

So, I'm drawing the world like this:

  _SpriteBatch.Begin(
                SpriteSortMode.FrontToBack,
                null,
                SamplerState.PointClamp,        // Don't smooth
                null, null, null,
                _Camera.GetTransformation());

The GetTransformation() method on my Camera object does this:

    public Matrix GetTransformation()
    {
        _transform =
           Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) *
           Matrix.CreateRotationZ(Rotation) *
           Matrix.CreateScale(new Vector3(Zoom, Zoom, 1)) *
           Matrix.CreateTranslation(new Vector3(_viewportWidth * 0.5f,
               _viewportHeight * 0.5f, 0));
        return _transform;
    }

The camera properties in the method above should be self explanatory.

How can I get a rectangle indicating what the camera is looking at in world space?


texts: Blender export does not render correctly in Monogame

texts:
I am using Monogame 3.7.0.7 on Linux and Blender.

I have exported my model using the "FBX 7.4 Binary" exporter. Here is a render from Blender:

However, when rendered by Monogame, it does not look right:

My render code is very standard (F#)

    let model = this.Content.Load<Model> @"Skull"

    for mesh in model.Meshes do
      for effect in mesh.Effects do
        match effect with
        | :? BasicEffect as effect ->
          effect.EnableDefaultLighting ()
          effect.TextureEnabled <- true
          effect.PreferPerPixelLighting <- true

          effect.World <-
            Matrix.CreateScale (16.0f) *
            Matrix.CreateTranslation (Vector3.Up * 32.0f + Vector3.Backward * 128.0f)

          effect.View <- view
          effect.Projection <- projection
        | _ -> ()

      mesh.Draw ()

How should I export models from Blender for use in Monogame?


texts: How can I use websockets in a Unity WebGL project?

texts:
There are plenty of good Websocket APIs for C#, but I run into trouble when targeting Unity WebGL due to this restriction described in the Unity documentation:

  No direct socket access

  Due to security implications, JavaScript code does not have direct access to IP Sockets to implement network connectivity. As a result, the .NET networking
   classes (ie, everything in the System.Net namespace, particularly System.Net.Sockets) are non-functional in WebGL. The same applies to Unity’s old UnityEngine.Network* classes, which are not available when building for WebGL.

  If you need to use Networking in WebGL, you currently have the options to use the WWW or UnityWebRequest classes in Unity or the new Unity Networking features which support WebGL, or to implement your own networking using WebSockets or WebRTC in JavaScript.

How can I work around this restriction for networking in my Unity WebGL game?


texts: Why does texture-sampling only work at (0,0,0)?

texts:
I want to save the color of every point of one object in the RWTexture3D(UAV Resource) and transfer them to another object in its shader.

I made a test in the two shaders. Both in the fragment shader.

In first shader, I gave

RWTexture3D<float4> gUAVColor;
gUAVColor[uint3(0,0,0)] = float4(1.0f,0.0f,0.0f,1.0f);

In second shader:

Texture3D<float4> gVoxelList;
float4 output = gVoxelList.SampleLevel(SVOFilter, uint3(0,0,0),0);

The result is correct, I got red as the result.

But when I change the code, the texture cant be sampled correctly.

In first shader, I gave

RWTexture3D<float4> gUAVColor;
gUAVColor[uint3(1,0,0)] = float4(1.0f,0.0f,0.0f,1.0f);

In second shader:

Texture3D<float4> gVoxelList;
float4 output = gVoxelList.SampleLevel(SVOFilter, uint3(1,0,0),0);

I only changed the pos which save the red color from uint(0,0,0) to uint(1,0,0), but what I got changed to black, which means it's uncorrect.

If I use gVoxelList[uint(1,0,0)].xyz ,it works.

I have no idea where the mistake will be.


texts: How to make shake effect on camera in LibGDX?

texts: I want to shake my OrhographicCamera on some event (i.e. click on the keyboard). How can I do that?


texts: Drawing pixels with SDL2 advice, is it fine to draw them one by one on the CPU?

texts:
I want to make a raycaster and I figured out how to open a window and draw pixels to it with SDL2, but the way I am doing it now just doesn't seem very efficient, I figured out how to do it from briefly reading the documentation.
For every pixel in the window, I am going through them one by one, setting the render color with SDL_SetRenderDrawColor(), then drawing the pixel with SDL_RenderDrawPoint() based on an array. It's surprisingly fast doing this but is there some way I can send like a pixel buffer to the GPU or something?
I see there is a SDL_RenderDrawPoints (plural version) function but it only takes positions, meaning all the pixels drawn with it would be the same color? I'm looking for a similar function but either it also takes the color data too or it is just a buffer of color data and its index determines its position. Rendering a bunch of pixels that are all the same color doesn't seem very useful to me.
I later tested it by fading between colors and with window sizes of more than 600 x 400 the performance is horrible with my method, with 1200 x 800 it is like 5fps.


texts:
With Metal, I need to pass in an array of primitives to the GPU to be rendered. I'm making a terrain-based voxel game like Minecraft, but I have a problem.
foring through all of the visible voxels, and in each processing the list of block IDs and Metadata into a list of primitives for rendering is asinine, because I imagine obtaining primitives from raw block data being an expensive process. Surely there's a better way.
Given that you cannot duplicate or cull vertices and planes on the fly on the GPU, doing this in the vertex shader is out of the question. My problem is when or how translate raw block data into a list of primitives ready for the GPU to apply 3D projections to it.
It would definitely be a good idea to maintain the already-processed primitive lists, and only update them when a block updates. However, maintaining these is tricky. Maintaining them one block at a time is very messy, but one voxel at a time would require stitching them together prior to rendering.
This is the foundation of a block sandbox game like Minecraft. Without it I can't progress to gameplay mechanics. My game manages voxel data with a C++ style map, of 3 dimensional arrays of 16 by 16 by 16 4-byte blocks. I simply need to know where, when, and how the process of obtaining primitives from raw block data should take place. How do most games do it?
It's also worth noting that I'm using Metal, a game framework, rather than a game engine, so if game engines generally abstract away this process and therefore this question seems nonsensical, I'm not using a game engine, I'm using a game framework.


texts: Need to produce an animated texture of Water where each image tiles in all directions

texts:
I need to produce a 2D 'animated' texture of "water" for a game in which each image tiles in 'all' directions, much like those produced by the Caustics Generator, but with the power and flexibility of something the likes of Blender.

The final result from Caustics Generator is 32 images that are actually animated such that when the full 32 images are played in a loop they will seamlessly loop forever. They will not only loop in time, but each image also tile in all directions. This is nice, but it comes in only one flavor so to speak.

I'd like to accomplish the same thing with a Blender type tool, and I have actually gotten to the point where I generate the X number of images, but they do not tile in 'all' directions, nor are they slightly animated. I've tried Blender texture animations using offsets but with only limited success.

Does anyone know of how to (or of a tool) which will animate textures such that they tile in all (4) directions?

Many thanks in advance ....


texts: How to render a large number of colored dots in 3d space?

texts:
I would like to create a game similar to Scanner Sombre. The player is in a dark environment and can't see their surrounding unless they use a scanner. That scanner sends out rays which mark little dots on all surfaces, creating 3D map of environment.

I tried to just paint visible dots on transparent textures, but that does not work because the dots are supposed to always face the player.

I considered to instantiate a new game object for every single dot. But as the game progress, the player will see billions of these dots at once, and that would likely be terrible in terms of performance. Can someone suggest a possible technique to do this?


texts: How do I make function on user clicked on close button Ads reward?

texts:
So I'm here want to make function when the user closed the Ads before video ads end, the function is stopping or revert, in this case, I'm using ienumerator methods, but I don't know how to add the handler on Ads, because I already using HandleRewardClosed method not like I want but because its same with user watch the vid till end not closed the videos before ended .
    public void loadRewardVideo()
    {
        rewardedAd.LoadAd(new AdRequest.Builder().Build(), rewarded_Ad_ID);

        rewardedAd.OnAdLoaded += HandleRewardedAdLoaded;
        rewardedAd.OnAdClosed += HandleRewardedAdClosed;
        rewardedAd.OnAdOpening += HandleRewardedAdOpening;
        rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad;
        rewardedAd.OnAdRewarded += HandleUserEarnedReward;
        rewardedAd.OnAdLeavingApplication += HandleOnRewardAdleavingApp;

    }

    /// rewarded video events //////////////////////////////////////////////

    public event EventHandler<EventArgs> OnAdLoaded;

    public event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad;

    public event EventHandler<EventArgs> OnAdOpening;

    public event EventHandler<EventArgs> OnAdStarted;

    public event EventHandler<EventArgs> OnAdClosed;

    public event EventHandler<Reward> OnAdRewarded;

    public event EventHandler<EventArgs> OnAdLeavingApplication;

    public event EventHandler<EventArgs> OnAdCompleted;

    /// Rewared events //////////////////////////

    public void HandleRewardedAdLoaded(object sender, EventArgs args)
    {
        Debug.Log("Video Loaded");
    }

    public void HandleRewardedAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
    {
        Debug.Log("Video not loaded");
    }

    public void HandleRewardedAdOpening(object sender, EventArgs args)
    {
        Debug.Log("Video Loading");
    }

    public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args)
    {
        Debug.Log("Video Loading failed");
    }

    public void HandleRewardedAdClosed(object sender, EventArgs args)
    {
        Debug.Log("Video Loading failed");

        StartCoroutine(ClosedAds());
    }

    IEnumerator ClosedAds()
    {
        _GameManager.instance.isGameOver = true;
        yield return new WaitForSeconds(.05f);
        _GameManager.instance.isStarted = false;

        Time.timeScale = 0;

        _FirebaseRemoteConfig.instance.DisplayAds();

        _GameManager.instance.ShowingGameOverPanel();

        _GameManager.instance.pauseBtn.SetActive(false);
    }
```


texts: How do I get my fish to face the right way?

texts:
I'm making this 2d collecting game in Unity where you collect fish. However I can't get them to face the direction they are going. I've asked on some Discords and got no answer. Thanks in advance.
Here's is the video of the fish.
And here's the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    public float minY;
    public float maxY;
    public float minX;
    public float maxX;
    public float speed;
    public float maxZ;
    Vector2 targetPosition;

    // Start is called before the first frame update
    void Start()
    {
        targetPosition = GetRandomPosition();
    }

    // Update is called once per frame
    void Update()
    {
        if ((Vector2)transform.position != targetPosition)
        {
            transform.right = (Vector2)targetPosition;
            transform.position = Vector2.MoveTowards(transform.position, targetPosition, speed * Time.deltaTime);

        } else {
            targetPosition = GetRandomPosition();
        }
    }

    Vector2 GetRandomPosition()
    {
      float randomX = Random.Range(minX, maxX);
      float randomY = Random.Range(minY, maxY);
      return new Vector2(randomX, randomY);
    }
}


texts:
I am designing a Spritebatch class, for static and dynamic objects with WebGL.
A problem I'm facing is that I have read several different opinions on sprite batching but with one goal.

Put all vertices in one buffer and render them

So in WebGL I'm using gl.bufferData(....,new Float32Array(size), gl.STEAM_DRAW).

And here is my first problem: when the spritebatch should be dynamic then size is not fixed and will increase, which leads to recreating the Float32Array which I found out is very expensive for n ≥ 10000 (at least on my machine).

Second Problem, let's say I give the Float32Array(maxElements) a maximum size, and I add 4 Sprites then I have allocated much more than I actually need.

Other way: I create Spritebatch when I know how many sprites I have. So basically I put 4 Sprites into my scene, then before rendering I create a Spritebatch with size 4 * numVerticesPerSprite. However let's say I want to update Sprite 2, I need some kind of index structure in my Spritebatch class to identify at which position the vertices of Sprite 2 are stored inside the SpriteBatch (inside Float32Array()).

So my question is :

How is a dynamic Spritebatch supposed to work and can you think of an indexing method to identify Sprite X's vertices inside the Float32Array to update/remove them? (Additionally: Do particle systems solve what i am looking for? I assume they are also some kind of sprite batching)


texts:
I was going through this tutorial for having transparency which can be used to solve my problem here. The code is written in XNA 3 but I'm using XNA 4.

What is the alternative for the following code in XNA 4?

device.RenderState.AlphaTestEnable = true;
device.RenderState.AlphaFunction = CompareFunction.GreaterEqual;
device.RenderState.ReferenceAlpha = 200;
device.RenderState.DepthBufferWriteEnable = false;

I searched a lot but didn't find anything useful.


texts: Font rendering, how do you align glyphs of a font?

texts:
I'm trying to render text quad using texture generate by BitmapFontWriter of libgdx.
For the font I can get size, PaddingTop, PaddingRight, PaddingBottom, PaddingLeft, LineHeight, CapHeight, Baseline, Ascent, Descent.

For each glyph I can get u, v, width, height, x offset, y offset, x advance

The chars rendered are OPQZ[\\]^_`abcdefg你好,. If I just render the quad. I get:

Q, g and the `are definitely incorrect. The brackets and notdef are a little large.
The only thing that I find meaningful for me is y offset. If I shift the quad with it, I get:

Q is not changed at all. g gets slightly better. Lots of them get worse.


texts: Establishing if a tile is available to move into

texts:
I'm working on a grid-based game as a hobby project. Think of an ANSI game like ZZT. The grid is represented by a two-dimensional array of objects which contain both the UI element which takes care of displaying the sprite image and also the data accompanying whatever is in that position on the grid. I'm having trouble working out the mechanics of elements on the game grid determining whether they are able to move into a neighbouring cell.

Determining whether there is something in any given grid position is straightforward, as each instance of the class representing a cell on the grid has a property representing the sprite in occupation of the cell. Checking if this property is nil works fine in establishing if something static is there, but it becomes problematic if there are many objects moving from one grid position to another. The problems I'm having are:

Objects in grid cells will attempt to push objects out of their destination cell; this is intended behaviour, so that the player or NPCs can move objects around. The object which is pushed will check if it is capable of moving in that direction, and if the cell into which it is being asked to move already contains another object. If it does, it will attempt to push that object, and so on and so on until an object either agrees to be pushed (into an empty spot), or refuses (because there is nowhere for it to move or because it cannot move in that direction). The return values for the attempt to push will then cascade back up to the originating object and the sprites all move (or not). This causes a problem, however, if there are several sprites moving in a straight line in the same direction. Rather than all moving forwards together (which they should), the last object in the line thinks that the next cell is occupied so tries to push the object in that cell, which is unnecessary, because that object will be moving anyway. This causes the objects to spread out with gaps between them, which is abnormal.
Due to this, I considered having the objects check if the destination cell is occupied, and if so, check if the object in that cell will be moving out, and if anything else will be moving in. However, I'm concerned this could result in a condition where several objects may refuse to move because of each other's presence.

I have considered looking at source code for a similar game, but I don't want to copy another implementation, rather I'm looking for guidance on how I can solve the problem. Thanks in advance!


texts: How long should interpolation last in multiplayer game?

texts:
I'm making a multiplayer game. Server is sending update packets 20x per second, that contain players positions, velocities and other important data. I want to interpolate between current and updated positions, so that it feels smooth. I know linear interpolation formula.

My question is: how long should such an interpolation last? Is it 50ms, 2 frames or what?


texts: Algorithm for procedureral 2D map with connected paths

texts:
Problem to solve: Generate a random 2D dungeon map for a tile-based game where all rooms are connected.

I am looking for better solutions than what I currently have.

My current solution is that I run two algorithms. The first generates the dungeon with its rooms. The second make sure that all rooms are connected. I am curious what other soltions may exist. Faster and / or easier etc. Speed is not really a concern, but if speed can be gained at no real cost, well, that is a good thing. More important is that I, and others that read, may learn different ways to approach and solve the problem.

Below are my current implementation. Rooms currently have no exits or exits in any 2, 3 or 4 directions.

Generating the dungeon rooms

Setup: Set the current room to the top left room.

Get a valid room type for the room (where valid room type is a type with no exits out of the dungeon and that have exits that matches the exits of the room above and the room to the left. Only need to check above and to the left due to step 2 below).
Put down the room and advance the x-coordinate one step. If the x-coordinate exceeds the dungeon width, set the x-coordinate to 0 and advance the y-coordinate one step. If the y-coordinate exceeds the dungeon height, we are done.
Repeat from #1.

I then check to see if all rooms are connected If they are not all connected I run a second algorithm that, in a non-sexy but definately good enough way in terms of dungeon layout, goes through the rooms and change them so that all end up being connected.

Checking to see if all rooms are connected

Setup: Create a 2D map of integers representing paths and initialize the entries to a "unprocessed" (not yet traversed) value, -1. Set a start path index integer that keeps track of the current path to 1. Set the current room to the top left room by adding it to a stack of rooms to check.

If the stack contains rooms to check, pop it set the path index of the room to the current path index. If the stack does not contain any rooms, increase the path index and try to get a room by advancing column by column, row by row, until we get a room that has not been processed yet. If no room can be found, we are done.
Check to see if the room has an exit to the left. If it has add the left room to the stack if it is not already on there.
Repeat step 2 for down, right and top directions (since we are using a stack that means the rooms are traversed in clockwise order, starting with the top direction).
Repeat from step 1.
If the path indices count is greater than one, there are disconnected rooms.

If there are disconnected rooms I then group the rooms by their path index, get the index of the biggest path and connect all other rooms to those rooms. This is a work in progress, but my (current, "brutish") plan is to go through each room in a room group (except the first) check to see if there is a horizontal or vertical path to the biggeset room group, and if so, create a horizontal / vertical path there by injecting / updating the rooms inbetween. Rinse and repeat. Ugly, yes, but it is something that will not be noticable in terms of visual pattern so it works in that sense.


texts: Methods to remove horizontal world slices of voxels in a 3D voxel world

texts:
I've recently been working on a hobby voxel world recently.

I'm currently interested in ideas or solutions which would enable me to basically step up and down the Y-axis 1 horizontal block slice at a time, effectively making all upper horizontal slices transparent so that I can see objects/terrain/units under the earth.

[A quick visual attempt at describing the problem]

I've done a bit of googling on the subject but perhaps I'm not describing the problem set correctly because I'm unable to find anything satisfactory.

Goals :
1.) I dont' want to have to recreate the chunk meshes across the entire world everytime I step up and down the Y-axis blocks. It would destroy performance and probably crash Unity.
2.) Reasonably optimized quick stepping up and down the Y-axis i.e. no perf drops.

I know that a few options must be out there as I've seen examples in other engines and games (Byte56's Age of Goblins tech demo and Gnomoria etc). I'm guessing an algorithm via some magic shader math would be perfect.

All ideas greatly appreciated!


texts: OpenGL/SDL2 How to resize the render area with the window?

texts:
After calling SDL_SetWindowSize, the area being rendered to doesn't change with the window, so if the window gets bigger, it leaves a black area on the top and right sides.  I am adjusting the OpenGL viewport to the new window dimentions.  Everything I'm drawing scales correctly but is cut off when the window is bigger.

I've been searching for the solution all day and all I've found is creating a new OpenGL context, but that causes crashes unless I reload all my graphics data which seems ridiculous just to resize the window.

Is it the default framebuffer that needs to be resized?  According to the OpenGL wiki,

  All default framebuffer images are automatically resized to the size of the output window, as it is resized.

So if the default framebuffer is being resized, why is it only rendering to the same small area?

I could initialize it to the largest possible resolution and then shrink it, but wouldn't that cause OpenGL to process a bunch of fragments outside the window?


texts: How to reference and call a function from different script ?

texts:
I've a script : Toy .

Depending of toy "type" i need to activate different feature.

For instance, for "Police-Car" i need to activate Siren, for "Truck" i need to activate horn .

I don't want to re-engineer my code creating a classic way like:

  Toy Class

  Truck : Toy
  Police-Car : Toy

So I want to call a generic public function "Activate", existing in Truck, Police .. from my Toy class.

How can i reference different script ( PoliceCarScript, TruckScript) inside Toy , so i can launch the Activate public method of PoliceCarScript, TruckScript ?

Thanks


texts: I have a monster spawner that spawns the "enemy" kid which is red, and it has a line in the script where it references the "player" gameobject's transform. Before I made the spawner, I had the enemies put by hand and I could reference the player object without issue. Now they're not handplaced, they are spawned from the prefab folder by the spawner. When they spawn the game gives the null reference exception error and stops. I look up to the enemies that are spawned and none of them have the player gameobject referenced. Also when I click on to the enemy prefab to reference the player object, it just doesnt allow me to. How can I resolve this issue?


texts: Components in a client/server network game?

texts:
Behavior and logic are executed on the server.  The clients are mostly for rendering, audio, and gathering input.

It looks as though most of the a components architecture benefits are only realized on the server.

Is it still beneficial to design the client with an component based architecture?  Or is there a different approach that better fits a client.


texts: How To Animate Skeletal Interactions (Hugging, Handshakes etc.)

texts:
I am fairly new to animating and IK systems, but I've got the basics down to some extend. Now I am looking into how to go about skeletal actor animation interactions such as handshakes, fighting, horse riding, hugging or sex animations and such, to be used in unreal engine 4. I would like someone to point me into the right direction on how to go about this.

As I am new to this, if the question is too broad or vague please do let me know.


texts: Which buffering process would be more efficient?

texts:
I'm working on the base engine of my game right now, specifically converting a text file into a level on-screen. As a 2D platformer, each level has an array of rectangles that can be drawn to the screen. Obviously I don't want to draw all these bad boys to the screen every frame, as that would slow everything down. I've thought up two solutions to this problem myself:

Draw these rects to a separate texture (I'm using SDL2, by the way) and paint a specific portion to the screen every frame
Choose which rects to draw every frame based on the player's position by checking collision between every rect and an imaginary moving "chunk"

My question: Which of these two processes, if either, would be less of a burden to the cpu? If neither seem reasonable, what other alternatives are there?


texts: Gamemaker vs Unity2d - Speed of Development

texts:
I know coding, so programming is not a problem
Money is not a problem at all, I can get both GameMaker Master
Collection and Unity Pro

I want to make a 2d game.

So which one is better for speed of development? On which one would I be able to finish my project earlier?


texts: Use an object's x position to seek within an animation

texts:
I have an animation clip I want to play, using the object's x position to control which frame of the animation is displayed. ie.

When the object is at x = -2, the animation should show its initial frame.
As the object moves rightward (increasing x) the animation should play forward.
When the object is at x = 6, the animation should show its final frame.
As the object moves leftward (decreasing x) between these values, the animation should play in reverse.

I thinks this is a form of clamping where I want to map x values into key frames of the animation.

Below just a simple code to run animation:

void Update () {
    if (isPositionChanging)
    {
        if(transform.position.x > xPos){
            if(incrementOrDecrement <=12) {
            incrementOrDecrement ++;
            AnimationPlayOnPositionValue(1, incrementOrDecrement);
            }
        }
        else {
            if (incrementOrDecrement >= 0)
            {
            incrementOrDecrement--;
            AnimationPlayOnPositionValue(1, incrementOrDecrement);
            }
        }

    }
}

void AnimationPlayOnPositionValue(float speed,float timeToUpdate) {
    animatedObject["MachineAnimationComplete"].speed = speed;
    animatedObject["MachineAnimationComplete"].time = timeToUpdate;
    animatedObject.Play();

}


texts: Dragging and dropping sword in unreal engine 4

texts:
I am developing a 2d game using unreal engine 4 in which the user drags and drops a sword.I want the sword to follow the position of my finger.At the moment, when I drag the sword, it moves at an offset from my finger.The game has been packaged to an pad and I have set up the functionality using blueprints.

Pseudo code:

On Drag (){

finger position = sword position on screen

on drop = finger position on release from screen = position of sword

}

How do I make the sword follow the position of my finger as I drag it?


texts: How do I ignore 1 axis on vector 3 reset to 0,0,0?

texts:
coding noob 3D artist here. I'm trying to create a scrolling parallax background with 3D objects, I have it set so that when it scrolls off screen, it resets it's position off screen on the opposite side so it repeats. However, If I want to have multiple depths to these background objects, it needs to not reset that objects position in the Z axis, or when it loops once it'll just overlap the other objects. How can I tell it to ignore the Z axis on resets? Here's what I have so far.

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

public class BGSLIDE : MonoBehaviour
{
    public float speed = 2.0f;
    public Transform cube;
    public CC player;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        cube.position += new Vector3(speed*player.velocity.x, 0, 0);
       if (cube.position.x > 10)
        {
            cube.position = new Vector3(-10,0,0);
        }
       if (cube.position.x < -10)
        {
            cube.position = new Vector3(10,0,0);
        }

    }

}


texts:
I am trying to show multiple images on a grid system which are randomly generated and the grid is moving from right to left.

What my client wants is when a part of a picture goes off the left edge of the viewport, it should start to peek in from the right, similar to the image shown below:

You can see the red and blue images each represent the same object. When they go off the left edge of the screen, they appear the right edge. It should happen seamlessly, without a sudden "pop" appearing out of nowhere.

I think it can be done via a shader, but I'm not a shader programmer. How can I achieve this effect?


texts: How to create an API for event-based, modular Java game?

texts:
I don't really know how to explain what I am trying to do that well, but yeah I'll try my best.

I'm currently creating a game with LWJGL 3, and I hope to make it event based and rather abstract as to allow the game to be hopefully easily moddable by community members through their own .jar files. To give them the ability to modify the current functions of the game, I want to make the game event based so they can listen to events and modify them or cancel them completely before my function executes, and provide a way for them to create their own structures, entities, events, artifacts(items), et cetera. I just cannot wrap my head around how to do this exactly, at least with creating the API.

I spent a lot of time researching and I just came up with allowing modules through Unity or with Lua, but that's not what I am looking for. So, what is the best way to set up an API like this? Do I create interfaces for all of my own events, entities, items, and things or do I just create base interfaces which I implement in my own classes? Then however I do this, what do I actually provide for them to create their mod/module? My whole game or just these interfaces. I just cannot figure out a good way to set up the API especially since I've never created one myself, let alone for a game.


texts: XNA spritebatch.Draw: Which part gets colored by the color parameter?

texts:
Which part gets colored and how can I control it?
I have a rounded block and my goal is to have the center filled with a certain color chosen by that parameter. Here's the picture:

When I draw it with Color.Red for example, just nothing happens.
Simply creating the texture in these colors I need won't help, I want to create the colors very dynamic. That's a very simply texture but I also want to apply it on harder ones.

The center is transparent already.


texts:
I want to create a modular weapon system. I already got most of it working, but I wonder how to make an improvement.

Weapons in my game have different firing modes (semi and auto) and "bullet" modes (projectile and hitscan). Each weapon is it's own blueprint, and there I can select proper one in editor, so for example an Uzi would be auto / histcan, while a rocket launcher would be semi / projectile. (the firing mode actor gets created at spawn from the class selected in editor).

I want to make it easier to edit by giving the weapon some variables, like spread and projectile blueprint. But not all of the variables apply to all the types of weapon...

TLDR:
Can I create / show different variables in the editor, depending on other variables? If I choose projectile type of weapon, can I also select the projectile type, but not show the option if I chose hitscan?


texts: When should I use skill trees versus skill lists in an RPG?

texts:
What are the pros and cons of skill trees versus flat skill lists in role playing games? In what situations is one more appropriate than the other?

Here is an example of a skill list, taken from Elder Scrolls IV: Oblivion:

Here is an example of a skill tree, taken from Diablo II:

Some additional questions:

Are skill trees inherently more complex than skill lists?
Do skill lists tend to broadly cover a character's abilities, while skill trees focus on specific spells or aspects of a character?
The Elder Scrolls: Morrowind uses skill lists and has a skill called Athletics that was removed in Skyrim. Do skill lists' loose coupling of skills make it easier to create useless or irrelevant skills?


texts:
I'm trying to figure it out how to check if keyboard key was released. I tried messing around with InputMultiplexer, InputProcessor, etc. Nothing helped. Not enough documentation from lib developers (at least for me).

Anyone had similar problem? Can someone help me?

With InputProcessor I can check if single key was pressed. But what if I want to check multiple keys?


texts:
When I try to import a video file to play in a VideoPlayer component, I get the following errors in the Console:

WindowsVideoMedia error 0xc00d5212 while reading C:/Users/Jonas/OneDrive/Projects/Project1/Assets/Videos/output.mp4

Context: Setting media type for first video stream
Error details: No suitable transform was found to encode or decode the content.
Track types:
   Audio Track, type: U
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
-----------------------------------------------------------
Error while reading movie: C:/Users/Jonas/OneDrive/Projects/Project1/Assets/Videos/output.mp4
UnityEditorInternal.InternalEditorUtility:ProjectWindowDrag(HierarchyProperty, Boolean)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
-----------------------------------------------------------
VideoClip import error for Assets/Videos/output.mp4
UnityEditorInternal.InternalEditorUtility:ProjectWindowDrag(HierarchyProperty, Boolean)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
-----------------------------------------------------------
WindowsVideoMedia error 0xc00d5212 while reading C:/Users/Jonas/OneDrive/Projects/Project1/Assets/Videos/output.mp4

Context: Setting media type for first video stream
Error details: No suitable transform was found to encode or decode the content.
Track types:
   Audio Track, type:
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

The video file is just an ordinary H.264/AAC MPEG-4 video file transcoded using ffmpeg. But I also tried the same format and H.264/AAC QuickTime MOV (both rendered from Blender) and AVI (JPEG) from Blender as well.

System Details:

Unity 2018.4.12f1 (LTS) Personal
Build target: Android (Minimum API Level 25)
Windows 7 Home Premium 64 Bit (SP1)
Blender 2.80
ffmpeg version N-85588-g6108805

I tried to post this to the Unity Forums before, but as of writing this, the thread has yet to be greenlighted by moderation, so I might as well try posting it here, as you usally get an answer much more quickly


texts: Unity C#: strange texture/sprite problems

texts:
I've been making a gallery style shooting game, like something you'd find at a carnival, with ducks to shoot. I'd made the game and it was all working fine. However opening it today, it doesn't look the same. There are some problems with the GUI graphics. They are drawn like this:

The other day when I finished it, it worked completely fine, and unfortunately I don't have an image of what it looked like when working. The code I've used to draw this is as follows:

void OnGUI() {
    GUI.Label (new Rect (10, 10, scoreLabel.texture.width, scoreLabel.texture.height), scoreLabel.texture);
    GUI.Label (new Rect (scoreLabel.texture.width - 7, 10, colon.texture.width, colon.texture.height), colon.texture);

    int tempWidth = 0;

    for (int i = 0; i < charArray.Length; i++) {
        if(i > 0) tempWidth += numbers[int.Parse (charArray[i - 1].ToString ())].texture.width * 2 / 5;
        GUI.Label (new Rect (135 + tempWidth, 13, 40, 30), numbers[int.Parse (charArray[i].ToString ())].texture);
    }
}

Previously when it was working, the settings for the sprite/texture wouldn't affect the sprite/texture being drawn. The settings (for the numbers) are as below:

Can anybody advise me on what to do? I've played with the settings, and restarted unity and my computer and had no luck. Thanks in advance!


texts:
Can you use any function to render more than a line of text in a surface?

If you can't do this, what whould be the way to go?
I am doing the following: Create a surface (not sure if should be a software or a hardware one) and then create as many surfaces as lines my text have, then blitting all the surfaces, and freeing all the surfaces. But this turns to be very slow. This is the code:

void Text::updateSurface() {
    if (surface != NULL) {
        SDL_FreeSurface(surface);
    }

    TTF_Font * font = TTF_OpenFont(fontPath.c_str(),size);
    if (font == NULL) {
        ERROR("Null font"<<TTF_GetError());
    }

    int maxWidth = 0;
    int totalHeight = 0;

    std::vector<SDL_Surface *> surfaces;
    for (size_t i=0; i<lines.size(); i++) {
        SDL_Surface * partialSurface = TTF_RenderText_Solid(font, lines[i].c_str(), color);
        if (partialSurface == NULL) {
            ERROR("surface == NULL: "<<TTF_GetError());
        }
        surfaces.push_back(partialSurface);
        totalHeight += partialSurface->h;
        maxWidth = std::max(maxWidth, partialSurface->w);
    }

    TTF_CloseFont(font);

    surface = SDL::allocateSurface(maxWidth,totalHeight);
    if (backgroundColor != NULL) {
        SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format,backgroundColor->r, backgroundColor->g, backgroundColor->b));
    }
    totalHeight = 0;
    for (size_t i = 0; i < surfaces.size(); i++) {
        SDL_Rect dst = {0, totalHeight, 0, 0};
        switch(aligment) {
        case ALIGMENT_RIGHT:
            dst.x = maxWidth - surfaces[i]->w;
            break;
        case ALIGMENT_CENTER:
            dst.x = (maxWidth - surfaces[i]->w) / 2;
            break;
        case ALIGMENT_LEFT:
        default:
            break;
        }
        totalHeight += surfaces[i]->h;
        SDL_BlitSurface(surfaces[i],NULL,surface,&dst);
        SDL_FreeSurface(surfaces[i]);
    }
}

This is the code for SDL::allocateSurface(...)

static SDL_Surface * allocateSurface(int width, int height, int bpp = -1, Uint32 flags = 0)

SDL_Surface * SDL::allocateSurface(int width, int height, int bpp, Uint32 flags) {
    if (bpp == -1) {
        bpp = SDL::bpp; //SDL_GetVideoInfo()->vfmt->BitsPerPixel;
    }

    if (flags == 0) {
        flags = SDL_HWSURFACE;
    }

    Uint32 rmask, gmask, bmask, amask;

    #if SDL_BYTEORDER == SDL_BIG_ENDIAN
        rmask = 0xff000000;
        gmask = 0x00ff0000;
        bmask = 0x0000ff00;
        amask = 0x000000ff;
    #else
        rmask = 0x000000ff;
        gmask = 0x0000ff00;
        bmask = 0x00ff0000;
        amask = 0xff000000;
    #endif

    return SDL_CreateRGBSurface(flags, width, height, bpp, rmask, gmask, bmask, amask);
}


texts: How do I create particles that react to the player and enemies?

texts:
I'm currently making a game with my own game engine which I've written in C++ and I'm using the most recent directx SDK.

The game is a top down space shooter (with a pretty interesting twist) and I'm looking to have a sort of nebula effect that the player will fly through. I really want to try and nail that nice tactile feel of hundreds of particles moving out of the way of the player ship as it flies into them. Somewhat like how particles would move out the way of the player in Geomtry Wars on XBLA.

I'm an experienced programmer when it comes to C++. I don't know, however, how to start implementing this effect. Does anyone have any cool ideas or design choices I might want to look into? Feel free to answer to any degree of depth you fancy.


texts: Calculating impulse with multiple collision points

texts:
In my amateur 2D rigid body physics engine for a game I react on collisions between two bodies with an impulse j (formula 11) as explained here.
To calculate this impulse I need one contact point P between the two colliding bodies and the perpendicular normal n of the edge the contact point of A is colliding with.

(source: myphysicslab.com)
That works wonderful. At least as far as I don't have multiple contact points. But what to do if this is not the case?
Should I calculate an impulse for each of the contact points or is there a way to reduce multiple contact points to a single one if this is a correct solution?
As an example I have following two situations, where two bodies collide. The x denotes the center of mass and the tips of each triangle pointing down an vertice of A that is colliding with the edge underneath:
    _____________________                        _____________________
   |                     |                      |                     |
A  |          x          |                   A  |                     |
   |    _____________    |                      |         x  ______   |
    \  /             \  /                       |           /      \  /
     \/               \/                        |    __    /        \/
    _____________________                        \  /  \  / ___________
   |                     |                        \/    \/ /           |
B  |          x          |                   B   _________/    x       |
   |_____________________|                      |______________________|

In the left situation its intuitively pretty clear that I can reduce the two collision points to one exactly in the middle between both since the this would be collinear to both centers of mass. Also as normal n the perpendicular vector of the edge both vertices are colliding with can be chosen.
But what to do in the right situation?


texts: Godot 3.1.2: Black lines / borders around Sprite

texts:
In Godot 3.1.2 using OpenGL ES2, black borders/ lines seem to form around some sprites I have imported. Usually they appear on top of the sprite but can also "border" around it.

Being new to Godot development but coming from Unity I expect I did something wrong in the import or that the texture settings aren't set correctly. But so far I haven't been able to find any setting that resolves this issue.

So my question is: where can I find texture/image settings that can resolve this issue? Or if the issue stems from another source, how can I make sure that the images are being displayed without the black lines?
(Bonus question: Is there also a way/ setting to display tiles in the Y-Axis non-blurry?)

(I'm pretty new to Stack Exchange/ GameDev so if my question is missing some details please let me know :) )


texts:
I'm working on a city-based isometric game where the player controls a character moving around in the city.
I need to create both an overview map and a minimap similar to both GTA and Mafia 3. Here's a good example:
https://youtu.be/0Jfgjt_1JFg?t=1437 (timestamp)
My question is:
How would you implement such a map? My best guess is to have another camera present a simplified city by switching out material or manipulating with shaders. Another idea was to simple have the map as a drawn image and then "manually" track the player.
Really looking forward to hear you solution!


texts: What are the reasons for MMOs to have level caps?

texts:
In many MMOs players character progression is artificially capped, e.g. by level 60 or 90 or 100 or whatever. Why do MMOs have these level caps in the first place? Why not just allow characters to continue to arbitrary levels with a mathematically designed leveling system that keeps the leveling experience interesting and endless?

Answers to this question may help us to see the reason behind the feature and decide if and how this should be implemented in our MMOs.


texts:
I'm having a difficult time to understand , how to implement the behavior of an enemy in a tile based game,

movement
attack
behavior per enemy level ( higher level enemies should be hard to kill)
defend
other behavior

since the game is a tile game written in javascript,
the behavior of the enemies could be implement as functions like

Chaser - hunts its opponents
Brave - does not start running if with low HP
Sensitive - when damaged might take additional damage

using the standard entity class , based on the configuration defined for the enemy, could it be extend  as the behavior?

Or write like standard enemy behavior and additionally write separate scripts per enemy on how they should behave against the opponent, surroundings, etc..


texts: How can I detect connected (but logically distinct) bodies of water in a 2D map?

texts:
I have a 2D hexagonal grid map. Each hex cell has a height value used to determine if it's water or ocean. I'm trying to think of a good way to determine and label bodies of water. Oceans and inland seas are easy (using a flood fill algorithm).

But what about bodies of water like the Mediterranean? Bodies of water that are attached to larger ones (where "seas" and "gulfs" differ only by the size of the opening)?

Here's an example of what I'm trying to detect (the blue body of water in the middle of the image, which should be labelled differently from the larger body of ocean on the left, despite being technically connected):

Any ideas?


texts: How do I draw a circular portion of a texture within LibGDX using an OpenGL ES shader?

texts:
What is the simplest way to implement a shader to draw a circular portion of a full screen texture where the circle is dynamically resized as part of an animation using LibGDX?

Is a shader even the best place to do this kind of thing?

I'm sure you could do this in software using a Pixmap but that would be slow. In the end I managed to get something working using the OpenGL depth buffer, a ShapeRenderer to draw a circular mask and a SpriteBatch to draw the texture but it feels messy and awkward.


texts: WHY !! CountDown not Working inside the IF Condition?

texts:
i need a way to make the countdown decreasing inside the if statement i am stacking in  this problem for more than 3 days .. Don't suggest to me Coroutine cause it will not working in my case cause i am using clones (initiated prefabs)

i know that the countdown will work only one frame if it's inside an IF Statement ... Any Ideas to make it working ...Ty

The game is about cars ... and every instantiated car has a random countdown timer

void Update()
{
    if(carNumber < cars)
    {
        SpawnCars();
    }
}

and this is the spawn  function

void SpawnCars()
{
    randomSpawnPoint = Random.Range(0, spawnPoints.Length);

    randomSpawnCars = Random.Range(0, Cars.Length);

    GameObject obj = Instantiate(Cars[randomSpawnCars],spawnPoints[randomSpawnPoint].position, Quaternion.Euler(-90, 180, 0)) as GameObject;

    carNumber++;

    obj.gameObject.tag = "select";// + k;

    rcf = obj.GetComponent<RayCastForward>();
    TextMesh txt = FindObjectOfType<TextMesh>();

    time = Random.Range(4, 20);

    txt.text = (time - Time.deltaTime).ToString("0");
    print(time);
    print(carNumber);
}

EDIT: time is the timer


texts: Collider inside collider in MRTK VR: Move the brain via controller while being able to click the spheres

texts:
I faced a similar issue in 3d unity,
Collider inside another collider: Move the brain via mouse while being able the click the spheres
There is a box collider on the brain and individual sphere colliders on the spheres.
One of the suggestions was setting up a layer mask with the mouse, which worked surprisingly well. Now I would like to be able to accomplish the same in MRTK with Windows Mixed Reality Controllers. I need to know how to set up a similar layer mask for the pointers in MRTK so that clicks are only registered on the spheres but the brain can be rotated by click and drag.


texts: Deferred shading - how to combine multiple lights?

texts:
I'm starting out with GLSL and I've implemented simple deferred shading that outputs G-buffer with positions, normals and albedo.

I've also written a simple point light shader.

Now I draw a sphere for the point light and output goes into a lighting buffer.

The problem is, how do I combine the results of lighting buffer when drawing multiple lights?

E.g. when I'm drawing the second light to the lightbuffer using the point light shader, how do I add first light to the second light in the lighting buffer. I mean, you can't read from and write to the same output buffer?


texts: Figuring out what object is closer to a certain point?

texts:
I'm trying to create fog of war, I have the visual effect created but I'm not sure how to deal with the hiding of other players if they're within the fog of war.

So right now the thing I'm trying to do is if another player is hiding behind a wall then not to render that player. I was thinking of doing it by sending a ray in the direction of all the players, and then creating a list of all the obstacles that ray collides with and then trying to figure out if an obstacle was closer than the player in order to predict the distance.

But then I realized I'm not really sure how to figure out if the obstacle is infact closer or not because I have to account for all the dimensions, so I'm kind of stuck. First of all is this approach the correct way to go about it and secondly how would I calculate if the obstacle was infact closer taking into account the X Y and Z.

Thanks


texts:
Im having a slight problem in getting my Combination keypad to work. Ok so basically I'm using gameObject buttons to use for the numbers 0-9. So each gameObject button has a number link to it. The combination passcode is found by finding items, in which these items have link numbers to them as well, hence item.password. The problem Im having trouble with is for the combination to show if its correct or incorrect and also if you push one of the buttons 5 times it will show incorrect code. Please help if you can Here is the code:

This is where I will have the mouse click on the button to declare a password digit.

public class RayCasting : MonoBehaviour
{
public float pickupDistance;
public List<Item> items;
public List<Keybutton> buttons;

// This is for the KeyPad Buttons Area

    foreach(Keybutton button in buttons)
    {

        if(Input.GetMouseButtonDown(0)) {
            if (button.gameObject.Equals(hit.collider.gameObject))
            {
                hit.transform.renderer.material.color = Color.red;
                    button.ButtonWasClicked(button.currentCombination);
                break;
            }
        }
    }

}

}

This is where the magic works. This is basically the gears of the combination to work. It suppose to get the 5 combination numbers from my Item class password variable and implement them to make the combination. The thing is that Im not sure if that works plus if I hit one gameObject button 5 times it says incorrect passcode.

[System.Serializable]
public class Keybutton
{
public GameObject gameObject;
private int Combination;
public int currentCombination;
private int buttonClickProgress;

public void  ButtonWasClicked (int buttonNmb){
Item item = new Item ();

Combination = item.password;
buttonClickProgress++;
currentCombination = buttonNmb;

if(buttonClickProgress < 5){
    decimal d = (decimal)currentCombination / 10;
}
else{
    if(currentCombination == Combination){
        Debug.Log("Correct Passcode");
        buttonClickProgress = 0;
        currentCombination = 0;
    }
    else{
        Debug.Log("Wrong Passcode, reseting...");
        buttonClickProgress = 0;
        currentCombination = 0;

        gameObject.SetActive(false);
    }
}
}
}

Any ideas? I know its a lot but feel free to ask whatever you need.


texts: How to convert a rotation around an axis into pitch and yaw rotation

texts:
So i want to rotate particles towards a point and i've already figured out how to calculate the angle and the rotation axis.

Currently what i do is simply use a 3 dimensional matrix, apply the rotation and then extract the euleric angles from the matrix using joml.

Now using the result i have the problem that the particle is also using the z rotation, messing up the orientation of the particles texture. The easiest way to fix this would be to only use yaw and pitch, but how do i convert the roation to just a rotation around the x and y axis?


texts:
I have a very clear idea for my first Game . I have immense Experience in Coding Games in LibGDX but i am very poor at game art . So far I've been hating all the characters I've drawn . Are there any good books or other resource for learning 2D Character and Game elements Art .

Thank You


texts: Multiple errors on brand new C++ project

texts:
I've just started a brand new project and created a created a new C++ Character class. However Visual Studio 2017 shows 140 errors. The project still builds fine, however the syntax highlighting and errors are very intrusive.

Here are some examples of the errors:

on the BaseCharacter.cpp class I just created:
class "UObject" has no member "BeginPlay"
class "UObject" has no member "Tick"
class "UObject" has no member "SetUpPlayerInputComponent"

on multiple '.h' files:
this declaration has no storage class or type specifier

for all '*.generated.h' files:
cannot open source file "[ClassName].generated.h"

Is this a problem with my intellisence or the project itself? I haven't changed any of the code that was generated by Unreal.


texts: Which language is best for 2D and 3D games to be played on the desktop and on the web?

texts:
I am B.Tech. student and have done some CS courses and have some knowledge about programming languages. I know C++ (I've made some small desktop GUI programs with Qt and in Visual Studio), Java (also have done some GUI in Swing) and Python.

Now I want to learn to make 2D and 3D games which can be played on the desktop and also on the web. So which language will be best for this? I have played some web games and they all need Flash player to run, so are they all made in AS or some other Flash language?


texts: How to keep the value of angle between 0 and PI in box2d

texts:
In box2d, if i rotate an object multiple times in clockwise or anti clockwise direction, the value of angle ( body.getAngle() ) keeps on increasing. Like at start it is at 0 radians, then 1.57(90 deg), after complete roatation 6.28, then after second rotation 2*6.28 .
If a player keeps on rotating for too much time, angle value becomes really big.And for multiplayer games, sending big values uses more bytes.

How can i keep the value between 0 to +-3.14.Is there any solution in box2d Or
Is it a good way of sending Sin(angle) to keep the value between -1 and 1 and doing reverse of sin at client side.


texts: How to load geometry/object/scene created in Clara.io with Three.js

texts:
Does anybody know how to load anything created in Clara.io into your Three.js scene?

Clara.io allows export of ThreeJS geometry, object or scene. I tried all those in combination with all THREE loaders (JSONLoader, SceneLoader, GeometryLoader, etc.) without any success (Parse function inside of three.js fails to process json structure).

Structure of exported file from Clara.io looks to be completely different from what Three.js loaders expect. Can this be achieved in any way or is Clara export simply useless at this point?

I am talking three.js v.65 in combination with current version of Clara.io


texts: How can I export a model from Unity to three.js?

texts:
I want to buy some assets from the Unity asset store and use them in my three.js project, but I am not sure what the best way to go about this is. Some cursory googling got me this, but Collada Exporter does not support the latest version of Unity afaik. I have also tried some other exporters such as this one, but the objects I get out of it are buggy (mirrored pieces not rendering etc.). Ideally my workflow would be Unity -> Blender -> three.js (as json). I know there is a three.js blender exporter, so I suppose the missing part is going from Unity to Blender. I would also like animations to be exported.

Does anyone have experience with a workflow successfully exporting assets from Unity to three.js?


texts: Loading sprite resources from nested folders

texts:
This is how I try to load my sprite images:

 sprite Sprites[];

 void Start() {
    ...
    Sprites = Resources.LoadAll<Sprite>("Card/AnimalImages");
    Debug.Log("Sprite name: " + Sprites[8].name);
    ...
 }

But it gives me the error that you can see in the picture below. Note that in the same figure there is a hierarchy of folders on the right side. I put two ellipsis in the code because it is actually much longer than what I posted, but I assure you that the script is correctly attached to the object and it generally works.

The problem is that it doesn't load the sprites as I expect: the debugger hangs at the point where the Debug.Log(...); is executed (precisely when it tries to access the Sprites vector which is probably empty).

It's the first time in Unity3D where I need to load the sprites in that way. I tried to look in some previous posts, probably I will have missed someone, but in those found until now no one has helped me.

Can someone help me to understand how to load the sprites and especially where is my mistake?

  Update

I tried to check if could be a problem of static/dynamic arrays, but it seems not to be a problem of this type, in fact following code:

    Sprites = new ArrayList(Resources.LoadAll<Sprite>("Card/AnimalImages"));
    Debug.Log("Size of dynamic array: " + Sprites.Count);

prints:

Size of dynamic array: 0


texts:
Follow up for my previous question, whose answer lead to another question:

As the OpenGL specification documentation states,
in glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices), indices "Specifies a pointer to the location where the indices are stored."

So why does calling gl::glDrawElements(gl::GL_TRIANGLES, IndexBuffer.size(), gl::GL_UNSIGNED_INT, (void*)(0)); work, but calling gl::glDrawElements(gl::GL_TRIANGLES, IndexBuffer.size(), gl::GL_UNSIGNED_INT, &(IndexBuffer.at(0))); doesn't ?


texts: Getting Vector at 90 Degrees from provided vector

texts:
I need a function that can take a vector as an input and provide a vector that is at a 90-degree angle to the provided vector. I understand that in 3D there is an infinite amount of vectors that could be produced from this calculation, but I only require 1. I have been using GLM and have tried using its built in vector rotation functions but to no avail. I would like to keep the solution compatible with GLM as I wish to have everything standardized.

Here is a basic visualization of what I need.

Edit
The function's purpose is to pass a direction vector into a function, radius, and an angle and it will create a point around the origin at x angle in space. The reason for this is so I can loop through and create a point cloud in 3D space and then join them together to make shapes such as cylinders (see photo)

Solution Code

glm::vec3 CreateAngledPoint(glm::vec3 rotation_point, float radius, float angle, glm::vec3 normal)
{
    // Normalize the normal (axis to rotate on)
    normal = glm::normalize(normal);
    // Create a vector that will be used for the dot product
    glm::vec3 to_cross = glm::normalize(glm::vec3(0.0f,1.0f,0.0f));
    // Make sure that the normal and cross vector are not the same, if they are change the cross vector
    if (to_cross == normal) to_cross = glm::normalize(glm::vec3(0.0f, 0.0f, 1.0f));
    // Get the cross product
    glm::vec3 to_return = glm::normalize(glm::cross(normal,to_cross));
    // Rotate point around the axis
    to_return = glm::rotate(to_return, angle* RAD_TO_DEG, normal);
    // Scale the point up from the origin
    to_return *= radius;
    // Apply it to the point in space we are rotating around
    return rotation_point + to_return;
}

Example of its usage


texts: Is there any distinction between these two? I couldn't find anything in google under "Adaptive vs progressive mesh", but googling them both separately gives results as if they were likely the same.


texts: Multiplayer box2d networking for turn based game

texts:
I am currently in the planning stages for a 2D game for mobile devices
which I will be making in C++ using cocos2d-x.  The game will be turn based and each turn will have a phase in which the physics simulations will take place. It will also be cross-platform.

I am new to multiplayer networking and am wondering what the best way to synch the physics would be since Box2d does not behave exactly the same on different devices.

The simulation does not have to occur simultaneously on each device but I do need the results to be exactly the same. Ideally the players will be able to witness, on their own device, the same physics simulation( i.e. motion, bouncing, collisions ) and result that occurred during their opponents turn whenever they decide to start their own turn.

What would be the best way to do this? From my research I've come up with a couple of solutions. Should I write some server code on which I would take user input and handle all of the physics simulation, then send the results to each device? or is there a way I could handle the simulation on one device and send all of the information to the other?

Also how exactly does one send everything that happens during a simulation through the network since I can not run the simulation on each device and be guaranteed the same results? Would I just update the server( or device ) with information of what occurs during every few TimeSteps?


texts:
I am working on a simple game, where I need to do a collision detection of two Texture2D. The code I have written is:

bool perPixelCollission = false;
            Texture2D texture1 = sprite1.Texture;
            Texture2D texture2 = sprite1.Texture;
            Vector2 position1 = new Vector2(sprite1.CurrentScope.X, sprite1.CurrentScope.Y);
            Vector2 position2 = new Vector2(sprite2.CurrentScope.X, sprite2.CurrentScope.Y);

            uint[] bitsA = new uint[texture1.Width * texture1.Height];
            uint[] bitsB = new uint[texture2.Width * texture2.Height];

            Rectangle texture1Rectangle = new Rectangle(Convert.ToInt32(position1.X), Convert.ToInt32(position1.Y), texture1.Width, texture1.Height);
            Rectangle texture2Rectangle = new Rectangle(Convert.ToInt32(position2.X), Convert.ToInt32(position2.Y), texture2.Width, texture2.Height);

            texture1.GetData<uint>(bitsA);
            texture2.GetData<uint>(bitsB);

            int x1 = Math.Max(texture1Rectangle.X, texture2Rectangle.X);
            int x2 = Math.Min(texture1Rectangle.X + texture1Rectangle.Width, texture2Rectangle.X + texture2Rectangle.Width);

            int y1 = Math.Max(texture1Rectangle.Y, texture2Rectangle.Y);
            int y2 = Math.Min(texture1Rectangle.Y + texture1Rectangle.Height, texture2Rectangle.Y + texture2Rectangle.Height);

            for (int y = y1; y < y2; ++y)
            {
                for (int x = x1; x < x2; ++x)
                {
                    if (((bitsA[(x - texture1Rectangle.X) + (y - texture1Rectangle.Y) * texture1Rectangle.Width] & 0xFF000000) >> 24) > 20 &&
                        ((bitsB[(x - texture2Rectangle.X) + (y - texture2Rectangle.Y) * texture2Rectangle.Width] & 0xFF000000) >> 24) > 20)
                    {
                        perPixelCollission = true;
                        break;
                    }
                }
                // Reduce amount of looping by breaking out of this.
                if (perPixelCollission)
                {
                    break;
                }
            }

            return perPixelCollission;

But this code is really making the game slow. Where can I get some very good collision detection tutorial and code? What is wrong in this code?


texts: Unwanted highlight on far side of objects near the edges of the screen when using orthographic camera

texts:
I was creating a simple unity game with a sphere as a ball. The problem is that the ball face towards the camera origin renders material correctly but the one away from camera does not.  The ball has a standard material , the scene has directional light which faces in the camera's direction.The camera is orthographic and the background is solid.

Let me explain, in the material inspector window preview the ball is properly shaded from all sides as you can see. But in the game screenshot I have posted, the left half of the ball abruptly becomes lighter. Now this lighter shade is not because of the directional light or any other light source its because of the camera. because as I move near the camera center origin the original material shade returns but the farther I move the lighter shade nearly takes over half of the ball. I tried changing the camera rendering path to a vertex legacy lit and that solves the problem but I don't think that is the ideal solution. I am a newcomer to Unity and this is my first game. I tried going through the documentation but didn't find anything helpful. Any help will be greatly appreciated. :) .


texts:
So I'm gathering information for my project, and one of the things I want to achieve is to create a very sophisticated crafting system and weapon modification but I want the weapon customization to look in a specific manner.

A very good reference would be Crysis weapon attachments system, where if you open it, your character tilts the weapon and there are few menus popping up, all attached to the weapon, so you can see the menus moving around as your weapon is moving (due to you breathing for example, or walking).

Here is a quick image reference:

So 1st thing comes to my mind is, how in the name of god should I approach this? Pardon if this is quite easy thing to do, I'm just completely new to Unity. (I have solid C++ background so programming isn't the obstacle)

Edit 1: To be precise, I'm wondering how to work out the positioning of the menus in relation to the weapon. So the menu is moving with the weapon and eventually even turn slightly to give that 3D'ish effect.