c# reference site? need help figuring out storing rigidbodies into List<>

I've been searching forums trying to find everything I can about using lists to take advantage of their dynamic quality instead of storing the rigidbodies into a set array.

Shooting bullets, want to store instantiated bullet rigidbody in List to keep info, check for parameters and destroy the object when parameters met

I'm just not able to fully see what I need to do here and would like any help finding a good site to review how Lists can be used/implemented.

Is there documentation in the Unity Scripting Reference (and if so what should I search for to find this)?

Any help pointing me in the right direction is very appreciated!

3 Answers

3

No, there is very little C# refrence in the Unity docs. You will need MSDN for that. Look at this:http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx.

will check this out thx!

In the Unity docs, you can change the script format from javascript to C#. Just klick at the button above the snippets.

List is part of .NET in System.Collections.Generic, so you can get info about it from MS or better yet from the Mono site since that is the implementation that matters.

As for your question you can just do something like:

private List<Rigidbody> firedBullets = new List<Rigidbody>();

void Fire()
{
  // whatever stuff you do to fire
  firedBullets.Add( bullet.rigidbody );
}

void Update()
{
  // do whatever you wanted to do with them
  foreach( Rigidbody rb in firedBullets )
  {
    //
  }
}

I tried the mono site and found it to be useless. MSDN FTW.

thanks Molix...now off to read on some of this stuff