texts:
I'm working on a game which I'm writing in Javascript and then porting to iOS/Android via phonegap/cordova.

For the most part, I understand how to code and how to get what I want to happen, BUT I have a major struggling point in using proper techniques and avoiding redundancy and over-complexity.

For example, one of my first forays into game dev, I had tried to answer a question on how to simplify a set of actions or functions that are related (you can check out my bad answer here How can I design lots of different attack types that can be combined? )

Now, I'm sort of at a similar pass at my game, I have different 'enemy types' that are supposed to trigger a different action when they touch the player. I have a if/else structure right now to change between these different circumstances.

Sean Middleditch did a good job of answering why 'data-driven' design works better than 'procedural' design, but for the life of me I can't figure out HOW to employ this. It seems to me that no matter how I want to structure my objects in my game, and which properties I give them, at some point I will need an if/else or switch statement, can anyone help me work past this?

if(enemyType == 'black'){  // enemyType is a color
            done(index);   // done is a function that removes the enemy after it touches the player
            updateScore(score); // black is score point so it updates score
}else if(enemyType == 'red'){  // red is a death so gameOver
    done(index);
    if(!gameVars.invincible && gameVars.lives == 1){ // but the player might be invincible or have extra lives
        gameOver();
    }else if (!gameVars.invincible){ // in that case we manage the lives or ignore the hit completely
        manageLives(-1);
    }
}else if(enemyType == 'blue'){ // the rest are power ups of types
    done(index);
    setInvincible();
}else if(enemyType == 'grey'){
    done(index);
    setSlowTime();
}else if (enemyType == 'green') {
    done(index);
    gameVars.teir_reducer += 2;
}else if (enemyType == 'yellow') {
    done(index);
    gameVars.speed_reducer += 10;
}else if (enemyType == 'orange') {
    done(index);
    updateScore(1000);
}else if (enemyType == 'purple') {
    done(index);
    manageLives(1);
}else if (enemyType == 'violet') {
    done(index);
    setMagenetic();
}else if (enemyType == 'gainsboro') {
    done(index);
    setWarp();
}


texts: Why do I have render problems happening frequently in my Unity scene?

texts:
I am making vertical endless runner. My platforms are moving down, and the camera and players are remaining in the same location, resulting in the effect of player movement. The obstacles are generated and move in same direction as platforms.

The problem is obstacles rendered by the camera is not right. I mean that the obstacles are in camera's FOV but are still visible after some time when they reach the player to close.


texts: How to make Unity sprite animation not lerp?

texts:
I set sprite animation at key1 and key2.

at Key1 :

Position.x = 0

at Key2 :

Position.x = 1

I want it not lerping. i mean i want it appear at posX 0 and posX 1. not between 0~1.

what should i do?


texts: What decrease of polycount should occur as a function of distance?

texts: What decrease in polycount should occur as a function of distance. I make a terrain and I wounder what is the right formula to keep the "poly size"(the screen size) constant. Or is there some mental flaw in this approach?


texts:
Is there a way that even though two objects that have different y co-ordinate collide?

In my game, I wanted to make my object rotate as explained in previousquestion. When I added the code, the object now dissapears from the scene even though it's x and y co-ordinate are in the scene. I traced(in the function that kills the characer if it touches it. i.e hitt) the x and y value of the object and found that it is still there on the scene.
The code is:

ground.addEventListener(Event.ENTER_FRAME, hitt);

function hitt(event: Event) {
    if (green.hitTestObject(ground) || blue.hitTestObject(ground) || brown.hitTestObject(ground) || black.hitTestObject(ground)) {
        dead = true;
    }
    else if (kill.hitTestObject(black) || kill.hitTestObject(green) || kill.hitTestObject(blue) || kill.hitTestObject(brown)) {
        dead = true;
        trace("here",kill.y,green.y,green.x);
    }
}

The output is:

[SWF] hello.swf - 519178 bytes after decompression
here -608.95 -401 62.55

I don't know what's going on? Please Help..!!


texts: Rendering objects with either normal maps, either specular maps, or with both, or with neither?

texts:
My hobby engine has a deferred renderer that supports normal maps and specular maps. Now, some objects may have normal maps, and some may have specular maps. In some cases, an object has both maps, and in some cases, it has neither.

The question is: how should I implement the rendering of these objects? Should I have a render queue for each different object type and render them with separate shaders like this:

Queue A: Objects without normal and specular map
Queue B: Objects with normal map, without specular map
Queue C: Objects without normal map, with specular map
Queue D: Objects with both normal map and specular map

// Render loop
bind shader for type 'A' objects
for each object in Queue A:
    render object

bind shader for type 'B' objects
for each object in Queue B:
    render object

// and so forth...

Or, should I use a single shader and bind a "default" normal map and specular map for those objects that do not have such maps? By a default map, I mean for example a normal map texture that's completely colored (128, 128, 255). This would be something like this:

bind shader
bind default normal map texture
bind default specular map texture

for each object in Queue A:
    render object

for each object in Queue B:
    bind object's normal map
    render object

bind default normal map texture
for each object in Queue C:
    bind object's specular map
    render object

for each object in Queue D:
    bind object's normal map
    bind object's specular map
    render object

Basically, the first approach would involve less texture binds and more shader binds, whereas the second approach would be the opposite. Is either of these a preferred way to approach the problem? Or have I missed something completely here?

You can assume the objects are queued correctly to the queues.


texts: Can you embed a Unity3d mobile project into an existing native mobile app?

texts: I am creating an application for both Android and iPhone that will have a few mini games in it. I would like to create the non game section in native Android and iPhone. My question is, is it possible to have a native app that will incorporate the Unity mini game I am creating all inside one apk and ios project?


texts: Regulating how much to draw based on how much was drawn last frame

texts:
[Edit: I found an answer - see below]

I have a 3D game world on an iPhone (limited graphics speed), and I'm already regulating whether I draw each shape on the screen based on it's size and distance from the camera. Something like...

if (how_big_it_looks_from_the_camera > constant) then draw

What I want to do now is also take into account how many shapes are being drawn, so that in busier areas of the game world I can draw less than I otherwise would.

I tried to do this by dividing how_big_it_looks by the number of shapes that were drawn last frame (well, the square root of this but I'm simplifying - the problem is the same).

if (how_big_it_looks / shapes_drawn > constant2) then draw

But the check happens at the level of objects which represent many drawn shapes, and if an object containing many shapes is switched on, it increases shapes_drawn lots and switches itself back off the next frame. It flickers on and off.

I tried keeping a kind of weighted average of previous values, by each frame doing something like shapes_drawn_recently = 0.9 * shapes_drawn_recently + 0.1 * shapes_just_drawn, but of course it only slows the flickering down because of the nature of the feedback loop.

Is there a good way of solving this?

My project is in Objective-C, but a general algorithm or pseudo-code is good too.

Thanks.

Edit: Please, I'm not asking for general advice on rendering performance. I need an answer to the specific question of how to take the shapes drawn in previous frames into account without getting flickering.


texts: Blender to Unreal Material workflow....?

texts:
I'm new to game development and the Unreal Engine and I have a general question.

I model my objects in Blender and import them into Unreal Engine.  My question is, is it better to create and apply your materials and textures within Blender and then import them?  Or is it better to save that work for Unreal?

Also does it matter which rendering engine I use in Blender?  I use Cycles by default.


texts: Handling metallic roughness maps colour channels

texts:
I'm trying to use a metalness/roughness workflow and I'm not sure how to translate the colour channels into the different metalness and roughness attributes. I'm not sure if there's a standard on how to encode that information and I can't find any online resources on how to treat the colour channels so I'm guessing that there is no standard.

I have had materials which have used only the R and B channels and having the B channel set as 0 and I have had materials that somehow use all the RGB channels and I'm confused as to why they would need a third channel to determine metallness and roughness.

My question is, how should I determine the format that the map is in and which channel corresponds to which attribute?

Update:
I've already come to terms that I'll probably have to compile new shaders for different materials but I'm trying to figure out a way of identifying the format that a map is in. It would appear that for one of the models I'm using, it stores its bump map in the R channel. I didn't even know that was an option

Update 2:
I imagine I'll have to just delegate this to the asset pipeline and have the user select which channels to sample from. That or have a hardcoded format and make sure that any PBR materials imported follow that format


texts: Finding direction of travel in a world with wrapped edges

texts:
I need to find the shortest distance direction from one point in my 2D world to another point where the edges are wrapped (like asteroids etc). I know how to find the shortest distance but am struggling  to find which direction it's in.

The shortest distance is given by:

int rows = MapY;
int cols = MapX;

int d1 = abs(S.Y - T.Y);
int d2 = abs(S.X - T.X);
int dr = min(d1, rows-d1);
int dc = min(d2, cols-d2);

double dist = sqrt((double)(dr*dr + dc*dc));

Example of the world

                   :
                   :  T
                   :
    :--------------:---------
    :              :
    :           S  :
    :              :
    :              :
    :  T           :
    :              :
    :--------------:

In the diagram the edges are shown with : and -. I've shown a wrapped repeat of the world at the top right too. I want to find the direction in degrees from S to T. So the shortest distance is to the top right repeat of T. but how do I calculate the direction in degreed from S to the repeated T in the top right?

I know the positions of both S and T but I suppose I need to find the position of the repeated T however there more than 1.

The worlds coordinates system starts at 0,0 at the top left and 0 degrees for the direction could start at West.

It seems like this shouldn’t be too hard but I haven’t been able to work out a solution. I hope somone can help? Any websites would be appreciated.


texts: How can I read a value from a file accessed via the Internet?

texts:
I have made text file and I put it on Dropbox, I have in this text file a value. From my code, I want to check if this value is 1.

I have tried this code, inspired by the Unity example, but it looks like I'm not able to reach the file.

void Start()
{
    StartCoroutine(GetText());
}

IEnumerator GetText()
{

    UnityWebRequest www = UnityWebRequest.Get("https://www.dropbox.com/s/6jkhtnpskzsi5pj/TestTXT.txt?dl=0");
    yield return www.SendWebRequest();

    if (www.isNetworkError || www.isHttpError)
    {
        Debug.Log(www.error);
    }
    else
    {
        // Show results as text
        Debug.Log(www.downloadHandler.text);
        // Or retrieve results as binary data
        byte[] results = www.downloadHandler.data;
    }
}


texts: How to Construct a Perspective Projection With 4 Vanishing Points

texts:
Is it possible to construct a projection matrix which will create a perspective with four (or more) vanishing points?

This question have an OpenGL tag, but general insights are welcomed as well.


texts: What is the best way to close dialogs in a platform game controlled by keyboard only

texts:
I'm developing a flash puzzle platform game in my free time and I got stuck on deciding how to implement a feature. The game will be controlled by keyboard only, no mouse available.

My game will have Dialog boxes, used for story telling, announcing events, tutorial hints etc. I'd really prefer not to dedicate a large portion of the screen allowing the player to play while the dialog is displayed.

So my approach is to pop up the dialog and pause the game until the player closes the dialog. That's because the game has a small resolution (640 x 320) and some of the dialogs are pretty large (up to 5 lines text, talker's thumbnail etc).

EDIT : Another major reason I want to pause the game, is that I want to be 100% sure the player will not miss a dialog. Also, I want her to read it in a certain level area, before visiting another area of the level, or doing something that will advance the plot.

The thing Is that I can't find a way to make this work right. After testing the game with a few friends, I'm not satisfied from the feedback I get.

If I force them to close the dialog with one specific key (ACTION), I see people keep hitting keys randomly (e.g FIRE or JUMP key), while they know that it's closed with ACTION, like they did that 2 minutes before. They eventually get to close the dialog, but I can see they get a bit frustrated. I don't think they adopt the control as fast as I'd expect.

If I let them close the dialog with ANY key, they find themselves closing the dialog by mistake. Some of the dialogs are popping out while they're not expecting it.

So I'm starting to think that the 'Pause for dialog - close it to Resume' might be a bad idea in the first place. Do you think it is ? Or is it OK to have the dialog pause, but I just have to find the way to do it right ? Maybe the problem is not the controls, but something else, like say, I should not pop out the dialogs unexpectedly ?

Do you have any example of some game doing that right ?


texts: Mixing Javascript with C++ for mobile development?

texts:
I have a few games for the iPhone, Android, and Windows 8 that I built using native C++. This works great but is really limiting when I try to create menus and start screens.

I have read about rapid development using jQuery Mobile and Phonegap but have never used any of these frameworks. However there looks to be an advantage using this to ceate my game menus and simple screens.

Is it possible to mix my existing C++/OpenGL game code with JavaScript used for simple  navigation, obviously this would need to compile into a native binary for iOS, Android, and BB. Is this possible?

I am all ears to any of the following to solve this; a framework, technique, or any approach that can make this happen.


texts: Implementing the "earn resource every N seconds" mechanism common to F2P games

texts:
In many free-to-play games, play will be rate limited in some manner by a resource that you naturally earn on a timed interval, but can opt to increase artificially through buy-ins.

A current example of this is the popular game Candy Crush, which refills 1 life (retry) on some set interval.

Key requirements:

The client should be able to accurately predict the time to the next resource, such that it might display a countdown, etc.
Resource gain is not regular.  It can be offset by, at least, resource buy-ins, or perhaps varying intervals between users.
Resource gain is capped, and thus not continual.  E.g. maximum "lives" might be 5.
The server is the resource authority, obviously.  The client might predict resource generation without actual notification as to such, but the resource count is determined server side.

Naively, one might simply implement this as a database update across the collection on the interval (if the interval is constant), but this would surely not scale.  It would become more and more out of sync with the client timers as the dataset scales and the operation takes more time.  Not to mention, it would be wasteful, as it's likely that only the percentage of your membership currently online needs to see realtime updates.

It seems like it would be possible to calculate the resource as a function of time since creation, time spent uncapped, resources earned, and resources spent.  Would this be a viable option?

The question is, what is the best way to implement this mechanism to scale?


texts: How do I make Ground Check stop rotating with the character when it rotate?

texts:
How do I make my character routice without Ground Check rotating with it, but still follow my character?

Code:

using UnityEngine;
using System.Collections;

public class Player: MonoBehaviour {

public float maxspeed = 10f;
bool facingRight = true;

Animator anim;

bool grounded = false;
public Transform groundCheck;
float groundRadius = 0.2f;
public LayerMask whatIsGround;
public Vector2 jumpDirection = new Vector2(1f, 1f);
public float jumpFocre = 500f;
bool doubleJump = false;

void Start ()
{
    anim = GetComponent<Animator> ();
}

void FixedUpdate () {
    grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);
    anim.SetBool ("Ground", grounded);

    if (grounded)
        doubleJump = false;

    float move = Input.GetAxis ("Horizontal");
    anim.SetFloat ("Speed", Mathf.Abs (move));

    GetComponent<Rigidbody2D>().velocity = new Vector2(move * maxspeed, GetComponent<Rigidbody2D>().velocity.y);
}
void Update()
{
    if((!doubleJump) && Input.GetKeyDown ("up"))
    {
        anim.SetBool("Ground", false);
        float move = Input.GetAxis ("Horizontal");
        jumpDirection.x = move;
        GetComponent<Rigidbody2D>().AddForce(jumpDirection.normalized * jumpFocre);

        if(!doubleJump && !grounded)
            doubleJump = true;
    }

}

void Flip()
{
    facingRight = !facingRight;
    Vector3 theScale = transform.localScale;
    theScale.x *= -1;
    transform.localScale = theScale;
}
}


texts: Translating a terrains position using input in Unity 3D C#

texts:
I am trying to make a terrain in Unity move, but im having trouble. Here's the code i have.

using UnityEngine;
using System.Collections;

public class NewScript : MonoBehaviour {

Camera camera;

Transform Terrain;
// Use this for initialization
void Start () {

}
// Update is called once per frame
void Update () {
    Terrain.Translate(new Vector3(500, 500 ,500));
}
}

now i would suspect that the terrain would just keep translating its position but it doesnt budge. How do i make a terrain move, or if you cant, how can i make the camera move and preferably with input. I am familiar with the XNA framework, is there a way to implement the input from XNA into unity?


texts: Understanding HingeConstraint in jBullet

texts:
I'm using the java port of BulletPhysics engine jBullet.
I'd like to make a joints between 2 triangles so that one edge of the first and one edge of the seconds act like a hinge.

But I don't understand how to use the HingeConstraint class because it lacks documentation. What pivotInA and pivotInB are? They are the pivot points of the hinge in respect to the object centre? And axisInA? How does it differs from axisInA?

For two triangles do I have to make 2 Hinge constrains in 2 vertex or 1 in the middle point of the 2 edges of the hinge?

Where can I find a simple working example of this?


texts: How do I clear streaming textures in SDL?

texts:
I need to clear a streaming texture before I draw into it on the next frame, because only a part is updated, and it's random enough that I can't predict which part will be clear.

I don't want to reinitialize it every time, or rewrite the whole texture each time.

Here is the code I tried, but this fails every time, since the texture is in streaming mode.

SDL_Texture* StreamingTexture = SDL_CreateTexture(render, SDL_PIXELFORMAT_RGBA8888,
        SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);

SDL_SetRenderTarget(render, StreamingTexture);
SDL_SetRenderDrawColor(render, 0, 0, 0, 0);
SDL_RenderClear(render);


texts: Irradiance cubemap to spherical harmonics conversion

texts: What are advantages of using spherical harmonics instead of irradiance cubemap? Are there any common used methods for conversion?


texts: How do you de/serialize a monobehaviour class?

texts:
It seems JsonUtility.FromJson does not work for MonoBehaviour classes (and I can't get Newtonsoft to parse strings to Vector3s)
Suppose you have a MonoBehaviour class like this (so that the values can be easily specified in inspector in editor)

public class PropertyClass:MonoBehaviour{
  public Vector3 location;

  public string name;
}

Suppose you have json data downloaded as a string called text, that you try to convert to PropertyClass[] format via using an JSONHelper around JSONUtility.FromJson(text);
How do you have it autopopulate?
If you specify a FromJsonOverwrite solution - how do you have that work with JSONHelper?
using System;
using UnityEngine;
using System.Collections;

public static class JSONHelper
{
    public static T[] FromJson<T>(string json)
    {
        Wrapper<T> wrapper = UnityEngine.JsonUtility.FromJson<Wrapper<T>>(json);
        return wrapper.Items;
    }

    public static string ToJson<T>(T[] array)
    {
        Wrapper<T> wrapper = new Wrapper<T>();
        wrapper.Items = array;
        return UnityEngine.JsonUtility.ToJson(wrapper);
    }

    [Serializable]
    private class Wrapper<T>
    {
        public T[] Items;
    }
}
```


texts: Is there any game engine capable of true binaural positional 3D audio?

texts:
I am by no means a game designer, so I apologise in advance if I fail to use the proper jargon. Feel free to correct my mistakes.

My understanding is that, at the moment, in most if not all first-person shooters (such as L4D2 or Bioshock), the "3D audio" is generated by taking the player's position and displacement within the game into account, but mainly by playing on

balance (to indicate the direction to the source of a sound),
amplitude (to indicate the distance between the player and the source of a sound).

However, for a psychology experiment, I'd like to make my subjects play a custom first-person shooter with true binaural positional 3D audio using head-related transfer functions (HRTFs). If you don't know what I'm talking about, I invite you to listen to the binaural recording at this URL.

I know of only one game using true binaural positional 3D audio: Papa Sangre, but it's not an FPS.

My questions (all related) are:

Can any currently available game engine (Valve's Source?) be used to design such an FPS game?
If the answer to 1. is yes, do you have any useful links?
If the answer to 1. is no, has a game engine capable of such marvels been announced yet?
Are there signs that true binaural positional 3D audio will find its way soon in future FPS games? (I certainly hope so!)


texts: How to decide how many textures to break an object into?

texts:
So I am making a couple spacecraft in my game.  And I want them to look sharp and as photorealistic as possible.

How can I decide if a certain craft should be broken into multiple meshes to each have its own texture based on its size?

Is there a rule?  Like if you are using 4096 size  textures. Obviously a bicycle could be a single mesh with 1 texture.

But what about a small sports car?  An SUV?  A dumptruck?


texts: How to organize data transfer between the client and the game server?

texts:
I have a game like minecraft, I can run, set and delete blocks. The world consists of a limited set of chunks. I want to write a server for it with the help of a library called boost asio. I need help with the following: how to properly transfer customers data chunks along with data from other characters. Example of a situation: a player enters a server, on which we assume there are already a couple of players. It needs to transfer information about chunks (just a three-dimensional array containing the type of the block) because he came in and did not know anything about the server world and of course the data of other players (their nickname, position, gaze direction). Do I need to integrate it all into one structure? Like this:

struct Data {
 std::string name;
 glm::vec3 position;
 glm::vec2 eye_dir;
 bool updateChunk;
 glm::vec3 chunkNumber;
 uint chunk[16*16*16];
}

That is, the client sends the numbers of the chunks that it needs to update and when the server sends it a packet, then it looks: if you send chunkUpdate = true, then it takes an array and puts the data into the client. Is this approach correct at all? And another question: communication between such packages between the client and the server is strictly a game of “throw the ball to each other in turn”?

P.S. I apologize in advance if there is not enough information or I have explained the essence incomprehensibly, I will be glad if you ask a clarifying question in this case.


texts: DirectX 11 Constant Buffers vs Effect Framework

texts:
I'm having some trouble understanding the differences between using constant buffers or using the effect framework of DirectX11 for updating shader constants.

From what I understand they both do exactly the same thing, although from reading the documentation it appears as if using effects is meant to be 'easier'. However they seem the same to me, one uses VSSetConstantBuffers and the other GetConstantBufferByName.

Is there something I'm missing here?


texts:
I have a cloud of objects, each with a 3D position, and I want to pick out tight groups of these objects.

Specifically, I want to find all objects which form a grouping of radius r within a large cloud of objects. It is likely that the objects are spaced out in vague groupings already, but I need to identify these and essentially put a sphere of radius r around them.

I would prefer to avoid a brute force method if possible - which I presume would be a process of comparing objects against each other to find two within a distance 2r of each other, then putting a sphere in the middle and determining what other objects are within this sphere.

My actual use case is not games related at all, but if an game based example use case would help, here is how I might use it in a game;

The player is flying a plane over a battlefield and has been given orders to bomb the enemy.

To assist the player I want to highlight tight groups of enemies that make prime targets, however the troops on the ground do not move or coordinate in a flocking system, they move completely as individual entities.

Given those criteria, how might I identify the largest groups of objects within the bomb's blast radius?


texts: Releasing a game without really having an officially registered company

texts:
I'm thinking of releasing my iOS game without formally registering a company at all.  I'm not sure I even want to create a company.

ITunes wants to know the copyright holder of my title. I have 2 questions regarding this:

1) Can I use my (already decided upon if will exist) company name and just register it later (if the need arises)?

2) Or should I just use my NAME as the copyright holder, regardless if I plan to formally register the company later or not?


texts:
I was trying to make a game with a bow and arrow using lwjgl but I couldent get the arch right. I have a function called projectile that is updated once a frame for each arrow. my frame cap is at 60 fps. the projectile function looks like this.

public static void projectile(Entity arrow, double speed, double gravity){

    Vector3f position = arrow.getPosition();
    float rotX = arrow.getRotX();
    float rotY = arrow.getRotY();
    float rotZ = arrow.getRotZ();

    //code

    return;
}

How can I use this function to move the arrow with it's speed and gravity along an arch. based on its rotation(for direction it moves in) and location. if you need more information please ask. thank you :)


texts: How do I pass my objects to the update method?

texts:
I've had formal education in Java for around half a year now, and as a hobby I would like to attempt game development. I've downloaded the Slick2d library to help with this.

I've run into a problem as of right now. When I create my game objects, like player, etc. I presume I have to do this in the pre-build init() method, but I probably could do it in the main() as well (What one would you suggest?). Now, my question is, when I create a Player instance in init() or main(), how do I pass it to the update() method? I could of course make the player object public/global, but I've been taught that this is very poor programming, so I'm reluctant to do this.

I would greatly appreciate an answer, since I would like to learn to do things the "correct" way, and as of right now I have no single clue what that is. Thanks for your consideration.


texts:
I have a "lighting" texture (black background with white or colours for lights) that I want to draw as a multiplcation operation. SpriteBatch.Begin can specify BlendState.Additive, but there's no BlendState.Multiplicative.

I also tried the solution in this answer, but it didn't work -- even when I (incorrectly?) changed the code to work with XNA 4 style ColorDestinationBlend, I ended up with the final solution being inverted (black area where the light is, everything else is visible).

I initially thought of a shader, but I couldn't get shaders to work with MonoGame, so I'm falling back to SpriteBatch.


texts:
I'm using Unity 2018 and its really confusing me. I generate a plane mesh in code and when it comes to positioning (transform.position.x) it on the X axis I can't understand why moving it further to the right the X value decreases (into the negatives) and the X value increases to the left??

The Y axis works as expected, up increases the value (positive), down decreases (negative).
The Z axis, away from camera = negative and towards = positive.

(Just creating a basic 3D cube game object using the Unity Create tool, the same issue applies.)

I need to figure if this is how Unity is set up now? Or I'm doing something wrong.. But I'm stuck on this!!

//create mesh code:

Mesh CreateMesh(float width, float height)
    {
        Mesh m = new Mesh();
        m.name = "ScriptedMesh";
        m.vertices = new Vector3[] {
         new Vector3(0, 0, 0.01f),
         new Vector3(width, 0, 0.01f),
         new Vector3(width, height, 0.01f),
         new Vector3(0, height, 0.01f)
     };
        m.uv = new Vector2[] {
         new Vector2 (0, 0),
         new Vector2 (0, 1),
         new Vector2(1, 1),
         new Vector2 (1, 0)
     };
        m.triangles = new int[] { 0, 1, 2, 0, 2, 3 };
        m.RecalculateNormals();

        return m;
    }

//build our first wall mesh obj

                    var wallObj = new GameObject("Wall-" + wallc.WallLengthCM + " (" + wallIndex + ")");
                    var _wallMesh = (MeshFilter)wallObj.AddComponent(typeof(MeshFilter));
                    _wallMesh.mesh = CreateMesh((float)wallc.WallLengthCM, (float)wallc.WallHeightCM);
                    MeshRenderer wallRenderer = wallObj.AddComponent(typeof(MeshRenderer)) as MeshRenderer;
                    wallRenderer.material = ShedWallMat;
var wallMesh = Instantiate(_wallMesh,
                new Vector3 { x = 0, y = ((float)wallc.WallHeightCM * 2 * wallIndex) + vertSpace, z = 0 },
                new Quaternion { w = 0, x = 0, y = 0, z = 0 });


texts: Need a good quality bitmap rotation algorithm for Android

texts:
I am creating a kaleidoscopic effect on an android tablet. I am using the code below to rotate a slice of an image, but as you can see in the image when rotating a bitmap 60 degrees it distorts it quite a lot (red rectangles) – it is smudging the image! I have set dither and anti-alias flags but it does not help much. I think it is just not a very sophisticated bitmap rotation algorithm.

canvas.save();
canvas.rotate(angle, screenW/2, screenH/2);
canvas.drawBitmap(picSlice, screenW/2, screenH/2, pOutput);
canvas.restore();

So I wonder if you can help me find a better way to rotate a bitmap. It does not have to be fast, because I intend to use a high quality rotation only when I want to save the screen to the SD card - I would redraw the screen in memory before saving.

Do you know any comprehensible or replicable algorithm for bitmap rotation that I could programme or use as a library? Or any other suggestion?

EDIT: The answers below made me think if Android OS had bilinear or bicubic interpolation option and after some search I found that it does have its own version of it called FilterBitmap. After applying it to my paint

pOutput.setFilterBitmap(true);

I get much better result


texts: Rendering perspective independent polygons in perspective view

texts:
I am creating an editor where I have "grabhandles" that can be dragged to transform a primitive object.

My problem is that I can't find the correct solution to show these grabhandles in a perspective view.

They need to have the correct position AND same size independent of where they are,how far away they are on the perspective viewport and independent of what the viewport dimensions are.

In orthographic mode I do not have this problem as I create the handle polygons by multiplying it with a zoom factor.


texts: Show procedural map without running the game?

texts: Currently I have a script that generates prefabs by code and I'm wondering if I could show a certain "seed" of that map without actually running the game. The reason why is that I often want to tweak things, and when I run the game and alter settings for objects like lights they get reset when I stop running the game and perhaps have some kind of button where I can reset the seed and see another generation of the map.


texts: how can I make camera to follow smoothly

texts: What I meant by slow parent is that I want the camera to not move immediately my third person controller moves so it won't look as though the earth is moving. The camera is the child of the player


texts: How to apply logarithmic type formula for speed?

texts: I want my character's speed to ramp up using somewhat of a logarithmic formula. I am confused about how specifically I would implement this. I want the character to move fast with a little movement as as the movement gets larger the added contribution to speed is less and less. I said logarithmic function because this kind of mimics the shape of what I am after. Does anyone have an example of how this is done?


texts:
I'm an iOS developer and I'm trying to make 2d animations with Unity 4.3 + RageTools Pro + RageSpline. I want to integrate the animations into a native iOS application.
In Unity I have different kind of animations, different characters, and I want to control these separately in Xcode.

I know how to build unity project to Xcode and I know how to customize the Unity view in Xcode, my problem is that I can't access individually the animations, I can't loop them and I can't switch them in a specific view.
My another problem is that the built Xcode project from Unity is too large (more than 300 MB).

So the question is if I continue to develop the character animation within unity is it possible to handle separately the animations in Xcode? Or do I have to find a another solution (use another animation tool, or export from unity into some different file format like FBX).
In summary I want to make a simple iOS app with simple animations and i'm looking for the simplest solution.

Thanks in advance for your help.


texts:
My physics engine is coming along quite nicely, and I'm ready to start working on some more advanced features. I'm trying to set up my collision engine so that an arbitrary delegate can be notified when a collision occurs.

Say we have object A, object B, and object C in the physics simulation. I want to be able to inform a delegate about a collision between A and B, and also inform a potentially different delegate about a collision between A and C.

I have a known interface for the delegate, I have the potential of storing a state for my collision detector, although I currently do not, and have the ability to store states in the objects, themselves. Similarly, I use this delegate model to handle collision resolution, simply setting the physics engine as the delegate for all objects by default, and allowing the user to change the delegate if desired.

I have already tried having each object store it's own collision delegate, that would be informed when a collision occurred. This didn't work, because when the objects had the same collision delegate, the same collision was handled twice. When I switched to only using the delegate of the first object (however that was decided), the order of simulation became an issue. I want to use a dictionary, but that introduces a significant amount of overhead. However, that seems like the direction I need to be heading.

How do I handle my collision resolution using a delegate scheme?


texts: On-screen counting within a certain time-frame

texts:
In my game the player can collect a 'virtual currency' - on the main menu I display the amount the player has collected.  However, instead of simply displaying it, I want to count up from 0 to the amount the player has and then stop.

So - the logic would look something like this:

if (coinsToDisplay<=coinsPlayerHas){
    coinsToDisplay++
}

And then I would simply render the amount to the screen.

The problem is that obviously the more coins the player has the longer it takes to count.

I need to find a way make sure the counting always takes an arbitary amount of time (lets say 2 seconds).

My logic is called 60 times per second.  I know that I can introduce a delay to slow down the couning if the user has a very small amount of coins.  The time to wait between each count would be:

delay = 2000/coinsPlayerHas;  //2000 being 2 seconds expressed as milliseconds

I then wouldn't update the amount until the delay had passed.

if (delayHasExpired()){  //Only run this once our timer passed

    if (coinsToDisplay<=coinsPlayerHas){
        coinsToDisplay++
        resetDelay();
    }

}

But what if the player has thousands of coins?  At 60 Ticks Per Second the most I could count when incrementing 1 per tick is 120 max in 2 seconds.   Therefore I need to find a way of counting more than 1.

I just can't figure it out, so any pointers would be appreciated.


texts: Rotation with XMMatrix to Rotation with XMFLOAT3

texts:
I'm rotating a Direction Light around a fixed object, so the light only contains a XMFLOAT3 to determine it's direction that it is facing.

I have another object rotation using the variable Rotation which is an XMMATRIX.

Rotation = XMMatrixRotationAxis( rotaxis, rot);

I picked out the parts I needed by doing the following:

XMFLOAT3 newRotation;
newRotation.x = Rotation._11;
newRotation.y = Rotation._12;
newRotation.z = Rotation._13;

Is there a cleaner way of doing this? An easier built in function?


texts: Are there any clever methods of regulating bandwidth usage for voice chat payload packets?

texts:
For example, suppose my code can determine that upstream bandwidth is unusually limited.  And suppose I'm using a fully-connected mesh topology combined with a UDP-like protocol for voice chat.  Is there an established way to reduce the risk of packet loss so that the voice playback will either be solid or muted, but not jittery or choppy?  This must be a solved problem in the VoIP world, but I'm not sure where to look.

EDIT: To clarify my abuse of the term jitter: I mean, if two UDP voice packets arrive out of order, the audio would sound jittery in a colloquial sense (i.e. I mean packet jitter, not audio signal displacement).  The choppy sound I'm referring to is related, where a UDP packet is lost instead of arriving late and causes a gap or jump in the audio.

When I refer to muting the playback, I don't mean as a function of source input to avoid background noise.  I mean on the receiving end of the conversation, if there's high packet loss, just stop playback instead of playing choppy audio.


texts:
I'm doing a tile based 2d rpg in pygame. The problem I'm working on right now is character movement...
I am already able to create a map by using multidimensional arrays and a 'camera' follows the player.
My problem is now the collision detection... The player should only move one tile at the time so I can easily get his position in tile coordinates and check if he's collided. But I don't know how to do that! At the moment, if a key is pressed, the player moves four pixels in a direction every frame. But that makes tile based collision detection nearly impossible. The player has the size of one tile and yeah, my question is, how can I make the player move only one tile (but NOT every frame since then he would move 32 pixels every single frame.)
I know this question was asked before : Pygame Tile Based Character movement speed  but this wouldn't work for me, because you had to press the key EVERY TIME you want to move one tile. I use booleans so the player moves as long as the key is pressed.


texts: How do I calculate the normal of a plane defined using homogeneous coordinates?

texts:
I can define a plane in 3D space using three 3D points (p0, p1, p2) that all lie in the plane and that form a non-degenerate triangle. Calculating the normal of the plane is as simple as calculating the cross product of any two non-parallel 3D vectors that lie in the plane, for instance (p1 - p0) and (p2 - p0). So far, so good.

But what if I use homogeneous coordinates for my points? How do I find the normal of the plane then? Of course, if all points have w != 0, I could simply normalize them (divide by w) and treat them as regular 3D points. But what if one or more points have w == 0?

The way I see it, there are three possible answers to this question:

You do it the same way. If so, please explain how to calculate the cross product of two 3D vectors defined using homogeneous coordinates.
You do it some other way. If so, please explain how.
You can't, your question makes no sense and you are clearly confused. If so, please explain why.


texts: Moving a GameObject to a position, waiting, and then moving it again

texts:
Hello hello :) Ive been attemping to move a platform (a door basically), and it has partually worked. What works so far is i can move an object from A to B and wait, however it will not move it towards C afterwards, here is my code (note that all of the Debug.Logs work). Here is my code.

 public class OpenDoor : MonoBehaviour
{
    public Transform origPos;
    public Transform targetPos;
    public float speed;
    public GameObject button;
    private ButtonScript bs;

    private void Start()
    {
        bs = button.GetComponent<ButtonScript>();

    }

    void Update()
    {
        if (bs.buttonActive) {
            Debug.Log("Button Active 2");
            StartCoroutine(MovePlatform());
            bs.buttonActive = false;
        }
    }

    IEnumerator MovePlatform()
    {
        float step = speed * Time.deltaTime;
        bool arrived = false;
        while (!arrived)
        {
            transform.position = Vector3.MoveTowards(transform.position, targetPos.position, step);
            if (Vector3.Distance(transform.position, targetPos.position) == 0)
            {
                Debug.Log("DISTANCE 0");
                arrived = true;
            }
            yield return null;
        }
        if (arrived) {
            Debug.Log("Arrived");
            yield return new WaitForSeconds(1);
            Debug.Log("Waited");
            transform.position = Vector3.MoveTowards(transform.position, origPos.position, step);
        }

    }
}

Any assisstance would be greatly appreciated :)


texts: Target Tracking: When to accelerate and decelerate a rotating turret?

texts:
Say I have a moving circular target defined as:

Vector2 position;
Vector2 velocity;
float radius;

And a rotating turret (mounted on a moving vehicle of some kind) defined as:

Vector2 position;
Vector2 velocity;
float angle; // radians
float angularVelocity; // radians per second
const float maxAngularVelocity; // radians per second
const float maxAngularAcceleration; // radians per second per second

(Or something along those lines. Note that position and velocity of both are controlled elsewhere - assume velocity is constant and position changes based on velocity.)

I am trying to write two related AI functions to determine, on a given frame:

What angular acceleration (and in which direction) to apply to the turret's angle to keep the turret pointing at the target?
If the target is currently in sight, can it (any part within its radius) be kept in sight for x seconds, where x is a fraction of a second? (Alternatly: is there another strategy to ensure the target is actually "locked on" and not simply flying across the sights?)

And I could use some help...


texts: My players position is stored in a world matrix and I want to make him jump. Can I do this just by creating a translation from the matrix? I want the player to be able to jump while moving in a direction also. I've looked on google but didn't find any tutorials on jumping with a matrix


texts:
I'm currently working on a project that requires me to load .md5mesh format and draw it.

Following this link I've managed to load the mesh into the engine successfully, but a problem arises when calculating normals; they just don't seem to smooth.

To clarify that it was not my rendering or shader code that was the problem, I loaded a model of .OBJ format, and that lights smoothly.

The mesh is calculated correctly too, as I am able to load in complex models with multiple joints and mesh parts.

Here's a screenshot of the lighting.

And here is how I currently calculate the normals (All normals are set to zero before computing):

EDIT Amended the psuedo-code to be more accurate to what I have. The original may have been confusing.

for (unsigned int i = 0; i < NumberOfTriangles; i++)
{
    Math3::vec3 r, s, result;
    Math3::vec3 p1, p2, p3;

    p1 = Triangle[i].Vertex[0];
    p2 = Triangle[i].Vertex[1];
    p3 = Triangle[i].Vertex[2];

    r = p2 - p1;
    s = p3 - p1;

    result = Math3::Cross(s, r);

    // Add the triangles face normal to each vertex
    // The Vertex's are not local to the triangles.
    // Triangle[i].Vertex[j] is just an index.
    Vertex[Triangle[i].Vertex[0]].normal += result;
    Vertex[Triangle[i].Vertex[1]].normal += result;
    Vertex[Triangle[i].Vertex[2]].normal += result;
}

After the loop I normalise each vertex normal to find the average normal.

EDIT Here is how I find the average normal:

for (unsigned int i = 0; i < NumberOfVerts; i++)
{
    float nx = Vertex[i].normal.x;
    float ny = Vertex[i].normal.y;
    float nz = Vertex[i].normal.z;

    float len = sqrt(nx * nx + ny * ny + nz * nz);

    Vertex[i].normal.x /= len;
    Vertex[i].normal.y /= len;
    Vertex[i].normal.z /= len;
}

As you can see in the image the .md5mesh model is shading flat instead of shading smoothly like the .OBJ model.

So what am I missing?


texts:
Is it necessary to use graphics APIs to get hardware acceleration in a 3D game? To what degree is it possible to free of dependencies to graphics-card APIs like OpenGL, DirectX, CUDA, OpenCL or whatever else?

Can I make my own graphics API or library for my game? Even if it's hard, is it theoretically possible for my 3D application to independently contact the graphics driver and render everything on the GPU?


texts: Resolution independence - resize on the fly or ship all sizes?

texts:
My game relies heavily on textures of various sizes with some being full-screen. The game is targeted for multiple resolutions. I found that resizing textures (downsizing) works quite well for this game’s art type (it’s not Pixel Art or anything like that). I asked my artist to ensure that all textures at the edges of the screen to be created in such a way that they can safely “overflow” off screen; this means that aspect ratio is not an issue.

So with no aspect ratio issues, I figured that I would simply ask my artist to create assets in very high resolution, and then resize them down to the appropriate screen resolution. The question is, when and how do I do that?

Do I pre-resize everything to common resolutions in Photoshop and package all assets in the final product (increasing the size download that the user has to deal with) and then select the appropriate asset based on the detected resolution? Or do I ship with the largest set of Textures, detect the resolution on load, set a render target and draw all downsized assets to it and use that? Or for the latter, do I use some sort of a CPU-sided algorithm to resize on game load?


texts: Exporting models from Crocotile3D to Unreal Engine 4 (.obj). Texures are always blurry. I want crisp, clean textures

texts:
Can anyone help me? I am exporting models with textures (.obj) from Crocotile3D to Unreal Engine 4. I want them to be crisp and clear, as in the left image (Crocotile editor), but only get blurry, as in the right image (Unreal editor). Whether I export the model at scale x 1 or greater doesn't make any difference. My textures are 16x16 pixels.

I have watched endless videos and tinkered with settings but been stuck for two days. Any help or advice will be much appreciated!


texts:
Can I limit the number of shader units used by my video card? (A shader unit is the part of the hardware which can execute a shader program, where each unit runs in parallel).

I'm interested in this in an OpenGL context, i have an ATI 5770 just in case that you need to know.


texts: How come changing the speed of an animation isnt making the animation speed up?

texts: I made an animation of a bow string being pulled and another animation of the string being released but my issue is that I need the string to snap back quickly. I changed the speed of the release animation which is what makes the string go back to being straight (as if you had just released it). However, changing the speed isn't making the animation happen any faster... Any ideas why this might be happening?


texts: How can I select and scale an edge loop within Blender?

texts:
I'm a web developer looking into game development as a hobby for fun and the challenge. I have just started learning blender 2.6. I am currently doing a tutorial at http://cgcookie.com/blender/2010/12/22/modeling-a-building/
at around 9:30 after making loop cuts he scales a column. I cant get the same selection as he did. he has vertices selected but selected the whole loop cut? can someone tell me how to make that selection he did.
Also what setting does he use to display the dimension numbers of his selections?


texts: Is it possible to generalize Liang-Barsky Line Clipping Algorithm for n-dimensional space ?


texts: Does my 2D OpenGL renderer need optimized?

texts:
I've started a game engine for learning purposes. I have successfully gotten an opengl renderer working and I can draw textures of varying sizes to the screen. The way I have done this is by creating a hard coded array of vertices that are just a box.

float Renderer2D::vertices[30] = {
        0.f,  1.f, 0.0f, 0.0f, 0.0f, // Top-left
        0.f, 0.f, 0.0f, 0.0f, 1.0f,  // Bottom-left
        1.f, 1.f, 0.0f, 1.0f, 0.0f, // Top-right
        1.f, 1.f, 0.0f, 1.0f, 0.0f, // Top-right
        0.f, 0.f, 0.0f, 0.0f, 1.0f,  // Bottom-left
        1.f, 0.f, 0.0f, 1.0f, 1.0f // Bottom-right
};

(The first three are xyz - The fourth and fifth floats are texture coords)

I send this to the GPU at the beginning of my program. For every sprite I draw, I create a transformation matrix like this:

void Renderer2D::draw(int x, int y, int w, int h)
{
    float posX = 2.0f * x / m_screenWidth - 1.0f;
    float posY = 1.0f - 2.0f * y / m_screenHeight - 2.0f*h/m_screenHeight;

    glm::mat4 translation, scale;
    translation = glm::translate(glm::mat4(1.0f), glm::vec3(posX, posY, 0));

    scale = glm::scale(glm::mat4(1.0f), glm::vec3(2.0f * w /   m_screenWidth,2.0f*h/m_screenHeight, 1.f));
    transformation = translation * scale;
    glUniformMatrix4fv(m_shaderProgram.getMVPLocation(), 1, GL_FALSE, &transformation[0][0]);
    glUniform1i(m_shaderProgram.getSamplerLocation(), 0);

    m_shaderProgram.enableVertexAttribArray();

    glActiveTexture(GL_TEXTURE0);
    glDrawArrays(GL_TRIANGLES, 0, 6);

    m_shaderProgram.disableVertexAttribArray();
}

I started looking up other questions on here about sprite batches, so I could optimize my draw calls. But in all of these questions it was suggested that a vertex array should be built up, with vertex's for every sprite.

In my code, I send vertices to the gpu once, and call glDrawArrays for every sprite. If I built the vertex array every frame, I'd send the vertices every frame (not every sprite) and call glDrawArrays once per frame. I would still have to calculate the matrices for every sprite.

Is glDrawArrays much more computationally expensive than sending a vertex buffer? Does this definitely need fixing?

If I build a vertex buffer dynamically, how could I allocate the space if I don't know how many sprites are going to be drawn? Do you just put a hard limit on it?


texts: Are random events beyond players' control necessary for "strategy" games?

texts:
By "random event" I mean critical hits, misses, random variation in some kind of result etc. Examples of these include the accuracy mechanic in XCom; critical hits and accuracy chance in Darkest Dungeon; misses and fire/breech chance in FTL.

Something in common about these examples is that they are all games in which players have an indefinite amount of time to decide on actions. So, could it be that by adding random, RNG-based events, the game relieves the players' burden of feeling compelled to predict every possible outcome in the future? Could a game similar to the example do away with the randomness? If so, how could that change the experience?


texts: How to access random material in a renderer besides first without cloning any materials except accessed one?

texts:
Clones only first material:

renderer.material

Clones all materials in the same renderer:

renderer.materials[0]


texts: Multiple game frames in construct 2 for new levels?

texts: Hi there I'm new to Construct and have tried out a few platformer tutorials. I'm getting to grips with setting variables and collisions, I'm now at the stage where I want to start adding new levels. What the best way to effectively go to a new level, I know in flash this would be a new frame on the timeline, what would you do in construct 2?


texts: Moving object to point a to point b smoothly

texts:
I am working on a problem where distance between the point A and B or given and object of interest should move smoothly from A to B.

I can control only control the speed of the object using this object should start slowly from point ease in and ease out at point B and need to exactly land on point B

I tried implementing ease in speed using distance covered however, at the beginning distance covered will be zero there will be starting problem. I solved starting problem using time elapsed as reference however this will not work precisely stoping object at point B, so I used distance remaining as a key to ease out.

This works for larger distance for smaller distance yet to tweak the code . Overall implementation messy not satisfied. Is there any generic solution to solve this problem? Note speed just a parameter controls overall movement of object, I can't say there is a exact relationship speed and distance covered.

(Unity developers: Note I am trying to control the movement of the character using three animation idle:speed=0, slowwalk:average speed=1, fastwalk: average speed=2)


texts: How To Blit an Image onto Only Opaque Parts of a Surface?

texts:
I want to blit an image onto the parts of a surface that aren't transparent. I was wondering if there were a quick way to do this in Pygame. I want to be able to add effects to stuff.

I know that I could use set_at and get_at to do it, but that would be too slow.


texts:
I'm learning about the game development. No i'm on the total basics - writting a proper game loop. As i've searched over the Web i'v found that simple but good working pattern using so called fixed time step:
double previous = getCurrentTime();
double lag = 0.0;
while (true)
{
  double current = getCurrentTime();
  double elapsed = current - previous;
  previous = current;
  lag += elapsed;

  processInput();

  while (lag >= MS_PER_UPDATE)
  {
    update();
    lag -= MS_PER_UPDATE;
  }

  render();
}

I roughly understand the logic behind this piece of code but i have the question regarding the game composition.
What exactly the update function do and what the render function. What's their responsibility? Am i assuming right that in the super simple 2D game the update function can for e.g. calculate the distance in pixels the object (e.g. a Car) should move in the next frame and the render function in such a case just takes this calculated position and draws the Car on the screen?
Correct me if i'm wrong and please provide some example/s.
Thx.
PS.
Sorry for such a basic question but i'm really beginner.


texts: Physics / drag of object falling through atomsphere

texts:
Trying to simulate an object plunging into atmosphere.  It seems to work, until the velocity falls past terminal velocity... down to zero... and then back up!

Something must be wrong with how I am applying drag?  I've looked at the code so long, I've managed to confuse myself.

Here I set variables/constants:

Mass = 5;                           //Object Mass
Radius = 7;                         //Radius of the blunt end facing the air stream (too sensitive!!!)
Area = power(Radius,2)*pi;          //The total area of the blunt end facing the air stream
Gravity = 9.8;                      //Earth
DragCoeff = 1.61;
Velocity = 10000;                   //Initial velocity straight down (vector needs to be added)
Acceleration = Gravity * (1/Mass);  //this is acceleration FORCE... subtract drag from this
Altitude = 100000;                  //initial altitude(meters) (atmosphere "begins" at 100Km)

Then, in the main loop of the program:
(note, delta_time is provided by the system in microseconds from the last execution of the loop)

d_time = delta_time / 1000000;                                          //Convert delta_time to seconds
AirDensity = 1.07* power(2.718,-.00005*Altitude);                       //How dense is the air right now?

TermVel = sqrt(2 * Mass * Gravity / AirDensity * Area * DragCoeff);     //Terminal Velocity at our altitude
Velocity = Velocity + Acceleration * d_time;                            //Acceleration added
Drag = 0.5 * AirDensity * sqr(Velocity)* DragCoeff * Area;              //Drag calculated
Velocity = Velocity - (clamp(Drag, 0, TermVel) * d_time);               //Drag subtracted
Altitude = Altitude - Velocity * d_time;                                //Update the position

Thanks ever so much for your kind help in understanding what I've done wrong here.

SS

Edit:
Thanks, Jason... I think I have the correct changes made... but my mass of "5" was causing it to behave really poorly.... the velocity went way negative... so I increased the mass significantly, and it seems to behave better... I will explore it a bit more.

Does it look like I have it right?

Thank you again, ever so much.

SS


texts: Movement doesn't look smooth (slight lag)

texts:
Currently I'm using a variable time step and when the FPS drops by even a small amount you can easily notice a slight lurch forward of the player. I'm making a platformer and I'm wondering whether I should use a fixed timestep instead, however I'm confused as to why my movement doesn't look smooth, because the various articles I've read all say that a variable timestep is meant to make movement look much smoother.

So my question: Is a fixed timestep the better option for a 2D platformer, and why would anyone even use a variable timestep if your sprite appears to jump forward every 2-3 seconds?

private static final int UPDATE_RATE = 90;
private static final long UPDATE_PERIOD = 1000000000L / UPDATE_RATE;

private void mainLoop() {
    long beginTime, timeTaken, timeLeft;
    while (state == State.PLAYING) {
        beginTime = System.nanoTime();

        update();
        repaint();

        timeTaken = System.nanoTime() - beginTime;
        timeLeft = (UPDATE_PERIOD - timeTaken) / 1000000L;
        if (timeLeft < 10)
            timeLeft = 10;
        try {
            Thread.sleep(timeLeft);
        } catch (InterruptedException ex) { }
    }
}

Delta time is calculated every time repaint is called.

long currentTime = System.nanoTime();
        deltaTime = (currentTime - previousTick) / 1000000L;
        previousTick = currentTime;

This is how I pass the delta time into the player class.

public void move(float deltaTime) {
    if(left && !right)
        xPos -= 250*(deltaTime/1000);
    if(right && !left)
        xPos += 250*(deltaTime/1000);
}


texts: How do I create a Fixture in Andengine and assign it user data?

texts:
I´m following this tutorial: How do I use a JBox2D ContactListener to check if my character is standing on the ground? in order to get input from player's bottom part including a fixture in player's main body.
My problem is that I´m initializing FixtureDef like this:

    body = PhysicsFactory.createBoxBody(physicsWorld, this,BodyType.DynamicBody,PhysicsFactory.createFixtureDef(0,0, 0));

    body.setUserData("player");
    body.setFixedRotation(true);

    // create the bottom sensor
    final FixtureDef footSensor = PhysicsFactory.createFixtureDef(0, 0, 0);
    footSensor.isSensor = true;
    body.createFixture(footSensor);

Now I can't do: footSensor.setUserdata("sensor") because only Fixture class has this method. How can I initialize Fixture class to be able to include a user data? Thank you.


texts: How to stop jumping again when character is in air (double jump)?

texts:
I'm using touch inputs in my game to control the character. I would like to know how to disable my character from jumping again in the air.

if (FingerTouchy.phase == TouchPhase.Ended)
                {
       charcter.transform.Translate(Vector2.up * speed * Time.deltaTime);
       float jumpForce = 250;
                        charcter.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, jumpForce));

                    }

Update

Im using Collision Detection

void OnCollisionEnter (Collision col)
    {
        if(col.gameObject.tag == "Ground")
        {
            grounded = true;

        }
    }

And checking if charcter is grounded

if(FingerTouchy.phase == TouchPhase.Ended)
            {

                    float jumpForce=250;
                    if (grounded)
                        continue;
                    charcter.transform.Translate(Vector2.up * speed * Time.deltaTime);
                    charcter.GetComponent<Rigidbody2D>().AddForce(new Vector2(0,jumpForce));
                        grounded=false;

                }

using collision/collision2d doesn't work too.


texts: Voxel terrain collision detection with AABBs

texts:
I'm working on implementing collision detection on voxel terrain (Like Minecraft) with AABBS.

Right now, I have it so I can tell if a point is within a voxel or not, I do this by having a 2D byte array of active voxels. If a byte at any index is 0, the voxel is air. If its 1, its solid. Right now I'm just testing to see if the voxel at the player's position vector is solid or not.

My problem is, I now wish to implement AABBs to get more precise detection, but I have no idea how to do it without checking if all the voxels within the AABB are solid. That might now be a problem for games like Minecraft, where there would only have to be about 1 extra voxel check, but the voxels in my game are much smaller (The player's dimensions are about 4x10x4), so I would have to check a lot of voxels.

Ive seen one or two other people having a issue similar, but I didn't find the answers they got clear enough, and so I come here asking for your help.

Thanks.


texts: In Unity, how do I move my character to an object when I click on it?

texts:
Basic question here, and I feel like I'm close but can't quite get it.

I have an object--it's a pot on a stove--that is in my 2D game. There will be multiple pots that appear and disappear in the game, all in predefined places (like on top of the burners of a stovetop). There's also a chef in the game, who goes to each pot and does an action. The user never directly controls the chef's movement--instead, when the user clicks a pot, the chef runs over to the counter in front of that pot, where he can perform an action on the pot.

Can someone tell me how to do this? I'm not only looking for the code but for a "correct" design, in terms of where the various variables and methods should be located. In other words, what goes in the pot's script and what goes in the chef's script? (I'm using C#.)

My thought was that the pot GameObject would have an OnMouseDown() method, to catch the user clicking on it. And in that method, there should be a call to a Move() method that is attached to the chef GameObject.

But what I have is not quite working. The chef moves one small bit toward the pot but then stops. I realize that this is because I'm calling the Move function once and that's it; it seems like the Update method should be involved somehow (the pot's or the chef's?); or maybe I should have an if statement in my Move method that checks to see if the user is at the pot, and if not, runs the move code in a loop. Or maybe the design is just fundamentally wrong and it could be done more easily.

Here is the code I have:

public class PotController : MonoBehaviour {

    private GameObject chefObject;

    void Start () {
        chefObject = GameObject.Find ("Chef");
    }

    void OnMouseDown() {
        ChefController chefScript = chefObject.GetComponent<ChefController> ();
        chefScript.Move ();
    }

}

public class ChefController : MonoBehaviour {

    public float moveSpeed;
    private Vector3 moveDirection;

    public void Move () {

        Vector3 currentPosition = transform.position;
        if (Input.GetButton ("Fire1")) {
            Vector3 moveToward = Camera.main.ScreenToWorldPoint (Input.mousePosition);
            moveDirection = moveToward - currentPosition;
            moveDirection.z = 0;
            moveDirection.Normalize ();
        }
        Vector3 target = moveDirection * moveSpeed + currentPosition;
        transform.position = Vector3.Lerp( currentPosition, target, Time.deltaTime );

    }

}


texts: I' looking to get rights to an game called Grand Theft Auto: Chinatown Wars for the Nintendo DS. I am a Nintendo 3DS Developer trying to make a remastered version for the Nintendo 3DS. How would I go about getting the rights for the game. Do I get the rights from Rockstar, Nintendo, or another party. I'm not sure.


texts:
This seems like it should be incredibly easy and I know there are other posts out there with a similar title, but I promise you I have looked at all of them. All I want is for my canvas that simply says "you win" to appear when I enter an invisible box collider that I have . My canvas is by default set to disabled.

public class YouWin : MonoBehaviour {
public Canvas myCanvas;

private void Start()
{
    myCanvas = GetComponent<Canvas>();

}

void OnTriggerEnter (Collision Collider)
{
    {
        myCanvas.gameObject.SetActive(true);
    }
}

This script seems incredibly simple and straightforward, but for whatever reason, when I enter my box, nothing at all happens. Why might this be? What am I missing?

As per an answer I also tried

public class YouWin : MonoBehaviour {
public GameObject canvas;

void OnTriggerEnter (Collider Collider)
{
    {
        canvas.gameObject.SetActive(true);
    }
}

But had no luck with this either. I've been tinkering to no avail, can you please give me some suggestions?


texts: Can I mention other games' titles, characters, maps, weapons etc. in my game?

texts:
Let's say I was about to make a quiz game where the questions are like this:

When was Fallout 4 released?
What is your first pickaxe in Minecraft?
Who do you have to kill as the last boss in Skyrim?

And let's pretend I have 1000 of these questions, from 1000 games.
What are the chances some of those 1000 could sue me, remove my game from the internet, pay them a fee etc.? Even if it becomes very popular.

Taking it one step further, could I buy their games, take in game screenshots personally, then use those as pictures in my own game?

Does it make a difference if it's a free-to-play or a game that has to be bought?


texts:
I am trying to program point line segment collision detection and reaction.  I am doing this for fun and to learn.

The point moves (it has a velocity, and can be controlled by the user), whilst the lines are strait and stationary.  The lines are not axis aligned.  Everything is in 2D.

It is quite straight forward to work out if a collision has occurred.  For each frame, the point moves from A to B.  AB is a line, and if it crosses the line segment, a collision has occurred (or will occur) and I am able to work out the point of intersection (poi).

The problem I am having is with the reaction.  Ideally I would like the point to be prevented from moving across the line.  In one frame, I can move the point back to the poi (or only alow it to move as far as the poi), and alter the velocity.  The problem I am having with this approach (I think) is that, next frame the user may try to cross the line again.

Although the point is on the poi, the point may not be exactly on the line.  Since it is not axis aligned, I think there is always some subtle rounding issue (A float representation of a point on a line might be rounded to a point that is slightly on one side or the other).  Because of this, next frame the path might not intersect the line (because it can start on the other side and move away from it) and the point is effectively allowed to cross the line.

Firstly, does the analysis sound correct?

Having accepted (maybe) that I cannot always exactly position the point on the line, I tried to move the point away from the line slightly (either along the normal to the line, or along the path vector).  I then get a problem at edges.  Attempting to fix one collision by moving the point away from the line (even slightly) can cause it to cross another line (one shape I am dealing with is a star, with sharp corners).  This can mean that the solution to one collision inadvertently creates another collision, which is ignored.

Again, does this sound correct?

Anyway, whatever I try, I am having difficulty with edges, and the point is occasionally able to penetrate the polygons and cross lines, which is undesirable.  Whilst I can find a lot of information about collision detection on the web (and on this site) I can find precious little information on collision reaction.

Does any one know of any good point line collision reaction tutorials?  Or is my approach too flawed/over complicated?


texts: How can I render a wave effect like the one used in California Games' surfing mini-game?

texts:
Well, I'm trying to study XNA, and I'm trying to make a California Games-inspired surfing game.

I got the surfer guy done, and it's working very well but I don't have any idea on how I should draw the wave coming and animate it. If you don't remember what the game looks like, here it is. The wave I'm talking about is the one which is coming from the left at around the 00:40 mark:


texts: Storing and using UV and Normal Data with OpenGL

texts:
I'm having trouble mapping UV coordinates to vertices in OpenGL. I'm binding my buffers and enabling all of my attrib arrays perfectly well and things are rendering - but what I'm stuck on is how to map UV and Normal data.

You can't just store UV and Normal data with the Vertex data, because obviously you'll be re-using vertices, but not necessarily with the same Normal or UV.

For clarity this is the general flow of what I'm doing at the moment:

I bind my shader program.
I bind my vertex array buffer with GL.BindBuffer
I Bind my element buffer with GL.BindBuffer
I use GL.Uniform (1, 2, 3 or 4) to bind values to my uniform variables
I enable all of my vertex buffer attributes with GL.EnableVertexAttribArrau and then encode their layout using GL.VertexAttribPointer
I draw using GL.DrawElements
I disable all of my vertex attrib arrays again

I'm totally stuck on how to encode UV and Normal data to my vertex attributes. Do I need to use a second buffer? If so; how does OpenGL know to use a different set of indices to find them? I'm totally lost and any help would be greatly appreciated.


texts: Round to the nearest multiple of 0.75 in C#

texts:
How can I round a number to the nearest multiple of 0.75 in C# / Unity?

The context is that I have a block and I want its position to be rounded at the nearest 0.75 multiple. For example: 0, 0.75, 1.5, 2.25, 3, 3.25, 4.5, 5.25, 6, ...
How can I do that?


texts: Implement navmesh for climbing cliffs and walls

texts:
I am trying to implement dynamic wall climbing similar to Conan exiles and Legend of Zelda: Breath of the Wild.
My system as of now uses a raycast to get the direction of a geometry's normal, and I make the player face that. I send another raycast in the direction of the players input, which takes the hit point, and lerps the player to that ray's hit position on the geometry.
Although this system works well on a flat wall it struggles a lot on complex geometry such as a bumpy cliff, and constantly hangs on small edges.
I recently saw this video from the cancelled game Worlds Adrift that seems to implement some sort of navmesh by making a flat plane that follows the terrain's normals. This allows the player to climb over gaps and complex geometry as if it was a smooth surface.

I don't completely understand how they managed this, and I was wondering if someone who is knowledgeable about these things could explain how I could implement something like this in Unity.


texts: Is there any different between these 2 command?

texts: I came across this question on stackoverflow https://stackoverflow.com/questions/17147553/int-num-new-int-what-happens-when-this-line-executes . Wonder if there is any difference for sprite and spriteRender in unity between both of these commands sprite y=new sprite() and sprite y; or SpriteRenderer x=new SpriteRenderer() and SpriteRenderer x;? I tested in unity, both commands also generate the same option to attach game object, so do both have the same meaning as well?


texts: Locking global Y rotation component of camera orientation

texts:
Question:
For research purposes, I'm trying to lock the global camera yaw in VR -- though, the "how" is more of a 3D math question and has little to do with VR. The user is in control of the orientation of the headset, but I want to take control of the global yaw. To illustrate the movement the user is allowed:

What I've tried:
I've a number approaches, but so far each one has ended up distorting the camera's orientation in some way. My most recent attempt sets the euler y component of both global last/current head rotations to any arbitrary, but same, value so delta yaw between them is always 0. But, the result is weird looping behavior in the same global area -- irrespective of where yaw first locked -- while rotating my head in a straight line.

Edit: It appears as the global yaw approaches 180, it flips. With global pitch=0, this happens instantly at 180, but with non-zero values of pitch it starts earlier and the flip happens over time. Here is a clip that illustrates this behavior.
Implementation of this approach (in pseudo-code, as I'm not using a well-known development platform/API):
var lastWorldOrientation = getHMDOrientation();//This method returns world space orientation
var displayedOrientation = lastWorldOrientation;
void Update() {
    var nowWorldOrientation = getHMDOrientation();
    var delta;

    if (lockedYaw) { //null if not locked, else float with value yaw locked to
        var tempLast = lastWorldOrientation;
        var tempNow = nowWorldOrientation;
        tempLast.eulerAngles.y = lockedYaw;
        tempNow.eulerAngles.y = lockedYaw;

        delta = tempLast:toObjectSpace(tempNow);
    } else {
        delta = lastWorldOrientation:toObjectSpace(nowWorldOrientation);
    }

    lastWorldOrientation = nowWorldOrientation;
    displayedOrientation = displayedOrientation * delta;
    camera.rotation = displayedOrientation;
}

While all of my attempts have been manipulating the euler angles of the HMD / camera rotations, I also have the ability to manipulate and read them in quaternion or matrix form. Any ideas why the current approach I'm using experiences the distortion it does, and how I can lock the global yaw of the camera without interfering with the other two axes?


texts: How do you get textures out of a png file

texts:
I have 1 png of many different textures. I want to use these textures in my iphone game using cocos2d. I found the program "Zwoptex" where you can combine many textures to one png and create a plist file that you can use in your program.

But if you have already a png file how do you get all these textures out of this file automatically OR how do I create a plist file from this png file?


texts: Does DirectX implement Triple Buffering?

texts:
As AnandTech put it best in this 2009 article:

  In render ahead, frames cannot be dropped. This means that when the
  queue is full, what is displayed can have a lot more lag. Microsoft
  doesn't implement triple buffering in DirectX, they implement render
  ahead (from 0 to 8 frames with 3 being the default).

  The major difference in the technique we've described here is the
  ability to drop frames when they are outdated. Render ahead forces
  older frames to be displayed. Queues can help smoothness and
  stuttering as a few really quick frames followed by a slow frame end
  up being evened out and spread over more frames. But the price you pay
  is in lag (the more frames in the queue, the longer it takes to empty
  the queue and the older the frames are that are displayed).

As I understand it, DirectX "Swap Chain" is merely a render ahead queue, i.e. buffers cannot be dropped; the longer the chain, the greater the input latency. At the same time, I find it hard to believe that the most widely used graphics API would not implement such fundamental functionality correctly. Is there a way to get proper triple buffered vertical synchronisation in DirectX?


texts: How to catch basic system events (such as input) in Linux/C++

texts:
As old and as standard as Linux/C++ is now, I would imagine there's an efficient method, even a library or three, for something as elementary as catching system events.

The types of events I need are things like:

GUI: Window resizing, moving, ...
IRQ: Inputs (Keyboard/Mouse), USB, ...
FS: Node operations, r/w, ...
Anything similar, Shutdown, log out, ...

I know:

/dev/input/* can be polled
Udev ...
Xorg can be polled
IRQ Handlers ...

Most of these are either inefficient and/or require certain environments, (Xorg, Udev, etc.) IRQ Handlers are efficient, but are good for only one type of event.

Game engines have to be especially efficient with these, in particular inputs, for the sake of FPS loops. If anyone can provide implementation details for inputs, that would suffice and be appreciated.

What is the efficient method I'm looking for? What is commonplace? If I have to build it myself, where do you suggest I start? What tools would I need?

  So, to clarify, applications have always had to do this one way or another right? Web browsers, game engines, desktop environments, etc, have all had to gather input and other events efficiently. "How is that?" I'm asking. Is it unreasonable to expect an established OS/PL for practical API(s)? Of course not!


texts: Does a game engine affect the quality of pre-baked Global Illumination?

texts:
If I were to pre-bake Global Illumination into light maps using a high quality renderer like Mental Ray or PRman, and loaded it into two different engines such as Unity and Unreal, would there be a noticeable difference in quality?

If there is a difference, could you give me a few examples of engines that are better at it than others?


texts: How do I create selectable menu options in C#/XNA?

texts:
Ok, I have my game's menu system set up. There are 3 screens (Controller Detect Screen, Title Screen, and GamePlay Screen). I wish to improve on this by having the ability for the player to select options on the screen, but I do not know how.

I don't know how to make menu choices that can be highlighted or making transitions from screen to screen rather than having it warp the way it presently does.


texts: How can I compute a "steepness" value for height map cells?

texts:
Here's a question related to height map generation. From a 2D height map I want to produce a second map, I guess you can call it sort of a derivative map, which shows the "steepness" of all the discrete values of the map. I plan to use it to quickly determine what kinds of objects can be placed on different locations.

In practice you would have many areas where rise/run is a fractional value, since many places do not have 45 degree angle slopes. But running through the pixels of the height map in any direction, the value differences are all integer values.

So what I planned to do in order to represent smooth slopes of varying degrees is, iterate through the pixels row by row, and find the lengths of all the distances where height does not change, and for every change in height, divide that by the length of the distance. Do the same thing column by column and then average the two results for each pixel. I do have to wonder how accurate this is in situations where a lower elevation is surrounded by two walls/plateaus since the rise/run is technically infinity, as it represents a completely vertical climb.

Is this a reasonable way for calculating steepness? I haven't found any resources on how to produce a 2D array of steepness values from height maps, just things on topographic (real-life maps) with the basic rise/run formula.


texts: Normal vector of a face loaded from an FBX model during collision?

texts:
I'm loading a simple 6 sided cube from a UV-mapped FBX model and I'm using a BoundingBox to test for collisions. Once I determine there's a collision, I want to use the normal vector of the collided surface to correct the movement of whatever collided with the cube. I suppose this is a two-part question:

1) How can I determine which face of the cube was collided with during a collision?

2) How can I get the normal vector of that surface?


texts: Cannot decide between using a MessageBus and entities for events in my ECS game

texts:
For example, let's say that the player walks into an enemy and in response, a chain of events should occur (such as: his score goes up, the enemy dies, a cinematic starts, etc.)
I see two "proper" ways of accomplishing this:
Method 1:
There exists a global message bus in the game. Any system can emit events to it, and any other system can listen for some events from it. For example, the system handling the players score would look like this:
messageBus.listen("playerhitsenemy", e => {
  score += e.monsterType;
});

and the collision system may look like this:
messageBus.emit("playerhitsenemy", { monsterType: 5 });

Similarly, other systems can listen for the same event, such that when something happens, the CPU immediately moves from processing the current system to the other system processing this event. That is, the emit call is basically just a list of callbacks that are immediately invoked and sent the message.
Method 2:
The second method, instead, is to encode events / messages as entities themselves. That is, when an event occurs (such as the player hitting something in the collision detection system), this would happen:
let newEntity = new Entity();
newEntity.components.push(new MessageComponent());
newEntity.components.push(new MessagePlayerHitsEnemyComponent(5));
entityAdmin.spawnNewEntitiy(newEntity);

That is, a new "message" entity is created, and it is given the generic Message component and the concrete event component type as well, MessagePlayerHitsEnemy.
Then, all systems interested in these messages would have something like this in their execute function:
for (let entity of entityAdmin.query(MessagePlayerHitsEnemyComponent) {
  let monsterType = entity.getComponent<MessagePlayerHitsEnemyComponent>();

  score += monsterType;
}

And then at the end of the frame there would be a system whose responsibility was deleting all messages, like so:
for (let entity of entityAdmin.query(MessageComponent) {
  entityAdmin.remove(entity);
}

I cannot decide which is better. The first method seems simpler and probably more efficient in Javascript, considering it's just immediately invoking all the requested functions. However, the second one seems more "correct", in each system is iteratively processed. That is, first the collision system runs in its entirety, then the scoring system, etc. There is no "jumping around" from system to system during execution. Each system processes everything in its entirety, and then the second system processes everything it's interested in, etc.
So, in essence, the first method seems simpler and more efficient, while the latter method seems more "correct", pure, verbose, debuggable, and extendable. Which one should I pick?


texts: Input events not working simultaneously on android devices in libgdx

texts:
I am making a simple platform game in Libgdx... in which I have made the player to move left, move right and jump. The code works fine on Desktop but on Android devices, Jump is not fired when the player moves left or right. It looks strange. Here is my code...

private void updatePlayerForUserInput(float deltaTime)
    {

    // check input and apply to velocity & state
    if ((Gdx.input.isKeyPressed(Keys.SPACE) || isTouched(0.87f, 1,0,1f)) && world.player.grounded)
    {
        world.player.velocity.y += world.player.JUMP_VELOCITY;
        world.player.state =2;
        world.player.grounded = false;
    }

    if (Gdx.input.isKeyPressed(Keys.LEFT) || Gdx.input.isKeyPressed(Keys.A) || isTouched(0, 0.1f,0,1f))
    {
        world.player.velocity.x -=world.player.MAX_VELOCITY;
        if (world.player.grounded)
            world.player.state =1;
        world.player.facesRight = false;
    }

    if (Gdx.input.isKeyPressed(Keys.RIGHT) || Gdx.input.isKeyPressed(Keys.D) || isTouched(0.2f, 0.3f,0,1f))
    {
        world.player.velocity.x =world.player.MAX_VELOCITY;
        if (world.player.grounded)
            world.player.state =1;
        world.player.facesRight = true;

    }
}

private boolean isTouched(float startX, float endX , float startY, float endY)
{
    // check if any finge is touch the area between startX and endX
    // startX/endX are given between 0 (left edge of the screen) and 1 (right edge of the screen)
    for (int i = 0; i < 2; i++)
    {
        float x = Gdx.input.getX() / (float) Gdx.graphics.getWidth();
        float y = Gdx.input.getY() / (float) Gdx.graphics.getHeight();
        if (Gdx.input.isTouched(i) && (x >= startX && x <= endX) && (y>=startY && y<= endY))
        {
            return true;
        }
    }
    return false;
}

I took the idea from the demo platform game SuperKoalio by mzencher at

https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/superkoalio/SuperKoalio.java

Please suggest


texts: Removing the circle outline rendered on Box2d CircleShape

texts:
How can I remove the outline on the CircleShape below?

CircleShape circle = new CircleShape();
circle.setRadius(1f);

This is what I'm using to draw:

batch.draw(textureRegion, position.x - 1, position.y - 1, 1f, 1f, 2, 2, 1, 1, angle);

I use this to set the body for a Box2d collision but I get a silly circle shape around my texture in libGdx. My textured sprite (ball) has a circle over the top of it with a line running from center along the radius.

Any ideas on how to remove the overlying circle lines?


texts: How to write a PBR Unlit Shader in Unity?

texts:
I have a REALLY specific case here:

I have an Texture (a webcam), that is used by a shader to pickup a few x,y colors at the cordinates, and renders to a Custom Render Texture, that is later fetched (download pixel color information from GPU to CPU), and I can handle the algorithm from there.

The thing is, once I upgraded the project to PBR (Physically Based Rendering), all my Unlit scripts become PINK, and they stopped working.

This is a special case because:

It doesn't need to appear on the screen
It acts as a "Compute Shader", but with backward compatibility to old phones
It works well without PBR, but once PBR is enabled it becomes pink and stops working
It doesn't need to reflect, refract, output pixels or anything to the "Screen", only to my Custom Render Texture so that I can fetch it later.
The algorithm doesn't fits on a Graph based programming (it has iterations and etc)

Well, I didn't find documentation on how to write custom PBR shaders and here I am.


texts: Unreal4, C++: Spawned actors visible after stopping, not during play

texts:
I've created a class with a function InitializeModel, that is exposed to blueprint. In this function some AStaticMeshActors should be spawned, but I cannot see them during play, I need to stop the game for them to appear. If I stop the game and start it again they're still visible. In blueprint I'm using BeginPLay event to trigger "create object from class" then running the InitializeModel on it,
I've tried placing some prints in InitializeModel and I know that it runs properly just after beginPlay, but models are invisible just after that, they're visible after stopping, and later, after starting play again.
Hi
In header file, as public field of this class, I've got:
UPROPERTY()
TMap < FString, UStaticMesh*> mMeshes;

In Cpp :
MyClass::MyClass()
{
    static ConstructorHelpers::FObjectFinder<UStaticMesh> StaticMeshFinder(TEXT("StaticMesh'/Game/box.box'"));
    mMeshes.Emplace("box0", StaticMeshFinder.Object);
}

bool MyClass::MyClass()
{
    bool result{ false };
    [...]
    // Preparation of scene
    float unitsScale{ 100.0f };
    for (int i = 0; i < m_numberOfBlocks; i++)
    {

        FTransform transform;
        FVector vec;
        FRotator rotation;
        FActorSpawnParameters SpawnParams;
        AStaticMeshActor* NewElement = GetWorld()->SpawnActor<AStaticMeshActor>(vec, rotation, SpawnParams);
        NewElement->GetStaticMeshComponent()->SetStaticMesh(mMeshes["box0"]);
        NewElement->SetActorHiddenInGame(false);
        NewElement->SetMobility(EComponentMobility::Movable);

        m_elementsList.Add(NewElement);
    }
    return true;
}

All I want to do is to place some simple meshes in scene at the start of playing. I'd like to be able to move them later. So if that's not the correct way to do this then please, show me the correct way,
Regards


texts:
There are more or less standardized TV-show/movie formats and recommended timings:

1.

  By the early 1960s, television companies commonly presented half-hour long "comedy" series, or one hour long "dramas." Half-hour series were mostly restricted to situation comedy or family comedy, and were usually aired with either a live or artificial laugh track. One hour dramas included genre series such as police and detective series, westerns, science fiction, and, later, serialized prime time soap operas. Programs today still overwhelmingly conform to these half-hour and one hour guidelines. Source

2.

  In the United States, most medical dramas are one hour long. Source

3.

  Traditionally serials were broadcast as fifteen minute installments each weekday in daytime slots. In 1956 As the World Turns debuted as the first half-hour soap opera. All soap operas broadcast half-hour episodes by the end of the 1960s. With increased popularity in the 1970s most soap operas expanded to an hour (Another World even expanded to ninety minutes for a short time). More than half of the serials had expanded to one hour episodes by 1980. As of 2010, six of the seven US serials air one hour episodes each weekday. Source

Interesting. Are there any standards of timing in game development?

Well, 5-20 minutes casual games, of course. There is even a "5-minutes-game" site. And 1-hour-gamer site. Are there 1-week, 1-year, 1-eternity game formats? Chess and Go - deep games that you can study all your life; but they are played in hour or several days (pro games). Addictive long-term online role-playing games (without win-condition) are played in monthes and, possibly, years. Replayability is an important factor to consider.

It's good when game design document contains a line: "A game is designed for solving in X hours". How can it be measured before there is any prototype or demo? When you know your game format, you know your audience (and vice versa). It is practical question.

Are there psychological researches about dynamic of gaming interest and involvement?

And is there a correlation between game format and game genre?


texts: Iterating through map : need help getting cluster of flags (points) while avoiding duplicates

texts:
I have a grid style game where I make use of objects called flags which have points attached to them.
I want to be able to look at the map and find the tile(position) where it maximizes the points (using the cardinal flags North,South,West,East of current position and uses radius to give a bigger search area); while trying to avoid using the same flags.
My method works in the sense that it adds the points up correctly based on the position. However, when I move to the next tile over; if the previous tile uses flags (x,y) and the next tile over uses flags (x,y,z)
Example using method below:
Tile 1 @ Position (3,4)

Flags (x,y)

Tile 2 @ Position (3,5)

Flags (x,y,z)

Expected result for Tile 2 : z flag only
    //searches each tile for corresponding flag points
    public Map<Map<Integer, List<Flag>>, Position> checkTilePoints(Player player) {
        List<Flag> localFlags = new ArrayList<>();
        Map<Map<Integer, List<Flag>>, Position>tilePoints = new HashMap<>();
        int diameter = 4; //as much diameter as warfrig
        int radius = diameter / 2;
        int squareRadius = radius;
        for (int i = 0; i < context.getMap().getMap().length; i++) {
            for(int j = 0; j < context.getMap().getMap()[i].length; j++) {
                localFlags.clear();
                int pointTotal = 0;
                if(context.getMap().isRock(i, j, player) || context.getMap().isOutOfBounds(i, j)) {
                    continue;
                }
                for (int x = i - squareRadius; x < i + squareRadius; x++) {
                    for (int y = j - squareRadius; y < j + squareRadius; y++) {
                        if((java.lang.Math.pow(x - i, 2) + java.lang.Math.pow(y - j, 2)) < java.lang.Math.pow(radius, 2)) {
                            Flag checkedFlag = context.getMap().getFlag(x, y);
                            if ((checkedFlag != null) && (!localFlags.contains(checkedFlag))) { // add once only
                              localFlags.add(checkedFlag);
                            }
                        }
                    }
                }

                Flag north = context.getMap().getFlag(i, j + radius);
                Flag south = context.getMap().getFlag(i, j - radius);
                Flag west = context.getMap().getFlag(i - radius, j);
                Flag east = context.getMap().getFlag(i + radius, j);

                if ((north != null) && (!localFlags.contains(north))) {
                    localFlags.add(north);
                }
                if ((south != null) && (!localFlags.contains(south))) {
                    localFlags.add(south);
                }
                if ((west != null) && (!localFlags.contains(west))) {
                    localFlags.add(west);
                }
                if ((east != null) && (!localFlags.contains(east))) {
                    localFlags.add(east);
                }

                for(Flag points : localFlags) {
                    pointTotal += points.getSize().getID();
                }
                if(pointTotal != 0) {
                    //TODO - create hashmap to return
                }
            }
        }
        return null;
    }

I'm not sure if I explained my problem very well, but overall; I want to fix this method to just add the cluster of flags based on the position without using duplicate flag already checked


texts: How can I create a bomb explosion in Farseer that pushes nearby objects away?

texts: I'm trying to create a bomb explosion in Farseer. I created a circle for the bomb. However, if the bomb explodes, the objects (bodies) that are around it should fly away because they're pushed back by the enormous force of the explosion. I'm not sure how to create that force, though - how can I do it?


texts: How to use textures in 2D games in WebGL

texts:
I have been trying to figure out how to structure the VBOs in WebGL, and think that keeping them all together in one if at all possible sounds like the best approach. Right now I'm thinking of having color buffer, position buffer, and index buffer, just those 3. But my question is what about a texture buffer (maybe it's called a UV buffer, but I'm not sure if that's 3D only).

I would like to have a game with basically flat colors and alpha/opacity and some drop shadows perhaps, maybe some glows, but nothing too complex. Mainly it would be like traditional vector graphics look but in WebGL. As such, I'm wondering how to solve the texture problem. If I need a texture, or I don't at all need one.

Part of figuring this out is knowing what you should really be using textures for. I get that they are useful for mapping images to geometry, but I don't know of any other use case. Wondering if one could explain some use cases of textures as it applies to my situation. The main goal is figuring out if I need a texture buffer at all, or I can/should just stick with color/position/index.

A look I like is like this: