texts: how to make AI do jump on navigation mesh system?

texts:
hi :D i'm currently using unreal for make a sand-box game for learning purpose.

and due to the unique attribute of sand-box game, i am looking for how AI move naturally on map (which changes so often).

i find a way to place Nav-links on map dynamically and working on that way. but i think if i can make AI do Jump or fall off,climb low height wall like thing, it would be more performance-friendly than placing bunch of Nav-links.

so i searched about that, and i find 'how to get navigation-mesh in unreal', 'how to override path following' kind of stuff. but i really can't find and don't get about 'How to make AI decide to jump when it need'

i put an image for detailed question. Stick man is the AI and while the flag on right top is the goal( target move location ), there is also 2 obstacles(A and B) for reach the goal.

so here is my question :

while the navigation mesh isn't linked between the platform and above the obstacle A. How path-finder knows it can use 'A' when it can do Jump?
i think obstacle B is more difficult situation. unlike situation A, 'navigation mesh B'has the same or inner positions of 'navigation mesh platform'. while the only noticeable difference is height, how AI or path-finder know it is valid path and needs do jump?
quite same question about B i think. i forgot to draw on image though. so, if AI figure out the path and try to do jump for reach to goal but there is some obstacle just placed which block the jump. how it know and fix the path?

i know it is very difficult question, and very hard to explain. especially the question 2 and 3. so i understand even only answer for question 1. and even so, i feel so appreciate about it.

since English is not my first language, please excuse my poor English skill. and hope you don't bother about it :).

thanks for reading, and hope you have a wonderful day and stay happy :)


texts: XNA Library DrawPrimitives throwing primitiveCount error

texts:
I downloaded the project from here http://silverlight.bayprince.com/tutorials.php?tutorial=13 and tried adding a new OBJ file with a few thousand vertices listed.

The classic teapot works but when I tried loading a different model with alot more vertices included, it suddenly throws this primitiveCount error when the DrawPrimitives gets called.

EDIT:

The code includes a class that would read the data from the OBJ file. This will then return a VertexBuffer object back to the main program. The drawing starts when the Draw event is called.

There are 417936 vertices created from the OBJ file and since I'm using a trianglelist, I divided the vertices by 3 to get the total primitives count.

here's the code for the draw event:

private void DrawingSurface_Draw(object sender, DrawEventArgs e)
        {
            GraphicsDevice device = GraphicsDeviceManager.Current.GraphicsDevice;

            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, new Microsoft.Xna.Framework.Color(0, 0, 0, 0), 10.0f, 0);

            device.RasterizerState = new RasterizerState()
            {
                CullMode = CullMode.None
            };

            device.SetVertexBuffer(_vertexBuffer);

            foreach (EffectPass pass in _effect.CurrentTechnique.Passes)
            {

                    pass.Apply();
                    device.SamplerStates[0] = SamplerState.LinearClamp;
                    device.DrawPrimitives(PrimitiveType.TriangleList, 0, _vertexBuffer.VertexCount / 3);
            }

            // set camera
            _effect.World = Matrix.Identity;
            _effect.View = Matrix.CreateLookAt(new Vector3(_x, _y, _z), Vector3.Zero, Vector3.Up);
            _effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, 2.0f, 1.0f, 100.0f);

            // move camera along a circumference
            _x = (float)(_radius * Math.Sin(_hAngle * (Math.PI / 180)));
            _z = (float)(_radius * Math.Cos(_hAngle * (Math.PI / 180)));

            // move camera along a circumference
            //_y = (float)(_radius * Math.Cos(_hAngle * (Math.PI / 180)));

            e.InvalidateSurface();
        }

then the error occurs on the DrawPrimitives.

Any clues about this?


texts:
I'm using Unity3D. I'm working advanced topics. For example Mipmap.

How I can automatic mipmap (use camera distance) for textures?

Thank you.


texts: On Android, How can I avoid FPS drops during sensor listener setup/tear down?

texts:
When I open my Android app after 5 or 10 seconds it sets up the sensor listener, during which I see clear stuttering and the FPS drops for a second to 40 instead of 60.

Is there a way to avoid this?

I am working in Android Studio with LibGDX.


texts: How do I set meshCollider.cookingOptions to MeshColliderCookingOptions.Everything in code?

texts:
I'm procedurally generating some meshes for a project, and I need to add colliders to them. The meshes are generating fine, but after setting the shared mesh in the mesh collider, I need to be able to set the cookingOptions to Everything. In the inspector, I can do this fine and the colliders work correctly. Since I am generating these at runtime, I can't really do this after making a build. How do I go about doing this?

Works Correctly:

Does not Work Correctly:


texts: pushing rigidbody with force to match mouse position

texts:
i'm making a game in which the player character, a 2d rigidbody, is controlled by the user's mouse dragging them. i originally made it so that the player character's position was made the same as the mouse's whenever the mouse was clicking, but this allows for the player to drag the character through walls. i decided the best way to get past this is to apply force to the character until it reaches the mouse's position so as to get the player there as fast as possible without going through walls. when the character reaches the mouse's position, i tried to set its velocity in both axes to 0. however, i seem to be stuck as the movement is largely inaccurate. here's my code:

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

public class Player : MonoBehaviour
{
    public Rigidbody2D rb2D;
    public bool isBeingHeld;
    public float force = 1;
    Vector3 mousePos;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        mousePos = Input.mousePosition;
        mousePos = Camera.main.ScreenToWorldPoint(mousePos);

        if (isBeingHeld == true)
        {
            if (mousePos.x == this.transform.position.x)
            {
                rb2D.velocity = new Vector2(0, rb2D.velocity.y);
            }
            if (mousePos.y == this.transform.position.y)
            {
                rb2D.velocity = new Vector2(rb2D.velocity.x, 0);
            }
            if (mousePos.x > this.transform.position.x)
            {
                rb2D.AddForce(new Vector2(force, 0));
            }
            if (mousePos.x < this.transform.position.x)
            {
                rb2D.AddForce(new Vector2(-force, 0));
            }
            if (mousePos.y > this.transform.position.y)
            {
                rb2D.AddForce(new Vector2(0, force));
            }
            if (mousePos.y < this.transform.position.y)
            {
                rb2D.AddForce(new Vector2(0, -force));
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            isBeingHeld = false;
        }
    }

    private void OnMouseOver()
    {
        if (Input.GetMouseButtonDown(0))
        {
            mousePos = Input.mousePosition;
            mousePos = Camera.main.ScreenToWorldPoint(mousePos);
            isBeingHeld = true;
        }
    }
}

thank you!


texts: Unity - Part of the sprite is covered in shadow

texts:
I have a sprite with Transparent/Cutout/Diffuse shader. Recieving shadows is turned on in SpriteRenderer. The light is a pointlight and I am using deffered rendering path.

However when I am above or right of the object, it is covered in shadow. When I am below or left of the object everything seem to work as it should.If I place the light in the center of the sprite, only a part of the sprite is lit up, the other part is covered in shadow.

Maybe it is something with normals? I need to get rid of the self shading effect.

Shader

Shader "Transparent/Cutout/Diffuse" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
    _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}

SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 200

CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff

sampler2D _MainTex;
fixed4 _Color;

struct Input {
    float2 uv_MainTex;
};

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

Fallback "Transparent/Cutout/VertexLit"
}

I found out what unity uses for lambert lightning. Since I use deffered rendering so unity should use function with _PrePass prefix. But the implementation of the actual lighning is implemented somewhere else and is it used for all materials, that looks like dead end.

Custom Lightning

inline fixed4 LightingSLambert (SurfaceOutput s, fixed3 lightDir, fixed atten)
{
fixed diff = max (0, dot (s.Normal, lightDir));

fixed4 c;
c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten * 2);
c.a = s.Alpha;
return c;
}

inline fixed4 LightingSLambert_PrePass (SurfaceOutput s, half4 light)
{
fixed4 c;
c.rgb = s.Albedo * light.rgb;
c.a = s.Alpha;
return c;
}

inline half4 LightingSLambert_DirLightmap (SurfaceOutput s, fixed4 color, fixed4 scale, bool surfFuncWritesNormal)
{
UNITY_DIRBASIS
half3 scalePerBasisVector;
half3 lm = DirLightmapDiffuse (unity_DirBasis, color, scale, s.Normal, surfFuncWritesNormal, scalePerBasisVector);
return half4(lm, 0);
}


texts: why is my mesh black in blender even though the color is set to white

texts: I set my mesh black then wanted to set it back to white but can't. How do i do it ?


texts: Change DisplayObject's bounds in Flash/AS3

texts:
I'm developing some platform-like game using AS3 and Flash CS5 for animations. I've already done most of the mechanics now, and I've starded to drawing characters and animating them. But some problem appeared. I used getBounds(this) for caching all of the collisions, and after changing the placeholders to real images everything sucks. Is there any way to change the bounding box to something more constant? What's the proper way to handle with this problem in AS3?
I was thinking about representing each colidable object as a pair of animated object and some constant object that will be my colliding box. But usage of that model will be quite annoying... couse I would need to make two working objects/classes for each object that I would like to have collidable.
Every help will be appreciated. Looking for some non-noob ways of dealing with it =]


texts: Cocos2dx - Physics - Abort() When Changing Dynamic PhysicBody to Static?

texts:
I just learned cocos2dx v3.3 integrated chipmunk physics engine.

Here ,as you see, I create a simple circle with physic as:

auto sprite = Sprite::create("circle.png");
auto body = PhysicsBody::createCircle(sprite->getContentSize().width / 2);
body->setContactTestBitmask(-1); //active collisions event
sprite->setPhysicsBody(body);
sprite->setPosition(...);
this->addChild(sprite);

When I toggle this circle static/dynamic in normal situation everything work fine and when circle become static it stop in its position (as we expect gravity don't move it longer). here is a toggle code which works fine:

body->setDynamic(false);
scheduleOnce([=](float dt){body->setDynamic(true);},3,"Back to Dynamic Mode Timer");

PROBLEM BEGINS

But I want when the circle collide with something else ( in my case screen edge with is not important part of scenario), it become static then. so I use below code:

auto contactListener = EventListenerPhysicsContact::create();
contactListener->onContactBegin = [=](PhysicsContact &contact) -> bool
{
    return true;
};
contactListener->onContactPostSolve = [=](PhysicsContact& contact, const PhysicsContactPostSolve& solve)
{
    contact.getShapeA()->getBody()->setDynamic(false); // ==> Cause Abort() !
};

_eventDispatcher->addEventListenerWithSceneGraphPriority(contactListener, this);

But I just face a abort() message and game exit.

The call stack ( God bless it) show that the error is comming from line 300 in CCPhysicsBody.cpp:

if (_world != nullptr)
{
    cpSpaceRemoveBody(_world->_info->getSpace(), _info->getBody());
}


texts: Reuse VertexBuffer or new VertexBuffer object?

texts:
I'm trying to render bitmap fonts in directX10 at the moment, and I want to do this as efficiently as possible. I'm having a hard time getting a start on my design because of this question though.

So should I reuse a single VertexBuffer or make multiple VertexBuffer objects?

Currently I allocate one dynamic VertexBuffer per Quad object in my program. This way I wouldn't have to map/unmap a VertexBuffer if nothing moves on my screen. For fonts I can implement a similar method on where I allocate one buffer per text box, or something similar.

After searching I read about reusing a single VertexBuffer for all objects. Vertex caching came up also. What is the advantage/disadvantage of this, and is it faster than my previous method?

For last, is there any other method I should look into rendering many 2d quads in the screen?

Thank you in advance.


texts:
I'm trying to actually learn OpenGL after having experimented with it for a while, and so I'm trying to build a rudimentary rendering engine (not a game engine) to lead me through it. I've come to a conceptual obstacle however: I don't know exactly what a model really is. I mean obviously, it is composed of one of more meshes and textures, and other important data. But how much data? Should shaders be associated with models directly, with each one holding some sort of reference to the shader they require? Or should that be handled in another layer?

I think it makes sense to incorporate the shader program and the necessary parameters along with the meshes and textures as part of a model, but I wanted a more experienced opinion.


texts:
I want to make a game for Android that has a 10x10 Grid Plane as UI.In this game users going to touch on a grid and tihs grid will be painted.

My question is how do I understand which gird or tile was clicked ? I thought maybe I will make this grid on a coordinate system so that if the user touchs a point on the gamescreen aapp will take this point and will find out in which coordinate interval is in.

Like so:

I touched -> [-2.68,3.85]
The grid -> [-3,4] will be painted.

How do I do this in Android Studio?


texts: How to simulate timed attacks in browser-based games?

texts:
In my MMORTS browser-based game, I want that all attacks be performed 7 minutes later after the player does it.

So, when the player clicks on attack button, a countdown becomes visible to both the attacker and the defender.

Showing countdown and handling its events isn't my question. In fact, my Q is how can I implement this countdown in server side and database.

I haven't any idea about managing this situation. Any helps is highly appreciated...


texts: Is it possible to decompile a .xnb file?  I've lost my shader code, but only have my .xnb file left.


texts: Change button sprites in scrollview Unity3D_5.2

texts:
I have a scroll view with lots of buttons on it. when i press one button, that button needs to change the sprite and stay like that. if any other button (or same one) is pressed previous button needs to revert back to original sprite..
here is some example

button 2 was pressed and changed sprite, it stays like that untill it is pressed again or any other (in this case button 3) is pressed


texts: C++ property system interface for game editors (reflection system)

texts:
I have designed an reusable game engine for an project, and their functionality is like this:

Is a completely scripted game engine instead of the usual scripting languages as Lua or Python, this uses Runtime-Compiled C++, and an modified version of Cistron (an component-based programming framework).to be compatible with Runtime-Compiled C++ and so on.

Using the typical GameObject and Component classes of the Component-based design pattern, is serializable via JSON, BSON or Binary useful for selecting which objects will be loaded the next time.

The main problem: We want to use our custom GameObjects and their components properties in our level editor, before used hardcoded functions to access GameObject base class virtual functions from the derived ones, if do you want to modify an property specifically from that class you need inside into the code, this situation happens too with the derived classes of Component class, in little projects there's no problem but for larger projects becomes tedious, lengthy and error-prone.

I've researched a lot to find a solution without luck, i tried with  the Ogitor's property system (since our engine is Ogre-based) but we find it inappropiate for the component-based design and it's limited only for the Ogre classes and can lead to performance overhead, and we tried some code we find in the Internet we tested it and worked a little but we considered the macro and lambda abuse too horrible take a look (some code omitted):

   IWE_IMPLEMENT_PROP_BEGIN(CBaseEntity)
     IWE_PROP_LEVEL_BEGIN("Editor");
       IWE_PROP_INT_S("Id", "Internal id", m_nEntID, [](int n) {}, true);
            IWE_PROP_LEVEL_END();
            IWE_PROP_LEVEL_BEGIN("Entity");
              IWE_PROP_STRING_S("Mesh", "Mesh used for this entity",
         m_pModelName, [pInst](const std::string& sModelName) {
           pInst->m_stackMemUndoType.push(ENT_MEM_MESH); pInst->m_stackMemUndoStr.push(pInst->getModelName());
           pInst->setModel(sModelName, false); pInst->saveState();
         }, false);
       IWE_PROP_VECTOR3_S("Position", m_vecPosition,
  [pInst](float fX, float fY, float fZ) {
    pInst->m_stackMemUndoType.push(ENT_MEM_POSITION); pInst->m_stackMemUndoVec3.push(pInst->getPosition()); pInst->saveState();
    pInst->m_vecPosition.Get()[0] = fX; pInst->m_vecPosition.Get()[1] = fY; pInst->m_vecPosition.Get()[2] = fZ;
    pInst->setPosition(pInst->m_vecPosition);
  }, false);
       IWE_PROP_QUATERNION_S("Orientation (Quat)", m_quatOrientation,
  [pInst](float fW, float fX, float fY, float fZ) {
    pInst->m_stackMemUndoType.push(ENT_MEM_ROTATE); pInst->m_stackMemUndoQuat.push(pInst->getOrientation()); pInst->saveState();
    pInst->m_quatOrientation.Get()[0] = fW; pInst->m_quatOrientation.Get()[1] = fX; pInst->m_quatOrientation.Get()[2] = fY; pInst->m_quatOrientation.Get()[3] = fZ;
    pInst->setOrientation(pInst->m_quatOrientation);
  }, false);

     IWE_PROP_LEVEL_END();
    IWE_IMPLEMENT_PROP_END()

We are finding an simplified way to this, without leading confusing the programmers, (will be released to the public) i find ways to achieve this but they are only available for the common scripting as Lua or editors using C#. also too portable, we can write "wrappers" for different GUI toolkits as Qt or GTK, also i'm thinking to using Boost.Wave to get additional macro functionality without creating my own compiler.

The properties designed to use in the editor they are removed in the game since the save file contains their data and loads it using an simple 'load' function to reduce unnecessary code bloat may will be useful if some GameObject property wants to be hidden instead.

In summary, there's a way to implement an reflection(property) system for a level editor based in properties from derived classes?

Also we can use C++11 and Boost (restricted only to Wave and PropertyTree)


texts: How to calculate directional light frustum from camera frustum

texts:
I'm playing around with OpenGL for a few weeks now.

For the following screenshot I picked the glm::ortho values for my lightsource by trial and error. There are two directional light sources with shadows.

I would like to calculate the values for glm::ortho by creating a bounding box around the camera frustum.

I have the corners of the camera frustum in world space ... what is the next step?
I think I should move the camera frustum into light space, calculate the bound box and put the dimensions of that bounding box into glm::ortho. But ... how? :)

The block below is a simplified version of my code with only one light source.

// Camera
mat4 cameraViewMatrix = lookAt(
    vec3(1.2f, 1.2f, 1.2f),
    vec3(0.0f, 0.0f, 0.0f),
    vec3(0.0f, 0.0f, 1.0f)
);

mat4 cameraProjectionMatrix = perspective(45.0f, 800.0f / 600.0f, 0.5f, 10.0f);

// Light
mat4 lightViewMatrix = lookAt(
    vec3(3.0f, -2.0f, 2.0f),
    vec3(0.0f, 0.0f, 0.0f),
    vec3(0.0f, 0.0f, 1.0f)
);

// Camera Frustum
vector<vec4> cubeNDC;
cubeNDC.push_back(vec4(-1.0f, -1.0f, -1.0f, 1.0f));
cubeNDC.push_back(vec4(1.0f, -1.0f, -1.0f, 1.0f));
cubeNDC.push_back(vec4(1.0f, -1.0f, 1.0f, 1.0f));
cubeNDC.push_back(vec4(-1.0f, -1.0f, 1.0f, 1.0f));
cubeNDC.push_back(vec4(-1.0f, 1.0f, -1.0f, 1.0f));
cubeNDC.push_back(vec4(1.0f, 1.0f, -1.0f, 1.0f));
cubeNDC.push_back(vec4(1.0f, 1.0f, 1.0f, 1.0f));
cubeNDC.push_back(vec4(-1.0f, 1.0f, 1.0f, 1.0f));

mat4 viewProjectionMatrixInverse = inverse(matProj * matView);

vector <vec4> cameraFrustum;
for(vec4 vertex: cubeNDC) {
    vec4 vertexTransformed = viewProjectionMatrixInverse * vertex;
    vertexTransformed /= vertexTransformed.w;
    cameraFrustum.push_back(vertexTransformed);
}

// Magic

mat4 lightProjectionMatrix = ortho(...);

Thanx for your help. :)


texts: Which image format to use for sprites in an HTML5 game?

texts:
In a 2D HTML5 game, what is the best image format to use and why? Should I use different formats in different situations? For example, .png for the background image, .jpeg for the animation frames and so on...

The "why" part is important to me. It doesn't really have to be localized to HTML5, it can be general advice as well.


texts: What behaviors should go into making a "non-perfect" AI combatant?

texts:
When making an npc combatant, it's easy obvious what to do to get a robot deathmachine by optimizing combat tactics, timing and attack types, but harder (and more interesting in a fight) to get an idiosyncratic, inpredictable enemy.  What behaviors (algorithms?) are useful for creating a more organic, unconventional enemy?

Edit: My specific use case is with MMO-like enemies, e.g. World of Warcraft, although with less graphics involved.  Note that that means both human and inhuman enemies (animals, monsters, etc)


texts: I'm interested in participating in some gamejams and was hoping to be able to attend one in person. Is there a way I could search for gamejams in the general Dallas area?


texts:
Code:

import pygame
pygame.init()
#
def Main(display,colors):
    clock =pygame.time.Clock()
    #
    surface = pygame.Surface(surface_resolution) # Create main surface
    surface.fill(colors["RED"])
    pygame.draw.rect(surface,colors["GREEN"],pygame.Rect((0,0),(110,110)))
    pygame.draw.rect(surface,colors["BLUE"],pygame.Rect((10,10),(100,100)))
    #
    while True:
        clock.tick(60)
        #
        for event in pygame.event.get(): # Main event loop
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE: # Exit game with Escape key
                    pygame.quit()
                    return
        #
        display.fill(colors["WHITE"]) # Fill the display white
        display.blit(surface,(display.get_size()[0]/2-surface.get_size()[0]/2,display.get_size()[1]/2-surface.get_size()[1]/2)) # Blit main surface on center of display
        #
        pygame.display.flip()
#
if __name__ in "__main__":
    global resolution
    global surface_resolution
    resolution =         (1920,1080) # Resolution of the display
    surface_resolution = (1536,864)  # Resolution actually seen
    #
    #
    display = pygame.display.set_mode(resolution,pygame.FULLSCREEN) # Create fullscreen display
    #
    colors = {                 # Defign colors
        "WHITE":(255,255,255),
        "RED"  :(255,0,0),
        "GREEN":(0,255,0),
        "BLUE" :(0,0,255),
        "BLACK":(0,0,0)
    }
    #
    Main(display,colors) # Run main loop

I have been experimenting with various resolutions in fullscreen Pygame. My new computers native resolution is 1920x1080 as apposed to my old computers resolution of 1366x768, so I started to test resolutions higher than 1366x768. However, when I run pygame with my native resolution, the highest resolution that fits my monitor is 1536x864 with the rest of the primary display off the screen.

This code creates a red surface with a 110x110 rectangle in the upper left corner and blits it to the center of the display. When I set the surfaces size to anything higher than 1536x864, parts of the 110x110 rectangle are cut off, and when I set the display and the surface size to 1366x768, Pygame stretches the display to fill my moniter.

The pygame display docs say that:

  When requesting fullscreen display modes, sometimes an exact match for the requested resolution cannot be made. In these situations pygame will select the closest compatible match. The returned surface will still always match the requested resolution.

However, when I run the following code to get all the available fullscreen resolutions, I see that 1920x1080 is an available resolution.

>>> for mode in pygame.display.list_modes():
        print(mode)
(1920, 1080)
(1680, 1050)
(1600, 900)
(1440, 900)
(1400, 1050)
(1366, 768)
(1360, 768)
(1280, 1024)
(1280, 960)
(1280, 800)
(1280, 768)
(1280, 720)
(1280, 600)
(1152, 864)
(1024, 768)
(800, 600)
(640, 480)
(640, 400)
(512, 384)
(400, 300)
(320, 240)
(320, 200)
>>>

My question is why does this happen, and how can I stop Pygame from stretching the display in this manner? I feel like I'm completely missing the point with this, but I couldn't find anything about this anywhere else.


texts: I am making a game in opengl and am trying to get a camera to follow an airplane. How can I get the camera to match the roll, pitch, and yaw of the plane? I am using glm as my math library. Thanks!


texts:
A recurring problem I get is this one: given two different billboard sets with alpha textures intended to create particle special effects (such as point lights and smoke puffs), rendering them correctly is tedious.

The issue arising in this scenario is that there's no way to use depth writing and make certain billboards obey depth information as they appear in front of others that are clearly closer to the camera. I've described the problem on the Ogre forums several times without any suggestions being given (since the application I'm writing uses their engine).

What could be done then? sort all individual billboards from different billboard sets to avoid writing the depth and still have nice alpha blended results? If yes, please do point out some resources to start with in the frames of the aforementioned Ogre engine. Any other suggestions are welcome!


texts: Algorithm for spacing points out among a line

texts:
I'm writing an angled tile system, and my implementation is to have a starting height and an ending height inside the tile.

Like so:

The starting and ending height allow me to get the length of the angle and the angle in degrees using atan2.

For collision against the angled tiles I give the tiles a collection of points along the line, and as a bounding box intersects any of a tile's slope points it will move the box's y position to that point.

This implementation works fine for 45 degree tiles, however with other degrees I don't know how to create the points on the line.

What algorithm could I use to space the points out along the line when they are not in a perfect 1 to 1 ratio angle? (e.g. 17 degrees instead of a nice 45 degrees)

EDIT: Here's a way to interpret my question perhaps more academically:

Given a length of a line and its angle, and an arbitrary number of points, find an algorithm that will space the points out among the line that will as closely resemble the angle.


texts: Pick which directional light shades which object

texts:
Suppose you have two directional lights pointing at one sphere from different angles. You would expect the sphere to cast two shadows, but it turns out that this isn't the default behavior. The first light in the scene is the only one that casts a shadow. I want all my yellow spheres to take shadows from light A, but I want all my blue spheres to take shadows from light B instead of A. Is there a way to do this?

(It seems there's a fullforwardshadows pragma that could make the spheres cast both shadows. I'll try to figure that out if need be, but I really only need one shadow per sphere.)


texts: Godot Engine: Why is baking light making my scene darker?

texts:
I have an interior scene with some windows.  The light is from an OmniLight near the ceiling, default environmental light from outside, and a desk lamp with emission.  Without baking light, the scene looks like this:

Consistent with the documentation for emission, the desk lamp is not affecting the surrounding objects.  I want to bake the light to see the lamp's effect and to support low end hardware.
I followed the baked lightmaps tutorial and set the BakedLightmap's extents to encompass the entire room.  After baking, the scene looks like this:

I can see the lamp's light, as expected, but now everything is too dark.  It is unclear to me from Godot's documentation if scenes include indirect light without baking.  I have tried this with the OmniLight set to bake "all" and only indirect light.
What am I missing here?

UPDATE 10 April 2021:
The problem seems to be that baking environmental light isn't working as expected.  I was using Godot 3.2.3; now I'm using 3.3rc8.  That gives the BakedLightmap options for environmental light, but the problem remains.
I began troubleshooting by shuttering all the light sources as follows:

Hid the OmniLight, and set its "Bake Model" property to "disabled"
Unchecked "use in baked light" for the desk lamp
Set the default environment's background and ambient energy to 0
Set the BakedLightmap's "environment mode" to "Disabled", verified "Min Light" is set to pure black, and cleared the "Light Data"

When I run the game, I get exactly what I expect--a black screen.  If I bake light under these conditions, I continue to get a black screen, as expected.
Here's where things get screwy.  When I set the BakedLightmap's "environment mode" to "Scene"--with the environment still without any light--I get dim illumination.


texts: How to display multiple textures with OpenGL without a texture atlas

texts:
I tried to dig into OpenGL a bit to use in 2D games (mainly because of shaders). There are multiple tutorials out there showcasing how to display and blend textures, and that's fine. But i haven't found a single one that would teach how to display multiple textures at once. Now, I know that one of the popular methods is using a texture atlas and then, provided you have a well-done atlas, it's just a matter of assigning proper UVs to objects using the texture in vertices sent to a buffer array. However, how would one go about it if he didn't want to use a texture atlas. Modern OpenGL offers at least 70something texture units if my memory serves me right, that's something, but then you would have to bind different textures (and possibly end up with an outrageous amount of samplers) which would waste a lot of GPU's computing power. Let's consider the following screen, assuming that everything, including clouds, is a separate object using it's own texture

How, in pseudocode, should I handle displaying that "the proper way" without a texture atlas to get an effect like that? I experimented with rebinding textures etc. but none of that helped. Also, how shaders should look like because i don't think that having a sampler for every object is a way to go as well. Maybe something with a TEXTURE_2D_ARRAY, but if yes then how to use it properly? Again, what I'm looking at is just a list of steps i need to take to get an image like that written in a pseudocode. Thanks in advance!


texts:
Possible Duplicate:
  What are effective marketing strategies for iPhone games?

I'm interested in promoting my latest iOS game.  What have you done that really helped spread the word?  Any smaller game review sites that were helpful?  How about publishing?


texts: Z-order for cocos2d top-down game with sprite batching

texts:
I'm trying to understand how to create z-order system like you can see in http://www.realmofthemadgod.com/

Character is above the tree when he is in front of it and vice versa.

Also, I'm planning to use sprite batching and all the sprites will not fit in one texture (2048*2048 for cocos2d-iphone). So I need to use several batches (like one for background and one for characters).

Additional "top-background" layer with  above the character layer will not solve the problem: what if two characters are staying in front and behind a tree at the same time?

So, I'm thinking about some sort of masking but I don't know how to properly implement it.

Example from the RotMG: http://i.stack.imgur.com/d8dAe.png


texts: stretch images when window is re-sized in XNA

texts: Is there a way to re-size all the images inside the view port in a XNA project. At the moment when I re-size the view port the background stays at the same size of the image when I want it to re-size, this is the same for the different sprites.  I have looked at different sources and I have not been able to find anything that has helped.


texts: How do I create textured landscape in low poly style?

texts:
I'm trying to create something similar to this kind of artistic landscapes in Unity.

I've been from trying to use Unity's terrain system and Gaia to making it in Blender; no matter how I can't figure out how it's made; how to texture it afterwards.

I'd be thankful is someone can point me in the starting direction.

Thanks !


texts: Adding Player Movement and Firing on Touch Input (Unity)

texts:
I am having many problems with this. I am a new game developer and I am using a Unity tutorial. But I want to add touch input for movement and a touch button for firing the weapon. How can I do this? I followed several tutorials and even the documentation provided by Unity, and could not get it to work. Here is my code.

For Player Movement and animation:

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public float speed = 6f;

    Vector3 movement;
    Animator anim;
    Rigidbody playerRigidbody;
    int floorMask;
    float camRayLength = 100f;
    void Awake()
    {
        floorMask = LayerMask.GetMask ("Floor");
        anim = GetComponent <Animator> ();
        playerRigidbody = GetComponent <Rigidbody> ();
    }
    void FixedUpdate()
    {
        float h = Input.GetAxisRaw ("Horizontal");
        float v = Input.GetAxisRaw ("Vertical");
        Move (h, v);
        Turning ();
        Animating (h, v);
    }
    void Move (float h, float v)
    {
        movement.Set (h, 0f, v);
        movement = movement.normalized * speed * Time.deltaTime;
        playerRigidbody.MovePosition (transform.position + movement);
    }
    void Turning ()
    {
        Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition);
        RaycastHit floorHit;
        if(Physics.Raycast (camRay, out floorHit, camRayLength, floorMask))
        {
            Vector3 playerToMouse = floorHit.point - transform.position;
            playerToMouse.y = 0f;
            Quaternion newRotation = Quaternion.LookRotation (playerToMouse);
            playerRigidbody.MoveRotation (newRotation);
        }
    }
    void Animating (float h, float v)
    {
        bool walking = h != 0f || v !=0f;
        anim.SetBool ("IsWalking", walking);
    }
}

For firing the weapon:

using UnityEngine;

public class PlayerShooting : MonoBehaviour
{
    public int damagePerShot = 20;
    public float timeBetweenBullets = 0.15f;
    public float range = 100f;

    float timer;
    Ray shootRay;
    RaycastHit shootHit;
    int shootableMask;
    ParticleSystem gunParticles;
    LineRenderer gunLine;
    AudioSource gunAudio;
    Light gunLight;
    float effectsDisplayTime = 0.2f;

    void Awake ()
    {
        shootableMask = LayerMask.GetMask ("Shootable");
        gunParticles = GetComponent<ParticleSystem> ();
        gunLine = GetComponent <LineRenderer> ();
        gunAudio = GetComponent<AudioSource> ();
        gunLight = GetComponent<Light> ();
    }

    void Update ()
    {
        timer += Time.deltaTime;

        if(Input.GetButton ("Fire1") && timer >= timeBetweenBullets && Time.timeScale != 0)
        {
            Shoot ();
        }

        if(timer >= timeBetweenBullets * effectsDisplayTime)
        {
            DisableEffects ();
        }
    }

    public void DisableEffects ()
    {
        gunLine.enabled = false;
        gunLight.enabled = false;
    }

    void Shoot ()
    {
        timer = 0f;

        gunAudio.Play ();

        gunLight.enabled = true;

        gunParticles.Stop ();
        gunParticles.Play ();

        gunLine.enabled = true;
        gunLine.SetPosition (0, transform.position);

        shootRay.origin = transform.position;
        shootRay.direction = transform.forward;

        if(Physics.Raycast (shootRay, out shootHit, range, shootableMask))
        {
            EnemyHealth enemyHealth = shootHit.collider.GetComponent <EnemyHealth> ();
            if(enemyHealth != null)
            {
                enemyHealth.TakeDamage (damagePerShot, shootHit.point);
            }
            gunLine.SetPosition (1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition (1, shootRay.origin + shootRay.direction * range);
        }
    }
}

Any help would be greatly appreciated :)


texts: Whats the best cross-platform game engine that supports Linux?

texts: What is the best cross-platform game engine, being the most commercially supported, there is for free available for development on Linux? I'm planning on creating multiple, non-commercial, fps games to gain real industry experience in C++ game development.


texts: Copy velocity of one object to other object

texts:
I have a script to pick up items with a VR controller. I connect the object to the VR controller through a FixedJoint on a rigidbody attachPoint. When I drop an item through destroying the Joint however it plummets straight down to the ground, no force from the controller is transferred to the released object. Thus I can't throw the object.

I tried it using the AddForce() method. attachPoint's velocity is the controller's as it is a child of the controller. Relevant code below.

Can someone help me with transferring the velocity of the controller at the time of release to the object just released?

Thanks!

public class PickupCarryRelease : MonoBehaviour {

    public Rigidbody attachPoint;

    FixedJoint joint;
    GameObject obj;
    Collider grabbedObjColl;

    void Update()
    {
        Release();
    }

    void Release()
    {
        var device = SteamVR_Controller.Input((int)trackedObj.index);
        if (canGrab && joint != null && device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            var obj = joint.gameObject;
            var rb = obj.GetComponent<Rigidbody>();

            grabbedObjColl.isTrigger = false;
            rb.detectCollisions = true;

            //Transfer velocity

            Destroy(joint);
            rb.AddForce(attachPoint.velocity, ForceMode.Impulse);
            StartCoroutine(GrabDelay());
        }

    }
}


texts: 2015 android multiplayer server based Implementation

texts:
There are a lot of old posts about multiplayer implementations on SE, so i'm looking for an up-to-date answer. What is the best server-client implementation of real-time multiplayer now? I have an Amazon MYSQL Server hosted by digitalOcean, I've made a REST web service that communicates with the Server and Android app, and I have my Android app running receiving and sending data.

I want to add a multiplayer minigame to what I have right now where 2 players would see the same screen and one user would receive location data (which i'm already storing in the server and sending to all devices with the app) from the other and would have an interface to interact with the data they're receiving (like building towers around the location and deploying units). The computer AI would need to be synced between both devices.

The matches would last maybe 3 minutes tops and the location data would have to be streamed constantly as well as the interaction from the other user. The computer AI would be streamed to both.

I've done a lot of research on the topic, and most of my experience was from a bluetooth P2P game I created in 2011 using sockets. So what are the most common implementations today? What are the most common libraries? I'm currently using Android Studio for the app and Notepad++ for the PHP webservice.

EDIT:
I'm fine with answers promoting their own products, but explain how your product is better than Google's Game Services (which appears to be the best choice right now). I'm really looking for a way to implement the multiplayer with the server I'm already using.


texts: Performance in unity at runtime (mesh creation) vs (assets bundle loading)

texts:
I'd like to load a 3d model that contains several objects in real-time. I believe I have to two methods to do this:

create an assets bundle that contains my model (all object) and loaded at runtime.
load mesh data (vertex, normals, vertex colors) to create a mesh (all object) at runtime.

Currently, my data is presented as mesh data (vertex, normals, vertex colors) and I would like to know if it is better to load them on at runtime and create the meshes from them. Or is it better to create an assets bundle from the mesh and put it in the server and then load the assets bundle?

To simplify my question is it more optimize to use:

(triangles, vertex, normals, vertex colors)?
or use unity assets?

Thank you in advance.


texts: combining multiple materials into one material (Unity)

texts:
I am confused with how should I texture my character.

I am using blender for modelling. And while my model is too complex I dont want to use uv map techniuqe. I can get what I need with using seperate materials. Therefore I assign different materials to different meshes in Blender then import it to Unity. Therefore I have lots of different material in one model and I think it increases draw call. What can I do to combine these material into just one.

I thought baking would be sollution but while my character is dynamic I can not get a good result.


texts: Does swap buffer with vsynch guarantee synchronization?

texts:
I was wondering if I could assume that all buffer related GPU operations such as:

glDrawElements
glBufferData
glSubBufferData
glUnmapBuffer

are guaranteed to be completed after swap buffer is performed (i.e. frame is finished) assuming vsync is on.
I'm confused as I've come across implementations of vertex streaming techniques such as rond robin vbo which imply that a vbo could still be in use during the next frame.
What I basically want to do is stream vertices through glMapBufferRange with GL_UNSYNCHRONIZED_BIT, managing the correct ranges myself so that writes and reads never overlap.
This would work very well if I could just assume synchronization and reset the stream range index at the end of the frame.
In other words, does swap buffer with vsynch guarantee synchronization?


texts: How do I port a game which uses print-output to pygame font rendering with the least amount of work?

texts:
I've been working on a text based RPG. It's pretty simple, I'm not very experienced with Python, or any other language for that matter.

Edit: For context, I recently posted this question: Python 3: How can I make my Text-based game windowed?

Here's my game you'd like to check out the code: https://gist.github.com/NervousTumbleweed/f42f326982f2af1549b528ce0156e34a

I took a long hiatus from working on the game because I became caught up in work, and after coming back to it today I've decided that I want it to run in a window, not a console.

I want my end product to have background art and audio files. I have a pretty good idea of how to do this (I've done very simple versions of this in languages like MATLAB and Processing)

What I'm beginning to realize though, is that many of the functions that I use in my game don't just magically "transfer" over to pygame. I don't get to just create a window and poof my game is there.

For example, my print() commands all won't appear in a pygame window, correct? So I did some research and it seems like I could (maybe) create a font, and replace them with:

textsurface = myfont.render('Some Text', False, (0, 0, 0))
screen.blit(textsurface,(0,0))

But then I realized, how the hell do I get commands in there?

What about strings that are attributes of objects, will those display?

Is the way my game logic is written even compatible with this module?

So now I'm pretty bummed out and frazzled. I'm willing to restart from scratch I guess, but part of what motivated me to come back to the game was that I wanted to finish it.

Would the best move be to completely start over, or can a good amount of my code be salvaged and made compatible with displaying in a pygame window?


texts: Is there a centralized achievement system for browserbased onlinegames

texts:
I plan to implement missions with achievements (or rewards/badges) in my online space browser game spacetrace.

I want somehow connect that to an existing online achievement platform for browser-based HTML5-games?

There are some online platforms that lets users show their achievements in several games they have reached like GameCenter, OpenFeint, Steam, PlaystationNetwork and Scoreloop

But is there a great community for browser-based onlinegames too?

clay.io looks quite promising.

Which is the most used platform that I should implement the achievements on?


texts: How should one component "trigger" another one in a component system?

texts:
In my game I have a MoveComponent and a ClimbComponent.

Some characters can only move around on one level, others are able to climb to the next floor.

My intention is to have characters randomly be able to climb if the are about to bounce into a wall.

How would I manage this? Should the ClimbComponent be added dynamically and also be removed again, or should random characters always have the ClimbComponent and it would be activated and deactivated dynamically?


texts: Does concurrency inherently introduce "randomness" into a game?

texts:
When a game is implemented with concurrency (as most games are), does this necessarily, by its very nature, introduce an element of randomness into the game that is outside of the players' control?

Note that when I use the word "random", I'm not meaning to launch into a philosophical debate about the deterministic nature of the system.  I understand that concurrency is deterministic in the sense that the operating system decides which processes to allow time on the CPU and in what order (or the JVM controls which Thread's turn it is to execute, etc).  But my understanding of this is that there is no way to control or predict whether one thread's next command will execute before or after another.

The reason I'm asking is because this seems like a fundamental difficulty for game development where a game is supposedly designed around a player's skill.  Consider a game like League of Legends.  Assume that two players are battling it out.  It's a very close contest between the two and it's coming down to the wire -- so much so that whoever gets their last attack off will be the one to kill the other and win the game for their team.

If the players are implemented using concurrency and the situation really was like this, is it essentially out of the players' hands at this point?  Is the outcome of this match all up to whatever system is arbitrarily deciding which player's thread/process will execute next?  If not, what am I misunderstanding about concurrency?  If so, is there any way around this problem so that a game of skill can always be a game of skill, especially in those most crucial moments?


texts: Workaround to losing the OpenGL context when Android pauses?

texts:
The Android documentation says:

  There are situations where the EGL
  rendering context will be lost. This
  typically happens when device wakes up
  after going to sleep. When the EGL
  context is lost, all OpenGL resources
  (such as textures) that are associated
  with that context will be
  automatically deleted. In order to
  keep rendering correctly, a renderer
  must recreate any lost resources that
  it still needs. The
  onSurfaceCreated(GL10, EGLConfig)
  method is a convenient place to do
  this.

But having to reload all the textures in the OpenGL context is both a pain and hurts the game experience for the user when reentering the app after a pause. I know that "Angry Birds" somehow avoids this, I'm looking for suggestions on how to accomplish the same?

I'm working with the Android NDK r5 (CrystaX version.) I did find this possible hack to the problem but I'm trying to avoid building an entire custom SDK version.


texts: Collision, triggering, and range detection in an RTS. What are the optimal solutions for unit spatial awareness?

texts:
I've finally ran into the problem of multiple triggers and collisions within my 2D RTS. Up till now I've been using unities sphere colliders as a way of simulating spatial awareness. To trigger when objects have entered and exited a specific area around a unit or building so that they can be appropriately targeted.

This became a performance problem when I started having hundreds of colldiers overlapping each other. Since the units are aware of projectiles as well as other units/buildings, this becomes very expensive very fast. I've found that I can only manage to have a couple hundred projectiles and about 100 colliders within close proximity of each other before the game slows to a crawl just from PhysX. (hundreds of projectiles entering and exiting 100 collliders all the time)

I did some research and found spatial partitioning mentioned all over the place. Is this a solution to the problem I am currently presented with? Are there other solutions for objects to have spatial awareness of potentially hundreds of other objects at a time without bringing my CPU to it's knees?


texts: Do you need expensive servers and fancy hosting in order to make a multiplayer game?

texts:
I've finished working on an RPG and it would seem so much more fun to make it multiplayer. SFML has a networking feature, I figured it's possible but then again, never in my life have I even tried something basic about networking, in fact my knowledge of it is very limited.

What would it take to make a multiplayer game resource-wise? I'm not talking about an MMO, more like a co-op type of game. Do I need mountains of cash to pay for hosting and servers and many many things to make one?


texts: How to load a mesh from the .X-format in DirectX10 via SlimDX?

texts: As of DirectX10, the usual functions to load a mesh in the .X-format are marked as deprecated and they are DX9 functions anyway. How can I load a mesh from the .X-format into an ID3DX10Mesh object using the SlimDX wrapper?


texts: Parts of 3D model disappear during animation

texts:
I'm trying to properly play an animation done in Blender 2.8 inside my OpenGL application. When the animation is running, it happens that at some particular frames, some parts of the 3D model "disappear", by "disappear" I mean that they obviously get relocated at some incorrect position and rotation in the 3D scene.

The model is an FBX file.
Has anyone got an idea about what could be the possible reasons for that?
Maybe some wrong settings in Blender?

Thanks in advance!


texts: How do games such as aa Game have high levels in the structure of their code? I mean if we want create a game with high levels, should we create and use a class for each level? I do not want code from you. only I want know for creating a game with high levels in android, What we should do in coding? Is it good if we create and use a class for each level?


texts: Unity 3d Forge Networking: Transfer object ownership

texts:
I have a simple chess game setup to play around with the Forge Networking asset.  I am having an issue where only the server is able to click and drag pieces around the board.  If a client attempts to move a piece, it gets snapped back to its original position.

I assume this issue is because the server is the actual owner of the NetworkedMonoBehaviour components on my chess pieces.  Is it possible to transfer ownership of a NetworkedMonoBehaviour in code?  It seems that all of the owner properties have protected set methods so I am unable to access any of them.


texts: Is it possible to use Metal and SceneKit at the same time?

texts: All the tutorials that I've found online speak about using Metal alone, without any other supporting library. But I don't understand if it's possible to create a SceneKit game and then use a Metal layer just to make some optimizations.


texts: How do I generate platforms in a specific position in godot?

texts: I am making a rogue-like game in Godot. Currently, I am stuck with the world generation. I know how to add children, but I am wondering if there is a way to add those children in a specific position. I also need to know how to add nodes to an array, and then choose one from the array to spawn.


texts: How do i make an object to be visible only on a particular layer?

texts:
Please refer the image below to understand.

I am working on 2D game. I have three elements: "background(layer 0), foreground(layer 1) and the object".

I have used sprite renderer to set background and foreground images. Object gets instantiated during runtime.

How do i make Part-A of the object invisible? I want to make object visible only on foreground. If the object is completely on the background, it should be completely invisible. if the object is completely on foreground, it should be completely visible. Part-A and Part-B are just for reference. It is one single object.

The goal to be achieved is the image below:


texts:
I'm focusing on a game for the Android platform, and thinking of building multiple versions with different themes. Every one of them would have a distinct name, graphics, and content, but the same game engine.

I would be maintaining the same code base for these 20 apps. If I capitalize on this format with different themes, is that forbidden in Google play?


texts: Rigid body falls through static mesh even though collision is detected

texts:
I'm using Jitter Physics to create a game. For testing, I have ball (a spherical rigid body) falling onto a small box-like mesh. The problem is that the ball falls straight through the floor, even though the collision seems to be detected properly.

The mesh's rigid body is created using a triangle mesh shape. In the code below, model is the floor's 3D model

Octree octree = PhysicsUtilities.ExtractOctree(model);
octree.BuildOctree();

Body body = new RigidBody(new TriangleMeshShape(octree));
body.IsStatic = true;

The PhysicsUtilities.ExtractOctree function extracts vertices from the 3D model in order to create the rigid body. As far as I can tell, that function is working correctly (i.e. all vertices and indices look correct). To check if the collision was detected, I added a callback function as follows.

CollisionSystem collisionSystem = new CollisionSystemSAP();
collisionSystem.CollisionDetected += OnCollisionDetected;

World world = new World(collisionSystem);

The ball-floor collision is detected and everything about the collision looks correct. I've even tried changing values in world.ContactSettings, but nothing worked.

Has anyone else experienced this problem? I've tried everything I can and Jitter's documentation is pretty low.


texts: Should I separate the Pathfinding info from the Tile Info class?

texts: I have implemented A* on a Tile Based Game, my Tile class contains a lot of info like Position, TileType, Items, Characters, etc on it. Right now that class has the Edges references(neighbours), movement cost, etc. Should I create a new Class like Node to just contains the Pathfinding related info?


texts: Where does the game code fit into the engine?

texts:
I was wondering if somebody could tell me how the game and the game engine fit into game development. What I specifically mean is, the game engine does not actually contain a game. Do game developers build an engine, then create a new class that inherits from the engine, which becomes the game?

For example,

class ShooterGame : public Engine
{
};

I'm not sure about where the game code fits into the engine.


texts: Can you use A* to make a unit move nonspecifically?

texts:
A* is typically used to calculate the best way to move towards something, and it's quite flexible when it comes to threats, extra movement costs, and 'refuelling' on the way to something.

However, if you designate only threats, perhaps with a main threat first and foremost, can you use it for "finding somewhere to go"? What about adding both threats, safety, resources and other such heuristic influencers to determine what a unit does when idle?


texts: What scripting language should I choose for my game?

texts:
In what cases are what scripting languages better than others?

All answers are appreciated, please provide a description, and describe in what cases the language excels in.


texts: Tracing a 2d path through multiple gravity fields

texts:
For a projectile starting at origin O, an initial velocity V, and several stationary planets P[n], how would I pre-calculate and store the path it would take without actually stepping through each frame along the curve?

I have some idea of how to do this for a single gravity source (conic section, parametric curves), but how do you blend multiple forces, and thus multiple curves, together?

The idea is to give the player some idea of the trajectory their shot will take, so it doesn't need to reflect the actual path exactly, but the closer the better.


texts: What is the "DirectX for Managed Code Update"?

texts:
I came upon this site while looking for information about working with DX in managed code and saw that MS released something containing a 'DirectX for Managed Code Update'.
This sounds promising but I can't find much information about it.

Is this an out of date update referring to what was formerly Managed DirectX, or something new*?

If new, has anyone used it? How does it compare to SlimDX?

(*as new as it can be from June last  year)


texts: Why divide by w makes the pixel shader look better?

texts:
I'm writing a shader in HLSL (Direct3D11 with SharpDX) and after some computations I was trying to make a test and print the depth z of a specific point in my pixel shader, like this:

myZ = input.p.z;
color = float4(myZ, myZ, myZ, 1.0f);
return color;

The result of this is the one I expect, but though I see what I expect (pixels darker as I get closer and lighter when they are far away), I have to move the camera quite close to the model to start seeing some darker pixels. If not, everything is white.

The thing is, if I do this instead, as I read in some forum:

myZ = input.p.z/input.p.w;
color = float4(myZ, myZ, myZ, 1.0f);
return color;

then I can see everything from the beginning much finer. The problem is I don't understand the logic behind this. Why would this help and why would it make sense.

Any help appreciated, thanks!


texts: Is it more efficient to store my tile grid as a dictionary or an array?

texts:
I've just started making a video game in AS3, and I'm trying to keep the graphics, sound, and actual game state in three completely different spots and sets of classes.  That being the case, the graphics module will have to repeatedly parse the state module.  The game is divided into levels, and each level is divided up into square spaces (like a board game); thus the graphics module will have to repeatedly parse out a certain cross-section of spaces of the current level.

The player will always show up in the middle of the spaces' overall graphic (the "Grid"), and there will be 4 spaces in every direction from the player's positioin that will be displayed, along with any object each space may contain (such as the player, a monster, etc.).

So right now I'm trying to decide how to store the spaces in each level (all of the level's spaces themselves, not the graphics).  The first thing that came to mind was a 2D Array.  Then I started to use a 2D Vector, then came back to using an Array, like at first; and now I'm wondering whether to use an Array or a Dictionary.

The problem:

Let's say a level looks like this:

xxxxxxxxxxxx
xxxxxxxxxxxx
xxxxPxxxxxxx

x's are blank spaces, P is the space that the player.  As the Grid parses this information, if it's a 2D Array, then it can use the length property of the main Array and the length property of each sub-array to set up its for loops reasonably well.  Furthermore if a space is outside the bounds of the 2D array, then rather than wasting memory trying to form more objects in the code or something, the Grid can just assume the space is blank:

var arr:Array;
var space:Space;

for (var i:int = level.playerX - 4; i <= level.playerX; i++)
{
    arr = level.spaces[i];
    if (arr)
    {
        for (var j:int = level.playerY - 4; j <= level.playerY; j++)
        {
            space = arr[j];
            if (space)
            {
                // find every object inside space and animate accordingly
            }
            else
            {
                // assume the space is blank
            }
        }
    }
    else
    {
        // assume the whole column of spaces is blank
    }
}

Within the player's radius, the Grid must animate any non-existent spaces as blanks.  Therefore the graphical output is as follows:

xxxxxxxxx
xxxxxxxxx
xxxxxxxxx
xxxxxxxxx
xxxxPxxxx
xxxxxxxxx
xxxxxxxxx
xxxxxxxxx
xxxxxxxxx

But now if we have a level that looks more like this:

xxxxxxxxxxxxx
xxxxxxxxx
    Pxxxx
    xxxxx

then using an Array leaves two basic options:

Use null elements within the sub-arrays to get the Grid to animate non-existent spaces that come before the real ones in the sub-array (the sub-array's length can be used for non-existent spaces that come after the real ones).
Make that simple for-looping inside the Grid a whole lot more complex to compensate for rows and columns of spaces starting at variable locations along each axis (and not simply ending at variable locations).

I don't want to use option 2.  I was just going to use option 1 with Arrays, but now the possibility of using Dictionaries instead has come to mind.  At least with Dictionaries, I wouldn't have to just waste memory every time I wanted, let's say, for the first space in a row to begin at postion 5.

Sorry, I know this was lengthy, but I hope I've illustrated the problem.  Which is better - an Array, or a Dictionary?  If a Dictionary is better, should it use sub-Dictionaries or sub-Arrays to establish a 2-dimensional effect?  Thanks!


texts: Update DXGI swapchain sample count without recreating swapchain in full-screen mode

texts:
I'm implementing the ability to tweak graphics settings in my application at runtime (resolution, refresh rate, v-sync, multisampling).
It is possible to update the resolution, format and refresh rate using IDXGISwapChain::ResizeTarget and IDXGISwapChain::ResizeBuffers. However, I cannot find any way to update the swapchain's sampling(count and quality) in the same way. The only option I have is to go to windowed mode using IDXGISwapChain::SetFullscreenState, then release the swapchain, recreate the swapchain with a new DXGI_SWAP_CHAIN_DESC, and then go back to fullscreen again. (Didn't mention releasing and recreating back buffer and depth stencil since it is a must do).I am willing to stay at full-screen mode before and after the settings are applied.


texts:
I'm currently facing this problem: If I click on a Button on my Canvas, the currently selected Unit moves towards the location under the Button.

Is is there any option to solve this? I'm using the A* Project for this.

Sadly, I can not provide a lot of things I've done so far as I absolutely have no clue how to solve this problem.

If I disable the Button Option "Raycast Target" ist still moves to this position but holds a bit earlier.

Also, adding this as check didn't work:

if (!EventSystem.current.IsPointerOverGameObject() )

I also checked if the Raycast hit's the layer of the GUI

My Movement code so far:

public override void MouseClick(GameObject hitObject, Vector3 hitPoint, Player controller)
    {
        base.MouseClick(hitObject, hitPoint, controller);
        if (hasAuthority && player && player.human && currentlySelected)
        {
            if (hitObject.name == "Ground" && hitObject.name != "UI" && hitPoint != ResourceManager.InvalidPosition)
            {
                float x = hitPoint.x;
                float y = hitPoint.y + player.SelectedObject.transform.position.y;
                float z = hitPoint.z;
                destination = new Vector3(x, y, z);
                //Debug.Log("Start_Move");
                StartMove(destination);
            }
        }
    }


texts: Moving walkway in Three.js - pathfinding algo or vector math ala Nature of Code?

texts:
I am trying to develop a moving walkway for a 3D virtual space made in Three.js (link here).  Right now guests navigate using WASD or the arrow keys and the mouse to look around.
My goal is to have guests would navigate themselves onto the walkway and be moved along a path through the space, like a high speed lazy river.  They could hop off any time once they reach their destination.
I was planning on using vectors and adapting some steering behaviors code from The Nature of Code series (which is based on Craig Reynolds' steering behaviors).  I would accelerate the user once they're on the path and keep them on the path using steering, until they move themselves off.
I am curious if there is a better way to do this and determine the pathway.  I checked out Don McCurdy's Three.js pathfinding work, but it requires that you build an external mesh in something like Blender and import that into Three.js, which I haven't been able to do yet.  A lot of Blender's options have also changed since he wrote the tutorials, so it's hard to map.
I'm all ears if anyone has suggestions.


texts: Microsoft OpenGL layer via software emulation - docs

texts:
I would like to know about the main specs about this layer that renders OpenGL through software emulation.

What are the supported extensions and what is the OpenGL version supported?
Fixed or programmable pipeline?


texts: Binding Lua Function to Perform tasks using std::async

texts:
I am trying to load a bunch of mesh resources in the format of .obj files. Some of the files are very high in poly count so when loading using the below method It takes more than 10 seconds. I would really like to cut this time down.
My question is how can I bind this to call loadMesh with std::async? Because I think that might help speed up the process.
Mesh *Loader::loadMesh(const std::string &path)
{
    std::shared_ptr<Mesh> mesh = Mesh::load(path);

    m_meshes.push_back(mesh);

    return m_meshes.back().get();
}

.
.
.

//this is the binding
    luabind::module(m_world->getLua()->get())
    [
        luabind::class_<Loader>("world")
            .def("load_mesh", &Loader::loadMesh)
    ]


texts: Get perpendicular vector from another vector

texts:
I should clarify that I understand there is an infinite amount of 'perpendicular' vectors in 3D space. I am creating an electricity effect, and to do this the ability to have any number of perpendicular vectors is a good thing. The hard part is how to select any random one of these vectors - how would I do that, given a base vector "direction" which has been normalised?

Keep in mind that I want the resultant vector to be random, not just always up and down on the y-axis or anything.


texts:
Flash has come a long way in the last decade, and it's a well-kept secret getting a Flash game to connect to a multi-client server for chat and/or basic avatar movement in real time.

Why has the industry as a whole not made this a common-knowledge type of thing yet? We keep pushing to the web but I am finding it incredibly difficult gathering learning material on this subject.

Sure, I can find multi-client server socket tutorials in various languages (using select statements and/or threads to handle multiple socket connections), but in regards to Flash applications inside of a browser? NOPE!

Can everyone please share what they know? :] It's a subject I'd really love to get into but I'm afraid I just honestly don't know enough about how to do it.


texts: XNA Moddable Game - Architecture Design and Reflection

texts:
I've decided to embark on an XNA moddable game project of a simple rogue style. For all purposes of this question, I'm going to not be using a scripting engine, but rather allow modders to directly compile assemblies that are loaded by the game at run time. I know about the security problems this may raise.

So in order to expose the moddable content, I have gone about creating a generic project in XNA called MyModel. This contains a number of interfaces that all inherit from IPlugin, such as IGameSystem, IRenderingSystem, IHud, IInputSystem etc.

Then I've created another project called MyRogueModel. This references MyModel project, and holds interfaces such as IMonster, IPlayer, IDungeonGenerator, IInventorySystem. More rogue specific interfaces, but again, all interfaces in this project inherit from IPlugin.

Then finally, I've created another project called MyRogueGame, that references both MyModel and MyRogueModel projects. This project will be the game that you run and play. Here I have put the actual implementation of the Monster, DungeonGenerator, InputSystem and RenderingSystem classes. This project will also scan the mods directory during run time and load any IPlugins it finds using reflection and override anything it finds from the default. For example if it finds a new implementation of the DungeonGenerator it will use that one instead.

Now my question is, in order to get this far, I have effectively 2 projects that contain nothing but interfaces... which seems a little... strange ? For people to create mods for the game, I would give them both the MyModel and MyRogueModel assemblies in which they would reference. I'm not sure whether this is the right way to do it, but my reasoning goes as follows :

If I write 1 input system, I can use it in any game I write.

If I create 3 rogue like games, and a modder writes 1 rendering system, that modder could use the rendering system for all 3 games, because it all comes from the MyModel project.

I come from a more web based C# role, so having empty interface projects doesn't seem wrong, its just something I haven't done before. Before I embark on something that might be crazy, I'd just like to know whether this is a foolish idea and whether there's a better (or established) design principle I should be following ?


texts:
Hey guys, I'm not sure if this is the right place to ask, but I'm also not sure where else to ask.  I have a 3D model in Solidworks that is imported from a STL file.  Solidworks imports the file multiple triangular faces and as either a solid, or a surface.  See pic below:

What I need to do is take the model and have it be hollow but with a thickness, not that big.  Also it would help to have the surface be one smooth surface since I will be imported it to another program, ADINA.  Any ideas or suggestions?


texts: How to achieve sprite reflection effect in libgdx

texts:
I am currently working on an open world game similar to Pokemon using libgdx. I am currently stuck on this effect that I really want to be done before moving to other features of my game. How can I achieve the following water reflection effect?

I also want it to shimmer like in this video:

"Pokémon Sapphire | Reflections in the water | Episode 4" - 3:38


texts: How can I properly add material textures to my model?

texts:
This is the first time I'm doing game development and I decided to pick Godot engine.

I downloaded some object on the internet for my initiation learning. There are four files:

throp_srub.obj
normal.tga
diffuse.tga
throp_srub.fbx

The fbx didn't appear on the sidebar, so I drag the object mesh and then add spatial material, add diffuse.tga texture to albedo and normal.tga into normal map.

However, it didn't appear as the preview given:

The object appears like this:

Why is that and how can I fix it?


texts:
I'm currently trying to implement the lighting technique described in this article.

I've done pretty much exactly what is done in the article. My technique is the same, and my shader is the same. Here's my problem:

The lighting looks great when everything is kind of dark, but when it's not dark, the lights are far too bright.

This what it looks like when it's dark:

And here's what it looks like when it's light:

As you can probably tell, the light in the second image is far too bright. I'm looking for something about as intense as the first picture, but with the overall lighting like the second picture.

My fragment shader code is as follows: (Vertex shader is not relevant)

#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
varying LOWP vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
uniform sampler2D u_lightmap;
uniform LOWP vec4 ambientColor;
uniform vec2 u_resolution;
void main()
{
    vec4 diffuseColor = texture2D(u_texture, v_texCoords);
    vec2 lightCoord = gl_FragCoord.xy / u_resolution.xy;
    vec4 lightColor = texture2D(u_lightmap, lightCoord);

    vec3 ambient = ambientColor.rgb * ambientColor.a;
    vec3 intensity = ambient + lightColor.rgb;
    vec3 finalColor = diffuseColor.rgb * intensity;

    gl_FragColor = v_color * vec4(finalColor, diffuseColor.a);
}

ambientColor is set to (1, 1, 1, alpha) or (white, alpha), where the higher the alpha, the lighter it is. The dark image is 0.1f, and light is 0.9f.

I think the problem is with ambient + lightColor.rgb, but I am not sure how else I could write it and maintain the same effect for when it is dark.


texts: Repeat image on a fixed background, Cocos2D?

texts:
I'm quite new to Cocos2d, does anyone know how to create a background that would be one fixed screen (no scrolling), with a small image just repeated to the whole size of the screen - depending on device?

The best way I can explain the look I'm after is something similar to repeating a small image for a website background.

Thank you in advance for any help :)


texts: C++ Data structure pattern preferability?

texts:
So im looking at ways of handling large amounts of data in situations such as an entity manager or particle system.

So i have concluded to use an object pool, and there are two things that I could do to keep track of the free locations.

I can either have a free list through a linked list or use implement the array as a sorted list.

Both of these methods will work and i am sure there are more. My question is what is the difference and prefered usage cases for each of these methods, and if there is any difference at all.

If u have an questions please ask, and this is a real question and if u find a "duplicate" please check with me first in the comments. Ive had people mark my questions in the past as a duplicate when they were in fact unrelated.


texts: Best pathfinding algorithm for a tower-defense game?

texts:
What do you suggest would be the best algorithm for a tower-defense game? It's a 2D based tile game, where there is walls and towers blocking the way, between spawnpoints and their destination points.

Constantly, as the player places a new tower to block the way, or to help shoot spawning units before they reach their destination, a new path for the affected spawnpoint's path will have to be recalculated, and the units must be re-routed to that new path.

Therefore, I need performance.

I tried the A* algorithm, but everytime the player places a new tower, and path has to be recalculated, the existing units who haven't gone past the tower yet, get lost, and stand still, since they were a part of the old path that has now lost its pathing information.


texts: Why Are These 3D Square's Pixels Spaced?

texts:
So i'm currently attempting to write a 3D renderer. From no prior knowledge because I want to challenge myself. But I'm stuck here, and thought I'd bring it to StackExchange because I always see brilliant solutions! If more code is needed please just ask!

This Is My Square Render Code:

public void renderSquare(int xPos, int yPos, float zPos, int width, int height, int color) {
    clearArray();

    for(int y = 0; y < height; y++ ) {
        int yy = y + yPos;

        for(int x = 0;x  < width; x++) {
            int xx = xPos + x;

            float xS = -1f, yS = -1f;

            if(xx < centerX ) {
                xS = ((xx / zPos)) + centerX;
            }else {
                xS = ((xx / zPos)) - centerX;
            }

            if(yy < centerY) {
                yS = ((yy / zPos) - 0.5f) + centerY;
            }else {
                yS = ((yy / zPos) - 0.5f) - centerY;
            }

            setPixel((int)xS, (int)yS, color);

        }
    }
}

Plus How I Set Pixels:

public void setPixel(int xPix, int yPix, int color) {
    if(xPix < 0 || xPix > width || yPix < 0 || yPix > height)
        return;
    try {
        render_buffer[xPix + yPix * width] = color;
    }catch(Exception e) {
        return;
    }
}

Any help is appreciated]1


texts:
I am currently building a AI system for a game. I am familiar with State design pattern and implemented different states for each agent in my game.

Different states are like Running, Attack, Idle, Cover, Support etc.

In this game, I have around 10 agents which have mainly two behaviours - Defender and Attacker.

I made a class AIManager which have reference of all agents in the game. This class decides which agent will do what but I am facing issues in managing this class. There are many rules in the game like -

There will be two teams.
Each team will have 2 defender and 3 attackers.
Attacker will attack attackers and defenders.
Defender only attack to defenders.
At a time only two agents can attack a single agent.
If defender is in cover, it will not go to support state.
If defender is attacking, it will not go to run state.
If attacker is attacking, it can run away on specific condition.
... etc

To make these rules applicable, my AIManager class is totally mess, contains lots of if/else, need to check every possibilities, for loops. I am sure I am not doing right in implementing these game logic because when I need to change some rules or need to add another state, I need to go through all my game logic. This manager code is totally unstable.

I want to know how to tackle this situation, Is there any design pattern which I should follow or any suggestion would be of great help.


texts: How do I write a shader that lights up when objects are near a surface?

texts:
In this Overwatch gameplay video, the character's shield lights up white in areas that are near other objects' geometry.

Note the white edges on the blue shield, near the floor, walls and pillar.

I believe the shield has its own model and the effect is done with a shader, but I'm lost trying to figure how to translate the concept of "nearness" to shader programming.


texts:
I am a Unity noob trying to recreate something I did a long time ago in raw OpenGL.

I draw a scene normally glCullFace(GL_BACK), and then draw the walls a second time with face culling flipped glCullFace(GL_BACK) and a semi-transparent alpha to everything.

So my question is how to achieve this in Unity?

Can I basically set up Unity to draw the scene twice, the second time with the new culling mode, a global alpha and perhaps only drawing meshes that are children of node with a particular tag?

Or is there some better or other way to achieve this affect?


texts:
I'm working on a project where we would like to create a more "intelligent" bot in CS:GO (as a training-bot that you can play against in offline mode). We're currently in the start-up process and there's some initial questions. Would be greatly helpful if anyone can help out with some answers!

After some research there seems to be difficulties developing bots for CS:GO as a third-party-bot developer. Is it only VALVE that develops bots for CS:GO or is it possible for a developer to create a bot in CS:GO? Is anyone here comfortable with developing bots for games such as CS:GO? If so, it would be awesome to get some more in-depth answers about our project.


texts: Code optimalization - Mass selecting units (RTS)

texts:
Yo fellow game developers!

So recently gamedev became my favorite hobby and I started working on my RTS game module which would then let me create different RTS games with just few changes (W3 inpiration :3). Anyway I am new to optimalization since my previous games had quite serious optimalization issues so I need your help with a pieace of code!

I am having a mass selection of units with drawn rectangle on screen. I've got it all worked out but now I am wondering if there could be anything done about optimalization for cycling through list of units every time my mouse position changes even for a little bit.

This is inside my Update function. There is much more in there so i cut it out but this is the piece I am worried about:

    void Update(){
        //...previous code blah blah blah...
        if (Input.GetMouseButton(0)) {
            oldPos2 = point2;
            point2 = Input.mousePosition;
            if (oldPos2!=point2) {//performance optimalization
                Debug.Log ("Performing selection");
                if (Vector2.Distance(point1,point2) >= selBoxIniDist) {
                    isSelecting = true;
                    foreach (var item in Game.Units) {
                        if (IsWithinSelectionBounds (item.gameObject)) {
                            item.Selected = true;
                        } else {
                            item.Selected = false;
                        }
                    }
                }
            }
        }
        //...rest of the code here...
    }

So as i told you, there is no problem with the code. I just need your opinion if there could be any changes especialy to this part of the code. Or maybe general advices for optimalization.

Even tho I am checking every update if the mouse moved (so I dont cycle every update) I still feel like checking every "milimeter" 5 times if any of the units are contained in the viewport rectangle is a little bit overkill just for the selecting units. At the end of selection I usualy end up with around less than 100 cycles.

What do you think?

EDIT:
I might as well add a method that checks if the unit is in the viewport bounds and a utility method that calculate the bounds. Just so you why I am worried about performance.

Checking if bounds contain unit:

public bool IsWithinSelectionBounds( GameObject gameObject )
    {
        if (!isSelecting) {
            return false;
        }

        var camera = Camera.main;
        var viewportBounds = Utilities.GetViewportBounds( camera, point1, point2);

        return viewportBounds.Contains(camera.WorldToViewportPoint(gameObject.transform.position));
    }

Static utilities:

public static Bounds GetViewportBounds( Camera camera, Vector2 screenPosition1, Vector2 screenPosition2 )
{
    var cam = Camera.main;
    var v1 = cam.ScreenToViewportPoint( screenPosition1 );
    var v2 = cam.ScreenToViewportPoint( screenPosition2 );
    var min = Vector3.Min( v1, v2 );
    var max = Vector3.Max( v1, v2 );
    min.z = camera.nearClipPlane;
    max.z = camera.farClipPlane;

    var bounds = new Bounds();
    bounds.SetMinMax( min, max );
    return bounds;
}


texts: LibGDX How can I draw a line at a specific angle

texts: I'm working on a 2D platformer, shooter game and I'm attempting to draw a line to serve as a guide to indicate where the player is shooting. The line should be drawn from the player's sprite to the mouse's position. I need to draw a line between the player and the mouse, at the angle from the player to the mouse, how can I do something like this? Here is a concept picture to explain what I'm talking about:


texts: Handling XBox 360 Controller Connections in LibGDX after Game has Started

texts:
I am currently making a game with the java library LibGDX and want to add XBox 360 controller support using the GDX-Controllers extension. At the moment I have a setup where I create a listener to listen for particular button presses, then attach that listener to the static Controllers class using the method: Controllers.addListener(myListener)

This method works fine for listening for button press events from controllers which were connected at the time the program started but, if I try connecting a controller after the game has started, events for this controller are not registered.

I cannot see from the source code a way to update the listener for new controllers, and it appears from this blog post that disconnects and re-connects may not be supported on the desktop.

My question is: Is there a solution to my problem using GDX-controllers and, if not, what are my options for getting full Xbox 360 controller support (Including controller connects and disconnects) If I want functionality which integrates with the libGDX framework?


texts: Multiplayer game, client side prediction problem

texts:
I have been following this guide http://gabrielgambetta.com/fpm1.html for my 2D platformer multiplayer game.

However I can't do client side prediction in my game. I'll try to make an example.

[Client Perspective]
My game is locked at 60 fps, the client sends to the server every frame if some input has changed and records it. For example client sends to server that key left is pressed. Client moves the player every frame, (lets say velocity is 1) so during 30 frames the client moves the player 30 pixels to the left, 1 pixel per frame. Now at frame 30 client releases the left key, sends the input change to the server and player doesn't move anymore.

[Server Perspective]
Meanwhile the server receives the first input change, now every frame server moves the client player 1 pixel to the left every frame. Later it receives the second input change, the key release. Client player doesn't move anymore. Server sends X position to the client.

Now the problem. Ignoring the fact that I need to determine the order of the received packets in the client and compare it with the input packets sent that have not yet been processed by the server, without even going into this. The server response will never match with my client prediction.

Why?

Because between the first packet (key press) and the second packet (key released) received by the server there may have been 25, 30, 40 or even 60 frames server side, because UDP packets are unreliable, so in the server the player may have moved 25, 30, 60, etc pixels... And in the client only 30. So when the server sends the player X position to the client it will never match with the clients X.

Someone can help me? Thank you in advance.


texts: removing box2d objects before collision occurs

texts:
I am having a problem with a collision detection between the character and items, both created as box2d objects.
What I am trying to do is to delete the item or remove item from the collision method before character hits item and bounces away. Thus, I want to detect when the item and character collided to gain item effects.

Current sources are as below :

mWorld.setContactListener( new ContactListener() {
        @Override
        public void endContact(Contact contact) {
        }
        @Override
        public void beginContact(Contact contact) {
            Body bodyA = contact.getFixtureA().getBody() ;
            Body bodyB = contact.getFixtureB().getBody() ;

            Box2DUserData dataA = (Box2DUserData) bodyA.getUserData() ;
            Box2DUserData dataB = (Box2DUserData) bodyB.getUserData() ;

            if( dataA.id == Box2DUserData.ID_ITEM ) {
                //mWorld.destroyBody(bodyA);
                //bodyA.setTransform(new Vector2( 0, 0 ), 0 ) ;
                bodyA.setActive(false );
            }
            else if( dataB.id == Box2DUserData.ID_ITEM ) {
                //bodyB.getWorld().destroyBody(bodyB);
                //bodyB.setTransform(new Vector2( 0, 0 ), 0 ) ;
                //mWorld.destroyBody(bodyB);
                bodyB.setActive(false );
            }
        }
    });

This source works okay, but the bodies are removed after collision detection. So I can get the character walk through items, after the character bumped in item and stopped for a frame or so.

I am not sure if I am supposed to use World.setContactListener or another method, it would be grateful if someone could give me the right method or another way to detect collision and the way to remove body from collision method before it actually collides.

Thanks


texts: Why does unlocking cursor with keyup behave the same as unlocking it with keydown?

texts:
To understand the difference, let me review a bit about the behavior of GetKeyUp and GetKeyDown with the following code snippet.

void Update()
{
    if (Input.GetKeyDown(KeyCode.Escape))
    {
        Debug.Log("Escape Key Down");
    }

    if (Input.GetKeyUp(KeyCode.Escape))
    {
        Debug.Log("Escape Key Up");
    }
}

Right after pressing the Esc key (and holding it), a message "Escape Key Down" is produced. Later right after releasing the key, a message "Escape Key Up" will show.
The behavior does make sense.

Now I apply this for toggling (locking/unlocking) the mouse cursor. Here is my code snippet.

void Update()
{

    if (Input.GetMouseButtonDown(0))
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    if (Input.GetKeyUp(KeyCode.Escape))
    {
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible = true;
    }
}

Right after clicking the left mouse button, the cursor becomes invisible. However, right after pressing down the Esc key, the cursor becomes visible again. The expected behavior is that the cursor will be visible right after releasing the Esc key rather than right after pressing the key.

Question

How to fix this abnormal behavior?


texts: Mixing perspectives in an oblique-perspective game

texts:
I've been creating an adventure game using 45 degree angled tiles to create a 3D illusion- aka oblique style.

Using 45-degree angles...

I can create pretty much any size or shape building I want:

I found I can easily get another perspective if I simply flip the tiles horizontally:

While doing this gains an oblique perspective from the other way, it does change the vanishing point to be in the center of the map, versus towards the top left.

Is this style of mixing perspectives common? Does it ruin the perspective or add to it? I thought that just maintaining the point of origin at the top left the whole time would be monotonous.

To be clear, I wouldn't keep the two styles together. It'd be either like the buildings on the river or the buildings in the northwest.

Thanks

Edit: More of a full shot:


texts:
I would like to generate random cave type backgrounds similar to the one shown below.

I doubt anything I generate will look as good as the image, but something with that feel of sharp, jagged peak should be possible.

I don't have any experience in procedural generation and as such have no idea where to start....

Note: I am using libGdx on Android


texts: Unity List script field with +/- buttons in editor

texts:
I am using Unity 2018.4.11f1 LTS. I have a script with a public List<GameObject> field.

In the property inspector, Unity provides a UI to this field where you specify the size of the list and then assign elements:

public List<GameObject> receivers;

My question is: Is there a way (perhaps a different field type) to have Unity provide an editor UI that consists of a +/- button where you can add and remove elements, rather than a list-size-based UI?

Something more along the lines of e.g. what it gives you for UnityEvents:


texts: Lighting-Reflectance Models & Licensing Issues

texts:
Generally, or specifically, is there any licensing issue with using any of the well known lighting/reflectance models (i.e. the BRDFs or other distribution or approximation functions):

  Phong, Blinn–Phong, Cook–Torrance, Blinn-Torrance-Sparrow, Lambert,
  Minnaert, Oren–Nayar, Ward, Strauss, Ashikhmin-Shirley

and common modifications where applicable, such as:

  Beckmann distribution, Blinn distribution, Schlick's approximation,
  etc.

in your shader code utilised in a commercial product? Or is it a non-issue?


texts:
I'm using the Three.js JavaScript library to do some things in WebGL, and I wonder how the graphic aspects of timers are done on mobile.

I was creating numbers with geometries and just replacing them when needed. This was fine on desktop (or so I think, lol). Recently, I've been playing around with mobile and the previous method is far too slow.


texts: My friend is using Unreal Engine 4 v17. His problem is that when he exports to Android, the game is over 100mb in size. He's not using materials or importing anything. He found a (probably) useless file called "DefaultBloomKernel.uexp" and wants to remove it. How can that be done?


texts: Efficiently detect shoot direction with gravity playing a role?

texts:
How could I efficiently calculate shoot direction for enemy AI in order for it to hit the player?

Things I know:

player position, player velocity, gravity, bullet spawn position, bullet initial speed(not direction, gravity is also applied for it)

Bullets are slow and don't hit instantly.


texts: How can I make a custom memory allocation for classes with virtual methods?

texts:
I want to create a custom allocator that stores objects to the heap sequentially. The allocator itself is very simple. It just allocates a big chunk of memory and moves an offset as Allocate() calls happen.

The problem comes when allocating memory for custom types, especially classes with virtual functions.

SomeClassWithVirtualFunctions * address = array_allocator->Allocate(sizeof(SomeClassWithVirtualFunctions));
SomeClassWithVirtualFunctions->Init(...);

It throws a seg fault when the virtual function is called, since as i am given to understand, stuff that are initialized through the constructor (vtable for example) are now ignored.

However, if i do the following,

SomeClassWithVirtualFunctions * the_new_object = new SomeClassWithVirtualFunctions();
char * memory = array_allocator->Allocate(sizeof(*the_new_object));
memcpy(memory, the_new_object, sizeof(*the_new_object));
SomeClassWithVirtualFunctions->Init();

then the code works fine. I believe though that the above is a dangerous work-around trick.

The intend is to have a base class with virtual functions like Step() for example, that game classes like Player, Grass, Wall override to have unique behavior.

What is the best way to implement this? Do i use the custom allocator to store only primitive class members stuff, and classes are allocated normally?

Will overriding the new operator for SomeClassWithVirtualFunctions work?

void * operator new(size_t size) {
    char * address = array_allocator->Allocate(size);

    return address;
}


texts: Are JavaScript games exclusive to modern smartphones, or are older phone models also able to play games written in JavaScript?


texts:
From a game design perspective, I've got the following idea:

Traditional Tower Defense game. - an open, mazeable field as monsters approach the castle.

"Towers" consist of ground-pounding units like foot soldiers, moats, and other things. yawn

However, I'm adding the following features:

"Town" - a separate screen for
upgrading units and buying new
abilities.
"Tap Defense" - There are archers
sitting on the wall with excellent
range - tap monsters to shoot them.
RoF, Damage upgradeable in town.
"Tap Defense+" - for cash purchases,
you can buy wizard spells that deal
mega-damage (think Eagle in Angry
Birds).
"Underground" - the paid version will
come with Dwarven Sappers, which give
you an additional screen of "mazing"
and towers "underneath" the current
map, so you can build defenses in at
least 2 levels.

Is mazing, tapping, and 2 z-levels too much?

What kinds of things should be considered?  I already know that pausing while placing structures will probably be needed (or wanted).  Anything else?


texts:
Recently, I've been trying to use COLLADA files in OpenGL. The problem that a lot of people before me have run into is COLLADA's indice structure. It has multiple sets of indices, the first is for position, the second for the normal.
I know by now that it is completely impossible for OpenGL to use multiple sets of indices, so I must rearrange my normals so that I can use my position indices for my normals.

I've already made some code for this, but it doesn't seem to turn out right.

private static Vector3[] RearrangeNormals(Vector3[] norms, Vector3[] pos, int[] posindices, int[] normindices)
{
    Vector3[] newnorms = new Vector3[norms.Length] ;
    for (var i = 0; i < norms.Length; i++)
    {
            newnorms[posindices[i]] = norms[normindices[i]];
    }
    return newnorms;
}

With this function, it seems like half of my Suzanne mesh has it's normals correct, the other half... not so much. Here's an image of what I'm getting with my lighting test.

How should I handle rearranging my normals (or texcoords maybe in the future)?


texts: Does XNA support 1 dimensional textures. And by 1 dimension texture I mean something like Texture1d not a Texture2d where one dimension is 1 (because of the 4096 limit)