texts: Can this singleton class cause a memory leak?

texts:
In a game I'm writing using LibGdx, I'm wondering if a memory leak will occur on Android when the home key is pressed or a phone call gets received and the game gets put into pause.

I have a Singleton class which holds all of my games assets and I use a static method to get access to it.

public class Assets
{
    private static Assets assetsInstance;

    private Assets()
    {
        //load assets....
    }

    public static Assets getInstance()
    {
        if (assetsInstance == null)
        {
           assetsInstance = new Assets();
        }
        return assetsInstance;
    }

    public void nullAssets()
    {
        //here things are set to null
        assetsInstance = null;
    }
}

In my Main class:

public class Main extends ApplicationAdapter
{
    public static Assets gameAssets;
    private GameStateManager gsm;
    public void create()
    {
        gameAssets = Assets.getInstance();
        gsm = new GameStateManager(this);
    }

    public void pause()
    {
        gameAssets.nullAssets();
        gameAssts = null;
    }
}

My GameStateManager looks like this:

private int currentState;
private Main m;
private GameState[] gameStates;
private final in NUMBEROFSTATES = 6;
public static final int TITLESTATE = 0;
public static final int PLAYSTATE = 1;
//more states

public GameStateManager(Main m)
{
    this.m = m;
    gameStates = new GameState[NUMBEROFSTATES];
    currentState = TITLESTATE;
    loadState(currentState);
}

My GameState class:

public abstract class GameState
{
    protected GameStateManager gsm;
    protected Main m;

    protected GameState(GameStateManager gsm)
    {
        this.gsm = gsm;
        m = gsm.m;
    }

    //abstract methods
}

The game states all extend GameState.

By calling pause() in the Main class which sets gameAssets to null and also assigning assetsInstance to null, does that take care of everything needed to let the garbage collector remove the singleton? Or does the fact that GameState class has m = gsm.m; mean something will remain in the memory and become a problem?


texts: Loading and rendering one large image or many smaller ones

texts:
I am working on an android game with a top down style view similar to the original GTA's or a scrolling version of Legend of Zelda.

I have recently begun designing some prototype levels for the game which vary between a corridor style dungeon similar to diablo or an open area with obstacles similar to Zelda.  My question is would it be better to have one large background image and draw it once or a relatively small one (size of or less than the view) and draw it multiple times.

My concerns are the memory required to load/store a large background image vs the performance boost of only drawing one image.

Any input would be appreciated.


texts: Cocos2d/Cocos2d-x Attaching an arrow (sprite) to another body sprite (person)

texts:
I am trying to set up a simple bow and arrow game. When the arrow hits the enemy body, the arrow's body is deleted and the arrow sprite continues to update, keeping the position correct in relation to the enemy it hit. Picture an arrow sticking into a body and that body still rotating and moving. My problem is that the rotation is completely wrong when the enemy rotates. I know how to do this in 3d with matrix transformation but I can't seem to figure it out in 2d with Cocos.

Here is my method.

I save offset at which the arrow hit the enemy.
Every frame, I make the rotation of the sprite match the rotation of the enemy.
Then, I apply the offset I took initially which is where the arrow hit the enemy.

When they rotate, they rotate about their respective anchors and I am wondering if I need to set the anchor of the arrow to the center of the sprite. Does anyone know of an easy way to do this. If not, I will try to create an algorithm where the anchor is set to the offset divided by the width and height of the sprite image hopefully giving me the correct anchor values.

Then I assume I need to reposition the sprite.

Does anyone have a simpler way to do this?


texts: Traditional Chunk Loading vs. Chunk Swapping

texts:
I'm designing a voxel-based game (aren't we all?), and just yesterday implemented infinite terrain generation. I'd already had the terrain generation working off of simplex noise, so this wasn't a problem, and I've worked a lot with terrain generation before.. Anyway, I found myself hitting performance issues with the huge increase in "stuff to draw", so I started optimizing and disposing of vertex buffers for chunks that were out of frustum, then created a "SurroundingChunks(Vec3 position, int range)" function that as you may assume returns the chunks surrounding a position within a range. I used this to cull the chunks being even considered for drawing before the frustum check.

Performance is pretty good when it isn't generating new chunks (haven't multithreaded yet), but after I had already worked out the performance issue I came across an alternate solution, and I was wondering how it would compare.

In a normal chunk-based terrain, the player moves around in the chunks and chunks are loaded and unloaded depending on some algorithm/methodology. In this alternate method, there are a fixed number of chunks in existance. For the sake of simplicity, let's pretend we have a chunk-view-distance of 1, i.e., 8 chunks around the player and the one he's standing on for a total of 9. Instead of allowing the player to roam around infinite chunks, the chunks are replaced with others as the player proceeds in a direction. This could mean the player never moves, and some movement buffer dictates chunk changing, or it triggers when the player moves over a chunk boundary and then resets the player to the center (like many FPS mouse schemes, but with a player in 3D).

I drew a crappy little diagram in mspaint (don't have better tools on hand) to help illustrate this concept:

I'm curious whether this would perform better than doing all of the detection work for chunks in range and frustum culling followed by unloading any unneeded chunks, since it wouldn't require as much detection work. However, I am concerned that it would complicate things in the future, for example when there are enemy entities - they would have to constantly be position shifted with the land, etc..

I was hoping perhaps you guys would chime in with thoughts, pros, cons, opinions, etc.. :3


texts: How do I import Motionbuilder animation into my game?

texts: I have an animation sequence for a 3D model built in Autodesk Motionbuilder. How would import the data for the sequence into my java game for my model? Is there any tutorial on how to accomplish this? I already have my 3D model loaded into the scene.


texts: How to design a server for a multiplayer game?

texts:
I'm trying to write a multiplayer game where players join small matches with other players. What I also want is a way for players to login and go online. How would I design the a server that could handle logging in, matchmaking and the actual running of the match? I'd like to have multiple threads on the server to handle input from all the players, but I'm not exactly sure what I want to put in a single process and what I want to split apart. How would I set up the sockets for something like this?

I'd probably end up having this run on Amazon EC2 or something similar if that makes a difference.

I was planning on making the game a MOBA where there would be a small number of players (6-10) and latency would be relevant.


texts:
I'm trying to play a song in a MonoGame project, but it always gives me a weird error. Here is the (Very simple) code:

Song song = Content.Load<Song>("Song1");
        MediaPlayer.Play(song);

But whenever I run the program, it says this:

System.InvalidCastException: 'Unable to cast object of type 'Microsoft.Xna.Framework.Audio.SoundEffect' to type 'Microsoft.Xna.Framework.Media.Song'.'

Do you know why this happens? Any help would be appreciated! :D


texts: How can I decelerate a physics object to a stand still?

texts:
I am currently working on a little prototype and I am struggling to apply a friction force to slow down the player object.

I have a simple physics engine using the model of setting acceleration, which then is applied to the velocity before being applied to the position. To calculate the friction, before the acceleration is applied to the velocity, I multiply the velocity by -1 to the the opposite direction, then scale the magnitude by 0.5. I then apply this force to the acceleration by adding it to the existing acceleration.

This doesn't seem to work however, and the object just moves back and forwards erratically.

    constructor (x, y){
        this.r = 20;
        this.position = new Vector2(x, y);
        this.velocity = new Vector2(0, 0);
        this.acceleration = new Vector2(0, 0);
        this.maxSpeed = 2.3;
        this.friction = 0.5;
        this.createSprite();
        this.addForce(new Vector2(-5, 1));

    }

    createSprite(){
        let sprite = new PIXI.Graphics();
        sprite.beginFill(0xFF0000);
        sprite.lineStyle(5, 0xBB0000, 1);
        sprite.drawCircle(0, 0, this.r);
        sprite.endFill();

        this.sprite = sprite;
        this.sprite.position = this.position;
        app.stage.addChild(this.sprite);

    }

    move(){
        //this.calcFriction();
        this.velocity = this.velocity.add(this.acceleration); //apply acceleration to velocity
        this.limitVel();
        this.vel

        this.position = this.position.add(this.velocity);

        this.sprite.position = this.position;

    }

    limitVel() {
        let mag = this.velocity.magnitude();
        if(mag > this.maxSpeed){
            this.velocity = this.velocity.setMag(this.maxSpeed);
        }
    }

    addForce(force) {
        this.acceleration = this.acceleration.add(force);
    }

    calcFriction(){
        let negVel = this.velocity.scale(-1);
        let frictionForce = negVel.scale(this.friction);
        this.addForce(frictionForce);
        console.log(this.acceleration);

    }

}

This is the code I have written so far. The move function is called every frame.

I feel like there is one simple but important concept I'm missing here.

Thanks.


texts: How can I build Minecraft-style light propagation without recursive functions?

texts:
This question is more about expanding on an answer posted for an old but similar question.

Part of the answer says this:

  You simply fill the sunlight from the top to the bottom, every layer
  is gathering light from neighbor voxels in the previous layer with
  attenuation. Very fast - single pass, no lists, no data structures, no
  recursion.

I actually am having an easier time understanding how you would flood fill light for point lights. But doing so for sunlight, in one pass with no recursions, I still can't understand how it is done step by step.

Specific questions I would like to know about this:

Do you compare lighting of neighbor voxels only to the 4 cardinal directions, or do you check the up and down neighbors too?

If you don't store data structures for the lighting algorithm, how do you check for voxels that are already visited?

If there was a diagram explaining a step by step process of a single-pass light propagation that would be helpful. It seems like it would be easier on performance than casting several rays from each voxel to see if it hits light.


texts:
i just created a new HDRP project and my scene is blank. Pls Help!!!
Unity view:

Error: RenderTexture.Create failed: format unsupported for random writes - RGBA16 SFloat


texts: Resizing the camera view in Phaser 3 just like in Unity

texts:
I started to work in Phaser 3 with a previous background in programming in Unity and I can't figure out how to zoom the camera view. In Unity, I can change this value, to resize the camera view:

Then, everything in its view becomes bigger or smaller and it does not affect GUI elements, and the camera still fills up the full game window.
In Phaser I was trying to use those methods:
this.cameras.main.setSize(width,height) - it just resizes the camera making it smaller, and everything outside the camera becomes black
this.cameras.main.setViewport(x,y,width,height) - just as above, but x and y ads padding
this.cameras.main.setZoom(3) - the closest effect I want to achieve, but it zooms to the center of the scene, scales GUI elements and messes the camera bounds
I made an illustrative picture which can explain my problems better:

So how can I change the size of the main camera, to fit the game window and not scale the GUI, keeping the camera bounds at the same time?


texts:
The computer science major at my university requires that I take a sequence in either biology, chemistry, and physics, plus an additional natural science course (which I might fill with meteorology).  Since I'm into game development, physics is the obvious choice.  That, and I go to a big pre-med school; why damage my GPA being weeded out from a path I never wanted to take?

There are two main versions of the physics sequence, both covering the same material; one in three semesters, one in two, which I'm interested in.  The course descriptions (the best info I can get right now) follow;

  PHY 131: Classical Physics I

  First part of a two-semester physics sequence for physical-sciences or
  engineering majors who have a strong mathematics background and are
  ready for a fast learning pace. It covers mechanics, wave motion,
  kinetic theory, and thermodynamics. Calculus is used concurrently with
  its development in MAT 131. Three lecture hours and one recitation
  hour per week. The Laboratory component, PHY 133 (Lab 1), could be
  taken concurrently.

Since that's motion, waves, etc. it's obviously extremely useful, and therefore worthy of my attention.  No question there.  I'm going to take this in Spring of '13.

  PHY 132: Classical Physics II

  Second part of a two-semester physics sequence for physical-sciences
  or engineering majors who have a strong mathematics background and are
  ready for a fast learning pace. It covers electromagnetism, electric
  circuit theory, and optics. Calculus is used concurrently with its
  development in MAT 132. Three lecture hours and one recitation hour
  per week. The Laboratory component, PHY 134, may be taken
  concurrently.

(For reference, the descriptions for the three-semester versions are at this link, because they're a bit more descriptive.)

What I want to know is this; besides the obvious things like possible game design elements, does the material in PHY 132 play any significant role in game physics or similar?  If so, what are some examples?

I ask because if I can skimp on the material, I might take a PHY 132 equivalent online next summer at some community college.  That way I can ease the pressure on myself and free up a slot for something interesting.

At the very least, I might take a PHY 126 (part 2/3) equivalent online so I can take the more relaxed PHY 127 (part 3/3) that fall.  But I'd prefer the former option.

Any tips?


texts:
I am interested in implementing a map for my 2D action platformer. The map will be accessed when the player presses a certain button, and will show—at a very coarse grain—the sections of the world that the player has previously traversed. The sections are of various shapes and sizes, and I do not intend the map to show every platform and detail of each section, just a coarse grained shape of them and the various connections between them.

Ultimately, I want a map that looks similar to the one in Hollow Knight:

I am wondering what are some techniques for implementing this kind of map? It is hard to find info on how to implement this kind of map because of search result noise related to level design.

I image that I need to create an image of my final map, then define various areas on top of the image and link them to various area triggers in my level. When my player enters an area trigger in the world, I can send signal to the map to reveal and highlight the corresponding section of the map.

Is this a common technique?

How else could I implement this kind of map?

The engine I'm working in isn't important, so feel free to describe techniques in an engine-neutral way.


texts: Running into issues with Unity Vertical Layout Group

texts:
I feel sure that I'm missing something obvious, but I've been stuck with this over the past few days.

I want to make a relatively simple UI component for a character creation screen that looks something like this:

The structure is something like:

Canvas
-Panel
--Dropdown 1 Container
---Header
----Collapsible Body (Set as inactive)
-----Buttons for options
-----Buttons for options
-----Buttons for options
--Dropdown 2 Container
---Header
----Collapsible Body (Set as active)
-----Buttons for options
-----Buttons for options
-----Buttons for options
--Dropdown 3 Container
---Header
----Collapsible Body (Set as inactive)
-----Buttons for options
-----Buttons for options
-----Buttons for options
--Dropdown 4 Container
---Header
----Collapsible Body (Set as inactive)
-----Buttons for options
-----Buttons for options
-----Buttons for options
...

Unfortunately, some basic parts of this seem to be beyond my ability.

The panel that contains everything has a Vertical Layout group, but the "Spacing" can only be set to one value at a time, which doesn't work for this because the drop down boxes alternate between two sizes depending on whether they're active or not.
Grid Layouts don't seem to work either, because the cell sizes can't be changed dynamically.

Is there a simple option for this, or would I need to code something myself?

Thanks for any info you can provide.


texts: Unity has extreme lag while deleting trees from terrain

texts: So I have a terrain with sections of water in it. I just placed a whole bunch of trees in the scene with mass place. However, it spawned trees in the water which I obviously want to remove. But when I remove the trees, there a delay of a couple of seconds before it actually deletes them. This is so incredibly frustrating because my map is 8km x 8km so for me to have to go around every area of water and cliff and click, wait a few seconds and move on is going to take all day. Why can't I just click and drag without lag?


texts: How to have a point light with no falloff in Unity 3D?

texts:
Does anyone know of a good strategy to make point lights with no falloff, eg. anything in the radius of the light will be 100% illumination while anything outside the radius will be 0% illumination.

I want to use this as a sort of 3D line of sight drawing. The line of sight is a big sphere originating from the character's head that I thought would be a clever idea to have that represented as a point light, however with the falloff it doesn't correctly show where the edge of the line of site is.

I've tried a few solutions, such as a custom falloff package (doesn't seem to have the options I want) and a few shaders, but I am terrible at shaders so it's difficult for me to debug. I'll post the shader here in case somebody can tell me if I'm being dumb, otherwise if someone can point me to a different solution that would be great. Thanks!

Here's a shader I tried, but it just turns everything invisible and it's not immediately obvious to me why:

Shader "Custom/No Falloff v2"
{
    Properties
    {
        _Color("Color", Color) = (1,1,1,1)
        _MainTex("Texture", 2D) = "white" {}
    }
        SubShader
    {
        Tags{ "Queue" = "Transparent" }

        Pass
    {
        Blend SrcAlpha OneMinusSrcAlpha

        Tags{ "LightMode" = "ForwardAdd" }
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #include "UnityCG.cginc"
        #include "Lighting.cginc"

        // compile shader into multiple variants, with and without shadows
        #pragma multi_compile_fwdadd_fullshadows
        // shadow helper functions and macros
        #include "AutoLight.cginc"

        sampler2D _MainTex;
    float4 _MainTex_ST;

    fixed4 _Color;

    struct v2f
    {
        float2 uv : TEXCOORD0;
        SHADOW_COORDS(1) // put shadows data into TEXCOORD1
            float4 pos : SV_POSITION;
    };

    v2f vert(appdata_base v)
    {
        v2f o;
        o.pos = UnityObjectToClipPos(v.vertex);
        o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
        TRANSFER_SHADOW(o)
            return o;
    }

    fixed4 frag(v2f i) : SV_Target
    {
        fixed4 col = tex2D(_MainTex, i.uv) * _Color;

    // compute shadow attenuation (1.0 = fully lit, 0.0 = fully shadowed)
    fixed shadow = SHADOW_ATTENUATION(i);

    if (shadow < 0.5)
    {
        return fixed4(0.0156862745, 0, 0.23529411764,1.0); //or any other color for shadow
    }

    return col;
    }
        ENDCG
    }

        // shadow casting support
        UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
    }
}


texts: How to stop all character movement when jumping against the side of a platform?

texts:
My Sprite is Moving against a platform.

I have a script and an unusual one (that's what one of the member said.) My isGrounded isn't using any rayCasting. I didn't have any problem with it but when I created a platform and jump against it:

My character would fall down slowly.
If I try to move against the platform, I would be able to move and it would appear as if the character was flying.

So question is, how can I stop all my movements, jumping everything, when I collide like this with a platform?

My Code is:

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

public class pScript : MonoBehaviour {
    public Rigidbody2D rb;
    [SerializeField]
    public Transform[] Points;
    [SerializeField]
    public float radius;
    [SerializeField]
    public LayerMask layer;
    public bool jump;
    public bool isgrounded = false;
    [SerializeField]
    public float MoveSpeed;
    [SerializeField ]
    public float jumpHigh;
    public bool facingRight;
    public Animator animator;
    public Object CallfPanel;
    public Object CallfText;
    public float Move = 8f;
    public Vector3 Dir;
    public Vector3 tart;
    // Use this for initialization
    void Start () {
        rb = GetComponent<Rigidbody2D> ();
        animator = GetComponent<Animator> ();
        CallfPanel = GameObject.Find ("Panel");
        CallfText = GameObject.Find ("Text");
    }

    // Update is called once per frame
    void Update () {
        RaycastHit hit;
        Debug.DrawRay (transform.position, Vector3.right, Color.white, Move);
        tart = new Vector3 (200, 300, transform.position.z);
        Dir = Vector3.right;
        if (jump == true) {
            if (Physics.Raycast (tart, Dir, out hit, Move)) {
                jump = false;
            }
        }

        float horizontal = Input.GetAxis ("Horizontal");
        animator.SetFloat ("speed", Mathf.Abs (horizontal));

        isgrounded = isGrounded ();
        rb.velocity = new Vector2 (horizontal * MoveSpeed, rb.velocity.y);
        if (Input.GetKeyDown (KeyCode.Space)) {
            jump = true;
        }
        if (isgrounded && jump == true) {
            isgrounded = false;
            rb.velocity = new Vector2 (0, jumpHigh);
        }
        if (isgrounded == false) {
            jump = false;
        }
        changeDirections ();
    }
    private bool isGrounded(){

        if (rb.velocity.y <= 0) {
            foreach (Transform points in Points) {
                Collider2D[] collider = Physics2D.OverlapCircleAll (points.position, radius, layer);
                for (int i = 0; i < collider.Length; i++) {
                    if (collider [i].gameObject != gameObject) {
                        return true;
                    }

                }

            }

        }return false;
    }
    public void changeDirections(){
        float horizontal = Input.GetAxis("Horizontal");
        Vector3 theScale = transform.localScale;
        if (theScale.x == 1) {
            facingRight = true;
        } else {
            facingRight = false;
        }

        if (horizontal > 0 && !facingRight || horizontal < 0 && facingRight) {
            theScale.x *= -1;
            transform.localScale = theScale;
        }
}
    public void showTextDuration(){
        float lifetime = 4.0f;
        Destroy (CallfPanel, lifetime);

}
}


texts: Calculating speed between two objects is not working when one of the objects is moving very fast. How can be solved?

texts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;

public class SpaceshipCutscene : MonoBehaviour
{
    public Transform player;
    public Transform[] npcs;
    public Transform console;
    public Camera FPSCamera;
    public Camera mainCamera;
    public Animator[] anim;
    public float rotationSpeed = 3f;
    public float distanceFromConsole;

    private bool moveNpc = false;
    private float sp = 0f;
    private float distance;

    // Use this for initialization
    void Start()
    {

    }

    private void Update()
    {
        distance = Vector3.Distance(transform.position, npcs[0].transform.position);
        if (moveNpc)
        {
            // Soldier 2 rotating and looking at player
            Vector3 dir = player.position - npcs[0].position;
            dir.y = 0; // keep the direction strictly horizontal
            Quaternion rot = Quaternion.LookRotation(dir);
            // slerp to the desired rotation over time
            npcs[0].rotation = Quaternion.Slerp(npcs[0].rotation, rot, rotationSpeed * Time.deltaTime);

            var dist = Vector3.Distance(npcs[1].position, console.position);
            if (dist < distanceFromConsole)
            {
                sp += Time.deltaTime;
                sp = Mathf.Clamp(sp, 0f, 1f);
                anim[1].SetFloat("WalkingSpeed", sp);
            }

            Vector3 dirToComputer = console.transform.position - npcs[1].position;
            dirToComputer.y = 0;
            Quaternion rot1 = Quaternion.LookRotation(dirToComputer);
            npcs[1].rotation = Quaternion.Slerp(npcs[1].rotation, rot1, rotationSpeed * Time.deltaTime);

        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (HoriDoorManager.doorLockState == false && distance < 5f)
        {
            if (other.gameObject.tag == "SpaceshipCutscene")
            {
                FPSCamera.enabled = false;
                mainCamera.enabled = true;
                moveNpc = true;
                anim[0].SetBool("Aiming", true);
                anim[1].SetBool("Walktouse", true);
            }
        }
    }
}

When moving the player(transform) too fast it will not pass inside the line:

if (HoriDoorManager.doorLockState == false && distance < 5f)

But if I'm moving the player slow very slow or much slower then it will pass inside the line and make the rest of the code in the Update.

Before using the distance at all it was working fine but now I want to calculate the distance to make sure it will work only when the player is exit at specific direction.

But for some reason on high speed movement the distance calculation is not working good. It's not giving errors or exceptions it's just does nothing when exiting.

I did a test now and on the line:

if (HoriDoorManager.doorLockState == false && distance < 5f)

And changed it to:

if (HoriDoorManager.doorLockState == false)

And now it's working on any speed the character/player is moving.
So the problem is when calculating the distance on high speed.


texts: How to Implement a Timer for my Prefab for Roll-a-Ball Game (C# in Unity)

texts:
I am trying to create a public float timer that senses when the particular prefab has not been there for a certain amount of time. Then, it will replace that particular object.

The goal is to randomly spawn 10 of these cubes across the game board. Then when the player picks one up, it disappears. Then after say, 2 seconds, a new cube should be placed on the board.

Right now the Player already moves around the board just fine, and can pick up the cubes. When the player picks up a Cube, a new cube is automatically placed on the board with no delay.

This script will be attached to the cube prefab directly.

Apologies for the appearance of the code in advance.

using UnityEngine;
using System.Collections;

public class RandomPlacement : MonoBehaviour
{
public GameObject prefab;
private GameObject prefabClone;
public int count;
private GameObject[] getCount;
public float timer = 2;
// Instantiate the Prefab somewhere between - 10, 10 on the x, and z planes, with a height of 0.5 in y.

void Update ()
{
   getCount = GameObject.FindGameObjectsWithTag("PickUp");
   count = getCount.Length;
   if (count < 10)
   {
        timer -= Time.deltaTime;
        if (timer <= 0f);
        {
            Vector3 position = new Vector3(Random.Range(-9.0f, 9.0f), 1.0f, Random.Range(-10.0f, 9.0f));
            prefabClone = Instantiate(prefab, position, Quaternion.identity) as GameObject;
            timer = 2;
        }
    }
}
}

The code for the collision between the pick-up and ball is given by:

void OnTriggerEnter(Collider other)
{
    if (other.gameObject.CompareTag("PickUp"))
    {
        other.gameObject.SetActive(false);
    }
}

}

The "Cube" prefabs are all given the tag "PickUp" This script is attached to the "Player"


texts: prevent animation from moving the character

texts:
As stated in the question I've this problem: I'm using Unity and when playing an animation my character moves from point A to point B without my consent. Here's the code:

public class Walk : MonoBehaviour {

    private Animator humanAnimator;
    private iInputProvider input;

    private void Start()
    {
        input = new KeyBoardInput();
        humanAnimator = GetComponent<Animator>();
        walkMe = GetComponent<Rigidbody>();
    }

    private void FixedUpdate()
    {
        walk();
    }

    private void walk()
    {
        InputWrapper inputWrp = input.GetInputValues();

        animateWalk(inputWrp.verticalMove);
    }

    private void animateWalk(float verticalMove)
    {
        if (-0.1 <= verticalMove && verticalMove <= 0.1) //stand still
        {
            humanAnimator.SetBool("Walk", false);
            Debug.Log(humanAnimator.GetBool("Walk"));
        }
        else if (verticalMove > 0.1) // animate walk forward if the player is walking forward
        {
            humanAnimator.SetBool("Walk", true);
            Debug.Log(humanAnimator.GetBool("Walk"));
        }
        else if (verticalMove < -0.1)
        {
            // walk backward animation needed
        }

    }
}

Note that nowhere in the code I change the object position, i just start the animation. Here's the result:

https://imgur.com/OMvfmYE

note that it's not the effect of the gif, the character actually resets its position after the animation is terminated. I was expecting the character to "run on the place".
Anybody has some idea how can I fix this?

EDIT: if I uncheck the "Apply root motion" check box I've this result: https://imgur.com/4FdeCKH . Maybe it could be useful to know that I can't click on "Generate root motion curve" in my animation inspector because it's all uneditable: https://imgur.com/9q3h1cd


texts: Why do the order of uniforms gets changed by the compiler?

texts:
I have the following shader, everything works fine when setting the value of one of the matrices but I've discovered that getting a value back is incorrect for View and Projection, they are in reverse order.

#version 430

precision highp float;

layout (location = 0) uniform mat4 Model;
layout (location = 1) uniform mat4 View;
layout (location = 2) uniform mat4 Projection;

layout (location = 0) in vec3 in_position;
layout (location = 1) in vec4 in_color;
out vec4 out_color;

void main(void)
{
    gl_Position = Projection * View * Model * vec4(in_position, 1.0);
    out_color = in_color;
}

When querying their location they are effectively reversed, I did a small test by renaming View to Piew which  puts it before Projection if sorted alphabetically and the order is correct.

Now if I do remove layout (location = ...) from the uniforms, the problem disappears !?

I am starting to think that this is a driver bug as explained in the wiki.

Do you know why the order of the uniforms is changed whenever the shader is compiled ?

(using an AMD HD7850)


texts:
I am creating a game and I have a custom level format for levels in my game. I wanted to know if it is possible to create levels for that kinda format in Blender. My format is XML based and just declares the positions of certain objects. Online I have seen many people use Blender to create levels in their own custom format that blender can understand.

How do i get blender to understand my format and use blender to create levels for my game?


texts: Unity3D GUILayout Window Wont Show Components

texts:
I am fairly new to Unity, but picking things up quick. This is actually one of the first problems I have come across that has me stumped.

I am trying to print a good amount of components onto my GUI on top of my window.

Although, I can only see half of only one component at the upper left hand side of my window, in which the label says "Name". I can actually only see Na and half of the m.

(If I do NOT use the window, and just paint my components out on my OnGUI everything will paint just fine and looks exactly how I want)

To me, this sounded like some sort of Rect(); issue or something along the lines of the width and height not being set properly...Although they are.

Ill provide all the code that has any relation to the GUI. (There is only one object this script is attached to and it inherits from MonoBehavior)

You will notice that the Rects() or any Width/Hieght will be set to some high number, it was just to make sure it wasnt that line of code screwing up my window.

public GUISkin mySkin;
public Rect windowRect = new Rect();

void OnGUI() {
    GUI.skin = mySkin;
    DisplayBox();
}

private void DisplayBox() {
     windowRect = GUILayout.Window(0, windowRect, DoMyWindow, "", GUILayout.Width(800));
}
void DoMyWindow(int windowID) {
    DisplayName();
    DisplayPointsLeft();
    DisplayAttributes();
    DisplayVitals();
    DisplaySkills();
    DisplayCreateButton();
    DisplayResetButton();
}

These functions in the DoMyWindow just call GUI.Component statements to paint the gui.

Like I said above, if I dont use the window everything works perfect.

Also, you'll notice that the windowRect has no params. Its public and they are altered to extremely high numbers in the inspector. Still no result

What am I doing wrong?


texts: Trying to get reference to Button in Javascript Unity3d

texts:
I've this simple script in Unity3d:

#pragma strict

public var topLeft : UnityEngine.UI.Button;
public var topCenter : UnityEngine.UI.Button;
public var topRight : UnityEngine.UI.Button;
public var midLeft : UnityEngine.UI.Button;
public var midCenter : UnityEngine.UI.Button;
public var midpRight : UnityEngine.UI.Button;
public var bottomLeft : UnityEngine.UI.Button;
public var bottomCenter : UnityEngine.UI.Button;
public var bottomRight : UnityEngine.UI.Button;

private var x = "X";
private var o = "O";

function Start () {

    var board = [[topLeft, topCenter, topRight], [midLeft, midCenter, midpRight], [bottomLeft, bottomCenter, bottomRight]];
    for (var i = 0; i < board.length; ++i) {
        var row = board[i];
        for (var j = 0; j < row.length; j++) {
            var button = row[j];
            button.onClick.AddListener(function() { onTileClicked(button); });
        }
    }
}

function onTileClicked(tile : UnityEngine.UI.Button) {
    Debug.Log("Click click!");
}

Here is how I reference the buttons:

Why are all the buttons in 'board' variable null even if I referenced them through the GUI (the red rectangle in the image)?


texts:
Does anyone know of a C/C++ library (or has some source code) that can generate and output (by which I don't mean render) a tessellation of a general quadric, i.e. a 3d surface defined by the matrix equation

X'AX + B'X + c = 0

where X is a 3d point, A is a symmetric 3x3 matrix, B is a 3x1 vector and c is a scalar?


texts:
I'm trying to get world position from my vertex shader to my pixel shader so that I can disable the shader once a preset X coordinate has been passed (no shading once I'm over X).

Getting the screen position is not a problem so far but despite my best efforts to look after it and implement examples the calculations just don't return the preferred world positions I'm looking for.

Update: So got it to somewhat work, after compiling the shaders the output changes to such:

Could anyone explain why this happens?

I should mention that I'm really new to HLSL, been only scripting so far.

Edit:Added matrices.

world = Matrix.Identity;
view = Matrix.CreateScale(new Vector3(1, 0.75f, 0)) * Matrix.CreateTranslation(-playerpos.X, -playerpos.Y, 1);
projection = Matrix.CreateOrthographicOffCenter(0, view.Width, view.Height, 0, 0, 1);
Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);
projection = halfPixelOffset * projection; <\code>

    texture lightMask;
    sampler mainSampler : register(s0);
    sampler lightSampler = sampler_state{Texture = lightMask;};
    float4x4 World;
    float4x4 View;
    float4x4 Projection;

    struct vs2ps
{
    float4 Pos : POSITION0;
    float4 TexCd : TEXCOORD0;
    float3 PosW : TEXCOORD1;
};

vs2ps VS(float4 Pos : POSITION0,float4 TexCd : TEXCOORD0)
{
    vs2ps Out;
    Out.Pos = mul(Pos, World*View*Projection);
    Out.TexCd = TexCd;
    Out.PosW = mul(Pos, World);
    return Out;
    }

float4 PixelShaderFunction(vs2ps input) : COLOR0
{   float2 texCoord = input.TexCd;
    float4 screenPosition = (input.PosW,1.0f);
    float4 lightColor = tex2D(lightSampler, texCoord);
    float4 mainColor = tex2D(mainSampler, texCoord);
    if(screenPosition.x < 3500)
    {
         return (mainColor * lightColor);
    }
         else return mainColor;
}


texts: How do game designers create vibration patterns?

texts:
I am curious about creating and implementing vibration patterns for console controllers (for the PS4 controller, if it makes a difference).

There is a delay and motor speed parameter right? But also we can fade from left motor to right, or make them work together....

Is there a standardized way to create those patterns?

For example I thought about creating them with stereo wav audio in an audio editor and reading the wav file in my code to convert them to delays and speeds.

How is this done in the gaming industry?


texts:
Okay, I have a set of vertices that is around 10,000,000 (it's a long story, but it seems that it is needed), however only a few thousand of those will be onscreen at a time. It's currently setup as one vertex buffer (and it's one shape anyway) so the normal view frustum culling solution would not seem to be applicable here.

Is there any way of making it only drawing those few thousand verticies needed onscreen at one time?

Thank you!


texts: Pixel Perfect collision detection on rotated bitmaps

texts:
I have two bitmaps which are being drawn onto a canvas using a matrix

canvas.drawBitmap(bitmap, matrix, paint);

first to work out if I need to check for a collision i am using eucilidean vectors as such

//vector between the bitmaps
float vx = bitmap2.x - bitmap1.x;
float vy = bitmap2.x - bitmap1.x;

//magnitude of the vector between the two bitmaps
float m = Math.sqrt( (vx*vx)+(vy*vy) );

if( m < bitmap1.getDiagonalWidth() + bitmap1.getDiagonalWidth())
{
    //pixel perfect collision detection required
}

Firstly, is this the best way to approach this part of the collision detection?

Secondly once I have found that a collision is possible, do I need to do anything before throwing the bitmaps into a method that runs pixel perfect collision detection? basically, is the issue complicated because of the rotation of the images?

edit* it is possible that the bitmaps will also be scaled by the matrix. i would imagine that this will complicate things further.


texts: How can I easily determine the z-ordering of objects in multiple glDraw calls?

texts:
I have a simple 2D tile-based scene that I'm rendering with OpenGL. On each frame I first draw the static background, and then draw the dynamic elements (monsters, etc.). This way it seems that the later drawn elements "paint over" the earlier drawn ones (using separate glDraw calls).

However, when asking around, it seems that if I used a depth buffer the order in which things are drawn doesn't necessarily matter, as the depth buffer can be used to determine visibility.

But what happens when some things share the same z-value when using a depth buffer? Is the newer one "painted over" the older one?

If so, should I rely on this behavior, or rather use different z-values for my "layers"?


texts:
I have list of models and transform matrix for each of them. Some of models are flipped along X or Y or Z axis. This meshes will be rendered wrong, back face is rendered instead of front.

I tried to use glFrontFace(GL_CW) and that makes wrong models fixed but previous correct models are wrong.

How can I fix this?
Can I detect from transform matrix which models need glFrontFace switch?

Right cube and sphere are normal and left are flipped


texts:
I am a beginner making my second game (simple low graphics FPS), in Visual C++ 2010. So far, I only know how to use keyboard controls. I've had source files like keyboard.h and keyboard.ccp, responding to callback functions like kbd.UpIspressed().

How can I do this with mouse controls?


texts: How can I make water appear darker with depth, like in Minecraft?

texts:
In Minecraft when you look at water the deeper you view the darker it gets.  Does anyone know how to code something like that?

Minecraft with effect

similar game without effect


texts: How do game engines implement multiple rendering platforms?

texts: How do game engines like UE4, Unity, Source, Cry Engine, etc add different rendering library's to their game engines? (Eg. OpenGL, DirectX, Vulkan)


texts:
A little bit of context; I'm still not experienced at this, I'm creating a 2D platformer and this is my enemies script (some part of it). This is supposed to be a minatour, which charges towards the player on sight. When rays hit the player I call the Charge coroutine from update. As you can see below rays are not casted during the coroutine. Everything works according to plan, but after this coroutine ends if rays hit the player in two seconds, coroutine never stops again, rays are always casted and the minatour always keep charging. But if rays hit the player after 2 seconds it's perfectly fine. What am I doing wrong?

void FixedUpdate()
{
    if (!canChargeRight && !canChargeLeft)
    {
        rightRay = Physics2D.Raycast(transform.position, Vector2.right, rayDistance, layerMask);
        leftRay = Physics2D.Raycast(transform.position, Vector2.left, rayDistance, layerMask);

        if (rightRay.collider != null)
        {
            canChargeLeft = true;
        }
        else if (leftRay.collider != null)
        {
            canChargeRight = true;
        }
    }
}

void Update()
{
    if (canChargeRight)
    {
        StartCoroutine(Charge(-1));
    } else if (canChargeLeft)
    {
        StartCoroutine(Charge(1));
    }
}

private IEnumerator Charge(int chargeDirection)
{
    myRigidBody.velocity = Vector2.right * chargeDirection * chargeSpeed;

    yield return new WaitForSeconds(2);
    canChargeLeft = false;
    canChargeRight = false;
    myRigidBody.velocity = Vector2.zero;
}


texts: How do I add Different Screens to my C#/XNA Game?

texts:
I'm working on a Pong clone in XNA. Gameplay-wise, I have it where I want it to be.  I want to add a title screen and some other screens to it like a menu, as well as a screen for the Winning/Losing results.

I've tried the Game State Management Example on the App Hub site, but It's very complicated and I haven't been able to make sense of it. Is there a simpler way?

I'm hoping for a solution that can be used in other projects too.

Plus I'd like to know how to actually create menu items (basically, how do I display the different options on it, and highlight them, etc).


texts: How to prevent character from jumping multiple times

texts:
I just started learning Unity yesterday, Ive asked in many forums/servers this question but no one gave me a solution for my problem (in the title) so here's my code:

public class scr : MonoBehaviour
{
    public float speed = 1f;
    private Rigidbody rb;
    public float jumpforce = 1f;
    private bool isGrounded;
    public float disToGround = 0.5f;

    //Vai obter o rigid body do character
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    //Movimentaçao do character
    void FixedUpdate()
    {
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");

        Vector3 movement = new Vector3(moveHorizontal, 0f , moveVertical);

        rb.AddForce(movement * speed);

        if (isGrounded == false && Input.GetKeyDown(KeyCode.Space))
        {
            rb.AddForce(Vector3.up * jumpforce, ForceMode.Impulse);
        }
    }
}


texts: Best way to store a word list in Java/Android

texts:
I'm building a game where I form words (think Scrabble) and I need to have them validated in real-time, meaning that I need to have some sort of word list loaded where I can check if the word made exists or not.

I was wondering what would be the best way to store that list, should I just create an Array or use some sort of database (sqlite3 in this case).

Thanks


texts: What are your favourite game-specific coding gems?

texts:
I'll start off with John Carmack's the Fast Inverse Square Root in Quake III:

float Q_rsqrt(float number) {

  long i;
  float x2, y;
  const float threehalfs = 1.5F;

  x2 = number * 0.5F;
  y = number;
  i = * ( long * ) &y;
  i = 0x5f3759df - ( i >> 1 );
  y = * ( float * ) &i;
  y = y * ( threehalfs - ( x2 * y * y ) );

  return y;

}


texts: Why is C/C++ preferred for game developers?

texts: Some people say it offers more control to developers, but what is it precisely that can be controlled through C++ which can't be controlled using, for example, Java?


texts: Event error: "...can only be called from the main thread"

texts:
I have some custom networking classes which I'm trying to use in a unity game (c#).  The network class raises events, which I want to subscribe to in the game code.  However, whenever I try to do anything substantial in response to an event, I'm running into and error like this:

  SomeFunction can only be called from the main thread

How can I get this to work?  Presumably I have to communicate the event back to the main thread in some synchronous fashion.  Is there a 'best practice' way of doing this in Unity?


texts:
Each game has it's own "maximum number". One question that comes into mind every time I play a(nother) game is how are these maximums determined and how do these affect gameplay? To explain, here's some rough references from games and anime.

Numbers on Levels

One instance is the "level cap". In some games, it's 100 - which I can easily understand to be like percentage. But other games have weird level caps. I remember Fallout (3?) having a level cap of 30. The anime Log Horizon has a level cap of 90 (and increased to 100 after "the apocalypse"). Ragnarok Online once had 99, then increased (to 120?) for Renewal servers.

Numbers on Attributes

Another instance is attributes (Strength, Agility, Intelligence etc.). Ragnarok Online starts you at 5 a piece and level up in small increments. Skyrim starts you at ~15-25 depending on race. In the anime Sword Art Online, they have this scale of 1000.

Numbers on Damage

Then there's attack power. In Yu-Gi-Oh card game, the attack power comes in the thousands. MTG on the other hand is as small as 0-10, with the 1-6 range as very common numbers. DotA damage starts <100 and reach as high as 2000 on critical strikes.

Exceeding caps

Then there's this Skyrim mod that makes you level up in excess of the cap. Why would they make something like that? Is there something beyond the level cap that the regular game doesn't address? Is the system not enough?

In summary, here's my questions:

How are these scales and maximums determined? Is there some magical formula or a generic guideline (like from a game)?
How does these number affect overall gameplay? I mean I can have a 100-scale that does the same thing as 1000-scale or 10000-scale. But why do they opt for these numbers? Why go for smaller ones or the insanely huge ones?
Why is there a level cap? And what does it mean when the level cap is broken or increased?


texts:
I have a problem with 2d player movement, as I am unable to move on the Y-axis. Yet, the movement on the X-axis is working as intended.

Below, you can see my code:

public Sprite directionUp;
public Sprite directionDown;
public Sprite directionLeft;
public Sprite directionRight;

public float speed = 0.1f;
public byte direction = 0; //0 - up, 1 - right, 2 - down, 3 - left

private SpriteRenderer spriteRenderer;
private Rigidbody2D rb2D;
private Sprite[] directionArray;

// Use this for initialization
void Start () {
    rb2D = GetComponent<Rigidbody2D>();
    spriteRenderer = GetComponent<SpriteRenderer>();

    directionArray = new Sprite[]{ directionUp, directionDown, directionLeft, directionRight };
    if(directionArray[0] != null) spriteRenderer.sprite = directionArray[0];
}

// Update is called once per frame
void Update ()
{
    if (Input.GetKeyDown(KeyCode.Keypad7))
    {
        rb2D.MovePosition(rb2D.position + new Vector2(-1f, 1f));

        if (directionArray[0] != null) spriteRenderer.sprite = directionArray[2];
    }
    else if (Input.GetKeyDown(KeyCode.Keypad9))
    {
        rb2D.MovePosition(rb2D.position + new Vector2(1f, 1f));

        if (directionArray[0] != null) spriteRenderer.sprite = directionArray[3];
    }
    else if (Input.GetKeyDown(KeyCode.Keypad1))
    {
        rb2D.MovePosition(rb2D.position + new Vector2(-1f, -1f));

        if (directionArray[0] != null) spriteRenderer.sprite = directionArray[2];
    }
    else if (Input.GetKeyDown(KeyCode.Keypad3))
    {
        rb2D.MovePosition(rb2D.position + new Vector2(1f, -1f));

        if (directionArray[0] != null) spriteRenderer.sprite = directionArray[3];
    }
    else if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.Keypad8))
    {
        rb2D.MovePosition(rb2D.position + new Vector2(0f, 1f));

        if (directionArray[0] != null) spriteRenderer.sprite = directionArray[0];
    }
    else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.Keypad2))
    {
        rb2D.MovePosition(rb2D.position + new Vector2(0f, -1f));

        if (directionArray[0] != null) spriteRenderer.sprite = directionArray[1];
    }
    else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.Keypad4))
    {
        rb2D.MovePosition(rb2D.position + new Vector2(-1f, 0f));

        if (directionArray[0] != null) spriteRenderer.sprite = directionArray[2];
    }
    else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.Keypad6))
    {
        rb2D.MovePosition(rb2D.position + new Vector2(1f, 0f));

        if (directionArray[0] != null) spriteRenderer.sprite = directionArray[3];
    }
}

By the way, please keep in mind I am quite new to Unity.

EDIT 1///////////////////////

I have attached the entire script, some of the variables are unused right         now(was testing other methods of movement).

I tried to both Keypad - 1, 3, 6, 9, as well as the combinations which I didn't get to work yet (but this is off-topic and I will look into it once I will get the Y-axis to move).

Thanks, Zryw


texts: For my first game i want to create a topview game in c++ where you can drive a car (like in gta2). As far as i know i dont need any gravity. While doing a bit of research about games they often advice a physics engine. What are the benefits of a physics engine on a topview game?


texts: How to remove a box2d body when collision happens?

texts:
I’m still new to java and android programming and I am having so much trouble Removing an object when collision happens.
I looked around the web and found that I should never handle removing BOX2D bodies during collision detection (a contact listener) and I should add my objects to an arraylist and set a variable in the User Data section of the body to delete or not and handle the removing action in an update handler.
So I did this:
First I define two ArrayLists one for the faces and one for the bodies:

ArrayList<Sprite> myFaces = new ArrayList<Sprite>();
ArrayList<Body> myBodies = new ArrayList<Body>();

Then when I create a face and connect that face to its body I add them to their ArrayLists like this:

face = new AnimatedSprite(pX, pY, pWidth, pHeight, this.mBoxFaceTextureRegion);
Body BoxBody = PhysicsFactory.createBoxBody(mPhysicsWorld, face, BodyType.DynamicBody, objectFixtureDef);
mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(face, BoxBody, true, true));

myFaces.add(face);
myBodies.add(BoxBody);

now I add a contact listener and an update handler in the onloadscene like this:

this.mPhysicsWorld.setContactListener(new ContactListener() {
private AnimatedSprite face2;
@Override
public void beginContact(final Contact pContact) {
}
@Override
public void endContact(final Contact pContact) {
}
@Override
public void preSolve(Contact contact,Manifold oldManifold) {

}
@Override
public void postSolve(Contact contact,ContactImpulse impulse) {
}
});

scene.registerUpdateHandler(new IUpdateHandler() {

@Override
public void reset() { }

@Override
public void onUpdate(final float pSecondsElapsed) {

}
});

My plan is to detect which two bodies collided in the contact listener by checking a variable from the user data section of the body, get their numbers in the array list and finally use the update handler to remove these bodies.

The questions are:
Am I using the arraylist correctly?
How to add a variable to the User Data (the code please).
I tried removing a body in this update handler but it still throws me NullPointerException , so what is the right way to add an update handler and where should I add it.
Any other advices to do this would be great.
Thanks in advance.


texts: How to manage complex mesh importing in to a game engine

texts:
A bit of context: I'm developing a 3D rendering engine and can't really make much more progress until I get some more interesting and complex meshes loaded in to the scene. So far I have been using built-in simple meshes like cubes and planes. I have written a Mesh class to take a MeshData struct which contains Position, Normal, Tangent, Bitangent, Colour, Texture Coordinate, and optional Face data. The Mesh class takes this data and depending on a few things it will generate a VBO with all of the available data interleaved, an EBO, and a VAO which has both the VBO and EBO (if one exists) bound to it. I've been pretty happy with this so far and it works fine with a simple .OBJ which contains a relatively straight-forward mesh.

Currently I have an asset management system which allows me to load in assets like this:

Mesh * teapot = AssetManager::loadGlobalAsset<Mesh>("res/meshes/teapot.obj");

If the returned pointer == nullptr then the assets doesn't exist. If it isn't nullptr then one of three things just happened: (1) the asset was just newly created and successfully loaded in to the asset manager's pool of assets, (2) the asset was found to already exist in the pool of assets and its pointer returned, (3) the asset was found to already exist in the pool of assets, but was unloaded, so it was loaded and its pointer returned.

As I said this works great for simple meshes but I'm a bit stuck on what to do and what changes I now need to make to load meshes which have multiple sub-meshes which might have individual materials.

For example the Sponza mesh has many sub-meshes which make use of a set of materials.

I could just load the mesh right in to my scene and have the mesh spread across multiple scene nodes all with a common ancestor node, but then this would defeat the purpose of an asset manager and I would have to worry about cleaning up and unloading the mesh outside of the asset manager. I could also just load the mesh as one big combined mesh, but of course then I can't assign individual materials to the sub-meshes without a lot of trouble.

I currently can't load the mesh using my asset manager as assets are identified by the hash of their filepaths, and here we have a situation where many individual meshes technically have the same filepath. If I just create new assets and give them to the asset manager with an ID to later fetch the asset (which isn't necessarily a bad idea for built in assets (I think)), then I feel I have the following issues:

Easy to add multiple assets with same ID
Breaks the connection between the meshes contained in a single mesh file
No way of actually knowing the ID of a mesh which was loaded in via a mesh file
Would have to manually recreate the whole mesh from its loaded sub meshes if I wanted to simply display the mesh as-is.

There is also the issue of where to store the materials that are included in the material library that a mesh file might reference. Do I create new material assets from this library, add them to the manager, and then have the mesh somehow reference these materials? But then how would I reference these materials manually? It's a similar issue to last point from the above list. Also, meshes don't currently have any knowledge of its material, that's the scene node's job.

Thanks for any thoughts or comments on this issue. I'd be very interested to hear what you guys think.


texts: Question about separating game core engine from game graphics engine

texts:
Suppose I have a SquareObject class, which implements IDrawable, an interface which contains the method void Draw(). I want to separate drawing logic itself from the game core engine.

My main idea is to create a static class which is responsible to dispatch actions to the graphic engine.

public static class DrawDispatcher<T>
{
    private static Action<T> DrawAction = new Action<T>((ObjectToDraw)=>{});
    public static void SetDrawAction(Action<T> action)
    {
        DrawAction = action;
    }
    public static void Dispatch(this T Obj)
    {
        DrawAction(Obj);
    }
}

public static class Extensions
{
    public static void DispatchDraw<T>(this object Obj)
    {
        DrawDispatcher<T>.DispatchDraw((T)Obj);
    }
}

Then, on the core side:

public class SquareObject: GameObject, IDrawable
{
    #region Interface
    public void Draw()
    {
        this.DispatchDraw<SquareObject>();
    }
    #endregion
}

And on the graphics side:

public static class SquareRender{
    //stuff here
    public static void Initialize(){
        DrawDispatcher<SquareObject>.SetDrawAction((Square)=>{//my square rendering logic});
    }
}

Do this "pattern" follow best practices?

And a plus, I could easily change the render scheme of each object by changing the DispatchDraw parameter, as in:

public class SuperSquareObject: GameObject, IDrawable
{
    #region Interface
    public void Draw()
    {
        this.DispatchDraw<SquareObject>();
    }
    #endregion
}
public class RedSquareObject: GameObject, IDrawable
{
    #region Interface
    public void Draw()
    {
        this.DispatchDraw<RedSquareObject>();
    }
    #endregion
}

RedSquareObject would have its own render method, but SuperSquareObject would render as a normal SquareObject

I'm just asking because i do not want to reinvent the wheel, and there may be a design pattern similar (and better) to this that I may be not acknowledged of.

Thanks in advance!


texts:
How do we convert a pex file to a psc file?

https://skyrim.nexusmods.com/downloads/file.php?id=2909

There used to be a file here that allegedly converted pex files to psc files, but it's no longer available, so I was wondering if there was a alternative GUI program that allows you to do this. I am trying to modify a pex file in a Skyrim mod.


texts: How to have an AI controlled GameObject naively avoid another one?

texts:
I have an idea of an AI controlled game which the gameobject will follow a path but it will change its path if I put another gameobject in front of it. For instance, if the moving game object is moving horizontally, and I put a static game object on its path, I want it to turn and continue its progression vertically just before it hits it.

How can I achieve this?


texts: Is it possible to configure a unity project so it only runs on a device?

texts: I am want to give someone a sample Android Unity project and I want them to be able to run it only on a device, not the simulator. Is there a way that I can configure the project so that it will only run on a device?


texts: How do I handle Isometric collision detection?

texts:
I would like to make an isometric run-jump style platformer. The player should be able to jump on top of platforms above the floor, hit the side of objects etc.

I'll be using a 2D game engine so I wouldn't like to emulate full 3D collision for dimensions I'm not using.

I'm thinking objects in the game should be placed using: X, Y, width, height, and Z for depth.

Using those values, how should I detect collisions?


texts:
I'm looking for some ideas/algorithm name for alternative to distance fog.

I'm playing around an "infinite" terrain engine. I can't draw the whole map because there are no borders and I don't like the idea of hiding the terrain at a distance with fog.


texts: How to publish a mod on Steam for a game without Steam Workshop?

texts:
I'd like to publish a mod for a game that doesn't have Workshop or any community modding options.
I could go to Steamworks and publish it as a standalone game... but I don't see any option to "require" the user to have access to the base game to install it -- which is a requirement for the mod to work.(So it will appear on Steam with its own "store" page but doesn't allow to be downloaded unless the account holder also owns the base game)
I've spent days Googling this, but the only documentation I can find is how to add mods to Steam using Source, which I am not using. The mod is free if that matters at all.
Would like to use Steam because it's much easier to push updates to the mod than using NexusMods or ModDB. Thanks!


texts: 2D animated sprite jumping and gravity physics

texts: I'm currently writing a Megaman clone for my school project. So far all I did was making the character run and stay put when needed. Know I want to be able to make him jump using the 'X' button. I already have the animation sheet of the jump. But I really can't figure out how to do it and how the physics work after reading so much about it both here and other places. I think you get what I mean. From the state of staying put or running, going to a jumping position and landing. Also to be able to press left/right and the jump button to jump in the direction(I know It's stupid that I explain all of this because you probably know all this but just in case). Anyway this is my code for Game1: http://pastebin.com/zYM5gnRD And this is the code for my Animated Sprites class: http://pastebin.com/5H36YAdb I'm not saying it's the smartest writing, but it's only a school project so I need it to work so I'm fine with it. Thanks a lot, a lot in advance for those who read this and are going to help.


texts: Trying to set up a simple swapping system to swap two game pieces using a button press

texts:
I am trying to set up a system that will move two objects. This is a puzzle game with a cursor to visualize where the player is. I need to get the position of the cursor's left and right half, send that to a function that will then switch the two blocks when a key is pressed.
I have code that will move the cursor around but cannot figure out how to swap two blocks based on the position of the cursor.
I do not know if the code that is currently attached to the cursor will be of any help, but I can provide if necessary.
I am more or less looking for a general solution that I could apply to swapping two blocks.
I do not know if I need to be sending the positions of the cursor to the swap function in order to swap. How would I connect this to the tiles themselves? The code below is located in the board classv2 class. I am not very good with Unity as of yet. Any additional help would be appreciated.
 void Update()
    {
        if (Input.GetButtonUp("Swap"))
        {
            swapTiles(cursorLeft.transform.position.x, cursorRight.transform.position.x);
        }
    }

void swapTiles(float x1, float x2)
{

}

Game pieces are created and have an x and y number associated with a game board I created.
The Game pieces have a move routine. I can't seem to get the pieces to actually swap.
public void Move(int destX, int destY, float timeToMove)
{
    if (!m_isMoving)
    {
        StartCoroutine(MoveRoutine(new Vector3(destX, destY, 0), timeToMove));
    }
}

//Moves the piece.
IEnumerator MoveRoutine(Vector3 destination, float timeToMove)
{
    Vector3 startPosition = transform.position;

    bool reachedDestination = false;

    float elapsedTime = 0f;

    m_isMoving = true;

    while (!reachedDestination)
    {
        //if we are close enough to destination
        if (Vector3.Distance(transform.position, destination) < 0.01f)
        {
            reachedDestination = true;

            if(m_board != null)
            {
                m_board.PlaceGamePiece(this, (int)destination.x, (int)destination.y);
            }
            break;
        }

        //track the total running time
        elapsedTime += Time.deltaTime;

        //calculate the lerp value
        float t = Mathf.Clamp(elapsedTime / timeToMove,0f,1f);

        switch (interpolation)
        {
            case InterpType.Linear:
                break;
            case InterpType.EaseOut:
                Mathf.Sin(t * Mathf.PI * 0.5f);
                break;
            case InterpType.EaseIn:
                t = 1 - Mathf.Cos(t * Mathf.PI * 0.5f);
                break;
            case InterpType.SmoothStep:
                t = t * t * (3 - 2 * t);
                break;
            case InterpType.SmootherStep:
                t = t * t * t * (t * (t * 6 - 15) + 10);
                break;
        }

        //move the game piece
        transform.position = Vector3.Lerp(startPosition, destination, t);

        //wait until next frame
        yield return null;
    }
    m_isMoving = false;
}


texts: Unity3D and Texture2D. GetPixel returns wrong values

texts:
I'm trying to use Texture2D set and get colors, but I encountered a strange behavior.
Here's the code to reproduce it:

Texture2D tex = new Texture2D(2,2, TextureFormat.RGBA32 ,false);

Color col = new Color(1.0f,0.5f,1.0f,0.5f); //col values: 1.00, 0.500, 1.00, 0.500
tex.setPixel(0,0,col);
Color colDebug = tex.getPixel(0,0);  //col values: 1.00, 0.502, 1.00, 0.502

The Color retrieved with getPixel is different from the Color set before.
I initially thought about float approximation, but when inspectin col the value stored are correct, so can't be that reason.

It sounds weird even a sampling error because the getValue returns a value really similar that not seems to be interpolated with anything else.
Anyway I tried even to add these lines after building the texture but nothing change:

this.tex.filterMode = FilterMode.Point;
this.tex.wrapMode = TextureWrapMode.Clamp;
this.tex.anisoLevel = 1;

What's my mistake? What am I missing?

In addition to that. I'm using tex to store Rect coordinates returned from atlas generation, in order to be able of retriving the correct uv coordinate of an atlas inside a shader. Is this a right way to go?


texts: Other than the ESA are there other sources for demographic data?

texts: I'm pretty interested in seeing demographic data as I find them good targeting tools. But other than the ESA reports (free) and NPD numbers (paid) does anyone know any other sources for such data?


texts: What are the accessibility implications of requiring a button press or time-out on a game over screen?

texts:
For simple games, is there a de-facto standard that game over screens time out after a few seconds before, or require some sort of input in order to, transition back to the main menu?

Time-out pros:

Accessibility. Mobility-impaired users may have difficulty pushing the buttons so the game should advance for them.

Time-out cons:

Accessibility. Vision-impaired users may have difficulty seeing any post-game information displayed within the allotted time.
Tweaking the time-out so it's not too long as to be annoying if the user happens to game over a lot. Also: "Don't make QA mad"

Input pros:

Accessibility. Vision-impaired users may take as long as needed to see any post-game information displayed on screen.
Makes time-outs skippable.

Input cons:

Accessibility. Motor-impaired users may have difficulty pushing buttons.

I remember reading a Microsoft article about certain best practice design decisions regarding accessibility a long time ago but can't recall the specifics.


texts: How to make old cards still usable to players in CCG games?

texts: In CCG games, as the player progresses further and unlocks stronger cards alot of the old cards are ignored and not used anymore. Like for example a CCG with 1000 cards, 100 of them are very strong cards and the others not so much. All players will just use those 100 cards and ignore the rest 900 cards! What can be done in such case to make old cards still usable to players?


texts:
i'm facing an issue at the moment in my javascript/html platformer game that despite searching for this issue i can't solve. The problem is this:

When i place two platforms next to each other and the player moves between them, the algorithm believes the player is colliding with the side (left or right) face of the next platform. This is because all my bounding boxes are placed in an array and iterated through, the algorithm doesn't care if the player has to pass through one collider to get to another, it just thinks it has collided with both.

One solution is of course to make it consider what it has collided with first, another is simply not to place two platforms together. My solution would be to implement a kind of occlusion culling with collides, which if the player collides with a top face it can't collide with a side face if that side face's top face is higher or equal to top first that was being collided in.

That was hard enough to explain let alone implement and i just feel like there is a better work around that wouldn't be too difficult to implement and would be efficient.

My solution:

Another solution is to disable gravity if the player is in contact with the ground, this must be done carefully not to trigger an oscillation effect and also means that two iterations need to be made, one for collision in the y (done first) and the other for collisions in the x (done second).


texts:
I'm experimenting with 3D using SceneKit on iOS.  I'm trying to create a galaxy but would appreciate some guidance on the following things:

I'm having a hard time working out how to make the galaxy seem 'big'.  I've created multiple solar system nodes in a spiral, but the distances between them are hard to get right.  I want to get a sense of scale, but I'm not sure of the best approach.  Do I want to put huge distances between solar systems, and make the objects in the system very large too?  In this case I need to set the camera zFar to be massive.  I feel like I'm missing something.
I've created a cube map for the 'galaxy'.  As I zoom in on a solar system, the cube map seems to come in very close, which breaks the illusion of scale.  How do I make that better?

Thanks for any guidance!


texts: Forcing Non-Pitch Preserving Audio in HTML5, Construct 2

texts:
I'm working on a simple game built in HTML5 using Construct 2, in which a circle eats other circles; nothing fancy. The idea is that a song plays during the game, starting at a low pitch, and rising as more circles get eaten (which along with increasing movement speed, makes it pretty manic). Construct 2 has a way to set the playback speed for audio tracks (using the .ogg or aac formats for browser support), but passes the actual implementation of setting the speed to the browser used.

Since some browsers use a pitch-preserving algorithm, and others do not, the same HTML5 game may have the desired low to high pitch transition in one browser, but a artifact filled pitch-preserving version in another. I was wondering, then, is there a way to force the playback speed of the audio to act equivalently to a pitch setting, regardless of the browser used?


texts: Can I use jMonkeyEngine to make a closed source game?

texts: Can I just share the jMonkeyEngine code and keep my code closed or would I have to make my game open as well? Sorry if this is a noob question.


texts: How to add multiple transforms to a collection?

texts:
I have an array of Transforms:

public Transform[] monsterOne;

I can put a child's transform in this array using this code:

monsterOne = child.GetComponents<Transform>();

But if I try to do this in a loop for each child, the next child just replaces the last one, instead of adding to the array:

foreach (Transform child in transform)
{
    monsterOne = child.GetComponents<Transform>();
}

How can I add all of these transforms into one collection?


texts:
I've been beginning to work with different kinds of splines (e.g. Bezier, Hermite, B-splines) in some of my work with computer graphics and I am trying to get a grasp of how they work (mathematically and programmatically). I know that generally (at least for cubic splines), you will have 4 control points that influence the position of points along an interpolated line. For example, with Bezier curves (as far as I understand), there can be two end points where the line will begin and terminate and two control points that influence the direction of the line.

I've been programming Bezier, Hermite, and B-Splines (in javascript on an html5 canvas) and what I don't understand is how to choose these 4 points in order to see a specific curve rendered on the screen. So far, I have only been able to render at least part of a curve by randomly playing around with different numbers for each point.

This is one of the many questions I have about the inner workings of splines so could someone provide an overview on how they work and how they can be programmed (most of the examples online are more theoretical and rather unspecific)?


texts:
Possible Duplicate:
  How do I find artists to work on my game?

I have started working on a spacesim game but my art is terrible...

Is there a website where I could find people who might be interested in collaborating on a game with me?


texts: Are there any OpenGL ES 2.0 examples for JOGL?

texts:
I've scoured the internet for the last few hours looking for an example of how to run even the most basic OpenGL ES 2 example using JOGL but "by Jupiter!" it has been a total fail.

I tried converting the android example from the OpenGL ES 2.0 Programming Guide examples (and at the same time looking at the WebGL example -- which worked fine) yet without any success.

Are there any examples out there?

If anyone else wants some extra help regarding this question see this thread on the official Jogamp forum.


texts:
I want to achieve a distortion effect which distorts the full screen. For that I spawn a couple of images with normal maps. I render their normal map part on some camera facing quads onto a rendertarget which is cleared with the color (127,127,255,255). This color means that there is no distortion whatsoever. Then I want to render some images like this one onto it:
If I draw one somewhere on the screen, then it looks correct because it blends in seamlessly with the background (which is the same color that appears on the edges of this image). If I draw another one on top of it then it will no longer be a seamless transition. For this I created a blendstate in directX 11 that keeps the maximum of two colors, so it is now a seamless transition, but this way, the colors lower than 127 (0.5f normalized) will not contribute. I am not making a simulation and the effect looks quite convincing and nice for a game, but in my spare time I am thinking how I could achieve a nicer or a more correct effect with a blend state, maybe averaging the colors somehow? I I did it with a shader, I would add the colors and then I would normalize them, but I need to combine arbitrary number of images onto a rendertarget.
This is my blend state now which blends them seamlessly but not correctly:
    D3D11_BLEND_DESC bd;
    bd.RenderTarget[0].BlendEnable=true;
    bd.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
    bd.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
    bd.RenderTarget[0].BlendOp = D3D11_BLEND_OP_MAX;
    bd.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
    bd.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
    bd.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_MAX;
    bd.RenderTarget[0].RenderTargetWriteMask = 0x0f;

Is there any way of improving upon this?
(PS. I considered rendering each one with a separate shader incementally on top of each other but that would consume a lot of render targets which is unacceptable)


texts: I have a terrain on which I painted on and used many textures on it. Now when I start the game on my phone it lags alot. Is there any way I can convert the terrain to maybe a plane or anything simpler but still keep the textures and paintings on top?


texts: (LibGDX) Set actor to fixed position on TiledMap

texts:
How can I set an actor to an absolute / fixed position on my TiledMap, such that it does not follow the camera when I pan around?

Currently my code looks like:
camera = new OrthographicCamera();
rootGroup = new Group();

castleMap = new TmxMapLoader().load("castleMap.tmx");
isoMapRenderer = new IsometricTiledMapRenderer(castleMap, 1/32f);

...

final FitViewport fitViewport = new FitViewport(worldWidth, worldHeight);
stage = new Stage(fitViewport);
rootGroup.setSize(stage.getWidth(), stage.getHeight());
stage.addActor(rootGroup);

barracks = new Barracks(barracksIcon, self);
rootGroup.addActor(barracks);

From there, whether I try to position the barracks actor using
barracks.setPosition(x, y);

or using
Vector2 vector = new Vector2(x, y);
vector = stage.screenToStageCoordinates(vector);
vector = rootGroup.stageToLocalCoordinates(vector);
barracks.setPosition(vector.x, vector.y);

I get the same result.
I emphatically do not want to use Tables.
Thanks in advance!


texts: What should I do if my text exceeds my text render target boundaries?

texts:
I have a method for drawing strings in 3D that does the following:

Set a render target
Draw each character as a quadrangle using a orthographic projection to the render target
Unset the render target
Draw the render target texture using a perspective projection and a world transform

My problem is how to deal with strings whose characters length exceeds that of the render target dimensions?  For example if I have string "This is a reallllllllllly long string" and the render target can't accommodate it, it will only capture "This is a realllll".

The render target (and its size) could be set each frame but wouldn't that be far too costly?


texts: Creating a textured object infront of the current character in unity 3d

texts:
I've spent about half a day trying to get my head round this and I'm not having too much luck, essentially what I want to do is play an animation and then once the animation has finished create a flat disk shaped object in front of the current player, the code I have is as follows, please see my comments below for a list of problems:

Note this is cut down code to make the example easy.

static int idleState = Animator.StringToHash("Base Layer.idle");
static int portalState = Animator.StringToHash("Base Layer.Portal");

private RenderTexture portal_texture = Resources.Load("Portal") as RenderTexture;

void Start () {
    portal_texture = Resources.Load("Portal") as RenderTexture;
    anim = GetComponent<Animator>();
    if(anim.layerCount ==2){
        anim.SetLayerWeight(1, 1);
    }
}

void Update () {

    if(Input.GetKey("p")){
        anim.SetBool("cast_portal", true);
    }

    if(Input.GetKeyUp("p")){
        sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        sphere.transform.position = transform.TransformPoint(Vector3.zero);
        sphere.transform.localScale = new Vector3(3,3,1);
        Vector3 temp = sphere.transform.localScale;
        temp.x = (sphere.transform.localScale.x + 12.0f) * 0.5f;
        sphere.transform.localScale = temp;
        sphere.renderer.material.mainTexture = portal_texture;
    }
}

Problems

The render texture doesn't appear on the object
I need to have the object appear about 10 meters infront of where the character is facing, note I'm using a third person controller so camera position won't cut it.
How come in the inspector I can set any of the scaling options to 0.001 but if I try it in vector3 it throws an exception when compiling?
Where do I need to put this code so it only adds the sphere once the animation has finished?

I only started with unity this week so I'm probably missing something very obvious, I'm just having a bit of a brain freeze so any help would be greatly appreciated.

Thanks


texts: glVertexAttribPointer alters completely different shader program

texts:
My program contains two shader programs in it. The following code is for preparing one of the shader program's attributes:

int positionHandle2 = glGetAttribLocation(programAColorUTranslate, "vPosition");
glEnableVertexAttribArray(positionHandle2);
glVertexAttribPointer(positionHandle2, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0);
translateHandleAColorUTranslate = glGetUniformLocation(programAColorUTranslate, "vTranslate");

int aColorHandle = glGetAttribLocation(programAColorUTranslate, "aColor");
glEnableVertexAttribArray(aColorHandle);
/*glVertexAttribPointer(aColorHandle, 3, GL_FLOAT, GL_TRUE, 5 * sizeof(float), 0);*/

At this point, the program works fine, except that the vertices drawn by the above shader program are not colored, since the line above is commented out. However, if I uncomment the line above (and change the stride of position handle to 5 * sizeof(float)) to try to add colors to the above shader program's vertices, random shapes appear in my program. Supposedly, the above line should only alter triangles rendered by one of the shader programs, not both. However, every single vertex in my program is being rendered incorrectly after uncommenting the about line, to the point that the program becomes unrecognizable from before.


texts: Setting up SFML with CLion on Windows 10

texts:
For a school project I am trying to set up SFML on my computer that runs Windows 10. The assignment is developing a small engine, based on SFML, in a few weeks. I am very new to C++, and I am not used to the working pipeline and the ways of C++ development yet.

At the moment I am trying to set things up so that I can work on the project from home, but I have a lot of trouble understanding and setting things up, since it's very different to what I'm use to.

My CMakeLists.txt file looks like the following:

cmake_minimum_required(VERSION 2.8.4)
project(CppEngine)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")
if(WIN32)
    set(SFML_ROOT "$ENV{PROGRAMFILES(x86)}/SFML")
endif(WIN32)
set(CMAKE_BUILD_TYPE Release)
find_package(SFML 2.1 COMPONENTS system window graphics REQUIRED)
include_directories(${SFML_INCLUDE_DIR} ${PROJECT_SOURCE_DIR})
set(SOURCE_FILES main.cpp   )
set(HEADER_FILES            )
add_executable(CppEngine ${SOURCE_FILES} ${HEADER_FILES})
target_link_libraries(CppEngine ${SFML_LIBRARIES})

I get a very strange error message, as a result, whenever I try to compile and run. It is particularly strange, because I am running on Windows:

  error: #error This UNIX operating system is not supported by SFML library
               #error This UNIX operating system is not supported by SFML library

How can I fix this error?


texts: What to call an Object that falls only when it's collided with?

texts:
I am currently working on Objects/Blocks for my 2D Jump'n'Run. Now I want to add a new type of block, which falls down only if the player/an actor collides with it. But I don't know what to call this type.

Or more generally: Objects that only do stuff/change behaviour if interacted with.

How should I name the first type and
the second more general type?


texts: XNA 4.0 SpriteFont not displaying all Characters

texts:
Am looking for a little help and trying to use SpriteFont in my XNA 4.0 game but the problem is am displaying to string "This is a test" but all that's displayed on the screen is "This is     st" so the "a te" are missing from the screen.

The space is there for the characters but the letters are not.

The code am using is:

spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
spriteBatch.DrawString(font,"this is a test",new Vector2(692,372),Color.White);
spriteBatch.Draw(texture,new Rectangle(0,0,100,100),Color.White);
spriteBatch.End();

Any help with this would be great!


texts:
I say "deceleration" because I'm not using acceleration at the moment; what I mean is moving the velocity back towards zero, eventually stopping.

I'm new to vectors and not so great with physics and such. How is "deceleration" normally handled?

What I have now works, but it seems kind of hackish.

update:function(Game, t, dt) {
    var speed = Game.Input.isKeyDown('shift') ? 8 : 4;

    if (Game.Input.isKeyDown('a')) {
        this.velocity.i -= speed;
    }
    else if (Game.Input.isKeyDown('d')) {
        this.velocity.i += speed;
    }
    else {
        if (Math.abs(this.velocity.i) > 3) {
            this.velocity.i += (this.velocity.i > 0) ? -speed : speed;
        }
        else {
            this.velocity.i = 0;
        }
    }

    if (Game.Input.isKeyDown('w')) {
        this.velocity.j -= speed;
    }
    else if (Game.Input.isKeyDown('s')) {
        this.velocity.j += speed;
    }
    else {
        if (Math.abs(this.velocity.j) > 3) {
            this.velocity.j += (this.velocity.j > 0) ? -speed : speed;
        }
        else {
            this.velocity.j = 0;
        }
    }

    this.updateVectors(dt);
}

I used 3 because anything lower exhibits weird behaviour, I'm guessing if I raised the speed then it would need to be changed.


texts: How to implement smooth wandering on an annulus?

texts:
I am creating a 2D action platformer and want to create some steering behavior for a mage enemy.

Basically, I want the mage to smoothly wander inside an annulus centered on my player.

Below is an image depicting an example path the mage could follow.

The enemy currently has simple seek behavior. It simply accelerates toward whatever is set as its target.

I tried choosing a random target point in the annulus every so often, but when you do this, the enemy sometimes drifts across the center of the annulus to reach a point chosen on the other side.

So my question is, how can I achieve the desired movement?


texts: Collision detection for 2D RTS game in C++

texts:
I'm currently working on a real time strategy game in C++, and I need to implement a collision detection algorithm. I need to have a very efficient algorithm because this game will be running on mobile devices, and has potential to have many objects on the screen at one time.

I was thinking that a QuadTree might work for this, but then I realized it could be slow since QuadTree's are designed for static objects, and having many objects moving around the Q-Tree might not be optimal.

So I'm wondering what a good algorithm is for detecting collisions? The objects in my game will just have simple axis aligned bounding boxes to check for collisions, so I need a nice spacial indexing system so an object only checks for collisions with objects around it.


texts: How to calculate the price for acquisition of a mobile game

texts:
I searched long and hard thru the Game Dev community here and I didn't manage to find a good enough answer for a situation that I need help with.

Here is the deal - I've spent about a year to single-handedly develop a mobile game which is a mix between MMORPG and idle battle games. Wouldn't like to go into too much depth as to which game we are talking about and who is trying to buy it but, a company I have worked for before reached out to me with a proposal to buy the game from me so they can reap the profit from it and develop it further since they are a professional game dev company while I am a single person and I can't really reach the game's full potential as far as growth and player base goes. Now the game is pretty beneficial for me since I live in a region with a very low-income standard so the money I get from the game might not be much for many other people but for me, they are equal to about 1.5 ~ 2 monthly salaries (we are talking average salary for this country). That is about 600 Euros of pure profit after I pay for all the expenses. Of course, this number fluctuates depending on different events and sales I release and general user activity. It is a free-to-play-game so the income is mostly from microtransactions for in-game rare currency and special event item packs purchases.

Now the issue I have is that I am not sure how to set a price for the acquisition. What feels right for me would be to calculate the potential average income from the game in the next 12 months and add to this the average salary per month for a game dev of my qualifications multiplied by the number of months it took me to develop it to its released state. That would round up to about 15k euros.

When I think about it 15k euro isn't a small price to pay, but the game will pay that off in the next 1-2 years, and it might even grow much faster after they make investments for advertising and release new features and so on and so on. This means that after the second year they should be on a clean juicy profit from that deal, and that sounds good to me as well since 15k euros for me is a decent sum of money considering that the game has been running for about 14 months. And lets not forget that it has been beneficial for me for the last few months so it hasn't been always uphill.

What I need really is an advice as to is this price of around 15k Euro justified and is it a good deal for both sides, since I don't want to shoot way high and blow the acquisition, but I don't want to give the game away for a low price since it really holds a lot of potential, and it is my first fully released game.


texts: How make collision for terrain Modeled in 3D's max

texts: I read couple articels about collisions and terrain but there is nothing about terrain making in 3D program I can't see boundingBox being used for terrain collision there must be something like Every Single trinangle collision tell me if i wrong and give me some tips


texts: UE4 - Want my landscape to be unlit BUT catch shadows from objects

texts:
Here is my problem, I have a landscape that was created through photogrametry. I already has strong shadows on it's diffuse texture so I don't want it to be affected by my virtual sun. What I do want though is for objects added in my scene to receive shadows from the landscape, and for the objects to cast shadows onto the landscape. To do that I matched my virtual sun as close as I could with the shadows on the diffuse texture of the landscape.

How do I keep my landscape unlit yet able to receive and cast shadows from and to other objects?


texts: How could I implement my library/game to run in a browser plugin?

texts:
I usually code cross-platform, to build as native code for Mac Linux and Windows,
but I clearly see the value in being able to display my game in a browser.

Could you guide me in doing such a task? How could i have something like Unity Web Player?
Cross-browser is preferable, but Chrome would already be great  :)

I use technologies such as SFML, libRocket, Box2D and more.. If that is pertinent to the question!

Thanks


texts: Combination of DLL/Plugins with Object/Components

texts:
I worked on a personal game project (learning) for about the last year or so off and on in Ogre3D. Now that I am starting a new project, I want to avoid the Class Heirarchy for objects and having all of my libraries stuffed into one project file.

After a massive amount of reading, I am going to start implementing a Object/Components system tomorrow, mostly based off of what I have read on http://gameprogrammingpatterns.com/component.html but I want to have a better understanding before I proceed.

Ogre3D offers a Plugin system, which I understand to basically be the equivalent of a normal .dll library except it has install()/initialise()/uninstall()/etc methods, intended for registering factories.

So my confusion comes down to what would be best kept in a Plugin or DLL?

Most of what I read, people recommend putting wrappers for third party libraries into Plugins/DLLs so I am assuming I would want to have one for my Physics (Bullet) System, Audio (OpenAL) System, Input (OIS) System, and so on.

In that case, should I basically just strip the Managers out of my project, and move them to a Plugin/DLL? I am still quite confused on how I will actually go about implementing them into Components once they are moved, but I guess that will come with time.


texts:
My game consists of a player that hopes between ropes.
For now, I created the player and the rope classes.
 Each one contains details about the object and its movement patterns.
What is the next step in orfer to link between them?
  Iwant the player to stick on a rope once they have the same x.
Should i create an activitt Game that implements this attach method?
Thank you.


texts: Game Maker picking the wrong network adapter for broadcast

texts:
In my game I need to get the local network IP of the computer that is running the game, and for that purpose I have the following code:

// Create event
randomize();
var random_port = irandom_range(49152,65535);
host = network_create_server(network_socket_udp, random_port, 5);

if ( host < 0 ) {
    show_message("Failed to create a broadcast server");
    game_end();
} else {
    var tsock = network_create_socket(network_socket_udp);
    var tbuff = buffer_create(32, buffer_fixed, 1);
    buffer_fill(tbuff, 0, buffer_bool, 0, 32);
    network_send_broadcast(tsock, random_port, tbuff, buffer_get_size(tbuff));
    network_destroy(tsock);
    buffer_delete(tbuff);
}

/// Async network event
global.game_ip = string(async_load[? "ip"]);
instance_destroy();

I've manually set up my local network IP to be 192.168.1.150, but when I run the code above, I get the IP 169.254.51.115.

Because I wasn't expecting such IP, I ran the ipconfig/all command (on Windows) and I got the following output (I've translated the output because my computer is in another language, and I've deleted the information that isn't relevant to this):

Ethernet adapter:

   Specific dns for this connection. . : Home
   Description . . . . . . . . . . . . . . . : Realtek PCIe GBE Family Controller
   [...]
   IPv4 address. . . . . . . . . . . . . . : **192.168.1.150(Preferred)**
   Subnet Mask . . . . . . . . . . . . : 255.255.255.0
   Default gateway . . . . . : 192.168.1.1
   DHCP server . . . . . . . . . . . . . . : 192.168.1.1
   DNS Servers. . . . . . . . . . . . . . : fe80::1%13
                                       1.1.1.1
                                       1.0.0.1

Ethernet Npcap Loopback Adapter:

   Specific dns for this connection. . :
   Description . . . . . . . . . . . . . . . : Npcap Loopback Adapter
   IPv4 automatic configuration address: **169.254.51.115(Preferred)**
   Subnet mask . . . . . . . . . . . . : 255.255.0.0
   Default gateway . . . . . :
   DNS Servers. . . . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1

So, from my understanding point of view, Game Maker is getting the Ethernet Npcap Loopback Adapter instead of the regular ethernet adapter.

I could delete the Npcap Loopback adapter, but what if a user has wifi and ethernet connection?

Is there a way for Game Maker to choose one or another adapter?

In case the previous answer is no, is there a workaround for this  to avoid getting the Npcap loopback adatper?


texts: Deferred Lighting - How to map to the generated texture?

texts:
I'm trying to implement deferred lighting and I have done the first and second pass but I'm stuck on the third as I don't know how to map from the current pixel being drawn to the generated texture with the light.

Generated texture with light calculated

Current picture

I would appreciate it if someone could help me figure out how to map my generated texture with the current pixel I'm drawing.

I don't know if it matters, but I'm working with DirectX but an explantion with OpenGL would also be welcomed.


texts: My unity game fails to open in my mobile

texts:
I'm new to Unity, and want to make a android game. I made a very simple scene:

A sphere
A cube (floor)
A simple script that moves the sphere by touch.

I tried it with unity remote and it works fine. But the problem manifests when I build it to test it. When I run it on my mobile, it opens and suddenly gets closed. I don't know what is the actual problem. what should i do?


texts: Preventing a Child object (eg. some weapon) from going inside other objects in the scene?

texts:
I have Cube with a sword like object as its child object. But when the cube moves in the scene the sword goes into the other objects in the scene. The sword have a BoxCollider attached to it but the scene contains objects that are stationary and don't have a Rigidbody attached as I don't want them to be controlled by physics, same for the sword. If I attach Rigidbody to it then it will be displaced from its main position on collision.

I tried to render only the Cube including the sword with one camera having higher depth value then the main camera in the scene. If my game was in first person then this works fine but In 3rd person when object get behind other objects in the scene we can still see the object.

How can I prevent the sword from going into other object without being controlled by physics?

Image: