texts: When I add UPROPERTY or UFUNCTION to TEnumAsByte the compiler throw a link error

texts:
FootstepSound.h
#pragma once

#include "CoreMinimal.h"

#include "Sound/SoundCue.h"

#include "FootstepSound.generated.h"

UCLASS(Blueprintable)
class MyProject_API UFootstepSound : public UObject
{
    GENERATED_BODY()

public:

    UFootstepSound();
    ~UFootstepSound();

    UFUNCTION()
        FORCEINLINE TEnumAsByte<enum EPhysicalSurface> GetPhysicalMaterial() const { return this->vPhysicalMaterial; }

    UFUNCTION()
        FORCEINLINE TArray<USoundCue*> GetLeftStepSound() const { return this->sLeftSteps; }

    UFUNCTION()
        FORCEINLINE TArray<USoundCue*> GetRightStepSound() const { return this->sRightSteps; }

    UFUNCTION()
        FORCEINLINE TArray<USoundCue*> GetJumpSound() const { return this->sJump; }

    UFUNCTION()
        FORCEINLINE TArray<USoundCue*> GetSprintingSound() const { return this->sSprinting; }

    UFUNCTION()
        FORCEINLINE float GetWalkVolume() const { return this->fWalkVolume; }

    UFUNCTION()
        FORCEINLINE float GetSprintVolume() const { return this->fSprintVolume; }

    UFUNCTION()
        FORCEINLINE float GetCrouchVolume() const { return this->fCrouchVolume; }

private:

    UPROPERTY(EditDefaultsOnly)
        TEnumAsByte<enum EPhysicalSurface> vPhysicalMaterial;

    UPROPERTY(EditDefaultsOnly)
        TArray<USoundCue*> sLeftSteps;

    UPROPERTY(EditDefaultsOnly)
        TArray<USoundCue*> sRightSteps;

    UPROPERTY(EditDefaultsOnly)
        TArray<USoundCue*> sJump;

    UPROPERTY(EditDefaultsOnly)
        TArray<USoundCue*> sSprinting;

    UPROPERTY(EditDefaultsOnly)
        float fWalkVolume = 0.2f;

    UPROPERTY(EditDefaultsOnly)
        float fSprintVolume = 0.5f;

    UPROPERTY(EditDefaultsOnly)
        float fCrouchVolume = 0.1f;
};

FootstepSound.cpp
#include "Character/Sound/FootstepSound.h"

UFootstepSound::UFootstepSound() {}

UFootstepSound::~UFootstepSound() {}

When I add to TEnumAsByte<enum EPhysicalSurface> UPROPERTY() or UNFUNCTION() the compiler throw a link error (unresolved externals), if I remove UFUNCTION() and UPROPERTY() on TEnumAsByte<enum EPhysicalSurface>, compile completing without any errors. Idk how fix this. On others properties or functions UPROPERTY() and UFUNCTION() works fine


texts: Unity Standard surface shader with tessellation

texts:
So I'm experimenting with tesselation to try and make a custom snowshader and after I finnaly manage to compile the shader without any errors.

The plane I'm using the shader on simply become completly invisible. Here is the entire shader code. I'm lost at what I'm doing wrong.

Shader "Custom/SnowTessellation" {
    Properties{
        _EdgeLength("Edge length", Range(2,50)) = 15
        _MainTex("Base (RGB)", 2D) = "white" {}
    _Glossiness("Glossiness", Range(0,1.0)) = 0
        _Metallic("Metallic", Range(0,1.0)) = 0
        _DispTex("Disp Texture", 2D) = "gray" {}
    _NormalMap("Normalmap", 2D) = "bump" {}
    _Displacement("Displacement", Range(0, 1.0)) = 0.3
        _Color("Color", color) = (1,1,1,0)
        _SpecColor("Spec color", color) = (0.5,0.5,0.5,0.5)
    }
        SubShader{
        Tags{ "RenderType" = "Opaque" }
        LOD 300

        CGPROGRAM
#pragma surface surf Standard fullforwardshadows vertex:disp  tessellate:tessEdge nolightmap
#pragma target 5.0
#include "Tessellation.cginc"

        /*struct appdata {
        float4 vertex : POSITION;
        float4 tangent : TANGENT;
        float3 normal : NORMAL;
        float2 texcoord : TEXCOORD0;
        float2 texcoord1 : TEXCOORD1;
        float2 texcoord2 : TEXCOORD2;
    };*/
        struct Input {
        float2 uv_MainTex;
    };
    float _EdgeLength;

    float4 tessEdge(appdata_full v0, appdata_full v1, appdata_full v2)
    {
        return UnityEdgeLengthBasedTess(v0.vertex, v1.vertex, v2.vertex, _EdgeLength);
    }

    sampler2D _DispTex;
    float _Displacement;

    void disp(inout appdata_full v)
    {
        UNITY_INITIALIZE_OUTPUT(appdata_full, v);
        float d = tex2Dlod(_DispTex, float4(v.texcoord.xy,0,0)).a * _Displacement;
        v.vertex.xyz += v.normal * d;
    }

    sampler2D _MainTex;
    sampler2D _NormalMap;
    fixed4 _Color;
    half _Glossiness;
    half _Metallic;

    UNITY_INSTANCING_BUFFER_START(Props)
        // put per-instance properties here
        UNITY_INSTANCING_BUFFER_END(Props)

        void surf(Input IN, inout SurfaceOutputStandard o) {
        fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
        o.Albedo = c.rgb;
        o.Metallic = _Metallic;
        o.Smoothness = _Glossiness;
        o.Normal = UnpackNormal(tex2D(_NormalMap, IN.uv_MainTex));
    }
    ENDCG
    }

    FallBack "Diffuse"
}


texts: Collisions on editor mode, or saving changes in play mode through script

texts:
I have a prefab that has a collider. This collider serves as an obstacle. The thing is that I want to remove this collider from all objects inside another collider defining the map limits.

This way, objects inside the game area will keep their collider, but those outside the play area get their collider removed, and serve just as decoration.

I can't use the OnTriggerEnter2D as physics are disabled in editor mode. But applying the changes in play mode is no good neither, as changes are not saved.

How can I create an script that checks if a collider is inside another collide in editor mode, so I can remove it if it does?

Or is there any way to create a script that runs on play mode and use the OnTriggerEnter to delete the collider I want, then save the changes for the editor?

Using bouding boxes is no good, as the collider delimiting the play area is an irregular polygon collider.

Any ideas?


texts: Drawing lots of tiles with OpenGL, the modern way

texts:
I'm working on a small tile/sprite-based PC game with a team of people, and we're running into performance issues. The last time I used OpenGL was around 2004, so I've been teaching myself how to use the core profile, and I'm finding myself a little confused.

I need to draw in the neighborhood of 250-750 48x48 tiles to the screen every frame, as well as maybe around 50 sprites. The tiles only change when a new level is loaded, and the sprites are changing all the time. Some of the tiles are made up of four 24x24 pieces, and most (but not all) of the sprites are the same size as the tiles. A lot of the tiles and sprites use alpha blending.

Right now I'm doing all of this in immediate mode, which I know is a bad idea. All the same, when one of our team members tries to run it, he gets very bad frame rates (~20-30 fps), and it's much worse when there are more tiles, especially when a lot of those tiles are the kind that are cut into pieces. This all makes me think that the problem is the number of draw calls being made.

I've thought of a few possible solutions to this, but I wanted to run them by some people who know what they're talking about so I don't waste my time on something stupid:

TILES:

When a level is loaded, draw all the tiles once into a frame buffer attached to a big honking texture, and just draw a big rectangle with that texture on it every frame.
Put all the tiles into a static vertex buffer when the level is loaded, and draw them that way. I don't know if there's a way to draw objects with different textures with a single call to glDrawElements, or if this is even something I'd want to do. Maybe just put all the tiles into a big giant texture and use funny texture coordinates in the VBO?

SPRITES:

Draw each sprite with a separate call to glDrawElements. This seems to involve a lot of texture switching, which I'm told is bad. Are texture arrays maybe useful here?
Use a dynamic VBO somehow. Same texture question as number 2 above.
Point sprites? This is probably silly.

Are any of these ideas sensible? Is there a good implementation somewhere I could look over?


texts: Where can I meet other independent game developers?

texts: I live in a large urban area and suspect there are groups of independent game developers that meet to discuss games and just hang out.  Are there any clubs or groups or associations or whatever for indie devs?


texts: How do you create a single/internal pre-loader for a Flash game written using Flex?

texts: I've got a somewhat large SWF which I'd like to deliver through a pre-loader so the user doesn't have to appear to wait as long. With Actionscript it's pretty easy to create an external pre-loader but doing so makes it harder to distribute my game. What methods are available for including the pre-loader in a single SWF?


texts: Can I always assume that fixed time step in Unity is reliable?

texts: I was thinking about games on low end machines or phones where the CPU would be limited. If I were to move all of my game logic into FixedUpdate() can I assume that it will always be called with the same time delta? Or would it still be worth adding code to make it take the actual time delta into account?


texts: What's the difference between bloom and emission?

texts:
In my engine, I've implemented bloom but I also want to implement emission because some models that I have come with an emission map. It sounded to me like something adjacent to bloom but I guess it's different since other engines differentiate the two like here:

Unity Emission: https://docs.unity3d.com/Manual/StandardShaderMaterialParameterEmission.html
Unity Bloom: https://docs.unity3d.com/Manual/PostProcessing-Bloom.html

and also because it seems like it's something that is done in the material shader and not in any post-processing.

What is the difference (i.e not a part of post-processing) and how could I go about writing emission into my standard material shader (I'm using a deferred rendering technique)?

UPDATE:

Alright, I've seen that emission is just something that you add on top of the fragment after you've sampled the emission map. How then, would someone get that light appear to be glowing off the surface like in Unreal and Unity and also seemingly lighting other surfaces? Is that then to do with global illumination (I currently have a baked G.I solution for static scenes)?


texts:
I'm creating a small text RPG as a way to practice python and I'm running into a question about how to load data.  The game is a wild west game, though that isn't too relevant, and I need to store lists of weapons and their properties, as well as lists of characters, scenarios, etc.  I've got a good idea of how to represent this data as classes but I'm not as clear on how to store and load the data.

My main question revolves around the relationship between data and classes.  I have read through some posts here on SE and many of them relate to storage, so I have some good information there.

When should I load that data in?  For example, the player chooses from several weapons when the game starts.  Should I load in all the weapons and instantiate all the weapon objects at that point?  Should the weapon class have the ability to show weapons from the database without instantiating them?

Thanks for any help.


texts:
I'm currently trying to generate a Minecraft like voxel terrain with 3D Simplex Noise and also want to implement caves.

I found the method of Perlin Worms in this thread, which generates really nice results.
However, I have no clue on how to generate it on a chunk by chunk basis.
Is this possible or are there any alternatives that produce a similar worm like cave on a chunk by chunk basis?

Edit: This is the problem which I don't know how to solve.

Edit2: This is the result from combining 2D Ridged Multifractal Noise with a Simplex Noise heightmap. Still needs some tweaking, but this is pretty much the result I wanted. Thanks to Byte56.


texts: OpenGL: Interpole keyframes of animated 3d object inside vertex shader

texts:
Lets say I have N vertex buffers that hold the N key frames of an animated 3d object, that was created by an application like blender. To smoothly interpolate these frames, I would like to bind two buffers to render the object with a vertex shader like this:

in vec4 inPos0;
in vec4 inPos1;

in vec3 inNormal0;
in vec3 inNormal1;

... other attributes...

uniform float time;

void main(){
    vec4 currentPos = mix(inPos0,inPos1,time);
    ... other calculations ...
}

To do this, the two buffers must be bound simultaneously, so I'd need to call glVertexAttribPointer every time, that a new keyframe should be used. This way buffer I can be bound to inPos0 and buffer I+1 to inPos1.

My question: Is this a good way to interpolate key frames? Or is there any builtin function to handle this scenario?


texts: Translating yaw degrees into 2D movement

texts:
I've been hitting my head on the wall for a while with this, and I'm almost sure I'm overcomplicating it.

I have a variable for yaw in degrees (and also pitch and roll, but those should be irrelevant). I want to turn that variable into normalized 2D movement, so the distance traveled per frame should always be a constant.

I was easily able to to workout movement when I had a fixed view direction, but translating it with yaw is what's confusing me. I've been trying a combination of converting to radians, then using cos(x) and sin(x) but it only works if I'm looking in a certain direction.


texts:
I'm making a pool game. I've separated the gameplay logic and the physics into two systems, entities and physics. Each entity holds a reference to a body which the physics system uses. The body itself holds a reference back to it's owner. When an entity collides with another entity, the Collided(Entity other) method is called on both.

What I'm trying to do now is to play a sound when both entities colliding are of a certain subclass. I'm not sure how to do that. I could do it in the Collided method, but then the sound would be played two times at the same time, since the method was called on both entities.

How do you suggest I do this?


texts: How do I pause and unpause gameobjects on is own in the scene without pressing keys in unity3d

texts:
I can't get my gameobject to pause or unpause in the scene in Unity3d.
I need the game to pause for a couple of seconds maybe longer than unpause
 by itself. Here is my script :

using UnityEngine;
using System.Collections;

public class hu : MonoBehaviour {
GameObject[] pauseObjects;
public bool isPaused;
 void Start () {

 pauseObjects = GameObject.FindGameObjectsWithTag("Player");

 }

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

  {
   if(Time.timeScale == 1)
   {
    Time.timeScale = 7f;

   } else if (Time.timeScale == 8f){

    Time.timeScale = 1;

   }
 }
}
}


texts: How can I create a fog-of-war based on character line of sight mesh and a shader?

texts:
I've a 3D-game using perspective view, through raycasting, I create a mesh that represents the line of sight of my characters.

I'm looking for a way to "darken" (think old-school Fog of War - Unexplored = pitch black, explored but not in sight = darkened) the entire area outside of this mesh, preferably using a shader?

Black grid above scene doesn't really work well with perspective camera + mesh, as they create the hole based on the camera and not the unit.
(i.e, I want the shader to act upon the characters line of sight and not the characters line of sight as seen by the camera - otherwise units can see behind walls).

Anyone have any pointers on how to achieve this?

In the following image, the white area is a mesh created by raycasting, I'd like to create a fog-of-war shader that darkens everything outside the LoS-mesh in screen-space.

The result should be similar to what you'd see in older roguelikes, I think it's called "shadowcasting", but in 3D.


texts: Circle to Circle collision, checking each circle against all others

texts:
I'm currently coding a little circle to circle collision demo but I've got a little stuck. I think I currently have the code to detect collision but I'm not sure how to loop through my list of circles and check them off against one another.

Collision check code:

public static Vector2 GetIntersectionDepth(Circle a, Circle b)
    {
        float xValue = a.Center.X - b.Center.X;
        float yValue = a.Center.Y - b.Center.Y;

        Vector2 depth = Vector2.Zero;

        float distance = Vector2.Distance(a.Center, b.Center);

        if (a.Radius + b.Radius > distance)
        {
            float result = (a.Radius + b.Radius) - distance;
            depth.X = (float)Math.Cos(result);
            depth.Y = (float)Math.Sin(result);
        }

        return depth;
    }

Loop through code:

        Vector2 depth = Vector2.Zero;

        for (int i = 0; i < bounds.Count; i++)
            for (int j = i+1; j < bounds.Count; j++)
            {
                depth = CircleToCircleIntersection.GetIntersectionDepth(bounds[i], bounds[j]);
            }

Clearly I'm a complete newbie, wondering if anyone can give any suggestions or point out my errors, thanks in advance. :)


texts:
I am developing a very simple game in libGDX for android devices. Simply, the game is a character who runs and jumps over obstacles, every time the character jumps over one of said obstacles, a counter increments and the score is displayed.

I am currently detecting the character jumping over the obstacles by creating two Rectangle objects (invisible) - one small one for the center of the character and the second is a long thin line from the center of the obstacle. I use the 'overlaps()' command to check whether or not the character has passed said line.

This issue I am having is that because I am calling to check on the overlap in my update method, it is called many times in a second and hence sometimes adds two points to the score as the small rectangles are still overlapping on the second round of checking.

I have got the sizes down to a near perfect size with the occurrence of incorrect scores at a minimum, however they do still happen.

So my question is what would a better way be to detect a line crossing / collision?


texts: how to make a fast fragment shader that converts intensity to saturation?

texts:
I have a simple fragment shader that looks like this:

#ifdef GL_ES
precision lowp float;
#endif

varying vec4 v_fragmentColor;
varying vec2 v_texCoord;
uniform vec4 u_desiredColor;
uniform sampler2D u_texture;

void main()
{
    gl_FragColor = texture2D(u_texture, v_texCoord) * u_desiredColor;
}

My goal is to take a grayscale image and apply a color to it, but maintain luminance.   There was a stackoverflow post from years ago where the poster was after exactly what I want:

https://stackoverflow.com/questions/4361023/opengl-es-1-1-how-to-change-texture-color-without-losing-luminance

The answers however are outdated (OpenGL ES 1.0) and also I am a little confused by them.  The accepted answer says to use multi-texturing, and the 2nd answer says that is "nonsense".  Regardless, the code example there is incompatible with the version of OpenGL ES 2.0 that my game is using with cocos2d v2.x.

Here are my original grayscale sprites:

With my simple shader applied and setting u_desiredColor to vec4(1.0, 0.0, 0.0, 1.0), you can see it does exactly what I don't want it to do-- it completely tints the entire image, turning everything red, including the white.

What I really want is for the darker shades of gray have the richest color, but as the sampled grayscale pixel approaches white, the colorized pixels lose saturation, where ultimately a sampled pixel of white has 0% saturation-- but a sampled pixel of dark gray would be 100% saturation.

My desired output is:

My thought was that the simplest approach would be to have my shader make the output pixel color's saturation be something like (1.0 - samplePixelIntensity). So, if the sample pixel's intensity was 1.0, that would mean 0% saturation in the output, if the sample pixel's intensity was 0.5, it would have 50% saturation.. if the sample pixel's intensity was 0.2, then it would have 80% saturation.

However, I am not very familiar with writing shaders, so I am wondering how I might construct something like this?


texts: Make players Rigibody move in direction its going?

texts:
I have my snowboard character which I am trying to fix the movement for. At the moment, The player is using transform.forward on the rigidbody to move forward. If my player turns around and faces up the hill, it keeps going no matter what. I need a way that my player goes in the direction that the gravity is pushing it, This will also mean my player can ride switch.

Also, My player is a capsule not a sphere so it doesnt roll around.

I have tried playing around with rigidbody.velocity but nothing seems to want to work.

if(Input.GetButton("Jump")){
transform.localPosition += transform.forward * Time.deltaTime * force; //force is the speed of the character
}

This is also Javascript ( yes I know i should use C# I'm learning it currently)


texts: UnrealEngine: Variables of GetGameMode are empty

texts:
I'm confronted with the following issue:

Inside the class setup for one of my actors, I'm trying to get the value of an array which is declared, instanced and successfully populated in my GameMode's BeginPlay function. I've tested it many times over with print strings. The variable is solid.

However, inside my actor, when I go through GetGameMode, and access that value (i.e. an array), it is empty. For the life of me, I can't figure out what I'm doing wrong.

Here's the screenshot of the actor's blueprint, where the array called Players Array returns empty.

Thank you for your time :)..


texts: Physics for a 2.5D platformer with a plane that curves

texts:
I'm creating a 2.5D platformer in XNA which uses 3D models that are constrained to travelling along a 2D plane (just like Trine).

To make things tricker, however, I want the 2D plane itself to be able to curve. Consider this replay of Klonoa (you only need to watch for 10 seconds): although the player was on a 2D plane, the plane itself could wrap around the side of a mountain, effectively allowing the player to travel through 3D space - all the while constrained to the regular 2D plane of a platformer.

How should the physics be approached in a game like this?

Should I use a 2D physics engine or a 3D physics engine?
Are there any physics engines actually designed with this situation in mind?
For any that weren't designed for this: what hacks or tricks will be necessary to get the physics engine cooperating with me?


texts:
Assume I have a model and I don't map the UV for this model and I just apply a texture for the model. I see that Unity will apply a single color to the model, something like this (I took the img from this topic):

I guess the default pixel color it uses maybe at UV (0, 0) or UV (1, 1), but after I test it, I see that my guess is wrong, the colors doesn't match.

color 1: the color of the model when I apply the texture to a non-UV model

color 2: the color of pixel at UV (0, 0) of the texture (color = myTexture2D.GetPixelBilinear(0.0f, 0.0f);)

I see color 1 is lighter than color 2.

So how get get the color from the texture that matches color 1?

Edit
I have tried another test:

Here is the texture (4 pixels with 4 different colors):

And I got this color when I apply this texture to a non-UV mapping model:

It seems like they use an algorithm to make the non-UV color (like blend some colors of the texture together)


texts: How much memory usage is too much in a Flash game?

texts:
I'm developing a Flash game, and I can appreciate that the memory usage is a little high for a Flash game (I think). Let's say 100+ MB.

So how much is too much when talking about memory usage in Flash games?


texts: Exported Blender model is flipped when Imported into game using Assimp

texts:
I have made a 3D game engine, and as part of this I use Assimp to load in meshes to my game. One of the meshes I load in is my terrain.obj mesh that I made and exported from Blender(Version 2.82). The issue is that I noticed in my game the terrain is flipped, for example in Blender a certain mountain will have a valley next to it, but in my game that valley and mountain are at opposite sides of the mesh from each other, as if the model in my game has had its mesh vertices flipped on an x or z axis, I don't understand why this is happening, I would assume the model I export from Blender and load into my game with assimp should be identical.

My blender export settings are as follows:

The image you see above is the default export settings, I have changed nothing except I scale the model up by x64 and untick the write materials option.

My assimp code that loads in the mesh is as follows:

Assimp::Importer importer;

        const aiScene* scene = importer.ReadFile(("../res/models/" + fileName).c_str(),
                                                 aiProcess_Triangulate |
                                                 aiProcess_GenSmoothNormals |
                                                 aiProcess_FlipUVs |
                                                 aiProcess_CalcTangentSpace);

I noticed that aiProcess_FlipUVs sounded suspect because of the word "flip", and could possibly be the issue so I commented it out and this actually made the mesh load in exactly as it is in blender, that is all the hills and valleys are where they are supposed to be and not at opposite sides of the terrain from each other. But commenting this out also made the game world (terrain mesh) load in upside down, and upon swinging my camera around completely so that it was the write way up, my look controls (up / down / left / right) are all inverted.

Therefore, does anyone know how to correctly export the mesh from Blender and import it using Assimp so that the mesh exported from Blender is identical to the mesh imported with Assimp without removing the line of code aiProcess_FlipUVs as it may have solved the flipped mesh vertices issue but my controls and game world are inverted. I am new to Blender and Assimp so there must be something I am doing wrong or have missed.


texts:
How can a file be synced across multiple devices? I am able to store the data locally using binary serialization, but the user should have the ability to access it on any device at any time.

Is this done automatically by the operating system? If the user logs into an Android phone using a Google account, would local data created by the application appear on every device that Google account is logged into or would I need to implement this functionality myself?

I have considered using a remote database, but I am not so sure that is the best option. My target platforms are Windows Universal, Android, and iOS.

The closest topic I found when I researched this is "Remote Settings" and "binary serialization", but neither help in my case.


texts: How do you move a sprite in sub-pixel increments?

texts:
Pixels are either on or off. The minimum amount you can move a sprite is a single pixel. So how you make the sprite move slower than 1 pixel per frame?

The way I did it was to add the speed to a variable and test if it had reached 1 (or -1). If it did, then I would move the sprite and reset the variable to 0, like so:

update(dt):
    temp_dx += speed * dt
    temp_dy += speed * dt

    if (temp_dx > 1)
        move sprite
        reset temp_dx to 0
    if (tempy_dy > 1)
        move sprite
        reset temp_dy to 0

I disliked this approach because it feels silly and the sprite's movement looks very jerky. So in what way would you implement sub-pixel movement?


texts: Shader that render canvas before any object

texts:
I have a canvas (in world space/3d) which is not showing to camera due to this shader which is applied to another (sphere) object.

Shader "Custom/TextureHolderCustom" {
    Properties {

        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Mask ("Mask Texture", 2D) = "white" {}

    }
    SubShader {
    Tags{"Queue" = "Transparent"}
       Cull Off
       Lighting On
       Zwrite On
       Blend SrcAlpha OneMinusSrcAlpha

       Pass
       {
       SetTexture[_Mask]{combine texture}
       SetTexture[_MainTex]{combine texture,previous}
       }
    }
    FallBack "Diffuse"
}

sphere object where my above shader is attached showing first but my canvas is not showing. I want to show the canvas first. I think i attach above shader to my canvas but it is not possible to apply m

I am zero in shader programming


texts:
I am fairly new to this world, so bear with me.

I have a grid of blocks in a top-down, 2d game written using Slick. The best way to think of it is the Pokemon world.

Right now, I am rendering all the blocks on a specific map, whether they are on the screen at the time or not.

Is there a better way to do this? My thought was maybe to try creating an image out of what I would have rendered and taking the section that fits the screen to render. I don't know how to do this, but I wanted to consult the experts before I dove into it. Thanks! ;)

EDIT

Just thought I would add that Slick has a way of dealing with clipping in specialized cases as well as the screen's viewport. See the Wiki page for more info.


texts: Drawing an isometric characters: solutions for aiming

texts:
I decided to implement an isometric 2D game for iPhone, using SpriteKit and GameplayKit, and Inkscape/GIMP as graphic tools. I prefer vectorial graphics because as a iOS programmer I am required to create multiple versions of my assets, each one of different size in order to adapt to different screen resolutions. I use GIMP just rarely, in the case that I need to adjust the images created with Inkscape.

I draw my hero using Inkscape, and this is the result:

Now since it's an isometric game, the hero needs to move in all the four directions, and he also needs to aim the shotgun to different directions. I will also need to draw the hero with more weapons, but for now I have this one. Now the question is: should I draw a new version of the hero for all the possible directions in which the shotgun could be pointed, or there is a smarter way?

The only options that come to my mind are:

Drawing the hero aiming the shotgun only in the main directions (maybe 0°, 15°, 30°, etc...)
Drawing the hero aiming in 3 directions (0°, 45°, -45°) and then finding a way to interpolate the images in order to draw the hero aiming in the intermediate directions
Using two separate layers, the top layer to draw the arms and the shotgun of the hero, and rotating it in the desired direction

Clearly the best way would be to redraw the hero for each aiming direction, but it requires too much work. If instead I choose the 3rd option I think I'd get not so much realistic results. What do you suggest? or maybe there is a smarter way?


texts:
In Flash, for example, I can place an xml file along with the binary, then if I modify some variable the game will change for everyone.

How to achieve something like that in Android? I know that for every change I make to the game, the player would need to download a new update.

But the main goal I'm looking for, is modifying a game stats without the need for recompile the entire APK.

I'm working with Haxe+OpenFL.


texts: Is my game at risk of fines due to CVAA if I don't support text-to-speech in chat?

texts:
Looking at a similar game like Among Us: as far as I know, it only has in text chat as a norm of communication. Shouldn't the game be obligated to have more options for disabilities like text to speech to meet the requirements of the US laws of CVAA?
I want to develop a game with voice and text channels, and I am concerned this may expose me to risk, because adding special things for disabilities will simply not work and it would be so costly by me.
https://www.reddit.com/r/GamerGhazi/comments/ac774q/starting_this_year_games_will_need_to_implement/
https://www.youtube.com/watch?v=0GROVGdetG4
https://www.thenerdmag.com/video-games-in-us-will-now-require-text-to-speech-and-vice-versa-to-cater-disabilities/
Neither PUBG, CSGO, VALORANT, DESTINY has text-to-speech options. Are companies ignoring the rule, or for as long as you are a big corporation with good lawyers this doesn't apply to you?
I as an indie developer with my idea won't stand a chance. What should I do?


texts: android game: how to approach mutliplayer

texts:
I'm making a single player game that is near completion, and I am already starting to think about giving the game multiplayer.  The multiplayer would basically be finding someone to play against, likely in a waiting room or just have a match-making function, and then having a pokemon style battle between the people in real time.  I think it would be relatively simple as I'm just sending information about each attack(move chosen and damage) and what it did back and forth, but I'm not sure what resources to consult for this.  I am very new to Android/Java development and really just learning as I go.

I have heard a bit about Skiller, but I'm still unfamiliar with using other SDK's and how easy it may be.  Does anyone have any suggestions as to what SDK's or methods for accomplishing this.  I currently have no money to spend on software development, but I'd like to get started on learning how to do this.


texts: Performance issues with visibility detection and object transparency

texts:
I'm working on a 3d game that has a view similar to classic isometric games (diablo, etc.). One of the things I'm trying to implement is the effect of turning walls transparent when the player walks behind them. By itself this is not a huge issue, but I'm having trouble determining which walls should be transparent exactly.

I can't use a circle or square mask. There are a lot of cases where the wall piece at the same (relative) position has different visibility depending on the surrounding area.

With the help of a friend I came up with this algorithm:

Create a grid around the player that contains a lot of "visibility points" (my game is semi tile-based so I create one point for every tile on the grid) - the size of the square's side is close to the radius where I make objects transparent. I found 6x6 to be a good value, so that's 36 visibility points total.
For every visibility point on the grid, check if that point is in the player's line of sight.
For every visibility point that is in the LOS, cast a ray from the camera to that point and mark all objects the ray hits as transparent.

This algorithm works - not perfectly, but only requires some tuning - however this is very slow. As you can see, it requries 36 ray casts minimum, but most of the time 60-70 depending on the position. That's simply too much for the CPU.

Is there a better way to do this?

I'm using Unity 3D but I'm not looking for an engine-specific solution.


texts: Can't interact with anything in UI canvas, although it was working previously

texts:
I'm working on a menu with several buttons and input fields. For a while everything was working fine, but suddenly every button and input field is not reacting to being clicked on, as if everything's been disabled.

This problem is only occurring in one of my scenes. My canvas has a graphic raycaster and my buttons have methods attached to them.


texts:
I'm wanting to use mobile devices to control a game.  I'd like to use an industry standard protocol for wifi game controllers rather than roll my own, but have been unable to find any standard.

Does there exist any industry standard wifi game controller protocol?  Is there some unofficial protocol many implement, preferably with quality Android/iPhone client implementations available?


texts: Making a successful party matchmaking system

texts:
I am currently making lots of servers and stuff like that for a game that me and a few friends are working on.
For the last few days I've been thinking a lot about how to best implement a partied matchmaking system.
Let's assume I follow two paths and consider they're problems:

HTTPS Matchmaking Server

The first problem with this is the fact that I cant send data to the client without the client first sending a request to me, therefore I see no way for the client to request matchmaking and then receive a response if it took lets say 2 minutes to find them a game.
Furthermore I need all clients in a single party to talk to me so I can communicate to every single one of them the IP address of the game server that they need to join.

Socket Matchmaking Server

The problem with this one is the fact that I can only have so many users connected to the matchmaking server at once before it crashes with likely a couple hundred sockets / threads communicating with clients. To overcome this I thought I should disconnect them and figure out some way for them to constantly check and see if they have found a match, be it through a HTTP request to a different web server or something.
Once again, I need every single player in the party to connect to my matchmaking server so they can receive the IP of the server to join which will somehow be retrieved from a server manager server which controls all game servers.

So far the way I have thought about parties in the aspect of multiplayer is the idea that every single lobby is a party and therefore regardless of the number of members, I can treat all parties the same.
Does anybody have a solution to my problem?


texts: Is it possible to emulate vector scaling with raster graphics?

texts:
I'm looking to develop a Tech Design Document with my programming team and we're now on the fence about a major 2D graphical engine decision.

What we would like to try to emulate is a more dynamic camera to allow dynamic and fluid zooming in order to have in game cutscenes and add some extra mood to the game.

Someone has already asked pretty well the same question we'd ask about vector vs raster so I'd like to ask a follow up question elaborating on that.

Considering that vector graphics can lead to trouble down the line. Could we potentially have a master sprite that is, using the metric of the discussion at the link, 10x bigger than the desired in game sprite and then actively scale it down. Then when we want to zoom in and out we can change the down scaling so that the output sprite gets smoothly larger and smaller as the 'camera' zooms?

Would it be possible to optimize such a system for a game that has a somewhat complex environment, 2 player controlled characters and around... a maximum of 10 enemies on screen at any given time?


texts:
What algorithm can I devise for a 2D drag racing game to simulate a race?

The gameplay is 2D and the camera's perspective is from the right side of the cars i.e. cars are seen from their right side in the game. This means that the cars travel in a horizontal line, from left to right till they reach the finish line.

There can be many participants in the race however the algorithm must not be affected by the number of participants in a race. It must work for any and every car given the stats of that car and other race-time driving info e.g. the time of a gear shift, good shift, perfect shift, over rev, etc.

To rephrase my question I am just asking for an algorithm which simulates the car motion/velocity along a straight line according to the stats the car has and according to the way the driver shifts up/down and revs a car.

A car can have many stats. Some I thought of including in the game are:

General stats

Top speed (mph)
Acceleration (can be represented by just a number)
Power (bhp)
Weight (lbs)
Grip (can be represented by just a number)

Tuning stats

Nitrous duration vs. nitrous power (can be represented by just a number)
Final drive (can be represented by just a number)
Gear ratio for each gear (can be represented by just a number)
Tire pressure (can be represented by just a number)

Upgrading a part will usually vary these stats.

Each participant is able to shift up or down but once the race starts acceleration is automatic. Players will be able to choose from automatic and manual acceleration in a later release; for this release the acceleration is automatic. Players must only worry about gear shifting in a race. And outside a race players must worry about changing, upgrading and/or tuning their cars.

Also, the game is multiplayer on a single system and not on a network. That is, the kind of multiplayer we have on consoles with two controllers. No LAN/WiFi networking is involved so we don't have to worry about network lags. Actually, I'm developing the game for Sifteo Cubes.

If a single player plays the game we then have AI opponents. We can have any mix of human and AI players in a race as long as their number is within the capacity supported by that race.

Right now I am trying to build a prototype so this must be all there is to the game. However, the game will keep evolving after the prototype. It will even keep on evolving after its release; in the form of updates and sequels.

Any ideas from the gamedev community to make this game better or add/remove features are gladly welcome.


texts: Making (or emulating) a "D-Pad" on a touch-screen; virtual d-pad

texts: With the proliferation of touch based devices, many lacking a true D-Pad, I'm wondering if anyone has any resources on how to emulate a D-Pad on a touch screen? I'm specifically interested in XNA and/or Android code examples.


texts: Custom Rule-Based System for Action Recognition in a Game

texts:
I want to make objects in a side project interatible with each other. For this, I want to be able to create rules so "Collisions" (Interactions) can be recognised by testing the rules. The rules should be able to reference what object does the player is trying use, in what state the object is, with which object does he try to interact with (could be nothing) and the state of this object. Maybe the rules will need to consider the state of the game as well.

With this in mind, here is my question. How could I create a rule-based system that I could use ? What design patterns could I use to create something scalable and that will allow me to add, remove and modify rules without having to regenerate the project ?


texts: Correct way to use Farseer Physics in XNA

texts:
I am using Farseer Physics for my 2D sidescroller game and I'm not sure how to proceed with it. I currently have a Sprite class (handles nothing but graphics), a GameObject class (contains specific object info like hit points), a World object which contains the list of Bodies, and a Level object which contains all of these objects.

Originally I was trying to keep track of the Sprites, GameObjects, and Bodies separately because I felt that would provide loose coupling but it quickly became a headache.

So my new idea was to add a Sprite member to the GameObject class but I'm still not sure how to maintain the Bodies because they have to communicate with GameObject.

Specifically, my issue is this: The position of the Body is used to draw the Sprite inside of the Level. In order to do that I would have to maintain a link between GameObjects and Bodies. Is this correct or is there a better way to architect my game?

If any of this is unclear please ask and I'll try to clarify. Thank you in advance for any help.


texts: OpenGL Compute Shader vs Fragment Shader device support

texts:
I have a game with massively parallelizable logic, which I intend to write calculate on the GPU (Java/LibGDX).
I am planning to implement a logic for it through a fragment shader, instead of a compute shader because I have the intuition that Fragment shaders supported on more devices, than compute shaders.
Is this even true? Given all other variables eliminated, are fragment shaders available on more devices, than compute shaders? Or in openGLES(desktop, android, ios) compute shaders are always available anyway?
What restrictions are in effect here?


texts:
It's actually a bunch of inter-related questions:

Are compressed textures (dxt5/dxt1 etc.) ever completely decompressed while going through rendering pipeline?
If the answer to the first question is true, then how is memory managed for several large uncompressed textures?
Is framebuffer any different from VRAM in modern GPU?


texts: Visually updating the position of a game object controlled by an animator controller

texts:
I have a game object that is controlled by an animator controller. In order to activate the next animator state, the user is supposed to grab this game object, and then move it from Point A to Point B.

As a test, in said game object's Update() method, I added the following line:

this.transform.localPosition += Vector3.up;

When running the game, I can see that the y-coordinate of the game object's position increases every single frame, just as intended. However, visually, the game object's position is not changing at all -- it remains in the same place all the time.

What should I do to ensure that game object's position is also visually updated?

EDIT:

Here are the properties of the animator I am using:

EDIT:

If relevant, here is the skinned mesh renderer for said game object:


texts: How to convert 3D coordinates to 2D Isometric Coordinates?

texts:
I wanted to make an isometric game which has a bouncing ball.

I assume that there is a way I can "show" a jumping motion in isometric, since it has been done before, but I was unable to find the maths/formulae which will help me depict this (Z-axis)motion.

If you know how i could do this please share.

Thank you :D

PS: If this sounded a bit confusing to you, just ask me in the comments.


texts: Possible legal pitfalls in font licensing for mobile games?

texts:
As I start to look into finding a the right font for a new mobile game I'm developing, I'm noticing that license agreements for fonts are pretty varied.  Looking on advice for what pitfalls to avoid in choosing a distinctive font for a mobile game that will initially be free, but which we eventually plan to monetize.

My main concern is with a license that may not cover our intended uses, and lead to penalties.

We're willing to spend a little money in order to COA ("cover our butts")


texts: Should I use the X-Y-plane when using an orthographic projection in OpenGL?

texts:
I'm currently at a loss rendering a tile-based 3D map with an orthographic projection in OpenGL. Imagine any isometric 3D game (using actual geometry instead of sprites).

Internally, the tiles of my map have x and y coordinates (for column and row position within the map respectively). The tile with x=0 and y=0 is the one in the "top left", the one with y=0 and x=1 the one to the right of the first tile and so on.

Since in OpenGL, the coordinate system is so that the X-Z-plane is the "ground" plane, I create the model matrix for each tile by using the tile's y coordinate for the matrix' (or position vector's) z component. I then set up an orthographic "camera" by using glm::ortho().

This seems to work fine at first, but I quickly ran into clipping issues when trying to render larger parts of the map. I assume this is due to the fact that the orthographic projection clips on z. A quick and dirty attempt of having the map in the X-Y-plane confirmed this, as I didn't have clipping issues then.

Now, I'm not sure what's the best approach here?

Change the code so the tiles are being layed out in the X-Y plane? In that case, it seems as if I would have to remember to rotate every single object around x accordingly, which seems wrong.
Do I need to set up the orthographic projection manually to use Y as the clipping plane? Is that even possible? I think OpenGL always uses z for clipping, right?
Some other approach? I think I'm lost in coordinates and matrices, really.

I assume this is a common problem with a well-known solution, so I'm hoping to learn about that before I go ahead, change a lot and then learn I did it the wrong way...


texts: OpenGL ES 2.0: Vertex and Fragment Shader for 2D with Transparency

texts:
Could I knindly ask for correct examples of OpenGL ES 2.0 Vertex and Fragment shader for displaying 2D textured sprites with transparency?

I have fairly simple shaders that display textured polygon pairs but transparency is not applied despite:

texture map contains transparency information
Blending is enabled: glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

My Vertex Shader:

uniform mat4 uOrthoProjection;
uniform vec3 Translation;

attribute vec4 Position;
attribute vec2 TextureCoord;

varying vec2 TextureCoordOut;

void main()
{
    gl_Position = uOrthoProjection * (Position + vec4(Translation, 0));
    TextureCoordOut = TextureCoord;
}

My Fragment Shader:

varying mediump vec2 TextureCoordOut;
uniform sampler2D Sampler;

void main()
{
    gl_FragColor = texture2D(Sampler, TextureCoordOut);
}


texts: 8-bit Game: To pre-scale images, or post scale my Cocos2d scene. Which is the better approach?

texts:
I'm wanting to develop a game with an 8-bit feel. Since this game is mostly for my personal enjoyment, I've set a requirement that I want my game to have an 8-Bit feel to it that is most similar the 8-Bit systems of yore, on a lovely CRT TV.

This is also my first Cocos2d project so I don't know which approach is better.  I'd like the general advice of the community on how to render my game.  I've come up with two possible approaches.  Please advice which is better.

Approach #1

Create images for backgrounds and sprites using the "8-bit" resolution of my game.  After I'm done making an image, I scale it up and I save two variants; the standard sized one and the "@2x" variant.

When I render the game, everything looks very 8-Bit but I will still need to apply mathematics to every animation so that my virtual pixels always shift by 4 or 8 pixels (for retina displays) on the screen when they move.

This approach doesn't sound difficult but it seems like it could become a bit annoying and tedious.

Approach #2

Generate all content in my image designer at the exact resolution of my virtual screen.  When I generate my scenes in Cocos2d, I generate them all with the "virtual resolution".  When the scene is displayed on the iOS screen, I scale the entire scene up to the resolution of the device.

I think this could be the simplest approach since all of my sprite and background movement mathematics can just behave as normal.  However, I'm not sure that this approach is even possible.  Furthermore, I know that within iOS, graphic scaling has an anti-alias affect that gets applied to graphical objects as they scale-up.  Obviously, I'd want to cut this affect off and just use a "nearest neighbor" algorithm to scale-up my scene.

If I can't cut off the scaling anti-aliasing, I don't want to use this method.  However, if I can setup such a rendering system, I think this approach would be best.

So, my question is simple.  Can I use approach #2 and, if so, which approach is really easier to work with in Cocos2d and iOS?


texts: What elements make a game machinima-friendly?

texts:
What types of things should a game have in order to make it machinima-friendly? I imagine that a spectator mode helps, but are there other important elements? Perhaps support for mods?

Are there any example of games that are known for being especially easy to make movies with?


texts: How can I allow players to draw decals for their avatar and items?

texts:
I want the player to be able to draw a simple symbol, even if it's pixelated black or white, that their character can have on their weapons, armour, forehead or even markers and monuments. How would I go about that, if I want to do it?  Better if the suggestion is C#/Unity-specific.

PS: The game would be a turn-based, square grid RPG, maybe somewhat like Dofus, but it should probably be in 3D to allow for more flexibility.


texts: How to keep consistent between image quality, device range support and final size of the game?

texts:
I am developing a game with the LibGdx framework, but I would like to discuss a more theoretical question.

Criteria:

I want to support as many devices as possible for my game (phones and tablets)
I want to see the same image quality for each device (it is a different topic about scaling or aspect ratio)
I want my game to not freeze (support devices with a low amount of RAM).
I want to make my game as small as possible.

For example, let's take a look at the Samsung Galaxy Tab S4 10.5. It has a resolution of 2560x1600.

If I take this resolution as standard, and make all other textures dependent on this background resolution, it will make a huge size for images. Also, It won't work on slower and older devices with small resolution. (800x480, etc). So it does not satisfy criteria #1, #2 and #3.

I suppose I can make different quality versions of the same images for different devices. It may affect only the #4 criteria, but it's not as critical as others.

What strategies do you guys use to satisfy the above criteria?


texts: How to do 1.5x scaling for pixel art where only one dimension has to scale?

texts:
I'm working on a point and click adventure game where the top third of the screen is a 16:3 single piece background with sprites on top. The width has to be edge to edge. It can't be cropped because the screen doesn't move.

The bottom of the screen will be one where you can interact with objects. Think Papers, Please. It can be any dimension, it can be 16:6 for 16:9 screens and 16:9 for 4:3(16:12). The objects on the bottom screen can be scaled imperfectly so say a notebook that is 64x64 on 720p can be 2x scaled to 128x128 on 1080p. It will only be compared to other 2x scaled objects so it won't look out of place.

Shades of green indicate areas where light green can be stretched to fill, orange indicates the area that I don't know what to do with. Black can't be scaled 2x because it wouldn't fit and it can't be cropped.

Am I still forced to make 2 different sets of art if I want it to look right?


texts: Generating shaders from fragments / HLSL Dynamic Linking in older shader models

texts:
In shader model 5 is a feature called dynamic linking which separates hlsl fragments by using interfaces and their methods implemented in classes.

I don't have any experience with this technique, my program uses about 10 shaders (10 separated files *.hlsl) and there are some identical parts in different shaders. So it will be good for me to separate a common logic (light for example) to its own file and just use it from other shaders.

I was always fascinated by modern game engines and their development kits capable of composing these shader fragments together by simple clicking in some internal editor. So a developer can create very complex scenes this way - choose materials, lights, particles, animations, etc. and it's very cool and productive I guess. If I omit some graphical editor and a sophisticated logic behind it, it is pretty what I want to achieve, isn't it? Just on a code level.

So with hlsl's dynamic linking in shader model 5 I have some idea how it can be done, but what about older shader models? When there was no shader model 5, what technique did engines use?


texts: Is there a way to clear a libGDX Pixmap? Or is the only way to dispose it and create a brand new Pixmap?


texts: How do I use playerprefs to make ui slider keep the sound settings?

texts: I have not use playerprefs before, I want to know how to keep the change of the audio when the player change it throughout the game.


texts: Determining if something is on the right or left side of an object?

texts:
I have a character in a 3D world which is facing an arbitrary direction on a flat plane, the player can click on the left or right side of the character and based on which side is clicked on a different action happens.

How can I determine which side the click occured on? Obviously for straight on ahead (0,0,1) I can simply use the x coordinate of the click point to determine if it's the left or right hand side, but what about other cases?


texts: Acceleration structure for AABBs with many overlaps

texts:
I have large number of AABB in 2D. They are created around complex polygons and I use them as pre-test before real point in polygon test (which is expensive).
I was thinking of creating acceleration structure, since testing hunderds of AABB is not ideal even with a simple point-in-AABB test.
What acceleration structure is considered best for this, since AABBs may overlap a lot (however, polygons do not). See the picture with a simple small example.

I was looking at BVH, but for them overlaps should be minimal. Another solution are kD-trees, however the overlaps are problem as well. QuadTree is similar to kd-Tree.


texts: How to properly copy/paste object between folder?

texts: I'm new to unity and found some simple task can't be done here. For example in projects tab, i want to copy/paste a script from script folder to other folder. I should be able to simply select the script, press ctrl C , go to target folder , press ctrl V to paste but nothing happen. So for now , i have to duplicate it then move it to new folder then rename it. But why can't i do simply copy and paste ?


texts: Alternatives to NSMutableArray for storing 2D grid - iOS Cocos2d

texts:
I'm creating a grid-based iOS game using Cocos2d. Currently the grid is stored in an NSMutableArray that contains other NSMutableArrays (the latter are rows in the grid). This works ok and performance so far is pretty good. However the syntax feels bulky and the indexing isn't very elegant (using CGPoints, would prefer integer indices). I'm looking for an alternative.

What are some alternatives data structures for 2D arrays in this situation?

In my game it's very common to add and remove rows from the bottom of the grid. So the grid might start off 10x10, grow to 17x10, shrink to 8x10 and then finally end with 2x10. Note the column count is constant.

I've consider using a vector<vector<Object*>>. Also I'm vaguely aware of some type of "fast array" or similar offered by Cocos2d. I'd just like to learn about best practices from other developers!


texts: Working out of a vertex array for destrucible objects

texts:
I have diamond-shaped polygonal bullets.  There are lots of them on the screen.

I did not want to create a vertex array for each, so I packed them into a single vertex array and they're all drawn at once.

| bullet1.xyz | bullet1.rgb | bullet2.xyz | bullet2.rgb

This is great for performance.. there is

struct Bullet
{
    vector<Vector3f*> verts ; // pointers into the vertex buffer
} ;

This works fine, the bullets can move and do collision detection, all while having their data in one place.

Except when a bullet "dies"

Then you have to clear a slot, and pack all the bullets towards the beginning of the array.

Is this a good approach to handling lots of low poly objects? How else would you do it?


texts: How to access arrays of prefabs and other properties through the inspector in a given hierarchy

texts:
The script below is added to an empty game object WeaponGroup, which can be populated using the editor. I have made a new game object WeaponGroups which should have a script SetupWeaponGroupsScript. How can I transfer the properties below so that each WeaponGroup (SetupWeaponGroupsScript will have an array of WeaponGroup objects) is setup in a way similar to what is done below, so that I make the SetupWeaponsScript properties hidden to the inspector and populate them through SetupWeaponGroupsScript?

public class SetupWeaponsScript {

// Here's our tuple combining a weapon prefab and a direction.
[System.Serializable]
public struct DirectedWeapon {
    public WeaponScript weapon;
    public WeaponScript.Direction direction;
}

// The prefabs array is now this tuple type.
public DirectedWeapon[] weaponPrefabs;
public WeaponScript[] weapons;

void Start ()
{
    weapons = new WeaponScript[weaponPrefabs.Length];

    for (int i = 0; i < weaponPrefabs.Length; i++)
    {
        // Using typed Instantiate to save a GetComponent call.
        weapons[i] = Instantiate<WeaponScript>(weaponPrefabs[i].weapon);
        weapons[i].weaponDir = weaponPrefabs[i].direction;
    }
}
}

In other words I'd like to have the following hierarchy in the editor:


texts:
I am currently developing a voxel game and I had recently noticed that the game from startup is at around 2GB of memory. Currently I am rendering 14 x 14 chunks as shown:

I did a profile on the game and I noticed that the function call glfwSwapBuffers(...) takes 9,964 m/s to run (76.4%) and as the program's life continued it kept growing. The next function is glDrawElements() which takes 849 m/s to run (8.49%). I am unsure what is causing the bottleneck.

Going back to the high memory usage issue there are two things that seem to be causing high memory. As explained in this thread here: Voxel Game - Lag when camera is inside of the terrain
I generate the terrain once and since I posted that question, I create a mesh for each chunk made up of the visible vertices. After that I send each chunk entity to my renderer and it is drawn from these two blocks of code.

    for(Chunk[] chunks1D: chunks)
    {
        for(Chunk chunk: chunks1D)
        {
            //Model matrix
            Matrix4f modelViewMatrix = transformation.getModelViewMatrix(chunk.getEntity(), viewMatrix);
            shader.setUniform("modelViewMatrix", modelViewMatrix);
            //Render mesh
            shader.setMaterialUniform(chunk.getEntity().getMesh().getMaterial());
            chunk.getEntity().render();
        }
    }

which calls this

public Matrix4f getModelViewMatrix(Entity entity, Matrix4f viewMatrix)
{
    Vector3f rotation = entity.getRotation();
    Vector3f position = entity.getPosition();
    float scale = entity.getScale();
    modelMatrix.identity().translate(position).
        rotateX((float)Math.toRadians(-rotation.x)).
        rotateY((float)Math.toRadians(-rotation.y)).
        rotateZ((float)Math.toRadians(-rotation.z)).
        scale(scale);
    //Copy view matrix
    Matrix4f currentView = new Matrix4f(viewMatrix);
    modelViewMatrix = currentView.mul(modelMatrix);
    return modelViewMatrix;
}

and this

public void render()
{

    //Bind the VAO
    glBindVertexArray(vaoID);
    glEnableVertexAttribArray(0); //Vertex Data
    glEnableVertexAttribArray(1); //Colour data
    glEnableVertexAttribArray(2); //Normal data

    //Draw the vertices: mode: Triangles, count, type: integers, offset
    glDrawElements(GL_TRIANGLES, numVertices, GL_UNSIGNED_INT, 0);

    //Restore state
    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);
    glDisableVertexAttribArray(2);
    glBindVertexArray(0);

}

From the profile I found two sources of high memory, one for Matrix4f which is due to the getModelViewMatrix(...) function (the memory usage grows over the programs lifespan) and another for float and float[] from the genChunkMesh(...) function as shown in my other thread (Voxel Game - Lag when camera is inside of the terrain) which is called once when a chunk is loaded. It seems as if for both cases that Matrix4f, float[] and float instances are being created by they are never released from memory. :/ I have tried looking everywhere for a solution but I can't find one... I feel my game is optimised well enough for what is being rendered and these problems shouldn't be occurring.

tldr: Simple voxel terrain gen requires high amounts of CPU and the culprit is glfwSwapBuffers which takes 9,694 m/s to run (grows over time). High memory usage also from Matrix4f, float and float[] (floats of which seem to be retained from chunk mesh generation) objects causing the game to use ~2Gb of memory from startup (14 x 14 chunks) each chunk contains its own mesh (containing a VAO which has all of the chunks visible vertices, normals and colours) and two 3D int arrays one for the chunk's blocks and one for the chunk's visible blocks (16 * 16 * 128) each storing the block ID at that location.


texts: Get OnMouseDown to work with a 2D Polygon Collider

texts:
I'm having a hell of time getting a 2D polygon collider to register a mouse click. I've attached images and code to show where I'm at. I cannot get the click to work.

Ultimately, the thing I'm trying to achieve is to just set the area defined by the collider to be clickable rather than the entire image sprite.

What am I doing wrong here? Need help!

I've defined the collider:

I've setup the components for my image:

using UnityEngine;
using System.Collections;

public class MouseClick : MonoBehaviour
{
    void OnMouseDown()
    {
        Debug.Log ("Clicked the Collider!");
    }
}


texts:
I just started with andengine, so this maybe gonna be silly question.
How to make my sprites more smooth while I rotate them? Or maybe it because this is screenshot from tablet?

Thanks JohnEye it works:

Just need to change my BitmapTextureAtlas from:

BitmapTextureAtlas carAtlas = new BitmapTextureAtlas(this.getTextureManager(),100, 63);

to:

BitmapTextureAtlas carAtlas = new BitmapTextureAtlas(this.getTextureManager(),100, 63, TextureOptions.BILINEAR);


texts: How to use collision masks and overlap_area in pygame?

texts:
So, I've been prototyping a game, and I've been using sprite collision, and it's not cutting it any more. I read up on the documentation about masks and overlap area: https://www.pygame.org/docs/ref/mask.html#pygame.mask.Mask.overlap_area

How exactly do I use this? The documentation says "This can be used to see in which direction things collide, or to see how much the two masks collide. An approximate collision normal can be found by calculating the gradient of the overlap area through the finite difference."

I don't quite follow this description. How can I tell the direction of the collision? What does the return value actually contain? How would I implement this collision for two Pygame Sprites with images and transparency?

Is there a more in-depth explanation (preferably with sample code) anywhere? I can't find anything more detailed than the documentation.


texts:
I want to include a feature in my game that allows me to host raw 3d models (.fbx/ .obj/ etc., not AssetBundles) on a server.
The game should download these files, save them to the device and load them into a scene.
I want to support multiple file formats, so writing my own parser is not an option!

First idea:Use the WWW class to load the model data, save it as a String in the player prefs, and load it if requested.(the last part is the problem)

Second idea:Use the WWW class to load the model data, extract the jar file containing StreamingAssets folder to the sdcard. Writing the model data into a new file in this directory. Creating a new ZIP..ah...JAR archive from the folder and replacing the old .jar file.Of course I would need an Android Plugin and a archive java library for that. Then the Models will be loaded from the Ressources.(this is a pretty weird idea and cannot be the right way)

Do you know, if that works?Has anybody ever done something like that?

UPDATE 1:

I tried to use the obj loader from samed-tarık-Çetİn's comment, but I got this error:

ArgumentNullException: Argument cannot be null.
Parameter name: key
System.Collections.Generic.Dictionary`2[System.String,UnityEngine.Material].get_Item (System.String key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:136)
GeometryBuffer.PopulateMeshes (UnityEngine.GameObject[] gs,     System.Collections.Generic.Dictionary`2 mats) (at Assets/OBJ/src/GeometryBuffer.cs:145)
OBJ.Build () (at Assets/OBJ/src/OBJ.cs:236)
OBJ+<Load>c__Iterator0.MoveNext () (at Assets/OBJ/src/OBJ.cs:63)

Replacing line 145 in GeometryBuffer.css with gs[i].GetComponent<Renderer>().material = new Material(Shader.Find("Standard")); did resolve the runtime error and a Material, OBJ (Mesh Filter) and Mesh Renderer Component have been added, but it still show a model.

UPDATE 2:
I am behind a proxy so loading the model from the web didn't work.
Loading .obj files from file:///<path to obj> works perfectly fine though.


texts: Best form of audio compression / packing

texts:
Currently in my game I have a large amount of sounds and am getting to the point where I need to find a way to reduce the overall size of the sounds to save space when I deploy. I was wondering if there are any techniques for audio compression / packing like there is for graphics pack (DXT)?

Thanks in advance

Edit: The engine that I am using only supports .Wav files so I will have to be able to decompress audio back to a .Wav format

Edit 2: The majority of the files that I will need to compress and decompress will be sound effects and background tunes which can lose some quality. Any solution preferable needs to be open source for this.


texts:
I'm currently working on a 3D game. My game have like 10 NPC's and a really small world.
But if I want to have a larger world with lots of NPC's? I think it's not a good idea to update and check collision with NPC's that is far far away from the hero.

So any tip on how to handle things that are outside the hero's sight.


texts: How to procedurally generate Mountains that Looks more natural

texts:
My Terrain was looking a bit plain so to freshen it up a bit I decided to add mountains to the terrain generation. Unfortunately the Mountains don't look very natural with the surrounding terrain.

I generate the mountains currently by:

1.start at a random spot on the map that is above sea level

2.raise that to the highest point and have surrounding blocks staircase up to it using a radial noise pattern

3.move a certain number of blocks away and repeat until the mountain reaches the coast

here is the code for extra clarification:

void generateMountains()
{
    //Find Starting Location
    int startingX = Random.Range(0, grid.columns);
    int startingY = Random.Range(0, grid.rows);
    RidgedMultifractal noise = new RidgedMultifractal();
    noise.Frequency = .01;
    noise.OctaveCount = 8;

    while (grid.FindTile(startingX, startingY).elevation < -3)
    {
        startingX = Random.Range(0, grid.columns);
        startingY = Random.Range(0, grid.rows);
    }
    //createMiddle highest point
    Grid.Tile middlePoint = grid.FindTile(startingX, startingY);

    //how many mountainBlocks to be generated
    while(middlePoint.elevation > SEALEVEL)
    {
        var tilesAroundMid = grid.getNeighborhood(middlePoint, false, 25);

        for (int i = 0; i < tilesAroundMid.Count; i++)
        {
            //setting the distance away from mid
            float distanceToCenter = Mathf.Sqrt(Mathf.Pow(middlePoint.x - tilesAroundMid[i].x, 2) + Mathf.Pow(middlePoint.y - tilesAroundMid[i].y, 2));

            if (tilesAroundMid[i].elevation + Mathf.RoundToInt(((float)noise.GetValue(tilesAroundMid[i].x, tilesAroundMid[i].y, .1) * 10 - distanceToCenter) + 15) >= tilesAroundMid[i].elevation)
            {
                tilesAroundMid[i].elevation += Mathf.RoundToInt(((float)noise.GetValue(tilesAroundMid[i].x, tilesAroundMid[i].y, .1) *10 - distanceToCenter) + 15);
            }
        }
        middlePoint = grid.FindTile(middlePoint.x + Random.Range(10,15), middlePoint.y + Random.Range(10,15));

    }

}

How would I change my code so that the mountains generated looks more natural and realistic with the surrounding terrain?


texts: How to find a free patch of area in a tiled map?

texts:
I've been trying to formulate the question and try to find some information on Google, but didn't managed to, so here it is...
We've got a nice tropic-themed game that is about to be released soon, that uses a tile map and an A* pathfinding is utilized and everything works flawlessly.

Until when it comes to the point where I need to somehow find unoccupied patch of area on the map that matches certain criteria, so that I can guide the player to place their just bought map objects on.

The map is 200x200 tiled map and it holds instances of each tile that determine two things - if it is occupied and if it is a water or a ground tile. These are already used for the A* pathfinding algorithm that I've put into the game.

Let's say the player buys a water-placible map object from the store and the map object occupies 5x5 tiles for instance. I need to guide the player to a free patch of water tiles where they can place that map object.

Any guidance and/or reference to such algorithms will be highly appreciated :) Thanks

EDIT: It turns out that I need to find such a patch as close as possible to given point (centre of viewport for instance). This will improve user experience


texts: Camera movement and threshold not working

texts:
I have a platformer that is in progress, part of this has a camera which I only want to move when the character moves out of a certain threshold, to try to accomplish this I have the following if statement:

 if(((Mathf.Abs(target.transform.position.x))-(Mathf.Abs(transform.position.x)))>thres){
            x = moveTo(transform.position.x, target.position.x, trackSpeed);
            }

in unity/c#. In pseudocode it means

if((absolute value of player x) - (absolute value of camera x) is greater than the threshold){
move
{

however this does not seem to work correctly. it appears to work for the first couple of times the threshold is reached, however the distance between the camera and the player has to increase every time for the camera to move. I do not believe the movement of the camera is the problem, however the code for it is as follows:

private float moveTo(float n, float target, float accel) {
    if (n == target) {
        return n;
    }
    else {
        float dir = Mathf.Sign(target - n);
        n += accel * Time.deltaTime * dir;
        return (dir == Mathf.Sign(target-n))? n: target;
    }
}

}


texts:
How can I retrieve the camera's world-space position from its view matrix?
The only answers I've seen to this question suggest the translation is in the last row/col but this wouldn't work since the matrix contains [x (dot) right, y (dot) up, z (dot) look]


texts: What files and libraries do I need for OpenGL and controls

texts:
I am starting a 3D game, however I find OpenGL file system very confusing. OpenGL package doesn't have  one file, other package doesn't have another, so I need a summary of what files do I need to start playing with 3D. It would be good if it included keyboard and mouse controls.

Shortened question: Where can I get all files for OpenGl 4.0 and integrated controls libary?


texts: High quality graphics but low apk size - How?

texts: So I have been playing this app that has so many high quality graphics with some 3d models and tons of levels and it is only 70mb in size.My app that has only 2 pictures is about 20 mb in size lol..Why?


texts: How to see which mouse button was pressed (Unity Input System)

texts:
I have switched my game to use the new Unity Input System, and I want to know which mouse button was pressed when an action is called.
Here's how it's set up:

Whenever one of these three mouse buttons are pressed, the MouseButtonClicked action will fire. I want to somehow know which one of these buttons was pressed from this single action, rather than making 3 seperate actions for 3 seperate mouse buttons.
I have tried reading the values from InputAction.CallbackContext context but I can't seem to get a proper value from the mouse button which was pressed.
How can I do this?


texts: Effort of impementing interpolation in networked Asteroids

texts:
Questions:
When we draw with interpolation, where should the collision detection code be?
Is it worth implementing interpolation in the following situation?

This is for Scrolling Asteroids. I have my game working at the moment without interpolation. It does physics updates using fixed step time deltas. The frame display rate is decoupled from this. So, it might be doing 40 Physics updates per second and 75 frame draws per second. Up until now, it is in the physics update routine that I do the collision detection and response. Your ship can collide with a rock. Your photons (bullets) can collide with a rock.

Now I am considering improving it to use interpolation as per all the good articles recommend:

http://www.koonsolo.com/news/dewitters-gameloop/

and

http://gafferongames.com/game-physics/fix-your-timestep/

So when this is implemented, I might be making the following calls:

update(dt)
draw(0.24)
draw(0.64)
update(dt)
draw(0.24)
draw(0.76)

The floating point numbers shown are examples of actual calculated interpolation value i.e. the proportion of the physics update that is complete at the time the frame is being drawn. I am going to have to change the draw code to draw the objects at a fraction of the distance between their previous and current value positions and rotations. That is yet to be done.

Question: Will I also have to do move my collision detection code out of the update routine and into the draw routine, seeing as I will be drawing these interpolated frames ?

Bear in mind, my highest priority goal is to make this networked: multiple player ships on as large a Universe as possible. So a physics update solution that is compatible with the networked game that is required. Is the interpolation worth the effort? Right now. I rarely if ever see a problem with smoothness. If I reduce my physics updates to 25 per second which I have only done as an experiment then it is a bit jerky. But the game easily runs at higher rates than that so there may never be a problem.

So the two questions:

Collision detection where?
Is introducing interpolation worth the
effort or should I proceed to networked version straight away?

Thanks in adance:


texts: Combining Minecraft and Dwarf Fortress: Simulating autoplay in a pseudo-infinite procedurally generated world?

texts:
One of the interesting things about Dwarf Fortress (and other procedurally generated games like Civilization) is that the game simulates multiple AI factions interacting with each other over time (what might be termed "autoplay") to generate an evolving world which changes over time, even whilst the player is playing the game.

On the other hand, simulating all the factions simultaneously is surely going to become a bottleneck as the map grows. With a bigger map and more factions, the performance requirements become exorbitant. Minecraft gets around this problem by simply storing the inactive chunk in memory as-is as soon as the player leaves the area. The minecraft world is a static, never-changing place. When a player comes back from a trip, the chunk is exactly as he left it. No world evolution occurs. Everything is always the same.

The most straightforward approach to this, which is to just to make chunks remain loaded in memory even after the player is no longer in them, has the same performance issues as mentioned earlier - as the player moves across thousands of blocks, you will sooner or later run into computation limits. Moreover, this does not solve the general problem of faction simulation - factions can expand or contract through many chunks, whereas keeping one chunk loaded in memory would not affect its neighboring chunks, so that doesn't quite achieve the same effect as autoplay.

The "solution" that I thought of is to come up with a closed form formula that simulates autoplay somehow. That is, a function f(time,coordinates), such that given the time and and coordinates of a block, will tell you what state that block should be in. The problem with this is that this assumes a truly predeterministic world evolution, in which players have control over only their local chunk and no others. In other words, no butterfly effect. Furthermore, when a player leaves a chunk, he has made some changes to it, but the function cannot take those changes into account when computing the state of the block the next time the player enters it, in other words all changes that the player made to the block are lost as soon as he leaves. This is obviously not ideal.

Am I asking for something impossible?


texts: Character movement resetting x & y position in HTML5 game

texts:
I have an HTML5 game I'm working on and I'm at the point where I'm trying to make the character move.  For the most part, the character(A rectangular square) is moving, but it's not moving from its starting position.  Instead, when I hit the move key the character's x position and y position are reset to 0, 0.  My question is, why is the character's position being set to 0, 0 before it starts moving?

I've included a link to the dropbox with the project so it's easier to see what's going on, but here's the movement script for reference.

initMap.js Script, lines 81 - 92

case "Player":
    gameObjectsLayerCtx.fillStyle = "rgb(0, 0, 0)";
    gameObjectsLayerCtx.fillRect(xPos, yPos, destWidth / 3, destHeight / 3);
    window.onkeydown = function(ev){
        var key = ev.key;
        if(key == "w"){
            yPos += 5;
            gameObjectsLayerCtx.clearRect(0, 0, gameObjectsLayer.width, gameObjectsLayer.height);
            gameObjectsLayerCtx.fillRect(xPos, yPos, destWidth / 3, destHeight / 3);
        }
    };
    break;

Project

The script is the initMap.js script and the movement functionality is from lines 81 - 92

The character's starting position

Where the character moves to when pressing the move key


texts:
I have a canvas with two buttons in it and I want to enable it on the button click, but when I try to enable it, it doesn't work. However, when I try to disable it on button click it does work.
Here is my code:

 public GameObject mycanvas;
  public  void onClick() {
     mycanvas.SetActive(true);
}

Can someone please tell me what I am doing wrong?


texts: How to effectively/properly use IntPtr in ImGui.NET

texts:
How should I go about using methods that take an IntPtr in the .NET Dear ImGui wrapper, ImGui.NET?
For example, ImGui.SetDragDropPayload takes a type string, an IntPtr, and a size unint. When I ImGui.GetDragDropPayload() I don't seem to be able to just grab the type that I set (I can only query if it is a certain type)... And I'm not sure how to use IntPtr to represent an object in my game engine, which I presume is one of the use cases this parameter is intended for.
I feel like there is a fundamental paradigm that I'm not understanding here, as using IntPtr to hold game data seems like a common thing in ImGui.NET. I've done some looking into how to represent objects as IntPtr in .Net, but this seems to point me to creating IntPtr for use in WinApi functions and I haven't been able to get anything working yet or understand how I should be approaching this...
As you can probably tell, I'm also entirely unfamiliar with the C++ Dear ImGui, so this makes things even trickier for me to get my head around. Any thoughts would be appreciated!
Edit:
Here's an example of how I'm using it right now. As I mentioned, I don't know how to use the payload propertly, so I'm just using a separate static object to represent what's currently being dragged. Then checking to see if the payload's NativePtr is null or not. It seems to work, I think, but is obviously not ideal:
private static unsafe void SubmitTestWindow()
{
    ImGui.Begin("Test");

    string[] items = new string[] { "hello", "world", "how", "are", "you?" };

    for (int i = 0; i < items.Length; i++)
    {
        ImGui.Button(items[i]);
        if (ImGui.BeginDragDropSource())
        {
            ImGui.Text(items[i]);
            ImGui.SetDragDropPayload(typeof(string).FullName, IntPtr.Zero, 0);
            draggedItem = items[i];
            ImGui.EndDragDropSource();
        }
        if (ImGui.BeginDragDropTarget())
        {
            var payload = ImGui.AcceptDragDropPayload(typeof(string).FullName);
            if (payload.NativePtr != null)
            {
                Console.WriteLine("Dropped " + draggedItem + " onto " + items[i]);
                draggedItem = null;
            }
            ImGui.EndDragDropTarget();
        }
    }

    ImGui.End();
}


texts: MobileSingleStickControl Elements Disabled Unity

texts:
I cloned my Unity project on other system. Elements attached to canvas(a prefab) are disabled and when I select an element in inspector, for example Background (shown in screenshot) it is showing weird stuff.

I suspect that some file has not been pushed that contains data related to assets, since inspector is showing improper values. For example; Rect Transform showing instance ID instead of showing X, Y value (please refer screenshot).

Please suggest what can be missing in project that hasn't been pushed or loaded properly by Unity? Thanks.

Note: I am using Unity v5.0.1. Cloned project made in Windows onto my mac system.

EDIT

I upgraded unity. Now elements are similarly disabled in prefab in my original project with normal inspector mode, displaying correct components and values. See screenshot below. No element is rendering and canvas is showing empty like the first screenshot.


texts: Why is Instantiate spawning too many clones?

texts:
just at a bit of an impasse with this one if anyone can help.

I am developing an endless runner, and I am trying to instantiate my obstacle prefabs by having my player go through a trigger which activates an instantiation. The problem I'm having is that when the player goes through the trigger, my code seems to instantiate multiple prefabs at a time. I'll post screenshots and my code to illustrate this better.

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

public class ObsGenerator : MonoBehaviour
{

    public GameObject spawnTrigger;
    public GameObject Player;
    [SerializeField] private List<Transform> obstacleList;

    public Transform spawnLocation;

    public void OnTriggerEnter2D(Collider2D Player)
    {
        if (Player.CompareTag("Respawn"))
        {
           // for (int i = 0; i < obstacleList.Count; i++)
            {
                spawnObstacle();

            }
        }
    }

    public void spawnObstacle()
    {
        for (int i = 0; i < obstacleList.Count; i++)

            if (obstacleList.Count > 0)
            {
                Transform chosenLevelPart = obstacleList[Random.Range(0, obstacleList.Count)];
                Instantiate(chosenLevelPart);
            }
        }
    }

Really appreciate anybody's help!


texts: Unity 2018 can't find android sdk path on mac osx

texts:
I use osx catalina 10.15.5 and run couple version of unity 2019 without problem. but when i download unity 2018 (2018.4.24f1), it couldn't find android sdk.
the default location for the sdk is :

/Applications/Unity/Hub/Editor/[unity
version]/PlaybackEngines/AndroidPlayer/SDK

for example, unity 2019.4.24f1, the default location for the sdk is here :

/Applications/Unity/Hub/Editor/2019.4.24f1/PlaybackEngines/AndroidPlayer/SDK

and everything is working fine.
But for 2018 version, the android build support already install for this version, but there's no SDK folder :

/Applications/Unity/Hub/Editor/2018.4.24f1/PlaybackEngines/AndroidPlayer/
... NO SDK FOLDER HERE

Does anyone can help to fix it ?
Thanks


texts: How to implement constant velocity and collisions without gravity

texts:
I am learning game development and i am trying to implement the AndEngineBox2D Extension such that my character is always moving at a constant velocity, when it collides with a body sprite, the character automatically changes direction (is deflected) and moves in the new direction until another collision has happened and the same is done repeatedly.

My Question:
Is it possible to implement the changes in trajectory  with AndEngineBox2D's physics world or i have to to handle it manually is java code.


texts:
Here's the thing. I am making a 3D top-down game about cars on the road. Right now I have different-colored cuboids representing cars. They are position-locked in Y and rotation-locked on all three axis (axises? Sorry, English isn't my first language). The cuboid in question is controlled with the following code:

using UnityEngine;
using System.Collections;

[System.Serializable]
public class Boundary
{
    public float xMin, xMax, zMin, zMax;
}

public class PlayerController : MonoBehaviour

public float speed;

public Boundary boundary;

void FixedUpdate ()
{
    float moveHorizontal = Input.GetAxis("Horizontal");
    float moveVertical = Input.GetAxis("Vertical");

    Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    GetComponent<Rigidbody>().velocity = movement * speed;

    GetComponent<Rigidbody>().position = new Vector3
        (
            Mathf.Clamp (GetComponent<Rigidbody>().position.x, boundary.xMin, boundary.xMax),
            0.0f,
            Mathf.Clamp (GetComponent<Rigidbody>().position.z, boundary.zMin, boundary.zMax)
        );
    }

}

It's pretty simple, almost unchanged code from the Unity tutorial. Boundaries are set as -8, 8 on X and -13, 13 on Z. The cuboid spawns at 0, 0.55 (It's 1 height, I gave it some clearance), -13. I move it forward with the WASD and it just gets stuck at 0.15 Z. Just dies there and can't move anywhere.

I'm very new to Unity, so I expect it to be some rookie mistake. Can someone help me out? Thank you.


texts: Why is this orthographic projection matrix not showing my textured quad?

texts:
I've been following tutorials, mainly this one, and I am still not quite sure why my textured quad is not showing inside the frustum that I've rendered before. I can see it if and only if I don't multiply gl_Position with OrthoProjMatrix * vertexmodelspace, and instead, multiply gl_position with vertexmodelspace.

Here is some of my code; my Main.CPP is also available via PasteBin.

Orthographic Projection Matrix Setup Code:

void OpenGL_Engine::OrthoProjectionSetup(GLuint program)
{
    GLfloat Right = 100.0;
    GLfloat Left = 50.0;
    GLfloat Top = 100.0;
    GLfloat Bottom = 50.0;
    GLfloat zFar = 1.0;
    GLfloat zNear = -1.0;

    GLfloat LeftAndRight = 2.0f / (Right - Left);
    GLfloat TopAndBottom = 2.0f / (Top - Bottom);
    GLfloat ZFarAndZNear = - 2.0f / (zFar - zNear);

    GLfloat orthographicprojmatrix[] = {
    //XX XY XZ XW
    LeftAndRight,
    0.0, 0.0,
    - (Right + Left) / (Right - Left),

    //YX YY YZ YW
    0.0,
    TopAndBottom,
    0.0 ,
    - (Top + Bottom) / (Top - Bottom),

    //ZX ZY ZZ ZW
    0.0,
    0.0 ,
    ZFarAndZNear,

    //WX WY WZ WW
    - (zFar + zNear ) / (zFar - zNear),
    0.0,
    1.0
    };

    GLint orthographicmatrixloc = glGetUniformLocation(program, "OrthoProjMatrix");
    glUniformMatrix4fv(orthographicmatrixloc, 1, GL_TRUE,
        &orthographicprojmatrix[0]);
}

Vertex Shader Code :

#version 330 core

layout(location = 0) in vec4 vertexposition_modelspace;
layout(location = 1) in vec2 vertexUV;
out vec2 UV;
uniform mat4 OrthoProjMatrix;

void main()
{
    gl_Position =  OrthoProjMatrix * vertexposition_modelspace;
    UV = vertexUV;
}

I'm having problems with the orthographic projection matrix; either it is not being done correctly, not setup correctly, my shader is not setup correctly or it's the textured quad that is not in view. Please note that I do not want to use a library for this. What am I doing wrong?


texts:
I was watching the "Devs Play" S01E05 where JP LeBreton sat down with John Romero and played through Doom, while Romero would explain some of the game/level design choices they made.

There are loads of great points that both of them juggle around, though, there is one that I cannot fully understand. Maybe that's my language barrier or something, but yeah - Unit slotting.

It's a short segment of the video, starting at 2m56s where Romero has a little laugh about slotting in modern games.

I cannot seem to grasp the concept of it. Is it that units are auto-swarming towards you and attack in somewhat of a queue? Or maybe it's that their attacks are synchronized as to not overwhelm you? Or... what the heck is slotting?


texts: GameObject transform with respect to local camera?

texts:
I'd like to recycle objects as they pass behind the camera frustum -- i.e, the plane of the local Z axis, orthogonal to the camera vector:  Camera.main.transform.forward.

Is there a nice method to test for the above case?  That is, "if a GameObject's location < local Z = 0 plane", we can know that it is behind the camera.


texts: Should I be using Reach or HiDef profile if I have large spritesheets?

texts:
I'm working on a platformer in monogame, that I want to use a large number of sprites for making up items and objects in the background.

The main spritesheet I've created is 4095x3734, when I tried to convert it into xmb using XNA Content Compiler, I received an error that Reach Profile only supports 2048x2048.

I've read that I can use HiDef which will support 4096x4096, which will be sufficient for my requirements, but I am a bit concerned about what the potential pitfalls will be - will less graphics cards support the game? What about Mac/Linux? Does monogame fully support HiDef?

In short, I would like to know if there are any cons of using HiDef and if using multiple 2048x2048 spritesheets would perhaps be better - and how much of a performance hit it would be.


texts: Getting positions of static entities in a Tiled Map

texts:
I'm creating a 2D game that uses a Tiled Map with an underlying 2D array to store where entities are in the world. At the moment, I'm just creating one instance of an entity, assigning it a number, and storing that in the array to determine what entity is at what position in the array/world. However, this is presenting some issues. The most prevalent being getting the position of an entity from the entity object, because there is only one object being used throughout the whole world.

Would it just be easier to have non-static entities and populate the array with many instances of the entity object or is there a simple way I could get the position of an entity on the tile map through the object?


texts: Unity animator controller animations don't work

texts:
I'm having problems animating a character pack I purchased from unity asset store.

I've placed the character in an environment and created an animator controller. After I drag the animation that to the animator tab, there aren't any motions. Even if I place triggers or booleans in my script as parameters in the animator it doesn't work.

It worked with other characters but the animations were somehow embedded in the 3d models. How is this supposed to work?


texts:
I have a 3d game, but for movement I use only two axes (X and Z) - X is vertical, Z is horizontal

Here's what I'm trying to achieve:

Player is the circle, InputDirection is Blue, NewInputDirection is Green.
I'm struggling on getting the desired green direction.

Image 1
The player moves up (he's pushing onto the wall)

InputDirection: (-1f, 0f, 0f)

NewInputDirection: (0f, 0f, 0f) because we should stop him.

Image 2
The player moves towards the wall and the bottom. When he reaches the wall, his horizontal axis should be blocked - set to 0, so he slides)

InputDirection: (0.5f, 0f, -0.5f)

NewInputDirection: (0.5f, 0f, 0f)

Image 3
Same thing as above, but the wall is rotated.

Right now, my code looks like this:

RaycastHit hit;
bool collides = Physics.Raycast(this.playerRigidbody.position, inputDirection, out hit, 1f); // ray in front of the player

if(collides){ // if there's a collision
    // calculate the direction from the player to the collision contact point
    Vector3 collisionNormal = (hit.point - playerRigidbody.position).normalized;
    // idk...
}

I don't know how to calculate it. I've tried various ways. Should I also take the wall's rotation into account?


texts:
One of my hobbies (aside programming, of course) is 3d modeling (completely amateur, using 3ds MAX) and I'd like to mix programming with 3d modeling (what a marriage!). So I've read a little about it and figured I'd have to have good notions on geometry, math, point spacial position (which I do, from my 3d modeling experience), but I don't know how to use API's for it, so I've 'simulated' simple 3d with some simple programs I've made (first a spinning cube, then a more complex Labyrinth (or maze, if you will)).

NOTE: I have no intentions on harming anyone's computers. If you don't trust it, use a VM or something.
Once you run it, I'd appreciate if you commented here stating that the EXE's are safe. Thank you.

Here are some questions:
1) What would be a nice 3d development tool for a .NET programmer like me?
2) Is there a way of using 3d models made in 3DS Max ? (I intend on modeling characters)
3) What knowledge should I have in order to render it, and move it around ?
4) Which API should I use ?

The development environment would be nice if it:

Had the possibility to import existing 3D models exported by 3DS MAX (not a must, but a plus)
Had the ability to create 3d models programmatically (a must)
Possibly has a tool for materials and textures (that would be a huge plus)
Is Well known (high availability of tutorials, questions in S.O., forums..)

And it would be really nice if I could use C# all the way :)

EDIT
For the ones that asked if I want to do something more UI-guided, just to mess around with some models, and not learn about how to create a game-engine, I say no, that's not the case.

If you download my Labyrinth little game, you'll notice that I've basically MADE a simple renderer from scratch using DrawPolygon on bitmaps created via code. So that's a clue that what I want is to learn, and that I somehow like the idea of mixing images and codes together, along with some user interaction.

Imagine that I have a model, say the weighted companion cube, and I want to make a full-screen, or windowed lil' program that spins it (much like the crappy spinning cube I've made a while before the other one), setting the position, the position and angle of the camera, velocity, a simple ambient (say a simple monocolor box (which would be a room) drawn maybe through code (not an imported model)) and editing it with simple user interaction (say pressing left or right on the keyboard changes direction, or pressing '+' would make it faster), all that without using a wizard or something, but coding.

Now for those that didn't quite get my intentions in here, I hope this example makes it clearer of how powerful and customizable I hope it should be. If there are any more questions, let me know!

EDIT
I'm going to start with UNITY, and I've noticed there's a pro version, is the free version enough to do what I want ? (not counting on the 1 month free pro account)
As for XNA, does the same scenario apply as well ?
Please leave a comment!