texts:
I am currently in the process of creating my first game (as a hobbyist) and I have an issue with Unitys Rigidbody.
The objective of the game is to steer a ball in a 2-d-ish environment (3-d rigidbody that is constrained to two dimensions) by moving (e.g. rotating) the platforms the ball touches. Basically this works kind of well, but movent after hitting a platform "feels" a bit off. When the platform rotates, the ball kind of slides off instead of bouncing, supposedly because the movement of the platform is not taken into account when the ball hits it.

I set the types of the mesh colliders of the platforms to convex and non-trigger. The rigidbody calculation is "continuous dynamic". The platform colliders are pill-shaped (basically cylinders with demi-sphere on both ends).
Is there any built in way to take the platforms dynamics into account with the rigidbody or will I have to roll my own physics implementations? (It feels that this would be quite difficult, since I'd have to calculate the speed of the platform at the point of the collision and somehow take this into account!?)


texts:
I'm a bit new in opengl so please bear with me. I have a viewport window like this

I have implemented zoom in/out features using the arrow keys. The problem is it zooms in and out with the whole image. Can anyone point me in the right direction as to how I can make the GUI on the sides stay in place while making my viewport (the white rectangle) zoom in and out?

Thank you!


texts:
I'm creating a couple of classes Vector2 (X & Y) and Vector3 (X, Y & Z), but I don't know whether to make Vector3 inherit from Vector2, or whether to re-implement the member variables m_x and m_y again? What are the pros and cons of each side (inheritance vs redefinition).

Edit: I'm using C++ (VS2010).


texts:
I have a sphere with values center,radius and I need to convert the sphere to a bounding box with values min,max.

How do I convert a sphere into a bounding box?


texts: Voxel terrain rendering with marching cubes

texts:
I was working on making procedurally generated terrain using normal cubish voxels (like minecraft) But then I read about marching cubes and decided to convert to using those. I managed to create a working marching cubes class and cycle through the densities and everything in it seemed to be working so I went on to work on actual terrain generation. I'm using XNA (C#) and a ported libnoise library to generate noise for the terrain generator. But instead of rendering smooth terrain I get a 64x64 chunk (I specified 64 but can change it) of seemingly random marching cubes using different triangles.

This is the code I'm using to generate a "chunk":

public MarchingCube[, ,] getTerrainChunk(int size, float dMultiplyer, int stepsize)
    {
        MarchingCube[, ,] temp = new MarchingCube[size / stepsize, size / stepsize, size / stepsize];
        for (int x = 0; x < size; x += stepsize)
        {
            for (int y = 0; y <size; y += stepsize)
            {
                for (int z = 0; z < size; z += stepsize)
                {
                    float[] densities = {(float)terrain.GetValue(x, y, z)*dMultiplyer, (float)terrain.GetValue(x, y+stepsize, z)*dMultiplyer, (float)terrain.GetValue(x+stepsize, y+stepsize, z)*dMultiplyer, (float)terrain.GetValue(x+stepsize, y, z)*dMultiplyer,
                    (float)terrain.GetValue(x,y,z+stepsize)*dMultiplyer,(float)terrain.GetValue(x,y+stepsize,z+stepsize)*dMultiplyer,(float)terrain.GetValue(x+stepsize,y+stepsize,z+stepsize)*dMultiplyer,(float)terrain.GetValue(x+stepsize,y,z+stepsize)*dMultiplyer };
                    Vector3[] corners = { new Vector3(x,y,z), new Vector3(x,y+stepsize,z),new Vector3(x+stepsize,y+stepsize,z),new Vector3(x+stepsize,y,z), new Vector3(x,y,z+stepsize), new Vector3(x,y+stepsize,z+stepsize),
                       new Vector3(x+stepsize,y+stepsize,z+stepsize), new Vector3(x+stepsize,y,z+stepsize)};
                    if (x == 0 && y == 0 && z == 0)
                    {
                        temp[x / stepsize, y / stepsize, z / stepsize] = new MarchingCube(densities, corners, device);
                    }
                    temp[x / stepsize, y / stepsize, z / stepsize] = new MarchingCube(densities, corners);
                }
            }
        }

(terrain is a Perlin Noise generated using libnoise)

I'm sure there's probably an easy solution to this but I've been drawing a blank for the past hour.

I'm just wondering if the problem is how I'm reading in the data from the noise or if I may be generating the noise wrong? Or maybe the noise is just not good for this kind of generation? If I'm reading it wrong does anyone know the right way?

the answers on google were somewhat ambiguous but I'm going to keep searching.

Thanks in advance!


texts:
I am using a tilemap to design levels for my game in Unity.
So, naturally, I need some circle/box colliders to interact with the objects in the game.

I know that if I use a prefab for every tile, I can also attach a collider, and never have to worry to add or modift colliders. But this seems too impractical, and also if I want to modify a block of colliders, I have to do this for every single tile.

I also tried using Tilemap Colldier 2D, but it generates colliders for the places I don't want colliders, such as grasses that stick out from the ground tiles.

My question is, is there any neat way to organize colliders so that I can identify them by looking at their names, IDs, etc.?

Currently, I am designing only one level and anxiety builds up on me as I take a look at the colliders in a single tilemap. How can I automate or organize the colliders for my tilemap?


texts: Why do restitution values less than one still cause infinite bouncing in Box2D?

texts:
I'm currently trying to implement basketball bouncing into my game using Box2d (jBox2d technically), but I'm a bit confused about restitution.

While trying to create the ball in the testbed first, I've run into infinite bouncing, as described in this question, however obviously not using my own implementation.

The Box2d manual describes restitution as follows:

  Restitution is used to make objects bounce. The restitution value is usually set to be between 0 and 1.
  Consider dropping a ball on a table. A value of zero means the ball won't bounce. This is called an
  inelastic collision. A value of one means the ball's velocity will be exactly reflected. This is called a
  perfectly elastic collision.

My confusion lies in that I am still getting infinite bouncing with restitution values at 0.75/0.8. The same behavior can be seen in the testbed under Collision Watching -> Varying Restitution, on the 6th and 7th balls. I believe the last one has restitution of 1, which makes sense, but I don't understand why the second to last ball bounces infinitely (as is happening with my working basketball I've created).

I am looking to understand the restitution concept more fully, as well as look for a solution to infinite bouncing with the Box2d framework. My instinct was to sleep objects that appeared to be moving in very small increments, but this seems like a misuse of the engine. Should I just work with lower restitution values altogether?


texts: Unity Performance: How many Materials per Object?

texts:
I have learned that a Mesh with 4 Materials each 1024x1024 in Size is somewhat slower than a Mesh with 1 Material 2048x2048 in Size? In my usual workflow I tend to seperate different Materials into different Materials so an Object tends to have around 2-8 Materials. I have created more than a hundred Assets like this.

Is the performance dramatically affected by this? Is it acceptable to upload such Objects to sites like turbosquid or sell them on Unity Asset Store or will the buyer behead me after noticing?

Window Textures need to be transparent, Metal / Wood / Concrete need different smoothness settings. As far as I know Unity doesn't support Gloss maps.


texts:
I want my camera to rotate around the centre of screen and I'm not sure how to achieve that. I have a rotation in the camera but I'm not sure what its rotating around. (I think it might be rotating around the position.X of camera, not sure)
If you look at these two images: http://imgur.com/E9qoAM7,5qzyhGD#0

http://imgur.com/E9qoAM7,5qzyhGD#1

The first one shows how the camera is normally, and the second shows how I want the level to look when I would rotate the camera 90 degrees left or right.
My camera:

public class Camera
{
    private Matrix transform;
    public Matrix Transform
    {
        get { return transform; }
    }

    private Vector2 position;
    public Vector2 Position
    {
        get { return position; }
        set { position = value; }
    }

    private float rotation;
    public float Rotation
    {
        get { return rotation; }
        set { rotation = value; }
    }

    private Viewport viewPort;

    public Camera(Viewport newView)
    {
        viewPort = newView;
    }

    public void Update(Player player)
    {

        position.X = player.PlayerPos.X + (player.PlayerRect.Width / 2) - viewPort.Width / 4;

        if (position.X < 0)
            position.X = 0;

        transform = Matrix.CreateTranslation(new Vector3(-position, 0)) *
            Matrix.CreateRotationZ(Rotation);

        if (Keyboard.GetState().IsKeyDown(Keys.D))
        {
            rotation += 0.01f;
        }
        if (Keyboard.GetState().IsKeyDown(Keys.A))
        {
            rotation -= 0.01f;
        }
    }
}

(I'm assuming you would need to rotate around the centre of the screen to achieve this)


texts: How to override the NetworkManager in Unet properly?

texts:
I need some customization on the NetworkManager Class for my game I'm working on. I've read, that it's pretty common to override stuff from the NetworkManager. So I've implemented the NetworkManager as CustomNetworkManager class like this :

using UnityEngine.Networking;

public class CustomNetworkManager : NetworkManager
{

}

I hope I'm right, that I don't have to implement a method to get all the functionality from the base class?

I duplicated my NetworkManager Object, which basically was just the NetworkManager with another CustomNetworking Script. Then I replaced the old NetworkManager with my new CustomNetworkManager and changed the references in the other script accordingly.

So my old GameObject looks like this :

And this is my new GameObject :

The old GameObject works (I just have to change the NetworkManager type in my CustomNetworking class)

But the new GameObject with the custom implementation is getting the following error :

NullReferenceException: Object reference not set to an instance of an object
CustomNetworking.EnableMatchmaker () (at Assets/CustomNetworking.cs:27)

The CustomNetworking class with the error looks like this :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.Match;
using UnityEngine.Networking.Types;

public class CustomNetworking : MonoBehaviour
{
    public CustomNetworkManager manager;
    public MatchInfo currentMatch;

    // Use this for initialization
    void Start()
    {
        manager = GetComponent<CustomNetworkManager>();
    }

    public void EnableMatchmaker()
    {
        manager.StartMatchMaker(); //This is the first call which is made and where the error occurs
    }

    public void CreateMatchmakerMatch()
    {
        manager.StartMatchMaker();
        manager.matchMaker.CreateMatch(
            manager.matchName,
            manager.matchSize,
            true, "", "", "", 0, 0,
            manager.OnMatchCreate);

    }

    public void FindMatchmakerMatch()
    {
        manager.matchMaker.ListMatches(0, 20, "", false, 0, 0, manager.OnMatchList);

        if (manager.matches != null)
        {
            for (int i = 0; i < manager.matches.Count; i++)
            {
                var match = manager.matches[i];
                manager.matchName = match.name;
                manager.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, manager.OnMatchJoined);
            }
        }
    }

    public void DestroyMatchmakerMatch()
    {
        manager.client.Disconnect();
        manager.matchMaker.DropConnection(manager.matchInfo.networkId, manager.matchInfo.nodeId, 0, manager.OnDropConnection);
        manager.matchMaker.DestroyMatch(manager.matchInfo.networkId, 0, manager.OnDestroyMatch);
        manager.StopMatchMaker();
    }

    public void StartMatchmakerMatch()
    {
        //manager.StartClient()
      manager.ServerChangeScene("MainScene");
    }
}

I think I did some failure with implementing the overwritten NetworkManager, hopefully someone can help me with this issue.


texts: Unity: How to get the visible bounds of an object, i.e. as it is seen from the camera?

texts:
Imagine you'd like to highlight a 3D GameObject by drawing a (translucent) UI panel above it. The UI panel should cover the object exactly. Therefore the object's bounds, as it is seen from the camera, are needed.
How do you get these bounds? (In word space, or screen, viewport or canvas space, any way's fine).
My problem is that [Collider|Renderer|Mesh].bounds does not take the camera's position into account. Hence, depending on the camera's location and the object's dimensions, the bounds are more or less off.
Do you know how this can be fixed?
Any advise is very much appreciated. Thank you!


texts: Unity: Efficient way to get the average pixel color for a portion of the camera viewport

texts:
At it's core, the problem I'm trying to solve is this:
I have a camera (not main) that I would like to project to a 2 pixel RenderTexture. I would like the first pixel to be the average color of all pixels in the left portion of the camera viewport (or a close approximation). And the second pixel to be the average color of all pixels in the right portion of the camera viewport.
So far I've looked into doing this via OnRenderImage(src, dest) but I'm open to any suggestions. Same goes with camera resolutions, 256x256 seems like a good starting point but open to suggestions here too. It's worth mentioning that I just threw together a brute-force non threaded approach that works but totally tanks FPS (nothing surprising)
Any help would be greatly appreciated. This doesn't seem like an incredibly weird downscaling approach but I can't seem to find anything regarding it. There might be a clever way of dealing with this via a shader but I have yet to find it. Bilinear downscaling (which I think is what unity uses by default) sadly does not give the appropriate result.
System compatibility is not an issue, Win 10, DX 12.


texts:
So, I am trying to make a "trap" block. It should kill the entity that will stand on it(or walk as in the code, if somebody knows how to make that it will do something while an entity stands on it, it will be helpful). Here's the code for the block:

package com.daniel_sl.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;

public class Trap extends Block{

  public boolean isDead;

  protected Trap(Material material) {
    super(material);
  }

  public void setDead()
  {
    this.isDead = true;
  }

  public void onEntityWalking(Entity Entity){
    if(Entity instanceof EntityLiving){

      Entity.setDead();
    }
  }
}

When I stand on the block it doesn't do anything.


texts: Why I'm getting the same result when deleting target?

texts:
In the following code we use target in the function:

moon.mouseEnabled = false;
sky0.addChild(moon);

addEventListener(MouseEvent.MOUSE_DOWN, onDrag, false, 0, true);
addEventListener(MouseEvent.MOUSE_UP, onDrop, false, 0, true);

function onDrag(evt:MouseEvent):void {
    evt.target.addChild(moon);
    evt.target.startDrag();
}

function onDrop(evt:MouseEvent):void {
    stopDrag();
}

But if I rewrite this code without evt.target it still work. So what is the difference, am I going to get errors later in the run time because I didn't put target? If not then why some use target a lot while it works without it.

function onDrag(evt:MouseEvent):void {
    addChild(moon);
    startDrag();
}


texts:
I'm using Unity3D (not 4) and I'm experiencing a bit of a problem with character movement. I'm using a capsule as a First Person player with a camera attached to it. In this capsule is the stock ThirdPersonController script (with the animation parts removed). I know it's not conventional, but it's not the problem in this case.

The problem is when my character goes down hills, running or walking, it bounces down. It's as if it's going horizontally, then realising it's not grounded and then falling. It works fine going uphill but the downhill is driving me crazy.

One solution that may be possible is raycasting, I know what it is but I have no clue on how to use it.


texts: Mirror/Unet, RegisterSpawnHandler throws invalid asset Id error because assetId is 0 for dynamically loaded assetbundles

texts:
Its weird how documentation literally states that

For more advanced uses, such as object pools or dynamically created
Assets, you can use the ClientScene.RegisterSpawnHandler method

But seems like its broken, because dynamically loaded objects' assetIds' are always 0:
(This is true for all other dynamically spawned objects)

My code structure:
I have a "MapLoader" script that loads objects from filesystem using its config file.
MapLoader creates vehicles and assigns them unique UIDs that are same across players.
Vehicles are added into Static dictionary with UID -> vehicle key/value pairs, and to a list of GameObjects:
        VehicleNetworking vehicleNet = spawned.AddComponent<VehicleNetworking>();
        vehicleNet.vehicleScript = vehicleScript;
        vehicleNet.uid = uid;

        spawned.tag = "vehicle";
        spawned.layer = 10;

        GameManager.vehiclesToSpawn.Add(spawned);
        GameManager.AddVehicle(vehicleNet);
    }

After vehicles have been added, I call functions on the local Player object to spawn them:
  foreach (GameObject vehicle in GameManager.vehiclesToSpawn)
    {
        if (isServer)
        {
            SpawnServerVehicles(vehicle);
        }
        else
        {
            SpawnClientVehicles(vehicle);
        }
    }

Spawn scripts:
[Server]
void SpawnServerVehicles(GameObject vehicle)
{
    Debug.Log("Server should spawn: " + vehicle.name);
    NetworkServer.Spawn(vehicle);
}

[Client]
void SpawnClientVehicles(GameObject vehicle)
{
    Debug.Log("Client should spawn: " + vehicle.name);

    MD5 md5 = MD5.Create();
    string vehicleId = vehicle.GetComponent<VehicleNetworking>().uid;
    byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(vehicleId));

    Guid result = new Guid(hash);
    Debug.Log(vehicle.name + "-" + result);
    ClientScene.RegisterSpawnHandler(result, SpawnHandler, UnSpawnHandler);
}

Spawn handlers:
private static GameObject SpawnHandler(Vector3 position, Guid vehicleGuid)
{
    Debug.Log("Called Spawn Handler");
    GameObject go = new GameObject();
    return go;
}

private static void UnSpawnHandler(GameObject gameObject)
{
    Destroy(gameObject);
    Debug.Log("Called UnSpawn Handler");
}

If I am doing everything right, and Mirror library is actually broken, then I'd like to know what could the workarounds be?
My goal is to have SyncVars on vehicles working and syncing with the server(But for this, I need to have NetworkIdentity on vehicles, and for them to work, they need to be spawned using NetworkServer or ClientScene).


texts:
I have a question that is confusing me with making a game.

For my game launch i pre load everything for the main menu then i loop the game to display it.

But lets argue player wants to launch a new game or a specific level, then you preload the relevant sounds/graphics for that level right?

How ever, the player must already be running the game loop if they are at the main menu, so you can't load in the game loop or you will load every frame...but im pretty sure most big games don't preload every level when you first run the game from desktop because it would take a long time on some of these games....

How is it done :S


texts: Playing Audio Source in Unity 2d game on destroy

texts:
I'm trying to play a sound when an enemy is destroyed.  I created a child game object and put this in the OnEnterCollision2D function:

 private void OnCollisionEnter2D(Collision2D collision)
{
    effect = GetComponent<AudioSource>();
    effect.transform.parent = null;
    effect.Play();
    Destroy(effect.gameObject, 1);
    Destroy(gameObject);
}

However, it doesn't seem to fire this event when the bullet enters the enemy character.


texts: Using an engine to create content with PHP - but how should it happen?

texts:
I need to create an engine that will allow me to add content to a website. The website is a browser-based game. This is a verbose engine that should be able to handle many different aspects of the project.

For an example, I want the developers to be able to insert "dreams" into the game. A dream is called each night for the player, and upon login they will see the dream they had. A developer will write up a cool dream for the game and insert it... but to where?

That's what I'm struggling with. Naturally, I think to myself that all content for the game will enter a database once a developer is done with it. However, the amount of content could be potentially very high, and it may be too hard on the server's resources once the game grows bigger - userbase included. The other way to do it to simply hardcode everything in: a simple "dreams" file that a developer would append their dream to. I cannot have such a system, however, if this project were to have five casual developers that don't know how to even open a PHP tag! ;)

Presently the best way I can imagine a player receiving a dream is to have a developer write it and then the database pulls the dream the player receives from the database. It seems unnecessarily arduous and I'm hoping that if I still must use a database, that you folks can steer me into the right direction for how to execute this efficiently.


texts: Swapping Framebuffers or swapping attachments?

texts: I wanted to know what the better approach would be for post-processing: swapping between framebuffers or swapping between textures attached to one framebuffer?


texts: GLSL error on AMD gpu. No error on nVidia

texts:
I have an OpenGL program that works fine on nVidia card, but produces Access violation error and GL_INVALID_OPERATION at glDrawElements on AMD gpu.

For starters I have this geometry shader which now won't compile.

#version 330

// Input is triangles, output is triangle strip.
layout(triangles) in;
layout(triangle_strip, max_vertices = 6) out;

// Data passed from vertex shader.
in VertexData
{
   vec3 normal;
   vec3 view;
}  inData[];

// Data passed to fragment shader.
out FragData
{
   vec3 normal;
   vec3 view;
} frag;

// Uniforms.
uniform mat4 modelview_matrix;
uniform mat4 projection_matrix;

// Array of indexes for triangles to be split.
uniform int index[256];
uniform vec3 points[256];

uniform float split_factor;

uniform int tear;

void create_split ();
void make_face (vec4 a, vec4 b, vec4 c, vec3 normalA, vec3 viewA, vec3 normalB, vec3 viewB, vec3 normalC, vec3 viewC);

void create_split ()
{
   float f = gl_PrimitiveIDIn * split_factor;
   if ( f == 0.0f)
   {
       f = 0.2f;
   } else if ( f > 0.9f )
   {
       f = 0.9f;
   }

   vec4 midPointA = (gl_in[0].gl_Position + gl_in[1].gl_Position) * f ;
   vec4 midPointD = (gl_in[3].gl_Position + gl_in[4].gl_Position) * f;

   vec3 normalA = inData[0].normal;
   vec3 viewA = -midPointA.xyz;

   vec3 normalB = inData[1].normal;
   vec3 viewB = -midPointB.xyz;

   vec3 normalC = inData[2].normal;
   vec3 viewC = -midPointC.xyz;

   make_face (gl_in[0].gl_Position, midPointA, midPointD, inData[0].normal, inData[0].view, normalA, viewA, normalC, viewC);
   make_face (gl_in[0].gl_Position, midPointD, gl_in[4].gl_Position, inData[0].normal, inData[0].view, normalA, viewA, normalC, viewC);
}

void make_face (vec4 a, vec4 b, vec4 c, vec3 normalA, vec3 viewA, vec3 normalB, vec3 viewB, vec3 normalC, vec3 viewC)
{
   gl_Position = a;
   frag.normal = normalA;
   frag.view = viewA;
   EmitVertex();

   gl_Position = b;
   frag.normal = normalB;
   frag.view = viewB;
   EmitVertex();

   gl_Position = c;
   frag.normal = normalC;
   frag.view = viewC;
   EmitVertex();

   EndPrimitive();
}

void main()
{
    int i = 0;
    bool flag = false;

   if ( tear == 1 )
   {
      while(i < MAX && !flag)
      {
          if (gl_PrimitiveIDIn == index[i])
          {
              if (i > 0 && i < 256)
              {
                  if (index[i+1] - index[i] < 100)
                  {
                      create_split();
                      flag = true;
                  }
               }else if (i == 0 || i == 256)
               {
                  create_split();
                  flag = true;
               }

           }
           i++;
       }
   }

   i = 0;
   if (!flag)
   {
       for (i = 0; i < gl_in.length(); i++)
       {
           gl_Position = gl_in[i].gl_Position;
           frag.normal = inData[i].normal;
           frag.view = inData[i].view;
           EmitVertex();
           if ( i == 2)
           {
               EndPrimitive();
           }
       }
       EndPrimitive();
   }
}

Which produces those errors:

Compiling the geometry shader : _shaders/gs_smooth.glsl ...
Error: The shader _shaders/gs_smooth.glsl failed to compile.
Shader info log for GL index 4
Geometry shader failed to compile with the following errors:
ERROR: 0:55: error(#147) "[" array index out of range: '3'
ERROR: 0:55: error(#147) "[" array index out of range: '4'
ERROR: 0:82: error(#147) "[" array index out of range: '4'
ERROR: error(#273) 3 compilation errors.  No code generated

I've tried googling but nothing interesting showed up.
This error is not happening on the nVidia card.

Also AMD card is R9 270 while nVidia is GTX970.

Thanks.


texts: Weird blending behavior on PowerVR SGX544MP2

texts:
On PowerVR SGX544MP2, sometimes blending behaves in a very strange way for me.

Instead of blending with the actual color from the previous draw calls, it tries to blend with black:

(sorry about the low quality, it's not my tablet and not my photo)

Some polygons render correctly, however (that blue hit decal on the left (which is blended with black in the middle, however), the beam and the HUD), but certain decals are broken.

How do I fix or work around the problem? It seems to be related to deferred rendering of tiles, but I don't really know. On other GPUs, it looks alright.


texts: How do I run a callback when all objects have stopped moving?

texts:
I'm using Bullet and want to take some action once all objects in a dynamic world have reached 0 velocity (or at least a value that's very close).

I was trying to iterate over all of them all the time and when a counter equals getNumCollisionObjects() then do that action. But it's a complex procedure and I'm beginning to think it's unnecessary.

Is there a better way, perhaps by comparing two frames or a Bullet built-in?


texts: Player object glitching around when there is a low framerate Unity C#

texts:
I just started to make this game, it runs fine on my computer. 60fps, but when I tested it on another computer, with lower fps, the player just started to jitter and glitch around a lot. The game is basically unplayable like that, and I want to make sure that everyone who plays my game will be able to enjoy the full experience. I have pasted the specific part of the code for the movement below.

void Update () {

    rb.AddForce (Vector3.forward * ForwardSpeed);

    if (Input.GetKeyDown (KeyCode.A) && side > maxSideLeft) {
        rb.AddForce (-Vector3.right * Speed);
        side -= 1;
    } else if (Input.GetKeyDown (KeyCode.D) && side < maxSideRight) {
        rb.AddForce (Vector3.right * Speed);
        side += 1;
    }

    if (Input.GetKeyDown (KeyCode.W) && level < maxLevelHeight) {
        rb.AddForce (Vector3.up * Speed);
        level += 1;
    } else if (Input.GetKeyDown (KeyCode.S) && level > minLevelHeight) {
        rb.AddForce (-Vector3.up * Speed);
        level -= 1;
    }

    if (Input.GetKeyDown (KeyCode.R) || Input.GetKeyDown(KeyCode.Space)) {
        SceneManager.LoadScene ("Scene1");
        Time.timeScale = 1;
    }
}


texts: Why should I not use MySQL for a browser based game?

texts: I keep reading on here that I shouldn't use MySQL for game development/play on the Internet, a browser game.  I understand MySQL wasn't made necessarily for that and for big relational needs.  Ok.  But what do I use then?  I am on a shared hosting, Unix/Linux platform.  What do I use to store my "stats" or other game necessities, level information, player information, etc.


texts: Writing via content pipeline in Xbox game project

texts:
I'm creating an Xbox application and I have this problem with the content pipeline. Loading .xnb files is not a problem but I can't seem to find any helpful tutorials on writing via the content pipeline. I want to write an XML whenever the user presses a custom made "save" button. I've searched the web for "saving game sate" etc. but so far I haven't found a solution for my case.

So, summarized: is there a way to write data (in XML format) via the content pipeline, if my Save() method is called?

Cheerz


texts:
I know this may be a somewhat dumb idea, but is there any "easy" resource that anyone can point me towards that shows how to set up a simple LAN connection in an Actionscript application? I only need to have two clients connected. Nothing extremely robust.

This is not an AIR application. It's for a game idea that I have that will need two players essentially. It will be local, so having each other's IP addresses will be an option. So no need to find or detect any IP addresses.

Thanks.


texts: Game runs in UE4Editor but not standalone

texts:
I have just completed these instructions to build and run UE4Editor for Linux.

I created a new C++ project and in the editor I hit the Launch button and after a while it compiled and ran successfully.

If I close down UE4Editor and cd to MyTestProject/Binaries/Linux/ there is a MyTestProject executable, but if I try to run that from the shell I get

error while loading shared libraries: libApexCommonPROFILE.so: cannot open shared object file: No such file or directory

How do I set up the program so that it can be run standalone, not from within the editor?


texts: How to deal with (bad?) player suggestions

texts:
Every game which builds a community while still being in active development will soon be confronted with players who post suggestions for new features on its forum. Most of these suggestions, however:

Go into a completely different direction than where you want your game to go
Would require far too much effort for the benefit they could have
Are just plain awful

What's a good way to deal with such suggestions?

Should you tell the players honestly what you think about their suggestions so that they learn to make more constructive ones?

Should you always try to maintain a positive and encouraging attitude towards player ideas, even when you secretly think that there is not a chance in hell you are following them?

Should you just ignore any suggestions which you don't like?


texts: Editing a new list of vector3's without changing the original list? (Unity)

texts:
I just got Vectrosity for Unity and need to make a line of all the destinations for an object. Issue is that I need to use a single list of vector3's to create the line (as far as I'm aware).

I have a list of vector3's that is the objects queued destinations. I then need to insert the objects current location at index [0] in the list so that the first line point is at the objects location. Issue is that no matter how I try and accomplish this I'm still referencing the original destinations list, and inserting something at [0] on the list for the lines changes the original destinations list as well.

How do I go about creating a single List from a list of vector3's and an extra point without changing the original list that is being referenced? Do I need to clone it?


texts: How to map absolute Joystick position to object rotation?

texts:
In my (Ogre) 3d scene I have an object that should be rotated locally based on Joystick input. I have a Joystick with min/max values of [-32767, 32767] on both X and Y axes. When the Joystick is in its origin position, the object should not be rotated. When the user moves the Joystick, the object in the 3d scene should follow this movement (or better: orientation) up to a max. of +/- 45 degrees on both axes.

Or in other words: when the user moves the Joystick e.g. fully to the left, the object's orientation in the 3d scene should be set to 45 degrees on the according axis.

Being new to 3d programming I searched on the Internet on how to achieve this. I think to understand that I want to use Quaternions for this task. I found some examples and tutorials on how to use Quaternions for rotating objects. What I don't understand though is how I can map from the Joystick's current absolute axes positions to the absolute, local rotation of an object.

I see that I could use the rotate() method of the object's node to set its rotation, but I understand that this rotates the object relatively to it's current position. But instead I want to map from the Joystick's absolute position to the absolute orientation/rotation of the object in the scene.

Any advice how I should approach this?


texts: How can I simplify this code to compute the shortest rotation between two angles?

texts:
The following code will find the shortest rotation (in radians) (from pi to -pi) that I need to apply to from to leave me with to.

Scalar rotationBetween(Scalar from, Scalar to)
{
    Scalar fromMod = std::signbit(from) ?
        pi * 2 + std::fmod(from, pi * 2) : std::fmod(from, pi * 2);
    Scalar toMod = std::signbit(to) ?
        pi * 2 + std::fmod(to, pi * 2) : std::fmod(to, pi * 2);

    Scalar rotation = toMod - fromMod;

    if(rotation > pi)
        return rotation - 2 * pi;
    else if(rotation < -pi)
        return 2 * pi + rotation;
    else
        return rotation;
}

Scalar is a c++ float.

Can I simplify this? I feel like this is far too much logic to do something so simple.


texts:
I've been trying to write my own collision code, less because I want to, more because I want to understand its working.

To do this, i've been working off of the popular collision book i'm sure you've all heard of: Morgan Kaufmann Real Time Collision.

I'm on the subject of Oriented Bounding Boxes. These are boxes that can have an orientaiton applied to them.
If it matters, i'm doing my code in 2D. It seems easy enough to just cut out an axis from the books calculations.

Here is the OBB they define:

// Region R = { x | x = c+r*u[0]+s*u[1]+t*u[2] }, |r|<=e[0], |s|<=e[1], |t|<=e[2]
struct OBB {
    Point c;     // OBB Center Point
    Vector u[3]; // Local x-, y-, and z-axes
    Vector e     // Positive halfwidth extents of OBB along each axis
};

The confusing one is the Vector array, u.

Point c is the center 3 axis position of the box.
Vector e is the width, height, and length of the box.
Vector u[3] baffles me. My best guess is that it is the center-point of each of the 3 sides (with the reflected 3 finishing the box)

How does rotation work into this? Is the Vector u[3] taking the roation in somehow? How?


texts:
I'm just getting started with 3D so I'm not sure what's this is called. If I move a point in a polygon out of alignment with the other points in the polygon, such that is would be on a separate plane, what do you call it? What are the implications of doing so? Should this be avoided? Does this affect CPU? rendering? Is this universally supported by hardware and WebGL?

In my example, I have essentially turned a square plane into two triangular planes, creating a "v" in the middle of a cube. It appears that both triangles belong to a single face on the cube.


texts: Handling image size based on different ios device versions (Unity2D)

texts:
This game is built using Unity 4, C#, and the 2D toolkit. In the unity game scene settings, it is set to (ios 5 tall) and I matched the Menu background dimensions with the dimensions of an ios 5 tall device.  When testing this build on a different ios device(ios 4 etc...), the menu background doesn't fit (stretch) to the width and height of the tested device's dimensions. The answer seems pretty obvious that i'm not handling all devices dimensions.

What would be a good approach on handling images based on different ios devices? Are there any build settings to build a project that handles each device dimensions?

Thanks in advance for any advice or a good approach for cross-device handling


texts: I am trying to create a platform game where a player jumps between platforms horizontally (using a projectile curve). Currently, I have a class that blits platforms and a background, as well as the player. However, I cannot get it to detect when a platform and the player collide. I have used actual images and then done self.rect = self.image.get_rect() for both the platform and the character. My question is have I done something wrong with my theory or have I just not coded it correctly.


texts:
I'm working on a multiplayer RPG using only C++ and SDL2. I've already made the main menu and a map editor, and I'm preparing to make the actual game. The main menu and map editor were easy to structure, because they had repetitive visuals and concepts -- map-editing tools can be represented as an enumerated list, just like saved-games and settings -- and so I was able to store them in structured vectors, and then when I went to render everything and check for user actions I could just iterate through the lists and hit every visible menu item. My code for those sections is small and neat; I'm proud of it.

Now, in the game, I'm realizing that my HUD is composed of a rather random assortment of types of things that the player can click on. There's a quick-access area for items, another one for spells, another one for the map, another for NPC-buddy commands, etc, and each of those have totally unique popup menus associated with them. Then there's a menu for crafting, a menu for NPC dialog, and several of the items have their own independent menus for interacting with them.

I'm trying to think of the right way to structure all these lists. Storing them in vectors like I did with the menu and stuff seems like it will land me with an unwieldy and asymmetrical set of nested vectors, and it might be complicated to iterate through it. How do good programmers handle this kind of thing? Should I just make an independent section in code for each in-game menu?


texts: I have been learning about the A* path finding algorithm and I can't understand the heuristic cost in this algorithm. What is it and what is its use in the algorithm?


texts: Unity 2019 build for Oculus Go not appearing on device

texts:
My project was building fine in 2018 and showing up on my Go under "unknown sources".

My project builds fine in 2019 and it says it gets installed but it no longer shows up under "unknown sources" or anywhere else that I can see.

I can uninstall using adb - so it's there apparently, but where, and how can I launch it?

thanks


texts:
I am working on a cool little city generator which makes cities in the isometric perspective. However, a problem arose where if the grid size was over a certain limit it would have awful lag. I found the main problem to be in the draw method. So I took the precautionary step of rendering only items that were onscreen. This fixed the lag but, not by much.

The idea I have is to render the frame once and take a snapshot. Then, display that as a texture2d on screen. This way I don't have to render 1,000,000 objects every frame since they don't change anyways.

TL;DR - I want to

Take a snapshot of an already rendered frame
Turn it into a Texture2D
Render that to the screen instead of all the objects.

Any help appreciated.


texts:
I have no experience in AI at all, but I would like to know how I could do this?
Even if the AI just followed a path how could I do this?


texts: Unity: Change Text with Time (Text Flashes)

texts:
I am trying to display instructions within the Unity game. The idea is to have the instructions appear over time. For example, "instruction 1" then wait 5 seconds and show "instruction 2" instead of instruction 1 (on the same spot, in this case, I am changing the "message" variable in the code to change the instructions). This code does change the instructions but the problem is that it does it in a haphazard fashion. It appears that "instruction 1" is replaced with "instruction 2" and then it reverts back to "instruction 1" within a second and then back to "instruction 2" so instead of just 1-appearing->1-disappearing->2-appearing->etc in a smooth fashion, it does this weird flashing thing before proceeding to the next instruction. How could I fix this?

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

public class Growing : MonoBehaviour {

    public Text instructions;
    public string message;

    void Start () {
         instructions.text = message;
    }

    void Update () {

         Instructions();

         //other code to begin moving a game object
    }

    IEnumerator Instructions() {
        //run instructions
        message = "GET READY FOR YOUR FOCUSED BREATHING EXERCISE";
        yield return new WaitForSecondsRealtime(5);
        message = "MAKE SURE YOUR BODY IS COMFORTABLE";
        yield return new WaitForSecondsRealtime(5);
    }


texts: What makes Unity3D games look so similar?

texts:
For some reason, I'm quite good at guessing whether or not a game (both 2D and 3D) is made with Unity3D. But I can't really figure out why that is.

What makes Unity3D games look similar? Is it because people use the same textures? Or is it the texture filtering? The lighting? Something else? I'd really like to know for educational purposes.


texts: Sampling from Normal Map and Diffuse Map in Pixel Shader

texts:
I'm having some issue changing a basic lighting shader to take a normal texture and a diffuse texture for a model and then using the normal texture for lighting.
The code is very simple and i can't see where i have gone wrong at all, am i not allowed to sample two textures with the same sampler?
This is the output i am getting:

Using the two textures:

THe basic shader code is:

Texture2D shaderTexture : register(t0);
Texture2D heightNormalTexture : register(t1);

    float4 PS(VOUT pIn) : SV_Target
{
    float4 diffuseColour = shaderTexture.Sample(SampleType, pIn.texCoord);
    float4 normal = heightNormalTexture.Sample(SampleType, pIn.texCoord);

    float3 litColour = float3(0.0f, 0.0f, 0.0f);

    for(int i = 0; i < 3; i++)
    {
        SurfaceInfo sInfo = {pIn.posW, normal.xyz, diffuseColour, pIn.spec};
        [branch] switch(gLight[i].type)
        {
            case 0: //Parallel
            {
                litColour += ParallelLight(sInfo, gLight[i], gEyePosW);//
                break;
            }
            case 1: //Point
            {
                litColour += PointLight(sInfo, gLight[i], gEyePosW);
                break;
            }
            case 2: //Spotlight
            {
                //litColour += SpotLight(sInfo, gLight[i], gEyePosW);
                break;
            }
        }
    }
    return float4(litColour, diffuseColour.a);
}

The lighting code seems to work just fine when i pass in the normals as part of the vertex buffer, but goes this odd mash-up of diffuse and normal when i try to use the normals from a texture. From what i can tell i am setting the texture right in C++.

    ID3D11ShaderResourceView *pixelShaderTextures[2];
pixelShaderTextures[0] = m_textureManager.GetTextureResourceView(std::string("TestHeightMapNormal"));
pixelShaderTextures[1] = m_textureManager.GetTextureResourceView(std::string("TestTexture"));

context->PSSetShaderResources(0, 2, pixelShaderTextures);

If you guys have any help/advice for me to resolve this, that would be great.


texts:
Possible Duplicate:
  What are some good resources for getting a beginner started in developing games?

I'm a CS student, having plenty enough knowledge in programming, and general algorithms. What is your suggestion in game developing? How to start?

Thanks a lot!


texts:
Where are you supposed to store InputLayout?

Suppose i have some basic structure like.

class Mesh
{
   List<MeshPart> MeshParts
}

class MeshPart
{
   Effect Effect;
   VertexBufferBinding VertexBuffer;
   ...
}

Where should I store input layout?

It's a connection between vertex buffer and specific pass, i can live with just 1 pass but I still have diffferent techniques so i need at least an array with some connection to effecttechniques, but I would appreciate something not crazy like dictionary. I could also create wrapper for Effect and EffectTechnique, but there must be some normal solution.


texts: Can I publish the games I learnt from tutorials and modified as per my style of game-play?

texts:
I am new to the world of making games and all. Well its been a few months or so. There are many tutorials that I have been watching. On the way, I made a few games that I saw and made. I am not asking about those. In fact I don't want to publish those games in my name ever.
But then there are some small games that I made which are modified version from what I learnt of those games. Like I changed the game-play style, made it simpler and ignored some features from a game.  Can I publish them in play store? Or this would be any break of law or something? or Something that I should not do?


texts: Can i use a method to change a variable that is external to it?

texts:
I'm trying to change two booleans that exist outside my method. I read about passing by value and passing by reference and in this case i think the correct way is to use passing-by-reference.
However, it is not working. I call the method and my booleans still with the same value as before the calling.
Can someone help me?
Thanks!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CheckingPosition : MonoBehaviour
{
    public bool isClose = false;
    public bool isFar = false;
    public float radius;
    public float distance;
    private Vector3 initPos;
    private Vector3 actualPos;

    // Start is called before the first frame update
    void Start()
    {
        initPos = this.transform.position;
    }

    // Update is called once per frame
    void Update()
    {
        actualPos = this.transform.position;
        Vector3 direction = actualPos - initPos;
        var distance = direction.magnitude;

        CheckPositionAndCount1(ref isClose, ref isFar);
    }

private void CheckPositionAndCount1(ref bool close, ref bool far)
    {
        if (close == false && far == false && distance > radius && distance != 0)
        {
            far = true;
            Debug.Log("Saiu pela primeira vez");
            return;
        }
        else if (isClose == false && isFar == true && distance <= radius)
        {
            far = false;
            close = true;
            Debug.Log("Está perto");
            return;
        }
        else if (isClose == true && isFar == false && distance > radius)
        {
            close = false;
            far = true;
            Debug.Log("Está longe");
            return;
        }
        return;
    }
````


texts: How to get Unity's 4.6 UI images to layer over each other perfectly?

texts:
I've been noticing that if I have two images, lets say squares. I have  A as the parent of triangle B. Triangle A and B both have their offsets at their anchors, which are on the 4 corners of it's "box".

Triangle A should be behind triangle B, since it renders from top to bottom in the hierarchy (the last item being on top). However as I re-size my screen, sometimes triangle  A will poke out from behind triangle B. Even if they both are using the same image, and have the exact same dimensions.

Whats causing this, and how do I fix it?

Additionally, I noticed that while the anchors and offsets can be finely adjusted, the image is not. You have to adjust by certain interval sizes and the image will just snap to that new size rather than adjusting finely as you change the offset or anchors.


texts: How can I set up potentially dozens of cameras rendering to targets without killing performance?

texts:
I'm thinking through how I'd do a particular trick for playing cards with animated 3D faces. Setting up a single card is pretty trivial. I would create another camera somewhere, maybe restrict some layers so it'll only show what I want it to show so I don't have to worry what's behind it, put an object in front of it that is the basis of the card, have the camera render to a texture, and put that texture on a quad (the card) with the same aspect ratio. Now whenever the main camera views the card, regardless of angle, the card displays what the other camera sees.

I don't believe this approach would scale well as I'd have to duplicate everything for every card. The way I imagine it, there could be dozens of cards visible at once so every frame would require rending all of them. Even at low qualities that sounds bad for performance. Also the main reason I want to animate cards is to have them respond to input and actions happening to the cards so two instances of the same card won't show exactly the same thing. Another thing is where would I place all these cameras and their models in the 3D space so that they won't see each other? I could put them on top of each other and use layers to only capture what I want but something doesn't feel right about having dozens of layers.

How would I begin to pull this off on a scale of dozens of cards?


texts:
So I'm using the Unreal Engine 4 to make a mobile game. I'm currently trying to set up the Google Play services so I can do Leaderboards, Acheivements and In-App Purchases but I'm struggling with the first right now.

You can see the behaviour in this short video.

It seems that it tries to contact the service then something goes wrong and it gives up. I made a logcat logfile from my phone while this was happening and this is what I got:

I/GamesNativeSDK(16078): Connecting to Google Play...

V/GamesNativeSDK(16078): Attached to JVM on thread main_dispatch

D/ChimeraCfgMgr(11916): Loading module com.google.android.gms.games from APK com.google.android.play.games

D/ChimeraModuleLdr(11916): Module APK com.google.android.play.games already loaded

D/ChimeraCfgMgr(11916): Loading module com.google.android.gms.games from APK com.google.android.play.games

D/ChimeraModuleLdr(11916): Module APK com.google.android.play.games already loaded

V/GamesNativeSDK(16078): Play Games callback indicates connection failure.

I/GamesNativeSDK(16078): UI interaction required to connect to Google Play.

D/UE4     (16078): [2015.10.26-19.31.29:804][  0]LogOnline:Warning: Async task 'Login' failed in 0.582350 seconds

E/SignInIntentService(11916): Access Not Configured. The API (Google Play Game Services API) is not enabled for your project. Please use the Google Developers Console to update your configuration.

E/SignInIntentService(11916): com.google.android.gms.games.server.error.GamesException

E/SignInIntentService(11916):  at com.google.android.gms.games.server.GamesServer.getResponseBlocking(GamesServer.java:164)

E/SignInIntentService(11916):  at com.google.android.gms.games.broker.PlayerAgent.getPlayerFromNetwork(PlayerAgent.java:1700)

E/SignInIntentService(11916):  at com.google.android.gms.games.broker.PlayerAgent.fetchPlayer(PlayerAgent.java:621)

E/SignInIntentService(11916):  at com.google.android.gms.games.broker.DataBroker.loadSelf(DataBroker.java:920)

E/SignInIntentService(11916):  at com.google.android.gms.games.service.PlayGamesSignInIntentService$LoadSelfOperation.executeInternal(PlayGamesSignInIntentService.java:402)

E/SignInIntentService(11916):  at com.google.android.gms.games.service.PlayGamesSignInIntentService$BaseOperation.execute(PlayGamesSignInIntentService.java:51)

E/SignInIntentService(11916):  at com.google.android.gms.games.service.PlayGamesSignInIntentService$OperationAdapter.execute(PlayGamesSignInIntentService.java:487)

E/SignInIntentService(11916):  at com.google.android.gms.chimera.BaseAsyncOperationService$OperationTask.run(BaseAsyncOperationService.java:179)

E/SignInIntentService(11916):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

E/SignInIntentService(11916):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

E/SignInIntentService(11916):  at java.lang.Thread.run(Thread.java:818)

E/LoadSelfFragment(16219): Unable to sign in - application does not have a registered client ID

I understand the error messages. But I don't understand why I get them. I tried to Deploy directly from the launcher as well as make a signed APK and install on my phone. It's the same result.

I looked around for a solution to this issue but I can't find any problems with the settings in my Developer Console nor anything missing. I'm a bit at a loss here and I'm aiming for a release in December 2015 so I need help. Epic Games had pretty much no documentation on the nodes provided to do this so all of this have been fumbling in the dark.


texts:
I have child object with ParticleSystem component.
I want to have particles disabled until I press button.

I unchecked child object to make it disabled but when I press play it enables automatically(with no scripts attached). Then I made this script below (with .SetActive(false) part only) and it worked.

But then I needed to activate it somehow, which I did, but now when I press play, object is automatically enabled/ activated again.

Is there another way of doing this because I need it haha.

var particle1: GameObject;
var particle2: GameObject;
var particle3: GameObject;

public var triggered : boolean = false;

function OnTriggerEnter() { triggered= true; }
function OnTriggerExit()  { triggered= false;}

function Start()
{
    particle1.SetActive(false);
    particle2.SetActive(false);
    particle3.SetActive(false);
}

function Update()
{
    if (triggered && Input.GetKeyDown(KeyCode.JoystickButton1))
        particle1.SetActive(true);
        particle2.SetActive(true);
        particle3.SetActive(true);
}


texts:
I have these armor types:

LEATHER
MAIL
PLATE

which are, basically, light, medium and heavy, and these weapon types:

BLADE
PIERCE
BLUNT

I need a sensible 3x3 table which tells what armor type is succeptible to (and, possibly, good against, though it's not necessary) which damage type. In other words, how good the mail armour actually is against pikes/arrows, etc... Any ideas?

P.S. Wikipedia search and personal gameplay experience didn't help me too much, as both are mostly concluding: the heavier, the better.


texts: Cannot find folder when building game to .jar LibGDX

texts:
Whenever I run my game from my IntelIJ IDEA the game runs fine. It finds every folder and every asset in there. But whenever I build my game with :desktop:dist and run it it will not see the folder I try to open as a folder and it will have 0 contents.

This is the code I use to open the folder:

        FileHandle mapFolder = Gdx.files.internal("maps");

    System.out.println(mapFolder.list().length);

    for (FileHandle entry : mapFolder.list()) {
        System.out.println("something is in");
        maps.add(new Map(entry.toString()));
    }

    loadMap(maps.get(0));

The length it prints is 0. It does not print something is inso im fairly sure this is not working.

Whenever I try Gdx.files.classpath I get this error: Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Cannot list a classpath directory: maps

For clarification: It's a desktop only project. So no android.

I cannot figure it out, and I've looked at a lot of topics to try and fix this issue.


texts: Specifying a root signature in the HLSL code of a DXR shader

texts:
I've noticed that I cannot specify a root signature in the HLSL code of a DXR shader. For example, if I got a ray generation shader with the following declaration
[rootsignature(
    "RootFlags(LOCAL_ROOT_SIGNATURE),"  \
    "DescriptorTable("                  \
    "UAV(u0, numDescriptors = 1),"  \
    "SRV(t0, numDescriptors = 1))")]
[shader("raygeneration")]
void RayGen()
{}

CreateRootSignature yields the error message

No root signature was found in the dxil library provided to CreateRootSignature. [ STATE_CREATION ERROR #696: CREATE_ROOT_SIGNATURE_BLOB_NOT_FOUND].

I've noticed that even when I add a typo (for example, write roosignature instead of rootsignature), the compiler doesn't complain about this typo. So, it seems like the whole attribute declaration is simply ignored.
If I change the code to a simple rasterization shader, everything works as expected.
So, is the specification of a root signature in the HLSL code of a DXR shader not supported?


texts:
I've recently started to experiment with raymarching over on shadertoy.com. It seems common to find the normal for a distance field like so:

vec3 scene_normal(vec3 p)
{
    vec3 e = vec3(0.001, 0.0, 0.0);

    vec3 n = vec3(
        scene_distance(p + e.xyy) - scene_distance(p - e.xyy),
        scene_distance(p + e.yxy) - scene_distance(p - e.yxy),
        scene_distance(p + e.yyx) - scene_distance(p - e.yyx));

    return normalize(n);
}

However, I can't seem to find anything about tangents. Is there a similar method to find tangents generically for a scene, or do I have to generate them specifically for the shapes I'm raymarching?


texts:
I would like to implement an action system where gameobjects offer different actions available to characters.
Actions are composed of several steps holding the details to be performed. These steps have different logic applied to them (go to location, play animation for a time, change variables), so I would like to have them as subclasses.
However I would also like to be able to set up the actual data for an action in the UnityEditor. I know it is possible to do this using ScriptableObjects, but that requires creating an asset for each instance of a step, which I'd like to avoid, since only the classes get reused, the instances being pretty much unique to each gameobject.
Is there a way to work with subclasses in the unityeditor without requiring a dedicated asset for each of the subclass instances cluttering up my folders?


texts: Head tracking stuttering/lag/blur issue with Google Carboard

texts: I am working on Virtual Reality app. I have created a city terrain and when I move around the terrain using keyboard it move smoothly but when using head tracking I feel a lag/blur when I move or look around the scene using Google Cardboard. How can I improve the performance.Is there any method in unity?


texts:
I want to create some fairly complex 2d predefined paths for my AI sprites to follow.

I'll need to use curves, splines etc to get the effect I want.

Is there a drawing tool out there that will allow me to draw such curves, "mesh" them by placing lots of points along them at some defined density and then output the coordinates of all of those points for me?

I could write this tool myself but hopefully one of the drawing packages can do this?

Cheers!


texts: Is there a way to assign a texture to a button and resize it in the Unreal Engine?

texts:
I'm attempting to create a main menu for my game and have followed an easy tutorial to do so. The tutorial doesn't cover assigning textures or images to buttons, so I set out to do this myself.

Assigning the image to the button (I have a 'normal', 'hover', and 'clicked' texture) was rather easy, but the images don't fit.

Using the 'Image Size' options don't do anything at all and I've got no idea on how to change the image without going back into Photoshop or GIMP and just redoing the whole image to fit the button size.

Is there any way to actually change the size of the image inside the button in Unreal? Or do I just have to suck it up and re-do it?


texts: Does the license of games made with Game Maker need to include the Game Maker part?

texts: In the default license generated by Game Maker for your games, some of YoYo Games stuff is mentioned. Are those necessary to be shipped with an application made with GM? Is it legally ok if I remove those and create my own license agreement, not mentioning Game Maker or YoYo Games in it?


texts: User generated content: a basic yet simple to use OR a complex yet powerful solution?

texts:
As stated above, which solution is better for a game based on user generated content?

The simple solution (in-game editor) is great for gamers without experience in coding and etc. In this way every player could populate the game with content. But the content would be very limited.
The complex solution would allow the content to be with almost no limitation but casual gamers probably couldn't make hardly any content at all.

If both solutions are used, the quality behind the second solution would be more valuable than the first solution's quantity.

However, making a powerful in-game editor could even take more time and manpower than the actual game and every gamer would have to learn how to use the new complex tool, understand it, and master it if he or she wants to make quality content.

You would be able to make levels and objects for it as well as the  player model itself.


texts: Overcoming fill rate and generation bottlenecks in voxel engine

texts:
I decided to make a voxel engine using octrees. I am instancing entire cubes and sending the sizes and positions to the vertex shader.

I currently have 2 major problems:

Problem 1 - Because the cubes are instanced I can't remove hidden faces which means that some pixels are being overwritten lots of times. I have backface culling enabled but it doesn't fully help - also I noticed depending on the direction I look the lag is more / less which means sorting it might help, but then I don't really want to be sorting my cubes every frame.

Problem 2 - A 64*64*64 octree takes around 1/2 a second to fill and compress which is too slow, probably needs to be 1/10th of that speed. My method for that is as follows:

I have a generation function bool isCube(glm::vec3). Then, I create a full octree and fill up the base nodes with 0 or 1 depending what isCube returns for that given position. Finally, I compress it by checking if all leaves are the same, remove them, and store that value in the node above.

For reference the current isCube function looks like this:

bool isCube(glm::vec3 pos)
{
    if (glm::length(pos) < 300)
        return true;
    return false;
}

What sort of measures can I take to reduce fillrate?

What is the best way to go about generating landscape with octrees?


texts:
I have made a map generation in my tile based game. It almost exactly does what I want, except for 1 thing. The rivers look like this:

The problem with this is, the water is not realistic. It are just some spots random over the world. I want to make a realistic river generation. Which would include different sizes (between 5 and 20 block wide), branches, lakes and different depths (by changing the colour of the water). What is the best way to do that?

Here is an Simcity 4 example of what I mean with realistic rivers:

My code:

waterOffsetX = Random.Range (10f, 300000f);
waterOffsetX = Mathf.Round (waterOffsetX) + 0.5f;
waterOffsetY = Random.Range (10f, 300000f);
waterOffsetY = Mathf.Round (waterOffsetY) + 0.5f;

for (float x = -gridX; x < gridX; x += 1)
{
    for (float y = -gridY; y < gridY; y += 1)
    {
        Vector3 spawnPos = new Vector3 (x, y, 0);
        float perlinWater = Mathf.PerlinNoise (x * seedWaterX + waterOffsetX , y * seedWaterY + waterOffsetY);

        if (perlinWater > perlinThresholdWater) {
        GameObject waterTile = Instantiate (water, spawnPos, Quaternion.identity) as GameObject;
    }
    }
}

Values:
seedWater (X & Y) = 0.1
Grid (X & Y) = 50
perlinThresholdWater = 0.6


texts: Options for UDK and version control repositories?

texts:
Another developer and I have begun to experiment with the Unreal Development Kit and have installed the UDK to our local computers. He's been toying around and experimenting and has some basic code and assets already developed. We want to set up a VCS repository so we can collaborate on development of a UDK project.

Some things we've noticed:

Source code goes in Development/Src/GameName/.
Binary Content and other assets go in UDKGame/.
The rest of the folders in the root directory are for the core UDK installation.

In terms of repositories, we've already come up with several options:

Commit everything (even the core UDK code).

Pro: Easy
Con: We're committing lots of code that, while a dependency of our project, isn't technically part of the project.

Commit the two folders we contribute to in two separate repositories.

Pro: Isolates versioned code to stuff we create.
Con: Slightly more difficult to set up, commits for one fix span multiple repositories, and we're committing a lot of binary content.

Change the config so both the src and the assets live in one folder, then commit that.

Pro: Isolates versioned code, commits for changes are in one repo.
Con: Committing binary content.

Commit SRC to one repo, use another solution for assets (FTP, Dropbox, etc)

Pro: Isolates versioned code, no extra overhead in versioning binary content.
Con: Changes span multiple places and manual updates to a remote storage solution are needed.

As we assess the best way to go about this so we don't back ourselves into a corner later, I'm wondering if there are other options and what their pros and cons are. I realize we could easily just pick a solution and change it up once we ran into scaling issues, but version control has always been one of those things I like to do once upfront and then forget about when I work on projects.


texts: How to keep clicks from menu from interfering with game state?

texts:
I ran into a problem coding my game in which when I click the play button on the newly implemented menu, it also creates a bullet from my player. The player and the menu both rely on the mouse input. How would I make it so that this doesn't occur? Perhaps how would I delay input from the mouse for a second until after the game starts?

Thank you.

public static boolean pressed = false;

public void mousePressed(MouseEvent e)
{
    int mx = (int) e.getX();
    int my = (int) e.getY();

    if(Game.state == STATE.MENU) {
        if(Menu.playButton.contains(mx, my))
        {
            // Pressed Play Button
            pressed = true;
            Game.setState(Game.STATE.GAME);
        }

        for (int i = 0; i < handler.object.size(); i++)
        {
            GameObject tempObject = handler.object.get(i);

            if(tempObject.getId() == ID.Player && pressed == true)
            {
                handler.addObject(new Bullet(tempObject.getX()+16,
                        tempObject.getY()+24, ID.Bullet, handler, mx, my, game));
                bullets_shot += 1;

            }
        }
    }
}


texts: Saving mesh and instance data on the GPU?

texts:
I am trying to optimize drawing a large number of voxels by using GPU instancing in Unity.
I am currently using Graphics.DrawMeshInstanced in a script Update(), but it occurred to me that I am still sending data from the CPU to the GPU every frame, even though my voxel positions are
static.

If I can provide a guarantee that there will be no changes at all to the voxels,
is there any way to keep the mesh data and instance positions in memory on the GPU,
and avoid a CPU -> GPU bottleneck? (I found this, not sure if it is relevant https://docs.unity3d.com/ScriptReference/Mesh.UploadMeshData.html)

If so, how would I instance such meshes to draw multiple copies of them? If not possible, is there any way I can better optimize drawing large numbers of identicaly meshes whose position does not change?


texts: Why does this transparent shader cause objects' z-sorting to be backwards?

texts:
I am making a Klondike Solitaire game, with the intent of later expanding it to encompass other solitaire games and allow deck customization. As part of this, the playing card meshes I am creating programatically are mostly opaque, but require non-alphatest transparency in order to draw the pips (rank/suit icons) correctly.

The problem is this:

The z-sorting of the cards is the exact opposite of what it's supposed to be. I know that transparency is the problem because the z-sorting works properly when it's disabled (the #pragma alpha:fade in the shader is removed):

...which obviously breaks how the cards' material is being rendered.

This is the shader I have:

Shader "Custom/Card" {
    Properties {
        _CardAtlasTex ("Card Atlas", 2D) = "white" {} // card atlas texture
        _ColorUVZone ("Colour UV Zone", Vector) = (0,0,0,0) // texture zone inside which the pips are, and so the suit colour should be used
    }
    SubShader {
        Tags { "RenderType"="Opaque" "Queue"="Geometry" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Lambert vertex:vert alpha:fade

        sampler2D _CardAtlasTex;
        float4 _ColorUVZone;

        struct Input {
            float2 uv_CardAtlasTex;
            float3 vertexColor;
        };

        void vert (inout appdata_full v, out Input o) { // http://answers.unity3d.com/questions/923726/unity-5-standard-shader-support-for-vertex-colors.html
            UNITY_INITIALIZE_OUTPUT(Input,o);
            o.vertexColor = v.color;
        }

        void surf (Input IN, inout SurfaceOutput o) {
            half4 card = tex2D (_CardAtlasTex, IN.uv_CardAtlasTex);
            o.Albedo = card;
            o.Alpha = 1; // make it opaque to start with

            // if this is a pip, colourize it
            if (IN.uv_CardAtlasTex.x >= _ColorUVZone.x && IN.uv_CardAtlasTex.y >= _ColorUVZone.y && IN.uv_CardAtlasTex.x <= _ColorUVZone.z && IN.uv_CardAtlasTex.y <= _ColorUVZone.w) {
                o.Albedo *= IN.vertexColor; // colourized
                o.Alpha = card.a; // transparented
            }
        }
        ENDCG
    }
    FallBack "Diffuse"
}

Things I have tried:

Changing the subshader's RenderType to things like Transparent or TransparentCutout, or removing it entirely. No effect.
Changing the subshader's Queue to things like Transparent or AlphaTest, or removing it entirely. No effect.
Adding a ZWrite On (just before the LOD 200). Does nothing because the generated code forces ZWrite Off due to having #pragma alpha:fade (as far as I can tell), and putting the line after the pragma in hopes of re-overwriting it is a syntax error.

From #3, I'm guessing that if I can somehow force ZWrite On despite the alpha:fade, it should work as expected. But chances are there's something else I'm missing that could work.

Other notes:

The problem is very consistent: the back-most cards are always drawn front-most, no matter what the shuffle is or whether the lower cards are ahead or behind.
There is no alternative to using full transparency; pips can be any colour against any background. (The face card designs don't use transparency.)
All cards use the same material, which uses a single texture atlas.


texts: Find Initial Velocity for Parabolic Arc with Fixed Angle that Crosses Target Position

texts:
In my game I want skeletons to occasionally lob bones at the player. The player can be anywhere in relation to the skeleton (above or below, to the left or right), and I want the skeletons to throw a bone such that it lands on the player (or its parabolic arc intercepts them while rising, if the player is above the skeleton).

Given an arbitrary starting position, an arbitrary target point, and an arbitrary launch angle, how can I calculate the initial velocity of a ballistic projectile (assuming no air resistance) such that its parabolic trajectory intercepts the target point?

I know there are a number of similar questions on this site, but none of them appear to have this particular set of requirements:

Calculating initial velocities given trajectory parabola requires a known/fixed apex height.

Calculating velocity needed to hit target in parabolic arc and Throw object towards predefined place? assume a known/fixed travel time.

I want to have a fixed launch angle, initial position, and final position, and from those determine the initial velocity.

The Wikipedia article Trajectory of a projectile comes close, but I have no idea how to solve that for velocity.

Reference

In computer coordinates, the Y axis is inverted from Cartesian coordinates. The accepted formula operates independently of this, but it's unintuitive to deal with. This means that gravity will be a positive number, while being above the projectile will result in a negative displacement.

This also means that the fixed angle you choose will be the negative of what the habitual version would suggest.

As a final note, I adjusted for the absolute value of Vx by performing this manipulation before calculating Vy:

if sign(x_velocity) != sign(delta_vector.x):
    x_velocity = -1 * x_velocity
var y_velocity = x_velocity * tan(angle)

Full pseudocode reference:

static func get_velocity_of_arc_intercept(initial_position, target_position, angle):
    var delta_vector = target_position - initial_position
    var x_velocity = sqrt((gravity * delta_vector.x * delta_vector.x) / (2 * (delta_vector.y - (tan(angle) * delta_vector.x))))
    # Adjust for lost sign.
    if sign(x_velocity) != sign(delta_vector.x):
        x_velocity = -1 * x_velocity
    var y_velocity = x_velocity * tan(angle)
    return Vector2(x_velocity, y_velocity)


texts: Configurable Dice Cup Sound Effect for HTML5 Game

texts: I am developing an HTML5/javascript based game, where the players will have to roll virtual dice. I am working on a 3d model of a dice Cup and plan on having the users shake it and turn it upside down in order to roll the dice. I would like some realistic sound effects to go along with this interaction, but do not know how to achieve this. The problem is that the number of dice, the duration, intensity and speed of the dice cup shake will vary. Consequently, I don't think I will be able to create a convincing sound experience by using a prerecorded sound effect. How does one deal with making such sound effects configurable?Would I need to programmatically generate the sound using the web audio API? If so I would be grateful for any pointers as to how to do it.


texts: How to find the largest bounding boxes in 3D array to cover all cells?

texts:
I'm trying to generate colliders automatically from a 3D array where each cell represents a constant-sized piece in a world (like a voxel). I'm trying to optimize the number of colliders, so I want to traverse the 3D array and create as few colliders as possible to cover all cells.

I know that for a single axis (1D array), I could do something like this:

// Let's say 0 = empty and 1 = wall
int[] array = {0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1};
boolean creating = false; // Was start index found?
int startIndex = 0; // Where the box started?
int endIndex = 0; // Where the box ended?

for (int i = 0; i < array.length; ++i) {
    if (!creating) {
        if (array[i] == 1) {
            creating = true;
            startIndex = i;
            endIndex = i;
        }
    }else{
        if (array[i] == 1) {
            // The line of blocks continues, increment the end index
            endIndex = i;
        }else{
            // Empty cell found, create a collider
            createBox(startIndex, endIndex);
            creating = false;
        }
    }
}

// Result would be four colliders sized 2, 1, 3 and 1

However, I can't figure out how to expand this to two and three dimensions. For instance, take this 2D array:

{{ 1, 1, 1, 0, 0, 0, 0 },
 { 1, 1, 1, 0, 1, 0, 0 },
 { 1, 1, 1, 0, 1, 0, 0 },
 { 0, 0, 0, 0, 1, 0, 0 },
 { 1, 1, 1, 1, 0, 0, 0 }}

This should result in three colliders: the first from (0, 0) to (2, 2), the second from (3, 1) to (3, 5) and the third from (0, 4) to (3, 4). However, simply looping the two dimensions wouldn't work.

Any ideas how to tackle this?


texts: XNA 4.0 Refresh AudioEngine, WaveBank and Others Not Found

texts:
I'm going through the Learning XNA 4.0 book, and unfortunately I installed XNA 4.0 refresh. All the code up until now has worked, with the exception of me needing to remove the Framework.Net and Framework.Storage. (As a side question, will this be problematic later?)

The problem I'm having now is that in my Game1.cs file, I have imported all of the XNA.Framework libraries, and when I try and create instances of any of the following classes, an error pops up saying VisualStudio can't find them: AudiEngine, WaveBank, SoundBank, and Cue.

I have googled around for a while, and the only solution I saw was to import Microsoft.Xna.Framework.Xact, but this doesn't seem to exist for me.

Any help is much appreciated,
Thanks
Peter.


texts: Approximately circular range of motion on a square tile grid

texts:
I've been working on a grid based tactics style game to learn the ropes of Unity. I have an issue with movement range for a player unit. Let's say the units move range is 3 spaces..
If I set up each grid tile with 4 neighbours (up down left right), I get this movement range:

If I give each tile diagonal neighbours too- 8 in total, I get this;

What I'm actually looking for is what you'd see in these type of games traditionally, like this;

Here is the code that finds the unit move range list, starting at tile (5, 5). It adds the initial tile/node and its neighbours to the movelist, then works outward looping through all their neighbours. It's based off a youtube tutorial.
public HashSet<Node> getUnitMovementOptions() {

    float[,] cost = new float[mapSizeX, mapSizeY];
    HashSet<Node> moveList = new HashSet<Node>();
    HashSet<Node> tempMoveList = new HashSet<Node>();
    HashSet<Node> finalMoveList = new HashSet<Node>();

    int moveSpeed = 3;
    Node unitStartNode = graph[5, 5];
    finalMoveList.Add(unitStartNode);

    /// Initial costs for the neighbouring nodes
    foreach (Node n in unitStartNode.neighbours) {
        cost[n.x, n.y] = costToEnterTile(n.x, n.y, unitStartNode.x, unitStartNode.y);
        if (moveSpeed - cost[n.x, n.y] >= 0) {
            moveList.Add(n);
            }
        }

    finalMoveList.UnionWith(moveList);

    while (moveList.Count != 0) {
        foreach (Node n in moveList) {
            foreach (Node neighbour in n.neighbours) {
                if (!finalMoveList.Contains(neighbour)) {
                    cost[neighbour.x, neighbour.y] = costToEnterTile(neighbour.x, neighbour.y, n.x, n.y) + cost[n.x, n.y];

                    if (moveSpeed - cost[neighbour.x, neighbour.y] >= 0) { tempMoveList.Add(neighbour); }
                    }
                }
            }

        moveList = tempMoveList;
        finalMoveList.UnionWith(moveList);
        tempMoveList = new HashSet<Node>();
        }

    Debug.Log("Total move spaces for this unit is: " + finalMoveList.Count);
    return finalMoveList;
    }

Here is the costToEnterTile function:
public float costToEnterTile(int targetX, int targetY, int sourceX, int sourceY) {

    Tile t = tileTypes[tiles[targetX, targetY]]; // get current tile type
    float cost = t.movementCost;

    // diagonal
    if (sourceX != targetX && sourceY != targetY) {
        cost += 0.3f;
    }

    return cost;
}

If I tamper with the cost value in here, I can get different results in the movement range overall shape, but it's a bit hit and miss depending on the movement range.
Can anyone offer insights in to what path I need to head down to solve this?


texts: How do I ensure a piece of code runs only once?

texts:
I have some code that I only want to run once, even though the circumstances that trigger that code could happen multiple times.

For example, when the user clicks the mouse, I want to click the thing:

void Update() {
    if(mousebuttonpressed) {
        ClickTheThing(); // I only want this to happen on the first click,
                         // then never again.
    }
}

However, with this code, every time I click the mouse, the thing gets clicked. How can I make it happen only once?


texts: Collision handling for grid based games and simulations

texts:
I'm trying to implement a grid based game where there are many creatures moving in the grid from square to square. I'm having a hard time handling collision with creatures in the grid (multiple creatures trying to move into the same square or cell). Where can I find information on how I should handle a game (or simulation) where multiple creatures in a grid want to move into the same cell but aren't allowed to? It's easy to handle 2 creatures, but handling n object collision is tough.

I'm looking for info on how to handle collision in a grid world. I don't expect a specific answer as much as resources or suggestions to find more info.

EDIT: To clarify, I'm looking for info on HOW TO HANDLE COLLISIONS BETWEEN MULTIPLE OBJECTS IN A GRID. In a grid world where multiple objects want to move into the same cell at the same time, how do I resolve this? Does one object get to move into the cell and the other objects remain stationary? Do I make each object push the other object out of its cell? These are the questions I want to answer.

An example of the problem I'm looking to answer:
Consider a grid where there's 3 creatures who move from tile to tile. What do I do when two creatures, A and B, try moving into the same tile? Let's consider if I allow creature A to move into the tile but creature B remains stationary. What happens if a different creature C wanted to move into the tile that creature B was stuck in? Then creature C also wouldn't be able to move.

This would cause an issue if I would evaluate creature C's movement first, telling it that he can move into the tile that creature B is in (because creature B plans to move out) but then creature B ends up never moving out.

How do I determine which creatures to evaluate first? Also, how do I avoid this huge chain of creatures being forced to remain stationary (in this example, only 1/3 creatures were able to move).


texts: implementing magnet like system in unity

texts:
I'm implementing magnet like behavior in unity3d.
the red object have a script that add force to it toward a blue object.
to do that i use this code:

void FixedUpdate()
{
    float distance = Vector2.Distance(blue.transform.position, transform.position);
    speed = MAX_DISTANCE - distance;
    body2d.AddForce((blue.transform.position - transform.position).normalized * speed);
}

MAX_DISTANCE is maximum distance that red and blue object can have.

with this code i got this behavior :

but i don't want red object gets this far after reaching blue object i want red object to decrease it's speed and after maybe some shaking around blue object and eventually stop on blue object, how can i implement this?

UPDATE
red and blue objects can't collide with each other they just know their location.


texts:
What would be the best way to load enemies in a level. For example take Mario, are enemies rendered at their x,y positions as the game is loaded or when the player walks past a specific x value. Wouldn't this mean that you would have multiple if conditions checking whether the player has reached a specific x value to spawn an enemy; this doesn't seem like a very good solution to this problem at least to me.

What would be the recommended way?


texts: How to make a boss control multiple object spawners in Game Maker Studio 2

texts:
I'm working on a boss fight for a 2D platformer/shooter game in the vein of the Megaman franchise. I expect part of the fight to include this boss causing large boulders to fall from certain points on the ceiling to possibly crush the player, which serve both as an attempt to harm the player and a possible means by which the player may harm the boss. I am having some difficulty, however, with conceptualizing how to tie these randomly-falling rocks to an action on the boss's part. I can make spawner objects to drop the boulders when prompted, my issue mainly lies in how to give the boss object the ability to trigger this action, especially given there will be several such spawners in the level, which may be selected at random.

Are there any functions or techniques that may be useful in allowing a single "boss" object to trigger one or more of a set of other "spawner" objects as a part of an action the "boss" takes, rather than simply automating the spawners to work on their own timing?


texts: Render isometric TMXTilemap with antialiasing method

texts: I'm currently working on a cocos2d-x project that uses isometric tile maps.all the tiles are as small as 64*64 px.So I have to scale the map up a little bit.TMXTilemap is handy but its render method scales each tile first and then draw them together,which will cause black gaps between tiles if you are using "anti-aliasing" for the map's texure.So I was thinking to render the whole map on a texture first,so that scaling it up with anti-aliasing method will look nice.I wonder how exactly I can do this.


texts:
how to make a score displaying system without using bitmap in libgdx.
I making a fluppy bird remake
somone can explaim me in details?


texts:
To a pixel shader of a 2D game, I'm passing a 1-row heightmap that holds the height in UV coordinates of evenly distributed points throughout the texture I'm drawing, but as for n points there will obviously be n-1 lines connecting consecutive ones, I can't make these lines as wide as they should be.
For example, filling the pixels below the lines of a heightmap that holds 3 values ({0f, 1f, .5f}) should result in something like:

but instead, it looks like this:

It is visible that the correct result lies on the first 2/3 of the second one, and the last 1/3 comes from clamping the heightmap.

Here is a simpler version of the pixel shader code.

float4 PixelShaderFunction(float4 texCoords:TEXCOORD0):COLOR0
{
    float verticesCount = 3;
    float verticesFrequency = 1/verticesCount;

    float lastHeight = tex2D(heightMapSampler, float2(texCoords.x, 0));
    float nextHeight = tex2D(heightMapSampler, float2(texCoords.x + verticesFrequency, 0));

    float delta = (texCoords.x % verticesFrequency)/verticesFrequency;
    float height = lerp(lastHeight, nextHeight, delta);
    if(texCoords.y > height)
        return float4(1, 0, 0, 1);
    return float4(0, 0, 0, 1);
}

I tried multiplying the texture coordinates by (verticesCount-1)/verticesCount but that didn't seem to do the job. Thank you!


texts: How to keep a rigidbody on the ground going up/down a slope? (Unity 2D)

texts: I'm not sure if this is possible, but Im working a 2D project to has randomly generated loops (imagine a sin or cos graph). I have a 2D character (a quad for now). I want my character want to ski a long the slopes. The bottom surface always needs to be in contact with the terrain, unless it's a sudden slope change. Im trying to use to rigidbody for this, but when going down slopes the character just bounces and rolls down the hill. What can I fix this?


texts: Animator Component gets removed automatically - Unity

texts:
I am creating a simple scaling animation on image (in Unity). When I play game in unity editor, the animator component get removed automatically. Here I am copying snapshop of Inspector of Image.

What should I correct?


texts: how do I create a moving type of block like in Mario[box2d]

texts:
I want to create a block which only moves up and only when hit from below. I am trying out a distance joint and I read it can be used as a spring, is this the correct solution?

the way I have tried it is to create a block, and right underneath it I created a body and created a distance joint between these 2, however I do not see any type of spring physics, the block just falls down and acts like a rope joint.

DistanceJointDef j = new DistanceJointDef();
        j.type = JointType.DistanceJoint;
        j.frequencyHz = 4f;
        j.dampingRatio = .5f;
        j.bodyA = body;
        j.bodyB = body2;

my joint def.

edit: right now I am just using a pristmastic joint and so far it seems okay.


texts: I'm new to Cocos2d-x and looking for a good way/tutorial on how to play animations in Cocos2d-x.


texts:
is there a tutorial and patterns to write unit tests in Unity ?

Should we use the classical c# way and test the code or should we test the interactions in UI ? If so how?


texts: Run a method once per iteration without adding a component to a game object in Unity

texts: I want to run a function once per main loop iterator but I don't want to add this as a script to a game object in my scene. This is something that should always run no matter what scene and making people include it into every scene on a game object would cause issues because I'll/people will forget. Is there any hooks into the main loop where I can tell unity to run this function once per loop for the entire game not just per scene?


texts: I would like some know how can someone make an animation like this, in Monogame specifically.Since i am completely clueless on how to go around this i how should i go about this ? I hate asking questions this general, but since i don't know how to do that, adding any more to the question wouldn't really help. Even the general concept behind this is highly appreciated.


texts: LibGDX, How to create a 2d collision terrain

texts:
How can I create a surface so my bike collides with the ground?
I'm thinking of placing x,y coordinates, but that will be too straight and I want it more smooth. (I don't want to place 1 million dots)


texts: Diverse loading-screen tips and who does that?

texts:
Smaller games and projects have been seen to add jokes and tips that are not directly game related and in any form advice to their loading screens. For some reason I can't think of a tripple A title? Anyone else?

Some people around the industry think its bad taste... I've seen arguments where companies have senseless aggression as core gameplay but get iffy about throwing harmless jokes into splash screens. It was really weird.

Can you name a big game that does it?


texts: Should I go to a University or Trade school to be a Game artist?

texts: Im a senior this year and I'm seriously looking at colleges that can help me get into the game in the Game industry. I've been told countless times it's better if I go to a University(Usc, Becker college, etc) than go to somewhere like Digipen or Full Sail. I'm just really confused about how I should tackle this path. I'd appreciate some help and advice please?


texts: How to detect when two bitmaps intersect in Android

texts:
I made two bitmaps based off of two ImageViews using this code:

playerimage.buildDrawingCache();
Bitmap bplay1 = playerimage.getDrawingCache();
brickimg.buildDrawingCache();
Bitmap bbrick1 = brickimg.getDrawingCache();

I tried getting the height and width of each bitmap for collision detection, but it made the app crash. This is what I used for it:

int w1 = bplay1.getWidth();
int h1 = bplay1.getHeight();
int w2 = bbrick1.getWidth();
int h2 = bbrick1.getHeight();

Is there a different way to get the coordinates of a bitmap to test collision detection?


texts:
I am rewriting a game I made to use a (custom) collision manager that uses the minimum displacement method. As of now, my simple manager can only recognize and act on a couple of shapes - Circles and AABB's. Those were pretty simple to implement, but I've run into a problem: My game also needs to be able to have bitmaps that the player (represented by an AABB) can interact with, such as the one below:

I have a couple of questions:

1) Does it make sense to have a shape BitmapShape, which does collision detection at the pixel level and searches outward in the bitmap for a place to move intersecting objects to? In the image above, it would make sense to check the players bottom-center coordinates against the bitmap of the hill, but you can imagine that this would provide odd results for an intersection from the top of the player.

2) How could any system like this allow for a rectangle to move up a hill? Wouldn't an minimum-displacement based method always move the rectangle backwards down a hill?

Thanks


texts:
So I made an empty game object in inspector, called it "squareTest", and I clicked and dragged 3 sprites in. One is the square being black, one is the square being red, and one is the square being green. What I want to do is this:

In the code, it starts by default as the black sprite. Whenever 'x' happens, the sprite changes to the red square. And whenever 'y' happens, it changes to the green square. BTW, x and y could mean anything. I just want some logic to it, as in

if (password == "Open sesame") {
    //Change square color
}

My game programming experience is from Pygame, and this problem could have been solved like this (using a sprite sheet that goes from left to right)

if Condition:
    square_spritesheet.current_frame = 5

screen.blit(square_spritesheet.texture, (x, y),
(self.current_frame*self.frame_width, 0, self.frame_width, self.frame_height))
#screen.blit goes (image, (x, y),
#(start chopping_X, start chopping_Y, end chopping_X, end chopping_Y)

Unfortunately, I do not have a clue how this could be accomplished in Unity.
I do not know if this is possible with an animator controller. I just want to know if this is possible, and how it could be achieved, with or without an animator. Thank you very much!

The different colored squares are different textures, and I do not need transitions between states.


texts: StartCoroutine function inside TriggerOnEnter2D not working - unity + kinect

texts:
So i'm using Kinect with unity to track user's hand movements, and let the user's hand act as a mouse, I have written the code to detect a collision between a button (sprite object) and the hand cursor using OnTriggerEnter2D, but I want the hand cursor to remain on the button (sprite object) for atleast 3 seconds for it to be considered as a button click action. The WaitForSeconds coroutine doesn't seem to be working. What am i doing wrong?

public class MenuSelect : MonoBehaviour{

private string btnName;
private string themeName;

// Use this for initialization
void Start ()
{
    //gestureListener = Camera.main.GetComponent<GestureListener>();
}

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

}

void OnTriggerEnter2D(Collider2D col)
{
    //print("Collision Detected");
    StartCoroutine(WaitTime(3));
    if(col.gameObject.tag == "Button")
    {
        btnName = col.gameObject.name;
        switch(btnName)
        {
            case "musicBtn":
                Application.LoadLevel("Menu_Music");
                break;

            case "startBtn":
                Application.LoadLevel("Menu_Select");
                break;

            case "instructBtn":
                print("Instruction Clicked");
                break;

            case "exitBtn":
                Application.Quit();
                break;

            case "themeBtn":
                Application.LoadLevel("Menu_Theme");
                break;

            case "backBtn":
                Application.LoadLevel("Menu_LoadScreen");
                break;
        }
    }

}

IEnumerator WaitTime(float waitTime)
{
    yield return new WaitForSeconds(waitTime);
    print("seconds up already");
}   }


texts: Realtime inverse kinematics on unity apps for android and iOS

texts:
Hello I want to understand how much overheads do implementing inverse kinematics in realtime add.

I am looking at an implementation as such demonstrated in the video. https://www.youtube.com/watch?v=Gyakxv34404&feature=youtu.be

Let me explain the exact requirement now.

Assuming a game of mario, where mario is a 3D Character. And there is a coin placed at a height. So when mario comes into area of effect for the coin, we know the initial position of his arms, and we know the expected final position which is the position of the coin.

So we create a trajectory from initial to final position in realtime and the main character moves accordingly in the trajectory.

Now I can understand this would work fine in editor but if we have exported the game and this computations happen realtime for every object, how much CPU intensive would this be? Do all the existing IK assets provided on store

for example in this video of final IK https://www.youtube.com/watch?v=ZuWvGq3yV44 the characters are following the trajectory in real time I suppose. But what if we were to create the trajectory realtime depending on player positions, would that be a CPU intensive task to NOT work on mobile devices?


texts: How do some mobile games scale graphics so beautifully?

texts:
I'm working on my first Android game and have been struggling a bit with scaling.

I've got 3 test devices 800x480, 1920x1080 and a 2560x1600 tablet. Some games look near perfect on all of them - many other games don't, including mine.

I'm really struggling with images looking blocky when scaling. I'm using the libdgx library, and have turned on linear filtering for everything. Almost always scaling down. Fonts are something I'm really struggling with.

I've been dissecting the apk's of various games for tips but can't see anything in particular that they're doing. In one game I examined (Candy Crush Saga) there's only 1 set of images, they only use 1 font. They also have a ttf in there, but I can't work out where that's used. The main font in a pre-created bitmap font.

Does anyone else have any tips or tricks. Ho do others manage it, especially the font scaling?


texts: Im working on a game right now, but I was wondering how I would store the game data in cookies(in javascript) where you can load it up, and resume the last spot you were at. I was looking at some other websites like w3schools, but I didn't really understand it