texts: 3-hit combo system plays first attack animation every time

texts:
So the new input system is out, and we're using it for our game. The next hurdle I'm trying to get over is implementing a melee combo  ( E->-E->E). Not 100% sure how to get the new system to execute something like that. Right now my trigger isn't resetting. Images of the animator graph at the bottom

public class PlayerController : MonoBehaviour
{
    Rigidbody2D _rigidbody;
    SpriteRenderer _renderer;
    Animator _animator;
    public float fallMultiplier = 2.5f;
    public float lowJumpMultiplier = 2f;

    PlayerInputActions inputActions;
    Vector2 movementInput;
    public bool inInteractionZone;
    public int attackCount = 0;
    public float attackTimeout = 0.5f;

    bool touchingWall;
    private void Awake()
    {
        HRHEventHub.OnPlayerDeath += HRHEventHub_OnPlayerDeath;
        inputActions = new PlayerInputActions();
        inputActions.Player.Move.performed += ctx => movementInput = ctx.ReadValue<Vector2>();
        inputActions.Player.Interact.performed += InteractPressed;
    }

    private void InteractPressed(InputAction.CallbackContext obj)
    {
        //TODO add attack timeout
        //Check if we are inside a interaction zone
        if (inInteractionZone)
        {
            //TODO implement
            return;
        }
        if (attackCount == 0 && _grounded)
        {

            attackCount++;
            _animator.SetTrigger("Attack");
            //_animator.SetBool("ATK1", true);
        }
        else
        if (attackCount == 1 && _grounded)
        {
            attackCount++;
            _animator.ResetTrigger("Attack");
            _animator.SetTrigger("Attack");

        }
        else
        if (attackCount == 2 && _grounded)
        {
            attackCount = 0;
            _animator.ResetTrigger("Attack");
            _animator.SetTrigger("Attack");

        }

    }

}


texts:
I have recently been looking to add a feature which will allow me to render a movie\video into my game. I.e, something pre-rendered and played as the game starts.

I am using Java2D purely so I am curious if there are any frameworks out there that will allow me to do this in an active rendering environment.

Thanks.


texts: Why is this LIBGDX Action behavior THE EXACT OPPOSITE of what I expect?

texts:
Here is a code snippet of the relevant section in my render loop. My intention was to make the actor who was currently focused blinking, to indicate that it was the currently selected UI element. But after noticing that setting the condition of the if statement to == was giving me THE EXACT OPPOSITE of what I expected (namely: all elements that had previously had focus that were not the currently focused element of the stage were blinking), I changed it to the opposite and received the desired outcome.

QUESTION: What fundamental lesson of how Actions work am I missing? Why is this happening?

    Actor currentFocus = stage.getKeyboardFocus();

    if(currentFocus != gameVolumeSlider){
        gameVolumeSliderLabel.addAction(Actions.forever(Actions.sequence(fadeIn(.5f),fadeOut(.5f))));
    }
    if(currentFocus != musicVolumeSlider){
        musicVolumeSliderLabel.addAction(Actions.repeat(RepeatAction.FOREVER, Actions.sequence(fadeIn(.5f),fadeOut(.5f))));
    }
   if(currentFocus != backButton){
        backButton.addAction(Actions.repeat(RepeatAction.FOREVER, Actions.sequence(fadeIn(.5f),fadeOut(.5f))));
    }

    stage.act(Gdx.graphics.getDeltaTime());
    stage.draw();


texts: Why do we multiply perspective * modelview * point?

texts:
A common line in vertex shaders is:

gl_Position = projection_matrix * model_view_matrix * object_space_vertex;

I've seen this a lot, why isn't it written like

gl_Position = object_space_vertex * model_view_matrix * projection_matrix;

?

That would be more intuitive I suppose. Is it mathematically wrong?


texts: Unity fade all UI elements which belong to one Canvas

texts:
Like the question describes I want to fade out/in all UI-Elements belonging to a parent canvas.

So things I got are :

A World-Canvas which contains multiple UI-Items
A script which can fade one color depending how close my cursor comes to that item

Things I want :

A script which can fade my whole canvas without attaching each single Element with a color property to it

Thoughts :

This would most likely work with a script which searches all Text children and Image children of the canvas, but I think that would be rather poorly performing code

I'm totally fine if there is no better solution as the mentioned one, but I would be annoyed if I implement it that way and there is a simple trick I don't know about :)


texts: How do I correctly project a point behind the camera?

texts:
I am making a 3D game in which I put an exclamation marker above points of interest.

In order to find out where in the 2D screen should I put my marker, I am manually projecting the 3D point where the marker should be.

It looks like this:

Looks pretty good. When the marker is outside of the screen, I simply clip the coordinates so they fit into the screen. It looks like this:

So far the idea is going pretty well. However, when the points of interest are behind the camera, the resulting X,Y coordinates are inverted (as in positive/negative), and I get the marker to appear on the opposite corner of the screen, like this:

(The projected-then-clamped point is the tip of the marker. Don't mind the rotation of the marker)

It makes sense, since the coordinates behind the frustum are inverted in X and Y. So what I'm doing is to invert the coordinates when they are behind the camera. However, I still don't know what is exactly the condition when the coordinates should be inverted.

This is currently what my projection code looks like (in C# with SharpDX):

    public override PointF ProjectPosition(float viewportWidth, float viewportHeight, float y)
    {
        var projectionMatrix = Matrix.PerspectiveFovRH(GetCalibratedFOV(Camera.FOV, viewportWidth, viewportHeight), viewportWidth / viewportHeight, Camera.Near, Camera.Far);
        var viewMatrix = Matrix.LookAtRH(new Vector3(Camera.PositionX, Camera.PositionY, Camera.PositionZ), new Vector3(Camera.LookAtX, Camera.LookAtY, Camera.LookAtZ), Vector3.UnitY);
        var worldMatrix = Matrix.RotationY(Rotation) * Matrix.Scaling(Scaling) * Matrix.Translation(PositionX, PositionY, PositionZ);
        var worldViewProjectionMatrix = worldMatrix * viewMatrix * projectionMatrix;

        Vector4 targetVector = new Vector4(0, y, 0, 1);
        Vector4 projectedVector = Vector4.Transform(targetVector, worldViewProjectionMatrix);

        float screenX = (((projectedVector.X / projectedVector.W) + 1.0f) / 2.0f) * viewportWidth;
        float screenY = ((1.0f - (projectedVector.Y / projectedVector.W)) / 2.0f) * viewportHeight;
        float screenZ = projectedVector.Z / projectedVector.W;

        // Invert X and Y when behind the camera
        if (projectedVector.Z < 0 ||
            projectedVector.W < 0)
        {
            screenX = -screenX;
            screenY = -screenY;
        }

        return new PointF(screenX, screenY);
    }

As you can see, my current idea is to invert the coordinates when either the Z or W coordinates are negative. It works -most- of the time, but there are still some very specific camera locations where it doesn't work. In particular this point shows one coordinate working and the other one not (the correct location should be the bottom right):

I have tried inverting when:

Z is negative (this is what makes most sense to me)
W is negative (I don't understand the meaning of a negative W value)
Either Z or W is negative (what's currently working most of the time)
Z and W are of different sign, a.k.a.: Z / W < 0 (makes sense to me. doesn't work though)

But have still not found a consistent way with which all my points are correctly projected.

Any ideas?


texts: Build includes sprite packer atlas and its original textures

texts:
I use Unity's Sprite Packer, it's working great. However, when I looked at the build report (in the Editor.log) it turns out that the build often includes the generated atlas texture and its original textures too. It wastes too much space. I checked the size of the unzipped APK and the build report was correct. I tried several configurations (adding and removing textures) but I could not find any regularities.

Some observations: - I could reproduce this only if I use 25+ textures in an atlas with variable sizes. - Texture compression settings did not matter. Packer policy could modify the result but did not solve the problem.

Has anybody had similar experience? I can upload my test project if necessary.


texts: Is Google App Engine suitable for a real-time but single player game?

texts:
I'm in the planning stage of a new project. Without going into details, this is a real-time 2D game with some basic construction aspects, combat, and a large procedurally generated world.

Because of the design of the game, it really makes most sense for it to run directly in a browser with all of a player's progress stored on the server. Basically each player will have their own persistent 2D map which they can modify, and I want them to be able to access it from any computer. It's not multiplayer.

Imagine a real-time 2D action and building game that could be played completely offline, except it saves your progress to a server so it can be accessed from anywhere.

This will be my first foray into making an online game or web application, so I'm wanting it to be as painless as possible. Would GAE work well for a game like this? I've been told that GAE is simply not appropriate for a real-time game; however, this has always been said in the context of a multiplayer game, not a single player game.

I should also note that it would be acceptable for the game to have an ordinary save option and to only save data to the server when this option is used by the player. Since that means the player would lose progress if he just closed the tab or browser window without saving, it could be accompanied with a 5 minute autosave.


texts: Find x and y position with angles in 3D world

texts:
I'm actually creating a Tracking Camera (or 3rd person camera), and to do so, I used two angles (X and Y) for the rotation of the camera and an other floating value for the distance between the target and the camera.

The camera system works fine, but I am searching a way to calculate the position of the correct position of the camera (for debug purpose only)

Do you have an idea of how I can do to figure it out?

This is the camera update function:

public void Update(GameTime gameTime)
{
  this.View =
    Matrix.CreateTranslation( 0, 0, 0 ) *
    Matrix.CreateRotationY( MathHelper.ToRadians( this.RotationAngle ) ) *
    Matrix.CreateRotationX( MathHelper.ToRadians( this.ArcAngle ) ) *
    Matrix.CreateLookAt(
      new Vector3( 0, 0, -this.Distance ),
      this.TrackingPosition,
      Vector3.Up );

  Viewport _viewport = this.graphicsDevice.Viewport;
  Single _aspectRatio = (Single)_viewport.Width / (Single)_viewport.Height;

  this.Projection = Matrix.CreatePerspectiveFieldOfView(
    MathHelper.PiOver4,
    _aspectRatio,
    NEAR_PLAN, FAR_PLAN );

  // Find x and y
  this.Position = new Vector3( 0, 0, -this.Distance );
}


texts: Avoiding GC Allocation in Unity UNet API

texts:
I'm trying to profile the game using Unity Profiler, I can see in the Hierarchy tab that there's an 18.3 KB correlated to NetworkIdentiry.UNetStaticUpdate().

I guess this has happened inside the Unity UNet API, is there a workaround to avoid that to happen? and why an internal Unity calls can cause GC?


texts:
I am puzzled by the behaviour I am seeing in my game that uses Chipmunk2D for physics.
I am not sure what I see is physically correct or not?

If I apply two forces as such, the tank turns, as expected.

The force at RHS of tank is much larger, causing the turn.

So far so good.

However, if the differential gets just a little smaller, as shown below,
the tank goes dead-straight.

I emulate the friction by following the example for Chipmunk2D.

The forces are applied using the cpBodyApplyForceAtLocalPoint() function.


texts:
Im new to drop down menus. How can I make a working shop in html/javascript. I have this so far  http://prntscr.com/o15oj7   . I want help with the selling of a material part. i know i should use if statements but im not sure how to format the function . I want if bronze is selected for how much you can sell it for to be displayed. then if u press sell button you gain that much gold then lose 1 bronze.

var goldcoins = 0;
var goldcoins = 0;
var Bronzeprice = 10;
var Silverprice = 20;
var GoldPrice = 50;
var DiamondPrice = 100;
var ShrimpPrice = 10;
var BassPrice = 20;
var SalmonPrice = 50;
var SharkPrice = 100;

function sellItem(){
    var mylist=document.getElementById("myList");document.getElementById("favorite").value=mylist.options[mylist.selectedIndex].text;}

Html code:

   </style>
                   Shop

                       Auto Miner <button
onclick="buyMiner()"
    id="MinerCostBtn" >Buy</button>

                   Auto Fisher <button onclick="buyFisher()" id="FisherCostBtn" >Buy</button>

                <form>
                Sell:
                <select id"SellBox" >
                    <option> Bronze </option>
                    <option> Silver </option>
                    <option> Gold </option>
                    <option> Diamond </option>
                    <option> Shrimp </option>
                    <option> Bass </option>
                    <option> Salmon </option>
                    <option> Shark </option>
                    </select>
                    For:&nbsp;0 &nbsp;<button onclick="SellItem()" id="SellBtn" >Sell</button>

                  </form>

                  Gold Coins: 0

                  Buy skillpoint 100,000 gold <button onclick="buySkillPoint()" id="SkillPointBtn" >Buy</button>

                  Buy diamond 10,000 gold <button onclick="buyDiamond()" id="diamonddBtn" >Buy</button>

                  Buy shark 10,000 gold <button onclick="buyShark()" id="sharkkBtn" >Buy</button>

I expect when bronze is selected (etc) for how much you will gain from it to be displayed then when button is pressed for you to lose 1 bronze and gain that amount of gold. While the drop down menu is on that item. I have the variables on a diffrent javascript . i do that all those drop down button items . I just need to know how to format the funtion so if they are selected in the drop down menu that item will sell.


texts: How to check the memory leackage in libGDX game development?

texts:
I'm developing a multi-platform game in libGDX. Sometimes there is a huge issue with memory. The game used to stick a lot. In fact, I even used pooling.

Is there any method to check the memory leakage in libGDX?


texts:
EDIT:

After doing some research on my own I found that by deleting the debug.keystore file everything fixed itself.

So currently I'm exporting my game strictly for testing to the Android.

However, when I attempt to build for the Android, I get these errors:

  Using keystore: C:\Users\Tim Williams.android\debug.keystore THIS TOOL IS >DEPRECATED. See --help for more information.

  Debug Certificate expired on 4/14/12 11:18 AM

  UnityEngine.Debug:LogError(Object) PostProcessAndroidPlayer:BuildApk(String, >Boolean) (at C:/BuildAgent/work/b0bcff80449a48aa/Editor/Mono/BuildPipeline/PostProcessAndroidPlayer.cs:1014) PostProcessAndroidPlayer:PostProcess(BuildTarget, String, String, String, String, String, String, BuildOptions) (at C:/BuildAgent/work/b0bcff80449a48aa/Editor/Mono/BuildPipeline/PostProcessAndroidPlayer.cs:444) UnityEditor.HostView:OnGUI()

And

  Error building Player: UnityException: APK Builder Failed! Failed to build APK >package. See the Console for details.

Does anyone have any ideas what these errors are, and how I could fix them? This is my first time building for any mobile device, so I'm a bit confused (Also, I do have the Android SDK.)

Thanks,

Tim.


texts: Move a 2D sprite into an irregular terrain

texts:
With a tile based engine, in my knowledge, is not possible to move a sprite into an irregular terrain. So which are the techniques to use for implementing that?
Maybe an hexagonal tile based engine?


texts: Unable to wire UI Text object to C# Script

texts:
I have created UI text object

And then created Text field in behavior class:
using UnityEngine.UI;

public class Explorer : MonoBehaviour
{
    public Material mat;
    public Text text;

...

void FixedUpdate () {
    ...
    text.text = string.Format("x {0}", scale);

If I just run it, it says
Object reference not set to an instance of an object

at runtime.
If I try to drag ZoomText to Text slot, it doesn't allow me:

If I first drag ZoomText from Hierarchy to Project

then it allows me to set Text slot, but still gives
Object reference not set to an instance of an object

at runtime.
If I am trying to set text field by Find
private void Start()
{
    text = (Text) GameObject.Find("ZoomText");
}

it gives me
Cannot convert type 'UnityEngine.GameObject' to 'UnityEngine.UI.Text'

What I am doing wrong? Suspect may be incorrect types, but how to know correct ones?


texts: A number of teams playing against each other: what is a fitting game term?

texts:
Basically I am looking for the right expression for a specific set (usually 2-6) of teams (a team is a group of individuals controlled by one player) in a tounament-like game. The team-set is a subset of a larger number of existing teams e.g.: there exist 10 teams t1, ..., t10. Team-Set 1 is {t1, t3, t7}, team-Set 2 is {t1, t5, t8, t10} and so on. What would be a good expression for "team-set" in a somewhat-military (fun-based combat) game context?

The teams of the set fight against each other, and not together (alongside each other). So I am looking for a somewhat confrontative term.


texts: Simple, casual open source OpenGL games to implement other things in

texts:
I am looking for a simple casual game (open source) done in openGL. I need it to implement communication component i build this is not for learning opengl  and to implement some other stuff into it. Where can I find one?
(I am using C++)
Thanks


texts: Method for spawning enemies according to player score and game time

texts:
I'm making a top-down shooter and want to scale the difficulty of the game according to what the score is and how much time has Passed. Along with this, I want to spawn enemies in different patterns and increase the intervals at which these enemies are shown. I'm going for a similar effect to Geometry wars. However, I can think of a to do this other than have multiple if-else statments, e.g. :

        if (score > 1000) {
    //spawn x amount if enemies
        }
        else if (score > 10000) {
    //spawn x amount of enemy type 1 & 2
        }
        else if (score > 15000) {
       //spawn x amount of enemy type 1 & 2 & 3
        }
        else if (score > 25000) {
       //spawn x amount of enemy type 1 & 2 & 3
       //create patterns with enemies
        }
       ...etc

What would be a better method of spawning enemies as I have described?


texts: Add parabola curve to straight MoveTowards() movement

texts:
I have some units shooting arrows, right now they move in a straight line to the target. I want them to move like a real arrow, i.e using a parabola curve. However I don't want to use physics.

The math I need to do seems to be beyond me, I've tried to convert 2d solution I found online and other semi-similar solution with no luck.

My current straight movement:

private void Update()
{
    var nextPos = Vector3.MoveTowards(transform.position, target, speed * Time.deltaTime);
    transform.LookAt(nextPos, transform.forward);
    transform.position = nextPos;

    if (Vector3.Distance(nextPos, target) < .1f)
        Arrived();
}

An example of a 2d version I tried to replicate: Here.


texts: A trigger collider in Unity doesn't allow the player to pass through

texts:
It's my understanding that checking "Is Trigger" on a collider should allow rigid bodies to pass through without collision prevention, but my trigger isn't doing that consistently.  The player cannot pass through, but other objects can.

The trigger is a cube primitive with "mesh rendered" unchecked so that the cube won't be visible.  The cube has a box collider with "is trigger" checked, and also a script.  The script currently doesn't do anything except output from Debug.Log in OnTriggerEnter() as a test.

Primitives are able to pass through.  The test is just a basic Unity sphere with all the default settings, including a sphere collider.  The only change was that I added a RigidBody.

Imported models also pass through.  I have a simple .blend model with a rigid body and box collider.

The player does not pass through.  The main difference between the player's object and the other imported model is that the player is using a custom mesh collider which is different than the player's rendered mesh.  The rendered mesh is the game object and the low-poly collision mesh is a child of that object.

I've tried several variations, including switching the player from a mesh collider to a box collider, and also moving the box collider to the main mesh rather than a child mesh, but the results are the same.  The player stops moving as soon as he hits the location of the trigger's box collider.

Any ideas are appreciated.  Thanks in advance.

MORE INFO:

Here's a screenshot of the scene layout, with the invisible trigger collider selected.

Also pictured is the hierarchy showing that the trigger collider ("Jump Pad Trigger") has no children.  On the right is displayed every component that the trigger object has.  I've also moved the collider from its original location several times to prove that it's not another object in the scene that the player is colliding with.


texts:
I would like to implement an interactive zoom on a 3d object with mouse wheel.A naive approach is simple where you just scale camera marix Z poistion or modify FOV.But I would like the zoom scaling to be aware to the scale of the object and adapt its speed to it accordingly.It is standard behavior of CAD programs like Maya and 3d max.In this demo  the zoom scaling is performed by exponential grow of the value but it would still be the same for models with radius of 10 units and 100000 units.I am sure eventually I will probably roll my own solution but I am interested to know if there are some industry standard techniques for this kind of interactivity.

Also I am sorry if this is not an appropriate place to ask.I thought game devs should have some experience in this area.


texts:
You see, especially in FPS games, when a bullet hits a wall or a character, etc. You end up with the bullet hole.

Is this usually done with the actual skin temporarily changing, or just an overlay of another image (or something totally different)?

Could anyone give me pointers on how to go about this? I'm using XNA (C#)


texts: What's the difference between Update and FixedUpdate in Unity, and should I bother?

texts:
I was told to use Update() for graphics and FixedUpdate() for physics, but sometimes my inputs won't register when I use FixedUpdate(). It works fine if I use Update() for everything though.

Should I bother with FixedUpdate(), or am I doing something wrong?


texts: Game resource timers - general implementation

texts:
I'm interested in understanding how resource generation timers work on many of the mmorts type games out there. I can't wrap my head exactly around how the timers are synched with servers, especially with multiple users. If I need to provide more details, please let me know.

Thanks!


texts: Drawing only objects that are currently in viewport [Gamemaker]

texts:
Following on from my previous question about optimising large object counts in Gamemaker, I am looking for a method for the solution proposed by liggiorgio.

My game has large numbers of small, sprite-based objects, represent individual strands or clumps of fur. For a variety of reasons, they all need to be interactive objects. At the moment, I am reaching limits on how many I can generate without the game grinding to a halt.

As the game involves a very large (20,000px x 20,000px) room with a restricted viewport, liggiorgio proposed a solution using the built-in Application Surface to only draw objects which are currently within the viewport. This would mean that the vast majority of the room, and its objects, would not be drawn, and hopefully framerates should improve.

Can anybody help me with implementing this?

Update: I am now using this code in an object's Draw event as a test:

if (x > view_xview[0] and x < (view_xview[0] + view_wport[0]))
and (y > view_yview[0] and y < (view_yview[0] + view_hport[0]))
{
draw_self()
} else {
}

However, even when I pan the view over to the affected object, it is not drawn.

Edit: Thanks, liggiorgio, for your below solution. This code works well for drawing and not drawing based on view in the room, as far as I can tell. However, not-drawing the large number of oFur objects does not seem to help with my performance issues. I think that deactivating those not currently in view is the best option.

I know that deactivating instances can be risky, but I don't think it will be a problem for me:

I only have one room in my game, so there is no worry about
persistent objects not being carried over;
At no point will I be trying to delete all of the oFur objects at once;
I have created a FurDeactivation control object, so I won't fall into the trap of having the oFur modules try to deactivate themselves and then therefore be unable to reactivate themselves when they are in the view. I made this mistake at first, but I've now corrected it with the FurDeactivation control object.

This is the script that is running in the Step event of the control object. The ObjectType is oFur;

///DeactivateIfOutOfFrame(ObjectType)

ObjectType = argument0

with ObjectType {
if ((x > (view_xview[0]-sprite_width/2)) && (y > (view_yview[0]-sprite_height/2)) && (x < (view_xview[0]+view_wview[0]+sprite_width/2)) && (y < (view_yview[0]+view_hview[0]+sprite_height/2)) )
{
instance_activate_object(self)
} else {
instance_deactivate_object(self)
}
}

At the moment, it does not seem to be deactivating any of the instances of oFur outside the view. Any ideas?


texts: Change in force on objects after collision

texts:
i am implementing a billiard simulation game and i have a question about collision response.

As integrator, i am using Semi-Implicit Euler,

ball.setVelocity(ball.getVelocity().add(ball.getAcceleration().multiply(dt)));
ball.setPosition(ball.getPosition().add(ball.getVelocity().multiply(dt)));

Before integrating, i am calculating acceleration :

this.setAcceleration(this.getForce().multiply(1 / this.getMass()));

dt is time frame here, and acceleration, velocity, force and position are Vector class. (operations as add, multiply... are standard vector operations).

My question is - when i initially hit ball with cue, i am giving force -k*x (Hooke's law) to ball. But when it collides with other ball, i can only find formulas that calculate new position and new velocity, but my force will stay same. But how to change force here in both balls (it will change velocity and position later in SE Euler).

I appreciate any answer!


texts:
I am not sure how that systems type called, so I try to describe what we want and it will be great if someone can advise…

We have online game with client/server architecture. The game has some configs and this configs must be available for change. Simple example is that we have monster_id 10 with attack_power 15 and our game designers while trying to improve balance, changed attack_power value to 14, so next time, when clients load game, they also load Monster config and monster with id 10 have attack_power 14.

For now, we use Google Sheets as configs “frontend”. We add some custom scripts that allow load this sheet as json on our backend that will compress it, update revision and store in our DB. And when game client booted, backend sends this compressed configs from DB. But the problem is that architecture lack off functionality… I mean, that is hard to ever add simple validation for some rows of sheets, because we need to use google macros and they (as I know) even don`t allow to load external js libraries…

Ofc we can write our backend&frontend for this, but I think that it is as making a bicycle… So, my question is there any system that work with “dynamic configuration” as described above and allow users to customize it, write extension etc.?


texts: How to detect a swipe and make the player GO rotate towards the end of the touch Android Unity

texts:
I am making a game where the user can swipe on the screen and the player gameobject will turn towards the end of the swipe.

I am using the following to detect the end of the swipe:

        if (touch.phase == TouchPhase.Ended)
        {
            swipeEndPos = touch.position;
            swipeDistance = (swipeEndPos - swipeStartPos).magnitude;
            if (swipeDistance > minSwipeDistance)
            {
                Vector3 swipeEndPoint = mainCamera.ScreenToWorldPoint (swipeEndPos);

                player.Turn (swipeEndPos);
            }
        }

And the following to make the player turn towards the end position:

     public void Turn(Vector3 direction)
     {
       transform.Rotate (new Vector3(0,direction.y,0), Space.Self);
     }

Can someone please explain what I am doing wrong?

Thank you.


texts:
Can anyone please help me out with a small test game I'm creating. I'm basically creating this game to learn a few things about HTML5 and so far it's all been good. I've been able to create a canvas with a air balloon that can fly and drops to the bottom when it's not. Now I want the air balloon to be able to stop on another image, which I've called "level1". If someone could perhaps have a look at it, view the source and suggest how I would do this, I would appreciate it.

Or perhaps using images isn't the most efficient way to create a level. If it isn't then please say. Thanks again. :)

Here's the game.


texts: Is my understanding of designing games in layers correct?

texts:
I have started explaining how a game is designed in layers to a friend of mine. I want to make sure that I explained things, correctly, so I wanted to verify my thoughts.

Basically, the way I understand it, games are designed with the following layers, in the following order:

Rendering Engine
Physics Engine
Game Engine
Scripted Game

Is this correct?  Am I explaining this right?


texts:
Does phaser have any function that returns the width of the text or if not, how can I center text inside rectangle I've drawn?

Thanks!


texts: For creating a distant moon in a 3D game, is it better to use a model or texture?

texts:
I'm working on my indie game and I want to create a moon (it's a 3D game) however I am unsure if I should create a model and put it far away, or if I should use a texture on a plane and have it constantly move so the face of the plane is facing the player.

The problem I had last time I tried a model is the render view, as the model was really far away (as when I did it very small, you could sort of tell it was a tiny model rather then a far-away moon) and with the texture I'm not sure if it comes across as tacky.

I'd really like to hear the pros and cons of each, since I'm planning to use the 'render objects only when in view' method and basically want advice on which I should go with.


texts: Is there any way to make animations using physical dolls?

texts:
I've had trouble animating characters using 3D applications. It is too slow and difficult. I've programmed my own 3D animator that uses only the keyboard to change key angles. The results are much better, yet it draws some considerable time.

http://dl.dropboxusercontent.com/u/62862049/Screenshots/tq.png

I'm reaching the conclusion animating is hard because nor the keyboard nor the mouse are ideal input sources for that kind of thing. I guess the best would be a physical doll one could manipulate. Is anyone aware of such a product?


texts:
How,can I disable coloring when texture is applied, because right now
the texture is being colored over.

foreach (BasicEffect effect in mesh.Effects)
{
    effect.TextureEnabled = textureApplied;

    if(textureApplied)
        effect.Texture = Texture2D.FromStream(GraphicsDevice,System.IO.File.OpenRead(texturePath));
    else
    {
        effect.DiffuseColor = ti.DiffuseColor;
        effect.EmissiveColor = ti.EmissiveColor;
    }
    ...
}
mesh.Draw();

Also, is there any easy way for xna to export models? Or do I have to write my own?


texts: How to avoid players getting lost in and/or bored by the meta game?

texts:
Yesterday, I noticed something that I had never noticed consciously before, but which had "ruined" more or less all games that I have ever played:

The longer you play a game, the more you get lost in and bored by the meta game. What I mean is that the longer you play, the more you know the meta game. Once you know the meta game by heart, you basically stop playing the game and instead only play the meta game anymore.

Here are a few examples from different genres to show what I mean:

DotA: In the beginning, DotA is super fun, although you totally suck at it. You learn new heros, you are happy when you are able to buy an expensive item and so on. After being "pro" in DotA, you basically only play the meta game anymore: You pick exactly the hero that can counter the enemy and play exactly a perfect meta game for your hero (e.g., go to jungle until you are fat, time creep spawns to stack, and so on). You know basically exactly at which time you will be able to buy which item and you execute this. You no longer play the game, you just play the meta game. You execute a well-thought-out choreography, which you perfected by executing it 100 or more times. Eventually this gets boring!

Anno XXXX:
In the beginning, you build an island and have to master more and more challenges to keep you citizens happy. Cool! Once you know the meta game the whole game becomes a "Oh, I need these 10 resources in these proportions, then the people are happy. I build a fleet and capture the enemy or keep on playing until my island is full".

Cities: Skylines (or any Sim City):
In the beginning, it is fun to master what your people need. In the end, you know exactly what they need, so it becomes more or less a burden: E.g., for each new residential district, I need a police station, a fire station, garbage incineration plant, crematory, a hospital, I connect everything to the highway, add a subway station and add bus lines. Done. Lame. It starts feeling totally mechanic. I no longer feel like building a real city. I feel like building a mathematically simulation of a city and just responding to optimize all parameters for this simulation.

Civilizations:
A super nice game to explore in the beginning! So many technologies, just wow! In the end: I know exactly which technology to develop when. I have a more or less complete ordering among the technologies. I know where exactly to place the next city and which units to build. Heck, I think I could even write an AI that does more than 95% of the things I do, since everything has become so mechanic.

I could go on forever. Almost all games have this. For some players, this is where the game gets really cool. Some players want to play the meta game! But for others, including me, it gets boring. I want to feel like playing a game, like exploring. Not optimizing a numerical simulation.

So, when designing a game, how can you avoid that this will happen? Is it possible to hide the meta game to such an extent that the player no longer feels it, even when playing the game for long.


texts: How can I get a 2D texture to rotate like a compass in XNA?

texts:
I'm working on a small maze puzzle game and I'm trying to add a compass to make it somewhat easier for the player to find their way around the maze. The problem is: I'm using XNA's draw method to rotate the arrow and I don't really know how to get it to rotate properly. What I need it to do is point towards the exit from the player's position, but I'm not sure how I can do that.

So does anyone know how I can do this? Is there a better way to do it?


texts: How to reference a map position in code?

texts:
I'm coding a digital version of the Macao board game which has a flat map similar to below. Players have a "ship" which starts in the blue box and can follow the dashed lines in any direction/orientation.  The larger rectangles represent city locations.

I'm stuck in the following issues.

How do I record the position of each ship?  I'm thinking co-ordinates like X,Y but that doesn't tell me the segment its on
How do I construct the route paths as objects?   Do I put them in an array?
Finally; in order to measure distance between 1 rectangle and another, it will need to count how many segments there are to ascertain the shortest distance.  I believe this can be resolved via a simple path algorithm.

I've not created a map like this before in a project but would welcome any help on how to move this forward.


texts:
As with all Unity versions Unity 5 comes with a set of Standard Assets. This new set of Standard Assets comes with a Car Controller. Either by attaching a Car user controller script or a Car A.I. script the Car is ready to be used within a game. I am using that said Car controller to create my own car in a game. What I am trying to do is increase the cars acceleration and top speed. I did not find any documentation on the mechanics behind the car controller (and since I do not know much about cars) I did not find a way on how to do this. I am reading the script and understand the flow of code but do not understand which variables affect what in the script.

Now for Top speed the car controller exposes a public variable responsible for that precise task.
But what about acceleration?


texts: Texture is black when manually building mipmap

texts:
I am trying to manually build a mipmap from a series of images. For the sake of brevity, let's assume the file containing the images I want (from 256x256 to 32x32) have paths file_1...4.

What I do to load the texture is:

GLuint textureID;
glGenTextures(1,&textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 4);

for i from 1 to 4
    unsigned char* image =  stbi_load_from_file(file_i, &width, &height, &comp, 3);
    glTexImage2D(GL_TEXTURE_2D, (i-1), GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
    stbi_free_image(image);

When I go and try to use this created texture in a render all I got is a black result. Using singularly each texture works properly, so I excluded they're malformed. What can it be?


texts: Where can I find game postmortems with a programmer perspective

texts:
There are a number of interesting game post-mortems in places like GDC vault or gamastura.com. The post-mortems are generally give with a CEO/manager perspective or a designer perspective, or, more often a combination of both e.g DOOM postmortem

But I have not been able to find many post-mortems which are primarily from the programmers perspective. I'm looking for discussions and rational for technical choices and tradeoffs and how technical problems were overcome. The motivation here is to learn what kind of problems real game programmers encounter and how they go about solving them.

A perfect example of what I'm looking for is Renaud Bédard's excellent GDC talk on the development of Fez, "Cubes all the way down". Where can I find more like that?


texts: How to calculate 2D viewport coordinates in a shader?

texts:
In Unity, I use the following shader to calculate 2D viewport coordinates :

Shader "Foo"
{
    SubShader
    {
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            struct vertInput {
                float4 pos : POSITION;
            };

            struct vertOutput {
                float4 pos : SV_POSITION;
                float4 uv : TEXCOORD0;
            };

            vertOutput vert (vertInput input)
            {
                vertOutput o;
                o.pos = mul(UNITY_MATRIX_MVP, input.pos);
                o.uv = mul(UNITY_MATRIX_MVP, input.pos);
                return o;
            }

            fixed4 frag (vertOutput output) : SV_Target
            {
                float2 viewport = output.uv.xy / output.uv.z;
                return float4(sin(viewport.x*10.0), sin(viewport.y*10.0), 0.0, 1.0);
            }
            ENDCG
        }
    }
}

At first, it seems to work great. Here is results :

However if I move camera very close to the surface, the following unexpected glitch occurs :


texts: How to change pixel color of Texture with Fragment Shader

texts:
I want to change the pixel color of a texture. I don't know where to start and what to add. Really need help, I only find useless snippets in the internet.

My current Code:

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
...
GLES20.glAttachShader(riGraphicTools.sp_SolidColor, vertexShader);
GLES20.glAttachShader(riGraphicTools.sp_SolidColor, fragmentShader);
GLES20.glLinkProgram(riGraphicTools.sp_SolidColor);

vertexShader = riGraphicTools.loadShader(GLES20.GL_VERTEX_SHADER, riGraphicTools.vs_Image);
fragmentShader = riGraphicTools.loadShader(GLES20.GL_FRAGMENT_SHADER, riGraphicTools.test_Image);

riGraphicTools.sp_Image = GLES20.glCreateProgram();
GLES20.glAttachShader(riGraphicTools.sp_Image, fragmentShader);
...
}

The riGraphicTools Class:

public class riGraphicTools {

public static final String test_Image =
        "precision mediump float;" +
        "varying vec2 v_texCoord;" +
        "uniform sampler2D s_texture;" +
        "void main() {" +
        "  gl_FragColor = texture2D( s_texture, v_texCoord );" +
        "}";

public static final String vs_Image =
    "uniform mat4 uMVPMatrix;" +
    "attribute vec4 vPosition;" +
    "attribute vec2 a_texCoord;" +
    "varying vec2 v_texCoord;" +
    "void main() {" +
    "  gl_Position = uMVPMatrix * vPosition;" +
    "  v_texCoord = a_texCoord;" +
    "}";
}


texts: How make animation only consider the final position?

texts:
I'm trying to make an energy indicator for a puzzle, and i decide to user animation to set the position of the red indicator(photo).

My first ideia is to make 9 animations, and for every black arrow i set the final position to the red indicator. And organizer in the animation controller.

But the main problem is, after every animation, the red indicator got to the first position, in the case the first arrow black, and then go the final position, because all the animation have the same position in the begin (0s).

How can i animation the trasition of red indicator to only got to the end position? Like, if the position of the red indicator was in the 7th black arrow and then go to 3th arrow. Is possible with animation?


texts: How do I create 2D water with dynamic waves?

texts:
New Super Mario Bros has really cool 2D water that I'd like to learn how to create.

Here's a video showing it. An illustrative part:

Things hitting the water create waves. There are also constant "background" waves. You can get a good look at the constant waves just after 00:50 in the video, when the camera isn't moving.

I assume the splash effects work as in the first part of this tutorial.

However, in NSMB the water also has constant waves on the surface, and the splashes look very different. Another difference is that in the tutorial, if you create a splash, it first creates a deep "hole" in the water at the origin of the splash. In new super mario bros this hole is absent or much smaller. I am referring to the splashes that the player creates when jumping in and out of the water.

How do I create a water surface with constant waves and splashes?

I am programming in XNA. I've tried this myself, but I couldn't really get the background sine waves to work well together with the dynamic waves.

I am not asking how the developers of New Super Mario Bros did this exactly—just interested in how to recreate an effect like it.


texts: How to load values into a script from a file?

texts:
I have a prefab of a "generic unit;" each one has a script with some public variables: name, health, and attack.

Currently, I am manually making copies of that prefab and editing their names, health and damage values in the inspector. This seems unwise to me.

I would rather be able to make a simple file for each unit type, containing its important information, like this:

name = "Archer"
health = 3
attack = 1

And so on. Then, I would like to be able to turn that into actual GameObjects in Unity, presumably by instantiating the prefab and filling in its values with values from the file.

I could then make a script that runs when the game begins and iterates through, making all the objects I need.

However, I do not know the proper way to go about doing this. Is there some way to read files and slot values into variables of a script?

To be clear, I would like to be able to tell Unity to make an Archer, then have it read the Archer file, look up its values for health and attack, then instantiate a copy of the Generic Unit prefab and slot the values that it read into the public variables of a script component of the newly-created game object.


texts: You've killed the enemy you needed to get across. Now you have to die and retry?

texts:
I am designing enemies for a platformer, and want to have enemies which the player utilises to get through levels.

I like the idea of jumping on enemies to platform across gaps, but it's problematic if they die. It feels really bad to put the player in an unwinnable state, having killed their means to platform across a level. It just feels messed up to be like, 'You've killed the enemy you needed to get across. Now you have to die and retry'.

What are some ways of fixing that problematic game state?


texts: Many OpenGL declarations are not occured in GLESv3 gl3.h

texts:
I created a small OpenGL renderer in C++ and I want to move to Android so I prepared eclipse with all suitable platforms and create a Native Activity project then add the NDK to the includes and successfully executed and run a sample which color the screen, once I imported the files from the C++ project (copy them to jni folder) and fixed the includes I found many GL declarations are not occurred for example "Function 'glDrawBuffer' could not be resolved", I opened the gl3.h file and discovered that they are not occurred in that file, in my desktop version I use glew library and the file glew.h contains all those definitions so I tried to copy the definition from glew.h

GLAPI void GLAPIENTRY glDrawBuffer (GLenum mode);

to gl3.h

GL_APICALL void GL_APIENTRY glDrawBuffer (GLenum mode);

but still have the same error.
is these functions and constants are not occurred in the ES version of OpenGL or I need to update something? I have NDK r 15, SDK 22, Eclipse neo and GCC compiler with Android Builder.

Edit:

I found this definition in the same file

GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs);

I think it is the same function but different number of arguments so I can guess there are many differences between OpenGL and the ES3 so the is same code will not run and must be changed?

also is there a place where I can find the equivalent functions or constants?


texts: How can I support the creation and rendering of both interior and exterior environments?

texts:
Say I already have a renderer that can support outdoor terrain and environment rendering. How would I go about adding support for interior environments (for example, like World of Warcraft's dungeons) to my game?

I'm interested both in how I should fit the interiors into my content creation process (for example, I thought about leaving holes in the terrain mesh into which I can "paste" the interior dungeon mesh at runtime) and how to render them (it seems like I'd want a different rendering flow other than a blended texture rendering phase that terrain uses).


texts: Why is the equation \$S = ut + \frac 1 2 a t^2\$ not used directly to calculate final position of an object?

texts:
Most articles I've read on physics integration in games say to do it like this:

first we calculate velocity after a certain elapsed time dt like this: velocity.x += acceleration.x * dt
then we calculate position as: x += velocity.x * dt

But this will definitely give an inaccurate result.

Therefore, what is the reason to not use the equation of motion \$S = ut + \frac 1 2 a t^2\$ to calculate an accurate displacement and add it to the position?


texts: Projectile code reports wrong number of arguments

texts:
I'm not certain as to why my code isn't working. The error reports that the instance_create line uses a wrong number of arguments. What am I doing wrong?

if(ammo > 0)
{
    ammo -= 1;

    bullet_id = instance_create(
        x + lengthdir_x(lenx, image_angle) - lengthdir_y(leny, image.angle),
        y + lengthdir_y(lenx, image_angle) + lengthdir_x(leny, image_angle));

    bullet_id.direction = image_angle;
    bullet_id.image_angle = bullet_id.direction


texts: Why should I use separate initialization and clean up methods instead of putting logic in the constructor and destructor for engine components?

texts:
I'm working on my own game engine, and I am currently designing my managers. I've read that for memory management, using Init() and CleanUp() functions are better then using constructors and destructors.

I have been looking for C++ code examples, to see how those functions work and how I can implement them into my engine. How does Init() and CleanUp() work, and how can I implement them into my engine?


texts: Put a coroutine on potentially infinite loop

texts:
I have several coroutines always running.

I want to put these coroutines on hold as I set the game to pause mode.

Consider the content of these coroutines as follows

while (timeleft > 0)
        {
            if (pause)
            {
                continue;
            }
            ...
            timeleft -= Time.FixedDeltaTime;
            yield return null;
        }

I thought that would be okay to insert the if(pause) clause to have the coroutines to wait while pause is up.

What, insted happens is that (I guess) these infinite loops make unity not responding so that I have to kill the process.

Can I be right in thinking that the system does not like coroutines to be in a potential infinite loop? Or that is just okay and I have to heavily debug somewhere else?


texts: Using a MTLTexture as the environment map of a SCNScene

texts:
I want to set a MTLTexture object as the environment map of a scene, as it seems to be possible according to the documentation. I can set the environment map to be a UIImage with the following code:

let roomImage = UIImage(named: "room")
scene.lightingEnvironment.contents = roomImage

This works and I see the reflection of the image on my metallic objects. I tried converting the image to a MTLTexture and setting it as the environment map with the following code:

let roomImage = UIImage(named: "room")
let loader = MTKTextureLoader(device: MTLCreateSystemDefaultDevice()!)
let envMap = try? loader.newTexture(cgImage: (roomImage?.cgImage)!, options: nil)
scene.lightingEnvironment.contents = envMap

However this does not work and I end up with a blank environment map with no reflection on my objects.

Also, instead of setting the options as nil, I tried setting the MTKTextureLoader.Option.textureUsage key with every possible value it can get, but that didn't work either.

You can have a look at the example project in this repo and use it to reproduce this use case.


texts: Mesh made in Blender is correct in Unity3D as a rendered mesh, but "empty" as a collider?

texts:
I created a simple stair "block" in Blender, and it's rendered correctly, but when I tick "Generate Colliders" and try to use it in a Mesh Collider, there is nothing.

(Ps.: I need the real mesh as a collider, not just that generated convex one)

Maybe a good clue is that my other objects' generated colliders are smaller than the rendered meshes themselves. Maybe this one is scaled to zero?

After triangulating:

And via Unity's automatic triangulation: (the original, non triangulated blender model)


texts:
I've made a few games without using XNA and recently started to see some documents and samples around and took an interest on it but i have a few doubts for going into it or not.

What limitations do i have if i am planning to create a mmorpg with XNA for distributing it (if it has a item mall or is paid to play for example) ?
Do i need more accounts to test it (for example to login into my own game 3 players) or XNA does not cost anything at this level (heard something about LIVE Gold Membership plus which is why i am asking this one) ?


texts: How can I pass a texture to a custom deferred lighting model in Unity?

texts:
I've replaced the Internal-DeferredShading.shader with my own shader, and it's working fine, but I want to add a uniform texture for it to sample from.

I've tried adding a texture as a property and assigning it a default value in the inspector but at run-time the shader still uses the default value given in the shader (e.g. white).

Is it possible to do this?


texts: Why does my Vuforia 8.0 AR app work with a PC webcam, but not with a phone camera, and how do I fix it?

texts:
I am making an AR recognition app, the first time I have done so in 2018.3. I have installed the database and target info from the Vuforia developer portal. I have imported my model, and created an animator controller. I have an app key in place from Vuforia.

In Game mode using an attached webcam, the detection looks and works great, and the state manager correctly begins the animation. Cool.

Building for Android 7 proceeds without problem or console error. The app launches, but after target recco, only a small flickering portion of the model appears over the target... in fact, I assume it is the model, but it looks weird and meshy, as though it is cut off with straight edges.

Changing distance and angle with the phone camera does not change. Changing the scale of the object in Unity and recompiling does not change.

The behavior I am seeing does not occur if I replace my model with default cube. I also recalculated normals, and lowered the poly count: still no luck.

All input welcome.


texts: Make a glass cup look like it's full of water

texts: I've been struggling to figure out a way to make a glass cup full of water, and since the cup is made of glass a plane on the top of the glasse won't really do it, so how can i go around making the glass looks like it's full of water?


texts:
I'm having a hard time trying to describe this in correct terms so I will just give as much detail as possible and hopefully someone knows what I'm trying to do =-)

I am trying to compare two node trees to determine how similar/different they are structure-wise. In my diagrams below, both examples have the same number of children, grandchildren, etc. In example 1, Root has a child with two children, but in example two, root does not.

I could probably figure out how to recursively loop through and count how many of each level there are and compare that, giving me an idea of how similar the trees are, but only doing it that way, it will look like they are identical, but in fact they aren't.

Anyone happen to know about this? Or even what the technical term for what this is?

Edit: Also, this is in C# and I am using Lists to store these objects and their children.

Example 1

Example 2


texts:
I am building a game that uses client-server architecture and have the following question regarding server to client updates.

Currently the server is doing 60 ticks per second and is sending updates to the connected clients after every step, this means information about every entity that is in the world. Since my game is rather slow and rts based, a lot of the entities do not change state after every step and do not need to be updated. So to reduced server load I added an update queue. Only entities that require an update are added to this queue and it is executed after each step.

Looking at this approach I wonder if there are any significant disadvantages to it. One I could think of is that maybe as the time goes by and the game gets more complicated all the entities will need to be updated on every step anyway and that might be just a waste of time to implement.


texts: How do I make the turning of my character smooth?

texts:
I'm pretty sure I need to use the Quaternion.Lerp although I don't know how, my character already rotates but it's instantly, which is pretty unrealistic and not smooth. I'm extremely new with Unity (I just started 2 days ago), so I think asking here is a good idea since I will get help from people with experience:

private Rigidbody rb;

void Start()
{
    rb = GetComponent<Rigidbody>();
}

void Update()
{
    //Character Rotation
    {
        if (Input.GetKey(KeyCode.D))
            rb.transform.rotation = Quaternion.Euler(0, 90, 0);

        if (Input.GetKey(KeyCode.A))
            rb.transform.rotation = Quaternion.Euler(0, -90, 0);

        if (Input.GetKey(KeyCode.W))
            rb.transform.rotation = Quaternion.Euler(0, 0, 0);

        if (Input.GetKey(KeyCode.S))
            rb.transform.rotation = Quaternion.Euler(0, 180, 0);
    }
}


texts: How do I make a video preview of my Android game?

texts: I noticed some apps have a link to a Youtube video instead of a screenshot in Google's Android Play store.  How can I make a video of my Android game running on a physical device?  The emulator won't work for me (my game uses the camera preview feed). I guess I could take a video of the phone with another device, but that seems a little cheesy to me.


texts: Terrain does not show up in distance in play mode, but does in editor

texts:
I'm trying to make a big landscape with high mountains but the terrain doesn't show in the distance in play mode.
Which settings should I change, or what can I do?
My terrain is divided in many pieces - do I have to change all of these terrains or is there any other option?


texts: Recenter User Orientation on X and Y axis on with Oculus GO and Unity

texts:
I am working on an Oculus GO App for patients in a doctors chair. They'll be using Oculus GO Headsets while sitting, lying, or something in between. So what I am trying to do is to recenter the HMD orientation when the HMD is mounted. But since the patients position can be seated or lying horizontally, I will need to recenter the rotation on all three axis, or at least X and Y.

Unity provides:

UnityEngine.XR.InputTracking.Recenter();

But that will only recenter the Y Axis.

Oculus Integration provides:

OVRManager.display.RecenterPose();

But under the hood its just using the Unity InputTracking.Recenter() again.

So how can I recenter my whole scene or the player on y-axis as well?
If you go to Oculus GO main menue and push the recenter button on your controller, it does exactly what I want. However I can't find a way to do the same thing in my Unity application.

Thanks in advance!


texts: In practice, is it better to store Euler angles or store three vectors represent as "front/right/up"?

texts:
I'm writing a game engine, and when it comes to the transform part, I just use the representation which unity/ue uses, that is: a vector for the position, a vector for Euler angles, and a vector for scale.

But I found that in most cases, I need to deal with the axis of an object, it's much intuitively to use the three axes.

So in practice, is it better to store Euler angles or vectors for axis?

Let me give a example to explain myself:
Here's my transform class:

class Transform {
 public:
    glm::vec3 position_;
    glm::vec3 rotation_;
    glm::vec3 scale_;
}

And each time I want to "move it forward to xxx meters", I need to calculate a front vector, which is a local z axis of the object(I use the term 'local' which comes from blender, the local cooradinate, not sure I make myself clear), what I do is to rotate the (0,0,1) with the Euler angles, to get a vector, which is the "local" z axis of the object.

My question is that is it batter to use the data structure I pasted above, or use there vectors, represent for x,y,z axes for the object?


texts: Rendering order of shadowing point lights?

texts:
I'm implementing shadow mapping in my deferred rendering engine. I've got spot lights working, and now I'm working on point lights. Currently, I do it like this:

// Loop through the point lights
for each point light do

    Loop through "directions"
    for I = 1, 6 do
        Render the shadow map for direction 'I'
        Render the point light
    end
end

This works fine, but is this sub-optimal? Should I instead render all the shadow maps at once? If so, how would I handle all the shadow maps at once in the second phase when rendering the light volume?


texts: About to release a free game on Google Play Store, any legal considerations I should take into account?

texts:
I will release in the next few weeks a small free game on the Google Play Store. I was wondering if there was any important legal aspects I should consider before release.

Here's a few infos:

I'm doing this alone.
There's no code/graphic assets/gameplay concepts I would like to protect in particular. I don't have any issues with people copying something from my game.
I'm not sure right now, but maybe I'll add the possibility to make a small donation (so there will be IAP in a sense).
I'm using a music track from http://opengameart.org/. The author has specified that it wasn't necessary to credit him, though I would like to.


texts:
Inertia seems to be useful in a physics engine, so useful that even in Box2DLite, a demo of Box2D it hasn't been omitted.

See this Body class from Box2DLite:

struct Body
{
    Body();
    void Set(const Vec2& w, float m);

    void AddForce(const Vec2& f)
    {
        force += f;
    }

    Vec2 position;
    float rotation;

    Vec2 velocity;
    float angularVelocity;

    Vec2 force;
    float torque;

    Vec2 width;

    float friction;
    float mass, invMass;
    float I, invI; //inertia and reverse inertia
};

In the implementation of the class, inertia is set as the mass multipled by something:

I = mass * (width.x * width.x + width.y * width.y) / 12.0f;
invI = 1.0f / I;

What does this formula means ? I understood from wikipedia that Inertia is how much something doesn't want to move but there's not much formulas in this article. Why is it useful in a physics engine ? How is it used in the context of a collision ? Is it compared to other bodies ?


texts: Fastest way to render lines with AA, varying thickness in DirectX

texts:
So I'm doing some DirectX development, using SharpDX under .NET to be exact (but DirectX/C++ API solutions are applicable). I'm looking for the fastest way to render lines in an orthogonal projection (e.g. simulating 2D line drawing for scientific apps) using DirectX.

A screenshot of the sorts of plots I'm trying to render follows:

It's not uncommon for these sorts of plots to have lines with millions of segments, of variable thickness, with or without antialiasing per-line (or full screen AA on/off). I need to update the vertices for the lines very frequently (e.g. 20 times/second) and offload as much to the GPU as possible.

So far I have tried:

Software rendering, e.g. GDI+ actually not bad performance but obviously is heavy on the CPU
Direct2D API - slower than GDI, especially with Antialiasing on
Direct3D10 using this method to emulate AA using vertex colours and tessellation on the CPU side. Also slow (I profiled it and 80% of time is spent computing vertex positions)

For the 3rd method I'm using Vertex Buffers to send a triangle strip to the GPU and updating every 200ms with new vertices. I'm getting a refresh rate of around 5FPS for 100,000 line segments. I need millions ideally!

Now I'm thinking that the fastest way would be to do the tessellation on the GPU, e.g. in a Geometry Shader. I could send the vertices as a line-list or pack in a texture and unpack in a Geometry Shader to create the quads. Or, just send raw points to a pixel shader and implement Bresenham Line drawing entirely in a pixel shader. My HLSL is rusty,  shader model 2 from 2006 so I don't know about the crazy stuff modern GPUs can do.

So the question is:
 - has anyone done this before, and do you have any suggestions to try?
 - Do you have any suggestions to improve performance with rapidly updating geometry (e.g. new vertex list every 20ms)?

UPDATE 21st Jan

I have since implemented method (3) above using Geometry shaders using LineStrip and Dynamic Vertex Buffers. Now I'm getting 100FPS at 100k points and 10FPS at 1,000,000 points. This is a huge improvement but now I'm fill-rate and compute limited, so I got thinking about other techniques/ideas.

What about Hardware Instancing of a Line Segment geometry?
What about Sprite Batch?
What about other (Pixel shader) oriented methods?
Can I efficiently cull on the GPU or CPU?

Your comments & suggestions much appreciated!


texts: As a fairly unknown independent band, what is the best way to get our music into computer games? I'm not so much thinking about licensing issues, but more about what channels are available and how to get noticed by game devs that could be interested in our type of music.


texts: How to increase the speed of a projectile?

texts:
I am working on a project where I am launching a projectile and according to the following snippet:

 // launches the object towards the TargetObject with a given LaunchAngle
    void Launch()
    {
        // think of it as top-down view of vectors:
        //   we don't care about the y-component(height) of the initial and target position.
        Vector3 projectileXZPos = new Vector3(transform.position.x, 0.0f, transform.position.z);
        Vector3 targetXZPos = new Vector3(TargetObjectTF.position.x, 0.0f, TargetObjectTF.position.z);

        // rotate the object to face the target
        transform.LookAt(targetXZPos);

        // shorthands for the formula
        float R = Vector3.Distance(projectileXZPos, targetXZPos);
        float G = Physics.gravity.y;
        float tanAlpha = Mathf.Tan(LaunchAngle * Mathf.Deg2Rad);
        float H = (TargetObjectTF.position.y + GetPlatformOffset()) - transform.position.y;

        // calculate the local space components of the velocity
        // required to land the projectile on the target object
        float Vz = Mathf.Sqrt(G * R * R / (2.0f * (H - R * tanAlpha)) );
        float Vy = tanAlpha * Vz;

        // create the velocity vector in local space and get it in global space
        Vector3 localVelocity = new Vector3(0f, Vy, Vz);
        Vector3 globalVelocity = transform.TransformDirection(localVelocity);

        // launch the object by setting its initial velocity and flipping its state
        rigid.velocity = globalVelocity;
        bTargetReady = false;
}

Everything seems to work perfectly except:

1- Whenever I increase the velocity it gets beyond the target.

2- Whenever I decrease the velocity it does not reach the target.

So how am I able to increase the speed and reach the exact target?


texts: Unity, check if all GameObject tagged are destroyed

texts:
Hello im a total noob so please dont blame me.
So, I have this code but I cant find a fitting answer on how to check if everything tagged "Target1" is destroyed. Most of the answers are either overcomplicated or ,and most certainly, im too stupid

public Transform teleportTarget;
public GameObject thePlayer;
public Transform[] spawnLocations;
public GameObject[] whatToSpawnPrefab;
public GameObject[] whatToSpawnClone;

void spawnTargets()
{
    whatToSpawnClone[0] = Instantiate(whatToSpawnPrefab[0], spawnLocations[0].transform.position, Quaternion.Euler(0, 180, 0)) as GameObject;
    whatToSpawnClone[1] = Instantiate(whatToSpawnPrefab[1], spawnLocations[1].transform.position, Quaternion.Euler(0, 180, 0)) as GameObject;
    whatToSpawnClone[2] = Instantiate(whatToSpawnPrefab[2], spawnLocations[2].transform.position, Quaternion.Euler(0, 180, 0)) as GameObject;
    whatToSpawnClone[3] = Instantiate(whatToSpawnPrefab[3], spawnLocations[3].transform.position, Quaternion.Euler(0, 180, 0)) as GameObject;
}

private void TeleportPlayer()
{
    thePlayer.transform.position = teleportTarget.transform.position;
}

Im just looking for a way to check if all GameObjects Tagged "Target1" (in the whole game)
are destroyed and then to spawnTargets and TeleportPlayer.
Previously I had the bug, that when they respawned it wasnt checking anymore. It has to check all the time.Because else I get stuck, because teleport teleports me all the time. I hope you understand what I mean

I know this is a easy question but im a noob and im sorry for wasting your time, still I hope you can help me.


texts: What is a simple algorithm for calculating evenly distributed points on an ellipse?

texts:
I am looking for a simple algorithm to plot evenly distributed points on an ellipse, given the major and minor axes. This is really easy to do with a circle like so:

var numberOfPoints = 8;
var angleIncrement = 360 / numberOfPoints;
var circleRadius = 100;
for (var i = 0; i < numberOfPoints; i++) {
    var p = new Point();
    p.x = (circleRadius * Math.cos((angleIncrement * i) * (Math.PI / 180)));
    p.y = (circleRadius * Math.sin((angleIncrement * i) * (Math.PI / 180)));
}

(which creates points that are the same distance apart from their neighboring points) but I can't find or figure out a way to do this on an ellipse. (Solutions in AS3 preferred, but not required.)


texts: How to not-unroll loops in Shader Model 3 HLSL

texts:
I'm working on raycaster in HLSL, unfortunately it have to be in DX9. But it cannot be compiled

I did similar raycaster in DX11 and i know that there is always problem with FXC compiler that it tries to unroll loops, this problem can be solved in DX11 by [loop] command before loop, which tells to compile to not unroll loops. Can i do something similar in DX9? I'm using february 2010 compiler.

My loop is not doing any divergent flow control stuff. And i would like to have it to be able to do early out.


texts: How can I properly display the distance with the unit in a string on the UI?

texts:
I wrote a script for distance of car and I don`t know how to make distance like this Distance: 156Km. I wrote this code:

distanceText.text = ((int)distance).ToString() + "Km";

It works only from 1 to 9; when it goes to 10 Km, it disappears but if I write it like this:

distanceText.text = ((int)distance).ToString() + " Km";

It show like this: from 1 to 9 -> "5 Km" and from 10 to 99 -> "99Km" but when it goes to 100 Km and above, it disappears. What code should I write for this to show always Km after the distance.

And I have one more question. I have a gameover canvas and I'd like in gameover canvas to show the final distance I make with PlayerPrefs but it doesn't work.

Here it shows how it does not work:


texts:
I want to create a custom level editor for the level designers that should allow them to place predefined objects in Unity3d similar to the Terrain wizard.

How can I register Mouse Events in the Scene window of the Editor?


texts: In my game, I want to have it so that if a chess piece tries to move farther away than a certain distance it won't work. To do this, I need it to have an if statement that works between two numbers, but I can only seem to do above or below a number, not between. Is there a way to do this, or am I going to have to use to if statements?


texts:
How can I draw background tile in my 2D side-scrolling game? Is that loop logical for OpenGL es? My tile 2400x480. Also I want to use parallax scrolling for my game.

batcher.beginBatch(Assets.background);
for(int i=0; i<100; i++)
    batcher.drawSprite(0+2400*i, 240, 2400, 480, Assets.backgroundRegion);

batcher.endBatch();

UPDATE

And thats my onDrawFrame.I'm sending deltaTime for fps control.

public void onDrawFrame(GL10 gl) {
    GLGameState state = null;

    synchronized(stateChanged) {
        state = this.state;
    }

    if(state == GLGameState.Running) {
        float deltaTime = (System.nanoTime()-startTime) / 1000000000.0f;
        startTime = System.nanoTime();

        screen.update(deltaTime);
        screen.present(deltaTime);
    }

    if(state == GLGameState.Paused) {
        screen.pause();
        synchronized(stateChanged) {
            this.state = GLGameState.Idle;
            stateChanged.notifyAll();
        }
    }

    if(state == GLGameState.Finished) {
        screen.pause();
        screen.dispose();
        synchronized(stateChanged) {
            this.state = GLGameState.Idle;
            stateChanged.notifyAll();
        }
    }
}


texts: DirectXTK: Only SpriteBatch::Begin and Draw methods give LNK2019: unresolved external

texts:
I'm using DirectXTK Desktop 2017 with Visual Studio 2017 and SpriteBatch::Begin() and SpriteBatch::Draw() give an LNK2019 unresolved external error (but not SpriteBatch::End() or SpriteBatch::GetRotation()). Since I am able to call these functions as well as use WICTextureLoader to load a texture, I believe the include and library paths are all fine, but something might have gone wrong in the .lib compilation of the DirectXTK.

Anyone know what this might be due to? Thanks in advance.


texts: Why the spotlight is working only in scene view window but not in game view?

texts:
What i did is disabled in the Hierarchy the Directional Light.
The Spotlight is child of the character so it will move with it.

Then in Window > Lighting > Settings

In the Spotlight i just changed the range and rotation a bit.
It's strange since it's showing the light in the scene view but not in the game view not even when running the game.

And this is the Spotlight config:


texts:
I'm working on a menu that needs a wordy description, but I've noticed that it only shows 4 letters, then cuts off and this doesn't seem right.

I right click, select UI > text and again, it only displays 4 words, even though I can write a lot more there. Am I doing something wrong here?

I'm not sure how to get past this and I want to ask if anyone knows how to get past this? It seems like such a strange limit to put on the UI canvas.


texts:
In my tile-based game, I'm using a A-star algorithm, which I have not written myself but I believe should be correctly implemented.

The problem I have is that the enemy AI can get stuck so that the enemy never gets any closer to the player.

Here's an ascii example of what I mean (x = enemy, p = player, . = ground):

....
x..p
....
....

Now, if I move the player down and process turn (which moves the enemy), the pathfinder finds the the next tile to be at south... and if I move the player up again, the pathfinder finds the next tile to be at north... so the enemy never gets any closer to the player (unless there are some obstacles, or I am closer to the enemy).

I feel stupid not to be able to figure this out on my own (at least in a nice way), but here we are. Is this a common problem, or am I doing something stupid?


texts: Unity: Assigning a key to perform an action in the inspector

texts:
I am trying to write a simple piece of code in JavaScript where a button toggles the activation of a shield, by dragging a prefab with Resources.load("ActivateShieldPreFab") and destroying it again (Haven't implemented that yet).

I wish to assign this button through the inspector, so I have created a string variable which appears as intended in the inspector. Though it doesn't seem to register the inspector input, even though I changed the value through the inspector.

  It only provides the error: "Input Key named: is unknown" When the
  button name is assigned within the code, there is no issues.

Code as follows:

var ShieldOn = false;
var stringbutton : String;

function Start(){
}

function Update () {
    if(Input.GetKey(stringbutton) && ShieldOn != true)
    {
        Instantiate(Resources.load("ActivateShieldPreFab"), Vector3 (0, 0, 0), Quaternion.identity);
        ShieldOn = true;
    }
}


texts:
I currently have this code, which moves an object in a straight line at an angle, where "dir" is the angle.

velX = (float)(Math.cos(Math.toRadians(dir))) * speed;

velY = (float)(Math.sin(Math.toRadians(dir))) * speed;

x += velX;

y += velY;

What I need now is to have the object move like a sine wave, do I have to change the way I calculate velX and velY or is there some way of changing dir that would make it work?

I tried this but it didn't work, my objects would just got bunched up near 0, 0.
Move a sprite in a sine wave along different angles


texts: Cannot draw around the screen after zooming out with LibGDX projection coordinate

texts:
I've just started developing game in android using LibGDX.
I've follow some samples and now my simple game can draw path when user move their finger around the screen.

now problems appear when i add another feature to allow user to pinch zoom in and out.
after zooming OUT the orthographic camera user can still draw the path BUT
the path can no longer follow user finger to the edge of the screen, the user can only draw the path around the center of the screen. looks like the coordinate projection after zoom out not changed and still limited to the projection before zoom out!

how can i make my game to keep drawing line around the entire screen even after the user have zooming out the camera?

here's my code:

   1. in my Screen implemented class:

@Override
public void render(float arg0) {
    Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    renderer.render();
}

@Override
    public boolean touchDragged(int screenX, int screenY, int pointer) {
        // TODO Auto-generated method stub
        isDrawing = true;

        Vector2 v = new Vector2(screenX, Gdx.graphics.getHeight()-screenY);

        //add new point for drawing path
        inputPoints.insert(v);

        return true;
    }

   2. in my Renderer class:

cam = new OrthographicCamera();
    cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    this.cam.update();

public void setZoom(float zoom) {
     this.cam.zoom = zoom;
     this.cam.update();
 }

//the triangle strip renderer
    path = new PathClass();

public void render() {
    cam.update();
    batch.setProjectionMatrix(cam.combined);

    //generate the triangle strip from our path
    Array<Vector2> xox = screen.path();
    path.update(xox);

    //the vertex color for tinting, i.e. for opacity
    path.color = Color.WHITE;

    //render the triangles to the screen
    path.draw(cam);
}

   3. on my PathClass:

public void draw(Camera cam) {
    if (tristrip.size<=0)
        return;

    gl20.begin(cam.combined, GL20.GL_TRIANGLE_STRIP);
    for (int i=0; i<tristrip.size; i++) {
        if (i==batchSize) {
            gl20.end();
            gl20.begin(cam.combined, GL20.GL_TRIANGLE_STRIP);
        }
        Vector2 point = tristrip.get(i);
        gl20.color(color.r, color.g, color.b, color.a);
        gl20.vertex(point.x, point.y, 0f);
    }
    gl20.end();
}


texts: Libgdx clicklistener of Image Actor not recognising click

texts:
So I am attempting to make a an image of a closed door for a ship. On clicking this door, it would then change to an open door. However, I am struggling to get the click listener to work for the Image. Weirdly, if i use a textbutton instead it works, with pretty much the same code. Below is the class in which a stage is created and the Image actor added to it.

    public class battleScreenActorOverlay implements Disposable {

public battleScreenActorOverlay(World world, SpriteBatch sb, battleShipScreen syst, float bottomButsH, float viewportWidth, float viewportHeight, List<Float> testDoor) {

    viewport = new ExtendViewport(viewportWidth,viewportHeight, new OrthographicCamera());
    stage = new Stage(viewport, sb);
    Gdx.input.setInputProcessor(stage);
    shipObjsAt = new TextureAtlas("batScreen/objects/shipObjects.atlas");
    Skin skin2 = new Skin(shipObjsAt);

    Image img = new Image(skin2.getDrawable("doorV"));
    img.setTouchable(Touchable.enabled);
    img.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            System.out.println("clicked");
        }
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("touch down");
            return true;
        }
        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("touch up");
        }
    });

    // set Image position and dimensions, then boundaries
    img.setPosition(testDoor.get(2),testDoor.get(3));
    img.setSize(testDoor.get(1)*6, testDoor.get(0)*6);
    System.out.println("gabriel "+img.getX()+" "+img.getY()+" "+img.getWidth()+" "+img.getHeight());
    img.setBounds(img.getX(),img.getY(),img.getWidth(),img.getHeight());

    // add to stage which is then rendered in main class
    stage.addActor(img);
    stage.act();
}

Then the main class basically does some stuff like this:

public class battleShipScreen implements Screen {

// a load of variable declarations here

public battleShipScreen(MyGdxGame game){

    // create viewport etc

    genShip();

}

public void genShip(){
    // basically method for setting door positions
    batScreenActs = new battleScreenActorOverlay(world,game.batch,this,margin,gameport.getWorldWidth(),gameport.getWorldHeight(),testDoor); // calls class which creates stage and adds door

}

@Override
public void show() {

}

public void update(float dt){
    world.step(1/60f,6,2);
    handleInput(dt);
    gamecam.update();
    renderer.setView(gamecam);

}

public void handleInput(float dt) {
 // classic handle input
}

@Override
public void render(float delta) {

    update(delta);
    Gdx.gl.glClearColor((float) 60/255, (float) 181/255, (float) 0/255, (float) 0);    // clears screen
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);                       // clears screen
    // render game map
    renderer.render();
    game.batch.setProjectionMatrix(gamecam.combined);

    game.batch.setProjectionMatrix(batScreenHUD.stage.getCamera().combined);

   game.batch.setProjectionMatrix(batScreenActs.stage.getCamera().combined);
    batScreenActs.stage.act(Gdx.graphics.getDeltaTime());
    batScreenActs.stage.draw();
}

@Override
public void resize(int width, int height) {
    System.out.println("resizing "+height+" by "+width);
    gameport.update(width,height);
    gamecam.update();
}

@Override
public void pause() {

}

@Override
public void resume() {

}

@Override
public void hide() {

}

@Override
public void dispose() {

}

Sorry for the long post, but I have been trying to sort this out for a few days now and have literally no idea what i am doing wrong. Any help working out how to make an Image actor click listener work would be much appreciated!


texts:
I am making a multiplayer game in Java that uses a client-server model, where all important decisions are made by the server and communicated to all clients over UDP. Currently the clients and the server both send packets at 30fps. The clients just send a single packet each time, but for the server the situation is a little more complicated.

The server needs to update the client on the positions of all Entities in the game, of which there could be many (100+) at any given time. Currently each of these updates is being sent in a separate packet.

It seems to me that combining some of these updates into a single packet could be beneficial, as it would reduce the overhead of creating and sending all these packets. But combining too many updates would create a packet that is "too large" to be sent efficiently across the network.

Where does the balance lie between packet size and the number of packets being sent, in order to achieve the fastest and most reliably delivery?


texts: Lua script for World of Warcraft: Get Quest Info

texts:
I'm looking to make a very simple addon or even a macro where I can enter a quest ID and get the quest completion status.  As it is, I know I can use IsQuestFlaggedCompleted to get the quest status, but I wanted to also get the name of the quest so the return in the chat log will show something a little more understandable.
For example:
Enter /questDone 43502
instead of just 43502: true as the output, I want it to look like A Change of Seasons: Quest Completed.

I see a function C_TaskQuest.GetQuestInfoByQuestID that's supposed to return the quest's title, but it doesn't seem to work as expected.  It always seems to return nil for the quest name...


texts:
I know that this question depends really very much on plenty factors: 2D-Pong and a MMORPG are two totally different worlds; it also depends on creators' experience, on game quality, on the available technologies, on target platform and so on, but well, I guess we can categorize games and study the average (or maybe focus on real-world examples).

How long, in man-hour, does it take on average to create a:

AAA MMORPG
AAA non-MMO game (like a RTS, an FPS etc, RPG)
Indie game
Game for mobiles
Amateur desktop game

What phases can we split the game creation process in (story designing, writing the engine, creating art, testing ...) and how long would each of these take (for the above categories)?

Examples of real games would be apprecciated!


texts: Hex axial coordinates to table coordinates conversion

texts:
I am developing a browser game based on a hex map. I am storing my data based on axial coordinates system.

I developed a function which shows me axial coordinates of hexes within $distance from a given hex. Now I want to show those hexes in a form in a HTML table.

The data that I have is only axial coordinates of center hex as well a list of axial coordinates of hexes within distance (not sorted in any way)

As shown in the transition scheme below, hexes may always be shown in form of a simple HTML table:

But I am struggling at how to get each of the map hexes shown in a correct table field (row/column) of the table, assuming that table numbering looks like this:

To solve this out it seems to me that in first instance I need to determine the size of the HTML table that I need. If I will be able to determine what is table coordinate of center of the HTML table then I would be able to find out localisation of each hex in reference to the center hex.

In case of $distance = 1 I need 3 columns and 3 rows:

In case of $distance = 2 I need 5 columns and 5 rows:

This leads me to the conclusion that my required HTLM table size is:

$distance *2 + 1

The center hex lies in the middle of the table, so its coordinates are:

($distance *2 + 2) /2

But what is next, how to convert axial coordinates to table coordinates?


texts:
I have made a struct which sets 4 variables that define a rect

void setDestSize(int width, int height)
        {
           Width = width;
           Height = height;
        }
        void setSrcRect(int x, int y, int width, int height)
        {
           SrcX = x;
           SrcY = y;
           SrcWidth = width;
           SrcHeight = height;
        }

and I have a class that uses CSprite and it draws an Image. In my Render function it has
if (Visible)
    {
        Transform.SetIdentity();

    // Build transform
    Transform.SetRot(Angle);
    Transform.ScaleRot(Scale);
    Transform.SetTrans(Position);
    Iw2DSetTransformMatrix(Transform);
    Iw2DSetColour(Colour);
    // Render image
    if (ShipBullet != 0)
        Iw2DDrawImage(ShipBullet, CIwFVec2(Position.x, Position.y));

    boundingRect.srcX = Position.x;
    boundingRect.SrcY = Position.y;

    Iw2DSetColour(0xff0000ff); // Set red
    Iw2DDrawRect(CIwFVec2(boundingRect.srcX, boundingRect.SrcY),
        CIwFVec2(boundingRect.Width, boundingRect.Height));

When I draw that rect, It's drawn somewhere else, and its not bounded on the sprite..


texts: How can I exit an Unreal game with a specific exit code?

texts:
How could I quit out of a Unreal game with a specific exit code? In Unity you can just Application.Quit(exitCode); but I could not find anything regarding Unreal.

I know you can use the QuitGame-node or FGenericPlatformMisc::RequestExit(false); in C++ but without the custom exit code that I am looking for.

Any ideas?


texts: How to setup Steam VR Controller models and behavior in Unreal Engine?

texts:
I want to preface this question by stating I am somewhat new to Unreal Engine. I googled for a solution to this, but no avail.

So I am setting up a bit of a sand box project in Unreal Engine to get a feel for VR development using the HTC Vive. The first thing I wanted to do was emulate the behavior of the motion controllers in the default Vive Screen. Basically, a 1:1 model of the controller appears inside the game space. It moves with the controller as you spin, point, twist and move the controller in real time. All the buttons respond in game when they are pressed in real life.

The solution I have hit on is to grab the raw model asset from /SteamApps/common/SteamVR/renderresource/ and manually line it up with the model ( by default the model is tiny, oriented wrong, and offset from the controller), and build individual events for each of the button that manipulates the models of the buttons in game. This seems kinda clunky and I was curious if there was a better way of doing this.


texts: Is there a place in games for people with financial engineering or operations research backgrounds?

texts:
I just started my first year in college in an engineering school. I haven't had any classes about programming, and although I'm in an engineering school I'm not that good at (and don't enjoy) physics or chemistry. For me, the way to go is math related majors, which are Financial Engineering or Operations Research.

Although I believe I will be somewhat good in those areas I definitely don't want to get sucked into the "financial blackhole" with extreme work hours and stress levels. I want to have creativity in my life.

So I am wondering what kind of jobs can I find in the gaming industry with a background of Financial Engineering or Operations Research? Can I join the creative groups of game development companies?


texts:
Unreal Development Kit for iOS was recently released. The system requirements note that Windows is needed. Does this mean that iOS game development is possible on a PC now?

I am confused since I thought iOS development required an OSX machine.

Thanks in advance.


texts:
I'm trying to create an application using the Kinect to simulate the following project:

Kinect Hand Tracking

I want my project to have similar usability with the Kinect tracking hand and finger positions for use in a menu system, or to navigate another system.

What I would like to know is; is it possible for the exact same to be accomplished in XNA using Kinect?

I know that it can be done in Winform / C#, but I know XNA / C# a lot better and would (ideally) prefer to use that.


texts: Rendering Textured Terrain With SharpDX Toolkit

texts:
So i recently moved from XNA to SharpDX Toolkit and started with some basics. The 2d part was easy since nearly nothing has changed but im really struggeling with the 3d part. For example i wanted to render a heightmap based on riemers terrain tutorial however came along the following issue:

I have a little map (or terrain) class that contains the index and vertex arrays as buffer like so:

private SharpDX.Toolkit.Graphics.Buffer<VertexPositionNormalTexture> _mesh;
private SharpDX.Toolkit.Graphics.Buffer _indexBuffer;
private readonly static VertexInputLayout InputLayout = VertexInputLayout.New<VertexPositionNormalTexture>(0); // copied from the basic geometry

this get filled in propertly and render fine with VertexPositionColor.
rendered the common XNA way:

//set effect parameters and resources
foreach (EffectPass pass in _effect.CurrentTechnique.Passes) {
    pass.Apply();

    //Globals.DefaultGraphicsDevice.SetRasterizerState(CullNone);

    Globals.DefaultGraphicsDevice.SetVertexBuffer(0, _mesh);

    // Setup the Vertex Buffer Input layout
    Globals.DefaultGraphicsDevice.SetVertexInputLayout(InputLayout);

    // Setup the index Buffer
    Globals.DefaultGraphicsDevice.SetIndexBuffer(_indexBuffer, true);

    // Finally Draw this mesh
    Globals.DefaultGraphicsDevice.DrawIndexed(PrimitiveType.TriangleList, _indexBuffer.ElementCount);
}

Now with my own half converted half remade shader i get

a) a black terrain or

b) HRESULT: [0x80070057] (wrong parameter)

and i cant figure out why (most likely since i never done much with 3d shaders)

the shader:

struct VertexShaderInput {
    float4 Position     : SV_Position;
    float3 Normal       : NORMAL;
    float2 TextureCoords: TEXCOORD0;
};

struct VertexShaderOutput {
    float4 Position     : SV_Position;
    //float4 VPosition      : SV_Position; //im not used to SV_Position and SV_Target so this could be the main problem
    float LightingFactor: TEXCOORD0;
    float2 TextureCoords: TEXCOORD1;
};

struct PixelShaderOutput {
    float4 Color        : SV_Target;
};

//------- Constants --------
float4x4 xView;
float4x4 xProjection;
float4x4 xWorld;
float3 xLightDirection;
float xAmbient;

Texture2D xTexture;
sampler TextureSampler = sampler_state {
    texture = <xTexture>;
    magfilter = LINEAR;
    minfilter = LINEAR;
    mipfilter = LINEAR;
    AddressU = mirror;
    AddressV = mirror;
};

VertexShaderOutput TexturedVS(VertexShaderInput VSin) {
    VertexShaderOutput Output = (VertexShaderOutput)0;
    float4x4 preViewProjection = mul(xView, xProjection);
    float4x4 preWorldViewProjection = mul(xWorld, preViewProjection);

    Output.Position = mul(VSin.Position, preWorldViewProjection);
    Output.TextureCoords = VSin.TextureCoords;

    float3 Normal = normalize(mul(normalize(VSin.Normal), xWorld));
    Output.LightingFactor = dot(Normal, -xLightDirection);

    return Output;
}

PixelShaderOutput TexturedPS(VertexShaderOutput PSIn) {
    PixelShaderOutput Output = (PixelShaderOutput)0;

    Output.Color = xTexture.Sample(TextureSampler, PSIn.TextureCoords);
    Output.Color.rgb *= saturate(PSIn.LightingFactor) + xAmbient;

    return Output;
}

technique Textured {
    pass p0 {
        Profile = 9.1;
        AlphaBlendEnable = false;
        CullMode = None;
        PixelShader = TexturedPS;
        VertexShader = TexturedVS;
    }
}

im thankfull for any help

(Disclaimer: i moved this from stackoverflow to here since i think it was missplaced and didn't got any attention)


texts: How to get the SteamID of the currently active user from the filesystem or shell? (Windows)

texts:
Can anyone tell if it's possible to programmatically read the SteamID of the currently logged on user on Windows? Either from the filesystem or through cmd / powershell?

Context: I'm looking to make a mod for a Steam game and it's going to exchange some data with a 3rd party server. But I'll need a way to reliably tell the users SteamID for authentication and resource assignment purposes. With the scripting engine of the game I can read files from the filesystem, make http requests or run other binaries like cmd, but that's about it. The Steam SDK/API functions are not exposed.

Currently I'm reading the "LastOwner" property of the appmanifest vcf file that is created with every game in the steamapps folder. However, that one is just the ID of the user that installed the game, which is not necessarily the ID of the active user.


texts:
I am wondering what is the best way to position rectangles, the ways I have thought of are:

Have an x and y at upper left, then have a width and height
Have an x and y at upper left, and an x and y at lower right
Have an x and y at center, and have width and height ("radii" of the rectangle)

I guess that the third way might make the most sense since it's the closest to how I would do a circle (position and radius) but I do not know if it is the best way to do it.

I would prefer to stay away from the second way, as I would want only one part for position

Is there a preferred way to do this?


texts: In Unity - Move a GameObject at Animator State

texts: I want to move one of my GameObject to a different vector 3 position, when animator transit to a new state. How do I do it? Also there shouldn't be any delay.


texts: How to play the sound of an object sliding on another object for a variable duration

texts:
I would like to add sound effects to a basic 2D game. For example, a stone sphere is rolling on wood surface. Let's say I have a 2 second audio recording of this. How could I use the sample to add sound for an arbitrary duration ?

So far I have two solutions in mind:

a/ record the sound for an amount of time that is greater than the maximum expected duration, and play only a part of it;

b/ extract a small portion of the sample and play it in a loop for the duration of the move; however I'm not sure if it makes sense with an audio wave.


texts:
I found a cool kickstarter project called "Skywanders".
It's an minecraft like space game with a lego like building system and pretty cool graphics.

One thing I noticed are the "nebula clouds". They are procedurally generated 3D Objects and they look amazing.

How do I generate such nebulas? I bet there's a way to do that. And is it possible to convert a 2D nebula into a 3D one? I didn't found any algorithm yet or other sources.