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!
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.
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.
will check this out thx!
– anon40947944