texts: Error on running exe, build using SharpDX

texts: I have developed a windows application to read gamepad using SharpDx (XInput) and C# (VS 2008). The application is running smoothly in my development environment. But when i move to some other machine (Windows 7), its giving me error "Unable to load dll 'xinput1_3.dll' ". My question is is it mandatory to have directx runtime environment in clint machine also to run the exe ?  Because i was thinking it will make use of dll "XInput9_1_0.dll" which is a part of windows 7.


texts:
I am a newbie in Python, I am very bad at math too and I need some help. Also close/move this post if you feel this isn't the right place for it.

Hero1 = 5000   # His HP is 5k.
Hero1dmg = 200 # damage output

How can I subtract some value (let's say 20%) from Hero1's damage output?


texts: Calculating initial velocities given trajectory parabola

texts:
I'm working on a volleyball game but my maths/physics knowledge isn't quite up to par. I need some help with the following problem:

The player can hit the ball from anywhere on the left of the court into one of three points on the right:

    P    | x  x  x

The ball travels in a parabola defined by the three points, all of which are known:

The players X coord and height (Xp, Yp)
The point just above the top of the net (0, Yn) (assume the left of the court is negative along the x axis)
The point where the ball impacts the ground on the other side of the net (Xi, 0)

I need to calculate the initial X/Y velocities when the player hits the ball so that the ball, affected only by gravity, follows that parabola. EDIT Alternatively, the velocity magnitude and angle from which the X/Y component velocities can be calculated.

I'm able to find the function of the parabola using pen and paper but since this involves "saving" equations with unknown variables I have no idea how to translate that to code (how could you have variable a = 2b for example if b is undefined?). I'm not even sure if finding the function is necessary for this problem.

Any help?

EDIT: I just came to the realisation that if I can calculate the flight time then I can divide the distance traveled each frame along the x axis and just plug that into the parabolic function to get the ball's y coordinate. I guess that's my next avenue of research.


texts: Do game studios look at personal projects when hiring?

texts:
I am 17 and I have spent the past 5 years making games for fun. But now I am faced with college and it might be time to get serious about this hobby.

So do Game Studios want to see personal games or 3d models in resumes, or will they only care about professional level work? To a lesser extent my question is also when would a company hire a high school student and why?

As always with these sites I feel like i'm walking on eggshells, so if this is posted in the wrong place, or if i'm breaking any rules please tell me.


texts: Block With Given ID Does Not Exist - Minecraft Mod

texts:
I have tried to make my own Minecraft Block using Forge, but for some reason, when I use /give Playerxxx 1000 1 the game says, There is no block with id '1000'

My Block Code:

package net.minecraft.blockr;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;

public class Basalt extends Block
{
    public Basalt(int par1, Material par2Material)
    {
        super(par1, par2Material);
        this.setCreativeTab(CreativeTabs.tabBlock);
    }

}

Mod code:

package net.minecraft.blockr;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

@Mod(modid="blockr", name="Blockr Mod", version="PreAlpha v0.0.1")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class BlockrMod
{
    public static Block basalt;

    @Init
    public void load()
    {
        basalt = new Basalt(1000, Material.ground).setUnlocalizedName("basalt");

        GameRegistry.registerBlock(basalt, basalt.getUnlocalizedName());
        LanguageRegistry.addName(basalt, "Basalt Block");
    }

    public String getVersion()
    {
        return "0.0.1";
    }
}

What exactly is going wrong?
My package is blockr (as my mod is called blockr)

I know my mod was loaded as I see in Forge under Mods I see my mod


texts:
So I read Reynold's 1999 paper, [Steering Behaviors For Autonomous Characters][1], and I presume something went over my head, because it doesn't seem to make any sense to me.

steering_force = truncate (steering_direction, max_force)
acceleration = steering_force / mass
velocity = truncate (velocity + acceleration, max_speed)
position = position + velocity

Not sure how this makes any sense. Unless there's a constant time step of 1s, this integration (a forward Euler, which is bad in it's own right), doesn't make much sense to me.

The behaviors themselves don't seem to make much sense either:

Seek:

desired_velocity = normalize (position - target) * max_speed
steering = desired_velocity - velocity

The desired_velocity is in the wrong direction? Should be (target - position)? It also doesn't return a force - it returns a difference of velocities. It doesn't scale at all with mass.

Arrival

target_offset = target - position
distance = length (target_offset)
ramped_speed = max_speed * (distance / slowing_distance)
clipped_speed = minimum (ramped_speed, max_speed)
desired_velocity = (clipped_speed / distance) * target_offset
steering = desired_velocity - velocity

This just doesn't make any sense to me. This will flat out not work. Sure, you'll eventually get a vector pointing away from the target, but depending on the vehicle's mass, may not be able to stop it in time. It's also dependent on an arbitrary slowing radius not tied to the objects max thrust, max speed, or mass. Like Seek, it also doesn't actually return a force.

I stopped reading after that. Clearly there is something I am missing here..


texts:
I am looking for an algorithm how to generate cavity (or curvature) map. There seems to be no refernce to it, only final solutions like xNormal software, but that is not what I want. I am looking for a way how to do it, not for a final solution.

I have also found this site: http://wiki.polycount.com/wiki/Curvature_map, but again, mostly references how to do it in specified soft (maya etc).

On my input, I have a mesh and a normal map. From this, I have calculated curvature on my mesh, and now I would like to extend this info with more details from normal map.


texts: Post-Processing effects not visible with LWRP in Unity3D

texts:
I'm are running into an issue when setting up Post-Processing effects for the new Lightweight render pipeline.

Post-processing effects are visible in scene and Game view, but not in Play mode.

The project is using single pass rendering for VR
We are using the LWRP 3.0.0 and the Post-Processing package 2.1.2 (both are up to date)
It seems like the Post processing volume and layer settings are working fine, as the effects are visible in scene and game view

We tried :

Tweaking the quality and graphics settings
Creating a new camera and setting the post processing settings again
Removing all additional cameras in the scene
Setting the exiting UI Canvas in the scene to Screen Space (Camera) instead of Screen Space (Overlay)


texts: Calculate the distance/number of moves one square is from another

texts:
Say I have a 9x7 grid (could be any size) I want to be able to calculate the distance any square is from another. In the image I have selected 5,4 is my target square. Now square (1,2) is 4 moves away (if you can move left, right, up, down and diagonal), as denoted by the orange dot. It is clear from the diagram that the distance from the target square is simply showed by a growing square surrounding the target square. Is there a function which will calculate me the distance of a particular square to my target square using the x and y values of both squares.

e.g. I want to know how many moves it will take from (8,5) to the target square, looking at the diagram I know this is three but is there a function I can use?


texts: LeanTween : How to check if gameObject is destroyed?

texts:
I am trying to animate a gameObject using LeanTween which has got destroyed already.
The MissingReferenceException occurs in LeanTween.setOnUpdate();
The null check doesn't work either: (gameObject != null)
I have used LeanTween.cancel(gameObject,false); but it still throws an exception.


texts:
I am looking for advice how to solve an exception I am getting,

I've looked around and seen people get the same error but most people whom had it seems to run on old graphics drivers and once they fixed that it seemed to work for most people.

I doubt that's the reason causing it for me since I have the latest nVidia drivers and the game runs well from the IDE. I also did create a jar of the game before I implemented Slick2d and that ran without exceptions.

I used to get another exception, that it couldn't find the right natives for lwjgl so I removed the natives from the build and made a fat jar with jarsplice and added them during that process and that's when I ended up at this point.

I've tried and tried for days and it's probably something really stupid and easy to fix but I havn't built a lot of project to be ran from outside Eclipse so any help would be greatly appreciated.

Some basic info on my rig:

OS: Windows 7: Enterprise

CPU: Intel Core i7-2600K

GPU: nVidia GTX 980

RAM: 8192MB (forgot the brand and make, it's old lol)


texts: Client code handling its own generics when returned by an engine

texts:
I'm writing a game engine in Java 8, and have prototype client code written in Groovy.

New Game objects can be created with a builder which defines everything which fills in the blanks. To simplify things, suppose the only thing the Game class needs is a mapping of keyboard inputs (which both the client and engine know about) to dynamic input events (which only the client knows about).

The input events are defined by the client, and are only ever dealt with by the client. The engine acts only to notify the client that an input has occurred which has been mapped to that input event. At that point, it then calls a method implemented by the client with that input event as the sole parameter.

My goal is to have the client code which receives the input event know at compile time the type of the event which is first provided by the client when the Game object is instantiated. My initial naive attempt at this was to turn all my engine code into generic type of <T extends Enum<?>> but this just made a mess of everything, and solved nothing since the client code, as far as I know, only knows it's dealing a generic enum when it gets a callback.

Is this what I'm attempting even possible? Am I heading down the road with enums and generics?


texts: Why does my recursive coroutine freeze Unity?

texts:
I want the bounds (left wall and right wall) to follow the player's y position, a couple of times. However when I use this code, Unity freezez as soon as it runs, and I have to manually shut it down.

Any idea why?

public Transform bounds;

//in another function
StartCoroutine(Follow_Bounds(0));

IEnumerator Follow_Bounds(int a)
{
    yield return new WaitForSeconds(1f);
    while(a < 3)
    {
        StartCoroutine(Follow_Bounds(a + 1));
    }
   bounds.position = new Vector2(bounds.position.x, transform.position.y);
}


texts: What's the proper way to set up a texture atlas in Unity 3D?

texts:
I am using Unity3d (free) to make a game with user-defined content (i.e., load in a map, it'll build the level for you).

Everything is working as expected, except for the rendering.

Note the artifact / seam along the edge of the two cubes.

I am not entirely sure what is causing this, other than, perhaps a rounding error?

At any rate, every mesh in my scene shares the same texture, with specific UV offsets generated at 1/8 intervals for each corresponding texture:

Playing around with the assigned UVs moves the artifacts around. For instance, the red brick texture has the issue between the top faces:

So clearly, I'm doing this in a suboptimal way. Is there something specific I'm doing wrong? Or is there a better way to build meshes with texture atlases?


texts: HLSL problem with divide by homogeneous component

texts: When I try to divide my position.z by my position.w in HLSL I get as result always 1.0f or higher. Is this a common problem for some reason? When I divide my position.x or y by the w this works fine. But the divide for the z gives a wrong result. I use the view matrix for my camera and the projection matrix as i use it in the game because I want to create a depthmap from the cameraposition. Can anybody explain what I'm doing wrong? Do I need another view matrix?


texts: Collision detection not working on some parts of mesh

texts:
Racing game with a single mesh to act as a collider for all the track sides. Recently revised the mesh and now it is behaving strangely. The player correctly collides (bounces off) some parts, on other parts it is hit and miss whether the collider works and on others the player acts like there is no collider present at all.

I have checked that all the meshes normals are facing the correct direction and that there are no gaps in the mesh.

I have set the collisions on the player rigid body to be continuous.

Can anyone suggest what might be happening?

I was previously using the exact same technique but re-created the collider mesh to clean it up and upon importing from Blender into Unity the collider behaviour is now all over the place.

This picture shows part of the collider where the player just passes straight through the walls.

Car collider in Unity:

Track mesh collider in Unity:


texts: Why the canvas text is gray and not really white?

texts:
This script change the text color to white:

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

public class DisplayInfo : MonoBehaviour
{
    public string myString;
    public Text myText;
    public float fadeTime;
    public bool displayInfo = false;

    // Use this for initialization
    void Start()
    {
        if (myText == null)
        {
            Debug.LogError(myText + " Is null please add Text component !");
        }

        if (myString == "")
        {
            Debug.LogWarning(myString + " Is empty, No text will be display.");
        }

        myText.color = Color.clear;
    }

    // Update is called once per frame
    void Update()
    {
        FadeText();
    }

    void FadeText()

    {
        if (displayInfo)
        {
            myText.text = myString;
            myText.color = Color.Lerp(myText.color, Color.white, fadeTime * Time.deltaTime);
        }

        else
        {
            myText.color = Color.Lerp(myText.color, Color.clear, fadeTime * Time.deltaTime);
        }
    }
}

This is the script i'm using with the DisplayInfo:

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

public class DetectInteractable : MonoBehaviour
{
    public Camera cam;
    public float distanceToSee;
    public string objectHit;
    public Image image;
    public bool interactableObject = false;
    public DisplayInfo displayInfo;
    public Canvas canvas;

    private RaycastHit whatObjectHit;

    private void Update()
    {
        Debug.DrawRay(cam.transform.position, cam.transform.forward * distanceToSee, Color.magenta);

        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out whatObjectHit, distanceToSee))
        {
            if (whatObjectHit.collider.gameObject.tag == "Interactable")
            {
                image.color = Color.red;
                objectHit = whatObjectHit.collider.gameObject.name;
                interactableObject = true;
                displayInfo = whatObjectHit.collider.gameObject.GetComponent<DisplayInfo>();
                displayInfo.displayInfo = true;
            }
            else
            {
                image.color = Color.white;

                if (displayInfo != null)
                    displayInfo.displayInfo = false;
            }
        }
        else
        {
            image.color = Color.white;

            if (displayInfo != null)
                displayInfo.displayInfo = false;
        }
    }
}

When it's "Interactable" then i display the info about this object.

The DetectInteractable is attached to the Player (FPSController) in the hierarchy:

And on each "Interactable" item i attach the script DisplayInfo:
For example the door:

And this is the editor screenshot before running the game:
Display Infomration is Canvas. The Text i set it's color to white in the inspector.

But when running the game the text i see on objects is gray and i see that on the inspector the white is becoming gray: On the game view window there is a text Security Door in fray it's hard to see it. It should be in white and bright enough to see it clear:


texts:
So, I got this to do the anims for my sprite in Unity 2d...

using UnityEngine;
using System.Collections;

public class Move : MonoBehaviour {
public float Speed = 2;
Animator anim;
// Use this for initialization
void Start () {
    anim = GetComponent<Animator>();
}

void FixedUpdate () {
    rigidbody2D.velocity = new Vector2(Input.GetAxis("Horizontal") * Speed, 0);
    anim.SetFloat("HorizontalSpeed", Mathf.Abs(rigidbody2D.velocity.x));

if(transform.localScale.x > 0 && rigidbody2D.velocity.x  < 0)
    transform.localScale = new Vector3(-1, 1, 1);

if(transform.localScale.x < 0 && rigidbody2D.velocity.x > 0)
    transform.localScale = new Vector3(1, 1, 1);

}
}

That works fine... then I add the script so he can move up and down. (the previous was moving left+right)

using UnityEngine;
using System.Collections;

public class UpMove : MonoBehaviour {
public float VerticalSpeed = 2;
Animator anim;
// Use this for initialization
void Start () {
    anim = GetComponent<Animator>();
}

void FixedUpdate () {
    rigidbody2D.velocity = new Vector2(Input.GetAxis("Vertical") * VerticalSpeed, 0);
    anim.SetFloat("VerticalSpeed", Mathf.Abs(rigidbody2D.velocity.y));
}
}

Welll.. The second script doesn't do anything.
I've been working at this (rookie noobness) for around an hour now.. so pls pls pls.


texts: Find an infinite loop in a very big project in Unity

texts:
How can I find an infinite loop in a very big project in Unity?

I tried to use breakpoints in MonoDevelop and debug, but I was not able to track the loop. I tried to put Debug.Log() in a few places and it did not help as well.

So, are there are any other ways of doing it?

It is possible that the loop is not a problem, but I think it is very unlikely. The problem is that when I perform some actions the Unity Editor just stucks and becomes unresponsive at all and I should disable it through the task manager.


texts:
I would like to get the position of each edge of a sprite when he has been rotated.

I have no idea how to do it, I made a image to explain it.

I would like to get the X and Y position of each Red circles please thanks you
.

Sprite sprite = new Sprite(texture);
sprite.setRotation(-20);


texts:
I'm a web developer with a keen interest in game development for the iOS platform. I develop mostly with Ruby for the day job but I have dabbled quite a bit with Java in the past, random world generators, platform games, space invaders etc, never anything serious though and only using Java2D.

It seems to be an extremely steep learning curve to get into iOS game development, so my question is where do I start?

I'm not particularly interested in 3D initially, top down / isometric would probably suit the first game I have in mind.

Can anyone recommend a good skills path to learn through, or any videos/tutorials or books to get? I realise this will take a while but I'm happy as long as I know I'm on the right track.

Thanks,
Matt


texts: Going from point a to b through a curve using "gravity"

texts:
I have enemies and when they die they spawn an energy ball with a given velocity. I want to move this ball to the player using "gravity" to create a curved path. I have a version of the function but it is not arriving correctly to the end point without tweaking gravity force (if gravity is low, the velocity vector is not changed fast enough to get to the target position). Has anyone done this previously? I prefer to use gravity than a function curve like a bezier.

We can assume player will be stand still. So, it does not move. Target position will remain the same.

Here the code I'm using right now, I'm using unity3d:

    float gravityMultiplier = 100;

    _gravity = (targetPosition - _t.position).normalized*gravityMultiplier;
    _gravity.z = 0;

    velocity += _gravity * Time.deltaTime;

    _t.position += velocity*Time.deltaTime;

What I'm doing here is just modifying the velocity of the object to make it be attracted by a point at targetPosition. _t is just the gameobject transform.

Thanks in advance.


texts: What is FRotationMatrix in Unreal engine 4?

texts:
I am working on FPS shooter example in Unreal engine 4 documentation.

One of the lines for forward movement of pawn is

FVector Direction = FRotationMatrix(Controller->GetControlRotation()).GetScaledAxis(EAxis::X);

This line gets the forward facing direction of the pawn in world coordinates. I understand that part.

I would like to know what is it mathematically and how does FRotationMatrix get values it gets? How does simple 3 valued vector like rotation get converted to a 4x4 matrix?

Can some one please help me understand.


texts: Ponderate dijkstra relative to previous position

texts:
I use dijkstra in my rust game to find path to a destination. My game is in a square grid like this:

There is, for illustration, the Rust code which use dijkstra:
use crate::map::Map;
use crate::physics::GridPoint;
use pathfinding::prelude::dijkstra;

pub fn find_path(map: &Map, from: &GridPoint, to: &GridPoint) -> Option<Vec<GridPoint>> {
    match dijkstra(from, |p| map.successors(p), |p| *p == *to) {
        None => None,
        Some(path) => Some(path.0),
    }
}

// ...

pub fn successors(&self, from: &GridPoint) -> Vec<(GridPoint, i32)> {
        let mut successors = vec![];

        for (mod_x, mod_y) in [
            (-1, -1),
            (0, -1),
            (1, -1),
            (-1, 0),
            (0, 0),
            (1, 0),
            (-1, 1),
            (0, 1),
            (1, 1),
        ]
        .iter()
        {
            let new_x = from.x + mod_x;
            let new_y = from.y + mod_y;

            if new_x < 0 || new_y < 0 {
                continue;
            }

            if let Some(next_tile) = self.terrain.tiles.get(&(new_x as u32, new_y as u32)) {
                successors.push((GridPoint::new(new_x, new_y), next_tile.pedestrian_cost))
            }
        }

        successors
    }
// ...

And visualization of found path (white is found path, pink is goal):

The found path is not a direct line. I'm not surprised, because the weight of diagonal is the same as lateral. With what I understand with dijkstra is I can return successor with weight for a coordinate. But I can't increase weight of diagonal/lateral according to previous position (ex: comming from West -> moving to Est will be less weight; maybe it is not the solution ...).
How can I achieve that ? With another algorithm than dijkstra ?


texts: How can I make something happen for a set number of frames?

texts:
I want to add a nitro boost feature to my racing game. I want the car to go faster for 45 frames when the nitro is used, but for whatever reason I can't make it work. I originally tried using a while loop but obviously that doesn't work for JavaScript physics. Here's what I have now:

this.nitro = function() {
    if (this.hasNitro) {
        this.nitroSpeed = this.carSpeed * 2;
        this.speedCopy = this.carSpeed;
        var refreshIntervalId = setInterval(function() {
            this.carSpeed = this.nitroSpeed;
            this.nitroCount--;
            if(this.nitroCount==0){
                this.endNitro();
            }
        }, 1000 / FRAMES_PER_SECOND);
    }
}
this.endNitro = function(){
    clearInterval(refreshIntervalId);
    this.carSpeed = this.speedCopy;
    this.hasNitro = false;
}

There are two cars in the game, each an instance of the car class. One of them is controlled with the arrow keys and the other is controlled with WASD. When the car's nitro button is pressed, nitro() is called on that car. The goal of the nitro is to double the car's speed for NITRO_TIME frames. When the car is initialized, nitroCount is set to NITRO_TIME.


texts: Making a button that spawn objects in the world?

texts: I want to make a button that can spawn an object that I've already created. Though I have no clue how to actually do this / where to start. Has anyone ever done something similar?


texts: Unity scene has phantom models in every scene new and existing a like even when deleted

texts:
I have asked about this over at Unity Forums but have not got a response yet.
My issues is that in the image below all there is is a light source but several of my monster models are in the scene somehow. I cannot select them or interact with them in any fashion. The are there whether it is an existing scene or I create a new scene.
If anyone has any clue what this is from it would be a great help because it is driving me madd!
Thanks!


texts:
I am trying to procedurally generate planets in Unity. The actual planet is already done, but now I am trying to add clouds. For this I created a PBR-Graph shader that draws the clouds based on some noise. It works fine on a quad and even on a plane.
The problem is, that I now created 6 meshes that form a sphere, using a script to go around the planet. I have applied the shaded material to the meshes, but for some reason it behaves, as if the entire mesh would be a single pixel, as in I don't get the white cloud shapes moving around with transparent parts inbetween, like I do on a plane, but instead the entire mesh is transparent or white or gray or partially transparent, like a single pixel from the plane. As the clouds move on the plane, the meshes around the planet flicker and change accordingly.
Could someone help me to figure this out?
I don't know why its doing that and its really weird.
Basically the entire mesh acts like a single pixel of the texture, while objects like planes and quads work correctly. I can even get it to work on a sphere, but only on one I created manually by doing new 3D-Object - Sphere and then applying the shaded material to it.
As I want to be able to generate planets with a script, this wouldn't work as it involves me doing something manually...
Here is my code:
This is how the meshes are created:
for (int i = 0; i < 6; i++){

        if(cloudMeshFilters[i] == null){

            GameObject meshObj = new GameObject("cloudMesh");
            meshObj.transform.parent = transform;

            meshObj.AddComponent<MeshRenderer>();
            cloudMeshFilters[i] = meshObj.AddComponent<MeshFilter>();
            cloudMeshFilters[i].sharedMesh = new Mesh();

        }

        cloudMeshFilters[i].GetComponent<MeshRenderer>().sharedMaterial = cloudMaterial;

        cloudMeshes[i] = new CloudMeshes(shapeSettings, cloudHeight, cloudMeshFilters[i].sharedMesh, resolution, directions[i]);

    }

And this is the cloudMeshes class:
public class CloudMeshes
{

int resolution;
Vector3 localUp;
Vector3 axisA;
Vector3 axisB;
Mesh mesh;
ShapeSettings settings;
int height;

public CloudMeshes(ShapeSettings settings, int height, Mesh mesh, int resolution, Vector3 localUp)
{
    this.mesh = mesh;
    this.resolution = resolution;
    this.localUp = localUp;
    this.settings = settings;
    this.height = height;

    axisA = new Vector3(localUp.y, localUp.z, localUp.x);
    axisB = Vector3.Cross(localUp, axisA);
}

public void ConstructMesh(){

    Vector3[] vertices = new Vector3[resolution * resolution];
    int[] triangles = new int[(resolution - 1) * (resolution - 1) * 6];
    int triIndex = 0;

    for(int y = 0; y < resolution; y++){
        for(int x = 0; x < resolution; x++){

            int i = x + y * resolution;
            Vector2 percent = new Vector2(x,y) / (resolution - 1);
            Vector3 pointOnUnitCube = localUp + (percent.x - .5f) * 2 * axisA + (percent.y - .5f) * 2 * axisB;
            Vector3 pointOnUnitSphere = pointOnUnitCube.normalized;
            vertices[i] = pointOnUnitSphere * (settings.planetRadius + height);

            if (x != resolution - 1 && y != resolution - 1)
            {
                triangles[triIndex] = i;
                triangles[triIndex + 1] = i + resolution + 1;
                triangles[triIndex + 2] = i + resolution;

                triangles[triIndex + 3] = i;
                triangles[triIndex + 4] = i + 1;
                triangles[triIndex + 5] = i + resolution + 1;
                triIndex += 6;
            }

        }
    }

    mesh.Clear();
    mesh.vertices = vertices;
    mesh.triangles = triangles;
    mesh.RecalculateNormals();

}

}

The ConstructMesh() method is called after the for loop at the top has run.
Sorry for any incorrect indentations, that happend when pasting the code here...


texts: Visual cues in a full 3D game to help the player to identify the location of each object

texts:
I am working on adding some visual cues to the player to help identify where each objects are in 3D. In many space games, there is usually an indicate on the edge of screen that reflects the direction towards that particular object. For example, an indicator in the upper middle edge of screen may indicate that particular object is straight ahead and an indicator in the lower middle of edge screen may indicate that object is directly behind.

If the game is mostly 2D, such as most FPS shooters, this would not be a difficult problem. Then the indicator is basically a top down radar. But with full 3D, Im unsure how to translate this inherently 3D information to 2D in a intuitive, yet meaningful way. If just using the 2D radar method, then I cant convey pitch/elevation information. For example, an indicator in the upper middle edge of screen can not differentiate between an object that is straight head in the same plane as the player versus something that the player needs to tilt 45 degrees upwards to see.

Is there something better than the top down radar method?


texts: Library for generating primitive shapes?

texts:
I'm looking for a library to generate the data for primitive shapes for opengl. I have lights, and I simply wants to draw a sphere to represent the lights transform in the world

I do not want a library that draws it though, I want to control all openGL-related API calls myself (so, freeGLUT is Not what Im looking for), I simply want to generate the vertices, normals, etc for a mesh shape at runtime (a cube, sphere, etc).

Is there any nice, minimal library that can do this task? If not, what is the alghoritm for generating vertices for a sphere-shape?

Thanks

EDIT: I am not looking to load from 3d model formats either


texts: Trying to use an overlapping shader for 2D sprites but sprite wont show its shape

texts:
So Im trying to use this shader I had from a while ago to implement shadows in a 2D top down game. In order to show clouds on top of the game.
At the moment, Sprites dont overlap which is good, but the shape of the sprite rendered by the sprite renderer is completely different to the one inserted in the sprite renderer, as the sprites in the sprite renderer are circles not squares.
And it seems to cover any other sprite in the scenes which is not what a shade is supposed to be like.

How can I modify the shader so that it respects the sprite. Also I want it to react to lighting the same way as sprite diffuse does.

Shader "Custom/OverlappingDiffuse"
{
    Properties
    {
        [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" { }
        _Color ("Tint", Color) = (1, 1, 1, 1)
        [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
    }

    SubShader
    {
        Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Plane" "CanUseSpriteAtlas" = "True" }

        Cull Off
        Lighting On
        ZWrite Off
        Blend One OneMinusSrcAlpha

        Stencil
        {
            Ref 1
            // Comp NotEqual
            Comp NotEqual
            Pass Replace
            Fail Keep
            ZFail Keep
            ReadMask 1
            WriteMask 1
        }

        CGPROGRAM

        #pragma surface surf Lambert vertex:vert nofog keepalpha
        #pragma multi_compile _ PIXELSNAP_ON
        #pragma multi_compile _ ETC1_EXTERNAL_ALPHA

        sampler2D _MainTex;
        fixed4 _Color;
        sampler2D _AlphaTex;

        struct Input
        {
            float2 uv_MainTex;
            fixed4 color;
        };

        void vert(inout appdata_full v, out Input o)
        {
            #if defined(PIXELSNAP_ON)
                v.vertex = UnityPixelSnap(v.vertex);
            #endif

            UNITY_INITIALIZE_OUTPUT(Input, o);
            o.color = v.color * _Color;
        }

        fixed4 SampleSpriteTexture(float2 uv)
        {
            fixed4 color = tex2D(_MainTex, uv);

            #if ETC1_EXTERNAL_ALPHA
                color.a = tex2D(_AlphaTex, uv).r;
            #endif //ETC1_EXTERNAL_ALPHA

            return color;
        }

        void surf(Input IN, inout SurfaceOutput o)
        {
            fixed4 c = SampleSpriteTexture(IN.uv_MainTex) * IN.color;
            o.Albedo = c.rgb * c.a;
            o.Alpha = c.a;
        }
        ENDCG

    }

    Fallback "Transparent/VertexLit"
}

This is how is showing up in the editor:

here is what I want , and want I am getting at the moment:


texts: Can I use quaternions to control an helicopter?

texts:
I'm trying to make a simplified helicopter (for the moment, it's a cube) simulation in 3D and I'm having some problems with rotation. An helicopter can rotate along the three axes :

rotate on itself using the rear propeller : y axis rotation
tilt left and right to go left or right : z axis rotation
tilt up and down to go backward or forward : x axis rotation

I need  to be able to control each axis individually. So far I've tried using euler angles, but whatever the order of rotation I use, either I run into a gimbal lock or some axes "switch places".

I seems that I need to use quaternions, but I don't know how to control each individual axis, since quaternions uses a direction and an angle. Should I create three quaternions and multiply them together? Wouldn't I end up with the same problems?

The weird thing is, if I use my finger to represent the three axes of my helicopter (thumb up = y, index = z, middle = x), I don't seems to run into those problems. Why?


texts: Count number of CCNodes of a certain class on a layer

texts:
Pretty simple question. I'm working in Objective C (cocos2d) and I'm trying to count the number of a sprites of a certain class are present on the current layer being displayed. For example, I have a class named Seal which is a subclass of of CCNode and in my current layer I want to count how many instances of type Seal are present.

I know how to count the number of children of the layer by doing

int numberChildren = [[self children] count];

which correctly returns the number of children on the layer. But I just want the number of Seals on my layer. How could I do this? Thanks =)


texts:
I'm interested in the process of automatically generating advice when a player is consistently struggling through parts of a game.  Suppose I already know what advice I want to generate (e.g., "Press A twice to double-jump across long gaps").  My question is twofold:

Has it been shown that this intervention can be useful to gamer experience?
Has it been shown that excessive intervention will be ignored or will cause frustration?

References to game design or psychology research papers is a plus!


texts: Calculate bounce and friction after a projection-based collision

texts:
According to the N Tutorials, after a projection-based collision (i.e, adding a minimum translation vector to an object's position in order to bring it out of collision), bounce and friction are applied with the following three steps:

split velocity vector into two components: one parallel and one perpendicular to the collision surface

calculate bounce using the perpendicular component

calculate friction using the parallel component

I am assuming that, by "velocity vector", the tutorial refers to the object's current velocity.
How is this done? And, please try to keep it low-level so as not to confuse someone who knows essentially nothing about physics.


texts:
What is a more difficult type of game to develop on XNA: A Real Time multiplayer game or a Turn Based multiplayer game? (not client server or peer to peer, just in general)

Any links to articles would be greatly appreciated!


texts: TiledMap renders but gets duplicated when I move the camera

texts:
I've created a map (TMX file) using Tiled, imported it and it shows great but when I move the camera, it duplicates itself and the whole screen flickers.
In Tiled, I didn't use a spritesheet but rather a collection of images as they have different sizes.

See attached image:

Here is my game class:

public class MyGdxGame extends ApplicationAdapter {

    private IsometricTiledMapRenderer renderer;
    private OrthographicCamera camera;
    private TiledMap map;
    private Vector2 dragOld, dragNew;

    @Override
    public void create() {

        map = new TmxMapLoader().load("isometric_map.tmx");
        renderer = new IsometricTiledMapRenderer(map);

        camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        camera.position.set(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, 0);

        Gdx.input.setInputProcessor(new InputAdapter() {
            public boolean touchDown(int screenX, int screenY, int pointer, int button) {
                if (button == Input.Buttons.LEFT) {
                    dragNew = new Vector2(Gdx.input.getX(), Gdx.input.getY());
                    dragOld = dragNew;
                    return true;
                }

                return false;
            }
        });
    }

    @Override
    public void render() {
        super.render();

        camera.update();

        renderer.setView(camera);
        renderer.render();

        if (Gdx.input.isTouched()) {
            dragNew = new Vector2(Gdx.input.getX(), Gdx.input.getY());
            if (dragOld != null && !dragNew.equals(dragOld)) {
                camera.translate(((int) dragOld.x - dragNew.x), ((int) dragNew.y - dragOld.y)); //Translate by subtracting the vectors
                camera.update();
                dragOld = dragNew; //Drag old becomes drag new.
            }
        }
    }

    @Override
    public void resize(int width, int height) {
        super.resize(width, height);

        camera.viewportWidth = width;
        camera.viewportHeight = height;
        camera.update();
    }

    @Override
    public void dispose() {
        super.dispose();

        map.dispose();
    }
}

What am I missing?


texts:
I am creating a game engine using the JBox2D physics engine. It only allows you to create polygon fixtures up to 8 vertices, To create a body with more than 8 vertices, you need to  create multiple fixtures for the body.

My question is, How can I split the polygons a user creates into smaller polygons for JBox2D?

Also, what topology should I use when splitting the polygons and why?
(If JBox2D can have up to 8 vertices, why not split polygons into 8 per polygon)


texts:
I have a Dance Pad and I want use it in XNA as a controller. It has a USB connection.

Can someone help me?


texts: How to achieve the top-down (oblique) projection of textures using an OrthographicCamera?

texts:
This question is related to (How to calculate the initial velocity of projectile motion by a given distance and angle from point A to B) question.

Details

In the below image is the graphical projection of top-down (oblique).

And this is the pattern that I used to reference.

Currently

From the answer, the Coordinate systems describes how the oblique projection works.

screenPos.x = (worldPos.x - cameraOffset.x) * zoomFactor;
screenPos.y = (worldPos.y + worldPos.z - cameraOffset.y) * zoomFactor;

From the related question, currently the camera that I'm using is OrthographicCamera.

Additional question

In the above GIF animation, do I need to customize OrthographicCamera class to achieve the oblique projection? Or do I need to create a new ObliqueCamera class that extends Camera? (If yes, what pointers do I need to review to be able to do it, because I am new to graphical projection).


texts:
My game uses big const data which i need to retrieve it to use
data used on each level when its needed
data security is important

I got two options in my head which one is better?

Note the data is const and it never changes during game and only i can change it on coding for using it on some levels and after build it always same data

1: using return "data"

Something like this which means data stored in script and finding script will expose data

if(level_number < 10)
{
switch level_number

case 1:
return data_1;
.
.
.
}
if(10<level_number <20)
{
.
.
.
}

2: saving in binary file

Check if the file exist read it and if it isn't then create it during game and use it next time

This one uses binary formatter to save/load data and there is two options for this too

2.1: creating file during game which still have same problem like first solution

2.2: creating file on the editor and load it from plugin folder etc

And second one also have storage usage when first one just a script which returns some const data

I know you cant stop hackers from hacking offline file but i'm also looking better way to save this big const data and retrieve it to use it

Which one is better and if you have better solution i'm happy to hear it


texts:
Reading up on attack speed calculations for World of Warcraft I noticed that the formula for attack speed is:

  Attack_speed = "current attack speed" / (("Percent increase or
  decrease" / 100) + 1 )

So with a weapon of speed 1.8 and activating a 40% attack speed buff for example we would have:

  Attack_speed = 1.8 / ( (40 / 100) + 1 ) = 1.2857

So I am just wondering why is there a +1 in the formula. Logically I would assume that one would calculate the attack speed like this:

  Attack_speed = 1.8 - (1.8 * (40 / 100)) = 1.08

Which is just subtracting the 40% of 1.8 from 1.8, which is how one would normally calculate a percentage in math. Is this just by design or is there some logic to this?


texts:
I'm at the planning stages for a facebook game, it will be similar to farmville, but will feature parks. I've been a Flash game dev for many years but all this database stuff is new to me so I'm having trouble getting my head around what's the best way to handle the data.

I know I need a table for the players, so that's straightforward.

Each player can grow crops/flowers and/or harvest trees etc that are already in the parks. The way I'm setting it up is that the parks are made up of 2 layers, or 2 2D arrays, the bottom array or ground tile array is just big tiles, and in a 8x8 grid, so that seems pretty straightforward as well, just store 16 entries for each part in a "parks ground tile table", but first question about that. Those 16 entries would correspond to each park, so would I still use the auto increment on the ID, or some other kind of ID to represent them as a group somehow? I'm just thinking of what's the fastest way to grab those 16 from the database.

Next onto the trickier stuff which is the 2nd layer of the park or the items/objects/crops 2d array. Each player has to have their own version of this 2D array, so first qusetion is how do I set that up in the database? I was thinking maybe having a "park items array" and then each feature (tree, crop) etc for each player would just be stored in that array, but I can see that getting huge really quick, so not sure how to do that? or if the size of that would be an issue?

Then on top of that, each player can maintain multiple parks :p...again what would be the best database design to maintain all of those?

Thanks for any help!


texts: Trying to make a game entity jump. Can't figure out what is dt?

texts: At it's core what is delta time? In every equation to make a player jump I see that it is multiplied by delta time. Is this a constant value or a changing one? How does this value help? I don't understand why it's needed for velocity, acceleration and jumping.


texts: What method could I use to avoid using a lookup table for each item when loading a players inventory?

texts:
Let me explain a little about the pickup items and inventory to make this much clearer.

Every in world item that can be picked up has a ScriptableObject assigned to it that contains all the information about that item (id, name, description, maxstacksize, sprite etc).

When a player picks up an item it gets added to a List<InventoryItem>.  InventoryItem is a class that gets populated with some of the data pulled from the ScriptableObject (id, name, description, maxstacksize), and also gets an amount property.

I want to save the players inventory, but want to simplify the InventoryItem data.  So I created an InventoryItemSimple struct that holds the id and amount for each item in the inventory, and then save that list to file.

When loading the player inventory, currently I have a BIG list of ScriptableObjects that map to the id.  So I am looping over the saved inventory list and matching against the id in the lookup table, and then adding the item to the inventory.  I want to avoid this as over time their could be 2,000+ unique objects that could be in the world.

What's a better method to handle this?

If I stick with the lookup table, do I need to worry about how much memory is being used?  I don't think my lookup table will ever contain 2,000+ elements.  But the thought of having one massive list to manage doesn't appeal to me.


texts: Mirror Networking; How to Pass/Sync c# actions?

texts:
Since you can not pass actions as parameters to commands and rpc calls, how would you sync actions ? My main goal is to find an easy and generic way for objects to easily do actions from their local player. Something like:
_localPlayer.RunFromLocalToAllPlayers(()=>
{
    //MyAction
});

Local Player having these methods:
private Action _callbackForAllPlayers;
public void RunFromLocalPlayerToAllPlayers(Action callback)
{
    _callbackForAllPlayers = callback;
    Debug.Log(_callbackForAllPlayers);
    CmdRunFromLocalPlayerToAllPlayers();
}

[Command]
        private void CmdRunFromLocalPlayerToAllPlayers()
        {
            Debug.Log($"Running on server");
            RpcRunFromLocalPlayer();
        }

[ClientRpc]
        private void RpcRunFromLocalPlayer()
        {
            Debug.Log($"Running on client");
            _callbackForAllPlayers?.Invoke();
            Debug.Log(_callbackForAllPlayers);
        }

and of course that local Action variable is being null on other clients since i can not sync it or pass it as parameter.


texts:
I have tutorial text (which I plan to augment with voice-over later, but it must be text for now, because I have not contracted a VO actor yet).

The text presents itself in dialogs, which are like tweets (fewer than 140 characters each).  The text is big and readable.

The text contains vital instructions that step the user through what to do next.  In playtesting, a user would just press OK OK OK without reading the text.  The final dialog would disappear, and the user would be without a clue what to do, because he didn't read the instructions.  The game is expecting him to perform the task it just asked, and he doesn't know what it is.

I tried:

putting in a counter (3), (2), (1), then when the counter disappears you can press ok. I think the counter is annoying/distracting
graying out/disabling the button until 2-3 seconds have passed for each dialog of text
completely hiding the ok button until 2-3 seconds have passed for each dialog of text

How can I better handle this problem of the user not reading the tutorial text before dismissing the dialog?


texts: The edges of my model are not rendered smooth in xna. See here. What can i do for this, as when designer renders the same model in maya, edges are smooth. And is it possible to render models in xna which provide same results as Vray pugin renders in maya or max.


texts: VS Code is no more suggesting Pygame methods for me

texts:
I've been using Pygame a lot. And I'm cuurently coding in VS Code. Last week, I have installed JAVA and started learning it's basics. However, from the moment I installed the JDK, VS Code have changed (the theme, the code suggestions...) . So when I got back to Python and Pygame, I noticed that VS Code is not suggesting the methods and functions for me when I start typing. I also noticed that this issue is happening mostly with Pygame as everything is working properly with the standard Python library.
So what can I do ?
Btw, what are these suggestions called (I think they have a specific name) ?


texts:
this is my first Unity project and I'm getting desperate for answers.
I've been trying to get Admob to work using the official plugin. It's been giving me a ton of problems as I can't get the banner to show, despite me using nearly verbatim code as tutorials.

Here's my code:

  using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using GoogleMobileAds.Api;

public class AdMobTest : MonoBehaviour {

BannerView banner;
InterstitialAd fullAdmob;

// Use this for initialization
void Start () {
    RequestBanner();
    ShowBanner();
}

void RequestBanner()
{
    string bannerID = "Hiding my banner ID";
    banner = new BannerView(bannerID,AdSize.SmartBanner,AdPosition.Bottom);
    AdRequest adRequest = new AdRequest.Builder().Build();

    banner.LoadAd(adRequest);
}

public void ShowBanner()
{
    banner.Show();

}

public void RequestFull()
{
    string idFull = "hiding my banner ID";
    fullAdmob = new InterstitialAd(idFull);
    AdRequest adRequest = new AdRequest.Builder().Build();

    fullAdmob.LoadAd(adRequest);
}

public void ShowfullAds()
{
    if (fullAdmob.IsLoaded())
    {
        fullAdmob.Show();
        RequestFull();
    }
    else
    {
        RequestFull();
    }
}

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

}

I have a new 2D project setup with an empty scene and an "ad" game object, and a script added to that game object. I'm expecting something to show up on my phone's screen, but nothing is showing up.
I know this may be a stupid question, but I've spent a ton of time on this, and I'm pretty new to this stuff. So please help me out!


texts:
So I'm learning how to make games and program, and while trying to setup a projection camera using GLM in GFLW, this line of code refuses to work and I can't figuire out why. The code is in the image below.
                                                 Thanks!


texts: How do you make money from html5 games (i.e sponsorships)?

texts: I make games with flash and I am interested in making games in html but I haven't seen any companies or websites which are willing to buy these games (i.e game sponsorships). I was hoping somebody could tell me about a company who would do this or why people don't buy html games?


texts:
I have a camera that currently smoothly (ease in and out) linearly interpolates between two positions. The camera also moves in response to user input.
While this movement is nice and smooth it does not feel natural. My goal is to add some sort of feeling of inertia or natural movement or hand-heldedness to it.
Therefore I have been trying to generate a formula that simulates more natural camera movement on top of the interpolation and user control. Thus far I have not had success.
In one try I pretended that the camera had a stick going out of it and that at the end a ball was attached to a spring attached so said stick. This ball was then focused on adding some direction animation to the system... however I could never get this right. The camera would be shaky/oscillating and user movements looked really awful.
I also tried having the direction point towards a slower animated pole.
No such luck.
Why do these methods of generating a more natural 3D camera movements not work? What is usually used to make this work.


texts:
I downloaded some animations with root motion from Mixamo and the corresponding character model.

After created an animator with those animations and added it to the character game object, the root motion was causing the transform to move around, which was not supposed to happen.

I tried to uncheck "Apply Root Motion", and set "Motion - Root Motion Node" to "None", but neither of them worked.

The only thing that worked is checking "Loop Time - Loop Pose", but it doesn't make much sense to mess with root motion, someone even proposed it shouldn't disable root motion.

So, how to disable animation root motion?

Also I'm confused, is root motion optional? Must I get animations without root motion if it's not needed?


texts: How to iterate through the frames of an AnimationClip in editor mode

texts:
I'm working on a 2D game, using spritesheets as the basis for four AnimationClips. (Every frame from the spritesheet is a keyframe in the animation.) I'm trying to step through the frames of these AnimationClips and programmatically create Collider2Ds which fit the dimensions of each frame.

The problem is, I'm having an impossible time actually iterating through the frames. My character has an Animator component, with 4 different states. I've tried various inputs to my editor script, but the closest I've gotten has an AnimationClip as input:

private AnimationClip clip; // set in inspector
private GameObject targetForColliders; // set in inspector

void createColliders() {
    Animation animation = new Animation();
    AnimationUtility.SetAnimationClips(animation, new AnimationClip[] { clip });

    foreach (AnimationState state in animation) {
        // do useful things here
    }
}

Unfortunately, somehow the animation local variable is null, crazy as that sounds. I've confirmed that by both logging it and attempting to use it, which causes a NullReferenceException every time.

I can't access the Sprite containing the spritesheet directly, because I've made manual adjustments within Unity to the keyframes (removing some, duplicating others) and I don't want to have to manually sync my colliders with the modified assets.

Has anyone attempted to do something similar to this before? tl;dr: What's the easiest way to iterate through the frames of a 2D animation in an editor script?


texts: Why is there a discrepancy between these two transform.up vectors?

texts:
I was trying to implement a feature which required transform.up, the result didn't match the green axis gizmo displayed in the editor so I assumed it was being put off by the rotation of the object despite expecting the gizmo to adapt to that. I then modified the prefab such that everything was now child to an empty object and the secondary objects were child to that instead of the rotating model, and wrote a script that simply copies the transform so that it tracks. This still didn't show the values expected from what the gizmo in the editor showed. I then did a Debug.LogError in the track script and this time the result was as expected.

Why is transform.up showing the value expected from the local y-axis gizmo but when passing a reference to the original script and checking tracked.transform.up gives off results?

To reproduce in a simpler environment I set up a simple test scene.

Simple default cube with the hierarchy structure shown in the screenshot.
The transform values are as follows:

parent zeroed
x:0, y:-90, z:0 for cube
x:0, y:-90, z:90 for TrackPoint

Scripts are as follows:

test.cs - attached to trackpoint

private void Update()
{
    Debug.LogError(transform.up);
}

Track.cs - attached to tracker

public Transform transformToTrack;

private void Update()
{
    transform.position = transformToTrack.position;
    transform.rotation = transformToTrack.rotation;
    Debug.LogError(transform.up);
}

byref.cs - attached to cube

public GameObject refObj;

private void Update()
{
    Debug.LogError(refObj.transform.up);
}

When run, if you clear the console then click pause you'll see that one of them differs from the others. I don't understand why. My project and this sample scene differ in which it is that is giving unexpected results but the results are inconsistent with what I would expect.

But wouldn't they all give the same result?


texts: Best way to determine surface normal for a group of pixels?

texts:
One of my current endeavors is creating a 2D destructible terrain engine for iOS Cocos2D (See https://github.com/crebstar/PWNDestructibleTerrain ). It is in an infant stages no doubt, but I have made significant progress since starting a couple weeks ago. However, I have run into a bit of a performance road block with calculating surface normals.

Note: For my destructible terrain engine, an alpha of 0 is considered to not be solid ground.

The method posted below works just great given small rectangles, such as n < 30. Anything above 30 causes a dip in the frame rate. If you approach 100x100 then you might as well read a book while the sprite attempts to traverse the terrain. At the moment this is the best I can come up with for altering the angle on a sprite as it roams across terrain (to get the angle for a sprite's orientation just take dot product of 100 * normal * (1,0) vector).

-(CGPoint)getAverageSurfaceNormalAt:(CGPoint)pt withRect:(CGRect)area {

float avgX = 0;
float avgY = 0;
ccColor4B color = ccc4(0, 0, 0, 0);
CGPoint normal;
float len;

for (int w = area.size.width; w >= -area.size.width; w--) {
    for (int h = area.size.height; h >= -area.size.height; h--) {
        CGPoint pixPt = ccp(w + pt.x, h + pt.y);
        if ([self pixelAt:pixPt colorCache:&color]) {
            if (color.a != 0) {
                avgX -= w;
                avgY -= h;
            } // end inner if
        } // end outer if
    } // end inner for
} // end outer for

len = sqrtf(avgX * avgX + avgY * avgY);
if (len == 0) {
    normal = ccp(avgX, avgY);
} else {
    normal = ccp(avgX/len, avgY/len);
} // end if

return normal;
} // end get

My problem is I have sprites that require larger rectangles in order for their movement to look realistic. I considered doing a cache of all surface normals, but this lead to issues of knowing when to recalculate the surface normals and these calculations also being quite expensive (also how large should the blocks be?). Another smaller issue is I don't know how to properly treat the case when length is = 0.

So I am stuck... Any advice from the community would be greatly appreciated! Is my method the best possible one? Or should I rethink the algorithm? I am new to game development and always looking to learn new tips and tricks.

EDIT: This is a re-work of the getSurfaceNormal function to implement the 2nd algorithm as specified by Nathan. I am putting it here for purposes of feedback and to hopefully show in code what Nathan is talking about.

-(CGPoint)getSurfaceNormalAt:(CGPoint)pt withSquareWidth:(int)area {
// This method only looks at surface pixels

int avgX = 0;
int avgY = 0;
CGPoint normal;
float len;
ccColor4B color = ccc4(0, 0, 0, 0);

for (int w = area; w >= -area; w--) {
    int h = area;
    do {
        if ([self pixelAt:ccp(w + pt.x, h + pt.y) colorCache:&color]) {
            if (color.a != 0) {
                if (w < 0) {
                    avgX -= w;
                    avgY -= h;
                } else {
                    avgX += w;
                    avgY += h;
                }
                break;
            } // end inner if
        } // end outer if
        h--;
    } while (h >= -area);
} // end for
int perpX = -avgY;
int perpY = avgX;
len = sqrtf(perpX * perpX + perpY * perpY);
normal = ccp(perpX/len, perpY/len);

return normal;
}


texts:
I have been searching and searching for an answer to this question but nobody seems to be helping me. I have wasted the past two hours trying to figure out how to do this, so please help me out here.

I am making a FPS game in Unreal Engine 4, and I want to display ammo. I can do that fine, but changing the text of the UI displaying the ammo is turning into a nightmare. I need to access the text label variable

Inside of the blueprint that handles the actual gun firing

From there I should be able to adjust the text to match what my ammo is.

Unfortunately, no matter what I try, I cannot change the variable in my blueprint. I can't even make the variable public to begin with! What do I need to do to accomplish this?


texts: Object goes straight through game object without colliding

texts:
The "shot" is supposed to collide with the left bumper and then be destroyed, but the shot goes right through it. Both objects have a box collider.

The following is the code I am using:

#pragma strict
var speed : int = 2;
var collided_with : GameObject;

function Update () {
    transform.Translate(Vector3(-1 * speed * Time.deltaTime, 0, 0));
}

function OnCollisionEnter (col : Collision) {
    if (collided_with.tag == "Left") {
        Destroy(gameObject);
    }
}

I have made sure that all the tags are assigned correctly and that there are no spelling errors. The variable collided_with is also assigned to the left bumper. What am I doing wrong?


texts: How to move my character by itself but I can still move its direction or where it is going, using Mobile Joystick?

texts:
So, I am making a 2D airplane game right now and I wanted to know how to move my player automatically but I can still control where it should go or the direction. How do I code this using Mobile joystick?

CODE:

public float moveSpeed;

Rigidbody2D myBody;

protected Joystick joystick;

void Start()
{
    myBody = GetComponent<Rigidbody2D>();
    joystick = FindObjectOfType<Joystick>();
}

// Update is called once per frame

void Update()
{
    myBody.velocity = new Vector2( joystick.Horizontal * moveSpeed, joystick.Vertical * moveSpeed );
}


texts: I'm new to unity, I was wondering how would one go into implementing a dynamic 2d space map. Let me give you an example what i mean. You see our solar system on the map, if you zoom out at a treshold value this solar system would just be represented by a name and our sun and around it you see adjacent solar systems. How would I do this in unity?


texts: Will points on path with width intersect

texts:
I want to be able to check if a list of points will hit a screwed rectangle (rhombus i think).

I start out with 2 point P and T, i want to create a rectangle between the 2 points. I have used https://stackoverflow.com/questions/7854043/drawing-rectangle-between-two-points-with-arbitrary-width to do this. This gives me 4 points A, B, C and D of the new rectangle.

I then want to check if the point M is withing this rectangle.

The two black dots are my points P and T, the black box is the rectangle i want to generate between the two dots, being X wide.
I then want to test if the red dots are withing the black box.


texts: Thread.SetProcessorAffinity() equivalent for Windows?

texts: I want to be able to use multiple cores in my XNA game, but it seems that Thread.SetProcessorAffinity() is only usable on xbox. That being said, is there any way to run a small chunk of my code on another core, or failing that, share the load between all cores?


texts: Moving/spilling water inside a cup of glass

texts:
I made a glass of water but there are somethings i didnt know how to do well, what i did is i put a mesh on the top of the glass to represent the surface of the water but it doesnt really work well with glass because if you look from the sides you wont really see that there is water in there, this is what i did :

the glass from the side :

as you can see it doesnt really work well in my case.
I also tried putting an object that has the same shape as the cup inside to represent water but that would make it difficult for what i want to do next, because my next step would be to make the water rotate in the opposite rotation of the cup and make it spill if it reaches the top of the cup, and that is my second question how do i make the water spill from the cup?

Any help is very much appreciated.


texts: How can i draw Arc in center of the screen on canvas in android

texts:
RectF rectf = new RectF(10, 100, 700, 800);
c.drawArc(rectf, 0, 90, true, paint);

the above code is draw the arc using drawArc() method of canvas but i try to draw arc in a center of the screen.


texts: Where can I post job listings or browse through resumes?

texts:
[Hypothetically] I'm at a smaller company and looking for a place to get the word out about our available openings.  Alternately, I'm looking for a place to browse through resumes of people looking for jobs.  What are some services I can use to find the people I need?

Answer Format

One URL per answer
Costs (if applicable)
Specializations (if any)
Experiences using the service


texts:
I have read an article about texture splatting that says:

  Because the alphamap only has to be in a single channel of a texture,
  we can pack up to four alphamaps into a single texture – one in red,
  one in green, one in blue, and one in alpha.

But it does not mention a way to this. Can anyone tell me or point me to an article on how to do this? I've been googling it the whole afternoon but can't find any. Or maybe I just don't know the correct terms to search. :?

Thanks.


texts:
This question is probably a duplicate but I'm still asking it since it's all yesterday that I'm trying to get this done without any success. I followed many solutions and tried even more libraries which were either outdated or they simply didn't work.
Right now the most reasonable method I found is

Open the Content Pipeline;
Create a new Content if there isn't any;
Right click on Content -> Add -> New item -> SpriteFont Description
-> Give it a name;
Click Build;
Go to the output directory, grab the XNB file that was created and
put it in some folder of the project, under Content;
Change the properties to Content and Copy if newer;

And I use it like this:

private SpriteFont font;

font = Content.Load<SpriteFont>("NameOfXNBFile");

spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, Global.Camera.TranslationMatrix);

spriteBatch.DrawString(font, "Some Text", new Vector2(100, 100), Color.White);

spriteBatch.End();

I don't have any errors, the text is simply not shown. I think I could be close to a solution since one and only one single time the text appeared, but as the fool I am I happily closed the tabs of countless tutorials and made some changes which led the text to never show again.


texts: How can I exclude some rigid body from rayTest in Bullet Physics?

texts:
I'm trying to picking some object with rayTest method of BulletPhysics. The problem is my stage is surrounded with walls (btStaticPlane) and the target objects (btSphereShape) are in there. And I'm trying to pick with a line from the outside of the surrounding box.

So I have to exclude the planes from rayTest. How can I do this?


texts:
I tried to use this motion blur effect on my project but found some strange looking artifacts when setting it's alpha to low values. (Which increases the strength of the effect)

The effect works by only rendering a transparent image, so parts of the last few frames are still visible. When I set the alpha of the new image to a fairly low value (less than 0.5f) I get these strange artifacts:

Without the effect, the scene looks like this:

Notice that without the effect, the background is solid (minus lighting). The artifacts do not go away after any amount of time. For my implementation of the effect, I created a BufferedImage, rendered everything to it, then rendered the image to the screen with transparency. Could someone provide an explanation as to why these artifacts are occuring? Is there possibly a way that I could repair this?

image = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT)

//Draw everything to image

Graphics g = bs.getDrawGraphics();
Graphics2D g2d = (Graphics2D) g;
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
g.drawImage(image, 0, 0, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
g.dispose();


texts: How can I move my box collider temporarily?

texts:
I'm very new to game development, I mostly program other things. I'm trying to write a basic whack-a-mole type of game. I've gone ahead and created a hammer with a swinging animatio in the FBX. I've also attatched a box collider to the head of the hammer.

The issue is that when I play the hammer swing animation (and the hammer moves down), the box collider does not follow. I understand that this is because the animation is only for the object, but in this case it presents a problem since I need the collider to be at the hammer's lowest point once the animation gets there.

What is the right way to approach this problem? I've thought of a couple solutions on my own, are any of these valid?

1) Move the Collider with the animation. I've got no clue on how to do this.

2) Store the time when I start the animation, check if enough time has ellapsed for completed animation. Then manually move collider to the contact point. Wait a few milliseconds, then move it back. I tried this, the issue with this is that it moves the entire object with the collider.

void Update() {
   if (Input.GetMouseButtonDown(0)) {

       animator.SetTrigger("hammer");
       animationStartTime = Time.time;
       toAnimate = true;
   }
   if(Time.time-animationStartTime > 0.38 && toAnimate == true) {
       toAnimate = false;
       //bc = attatched box collider
       bc.transform.position = new Vector3(0, 0, 0); //move to target point (won't be 0,0,0 for real, just a test point)

    }
    if(Time.time- animationStartTime > 0.50)
    {
           bc.transform.position = transform.position + bcOffset; //reset to original position
     }
}

3) Do what I did in step 2, but create a collider not attatched to a parent object so that the parent object isn't moved. I don't know how to create a collider on its own however.

BoxCollider bc = new BoxCollider();
//I then use bc.size and bc.position and set them but it does not show up
//on my scene view so I don't think this works.

NOTES:

This script is attatched to hammer object.

The hammer is moved with this code:

hPos = Input.GetAxis("Mouse X") * -0.7f;
fPos = Input.GetAxis("Mouse Y") * 0.7f;
transform.position += new Vector3(fPos, transform.position.y, hPos);

Edit:
is it possible for me to apply the animation to the collider? This would probably be the easiest way.


texts: Unity2D Sprite flips camera when moving left and right

texts:
I am using the Unity Engine and coding in C#.

I have a sprite as a parent with a main camera as a child so that the main camera follows the sprite. However, when pressing 'A' and 'D' to move the camera 'flips 180 degrees' due to me using transform.eulerangles is there anyway that the camera can be excluded from this 'flip'?

void Movement () {

anim.SetFloat ("moveSpeed", Mathf.Abs (Input.GetAxisRaw ("Horizontal")));

if (Input.GetAxisRaw ("Horizontal") > 0) {
  transform.Translate (Vector3.right * moveSpeed * Time.deltaTime);
  transform.eulerAngles = new Vector2(0,0);
}

if (Input.GetAxisRaw ("Horizontal") < 0) {
  transform.Translate (Vector3.right * moveSpeed * Time.deltaTime);
  transform.eulerAngles = new Vector2(0,180);
}
}


texts: BitmapFont - where is getBounds method in new 1.6 libGDX

texts:
I download newest libgdx version 1.6 and i cant solve problem with center my BitmapFont text. Earlier in version 1.54 i used getBounds() method to find out width of text.

Share your solutions, thanks


texts: Best way to de-clutter name tags on units in RTS

texts:
This is an RTS-MMO mobile game I am building, Each unit has health-bar and name of the unit and owner on top of it and a small circle indicating if the unit is friendly and/or has weapons activated or not.

Problem is, when there are a lot of units in one spot, the tags become so cluttered and the critical information becomes lost.

I have tried making the name tags more transparent but this does not help.
Tried putting some name tags above the unit, other tags under the units, also to no avail.
Tried removing the healthbars unless the unit is damaged, didn't help much either!

How does RTS games solve this issue?
I have seen some RTS games remove the healthbars for non-damaged units, but this didn't have any impact on how it looks, and having no name tags or at least no owner-name-tags will be a no-go as this information is critical when attacking/approaching other units, or when picking own units (as units might be equipped with different tools and be named by their owner to be recognized.)


texts:
I'm trying to draw a hexagon grid in my Android application. I don't want to reinvent the wheel here, so I'm looking for some frameworks/libraries or just some basic ideas about how should one do this. Do you have some ideas?

What I found so far:

Some math but not for Android
Nice, but not for Java


texts:
I want to add somebasic point lights to my OpenGL application. I read here that I have to caluclate the light in a pre-projection space:

  Lighting can be done in any pre-projection space (e.g., world coordinates or eye coordinates), as long as all the objects and lights are all in that same space.

And here is my problem. My Renderer currently looks something like this:

public void onDrawFrame(GL10 unused)
{
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    Matrix.multiplyMM(camProjection, 0, projection, 0, camera, 0);

    for(int i=0; i < sceneObjects.size(); i++)
    {
        SceneObject object = sceneObjects.get(i);
        object.draw(camProjection);
    }

    // ...
}

As you can see I multiply my projectionMatrix with the viewMatrix and I think that is a good solution because I only have to do this once. To draw I give the PVMatrix to all objects and multiply it with their modelMatrix and then I push the finall MVPMatrix to the shader. This is a problem because I can not calculate the light direction in eye space in the shader because I do not have any pre-projection matrix here. Do I really have to push a MVMatrix to the shader and calculate the normals and so on with it? I think this is really inefficient because I have to do much more matrix multiplications, isn't it? What would you suggest to calculate this efficiently?


texts:
Upon checking the docs of SDL (1.2) I saw that the SDL_Rect struct defines the x and y as Sint16. I'm making a bitmap font text scroller and I need those specifically to be unsigned ints because the text does need to go offscreen, yet still using the same struct because the SDLBlit method needs it. I tried creating my own and typecasting it as an SDL_Rect but that didn't work. Any ideas?

Also, to be more clear. The string of text scrolls to the left, therefore the first letter of my text does indeed go off screen but the rest doesn't. I assumed this was the problem.

for(int i=0;i<strlen(string);i++) {
  SDL_Blitsurface(bitmapsurface, rects[chars[i]], screen, destrect);
  destrect.x+=8;
}


texts:
Have some WWW object downloading a .PNG image.

((SpriteRenderer)renderer).sprite = Sprite.Create(request.texture,
         new Rect(0,0,100,100));

My sprite looks fine.

Now, let's be a bit redundant and create a Texture2D out of the bytes from the download:

Texture2D t = new Texture2D(100,100);
t.LoadImage(request.bytes);
((SpriteRenderer)renderer).sprite = Sprite.Create(t, new Rect(0,0,t.width,t.height));

Technically, this should produce something identical to the above snippet. However, the sprite is blurry (as in, low quality).

I suppose it is when calling LoadImage. What may be causing this?


texts: Unity websockets client disconnects after server emits with data

texts:
I am using some unity "socket-io" plugin i found on the asset store.
(its essentially just a scoket.io wrapper for websocket-sharp) everything works absolutely fine, i can catch clients connecting or disconnecting, i can also emit from both sides and call some functions, but the only problem is, when i try to send data from server using .emit("name", data); client receives this data properly(i can console.log it) and suddenly disconnects, but restores connection afterwards.
if i just use .emit("name") everything works fine.

This is my server code:

//where _PLAYERS is just an array(object) of socket.id-s with corresponding Player objs
for (var key in _PLAYERS) {
    var data = {
        name: "test"
    };
    io.sockets.connected[key].emit("update", data);
}

I have also tried: io.to(key).emit("update", data); and inside io.on("connection") i did socket.emit("update", data). disconnects in all cases.

client:

socket.On("update", OnUpdate);
public void OnUpdate(SocketIOEvent e)
{
    Debug.Log(e.data); //this one doesn't work here
}

but it works inside wrapper code:

    private void OnMessage(object sender, MessageEventArgs e)
    {
        #if SOCKET_IO_DEBUG
        //result: 42["update","{\"name\":\"test\"}"]
        debugMethod.Invoke("[SocketIO] Raw message: " + e.Data);
        #endif
        Packet packet = decoder.Decode(e);

        switch (packet.enginePacketType) {
            case EnginePacketType.OPEN:     HandleOpen(packet);     break;
            case EnginePacketType.CLOSE:    EmitEvent("close");     break;
        ...

Hence, correct client receives a message with data successfully, but wrapper or websocket-sharp(not really sure which) causes it to error and doesn't fire my onUpdate() method.

OnMessage is just a function bind to websocket-sharp's onMessage. Like this:

ws = new WebSocket(url);
ws.OnMessage += OnMessage;

Keep in mind that io.sockets.connected[key].emit("update"); without data works fine. But i need to send data. Also client can .emit("name", data) to server, and it also works, but data from server crashes.

My main question is, what are all the possible reasons in this whole websocket thing that may cause client to disconnect after receiving a message with data? So If anybody isn't familiar with these particular libraries, at least i would be able to debug and find that error myself.

ps: websocket-sharp

and the wrapper i am using(which is deprecated a long time ago)


texts:
In a small game that I'm making enemies multiply when you kill them, however when clones are instantiated they don't chase the player like the original prefabs do (example: http://gfycat.com/VastActualElver)

Here is relevant part of my code:

 #pragma strict
    var moveSpeed : int = 3;

    var player : Transform;
    var MaxDist = 10;
    var MinDist = 1;

    function Update () {
        if(curhealth <= 0){
            Dead();
        }
        transform.LookAt(player);
        if(Vector3.Distance(transform.position, player.position) >= MinDist){
            transform.position += transform.forward * moveSpeed * Time.deltaTime;
        }
    }

function Dead () {
    Destroy(gameObject);
    var posx = Random.Range(-10, 10);
    var posz = Random.Range(-10, 10);
    Instantiate(enemys, Vector3(posx, 0.5, posz), transform.rotation);
}

What am I missing?


texts: Problem using ccTouchesEnded/ccTouchesBegan to move sprite in cocos2d-x?

texts: I'm using ccTouchesBegan/ccTouchesEnded to move sprite from one point to another but I'm having problem, if i give two or more consecutive inputs one by one while sprite is moving(runAction is being performed). It first moves to last point i touched and then teleports itself to previous touched points one by one.


texts:
I'm using Unity ECS entities to draw out some tiles. I would like to determine the layer (or sortOrder) of the rendered tile so that if a tile is placed over another at the same position, the tile with the higher layer value will be visible.

It appears random at the moment. I tried:

entityManager.SetSharedComponentData(entity, new RenderMesh
{
   mesh = mesh,
   material = mat,
   layer = level
});

But it didn't seem to do anything.


texts: Problem representing torque as a quaternion

texts:
Euler angles are much more intuitive to me than quaternions for representing 3-dimensional rotations. In fact, I barely understand quaternions at all. I use quaternions for rotation because people with more knowledge than me say they're better. (I'm familiar with the gimbal lock problem and axis-angle rotations, but that's getting away from the point.)

Given my nebulous understanding, what I'm trying to do might be really stupid. I want to rotate an object by applying an angular force (torque) which I'm representing as a quaternion plus a duration. To move the object, I do something like

abstract class PhysicsBody
    {
    protected Vector3 velocity = Vector3.Zero;

    public void ApplyForce(Vector3 force, float duration)
        {
        // mass and other concepts omitted for brevity
        this.velocity += force * duration;
        }
    }

and it works as expected. I figure rotation should work similarly, like so:

...

protected Quaternion orientation = Quaternion.Identity;

public void ApplyTorque(Quaternion torque, float duration)
    {
    this.orientation *= torque * duration;
    }

But of course it does not. If duration is less than 1, orientation does not change. If duration is greater than 1, things get weird and break after a few seconds.

I've experimented with renormalization, but I'm fumbling in the dark. What is the "correct" way to do this?


texts: Trying to leave a trail of particle effects with a Particle system attached to an Object Unity C#

texts:
I have a particle system attached to my game object, which starts to emit particles when I press down the "W" key and stops when I release it. The particle system works fine, but when I rotate the object, the particles rotate with the object. I would like to have the particles leave behind a trail of the path of the object.

Script below:

public class Motor : MonoBehaviour {

public ParticleSystem EngineLeft;
public ParticleSystem EngineRight;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
    if (Input.GetKey(KeyCode.W))    {
        transform.Translate(Vector3.forward * Time.deltaTime * Speed);
    }

    if (Input.GetKeyDown (KeyCode.W)) {
        EngineRight.Play ();
        EngineLeft.Play ();
    }

    if (Input.GetKeyUp (KeyCode.W)) {
        EngineRight.Stop ();
        EngineLeft.Stop ();
    }


texts: What colour space or mixing algorithm should I use for "watercolor-like" colour mixing in-game?

texts:
I want to make a game where the player creates potions out of coloured ingredients, and I think the RGB or HSV colour spaces would be confusing for players expecting (red + yellow = orange, red + blue = purple).
RYB (red-yellow-blue) seems the closest to what I want:
However, I don't want to hard-code the colours, as some ingredients are randomly generated or have impure colours. Also, I'd like to represent the "locations" of potions of objects on the colour space on a 2D "map". How would I implement this in code? E.g. mix two RED items with one BLUE item and one GREEN item.


texts:
So, lets say i have a client and server sending information to each other. Do i have to port forward both the server and the client, or do i just port forward the server? If i have to do both, is there any way of not needing to port forward? Im using SFML to be specific.

This isnt on local networks and its using UDP.


texts: Creating offline multiplayer Android games with Unity

texts:
Is it possible to create offline multiplayer Android games with Unity (played over bluetooth/ wi-fi)?
If so, then I would like to create a 2 player game prototype, containing a single room (empty cube) with 2 cubes (3rd person controllers) - each controlled by one player. The cubes can be moved about as their owners (players) wish. Any movement made by any of the 2 players can be seen in realtime in the other player's display.
How do I achieve this?

P.S. I know some basics of Unity. I have already created a small hack & slash game in Unity (PC-standalone). I am new to Unity Android, though.


texts:
I'm making a game with customization system for both characters and weapons and I don't know exactly what's the best way of doing the customizations themselves.
I'm thinking of creating separate prefabs for every item that can't be dismantaled.

For example, I'd make a prefab of a character (naked-ish) and place empty game objects as containers for clothes and equipment on the character pref. When a player'd change helmet or something else, I'd replace the old helmet pref with a new one saving the data to an XML or Json file. Then I'd pass this Json or XML to a level and a script on the level will assemble this character with all its stuff taking the info from the XML or Json file.

So, the question is: is that a good approach or is there a better or common way to do this taking into account that pretty much the same should work in multiplayer but with data passed via connection? If so, what are the security measures to take in multiplayer?


texts: Endless runner game: Dynamic world vs Static world

texts:
I've seen a lot of tutorials on how to build infinite runners and came up with a question about game optimization.

This types of games are built on two ways, according to my research; these are:

Set the player and camera static. Usually on the origin of the world space, and have all the environment assets created on the distance and move them towards the user.
The environment assets are created on a straight line to infinity and the player and the camera both move forward until the player loses. This means the environment's position will not be changed once they are created.

My question arises from here. Which of the two involves less calculations? Which one gives the player a better feel of movement? Is the difference actually significant (in terms of performance) or is it just a trivial question?


texts: Can anyone think of an approach to creating a bubble-like material in babylon.js? I imagine a good starting point would be with using the Fresnel shader.


texts: Game Center: Leaderboard score inconsistencies

texts:
Background

I'm currently developing a simple library that mirrors Game Center's functionalities locally. Basically, this library is a system that manages achievements and leaderboards, and optionally sync it with the Game Center. So, if the game is not GC enabled, the game will still have achievements and leaderboards (stored inside a plist). But of course, the leaderboards will then only contain the local player's scores (which is kind of useless, I know :P).

Problem

Currently I have coded both of the achievements and leaderboards subsystems. The achievements subsystem have already been tested and it works. I'm currently testing the leaderboards subsystem using multiple test user accounts. I loaded the test app on a device and on the simulator, both logged in with 2 different user accounts. Then I performed these steps:

I first used the device to upload a score.
Then, I ran the simulator, and the score submitted by the user on the device is shown. Which is cool.
Then, I used the simulator to upload a score. But on the device, still, only one score is listed.

I checked on the Game Center app (to see if the bug lies within my code), and I got the same thing. Under "All players", there is only one score on the device, but there are 2 scores on the simulator. I wanted to make sure that the simulator is not causing this, so I swapped the users on the device and the simulator, and the result is still the same. In other words, the first user is oblivious of the second user's score, but the second user can see the first user's score.

Then I tried with a third user. The result: the third user can only see the scores of the first user and himself. The second user still sees the scores of the first user and himself. The first user only sees his own score.

Now here comes the weird part. I then make the first user and the second user befriend each other. The result: under "Friends", the first user can see the second user's score, but under "All Players", the first user's score is the only one listed.

Screenshots

The first user sees this:

The second user sees this:

So, is this a normal thing when using sandboxed GC accounts? Is this behavior documented somewhere by Apple?


texts: Knowing the size of a framebuffer when rendering transformed meshes to a texture

texts:
I have a couple of 2D meshes that make a hierarchical animated model.
I want to do some post-processing on it, so I decided to render this model to a texture, so that I could do the post-processing with a fragment shader while rendering it as a textured quad.
But I don't suppose that it would be very smart to have the render texture's size as large as the entire screen for every layer that I'd like to compose – it would be nicer if I could use a smaller render texture, just big enough to fit every element of my hierarchical model, right?
But how am I supposed to know the size of the render target before I actually render it?
Is there any way to figure out the bounding rectangle of a transformed mesh?
(Keep in mind that the model is hierarchical, so there might be multiple meshes translated/rotated/scaled to their proper positions during rendering to make the final result.)
I mean, sure, I could transform all the vertices of my meshes myself to get their world space / screen space coordinates and then take their minima / maxima in both directions to get the size of the image required. But isn't that what vertex shaders were supposed to to so that I wouldn't have to calculate that myself on the CPU? (I mean, if I have to transform everything myself anyway, what's the point of having a vertex shader in the first place? :q )
It would be nice if I could just pass those meshes through the vertex shader first somehow without rasterizing it yet, just to let the vertex shader transform those vertices for me, then get their min/max extents and create a render texture of that particular size, and only after that let the fragment shader rasterize those vertices into that texture. Is such thing possible to do though? If it isn't, then what would be a better way to do that? Is rendering the entire screen for each composition layer my only option?


texts:
I want to check if the Y position is changing or not for the player and the enemy. If it has changed in the frame I want it to return true and if it didn't I want it to return false. I round because the enemy's position alternates between 0.8 and 0.800001 .

I tried to do Mathf.Round(transform.position * 100)/100 and I compare is to the enemyOldPosition which I assigned using enemyOldPosition = Mathf.Round(transform.position * 100)/100, but it says it's not equal.

I tried to check Debug.Log(enemyOldPosition - Mathf.Round(transform.position * 100)/100) and it returned 1.192093E-08.

void Update()
{
     if(Mathf.Round(player.transform.position.y*100)/100 == oldPosition)
     {
         isChangingY = false;
         oldPosition = Mathf.Round(player.transform.position.y*100)/100;
     }
     else
     {
         Debug.Log(oldPosition - Mathf.Round(player.transform.position.y*100)/100);
         isChangingY = true;
         oldPosition = Mathf.Round(player.transform.position.y*100)/100;
     }

     if(Mathf.Round(transform.position.y*100)/100 == enemyOldPosition)
     {
         enemyIsChangingY = false;
         enemyOldPosition = Mathf.Round(transform.position.y*100)/100;
     }
     else
     {
         Debug.Log(enemyOldPosition - Mathf.Round(transform.position.y*100)/100);
         enemyIsChangingY = true;
         enemyOldPosition = Mathf.Round(transform.position.y*100)/100;
     }

 }

This script is placed my on enemy, and they both have rigidbodies


texts: Getting invalid argument error on R32G32B32_FLOAT texture creation

texts:
D3D11_TEXTURE2D_DESC texDesc;
    texDesc.ArraySize = 1;
    texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
    texDesc.CPUAccessFlags = 0;
    texDesc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
    texDesc.Width = width;
    texDesc.Height = height;
    texDesc.MipLevels = 0;
    texDesc.MiscFlags = 0;
    texDesc.SampleDesc.Count = 1;
    texDesc.SampleDesc.Quality = 0;
    texDesc.Usage = D3D11_USAGE_DEFAULT;

    D3D11_SUBRESOURCE_DATA data;
    data.pSysMem = finalData.data();
    data.SysMemPitch = width * 3 * sizeof(float);
    data.SysMemSlicePitch = finalData.size() * sizeof(float);

    HRESULT hr = device->CreateTexture2D(&texDesc, &data, &texture);

I just can't see what's wrong. I am absolutely certain that the vector is properly initialized, that there is three floats per pixel and that the width is the given width. What's wrong? And the vector is of type float.

I've tried zeroing out the subresource data and just setting pSysMem, but no go.

Please help.


texts: Import blender camera with key frames to unity?

texts: I am wondering if I can take a camera tracked camera from blender and import it into unity. Is there any way to do this? Please let me know! Thanks in advance.


texts: C++ MMO: Best approach to store creatures in a multi-level world map for the purpose to find spectators

texts:
I'm developing a game which is a multi-level game, my game can have a maximum of 15 floors, and a fixed amount of tiles width/height.

Each tile in the map can have a creature. All fine until here;
I need to find spectators within a range / radius of the map, and sometimes within specified floor ranges, this can happen multiple times per second (players interacting with the world)

Currently this is how I search for lets say all spectators in all floors:

for (int floor = 0; floor != 15; floor++)
{
    for (int x = posx - range; x != posx + range; x++)
    {
        for (int y = posy - range; y != posy + range; y++)
        {
            Tile* ....
            Spectators.Add(Tile->GetCreature());
        }
    }
}

As you can tell, this isn't the best approach, I've thought about using a hash / chain of creatures on which each hash entry points to a X-Y coordinate in the world map, this would take a lot of trouble to worry about floors, and it's also more performance-friendly.

How can I achieve this?


texts: Server and client showing different spawned object - How do I unify them?

texts:
I have overridden OnServerAddPlayer and put some custom logic in place to set the rendered prefabs color. Something like this:

    var playerCount = NetworkServer.connections.Count;

    if(playerCount == 1)
    {
        player.GetComponentInChildren<Renderer>().material.color = Color.green;
    }

When I test the code with two application instances, the server host shows the expect result (first character is green, second is red) but the client instance shows both characters as red (the default).

Is my logic for setting the colour incorrect? or do I need to do something special to ensure that the my clients will see the colour I have set for the characters on the server?


texts: How to keep a data structure synchronized over a network?

texts:
Context

In the game I'm working on (a sort of a point and click graphic adventure), pretty much everything that happens in the game world is controlled by an action manager that is structured a bit like:

So for instance if the result of examining an object should make the character say hello, walk a bit and then sit down, I simply spawn the following code:

var actionGroup = actionManager.CreateGroup();
actionGroup.Add(new TalkAction("Guybrush", "Hello there!");
actionGroup.Add(new WalkAction("Guybrush", new Vector2(300, 300));
actionGroup.Add(new SetAnimationAction("Guybrush", "Sit"));

This creates a new action group (an entire line in the image above) and adds it to the manager. All of the groups are executed in parallel, but actions within each group are chained together so that the second one only starts after the first one finishes. When the last action in a group finishes, the group is destroyed.

Problem

Now I need to replicate this information across a network, so that in a multiplayer session, all players see the same thing. Serializing the individual actions is not the problem. But I'm an absolute beginner when it comes to networking and I have a few questions. I think for the sake of simplicity in this discussion we can abstract the action manager component to being simply:

var actionManager = new List<List<string>>();

How should I proceed to keep the contents of the above data structure syncronized between all players?

Besides the core question, I'm also having a few other concerns related to it (i.e. all possible implications of the same problem above):

If I use a server/client architecture (with one of the players acting as both a server and a client), and one of the clients has spawned a group of actions, should he add them directly to the manager, or only send a request to the server, which in turn will order every client to add that group?
What about packet losses and the like? The game is deterministic, but I'm thinking that any discrepancy in the sequence of actions executed in a client could lead to inconsistent states of the world. How do I safeguard against that sort of problem?
What if I add too many actions at once, won't that cause problems for the connection? Any way to alleviate that?