texts: Calculate tile ID on a Reus style world with canvas context.arc()

texts:
I need a bit of math help for my game.

I'm using Javascript and the Canvas tag to create a circular world, think God Finger, and Reus.  The current version of my game is here: http://lazyeels-sandbox.appspot.com/

The problem:
The Canvas draws an arc (or circle) starting at 90 degrees going clockwise. See an example image.

My game splits the world in to segments (tiles).  The world is 10 tiles in length I would like to calculate which tile the mouse is hovering over so the player can add buildings or adjust the height of the tile.

So I need to calculate the offset and deduct it from the mouse angle (either radians or degrees is fine). However, I can't seem to get it right.  I know that in theory I should do the following:

Calculate the angle of the mouse.
Calculate the tile by dividing by the segment size (as per regular tile maps i.e. y-axis/tilewidth).
Remove the offset of the angle to point 0 degrees at the top of the circle rather than 90 degrees clockwise).
Deduct the offset to get the new tile position.

Here is the main function I'm using;

var getMouseAngle = function(mouse){
    var world_length = 10;
    var segment = (Math.PI * 2)/world_length;

    // Get the distance
    var dx = mouse.x - ((canvas.width * 0.5) - Game.camera.xScroll);
    var dy = mouse.y - ((canvas.height - Game.camera.yScroll) * Game.camera.zoom);

    // calculate the angle
    var arctan = Math.atan2(dy, dx);

    // Reset the angle if it is a negative value
    var angle =  dy < 0 ? (Math.PI * 2) + arctan: arctan; // perhaps this is where I need to apply the offset.

    // Calculate the tile
    var orig_tile = angle/segment;

    // Calculate the offset
    var offset_tile = ((Math.PI * 3/2)/segment); // calculate offset clockwise = 270 degrees to the top of the circle (where the player sits).

    var tile = (orig_tile - offset_tile) // This is soooooo wrong

    return {
        dx: dx,
        dy: dy,
        degrees: (angle * 180/Math.PI).toFixed(2),
        radian: angle.toFixed(2)
        tile: Math.floor(tile),
    };

By comparison the player tile function was way easier:

Player.getTile = function(rotation){
    var tile = Math.floor(rotation/Game.level.segment);

    if(rotation > 0){
        tile = Math.abs((Game.level.world.length - tile)-1);
    } else {
        tile = Math.abs(tile)-1;
    }
    if(rotation == 0){
        tile = 0;
    }
    return tile;
};

Does anyone know where I'm going wrong in the calculation, i.e. how and when should I apply the offset - on the angle before calculating the tile, or afterwards?

I haven't shown the other permutations I tried, such as deducting the offset from the original angle, all of these resulted in the wrong tile ID being returned.

I know it should be a similar process to the player function, i.e. using the word_length in the calculation.


texts: How to scale openGL textures by a ratio based on height/width (or alternative)?

texts:
I have been able to successfully allow my UI to extend over edges of my game on higher resolutions by using the Android Guide and by implementing this code on the GL10 object:

gl.glTranslatef(GTEngine.get_SCREEN_RATIO(), 0f, 0f);

Where the first parameter is the ratio calculated by dividing the width by the height.

My confusion arises in the ability to use :

gl.glScalef(n,n, 1f);

... to scale the image by using the same screen ratio in order to account for the "growth" or "shrinkage" that comes with different resolutions. Does anyone have a solution for this n variable? I cannot seem to make up some mathematically solution that works, and am worried that I may be forced to build a case by case logic (>.>)


texts:
I am attempting to implement an auto-save feature into a mobile game.  I have the following code writing to the save file:

function saveFunc(input)
local saveData=input
local file = io.open( "saveFile.txt", "w" )

for i,val in ipairs(saveTable) do
    saveData=saveData.."\n"..val
end

file:write( saveData )
io.close( file )
end

This writes to the file correctly.  The problem is that after the function finishes, the whole app restarts.  Watching the output console, it re-prints the "Copyright (C)..." as if I had Relaunched the app.

I know it is this specific function because if I comment out the call for this function the game continues as normal.  I also tried commenting out the io.close(file) but the program still restarted.

How can I write to a file and not restart the app?


texts: Unity2D: Proper way to implement ladder climbing with a raycast controller?

texts:
I originally posted this on Stack Overflow, but was told I might have more luck here:

I've been slowing grinding out programming features for my character controller, and one of the last things to implement is ladder climbing. The code I've come up with over the past 2 days mostly works, but presents some issues:

Sometimes the character bounces after climbing while holding the up arrow, at the point with which a 1-way platform meets the end of the ladder.
Once the character is all the way up, resting on the 1-way platform, it cannot go back down. This can be remedied with a longer ladder collider, but that makes issue #1 worse.
If the character is on the ground near a ladder and jumps, but presses the up arrow at the very last second, it gets flung considerably far in a certain direction.
If the character is on a rope and jumps off the rope, but holds the up arrow before doing so, it goes slightly higher, but is noticeable. Not holding the up arrow, but rather just pressing the left or right arrow and jumping, yields a regular jump. Perhaps this has something to do with the x or y input axes?

The way my classes work is that I have a Controller2D class which handles most of the raycasting stuff and movement methods, a Player class for input that calls the movement methods, and a parameters class that sets default world parameters, like gravity and jump height, but can be overridden if the character is in a certain volume, such as water or a ladder collider (this allows me to set gravity to 0 while climbing so the character can move properly). Almost all of my ladder code is contained in the OnTriggerEnter/Stay/Exit functions, and I'm just not sure if this is the best way to do it.

I tried making a ClimbUp/ClimbDown method, and shooting a raycast from the center of the player, which would allow him or her to climb up, but this was not overly successful (there were too many issues compared to using OnTriggerStay).

I'm wondering if someone who has successfully implemented ladder climbing in a raycast controller, or anybody who might have advice, would be willing to point me in the right direction for this task.

Here's some of the script:

public void ClimbLadder(float y)
{
    ClimbingOnLadder = true;
    SetVerticalForce(y);
}

public void JumpWhileClimbing(float x)
{
    if (ClimbingOnLadder)
    {
        ClimbingOnLadder = false;
        overrideParameters = null;
        AddForce(new Vector3(x, Parameters.jumpVelocity * .70f, 0));
        JumpAfterClimbing = true;
        print(Parameters.jumpVelocity);
    }
}

private void OnTriggerEnter2D(Collider2D other)
{
    if (other.tag == "Ladder")
    {
        CanClimb = true;
    }
}

private void OnTriggerStay2D(Collider2D other)
{
    if (other.tag == "Ladder")
    {
        if (ClimbingOnLadder)
        {
            var newParameters = other.gameObject.GetComponent<ControllerPhysicsVolume2D>();

            if (newParameters == null)
            {
                return;
            }

            overrideParameters = newParameters.NewParameters;
            Debug.Log("overriding");

            if (ClimbingOnLadder && State.IsCollidingBelow)
            {
                ClimbingOnLadder = false;
                overrideParameters = null;
            }
        }
    }
}

private void OnTriggerExit2D(Collider2D other)
{
    if (other.tag == "Ladder")
    {
        CanClimb = false;
        ClimbingOnLadder = false;
        JumpAfterClimbing = false;
    }

    var newParameters = other.gameObject.GetComponent<ControllerPhysicsVolume2D>();

    if (newParameters == null)
    {
        return;
    }

    overrideParameters = null;
}


texts: Change transparency of image at runtime, LOVE2D

texts:
I would like to know how to take a defined image (e.g. a tile) in the LOVE game engine and draw it with a transparency that may vary per-frame. Stencils seem to only work for completely hiding parts of an image; I need to make an entire tile translucent, and the degree of translucency needs to be able to vary during gameplay.

(purpose: I am messing around with a game idea that involves partial information during fog-of-war, represented by superimposing all tiles that might be somewhere based on what you currently know)


texts: Unity 3D - Confine a gun rotation within certain degrees

texts:
I am having troubles making my gun rotate up and down, and have limits, for example, I want the down limit to be 0 degrees, and the up limit to be 90 degrees.

Currently I can't figure out how to define that, and when the gun gets to one of the extremes, it gets stuck there and doesn't want to go back. Whats wrong?

Here's how I rotate the gun using an on-screen joystick

float lookAxisX = CrossPlatformInputManager.GetAxisRaw("VerticalLook");

        if ((transform.localEulerAngles.x <= 360 && transform.localEulerAngles.x > 270) ||
            (transform.localEulerAngles.x >= 0)
            ) {
            transform.localEulerAngles += new Vector3(-lookAxisX * 2f, transform.localEulerAngles.y, transform.localEulerAngles.z);
        }

        Debug.Log("transform: " + transform.localEulerAngles);

Also right now, when the gun is at the default rotation (facing forward, its X angle is 0, and when it rotates up, it goes from 0 to 359,9, and then at 270 it gets stuck


texts: How do I dynamically use the rect tool in Unity2D?

texts:
The rect tool in Unity2D (I honestly do not remember if it is present in Unity3D) allows you to scale down/scale up an object in just one direction (what it does is it simultaneously increases/decreases the height of an object in transform.scale and transform.position. I was trying to scale down an object while keeping its position the same using this code (P.S. I took the first four lines of code from here: The Best Way To Generate a Random Float in C#):
       float range = (double)float.MaxValue - (double)float.MinValue;
       float sample = scaleRand.NextDouble();
       float scaled = (sample * range) + float.MinValue;
       float f = (float)scaled;
        if (f > 0.6f)
        {
            f = 0.6f;
        }
            gameObject.localScale = new Vector2(gameObject.lossyScale.x, (gameObject.lossyScale.y - f));

However, this code does not work. So, how can I recreate the effect of using the rect tool in Unity Editor using C#?


texts:
In many arcade-style games with a horizontally scrolling camera, enemies spawn offscreen, either left or right, and traverse the screen in the opposite direction.

Spawning enemies is easy enough, but my question concerns the logic of getting them to spawn in an arcade-type way, just offscreen and according to the predefined patterns of the designer.

One idea I thought of was designating trigger areas in my level.  When the player enters a trigger, enemy spawn points associated  with that trigger then spawn enemies. But with a scrolling camera, sometimes as the camera scrolls, those spawn points enter the viewport and enemies spawn on screen out of nowhere.

What is a good technique to achieve arcade-style enemy spawns?

Here are two examples of the types of spawns I am thinking about:

https://youtu.be/Z7lAZExM21k?t=310 (Blazing Chrome by Joymasher)
https://youtu.be/UAOFcpOfOVs?t=362 (Nightmare Busters by Arcade Zone)


texts: I have a 2D skeleton animation of human walk cycle - which is fine. I am trying hard to code that should STOP only hands animation but legs should not (on a player input - for example on space bar press) Is it possible to disable animation keyframes/curves/properties on some condition Or any other way to achieve this.


texts:
hi i am currently implementing UI screen that shows Depth Complexity of scene,
so that we can figure out how many time each pixels work for same pixels.

for this i need to render stencil ref value.
i successed to READ stencil ref value of each pixels using staging texture.
but i couldn't figure out how to pass this data to pixel shader, so that i can render 'Depth complexity'.

brief code that i have tried now.

//initializing Depth Stencil buffer-----------------------------------

D3D11_TEXTURE2D_DESC ds_desc;
    ds_desc.Width = SCREEN_WIDTH;
    ds_desc.Height = SCREEN_HEIGHT;
    ds_desc.MipLevels = 1;
    ds_desc.ArraySize = 1;
    ds_desc.Format = DXGI_FORMAT_R24G8_TYPELESS;
    ds_desc.SampleDesc.Count = 1;
    ds_desc.SampleDesc.Quality = 0;
    ds_desc.Usage = D3D11_USAGE_DEFAULT;
    ds_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
    ds_desc.CPUAccessFlags = 0;
    ds_desc.MiscFlags = 0;
    Create DepthStencil Texture ...

    D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc;
    dsv_desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
    dsv_desc.Flags = 0;
    dsv_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
    dsv_desc.Texture2D.MipSlice = 0;
    Create DepthStencilView

    DX_DContext->OMSetRenderTargets(1, rtv.GetAddressOf(), dsView.Get());

// process to create SRV--------------------------------------------------------
D3D11_TEXTURE2D_DESC desc;
    desc.ArraySize = 1;
    desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
    desc.CPUAccessFlags = 0;
    desc.Format = DXGI_FORMAT_X24_TYPELESS_G8_UINT;
    desc.Width = SCREEN_WIDTH;
    desc.Height = SCREEN_HEIGHT;
    desc.MipLevels = 1;
    desc.MiscFlags = 0;
    desc.SampleDesc.Count = 1;
    desc.SampleDesc.Quality = 0;
    desc.Usage = D3D11_USAGE_DEFAULT;
    Create StagingTexture2D...

DX_DContext->CopyResource(copyTex->Get(), graphic->DepthStencilBuffer());

    D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
    srvDesc.Format = DXGI_FORMAT_X24_TYPELESS_G8_UINT;
    srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
    srvDesc.Texture2D.MipLevels = 1;
    srvDesc.Texture2D.MostDetailedMip = 0;
    Create SRV for binding to pixel shader...

//

and i bind this srv into this pixel shader
and just always showing BLACK

Texture2D<float4> uiTexture : register(t0);

float4 main(PS_INPUT input) : SV_Target
{
    int2 idx = int2(0, 0);
    return uiTexture[idx];

}

any advice or alternative would be really appreciated.


texts: How are CSS and WebGL coordinates related?

texts:
I'd like to build a simple framework which rendering combines web page DOM elements with WebGL, such that they're manipulable in the same coordinate space.

How does the plain CSS coordinate system relate to the one used by WebGL? How can I make sure the two line up (e.g. have a div and a WebGL quad transformed the same way)? Can I expect CSS3D transform coordinates to correspond to WebGL?


texts: I am working on an Quiz game i am trying to get user input from the player in ters of button by adding listeners

texts:
but i get no touch input when i make click on gameplay, i have added onClick().Here is the code......................
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class Level2UI : MonoBehaviour
{
    private List<string> sceneHistory = new List<string>();
    [SerializeField] private Level2Manager gameManager;
   [SerializeField] private TextMeshProUGUI questionText;
   [SerializeField] private List<Button> options;
   [SerializeField] private Color CorrColor, WrongColor, NormalColor;
    private Question question;
    private bool answered;

    // Start is called before the first frame update

    void Awake()
    {
        for(int i = 0; i < options.Count; i++)
        {
            Button localBtn = options[i];
            options[i].GetComponentInChildren<Button>().onClick.AddListener(delegate { ClickedAnswer(localBtn); });
            //   localBtn.onClick.AddListener(delegate { ClickedAnswer(localBtn); });
            Debug.Log("testclick");
      //      btn.onClick.AddListener(ClickedAnswer);

        }
    }
    public void SetQuestion(Question question)
    {
        this.question = question;
        questionText.text = question.questionInfo;

        List<string> answerList = ShuffleList.ShuffleListItems<string>(question.options);
        for(int i=0; i< options.Count; i++)
        {
            options[i].GetComponentInChildren<TextMeshProUGUI>().text = answerList[i];
            Debug.Log("check");
            options[i].name = answerList[i];
            options[i].image.color = NormalColor;
        }
        answered = false;
   //     setButton();
    }

    public void ClickedAnswer(Button btn)
    {

        print("txt");
        if (!answered)
        {
            answered = true;
            bool val = gameManager.Answer(btn.name);

            if (val)
            {
                btn.image.color = CorrColor;
                Debug.Log("test1");
            }
            else
            {
                btn.image.color = WrongColor;
                Debug.Log("test");
            }
        }
    }
    //Call this whenever you want to load a new scene
    //It will add the new scene to the sceneHistory listss
    public void LoadScene(string newScene)
    {
        sceneHistory.Add(newScene);
        SceneManager.LoadScene(newScene);
    }

    //Call this whenever you want to load the previous scene
    //It will remove the current scene from the history and then load the new last scene in the history
    //It will return false if we have not moved between scenes enough to have stored a previous scene in the history
    public bool PreviousScene()
    {
        bool returnValue = false;
        if (sceneHistory.Count >= 2)  //Checking that we have actually switched scenes enough to go back to a previous scene
        {
            returnValue = true;
            sceneHistory.RemoveAt(sceneHistory.Count - 1);
            SceneManager.LoadScene(sceneHistory[sceneHistory.Count - 1]);
        }

        return returnValue;
    }
}


texts:
I would like to use dragonBones with pixi.js. I got a problem.

When the following line executes in dragonBones, I am getting an error:

slot.init(slotData, displays, new PIXI.Sprite(), new PIXI.mesh.Mesh(null, null, null, null, PIXI.mesh.Mesh.DRAW_MODES.TRIANGLES));

The error says: Uncaught TypeError: Cannot read property 'Mesh' of undefined.. And yeah, while debugging, I noticed that PIXI.mesh is really undefined.

What can I undertake against the error?

I am using this file for a dragonbones.

May it be that the problem is in the fact that I am using pixi.js - v4.5.6?


texts:
Two animated car object both contain a rigid body, a box collider and a script with an OnTriggerEnter event.

I want to check which car started the collision event, by hitting the other car.

Consider two cars; regardless of whether carA hits carB or carB hits carA, both cars contain the same script with the same event. So both cars become the trigger.

How do I identify which car started the collision? I wish to do so without the use of raycasting, as it is too expensive for what I am wanting to do.


texts: MonoGame game does not work on other pc, when installed by WiX

texts:
I made a simple tetris game. I wanted to give it to my friend, so that he could test it. I made very fast WiX project and setted up every file from bin/Debug. On my PC it works after installing, but when I sent installer file (.exe because of EmbedCab="yes") he ran it and it installed, yet game does not work at all. I suppose he does not have some DLLs. Is there a way to install those with WiX and what files should I add there?

I found, that I should use OpenAL installer, but how to run this with WiX?

I found a solution after a lot of searching. I now install OpenAL with WixUtilExtension using CustomAction tag. Now I found, that i need also ensure that .Net4.5 is installed. I will go googling. Maybe after another hour I will find how to do this :)


texts:
Been looking for a way to implement some OpenCL stuff in my libGDX project. It's possible via LWJGL which libGDX is based on, but it's only for the Desktop environment.

I would like to have it cross platform as libGDX was meant to be used; how can I do that?


texts: In Unity, How to format Old RPCs into new "PunRPCs"

texts:
In older unity versions you could simply used RPC. With newer verisons of Unity my code now doesn't work and it says that it needs to be transformed into "PunRPC" , Pun being "Photon Unity Networking." I am not sure how to reformat it to work with current unity versions. Can anyone shed light on this?

My Code

FXManager.cs

1 using UnityEngine;
2 using System.Collections;
3
4 public class FXManager : MonoBehaviour {
5
6   [RPC]
7   void SniperBulletFX( Vector3 startPos, Vector3 endPos ) {
8       Debug.Log ("SniperBulletFX");
9
10  }
11}

PlayerShooting.cs

1 using UnityEngine;
2    using System.Collections;
3
4    public class PlayerShooting : MonoBehaviour {
5
6   public float fireRate = 0.5f;
7   float cooldown = 0;
8   public float damage = 25f;
9   FXManager fxManager;
10
11  void Start() {
12      fxManager = GameObject.FindObjectOfType<FXManager>();
13
14      if(fxManager == null) {
15          Debug.LogError("Couldn't find a FXManger.");
16      }
17  }
18
19
20  // Update is called once per frame
21  void Update () {
22      cooldown -= Time.deltaTime;
23
24      if (Input.GetButton ("Fire1")) {
25          //Player wants to shoot...so. Shoot.
26          Fire ();
27      }
28  }
29
30  void Fire() {
31
32      if (cooldown > 0) {
33          return;
34      }
35
36      Debug.Log ("Firing our gun");
37
38      Ray ray = new Ray (Camera.main.transform.position, Camera.main.transform.forward);
39      Transform hitTransform;
40      Vector3 hitPoint;
41
42      hitTransform = FindClosestHitObject (ray, out hitPoint);
43
44      if (hitTransform != null) {
45          Debug.Log ("We hit:" + hitTransform.name);
46
47          // We could do a special effect at the hit location
48          // DoRicochetEffectAt (hitPoint);
49
50          Health h = hitTransform.GetComponent<Health> ();
51
52          while (h == null && hitTransform.parent) {
53              hitTransform = hitTransform.parent;
54              h = hitTransform.GetComponent<Health> ();
55          }
56
57          // Once we reach here, hitTransform may not be the hitTransform we started with!
58
59          if (h != null) {
60              // This next line is the equivalent of calling;
61              //                  h.takeDamage( damage);
62              //Except more "networky"
63              PhotonView pv = h.GetComponent<PhotonView> ();
64              if (pv == null) {
65                  Debug.LogError ("Freak out!");
66              } else {
67                  h.GetComponent<PhotonView> ().RPC ("TakeDamage", PhotonTargets.AllBuffered, damage);
68              }
69          }
70
71          if (fxManager != null) {
72              fxManager.GetComponent<PhotonView>().RPC ("SniperBulletFx", PhotonTargets.All, Camera.main.transform.position, hitPoint);
73          }
74      }
75      else {
76          // We didn't hit anything (except empty space), but let's do a visual FX anyway
77          if (fxManager != null) {
78              hitPoint = Camera.main.transform.position + (Camera.main.transform.forward*100f);
79              fxManager.GetComponent<PhotonView>().RPC ("SniperBulletFx", PhotonTargets.All, Camera.main.transform.position, hitPoint);
80          }
81      }
82
83      cooldown = fireRate;
84  }

If anymore information is needed, please let me know, I would love to figure out how the new "PunRPC(Photon Unity Neworking)" works so I can use it in future projects.

Edit: This is the error I get "PhotonView with ID 2 has no method "SniperBulletFx" marked with the PunRPC or @PunRPC(JS) property! Args: Vector3, Vector3
UnityEngine.Debug:LogError(Object)"


texts:
Possible Duplicate:
  What’s the best way to create animations when doing Android development?
  What animation technique is used in ‘Dont Starve’?

I've always admired Zeptolab for their smooth in game animations. Zeptolab has created both Cut the Rope and now Pudding Monsters.

I'm wonder how you're able to get animations this smooth? Are these sprite sheets? Are they actual 3D models?

Here's a video of their latest game:
http://www.youtube.com/watch?v=rV1dlN-dbJQ

If you get to the game play you'll see how the guys are constantly wiggling and it's so smooth. You also saw this in the monster guy in Cut the Rope.

I'm just wanting some insight into how this is done. Like what tools they may be using.

Thanks


texts:
I'm trying to keep this as simple as possible, as I've found out the last few days this is a very difficult topic. I'd like to generate multiple flat islands, formed by a voronoi diagram. I've followed a long and (for me) difficult tutorial of building a procedural hexagonal grid just to find out it looks to artificial.

I'd like to create a plane with faces divided in a voronoi diagram, and extrude multiple groups upwards to create islands. With that I'd like to achieve something similar as this: http://applemagazine.com/wp-content/uploads/2015/10/image2.jpg

Please help to get me started in the right direction, since my approach might be wrong in itself.

EDIT:

I've found this: https://github.com/jceipek/Unity-delaunay. Which draws lines in a voronoi diagram. Now I'm guessing the next step is to convert this to a mesh. Then I'd have to highlight random faces to be extruded to create the islands. Maybe this could be done with perlin noise, which I've just learned about. Extruding might not be the best way. Maybe deleting the faces that won't be land, and creating fall of edges (Like Wardy said).  I'm doing my best to figure this out on my own, but any help is greatly appreciated.


texts: Should I make my games graphics lower quality so everyone can play it?

texts:
The game I'm working on targets lower end graphics capabilities machine users.

Should I make my game's graphics lower quality so that everyone can play it or make its graphics high quality so that people must go and buy a new GPU to play it?


texts: Unity UI - Assigning Event Callbacks Via Script Fails for Objects Instantied by script

texts:
So I have a pretty basic tower defense game going on, there are set build points each with their own mini canvas UI for building and upgrading towers. Once you build a tower on them, they disappear and I instantiate a tower prefab with the new UI setup for upgrading said tower. Now, if I have a tower pre placed in the scene all the calls to the UI button events (set up via script) work just fine, however for whatever reason on a cloned object although all the setup script is still being called (I checked with debug statements) the events will not be called. I'm almost certain this is a bug, I'm using the latest stable version of Unity (5.3.4f1), I have my canvas set up correctly and there is an EventSystem object in the scene. Here is the button event setup script I use (it's a component on the button itself which is a child of the popup obejct on the Canvas which is a child of the actual tower object.

using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using System.Collections;

public class UpgradeButtonSetup : MonoBehaviour {
    public string buttonType = "";
    private AttackCollector ac;
    private Collector c;
    private UnityEvent eButtonDown;
    // Use this for initialization
    void Awake () {
        Debug.Log("Setting up");
        eButtonDown = new UnityEvent();
    //  eButtonUp = new UnityEvent();
        EventTrigger trigger = gameObject.GetComponent<EventTrigger>();
        EventTrigger.Entry entry = new EventTrigger.Entry();
        ac = transform.parent.parent.parent.GetComponent<AttackCollector>();

        if(ac == null){
            Debug.Log(transform.parent.parent.parent);
            c = transform.parent.parent.parent.GetComponent<Collector>();

            switch(buttonType){
                case "hp":
                    eButtonDown.AddListener(c.UpgradeHp);
                    break;
                case "resource":
                    eButtonDown.AddListener(c.UpgradeResourceGen);
                    break;
                default:
                    eButtonDown.AddListener(c.UpgradeHp);
                    break;
            }

        }
        else{
            switch(buttonType){
                case "hp":
                    eButtonDown.AddListener(ac.UpgradeHP);
                    break;
                case "attkspeed":
                    eButtonDown.AddListener(ac.UpgradeAttackSpeed);
                    break;
            }
        }

        entry.eventID = EventTriggerType.PointerDown;
        entry.callback.AddListener((eventData) => {ButtonDown();});
        trigger.triggers.Add(entry);

    }

    void ButtonDown(){
        eButtonDown.Invoke();
    }
}

Before I submit a bug to the Unity team I just want to sanity check to make sure it's not something on my end.


texts: What I want to achieve is the player moving to the touched position on a 2D grid-based game, stopping at the last reachable spot if the target position is unreachable. What is the strategy usually adopted in these cases? Should I implement a specific path finding algorithm for the player?


texts:
So far in previous games I have used simple 2D collision with boxes then checking at pixel level for a collision.

If making a pinball game in nearly a lot of frames the ball will be in contact with a wall or another surface so is there another approach?


texts: Changing Palette for Day/Light Mode using GIMP

texts:
Suppose I've a picture, which want to achieve day/light mode by changing 8bpp color palette.

If I want the pixel index of my picture is always fixed for both day mode and night mode. For example, the 1st pixel index is 100. Which I can look up index 100 in day mode palette and night mode palette. How can I use GIMP to do so? My goal is to not update my pixel index of my picture.

Also, as you see in two palette, they are not one one mapping. That is index 1 of the day mode palette and index 1 of the night mode palette may not used in the same pixel of the picture, how can I tackle this problem?

Actually, my use case is as follow
I want to use one 8bpp picture to achieve day/night mode by update only the color palette (without updating the pixel index). The advantage is I only have to prepare 2 256 byte palette rather than saving 2 big pictures in my limited data ram.

Thanks a lot


texts:
I am looking for an elegant way to do ray and polygon intersections in 2d. I don't care about languages.

Now what I'm doing is taking a line that lies on the ray (with a screen length) and testing line-to-line intersections between this derived-ray and all lines formed by each consecutive vertices in the polygon.

This, for now, is good even if I don't know which parts of the ray are inside or outside the polygon (in cases it is concave one). But for now I don't need this information, even if a general approach could maybe give it.

I don't care about self-intersection polygons.

Any advice? Maybe triangulating the polygons could be an idea?


texts: What common spritesheet formats for 2D Top-Downish Games are there?

texts:
For 2D top-down style sprites, what commonly used spritesheet formats are available?

By a sprite sheet format, I mean this: for any RPG Maker sprite sheet, you can count on all the walk animations being in the same place on the image between characters. For Final Fantasy 6's characters, you could open all their sprite sheets and compare them and in each one, the walk animations, crouching sprites, surprised sprites, etc would all be in the same places. They all adhere to a standard.

I'm using RPG Maker XP right now and it defines character tilesets as having four states -- facing up, down, left, and right, each with animation. This is really restrictive, and I'd rather have more options like Final Fantasy 6.

So are there any more common sprite sheet formats out there that I can use?


texts: What is the contents of the buffer *after* a call to glSwapBuffers()?

texts:
(SDL_GL_SwapBuffers() in particular)

When you have drawn a scene, and you call swap-buffers, it is routine to then glClear() the scene before drawing anything; if you don't clear, what is the contents of the buffer?  Is this defined by any specification, or does it vary by driver?


texts: c++ text based duel game, buggy turn mechanic

texts:
so ive checked this code 100 times for mistakes and everything checks out and should be working, I've tried everything I can think of but for some reason nothing works, this makes the movement super buggy and none of my attack works

this is a snippet from my initiation class

Frame();

Counter = 1;
//Player One's turn
while (Counter == 1)
{

    Map::Movement();
    Attack::Playerattack();
}
//Player two's turn
while (Counter == 2)
{
    Map::Movement2();
    Attack2::Playerattack();
}

part of my movement class

int ch;
switch (ch = _getch())
{
    //Player 1 movement
case KEY_W: //up
    if (Player::posy != 1)
    {
        Player::posy--;
        DisplayMap();
        Start::Counter++;
    }
    break;

case KEY_S: //down
    if (Player::posy != 20)
    {
        Player::posy++;
        DisplayMap();
        Start::Counter++;
    }
    break;

case KEY_A: //left
    if (Player::posx != 1)
    {
        Player::posx--;
        DisplayMap();
        Start::Counter++;
    }
    break;

case KEY_D: //right
    if (Player::posx != 20)
    {
        Player::posx++;
        DisplayMap();
        Start::Counter++;
    }
    break;

1st attack class

int ch;
switch (ch = _getch())
{
    case KEY_1:
        if (((Player::posx == Player2::posx) && (Player::posy == Player2::posy + Player::roa1)) || ((Player::posx == Player2::posx) && (Player::posy == Player2::posy - Player::roa1)) || ((Player::posy == Player2::posy) && (Player::posx == Player2::posx + Player::roa1)) || ((Player::posy == Player2::posy) && (Player::posx == Player2::posx - Player::roa1)))
        {
            Player2::hp = Player2::hp - Player::doa1;
            std::cout << "You have used: Attack 1" << std::endl;
            std::cout << "Player 2 HP is now: " << Player2::hp << std::endl;
            Start::Counter++;
        }

//if enemy is in range of attack 2 below the monster
    case KEY_2:
        if (((Player::posx == Player2::posx) && (Player::posy == Player2::posy + Player::roa2)) || ((Player::posx == Player2::posx) && (Player::posy == Player2::posy - Player::roa2)) || ((Player::posy == Player2::posy) && (Player::posx == Player2::posx + Player::roa2)) || ((Player::posy == Player2::posy) && (Player::posx == Player2::posx - Player::roa2)))
        {
            Player2::hp = Player2::hp - Player::doa1;
            std::cout << "You have used: Attack 2" << std::endl;
            std::cout << "player 2 HP is now: " << Player2::hp << std::endl;
            Start::Counter++;

2nd Attack class

int ch;
switch (ch = _getch())
{
    case KEY_K:
        if (((Player2::posx == Player::posx) && (Player2::posy == Player::posy + Player2::roa1)) || ((Player2::posx == Player::posx) && (Player2::posy == Player::posy - Player2::roa1)) || ((Player2::posy == Player::posy) && (Player2::posx == Player::posx + Player2::roa1)) || ((Player2::posy == Player::posy) && (Player2::posx == Player::posx - Player2::roa1)))
        {
            Player::hp = Player::hp - Player2::doa1;
            std::cout << "Player 1 HP is now: " << Player2::hp << std::endl;
            Start::Counter--;
        }

    case KEY_L:
        if (((Player2::posx == Player::posx) && (Player2::posy == Player::posy + Player2::roa2)) || ((Player2::posx == Player::posx) && (Player2::posy == Player::posy - Player2::roa2)) || ((Player2::posy == Player::posy) && (Player2::posx == Player::posx + Player2::roa2)) || ((Player2::posy == Player::posy) && (Player2::posx == Player::posx - Player2::roa2)))
        {
            Player::hp = Player::hp - Player2::doa1;
            std::cout << "player 1 HP is now: " << Player2::hp << std::endl;
            Start::Counter--;

if anyone has ANY ideas what im doing wrong or have overlooked please tell me and I will try it, I'm working in visual studio 2012.


texts: How to trace contour of shapes with holes?

texts:
I am experimenting with the RVO2 library for collision avoidance in a 2D simulation. This library supports specifying arbitrary obstacles as a list of vertices. The obstacles must be full shapes, i.e. they must not contain holes.

I've pretty much figured out how to find the contour of a shape (using algorithms such as these), but holes are giving me trouble. Basically I need to solve the following questions:

How to tell if a contour is inside or outside the shape?
How to tell if a shape has a hole inside?
Once a shape has been determined to have a hole, how to segment it to form a shape without hole?

This drawing illustrates the third idea: the outer shape has been segmented so the contour is continuous, i.e. RVO2 can consider it as a shape without hole.


texts: How can I create the correct player object based on a type in a network message?

texts:
I am using lidgren as a networking library for a small XNA game. I am using a client/server architecture for the game. Currently, I have the client and server connecting but I would like to be able to pass an enum with a character type when the client requests to join the server. Here is a sample of my code:

while ((inMsg = networkManager.ReadMessage()) != null)
        {

            switch (inMsg.MessageType){
                case NetIncomingMessageType.StatusChanged:
                    switch ((NetConnectionStatus)inMsg.ReadByte()){
                        case NetConnectionStatus.Connected:
                            if (!this.isHosting)
                            {
                              //Extract player info from message and create a local player
                            }break;
                        case NetConnectionStatus.RespondedAwaitingApproval:
                            pType = (PlayerType)inMsg.ReadByte();
                            playerManager.AddPlayer(pType);
                            //Then I will send the player information to the client
                            inMsg.SenderConnection.Approve();
                            break;
                    }
                    break;

            }

            this.networkManager.Recycle(inMsg);
        }

When server gets a message with RespondedAwaitingApproval flag, I would like to be able to read the message, extract the type and create an instance of a player of that type. How can I accomplish that?


texts: game object disappears when I add OnTriggerEnter script

texts:
I'm setting up collision detection for my enemy objects and projectile. When I add the detect collision script below, my enemy object just disappears. Projectile has the same detect collision script and also disappears.
I get this error code:
NullReferenceException: Object reference not set to an instance of an object
MoveForward.Start () (at Assets/Scripts/MoveForward.cs:16)
This is a copy of my prefab settings for enemy object:

I'd appreciate any advice. Thank you
Detect Collision Script
using System.Collections.Generic;
using UnityEngine;

public class DetectCollision : MonoBehaviour
{
  // Start is called before the first frame update
  void Start()
  {

  }

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

  }

  private void OnTriggerEnter(Collider other)
  {
    Destroy(gameObject);
    Destroy(other.gameObject);
  }

}

Move Forward Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveForward : MonoBehaviour
{
  public float speed = 20f;
  public GameObject Trump;
  public GameObject Player;
  private Rigidbody enemyRb;
  // Start is called before the first frame update
  void Start()
  {
    enemyRb = GetComponent<Rigidbody>();
    Player = GameObject.Find("Player");
    this.transform.LookAt(Player.transform);

  }

  // Update is called once per frame
  void Update()
  {
    transform.Translate(Vector3.forward * Time.deltaTime * speed);

  }
}


texts: How to add a JSON object / model into your whitestorm world / scene?

texts:
I am loading the object from my json file.

var loader = new THREE.ObjectLoader();
loader.load("blue-car.json",
function ( car ) {
  car.position.set(2, 0, 0);
  car.addTo(world);
 }
);

How can I add the object to my world? In regular three.js it works when I load the json file, but how do I do it in whitestorm?

Update: I tried using the importScene whitestorm method. No errors but it still doesn't show up. Here is an image of logging out a regular plane in whitestorm and the car that is loaded from the json file.

Thank You!


texts: Unity3D/AnimationRigging - Rig not a child Transform in the Animator hierarchy

texts:
I'm using Animation Rigging in Unity and was having some success until I realized my rig was built on the wrong GameObject. This was causing the Animator on the character to be overridden by the animator that Animation Rigging "Rig Setup" created.
I moved the Rig Builder component onto the Character GameObject that already had the Animator set up, but now every single rig component is causing an error. I've completely recreated the rig and all of the constraints, but still get the same error.
For example: "Could not resolve  'Character/Rig_HandIK/LeftHandIK'  because it is not a child Transform in the Animator hierarchy". Character is the GO with Animator & Rig Builder components, Rig_HandIK is a child of Character with a Rig component, and LeftHandIK is a child of Rig_HandIK which has the Two Bone IK Constraint component.


texts: What animation technique is used in 'Dont Starve'?

texts:
While playing a few games in my personal time off development I've stumbled across a survival 2D/3D survival game. The game was apparently made in SDL and GLUT (Dont starve) but what really amazed me was the animations in the game.

The animations are extremely smooth and fluent. There is no distortion while animating, what usually happens in hand-made animations is that pixels get removed, animations are jaggy and they simply aren't as smooth. That got me thinking on how they managed to accomplish such a quality of animations. Were they really handmade (If they were, then it must've taken a very talented artist), is it bone animation or are they using another technique?


texts: Why does Unity in 2d mode employ scaling and the default othographic size the way it does?

texts:
I previously used SFML, XNA, Monogame, etc. to create 2d games, where if I display a 100px sprite on the screen, it will take up 100px. If I use 128px tiles to create a background, the first tile will be at (0, 0) while the second will be at (128, 0).

Unity on the other hand, has its own odd unit system, scaling on all transforms, pixel-to-units, othographic size, etc, etc. So my question is two-fold, namely:

Why does Unity have this system by default for 2d? Is it for mobile dev? Is there a big benefit I'm not seeing?
How can I setup my environment, so that if I have a 128x128 sprite in Photoshop, it displays as a 128x128 sprite in Unity when I run my game?

Note that I am targeting desktop exclusively.


texts: What are some good namespaces for gameplay code?

texts:
I always struggle with naming namespaces when working in a team. I'd be very thankful if someone could share your preferred way of namespacing gameplay code? At least the root namespaces.

Edit: As this question has been downvoted I'm adding more details -
I'm basically looking for a namespacing template/examples that could be easily reused on many projects and won't have names like MarioCharacterNamespace which will obviously last a week. Also no maintenance greedy dependencies like depending on the company name or project name. I also tend to end up with very long namespaces like Game.Battle.BattleLogic.Controllers.Enemy and such that I'd also like to avoid.

So some template that's not too specific nor too general and can easily be reused on many projects at least in the beginning.


texts: Implimenting BADLAND like Body Movement in Box2d

texts:
I am trying to make a body (character in my game) move and behave in the same way as the character in the BADLAND Game with regards to rotation.

The character does not have fixed rotation and behaves normally when colliding with objects but automatically fixes its rotation to face forward when there are no other world forces applied.

How do I go about this. is it a use of a revolute joint with a motor? if so what do I attach the joint to?


texts: Discussion about Serious Games : Their lacks and forces

texts:
I would like to start a little discussion about serious video games. Do you think serious games DO have their place in today's world ? What kind of serious games do you think the most interesting in term of education / work tools ?

I've recently read an article about the educational power of such games in early ages. Do you think serious video games could become a ubiquitous learning tool in primary school ?

Any experience, title share or ideas are heightly appreciated, I want to get a feel of this question from experienced game developper that are interested of writing an answer !


texts: How do I stop overlapping shapes when collision detected in AndEngine?

texts:
I am making a very simple demo in AndEngine in which I have three rectangles: rect1, rect2 and rect3 in an ArrayList.

I register onAreaTouch as follows:

 @Override
public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX,
        final float pTouchAreaLocalY) {

    switch (pSceneTouchEvent.getAction()) {

    case TouchEvent.ACTION_DOWN:
        // this.setScale(1.0f);
        this.mGrabbed = true;
        break;
    case TouchEvent.ACTION_MOVE:
        if (this.mGrabbed) {
            for (int i = 0; i < rectangles.size(); i++) {

                int index = rectangles.indexOf(this);

                if (i != index) {

                    if (this.collidesWith(rectangles.get(i))) {
                        // should not overlap
                    } else {
                        this.setPosition(pSceneTouchEvent.getX() - 90, pSceneTouchEvent.getY() - 90);
                    }
                }
            }
        }
        break;
    case TouchEvent.ACTION_UP:
        if (this.mGrabbed) {
            this.mGrabbed = false;
        }
        break;
    }
    return true;
}

Rectangles are now overlapping with one another. I don't want this behavior, instead I'd like it if rect1 collides with rect2 then rect1 should not move further, but can move in any other direction.

[Cross-Posted here]


texts:
By now i have this Camera class.

package GameObjects;

import main.Main;

import org.jbox2d.common.Vec2;
public class Camera {

public int x;
public int y;
public int sx;
public int sy;

public static final float PIXEL_TO_METER = 50f;

private float yFlip = -1.0f;

public Camera()
{
    x = 0;
    y = 0;
    sx = x + Main.APPWIDTH;
    sy = y + Main.APPHEIGHT;
}

public Camera(int x, int y)
{
    this.x = x;
    this.y = y;
    sx = x + Main.APPWIDTH;
    sy = y + Main.APPHEIGHT;
}

public void update()
{
    sx = x + Main.APPWIDTH;
    sy = y + Main.APPHEIGHT;
}

public void moveCam(int mx, int my)
{

    if(mx >= 0 && mx <= 80)
    {
        this.x -= 2;
    } else if(mx <= Main.APPWIDTH && mx >= Main.APPWIDTH - 80)
    {
        this.x += 2;
    }

    if(my >= 0 && my <= 80)
    {
        this.y += 2;
    }
    else if(my <= Main.APPHEIGHT && my >= Main.APPHEIGHT - 80)
    {
        this.y -= 2;
    }
    this.update();
}

public float meterToPixel(float meter)
{
    return meter * PIXEL_TO_METER;
}

public float pixelToMeter(float pixel)
{
    return pixel / PIXEL_TO_METER;
}

public Vec2 screenToWorld(Vec2 screenV) {
    return new Vec2(screenV.x + this.x, yFlip
            * screenV.y + this.y);
}

public Vec2 worldToScreen(Vec2 worldV) {
    return new Vec2(worldV.x - this.x, yFlip
            * worldV.y - this.y);
}

}

I need to know how to modify the screenToWorld and worldToScreen functions to include the PIXEL_TO_METER scaling.


texts: How to resolve duplicate data in Entity Systems?

texts:
Whilst working on examples and upgrades for my C++ Entity System, something randomly caught the attention of my mind, by surprise: duplicate data. What I'm referring to is how an entity system that uses other libraries (e.g. Ogre3D, SFML, etc.), which already store some information about your entities, handles storing information in custom components.

The Problem:

Say you have two define component types, called: Position component (which holds the location of an Entity) and Velocitycomponent (which holds how fast an Entity is moving, and the direction it is moving toward). And of course, you have a Movement system, which moves entities with a Position and Velocity component attached to it. Now... here comes the tricky part, how would you store the Position component effectively/efficiently, so that you do not duplicate data? By duplication of data, this is what I mean (this is a simple example): a Sprite object typically has it's own x/y position (take for example, SFML's Sprite class), therefore if I had a Position component with it's own x/y values, then I would be duplicating data, would I not? I thought about using pointers/references* in a Position component, but that doesn't really work out if I want to save entities to files.

*Yes, I do know that sizeof(float) == sizeof(float*), but sizeof(vec2/3) != sizeof(vec2/3*). This doesn't really seem much of a problem at first: but what if I had bigger objects to store, such as:

A Mesh:

How would I store a Mesh effectively in a component? I was thinking of just storing a string to where the mesh data was located, but then I thought, what if it's not in a file? How do I resolve that? I also thought to store the raw data in the component, but if I use a 3rd party graphics library (such as Ogre3D or Irrlicht), then I require to actually create the Mesh data via another object.

So, the summed up question is: what's the best way to reduce duplicate data, using an Entity System design, in your game?

Would I have to re-make everything from scratch so that it just "fits" in my entity-system?  I'd prefer not to do that, especially if I decide to change the design  pattern that I use to make games.


texts:
I am using AndEngine, and I wish to create a 2d platform game like worms, where I can zoom out to see the whole world and zoom into single character, so I can select it.

I do not want to use the zoom camera, because I do not want scaling.  I want the user to see the platform crystal clear.

The only thing I thought about, is making N levels of ZOOM, where each zoom level has it's own set of tiles - very problematic solution, or doing it the other way around - making a huge tiles and sprites, and scaling them down - which still feel a little awkward to me.
What is the right way to implement such a thing???

Thanks!!!


texts: Enabling / disabling Static objects in Unity

texts:
The Unity docs clearly explain that game objects marked static should not be moved for performance reasons but I can't find any info regarding enabling / disabling.

Almost everything in my games levels is destructible so I only use real-time GI. When the player damages a game object enough it's either removed or replaced with a damaged version of the model, usually via an object pool.

What effect does enabling or disabling a static game object have on performance?


texts:
I'm quite new in video game AI, and I'm trying to design an AI for a turn based game.

The rules are simple:

The battle field is represented by an NxM board.
The game is between two team, each team has X character.
Each character, based on his type, can move within  C cells and can attack within A cells.
On each turn a player can move and then attack (not attack and then move ) with each one of the caracter in his team (time limit).

I'm thinking on how design the AI for this kind of game.

One solution I have thought is a Multi Agent System composed by two kind of agents:
The first one charachert Agent calculate on each step a function SCORE for each of the cells reachable by the character, and the second one, team Agent calculate the new position for each character based on the score calculated by the former agent. Each character can then attack an opponent if there is one reachable.

Is it a good solution?

Can someone suggest a different solution or give me some tips?


texts: Scene2d scrollbar not showing even though it exists in uiskin.json/atlas

texts:
Using uiskin.json, uiskin.png, uiskin.atlas, default.fnt from libgdx tests  I'm trying to make a console window, however the scroll bar is not shown. uiskin atlas contains a two relevat fragments:

default-scroll
  rotate: false
  xy: 78, 29
  size: 20, 20
  split: 2, 2, 2, 2
  orig: 20, 20
  offset: 0, 0
  index: -1
default-round-large
  rotate: false
  xy: 57, 29
  size: 20, 20
  split: 5, 5, 5, 4
  orig: 20, 20
  offset: 0, 0
  index: -1

Which are referenced in uiskin.json

com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle: {
    default: { vScroll: default-scroll, hScrollKnob: default-round-large, background: default-rect, hScroll: default-scroll, vScrollKnob: default-round-large }
}

And this is my console window:

//Skin is above mentioned uiskin.json, png, atlas
Window window = new Window("CONSOLE", skin);
window.padTop(20f);
window.setWidth(500f);
window.setHeight(250f);
window.setMovable(true);
window.setModal(true);
window.setResizable(true);
window.defaults().expand().fill();

Label consoleLog = new Label("TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT" +
                             "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT" +
                             "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT" +
                             "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT" +
                             "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT" +
                             "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT" +
                             "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT" +
                             "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT" +
                             "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT" +
                             "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT", skin)

consoleLog.setWrap(true);
ScrollPane scrollPane = new ScrollPane(consoleLog);
window.add(scrollPane);
window.row();
window.add(new TextField("", skin));

When I run this, I get a window with a label and a textfield, and I can scroll the label using mouse scroll or by dragging the text, but the scrollbar is not visible.

what am I doing wrong?


texts:
Can anyone help me someone with this code?

I'd like to go to the next level by clicking a button: example my level name is L1,L2,L3,L4,L5,L6,L7 and when I finish level L1, I want to go to level L2 with the click of a button, and from L5 go to L6 like this.

public class GameLevels : MonoBehaviour {

 public Button Play;
 private int idLevel;
 // Use this for initialization
 void Start ()
 {
     idLevel = PlayerPrefs.GetInt("idLevel");
     Play.interactable = false;
 }
 public void SelectLevel(int i){
     idLevel = i;
     PlayerPrefs.SetInt ("idLevel", idLevel);
     Play.interactable = true;
 }

 public void LoadLevel(string Levels)
 {
     SceneManager.LoadScene (Levels);
 }
 public void Replay()
 {
     SceneManager.LoadScene ("L" + idLevel.ToString ());
 }
 public void loadNextLevel()
 {

 }
}


texts: Overlapping sibling problem in AABB tree

texts:
I'm trying to make a real-time GPU (CUDA) ray tracer, and for now I'm tracing single rays, but I've ran into a problem: the BVH. This [PDF]paper has been my inspiration for the theoretical part, and as you can see, the BVH is composed of Axis Aligned Bounding Boxes, however, the stackless rope-based algorithm for the ray-AABB intersection does not take into account overlapping siblings, which occur quite a lot with the AABB creation algorithm I've read about in multiple places on the Internet, which is averaging the centroid of each triangle in the current triangle list and deciding in which child to place each triangle based on the projection of the average on the axis parallel to the longest edge of the parent box.

The use of AABBs in the paper indicates that there indeed exists a method to efficiently (in terms of speed) make AABB trees without overlapping siblings. Unfortunately, I can't find such a method.

Would someone please describe a fast method for creating an AABB tree without overlapping children? I'd also appreciate it if they'd post pseudocode too.

Thank you.


texts: XNA - DrawIndexedPrimitives or DrawUserIndexedPrimitives?

texts:
When rendering primitives in XNA, does it matter if I use DrawIndexedPrimitives() versus DrawUserIndexedPrimitives()? RB Whitaker uses the former, while Reimer's uses the latter.

From what I can tell, the intent is that if you're using a premade type that ships with XNA (such as VertexPositionNormalTexture), you should use the normal draw primitives function, while if you create a custom struct which satisfies IVertexType and/or VertexDeclaration, you should use the DrawUserPrimitives instead.

However, XNA places no such restriction on how they're used, and I am wondering why it wasn't just all rolled into one generic function to begin with.


texts: How to use grammars for procedural generation?

texts: I am working on a system to procedural generate a house using this article. I am trying to understand how grammars work and are made I have found very little information on the topic online. From my understanding a grammar is like a rule and you can for example recursively iterate through a model and add a part to it based on that rule then repeat that process for each rule. Is this the right idea? If not can you provide a explanation or some resources explaining it? Also can grammars be made simply by using a few if statements to determine where something should be or is there something more special about them? I saw a video explaining how they use grammars to make compilers and parse the code. It looked like they were using a custom format to define the grammars. Is this something related and also is this the same type of grammar? If so what is the purpose of using a grammar in my case of procedural generating a house they seam like they are unrelated for generating the placement of rooms?


texts: How to create same paradigm of monobehaviour and processing in C++

texts: Having worked with monobehaviour and processing before, is it possible to create the same paradigm both frameworks use which basically is writing all code in two main functions, start/setup and update/draw. To further elaborate, much like working in unity when creating a new script the user is presented with two functions a start and an update. The first function always gets called on the first frame while the latter gets called every frame there is no main function present only these two. I'd like to imitate that same structure on to c++.


texts:
I am making an isometric tower defense game in XNA and trying to implement the A* pathfinding algorithms for my enemy AI. I am quite new to programming, especially AI and pathfinding, so please excuse my lack of knowledge.

I am using an a* tutorial from an XNA game programming book but it is made for standard square tile maps. I am trying to adapt this into my isometric tile engine and running into a few problems. Firstly, here are the major differences between the two maps:

Book:

Tiles are 32x32.
directions are up, down, left, right.
obstacles are wall tiles

My Map:

tiles are 64 x 64
4 directions: NE, NW, SE, SW
impassable tiles

From these differences, I can figure out that I have to make changes to the grid setup, cost calculation and tile types.

I have made adjustments for the latter two, but I am having problems setting up the grid/gridnodes which is the most important part. Or perhaps, I simply don't understand the code well enough.

Here is the code for the Pathnode:

class PathNode
{

    public PathNode ParentNode;
    public PathNode EndNode;
    private Vector2 gridLocation;
    public float TotalCost;
    public float DirectCost;
    public Vector2 GridLocation
    {
        get { return gridLocation; }
        set
        {
            gridLocation = new Vector2(
               (float)MathHelper.Clamp(value.X, 0f, (float)50),
               (float)MathHelper.Clamp(value.Y, 0f, (float)50));
        }
    }

    public int GridX
    {
        get { return (int)gridLocation.X; }
    }

    public int GridY
    {
        get { return (int)gridLocation.Y; }
    }

    public PathNode(
        PathNode parentNode,
        PathNode endNode,
        Vector2 gridLocation,
        float cost)
    {
        ParentNode = parentNode;
        GridLocation = gridLocation;
        EndNode = endNode;
        DirectCost = cost;
        if (!(endNode == null))
        {
            TotalCost = DirectCost + LinearCost();
        }
    }

    public float LinearCost()
    {
        return (
            Vector2.Distance(
            EndNode.GridLocation,
            this.GridLocation));
    }

    public bool IsEqualToNode(PathNode node)
    {
        return (GridLocation == node.GridLocation);
    }

}

What should I change in this class to adapt this pathnode.cs to an isometric map? It is probably the gridLocation property but I am stumped as to what should be in there.

Any other tips on isometric pathfinding would be greatly appreciated!


texts: How to draw the contour of a hexagon area, like in Civ 5

texts:
I am trying to achieve the hexagon contour look you find in Civilization V:

I want to outline the area a unit can move to on a hexagon grid, so far I can get a list of all the tiles a unit can move to and from that select the tiles that are on the boundary, which looks like this:

Assume the list of boundary tiles are in random order. I can also get a list of all the corners on each hex. As you can see above the island in the middle would create a hole in the contour shape, Civ 5 also seems to handle these holes nicely:


texts:
while making my game called "Journeys of Nemo the Fish" i stumbled upon a collision detection problem. Please, help me to solve it.

The problem is: the program runs only the first if statement adjusting the coordinates of the player without taking in consideration what type of collision occurred.

Here is my code:

    short int py = player.getPosition().y;
    short int px = player.getPosition().x;
    short int pw = player.getGlobalBounds().width;
    short int ph = player.getGlobalBounds().height;

    for (int i = 0; i < block.size(); i++) {
        short int by = block[i].getPosition().y;
        short int bx = block[i].getPosition().x;
        short int bw = block[i].getGlobalBounds().width;
        short int bh = block[i].getGlobalBounds().height;

        if (player.getGlobalBounds().intersects(block[i].getGlobalBounds())) {
             // UP and DOWN
             if (px+pw > bx && px < bx+bw) {
                 if (py < by+bh && py > by) {
                     py = by + bh;
                 } else if (py+ph > by && py < by) {
                     py = by - ph;
                 }
             }

             break;
         }

          if (player.getGlobalBounds().intersects(block[i].getGlobalBounds())) {
             //LEFT and RIGHT
             if (py+ph > by && py < by+bh) {
                 if (px < bx+bw && px+pw > bx+bh) {
                     px = bx + bw;
                 } else if (px+pw > bx && px < bx) {
                     px = bx - pw;
                 }
             }

             break;
         }
     }

Here is a link to the video: Journeys of Nemo the Fish.

Thank you in advance.


texts: How to get obstacles to spawn randomly in x position in an infinite runner? 2D

texts:
I'm trying to make two obstacles that are different sized to come in  a random order in one straight line where the player is going. Doesn't have to be with object pooling.

It seems that the EnemyGenerator class is useless and all can be done in platformGenerator.

  using UnityEngine;
  using System.Collections;

public class EnemyGenerator : MonoBehaviour {

public ObjectPooler enemyPool;

public float distanceBetweenEnemies;

public void SpawnEnemies (Vector3 startPosition)
{
    GameObject karhu = enemyPool = enemyPool.GetPooledObject ();
    karhu.transform.position = startPosition;
    karhu.SetActive (true);

    //GameObject punakuono = enemyPool = enemyPool.GetPooledObject ();
    //punakuono.transform.position = new Vector3(startPosition.x - distanceBetweenEnemies, startPosition.y, startPosition.z);
    //punakuono.SetActive (true);
}

}

This also returns the error: "Assets/Scripts/EnemyGenerator.cs(12,36): error CS0029: Cannot implicitly convert type UnityEngine.GameObject' toObjectPooler'".

Edit: I had an extra enemyPool and the class is useless.

My game does spawning with a generation point that is stuck in the camera and when the player runs the generation point goes forward and spawns flatground ahead of him.

Ask me for more example code if you need.

Edit 1: Here is the PlatformGenerator that also spawns other objects.

  using UnityEngine;
  using System.Collections;

public class PlatformGenerator : MonoBehaviour {

public GameObject thePlatform;
public Transform generationPoint;
public float distanceBetween;

private float platformWidth;

public ObjectPooler theObjectPool;

private EnemyGenerator theEnemySpawner;
public float randomEnemyThreshold;
public ObjectPooler enemyPool;

// Käytä alkuarvon alustamiseen
void Start () {
    platformWidth = thePlatform.GetComponent<BoxCollider2D>().size.x;

    theEnemySpawner = FindObjectOfType<EnemySpawner> ();
}

// Päivitys tulee joka ruutu
void Update () {

    if (transform.position.x < generationPoint.position.x)
    {
        transform.position = new Vector3 (transform.position.x + platformWidth + distanceBetween, transform.position.y, transform.position.z);

        //Instantiate (thePlatform, transform.position, transform.rotation);
        GameObject newPlatform = theObjectPool.GetPooledObject();

        newPlatform.transform.position = transform.position;
        newPlatform.transform.rotation = transform.rotation;
        newPlatform.SetActive (true);

        if (Random.Range (0f, 100f) < randomEnemyThreshold)
        {
            GameObject newEnemy = enemyPool.GetPooledObject();

            Vector3 enemyPosition = new Vector3 (0f, 0.5f, 0f);

            newEnemy.transform.position = transform.position + enemyPosition;
            newEnemy.transform.rotation = transform.rotation;
            newEnemy.SetActive(true);
        }
    }

}

}

Edit 3: I found the problem.


texts: Smooth transitions between 2d animations

texts:
I am writing a 2d game (in libGDX, but I think that doesn't matter too much). In that game I want to have smooth transitions between animations. For example, let's think of a guy walking around. Now that guy is hit by something (a bullet for example) and dies. So I want to play the death animation for this guy now.

The problem: I cannot simply exchange the walking animation by the death animation, because the guy's current walking animation frame is not necessarily the same as the first frame of the death animation. So for the player that would look as if the animation "jumps" from walking to death.

So my question is: what is the "typical" way to achieve a nice and smooth transition from animation to another, in general?


texts: Is the viewport meant to be an absolute representation of where the underlying device is drawing?

texts:
I know this may sound like an odd question but I just wanted to confirm which way it is.

Currently I am using XNA within Windows Forms (MDI) and I am just wondering about the viewport, as I have multiple forms with their own graphics device to draw with.

Now originally I just assumed the viewport was meant to be a basically a wrapper for the screen size (i.e., width and height), however I noticed it contains an X and Y. So then I was unsure if it was meant to directly represent the drawing region of the device.

Take for example the below scenario:

I have a forms with a panel which is docked within a group box, its relative position in the form is { X: 100, Y: 100, Width: 320, Height: 280 } however its absolute position on the screen would be lets say { X: 400, Y: 320, Width: 320, Height: 280 }. Then if I were to use it like I was originally assuming the panel itself which hosts the underlying handle for Xna to draw to it would be { X: 0, Y: 0, Width: 320, Height: 280 }.

So if you imagine I then start dragging the window around a bit, the relative positions do not change, but obviously the absolute one would, as you could technically drag the panel off screen.

So basically the question is, do I need to use absolute positions for my viewport and update them every time the graphics device is about to be drawn, or do I use relative positions and only update when the area is resizing? and if so is it relative to the form, or is it always going to be 0,0 for the x/y in this scenario?


texts:
I am trying to achieve something I've seen numerous times, but I don't know where to start from. I've come across numerous old effects, which I can't recreate. The said effects are the glow animations seen here: world of warcraft armor sets or for instance here Diablo glowing wings. In my desperation I even tried to contact blizzard, but with no success.

My common logic tells me these effects are not implemented with particles as that would be too expensive, especially on the hardware WoW ran on. On top of that, these looks strangely static, in a way even 2-D. I suspect something to do with images. I'm only a hobbyist graphics programmer(on top of that, not a good one) and I can't wrap my head around it. I would really appreciate any help.


texts: opengl storing multiple indices into indices buffer

texts:
After parsing collada files I found out that we have to load two(or more) indices each pointing to say a vertex or normal etc.
like this (
3 0 2 0 0 0
)

Is there a way to load (and use)these indices to indices buffer(ELEMENT_ARRAY_BUFFER) like this (vnvnvn...)
; where v is vertex pointer, n is normal pointer from the above. with vertices loaded to VBO1 like (vvvv...) and in VBO2 like (nnnn...). So that we dont have to repeat the normals in VBO2.
VBO like (vnvnvn...) is also ok.
(and not something like this https://stackoverflow.com/questions/11148567/rendering-meshes-with-multiple-indices), I'm not trying to use multiple indices buffer. I'm trying to put all the given indices into one index buffer and use them alternately.

(If I wasnt clear i will try for more clarification.)


texts: Camera - View matrix in Android + openGLES 2

texts:
I am trying to use the touch screen on the tablet to control my camera movements and generate the view matrix accordingly.

I get the x and y coordinates of the screen and after doing some sanity checks on it I use them. My problem is I get the image and based on the movement it moves - but the object is always at a offset from the touch/pointer position. And I am not able to understand why. ( Kind of new at it)

Here is the camera logic -  Where pX and pY are coordinates of the device screen.

pitch = pY * 0.05;
yaw =   pX * 0.05;

LOGD(">>pitch %f", pY);

pitch = min(pitch,90.0f);
pitch = max(pitch,-90.0f);

LOGD(">>pitch(alter) %f", pitch);

if(yaw < 0) {
    yaw += 360.0f;
}
if(yaw > 360.0f) {
    yaw -= 360.0f;
}

I am not sure whether I am going about it in the right direction. Any suggestions will be appreciated.


texts:
I've really exhausted as much as Google has to give, I've spent a solid week googling every combination of words for an "AABBvsLine sweep", downloaded countless collision demos, dissected SAT intersection examples and an AABBvsAABB sweep trying to figure out how to approach this. I've not found a single thing covering this specific pairing.

Can anyone shed any light on how to get the hit time of a swept AABB vs a Line segment in 2D? I'm still getting familiar with the SAT but I do know how to implement it to a degree, I'm just not sure how to extract the hit time from the velocity in the non axis aligned separating axes for the sweep.

I really would appreciate anything at the moment, some code or even some helpful links, I'm at my wits end!


texts: Lowering Unity launcher graphic quality settings reduces mouse x turn speed, does quality affect time?

texts:
Lowering Unity App quality settings reduces mouse x turn speed, how to fix this?

I am not sure why this happens my only thought was time.timedelta is affected by the graphics quality setting in unity launcher.

when rotating a cube with input mouse x, the cube rotates at normal speed on high quality graphic settings, but lowering the graphic settings it begins to slow down.
Inevitably at lowest it barely rotates.

using UnityEngine;

public class This : MonoBehaviour
{
    private float mouseTurn;
    private float turnSpeed = 64f;

    void Update()
    {
        mouseTurn = Input.GetAxis("Mouse X");
        transform.Rotate(0, mouseTurn * turnSpeed * Time.deltaTime, 0);
    }
}


texts:
I want to make a menu with a bunch of buttons. I want them all to look the same and be easier to edit, so I decided to make one "Button Parent" widget, insert it few times and give it a different "on click" action.

I can't access the "on click" event in the main menu widget, also I apparently can't create a button child. My only idea left is to make a public variable for the button, and then do a different action depending on the variable once I set it in the main widget.

Is there a better / easier way to do this?


texts: How can I set a MonoGame window's position?

texts: How do I set the position of my window in MonoGame?


texts: What's wrong with this Open GL ES 2.0. Shader?

texts:
I just can't understand this. The code works perfectly on the emulator(Which is supposed to give more problems than phones…), but when I try it on a LG-E610 it doesn't compile the vertex shader. This is my log error(Which contains the shader code as well):

EDITED

Shader:

uniform mat4 u_Matrix;

uniform int u_XSpritePos;
uniform int u_YSpritePos;
uniform float u_XDisplacement;
uniform float u_YDisplacement;

attribute vec4 a_Position;
attribute vec2 a_TextureCoordinates;

varying vec2 v_TextureCoordinates;

void main(){
    v_TextureCoordinates.x= (a_TextureCoordinates.x + u_XSpritePos) * u_XDisplacement;
    v_TextureCoordinates.y= (a_TextureCoordinates.y + u_YSpritePos) * u_YDisplacement;

    gl_Position = u_Matrix * a_Position;
}

Log reports this before loading/compiling shader:

11-05 18:46:25.579: D/memalloc(1649): /dev/pmem: Mapped buffer base:0x51984000 size:5570560 offset:4956160 fd:46
11-05 18:46:25.629: D/memalloc(1649): /dev/pmem: Mapped buffer base:0x5218d000 size:5836800 offset:5570560 fd:49

Maybe it has something to do with that men alloc? The phone is also giving a constant error while plugged: ERROR FBIOGET_ESDCHECKLOOP fail, from msm7627a.gralloc

Edited: "InfoLog:" refers to glGetShaderInfoLog, and it's returning nothing. Since I removed the log in a previous edit I will just say i'm looking for feedback on compiling shaders.

Solution + More questions: Ok, the problem seems to be that either ints are not working(generally speaking) or that you can't mix floats with ints. That brings to me the question, why on earth glGetShaderInfoLog is returning nothing? Shouldn't it tell me something is wrong on those lines? It surely does when I misspell something.

I solved by turning everything into floats, but If someone can add some light into this, It would be appreciated. Thanks.


texts:
I'm trying to implement batching in my game (Sprite batching and 3D Mesh batching), I've read a lot of documentation about that but I don't understand something:

When each object have is own transformation (rotation, position, scale), how can I merge it with others geometries?
When each object use blending, how can I achieve depth with batching?

Thanks!


texts: Confusion with the texture coordinate system in XNA

texts:
I am creating a cow out of primitive shapes, and am using the minecraft cow texture as a placeholder. To create the primitive model I have created a 'model' class and created a sub class 'ModelCow' which inherits from the Model class. Each model contains a List of the component class which is like a sub part of the model. In the creation of the components a texturemap for each component is created, which defines the locations of each texture foreach face for that cube in a texture map for that cow.

The way each texture is determined is the top left pixel of the texture and the bottom right, I had to go through each texture and find the top left x and y and divide them by the width and height respectily - the same thing with the bottom right. The thing is the textures are all one pixel off what they should be i.e it is shifted right too far or one pixel is missing. The question is what am I doing inncorrectly. Am I meant to start counting from zero when I get the x and y/ top and right coordinates for the texture. Also in this case the actual width and height of the texture and subtracted by one, i.e. 32 is 31 and 64 is 63

Example of what I am doing is:

AAAAAAAA

AAAAAAAA

A#AAAAAA

AAAAAAAA

the '#' would be 1, 2 and the width would be 7 and the height would be 3. Is this correct?

Here is the code:

    float width = 63f;
    float height = 31f;

    // Body
    TextureMap bodyMap = new TextureMap();
    bodyMap.Add(new Vector4(28f / width, 4f / height, 39f / width, 13f / height), FaceDirection.ZIncreasing);
    bodyMap.Add(new Vector4(40f / width, 4f / height, 51f / width, 13f / height), FaceDirection.ZDecreasing);
    bodyMap.Add(new Vector4(18f / width, 14f / height, 27f / width, 31f / height), FaceDirection.XDecreasing);
    bodyMap.Add(new Vector4(28f / width, 14f / height, 39f / width, 31f / height), FaceDirection.YDecreasing);
    bodyMap.Add(new Vector4(40f / width, 14f / height, 51f / width, 31f / height), FaceDirection.XIncreasing);
    bodyMap.Add(new Vector4(52f / width, 14f / height, 61f / width, 31f / height), FaceDirection.YIncreasing);
    components.Add(Shape.BuildCube(new Vector3(0, 0, 0), new Vector3(0.7f, 0.7875f, 1.30f), bodyMap));

Whereas the first two coordinates are the top left and the last two are the bottom right. X and Y respectively.


texts:
I'm trying to install the Stripe API Library through NuGet Manager in Visual Studio but it installs it inside packages folder of the Project (I.E. before Project's Assets folder) doing this I cannot use the library:

Using UnityEngine;
Using Stripe; //Doesn't recognise this

Then I:

Moved those installed files from packages to Assets folder
Uninstalled Stripe from NuGet (as I could now access them in my script by using Stripe)

Now these are the main errors that I'm getting:

PrecompiledAssemblyException: Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included for the current platform. Only one assembly with the same name is allowed per platform. Assembly path: {0}
Assembly 'Assets/Temp/lib/netstandard2.0/Stripe.net.dll' will not be loaded due to errors:
Unable to resolve reference 'System.Collections.Immutable'. Is the assembly missing or incompatible with the current platform?

Assembly 'Assets/Temp/lib/netstandard1.2/Stripe.net.dll' will not be loaded due to errors:
Unable to resolve reference 'System.Collections.Immutable'. Is the assembly missing or incompatible with the current platform?


texts: How do I run functional tests against my Unity3D game?

texts:
Context

I am continuing some legacy code for a game in Unity3d, and I want to write some functional tests meant for regression, to ensure I don't break things when implementing new things or when refactoring.

I already know there is the 'Unit Test Tools' suite for Unity3d available as an asset. I have used it as a unit-test suite, so I test my models (classes).

Example of what kind of test I am thinking about

For "functional test" I mean things like this:

Run the program
When in the menu scene, assert there is a button that says "start"
Click it
Then assert a new scene is loaded
Assert pixel XXX is red
Click in coordinate XXX
Assert now that the pixel changed to green
etc.

Questions

Q1: How do I write and run functional tests for my game? Is this also typically done in the UnityTestTools (UTT)?

Q2: If UTT is more for Unit-Testing, then is there a separate suite for functional testing? Which one?

Notes:

I'm targetting Android, and running Unity5.3.1f1


texts: Designing an API for defining rigged game entities

texts:
I am making a game framework for building/constructing what I would imagine are called something like "multi-component rigged entities". This would be things like a stick-figure drawing. Can't find a great animation to demonstrate, but something like this, where the head is a circle, the hands circles, the arms are poles, torso is one block, etc. (imagine there is no bending, only rigid shapes moving attached by joints).

I need to design some kind of API for a user of the framework to use to describe such a rigged entity.
As one example, I am looking at Vue.js and their API is basically like this, you have a template:

    Ask a yes/no question:
    <input v-model="question">

{{ answer }}

And a model, which has external/internal properties, computed properties, and methods:
var watchExampleVM = new Vue({
  el: '#watch-example',
  data: {
    question: '',
    answer: 'I cannot give you an answer until you ask a question!'
  },
  watch: {
    question: function (newQuestion, oldQuestion) {
      this.answer = 'Waiting for you to stop typing...'
      this.debouncedGetAnswer()
    }
  },
  created: function () {
    this.debouncedGetAnswer = _.debounce(this.getAnswer, 500)
  },
  methods: {
    getAnswer: function () {
      if (this.question.indexOf('?') === -1) {
        this.answer = 'Questions usually contain a question mark. ;-)'
        return
      }
      this.answer = 'Thinking...'
      var vm = this
      axios.get('https://yesno.wtf/api')
        .then(function (response) {
          vm.answer = _.capitalize(response.data.answer)
        })
        .catch(function (error) {
          vm.answer = 'Error! Could not reach the API. ' + error
        })
    }
  }
})

This is just one example of an API I am looking for.
But what I'm looking for is some inspiration, perhaps from Unity or some other gaming framework/engine, where it allows you to specify not "view components" but entire rigged entities like in this animation above.
It seems to come down to a skeleton with bones and joints, and the bones are somehow attached to skins, but that's as far as my knowledge goes, and I'm not really sure what a DSL sort of thing would look like for defining a rigged entity.
How can I design an API that handles this task?


texts: Get video chipset manufacturer in Direct3D

texts:
I'd need to know if the video chipset Direct3D runs on is from Nvidia, AMD or Intel.

Is there a way to do that?


texts: What's the difference between a "Gameplay Programmer" and a "Gameplay Engineer?"

texts:
I was reading some job descriptions from some AAA developers in the gaming industry, and I noticed there were jobs for "Gameplay Programmers" as well as "Gameplay Engineers."

Are those the same thing?  Do they do the same thing?


texts: Best way to let the player know there are multiple solutions to a problem?(and force them to play again)

texts:
I am going to work on a map for my game that is in first person mode. This is the story(planned).

He is on a sinking ship and he wants to escape before the ship sinks. He has a few ways of doing so, either with the on board seaplane or an emergency raft. Both methods will lead the player to different maps in the game. So here is the question:

How can I notify the player that there is another way of "winning" the map if he chooses one. I do not want to just pop out and say "hey you could have used the boat" or even include a progress map of some sorts, but I still want the player to visit the map again in the future to figure out the paths. Any suggestions would be awesome.

The lighting would be dimmer as the scene is set at night. There will be blood, grease and other dirty stuff on the player's screen. The ship itself is most probably going to wobble around.

edit
Sorry that I didn't clarify, but I want to know methods to lure players to play the map again. Methods of letting the player know that there are different methods works, but I think that should not be the only method. I'll change the title.


texts: How can I reference classes from my scripts in my unit tests?

texts: Bit of a noob question, but I'm having trouble getting unit testing working in Unity. I created a PlayMode test assembly, I toggled "Enable playmode tests for all assemblies" as directed in the manual, but when I try to edit the test script, Visual Studio still isn't recognizing references to the classes I've written. There's also no option to manually add a reference within Visual Studio. Am I doing something wrong, or is this some kind of bug? It's hard to imagine what kind of unit testing you could even do without references to your main project.


texts: I use an A* algorithm to find a path voiding obstacles. On obtaining the path it would be a good idea to reduce the number of points. Then I would like to typically do a spline interpolation or Bezier Curves to find a smooth path but is it not possible that post smoothening my character bumps into an obstacle? If not possible then why and if it is possible, then how do I avoid it?


texts: Bug in XNA Developer function CalculateEigenVector() from the file "xnacollision.cpp"?

texts:
I am trying to decipher the content of the Microsoft XNA Developer source file "xnacollision.cpp" and I've found a function that calculates one of the three eigenvectors of a homogeneous system of three linear equations. The name of that function is CalculateEigenVector() and its content is as follows:

//-----------------------------------------------------------------------------
static inline XMVECTOR CalculateEigenVector( FLOAT m11, FLOAT m12, FLOAT m13,
                                         FLOAT m22, FLOAT m23, FLOAT m33, FLOAT e )
{
FLOAT f1, f2, f3;

FLOAT fTmp[3];
fTmp[0] = ( FLOAT )( m12 * m23 - m13 * ( m22 - e ) );
fTmp[1] = ( FLOAT )( m13 * m12 - m23 * ( m11 - e ) );
fTmp[2] = ( FLOAT )( ( m11 - e ) * ( m22 - e ) - m12 * m12 );

XMVECTOR vTmp = XMLoadFloat3( (XMFLOAT3*)fTmp );

if( XMVector3Equal( vTmp, XMVectorZero() ) ) // planar or linear
{
    // we only have one equation - find a valid one
    if( ( m11 - e != 0.0 ) || ( m12 != 0.0 ) || ( m13 != 0.0 ) )
    {
        f1 = m11 - e; f2 = m12; f3 = m13;
    }
    else if( ( m12 != 0.0 ) || ( m22 - e != 0.0 ) || ( m23 != 0.0 ) )
    {
        f1 = m12; f2 = m22 - e; f3 = m23;
    }
    else if( ( m13 != 0.0 ) || ( m23 != 0.0 ) || ( m33 - e != 0.0 ) )
    {
        f1 = m13; f2 = m23; f3 = m33 - e;
    }
    else
    {
        // error, we'll just make something up - we have NO context
        f1 = 1.0; f2 = 0.0; f3 = 0.0;
    }

    if( f1 == 0.0 )
        vTmp = XMVectorSetX( vTmp, 0.0f );
    else
        vTmp = XMVectorSetX( vTmp, 1.0f );

    if( f2 == 0.0 )
        vTmp = XMVectorSetY( vTmp, 0.0f );
    else
        vTmp = XMVectorSetY( vTmp, 1.0f );

    if( f3 == 0.0 )
    {
        vTmp = XMVectorSetZ( vTmp, 0.0f );
        // recalculate y to make equation work
        if( m12 != 0.0 )
            vTmp = XMVectorSetY( vTmp, ( FLOAT )( -f1 / f2 ) );
    }
    else
    {
        vTmp = XMVectorSetZ( vTmp, ( FLOAT )( ( f2 - f1 ) / f3 ) );
    }
}

if( XMVectorGetX( XMVector3LengthSq( vTmp ) ) > 1e-5f )
{
    return XMVector3Normalize( vTmp );
}
else
{
    // Multiply by a value large enough to make the vector non-zero.
    vTmp *= 1e5f;
    return XMVector3Normalize( vTmp );
}
}

In my opinion there are two mistakes:

1) The code snippet:

// recalculate y to make equation work
if( m12 != 0.0 )
   vTmp = XMVectorSetY( vTmp, ( FLOAT )( -f1 / f2 ) );

should be changed with:

if( f1 != 0.0f )
   vTmp = XMVectorSetX( vTmp, ( FLOAT )( -f2 / f1 ) );

if( f2 != 0.0f )
   vTmp = XMVectorSetY( vTmp, ( FLOAT )( -f1 / f2 ) );

2) In the next else block instead:

vTmp = XMVectorSetZ( vTmp, ( FLOAT )( ( f2 - f1 ) / f3 ) );

we must have:

vTmp = XMVectorSetZ( vTmp, ( FLOAT )( ( -f2 - f1 ) / f3 ) );

Please tell me if I am wrong or right!


texts:
I was watching some YouTube tutorials on making terrains in UE4 and in each one they mention that the larger the terrain the worse the performance gets.
I was wondering what you would do if you wanted to create a map like in skyrim or WOW. Is the terrain made of one massive terrain or is it made up out of a series of terrains in a grid? And is there any optimisation that you can do or is it all handled by UE4?


texts: Unity - Save/load in a sandbox game, how to instantiate saved objects

texts:
I have a game where a player can place GameObjects.

I can  save/load this GameObjects data with using JSON, for example its position, but I cannot think of a good way to tell my save-file (and my load) what Prefab it needs to instantiate at position X.

How I could this be done in a clever way?


texts: 2D Voxel isometric rendering with non grid-aligned objects

texts:
I'm currently working on making a simple SDL2 game (written in C++) where the maps are comprised of sprite voxels (essentially just a png of an isometric cube). Game entities move in 3D space. The world is rendered in 2D by a change of basis, where i,j,k are vectors (96,43,0), (96, -43, 0), (0, -105, 0)

Everything works fine with cubes that are aligned to the grid, the [x,y,z] locations and their contents are drawn in the correct order.

Moving entities are drawn at their closest grid-space location, resulting in a problem when the player sprite oversteps the boundary of their closet grid.

I don't know how to overcome this problem. One idea I had was to assign the player a list of [x,y,z] locations they are occupying, and have each of those locations when drawn, draw only the segment of the sprite that occupies their region. Unfortunately I lack the knowledge of how that could be carried out using SDL2.

Any advice would be appreciated, even if it isn't SDL specific. I'm sure there's an obvious solution and well-known technique, but my searches so far haven't been successful.


texts: How to find optimal perpendicular axis of rotation vector to draw arrows?

texts:
I am drawing lines on the screen. Each line has a point (x,y,z) and a direction (u,v,w). I want to draw arrow heads on these lines, like two lines that start from (x,y,z) and leave at a 15 degree angle.

I know how to draw these arrow head lines. I do this by rotating (u,v,w) by 15 degrees on some axis of rotation which is perpendicular to (u,v,w). The problem is the axis of rotation I am using is not making all my graphs look good.

Basically I'm given a unit vector (u,v,w). If |w|=1, then u and v are 0 and I just use (1,0,0) which is a unit vector and perpendicular to (u,v,w).

If that is not the case, then I use (v, -u, 0) which is not a unit vector but is perpendicular. Then I normalize it. The norm won't be 0, since |w| < 1 which means u^2 + v^2 != 0.

This gives ok results. But some tests, the arrow head lines look a bit messed up, or not even looking like a 15 degree angle from the main line.

Does anyone know a good way to find a good perpendicular unit vector to (u,v,w) so the results will always look good?

Thanks


texts: Which axis-aligned line does an AABB collide with first?

texts:
I am making the collision resolution system for my 2d top-down game, and I managed to find a solution where I query which surfaces of other AABBs the current entity can collide with in the next frame.

To resolve the new location of the player however, I need to find which surface the entity collides with first.

I have a list of lines, which is LinkedList<int[4]> collidedLines. a line is {x1,y1,x2,y1}, however in this case, they are axis-aligned, so either x1==x2 or y1==y2.

I also have the entity, which has the following properties:

int posX
int posY
int speedX  // The amount to move in the
int speedY  // next step of the game.
int size  // The halfwidth of the square AABB.

How can I find the first line the entity collides with? Thanks for your help!


texts:
I'm currently following tutorials on Youtube to learn howto use Unity. My code runs perfectly as per the tutorial, but i just have some questions regarding the code, with regards to screenToWorldPoint & viewportToWorldPoint.

The purpose of the code is for a 2D platformer, where the character's arms will rotate and face where the mouse cursor is.

Code:

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

public class ArmRotation : MonoBehaviour {

    public int rotationOffset = 0;

    // Update is called once per frame
    void Update () {
        Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position; //Gets the difference between
        difference.Normalize(); //Normalizing the vector

        float rotateZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.Euler(0f, 0f, rotateZ + rotationOffset);
    }
}

I've done some googling and am aware of the difference between screenToWorldPoint and viewportToWorldPoint as per the answer here  https://answers.unity.com/questions/168156/screen-vs-viewport-what-is-the-difference.html

Where

Screen: from [0,0] to [Screen.width, Screen.height]
Viewport: from [0,0] to [1,1]

Questions:

Why do we have to calculate the difference between the position of the mouse cursor and the position of the character's arm instead of just setting the following:
. Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition);

I've tried setting it to the position of the mouse cursor instead of using the difference between the arm & the cursor and while the code still works and the arm is still able to rotate, it is a little "off" from the direction of the cursor. E.g A little higher than where the cursor is. Why does using the difference solve this issue?

Why do we call difference.Normalize() ? To my understanding, Normalize returns a vector between 0 & 1.However, Mathf.Atan2 returns the angle in radians whose Tan is calculated by y/x. As such, calling Normalize and returning a vector to a value between 0 & 1 makes no difference because the value calculated will be the same between a un-normalised and normalised vector since the proportions are the same?

When i use ViewportToWorldPoint instead of ScreenToWorldPoint, i do not use Normalize because to my understanding, the Vector returned by ViewportToWorldPoint should already be within 0 & 1, hance we do not have to normalise it. However, when i test the code out in play mode,the arm barely rotates. Why is this so?

I would appreciate any help or pointers in the right directions.

Thanks!

EDIT: I had a look at the manual and realise that Normalize() returns a vector with the same direction, but magnitude 1, but i'm still just as confused


texts: How could an offline app store images so that they aren't trivially discoverable?

texts:
There is an app I play which has lots of images. I have reverse engineered the app but couldn't find the images in the APK. The app is an offline app so it doesnt retrieve images from a server.

My question is, then, where did this app store its images? I'd like to achieve the same level of protection (to deter casual observation of the images).


texts: Data Organization in Custom 3D Mesh File Format

texts:
After careful consideration to use middleware, I have decided on creating my own 3d file format format to export meshes from 3D authoring application (Softimage) into my game.

I will need to export the following:

Vertices
Indices
Normals
UVs
Material Information
Animation information (no clue, how to import it)
Collision mesh
Game Properties defined within 3D authoring tool (object intelligence, aggressivity, etc..)
..another assets..

Can I kindly ask for a hint, how to construct my custom file format. How to organize data within my files, please? Does anoybody have a good adivce on exporting animation information, especially when the mesh changes its geometry?

I would be thankful for advices that could point me into right direction. It would be nice to save some time instead of wasting it on incorrect approaches.

I use Softimage as my 3D authoring tool. Target platform is OpenGL ES 2.0 running on mobile devices (iOS, Android). Programming language: C++.


texts: Unity - change only z axis rotation to 0

texts:
I have a child where I want the rotation to work like (parentRot, parentRot, 0).

So first I set its localRotation to 0, meaning it will get the parents rotation: child.localRotation = Quaternion.identity;

But how can I make sure the world rotation (not local) value of the z axis stays at 0?


texts: Multi-Threaded Pipelined Game Engine Data Synchronization Questions

texts:
Let's say I'm setting up a worker pool based game engine with pipelining. Let's say I have 4 stages in my pipeline as such:

Stage 1: Physics
Stage 2: AI/Input
Stage 3: Game Logic
Stage 4: Rendering

Now let's say that the physics detects a collision between a bullet and a character in stage 1. Two frames later the game logic may choose to remove that bullet from the simulation, however none of the other copies of the data for the other pipeline stages will get this information. How is this sort of thing and other things like it get handled? Do you generally make changes like this to every pipeline stage's data at the end of a frame?