Flight Sim Project Update

Just a quick update on the progress of my flight sim hobby project. After my work on autopilots I thought it would be fun to expand on it with other systems and see what’s involved in making a flight simulator.

First I improved the visuals slightly from a “blocky” plane to a low-poly plane, added particle effects and aircraft navigation lights.

Next I changed the render pipeline in Unity to the high-definition render pipeline (HDRP) and started to improve the aircraft models.

Next was collosion-detection. Whilst the body was quite easy the wheel collider documentation in Unity left much to be desired. With the colliders in place I needed to ensure that the wheels and struts moved realisticly when the invisible colliders did.

I added animation for the exhaust vents and turbofan, particle systems for the flame, navigation lights, altitude autopilot from before. I must say I’m pleased with how it turned out.

Daytime test:

Nighttime test:

Censorship on Planetary Annihilation Steam Forums?

Planetary Annihilation (PA) from Uber Entertainment (UE) is an Early Access title on Steam currently available for purchase for $59.99 USD.  Early Access means that one can buy the game now even though it is not finished with the notion that one is supporting the devs in their endeavours.   In other words the title is pre-alpha.  This can be a good or bad thing and for the complete run-down I recommend listening to TotalBiscuit’s discussion on Early Access.

I’ve been looking over the PA forums hosted on Steam trying to become a little more informed about this interesting title; a title which was tempting me to open my wallet and let the moths fly free. Sadly I was only to discover a disturbing pattern of arguably fascist censorship by the powers that be of anything negative that people have said or even requesting features that are not aligned with the current agenda[4]. Most authors are expressing their concerns over the price of the title [1] [2] [3].

Now I’ve not encountered anything like this since perusing Bohemia Interactive forums – specifically ARMA xx or Carrier Command Gaia Mission where many a poor chap would be banned; or a thread locked should one sneeze or forget to pay homage to the sacrificial guinea pig.

One thread on Steam got locked for asking for a OS compatibility feature. Did I mention there were only five (5) posts in the thread. [4] So much for an open discussion.

Steam Green Light clearly states:

image

Uber Entertainment states on the Steam Early Access Game notice:

image

It seems the benefits of an Uber Entertainment (UE) Early Access relationship are clearly one-way and quite arrogant at that; at least that is the perception established by the UE Steam moderators. The suppression of any negative discussions only serves to raise suspicion. It is quite possible that the UE moderators on Steam are not on the same level of professionalism as UE proper; if so UE could perhaps consider reiterating company policy with all those that represent it.

I for one shall take no part in the Early Access. I think I shall wait patiently for the game’s release where upon I hope to buy should the title prove worthy.

I wish them the best of success until then.

[1] “Came back to check on this old game. Lmao @ the price again.”, http://steamcommunity.com/app/233250/discussions/0/648817378131765891/

[2] “to much money”, http://steamcommunity.com/app/233250/discussions/0/648817378087864723/

[3] “I just bought PA and I feel cheated”, http://steamcommunity.com/app/233250/discussions/0/648814844869954342/

[4] “I will buy it if developers add Windows XP compatability”, http://steamcommunity.com/app/233250/discussions/0/648816742617053191/

[5] “The Minecraft Beta was $5….”, http://steamcommunity.com/app/233250/discussions/0/648814845030059149/

Heightmaps and Force Fields

Work is proceeding on my space war game (SWG); it would be nice if I came up with a proper name for it but for now SWG shall suffice.  For the past couple of weeks I’ve been looking into missile mechanics and shield simulation.  For the missiles I simulate fuel load and consumption, albeit crudely, such that the missile has a limited flight time before tumbling into a fit of self-destructing acrobatics accompanied by a flash of yellow sparkles.

A work buddy suggested that I tackle force fields next and he had the good idea to use a ripple effect – the same sort of ripple effect you get when you drop a badger into a lake.  There is a very simple algorithm[1] that you can use to produce a variable heightmap for use in a water effect and thought this would be suitable for deforming my shields.

private void Start()
{
var mesh = new Mesh();
_heightMap1 = new float[Width,Height];
_heightMap2 = new float[Width,Height];
_buffer2 = _heightMap1;
_buffer1 = _heightMap2;
NumberOfVertices = Width*Height;
var vertices = new Vector3[NumberOfVertices];
var uvs = new Vector2[vertices.Length];
for (var y = 0; y < Height; y++)
{
for (var x = 0; x < Width; x++)
{
_heightMap1[x, y] = 0;
_heightMap2[x, y] = 0;
var p = new Vector3(Mathf.Lerp(-.5f, .5f, (float) x/Width),
Mathf.Lerp(-.5f, .5f, (float) y/Height),
0);
vertices[y*Width + x] = p;
uvs[y*Width + x] = new Vector2(p.x, p.y);
}
}
mesh.vertices = vertices;
mesh.uv = uvs;
var triangles = new List<int>();
var i = Width;
for (var y = 1; y < Height; y++)
{
for (var x = 0; x < Width - 1; x++)
{
triangles.Add(i + x);
triangles.Add(i + x - Width + 1);
triangles.Add(i + x - Width);
triangles.Add(i + x);
triangles.Add(i + x + 1);
triangles.Add(i + x + 1 - Width);
}
i += Width;
}
mesh.triangles = triangles.ToArray();
_buffer1[Width/2, Height/2] = 1;
var filter = GetComponent<MeshFilter>();
filter.mesh = mesh;
}

The Update method is called once per frame to update the simulation:

// Update is called once per frame
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
Punch(Width/2,Height/2, PunchStrength);
}
var mesh = GetComponent<MeshFilter>().mesh;
var vertices = mesh.vertices;
for (var x = 1; x < Width - 1; x++)
{
for (var y = 1; y < Height - 1; y++)
{
_buffer2[x, y] =
((_buffer1[x - 1, y] +
_buffer1[x + 1, y] +
_buffer1[x, y - 1] +
_buffer1[x, y + 1])/2) - _buffer2[x, y];
_buffer2[x, y] = _buffer2[x, y]*Damping;
}
}
var i = 0;
for (var y = 0; y < Height; y++)
{
for (var x = 0; x < Width; x++)
{
vertices[i++].z = _buffer2[x, y];
}
}
var t = _buffer1;
_buffer1 = _buffer2;
_buffer2 = t;
if (_buffer2 == _buffer1)
{
throw new ApplicationException("Heightmaps should not be the same");
}
mesh.vertices = vertices;
mesh.RecalculateNormals();
}

Here’s some shots of the ripple effect:

image

image

…and corresponding textured-mesh view:

image

Then of course I went to apply it to an ellipsoid and I was sort of stumped as to how to deformate a 3D object – something with no edges no less.  Realising I was a bit of a buffoon, the obvious answer was not to procedurally modify the mesh via a heightmap but rather use the heightmap as an input into a parallax shader where we can fiddle with the surface normals thus giving the illusion of heightened depth.  So I kept my code above for creating the heightmap but I just tossed the mesh modification.

I wanted my shader to be transparent so the alpha component is merely the heightmap value.

image

Here is a short video of the outcome.

———————————–
[1] “2D Water”, http://freespace.virgin.net/hugo.elias/graphics/x_water.htm

Autonomous Steering Update for Space Simulator

I recently added a behaviour for steering the ship towards a target destination; thrusting up to cruise speed; followed by a final deceleration step.  With a given velocity and breaking deceleration it’s reasonably easy to work at what point to start breaking.  This makes it nice to enter a point in orbit around a planet or perhaps a space station.

Next will be to work out an actual orbit based on either a given velocity or how far the orbit should be.  Fun days ahead!

Other updates include:

Though floating origin works rather well, the next problem is to scale the planets based on how far away they are.  “float”s don’t have the precision to otherwise model ranges of the distance from say the Sun to Jupiter and then to model Jupiter’s diameter.  It seems the solution is to treat things as continuous sub-scenes.  A topic for another day.

20121104 spacesim

An Example of How Not to Implement Autonomous Steering

Although sporting rather pleasing graphics; sensible controls and some really nice concepts such as expanded building and upgrade types than the original, CARRIER COMMAND GAEA MISSION has absolutely the worst AI I have ever encountered in any game on any platform.

The "autonomous" (and I use the word lightly here) steering is a complete joke with vehicles completely unable to proceed from A to B without performing a near-infinite number of three-point-turns.  Why sometimes vehicles even wanted to initiate a three-point turn in some cases is a complete mystery.

Vehicles get stuck between rocks, drive off bridges, cliffs and ram into each other in that typical fashion we have come to expect in all Bohemia Interactive Software (BIS).

When you consider this is a remake of the fine 80s CARRIER COMMAND where AI is a centre piece, it is quite criminal to even attempt making something similar where AI was left as an obvious after-thought.

Whilst the original CARRIER COMMAND allowed you control your units through the AI whilst allowing you to jump-in at any time, CARRIER COMMAND GAEA MISSION forces you to constantly baby-sit and micromanage all units all the time thus defeating the purpose of multiple units.

Why on earth did they not use the brilliant work of Mr Craig Reynolds of Boids and OpenSteer fame?

How to Disable Novalith Cannon Spamming in Sins of a Solar Empire–Rebellion

image

EDIT: 2014-2-1 The game appears to no longer spam so this article may no longer apply

Sins of a Solar Empire (Sins) is a real-time strategy (RTS) game where your goal is to explore, expand, exploit and exterminate [your enemy].  A Novalith Cannon is a super weapon that performs the job of exterminating your enemy (or you for that matter) with its ability to lob huge masses of energized something-or-others across the interplanetary void inevitably reducing the planet’s colony to cinders.

Unfortunately, playing against the AI (even the Easy Economist AI) will result in the computer building up to 4 of these monstrosities generally within the first half hour of the game, only to spam fire a weapon every few minutes.   Some have suggested to build 2 x star bases, research the Auxiliary Government upgrade and build shields around the planet.  I agree, though this can be tricky when one is lacking funds in the early part of the game.  Plus it forces you to research a particular defensive strategy every game you play – too bad if I want to be an economist.

image

Anyway there is a way to disable or reduce the number of novaliths in single player.  The easiest way is to edit the main config file[1] each time you play or make a script or mod.  The latter is a subject for another day.

Open Windows Explorer and navigate to your Sins folder, for Steam users it is generally:

C:\Program Files (x86)\Steam\SteamApps\common\sins of a solar empire rebellion

image

1. Open the GameInfo folder

2. Make a backup of the file Gameplay.constants and place it somewhere safe, ideally in a different folder.

image

3. Open Gameplay.constants in your favourite text editor

4. At the top of the file is a section called GameplayConstants

image

5. Look for the line maxNumberOfCannonsPerPlayer

image

6. Change the value (which is generally 4 meaning 4 novaliths) to a value between 0 and 4 (who knows if 4 is the max).  0 = none.  Yay!

7. Save the file

8. Launch Sins and start a new single player game to see your changes reflected

NOTE – I noticed the file was reset the next day so be sure to re-edit it the next time you play or make a script to perform the changes for you.

Have fun!

—————————————–
[1] Thanks to ezeltje299 for the initial instructions.

Skyrim, Such a Pretty Game

I’m having such an enjoyable time with Bethesda’s latest instalment in the Elder Scrolls series – Skyrim.  It looks absolutely gorgeous on my new gaming rig which I bought mainly so that Office would load faster, well no not really.  I think I’m spending half my time just wandering around looking at the world taking postcard-worthy screenshots.  Besides the pretty piccys, the game itself holds it’s own.

Take a look for yourself:

TESV 2011-11-10 22-05-52-45

image

 

TESV 2011-11-10 21-54-18-70

TESV 2011-11-11 17-18-14-75

TESV 2011-11-12 20-25-43-58

TESV 2011-11-17 07-16-26-88

image

TESV 2011-11-18 22-05-30-35

Highly recommended.