texts:
Here is the problem: I'm rendering a red triangle in an offscreen Frame Buffer Object. I have a texture of that Buffer, and i'm applying this texture to a Simple rectangle(at runtime).

I get This result:

This is exactly what i wanted. the problem is that when i strech my window the texture gets a little weird:

Just for curiosity i tried to render the rectangle without the texture.

And then I stretched the window once again:

I believe this is happening because in my default FBO I am setting glViewport to glViewport(0,0,m_Width,m_Height); (m_Width and m_Height are the dimensions of the Window)


texts: How do you get useful data from playtesters?

texts:
There are a few types of feedback you can get from playtesters, and I wonder how to best gather data for each of them...

Crash Reports. When my C++ game crashes while someone is playing it, how do I best make sure that I know about it and even better...   what caused it? Even getting something as simple as the file and line number which caused a crash would be incredibly helpful.
Design Feedback. When a play tester is playing the game, how can I figure out if they are having fun, why they are having fun, why they aren't having fun, and what we should spend time adjusting?


texts: Difference between Spherical Harmonics and Spherical Harmonics Lighting

texts: What is the difference between Spherical Harmonics and Spherical Harmonics Lighting in OpenGL?


texts: How can I add background color to a libGDX TextButton?

texts: I have a TextButton in my libGDX project and I want to add a color background to it. I tried the setColor() method but that didn't work.


texts: Converting Frame-Dependent Movement to Frame-Independent

texts:
I fine-tuned some movement physics for a 2D platformer in a frame-dependent manner and now I want to convert them to frame-independent.

I though this would be as easy as multiplying a few things by 60 (my FPS) and a few other things by a time delta.

Unfortunately, the resultant physics is not the same as the original, especially when I drop the frame rate from 60 fps to 30 fps.

Here's how the frame-dependent movement works in my Player class, simplified a bit for the purposes of illustration.

PLAYER_ACC = 1.5
PLAYER_FRICTION = -0.23
PLAYER_GRAV = 1.75
PLAYER_JUMP = 20

def get_input(self):
    if self.game.input("left"):
        self.acc.x = -PLAYER_ACC
    if self.game.input("right"):
        self.acc.x = PLAYER_ACC
    if self.game.input("up"):
        self.vel.y = -PLAYER_JUMP

def update(self):
    # reset acceleration
    self.acc = vec(0, PLAYER_GRAV)

    # process input
    self.get_input()

    # apply friction
    self.acc.x += self.vel.x * PLAYER_FRICTION     # The faster you're going, the more friction slows you down.

    # calculate velocity
    self.vel += self.acc

    # if the x-velocity approaches 0, set it equal to 0
    if abs(self.vel.x) < 1.5:
        self.vel.x = 0

    # downward velocity cap
    if self.vel.y >= 14:
        self.vel.y = 14

    # adjust position
    self.pos += self.vel + (PLAYER_GRAV * self.acc)    # Got this equation from a tutorial and I like how it feels.

Here's my attempt at making it frame-independent. My time delta is self.game.dt.

PLAYER_ACC = 1.5 * 60
PLAYER_FRICTION = -0.23
PLAYER_GRAV = 1.75 * 60
PLAYER_JUMP = 20 * 60

def get_input(self):
    if self.game.input("left"):
        self.acc.x = -PLAYER_ACC
    if self.game.input("right"):
        self.acc.x = PLAYER_ACC
    if self.game.input("up"):
        self.vel.y = -PLAYER_JUMP

def update(self):
    # reset acceleration
    self.acc = vec(0, PLAYER_GRAV)

    # process input
    self.get_input()

    # apply friction
    self.acc.x += self.vel.x * PLAYER_FRICTION    # The faster you're going, the more friction slows you down.

    # calculate velocity
    self.vel += self.acc * self.game.dt

    # if the x-velocity approaches 0, set it equal to 0
    if abs(self.vel.x) < 1.5 * 60:
        self.vel.x = 0

    # downward velocity cap
    if self.vel.y >= 14 * 60:
        self.vel.y = 14 * 60

    # adjust position
    self.pos += (self.vel + (PLAYER_GRAV * self.acc)) * self.game.dt

Unfortunately, the resultant physics did not feel the same as my original. Especially when I drop the frame rate from 60 fps to 30 fps.

I was thinking that maybe when I apply the friction to the acceleration, I need to raise it to the time delta, but this didn't help either. I am working at a small resolution (640x360) and I'm not sure if this is impacting anything.

My question is: How can I convert my current physics to frame-independent?

There are a few questions similar to this on Game Dev SE already, but none of them has led me to a solution.


texts: How do I create curved ground in a 2D runner game?

texts:
If I use tiled based map I can have only rectangular objects.

What is a strategy for creating slanted or curved ground in that case? Should I use a tile-based map, or should I define corner points in the map and create the ground programmatically?


texts: How to reproduce this (parallax?) effect?

texts:
I'm wondering how to imitate the camera movement like in the gif below. It´s from a Android game.

This game for example (via GIPHY)

Actually, I am not sure if this can be called a parallax effect, but it is the only word I can think of.

My code until now:

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

public class RotateAroundTarget : MonoBehaviour {

public Transform target;    // The object to follow
public Transform background;
public Transform foreground;
public float speedMod = 20.0f;  // Camera speed
public float topMargin = 0.2f;  // Top rotation margin

// The position of the target
private Vector3 point;
// Point if the camera is rotating to the left
private bool toLeft = false;

// Use this for initialization
void Start () {
    point = target.transform.position;
    transform.LookAt (point);
}

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

    // The camera is moving to the right until it reaches the top margin, then it changes it movement direction
    if (!toLeft) {
        transform.RotateAround (point, new Vector3 (0f, 1f, 0f), Time.deltaTime * speedMod);
        rotateBackground (1);
        rotateForeground (-1);
        Debug.Log ("Izquierda");
        if (transform.rotation.y >= topMargin) {
            toLeft = true;
        }
    } else {
        transform.RotateAround (point, new Vector3 (0f, -1f, 0f), Time.deltaTime * speedMod);
        rotateBackground (-1);
        rotateForeground (1);
            Debug.Log ("Derecha");
        if (transform.rotation.y <= -topMargin) {
            toLeft = false;
        }
    }
}

// Direction = 1 (left) | -1 (right)
public void rotateBackground(float direction){
    background.transform.Rotate (new Vector3(0, Time.deltaTime * (speedMod * 2) * direction, 0));
}

public void rotateForeground(float direction){
    foreground.transform.Rotate (new Vector3(0, Time.deltaTime * (speedMod / 2) * direction, 0));
}
}

But what I obtain in Unity Editor is this:
Result in Unity Editor (via GIPHY)

Any suggestion on how to get this?
Any help would be appreciated.


texts:
I have some trouble to do a Recoil routine.
I've a Tank, a turret cannon on it.
I want that after shot, turret fast recoil back, than (slowly) get back to start position.

This is the code I've tought but obviously it not works.

Update () {
  if(shot) {
     Shot();
     TurretBackRecoil();
  }

}

private void TurretBackRecoil() {
   transform.Translate(new Vector3(0,-10,0) * Time.deltaTime * 3 );
}

private void TurretForwardRecoil () {
    transform.Translate(new Vector3(0,10,0) * Time.deltaTime);
}


texts: How can I give to player points with ajax but secured?

texts: I have a virtual world game that I developed with jQuery, AJAX and PHP. Virutal World like club penguin. Now, I want to add a game into the virtual world - like bubbles or whatever. The main problem its that the game in ajax, so if the player got 20 points in the game - in the ajax request I have the player points and the player can change the ajax request to any points that he want. How can I do it secured? Thanks


texts: How can I apply my camera to all graphics objects?

texts:
Is there a way to have the camera be applied to all objects?

Can you have the camera effect objects that where made with glVertex3f();

This is the fourth time I have been writing this post. It keeps deleting. The first time it deleted almost all the text was when I logged in. Anyway ---

This is some of the code that does the camera:

    Projection = glm::perspective(fov, display.Ratio(), 0.001f, 1000.0f);
    glm::vec3 Pos = glm::vec3(this->position.x, this->position.y, this->position.z);
    glm::vec3 Target = glm::vec3(this->target.x, this->target.y, this->target.z);
    glm::vec3 Up = glm::vec3(this->up.x, this->up.y, this->up.z);
    glm::mat4 Lookat = glm::lookAt(Pos, Target, Up);
    glm::mat4 ModelV = glm::rotate(glm::mat4(1.0f), 0.0f, Up);
    CamLook = this->Projection * Lookat * ModelV;

CamLook is passed to the shader as MVP

Shader Code:

#version 400

in vec3 VertexPosition;
in vec3 VertexColor;
uniform mat4 MVP;

out vec3 Color;

void main() {
    Color = vec3(1, 1, 1);
    gl_Position = MVP * vec4(1, 1, 1, 1);
}

Please someone tell me what is wrong with this? I have been working on this for almost a month now and I can move on unless this is done.

Also I have another shader that does color on the objects.


texts: How do I set up moving platforms in a 2D side scroller to interact with the player properly?

texts:
Edit: I changed the way that gravity was applied so that it is applied even when a player is standing on a block, so instead of the game outputting that you are stepping on a tile as true and false (because if it is true gravity isn't applied, and it is moved out of collision thus in the next frame it does not collide) so now I'll be easier to check if the player is still colliding with a moving tile. I think that I will make a bool that checks if the player was colliding with the tile in the last frame, and if so set the velocities to equal that of the tile plus whatever they are doing (jumping, gravity, walking left and right).

I am trying to create moving tiles such as the ones in basically any platformer. The game is a 2d sidescroller, and the problem that I am running into is handling standing on moving tiles.

The tiles are stored in a vector, but I am unsure how to make it so that the play will have the same y and x velocity as the tile they are standing on, as well as not fall off it.

I was thinking of creating a pointer to the tile they are colliding with on the top (that is standing on it) and setting the velocities to be equal to that plus whatever the player presses (so going left or right or jumping).

However, I am unsure how to check if they collide and how to check if the player had jumped off the tile. I know how to check if the player's collision is at the top using half widths and half heights, but beyond that is a mystery.


texts:
I'm have problem with Isometric. I'm don't know how to name this "problem", but I'm show you some sceen what I get and what I'm need to get.

My code now drawing something like: http://2.bp.blogspot.com/_rqhF_8E1nlA/R59d_PmoREI/AAAAAAAAAGo/3yHpmy55moc/s400/lore2.png

But I'm need draw something like this:
http://3.bp.blogspot.com/_rqhF_8E1nlA/R59epfmoRFI/AAAAAAAAAGw/cE_o-A0bvm0/s400/lore3.png

I'm hear this is "Depth sort" But what it is? how I'm can apply to my code and where I'm can learn this?

My code: 'http://jsdo.it/keichioor/exU1


texts: How do I enable and disable objects with a certain tag in C#?

texts:
I have a script that is supposed to find every active object with a certain tag and on the push of a button enable and disable it's meshrenderer and collider. but the script only tries to enable and disable the previous on the object the script is attached to. what am i doing wrong and is there any feasible way to do this?

I've checked all tags, but the script keeps trying to reach this unrelated object. i even tried adding a mesh renderer and a colider. but nothing

here is the script:

private bool on = true;

public void Update()
{
    GameObject[] gameObjectArray = GameObject.FindGameObjectsWithTag("buildnode");

    if (Input.GetKeyDown("b"))
    {
        on = !on;
    }

    if (on == false)
    {
        foreach (GameObject go in GameObject.FindGameObjectsWithTag("buildnode"))
        {
            go.GetComponent<MeshRenderer>().enabled = false;
            go.GetComponent<Collider>().enabled = false;
        }
    }

    if (on==true)
    {
        foreach (GameObject go in GameObject.FindGameObjectsWithTag("buildnode"))
        {
            go.GetComponent<MeshRenderer>().enabled = true;
            go.GetComponent<Collider>().enabled = true;
        }
    }
}

Thank you and have a good day.


texts:
I am trying to draw an circle to Libgdx which is created from Image not ShapeRenderer. But when I try to draw image to SpriteBatch it does not draw smoothly.

I checked the image resolution and Image Dimension is 1673x1673 and Sprite Size is 80x80.

  //This is my GameState code
  @Override
    public void render(float delta) {
        update(delta);
        SpriteBatch sb = game.batch;
        Color bg = ThemeFactory.getInstance().getTheme().backgroundColor;
        Gdx.gl.glClearColor(bg.r, bg.g, bg.b, bg.a);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        sb.setProjectionMatrix(camera.combined);
        sb.begin();
        for(int i =0;i<elements.size();i++){
            if(!(elements.get(i) instanceof Arrow)){
                elements.get(i).render(sb);//HERE IS DRAWING HAPPENING
            }
        }
        sb.end();
        barriers.render(sb);
        renderHud();
    }

My circle constructor and rendering code is below.

public Circle(Texture texture, Size size, Vector3 position){
        mSprite = new Sprite(texture);
        mSprite.setSize(size.width, size.height);//80x80
        mSprite.setPosition(position.x, position.y);
        mSprite.setOriginCenter();
    }
@Override
public void render(SpriteBatch sb) {
    mSprite.draw(sb);
}

I tried TextureFilters Nearest Nearest and Linear Linear but nothing has changed. And also increased samples for desktop and android applications, nothing has changed too.


texts: Best way to deal with Collision in JavaFX

texts:
This question I'ts no exactly a fix for the current game I'm working on, but I am showing it as an example to explain my problem. I just want to know the best way to handle collision in JavaFX.

My problem is that I cant seem to make collision work with javaFX using the .intercept() function. the way I'm doing it is making a Pane that has the image and different overlapping rectangles that make the collision box. then i add this pane to another pane(the game world). then when I try to get the collision boxes that i want to compare and use .intercept() function it doesn't work, they seem to always collide no matter what, I am using .setLayoutX and Y to move my pane(the ship pane) if that matters and yes I am using .getBoundsOnParent()

The only way i have found that kind of works is comparing the panes themselves but that doesn't work since it just tries to compare the fills.

This is my ship:

This is my Collision Box:

Here is colliding by using the whole pane(see it doesn't work)


texts:
I'm not sure if this is at all possible, but maybe it will spark up an interesting conversation. (Sidenote: working on a small game in Löve).

I'm making an archery shooting kind of game, and I was thinking it might be cool to have critical and regular hits based on where the user shoot the arrow at the enemy. Example, if I have a troll image, and the user clicks the head of the troll, it will count as a critical hit.

Checking to see if the user clicked on the top part of the image vs the bottom, isn't the tricky part. The hard bit will be to check if the user clicked on apart of the image, instead of blank space in the png...

So, main question: Is it possible to get the rgb value of where an image has been clicked, to determine if they hit or missed the target.

Also, if this is at all possible, is there anyone familiar with Löve that can confirm it is doable?

Edit: I'm realizing now it's not the rgb value I want to look for, it is whether or not the clicked pixel has transparency. If it is 100% transparent that means the user missed the image.


texts:
I have an image-button and I set its position in create in this way:

imageButton.setPosition(orthographicCamera.position.x+150,150);

The problem is that the position always changes, despite I set it in create.
Also if I change device, I notice that the coordinates are busted, wrong, instead other views are right.

If I write setPositionin render, the image-button is faster than the camera, it gets away from the screen, but for other views, this doesn't happen because they follow the camera. Why?


texts: Is there a way to customize the Game-view Editor GUI?

texts: I need to add a simple slider like scale slider in Game-view to change the timescale because I usually test my games by changing timescale.


texts: Handling 3D perspective for different aspect ratio

texts:
I have problem for supporting different aspect ratio in developing Mobile Game.

I was developing on 2:3 screen which is iPhone 4 (Retina).

When I use width and height for screen size and use fixed FOV, then most of cases

look ok, but in 3:4 (which is iPad), the user can "See More" horizontally.

If I force the aspect ratio to 2:3, then looks "squeezed".

I am lost adjusting other values like moving camera, or changing FOV.

Is there any proper way or tips??

Or, What is good FOV for portrait mobile device screen which can cover most of aspect ratio look ok? - I am currently using 45 - and force aspect ratio to 2:3


texts:
I recently asked about how to separate entities from their behaviour and the main answer linked to this article: http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/

The ultimate concept written about here is that of: OBJECT AS A PURE AGGREGATION.

I'm wondering how I might go about creating game entities as pure aggregation using C#. I've not quite grasped the concept of how this might work yet. (Perhaps the entity is an array of objects implementing a certain interface or base type?)

My current thinking still involves having a concrete class for each entity type that then implements the relevant interfaces (IMoveable, ICollectable, ISpeakable etc).

How can I go about creating an entity purely as an aggregation without having any concrete type for that entity?


texts: How to modularly call a script based on parameters within the script?

texts:
I am coding an interaction system in Unity that does things based on whether the player taps interaction, or holds interaction. Each object holds their own scripts of how a player can interact with them and what happens (e.g., they can physically lift an object, add an object to their inventory, open/close a door, etc)

What I want is for the interactable_object to call component scripts that have been added to it and categorized as tapInteraction or holdInteraction, but I also want the component scripts to be separated from how they're called (e.g., they might be called via tap or hold, it shouldn't matter).

If I use interfaces, the tapInteraction could check for GetComponent<ITap>() and the holdInteraction could check for GetComponent<IHold>(), but then wouldn't each action need separate scripts defined as Lift : ITap and Lift : IHold? I feel like there would be a lot of repetition.

I'm wondering if there is some better way to go about this.

EDIT:

Thank you very much for the input DMGregory and Alex F!

I ended up going with an interface approach similar to what Alex F answered, but with two key differences:

It was very important to me to have the actions as components on the gameobject since a specific action (e.g. Lift or AddToInventory) would have a large amount of customization from object to object.
I also wanted the interaction to return a status as to whether it succeeded or not.

As such I created a base class Interaction that implements the interface IInteraction with a bool TryInteraction method, and registers/deregisters itself to an interactable_object via OnEnable and OnDisable as the tapAction or holdAction depending on if that Interaction is set as a tapAction or holdAction.

InteractionLift and InteractionInventoryPickUp inherit that base Interaction class, they implement the TryInteraction interface, and depending on their parameters will register themselves to a interactable_object script as either the hold or tap action. Then the interactable_object fires the hold or tap TryInteraction accordingly.


texts: I have come across this term "streamlined" user interface, and I wonder how is it different from other user interface type? What is the different between "streamlined" and "non-streamlined" user interface?


texts: How to tell which segment user is interacting with in dynamic road building system?

texts:
Im prototyping dynamic road building system as seen in most city builder games. I gather the points from user input (red dots) and programmatically generate mesh.

It's currently one big mesh, seems like a good default rendering performance wise.

Starting a new road/creating intersection from already existing road is a very important feature. Everything is pretty straight forward except how to know which segment user is hovering, clicking.

Options:

split segments into separate gameobjects and attach collider to each
use single big mesh and create empty gameobjects for colliders only

Is there a better way besides these two? That would be a lot of colliders if you consider the scale of city builders. I suspect there's a smarter way..

Note: on the other hand, if user adds new intersections, updating a huge mesh could be a problem. If I split meshes into reasonable chuncks, I could localize updates to only affected meshes.

Simplified data structure:

public class Road {
    public List<Segment> segments;
}

public class Segment {
    public Vector3 start;
    public Vector3 end;
}


texts: How to connect a UPhysicsConstraintComponent of an AActor to an FKSphylElem (capsule body) of a ragdoll?

texts:
I'm trying to connect an Actor's UPhysicsConstraintComponent to a capsule body of a ragdoll. The reason I do it this way, instead of just using sockets on the constraint, is bodies may have offsets from bones, and than connected things things would look incorrect. I'd like to connect to the physics bodyFKSphylElem  instead of the bone/socket.
The Physics Asset has a TArray<UPhysicsConstraintTemplate> called ConstraintSetup, which I am adding my "Actor constraint" to. It also has a TArray<USkeletalBodySetup> . These USkeletalBodySetups contain the geometries I'd like to connect to,in this case capsules as FKSphylElems.
I wrote some code to give my idea a test.
I am setting up bone and component names for the new constraint, but it does not connect objects, although the new UPhysicsConstraintTemplates and FConstraintInstances are added to the Phats ConstraintSetup (checked in the debugger).
   void UBPLibrary::ConnectConstraintToSkeletalMeshActorPhysicsAsset(
       UPhysicsConstraintComponent* Constraint,
       USkeletalMeshComponent* Mesh,
       FName BoneName) {

     if (!IsValid(Mesh) || !IsValid(Constraint))return;

     UPhysicsAsset* Phat = Mesh->PhysicsAssetOverride;

     if (!IsValid(Phat))return;

     UPhysicsConstraintTemplate* constraintTemplate = NewObject<UPhysicsConstraintTemplate>();

     FConstraintInstance * ConstraintInstance = &Constraint->ConstraintInstance;

     ConstraintInstance->ConstraintBone1=BoneName;
     ConstraintInstance->ConstraintBone2=FName(Constraint->GetName());

     constraintTemplate->DefaultInstance = *ConstraintInstance;

     if (!IsValid(constraintTemplate))return;

     Phat->ConstraintSetup.Add(constraintTemplate);

     //apply changes to the ragdoll
     UWorld* world = GetWorld(Constraint);
     FPhysScene* PhysScene_PhysX = world->GetPhysicsScene();

     Mesh->TermArticulated();
     Mesh->InitArticulated(PhysScene_PhysX);
 }


texts: Is it possible to get vertices after Primitive Assembly step (after face culling)?

texts:
I would like to check which vertices will be rendered from direction A (with face culling enabled) and render it from another direction to visualize face culling effect.

I have found information that using Transform Feedback I can received data from vertex or geometry shader. My question is if is it possible to get data from primitive assembly step and use it to render scene from another direction or should I calculate by myself which faces should not be rendered?

Any help and information would be greatly appreciated


texts: Fastest way to look up an entity with a set of components?

texts:
I'm currently trying to implement an ECS system, but I've sort of ran into a problem trying to fetch all of my entities that have a specific set of components. I currently have a Dictionary that maps a component name to a list of Guids (entities), so I have no problem fetching a list of entities if I were to query for just one component. But if I were to query entities for more than one component (e.g. all entities that have Render and Transform component), I run into a problem where it's no longer a constant time lookup.

I could probably loop through the entities to see if they contain that set of component names (they are stored in a dictionary that maps Guid to a list of strings), but I was thinking that there could be a faster way of doing this?


texts:
I'm having trouble with how to structure a game using c99. I've seen a few tutorials on making a game loop, but they are all done with c++ and classes. My main problem seems to be moving data around between the functions without creating a mess, and what stuff to put in what header files etc. Do I just do something similar to the c++ loops, and create a class-like header with a structure containing all items needed by more than one of the functions, along with the prototypes of said functions, and include the header in each function's header file? Then, in the main function, instantiate the structure and pass a pointer to it to every function in the loop?

Is this ok, or is there a better way to do it, and are there any good 'c' specific tutorials available?

Cheers


texts: Storing Player Location/Data in an Online Game

texts:
I know this question has been asked and answered in some threads, but I'd like a more beginner dumbed down explanation.

So player information, specifically direction and position, need to be updated constantly, for tons of players at the same time.

Let's just say 10 players in the same room move an inch in some direction. All of the other players need to see that instantly, obviously. I realize that saving the location to the database, and getting the location for everyone to see is a horrible idea.

So I guess my question is... how does this work? What happens if a player alt-f4's or kills the game process without saving or doing a "normal" exit? How often should I save the location to the database?

Thanks


texts: What's a good data structure solution for a scene manager in XNA?

texts:
I'm playing with XNA for a game project of myself, I had previous exposure to OpenGL and worked a bit with Ogre, so I'm trying to get the same concepts working on XNA.

Specifically I'm trying to add to XNA a scene manager to handle hierarchical transforms, frustum (maybe even occlusion) culling and transparency object sorting.

My plan was to build a tree scene manager to handle hierarchical transforms and lighting, and then use an Octree for frustum culling and object sorting. The problem is how to do geometry sorting to support transparencies correctly. I know that sorting is very expensive if done on a per-polygon basis, so expensive that it is not even managed by Ogre.
But still images from Ogre look right.

Any ideas on how to do it and which data structures to use and their capabilities? I know people around is using:

Octrees
Kd-trees (someone on GameDev forum said that these are far better than Octrees)
BSP (which should handle per-polygon ordering but are very expensive)
BVH (but just for frustum and occlusion culling)

Thank you

Tunnuz


texts:
You can see the effect in many games. The camera sways or wiggles a bit while walking to make the movement feel more realistic.

I have implemented a camera in my game. (Who'd have thunk it?) So is there a common approach to build this swaying effect in?


texts: Float inaccuracy. libgdx only? java only? also why?

texts:
Hey all I have just come to notice that floats are not accurate even when they are explicitly set and unchanged. For example i have some basic code running and it is:

 if (bike.getY() < previousBikeY){
        bike.accelY = 50f;

        System.out.println("bike accel Y :" + bike.accelY);
    }

The result in the log is:

I/System.out: accelY: 49.770126

If I wanted 49.77 id have set 49.77, this also makes me wonder about all the other uses of float i have (such as position, speed, gravity, time, etc).

A) Does this happen in other languages such as C++ or C#?
B) is this normal and something i should ignore OR do I need to take action?


texts: How to play a sound by C# that is linked to the object with AudioSource?

texts:
I trying to play a sound while the player is ontriggerenter. The sound is linked to the object with a AudioSource component. But notting happened.

using UnityEngine;
using System;
using System.Collections;

public class FloatBehavior : MonoBehaviour {

    Vector2 floatY;
    float originalY;

    public float floatStrength = 1;

    AudioSource triggerAudio;                                    // Reference to the AudioSource component.

    void Start () {
        this.originalY = this.transform.position.y;
        triggerAudio = GetComponent <AudioSource> ();
        Debug.Log (triggerAudio);
    }

    void Update () {
        transform.position = new Vector3(transform.position.x,
                                         originalY + ((float)Math.Sin(Time.time) * floatStrength),
                                         transform.position.z);
    }

    // OnTriggerEnter 2D
    void OnTriggerEnter2D(Collider2D other) {

        // If gameObject comes in contact with player
        if (other.gameObject.tag == "Player") {
            // Play the hurt sound effect.
            triggerAudio.Play ();
        }

    }

}

Trying to debug, but the triggerAudio object will retrieve: woodstump 3 (UnityEngine.AudioSource) UnityEngine.Debug:Log(Object) FloatBehavior:Start() (at Assets/C#/Objects/FloatBehavior.cs:17).

What am I missing in my script? Should I use AudioClip also?


texts:
Im trying to create a car game in c sharp! Im now trying to figure out a way to get some sounds into the game! For example, the acceleration sound of the car.

I recently tried to add a 5 second-sound of a real car accelerating, but I don't think its the right way to do it. Because then i have to start from the beginning all the time of the clip when i accelerate.

Is there maybe some way to work with frequencies? To send a frequency to the speakers and then just increase it when I accelerate (And to make it sound like a car)

I've heard about PWM, could that be something?

Thanks!


texts:
I am implementing online multiplayer game where client must be written in AS3 (Flash) to embed game into browser and server in C++ (abstract part of which is already written and used with other games).

Networking models may differ from each other, but currently I'm looking toward game's logic run on both client and server parts but they're written on different languages while it's not the main problem.

My previous game (pretty big one - was implemented with efforts of ~5 programmers in 1.5 years) was mainly "written" within electronic tables as structured objects with implemented inheritance: was written standalone tool which generated AS3 and C++ (languages of platforms to which the game was published) using specified electronic tables file (.xls or .ods). That file contained ~50 tables with ~50 rows and ~50 columns each and was mainly written by game designers which do not know any programming languages. But that game was single-player.

Having declared problem with my currently implementing MMO, I'm looking toward some vast pipeline, where will be resolved such problems like:

game objects descriptions (which starships exist within game, how much HP they have, how fast move, what damage deal...)
actions descriptions (what players or NPCs can do: attack each other, collect resources, build structures, move, teleport, cast spells) - actions are transmitted through server between clients
influences (what happens when specified action applied on specified object, e.i "Ship A attacked Ship B: field "HP" of Ship B reduced by amount of field "damage" of Ship A"

Influences can be much more difficult, yes, e.i. "damage is twice it's size when Ship has >=5 allies around him in a 200 units range during night" and so on. If to be able to write such logic within some "design document" it will be easily possible to:

let designers to do their job without programmer's intervention or any bug-prone programming
validate described logic
transfer (transform, convert) to any programming language where it will be executed

Did somebody worked on something like that?
Is there some tools/engines/pipelines which concernes with it?
How to handle all of this problems simultaneously in a best way or do I properly imagine my tasks and problems to myself?


texts: How do game engines mitigate CPU cost for many trigger zones & entities?

texts:
It's a rather simple question, but a somewhat fundamental in computing in general.
Let's say we have a player controlled character in an open world. The world is large. In this game-world we have a vast amount of trigger zones that basically responsible for changing music, changing lighting, changing animation and so on. And the game clock runs at 60 fps.

In this situation we have so many subroutines which sensitive to "If a player has entered the area" that we can count then by thousands. Here's where I'm not sure. Since we have so many trigger subroutines it seems we can't just simply put them to check, if a player has entered the area, every 60th of a second even though this simple "listening" is not gonna take up a lot of resources; but scaling the world bigger and bigger will create a performance hit for sure, with this approach. So, there must be some other mechanism to manage all of those trigger zones. I inclined to think that the mechanism goes like this:

a player's character subroutine constantly (at 60 fps) updates its position.
With each update frame the playable character subroutine goes
something like this: Hey, I'm at the position x(5.0),y(3.0),z(10.5)
so what branch of code should I execute being at this position? And
the respond comes from an indexed map where we have every possible
coordinates and corresponding code to execute. (of course we can have
a lossless compression going on for saving up the memory)

Am I correct? ...or does every subroutine listen for an input every update frame? (hope it's not :) )

Edit addition:
I'm not asking if games divide their worlds into chunks, areas or grid cells for saving up memory, but asking about their approach on saving up CPU/GPU cycles and how unactivated triggers are treated.

Thank you, who have already given their answers.


texts:
I'm currently developing a Flash game like 'Tiny Wings'. I have a lot of work done, but i'm currently working on placing the items ( coins and obstacles ) on the terrain.

My player it is moving on a auto-generated terrain (based on Emanuele Feronato's tutorials) so every time the player's x position is greater than (screenWidth + x) another hill is generated and so on.

I'm currently having problems placing the items in a correct angle and put 5 or more items together on a hill.

Could you please help me with this?

Thanks,
Regards.

PS: This is the URL to the Emanuele Feronato post and the code to make the hills
http://www.emanueleferonato.com/2011/10/04/create-a-terrain-like-the-one-in-tiny-wings-with-flash-and-box2d-%E2%80%93-adding-more-bumps/


texts: How to assign separate controller axes to Player1, Player2?

texts:
I need to have two players moving in a level for a school project and my player controller is already set up for using axis inputs (as opposed to discreet buttons) for directional input. I already know I can assign custom key inputs from the inspector if I just declare a public variable (initialization optional because there is a drop-down list in the inspector):

public KeyCode jumpInput = KeyCode.Space;

How can I assign custom directional axis inputs from the inspector? I already have alternative horizontal and vertical axes defined in my preferences, I just need to know how to assign them.

Been putting this project together for 36 CONTIGUOUS hours and I am ready to put it (and myself) to bed. Thank you in advance for your time.

EDIT: My confusion was coming from (beyond being awake too long) thinking that I needed a special data type (like KeyCode) for an Axis, and couldn't find it in the reference. But I didn't consider making a public string and plugging that into the input. This way, I just need to know what I named the new axes and use that for the public string.


texts:
I want to set a background color for my game.

I found this solution:

function create() {
  this.cameras.main.setBackgroundColor("#d5d5d5");
}

but I want to be sure that there is not a more standard way to do this, because editing the camera's property means that the background would be different for another camera.

Thank you for your help.


texts:
I am currently working on the 2D Bouncing ball physics that bounces the ball up and down. The physics behaviour works fine but at the end the velocity keep +3 then 0 non-stop even the ball has stopped bouncing. How should I modify the code to fix this issue?

Here is the video shows how it works.
Note: Bandicam cannot record the velocity transition between -3 and 0. So, it just shows -3 when the ball stops bouncing.
http://www.youtube.com/watch?v=SEH5V6FBbYA&feature=youtu.be

Here is the generated report: https://www.dropbox.com/s/4dkt0sgmrgw8pqi/report.txt

    ballPos         = D3DXVECTOR2( 50, 100 );
    velocity        = 0;
    acceleration    = 3.0f;

void GameClass::Update()
{
    // v = u + at
    velocity += acceleration;

    // update ball position
    ballPos.y += velocity;

    // If the ball touches the ground
    if ( ballPos.y >= 590 )
    {
        // Bounce the ball
        ballPos.y = 590;
        velocity *= -1;
    }

    // Graphics Rendering
    m_Graphics.BeginFrame();
    ComposeFrame();
    m_Graphics.EndFrame();
}


texts:
I bought a book called Programming game AI by example and I am trying to implement the arrive steering behavior. The problem I am having is that my objects oscillate around the target position; after oscillating less and less for awhile they finally come to a stop at the target position. Does anyone have any idea why this oscillating behavior occur? Since the examples accompanying the book are written in C++ I had to rewrite the code into C#. Below is the relevant parts of the steering behavior:

private enum Deceleration
{
    Fast = 1,
    Normal = 2,
    Slow = 3
}

public MovingEntity Entity { get; private set; }

public Vector2 SteeringForce { get; private set; }

public Vector2 Target { get; set; }

public Vector2 Calculate()
{
    SteeringForce.Zero();

    SteeringForce = SumForces();

    SteeringForce.Truncate(Entity.MaxForce);

    return SteeringForce;
}

private Vector2 SumForces()
{
    Vector2 force = new Vector2();

    if (Activated(BehaviorTypes.Arrive))
    {
        force += Arrive(Target, Deceleration.Slow);

        if (!AccumulateForce(force))
            return SteeringForce;
    }

    return SteeringForce;
}

private Vector2 Arrive(Vector2 target, Deceleration deceleration)
{
    Vector2 toTarget = target - Entity.Position;

    double distance = toTarget.Length();

    if (distance > 0)
    {
        //because Deceleration is enumerated as an int, this value is required
        //to provide fine tweaking of the deceleration..
        double decelerationTweaker = 0.3;

        double speed = distance / ((double)deceleration * decelerationTweaker);

        speed = Math.Min(speed, Entity.MaxSpeed);

        Vector2 desiredVelocity = toTarget * speed / distance;

        return desiredVelocity - Entity.Velocity;
    }

    return new Vector2();
}

private bool AccumulateForce(Vector2 forceToAdd)
{
    double magnitudeRemaining = Entity.MaxForce - SteeringForce.Length();

    if (magnitudeRemaining <= 0)
        return false;

    double magnitudeToAdd = forceToAdd.Length();

    if (magnitudeToAdd > magnitudeRemaining)
        magnitudeToAdd = magnitudeRemaining;

    SteeringForce += Vector2.NormalizeRet(forceToAdd) * magnitudeToAdd;

    return true;
}

This is the update method of my objects:

public void Update(double deltaTime)
{
    Vector2 steeringForce = Steering.Calculate();

    Vector2 acceleration = steeringForce / Mass;

    Velocity = Velocity + acceleration * deltaTime;

    Velocity.Truncate(MaxSpeed);

    Position = Position + Velocity * deltaTime;
}

If you want to see the problem with your own eyes you can download a minimal example here.

Thanks in advance.


texts: Unity: Cannot access variable of C# script from another object

texts:
I have already found similar questions on stackexchange.com related to accessing variables from another object. But my question seems to have a slightly different context and the answers from those questions are not working.

I have the following (stripped off) scene comprising the standard FPS character:

Scene001
  |
  |--FPSController
       |
       |--FirstPersonCharacter

My (stripped off) Assets hierarchy is as follows (folders are enclosed with <> brackets):

<Assets>
  |
  |--<Scripts>
  |     |
  |     |--Actions.cs
  |
  |--<Standard Assets>
        |
        |--<Characters>
              |
              |--<FirstPersonCharacter>
                   |
                   |--<Scripts>
                         |
                         |--FirstPersonController.cs

Now FirstPersonController.cs is attached to FPSController by default and Actions.cs is attached by me to FirstPersonCharacter.

Excerpt from FirstPersonController.cs is as follows:

...
namespace UnityStandardAssets.Characters.FirstPerson
{
     ...
     public class FirstPersonController : MonoBehaviour
     {
          ...
          private void GetCharacter()
          {
               GameObject _obj = GameObject.Find("FirstPersonCharacter");// ok here
               bool is_acted = _obj.GetComponent<Actions>().is_acted; // error here, please see below
          }
          ...
     }
}

Excerpt from Actions.cs is as follows:

public class Actions: MonoBehaviour {
    ...
    public static bool is_acted;
    ...
}

All I want is to access bool is_acted variable of Actions.cs from FirstPersonController.cs.

Error is as follows:

Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/
FirstPersonController.cs(63,38):error CS0246: The type or namespace
name `Actions' could not be found. Are you missing an assembly reference?

To me this seems to be a problem of namespace or folder location!!?

Any help is highly appreciated. Thanks in advance.

Updated above

Changed Action to Actions.
Corrected typo ().

Sample project:

https://ufile.io/knmxj


texts: Where should I put my mob rendering code?

texts:
I'm making a simple LWJGL game. However, I'm a bit confused about rendering. So I have a Mob class and a TriangleMob is a basic enemy.

package daniel.entity.Mob;

public class TriangleMob {
        public void render(){
        }
        public void move(){
        }
}

Now I'm wondering do I put a render method in the TriangleMob or do I put some render method in graphics bit.

I'm really confused as I thought you needed to put all rendering in it's own bit. Then, all game logic like movement in another bit. Essentially, I want to spawn a TriangleMob in the SpawnMob class and then render it. I could put the render method in the TriangleMob class, however I want logic and rendering to be in different parts.


texts: Intelligently move aircraft using curves

texts:
I am trying to code a script to move an aircraft entity from point A to point B and at some point in the middle of moving have the aircraft forward vector face Point C (to fire a missile at an enemy entity at C).

I implemented a bezier curve script that takes as input a list of waypoint and tangent handle Vector3 (Tangent handle is angle at point + weight which is represented by the length of the handle) which I plan to use to move the aircraft alone but I have not figured out a good algorithm to determine where to move to and the tangents at those points.

The control points in the img above are the same as my tangent handles.

The conditions are:

Aircraft must start at A, waypoint 0 is therefore at A
Tangent 0 angle must match Aircraft starting forward vector direction
Waypoint N (last waypoint) must be at point B (finishing location).
At some Waypoint (1 - N) the tangent must be facing the enemy position C
The last tangent must be level with the y = 0 plane (aircraft must be parallel with the ground)

Constraints

A,B,B are on the y=10 plane. This does not mean that waypoints in the middle of the movement need

The aim is to get smooth and somewhat natural looking movement, overly sharp changes of direction are undesirable.

My initial implementation was as follows:

waypointSequence.addPoint(position, tangentHandlePosition)

Vector3 middleWaypointPosition =
    new Vector3((aircraftTransform.position.x + movementLocation.x + enemyTransform.position.x) / 3f,
    (aircraftTransform.position.y + movementLocation.y + enemyTransform.position.y) / 3f,
    (aircraftTransform.position.z + movementLocation.z + enemyTransform.position.z) / 3f);
Vector3 finishTangent = middleWaypointPosition + (enemyTransform.position - middleWaypointPosition) / 2;
finishTangent.y = 10;
// Add first point - A position, A forward tangent
waypointSequence.addPoint(aircraftTransform.position, aircraftTransform.position + aircraftTransform.forward * 10);
// Second point - Centroid of A, B, C. Tangent is pointing at C
waypointSequence.addPoint(middleWaypointPosition, finishTangent);
// Last point - position is at B
waypointSequence.addPoint(movementLocation, movementLocation +
    (movementLocation - attackUnit.transform.position).normalized * 10);

It works somewhat well in most cases but there are a number of edge cases, for instance A and B being at the same position makes the craft move towards the target then suddenly turn back with a 180 degrees turn towards B. There are a number of cases where I observed strange behavior.

Does anyone have any suggestions on how to design this algorithm?


texts: How to keep the ball on zigzag movement?

texts:
I recently make a zig-zag movement it works perfectly but after the ball hit the collider or obstacle the ball is changing their direction like just forward, not zig-zag anymore I've tried to update the velocity after collide but it's same, also I have tried to constant the magnitude but that's not what I want
here my script
public float magnitude;
    public float forwardSpeed;
    public float horizontalSpeed;

    private Vector2 horizontalAxis;
    private Vector2 negationVector;

    public Rigidbody2D rb2d;
    public m_GameManager _GameManager;

    public bool isOver = false;

    private void Awake()
    {

        horizontalAxis = Vector2.right;
        negationVector = new Vector2(-1f, 0);
    }

    private void Start()
    {
        _GameManager = FindObjectOfType<m_GameManager>();
        UpdateVelocity();
    }

    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            ReverseHorizontalVector();
            UpdateVelocity();
        }
    }

    private void ReverseHorizontalVector()
    {
        horizontalAxis *= negationVector;
    }

    private void UpdateVelocity()
    {
        Vector2 velocity = GetCompositeVelocity();
        rb2d.velocity = velocity;
    }

    private Vector2 GetCompositeVelocity()
    {
        Vector2 forward = Vector2.up * forwardSpeed;
        Vector2 horizontal = horizontalAxis * horizontalSpeed;
        Vector2 composite = (forward + horizontal);

        return Vector2.ClampMagnitude(composite, magnitude);
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        UpdateVelocity();
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Goal"))
        {
            _GameManager.IncreaseScore();
        }
        if (collision.gameObject.CompareTag("L") || collision.gameObject.CompareTag("R") || collision.gameObject.CompareTag("Death")
            || collision.gameObject.CompareTag("Player"))
        {
            StartCoroutine(_GameManager.waitAfterDeath());
            isOver = true;
        }
    }

like I said before the ball zig zag but after colliding the movement change like that.


texts: How to slow down a sprite that updates every frame?

texts:
I am going through a Allegro 5 tutorial which has a game loop.

There is also a variable "active" which determines if a key is being held down. Thus if the left key is being held down active is on and it begins looping through the row on the sprite sheet that corresponds to moving left.

The problem is that this logic is checked everytime the loop is performed thus at approximately 60 fps the three images that are used to do the left walking animation cycle round super fast which means my character looks like it is in a rush.

Total beginner question: so what is the correct way to slow down the transition between sprites so that the walking looks like it is done at a moderate pace.

Here is the code used to transition across the sprite between the three different phases of the person walking:

        if (active) {
            sourceX += al_get_bitmap_width(player) / 3;
        } else {
            sourceX = 32;
        }

        if (sourceX >= al_get_bitmap_width(player)) {
            sourceX = 0;
        }

I can kind of guess what it should be in plain English: update sourceX only every certain part of a second but I can't think of how to put this into code.


texts:
I'd like to get into online games programming. I thought that as a start i'd be a good idea to implement an online database that would store the progress and score for a game i have made, i'll probably want to implement an account system too.

My issue is, i can't see to be able to ask google the right question. I don't know where to start. I've touched some on SQL and PHP, HTML and XSL, but, to me they're just languages, i can't see the big picture, how do these things connect to form a working service? I'm not looking for a solution, i just don't know what should i learn.

I'm not looking for knowledge on sockets, i'm familiar with network programming, i just don't understand the "modern" process of handling databases. I'd be very happy if somebody could lay out the structure of a database, how you put it out on the web, how you access the information and change it (not in a direct solution, just "this is done by programming a filter in SQL"), what languages are used for it, etc.


texts: Applying a getButtonDown & getButtonUp on a GUI button for touch input

texts:
I have a GUI interface with a button for the character's attack, however I want to implement a defense button where the user can hold the button down to block incoming attacks, when the user stops touching the button then the player goes back to idle.

Right now I have the attack button working correctly, whenever the button gets pressed, it triggers a method where the animator gets called and performs the action. I want to implement the getButtonDown("") and getButtonUp("") used commonly with the keyboard input. How can i implement such fucntions to a GUI button?


texts: Is there a way to force a resolution on Android when using Monogame?

texts:
I think I looked everywhere but I couldn't find a way.
My phone has a native resolution of 1920x1080 and I would like to run my game at 1280x720.

I tried by changing PreferredBackBufferWidth and PreferredBackBufferHeight but it doesn't seem to have any effect.

Is this possible?


texts:
Video playback in jMonkeyEngine 3.0 seemed to be in limbo for quite a while until I chanced upon this thread about playing videos by integrating JavaFX 2 into the JME3 framework. This coupled with the recent announcement of MP4 playback support in JavaFX made JME3 a real contender for a project I'm currently working on.

I followed the prescribed method as mentioned in the former thread, got the sources from the JME3-JFX project page and setup the project in eclipse. When I ran the example [TestMovie.java] with the given URL from Oracle, it ran smoothly with no issues. However when I attempted to play an MP4 file, it played for a brief period with messed up colours and then exited with a java.lang.IllegalArgumentException exception.

Here is the eclipse console output :

INFO: Audio effect extension version: 1.0
Nov 27, 2014 6:33:13 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio max auxilary sends: 4
Nov 27, 2014 6:33:34 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalArgumentException: Number of remaining buffer elements is 6627840, must    be at least 14745600. Because at most 14745600 elements can be returned, a buffer with at least 14745600 elements is required, regardless of actual returned element count
at org.lwjgl.BufferChecks.throwBufferSizeException(BufferChecks.java:162)
at org.lwjgl.BufferChecks.checkBufferSize(BufferChecks.java:189)
at org.lwjgl.BufferChecks.checkBuffer(BufferChecks.java:230)
at org.lwjgl.opengl.GL11.glTexImage2D(GL11.java:2845)
at com.jme3.renderer.lwjgl.TextureUtil.uploadTexture(TextureUtil.java:352)
at com.jme3.renderer.lwjgl.LwjglRenderer.updateTexImageData(LwjglRenderer.java:1913)
at com.jme3.renderer.lwjgl.LwjglRenderer.setTexture(LwjglRenderer.java:1936)
at com.jme3.material.MatParamTexture.apply(MatParamTexture.java:86)
at com.jme3.material.Material.render(Material.java:1088)
at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:523)
at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:322)
at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:374)
at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:763)
at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:719)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:983)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1029)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:252)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:745)

Now I'd like to clarify that the same MP4 file played flawlessly in a vanilla JavaFX project. Also, one of the developers has confirmed in the first mentioned thread on the jMonkeyEngine forums that he was able to play MP4 videos flawlessly and three of them simultaneously nonetheless. I'm testing these samples on Java 1.8 u25 on Windows 8.1 Pro [x86-64] running an Intel Core i5 [Haswell] with Intel HD 5000 graphics.

I'm a beginner to graphics development and am aware that the jMonkeyEngine forums are the best place to ask my question but their forum's Q/A section seems to be broken and I'm unable to post there. Any and all help will be appreciated.


texts: Programmatically drawing a "pencil" line or curve

texts:
If you look closely (scan it on a computer and zoon in) at a carbon pencil line you can see that there are differing shades of gray.  I tried looking on the Internet for any kind of algorithm or statistical model for how that gray would be drawn programatically.  Does anyone have information on this?  Thanks a lot!!

I want to make drawings on a computer that look they were drawn with a pencil.


texts:
I dont understand part of UDK's license about DLLBind:

does it allow to use DLLBind in UDK projects? Could I use DLLBind for commercial games without buying c++/native license?


texts: Android Java rectangle collision detection not working

texts:
I had been hard coding a collision detection system which was buggy. Then I came across using rectangles for collision detection. So I put it all in and it does not work, I put a log in and it never logged.

Note to Java programmers who are not Android programers: Android uses the word Rect instead of Rectangle.

Code for Block.java:

public Rect getBounds(){
    return new Rect (this.x, this.y, 10, 20);
}

Code for Sprite.java:

public Rect getBounds(){
    return new Rect (this.x, this.y, 20, 20);
}

Code for MainGame.java:

for(Block block : BLOCKS) {
    block.draw(canvas);
    block.rigidbody();

    Rect spriter = sprite.getBounds();
    Rect blockr = block.getBounds();

    if(spriter.intersect(blockr)){
        showgameover = 1;
        Log.d(TAG, "Game Over");
    }

}

Is anyone able to help?


texts: How can I know how difficult a question is?

texts:
I'm making a "Who Wants to be a Millionaire" style of game. I'm really stuck at the part where I should arrange questions from easy to hard.

Isn't this subjective? How can I tell how hard/difficult a question is?


texts:
I've been reading about shaders and looking at code. I found this in the code I'm looking at and it obviously has "Basic.fxo" there.

BasicFX = new BasicEffect(device, L"FX/Basic.fxo");

Now my question is what the file is for? I look in the folder and there is Basic.fx, Basic.fxo, and Basic.cod. I'm familiar with Basic.fx that's the shader? So I took out the .fxo and .cod reran the program and it just regenerated the files? What are the .cod/.fxo files for? Where do they come from? What do they do?


texts: HDR bloom techniques using post processing in Unity3D

texts:
I've seen many posts on how to accomplish HDR bloom effects in Unity3D using its (now legacy) Bloom component as part of the standard assets package.

I'm trying to replicate it using the new post processing package, but I can't seem to get it to work.

I have an an emissive material that's emitting at a value far >1 sitting at 10:

Bloom is set in a Post Processing Profile, and the threshold is >1:

Finally, HDR is enabled on my camera, along with a deferred rendering path.

Yet this doesn't work. I only see the bloom effect if I set my bloom threshold <1, after which all my materials bloom. It's as if HDR is not actually enabled. Anyone know why?


texts: Graph Isomorphism > What kind of Graph is this?

texts:
Essentially, this is a variation of Comparing Two Tree Structures, however I do not have "trees", but rather another type of graph.

I need to know what kind of Graph I have in order to figure out if there's a Graph Isomorphism Special Case...

As you can see, they are:

Not Directed
Not A Tree
Cyclic
Max 4 connections

But I still don't know the correct terminology, nor the which Isomorphism algorithm to pursue, guidance appreciated.


texts: How does the SDL dynamic API inject itself in statically linked code

texts:
I've been using SDL2 for development almost since it came out. Long story short, I stumbled upon the SDL dynamic API explanation. I've looked in SDL_Dynapi.c to understand how it works. I get that the jump table can be updated with function pointers to newer versions of the functions, but what I don't get is how one would actually goes about doing that dynamically.
Did I miss a function declaration, is there some specific function to call outside the application? I have no idea how an updated dynapi loads itself.


texts:
I need a way to detect if animation's clip finished playing and then execute a certain code. Here's some script, that I wrote (called in Update):

    if (Input.GetButtonDown ("Fire1") && pc_atttacking == false && PlayerStats.staminaCurrent != 0) {
        pc_atttacking = true;
        pc_anim.SetBool("attack", true);
    }

    if (pc_anim.GetCurrentAnimatorStateInfo (0).IsName ("attack")) {
        pc_atttacking = false;
        pc_anim.SetBool("attack", false);
    }

But it doesn't work as I want; it executes second code too early - when "attack" animation is at slightly more than half of playing position.
I want to execute it when "attack" animation is at last frame.


texts: Correctly creating/handling events for keypress in MonoGame C#

texts:
I'm having trouble finding the best approach to registering an instantaneous user key-press with MonoGame (where the key has been held down and then released), using events in C#. Unlike the click of a mouse button where only two events are usually required, it seems to me that a keyboard would require a considerable number of events where it would seem infeasible (and incredibly messy) to declare them all. I don't want to have classes individually handle the input themselves by checking the current keyboard state against the last etc.

This is the solution I've come up with, but something tells me it isn't very well designed.

public static class Input
{
    private static KeyboardState ks, ks_old = Keyboard.GetState();

    private static Dictionary<Keys, List<Action>> OnKeyPress = new Dictionary<Keys, List<Action>>();

    public static void AddKeyPressHandler(Action handler, Keys key)
    {
        if (!OnKeyPress.ContainsKey(key))
            OnKeyPress.Add(key, new List<Action>());
        OnKeyPress[key].Add(handler);
    }
    public static void Update() //Update function called every game update
    {
        ks = Keyboard.GetState();

        foreach (Keys key in Enum.GetValues(typeof(Keys)))
            if (!ks.IsKeyDown(key) && ks_old.IsKeyDown(key) && OnKeyPress.ContainsKey(key))
                foreach (var handler in OnKeyPress[key])
                    handler();
        ks_old = ks;
    }

}

With the current setup, objects needing to handle a key-press subscribe their methods in the following way in their constructor:

Input.AddKeyPressHandler(delegate() { Input_OnAPress; }, Keys.A);

What is the optimal way to handle keyboard input with MonoGame? Are there any obvious pitfalls with my code, functionally or design-wise?


texts:
I'm going to develop a real-time browser game using NodeJS in backend for a fast WebSocket, but I'll both prevent bots and other cheats, so my frontend JS might be very advanced.

I'm experienced with developing bot scripts, so I already know that I have to prevent all scripting methods for automating the game (clicking elements, using in-game functions, and so on), but to do that, I have to keep the WebSocket in an anonymous function where the whole game script will be.

Is there a good way to verify that the WS connection is in the official script in case cheaters would like to find a way to stop it to run a modified script?

My current ideas, might not be the best?

Generate the HTML with a script with a unique ID from the backend that the backend will accept only once, and other connections using this ID will just be rejected
Same as above, but push the ID through headers (might improve performance when comparing)
Bind the WS handshake value to their IP in the backend (will not allow multiple users on same IP, and will require the backend to unbind the IP before it can be used again - will easily be a problem)
Captcha, I know it can be pushed like every 10 min, but I don't want to use captcha after the login has been verified because the game will require the player to be able to do actions fast in some cases (to survive)

Why so complicated?

I've tried 2 other web games of same category, and another game.

The first was full of issues like latency and UI issues, so it was pain to play. The latency was unstable, but actions was done anyway, no matter if I wasn't aware about it before it was too late, but I'm pretty sure this game uses SSE instead of WS.

The 2nd game was too annoying because it had captcha way too often, like every 10 min. The 3rd game too, it sent captcha way too often. I think that it's okay with a captcha to verify login and registration, but when playing, captchas will make players leave because it's annoying


texts:
I'm trying to make my camera follow a 3D object, the X and Y values from the camera position are the same as the 3D object, but the Z axis is not the same, it has an offset of 13.0f so the camera looks to the object from a distance. The problem is that, the more I go up with the object, more the object disappears on the screen, its like the camera is following it slowly, or like, since the camera is far away then the object goes up faster than the camera, so how do I center the object in the middle of the camera?

[my current code for the view matrix of the camera]

view = glm::lookAt(position, position + forward, up);


texts: import text strings into Unity editor 3D text objects so that Scene View displays them

texts:
I am having trouble finding a solution to this problem.  I want to generate the text for TextMesh.text in a custom application and import into the Unity editor so that I can then scale the text to fit.  If anyone could point me in the right direction to simply edit a 3D Text game objects' text mesh.text property from a script so that it is reflected in the scene view in Unity's editor, I would greatly appreciate it!

Best Regards,
Ben


texts: Android APK export duplicating libgdx assets folder

texts:
I'm developing a game using libgdx targetting Java desktop and Android. For the assets I have a "data" folder inside the "assets" folder in the Android project. Then, I link it from the desktop project.

My problem comes when I export, my .apk contains:

assets
com
lib
data
META-INF
res
AndroidManifest.xml
resources.arsc
classes.dex

This means my data files are duplicated in "assets/data" and "data" being the first one the only relevant one. This increases my APK size from 5 to 10MB which is kind of annoying. In my file system I only have the "assets/data" folder, no trace of the intruder there.

Does someone have any ideas why is this happening? How can I solve it?

PS: I've tried deleting the intruder manually opening the apk with 7zip but that destroys the checksum and prevents updates to be properly installed (needs complete reinstall).


texts: Phaser: How to call a function inside another function?

texts:
So I actually have the following code that works:

var player;
var box_tnt;

function create (){
    this.physics.add.collider(player, box_tnt, hitTnt, null, this);
}

//the function hitTnt stop the game because the player died
function hitTnt (player, boxes){
   this.physics.pause();
   console.log('Game Over!');
   textGameOver.setText('GAME OVER');
   player.setTint(0xff0000);
   player.anims.play('default');
   gameOver = true;
}

and I want to do something like:

var player;
var box_tnt;

function create (){
    this.physics.add.collider(player, box_tnt, hitTnt, null, this);
}

//the function hitTnt stop the game because the player died
function hitTnt (player, boxes){
    gameOver();
    //other stuff here
}

function gameOver (){
    this.physics.pause();
    console.log('Game Over!');
    textGameOver.setText('GAME OVER');
    player.setTint(0xff0000);
    player.anims.play('default');
    gameOver = true;
}

but I have the following error message:

  TypeError: gameOver is not a function

Do you have please any ideas how to do it properly?


texts: How to create a grid of 3d objects without making them actual GameObjects

texts:
Very simple question:
If I'm going to be generating and placing a lot of 3d objects (in this case cubes), that are not going to be interactive, like no collision, no raycasting intersections etc.  Should they be GameObjects or is there a lighter solution that doesn't inherit the GameObject blob?

Cheers,


texts: Incrementally processing large number of entitites in an entity-component system

texts:
LibGDX/Ashley has a class IntervalIteratingSystem that allows you to process all entities in a particular family every X milliseconds. But if you have a lot of entities to process, it might be a bad idea to do all that at once. For example, if you want to process 10,000 entities once every 10 seconds, you might not actually want to wait 10 seconds, and then process all the entities -- you'd want to "spread it out" over many frames. Perhaps every 100ms you process 100 entities, cycling through them all.

To rephrase: I'd like to process a large number of entities but spread out across multiple frames, preferably:

providing a reasonable guarantee that all entities will processed at least once every X seconds,
enabling you to keep track of how much time has passed since that entity was last processed,
with a random entity order,
all entities are processed an equal number of times.

Here are my ideas so far...(some bad, some good)

Every time an entity is added to the Engine, add a Group1, Group2, or GroupN component (either randomly or sequentially), and then in my EntitySystem I cycle through the various families based on their Group#.
Every 10 seconds, add all 10,000 entities to a list, and then every 100ms, drain and process 100 from that list. (Memory-intensive, and might fall behind)
Every 100ms, iterate over all 10,000 entities, but skip 99% of them randomly (either using a PRNG or by checking their hashcode mod prime).
Maintain a list (a copy, really) of all relevant entities inside an EntitySystem using Engine#addEntityListener() and then process 1% of the list every 100ms by sequentially stepping through it, and wrapping around when reaching the end. (Uses LibGDX's unordered Array so removals are cheap).
Same as 4., but rely on Engine#getEntitiesFor and just let Ashley handle ordering and tracking entities instead of keeping a separate list.

At the moment, #1 and #5 seem most promising. #1 seems to meet all my requirements, but is a bit pervasive (creating and adding a bunch of components), #5 is less pervasive, but doesn't meet the requirements quite as well (#2 and #3 mostly).

Thoughts? Is there something better than these?


texts:
I am taking the step of moving on from Java over to c++, I have been working on my own custom game engine in java for a while so have a good understanding of polymophism, inheritance etc.

Now to the issue:

Currently I am working on a basic level format trying to get entities to render to the screen, this all goes well if i change the code to what i don't want it to be below is the code:

#include <SFML/Graphics.hpp>
#include "../Entities/Player.h"

#include "Layer.h"

class TileMap: public sf::Drawable, public sf::Transformable {
private:
    std::vector<Player> entities;
public:

    Player* addEntity(Player player) {
        entities.push_back(player);
        return &entities[entities.size() - 1];
    }

    void update() {
        for (unsigned int i = 0; i < entities.size(); i++) {
            entities[i].update();
        }
    }

    virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const {
        for (unsigned int i = 0; i < entities.size(); i++) {
            target.draw(entities[i]);
        }
    }

};

The player that is returned in the function is then stored in a DrawableEntiity* player; variable. & this works fine everything updates

As I want a generalized list of entities and not a list for each entity i add to the game i want to be able to change this from

std::vector<Player> entities;

and change it too (obviously including the include for it too)

std::vector<DrawableEntity> entities;

The issue is everytime i store it this way the draw and update functions of the lower level Entity class isn't called and instead the default function inside of the DrawableEntity is called.

This is probably a easy mistake on something I've overlooked but i can't find anything online anywhere that fixes the issue. a full code listing of the Entity classes can be found at http://pastebin.com/3rRuzZHs

Thanks for taking your time to read this
Jordan

P.S: If you need any more information let me know.


texts: My game scene is very busy and I am afraid it may hurt the players' eyes, how can I fix this?

texts:
I recently added many layers to my 2D game scene (multiple background sprites that scroll at different speeds via a parallaxing script) and it hurts my eyes to look at it. I have multiple layers of trees in different shades of green and as I move along I get a jagged movement as the trees overlap each other.

I tried fixing this by removing a layer of the trees, but it did not help. I also tried lowering my movement speed and, while it helped some, I cannot lower it any lower without making the movement painfully slow. I found the antiAliasing script on the unity Scripting API, but I am not sure where to put it, or if that is even what I need. Can anyone help? Have I made my question clear?


texts: Why won't this ClanLib "Hello World" project build in Eclipse CDT?

texts:
I've been trying to get a simple Hello World working with ClanLib using CDT (Eclipse), but I'm just not getting it configured properly.

First, from the command line, I'm able to get it to run using this command:

g++ -o mygame mygame.cpp `pkg-config --cflags --libs clanCore-2.3 clanDisplay-2.3 clanGL-2.3 clanGL1-2.3 clanApp-2.3` -lpthread

So no problems there.

Anyways, I tried setting up the correct build settings in Eclipse, but I just don't know where I'm supposed to add the info for the libraries. I tried adding it in the linker section, that didn't work. I tried a bunch of other things, nothing seemed to work...

Help would be appreciated, possibly as comprehensive as possible... I'm open to alternatives to Eclipse too. And the only reason this is such a problem is because this is the first time I'm trying to start a bigger C++ project, and I decided perhaps it's best to use some tools to make it a little easier, rather than a basic text editor (especially for debugging).

Oh, and I'm running Ubuntu, if that makes a difference. I'm really surprised there aren't any tutorials for setting up ClanLib in a development environment as popular as Eclipse...


texts: Separating Sprites from Models with PyGame

texts:
So I'm trying to code a game using the Model-View-Controller pattern, and therefore have a need to separate the models for my game objects with their sprite representations. The problem that I'm running into is with PyGame's sprite class. For example, let's take the code below for a Tank object in my game.

class Tank(Projectile):
    '''A tank object.'''
    MAX_SPEED = 8.0

    @property
    def MAX_TURN(self):
        return 10.0 - 0.75 * abs(self.velocity)

    def __init__(self, position=(0, 0), heading=0.0, power=100.0, name=None):
        Projectile.__init__(self, position, heading)

        self.gun = Gun(self)
        self.radar = Radar(self)

        self.power = power
        self.name = name

    def update(self, dt):
        super(Tank, self).update(dt) #Just writing this here for illustrative purposes

Additionally, in a separate views file, I have the code for the basis of a sprite:

class TankSprite(RotatableSprite):
    _image = pygame.image.load('images/tank/body.png').convert_alpha()
    _layer = 0
TankSprite.groups = tank_group, all_group

Now the standard solution might just be to merge these two into one, and then use pygame's pygame.sprite.group.update() method to update and draw everything as desired. But with a MVC pattern, I run into a few problems:

First, there is no way of knowing when a new object is created. For
example, when the Tank fires its Gun, its creates a Bullet object.
Since the Bullet is a model, there is no way to detect this creation
without some awkward View code in the Models.
Second, I don't believe I can use pygame's collision methods or
Group objects, which isn't the worst, but somewhat awkward.

Really, the bullet problem is killing me more than anything else. Any help would be appreciated.


texts: How do I handle loads of (prefab?) objects in Unity2D/3D?

texts:
I have been looking around for information regarding this process but I was unable to come across anything that would help me out. Basically, in a game where you may have many items or enemies or player objects, how would one go about creating these objects?

Am I supposed to be creating every single one of these objects as a prefab and then load them into the game when needed? Or is it possible to create one object that has references to the different variables needed to create the above objects and then load in from an external source all the necessary information? And then during run time, depending on what object I am looking at, the script will 'create' the object with the information from the external source.

Meaning, if I decide to have 50 different enemies in my game, do I need to make 50 prefabs, one for each enemy? Or just one prefab that loads in data pertaining to the 50 different enemies and then build upon that information?

Thank you!


texts: Resolving penentration after collision using Separating Axis Thereom

texts:
I implemented collision detection in my game using SAT. The detection works, but I'm trying to use the algorithm to figure out the penetration vector of the two OBBs and push them apart (before doing the 'actual' collision handling).

I think I got the penetration vector successfully. However I'm not sure which of the two entities in the collision to apply it on (i.e. add to the position of which entity).

If I apply it on both entities, obviously nothing happens. How can I know to the position which entity I need to add the penetration vector so the entities 'touch' at the exact point of collision?


texts: XNA: Instancing Cubes, Each Side Different Texture

texts:
I am trying to make thousands of instanced cubes, each with a unique texture on each side.

Am I going to have to split each cube into 6 instanced faces, or can I unwrap it in such a way the the texture atlas coordinates will come out right?

My idea is have each cube unwrapped into a 2 tile by 3 tile area as such:

Top     Bottom
Front   Back
Left    Right

Will the unwrap make it into the DrawInstancedPrimitives call?

Next, some cubes will have different textures than others. I was thinking about handling it with an atlas. One 2x3 texture in one slot, and another texture in another, forming a multi-texture image.

Am I on the right track here?


texts:
I was trying to implement a destructable tile like:

public class SpikeTile : Tile
{
  public int health = 3;
  public void TakeDamage(int dmg)
  {
    Debug.Log("Tile takes damage: " + dmg + ", health: " + health);
    health -= dmg;
}

And I will be able to remove it by using:

Vector3Int cell = tilemap.WorldToCell(collision_pos);

tilemap.SetTile(cell, null);

But it doesn't create a health value per tile! It is shared.

So I've also tried attach a GameObject with DestructibleTile to the above scriptable tile and:

DestructibleTile : MonoBehavior
{
    public int health = 3;

    // same logic
}

But it's also shared between all tiles! The stat is not per tile. (And after I attach the GameObject to customized Tile, it's impossible to SetTile to null anymore.)

Even tried create an array for all tiles to store the stats:

DestructibleTile : MonoBehavior
{
    public int[] health;

    // no idea how to map this to each tile
}


texts: How can I make the second soldier to stop walking once he is reaching the console?

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

public class SpaceshipCutscene : MonoBehaviour
{
    public Transform player;
    public Transform[] npcs;
    public Transform console;
    public Camera FPSCamera;
    public Camera mainCamera;
    public Animator[] anim;
    public float rotationSpeed = 3f;

    private bool moveNpc = false;

    // Use this for initialization
    void Start()
    {

    }

    private void Update()
    {
        if (moveNpc)
        {
            // Soldier 2 rotating and looking at player
            Vector3 dir = player.position - npcs[0].position;
            dir.y = 0; // keep the direction strictly horizontal
            Quaternion rot = Quaternion.LookRotation(dir);
            // slerp to the desired rotation over time
            npcs[0].rotation = Quaternion.Slerp(npcs[0].rotation, rot, rotationSpeed * Time.deltaTime);

            Vector3 dirToComputer = console.transform.position - npcs[1].position;
            dirToComputer.y = 0;
            Quaternion rot1 = Quaternion.LookRotation(dirToComputer);
            npcs[1].rotation = Quaternion.Slerp(npcs[1].rotation, rot1, rotationSpeed * Time.deltaTime);
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag == "SpaceshipCutscene")
        {
            FPSCamera.enabled = false;
            mainCamera.enabled = true;
            moveNpc = true;
            anim[0].SetTrigger("SoldierAimingTrigger");
            anim[1].SetTrigger("SoldierWalkingTrigger");
        }
    }
}

I have two soldiers(NPCS).

The first one npcs[0] is rotating facing the player and at the same time also playing animation.

The second npcs1 should ve rotating as well facing the console and then using animation start walking to the console and to stop in front of the console. But instead when he is reaching the console he start walking around the console nonstop.

The screenshot showing the animator state for the walking:

And the transition between the Ground and the Walking:

I'm using Cinemachine and using virutal camera: CM vcam1 to Follow and Look At the first soldier. The first soldier part is working fine the problem is with the second soldier.

UPDATE:

Instead trigger I changed the parameter to bool inside the OnTriggerExit I did:

anim[1].SetBool("Walk", true);

Then in the Update if moveNpc is true I did:

if (Vector3.Distance(npcs[1].position, console.position) < 4)
            {
                anim[1].SetBool("Walk", false);
            }
            else
            {
                Vector3 dirToComputer = console.transform.position - npcs[1].position;
                dirToComputer.y = 0;
                Quaternion rot1 = Quaternion.LookRotation(dirToComputer);
                npcs[1].rotation = Quaternion.Slerp(npcs[1].rotation, rot1, rotationSpeed * Time.deltaTime);
            }

But if I'm doing < 5 the soldier will not move at all.
If I'm doing < 4 or 3 or 2 the soldier will move forward to the console but instead to stop he will keep move through the console then will walk in circles around the console nonstop.


texts: Does indexing arrays with temporary objects leak memory?

texts:
For example, if I have something like this:

Array = {}
RemoteEvent.OnServerEvent:Connect(function(Player)
    local Part = Instance.new("Part", workspace)
    Array[Part] = Player.UserId
    wait(10)
    Part:Destroy()
end)

Will that leak memory? Will it automatically remove the index for that part once it detects that it's been removed? Or do I need to manually set it to nil when removing it?


texts:
I noticed that from looking at other examples like say .. riemers tutorials he takes a buffer with a bunch of vector3's in it and ties it to a shader which expects a float4 ... why does this work in his situation and not mine?

Also is there a simple fix for this situation that will allow me to do this with the shader  determining the w component as to my game logic this means nothing but is obviously crucial to the gpu.

Riemers code is here:

http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series4/Textured_terrain.php

and mine (key parts only) ...

CPU Code:

public struct TexturedVertex: IVertex
{
    public Vector3 Position { get; set; }
    public Vector2 Uv { get; set; }

    public TexturedVertex(Vector3 position, Vector2 uv) : this()
    {
        Position = position;
        Uv = uv;
    }
}

Shader Code:

struct VS_IN
{
    float4 pos : POSITION;
    float2 tex : TEXCOORD;
};

struct PS_IN
{
    float4 pos : SV_POSITION;
    float2 tex : TEXCOORD;
};

Texture2D picture;
SamplerState pictureSampler;

PS_IN VS(float4 inPos : POSITION, float2 uv : TEXCOORD)
{
    PS_IN output = (PS_IN)0;
    output.pos = mul(inPos, mul(World, ViewProjection));
    output.tex = uv;
    return output;
}

How do the two tie together?

I am however using sharpDX not XNA so my code for setting up the buffers is different slightly ...

I created my own mesh class that does this:

VertexBuffer = Buffer.Create(device, BindFlags.VertexBuffer ,Vertices.ToArray());
context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(VertexBuffer, Utilities.SizeOf<TexturedVertex>(), 0));


texts:
How can I switch cameras from First Person to Third person or from thrid person to first person. Like at GTA V you can switch the cameras. How to do this?

Tnx for your time.


texts: Making an RTS game- how to handle player-created units interacting with each other

texts:
I'm making an RTS game in Unity with C#. However, the interaction I'm going to have with player-created units interacting with other player-created units is what has me stumped. The player and his opponent can purchase units when they have the resources, and it instantiates them in the game. The main thing is checking whether an opponent's unit is within range to attack. Obviously, you can't have every unit asking every other unit what its position is, or it would get exponentially more CPU-consuming the more units are built, right? I'm trying to figure out how I'm going to go about this.

I figured I could have every unit report its position to a sort of master 'tracker', and then every unit could ask the tracker if any opponents' units have a position within X of their own. How I would actually implement this in Unity, though, I'm not sure about.

Moreover, I'm trying to get my head around Instantiated objects. If every unit is telling its position to the master 'tracker', what does it call itself? And let's say a unit asks the tracker if an enemy is in range and one is, what does the tracker tell it so it can locate the right GameObject and attack it? Sorry if I'm talking about it all wrong, I'm sure there's a simple methodology that exists on how to do it, but I can't think of any. Thank you.


texts:
I am debugging my Lerping to see how it works. It is rotating a card and it looks good. However the lerping contains way beyind the card is visually done rotating. I understand it has to do with the mathematics. Is thera a way i can fix it? Is it unavoidable with Lerp/Slerp? Basically what i want is the function to be done when the card has rotated enough so that steps are no longer visible.

public IEnumerator LerpRotationY (float durationSeconds, FlipsSide flipSide)
    {
            int targetAngle = FlipSideEnumToDegrees (flipSide);

            //float flipSpeed = 3F;
            var flipRotation = Quaternion.Euler (0, targetAngle, 0);
            float t = Time.deltaTime;
            var cardRotation = cardSides.rotation;
            var timePassed = Time.time;
            print ("SLERPING! ");
            while (t < durationSeconds) {

                    cardSides.rotation = Quaternion.Slerp (cardSides.rotation, flipRotation, t);

                    yield return null;
                    t += Time.deltaTime;
            }
            print ("SLERPING FINISHED: " + (Time.time - timePassed).ToString ());}


texts: How can I format my numbers in such a way that the digits are grouped?

texts:
I am developing a game using LibGDX, how can I make the label look like that:

Current display:    1000000000
Desired display: 1 000 000 000


texts: Unity Manual Instance Example Shader contains errors

texts:
The Unity Manual has a page on GPU instancing. One of the examples, titled "Adding instancing to vertex and fragment Shaders", causes the following errors to printed to the console when saved in a Shader file:

... unrecognized identifier 'UNITY_INSTANCING_BUFFER_START' at line ... (on d3d11)
... not enough actual parameters for macro 'UNITY_ACCESS_INSTANCED_PROP' at line ... (on d3d11)

This error message does not make any sense. The identifier is supposed to be created in the UnityInstancing.cginc file, if the render target is supported. This thing is, d3d11 is supported:

Line 211: #ifdef UNITY_INSTANCING_AOS
    #define UNITY_INSTANCING_BUFFER_START(buf)
    ...
    #define UNITY_INSTANCING_BUFFER_END(arr)
    ...
#endif

Line 41: #if defined(SHADER_API_D3D11) || ...
    #define UNITY_INSTANCING_AOS
#endif

My question:

Why does Unity say that these operations are not supported on this platform?


texts: How do I summarize a game idea into a short document?

texts:
I have a lot of game ideas, but never the time to work on them. I don't want to lose these ideas, so I want to 'store' them somewhere to come back to in the future. Sometimes an idea isn't really that good, and coming back would help me decide whether a game idea is worth pursuing.

I plan to keep these in some kind of catalog form. I would like to be able to capture the 'feel' of a game in as few words as possible. Even if looking back at the design a few years later, the feel and atmosphere of the game should be recoverable very quickly.

This isn't really a full design document, but something like a 'one-page' summary.


texts: How can I disable the green frames after a cinematic in UDK?

texts:
These green frames appear in my scene after the display of a cinematic (which I just added recently):

How can I remove them, ideally without resorting to transitioning the game mode?


texts:
I'm looking for suggestions on this

Say you have a cube map. You want to rotate it as efficiently as possible.

You can render the cube map, rotate the camera, and render the scene to another cube map.

But it would be faster to rotate the cubemap by operating on the texels.

I'm using D3D11, and I need to read the texels in the code (so I can't use the OpenGL "Texture Matrix"!)


texts:
Is it possible to read back content of VBO in OpenGL ES 2.0 ?
I have tried glMapBufferOES, but there is no READ flag.

I dont want any answers, like "you shouldnt do it" or "keep copy of geometry in ram".


texts: Using a smaller off-screen buffer for rendering

texts: I am seeing this in most of the game codes I read and tutorial videos I watch. When using double buffering in rendering, they use a smaller sized off-screen buffer, then just scale it up when drawing onto the screen. Why is this so? Is there any advantages and/or disadvantages when using this technique?


texts:
I'm curious what the process is for development for a game console such as Wii, Playstation, or Xbox. Do I need to use some game engine and compile for each platform?

What IDE is used? Any C++ IDE? Are all console games built in C++?


texts:
My script looks pretty good but it says Target variable has not been assigned value.

public GameObject AntagonisticElement;
public GameObject Target;
public float bulletSpeed;
public float enemySpeed;
public float bulletDestroyTime;
public GameObject explsn;
public GameObject bulletPrefab;
public Transform bulletSpawn;

Vector3 pos;

public float min = 20;
public float max = 10;

public int MaxCounter;
public int CounterStatus;
int numberofEnemy;
// Use this for initialization

void Start()
{

}

// Update is called once per frame
void Update()
{
    if (CounterStatus <= 0)
    {
        if (numberofEnemy < 3)
        {
            Vector3 creationPoint = transform.position;
            creationPoint.y = -0.5f;
            Instantiate(AntagonisticElement, creationPoint, transform.rotation);

            CounterStatus = MaxCounter;
            numberofEnemy++;
        }
    }

    else
    {
        CounterStatus--;
    }

    transform.LookAt(Target.transform.position);

    if (Vector3.Distance(transform.position, Target.transform.position) >= min)
    {
        transform.position += transform.forward * 4 * Time.deltaTime;

    }
    if (Vector3.Distance(transform.position, Target.transform.position) <= max)
    {
        shootAt();
    }

}

    void shootAt()
    {

        Instantiate(explsn, bulletSpawn.position, bulletSpawn.transform.rotation);
        var bullet = Instantiate(bulletPrefab, bulletSpawn.position, bulletSpawn.rotation);
        bullet.GetComponent<Rigidbody>().velocity = bullet.transform.forward * bulletSpeed;

    }


texts: Is it easy to switch from Chipmunk to Box2D?

texts:
Currently I'm doing some prototyping with physics in Python and I later plan to port the code over to C++.

Box2D has some features that I really like so I'd rather use that library instead. The problem is that the Python port of Box2D is pretty tedious to install and I'm lazy, :D while the Chipmunk port is very easy to install.

Is it hard for me to switch libraries later on when I port the code to C++? (Will I have to do big architectural changes?)


texts: Adjust Line Renderer start position to follow bone rotation

texts:
I'm trying to make my first game in Unity and I want a line renderer to draw from the end of a turret's gun barrel. The problem is I'm rotating 2 bones in the turret to make it look at the enemy. I've used the bounding box of the turret to calculate the offset from the turret's origin to the end of the gun barrel. But when the turret rotates this position is obviously wrong. How can I calculate the correct starting point for the line renderer after performing a rotation?

Here is the code for the rotation and the line renderer:

void Start () {
    enemyManager = GameObject.Find("EnemyManager").GetComponent<EnemyManager>();
    lazerLine = GetComponent<LineRenderer>();

    platform = transform.root.Find("Armature/BaseBone/PlatformBone"); //Get the root transform of this turret (I.e. the turret itself, not the gun barrel)
    gunBox = transform.root.FindChild("Armature/BaseBone/PlatformBone/LowerArmBone/UpperArmBone/GunBoxBone");

    gunBounds = transform.parent.GetComponent<SkinnedMeshRenderer>().bounds.size; //Get the bounding box of the turret
}

void LateUpdate()
{
    Vector3 lookAt;
    Quaternion platformRotation;
    Vector3 gunLookAt;
    Quaternion rotation;

    if (enemiesInRange.Count > 0)
    {
        //Rotate Platform (The silver platform at the base of the turret)
        lookAt = enemyManager.activeEnemies[enemiesInRange[0]].transform.position - platform.position;
        lookAt.y = 0; //0 the Y axis to stop the turret tilting up or down

        platformRotation = Quaternion.LookRotation(lookAt);

        float rotateSpeed = 10.0f * Time.deltaTime;
        platform.rotation = Quaternion.Lerp(platform.rotation, platformRotation, rotateSpeed);

        //Rotate GunBox
        gunLookAt = enemyManager.activeEnemies[enemiesInRange[0]].transform.position - gunBox.position;

        rotation = Quaternion.LookRotation(gunLookAt);
        gunBox.rotation = Quaternion.Lerp(gunBox.rotation, rotation, rotateSpeed);

    }

    if (timer <= effectsDisplayTime)
    {
        Vector3 lazerStart = transform.position;
        //Adjust the lazer to draw from the default position of the top gun barrel (using the bounding box of the turret to calculate the position)
        lazerStart.y += (gunBounds.y * 0.85f);
        lazerStart.z += (gunBounds.z / 2) + 0.05f;

        //Adjust the lazer to follow the current rotation of the gun
/* ##### This is the part I need to add ##### */

        //Draw the lazer
        lazerLine.enabled = true;
        lazerLine.SetPosition(0, lazerStart);
        lazerLine.SetPosition(1, enemyManager.activeEnemies[enemiesInRange[0]].transform.position); //Of the enemies in range, shoot the first enemy that entered the turrets range

        effectsEnabled = true;
    }
}

Here are 2 picture to give you a better idea of what's happening.

This is with the rotation code commented out.

This is with the rotation code running.


texts: Box2D recommended step, velocity and position iterations

texts:
Here in this article there is a nice explanation that velocity iterations and position iterations settings affect the way bodies will react when they collide, and step affects on speed and how gravity acts. So the precision is hidden behind position and velocity iterations, whereas you need to have the world step to advance the time in physics world. I also know that step should be constant to be able to have consistent and debug-able game physics. Hence I do this (where dt is FPS delta time):

if (m_world.GetBodyCount() > 0)
{
    static const double step = 1.0 / 70.0;
    static double accumulator = 0.0;

    // max frame time to avoid spiral of death
    if ( dt > 0.25 )
        dt = 0.25;

    accumulator += dt;

    while (accumulator >= step)
    {
        m_world.Step(step, VELOCITY_ITERATIONS, POSITION_ITERATIONS);
        accumulator -= step;
    }
}

So I guess the step should not be less then FPS minimum value to avoid discrete simulation (cutting effects). Usually FPS is 1/60.0 hence I have chosen 1/70 as a step to have the best performance. And as Velocity and Position iterations I use 6 and 2 respectively which turned to be enough for collisions till today. Is my logic correct or I miss something? Is there a way to optimize more? What are the recommended values for this parameters for mobile games (considering that the game should work on week devices too). Should I use non-constant velocity iterations and position iterations reducing them when FPS drops?


texts: How should I generate the board for a match-3-style game?

texts:
I am trying to create a "match 3" game. I'm stuck figuring out a good algorithm to fill up the game board.

My game's board is 8x8.

EDIT:

A few things:

The board should always be solvable. for example, the user has a score to reach by making matches. All boards must be able to produce enough available matches for the user to win each level or solve it.


texts: boost/geometry replacement in Java/for the JVM (Destructable Box2D terrain)

texts:
I'd like to reimplement https://github.com/seemk/DestructibleBox2D in Java. The main problem is finding an adequate replacement for the boost/geometry library.

Any ideas?


texts:
I made a GUI Tool for Unity
I tryed to add ScrollView like this before the for loop that creates GameObject buttons :
scrollPosition = GUI.BeginScrollView(new Rect(Screen.width-1,20,0,Screen.height-60),scrollPosition,new Rect(0,0,Screen.width-20, Screen.height-80),false,false,GUIStyle.none,GUI.skin.verticalScrollbar);

and I use GUI.EndScrollView after the for loop that creates Buttons


texts: I am running a Unity Game on a PC (for development purposes) and then on an Android phone (for production). I need to send data to the Game continuously from a WiFi enabled microcontroller (Esp32). Is it better for me to use UDP or Websockets for data transfer? What are the pros and cons of each method? In this scenario, the game device will act as a mobile hotspot while the esp32 will connect to this hotspot.