- Home /
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!
Answer by ShadowBroker · Apr 21, 2011 at 01:45 PM
In the Unity docs, you can change the script format from javascript to C#. Just klick at the button above the snippets.
Answer by Molix · Apr 21, 2011 at 01:47 PM
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. $$anonymous$$SDN FTW.
thanks $$anonymous$$olix...now off to read on some of this stuff
Answer by ckfinite · Apr 21, 2011 at 01:43 PM
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.