I’m starting out on a project where I want to be able to model injury or damage which is location specific, eg the closer you get to a fire, the quicker you’ll be injured. The fire (and smoke) can be distributed throughout the building.
I see doing this by generating heat intensity values for my domain (outside of Unity) and storing the values in a 3d array, probably just in an ASCII file.
I’d like to be able to open this file, allocate the values to an array and associate each vale to a cell in my domain.
My question is - which script should I use? I see that Javascript is ‘the preferred’ language but have had issues opening files with this in the past.
I know a bit of Python but am nervous about using Boo due to how well documented and supported this is.
As to C#, well I really have no experience in this language so it would be a very steeep learning curve.
What sorts of issues, and was this while using Unity? In my experience with Unity, the differences in what I can do with Javascript versus C# or Boo comes largely down to personal preference, as all the file access tools in Unity can be used equally well by all three languages.
For reading/writing files you use .net (which is the same for all 3 languages), or for just reading, you could use the TextAsset type that’s new in 2.0, if you want the files to be included in your project and not external. From what you described, I’d probably use TextAsset in that case.
I’m not clear if you’re saying that you’ve had problems with Javascript in the past, outside of Unity. Javascript in Unity is actually quite different in a lot of ways.
For fires, loading text files sounds like an unnecessary complication. Instead I would attach a trigger collider to your fire with a script that sends a message to whatever it touches, then the message is received by the player which causes him to lose health.
var heat : float = 5.00;
function OnTriggerStay (other : Collider)
{
other.gameObject.SendMessage("Burn", heat * Time.fixedDeltaTime, SendMessageOptions.DontRequireReceiver);
}
var health = 10.00;
function Burn (amount : float)
{
health -= amount;
}
function Update ()
{
if(health < 0)
{
print("I'm dead!");
Destroy(gameObject);
}
}